diff --git a/iscsi-scst/kernel/conn.c b/iscsi-scst/kernel/conn.c index 6f2f36b5a..3d774558b 100644 --- a/iscsi-scst/kernel/conn.c +++ b/iscsi-scst/kernel/conn.c @@ -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()", diff --git a/scst/include/scst.h b/scst/include/scst.h index 8401f242e..cb0f46bf6 100644 --- a/scst/include/scst.h +++ b/scst/include/scst.h @@ -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 diff --git a/scst/src/dev_handlers/scst_vdisk.c b/scst/src/dev_handlers/scst_vdisk.c index 67b5d4115..a7f07ce29 100644 --- a/scst/src/dev_handlers/scst_vdisk.c +++ b/scst/src/dev_handlers/scst_vdisk.c @@ -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); diff --git a/scst/src/scst_lib.c b/scst/src/scst_lib.c index ac1b136d5..feb888b72 100644 --- a/scst/src/scst_lib.c +++ b/scst/src/scst_lib.c @@ -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: diff --git a/scst/src/scst_pres.c b/scst/src/scst_pres.c index f17cd5e36..91979a790 100644 --- a/scst/src/scst_pres.c +++ b/scst/src/scst_pres.c @@ -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 */; diff --git a/scst/src/scst_proc.c b/scst/src/scst_proc.c index 2a3bc1981..7fede7bf2 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();