scst: Introduce file_inode() (merge r6084 from trunk)

git-svn-id: http://svn.code.sf.net/p/scst/svn/branches/3.0.x@6287 d57e44dd-8a1f-0410-8b47-8ef2f437770f
This commit is contained in:
Bart Van Assche
2015-06-11 17:11:13 +00:00
parent 6053d601d0
commit 25245f287e
6 changed files with 30 additions and 21 deletions

View File

@@ -766,7 +766,7 @@ static int conn_setup_sock(struct iscsi_conn *conn)
TRACE_DBG("%llx", (long long unsigned int)session->sid);
conn->sock = SOCKET_I(conn->file->f_dentry->d_inode);
conn->sock = SOCKET_I(file_inode(conn->file));
if (conn->sock->ops->sendpage == NULL) {
PRINT_ERROR("Socket for sid %llx doesn't support sendpage()",

View File

@@ -246,6 +246,17 @@ static inline unsigned int queue_max_hw_sectors(struct request_queue *q)
#endif
#endif
#if LINUX_VERSION_CODE < KERNEL_VERSION(3, 9, 0)
/*
* See also patch "new helper: file_inode(file)" (commit ID
* 496ad9aa8ef448058e36ca7a787c61f2e63f0f54).
*/
static inline struct inode *file_inode(const struct file *f)
{
return f->f_path.dentry->d_inode;
}
#endif
#ifndef __list_for_each
/* ToDo: cleanup when both are the same for all relevant kernels */
#define __list_for_each list_for_each

View File

@@ -820,7 +820,7 @@ static void vdisk_blockio_check_flush_support(struct scst_vdisk_dev *virt_dev)
goto out;
}
inode = fd->f_dentry->d_inode;
inode = file_inode(fd);
if (!S_ISBLK(inode->i_mode)) {
PRINT_ERROR("%s is NOT a block device", virt_dev->filename);
@@ -861,7 +861,7 @@ static void vdisk_check_tp_support(struct scst_vdisk_dev *virt_dev)
}
if (virt_dev->blockio) {
struct inode *inode = fd->f_dentry->d_inode;
struct inode *inode = file_inode(fd);
if (!S_ISBLK(inode->i_mode)) {
PRINT_ERROR("%s is NOT a block device",
virt_dev->filename);
@@ -923,7 +923,7 @@ static int vdisk_get_file_size(const char *filename, bool blockio,
goto out;
}
inode = fd->f_dentry->d_inode;
inode = file_inode(fd);
if (blockio && !S_ISBLK(inode->i_mode)) {
PRINT_ERROR("File %s is NOT a block device", filename);
@@ -1383,8 +1383,8 @@ static int vdisk_open_fd(struct scst_vdisk_dev *virt_dev, bool read_only)
virt_dev->filename, res);
goto out;
}
virt_dev->bdev = virt_dev->blockio ?
virt_dev->fd->f_dentry->d_inode->i_bdev : NULL;
virt_dev->bdev = virt_dev->blockio ? file_inode(virt_dev->fd)->i_bdev :
NULL;
res = 0;
out:
@@ -2996,7 +2996,7 @@ static int vdisk_unmap_range(struct scst_cmd *cmd,
#if LINUX_VERSION_CODE > KERNEL_VERSION(2, 6, 27)
sector_t start_sector = start_lba << (cmd->dev->block_shift - 9);
sector_t nr_sects = blocks << (cmd->dev->block_shift - 9);
struct inode *inode = fd->f_dentry->d_inode;
struct inode *inode = file_inode(fd);
gfp_t gfp = cmd->cmd_gfp_mask;
#if LINUX_VERSION_CODE <= KERNEL_VERSION(2, 6, 31)
err = blkdev_issue_discard(inode->i_bdev, start_sector, nr_sects, gfp);
@@ -3196,7 +3196,7 @@ static void vdev_blockio_get_unmap_params(struct scst_vdisk_dev *virt_dev,
goto out;
}
q = bdev_get_queue(fd->f_dentry->d_inode->i_bdev);
q = bdev_get_queue(file_inode(fd)->i_bdev);
if (q == NULL) {
PRINT_ERROR("No queue for device %s", virt_dev->filename);
goto out_close;
@@ -4654,8 +4654,7 @@ static int vdisk_fsync_fileio(loff_t loff,
file = virt_dev->fd;
#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 32)
res = sync_page_range(file->f_dentry->d_inode, file->f_mapping,
loff, len);
res = sync_page_range(file_inode(file), file->f_mapping, loff, len);
#else
#if 0 /* For sparse files we might need to sync metadata as well */
res = generic_write_sync(file, loff, len);

View File

@@ -9789,8 +9789,7 @@ int scst_vfs_fsync(struct file *file, loff_t loff, loff_t len)
{
int res;
res = sync_page_range(file->f_dentry->d_inode, file->f_mapping,
loff, len);
res = sync_page_range(file_inode(file), file->f_mapping, loff, len);
return res;
}
#endif
@@ -9832,7 +9831,7 @@ int scst_copy_file(const char *src, const char *dest)
goto out_close;
}
inode = file_src->f_dentry->d_inode;
inode = file_inode(file_src);
if (S_ISREG(inode->i_mode))
/* Nothing to do */;
@@ -10049,7 +10048,7 @@ static int __scst_read_file_transactional(const char *file_name,
goto out;
}
inode = file->f_dentry->d_inode;
inode = file_inode(file);
if (S_ISREG(inode->i_mode))
/* Nothing to do */;
@@ -10134,7 +10133,7 @@ int scst_get_file_mode(const char *path)
res = PTR_ERR(file);
goto out;
}
res = file->f_dentry->d_inode->i_mode;
res = file_inode(file)->i_mode;
filp_close(file, NULL);
out:

View File

@@ -678,7 +678,7 @@ static int scst_pr_do_load_device_file(struct scst_device *dev,
goto out;
}
inode = file->f_dentry->d_inode;
inode = file_inode(file);
if (S_ISREG(inode->i_mode))
/* Nothing to do */;

View File

@@ -269,7 +269,7 @@ int scst_proc_log_entry_write(struct file *file, const char __user *buf,
unsigned long level = 0, oldlevel;
char *buffer, *p, *e;
const struct scst_trace_log *t;
char *data = PDE_DATA(file->f_dentry->d_inode);
char *data = PDE_DATA(file_inode(file));
TRACE_ENTRY();
@@ -1390,7 +1390,7 @@ static ssize_t scst_proc_scsi_tgt_write(struct file *file,
const char __user *buf,
size_t length, loff_t *off)
{
struct scst_tgt *vtt = PDE_DATA(file->f_dentry->d_inode);
struct scst_tgt *vtt = PDE_DATA(file_inode(file));
ssize_t res = 0;
char *buffer;
char *start;
@@ -1545,7 +1545,7 @@ static ssize_t scst_proc_scsi_dev_handler_write(struct file *file,
const char __user *buf,
size_t length, loff_t *off)
{
struct scst_dev_type *dev_type = PDE_DATA(file->f_dentry->d_inode);
struct scst_dev_type *dev_type = PDE_DATA(file_inode(file));
ssize_t res = 0;
char *buffer;
char *start;
@@ -1913,7 +1913,7 @@ static ssize_t scst_proc_groups_devices_write(struct file *file,
int res, action, rc, read_only = 0;
char *buffer, *p, *e = NULL;
unsigned int virt_lun;
struct scst_acg *acg = PDE_DATA(file->f_dentry->d_inode);
struct scst_acg *acg = PDE_DATA(file_inode(file));
struct scst_acg_dev *acg_dev = NULL, *acg_dev_tmp;
struct scst_device *d, *dev = NULL;
@@ -2150,7 +2150,7 @@ static ssize_t scst_proc_groups_names_write(struct file *file,
{
int res = length, rc = 0, action;
char *buffer, *p, *pp = NULL;
struct scst_acg *acg = PDE_DATA(file->f_dentry->d_inode);
struct scst_acg *acg = PDE_DATA(file_inode(file));
struct scst_acn *n, *nn;
TRACE_ENTRY();