diff --git a/iscsi-scst/kernel/conn.c b/iscsi-scst/kernel/conn.c index fd66b7ff4..aa8cc742f 100644 --- a/iscsi-scst/kernel/conn.c +++ b/iscsi-scst/kernel/conn.c @@ -796,7 +796,7 @@ static int conn_setup_sock(struct iscsi_conn *conn) TRACE_DBG("%llx", (unsigned long long 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()", diff --git a/scst/include/scst.h b/scst/include/scst.h index 51b84bc59..4401a0b23 100644 --- a/scst/include/scst.h +++ b/scst/include/scst.h @@ -275,6 +275,17 @@ static inline void hex2bin(u8 *dst, const char *src, size_t count) } #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 diff --git a/scst/src/dev_handlers/scst_vdisk.c b/scst/src/dev_handlers/scst_vdisk.c index af66c288a..d2537ccd9 100644 --- a/scst/src/dev_handlers/scst_vdisk.c +++ b/scst/src/dev_handlers/scst_vdisk.c @@ -864,7 +864,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); @@ -907,7 +907,7 @@ static void vdisk_check_tp_support(struct scst_vdisk_dev *virt_dev) fd_open = true; 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); @@ -946,7 +946,7 @@ check: if (virt_dev->blockio) { struct request_queue *q; sBUG_ON(!fd_open); - q = bdev_get_queue(fd->f_dentry->d_inode->i_bdev); + q = bdev_get_queue(file_inode(fd)->i_bdev); #if LINUX_VERSION_CODE > KERNEL_VERSION(2, 6, 32) || \ (defined(RHEL_MAJOR) && RHEL_MAJOR -0 >= 6) virt_dev->unmap_opt_gran = q->limits.discard_granularity >> block_shift; @@ -1005,7 +1005,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); @@ -1465,8 +1465,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: @@ -3089,7 +3089,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); @@ -4770,8 +4770,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); diff --git a/scst/src/scst_lib.c b/scst/src/scst_lib.c index 8b9b4e9fb..298d90bec 100644 --- a/scst/src/scst_lib.c +++ b/scst/src/scst_lib.c @@ -10328,8 +10328,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 @@ -10371,7 +10370,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 */; @@ -10588,7 +10587,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 */; @@ -10673,7 +10672,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: diff --git a/scst/src/scst_pres.c b/scst/src/scst_pres.c index 2f5ecbdbe..0bb1126c8 100644 --- a/scst/src/scst_pres.c +++ b/scst/src/scst_pres.c @@ -682,7 +682,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 */; diff --git a/scst/src/scst_proc.c b/scst/src/scst_proc.c index e1b458bcb..57c9bbd1f 100644 --- a/scst/src/scst_proc.c +++ b/scst/src/scst_proc.c @@ -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();