linux-fsdevel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [RFC][PATCH 0/76] vfs: 'views' for filesystems with more than one root
@ 2018-05-08 18:03 Mark Fasheh
  2018-05-08 18:03 ` [PATCH 01/76] vfs: Introduce struct fs_view Mark Fasheh
                   ` (76 more replies)
  0 siblings, 77 replies; 88+ messages in thread
From: Mark Fasheh @ 2018-05-08 18:03 UTC (permalink / raw)
  To: linux-fsdevel; +Cc: linux-kernel, linux-btrfs

Hi,

The VFS's super_block covers a variety of filesystem functionality. In
particular we have a single structure representing both I/O and
namespace domains.

There are requirements to de-couple this functionality. For example,
filesystems with more than one root (such as btrfs subvolumes) can
have multiple inode namespaces. This starts to confuse userspace when
it notices multiple inodes with the same inode/device tuple on a
filesystem.

In addition, it's currently impossible for a filesystem subvolume to
have a different security context from it's parent. If we could allow
for subvolumes to optionally specify their own security context, we
could use them as containers directly instead of having to go through
an overlay.


I ran into this particular problem with respect to Btrfs some years
ago and sent out a very naive set of patches which were (rightfully)
not incorporated:

https://marc.info/?l=linux-btrfs&m=130074451403261&w=2
https://marc.info/?l=linux-btrfs&m=130532890824992&w=2

During the discussion, one question did come up - why can't
filesystems like Btrfs use a superblock per subvolume? There's a
couple of problems with that:

- It's common for a single Btrfs filesystem to have thousands of
  subvolumes. So keeping a superblock for each subvol in memory would
  get prohibively expensive - imagine having 8000 copies of struct
  super_block for a file system just because we wanted some separation
  of say, s_dev.

- Writeback would also have to walk all of these superblocks -
  again not very good for system performance.

- Anyone wanting to lock down I/O on a filesystem would have to freeze
  all the superblocks. This goes for most things related to I/O really
  - we simply can't afford to have the kernel walking thousands of
  superblocks to sync a single fs.

It's far more efficient then to pull those fields we need for a
subvolume namespace into their own structure.


The following patches attempt to fix this issue by introducing a
structure, fs_view, which can be used to represent a 'view' into a
filesystem. We can migrate super_block fields to this structure one at
a time. Struct super_block gets a default view embedded into
it. Inodes get a new field, i_view, which can be dereferenced to get
the view that an inode belgongs to. By default, we point i_view to the
view on struct super_block. That way existing filesystems don't have
to do anything different.

The patches are careful not to grow the size of struct inode.

For the first patch series, we migrate s_dev over from struct
super_block to struct fs_view. This fixes a long standing bug in how
the kernel reports inode devices to userspace.

The series follows an order:

- We first introduce the fs_view structure and embed it into struct
  super_block. As discussed, struct inode gets a pointer to the
  fs_view, i_view. The only member on fs_view at this point is a
  super_block * so that we can replace i_sb. A helper function is
  provided to get to the super_block from a struct inode.

- Convert the kernel to using our helper function to get to i_sb. This
  is done on in a per-filesystem patch. The other parts of the kernel
  referencing i_sb get their changes batched up in logical groupings.

- Move s_dev from struct super_block to struct fs_view.

- Convert the kernel from inode->i_sb->s_dev to the device from our
  fs_view. In the end, these lines will look like inode_view(inode)->v_dev.

- Add an fs_view struct to each Btrfs root, point inodes to that view
  when we initialize them.


The patches are available via git and are based off Linux
v4.16. There's two branches, with identical code.

- With the inode_sb() changeover patch broken out (as is sent here):

https://github.com/markfasheh/linux fs_view-broken-out

- With the inode_sb() changeover patch in one big change:

https://github.com/markfasheh/linux fs_view


Comments are appreciated.

Thanks,
  --Mark

^ permalink raw reply	[flat|nested] 88+ messages in thread

* [PATCH 01/76] vfs: Introduce struct fs_view
  2018-05-08 18:03 [RFC][PATCH 0/76] vfs: 'views' for filesystems with more than one root Mark Fasheh
@ 2018-05-08 18:03 ` Mark Fasheh
  2018-05-08 18:03 ` [PATCH 02/76] arch: Use inode_sb() helper instead of inode->i_sb Mark Fasheh
                   ` (75 subsequent siblings)
  76 siblings, 0 replies; 88+ messages in thread
From: Mark Fasheh @ 2018-05-08 18:03 UTC (permalink / raw)
  To: linux-fsdevel; +Cc: linux-kernel, linux-btrfs, Mark Fasheh

We want to de-couple some items from struct super_block, in particular those
that provide a 'fiew' into an fs.

Introduce a small struct, fs_view to contain these fields. This first patch
has a mostly empty fs_view. We do however, link it into the VFS:

Each super_block gets a default fs_view which is filled in via the
usual superblock intialization methods.

struct inode is updated to point to an fs_view structure via a new
'i_view' pointer, which replaces i_sb.

A filesystem can now optionally provide their own fs_view to point i_view
to.

So we don't lose our link from inode to superblock, fs_view gets
an embedded super_block pointer. A helper function, inode_sb() is
introduced to make getting the superblock from an inode less clunky.

Filesystems need no functional changes, and the only additional memory
usage here is the added pointer on struct super_block.

Signed-off-by: Mark Fasheh <mfasheh@suse.de>
---
 fs/inode.c         |  2 +-
 fs/super.c         |  1 +
 include/linux/fs.h | 21 ++++++++++++++++++++-
 3 files changed, 22 insertions(+), 2 deletions(-)

diff --git a/fs/inode.c b/fs/inode.c
index ef362364d396..4f08fdc2c60f 100644
--- a/fs/inode.c
+++ b/fs/inode.c
@@ -133,7 +133,7 @@ int inode_init_always(struct super_block *sb, struct inode *inode)
 	static const struct file_operations no_open_fops = {.open = no_open};
 	struct address_space *const mapping = &inode->i_data;
 
-	inode->i_sb = sb;
+	inode->i_view = &sb->s_view;
 	inode->i_blkbits = sb->s_blocksize_bits;
 	inode->i_flags = 0;
 	atomic_set(&inode->i_count, 1);
diff --git a/fs/super.c b/fs/super.c
index 672538ca9831..5258a57d410a 100644
--- a/fs/super.c
+++ b/fs/super.c
@@ -245,6 +245,7 @@ static struct super_block *alloc_super(struct file_system_type *type, int flags,
 	s->s_op = &default_op;
 	s->s_time_gran = 1000000000;
 	s->cleancache_poolid = CLEANCACHE_NO_POOL;
+	s->s_view.v_sb = s;
 
 	s->s_shrink.seeks = DEFAULT_SEEKS;
 	s->s_shrink.scan_objects = super_cache_scan;
diff --git a/include/linux/fs.h b/include/linux/fs.h
index c6baf767619e..4561cb9156d4 100644
--- a/include/linux/fs.h
+++ b/include/linux/fs.h
@@ -580,7 +580,7 @@ struct inode {
 #endif
 
 	const struct inode_operations	*i_op;
-	struct super_block	*i_sb;
+	struct fs_view		*i_view;
 	struct address_space	*i_mapping;
 
 #ifdef CONFIG_SECURITY
@@ -1340,6 +1340,24 @@ struct sb_writers {
 	struct percpu_rw_semaphore	rw_sem[SB_FREEZE_LEVELS];
 };
 
+/*
+ * "View" into a filesystem. Allows us to abstract out those
+ * superblock fields which change between the roots on a given
+ * filesystem. Most filesystems can ignore this - inodes are pointed
+ * to the default view 's_view' during initialization.
+ *
+ * A file system with multiple roots should allocate a view structure
+ * per root and point each inodes view pointer to it in iget.
+ */
+struct fs_view {
+	struct super_block	*v_sb;
+};
+
+static inline struct super_block *inode_sb(const struct inode *inode)
+{
+	return inode->i_view->v_sb;
+}
+
 struct super_block {
 	struct list_head	s_list;		/* Keep this first */
 	dev_t			s_dev;		/* search index; _not_ kdev_t */
@@ -1358,6 +1376,7 @@ struct super_block {
 	struct rw_semaphore	s_umount;
 	int			s_count;
 	atomic_t		s_active;
+	struct fs_view		s_view;		/* default view into the fs */
 #ifdef CONFIG_SECURITY
 	void                    *s_security;
 #endif
-- 
2.15.1

^ permalink raw reply	[flat|nested] 88+ messages in thread

* [PATCH 02/76] arch: Use inode_sb() helper instead of inode->i_sb
  2018-05-08 18:03 [RFC][PATCH 0/76] vfs: 'views' for filesystems with more than one root Mark Fasheh
  2018-05-08 18:03 ` [PATCH 01/76] vfs: Introduce struct fs_view Mark Fasheh
@ 2018-05-08 18:03 ` Mark Fasheh
  2018-05-08 18:03 ` [PATCH 03/76] drivers: " Mark Fasheh
                   ` (74 subsequent siblings)
  76 siblings, 0 replies; 88+ messages in thread
From: Mark Fasheh @ 2018-05-08 18:03 UTC (permalink / raw)
  To: linux-fsdevel; +Cc: linux-kernel, linux-btrfs, Mark Fasheh

Signed-off-by: Mark Fasheh <mfasheh@suse.de>
---
 arch/arc/kernel/troubleshoot.c            | 2 +-
 arch/powerpc/platforms/cell/spufs/inode.c | 6 +++---
 arch/s390/hypfs/inode.c                   | 4 ++--
 3 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/arch/arc/kernel/troubleshoot.c b/arch/arc/kernel/troubleshoot.c
index 6e9a0a9a6a04..18eb4984d555 100644
--- a/arch/arc/kernel/troubleshoot.c
+++ b/arch/arc/kernel/troubleshoot.c
@@ -104,7 +104,7 @@ static void show_faulting_vma(unsigned long address, char *buf)
 		if (file) {
 			nm = file_path(file, buf, PAGE_SIZE - 1);
 			inode = file_inode(vma->vm_file);
-			dev = inode->i_sb->s_dev;
+			dev = inode_sb(inode)->s_dev;
 			ino = inode->i_ino;
 		}
 		pr_info("    @off 0x%lx in [%s]\n"
diff --git a/arch/powerpc/platforms/cell/spufs/inode.c b/arch/powerpc/platforms/cell/spufs/inode.c
index db329d4bf1c3..d04460e86728 100644
--- a/arch/powerpc/platforms/cell/spufs/inode.c
+++ b/arch/powerpc/platforms/cell/spufs/inode.c
@@ -251,7 +251,7 @@ spufs_mkdir(struct inode *dir, struct dentry *dentry, unsigned int flags,
 	struct inode *inode;
 	struct spu_context *ctx;
 
-	inode = spufs_new_inode(dir->i_sb, mode | S_IFDIR);
+	inode = spufs_new_inode(inode_sb(dir), mode | S_IFDIR);
 	if (!inode)
 		return -ENOSPC;
 
@@ -284,7 +284,7 @@ spufs_mkdir(struct inode *dir, struct dentry *dentry, unsigned int flags,
 	else
 		ret = spufs_fill_dir(dentry, spufs_dir_contents, mode, ctx);
 
-	if (!ret && spufs_get_sb_info(dir->i_sb)->debug)
+	if (!ret && spufs_get_sb_info(inode_sb(dir))->debug)
 		ret = spufs_fill_dir(dentry, spufs_dir_debug_contents,
 				mode, ctx);
 
@@ -484,7 +484,7 @@ spufs_mkgang(struct inode *dir, struct dentry *dentry, umode_t mode)
 	struct spu_gang *gang;
 
 	ret = -ENOSPC;
-	inode = spufs_new_inode(dir->i_sb, mode | S_IFDIR);
+	inode = spufs_new_inode(inode_sb(dir), mode | S_IFDIR);
 	if (!inode)
 		goto out;
 
diff --git a/arch/s390/hypfs/inode.c b/arch/s390/hypfs/inode.c
index 43bbe63e2992..6a7679dcd9b7 100644
--- a/arch/s390/hypfs/inode.c
+++ b/arch/s390/hypfs/inode.c
@@ -128,7 +128,7 @@ static int hypfs_open(struct inode *inode, struct file *filp)
 			return -EACCES;
 	}
 
-	fs_info = inode->i_sb->s_fs_info;
+	fs_info = inode_sb(inode)->s_fs_info;
 	if(data) {
 		mutex_lock(&fs_info->lock);
 		filp->private_data = kstrdup(data, GFP_KERNEL);
@@ -164,7 +164,7 @@ static ssize_t hypfs_read_iter(struct kiocb *iocb, struct iov_iter *to)
 static ssize_t hypfs_write_iter(struct kiocb *iocb, struct iov_iter *from)
 {
 	int rc;
-	struct super_block *sb = file_inode(iocb->ki_filp)->i_sb;
+	struct super_block *sb = inode_sb(file_inode(iocb->ki_filp));
 	struct hypfs_sb_info *fs_info = sb->s_fs_info;
 	size_t count = iov_iter_count(from);
 
-- 
2.15.1

^ permalink raw reply	[flat|nested] 88+ messages in thread

* [PATCH 03/76] drivers: Use inode_sb() helper instead of inode->i_sb
  2018-05-08 18:03 [RFC][PATCH 0/76] vfs: 'views' for filesystems with more than one root Mark Fasheh
  2018-05-08 18:03 ` [PATCH 01/76] vfs: Introduce struct fs_view Mark Fasheh
  2018-05-08 18:03 ` [PATCH 02/76] arch: Use inode_sb() helper instead of inode->i_sb Mark Fasheh
@ 2018-05-08 18:03 ` Mark Fasheh
  2018-05-08 18:03 ` [PATCH 04/76] fs: " Mark Fasheh
                   ` (73 subsequent siblings)
  76 siblings, 0 replies; 88+ messages in thread
From: Mark Fasheh @ 2018-05-08 18:03 UTC (permalink / raw)
  To: linux-fsdevel; +Cc: linux-kernel, linux-btrfs, Mark Fasheh

Signed-off-by: Mark Fasheh <mfasheh@suse.de>
---
 drivers/block/loop.c                               |  6 ++---
 drivers/infiniband/hw/qib/qib_fs.c                 |  2 +-
 drivers/md/md-bitmap.c                             |  2 +-
 drivers/staging/lustre/lustre/llite/dir.c          | 18 +++++++-------
 drivers/staging/lustre/lustre/llite/file.c         | 28 +++++++++++-----------
 .../staging/lustre/lustre/llite/llite_internal.h   |  6 ++---
 drivers/staging/lustre/lustre/llite/llite_lib.c    | 20 +++++++++-------
 drivers/staging/lustre/lustre/llite/llite_nfs.c    | 10 ++++----
 drivers/staging/lustre/lustre/llite/namei.c        |  8 +++----
 drivers/staging/lustre/lustre/llite/statahead.c    |  8 +++----
 drivers/staging/lustre/lustre/llite/symlink.c      |  4 ++--
 drivers/staging/lustre/lustre/llite/vvp_io.c       |  4 ++--
 drivers/staging/lustre/lustre/llite/xattr.c        |  2 +-
 drivers/staging/ncpfs/dir.c                        | 17 ++++++-------
 drivers/staging/ncpfs/file.c                       |  4 ++--
 drivers/staging/ncpfs/ioctl.c                      |  6 ++---
 drivers/staging/ncpfs/ncp_fs.h                     |  2 +-
 17 files changed, 76 insertions(+), 71 deletions(-)

diff --git a/drivers/block/loop.c b/drivers/block/loop.c
index ee62d2d517bf..1b2452b7ae09 100644
--- a/drivers/block/loop.c
+++ b/drivers/block/loop.c
@@ -173,8 +173,8 @@ static void __loop_update_dio(struct loop_device *lo, bool dio)
 	unsigned dio_align = 0;
 	bool use_dio;
 
-	if (inode->i_sb->s_bdev) {
-		sb_bsize = bdev_logical_block_size(inode->i_sb->s_bdev);
+	if (inode_sb(inode)->s_bdev) {
+		sb_bsize = bdev_logical_block_size(inode_sb(inode)->s_bdev);
 		dio_align = sb_bsize - 1;
 	}
 
@@ -821,7 +821,7 @@ static void loop_config_discard(struct loop_device *lo)
 		return;
 	}
 
-	q->limits.discard_granularity = inode->i_sb->s_blocksize;
+	q->limits.discard_granularity = inode_sb(inode)->s_blocksize;
 	q->limits.discard_alignment = 0;
 
 	blk_queue_max_discard_sectors(q, UINT_MAX >> 9);
diff --git a/drivers/infiniband/hw/qib/qib_fs.c b/drivers/infiniband/hw/qib/qib_fs.c
index 1d940a2885c9..8eab4149c7d1 100644
--- a/drivers/infiniband/hw/qib/qib_fs.c
+++ b/drivers/infiniband/hw/qib/qib_fs.c
@@ -52,7 +52,7 @@ static int qibfs_mknod(struct inode *dir, struct dentry *dentry,
 		       void *data)
 {
 	int error;
-	struct inode *inode = new_inode(dir->i_sb);
+	struct inode *inode = new_inode(inode_sb(dir));
 
 	if (!inode) {
 		error = -EPERM;
diff --git a/drivers/md/md-bitmap.c b/drivers/md/md-bitmap.c
index 239c7bb3929b..2355a7c18ecb 100644
--- a/drivers/md/md-bitmap.c
+++ b/drivers/md/md-bitmap.c
@@ -385,7 +385,7 @@ static int read_page(struct file *file, unsigned long index,
 				ret = -EINVAL;
 				goto out;
 			}
-			bh->b_bdev = inode->i_sb->s_bdev;
+			bh->b_bdev = inode_sb(inode)->s_bdev;
 			if (count < (1<<inode->i_blkbits))
 				count = 0;
 			else
diff --git a/drivers/staging/lustre/lustre/llite/dir.c b/drivers/staging/lustre/lustre/llite/dir.c
index 99b0b77c75f5..809e493b61da 100644
--- a/drivers/staging/lustre/lustre/llite/dir.c
+++ b/drivers/staging/lustre/lustre/llite/dir.c
@@ -448,7 +448,7 @@ static int ll_dir_setdirstripe(struct inode *parent, struct lmv_user_md *lump,
 			cfs_curproc_cap_pack(), 0, &request);
 	ll_finish_md_op_data(op_data);
 
-	err = ll_prep_inode(&inode, request, parent->i_sb, NULL);
+	err = ll_prep_inode(&inode, request, inode_sb(parent), NULL);
 	if (err)
 		goto err_exit;
 
@@ -470,7 +470,7 @@ int ll_dir_setstripe(struct inode *inode, struct lov_user_md *lump,
 	struct md_op_data *op_data;
 	struct ptlrpc_request *req = NULL;
 	int rc = 0;
-	struct lustre_sb_info *lsi = s2lsi(inode->i_sb);
+	struct lustre_sb_info *lsi = s2lsi(inode_sb(inode));
 	struct obd_device *mgc = lsi->lsi_mgc;
 	int lum_size;
 
@@ -544,7 +544,7 @@ int ll_dir_setstripe(struct inode *inode, struct lov_user_md *lump,
 
 		buf = param;
 		/* Get fsname and assume devname to be -MDT0000. */
-		ll_get_fsname(inode->i_sb, buf, MTI_NAME_MAXLEN);
+		ll_get_fsname(inode_sb(inode), buf, MTI_NAME_MAXLEN);
 		strcat(buf, "-MDT0000.lov");
 		buf += strlen(buf);
 
@@ -1093,7 +1093,8 @@ static long ll_dir_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
 		rc = ll_get_fid_by_name(inode, filename, namelen, NULL, NULL);
 		if (rc < 0) {
 			CERROR("%s: lookup %.*s failed: rc = %d\n",
-			       ll_get_fsname(inode->i_sb, NULL, 0), namelen,
+			       ll_get_fsname(inode_sb(inode), NULL, 0),
+			       namelen,
 			       filename, rc);
 			goto out_free;
 		}
@@ -1363,7 +1364,7 @@ static long ll_dir_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
 			struct lov_user_mds_data __user *lmdp;
 			lstat_t st = { 0 };
 
-			st.st_dev     = inode->i_sb->s_dev;
+			st.st_dev     = inode_sb(inode)->s_dev;
 			st.st_mode    = body->mbo_mode;
 			st.st_nlink   = body->mbo_nlink;
 			st.st_uid     = body->mbo_uid;
@@ -1514,7 +1515,8 @@ static long ll_dir_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
 
 			for (i = 0; i < hur->hur_request.hr_itemcount; i++) {
 				fid = &hur->hur_user_item[i].hui_fid;
-				f = search_inode_for_lustre(inode->i_sb, fid);
+				f = search_inode_for_lustre(inode_sb(inode),
+							    fid);
 				if (IS_ERR(f)) {
 					rc = PTR_ERR(f);
 					break;
@@ -1571,7 +1573,7 @@ static long ll_dir_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
 		if (IS_ERR(copy))
 			return PTR_ERR(copy);
 
-		rc = ll_ioc_copy_start(inode->i_sb, copy);
+		rc = ll_ioc_copy_start(inode_sb(inode), copy);
 		if (copy_to_user((char __user *)arg, copy, sizeof(*copy)))
 			rc = -EFAULT;
 
@@ -1586,7 +1588,7 @@ static long ll_dir_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
 		if (IS_ERR(copy))
 			return PTR_ERR(copy);
 
-		rc = ll_ioc_copy_end(inode->i_sb, copy);
+		rc = ll_ioc_copy_end(inode_sb(inode), copy);
 		if (copy_to_user((char __user *)arg, copy, sizeof(*copy)))
 			rc = -EFAULT;
 
diff --git a/drivers/staging/lustre/lustre/llite/file.c b/drivers/staging/lustre/lustre/llite/file.c
index 938b859b6650..64df47bd1118 100644
--- a/drivers/staging/lustre/lustre/llite/file.c
+++ b/drivers/staging/lustre/lustre/llite/file.c
@@ -130,7 +130,7 @@ static int ll_close_inode_openhandle(struct inode *inode,
 
 	if (!class_exp2obd(md_exp)) {
 		CERROR("%s: invalid MDC connection handle closing " DFID "\n",
-		       ll_get_fsname(inode->i_sb, NULL, 0),
+		       ll_get_fsname(inode_sb(inode), NULL, 0),
 		       PFID(&lli->lli_fid));
 		rc = 0;
 		goto out;
@@ -837,7 +837,7 @@ ll_lease_open(struct inode *inode, struct file *file, fmode_t fmode,
 	rc2 = ll_close_inode_openhandle(inode, och, 0, NULL);
 	if (rc2 < 0)
 		CERROR("%s: error closing file " DFID ": %d\n",
-		       ll_get_fsname(inode->i_sb, NULL, 0),
+		       ll_get_fsname(inode_sb(inode), NULL, 0),
 		       PFID(&ll_i2info(inode)->lli_fid), rc2);
 	och = NULL; /* och has been freed in ll_close_inode_openhandle() */
 out_release_it:
@@ -866,7 +866,7 @@ static int ll_check_swap_layouts_validity(struct inode *inode1,
 	    inode_permission(inode2, MAY_WRITE))
 		return -EPERM;
 
-	if (inode1->i_sb != inode2->i_sb)
+	if (inode_sb(inode1) != inode_sb(inode2))
 		return -EXDEV;
 
 	return 0;
@@ -880,7 +880,7 @@ static int ll_swap_layouts_close(struct obd_client_handle *och,
 	int rc;
 
 	CDEBUG(D_INODE, "%s: biased close of file " DFID "\n",
-	       ll_get_fsname(inode->i_sb, NULL, 0), PFID(fid1));
+	       ll_get_fsname(inode_sb(inode), NULL, 0), PFID(fid1));
 
 	rc = ll_check_swap_layouts_validity(inode, inode2);
 	if (rc < 0)
@@ -1016,7 +1016,7 @@ static bool file_is_noatime(const struct file *file)
 	if ((mnt->mnt_flags & MNT_NODIRATIME) && S_ISDIR(inode->i_mode))
 		return true;
 
-	if ((inode->i_sb->s_flags & SB_NODIRATIME) && S_ISDIR(inode->i_mode))
+	if ((inode_sb(inode)->s_flags & SB_NODIRATIME) && S_ISDIR(inode->i_mode))
 		return true;
 
 	return false;
@@ -1669,7 +1669,7 @@ int ll_hsm_release(struct inode *inode)
 	u16 refcheck;
 
 	CDEBUG(D_INODE, "%s: Releasing file " DFID ".\n",
-	       ll_get_fsname(inode->i_sb, NULL, 0),
+	       ll_get_fsname(inode_sb(inode), NULL, 0),
 	       PFID(&ll_i2info(inode)->lli_fid));
 
 	och = ll_lease_open(inode, NULL, FMODE_WRITE, MDS_OPEN_RELEASE);
@@ -2566,7 +2566,7 @@ int ll_get_fid_by_name(struct inode *parent, const char *name,
 		*fid = body->mbo_fid1;
 
 	if (inode)
-		rc = ll_prep_inode(inode, req, parent->i_sb, NULL);
+		rc = ll_prep_inode(inode, req, inode_sb(parent), NULL);
 out_req:
 	ptlrpc_req_finished(req);
 	return rc;
@@ -2621,7 +2621,7 @@ int ll_migrate(struct inode *parent, struct file *file, int mdtidx,
 	op_data->op_fid3 = *ll_inode2fid(child_inode);
 	if (!fid_is_sane(&op_data->op_fid3)) {
 		CERROR("%s: migrate %s, but fid " DFID " is insane\n",
-		       ll_get_fsname(parent->i_sb, NULL, 0), name,
+		       ll_get_fsname(inode_sb(parent), NULL, 0), name,
 		       PFID(&op_data->op_fid3));
 		rc = -EINVAL;
 		goto out_unlock;
@@ -2796,7 +2796,7 @@ static int ll_inode_revalidate_fini(struct inode *inode, int rc)
 	} else if (rc != 0) {
 		CDEBUG_LIMIT((rc == -EACCES || rc == -EIDRM) ? D_INFO : D_ERROR,
 			     "%s: revalidate FID " DFID " error: rc = %d\n",
-			     ll_get_fsname(inode->i_sb, NULL, 0),
+			     ll_get_fsname(inode_sb(inode), NULL, 0),
 			     PFID(ll_inode2fid(inode)), rc);
 	}
 
@@ -2967,7 +2967,7 @@ int ll_getattr(const struct path *path, struct kstat *stat,
 
 	OBD_FAIL_TIMEOUT(OBD_FAIL_GETATTR_DELAY, 30);
 
-	stat->dev = inode->i_sb->s_dev;
+	stat->dev = inode_sb(inode)->s_dev;
 	if (ll_need_32bit_api(sbi))
 		stat->ino = cl_fid_build_ino(&lli->lli_fid, 1);
 	else
@@ -3061,7 +3061,7 @@ int ll_inode_permission(struct inode *inode, int mask)
 	*/
 
 	if (is_root_inode(inode)) {
-		rc = __ll_inode_revalidate(inode->i_sb->s_root,
+		rc = __ll_inode_revalidate(inode_sb(inode)->s_root,
 					   MDS_INODELOCK_LOOKUP);
 		if (rc)
 			return rc;
@@ -3448,7 +3448,7 @@ static int ll_layout_lock_set(struct lustre_handle *lockh, enum ldlm_mode mode,
 	/* wait for IO to complete if it's still being used. */
 	if (wait_layout) {
 		CDEBUG(D_INODE, "%s: " DFID "(%p) wait for layout reconf\n",
-		       ll_get_fsname(inode->i_sb, NULL, 0),
+		       ll_get_fsname(inode_sb(inode), NULL, 0),
 		       PFID(&lli->lli_fid), inode);
 
 		memset(&conf, 0, sizeof(conf));
@@ -3460,7 +3460,7 @@ static int ll_layout_lock_set(struct lustre_handle *lockh, enum ldlm_mode mode,
 
 		CDEBUG(D_INODE,
 		       "%s: file=" DFID " waiting layout return: %d.\n",
-		       ll_get_fsname(inode->i_sb, NULL, 0),
+		       ll_get_fsname(inode_sb(inode), NULL, 0),
 		       PFID(&lli->lli_fid), rc);
 	}
 	return rc;
@@ -3506,7 +3506,7 @@ static int ll_layout_refresh_locked(struct inode *inode)
 	lockh.cookie = 0ULL;
 
 	LDLM_DEBUG_NOLOCK("%s: requeue layout lock for file " DFID "(%p)",
-			  ll_get_fsname(inode->i_sb, NULL, 0),
+			  ll_get_fsname(inode_sb(inode), NULL, 0),
 			  PFID(&lli->lli_fid), inode);
 
 	rc = md_enqueue(sbi->ll_md_exp, &einfo, NULL, &it, op_data, &lockh, 0);
diff --git a/drivers/staging/lustre/lustre/llite/llite_internal.h b/drivers/staging/lustre/lustre/llite/llite_internal.h
index f68c2e88f12b..296a546ac72d 100644
--- a/drivers/staging/lustre/lustre/llite/llite_internal.h
+++ b/drivers/staging/lustre/lustre/llite/llite_internal.h
@@ -964,17 +964,17 @@ static inline struct client_obd *sbi2mdc(struct ll_sb_info *sbi)
 /* FIXME: replace the name of this with LL_SB to conform to kernel stuff */
 static inline struct ll_sb_info *ll_i2sbi(struct inode *inode)
 {
-	return ll_s2sbi(inode->i_sb);
+	return ll_s2sbi(inode_sb(inode));
 }
 
 static inline struct obd_export *ll_i2dtexp(struct inode *inode)
 {
-	return ll_s2dtexp(inode->i_sb);
+	return ll_s2dtexp(inode_sb(inode));
 }
 
 static inline struct obd_export *ll_i2mdexp(struct inode *inode)
 {
-	return ll_s2mdexp(inode->i_sb);
+	return ll_s2mdexp(inode_sb(inode));
 }
 
 static inline struct lu_fid *ll_inode2fid(struct inode *inode)
diff --git a/drivers/staging/lustre/lustre/llite/llite_lib.c b/drivers/staging/lustre/lustre/llite/llite_lib.c
index 6735a6f006d2..6f6df27635d4 100644
--- a/drivers/staging/lustre/lustre/llite/llite_lib.c
+++ b/drivers/staging/lustre/lustre/llite/llite_lib.c
@@ -1146,7 +1146,7 @@ static int ll_init_lsm_md(struct inode *inode, struct lustre_md *md)
 			lsm->lsm_md_oinfo[i].lmo_root = inode;
 		else
 			lsm->lsm_md_oinfo[i].lmo_root =
-				ll_iget_anon_dir(inode->i_sb, fid, md);
+				ll_iget_anon_dir(inode_sb(inode), fid, md);
 		if (IS_ERR(lsm->lsm_md_oinfo[i].lmo_root)) {
 			int rc = PTR_ERR(lsm->lsm_md_oinfo[i].lmo_root);
 
@@ -1257,7 +1257,8 @@ static int ll_update_lsm_md(struct inode *inode, struct lustre_md *md)
 		int idx;
 
 		CERROR("%s: inode " DFID "(%p)'s lmv layout mismatch (%p)/(%p) magic:0x%x/0x%x stripe count: %d/%d master_mdt: %d/%d hash_type:0x%x/0x%x layout: 0x%x/0x%x pool:%s/%s\n",
-		       ll_get_fsname(inode->i_sb, NULL, 0), PFID(&lli->lli_fid),
+		       ll_get_fsname(inode_sb(inode), NULL, 0),
+		       PFID(&lli->lli_fid),
 		       inode, lsm, old_lsm,
 		       lsm->lsm_md_magic, old_lsm->lsm_md_magic,
 		       lsm->lsm_md_stripe_count,
@@ -1272,13 +1273,13 @@ static int ll_update_lsm_md(struct inode *inode, struct lustre_md *md)
 
 		for (idx = 0; idx < old_lsm->lsm_md_stripe_count; idx++) {
 			CERROR("%s: sub FIDs in old lsm idx %d, old: " DFID "\n",
-			       ll_get_fsname(inode->i_sb, NULL, 0), idx,
+			       ll_get_fsname(inode_sb(inode), NULL, 0), idx,
 			       PFID(&old_lsm->lsm_md_oinfo[idx].lmo_fid));
 		}
 
 		for (idx = 0; idx < lsm->lsm_md_stripe_count; idx++) {
 			CERROR("%s: sub FIDs in new lsm idx %d, new: " DFID "\n",
-			       ll_get_fsname(inode->i_sb, NULL, 0), idx,
+			       ll_get_fsname(inode_sb(inode), NULL, 0), idx,
 			       PFID(&lsm->lsm_md_oinfo[idx].lmo_fid));
 		}
 
@@ -1428,7 +1429,8 @@ int ll_setattr_raw(struct dentry *dentry, struct iattr *attr, bool hsm_import)
 	int rc = 0;
 
 	CDEBUG(D_VFSTRACE, "%s: setattr inode " DFID "(%p) from %llu to %llu, valid %x, hsm_import %d\n",
-	       ll_get_fsname(inode->i_sb, NULL, 0), PFID(&lli->lli_fid), inode,
+	       ll_get_fsname(inode_sb(inode), NULL, 0), PFID(&lli->lli_fid),
+	       inode,
 	       i_size_read(inode), attr->ia_size, attr->ia_valid, hsm_import);
 
 	if (attr->ia_valid & ATTR_SIZE) {
@@ -1776,7 +1778,7 @@ int ll_update_inode(struct inode *inode, struct lustre_md *md)
 		inode->i_blkbits = min(PTLRPC_MAX_BRW_BITS + 1,
 				       LL_MAX_BLKSIZE_BITS);
 	else
-		inode->i_blkbits = inode->i_sb->s_blocksize_bits;
+		inode->i_blkbits = inode_sb(inode)->s_blocksize_bits;
 	if (body->mbo_valid & OBD_MD_FLUID)
 		inode->i_uid = make_kuid(&init_user_ns, body->mbo_uid);
 	if (body->mbo_valid & OBD_MD_FLGID)
@@ -2182,7 +2184,7 @@ int ll_prep_inode(struct inode **inode, struct ptlrpc_request *req,
 	md_free_lustre_md(sbi->ll_md_exp, &md);
 cleanup:
 	if (rc != 0 && it && it->it_op & IT_OPEN)
-		ll_open_cleanup(sb ? sb : (*inode)->i_sb, req);
+		ll_open_cleanup(sb ? sb : inode_sb((*inode)), req);
 
 	return rc;
 }
@@ -2452,8 +2454,8 @@ void ll_dirty_page_discard_warn(struct page *page, int ioret)
 
 	CDEBUG(D_WARNING,
 	       "%s: dirty page discard: %s/fid: " DFID "/%s may get corrupted (rc %d)\n",
-	       ll_get_fsname(page->mapping->host->i_sb, NULL, 0),
-	       s2lsi(page->mapping->host->i_sb)->lsi_lmd->lmd_dev,
+	       ll_get_fsname(inode_sb(page->mapping->host), NULL, 0),
+	       s2lsi(inode_sb(page->mapping->host))->lsi_lmd->lmd_dev,
 	       PFID(&obj->vob_header.coh_lu.loh_fid),
 	       (path && !IS_ERR(path)) ? path : "", ioret);
 
diff --git a/drivers/staging/lustre/lustre/llite/llite_nfs.c b/drivers/staging/lustre/lustre/llite/llite_nfs.c
index a6a1d80c711a..699a5d1f3941 100644
--- a/drivers/staging/lustre/lustre/llite/llite_nfs.c
+++ b/drivers/staging/lustre/lustre/llite/llite_nfs.c
@@ -198,7 +198,7 @@ static int ll_encode_fh(struct inode *inode, __u32 *fh, int *plen,
 	struct lustre_nfs_fid *nfs_fid = (void *)fh;
 
 	CDEBUG(D_INFO, "%s: encoding for (" DFID ") maxlen=%d minlen=%d\n",
-	       ll_get_fsname(inode->i_sb, NULL, 0),
+	       ll_get_fsname(inode_sb(inode), NULL, 0),
 	       PFID(ll_inode2fid(inode)), *plen, fileid_len);
 
 	if (*plen < fileid_len) {
@@ -312,10 +312,10 @@ int ll_dir_get_parent_fid(struct inode *dir, struct lu_fid *parent_fid)
 
 	LASSERT(dir && S_ISDIR(dir->i_mode));
 
-	sbi = ll_s2sbi(dir->i_sb);
+	sbi = ll_s2sbi(inode_sb(dir));
 
 	CDEBUG(D_INFO, "%s: getting parent for (" DFID ")\n",
-	       ll_get_fsname(dir->i_sb, NULL, 0),
+	       ll_get_fsname(inode_sb(dir), NULL, 0),
 	       PFID(ll_inode2fid(dir)));
 
 	rc = ll_get_default_mdsize(sbi, &lmmsize);
@@ -332,7 +332,7 @@ int ll_dir_get_parent_fid(struct inode *dir, struct lu_fid *parent_fid)
 	ll_finish_md_op_data(op_data);
 	if (rc) {
 		CERROR("%s: failure inode " DFID " get parent: rc = %d\n",
-		       ll_get_fsname(dir->i_sb, NULL, 0),
+		       ll_get_fsname(inode_sb(dir), NULL, 0),
 		       PFID(ll_inode2fid(dir)), rc);
 		return rc;
 	}
@@ -361,7 +361,7 @@ static struct dentry *ll_get_parent(struct dentry *dchild)
 	if (rc)
 		return ERR_PTR(rc);
 
-	dentry = ll_iget_for_nfs(dchild->d_inode->i_sb, &parent_fid, NULL);
+	dentry = ll_iget_for_nfs(inode_sb(dchild->d_inode), &parent_fid, NULL);
 
 	return dentry;
 }
diff --git a/drivers/staging/lustre/lustre/llite/namei.c b/drivers/staging/lustre/lustre/llite/namei.c
index a2687f46a16d..35296a363db5 100644
--- a/drivers/staging/lustre/lustre/llite/namei.c
+++ b/drivers/staging/lustre/lustre/llite/namei.c
@@ -326,7 +326,7 @@ int ll_md_blocking_ast(struct ldlm_lock *lock, struct ldlm_lock_desc *desc,
 				 * ->ilookup5()), because master inode state is
 				 *  NEW.
 				 */
-				master_inode = ilookup5_nowait(inode->i_sb,
+				master_inode = ilookup5_nowait(inode_sb(inode),
 							       hash,
 							       ll_test_inode_by_fid,
 							       (void *)&lli->lli_pfid);
@@ -340,7 +340,7 @@ int ll_md_blocking_ast(struct ldlm_lock *lock, struct ldlm_lock_desc *desc,
 		}
 
 		if ((bits & (MDS_INODELOCK_LOOKUP | MDS_INODELOCK_PERM)) &&
-		    inode->i_sb->s_root &&
+		    inode_sb(inode)->s_root &&
 		    !is_root_inode(inode))
 			ll_invalidate_aliases(inode);
 
@@ -782,7 +782,7 @@ static struct inode *ll_create_node(struct inode *dir, struct lookup_intent *it)
 	LASSERT(it_disposition(it, DISP_ENQ_CREATE_REF));
 	request = it->it_request;
 	it_clear_disposition(it, DISP_ENQ_CREATE_REF);
-	rc = ll_prep_inode(&inode, request, dir->i_sb, it);
+	rc = ll_prep_inode(&inode, request, inode_sb(dir), it);
 	if (rc) {
 		inode = ERR_PTR(rc);
 		goto out;
@@ -925,7 +925,7 @@ static int ll_new_node(struct inode *dir, struct dentry *dentry,
 
 	ll_update_times(request, dir);
 
-	err = ll_prep_inode(&inode, request, dir->i_sb, NULL);
+	err = ll_prep_inode(&inode, request, inode_sb(dir), NULL);
 	if (err)
 		goto err_exit;
 
diff --git a/drivers/staging/lustre/lustre/llite/statahead.c b/drivers/staging/lustre/lustre/llite/statahead.c
index 90c7324575e4..8245da36cfab 100644
--- a/drivers/staging/lustre/lustre/llite/statahead.c
+++ b/drivers/staging/lustre/lustre/llite/statahead.c
@@ -586,12 +586,12 @@ static void sa_instantiate(struct ll_statahead_info *sai,
 		goto out;
 	}
 
-	rc = ll_prep_inode(&child, req, dir->i_sb, it);
+	rc = ll_prep_inode(&child, req, inode_sb(dir), it);
 	if (rc)
 		goto out;
 
 	CDEBUG(D_READA, "%s: setting %.*s" DFID " l_data to inode %p\n",
-	       ll_get_fsname(child->i_sb, NULL, 0),
+	       ll_get_fsname(inode_sb(child), NULL, 0),
 	       entry->se_qstr.len, entry->se_qstr.name,
 	       PFID(ll_inode2fid(child)), child);
 	ll_set_lock_data(ll_i2sbi(dir)->ll_md_exp, child, it, NULL);
@@ -1277,7 +1277,7 @@ static int is_first_dirent(struct inode *dir, struct dentry *dentry)
 
 			rc = PTR_ERR(page);
 			CERROR("%s: error reading dir " DFID " at %llu: opendir_pid = %u : rc = %d\n",
-			       ll_get_fsname(dir->i_sb, NULL, 0),
+			       ll_get_fsname(inode_sb(dir), NULL, 0),
 			       PFID(ll_inode2fid(dir)), pos,
 			       lli->lli_opendir_pid, rc);
 			break;
@@ -1474,7 +1474,7 @@ static int revalidate_statahead_dentry(struct inode *dir,
 				/* revalidate, but inode is recreated */
 				CDEBUG(D_READA,
 				       "%s: stale dentry %pd inode " DFID ", statahead inode " DFID "\n",
-				       ll_get_fsname((*dentryp)->d_inode->i_sb,
+				       ll_get_fsname(inode_sb((*dentryp)->d_inode),
 						     NULL, 0),
 				       *dentryp,
 				       PFID(ll_inode2fid((*dentryp)->d_inode)),
diff --git a/drivers/staging/lustre/lustre/llite/symlink.c b/drivers/staging/lustre/lustre/llite/symlink.c
index 0690fdbf49f5..caebe4f16dab 100644
--- a/drivers/staging/lustre/lustre/llite/symlink.c
+++ b/drivers/staging/lustre/lustre/llite/symlink.c
@@ -74,7 +74,7 @@ static int ll_readlink_internal(struct inode *inode,
 	if (rc) {
 		if (rc != -ENOENT)
 			CERROR("%s: inode " DFID ": rc = %d\n",
-			       ll_get_fsname(inode->i_sb, NULL, 0),
+			       ll_get_fsname(inode_sb(inode), NULL, 0),
 			       PFID(ll_inode2fid(inode)), rc);
 		goto failed;
 	}
@@ -89,7 +89,7 @@ static int ll_readlink_internal(struct inode *inode,
 	LASSERT(symlen != 0);
 	if (body->mbo_eadatasize != symlen) {
 		CERROR("%s: inode " DFID ": symlink length %d not expected %d\n",
-		       ll_get_fsname(inode->i_sb, NULL, 0),
+		       ll_get_fsname(inode_sb(inode), NULL, 0),
 		       PFID(ll_inode2fid(inode)), body->mbo_eadatasize - 1,
 		       symlen - 1);
 		rc = -EPROTO;
diff --git a/drivers/staging/lustre/lustre/llite/vvp_io.c b/drivers/staging/lustre/lustre/llite/vvp_io.c
index e7a4778e02e4..3262a297e310 100644
--- a/drivers/staging/lustre/lustre/llite/vvp_io.c
+++ b/drivers/staging/lustre/lustre/llite/vvp_io.c
@@ -951,7 +951,7 @@ static int vvp_io_write_start(const struct lu_env *env,
 	if (pos + cnt > ll_file_maxbytes(inode)) {
 		CDEBUG(D_INODE,
 		       "%s: file " DFID " offset %llu > maxbytes %llu\n",
-		       ll_get_fsname(inode->i_sb, NULL, 0),
+		       ll_get_fsname(inode_sb(inode), NULL, 0),
 		       PFID(ll_inode2fid(inode)), pos + cnt,
 		       ll_file_maxbytes(inode));
 		return -EFBIG;
@@ -1366,7 +1366,7 @@ int vvp_io_init(const struct lu_env *env, struct cl_object *obj,
 			result = 0;
 		if (result < 0)
 			CERROR("%s: refresh file layout " DFID " error %d.\n",
-			       ll_get_fsname(inode->i_sb, NULL, 0),
+			       ll_get_fsname(inode_sb(inode), NULL, 0),
 			       PFID(lu_object_fid(&obj->co_lu)), result);
 	}
 
diff --git a/drivers/staging/lustre/lustre/llite/xattr.c b/drivers/staging/lustre/lustre/llite/xattr.c
index 532384c91447..2e4becc5b3c6 100644
--- a/drivers/staging/lustre/lustre/llite/xattr.c
+++ b/drivers/staging/lustre/lustre/llite/xattr.c
@@ -352,7 +352,7 @@ ll_xattr_list(struct inode *inode, const char *name, int type, void *buffer,
 	if (rc == -EOPNOTSUPP && type == XATTR_USER_T) {
 		LCONSOLE_INFO(
 			"%s: disabling user_xattr feature because it is not supported on the server: rc = %d\n",
-			ll_get_fsname(inode->i_sb, NULL, 0), rc);
+			ll_get_fsname(inode_sb(inode), NULL, 0), rc);
 		sbi->ll_flags &= ~LL_SBI_USER_XATTR;
 	}
 out:
diff --git a/drivers/staging/ncpfs/dir.c b/drivers/staging/ncpfs/dir.c
index 0c57c5c5d40a..10be63953509 100644
--- a/drivers/staging/ncpfs/dir.c
+++ b/drivers/staging/ncpfs/dir.c
@@ -160,7 +160,8 @@ ncp_compare_dentry(const struct dentry *dentry,
 	if (ncp_case_sensitive(pinode))
 		return strncmp(str, name->name, len);
 
-	return ncp_strnicmp(NCP_IO_TABLE(pinode->i_sb), str, name->name, len);
+	return ncp_strnicmp(NCP_IO_TABLE(inode_sb(pinode)), str, name->name,
+			    len);
 }
 
 /*
@@ -616,8 +617,8 @@ ncp_fill_cache(struct file *file, struct dir_context *ctx,
 		struct inode *inode;
 
 		entry->opened = 0;
-		entry->ino = iunique(dir->i_sb, 2);
-		inode = ncp_iget(dir->i_sb, entry);
+		entry->ino = iunique(inode_sb(dir), 2);
+		inode = ncp_iget(inode_sb(dir), entry);
 		if (inode) {
 			d_instantiate(newdent, inode);
 			if (!hashed)
@@ -664,7 +665,7 @@ ncp_fill_cache(struct file *file, struct dir_context *ctx,
 		ctl.valid = 0;
 	if (!ctl.filled && (ctl.fpos == ctx->pos)) {
 		if (!ino)
-			ino = iunique(dir->i_sb, 2);
+			ino = iunique(inode_sb(dir), 2);
 		ctl.filled = !dir_emit(ctx, qname.name, qname.len,
 				     ino, DT_UNKNOWN);
 		if (!ctl.filled)
@@ -857,10 +858,10 @@ static struct dentry *ncp_lookup(struct inode *dir, struct dentry *dentry, unsig
 	 * Create an inode for the entry.
 	 */
 	finfo.opened = 0;
-	finfo.ino = iunique(dir->i_sb, 2);
+	finfo.ino = iunique(inode_sb(dir), 2);
 	finfo.volume = finfo.i.volNumber;
 	error = -EACCES;
-	inode = ncp_iget(dir->i_sb, &finfo);
+	inode = ncp_iget(inode_sb(dir), &finfo);
 
 	if (inode) {
 		ncp_new_dentry(dentry);
@@ -883,8 +884,8 @@ static int ncp_instantiate(struct inode *dir, struct dentry *dentry,
 	struct inode *inode;
 	int error = -EINVAL;
 
-	finfo->ino = iunique(dir->i_sb, 2);
-	inode = ncp_iget(dir->i_sb, finfo);
+	finfo->ino = iunique(inode_sb(dir), 2);
+	inode = ncp_iget(inode_sb(dir), finfo);
 	if (!inode)
 		goto out_close;
 	d_instantiate(dentry,inode);
diff --git a/drivers/staging/ncpfs/file.c b/drivers/staging/ncpfs/file.c
index 8f8cc0334ddd..ecb525a92656 100644
--- a/drivers/staging/ncpfs/file.c
+++ b/drivers/staging/ncpfs/file.c
@@ -114,9 +114,9 @@ ncp_file_read_iter(struct kiocb *iocb, struct iov_iter *to)
 
 	if (!iov_iter_count(to))
 		return 0;
-	if (pos > inode->i_sb->s_maxbytes)
+	if (pos > inode_sb(inode)->s_maxbytes)
 		return 0;
-	iov_iter_truncate(to, inode->i_sb->s_maxbytes - pos);
+	iov_iter_truncate(to, inode_sb(inode)->s_maxbytes - pos);
 
 	error = ncp_make_open(inode, O_RDONLY);
 	if (error) {
diff --git a/drivers/staging/ncpfs/ioctl.c b/drivers/staging/ncpfs/ioctl.c
index d378b98cd7b6..6be6eae9e0db 100644
--- a/drivers/staging/ncpfs/ioctl.c
+++ b/drivers/staging/ncpfs/ioctl.c
@@ -325,7 +325,7 @@ static long __ncp_ioctl(struct inode *inode, unsigned int cmd, unsigned long arg
 		if (server->root_setuped)
 			result = -EBUSY;
 		else {
-			result = ncp_conn_logged_in(inode->i_sb);
+			result = ncp_conn_logged_in(inode_sb(inode));
 			if (result == 0)
 				server->root_setuped = 1;
 		}
@@ -375,7 +375,7 @@ static long __ncp_ioctl(struct inode *inode, unsigned int cmd, unsigned long arg
 			result = -EACCES;
 			mutex_lock(&server->root_setup_lock);
 			if (server->m.mounted_vol[0]) {
-				struct dentry* dentry = inode->i_sb->s_root;
+				struct dentry* dentry = inode_sb(inode)->s_root;
 
 				if (dentry) {
 					struct inode* s_inode = d_inode(dentry);
@@ -431,7 +431,7 @@ static long __ncp_ioctl(struct inode *inode, unsigned int cmd, unsigned long arg
 					result = 0;
 
 				if (result == 0) {
-					dentry = inode->i_sb->s_root;
+					dentry = inode_sb(inode)->s_root;
 					if (dentry) {
 						struct inode* s_inode = d_inode(dentry);
 
diff --git a/drivers/staging/ncpfs/ncp_fs.h b/drivers/staging/ncpfs/ncp_fs.h
index bdd262b6c198..534d2cad978c 100644
--- a/drivers/staging/ncpfs/ncp_fs.h
+++ b/drivers/staging/ncpfs/ncp_fs.h
@@ -46,7 +46,7 @@ static inline struct ncp_server *NCP_SBP(const struct super_block *sb)
 	return sb->s_fs_info;
 }
 
-#define NCP_SERVER(inode)	NCP_SBP((inode)->i_sb)
+#define NCP_SERVER(inode)	NCP_SBP(inode_sb((inode)))
 static inline struct ncp_inode_info *NCP_FINFO(const struct inode *inode)
 {
 	return container_of(inode, struct ncp_inode_info, vfs_inode);
-- 
2.15.1

^ permalink raw reply	[flat|nested] 88+ messages in thread

* [PATCH 04/76] fs: Use inode_sb() helper instead of inode->i_sb
  2018-05-08 18:03 [RFC][PATCH 0/76] vfs: 'views' for filesystems with more than one root Mark Fasheh
                   ` (2 preceding siblings ...)
  2018-05-08 18:03 ` [PATCH 03/76] drivers: " Mark Fasheh
@ 2018-05-08 18:03 ` Mark Fasheh
  2018-05-08 18:03 ` [PATCH 05/76] include: " Mark Fasheh
                   ` (72 subsequent siblings)
  76 siblings, 0 replies; 88+ messages in thread
From: Mark Fasheh @ 2018-05-08 18:03 UTC (permalink / raw)
  To: linux-fsdevel; +Cc: linux-kernel, linux-btrfs, Mark Fasheh

Signed-off-by: Mark Fasheh <mfasheh@suse.de>
---
 fs/aio.c             |  6 ++--
 fs/attr.c            | 12 +++----
 fs/binfmt_misc.c     |  6 ++--
 fs/block_dev.c       |  2 +-
 fs/cachefiles/rdwr.c |  4 +--
 fs/dcache.c          |  8 ++---
 fs/direct-io.c       |  8 ++---
 fs/eventpoll.c       |  2 +-
 fs/fs-writeback.c    | 30 ++++++++--------
 fs/inode.c           | 96 +++++++++++++++++++++++++++-------------------------
 fs/ioctl.c           |  8 ++---
 fs/iomap.c           |  7 ++--
 fs/libfs.c           |  2 +-
 fs/locks.c           | 15 ++++----
 fs/namei.c           | 14 ++++----
 fs/namespace.c       |  6 ++--
 fs/open.c            |  6 ++--
 fs/pipe.c            |  6 ++--
 fs/posix_acl.c       |  2 +-
 fs/stat.c            |  2 +-
 fs/xattr.c           |  2 +-
 21 files changed, 125 insertions(+), 119 deletions(-)

diff --git a/fs/aio.c b/fs/aio.c
index 6bcd3fb5265a..bd2a187ca6d1 100644
--- a/fs/aio.c
+++ b/fs/aio.c
@@ -1115,7 +1115,8 @@ static void aio_complete(struct kiocb *kiocb, long res, long res2)
 		 * thread.
 		 */
 		if (S_ISREG(file_inode(file)->i_mode))
-			__sb_writers_acquired(file_inode(file)->i_sb, SB_FREEZE_WRITE);
+			__sb_writers_acquired(inode_sb(file_inode(file)),
+					      SB_FREEZE_WRITE);
 		file_end_write(file);
 	}
 
@@ -1546,7 +1547,8 @@ static ssize_t aio_write(struct kiocb *req, struct iocb *iocb, bool vectored,
 		 * complain about held lock when we return to userspace.
 		 */
 		if (S_ISREG(file_inode(file)->i_mode))
-			__sb_writers_release(file_inode(file)->i_sb, SB_FREEZE_WRITE);
+			__sb_writers_release(inode_sb(file_inode(file)),
+					     SB_FREEZE_WRITE);
 	}
 	kfree(iovec);
 	return ret;
diff --git a/fs/attr.c b/fs/attr.c
index 12ffdb6fb63c..456c082fe636 100644
--- a/fs/attr.c
+++ b/fs/attr.c
@@ -119,7 +119,7 @@ int inode_newsize_ok(const struct inode *inode, loff_t offset)
 		limit = rlimit(RLIMIT_FSIZE);
 		if (limit != RLIM_INFINITY && offset > limit)
 			goto out_sig;
-		if (offset > inode->i_sb->s_maxbytes)
+		if (offset > inode_sb(inode)->s_maxbytes)
 			goto out_big;
 	} else {
 		/*
@@ -164,13 +164,13 @@ void setattr_copy(struct inode *inode, const struct iattr *attr)
 		inode->i_gid = attr->ia_gid;
 	if (ia_valid & ATTR_ATIME)
 		inode->i_atime = timespec_trunc(attr->ia_atime,
-						inode->i_sb->s_time_gran);
+						inode_sb(inode)->s_time_gran);
 	if (ia_valid & ATTR_MTIME)
 		inode->i_mtime = timespec_trunc(attr->ia_mtime,
-						inode->i_sb->s_time_gran);
+						inode_sb(inode)->s_time_gran);
 	if (ia_valid & ATTR_CTIME)
 		inode->i_ctime = timespec_trunc(attr->ia_ctime,
-						inode->i_sb->s_time_gran);
+						inode_sb(inode)->s_time_gran);
 	if (ia_valid & ATTR_MODE) {
 		umode_t mode = attr->ia_mode;
 
@@ -288,10 +288,10 @@ int notify_change(struct dentry * dentry, struct iattr * attr, struct inode **de
 	 * namespace of the superblock.
 	 */
 	if (ia_valid & ATTR_UID &&
-	    !kuid_has_mapping(inode->i_sb->s_user_ns, attr->ia_uid))
+	    !kuid_has_mapping(inode_sb(inode)->s_user_ns, attr->ia_uid))
 		return -EOVERFLOW;
 	if (ia_valid & ATTR_GID &&
-	    !kgid_has_mapping(inode->i_sb->s_user_ns, attr->ia_gid))
+	    !kgid_has_mapping(inode_sb(inode)->s_user_ns, attr->ia_gid))
 		return -EOVERFLOW;
 
 	/* Don't allow modifications of files with invalid uids or
diff --git a/fs/binfmt_misc.c b/fs/binfmt_misc.c
index a7c5a9861bef..c5f84bf4506b 100644
--- a/fs/binfmt_misc.c
+++ b/fs/binfmt_misc.c
@@ -657,7 +657,7 @@ static ssize_t bm_entry_write(struct file *file, const char __user *buffer,
 		break;
 	case 3:
 		/* Delete this handler. */
-		root = file_inode(file)->i_sb->s_root;
+		root = inode_sb(file_inode(file))->s_root;
 		inode_lock(d_inode(root));
 
 		if (!list_empty(&e->list))
@@ -685,7 +685,7 @@ static ssize_t bm_register_write(struct file *file, const char __user *buffer,
 {
 	Node *e;
 	struct inode *inode;
-	struct super_block *sb = file_inode(file)->i_sb;
+	struct super_block *sb = inode_sb(file_inode(file));
 	struct dentry *root = sb->s_root, *dentry;
 	int err = 0;
 
@@ -786,7 +786,7 @@ static ssize_t bm_status_write(struct file *file, const char __user *buffer,
 		break;
 	case 3:
 		/* Delete all handlers. */
-		root = file_inode(file)->i_sb->s_root;
+		root = inode_sb(file_inode(file))->s_root;
 		inode_lock(d_inode(root));
 
 		while (!list_empty(&entries))
diff --git a/fs/block_dev.c b/fs/block_dev.c
index fe09ef9c21f3..c9e00024b89d 100644
--- a/fs/block_dev.c
+++ b/fs/block_dev.c
@@ -973,7 +973,7 @@ void bd_forget(struct inode *inode)
 	struct block_device *bdev = NULL;
 
 	spin_lock(&bdev_lock);
-	if (!sb_is_blkdev_sb(inode->i_sb))
+	if (!sb_is_blkdev_sb(inode_sb(inode)))
 		bdev = inode->i_bdev;
 	inode->i_bdev = NULL;
 	inode->i_mapping = &inode->i_data;
diff --git a/fs/cachefiles/rdwr.c b/fs/cachefiles/rdwr.c
index 883bc7bb12c5..807fabb9310b 100644
--- a/fs/cachefiles/rdwr.c
+++ b/fs/cachefiles/rdwr.c
@@ -413,7 +413,7 @@ int cachefiles_read_or_alloc_page(struct fscache_retrieval *op,
 	ASSERT(inode->i_mapping->a_ops->readpages);
 
 	/* calculate the shift required to use bmap */
-	shift = PAGE_SHIFT - inode->i_sb->s_blocksize_bits;
+	shift = PAGE_SHIFT - inode_sb(inode)->s_blocksize_bits;
 
 	op->op.flags &= FSCACHE_OP_KEEP_FLAGS;
 	op->op.flags |= FSCACHE_OP_ASYNC;
@@ -706,7 +706,7 @@ int cachefiles_read_or_alloc_pages(struct fscache_retrieval *op,
 	ASSERT(inode->i_mapping->a_ops->readpages);
 
 	/* calculate the shift required to use bmap */
-	shift = PAGE_SHIFT - inode->i_sb->s_blocksize_bits;
+	shift = PAGE_SHIFT - inode_sb(inode)->s_blocksize_bits;
 
 	pagevec_init(&pagevec);
 
diff --git a/fs/dcache.c b/fs/dcache.c
index 8945e6cabd93..98ac784e6045 100644
--- a/fs/dcache.c
+++ b/fs/dcache.c
@@ -1897,7 +1897,7 @@ struct dentry *d_make_root(struct inode *root_inode)
 	struct dentry *res = NULL;
 
 	if (root_inode) {
-		res = d_alloc_anon(root_inode->i_sb);
+		res = d_alloc_anon(inode_sb(root_inode));
 		if (res)
 			d_instantiate(res, root_inode);
 		else
@@ -1996,7 +1996,7 @@ static struct dentry *__d_obtain_alias(struct inode *inode, bool disconnected)
 	if (res)
 		goto out_iput;
 
-	tmp = d_alloc_anon(inode->i_sb);
+	tmp = d_alloc_anon(inode_sb(inode));
 	if (!tmp) {
 		res = ERR_PTR(-ENOMEM);
 		goto out_iput;
@@ -3038,8 +3038,8 @@ struct dentry *d_splice_alias(struct inode *inode, struct dentry *dentry)
 					"VFS: Lookup of '%s' in %s %s"
 					" would have caused loop\n",
 					dentry->d_name.name,
-					inode->i_sb->s_type->name,
-					inode->i_sb->s_id);
+					inode_sb(inode)->s_type->name,
+					inode_sb(inode)->s_id);
 			} else if (!IS_ROOT(new)) {
 				int err = __d_unalias(inode, dentry, new);
 				write_sequnlock(&rename_lock);
diff --git a/fs/direct-io.c b/fs/direct-io.c
index 1357ef563893..1f3f224555d3 100644
--- a/fs/direct-io.c
+++ b/fs/direct-io.c
@@ -378,7 +378,7 @@ static void dio_bio_end_aio(struct bio *bio)
 					    dio->inode->i_mapping->nrpages);
 		if (defer_completion) {
 			INIT_WORK(&dio->complete_work, dio_aio_complete_work);
-			queue_work(dio->inode->i_sb->s_dio_done_wq,
+			queue_work(inode_sb(dio->inode)->s_dio_done_wq,
 				   &dio->complete_work);
 		} else {
 			dio_complete(dio, 0, DIO_COMPLETE_ASYNC);
@@ -638,7 +638,7 @@ int sb_init_dio_done_wq(struct super_block *sb)
 
 static int dio_set_defer_completion(struct dio *dio)
 {
-	struct super_block *sb = dio->inode->i_sb;
+	struct super_block *sb = inode_sb(dio->inode);
 
 	if (dio->defer_completion)
 		return 0;
@@ -1276,13 +1276,13 @@ do_blockdev_direct_IO(struct kiocb *iocb, struct inode *inode,
 		retval = 0;
 		if (iocb->ki_flags & IOCB_DSYNC)
 			retval = dio_set_defer_completion(dio);
-		else if (!dio->inode->i_sb->s_dio_done_wq) {
+		else if (!inode_sb(dio->inode)->s_dio_done_wq) {
 			/*
 			 * In case of AIO write racing with buffered read we
 			 * need to defer completion. We can't decide this now,
 			 * however the workqueue needs to be initialized here.
 			 */
-			retval = sb_init_dio_done_wq(dio->inode->i_sb);
+			retval = sb_init_dio_done_wq(inode_sb(dio->inode));
 		}
 		if (retval) {
 			/*
diff --git a/fs/eventpoll.c b/fs/eventpoll.c
index 0f3494ed3ed0..a7e3dbc83bbc 100644
--- a/fs/eventpoll.c
+++ b/fs/eventpoll.c
@@ -955,7 +955,7 @@ static void ep_show_fdinfo(struct seq_file *m, struct file *f)
 			   epi->ffd.fd, epi->event.events,
 			   (long long)epi->event.data,
 			   (long long)epi->ffd.file->f_pos,
-			   inode->i_ino, inode->i_sb->s_dev);
+			   inode->i_ino, inode_sb(inode)->s_dev);
 		if (seq_has_overflowed(m))
 			break;
 	}
diff --git a/fs/fs-writeback.c b/fs/fs-writeback.c
index d4d04fee568a..f8496f3651a1 100644
--- a/fs/fs-writeback.c
+++ b/fs/fs-writeback.c
@@ -490,7 +490,7 @@ static void inode_switch_wbs(struct inode *inode, int new_wb_id)
 
 	/* while holding I_WB_SWITCH, no one else can update the association */
 	spin_lock(&inode->i_lock);
-	if (!(inode->i_sb->s_flags & SB_ACTIVE) ||
+	if (!(inode_sb(inode)->s_flags & SB_ACTIVE) ||
 	    inode->i_state & (I_WB_SWITCH | I_FREEING) ||
 	    inode_to_wb(inode) == isw->new_wb) {
 		spin_unlock(&inode->i_lock);
@@ -1002,7 +1002,7 @@ void inode_io_list_del(struct inode *inode)
  */
 void sb_mark_inode_writeback(struct inode *inode)
 {
-	struct super_block *sb = inode->i_sb;
+	struct super_block *sb = inode_sb(inode);
 	unsigned long flags;
 
 	if (list_empty(&inode->i_wb_list)) {
@@ -1020,7 +1020,7 @@ void sb_mark_inode_writeback(struct inode *inode)
  */
 void sb_clear_inode_writeback(struct inode *inode)
 {
-	struct super_block *sb = inode->i_sb;
+	struct super_block *sb = inode_sb(inode);
 	unsigned long flags;
 
 	if (!list_empty(&inode->i_wb_list)) {
@@ -1122,11 +1122,11 @@ static int move_expired_inodes(struct list_head *delaying_queue,
 		moved++;
 		if (flags & EXPIRE_DIRTY_ATIME)
 			set_bit(__I_DIRTY_TIME_EXPIRED, &inode->i_state);
-		if (sb_is_blkdev_sb(inode->i_sb))
+		if (sb_is_blkdev_sb(inode_sb(inode)))
 			continue;
-		if (sb && sb != inode->i_sb)
+		if (sb && sb != inode_sb(inode))
 			do_sb_sort = 1;
-		sb = inode->i_sb;
+		sb = inode_sb(inode);
 	}
 
 	/* just one sb in list, splice to dispatch_queue and we're done */
@@ -1137,10 +1137,10 @@ static int move_expired_inodes(struct list_head *delaying_queue,
 
 	/* Move inodes from one superblock together */
 	while (!list_empty(&tmp)) {
-		sb = wb_inode(tmp.prev)->i_sb;
+		sb = inode_sb(wb_inode(tmp.prev));
 		list_for_each_prev_safe(pos, node, &tmp) {
 			inode = wb_inode(pos);
-			if (inode->i_sb == sb)
+			if (inode_sb(inode) == sb)
 				list_move(&inode->i_io_list, dispatch_queue);
 		}
 	}
@@ -1177,9 +1177,9 @@ static int write_inode(struct inode *inode, struct writeback_control *wbc)
 {
 	int ret;
 
-	if (inode->i_sb->s_op->write_inode && !is_bad_inode(inode)) {
+	if (inode_sb(inode)->s_op->write_inode && !is_bad_inode(inode)) {
 		trace_writeback_write_inode_start(inode, wbc);
-		ret = inode->i_sb->s_op->write_inode(inode, wbc);
+		ret = inode_sb(inode)->s_op->write_inode(inode, wbc);
 		trace_writeback_write_inode(inode, wbc);
 		return ret;
 	}
@@ -1513,7 +1513,7 @@ static long writeback_sb_inodes(struct super_block *sb,
 		struct inode *inode = wb_inode(wb->b_io.prev);
 		struct bdi_writeback *tmp_wb;
 
-		if (inode->i_sb != sb) {
+		if (inode_sb(inode) != sb) {
 			if (work->sb) {
 				/*
 				 * We only want to write back data for this
@@ -1641,7 +1641,7 @@ static long __writeback_inodes_wb(struct bdi_writeback *wb,
 
 	while (!list_empty(&wb->b_io)) {
 		struct inode *inode = wb_inode(wb->b_io.prev);
-		struct super_block *sb = inode->i_sb;
+		struct super_block *sb = inode_sb(inode);
 
 		if (!trylock_super(sb)) {
 			/*
@@ -2064,7 +2064,7 @@ int dirtytime_interval_handler(struct ctl_table *table, int write,
 
 static noinline void block_dump___mark_inode_dirty(struct inode *inode)
 {
-	if (inode->i_ino || strcmp(inode->i_sb->s_id, "bdev")) {
+	if (inode->i_ino || strcmp(inode_sb(inode)->s_id, "bdev")) {
 		struct dentry *dentry;
 		const char *name = "?";
 
@@ -2076,7 +2076,7 @@ static noinline void block_dump___mark_inode_dirty(struct inode *inode)
 		printk(KERN_DEBUG
 		       "%s(%d): dirtied inode %lu (%s) on %s\n",
 		       current->comm, task_pid_nr(current), inode->i_ino,
-		       name, inode->i_sb->s_id);
+		       name, inode_sb(inode)->s_id);
 		if (dentry) {
 			spin_unlock(&dentry->d_lock);
 			dput(dentry);
@@ -2113,7 +2113,7 @@ static noinline void block_dump___mark_inode_dirty(struct inode *inode)
 void __mark_inode_dirty(struct inode *inode, int flags)
 {
 #define I_DIRTY_INODE (I_DIRTY_SYNC | I_DIRTY_DATASYNC)
-	struct super_block *sb = inode->i_sb;
+	struct super_block *sb = inode_sb(inode);
 	int dirtytime;
 
 	trace_writeback_mark_inode_dirty(inode, flags);
diff --git a/fs/inode.c b/fs/inode.c
index 4f08fdc2c60f..034b3528cd9d 100644
--- a/fs/inode.c
+++ b/fs/inode.c
@@ -28,9 +28,9 @@
  * inode->i_lock protects:
  *   inode->i_state, inode->i_hash, __iget()
  * Inode LRU list locks protect:
- *   inode->i_sb->s_inode_lru, inode->i_lru
- * inode->i_sb->s_inode_list_lock protects:
- *   inode->i_sb->s_inodes, inode->i_sb_list
+ *   inode_sb(inode)->s_inode_lru, inode->i_lru
+ * inode_sb(inode)->s_inode_list_lock protects:
+ *   inode_sb(inode)->s_inodes, inode->i_sb_list
  * bdi->wb.list_lock protects:
  *   bdi->wb.b_{dirty,io,more_io,dirty_time}, inode->i_io_list
  * inode_hash_lock protects:
@@ -38,7 +38,7 @@
  *
  * Lock ordering:
  *
- * inode->i_sb->s_inode_list_lock
+ * inode_sb(inode)->s_inode_list_lock
  *   inode->i_lock
  *     Inode LRU list locks
  *
@@ -46,7 +46,7 @@
  *   inode->i_lock
  *
  * inode_hash_lock
- *   inode->i_sb->s_inode_list_lock
+ *   inode_sb(inode)->s_inode_list_lock
  *   inode->i_lock
  *
  * iunique_lock
@@ -214,10 +214,10 @@ static struct inode *alloc_inode(struct super_block *sb)
 		return NULL;
 
 	if (unlikely(inode_init_always(sb, inode))) {
-		if (inode->i_sb->s_op->destroy_inode)
-			inode->i_sb->s_op->destroy_inode(inode);
-		else
-			kmem_cache_free(inode_cachep, inode);
+		if (inode_sb(inode)->s_op->destroy_inode)
+			inode_sb(inode)->s_op->destroy_inode(inode);
+			else
+				kmem_cache_free(inode_cachep, inode);
 		return NULL;
 	}
 
@@ -238,8 +238,8 @@ void __destroy_inode(struct inode *inode)
 	fsnotify_inode_delete(inode);
 	locks_free_lock_context(inode);
 	if (!inode->i_nlink) {
-		WARN_ON(atomic_long_read(&inode->i_sb->s_remove_count) == 0);
-		atomic_long_dec(&inode->i_sb->s_remove_count);
+		WARN_ON(atomic_long_read(&inode_sb(inode)->s_remove_count) == 0);
+		atomic_long_dec(&inode_sb(inode)->s_remove_count);
 	}
 
 #ifdef CONFIG_FS_POSIX_ACL
@@ -262,10 +262,10 @@ static void destroy_inode(struct inode *inode)
 {
 	BUG_ON(!list_empty(&inode->i_lru));
 	__destroy_inode(inode);
-	if (inode->i_sb->s_op->destroy_inode)
-		inode->i_sb->s_op->destroy_inode(inode);
-	else
-		call_rcu(&inode->i_rcu, i_callback);
+	if (inode_sb(inode)->s_op->destroy_inode)
+		inode_sb(inode)->s_op->destroy_inode(inode);
+		else
+			call_rcu(&inode->i_rcu, i_callback);
 }
 
 /**
@@ -284,7 +284,7 @@ void drop_nlink(struct inode *inode)
 	WARN_ON(inode->i_nlink == 0);
 	inode->__i_nlink--;
 	if (!inode->i_nlink)
-		atomic_long_inc(&inode->i_sb->s_remove_count);
+		atomic_long_inc(&inode_sb(inode)->s_remove_count);
 }
 EXPORT_SYMBOL(drop_nlink);
 
@@ -300,7 +300,7 @@ void clear_nlink(struct inode *inode)
 {
 	if (inode->i_nlink) {
 		inode->__i_nlink = 0;
-		atomic_long_inc(&inode->i_sb->s_remove_count);
+		atomic_long_inc(&inode_sb(inode)->s_remove_count);
 	}
 }
 EXPORT_SYMBOL(clear_nlink);
@@ -320,7 +320,7 @@ void set_nlink(struct inode *inode, unsigned int nlink)
 	} else {
 		/* Yes, some filesystems do change nlink from zero to one */
 		if (inode->i_nlink == 0)
-			atomic_long_dec(&inode->i_sb->s_remove_count);
+			atomic_long_dec(&inode_sb(inode)->s_remove_count);
 
 		inode->__i_nlink = nlink;
 	}
@@ -339,7 +339,7 @@ void inc_nlink(struct inode *inode)
 {
 	if (unlikely(inode->i_nlink == 0)) {
 		WARN_ON(!(inode->i_state & I_LINKABLE));
-		atomic_long_dec(&inode->i_sb->s_remove_count);
+		atomic_long_dec(&inode_sb(inode)->s_remove_count);
 	}
 
 	inode->__i_nlink++;
@@ -402,7 +402,7 @@ EXPORT_SYMBOL(ihold);
 
 static void inode_lru_list_add(struct inode *inode)
 {
-	if (list_lru_add(&inode->i_sb->s_inode_lru, &inode->i_lru))
+	if (list_lru_add(&inode_sb(inode)->s_inode_lru, &inode->i_lru))
 		this_cpu_inc(nr_unused);
 	else
 		inode->i_state |= I_REFERENCED;
@@ -417,7 +417,7 @@ void inode_add_lru(struct inode *inode)
 {
 	if (!(inode->i_state & (I_DIRTY_ALL | I_SYNC |
 				I_FREEING | I_WILL_FREE)) &&
-	    !atomic_read(&inode->i_count) && inode->i_sb->s_flags & SB_ACTIVE)
+	    !atomic_read(&inode->i_count) && inode_sb(inode)->s_flags & SB_ACTIVE)
 		inode_lru_list_add(inode);
 }
 
@@ -425,7 +425,7 @@ void inode_add_lru(struct inode *inode)
 static void inode_lru_list_del(struct inode *inode)
 {
 
-	if (list_lru_del(&inode->i_sb->s_inode_lru, &inode->i_lru))
+	if (list_lru_del(&inode_sb(inode)->s_inode_lru, &inode->i_lru))
 		this_cpu_dec(nr_unused);
 }
 
@@ -435,18 +435,18 @@ static void inode_lru_list_del(struct inode *inode)
  */
 void inode_sb_list_add(struct inode *inode)
 {
-	spin_lock(&inode->i_sb->s_inode_list_lock);
-	list_add(&inode->i_sb_list, &inode->i_sb->s_inodes);
-	spin_unlock(&inode->i_sb->s_inode_list_lock);
+	spin_lock(&inode_sb(inode)->s_inode_list_lock);
+	list_add(&inode->i_sb_list, &inode_sb(inode)->s_inodes);
+	spin_unlock(&inode_sb(inode)->s_inode_list_lock);
 }
 EXPORT_SYMBOL_GPL(inode_sb_list_add);
 
 static inline void inode_sb_list_del(struct inode *inode)
 {
 	if (!list_empty(&inode->i_sb_list)) {
-		spin_lock(&inode->i_sb->s_inode_list_lock);
+		spin_lock(&inode_sb(inode)->s_inode_list_lock);
 		list_del_init(&inode->i_sb_list);
-		spin_unlock(&inode->i_sb->s_inode_list_lock);
+		spin_unlock(&inode_sb(inode)->s_inode_list_lock);
 	}
 }
 
@@ -470,7 +470,8 @@ static unsigned long hash(struct super_block *sb, unsigned long hashval)
  */
 void __insert_inode_hash(struct inode *inode, unsigned long hashval)
 {
-	struct hlist_head *b = inode_hashtable + hash(inode->i_sb, hashval);
+	struct hlist_head *b = inode_hashtable + hash(inode_sb(inode),
+						      hashval);
 
 	spin_lock(&inode_hash_lock);
 	spin_lock(&inode->i_lock);
@@ -531,7 +532,7 @@ EXPORT_SYMBOL(clear_inode);
  */
 static void evict(struct inode *inode)
 {
-	const struct super_operations *op = inode->i_sb->s_op;
+	const struct super_operations *op = inode_sb(inode)->s_op;
 
 	BUG_ON(!(inode->i_state & I_FREEING));
 	BUG_ON(!list_empty(&inode->i_lru));
@@ -790,7 +791,7 @@ static struct inode *find_inode(struct super_block *sb,
 
 repeat:
 	hlist_for_each_entry(inode, head, i_hash) {
-		if (inode->i_sb != sb)
+		if (inode_sb(inode) != sb)
 			continue;
 		if (!test(inode, data))
 			continue;
@@ -819,7 +820,7 @@ static struct inode *find_inode_fast(struct super_block *sb,
 	hlist_for_each_entry(inode, head, i_hash) {
 		if (inode->i_ino != ino)
 			continue;
-		if (inode->i_sb != sb)
+		if (inode_sb(inode) != sb)
 			continue;
 		spin_lock(&inode->i_lock);
 		if (inode->i_state & (I_FREEING|I_WILL_FREE)) {
@@ -927,7 +928,7 @@ EXPORT_SYMBOL(new_inode);
 void lockdep_annotate_inode_mutex_key(struct inode *inode)
 {
 	if (S_ISDIR(inode->i_mode)) {
-		struct file_system_type *type = inode->i_sb->s_type;
+		struct file_system_type *type = inode_sb(inode)->s_type;
 
 		/* Set new key only if filesystem hasn't already changed it */
 		if (lockdep_match_class(&inode->i_rwsem, &type->i_mutex_key)) {
@@ -1169,7 +1170,7 @@ static int test_inode_iunique(struct super_block *sb, unsigned long ino)
 
 	spin_lock(&inode_hash_lock);
 	hlist_for_each_entry(inode, b, i_hash) {
-		if (inode->i_ino == ino && inode->i_sb == sb) {
+		if (inode->i_ino == ino && inode_sb(inode) == sb) {
 			spin_unlock(&inode_hash_lock);
 			return 0;
 		}
@@ -1362,7 +1363,7 @@ struct inode *find_inode_nowait(struct super_block *sb,
 
 	spin_lock(&inode_hash_lock);
 	hlist_for_each_entry(inode, head, i_hash) {
-		if (inode->i_sb != sb)
+		if (inode_sb(inode) != sb)
 			continue;
 		mval = match(inode, hashval, data);
 		if (mval == 0)
@@ -1379,7 +1380,7 @@ EXPORT_SYMBOL(find_inode_nowait);
 
 int insert_inode_locked(struct inode *inode)
 {
-	struct super_block *sb = inode->i_sb;
+	struct super_block *sb = inode_sb(inode);
 	ino_t ino = inode->i_ino;
 	struct hlist_head *head = inode_hashtable + hash(sb, ino);
 
@@ -1389,7 +1390,7 @@ int insert_inode_locked(struct inode *inode)
 		hlist_for_each_entry(old, head, i_hash) {
 			if (old->i_ino != ino)
 				continue;
-			if (old->i_sb != sb)
+			if (inode_sb(old) != sb)
 				continue;
 			spin_lock(&old->i_lock);
 			if (old->i_state & (I_FREEING|I_WILL_FREE)) {
@@ -1422,7 +1423,7 @@ EXPORT_SYMBOL(insert_inode_locked);
 int insert_inode_locked4(struct inode *inode, unsigned long hashval,
 		int (*test)(struct inode *, void *), void *data)
 {
-	struct super_block *sb = inode->i_sb;
+	struct super_block *sb = inode_sb(inode);
 	struct hlist_head *head = inode_hashtable + hash(sb, hashval);
 
 	while (1) {
@@ -1430,7 +1431,7 @@ int insert_inode_locked4(struct inode *inode, unsigned long hashval,
 
 		spin_lock(&inode_hash_lock);
 		hlist_for_each_entry(old, head, i_hash) {
-			if (old->i_sb != sb)
+			if (inode_sb(old) != sb)
 				continue;
 			if (!test(old, data))
 				continue;
@@ -1481,8 +1482,8 @@ EXPORT_SYMBOL(generic_delete_inode);
  */
 static void iput_final(struct inode *inode)
 {
-	struct super_block *sb = inode->i_sb;
-	const struct super_operations *op = inode->i_sb->s_op;
+	struct super_block *sb = inode_sb(inode);
+	const struct super_operations *op = inode_sb(inode)->s_op;
 	int drop;
 
 	WARN_ON(inode->i_state & I_NEW);
@@ -1645,7 +1646,7 @@ int generic_update_time(struct inode *inode, struct timespec *time, int flags)
 	if (flags & S_MTIME)
 		inode->i_mtime = *time;
 	if ((flags & (S_ATIME | S_CTIME | S_MTIME)) &&
-	    !(inode->i_sb->s_flags & SB_LAZYTIME))
+	    !(inode_sb(inode)->s_flags & SB_LAZYTIME))
 		dirty = true;
 
 	if (dirty)
@@ -1695,7 +1696,7 @@ bool __atime_needs_update(const struct path *path, struct inode *inode,
 
 	if (IS_NOATIME(inode))
 		return false;
-	if ((inode->i_sb->s_flags & SB_NODIRATIME) && S_ISDIR(inode->i_mode))
+	if ((inode_sb(inode)->s_flags & SB_NODIRATIME) && S_ISDIR(inode->i_mode))
 		return false;
 
 	if (mnt->mnt_flags & MNT_NOATIME)
@@ -1723,7 +1724,7 @@ void touch_atime(const struct path *path)
 	if (!__atime_needs_update(path, inode, false))
 		return;
 
-	if (!sb_start_write_trylock(inode->i_sb))
+	if (!sb_start_write_trylock(inode_sb(inode)))
 		return;
 
 	if (__mnt_want_write(mnt) != 0)
@@ -1741,7 +1742,7 @@ void touch_atime(const struct path *path)
 	update_time(inode, &now, S_ATIME);
 	__mnt_drop_write(mnt);
 skip_update:
-	sb_end_write(inode->i_sb);
+	sb_end_write(inode_sb(inode));
 }
 EXPORT_SYMBOL(touch_atime);
 
@@ -1992,7 +1993,8 @@ void init_special_inode(struct inode *inode, umode_t mode, dev_t rdev)
 		;	/* leave it no_open_fops */
 	else
 		printk(KERN_DEBUG "init_special_inode: bogus i_mode (%o) for"
-				  " inode %s:%lu\n", mode, inode->i_sb->s_id,
+				  " inode %s:%lu\n", mode,
+				  inode_sb(inode)->s_id,
 				  inode->i_ino);
 }
 EXPORT_SYMBOL(init_special_inode);
@@ -2121,11 +2123,11 @@ struct timespec current_time(struct inode *inode)
 {
 	struct timespec now = current_kernel_time();
 
-	if (unlikely(!inode->i_sb)) {
+	if (unlikely(!inode_sb(inode))) {
 		WARN(1, "current_time() called with uninitialized super_block in the inode");
 		return now;
 	}
 
-	return timespec_trunc(now, inode->i_sb->s_time_gran);
+	return timespec_trunc(now, inode_sb(inode)->s_time_gran);
 }
 EXPORT_SYMBOL(current_time);
diff --git a/fs/ioctl.c b/fs/ioctl.c
index 5ace7efb0d04..37990af8e3ad 100644
--- a/fs/ioctl.c
+++ b/fs/ioctl.c
@@ -179,7 +179,7 @@ static int ioctl_fiemap(struct file *filp, unsigned long arg)
 	struct fiemap __user *ufiemap = (struct fiemap __user *) arg;
 	struct fiemap_extent_info fieinfo = { 0, };
 	struct inode *inode = file_inode(filp);
-	struct super_block *sb = inode->i_sb;
+	struct super_block *sb = inode_sb(inode);
 	u64 len;
 	int error;
 
@@ -547,7 +547,7 @@ static int ioctl_fioasync(unsigned int fd, struct file *filp,
 
 static int ioctl_fsfreeze(struct file *filp)
 {
-	struct super_block *sb = file_inode(filp)->i_sb;
+	struct super_block *sb = inode_sb(file_inode(filp));
 
 	if (!capable(CAP_SYS_ADMIN))
 		return -EPERM;
@@ -564,7 +564,7 @@ static int ioctl_fsfreeze(struct file *filp)
 
 static int ioctl_fsthaw(struct file *filp)
 {
-	struct super_block *sb = file_inode(filp)->i_sb;
+	struct super_block *sb = inode_sb(file_inode(filp));
 
 	if (!capable(CAP_SYS_ADMIN))
 		return -EPERM;
@@ -668,7 +668,7 @@ int do_vfs_ioctl(struct file *filp, unsigned int fd, unsigned int cmd,
 		return ioctl_fiemap(filp, arg);
 
 	case FIGETBSZ:
-		return put_user(inode->i_sb->s_blocksize, argp);
+		return put_user(inode_sb(inode)->s_blocksize, argp);
 
 	case FICLONE:
 		return ioctl_file_clone(filp, arg, 0, 0, 0);
diff --git a/fs/iomap.c b/fs/iomap.c
index afd163586aa0..2c6a327f0223 100644
--- a/fs/iomap.c
+++ b/fs/iomap.c
@@ -806,7 +806,8 @@ static void iomap_dio_bio_end_io(struct bio *bio)
 			struct inode *inode = file_inode(dio->iocb->ki_filp);
 
 			INIT_WORK(&dio->aio.work, iomap_dio_complete_work);
-			queue_work(inode->i_sb->s_dio_done_wq, &dio->aio.work);
+			queue_work(inode_sb(inode)->s_dio_done_wq,
+				   &dio->aio.work);
 		} else {
 			iomap_dio_complete_work(&dio->aio.work);
 		}
@@ -1034,8 +1035,8 @@ iomap_dio_rw(struct kiocb *iocb, struct iov_iter *iter,
 	ret = 0;
 
 	if (iov_iter_rw(iter) == WRITE && !is_sync_kiocb(iocb) &&
-	    !inode->i_sb->s_dio_done_wq) {
-		ret = sb_init_dio_done_wq(inode->i_sb);
+	    !inode_sb(inode)->s_dio_done_wq) {
+		ret = sb_init_dio_done_wq(inode_sb(inode));
 		if (ret < 0)
 			goto out_free_dio;
 	}
diff --git a/fs/libfs.c b/fs/libfs.c
index 7ff3cb904acd..775eb447a68b 100644
--- a/fs/libfs.c
+++ b/fs/libfs.c
@@ -1018,7 +1018,7 @@ int generic_file_fsync(struct file *file, loff_t start, loff_t end,
 	err = __generic_file_fsync(file, start, end, datasync);
 	if (err)
 		return err;
-	return blkdev_issue_flush(inode->i_sb->s_bdev, GFP_KERNEL, NULL);
+	return blkdev_issue_flush(inode_sb(inode)->s_bdev, GFP_KERNEL, NULL);
 }
 EXPORT_SYMBOL(generic_file_fsync);
 
diff --git a/fs/locks.c b/fs/locks.c
index d6ff4beb70ce..2a86a18c0523 100644
--- a/fs/locks.c
+++ b/fs/locks.c
@@ -263,7 +263,8 @@ locks_check_ctx_lists(struct inode *inode)
 		     !list_empty(&ctx->flc_posix) ||
 		     !list_empty(&ctx->flc_lease))) {
 		pr_warn("Leaked locks on dev=0x%x:0x%x ino=0x%lx:\n",
-			MAJOR(inode->i_sb->s_dev), MINOR(inode->i_sb->s_dev),
+			MAJOR(inode_sb(inode)->s_dev),
+			MINOR(inode_sb(inode)->s_dev),
 			inode->i_ino);
 		locks_dump_ctx_list(&ctx->flc_flock, "FLOCK");
 		locks_dump_ctx_list(&ctx->flc_posix, "POSIX");
@@ -282,8 +283,8 @@ locks_check_ctx_file_list(struct file *filp, struct list_head *list,
 		if (fl->fl_file == filp)
 			pr_warn("Leaked %s lock on dev=0x%x:0x%x ino=0x%lx "
 				" fl_owner=%p fl_flags=0x%x fl_type=0x%x fl_pid=%u\n",
-				list_type, MAJOR(inode->i_sb->s_dev),
-				MINOR(inode->i_sb->s_dev), inode->i_ino,
+				list_type, MAJOR(inode_sb(inode)->s_dev),
+				MINOR(inode_sb(inode)->s_dev), inode->i_ino,
 				fl->fl_owner, fl->fl_flags, fl->fl_type, fl->fl_pid);
 }
 
@@ -2622,7 +2623,7 @@ static void lock_get_status(struct seq_file *f, struct file_lock *fl,
 {
 	struct inode *inode = NULL;
 	unsigned int fl_pid;
-	struct pid_namespace *proc_pidns = file_inode(f->file)->i_sb->s_fs_info;
+	struct pid_namespace *proc_pidns = inode_sb(file_inode(f->file))->s_fs_info;
 
 	fl_pid = locks_translate_pid(fl, proc_pidns);
 	/*
@@ -2683,8 +2684,8 @@ static void lock_get_status(struct seq_file *f, struct file_lock *fl,
 	if (inode) {
 		/* userspace relies on this representation of dev_t */
 		seq_printf(f, "%d %02x:%02x:%ld ", fl_pid,
-				MAJOR(inode->i_sb->s_dev),
-				MINOR(inode->i_sb->s_dev), inode->i_ino);
+				MAJOR(inode_sb(inode)->s_dev),
+				MINOR(inode_sb(inode)->s_dev), inode->i_ino);
 	} else {
 		seq_printf(f, "%d <none>:0 ", fl_pid);
 	}
@@ -2702,7 +2703,7 @@ static int locks_show(struct seq_file *f, void *v)
 {
 	struct locks_iterator *iter = f->private;
 	struct file_lock *fl, *bfl;
-	struct pid_namespace *proc_pidns = file_inode(f->file)->i_sb->s_fs_info;
+	struct pid_namespace *proc_pidns = inode_sb(file_inode(f->file))->s_fs_info;
 
 	fl = hlist_entry(v, struct file_lock, fl_link);
 
diff --git a/fs/namei.c b/fs/namei.c
index cafa365eeb70..03ba6b32aeb7 100644
--- a/fs/namei.c
+++ b/fs/namei.c
@@ -425,7 +425,7 @@ int inode_permission(struct inode *inode, int mask)
 {
 	int retval;
 
-	retval = sb_permission(inode->i_sb, inode, mask);
+	retval = sb_permission(inode_sb(inode), inode, mask);
 	if (retval)
 		return retval;
 
@@ -2805,7 +2805,7 @@ static inline int may_create(struct inode *dir, struct dentry *child)
 		return -EEXIST;
 	if (IS_DEADDIR(dir))
 		return -ENOENT;
-	s_user_ns = dir->i_sb->s_user_ns;
+	s_user_ns = inode_sb(dir)->s_user_ns;
 	if (!kuid_has_mapping(s_user_ns, current_fsuid()) ||
 	    !kgid_has_mapping(s_user_ns, current_fsgid()))
 		return -EOVERFLOW;
@@ -3781,7 +3781,7 @@ SYSCALL_DEFINE3(mknod, const char __user *, filename, umode_t, mode, unsigned, d
 int vfs_mkdir(struct inode *dir, struct dentry *dentry, umode_t mode)
 {
 	int error = may_create(dir, dentry);
-	unsigned max_links = dir->i_sb->s_max_links;
+	unsigned max_links = inode_sb(dir)->s_max_links;
 
 	if (error)
 		return error;
@@ -4167,7 +4167,7 @@ SYSCALL_DEFINE2(symlink, const char __user *, oldname, const char __user *, newn
 int vfs_link(struct dentry *old_dentry, struct inode *dir, struct dentry *new_dentry, struct inode **delegated_inode)
 {
 	struct inode *inode = old_dentry->d_inode;
-	unsigned max_links = dir->i_sb->s_max_links;
+	unsigned max_links = inode_sb(dir)->s_max_links;
 	int error;
 
 	if (!inode)
@@ -4177,7 +4177,7 @@ int vfs_link(struct dentry *old_dentry, struct inode *dir, struct dentry *new_de
 	if (error)
 		return error;
 
-	if (dir->i_sb != inode->i_sb)
+	if (inode_sb(dir) != inode_sb(inode))
 		return -EXDEV;
 
 	/*
@@ -4363,7 +4363,7 @@ int vfs_rename(struct inode *old_dir, struct dentry *old_dentry,
 	struct inode *source = old_dentry->d_inode;
 	struct inode *target = new_dentry->d_inode;
 	bool new_is_dir = false;
-	unsigned max_links = new_dir->i_sb->s_max_links;
+	unsigned max_links = inode_sb(new_dir)->s_max_links;
 	struct name_snapshot old_name;
 
 	if (source == target)
@@ -4453,7 +4453,7 @@ int vfs_rename(struct inode *old_dir, struct dentry *old_dentry,
 		dont_mount(new_dentry);
 		detach_mounts(new_dentry);
 	}
-	if (!(old_dir->i_sb->s_type->fs_flags & FS_RENAME_DOES_D_MOVE)) {
+	if (!(inode_sb(old_dir)->s_type->fs_flags & FS_RENAME_DOES_D_MOVE)) {
 		if (!(flags & RENAME_EXCHANGE))
 			d_move(old_dentry, new_dentry);
 		else
diff --git a/fs/namespace.c b/fs/namespace.c
index 9d1374ab6e06..e26da6ef673e 100644
--- a/fs/namespace.c
+++ b/fs/namespace.c
@@ -494,10 +494,10 @@ int mnt_want_write_file(struct file *file)
 
 	ret = may_write_real(file);
 	if (!ret) {
-		sb_start_write(file_inode(file)->i_sb);
+		sb_start_write(inode_sb(file_inode(file)));
 		ret = __mnt_want_write_file(file);
 		if (ret)
-			sb_end_write(file_inode(file)->i_sb);
+			sb_end_write(inode_sb(file_inode(file)));
 	}
 	return ret;
 }
@@ -546,7 +546,7 @@ void mnt_drop_write_file_path(struct file *file)
 void mnt_drop_write_file(struct file *file)
 {
 	__mnt_drop_write(file->f_path.mnt);
-	sb_end_write(file_inode(file)->i_sb);
+	sb_end_write(inode_sb(file_inode(file)));
 }
 EXPORT_SYMBOL(mnt_drop_write_file);
 
diff --git a/fs/open.c b/fs/open.c
index 7ea118471dce..a24e3564050a 100644
--- a/fs/open.c
+++ b/fs/open.c
@@ -197,13 +197,13 @@ static long do_sys_ftruncate(unsigned int fd, loff_t length, int small)
 	if (IS_APPEND(file_inode(f.file)))
 		goto out_putf;
 
-	sb_start_write(inode->i_sb);
+	sb_start_write(inode_sb(inode));
 	error = locks_verify_truncate(inode, f.file, length);
 	if (!error)
 		error = security_path_truncate(&f.file->f_path);
 	if (!error)
 		error = do_truncate(dentry, length, ATTR_MTIME|ATTR_CTIME, f.file);
-	sb_end_write(inode->i_sb);
+	sb_end_write(inode_sb(inode));
 out_putf:
 	fdput(f);
 out:
@@ -309,7 +309,7 @@ int vfs_fallocate(struct file *file, int mode, loff_t offset, loff_t len)
 		return -ENODEV;
 
 	/* Check for wrap through zero too */
-	if (((offset + len) > inode->i_sb->s_maxbytes) || ((offset + len) < 0))
+	if (((offset + len) > inode_sb(inode)->s_maxbytes) || ((offset + len) < 0))
 		return -EFBIG;
 
 	if (!file->f_op->fallocate)
diff --git a/fs/pipe.c b/fs/pipe.c
index 7b1954caf388..f8fd756cc817 100644
--- a/fs/pipe.c
+++ b/fs/pipe.c
@@ -477,11 +477,11 @@ pipe_write(struct kiocb *iocb, struct iov_iter *from)
 		wake_up_interruptible_sync_poll(&pipe->wait, EPOLLIN | EPOLLRDNORM);
 		kill_fasync(&pipe->fasync_readers, SIGIO, POLL_IN);
 	}
-	if (ret > 0 && sb_start_write_trylock(file_inode(filp)->i_sb)) {
+	if (ret > 0 && sb_start_write_trylock(inode_sb(file_inode(filp)))) {
 		int err = file_update_time(filp);
 		if (err)
 			ret = err;
-		sb_end_write(file_inode(filp)->i_sb);
+		sb_end_write(inode_sb(file_inode(filp)));
 	}
 	return ret;
 }
@@ -888,7 +888,7 @@ static void wake_up_partner(struct pipe_inode_info *pipe)
 static int fifo_open(struct inode *inode, struct file *filp)
 {
 	struct pipe_inode_info *pipe;
-	bool is_pipe = inode->i_sb->s_magic == PIPEFS_MAGIC;
+	bool is_pipe = inode_sb(inode)->s_magic == PIPEFS_MAGIC;
 	int ret;
 
 	filp->f_version = 0;
diff --git a/fs/posix_acl.c b/fs/posix_acl.c
index 2fd0fde16fe1..cf485df47d36 100644
--- a/fs/posix_acl.c
+++ b/fs/posix_acl.c
@@ -867,7 +867,7 @@ set_posix_acl(struct inode *inode, int type, struct posix_acl *acl)
 		return -EPERM;
 
 	if (acl) {
-		int ret = posix_acl_valid(inode->i_sb->s_user_ns, acl);
+		int ret = posix_acl_valid(inode_sb(inode)->s_user_ns, acl);
 		if (ret)
 			return ret;
 	}
diff --git a/fs/stat.c b/fs/stat.c
index 873785dae022..178b81d4359e 100644
--- a/fs/stat.c
+++ b/fs/stat.c
@@ -32,7 +32,7 @@
  */
 void generic_fillattr(struct inode *inode, struct kstat *stat)
 {
-	stat->dev = inode->i_sb->s_dev;
+	stat->dev = inode_sb(inode)->s_dev;
 	stat->ino = inode->i_ino;
 	stat->mode = inode->i_mode;
 	stat->nlink = inode->i_nlink;
diff --git a/fs/xattr.c b/fs/xattr.c
index 61cd28ba25f3..ac81607672ee 100644
--- a/fs/xattr.c
+++ b/fs/xattr.c
@@ -53,7 +53,7 @@ strcmp_prefix(const char *a, const char *a_prefix)
 static const struct xattr_handler *
 xattr_resolve_name(struct inode *inode, const char **name)
 {
-	const struct xattr_handler **handlers = inode->i_sb->s_xattr;
+	const struct xattr_handler **handlers = inode_sb(inode)->s_xattr;
 	const struct xattr_handler *handler;
 
 	if (!(inode->i_opflags & IOP_XATTR)) {
-- 
2.15.1

^ permalink raw reply	[flat|nested] 88+ messages in thread

* [PATCH 05/76] include: Use inode_sb() helper instead of inode->i_sb
  2018-05-08 18:03 [RFC][PATCH 0/76] vfs: 'views' for filesystems with more than one root Mark Fasheh
                   ` (3 preceding siblings ...)
  2018-05-08 18:03 ` [PATCH 04/76] fs: " Mark Fasheh
@ 2018-05-08 18:03 ` Mark Fasheh
  2018-05-08 18:03 ` [PATCH 06/76] ipc: " Mark Fasheh
                   ` (71 subsequent siblings)
  76 siblings, 0 replies; 88+ messages in thread
From: Mark Fasheh @ 2018-05-08 18:03 UTC (permalink / raw)
  To: linux-fsdevel; +Cc: linux-kernel, linux-btrfs, Mark Fasheh

Signed-off-by: Mark Fasheh <mfasheh@suse.de>
---
 include/linux/backing-dev.h      |   4 +-
 include/linux/cleancache.h       |   2 +-
 include/linux/fs.h               |  29 +++++-----
 include/linux/fscrypt_supp.h     |   4 +-
 include/linux/hugetlb.h          |   2 +-
 include/linux/nfs_fs.h           |   2 +-
 include/trace/events/btrfs.h     |  10 ++--
 include/trace/events/ext4.h      | 118 +++++++++++++++++++--------------------
 include/trace/events/f2fs.h      |  52 ++++++++---------
 include/trace/events/filelock.h  |   8 +--
 include/trace/events/filemap.h   |  12 ++--
 include/trace/events/fs_dax.h    |  14 ++---
 include/trace/events/jbd2.h      |   2 +-
 include/trace/events/writeback.h |   2 +-
 include/uapi/linux/iso_fs.h      |   4 +-
 15 files changed, 134 insertions(+), 131 deletions(-)

diff --git a/include/linux/backing-dev.h b/include/linux/backing-dev.h
index 3e4ce54d84ab..0fb241c9324a 100644
--- a/include/linux/backing-dev.h
+++ b/include/linux/backing-dev.h
@@ -157,7 +157,7 @@ static inline struct backing_dev_info *inode_to_bdi(struct inode *inode)
 	if (!inode)
 		return &noop_backing_dev_info;
 
-	sb = inode->i_sb;
+	sb = inode_sb(inode);
 #ifdef CONFIG_BLOCK
 	if (sb_is_blkdev_sb(sb))
 		return I_BDEV(inode)->bd_bdi;
@@ -251,7 +251,7 @@ static inline bool inode_cgwb_enabled(struct inode *inode)
 		cgroup_subsys_on_dfl(io_cgrp_subsys) &&
 		bdi_cap_account_dirty(bdi) &&
 		(bdi->capabilities & BDI_CAP_CGROUP_WRITEBACK) &&
-		(inode->i_sb->s_iflags & SB_I_CGROUPWB);
+		(inode_sb(inode)->s_iflags & SB_I_CGROUPWB);
 }
 
 /**
diff --git a/include/linux/cleancache.h b/include/linux/cleancache.h
index 5f5730c1d324..74f89782f70e 100644
--- a/include/linux/cleancache.h
+++ b/include/linux/cleancache.h
@@ -51,7 +51,7 @@ extern void __cleancache_invalidate_fs(struct super_block *);
 #define cleancache_enabled (1)
 static inline bool cleancache_fs_enabled_mapping(struct address_space *mapping)
 {
-	return mapping->host->i_sb->cleancache_poolid >= 0;
+	return inode_sb(mapping->host)->cleancache_poolid >= 0;
 }
 static inline bool cleancache_fs_enabled(struct page *page)
 {
diff --git a/include/linux/fs.h b/include/linux/fs.h
index 4561cb9156d4..5d4bb19b2a43 100644
--- a/include/linux/fs.h
+++ b/include/linux/fs.h
@@ -1475,22 +1475,22 @@ struct super_block {
  */
 static inline uid_t i_uid_read(const struct inode *inode)
 {
-	return from_kuid(inode->i_sb->s_user_ns, inode->i_uid);
+	return from_kuid(inode_sb(inode)->s_user_ns, inode->i_uid);
 }
 
 static inline gid_t i_gid_read(const struct inode *inode)
 {
-	return from_kgid(inode->i_sb->s_user_ns, inode->i_gid);
+	return from_kgid(inode_sb(inode)->s_user_ns, inode->i_gid);
 }
 
 static inline void i_uid_write(struct inode *inode, uid_t uid)
 {
-	inode->i_uid = make_kuid(inode->i_sb->s_user_ns, uid);
+	inode->i_uid = make_kuid(inode_sb(inode)->s_user_ns, uid);
 }
 
 static inline void i_gid_write(struct inode *inode, gid_t gid)
 {
-	inode->i_gid = make_kgid(inode->i_sb->s_user_ns, gid);
+	inode->i_gid = make_kgid(inode_sb(inode)->s_user_ns, gid);
 }
 
 extern struct timespec current_time(struct inode *inode);
@@ -1899,10 +1899,10 @@ struct super_operations {
  * i_flags updated.  Hence, i_flags no longer inherit the superblock mount
  * flags, so these have to be checked separately. -- rmk@arm.uk.linux.org
  */
-#define __IS_FLG(inode, flg)	((inode)->i_sb->s_flags & (flg))
+#define __IS_FLG(inode, flg)	(inode_sb((inode))->s_flags & (flg))
 
 static inline bool sb_rdonly(const struct super_block *sb) { return sb->s_flags & SB_RDONLY; }
-#define IS_RDONLY(inode)	sb_rdonly((inode)->i_sb)
+#define IS_RDONLY(inode)	sb_rdonly(inode_sb((inode)))
 #define IS_SYNC(inode)		(__IS_FLG(inode, SB_SYNCHRONOUS) || \
 					((inode)->i_flags & S_SYNC))
 #define IS_DIRSYNC(inode)	(__IS_FLG(inode, SB_SYNCHRONOUS|SB_DIRSYNC) || \
@@ -2725,21 +2725,22 @@ static inline void file_start_write(struct file *file)
 {
 	if (!S_ISREG(file_inode(file)->i_mode))
 		return;
-	__sb_start_write(file_inode(file)->i_sb, SB_FREEZE_WRITE, true);
+	__sb_start_write(inode_sb(file_inode(file)), SB_FREEZE_WRITE, true);
 }
 
 static inline bool file_start_write_trylock(struct file *file)
 {
 	if (!S_ISREG(file_inode(file)->i_mode))
 		return true;
-	return __sb_start_write(file_inode(file)->i_sb, SB_FREEZE_WRITE, false);
+	return __sb_start_write(inode_sb(file_inode(file)), SB_FREEZE_WRITE,
+				false);
 }
 
 static inline void file_end_write(struct file *file)
 {
 	if (!S_ISREG(file_inode(file)->i_mode))
 		return;
-	__sb_end_write(file_inode(file)->i_sb, SB_FREEZE_WRITE);
+	__sb_end_write(inode_sb(file_inode(file)), SB_FREEZE_WRITE);
 }
 
 static inline int do_clone_file_range(struct file *file_in, loff_t pos_in,
@@ -3018,8 +3019,10 @@ static inline ssize_t blockdev_direct_IO(struct kiocb *iocb,
 					 struct iov_iter *iter,
 					 get_block_t get_block)
 {
-	return __blockdev_direct_IO(iocb, inode, inode->i_sb->s_bdev, iter,
-			get_block, NULL, NULL, DIO_LOCKING | DIO_SKIP_HOLES);
+	return __blockdev_direct_IO(iocb, inode, inode_sb(inode)->s_bdev,
+				    iter,
+				    get_block, NULL, NULL,
+				    DIO_LOCKING | DIO_SKIP_HOLES);
 }
 #endif
 
@@ -3370,13 +3373,13 @@ static inline int check_sticky(struct inode *dir, struct inode *inode)
 
 static inline void inode_has_no_xattr(struct inode *inode)
 {
-	if (!is_sxid(inode->i_mode) && (inode->i_sb->s_flags & SB_NOSEC))
+	if (!is_sxid(inode->i_mode) && (inode_sb(inode)->s_flags & SB_NOSEC))
 		inode->i_flags |= S_NOSEC;
 }
 
 static inline bool is_root_inode(struct inode *inode)
 {
-	return inode == inode->i_sb->s_root->d_inode;
+	return inode == inode_sb(inode)->s_root->d_inode;
 }
 
 static inline bool dir_emit(struct dir_context *ctx,
diff --git a/include/linux/fscrypt_supp.h b/include/linux/fscrypt_supp.h
index 477a7a6504d2..01e75d7e5ec8 100644
--- a/include/linux/fscrypt_supp.h
+++ b/include/linux/fscrypt_supp.h
@@ -54,8 +54,8 @@ static inline bool fscrypt_has_encryption_key(const struct inode *inode)
 
 static inline bool fscrypt_dummy_context_enabled(struct inode *inode)
 {
-	return inode->i_sb->s_cop->dummy_context &&
-		inode->i_sb->s_cop->dummy_context(inode);
+	return inode_sb(inode)->s_cop->dummy_context &&
+			inode_sb(inode)->s_cop->dummy_context(inode);
 }
 
 /* crypto.c */
diff --git a/include/linux/hugetlb.h b/include/linux/hugetlb.h
index 36fa6a2a82e3..91036dfbfe78 100644
--- a/include/linux/hugetlb.h
+++ b/include/linux/hugetlb.h
@@ -382,7 +382,7 @@ extern unsigned int default_hstate_idx;
 
 static inline struct hstate *hstate_inode(struct inode *i)
 {
-	return HUGETLBFS_SB(i->i_sb)->hstate;
+	return HUGETLBFS_SB(inode_sb(i))->hstate;
 }
 
 static inline struct hstate *hstate_file(struct file *f)
diff --git a/include/linux/nfs_fs.h b/include/linux/nfs_fs.h
index 38187c68063d..0d3dddba4d5d 100644
--- a/include/linux/nfs_fs.h
+++ b/include/linux/nfs_fs.h
@@ -238,7 +238,7 @@ static inline struct nfs_fh *NFS_FH(const struct inode *inode)
 
 static inline struct nfs_server *NFS_SERVER(const struct inode *inode)
 {
-	return NFS_SB(inode->i_sb);
+	return NFS_SB(inode_sb(inode));
 }
 
 static inline struct rpc_clnt *NFS_CLIENT(const struct inode *inode)
diff --git a/include/trace/events/btrfs.h b/include/trace/events/btrfs.h
index c3ac5ec86519..d8d8823c635a 100644
--- a/include/trace/events/btrfs.h
+++ b/include/trace/events/btrfs.h
@@ -136,7 +136,7 @@ DECLARE_EVENT_CLASS(btrfs__inode,
 		__field(	u64,  root_objectid		)
 	),
 
-	TP_fast_assign_btrfs(btrfs_sb(inode->i_sb),
+	TP_fast_assign_btrfs(btrfs_sb(inode_sb(inode)),
 		__entry->ino	= inode->i_ino;
 		__entry->blocks	= inode->i_blocks;
 		__entry->disk_i_size  = BTRFS_I(inode)->disk_i_size;
@@ -415,7 +415,7 @@ DECLARE_EVENT_CLASS(btrfs__ordered_extent,
 		__field(	u64,  truncated_len	)
 	),
 
-	TP_fast_assign_btrfs(btrfs_sb(inode->i_sb),
+	TP_fast_assign_btrfs(btrfs_sb(inode_sb(inode)),
 		__entry->ino 		= inode->i_ino;
 		__entry->file_offset	= ordered->file_offset;
 		__entry->start		= ordered->start;
@@ -500,7 +500,7 @@ DECLARE_EVENT_CLASS(btrfs__writepage,
 		__field(	u64,    root_objectid		)
 	),
 
-	TP_fast_assign_btrfs(btrfs_sb(inode->i_sb),
+	TP_fast_assign_btrfs(btrfs_sb(inode_sb(inode)),
 		__entry->ino		= inode->i_ino;
 		__entry->index		= page->index;
 		__entry->nr_to_write	= wbc->nr_to_write;
@@ -551,7 +551,7 @@ TRACE_EVENT(btrfs_writepage_end_io_hook,
 		__field(	u64,    root_objectid	)
 	),
 
-	TP_fast_assign_btrfs(btrfs_sb(page->mapping->host->i_sb),
+	TP_fast_assign_btrfs(btrfs_sb(inode_sb(page->mapping->host)),
 		__entry->ino	= page->mapping->host->i_ino;
 		__entry->index	= page->index;
 		__entry->start	= start;
@@ -1442,7 +1442,7 @@ DECLARE_EVENT_CLASS(btrfs__qgroup_rsv_data,
 		__field(	int,		op		)
 	),
 
-	TP_fast_assign_btrfs(btrfs_sb(inode->i_sb),
+	TP_fast_assign_btrfs(btrfs_sb(inode_sb(inode)),
 		__entry->rootid		= BTRFS_I(inode)->root->objectid;
 		__entry->ino		= inode->i_ino;
 		__entry->start		= start;
diff --git a/include/trace/events/ext4.h b/include/trace/events/ext4.h
index 4d0e3af4e561..89943e59ae36 100644
--- a/include/trace/events/ext4.h
+++ b/include/trace/events/ext4.h
@@ -91,7 +91,7 @@ TRACE_EVENT(ext4_other_inode_update_time,
 
 	TP_fast_assign(
 		__entry->orig_ino = orig_ino;
-		__entry->dev	= inode->i_sb->s_dev;
+		__entry->dev	= inode_sb(inode)->s_dev;
 		__entry->ino	= inode->i_ino;
 		__entry->uid	= i_uid_read(inode);
 		__entry->gid	= i_gid_read(inode);
@@ -120,7 +120,7 @@ TRACE_EVENT(ext4_free_inode,
 	),
 
 	TP_fast_assign(
-		__entry->dev	= inode->i_sb->s_dev;
+		__entry->dev	= inode_sb(inode)->s_dev;
 		__entry->ino	= inode->i_ino;
 		__entry->uid	= i_uid_read(inode);
 		__entry->gid	= i_gid_read(inode);
@@ -146,7 +146,7 @@ TRACE_EVENT(ext4_request_inode,
 	),
 
 	TP_fast_assign(
-		__entry->dev	= dir->i_sb->s_dev;
+		__entry->dev	= inode_sb(dir)->s_dev;
 		__entry->dir	= dir->i_ino;
 		__entry->mode	= mode;
 	),
@@ -169,7 +169,7 @@ TRACE_EVENT(ext4_allocate_inode,
 	),
 
 	TP_fast_assign(
-		__entry->dev	= inode->i_sb->s_dev;
+		__entry->dev	= inode_sb(inode)->s_dev;
 		__entry->ino	= inode->i_ino;
 		__entry->dir	= dir->i_ino;
 		__entry->mode	= mode;
@@ -193,7 +193,7 @@ TRACE_EVENT(ext4_evict_inode,
 	),
 
 	TP_fast_assign(
-		__entry->dev	= inode->i_sb->s_dev;
+		__entry->dev	= inode_sb(inode)->s_dev;
 		__entry->ino	= inode->i_ino;
 		__entry->nlink	= inode->i_nlink;
 	),
@@ -215,7 +215,7 @@ TRACE_EVENT(ext4_drop_inode,
 	),
 
 	TP_fast_assign(
-		__entry->dev	= inode->i_sb->s_dev;
+		__entry->dev	= inode_sb(inode)->s_dev;
 		__entry->ino	= inode->i_ino;
 		__entry->drop	= drop;
 	),
@@ -237,7 +237,7 @@ TRACE_EVENT(ext4_mark_inode_dirty,
 	),
 
 	TP_fast_assign(
-		__entry->dev	= inode->i_sb->s_dev;
+		__entry->dev	= inode_sb(inode)->s_dev;
 		__entry->ino	= inode->i_ino;
 		__entry->ip	= IP;
 	),
@@ -259,7 +259,7 @@ TRACE_EVENT(ext4_begin_ordered_truncate,
 	),
 
 	TP_fast_assign(
-		__entry->dev		= inode->i_sb->s_dev;
+		__entry->dev		= inode_sb(inode)->s_dev;
 		__entry->ino		= inode->i_ino;
 		__entry->new_size	= new_size;
 	),
@@ -286,7 +286,7 @@ DECLARE_EVENT_CLASS(ext4__write_begin,
 	),
 
 	TP_fast_assign(
-		__entry->dev	= inode->i_sb->s_dev;
+		__entry->dev	= inode_sb(inode)->s_dev;
 		__entry->ino	= inode->i_ino;
 		__entry->pos	= pos;
 		__entry->len	= len;
@@ -330,7 +330,7 @@ DECLARE_EVENT_CLASS(ext4__write_end,
 	),
 
 	TP_fast_assign(
-		__entry->dev	= inode->i_sb->s_dev;
+		__entry->dev	= inode_sb(inode)->s_dev;
 		__entry->ino	= inode->i_ino;
 		__entry->pos	= pos;
 		__entry->len	= len;
@@ -386,7 +386,7 @@ TRACE_EVENT(ext4_writepages,
 	),
 
 	TP_fast_assign(
-		__entry->dev		= inode->i_sb->s_dev;
+		__entry->dev		= inode_sb(inode)->s_dev;
 		__entry->ino		= inode->i_ino;
 		__entry->nr_to_write	= wbc->nr_to_write;
 		__entry->pages_skipped	= wbc->pages_skipped;
@@ -424,7 +424,7 @@ TRACE_EVENT(ext4_da_write_pages,
 	),
 
 	TP_fast_assign(
-		__entry->dev		= inode->i_sb->s_dev;
+		__entry->dev		= inode_sb(inode)->s_dev;
 		__entry->ino		= inode->i_ino;
 		__entry->first_page	= first_page;
 		__entry->nr_to_write	= wbc->nr_to_write;
@@ -452,7 +452,7 @@ TRACE_EVENT(ext4_da_write_pages_extent,
 	),
 
 	TP_fast_assign(
-		__entry->dev		= inode->i_sb->s_dev;
+		__entry->dev		= inode_sb(inode)->s_dev;
 		__entry->ino		= inode->i_ino;
 		__entry->lblk		= map->m_lblk;
 		__entry->len		= map->m_len;
@@ -482,7 +482,7 @@ TRACE_EVENT(ext4_writepages_result,
 	),
 
 	TP_fast_assign(
-		__entry->dev		= inode->i_sb->s_dev;
+		__entry->dev		= inode_sb(inode)->s_dev;
 		__entry->ino		= inode->i_ino;
 		__entry->ret		= ret;
 		__entry->pages_written	= pages_written;
@@ -513,7 +513,7 @@ DECLARE_EVENT_CLASS(ext4__page_op,
 	),
 
 	TP_fast_assign(
-		__entry->dev	= page->mapping->host->i_sb->s_dev;
+		__entry->dev	= inode_sb(page->mapping->host)->s_dev;
 		__entry->ino	= page->mapping->host->i_ino;
 		__entry->index	= page->index;
 	),
@@ -559,7 +559,7 @@ DECLARE_EVENT_CLASS(ext4_invalidatepage_op,
 	),
 
 	TP_fast_assign(
-		__entry->dev	= page->mapping->host->i_sb->s_dev;
+		__entry->dev	= inode_sb(page->mapping->host)->s_dev;
 		__entry->ino	= page->mapping->host->i_ino;
 		__entry->index	= page->index;
 		__entry->offset	= offset;
@@ -669,7 +669,7 @@ TRACE_EVENT(ext4_mb_release_inode_pa,
 	),
 
 	TP_fast_assign(
-		__entry->dev		= pa->pa_inode->i_sb->s_dev;
+		__entry->dev		= inode_sb(pa->pa_inode)->s_dev;
 		__entry->ino		= pa->pa_inode->i_ino;
 		__entry->block		= block;
 		__entry->count		= count;
@@ -716,7 +716,7 @@ TRACE_EVENT(ext4_discard_preallocations,
 	),
 
 	TP_fast_assign(
-		__entry->dev	= inode->i_sb->s_dev;
+		__entry->dev	= inode_sb(inode)->s_dev;
 		__entry->ino	= inode->i_ino;
 	),
 
@@ -765,7 +765,7 @@ TRACE_EVENT(ext4_request_blocks,
 	),
 
 	TP_fast_assign(
-		__entry->dev	= ar->inode->i_sb->s_dev;
+		__entry->dev	= inode_sb(ar->inode)->s_dev;
 		__entry->ino	= ar->inode->i_ino;
 		__entry->len	= ar->len;
 		__entry->logical = ar->logical;
@@ -806,7 +806,7 @@ TRACE_EVENT(ext4_allocate_blocks,
 	),
 
 	TP_fast_assign(
-		__entry->dev	= ar->inode->i_sb->s_dev;
+		__entry->dev	= inode_sb(ar->inode)->s_dev;
 		__entry->ino	= ar->inode->i_ino;
 		__entry->block	= block;
 		__entry->len	= ar->len;
@@ -844,7 +844,7 @@ TRACE_EVENT(ext4_free_blocks,
 	),
 
 	TP_fast_assign(
-		__entry->dev		= inode->i_sb->s_dev;
+		__entry->dev		= inode_sb(inode)->s_dev;
 		__entry->ino		= inode->i_ino;
 		__entry->block		= block;
 		__entry->count		= count;
@@ -898,7 +898,7 @@ TRACE_EVENT(ext4_sync_file_exit,
 	),
 
 	TP_fast_assign(
-		__entry->dev		= inode->i_sb->s_dev;
+		__entry->dev		= inode_sb(inode)->s_dev;
 		__entry->ino		= inode->i_ino;
 		__entry->ret		= ret;
 	),
@@ -942,7 +942,7 @@ TRACE_EVENT(ext4_alloc_da_blocks,
 	),
 
 	TP_fast_assign(
-		__entry->dev	= inode->i_sb->s_dev;
+		__entry->dev	= inode_sb(inode)->s_dev;
 		__entry->ino	= inode->i_ino;
 		__entry->data_blocks = EXT4_I(inode)->i_reserved_data_blocks;
 	),
@@ -982,7 +982,7 @@ TRACE_EVENT(ext4_mballoc_alloc,
 	),
 
 	TP_fast_assign(
-		__entry->dev		= ac->ac_inode->i_sb->s_dev;
+		__entry->dev		= inode_sb(ac->ac_inode)->s_dev;
 		__entry->ino		= ac->ac_inode->i_ino;
 		__entry->orig_logical	= ac->ac_o_ex.fe_logical;
 		__entry->orig_start	= ac->ac_o_ex.fe_start;
@@ -1039,7 +1039,7 @@ TRACE_EVENT(ext4_mballoc_prealloc,
 	),
 
 	TP_fast_assign(
-		__entry->dev		= ac->ac_inode->i_sb->s_dev;
+		__entry->dev		= inode_sb(ac->ac_inode)->s_dev;
 		__entry->ino		= ac->ac_inode->i_ino;
 		__entry->orig_logical	= ac->ac_o_ex.fe_logical;
 		__entry->orig_start	= ac->ac_o_ex.fe_start;
@@ -1128,7 +1128,7 @@ TRACE_EVENT(ext4_forget,
 	),
 
 	TP_fast_assign(
-		__entry->dev	= inode->i_sb->s_dev;
+		__entry->dev	= inode_sb(inode)->s_dev;
 		__entry->ino	= inode->i_ino;
 		__entry->block	= block;
 		__entry->is_metadata = is_metadata;
@@ -1157,7 +1157,7 @@ TRACE_EVENT(ext4_da_update_reserve_space,
 	),
 
 	TP_fast_assign(
-		__entry->dev	= inode->i_sb->s_dev;
+		__entry->dev	= inode_sb(inode)->s_dev;
 		__entry->ino	= inode->i_ino;
 		__entry->i_blocks = inode->i_blocks;
 		__entry->used_blocks = used_blocks;
@@ -1190,7 +1190,7 @@ TRACE_EVENT(ext4_da_reserve_space,
 	),
 
 	TP_fast_assign(
-		__entry->dev	= inode->i_sb->s_dev;
+		__entry->dev	= inode_sb(inode)->s_dev;
 		__entry->ino	= inode->i_ino;
 		__entry->i_blocks = inode->i_blocks;
 		__entry->reserved_data_blocks = EXT4_I(inode)->i_reserved_data_blocks;
@@ -1220,7 +1220,7 @@ TRACE_EVENT(ext4_da_release_space,
 	),
 
 	TP_fast_assign(
-		__entry->dev	= inode->i_sb->s_dev;
+		__entry->dev	= inode_sb(inode)->s_dev;
 		__entry->ino	= inode->i_ino;
 		__entry->i_blocks = inode->i_blocks;
 		__entry->freed_blocks = freed_blocks;
@@ -1299,7 +1299,7 @@ TRACE_EVENT(ext4_direct_IO_enter,
 	),
 
 	TP_fast_assign(
-		__entry->dev	= inode->i_sb->s_dev;
+		__entry->dev	= inode_sb(inode)->s_dev;
 		__entry->ino	= inode->i_ino;
 		__entry->pos	= offset;
 		__entry->len	= len;
@@ -1328,7 +1328,7 @@ TRACE_EVENT(ext4_direct_IO_exit,
 	),
 
 	TP_fast_assign(
-		__entry->dev	= inode->i_sb->s_dev;
+		__entry->dev	= inode_sb(inode)->s_dev;
 		__entry->ino	= inode->i_ino;
 		__entry->pos	= offset;
 		__entry->len	= len;
@@ -1357,7 +1357,7 @@ DECLARE_EVENT_CLASS(ext4__fallocate_mode,
 	),
 
 	TP_fast_assign(
-		__entry->dev	= inode->i_sb->s_dev;
+		__entry->dev	= inode_sb(inode)->s_dev;
 		__entry->ino	= inode->i_ino;
 		__entry->offset	= offset;
 		__entry->len	= len;
@@ -1407,7 +1407,7 @@ TRACE_EVENT(ext4_fallocate_exit,
 	),
 
 	TP_fast_assign(
-		__entry->dev	= inode->i_sb->s_dev;
+		__entry->dev	= inode_sb(inode)->s_dev;
 		__entry->ino	= inode->i_ino;
 		__entry->pos	= offset;
 		__entry->blocks	= max_blocks;
@@ -1481,7 +1481,7 @@ DECLARE_EVENT_CLASS(ext4__truncate,
 	),
 
 	TP_fast_assign(
-		__entry->dev    = inode->i_sb->s_dev;
+		__entry->dev    = inode_sb(inode)->s_dev;
 		__entry->ino    = inode->i_ino;
 		__entry->blocks	= inode->i_blocks;
 	),
@@ -1523,7 +1523,7 @@ TRACE_EVENT(ext4_ext_convert_to_initialized_enter,
 	),
 
 	TP_fast_assign(
-		__entry->dev		= inode->i_sb->s_dev;
+		__entry->dev		= inode_sb(inode)->s_dev;
 		__entry->ino		= inode->i_ino;
 		__entry->m_lblk		= map->m_lblk;
 		__entry->m_len		= map->m_len;
@@ -1564,7 +1564,7 @@ TRACE_EVENT(ext4_ext_convert_to_initialized_fastpath,
 	),
 
 	TP_fast_assign(
-		__entry->dev		= inode->i_sb->s_dev;
+		__entry->dev		= inode_sb(inode)->s_dev;
 		__entry->ino		= inode->i_ino;
 		__entry->m_lblk		= map->m_lblk;
 		__entry->m_len		= map->m_len;
@@ -1601,7 +1601,7 @@ DECLARE_EVENT_CLASS(ext4__map_blocks_enter,
 	),
 
 	TP_fast_assign(
-		__entry->dev    = inode->i_sb->s_dev;
+		__entry->dev    = inode_sb(inode)->s_dev;
 		__entry->ino    = inode->i_ino;
 		__entry->lblk	= lblk;
 		__entry->len	= len;
@@ -1646,7 +1646,7 @@ DECLARE_EVENT_CLASS(ext4__map_blocks_exit,
 	),
 
 	TP_fast_assign(
-		__entry->dev    = inode->i_sb->s_dev;
+		__entry->dev    = inode_sb(inode)->s_dev;
 		__entry->ino    = inode->i_ino;
 		__entry->flags	= flags;
 		__entry->pblk	= map->m_pblk;
@@ -1691,7 +1691,7 @@ TRACE_EVENT(ext4_ext_load_extent,
 	),
 
 	TP_fast_assign(
-		__entry->dev    = inode->i_sb->s_dev;
+		__entry->dev    = inode_sb(inode)->s_dev;
 		__entry->ino    = inode->i_ino;
 		__entry->pblk	= pblk;
 		__entry->lblk	= lblk;
@@ -1714,7 +1714,7 @@ TRACE_EVENT(ext4_load_inode,
 	),
 
 	TP_fast_assign(
-		__entry->dev		= inode->i_sb->s_dev;
+		__entry->dev		= inode_sb(inode)->s_dev;
 		__entry->ino		= inode->i_ino;
 	),
 
@@ -1837,7 +1837,7 @@ TRACE_EVENT(ext4_ext_handle_unwritten_extents,
 	),
 
 	TP_fast_assign(
-		__entry->dev		= inode->i_sb->s_dev;
+		__entry->dev		= inode_sb(inode)->s_dev;
 		__entry->ino		= inode->i_ino;
 		__entry->flags		= flags;
 		__entry->lblk		= map->m_lblk;
@@ -1901,7 +1901,7 @@ TRACE_EVENT(ext4_ext_put_in_cache,
 	),
 
 	TP_fast_assign(
-		__entry->dev	= inode->i_sb->s_dev;
+		__entry->dev	= inode_sb(inode)->s_dev;
 		__entry->ino	= inode->i_ino;
 		__entry->lblk	= lblk;
 		__entry->len	= len;
@@ -1929,7 +1929,7 @@ TRACE_EVENT(ext4_ext_in_cache,
 	),
 
 	TP_fast_assign(
-		__entry->dev	= inode->i_sb->s_dev;
+		__entry->dev	= inode_sb(inode)->s_dev;
 		__entry->ino	= inode->i_ino;
 		__entry->lblk	= lblk;
 		__entry->ret	= ret;
@@ -1960,7 +1960,7 @@ TRACE_EVENT(ext4_find_delalloc_range,
 	),
 
 	TP_fast_assign(
-		__entry->dev		= inode->i_sb->s_dev;
+		__entry->dev		= inode_sb(inode)->s_dev;
 		__entry->ino		= inode->i_ino;
 		__entry->from		= from;
 		__entry->to		= to;
@@ -1991,7 +1991,7 @@ TRACE_EVENT(ext4_get_reserved_cluster_alloc,
 	),
 
 	TP_fast_assign(
-		__entry->dev	= inode->i_sb->s_dev;
+		__entry->dev	= inode_sb(inode)->s_dev;
 		__entry->ino	= inode->i_ino;
 		__entry->lblk	= lblk;
 		__entry->len	= len;
@@ -2019,7 +2019,7 @@ TRACE_EVENT(ext4_ext_show_extent,
 	),
 
 	TP_fast_assign(
-		__entry->dev	= inode->i_sb->s_dev;
+		__entry->dev	= inode_sb(inode)->s_dev;
 		__entry->ino	= inode->i_ino;
 		__entry->pblk	= pblk;
 		__entry->lblk	= lblk;
@@ -2053,7 +2053,7 @@ TRACE_EVENT(ext4_remove_blocks,
 	),
 
 	TP_fast_assign(
-		__entry->dev		= inode->i_sb->s_dev;
+		__entry->dev		= inode_sb(inode)->s_dev;
 		__entry->ino		= inode->i_ino;
 		__entry->from		= from;
 		__entry->to		= to;
@@ -2093,7 +2093,7 @@ TRACE_EVENT(ext4_ext_rm_leaf,
 	),
 
 	TP_fast_assign(
-		__entry->dev		= inode->i_sb->s_dev;
+		__entry->dev		= inode_sb(inode)->s_dev;
 		__entry->ino		= inode->i_ino;
 		__entry->partial	= partial_cluster;
 		__entry->start		= start;
@@ -2125,7 +2125,7 @@ TRACE_EVENT(ext4_ext_rm_idx,
 	),
 
 	TP_fast_assign(
-		__entry->dev	= inode->i_sb->s_dev;
+		__entry->dev	= inode_sb(inode)->s_dev;
 		__entry->ino	= inode->i_ino;
 		__entry->pblk	= pblk;
 	),
@@ -2151,7 +2151,7 @@ TRACE_EVENT(ext4_ext_remove_space,
 	),
 
 	TP_fast_assign(
-		__entry->dev	= inode->i_sb->s_dev;
+		__entry->dev	= inode_sb(inode)->s_dev;
 		__entry->ino	= inode->i_ino;
 		__entry->start	= start;
 		__entry->end	= end;
@@ -2183,7 +2183,7 @@ TRACE_EVENT(ext4_ext_remove_space_done,
 	),
 
 	TP_fast_assign(
-		__entry->dev		= inode->i_sb->s_dev;
+		__entry->dev		= inode_sb(inode)->s_dev;
 		__entry->ino		= inode->i_ino;
 		__entry->start		= start;
 		__entry->end		= end;
@@ -2218,7 +2218,7 @@ DECLARE_EVENT_CLASS(ext4__es_extent,
 	),
 
 	TP_fast_assign(
-		__entry->dev	= inode->i_sb->s_dev;
+		__entry->dev	= inode_sb(inode)->s_dev;
 		__entry->ino	= inode->i_ino;
 		__entry->lblk	= es->es_lblk;
 		__entry->len	= es->es_len;
@@ -2258,7 +2258,7 @@ TRACE_EVENT(ext4_es_remove_extent,
 	),
 
 	TP_fast_assign(
-		__entry->dev	= inode->i_sb->s_dev;
+		__entry->dev	= inode_sb(inode)->s_dev;
 		__entry->ino	= inode->i_ino;
 		__entry->lblk	= lblk;
 		__entry->len	= len;
@@ -2282,7 +2282,7 @@ TRACE_EVENT(ext4_es_find_delayed_extent_range_enter,
 	),
 
 	TP_fast_assign(
-		__entry->dev	= inode->i_sb->s_dev;
+		__entry->dev	= inode_sb(inode)->s_dev;
 		__entry->ino	= inode->i_ino;
 		__entry->lblk	= lblk;
 	),
@@ -2307,7 +2307,7 @@ TRACE_EVENT(ext4_es_find_delayed_extent_range_exit,
 	),
 
 	TP_fast_assign(
-		__entry->dev	= inode->i_sb->s_dev;
+		__entry->dev	= inode_sb(inode)->s_dev;
 		__entry->ino	= inode->i_ino;
 		__entry->lblk	= es->es_lblk;
 		__entry->len	= es->es_len;
@@ -2334,7 +2334,7 @@ TRACE_EVENT(ext4_es_lookup_extent_enter,
 	),
 
 	TP_fast_assign(
-		__entry->dev	= inode->i_sb->s_dev;
+		__entry->dev	= inode_sb(inode)->s_dev;
 		__entry->ino	= inode->i_ino;
 		__entry->lblk	= lblk;
 	),
@@ -2361,7 +2361,7 @@ TRACE_EVENT(ext4_es_lookup_extent_exit,
 	),
 
 	TP_fast_assign(
-		__entry->dev	= inode->i_sb->s_dev;
+		__entry->dev	= inode_sb(inode)->s_dev;
 		__entry->ino	= inode->i_ino;
 		__entry->lblk	= es->es_lblk;
 		__entry->len	= es->es_len;
@@ -2447,7 +2447,7 @@ TRACE_EVENT(ext4_collapse_range,
 	),
 
 	TP_fast_assign(
-		__entry->dev	= inode->i_sb->s_dev;
+		__entry->dev	= inode_sb(inode)->s_dev;
 		__entry->ino	= inode->i_ino;
 		__entry->offset	= offset;
 		__entry->len	= len;
@@ -2472,7 +2472,7 @@ TRACE_EVENT(ext4_insert_range,
 	),
 
 	TP_fast_assign(
-		__entry->dev	= inode->i_sb->s_dev;
+		__entry->dev	= inode_sb(inode)->s_dev;
 		__entry->ino	= inode->i_ino;
 		__entry->offset	= offset;
 		__entry->len	= len;
diff --git a/include/trace/events/f2fs.h b/include/trace/events/f2fs.h
index 06c87f9f720c..8e958dd92412 100644
--- a/include/trace/events/f2fs.h
+++ b/include/trace/events/f2fs.h
@@ -171,7 +171,7 @@ DECLARE_EVENT_CLASS(f2fs__inode,
 	),
 
 	TP_fast_assign(
-		__entry->dev	= inode->i_sb->s_dev;
+		__entry->dev	= inode_sb(inode)->s_dev;
 		__entry->ino	= inode->i_ino;
 		__entry->pino	= F2FS_I(inode)->i_pino;
 		__entry->mode	= inode->i_mode;
@@ -205,7 +205,7 @@ DECLARE_EVENT_CLASS(f2fs__inode_exit,
 	),
 
 	TP_fast_assign(
-		__entry->dev	= inode->i_sb->s_dev;
+		__entry->dev	= inode_sb(inode)->s_dev;
 		__entry->ino	= inode->i_ino;
 		__entry->ret	= ret;
 	),
@@ -237,7 +237,7 @@ TRACE_EVENT(f2fs_sync_file_exit,
 	),
 
 	TP_fast_assign(
-		__entry->dev		= inode->i_sb->s_dev;
+		__entry->dev		= inode_sb(inode)->s_dev;
 		__entry->ino		= inode->i_ino;
 		__entry->cp_reason	= cp_reason;
 		__entry->datasync	= datasync;
@@ -319,7 +319,7 @@ TRACE_EVENT(f2fs_unlink_enter,
 	),
 
 	TP_fast_assign(
-		__entry->dev	= dir->i_sb->s_dev;
+		__entry->dev	= inode_sb(dir)->s_dev;
 		__entry->ino	= dir->i_ino;
 		__entry->size	= dir->i_size;
 		__entry->blocks	= dir->i_blocks;
@@ -370,7 +370,7 @@ TRACE_EVENT(f2fs_truncate_data_blocks_range,
 	),
 
 	TP_fast_assign(
-		__entry->dev	= inode->i_sb->s_dev;
+		__entry->dev	= inode_sb(inode)->s_dev;
 		__entry->ino	= inode->i_ino;
 		__entry->nid	= nid;
 		__entry->ofs	= ofs;
@@ -399,7 +399,7 @@ DECLARE_EVENT_CLASS(f2fs__truncate_op,
 	),
 
 	TP_fast_assign(
-		__entry->dev	= inode->i_sb->s_dev;
+		__entry->dev	= inode_sb(inode)->s_dev;
 		__entry->ino	= inode->i_ino;
 		__entry->size	= inode->i_size;
 		__entry->blocks	= inode->i_blocks;
@@ -456,7 +456,7 @@ DECLARE_EVENT_CLASS(f2fs__truncate_node,
 	),
 
 	TP_fast_assign(
-		__entry->dev		= inode->i_sb->s_dev;
+		__entry->dev		= inode_sb(inode)->s_dev;
 		__entry->ino		= inode->i_ino;
 		__entry->nid		= nid;
 		__entry->blk_addr	= blk_addr;
@@ -504,7 +504,7 @@ TRACE_EVENT(f2fs_truncate_partial_nodes,
 	),
 
 	TP_fast_assign(
-		__entry->dev	= inode->i_sb->s_dev;
+		__entry->dev	= inode_sb(inode)->s_dev;
 		__entry->ino	= inode->i_ino;
 		__entry->nid[0]	= nid[0];
 		__entry->nid[1]	= nid[1];
@@ -538,7 +538,7 @@ TRACE_EVENT(f2fs_map_blocks,
 	),
 
 	TP_fast_assign(
-		__entry->dev		= inode->i_sb->s_dev;
+		__entry->dev		= inode_sb(inode)->s_dev;
 		__entry->ino		= inode->i_ino;
 		__entry->m_lblk		= map->m_lblk;
 		__entry->m_pblk		= map->m_pblk;
@@ -756,7 +756,7 @@ TRACE_EVENT(f2fs_lookup_start,
 	),
 
 	TP_fast_assign(
-		__entry->dev	= dir->i_sb->s_dev;
+		__entry->dev	= inode_sb(dir)->s_dev;
 		__entry->ino	= dir->i_ino;
 		__entry->name	= dentry->d_name.name;
 		__entry->flags	= flags;
@@ -784,7 +784,7 @@ TRACE_EVENT(f2fs_lookup_end,
 	),
 
 	TP_fast_assign(
-		__entry->dev	= dir->i_sb->s_dev;
+		__entry->dev	= inode_sb(dir)->s_dev;
 		__entry->ino	= dir->i_ino;
 		__entry->name	= dentry->d_name.name;
 		__entry->cino	= ino;
@@ -813,7 +813,7 @@ TRACE_EVENT(f2fs_readdir,
 	),
 
 	TP_fast_assign(
-		__entry->dev	= dir->i_sb->s_dev;
+		__entry->dev	= inode_sb(dir)->s_dev;
 		__entry->ino	= dir->i_ino;
 		__entry->start	= start_pos;
 		__entry->end	= end_pos;
@@ -846,7 +846,7 @@ TRACE_EVENT(f2fs_fallocate,
 	),
 
 	TP_fast_assign(
-		__entry->dev	= inode->i_sb->s_dev;
+		__entry->dev	= inode_sb(inode)->s_dev;
 		__entry->ino	= inode->i_ino;
 		__entry->mode	= mode;
 		__entry->offset	= offset;
@@ -882,7 +882,7 @@ TRACE_EVENT(f2fs_direct_IO_enter,
 	),
 
 	TP_fast_assign(
-		__entry->dev	= inode->i_sb->s_dev;
+		__entry->dev	= inode_sb(inode)->s_dev;
 		__entry->ino	= inode->i_ino;
 		__entry->pos	= offset;
 		__entry->len	= len;
@@ -913,7 +913,7 @@ TRACE_EVENT(f2fs_direct_IO_exit,
 	),
 
 	TP_fast_assign(
-		__entry->dev	= inode->i_sb->s_dev;
+		__entry->dev	= inode_sb(inode)->s_dev;
 		__entry->ino	= inode->i_ino;
 		__entry->pos	= offset;
 		__entry->len	= len;
@@ -945,7 +945,7 @@ TRACE_EVENT(f2fs_reserve_new_blocks,
 	),
 
 	TP_fast_assign(
-		__entry->dev	= inode->i_sb->s_dev;
+		__entry->dev	= inode_sb(inode)->s_dev;
 		__entry->nid	= nid;
 		__entry->ofs_in_node = ofs_in_node;
 		__entry->count = count;
@@ -977,7 +977,7 @@ DECLARE_EVENT_CLASS(f2fs__submit_page_bio,
 	),
 
 	TP_fast_assign(
-		__entry->dev		= page->mapping->host->i_sb->s_dev;
+		__entry->dev		= inode_sb(page->mapping->host)->s_dev;
 		__entry->ino		= page->mapping->host->i_ino;
 		__entry->index		= page->index;
 		__entry->old_blkaddr	= fio->old_blkaddr;
@@ -1104,7 +1104,7 @@ TRACE_EVENT(f2fs_write_begin,
 	),
 
 	TP_fast_assign(
-		__entry->dev	= inode->i_sb->s_dev;
+		__entry->dev	= inode_sb(inode)->s_dev;
 		__entry->ino	= inode->i_ino;
 		__entry->pos	= pos;
 		__entry->len	= len;
@@ -1134,7 +1134,7 @@ TRACE_EVENT(f2fs_write_end,
 	),
 
 	TP_fast_assign(
-		__entry->dev	= inode->i_sb->s_dev;
+		__entry->dev	= inode_sb(inode)->s_dev;
 		__entry->ino	= inode->i_ino;
 		__entry->pos	= pos;
 		__entry->len	= len;
@@ -1165,7 +1165,7 @@ DECLARE_EVENT_CLASS(f2fs__page,
 	),
 
 	TP_fast_assign(
-		__entry->dev	= page->mapping->host->i_sb->s_dev;
+		__entry->dev	= inode_sb(page->mapping->host)->s_dev;
 		__entry->ino	= page->mapping->host->i_ino;
 		__entry->type	= type;
 		__entry->dir	= S_ISDIR(page->mapping->host->i_mode);
@@ -1259,7 +1259,7 @@ TRACE_EVENT(f2fs_writepages,
 	),
 
 	TP_fast_assign(
-		__entry->dev		= inode->i_sb->s_dev;
+		__entry->dev		= inode_sb(inode)->s_dev;
 		__entry->ino		= inode->i_ino;
 		__entry->type		= type;
 		__entry->dir		= S_ISDIR(inode->i_mode);
@@ -1311,7 +1311,7 @@ TRACE_EVENT(f2fs_readpages,
 	),
 
 	TP_fast_assign(
-		__entry->dev	= inode->i_sb->s_dev;
+		__entry->dev	= inode_sb(inode)->s_dev;
 		__entry->ino	= inode->i_ino;
 		__entry->start	= page->index;
 		__entry->nrpage	= nrpage;
@@ -1454,7 +1454,7 @@ TRACE_EVENT(f2fs_lookup_extent_tree_start,
 	),
 
 	TP_fast_assign(
-		__entry->dev = inode->i_sb->s_dev;
+		__entry->dev = inode_sb(inode)->s_dev;
 		__entry->ino = inode->i_ino;
 		__entry->pgofs = pgofs;
 	),
@@ -1483,7 +1483,7 @@ TRACE_EVENT_CONDITION(f2fs_lookup_extent_tree_end,
 	),
 
 	TP_fast_assign(
-		__entry->dev = inode->i_sb->s_dev;
+		__entry->dev = inode_sb(inode)->s_dev;
 		__entry->ino = inode->i_ino;
 		__entry->pgofs = pgofs;
 		__entry->fofs = ei->fofs;
@@ -1516,7 +1516,7 @@ TRACE_EVENT(f2fs_update_extent_tree_range,
 	),
 
 	TP_fast_assign(
-		__entry->dev = inode->i_sb->s_dev;
+		__entry->dev = inode_sb(inode)->s_dev;
 		__entry->ino = inode->i_ino;
 		__entry->pgofs = pgofs;
 		__entry->blk = blkaddr;
@@ -1569,7 +1569,7 @@ TRACE_EVENT(f2fs_destroy_extent_tree,
 	),
 
 	TP_fast_assign(
-		__entry->dev = inode->i_sb->s_dev;
+		__entry->dev = inode_sb(inode)->s_dev;
 		__entry->ino = inode->i_ino;
 		__entry->node_cnt = node_cnt;
 	),
diff --git a/include/trace/events/filelock.h b/include/trace/events/filelock.h
index d1faf3597b9d..522d2740a56f 100644
--- a/include/trace/events/filelock.h
+++ b/include/trace/events/filelock.h
@@ -48,7 +48,7 @@ TRACE_EVENT(locks_get_lock_context,
 	),
 
 	TP_fast_assign(
-		__entry->s_dev = inode->i_sb->s_dev;
+		__entry->s_dev = inode_sb(inode)->s_dev;
 		__entry->i_ino = inode->i_ino;
 		__entry->type = type;
 		__entry->ctx = ctx;
@@ -80,7 +80,7 @@ DECLARE_EVENT_CLASS(filelock_lock,
 
 	TP_fast_assign(
 		__entry->fl = fl ? fl : NULL;
-		__entry->s_dev = inode->i_sb->s_dev;
+		__entry->s_dev = inode_sb(inode)->s_dev;
 		__entry->i_ino = inode->i_ino;
 		__entry->fl_next = fl ? fl->fl_next : NULL;
 		__entry->fl_owner = fl ? fl->fl_owner : NULL;
@@ -132,7 +132,7 @@ DECLARE_EVENT_CLASS(filelock_lease,
 
 	TP_fast_assign(
 		__entry->fl = fl ? fl : NULL;
-		__entry->s_dev = inode->i_sb->s_dev;
+		__entry->s_dev = inode_sb(inode)->s_dev;
 		__entry->i_ino = inode->i_ino;
 		__entry->fl_next = fl ? fl->fl_next : NULL;
 		__entry->fl_owner = fl ? fl->fl_owner : NULL;
@@ -182,7 +182,7 @@ TRACE_EVENT(generic_add_lease,
 	),
 
 	TP_fast_assign(
-		__entry->s_dev = inode->i_sb->s_dev;
+		__entry->s_dev = inode_sb(inode)->s_dev;
 		__entry->i_ino = inode->i_ino;
 		__entry->wcount = atomic_read(&inode->i_writecount);
 		__entry->dcount = d_count(fl->fl_file->f_path.dentry);
diff --git a/include/trace/events/filemap.h b/include/trace/events/filemap.h
index ee05db7ee8d2..0517759b4b8f 100644
--- a/include/trace/events/filemap.h
+++ b/include/trace/events/filemap.h
@@ -30,8 +30,8 @@ DECLARE_EVENT_CLASS(mm_filemap_op_page_cache,
 		__entry->pfn = page_to_pfn(page);
 		__entry->i_ino = page->mapping->host->i_ino;
 		__entry->index = page->index;
-		if (page->mapping->host->i_sb)
-			__entry->s_dev = page->mapping->host->i_sb->s_dev;
+		if (inode_sb(page->mapping->host))
+			__entry->s_dev = inode_sb(page->mapping->host)->s_dev;
 		else
 			__entry->s_dev = page->mapping->host->i_rdev;
 	),
@@ -68,8 +68,8 @@ TRACE_EVENT(filemap_set_wb_err,
 		TP_fast_assign(
 			__entry->i_ino = mapping->host->i_ino;
 			__entry->errseq = eseq;
-			if (mapping->host->i_sb)
-				__entry->s_dev = mapping->host->i_sb->s_dev;
+			if (inode_sb(mapping->host))
+				__entry->s_dev = inode_sb(mapping->host)->s_dev;
 			else
 				__entry->s_dev = mapping->host->i_rdev;
 		),
@@ -95,9 +95,9 @@ TRACE_EVENT(file_check_and_advance_wb_err,
 		TP_fast_assign(
 			__entry->file = file;
 			__entry->i_ino = file->f_mapping->host->i_ino;
-			if (file->f_mapping->host->i_sb)
+			if (inode_sb(file->f_mapping->host))
 				__entry->s_dev =
-					file->f_mapping->host->i_sb->s_dev;
+					inode_sb(file->f_mapping->host)->s_dev;
 			else
 				__entry->s_dev =
 					file->f_mapping->host->i_rdev;
diff --git a/include/trace/events/fs_dax.h b/include/trace/events/fs_dax.h
index 97b09fcf7e52..d3173cae131d 100644
--- a/include/trace/events/fs_dax.h
+++ b/include/trace/events/fs_dax.h
@@ -24,7 +24,7 @@ DECLARE_EVENT_CLASS(dax_pmd_fault_class,
 		__field(int, result)
 	),
 	TP_fast_assign(
-		__entry->dev = inode->i_sb->s_dev;
+		__entry->dev = inode_sb(inode)->s_dev;
 		__entry->ino = inode->i_ino;
 		__entry->vm_start = vmf->vma->vm_start;
 		__entry->vm_end = vmf->vma->vm_end;
@@ -74,7 +74,7 @@ DECLARE_EVENT_CLASS(dax_pmd_load_hole_class,
 		__field(dev_t, dev)
 	),
 	TP_fast_assign(
-		__entry->dev = inode->i_sb->s_dev;
+		__entry->dev = inode_sb(inode)->s_dev;
 		__entry->ino = inode->i_ino;
 		__entry->vm_flags = vmf->vma->vm_flags;
 		__entry->address = vmf->address;
@@ -117,7 +117,7 @@ DECLARE_EVENT_CLASS(dax_pmd_insert_mapping_class,
 		__field(int, write)
 	),
 	TP_fast_assign(
-		__entry->dev = inode->i_sb->s_dev;
+		__entry->dev = inode_sb(inode)->s_dev;
 		__entry->ino = inode->i_ino;
 		__entry->vm_flags = vmf->vma->vm_flags;
 		__entry->address = vmf->address;
@@ -163,7 +163,7 @@ DECLARE_EVENT_CLASS(dax_pte_fault_class,
 		__field(int, result)
 	),
 	TP_fast_assign(
-		__entry->dev = inode->i_sb->s_dev;
+		__entry->dev = inode_sb(inode)->s_dev;
 		__entry->ino = inode->i_ino;
 		__entry->vm_flags = vmf->vma->vm_flags;
 		__entry->address = vmf->address;
@@ -206,7 +206,7 @@ TRACE_EVENT(dax_insert_mapping,
 		__field(int, write)
 	),
 	TP_fast_assign(
-		__entry->dev = inode->i_sb->s_dev;
+		__entry->dev = inode_sb(inode)->s_dev;
 		__entry->ino = inode->i_ino;
 		__entry->vm_flags = vmf->vma->vm_flags;
 		__entry->address = vmf->address;
@@ -234,7 +234,7 @@ DECLARE_EVENT_CLASS(dax_writeback_range_class,
 		__field(dev_t, dev)
 	),
 	TP_fast_assign(
-		__entry->dev = inode->i_sb->s_dev;
+		__entry->dev = inode_sb(inode)->s_dev;
 		__entry->ino = inode->i_ino;
 		__entry->start_index = start_index;
 		__entry->end_index = end_index;
@@ -266,7 +266,7 @@ TRACE_EVENT(dax_writeback_one,
 		__field(dev_t, dev)
 	),
 	TP_fast_assign(
-		__entry->dev = inode->i_sb->s_dev;
+		__entry->dev = inode_sb(inode)->s_dev;
 		__entry->ino = inode->i_ino;
 		__entry->pgoff = pgoff;
 		__entry->pglen = pglen;
diff --git a/include/trace/events/jbd2.h b/include/trace/events/jbd2.h
index 2310b259329f..95e0cb226d30 100644
--- a/include/trace/events/jbd2.h
+++ b/include/trace/events/jbd2.h
@@ -124,7 +124,7 @@ TRACE_EVENT(jbd2_submit_inode_data,
 	),
 
 	TP_fast_assign(
-		__entry->dev	= inode->i_sb->s_dev;
+		__entry->dev	= inode_sb(inode)->s_dev;
 		__entry->ino	= inode->i_ino;
 	),
 
diff --git a/include/trace/events/writeback.h b/include/trace/events/writeback.h
index 32db72c7c055..d5ae5ea65bc4 100644
--- a/include/trace/events/writeback.h
+++ b/include/trace/events/writeback.h
@@ -710,7 +710,7 @@ DECLARE_EVENT_CLASS(writeback_inode_template,
 	),
 
 	TP_fast_assign(
-		__entry->dev	= inode->i_sb->s_dev;
+		__entry->dev	= inode_sb(inode)->s_dev;
 		__entry->ino	= inode->i_ino;
 		__entry->state	= inode->i_state;
 		__entry->mode	= inode->i_mode;
diff --git a/include/uapi/linux/iso_fs.h b/include/uapi/linux/iso_fs.h
index a2555176f6d1..36aee6068b4a 100644
--- a/include/uapi/linux/iso_fs.h
+++ b/include/uapi/linux/iso_fs.h
@@ -160,7 +160,7 @@ struct iso_directory_record {
 #define ISOFS_BLOCK_BITS 11
 #define ISOFS_BLOCK_SIZE 2048
 
-#define ISOFS_BUFFER_SIZE(INODE) ((INODE)->i_sb->s_blocksize)
-#define ISOFS_BUFFER_BITS(INODE) ((INODE)->i_sb->s_blocksize_bits)
+#define ISOFS_BUFFER_SIZE(INODE) (inode_sb((INODE))->s_blocksize)
+#define ISOFS_BUFFER_BITS(INODE) (inode_sb((INODE))->s_blocksize_bits)
 
 #endif /* _ISOFS_FS_H */
-- 
2.15.1

^ permalink raw reply	[flat|nested] 88+ messages in thread

* [PATCH 06/76] ipc: Use inode_sb() helper instead of inode->i_sb
  2018-05-08 18:03 [RFC][PATCH 0/76] vfs: 'views' for filesystems with more than one root Mark Fasheh
                   ` (4 preceding siblings ...)
  2018-05-08 18:03 ` [PATCH 05/76] include: " Mark Fasheh
@ 2018-05-08 18:03 ` Mark Fasheh
  2018-05-08 18:03 ` [PATCH 07/76] kernel: " Mark Fasheh
                   ` (70 subsequent siblings)
  76 siblings, 0 replies; 88+ messages in thread
From: Mark Fasheh @ 2018-05-08 18:03 UTC (permalink / raw)
  To: linux-fsdevel; +Cc: linux-kernel, linux-btrfs, Mark Fasheh

Signed-off-by: Mark Fasheh <mfasheh@suse.de>
---
 ipc/mqueue.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/ipc/mqueue.c b/ipc/mqueue.c
index a808f29d4c5a..ac65b309c393 100644
--- a/ipc/mqueue.c
+++ b/ipc/mqueue.c
@@ -106,7 +106,7 @@ static inline struct mqueue_inode_info *MQUEUE_I(struct inode *inode)
  */
 static inline struct ipc_namespace *__get_ns_from_inode(struct inode *inode)
 {
-	return get_ipc_ns(inode->i_sb->s_fs_info);
+	return get_ipc_ns(inode_sb(inode)->s_fs_info);
 }
 
 static struct ipc_namespace *get_ns_from_inode(struct inode *inode)
@@ -456,7 +456,7 @@ static int mqueue_create_attr(struct dentry *dentry, umode_t mode, void *arg)
 	ipc_ns->mq_queues_count++;
 	spin_unlock(&mq_lock);
 
-	inode = mqueue_get_inode(dir->i_sb, ipc_ns, mode, attr);
+	inode = mqueue_get_inode(inode_sb(dir), ipc_ns, mode, attr);
 	if (IS_ERR(inode)) {
 		error = PTR_ERR(inode);
 		spin_lock(&mq_lock);
-- 
2.15.1

^ permalink raw reply	[flat|nested] 88+ messages in thread

* [PATCH 07/76] kernel: Use inode_sb() helper instead of inode->i_sb
  2018-05-08 18:03 [RFC][PATCH 0/76] vfs: 'views' for filesystems with more than one root Mark Fasheh
                   ` (5 preceding siblings ...)
  2018-05-08 18:03 ` [PATCH 06/76] ipc: " Mark Fasheh
@ 2018-05-08 18:03 ` Mark Fasheh
  2018-05-08 18:03 ` [PATCH 08/76] mm: " Mark Fasheh
                   ` (69 subsequent siblings)
  76 siblings, 0 replies; 88+ messages in thread
From: Mark Fasheh @ 2018-05-08 18:03 UTC (permalink / raw)
  To: linux-fsdevel; +Cc: linux-kernel, linux-btrfs, Mark Fasheh

Signed-off-by: Mark Fasheh <mfasheh@suse.de>
---
 kernel/audit.c          | 2 +-
 kernel/audit_fsnotify.c | 2 +-
 kernel/audit_watch.c    | 5 +++--
 kernel/auditsc.c        | 8 ++++----
 kernel/bpf/inode.c      | 6 +++---
 kernel/bpf/offload.c    | 4 ++--
 kernel/events/core.c    | 4 ++--
 7 files changed, 16 insertions(+), 15 deletions(-)

diff --git a/kernel/audit.c b/kernel/audit.c
index 227db99b0f19..23159573aafd 100644
--- a/kernel/audit.c
+++ b/kernel/audit.c
@@ -2050,7 +2050,7 @@ void audit_copy_inode(struct audit_names *name, const struct dentry *dentry,
 		      struct inode *inode)
 {
 	name->ino   = inode->i_ino;
-	name->dev   = inode->i_sb->s_dev;
+	name->dev   = inode_sb(inode)->s_dev;
 	name->mode  = inode->i_mode;
 	name->uid   = inode->i_uid;
 	name->gid   = inode->i_gid;
diff --git a/kernel/audit_fsnotify.c b/kernel/audit_fsnotify.c
index 52f368b6561e..981432cef19c 100644
--- a/kernel/audit_fsnotify.c
+++ b/kernel/audit_fsnotify.c
@@ -76,7 +76,7 @@ int audit_mark_compare(struct audit_fsnotify_mark *mark, unsigned long ino, dev_
 static void audit_update_mark(struct audit_fsnotify_mark *audit_mark,
 			     const struct inode *inode)
 {
-	audit_mark->dev = inode ? inode->i_sb->s_dev : AUDIT_DEV_UNSET;
+	audit_mark->dev = inode ? inode_sb(inode)->s_dev : AUDIT_DEV_UNSET;
 	audit_mark->ino = inode ? inode->i_ino : AUDIT_INO_UNSET;
 }
 
diff --git a/kernel/audit_watch.c b/kernel/audit_watch.c
index 9eb8b3511636..3e785d4cf8aa 100644
--- a/kernel/audit_watch.c
+++ b/kernel/audit_watch.c
@@ -499,7 +499,8 @@ static int audit_watch_handle_event(struct fsnotify_group *group,
 	}
 
 	if (mask & (FS_CREATE|FS_MOVED_TO) && inode)
-		audit_update_watch(parent, dname, inode->i_sb->s_dev, inode->i_ino, 0);
+		audit_update_watch(parent, dname, inode_sb(inode)->s_dev,
+				   inode->i_ino, 0);
 	else if (mask & (FS_DELETE|FS_MOVED_FROM))
 		audit_update_watch(parent, dname, AUDIT_DEV_UNSET, AUDIT_INO_UNSET, 1);
 	else if (mask & (FS_DELETE_SELF|FS_UNMOUNT|FS_MOVE_SELF))
@@ -553,7 +554,7 @@ int audit_exe_compare(struct task_struct *tsk, struct audit_fsnotify_mark *mark)
 	if (!exe_file)
 		return 0;
 	ino = file_inode(exe_file)->i_ino;
-	dev = file_inode(exe_file)->i_sb->s_dev;
+	dev = inode_sb(file_inode(exe_file))->s_dev;
 	fput(exe_file);
 	return audit_mark_compare(mark, ino, dev);
 }
diff --git a/kernel/auditsc.c b/kernel/auditsc.c
index e80459f7e132..9cb16a1ebedd 100644
--- a/kernel/auditsc.c
+++ b/kernel/auditsc.c
@@ -1797,7 +1797,7 @@ void __audit_inode(struct filename *name, const struct dentry *dentry,
 		if (n->ino) {
 			/* valid inode number, use that for the comparison */
 			if (n->ino != inode->i_ino ||
-			    n->dev != inode->i_sb->s_dev)
+			    n->dev != inode_sb(inode)->s_dev)
 				continue;
 		} else if (n->name) {
 			/* inode number has not been set, check the name */
@@ -1883,8 +1883,8 @@ void __audit_inode_child(struct inode *parent,
 				struct audit_field *f = &e->rule.fields[i];
 
 				if (f->type == AUDIT_FSTYPE) {
-					if (audit_comparator(parent->i_sb->s_magic,
-					    f->op, f->val)) {
+					if (audit_comparator(inode_sb(parent)->s_magic,
+						             f->op, f->val)) {
 						if (e->rule.action == AUDIT_NEVER) {
 							rcu_read_unlock();
 							return;
@@ -1906,7 +1906,7 @@ void __audit_inode_child(struct inode *parent,
 		     n->type != AUDIT_TYPE_UNKNOWN))
 			continue;
 
-		if (n->ino == parent->i_ino && n->dev == parent->i_sb->s_dev &&
+		if (n->ino == parent->i_ino && n->dev == inode_sb(parent)->s_dev &&
 		    !audit_compare_dname_path(dname,
 					      n->name->name, n->name_len)) {
 			if (n->type == AUDIT_TYPE_UNKNOWN)
diff --git a/kernel/bpf/inode.c b/kernel/bpf/inode.c
index 81e2f6995adb..130d9edc11eb 100644
--- a/kernel/bpf/inode.c
+++ b/kernel/bpf/inode.c
@@ -136,7 +136,7 @@ static int bpf_mkdir(struct inode *dir, struct dentry *dentry, umode_t mode)
 {
 	struct inode *inode;
 
-	inode = bpf_get_inode(dir->i_sb, dir, mode | S_IFDIR);
+	inode = bpf_get_inode(inode_sb(dir), dir, mode | S_IFDIR);
 	if (IS_ERR(inode))
 		return PTR_ERR(inode);
 
@@ -154,7 +154,7 @@ static int bpf_mkobj_ops(struct dentry *dentry, umode_t mode, void *raw,
 			 const struct inode_operations *iops)
 {
 	struct inode *dir = dentry->d_parent->d_inode;
-	struct inode *inode = bpf_get_inode(dir->i_sb, dir, mode);
+	struct inode *inode = bpf_get_inode(inode_sb(dir), dir, mode);
 	if (IS_ERR(inode))
 		return PTR_ERR(inode);
 
@@ -193,7 +193,7 @@ static int bpf_symlink(struct inode *dir, struct dentry *dentry,
 	if (!link)
 		return -ENOMEM;
 
-	inode = bpf_get_inode(dir->i_sb, dir, S_IRWXUGO | S_IFLNK);
+	inode = bpf_get_inode(inode_sb(dir), dir, S_IRWXUGO | S_IFLNK);
 	if (IS_ERR(inode)) {
 		kfree(link);
 		return PTR_ERR(inode);
diff --git a/kernel/bpf/offload.c b/kernel/bpf/offload.c
index c9401075b58c..6ff86b395175 100644
--- a/kernel/bpf/offload.c
+++ b/kernel/bpf/offload.c
@@ -265,7 +265,7 @@ int bpf_prog_offload_info_fill(struct bpf_prog_info *info,
 	up_read(&bpf_devs_lock);
 
 	ns_inode = ns_path.dentry->d_inode;
-	info->netns_dev = new_encode_dev(ns_inode->i_sb->s_dev);
+	info->netns_dev = new_encode_dev(inode_sb(ns_inode)->s_dev);
 	info->netns_ino = ns_inode->i_ino;
 	path_put(&ns_path);
 
@@ -461,7 +461,7 @@ int bpf_map_offload_info_fill(struct bpf_map_info *info, struct bpf_map *map)
 	}
 
 	ns_inode = ns_path.dentry->d_inode;
-	info->netns_dev = new_encode_dev(ns_inode->i_sb->s_dev);
+	info->netns_dev = new_encode_dev(inode_sb(ns_inode)->s_dev);
 	info->netns_ino = ns_inode->i_ino;
 	path_put(&ns_path);
 
diff --git a/kernel/events/core.c b/kernel/events/core.c
index 709a55b9ad97..58c02221e066 100644
--- a/kernel/events/core.c
+++ b/kernel/events/core.c
@@ -6713,7 +6713,7 @@ static void perf_fill_ns_link_info(struct perf_ns_link_info *ns_link_info,
 	error = ns_get_path(&ns_path, task, ns_ops);
 	if (!error) {
 		ns_inode = ns_path.dentry->d_inode;
-		ns_link_info->dev = new_encode_dev(ns_inode->i_sb->s_dev);
+		ns_link_info->dev = new_encode_dev(inode_sb(ns_inode)->s_dev);
 		ns_link_info->ino = ns_inode->i_ino;
 		path_put(&ns_path);
 	}
@@ -6918,7 +6918,7 @@ static void perf_event_mmap_event(struct perf_mmap_event *mmap_event)
 			goto cpy_name;
 		}
 		inode = file_inode(vma->vm_file);
-		dev = inode->i_sb->s_dev;
+		dev = inode_sb(inode)->s_dev;
 		ino = inode->i_ino;
 		gen = inode->i_generation;
 		maj = MAJOR(dev);
-- 
2.15.1

^ permalink raw reply	[flat|nested] 88+ messages in thread

* [PATCH 08/76] mm: Use inode_sb() helper instead of inode->i_sb
  2018-05-08 18:03 [RFC][PATCH 0/76] vfs: 'views' for filesystems with more than one root Mark Fasheh
                   ` (6 preceding siblings ...)
  2018-05-08 18:03 ` [PATCH 07/76] kernel: " Mark Fasheh
@ 2018-05-08 18:03 ` Mark Fasheh
  2018-05-08 18:03 ` [PATCH 09/76] net: " Mark Fasheh
                   ` (68 subsequent siblings)
  76 siblings, 0 replies; 88+ messages in thread
From: Mark Fasheh @ 2018-05-08 18:03 UTC (permalink / raw)
  To: linux-fsdevel; +Cc: linux-kernel, linux-btrfs, Mark Fasheh

Signed-off-by: Mark Fasheh <mfasheh@suse.de>
---
 mm/cleancache.c     | 10 +++++-----
 mm/filemap.c        | 12 ++++++------
 mm/hugetlb.c        |  2 +-
 mm/memory-failure.c |  2 +-
 mm/shmem.c          | 29 +++++++++++++++--------------
 mm/swapfile.c       |  4 ++--
 6 files changed, 30 insertions(+), 29 deletions(-)

diff --git a/mm/cleancache.c b/mm/cleancache.c
index f7b9fdc79d97..b4cabc316aea 100644
--- a/mm/cleancache.c
+++ b/mm/cleancache.c
@@ -147,7 +147,7 @@ static int cleancache_get_key(struct inode *inode,
 {
 	int (*fhfn)(struct inode *, __u32 *fh, int *, struct inode *);
 	int len = 0, maxlen = CLEANCACHE_KEY_MAX;
-	struct super_block *sb = inode->i_sb;
+	struct super_block *sb = inode_sb(inode);
 
 	key->u.ino = inode->i_ino;
 	if (sb->s_export_op != NULL) {
@@ -186,7 +186,7 @@ int __cleancache_get_page(struct page *page)
 	}
 
 	VM_BUG_ON_PAGE(!PageLocked(page), page);
-	pool_id = page->mapping->host->i_sb->cleancache_poolid;
+	pool_id = inode_sb(page->mapping->host)->cleancache_poolid;
 	if (pool_id < 0)
 		goto out;
 
@@ -224,7 +224,7 @@ void __cleancache_put_page(struct page *page)
 	}
 
 	VM_BUG_ON_PAGE(!PageLocked(page), page);
-	pool_id = page->mapping->host->i_sb->cleancache_poolid;
+	pool_id = inode_sb(page->mapping->host)->cleancache_poolid;
 	if (pool_id >= 0 &&
 		cleancache_get_key(page->mapping->host, &key) >= 0) {
 		cleancache_ops->put_page(pool_id, key, page->index, page);
@@ -245,7 +245,7 @@ void __cleancache_invalidate_page(struct address_space *mapping,
 					struct page *page)
 {
 	/* careful... page->mapping is NULL sometimes when this is called */
-	int pool_id = mapping->host->i_sb->cleancache_poolid;
+	int pool_id = inode_sb(mapping->host)->cleancache_poolid;
 	struct cleancache_filekey key = { .u.key = { 0 } };
 
 	if (!cleancache_ops)
@@ -273,7 +273,7 @@ EXPORT_SYMBOL(__cleancache_invalidate_page);
  */
 void __cleancache_invalidate_inode(struct address_space *mapping)
 {
-	int pool_id = mapping->host->i_sb->cleancache_poolid;
+	int pool_id = inode_sb(mapping->host)->cleancache_poolid;
 	struct cleancache_filekey key = { .u.key = { 0 } };
 
 	if (!cleancache_ops)
diff --git a/mm/filemap.c b/mm/filemap.c
index 693f62212a59..c81943b5ab3d 100644
--- a/mm/filemap.c
+++ b/mm/filemap.c
@@ -2064,9 +2064,9 @@ static ssize_t generic_file_buffered_read(struct kiocb *iocb,
 	unsigned int prev_offset;
 	int error = 0;
 
-	if (unlikely(*ppos >= inode->i_sb->s_maxbytes))
+	if (unlikely(*ppos >= inode_sb(inode)->s_maxbytes))
 		return 0;
-	iov_iter_truncate(iter, inode->i_sb->s_maxbytes);
+	iov_iter_truncate(iter, inode_sb(inode)->s_maxbytes);
 
 	index = *ppos >> PAGE_SHIFT;
 	prev_index = ra->prev_pos >> PAGE_SHIFT;
@@ -2702,7 +2702,7 @@ int filemap_page_mkwrite(struct vm_fault *vmf)
 	struct inode *inode = file_inode(vmf->vma->vm_file);
 	int ret = VM_FAULT_LOCKED;
 
-	sb_start_pagefault(inode->i_sb);
+	sb_start_pagefault(inode_sb(inode));
 	file_update_time(vmf->vma->vm_file);
 	lock_page(page);
 	if (page->mapping != inode->i_mapping) {
@@ -2718,7 +2718,7 @@ int filemap_page_mkwrite(struct vm_fault *vmf)
 	set_page_dirty(page);
 	wait_for_stable_page(page);
 out:
-	sb_end_pagefault(inode->i_sb);
+	sb_end_pagefault(inode_sb(inode));
 	return ret;
 }
 EXPORT_SYMBOL(filemap_page_mkwrite);
@@ -2965,10 +2965,10 @@ inline ssize_t generic_write_checks(struct kiocb *iocb, struct iov_iter *from)
 	 * exceeded without writing data we send a signal and return EFBIG.
 	 * Linus frestrict idea will clean these up nicely..
 	 */
-	if (unlikely(pos >= inode->i_sb->s_maxbytes))
+	if (unlikely(pos >= inode_sb(inode)->s_maxbytes))
 		return -EFBIG;
 
-	iov_iter_truncate(from, inode->i_sb->s_maxbytes - pos);
+	iov_iter_truncate(from, inode_sb(inode)->s_maxbytes - pos);
 	return iov_iter_count(from);
 }
 EXPORT_SYMBOL(generic_write_checks);
diff --git a/mm/hugetlb.c b/mm/hugetlb.c
index 976bbc5646fe..350ca2f2a05e 100644
--- a/mm/hugetlb.c
+++ b/mm/hugetlb.c
@@ -209,7 +209,7 @@ static long hugepage_subpool_put_pages(struct hugepage_subpool *spool,
 
 static inline struct hugepage_subpool *subpool_inode(struct inode *inode)
 {
-	return HUGETLBFS_SB(inode->i_sb)->spool;
+	return HUGETLBFS_SB(inode_sb(inode))->spool;
 }
 
 static inline struct hugepage_subpool *subpool_vma(struct vm_area_struct *vma)
diff --git a/mm/memory-failure.c b/mm/memory-failure.c
index 8291b75f42c8..08e2367985f8 100644
--- a/mm/memory-failure.c
+++ b/mm/memory-failure.c
@@ -98,7 +98,7 @@ static int hwpoison_filter_dev(struct page *p)
 	if (mapping == NULL || mapping->host == NULL)
 		return -EINVAL;
 
-	dev = mapping->host->i_sb->s_dev;
+	dev = inode_sb(mapping->host)->s_dev;
 	if (hwpoison_filter_dev_major != ~0U &&
 	    hwpoison_filter_dev_major != MAJOR(dev))
 		return -EINVAL;
diff --git a/mm/shmem.c b/mm/shmem.c
index b85919243399..29ad457b4774 100644
--- a/mm/shmem.c
+++ b/mm/shmem.c
@@ -192,7 +192,7 @@ static inline void shmem_unacct_blocks(unsigned long flags, long pages)
 static inline bool shmem_inode_acct_block(struct inode *inode, long pages)
 {
 	struct shmem_inode_info *info = SHMEM_I(inode);
-	struct shmem_sb_info *sbinfo = SHMEM_SB(inode->i_sb);
+	struct shmem_sb_info *sbinfo = SHMEM_SB(inode_sb(inode));
 
 	if (shmem_acct_block(info->flags, pages))
 		return false;
@@ -214,7 +214,7 @@ static inline bool shmem_inode_acct_block(struct inode *inode, long pages)
 static inline void shmem_inode_unacct_blocks(struct inode *inode, long pages)
 {
 	struct shmem_inode_info *info = SHMEM_I(inode);
-	struct shmem_sb_info *sbinfo = SHMEM_SB(inode->i_sb);
+	struct shmem_sb_info *sbinfo = SHMEM_SB(inode_sb(inode));
 
 	if (sbinfo->max_blocks)
 		percpu_counter_sub(&sbinfo->used_blocks, pages);
@@ -1002,7 +1002,7 @@ static int shmem_setattr(struct dentry *dentry, struct iattr *attr)
 {
 	struct inode *inode = d_inode(dentry);
 	struct shmem_inode_info *info = SHMEM_I(inode);
-	struct shmem_sb_info *sbinfo = SHMEM_SB(inode->i_sb);
+	struct shmem_sb_info *sbinfo = SHMEM_SB(inode_sb(inode));
 	int error;
 
 	error = setattr_prepare(dentry, attr);
@@ -1068,7 +1068,7 @@ static int shmem_setattr(struct dentry *dentry, struct iattr *attr)
 static void shmem_evict_inode(struct inode *inode)
 {
 	struct shmem_inode_info *info = SHMEM_I(inode);
-	struct shmem_sb_info *sbinfo = SHMEM_SB(inode->i_sb);
+	struct shmem_sb_info *sbinfo = SHMEM_SB(inode_sb(inode));
 
 	if (inode->i_mapping->a_ops == &shmem_aops) {
 		shmem_unacct_size(info->flags, inode->i_size);
@@ -1091,7 +1091,7 @@ static void shmem_evict_inode(struct inode *inode)
 
 	simple_xattrs_free(&info->xattrs);
 	WARN_ON(inode->i_blocks);
-	shmem_free_inode(inode->i_sb);
+	shmem_free_inode(inode_sb(inode));
 	clear_inode(inode);
 }
 
@@ -1654,7 +1654,7 @@ static int shmem_getpage_gfp(struct inode *inode, pgoff_t index,
 	 * Fast cache lookup did not find it:
 	 * bring it back from swap or allocate.
 	 */
-	sbinfo = SHMEM_SB(inode->i_sb);
+	sbinfo = SHMEM_SB(inode_sb(inode));
 	charge_mm = vma ? vma->vm_mm : current->mm;
 
 	if (swap.val) {
@@ -2056,7 +2056,7 @@ unsigned long shmem_get_unmapped_area(struct file *file,
 
 		if (file) {
 			VM_BUG_ON(file->f_op != &shmem_file_operations);
-			sb = file_inode(file)->i_sb;
+			sb = inode_sb(file_inode(file));
 		} else {
 			/*
 			 * Called directly from mm/mmap.c, or drivers/char/mem.c
@@ -2852,7 +2852,7 @@ static long shmem_fallocate(struct file *file, int mode, loff_t offset,
 							 loff_t len)
 {
 	struct inode *inode = file_inode(file);
-	struct shmem_sb_info *sbinfo = SHMEM_SB(inode->i_sb);
+	struct shmem_sb_info *sbinfo = SHMEM_SB(inode_sb(inode));
 	struct shmem_inode_info *info = SHMEM_I(inode);
 	struct shmem_falloc shmem_falloc;
 	pgoff_t start, index, end;
@@ -3010,7 +3010,7 @@ shmem_mknod(struct inode *dir, struct dentry *dentry, umode_t mode, dev_t dev)
 	struct inode *inode;
 	int error = -ENOSPC;
 
-	inode = shmem_get_inode(dir->i_sb, dir, mode, dev, VM_NORESERVE);
+	inode = shmem_get_inode(inode_sb(dir), dir, mode, dev, VM_NORESERVE);
 	if (inode) {
 		error = simple_acl_create(dir, inode);
 		if (error)
@@ -3039,7 +3039,7 @@ shmem_tmpfile(struct inode *dir, struct dentry *dentry, umode_t mode)
 	struct inode *inode;
 	int error = -ENOSPC;
 
-	inode = shmem_get_inode(dir->i_sb, dir, mode, 0, VM_NORESERVE);
+	inode = shmem_get_inode(inode_sb(dir), dir, mode, 0, VM_NORESERVE);
 	if (inode) {
 		error = security_inode_init_security(inode, dir,
 						     NULL,
@@ -3086,7 +3086,7 @@ static int shmem_link(struct dentry *old_dentry, struct inode *dir, struct dentr
 	 * but each new link needs a new dentry, pinning lowmem, and
 	 * tmpfs dentries cannot be pruned until they are unlinked.
 	 */
-	ret = shmem_reserve_inode(inode->i_sb);
+	ret = shmem_reserve_inode(inode_sb(inode));
 	if (ret)
 		goto out;
 
@@ -3105,7 +3105,7 @@ static int shmem_unlink(struct inode *dir, struct dentry *dentry)
 	struct inode *inode = d_inode(dentry);
 
 	if (inode->i_nlink > 1 && !S_ISDIR(inode->i_mode))
-		shmem_free_inode(inode->i_sb);
+		shmem_free_inode(inode_sb(inode));
 
 	dir->i_size -= BOGO_DIRENT_SIZE;
 	inode->i_ctime = dir->i_ctime = dir->i_mtime = current_time(inode);
@@ -3230,7 +3230,8 @@ static int shmem_symlink(struct inode *dir, struct dentry *dentry, const char *s
 	if (len > PAGE_SIZE)
 		return -ENAMETOOLONG;
 
-	inode = shmem_get_inode(dir->i_sb, dir, S_IFLNK|S_IRWXUGO, 0, VM_NORESERVE);
+	inode = shmem_get_inode(inode_sb(dir), dir, S_IFLNK|S_IRWXUGO, 0,
+				VM_NORESERVE);
 	if (!inode)
 		return -ENOSPC;
 
@@ -4093,7 +4094,7 @@ struct kobj_attribute shmem_enabled_attr =
 bool shmem_huge_enabled(struct vm_area_struct *vma)
 {
 	struct inode *inode = file_inode(vma->vm_file);
-	struct shmem_sb_info *sbinfo = SHMEM_SB(inode->i_sb);
+	struct shmem_sb_info *sbinfo = SHMEM_SB(inode_sb(inode));
 	loff_t i_size;
 	pgoff_t off;
 
diff --git a/mm/swapfile.c b/mm/swapfile.c
index c7a33717d079..e2316b4ad91e 100644
--- a/mm/swapfile.c
+++ b/mm/swapfile.c
@@ -2446,7 +2446,7 @@ static int swap_node(struct swap_info_struct *p)
 	if (p->bdev)
 		bdev = p->bdev;
 	else
-		bdev = p->swap_file->f_inode->i_sb->s_bdev;
+		bdev = inode_sb(p->swap_file->f_inode)->s_bdev;
 
 	return bdev ? bdev->bd_disk->node_id : NUMA_NO_NODE;
 }
@@ -2899,7 +2899,7 @@ static int claim_swapfile(struct swap_info_struct *p, struct inode *inode)
 			return error;
 		p->flags |= SWP_BLKDEV;
 	} else if (S_ISREG(inode->i_mode)) {
-		p->bdev = inode->i_sb->s_bdev;
+		p->bdev = inode_sb(inode)->s_bdev;
 		inode_lock(inode);
 		if (IS_SWAPFILE(inode))
 			return -EBUSY;
-- 
2.15.1

^ permalink raw reply	[flat|nested] 88+ messages in thread

* [PATCH 09/76] net: Use inode_sb() helper instead of inode->i_sb
  2018-05-08 18:03 [RFC][PATCH 0/76] vfs: 'views' for filesystems with more than one root Mark Fasheh
                   ` (7 preceding siblings ...)
  2018-05-08 18:03 ` [PATCH 08/76] mm: " Mark Fasheh
@ 2018-05-08 18:03 ` Mark Fasheh
  2018-05-08 18:03 ` [PATCH 10/76] security: " Mark Fasheh
                   ` (67 subsequent siblings)
  76 siblings, 0 replies; 88+ messages in thread
From: Mark Fasheh @ 2018-05-08 18:03 UTC (permalink / raw)
  To: linux-fsdevel; +Cc: linux-kernel, linux-btrfs, Mark Fasheh

Signed-off-by: Mark Fasheh <mfasheh@suse.de>
---
 net/sunrpc/auth_gss/auth_gss.c | 4 ++--
 net/sunrpc/rpc_pipe.c          | 4 ++--
 2 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/net/sunrpc/auth_gss/auth_gss.c b/net/sunrpc/auth_gss/auth_gss.c
index 9463af4b32e8..3560956424fe 100644
--- a/net/sunrpc/auth_gss/auth_gss.c
+++ b/net/sunrpc/auth_gss/auth_gss.c
@@ -769,7 +769,7 @@ gss_pipe_downcall(struct file *filp, const char __user *src, size_t mlen)
 
 static int gss_pipe_open(struct inode *inode, int new_version)
 {
-	struct net *net = inode->i_sb->s_fs_info;
+	struct net *net = inode_sb(inode)->s_fs_info;
 	struct sunrpc_net *sn = net_generic(net, sunrpc_net_id);
 	int ret = 0;
 
@@ -804,7 +804,7 @@ static int gss_pipe_open_v1(struct inode *inode)
 static void
 gss_pipe_release(struct inode *inode)
 {
-	struct net *net = inode->i_sb->s_fs_info;
+	struct net *net = inode_sb(inode)->s_fs_info;
 	struct rpc_pipe *pipe = RPC_I(inode)->pipe;
 	struct gss_upcall_msg *gss_msg;
 
diff --git a/net/sunrpc/rpc_pipe.c b/net/sunrpc/rpc_pipe.c
index fc97fc3ed637..c2851a1ee91c 100644
--- a/net/sunrpc/rpc_pipe.c
+++ b/net/sunrpc/rpc_pipe.c
@@ -497,10 +497,10 @@ static int __rpc_create_common(struct inode *dir, struct dentry *dentry,
 	struct inode *inode;
 
 	d_drop(dentry);
-	inode = rpc_get_inode(dir->i_sb, mode);
+	inode = rpc_get_inode(inode_sb(dir), mode);
 	if (!inode)
 		goto out_err;
-	inode->i_ino = iunique(dir->i_sb, 100);
+	inode->i_ino = iunique(inode_sb(dir), 100);
 	if (i_fop)
 		inode->i_fop = i_fop;
 	if (private)
-- 
2.15.1

^ permalink raw reply	[flat|nested] 88+ messages in thread

* [PATCH 10/76] security: Use inode_sb() helper instead of inode->i_sb
  2018-05-08 18:03 [RFC][PATCH 0/76] vfs: 'views' for filesystems with more than one root Mark Fasheh
                   ` (8 preceding siblings ...)
  2018-05-08 18:03 ` [PATCH 09/76] net: " Mark Fasheh
@ 2018-05-08 18:03 ` Mark Fasheh
  2018-05-08 18:03 ` [PATCH 11/76] fs/9p: " Mark Fasheh
                   ` (66 subsequent siblings)
  76 siblings, 0 replies; 88+ messages in thread
From: Mark Fasheh @ 2018-05-08 18:03 UTC (permalink / raw)
  To: linux-fsdevel; +Cc: linux-kernel, linux-btrfs, Mark Fasheh

Signed-off-by: Mark Fasheh <mfasheh@suse.de>
---
 security/apparmor/apparmorfs.c       |  4 ++--
 security/commoncap.c                 |  8 ++++----
 security/inode.c                     |  2 +-
 security/integrity/evm/evm_crypto.c  |  4 ++--
 security/integrity/ima/ima_policy.c  |  4 ++--
 security/integrity/integrity_audit.c |  2 +-
 security/lsm_audit.c                 | 10 +++++-----
 security/selinux/hooks.c             | 23 ++++++++++++-----------
 security/smack/smack_lsm.c           | 26 +++++++++++++-------------
 security/tomoyo/condition.c          |  2 +-
 10 files changed, 43 insertions(+), 42 deletions(-)

diff --git a/security/apparmor/apparmorfs.c b/security/apparmor/apparmorfs.c
index a9428daa69f3..862a4bd89597 100644
--- a/security/apparmor/apparmorfs.c
+++ b/security/apparmor/apparmorfs.c
@@ -181,7 +181,7 @@ static int __aafs_setup_d_inode(struct inode *dir, struct dentry *dentry,
 			       const struct file_operations *fops,
 			       const struct inode_operations *iops)
 {
-	struct inode *inode = new_inode(dir->i_sb);
+	struct inode *inode = new_inode(inode_sb(dir));
 
 	AA_BUG(!dir);
 	AA_BUG(!dentry);
@@ -2349,7 +2349,7 @@ static int aa_mk_null_file(struct dentry *parent)
 		error = PTR_ERR(dentry);
 		goto out;
 	}
-	inode = new_inode(parent->d_inode->i_sb);
+	inode = new_inode(inode_sb(parent->d_inode));
 	if (!inode) {
 		error = -ENOMEM;
 		goto out1;
diff --git a/security/commoncap.c b/security/commoncap.c
index 48620c93d697..f85a10da2ba2 100644
--- a/security/commoncap.c
+++ b/security/commoncap.c
@@ -400,7 +400,7 @@ int cap_inode_getsecurity(struct inode *inode, const char *name, void **buffer,
 	if (ret < 0)
 		return ret;
 
-	fs_ns = inode->i_sb->s_user_ns;
+	fs_ns = inode_sb(inode)->s_user_ns;
 	cap = (struct vfs_cap_data *) tmpbuf;
 	if (is_v2header((size_t) ret, cap)) {
 		/* If this is sizeof(vfs_cap_data) then we're ok with the
@@ -486,7 +486,7 @@ int cap_convert_nscap(struct dentry *dentry, void **ivalue, size_t size)
 	__u32 magic, nsmagic;
 	struct inode *inode = d_backing_inode(dentry);
 	struct user_namespace *task_ns = current_user_ns(),
-		*fs_ns = inode->i_sb->s_user_ns;
+		*fs_ns = inode_sb(inode)->s_user_ns;
 	kuid_t rootid;
 	size_t newsize;
 
@@ -497,7 +497,7 @@ int cap_convert_nscap(struct dentry *dentry, void **ivalue, size_t size)
 	if (!capable_wrt_inode_uidgid(inode, CAP_SETFCAP))
 		return -EPERM;
 	if (size == XATTR_CAPS_SZ_2)
-		if (ns_capable(inode->i_sb->s_user_ns, CAP_SETFCAP))
+		if (ns_capable(inode_sb(inode)->s_user_ns, CAP_SETFCAP))
 			/* user is privileged, just write the v2 */
 			return size;
 
@@ -589,7 +589,7 @@ int get_vfs_caps_from_disk(const struct dentry *dentry, struct cpu_vfs_cap_data
 	if (!inode)
 		return -ENODATA;
 
-	fs_ns = inode->i_sb->s_user_ns;
+	fs_ns = inode_sb(inode)->s_user_ns;
 	size = __vfs_getxattr((struct dentry *)dentry, inode,
 			      XATTR_NAME_CAPS, &data, XATTR_CAPS_SZ);
 	if (size == -ENODATA || size == -EOPNOTSUPP)
diff --git a/security/inode.c b/security/inode.c
index 8dd9ca8848e4..6a3d08901054 100644
--- a/security/inode.c
+++ b/security/inode.c
@@ -131,7 +131,7 @@ static struct dentry *securityfs_create_dentry(const char *name, umode_t mode,
 		goto out1;
 	}
 
-	inode = new_inode(dir->i_sb);
+	inode = new_inode(inode_sb(dir));
 	if (!inode) {
 		error = -ENOMEM;
 		goto out1;
diff --git a/security/integrity/evm/evm_crypto.c b/security/integrity/evm/evm_crypto.c
index 691f3e09154c..979bf5068d46 100644
--- a/security/integrity/evm/evm_crypto.c
+++ b/security/integrity/evm/evm_crypto.c
@@ -170,8 +170,8 @@ static void hmac_add_misc(struct shash_desc *desc, struct inode *inode,
 	crypto_shash_update(desc, (const u8 *)&hmac_misc, sizeof(hmac_misc));
 	if ((evm_hmac_attrs & EVM_ATTR_FSUUID) &&
 	    type != EVM_XATTR_PORTABLE_DIGSIG)
-		crypto_shash_update(desc, &inode->i_sb->s_uuid.b[0],
-				    sizeof(inode->i_sb->s_uuid));
+		crypto_shash_update(desc, &inode_sb(inode)->s_uuid.b[0],
+				    sizeof(inode_sb(inode)->s_uuid));
 	crypto_shash_final(desc, digest);
 }
 
diff --git a/security/integrity/ima/ima_policy.c b/security/integrity/ima/ima_policy.c
index 915f5572c6ff..61ded57e0427 100644
--- a/security/integrity/ima/ima_policy.c
+++ b/security/integrity/ima/ima_policy.c
@@ -265,10 +265,10 @@ static bool ima_match_rules(struct ima_rule_entry *rule, struct inode *inode,
 	    (!(rule->mask & mask) && func != POST_SETATTR))
 		return false;
 	if ((rule->flags & IMA_FSMAGIC)
-	    && rule->fsmagic != inode->i_sb->s_magic)
+	    && rule->fsmagic != inode_sb(inode)->s_magic)
 		return false;
 	if ((rule->flags & IMA_FSUUID) &&
-	    !uuid_equal(&rule->fsuuid, &inode->i_sb->s_uuid))
+	    !uuid_equal(&rule->fsuuid, &inode_sb(inode)->s_uuid))
 		return false;
 	if ((rule->flags & IMA_UID) && !rule->uid_op(cred->uid, rule->uid))
 		return false;
diff --git a/security/integrity/integrity_audit.c b/security/integrity/integrity_audit.c
index 90987d15b6fe..62e569589dc8 100644
--- a/security/integrity/integrity_audit.c
+++ b/security/integrity/integrity_audit.c
@@ -57,7 +57,7 @@ void integrity_audit_msg(int audit_msgno, struct inode *inode,
 	}
 	if (inode) {
 		audit_log_format(ab, " dev=");
-		audit_log_untrustedstring(ab, inode->i_sb->s_id);
+		audit_log_untrustedstring(ab, inode_sb(inode)->s_id);
 		audit_log_format(ab, " ino=%lu", inode->i_ino);
 	}
 	audit_log_format(ab, " res=%d", !result);
diff --git a/security/lsm_audit.c b/security/lsm_audit.c
index 67703dbe29ea..90d557cf7819 100644
--- a/security/lsm_audit.c
+++ b/security/lsm_audit.c
@@ -240,7 +240,7 @@ static void dump_common_audit_data(struct audit_buffer *ab,
 		inode = d_backing_inode(a->u.path.dentry);
 		if (inode) {
 			audit_log_format(ab, " dev=");
-			audit_log_untrustedstring(ab, inode->i_sb->s_id);
+			audit_log_untrustedstring(ab, inode_sb(inode)->s_id);
 			audit_log_format(ab, " ino=%lu", inode->i_ino);
 		}
 		break;
@@ -253,7 +253,7 @@ static void dump_common_audit_data(struct audit_buffer *ab,
 		inode = file_inode(a->u.file);
 		if (inode) {
 			audit_log_format(ab, " dev=");
-			audit_log_untrustedstring(ab, inode->i_sb->s_id);
+			audit_log_untrustedstring(ab, inode_sb(inode)->s_id);
 			audit_log_format(ab, " ino=%lu", inode->i_ino);
 		}
 		break;
@@ -266,7 +266,7 @@ static void dump_common_audit_data(struct audit_buffer *ab,
 		inode = a->u.op->path.dentry->d_inode;
 		if (inode) {
 			audit_log_format(ab, " dev=");
-			audit_log_untrustedstring(ab, inode->i_sb->s_id);
+			audit_log_untrustedstring(ab, inode_sb(inode)->s_id);
 			audit_log_format(ab, " ino=%lu", inode->i_ino);
 		}
 
@@ -282,7 +282,7 @@ static void dump_common_audit_data(struct audit_buffer *ab,
 		inode = d_backing_inode(a->u.dentry);
 		if (inode) {
 			audit_log_format(ab, " dev=");
-			audit_log_untrustedstring(ab, inode->i_sb->s_id);
+			audit_log_untrustedstring(ab, inode_sb(inode)->s_id);
 			audit_log_format(ab, " ino=%lu", inode->i_ino);
 		}
 		break;
@@ -300,7 +300,7 @@ static void dump_common_audit_data(struct audit_buffer *ab,
 			dput(dentry);
 		}
 		audit_log_format(ab, " dev=");
-		audit_log_untrustedstring(ab, inode->i_sb->s_id);
+		audit_log_untrustedstring(ab, inode_sb(inode)->s_id);
 		audit_log_format(ab, " ino=%lu", inode->i_ino);
 		break;
 	}
diff --git a/security/selinux/hooks.c b/security/selinux/hooks.c
index 8644d864e3c1..55bb29dd6726 100644
--- a/security/selinux/hooks.c
+++ b/security/selinux/hooks.c
@@ -331,7 +331,7 @@ static void inode_free_rcu(struct rcu_head *head)
 static void inode_free_security(struct inode *inode)
 {
 	struct inode_security_struct *isec = inode->i_security;
-	struct superblock_security_struct *sbsec = inode->i_sb->s_security;
+	struct superblock_security_struct *sbsec = inode_sb(inode)->s_security;
 
 	/*
 	 * As not all inode security structures are in a list, we check for
@@ -1500,7 +1500,7 @@ static int inode_doinit_with_dentry(struct inode *inode, struct dentry *opt_dent
 	if (isec->sclass == SECCLASS_FILE)
 		isec->sclass = inode_mode_to_security_class(inode->i_mode);
 
-	sbsec = inode->i_sb->s_security;
+	sbsec = inode_sb(inode)->s_security;
 	if (!(sbsec->flags & SE_SBINITIALIZED)) {
 		/* Defer initialization until selinux_complete_init,
 		   after the initial policy is loaded and the security
@@ -1581,7 +1581,8 @@ static int inode_doinit_with_dentry(struct inode *inode, struct dentry *opt_dent
 			if (rc != -ENODATA) {
 				printk(KERN_WARNING "SELinux: %s:  getxattr returned "
 				       "%d for dev=%s ino=%ld\n", __func__,
-				       -rc, inode->i_sb->s_id, inode->i_ino);
+				       -rc, inode_sb(inode)->s_id,
+				       inode->i_ino);
 				kfree(context);
 				goto out;
 			}
@@ -1593,7 +1594,7 @@ static int inode_doinit_with_dentry(struct inode *inode, struct dentry *opt_dent
 							     sbsec->def_sid,
 							     GFP_NOFS);
 			if (rc) {
-				char *dev = inode->i_sb->s_id;
+				char *dev = inode_sb(inode)->s_id;
 				unsigned long ino = inode->i_ino;
 
 				if (rc == -EINVAL) {
@@ -1873,7 +1874,7 @@ selinux_determine_inode_label(const struct task_security_struct *tsec,
 				 const struct qstr *name, u16 tclass,
 				 u32 *_new_isid)
 {
-	const struct superblock_security_struct *sbsec = dir->i_sb->s_security;
+	const struct superblock_security_struct *sbsec = inode_sb(dir)->s_security;
 
 	if ((sbsec->flags & SE_SBINITIALIZED) &&
 	    (sbsec->behavior == SECURITY_FS_USE_MNTPOINT)) {
@@ -1903,7 +1904,7 @@ static int may_create(struct inode *dir,
 	int rc;
 
 	dsec = inode_security(dir);
-	sbsec = dir->i_sb->s_security;
+	sbsec = inode_sb(dir)->s_security;
 
 	sid = tsec->sid;
 
@@ -2106,7 +2107,7 @@ static inline u32 open_file_to_av(struct file *file)
 	u32 av = file_to_av(file);
 	struct inode *inode = file_inode(file);
 
-	if (selinux_policycap_openperm && inode->i_sb->s_magic != SOCKFS_MAGIC)
+	if (selinux_policycap_openperm && inode_sb(inode)->s_magic != SOCKFS_MAGIC)
 		av |= FILE__OPEN;
 
 	return av;
@@ -2939,7 +2940,7 @@ static int selinux_inode_init_security(struct inode *inode, struct inode *dir,
 	int rc;
 	char *context;
 
-	sbsec = dir->i_sb->s_security;
+	sbsec = inode_sb(dir)->s_security;
 
 	newsid = tsec->create_sid;
 
@@ -3127,7 +3128,7 @@ static int selinux_inode_setattr(struct dentry *dentry, struct iattr *iattr)
 		return dentry_has_perm(cred, dentry, FILE__SETATTR);
 
 	if (selinux_policycap_openperm &&
-	    inode->i_sb->s_magic != SOCKFS_MAGIC &&
+	    inode_sb(inode)->s_magic != SOCKFS_MAGIC &&
 	    (ia_valid & ATTR_SIZE) &&
 	    !(ia_valid & ATTR_FILE))
 		av |= FILE__OPEN;
@@ -3172,7 +3173,7 @@ static int selinux_inode_setxattr(struct dentry *dentry, const char *name,
 		return dentry_has_perm(current_cred(), dentry, FILE__SETATTR);
 	}
 
-	sbsec = inode->i_sb->s_security;
+	sbsec = inode_sb(inode)->s_security;
 	if (!(sbsec->flags & SBLABEL_MNT))
 		return -EOPNOTSUPP;
 
@@ -3253,7 +3254,7 @@ static void selinux_inode_post_setxattr(struct dentry *dentry, const char *name,
 	if (rc) {
 		printk(KERN_ERR "SELinux:  unable to map context to SID"
 		       "for (%s, %lu), rc=%d\n",
-		       inode->i_sb->s_id, inode->i_ino, -rc);
+		       inode_sb(inode)->s_id, inode->i_ino, -rc);
 		return;
 	}
 
diff --git a/security/smack/smack_lsm.c b/security/smack/smack_lsm.c
index 03fdecba93bb..cf1dacb55d48 100644
--- a/security/smack/smack_lsm.c
+++ b/security/smack/smack_lsm.c
@@ -170,7 +170,7 @@ static int smk_bu_inode(struct inode *inode, int mode, int rc)
 
 	if (isp->smk_flags & SMK_INODE_IMPURE)
 		pr_info("Smack Unconfined Corruption: inode=(%s %ld) %s\n",
-			inode->i_sb->s_id, inode->i_ino, current->comm);
+			inode_sb(inode)->s_id, inode->i_ino, current->comm);
 
 	if (rc <= 0)
 		return rc;
@@ -184,7 +184,7 @@ static int smk_bu_inode(struct inode *inode, int mode, int rc)
 
 	pr_info("Smack %s: (%s %s %s) inode=(%s %ld) %s\n", smk_bu_mess[rc],
 		tsp->smk_task->smk_known, isp->smk_inode->smk_known, acc,
-		inode->i_sb->s_id, inode->i_ino, current->comm);
+		inode_sb(inode)->s_id, inode->i_ino, current->comm);
 	return 0;
 }
 #else
@@ -202,7 +202,7 @@ static int smk_bu_file(struct file *file, int mode, int rc)
 
 	if (isp->smk_flags & SMK_INODE_IMPURE)
 		pr_info("Smack Unconfined Corruption: inode=(%s %ld) %s\n",
-			inode->i_sb->s_id, inode->i_ino, current->comm);
+			inode_sb(inode)->s_id, inode->i_ino, current->comm);
 
 	if (rc <= 0)
 		return rc;
@@ -212,7 +212,7 @@ static int smk_bu_file(struct file *file, int mode, int rc)
 	smk_bu_mode(mode, acc);
 	pr_info("Smack %s: (%s %s %s) file=(%s %ld %pD) %s\n", smk_bu_mess[rc],
 		sskp->smk_known, smk_of_inode(inode)->smk_known, acc,
-		inode->i_sb->s_id, inode->i_ino, file,
+		inode_sb(inode)->s_id, inode->i_ino, file,
 		current->comm);
 	return 0;
 }
@@ -232,7 +232,7 @@ static int smk_bu_credfile(const struct cred *cred, struct file *file,
 
 	if (isp->smk_flags & SMK_INODE_IMPURE)
 		pr_info("Smack Unconfined Corruption: inode=(%s %ld) %s\n",
-			inode->i_sb->s_id, inode->i_ino, current->comm);
+			inode_sb(inode)->s_id, inode->i_ino, current->comm);
 
 	if (rc <= 0)
 		return rc;
@@ -242,7 +242,7 @@ static int smk_bu_credfile(const struct cred *cred, struct file *file,
 	smk_bu_mode(mode, acc);
 	pr_info("Smack %s: (%s %s %s) file=(%s %ld %pD) %s\n", smk_bu_mess[rc],
 		sskp->smk_known, smk_of_inode(inode)->smk_known, acc,
-		inode->i_sb->s_id, inode->i_ino, file,
+		inode_sb(inode)->s_id, inode->i_ino, file,
 		current->comm);
 	return 0;
 }
@@ -924,7 +924,7 @@ static int smack_bprm_set_creds(struct linux_binprm *bprm)
 	if (isp->smk_task == NULL || isp->smk_task == bsp->smk_task)
 		return 0;
 
-	sbsp = inode->i_sb->s_security;
+	sbsp = inode_sb(inode)->s_security;
 	if ((sbsp->smk_flags & SMK_SB_UNTRUSTED) &&
 	    isp->smk_task != sbsp->smk_root)
 		return 0;
@@ -1213,7 +1213,7 @@ static int smack_inode_rename(struct inode *old_inode,
  */
 static int smack_inode_permission(struct inode *inode, int mask)
 {
-	struct superblock_smack *sbsp = inode->i_sb->s_security;
+	struct superblock_smack *sbsp = inode_sb(inode)->s_security;
 	struct smk_audit_info ad;
 	int no_block = mask & MAY_NOT_BLOCK;
 	int rc;
@@ -1493,7 +1493,7 @@ static int smack_inode_getsecurity(struct inode *inode,
 		/*
 		 * The rest of the Smack xattrs are only on sockets.
 		 */
-		sbp = ip->i_sb;
+		sbp = inode_sb(ip);
 		if (sbp->s_magic != SOCKFS_MAGIC)
 			return -EOPNOTSUPP;
 
@@ -1737,7 +1737,7 @@ static int smack_mmap_file(struct file *file,
 	isp = file_inode(file)->i_security;
 	if (isp->smk_mmap == NULL)
 		return 0;
-	sbsp = file_inode(file)->i_sb->s_security;
+	sbsp = inode_sb(file_inode(file))->s_security;
 	if (sbsp->smk_flags & SMK_SB_UNTRUSTED &&
 	    isp->smk_mmap != sbsp->smk_root)
 		return -EACCES;
@@ -1884,7 +1884,7 @@ static int smack_file_receive(struct file *file)
 	smk_ad_init(&ad, __func__, LSM_AUDIT_DATA_PATH);
 	smk_ad_setfield_u_fs_path(&ad, file->f_path);
 
-	if (inode->i_sb->s_magic == SOCKFS_MAGIC) {
+	if (inode_sb(inode)->s_magic == SOCKFS_MAGIC) {
 		sock = SOCKET_I(inode);
 		ssp = sock->sk->sk_security;
 		tsp = current_security();
@@ -2759,7 +2759,7 @@ static int smack_inode_setsecurity(struct inode *inode, const char *name,
 	/*
 	 * The rest of the Smack xattrs are only on sockets.
 	 */
-	if (inode->i_sb->s_magic != SOCKFS_MAGIC)
+	if (inode_sb(inode)->s_magic != SOCKFS_MAGIC)
 		return -EOPNOTSUPP;
 
 	sock = SOCKET_I(inode);
@@ -3414,7 +3414,7 @@ static void smack_d_instantiate(struct dentry *opt_dentry, struct inode *inode)
 	if (isp->smk_flags & SMK_INODE_INSTANT)
 		goto unlockandout;
 
-	sbp = inode->i_sb;
+	sbp = inode_sb(inode);
 	sbsp = sbp->s_security;
 	/*
 	 * We're going to use the superblock default label
diff --git a/security/tomoyo/condition.c b/security/tomoyo/condition.c
index 8d0e1b9c9c57..3422f5f57e43 100644
--- a/security/tomoyo/condition.c
+++ b/security/tomoyo/condition.c
@@ -722,7 +722,7 @@ void tomoyo_get_attributes(struct tomoyo_obj_info *obj)
 			stat->gid  = inode->i_gid;
 			stat->ino  = inode->i_ino;
 			stat->mode = inode->i_mode;
-			stat->dev  = inode->i_sb->s_dev;
+			stat->dev  = inode_sb(inode)->s_dev;
 			stat->rdev = inode->i_rdev;
 			obj->stat_valid[i] = true;
 		}
-- 
2.15.1

^ permalink raw reply	[flat|nested] 88+ messages in thread

* [PATCH 11/76] fs/9p: Use inode_sb() helper instead of inode->i_sb
  2018-05-08 18:03 [RFC][PATCH 0/76] vfs: 'views' for filesystems with more than one root Mark Fasheh
                   ` (9 preceding siblings ...)
  2018-05-08 18:03 ` [PATCH 10/76] security: " Mark Fasheh
@ 2018-05-08 18:03 ` Mark Fasheh
  2018-05-08 18:03 ` [PATCH 12/76] fs/adfs: " Mark Fasheh
                   ` (65 subsequent siblings)
  76 siblings, 0 replies; 88+ messages in thread
From: Mark Fasheh @ 2018-05-08 18:03 UTC (permalink / raw)
  To: linux-fsdevel; +Cc: linux-kernel, linux-btrfs, Mark Fasheh

Signed-off-by: Mark Fasheh <mfasheh@suse.de>
---
 fs/9p/acl.c            |  3 ++-
 fs/9p/v9fs.h           |  2 +-
 fs/9p/vfs_inode.c      |  8 ++++----
 fs/9p/vfs_inode_dotl.c | 14 +++++++-------
 4 files changed, 14 insertions(+), 13 deletions(-)

diff --git a/fs/9p/acl.c b/fs/9p/acl.c
index 082d227fa56b..ccd91eb83725 100644
--- a/fs/9p/acl.c
+++ b/fs/9p/acl.c
@@ -266,7 +266,8 @@ static int v9fs_xattr_set_acl(const struct xattr_handler *handler,
 		if (IS_ERR(acl))
 			return PTR_ERR(acl);
 		else if (acl) {
-			retval = posix_acl_valid(inode->i_sb->s_user_ns, acl);
+			retval = posix_acl_valid(inode_sb(inode)->s_user_ns,
+						 acl);
 			if (retval)
 				goto err_out;
 		}
diff --git a/fs/9p/v9fs.h b/fs/9p/v9fs.h
index 982e017acadb..9e27ef7ebeaa 100644
--- a/fs/9p/v9fs.h
+++ b/fs/9p/v9fs.h
@@ -171,7 +171,7 @@ extern struct inode *v9fs_inode_from_fid_dotl(struct v9fs_session_info *v9ses,
 
 static inline struct v9fs_session_info *v9fs_inode2v9ses(struct inode *inode)
 {
-	return (inode->i_sb->s_fs_info);
+	return (inode_sb(inode)->s_fs_info);
 }
 
 static inline struct v9fs_session_info *v9fs_dentry2v9ses(struct dentry *dentry)
diff --git a/fs/9p/vfs_inode.c b/fs/9p/vfs_inode.c
index bdabb2765d1b..fb6220552fc6 100644
--- a/fs/9p/vfs_inode.c
+++ b/fs/9p/vfs_inode.c
@@ -690,7 +690,7 @@ v9fs_create(struct v9fs_session_info *v9ses, struct inode *dir,
 		/*
 		 * instantiate inode and assign the unopened fid to the dentry
 		 */
-		inode = v9fs_get_new_inode_from_fid(v9ses, fid, dir->i_sb);
+		inode = v9fs_get_new_inode_from_fid(v9ses, fid, inode_sb(dir));
 		if (IS_ERR(inode)) {
 			err = PTR_ERR(inode);
 			p9_debug(P9_DEBUG_VFS,
@@ -820,9 +820,9 @@ struct dentry *v9fs_vfs_lookup(struct inode *dir, struct dentry *dentry,
 	 * inode. But with cache disabled, lookup should do this.
 	 */
 	if (v9ses->cache == CACHE_LOOSE || v9ses->cache == CACHE_FSCACHE)
-		inode = v9fs_get_inode_from_fid(v9ses, fid, dir->i_sb);
+		inode = v9fs_get_inode_from_fid(v9ses, fid, inode_sb(dir));
 	else
-		inode = v9fs_get_new_inode_from_fid(v9ses, fid, dir->i_sb);
+		inode = v9fs_get_new_inode_from_fid(v9ses, fid, inode_sb(dir));
 	if (IS_ERR(inode)) {
 		p9_client_clunk(fid);
 		return ERR_CAST(inode);
@@ -1425,7 +1425,7 @@ int v9fs_refresh_inode(struct p9_fid *fid, struct inode *inode)
 	 * because we may have cached data
 	 */
 	i_size = inode->i_size;
-	v9fs_stat2inode(st, inode, inode->i_sb);
+	v9fs_stat2inode(st, inode, inode_sb(inode));
 	if (v9ses->cache == CACHE_LOOSE || v9ses->cache == CACHE_FSCACHE)
 		inode->i_size = i_size;
 	spin_unlock(&inode->i_lock);
diff --git a/fs/9p/vfs_inode_dotl.c b/fs/9p/vfs_inode_dotl.c
index 7f6ae21a27b3..ed462264239c 100644
--- a/fs/9p/vfs_inode_dotl.c
+++ b/fs/9p/vfs_inode_dotl.c
@@ -318,7 +318,7 @@ v9fs_vfs_atomic_open_dotl(struct inode *dir, struct dentry *dentry,
 		fid = NULL;
 		goto error;
 	}
-	inode = v9fs_get_new_inode_from_fid(v9ses, fid, dir->i_sb);
+	inode = v9fs_get_new_inode_from_fid(v9ses, fid, inode_sb(dir));
 	if (IS_ERR(inode)) {
 		err = PTR_ERR(inode);
 		p9_debug(P9_DEBUG_VFS, "inode creation failed %d\n", err);
@@ -435,7 +435,7 @@ static int v9fs_vfs_mkdir_dotl(struct inode *dir,
 
 	/* instantiate inode and assign the unopened fid to the dentry */
 	if (v9ses->cache == CACHE_LOOSE || v9ses->cache == CACHE_FSCACHE) {
-		inode = v9fs_get_new_inode_from_fid(v9ses, fid, dir->i_sb);
+		inode = v9fs_get_new_inode_from_fid(v9ses, fid, inode_sb(dir));
 		if (IS_ERR(inode)) {
 			err = PTR_ERR(inode);
 			p9_debug(P9_DEBUG_VFS, "inode creation failed %d\n",
@@ -453,7 +453,7 @@ static int v9fs_vfs_mkdir_dotl(struct inode *dir,
 		 * inode with stat. We need to get an inode
 		 * so that we can set the acl with dentry
 		 */
-		inode = v9fs_get_inode(dir->i_sb, mode, 0);
+		inode = v9fs_get_inode(inode_sb(dir), mode, 0);
 		if (IS_ERR(inode)) {
 			err = PTR_ERR(inode);
 			goto error;
@@ -723,7 +723,7 @@ v9fs_vfs_symlink_dotl(struct inode *dir, struct dentry *dentry,
 		}
 
 		/* instantiate inode and assign the unopened fid to dentry */
-		inode = v9fs_get_new_inode_from_fid(v9ses, fid, dir->i_sb);
+		inode = v9fs_get_new_inode_from_fid(v9ses, fid, inode_sb(dir));
 		if (IS_ERR(inode)) {
 			err = PTR_ERR(inode);
 			p9_debug(P9_DEBUG_VFS, "inode creation failed %d\n",
@@ -736,7 +736,7 @@ v9fs_vfs_symlink_dotl(struct inode *dir, struct dentry *dentry,
 		err = 0;
 	} else {
 		/* Not in cached mode. No need to populate inode with stat */
-		inode = v9fs_get_inode(dir->i_sb, S_IFLNK, 0);
+		inode = v9fs_get_inode(inode_sb(dir), S_IFLNK, 0);
 		if (IS_ERR(inode)) {
 			err = PTR_ERR(inode);
 			goto error;
@@ -864,7 +864,7 @@ v9fs_vfs_mknod_dotl(struct inode *dir, struct dentry *dentry, umode_t omode,
 
 	/* instantiate inode and assign the unopened fid to the dentry */
 	if (v9ses->cache == CACHE_LOOSE || v9ses->cache == CACHE_FSCACHE) {
-		inode = v9fs_get_new_inode_from_fid(v9ses, fid, dir->i_sb);
+		inode = v9fs_get_new_inode_from_fid(v9ses, fid, inode_sb(dir));
 		if (IS_ERR(inode)) {
 			err = PTR_ERR(inode);
 			p9_debug(P9_DEBUG_VFS, "inode creation failed %d\n",
@@ -881,7 +881,7 @@ v9fs_vfs_mknod_dotl(struct inode *dir, struct dentry *dentry, umode_t omode,
 		 * Not in cached mode. No need to populate inode with stat.
 		 * socket syscall returns a fd, so we need instantiate
 		 */
-		inode = v9fs_get_inode(dir->i_sb, mode, rdev);
+		inode = v9fs_get_inode(inode_sb(dir), mode, rdev);
 		if (IS_ERR(inode)) {
 			err = PTR_ERR(inode);
 			goto error;
-- 
2.15.1

^ permalink raw reply	[flat|nested] 88+ messages in thread

* [PATCH 12/76] fs/adfs: Use inode_sb() helper instead of inode->i_sb
  2018-05-08 18:03 [RFC][PATCH 0/76] vfs: 'views' for filesystems with more than one root Mark Fasheh
                   ` (10 preceding siblings ...)
  2018-05-08 18:03 ` [PATCH 11/76] fs/9p: " Mark Fasheh
@ 2018-05-08 18:03 ` Mark Fasheh
  2018-05-08 18:03 ` [PATCH 13/76] fs/affs: " Mark Fasheh
                   ` (64 subsequent siblings)
  76 siblings, 0 replies; 88+ messages in thread
From: Mark Fasheh @ 2018-05-08 18:03 UTC (permalink / raw)
  To: linux-fsdevel; +Cc: linux-kernel, linux-btrfs, Mark Fasheh

Signed-off-by: Mark Fasheh <mfasheh@suse.de>
---
 fs/adfs/dir.c   | 6 +++---
 fs/adfs/inode.c | 8 ++++----
 2 files changed, 7 insertions(+), 7 deletions(-)

diff --git a/fs/adfs/dir.c b/fs/adfs/dir.c
index 29444c83da48..e28357fcb2d4 100644
--- a/fs/adfs/dir.c
+++ b/fs/adfs/dir.c
@@ -20,7 +20,7 @@ static int
 adfs_readdir(struct file *file, struct dir_context *ctx)
 {
 	struct inode *inode = file_inode(file);
-	struct super_block *sb = inode->i_sb;
+	struct super_block *sb = inode_sb(inode);
 	const struct adfs_dir_ops *ops = ADFS_SB(sb)->s_dir;
 	struct object_info obj;
 	struct adfs_dir dir;
@@ -128,7 +128,7 @@ adfs_match(const struct qstr *name, struct object_info *obj)
 static int
 adfs_dir_lookup_byname(struct inode *inode, const struct qstr *name, struct object_info *obj)
 {
-	struct super_block *sb = inode->i_sb;
+	struct super_block *sb = inode_sb(inode);
 	const struct adfs_dir_ops *ops = ADFS_SB(sb)->s_dir;
 	struct adfs_dir dir;
 	int ret;
@@ -271,7 +271,7 @@ adfs_lookup(struct inode *dir, struct dentry *dentry, unsigned int flags)
 		 * This only returns NULL if get_empty_inode
 		 * fails.
 		 */
-		inode = adfs_iget(dir->i_sb, &obj);
+		inode = adfs_iget(inode_sb(dir), &obj);
 		if (inode)
 			error = 0;
 	}
diff --git a/fs/adfs/inode.c b/fs/adfs/inode.c
index 8dbd36f5e581..c946b072ef7f 100644
--- a/fs/adfs/inode.c
+++ b/fs/adfs/inode.c
@@ -23,9 +23,9 @@ adfs_get_block(struct inode *inode, sector_t block, struct buffer_head *bh,
 		if (block >= inode->i_blocks)
 			goto abort_toobig;
 
-		block = __adfs_block_map(inode->i_sb, inode->i_ino, block);
+		block = __adfs_block_map(inode_sb(inode), inode->i_ino, block);
 		if (block)
-			map_bh(bh, inode->i_sb, block);
+			map_bh(bh, inode_sb(inode), block);
 		return 0;
 	}
 	/* don't support allocation of blocks yet */
@@ -299,7 +299,7 @@ int
 adfs_notify_change(struct dentry *dentry, struct iattr *attr)
 {
 	struct inode *inode = d_inode(dentry);
-	struct super_block *sb = inode->i_sb;
+	struct super_block *sb = inode_sb(inode);
 	unsigned int ia_valid = attr->ia_valid;
 	int error;
 	
@@ -354,7 +354,7 @@ adfs_notify_change(struct dentry *dentry, struct iattr *attr)
  */
 int adfs_write_inode(struct inode *inode, struct writeback_control *wbc)
 {
-	struct super_block *sb = inode->i_sb;
+	struct super_block *sb = inode_sb(inode);
 	struct object_info obj;
 	int ret;
 
-- 
2.15.1

^ permalink raw reply	[flat|nested] 88+ messages in thread

* [PATCH 13/76] fs/affs: Use inode_sb() helper instead of inode->i_sb
  2018-05-08 18:03 [RFC][PATCH 0/76] vfs: 'views' for filesystems with more than one root Mark Fasheh
                   ` (11 preceding siblings ...)
  2018-05-08 18:03 ` [PATCH 12/76] fs/adfs: " Mark Fasheh
@ 2018-05-08 18:03 ` Mark Fasheh
  2018-05-08 18:03 ` [PATCH 14/76] fs/afs: " Mark Fasheh
                   ` (63 subsequent siblings)
  76 siblings, 0 replies; 88+ messages in thread
From: Mark Fasheh @ 2018-05-08 18:03 UTC (permalink / raw)
  To: linux-fsdevel; +Cc: linux-kernel, linux-btrfs, Mark Fasheh

Signed-off-by: Mark Fasheh <mfasheh@suse.de>
---
 fs/affs/amigaffs.c | 10 +++++-----
 fs/affs/bitmap.c   |  2 +-
 fs/affs/dir.c      |  2 +-
 fs/affs/file.c     | 28 ++++++++++++++--------------
 fs/affs/inode.c    | 16 ++++++++--------
 fs/affs/namei.c    | 12 ++++++------
 fs/affs/symlink.c  |  4 ++--
 7 files changed, 37 insertions(+), 37 deletions(-)

diff --git a/fs/affs/amigaffs.c b/fs/affs/amigaffs.c
index 14a6c1b90c9f..42dacf56dd0e 100644
--- a/fs/affs/amigaffs.c
+++ b/fs/affs/amigaffs.c
@@ -25,7 +25,7 @@
 int
 affs_insert_hash(struct inode *dir, struct buffer_head *bh)
 {
-	struct super_block *sb = dir->i_sb;
+	struct super_block *sb = inode_sb(dir);
 	struct buffer_head *dir_bh;
 	u32 ino, hash_ino;
 	int offset;
@@ -80,7 +80,7 @@ affs_remove_hash(struct inode *dir, struct buffer_head *rem_bh)
 	__be32 ino;
 	int offset, retval;
 
-	sb = dir->i_sb;
+	sb = inode_sb(dir);
 	rem_ino = rem_bh->b_blocknr;
 	offset = affs_hash_name(sb, AFFS_TAIL(sb, rem_bh)->name+1, AFFS_TAIL(sb, rem_bh)->name[0]);
 	pr_debug("%s(dir=%lu, ino=%d, hashval=%d)\n", __func__, dir->i_ino,
@@ -142,7 +142,7 @@ static int
 affs_remove_link(struct dentry *dentry)
 {
 	struct inode *dir, *inode = d_inode(dentry);
-	struct super_block *sb = inode->i_sb;
+	struct super_block *sb = inode_sb(inode);
 	struct buffer_head *bh, *link_bh = NULL;
 	u32 link_ino, ino;
 	int retval;
@@ -233,7 +233,7 @@ affs_remove_link(struct dentry *dentry)
 static int
 affs_empty_dir(struct inode *inode)
 {
-	struct super_block *sb = inode->i_sb;
+	struct super_block *sb = inode_sb(inode);
 	struct buffer_head *bh;
 	int retval, size;
 
@@ -272,7 +272,7 @@ affs_remove_header(struct dentry *dentry)
 	int retval;
 
 	dir = d_inode(dentry->d_parent);
-	sb = dir->i_sb;
+	sb = inode_sb(dir);
 
 	retval = -ENOENT;
 	inode = d_inode(dentry);
diff --git a/fs/affs/bitmap.c b/fs/affs/bitmap.c
index 5ba9ef2742f6..b6f7955680c4 100644
--- a/fs/affs/bitmap.c
+++ b/fs/affs/bitmap.c
@@ -122,7 +122,7 @@ affs_alloc_block(struct inode *inode, u32 goal)
 	u32 blk, bmap, bit, mask, mask2, tmp;
 	int i;
 
-	sb = inode->i_sb;
+	sb = inode_sb(inode);
 	sbi = AFFS_SB(sb);
 
 	pr_debug("balloc(inode=%lu,goal=%u): ", inode->i_ino, goal);
diff --git a/fs/affs/dir.c b/fs/affs/dir.c
index b2bf7016e1b3..098b52a09634 100644
--- a/fs/affs/dir.c
+++ b/fs/affs/dir.c
@@ -45,7 +45,7 @@ static int
 affs_readdir(struct file *file, struct dir_context *ctx)
 {
 	struct inode		*inode = file_inode(file);
-	struct super_block	*sb = inode->i_sb;
+	struct super_block	*sb = inode_sb(inode);
 	struct buffer_head	*dir_bh = NULL;
 	struct buffer_head	*fh_bh = NULL;
 	unsigned char		*name;
diff --git a/fs/affs/file.c b/fs/affs/file.c
index a85817f54483..e253f1137921 100644
--- a/fs/affs/file.c
+++ b/fs/affs/file.c
@@ -47,7 +47,7 @@ affs_file_release(struct inode *inode, struct file *filp)
 static int
 affs_grow_extcache(struct inode *inode, u32 lc_idx)
 {
-	struct super_block	*sb = inode->i_sb;
+	struct super_block	*sb = inode_sb(inode);
 	struct buffer_head	*bh;
 	u32 lc_max;
 	int i, j, key;
@@ -117,7 +117,7 @@ affs_grow_extcache(struct inode *inode, u32 lc_idx)
 static struct buffer_head *
 affs_alloc_extblock(struct inode *inode, struct buffer_head *bh, u32 ext)
 {
-	struct super_block *sb = inode->i_sb;
+	struct super_block *sb = inode_sb(inode);
 	struct buffer_head *new_bh;
 	u32 blocknr, tmp;
 
@@ -169,7 +169,7 @@ affs_get_extblock(struct inode *inode, u32 ext)
 static struct buffer_head *
 affs_get_extblock_slow(struct inode *inode, u32 ext)
 {
-	struct super_block *sb = inode->i_sb;
+	struct super_block *sb = inode_sb(inode);
 	struct buffer_head *bh;
 	u32 ext_key;
 	u32 lc_idx, lc_off, ac_idx;
@@ -294,7 +294,7 @@ affs_get_extblock_slow(struct inode *inode, u32 ext)
 static int
 affs_get_block(struct inode *inode, sector_t block, struct buffer_head *bh_result, int create)
 {
-	struct super_block	*sb = inode->i_sb;
+	struct super_block	*sb = inode_sb(inode);
 	struct buffer_head	*ext_bh;
 	u32			 ext;
 
@@ -353,7 +353,7 @@ affs_get_block(struct inode *inode, sector_t block, struct buffer_head *bh_resul
 	return 0;
 
 err_big:
-	affs_error(inode->i_sb, "get_block", "strange block request %llu",
+	affs_error(inode_sb(inode), "get_block", "strange block request %llu",
 		   (unsigned long long)block);
 	return -EIO;
 err_ext:
@@ -451,7 +451,7 @@ affs_bread_ino(struct inode *inode, int block, int create)
 	tmp_bh.b_state = 0;
 	err = affs_get_block(inode, block, &tmp_bh, create);
 	if (!err) {
-		bh = affs_bread(inode->i_sb, tmp_bh.b_blocknr);
+		bh = affs_bread(inode_sb(inode), tmp_bh.b_blocknr);
 		if (bh) {
 			bh->b_state |= tmp_bh.b_state;
 			return bh;
@@ -470,7 +470,7 @@ affs_getzeroblk_ino(struct inode *inode, int block)
 	tmp_bh.b_state = 0;
 	err = affs_get_block(inode, block, &tmp_bh, 1);
 	if (!err) {
-		bh = affs_getzeroblk(inode->i_sb, tmp_bh.b_blocknr);
+		bh = affs_getzeroblk(inode_sb(inode), tmp_bh.b_blocknr);
 		if (bh) {
 			bh->b_state |= tmp_bh.b_state;
 			return bh;
@@ -489,7 +489,7 @@ affs_getemptyblk_ino(struct inode *inode, int block)
 	tmp_bh.b_state = 0;
 	err = affs_get_block(inode, block, &tmp_bh, 1);
 	if (!err) {
-		bh = affs_getemptyblk(inode->i_sb, tmp_bh.b_blocknr);
+		bh = affs_getemptyblk(inode_sb(inode), tmp_bh.b_blocknr);
 		if (bh) {
 			bh->b_state |= tmp_bh.b_state;
 			return bh;
@@ -503,7 +503,7 @@ static int
 affs_do_readpage_ofs(struct page *page, unsigned to, int create)
 {
 	struct inode *inode = page->mapping->host;
-	struct super_block *sb = inode->i_sb;
+	struct super_block *sb = inode_sb(inode);
 	struct buffer_head *bh;
 	char *data;
 	unsigned pos = 0;
@@ -539,7 +539,7 @@ affs_do_readpage_ofs(struct page *page, unsigned to, int create)
 static int
 affs_extent_file_ofs(struct inode *inode, u32 newsize)
 {
-	struct super_block *sb = inode->i_sb;
+	struct super_block *sb = inode_sb(inode);
 	struct buffer_head *bh, *prev_bh;
 	u32 bidx, boff;
 	u32 size, bsize;
@@ -671,7 +671,7 @@ static int affs_write_end_ofs(struct file *file, struct address_space *mapping,
 				struct page *page, void *fsdata)
 {
 	struct inode *inode = mapping->host;
-	struct super_block *sb = inode->i_sb;
+	struct super_block *sb = inode_sb(inode);
 	struct buffer_head *bh, *prev_bh;
 	char *data;
 	u32 bidx, boff, bsize;
@@ -819,7 +819,7 @@ const struct address_space_operations affs_aops_ofs = {
 void
 affs_free_prealloc(struct inode *inode)
 {
-	struct super_block *sb = inode->i_sb;
+	struct super_block *sb = inode_sb(inode);
 
 	pr_debug("free_prealloc(ino=%lu)\n", inode->i_ino);
 
@@ -834,7 +834,7 @@ affs_free_prealloc(struct inode *inode)
 void
 affs_truncate(struct inode *inode)
 {
-	struct super_block *sb = inode->i_sb;
+	struct super_block *sb = inode_sb(inode);
 	u32 ext, ext_key;
 	u32 last_blk, blkcnt, blk;
 	u32 size;
@@ -961,7 +961,7 @@ int affs_file_fsync(struct file *filp, loff_t start, loff_t end, int datasync)
 
 	inode_lock(inode);
 	ret = write_inode_now(inode, 0);
-	err = sync_blockdev(inode->i_sb->s_bdev);
+	err = sync_blockdev(inode_sb(inode)->s_bdev);
 	if (!ret)
 		ret = err;
 	inode_unlock(inode);
diff --git a/fs/affs/inode.c b/fs/affs/inode.c
index 73598bff8506..f64d01e33a29 100644
--- a/fs/affs/inode.c
+++ b/fs/affs/inode.c
@@ -169,7 +169,7 @@ struct inode *affs_iget(struct super_block *sb, unsigned long ino)
 int
 affs_write_inode(struct inode *inode, struct writeback_control *wbc)
 {
-	struct super_block	*sb = inode->i_sb;
+	struct super_block	*sb = inode_sb(inode);
 	struct buffer_head	*bh;
 	struct affs_tail	*tail;
 	uid_t			 uid;
@@ -228,13 +228,13 @@ affs_notify_change(struct dentry *dentry, struct iattr *attr)
 		goto out;
 
 	if (((attr->ia_valid & ATTR_UID) &&
-	      affs_test_opt(AFFS_SB(inode->i_sb)->s_flags, SF_SETUID)) ||
+	      affs_test_opt(AFFS_SB(inode_sb(inode))->s_flags, SF_SETUID)) ||
 	    ((attr->ia_valid & ATTR_GID) &&
-	      affs_test_opt(AFFS_SB(inode->i_sb)->s_flags, SF_SETGID)) ||
+	      affs_test_opt(AFFS_SB(inode_sb(inode))->s_flags, SF_SETGID)) ||
 	    ((attr->ia_valid & ATTR_MODE) &&
-	     (AFFS_SB(inode->i_sb)->s_flags &
+	     (AFFS_SB(inode_sb(inode))->s_flags &
 	      (AFFS_MOUNT_SF_SETMODE | AFFS_MOUNT_SF_IMMUTABLE)))) {
-		if (!affs_test_opt(AFFS_SB(inode->i_sb)->s_flags, SF_QUIET))
+		if (!affs_test_opt(AFFS_SB(inode_sb(inode))->s_flags, SF_QUIET))
 			error = -EPERM;
 		goto out;
 	}
@@ -286,13 +286,13 @@ affs_evict_inode(struct inode *inode)
 	AFFS_I(inode)->i_ext_bh = NULL;
 
 	if (!inode->i_nlink)
-		affs_free_block(inode->i_sb, inode->i_ino);
+		affs_free_block(inode_sb(inode), inode->i_ino);
 }
 
 struct inode *
 affs_new_inode(struct inode *dir)
 {
-	struct super_block	*sb = dir->i_sb;
+	struct super_block	*sb = inode_sb(dir);
 	struct inode		*inode;
 	u32			 block;
 	struct buffer_head	*bh;
@@ -349,7 +349,7 @@ affs_new_inode(struct inode *dir)
 int
 affs_add_entry(struct inode *dir, struct inode *inode, struct dentry *dentry, s32 type)
 {
-	struct super_block *sb = dir->i_sb;
+	struct super_block *sb = inode_sb(dir);
 	struct buffer_head *inode_bh = NULL;
 	struct buffer_head *bh;
 	u32 block = 0;
diff --git a/fs/affs/namei.c b/fs/affs/namei.c
index d8aa0ae3d037..3fb3c33618f6 100644
--- a/fs/affs/namei.c
+++ b/fs/affs/namei.c
@@ -169,7 +169,7 @@ affs_hash_name(struct super_block *sb, const u8 *name, unsigned int len)
 static struct buffer_head *
 affs_find_entry(struct inode *dir, struct dentry *dentry)
 {
-	struct super_block *sb = dir->i_sb;
+	struct super_block *sb = inode_sb(dir);
 	struct buffer_head *bh;
 	toupper_t toupper = affs_get_toupper(sb);
 	u32 key;
@@ -198,7 +198,7 @@ affs_find_entry(struct inode *dir, struct dentry *dentry)
 struct dentry *
 affs_lookup(struct inode *dir, struct dentry *dentry, unsigned int flags)
 {
-	struct super_block *sb = dir->i_sb;
+	struct super_block *sb = inode_sb(dir);
 	struct buffer_head *bh;
 	struct inode *inode = NULL;
 
@@ -241,7 +241,7 @@ affs_unlink(struct inode *dir, struct dentry *dentry)
 int
 affs_create(struct inode *dir, struct dentry *dentry, umode_t mode, bool excl)
 {
-	struct super_block *sb = dir->i_sb;
+	struct super_block *sb = inode_sb(dir);
 	struct inode	*inode;
 	int		 error;
 
@@ -310,7 +310,7 @@ affs_rmdir(struct inode *dir, struct dentry *dentry)
 int
 affs_symlink(struct inode *dir, struct dentry *dentry, const char *symname)
 {
-	struct super_block	*sb = dir->i_sb;
+	struct super_block	*sb = inode_sb(dir);
 	struct buffer_head	*bh;
 	struct inode		*inode;
 	char			*p;
@@ -399,7 +399,7 @@ static int
 affs_rename(struct inode *old_dir, struct dentry *old_dentry,
 	    struct inode *new_dir, struct dentry *new_dentry)
 {
-	struct super_block *sb = old_dir->i_sb;
+	struct super_block *sb = inode_sb(old_dir);
 	struct buffer_head *bh = NULL;
 	int retval;
 
@@ -447,7 +447,7 @@ affs_xrename(struct inode *old_dir, struct dentry *old_dentry,
 	     struct inode *new_dir, struct dentry *new_dentry)
 {
 
-	struct super_block *sb = old_dir->i_sb;
+	struct super_block *sb = inode_sb(old_dir);
 	struct buffer_head *bh_old = NULL;
 	struct buffer_head *bh_new = NULL;
 	int retval;
diff --git a/fs/affs/symlink.c b/fs/affs/symlink.c
index a7531b26e8f0..c82618c32843 100644
--- a/fs/affs/symlink.c
+++ b/fs/affs/symlink.c
@@ -23,7 +23,7 @@ static int affs_symlink_readpage(struct file *file, struct page *page)
 
 	pr_debug("get_link(ino=%lu)\n", inode->i_ino);
 
-	bh = affs_bread(inode->i_sb, inode->i_ino);
+	bh = affs_bread(inode_sb(inode), inode->i_ino);
 	if (!bh)
 		goto fail;
 	i  = 0;
@@ -32,7 +32,7 @@ static int affs_symlink_readpage(struct file *file, struct page *page)
 	lc = 0;
 
 	if (strchr(lf->symname,':')) {	/* Handle assign or volume name */
-		struct affs_sb_info *sbi = AFFS_SB(inode->i_sb);
+		struct affs_sb_info *sbi = AFFS_SB(inode_sb(inode));
 		char *pf;
 		spin_lock(&sbi->symlink_lock);
 		pf = sbi->s_prefix ? sbi->s_prefix : "/";
-- 
2.15.1

^ permalink raw reply	[flat|nested] 88+ messages in thread

* [PATCH 14/76] fs/afs: Use inode_sb() helper instead of inode->i_sb
  2018-05-08 18:03 [RFC][PATCH 0/76] vfs: 'views' for filesystems with more than one root Mark Fasheh
                   ` (12 preceding siblings ...)
  2018-05-08 18:03 ` [PATCH 13/76] fs/affs: " Mark Fasheh
@ 2018-05-08 18:03 ` Mark Fasheh
  2018-05-08 18:03 ` [PATCH 15/76] fs/autofs4: " Mark Fasheh
                   ` (62 subsequent siblings)
  76 siblings, 0 replies; 88+ messages in thread
From: Mark Fasheh @ 2018-05-08 18:03 UTC (permalink / raw)
  To: linux-fsdevel; +Cc: linux-kernel, linux-btrfs, Mark Fasheh

Signed-off-by: Mark Fasheh <mfasheh@suse.de>
---
 fs/afs/callback.c | 2 +-
 fs/afs/dir.c      | 8 ++++----
 fs/afs/file.c     | 2 +-
 fs/afs/write.c    | 4 ++--
 4 files changed, 8 insertions(+), 8 deletions(-)

diff --git a/fs/afs/callback.c b/fs/afs/callback.c
index f4291b576054..73371c83b646 100644
--- a/fs/afs/callback.c
+++ b/fs/afs/callback.c
@@ -63,7 +63,7 @@ int afs_register_server_cb_interest(struct afs_vnode *vnode,
 			return -ENOMEM;
 
 		refcount_set(&new->usage, 1);
-		new->sb = vnode->vfs_inode.i_sb;
+		new->sb = vnode->vfs_inode.i_view->v_sb;
 		new->vid = vnode->volume->vid;
 		new->server = afs_get_server(server);
 		INIT_LIST_HEAD(&new->cb_link);
diff --git a/fs/afs/dir.c b/fs/afs/dir.c
index ba2b458b36d1..1a828b1da90f 100644
--- a/fs/afs/dir.c
+++ b/fs/afs/dir.c
@@ -453,7 +453,7 @@ static int afs_lookup_filldir(struct dir_context *ctx, const char *name,
 static int afs_do_lookup(struct inode *dir, struct dentry *dentry,
 			 struct afs_fid *fid, struct key *key)
 {
-	struct afs_super_info *as = dir->i_sb->s_fs_info;
+	struct afs_super_info *as = inode_sb(dir)->s_fs_info;
 	struct afs_lookup_cookie cookie = {
 		.ctx.actor = afs_lookup_filldir,
 		.name = dentry->d_name,
@@ -533,7 +533,7 @@ static struct inode *afs_try_auto_mntpt(struct dentry *dentry,
 	if (ret < 0)
 		goto out;
 
-	inode = afs_iget_pseudo_dir(dir->i_sb, false);
+	inode = afs_iget_pseudo_dir(inode_sb(dir), false);
 	if (IS_ERR(inode)) {
 		ret = PTR_ERR(inode);
 		goto out;
@@ -614,7 +614,7 @@ static struct dentry *afs_lookup(struct inode *dir, struct dentry *dentry,
 	dentry->d_fsdata = (void *)(unsigned long) vnode->status.data_version;
 
 	/* instantiate the dentry */
-	inode = afs_iget(dir->i_sb, key, &fid, NULL, NULL, NULL);
+	inode = afs_iget(inode_sb(dir), key, &fid, NULL, NULL, NULL);
 	key_put(key);
 	if (IS_ERR(inode)) {
 		_leave(" = %ld", PTR_ERR(inode));
@@ -861,7 +861,7 @@ static void afs_vnode_new_inode(struct afs_fs_cursor *fc,
 
 	d_drop(new_dentry);
 
-	inode = afs_iget(fc->vnode->vfs_inode.i_sb, fc->key,
+	inode = afs_iget(fc->vnode->vfs_inode.i_view->v_sb, fc->key,
 			 newfid, newstatus, newcb, fc->cbi);
 	if (IS_ERR(inode)) {
 		/* ENOMEM or EINTR at a really inconvenient time - just abandon
diff --git a/fs/afs/file.c b/fs/afs/file.c
index a39192ced99e..1abbe9f37163 100644
--- a/fs/afs/file.c
+++ b/fs/afs/file.c
@@ -376,7 +376,7 @@ static int afs_readpage(struct file *file, struct page *page)
 		ret = afs_page_filler(key, page);
 	} else {
 		struct inode *inode = page->mapping->host;
-		key = afs_request_key(AFS_FS_S(inode->i_sb)->cell);
+		key = afs_request_key(AFS_FS_S(inode_sb(inode))->cell);
 		if (IS_ERR(key)) {
 			ret = PTR_ERR(key);
 		} else {
diff --git a/fs/afs/write.c b/fs/afs/write.c
index 9370e2feb999..df5a30e0d46e 100644
--- a/fs/afs/write.c
+++ b/fs/afs/write.c
@@ -761,7 +761,7 @@ int afs_page_mkwrite(struct vm_fault *vmf)
 	_enter("{{%x:%u}},{%lx}",
 	       vnode->fid.vid, vnode->fid.vnode, vmf->page->index);
 
-	sb_start_pagefault(inode->i_sb);
+	sb_start_pagefault(inode_sb(inode));
 
 	/* Wait for the page to be written to the cache before we allow it to
 	 * be modified.  We then assume the entire page will need writing back.
@@ -790,7 +790,7 @@ int afs_page_mkwrite(struct vm_fault *vmf)
 	SetPagePrivate(vmf->page);
 	set_page_private(vmf->page, priv);
 
-	sb_end_pagefault(inode->i_sb);
+	sb_end_pagefault(inode_sb(inode));
 	return VM_FAULT_LOCKED;
 }
 
-- 
2.15.1

^ permalink raw reply	[flat|nested] 88+ messages in thread

* [PATCH 15/76] fs/autofs4: Use inode_sb() helper instead of inode->i_sb
  2018-05-08 18:03 [RFC][PATCH 0/76] vfs: 'views' for filesystems with more than one root Mark Fasheh
                   ` (13 preceding siblings ...)
  2018-05-08 18:03 ` [PATCH 14/76] fs/afs: " Mark Fasheh
@ 2018-05-08 18:03 ` Mark Fasheh
  2018-05-08 18:03 ` [PATCH 16/76] fs/befs: " Mark Fasheh
                   ` (61 subsequent siblings)
  76 siblings, 0 replies; 88+ messages in thread
From: Mark Fasheh @ 2018-05-08 18:03 UTC (permalink / raw)
  To: linux-fsdevel; +Cc: linux-kernel, linux-btrfs, Mark Fasheh

Signed-off-by: Mark Fasheh <mfasheh@suse.de>
---
 fs/autofs4/dev-ioctl.c |  2 +-
 fs/autofs4/root.c      | 20 ++++++++++----------
 2 files changed, 11 insertions(+), 11 deletions(-)

diff --git a/fs/autofs4/dev-ioctl.c b/fs/autofs4/dev-ioctl.c
index b7c816f39404..6b28b01e5022 100644
--- a/fs/autofs4/dev-ioctl.c
+++ b/fs/autofs4/dev-ioctl.c
@@ -166,7 +166,7 @@ static struct autofs_sb_info *autofs_dev_ioctl_sbi(struct file *f)
 
 	if (f) {
 		inode = file_inode(f);
-		sbi = autofs4_sbi(inode->i_sb);
+		sbi = autofs4_sbi(inode_sb(inode));
 	}
 	return sbi;
 }
diff --git a/fs/autofs4/root.c b/fs/autofs4/root.c
index 82e8f6edfb48..41b0a0b73bce 100644
--- a/fs/autofs4/root.c
+++ b/fs/autofs4/root.c
@@ -513,7 +513,7 @@ static struct dentry *autofs4_lookup(struct inode *dir,
 	if (dentry->d_name.len > NAME_MAX)
 		return ERR_PTR(-ENAMETOOLONG);
 
-	sbi = autofs4_sbi(dir->i_sb);
+	sbi = autofs4_sbi(inode_sb(dir));
 
 	pr_debug("pid = %u, pgrp = %u, catatonic = %d, oz_mode = %d\n",
 		 current->pid, task_pgrp_nr(current), sbi->catatonic,
@@ -553,7 +553,7 @@ static int autofs4_dir_symlink(struct inode *dir,
 			       struct dentry *dentry,
 			       const char *symname)
 {
-	struct autofs_sb_info *sbi = autofs4_sbi(dir->i_sb);
+	struct autofs_sb_info *sbi = autofs4_sbi(inode_sb(dir));
 	struct autofs_info *ino = autofs4_dentry_ino(dentry);
 	struct autofs_info *p_ino;
 	struct inode *inode;
@@ -577,7 +577,7 @@ static int autofs4_dir_symlink(struct inode *dir,
 
 	strcpy(cp, symname);
 
-	inode = autofs4_get_inode(dir->i_sb, S_IFLNK | 0555);
+	inode = autofs4_get_inode(inode_sb(dir), S_IFLNK | 0555);
 	if (!inode) {
 		kfree(cp);
 		return -ENOMEM;
@@ -614,7 +614,7 @@ static int autofs4_dir_symlink(struct inode *dir,
  */
 static int autofs4_dir_unlink(struct inode *dir, struct dentry *dentry)
 {
-	struct autofs_sb_info *sbi = autofs4_sbi(dir->i_sb);
+	struct autofs_sb_info *sbi = autofs4_sbi(inode_sb(dir));
 	struct autofs_info *ino = autofs4_dentry_ino(dentry);
 	struct autofs_info *p_ino;
 
@@ -694,7 +694,7 @@ static void autofs_clear_leaf_automount_flags(struct dentry *dentry)
 
 static int autofs4_dir_rmdir(struct inode *dir, struct dentry *dentry)
 {
-	struct autofs_sb_info *sbi = autofs4_sbi(dir->i_sb);
+	struct autofs_sb_info *sbi = autofs4_sbi(inode_sb(dir));
 	struct autofs_info *ino = autofs4_dentry_ino(dentry);
 	struct autofs_info *p_ino;
 
@@ -733,7 +733,7 @@ static int autofs4_dir_rmdir(struct inode *dir, struct dentry *dentry)
 static int autofs4_dir_mkdir(struct inode *dir,
 			     struct dentry *dentry, umode_t mode)
 {
-	struct autofs_sb_info *sbi = autofs4_sbi(dir->i_sb);
+	struct autofs_sb_info *sbi = autofs4_sbi(inode_sb(dir));
 	struct autofs_info *ino = autofs4_dentry_ino(dentry);
 	struct autofs_info *p_ino;
 	struct inode *inode;
@@ -749,7 +749,7 @@ static int autofs4_dir_mkdir(struct inode *dir,
 
 	autofs4_del_active(dentry);
 
-	inode = autofs4_get_inode(dir->i_sb, S_IFDIR | 0555);
+	inode = autofs4_get_inode(inode_sb(dir), S_IFDIR | 0555);
 	if (!inode)
 		return -ENOMEM;
 	d_add(dentry, inode);
@@ -868,7 +868,7 @@ int is_autofs4_dentry(struct dentry *dentry)
 static int autofs4_root_ioctl_unlocked(struct inode *inode, struct file *filp,
 				       unsigned int cmd, unsigned long arg)
 {
-	struct autofs_sb_info *sbi = autofs4_sbi(inode->i_sb);
+	struct autofs_sb_info *sbi = autofs4_sbi(inode_sb(inode));
 	void __user *p = (void __user *)arg;
 
 	pr_debug("cmd = 0x%08x, arg = 0x%08lx, sbi = %p, pgrp = %u\n",
@@ -905,11 +905,11 @@ static int autofs4_root_ioctl_unlocked(struct inode *inode, struct file *filp,
 
 	/* return a single thing to expire */
 	case AUTOFS_IOC_EXPIRE:
-		return autofs4_expire_run(inode->i_sb,
+		return autofs4_expire_run(inode_sb(inode),
 					  filp->f_path.mnt, sbi, p);
 	/* same as above, but can send multiple expires through pipe */
 	case AUTOFS_IOC_EXPIRE_MULTI:
-		return autofs4_expire_multi(inode->i_sb,
+		return autofs4_expire_multi(inode_sb(inode),
 					    filp->f_path.mnt, sbi, p);
 
 	default:
-- 
2.15.1

^ permalink raw reply	[flat|nested] 88+ messages in thread

* [PATCH 16/76] fs/befs: Use inode_sb() helper instead of inode->i_sb
  2018-05-08 18:03 [RFC][PATCH 0/76] vfs: 'views' for filesystems with more than one root Mark Fasheh
                   ` (14 preceding siblings ...)
  2018-05-08 18:03 ` [PATCH 15/76] fs/autofs4: " Mark Fasheh
@ 2018-05-08 18:03 ` Mark Fasheh
  2018-05-08 18:03 ` [PATCH 17/76] fs/bfs: " Mark Fasheh
                   ` (60 subsequent siblings)
  76 siblings, 0 replies; 88+ messages in thread
From: Mark Fasheh @ 2018-05-08 18:03 UTC (permalink / raw)
  To: linux-fsdevel; +Cc: linux-kernel, linux-btrfs, Mark Fasheh

Signed-off-by: Mark Fasheh <mfasheh@suse.de>
---
 fs/befs/linuxvfs.c | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/fs/befs/linuxvfs.c b/fs/befs/linuxvfs.c
index af2832aaeec5..fc997025b9a0 100644
--- a/fs/befs/linuxvfs.c
+++ b/fs/befs/linuxvfs.c
@@ -131,7 +131,7 @@ static int
 befs_get_block(struct inode *inode, sector_t block,
 	       struct buffer_head *bh_result, int create)
 {
-	struct super_block *sb = inode->i_sb;
+	struct super_block *sb = inode_sb(inode);
 	befs_data_stream *ds = &BEFS_I(inode)->i_data.ds;
 	befs_block_run run = BAD_IADDR;
 	int res;
@@ -157,7 +157,7 @@ befs_get_block(struct inode *inode, sector_t block,
 
 	disk_off = (ulong) iaddr2blockno(sb, &run);
 
-	map_bh(bh_result, inode->i_sb, disk_off);
+	map_bh(bh_result, inode_sb(inode), disk_off);
 
 	befs_debug(sb, "<--- %s for inode %lu, block %ld, disk address %lu",
 		  __func__, (unsigned long)inode->i_ino, (long)block,
@@ -170,7 +170,7 @@ static struct dentry *
 befs_lookup(struct inode *dir, struct dentry *dentry, unsigned int flags)
 {
 	struct inode *inode;
-	struct super_block *sb = dir->i_sb;
+	struct super_block *sb = inode_sb(dir);
 	const befs_data_stream *ds = &BEFS_I(dir)->i_data.ds;
 	befs_off_t offset;
 	int ret;
@@ -206,7 +206,7 @@ befs_lookup(struct inode *dir, struct dentry *dentry, unsigned int flags)
 		return ERR_PTR(-ENODATA);
 	}
 
-	inode = befs_iget(dir->i_sb, (ino_t) offset);
+	inode = befs_iget(inode_sb(dir), (ino_t) offset);
 	if (IS_ERR(inode))
 		return ERR_CAST(inode);
 
@@ -221,7 +221,7 @@ static int
 befs_readdir(struct file *file, struct dir_context *ctx)
 {
 	struct inode *inode = file_inode(file);
-	struct super_block *sb = inode->i_sb;
+	struct super_block *sb = inode_sb(inode);
 	const befs_data_stream *ds = &BEFS_I(inode)->i_data.ds;
 	befs_off_t value;
 	int result;
@@ -482,7 +482,7 @@ befs_destroy_inodecache(void)
 static int befs_symlink_readpage(struct file *unused, struct page *page)
 {
 	struct inode *inode = page->mapping->host;
-	struct super_block *sb = inode->i_sb;
+	struct super_block *sb = inode_sb(inode);
 	struct befs_inode_info *befs_ino = BEFS_I(inode);
 	befs_data_stream *data = &befs_ino->i_data.ds;
 	befs_off_t len = data->size;
-- 
2.15.1

^ permalink raw reply	[flat|nested] 88+ messages in thread

* [PATCH 17/76] fs/bfs: Use inode_sb() helper instead of inode->i_sb
  2018-05-08 18:03 [RFC][PATCH 0/76] vfs: 'views' for filesystems with more than one root Mark Fasheh
                   ` (15 preceding siblings ...)
  2018-05-08 18:03 ` [PATCH 16/76] fs/befs: " Mark Fasheh
@ 2018-05-08 18:03 ` Mark Fasheh
  2018-05-08 18:03 ` [PATCH 18/76] fs/btrfs: " Mark Fasheh
                   ` (59 subsequent siblings)
  76 siblings, 0 replies; 88+ messages in thread
From: Mark Fasheh @ 2018-05-08 18:03 UTC (permalink / raw)
  To: linux-fsdevel; +Cc: linux-kernel, linux-btrfs, Mark Fasheh

Signed-off-by: Mark Fasheh <mfasheh@suse.de>
---
 fs/bfs/dir.c   | 23 ++++++++++++-----------
 fs/bfs/file.c  |  4 ++--
 fs/bfs/inode.c | 16 +++++++++-------
 3 files changed, 23 insertions(+), 20 deletions(-)

diff --git a/fs/bfs/dir.c b/fs/bfs/dir.c
index ee832ca5f734..124c1eedb53c 100644
--- a/fs/bfs/dir.c
+++ b/fs/bfs/dir.c
@@ -38,14 +38,14 @@ static int bfs_readdir(struct file *f, struct dir_context *ctx)
 	if (ctx->pos & (BFS_DIRENT_SIZE - 1)) {
 		printf("Bad f_pos=%08lx for %s:%08lx\n",
 					(unsigned long)ctx->pos,
-					dir->i_sb->s_id, dir->i_ino);
+					inode_sb(dir)->s_id, dir->i_ino);
 		return -EINVAL;
 	}
 
 	while (ctx->pos < dir->i_size) {
 		offset = ctx->pos & (BFS_BSIZE - 1);
 		block = BFS_I(dir)->i_sblock + (ctx->pos >> BFS_BSIZE_BITS);
-		bh = sb_bread(dir->i_sb, block);
+		bh = sb_bread(inode_sb(dir), block);
 		if (!bh) {
 			ctx->pos += BFS_BSIZE - offset;
 			continue;
@@ -81,7 +81,7 @@ static int bfs_create(struct inode *dir, struct dentry *dentry, umode_t mode,
 {
 	int err;
 	struct inode *inode;
-	struct super_block *s = dir->i_sb;
+	struct super_block *s = inode_sb(dir);
 	struct bfs_sb_info *info = BFS_SB(s);
 	unsigned long ino;
 
@@ -130,7 +130,7 @@ static struct dentry *bfs_lookup(struct inode *dir, struct dentry *dentry,
 	struct inode *inode = NULL;
 	struct buffer_head *bh;
 	struct bfs_dirent *de;
-	struct bfs_sb_info *info = BFS_SB(dir->i_sb);
+	struct bfs_sb_info *info = BFS_SB(inode_sb(dir));
 
 	if (dentry->d_name.len > BFS_NAMELEN)
 		return ERR_PTR(-ENAMETOOLONG);
@@ -140,7 +140,7 @@ static struct dentry *bfs_lookup(struct inode *dir, struct dentry *dentry,
 	if (bh) {
 		unsigned long ino = (unsigned long)le16_to_cpu(de->ino);
 		brelse(bh);
-		inode = bfs_iget(dir->i_sb, ino);
+		inode = bfs_iget(inode_sb(dir), ino);
 		if (IS_ERR(inode)) {
 			mutex_unlock(&info->bfs_lock);
 			return ERR_CAST(inode);
@@ -155,7 +155,7 @@ static int bfs_link(struct dentry *old, struct inode *dir,
 						struct dentry *new)
 {
 	struct inode *inode = d_inode(old);
-	struct bfs_sb_info *info = BFS_SB(inode->i_sb);
+	struct bfs_sb_info *info = BFS_SB(inode_sb(inode));
 	int err;
 
 	mutex_lock(&info->bfs_lock);
@@ -180,7 +180,7 @@ static int bfs_unlink(struct inode *dir, struct dentry *dentry)
 	struct inode *inode = d_inode(dentry);
 	struct buffer_head *bh;
 	struct bfs_dirent *de;
-	struct bfs_sb_info *info = BFS_SB(inode->i_sb);
+	struct bfs_sb_info *info = BFS_SB(inode_sb(inode));
 
 	mutex_lock(&info->bfs_lock);
 	bh = bfs_find_entry(dir, dentry->d_name.name, dentry->d_name.len, &de);
@@ -189,7 +189,7 @@ static int bfs_unlink(struct inode *dir, struct dentry *dentry)
 
 	if (!inode->i_nlink) {
 		printf("unlinking non-existent file %s:%lu (nlink=%d)\n",
-					inode->i_sb->s_id, inode->i_ino,
+					inode_sb(inode)->s_id, inode->i_ino,
 					inode->i_nlink);
 		set_nlink(inode, 1);
 	}
@@ -225,7 +225,7 @@ static int bfs_rename(struct inode *old_dir, struct dentry *old_dentry,
 	if (S_ISDIR(old_inode->i_mode))
 		return -EINVAL;
 
-	info = BFS_SB(old_inode->i_sb);
+	info = BFS_SB(inode_sb(old_inode));
 
 	mutex_lock(&info->bfs_lock);
 	old_bh = bfs_find_entry(old_dir, 
@@ -296,7 +296,7 @@ static int bfs_add_entry(struct inode *dir, const unsigned char *name,
 	sblock = BFS_I(dir)->i_sblock;
 	eblock = BFS_I(dir)->i_eblock;
 	for (block = sblock; block <= eblock; block++) {
-		bh = sb_bread(dir->i_sb, block);
+		bh = sb_bread(inode_sb(dir), block);
 		if (!bh)
 			return -EIO;
 		for (off = 0; off < BFS_BSIZE; off += BFS_DIRENT_SIZE) {
@@ -345,7 +345,8 @@ static struct buffer_head *bfs_find_entry(struct inode *dir,
 
 	while (block * BFS_BSIZE + offset < dir->i_size) {
 		if (!bh) {
-			bh = sb_bread(dir->i_sb, BFS_I(dir)->i_sblock + block);
+			bh = sb_bread(inode_sb(dir),
+				      BFS_I(dir)->i_sblock + block);
 			if (!bh) {
 				block++;
 				continue;
diff --git a/fs/bfs/file.c b/fs/bfs/file.c
index 1476cdd90cfb..159ef9ebca2d 100644
--- a/fs/bfs/file.c
+++ b/fs/bfs/file.c
@@ -66,7 +66,7 @@ static int bfs_get_block(struct inode *inode, sector_t block,
 {
 	unsigned long phys;
 	int err;
-	struct super_block *sb = inode->i_sb;
+	struct super_block *sb = inode_sb(inode);
 	struct bfs_sb_info *info = BFS_SB(sb);
 	struct bfs_inode_info *bi = BFS_I(inode);
 
@@ -122,7 +122,7 @@ static int bfs_get_block(struct inode *inode, sector_t block,
 	}
 
 	if (bi->i_sblock) {
-		err = bfs_move_blocks(inode->i_sb, bi->i_sblock, 
+		err = bfs_move_blocks(inode_sb(inode), bi->i_sblock, 
 						bi->i_eblock, phys);
 		if (err) {
 			dprintf("failed to move ino=%08lx -> fs corruption\n",
diff --git a/fs/bfs/inode.c b/fs/bfs/inode.c
index 9a69392f1fb3..8216f6b03fda 100644
--- a/fs/bfs/inode.c
+++ b/fs/bfs/inode.c
@@ -44,15 +44,17 @@ struct inode *bfs_iget(struct super_block *sb, unsigned long ino)
 	if (!(inode->i_state & I_NEW))
 		return inode;
 
-	if ((ino < BFS_ROOT_INO) || (ino > BFS_SB(inode->i_sb)->si_lasti)) {
-		printf("Bad inode number %s:%08lx\n", inode->i_sb->s_id, ino);
+	if ((ino < BFS_ROOT_INO) || (ino > BFS_SB(inode_sb(inode))->si_lasti)) {
+		printf("Bad inode number %s:%08lx\n", inode_sb(inode)->s_id,
+		       ino);
 		goto error;
 	}
 
 	block = (ino - BFS_ROOT_INO) / BFS_INODES_PER_BLOCK + 1;
-	bh = sb_bread(inode->i_sb, block);
+	bh = sb_bread(inode_sb(inode), block);
 	if (!bh) {
-		printf("Unable to read inode %s:%08lx\n", inode->i_sb->s_id,
+		printf("Unable to read inode %s:%08lx\n",
+									inode_sb(inode)->s_id,
 									ino);
 		goto error;
 	}
@@ -116,7 +118,7 @@ static struct bfs_inode *find_inode(struct super_block *sb, u16 ino, struct buff
 
 static int bfs_write_inode(struct inode *inode, struct writeback_control *wbc)
 {
-	struct bfs_sb_info *info = BFS_SB(inode->i_sb);
+	struct bfs_sb_info *info = BFS_SB(inode_sb(inode));
 	unsigned int ino = (u16)inode->i_ino;
         unsigned long i_sblock;
 	struct bfs_inode *di;
@@ -125,7 +127,7 @@ static int bfs_write_inode(struct inode *inode, struct writeback_control *wbc)
 
         dprintf("ino=%08x\n", ino);
 
-	di = find_inode(inode->i_sb, ino, &bh);
+	di = find_inode(inode_sb(inode), ino, &bh);
 	if (IS_ERR(di))
 		return PTR_ERR(di);
 
@@ -165,7 +167,7 @@ static void bfs_evict_inode(struct inode *inode)
 	unsigned long ino = inode->i_ino;
 	struct bfs_inode *di;
 	struct buffer_head *bh;
-	struct super_block *s = inode->i_sb;
+	struct super_block *s = inode_sb(inode);
 	struct bfs_sb_info *info = BFS_SB(s);
 	struct bfs_inode_info *bi = BFS_I(inode);
 
-- 
2.15.1

^ permalink raw reply	[flat|nested] 88+ messages in thread

* [PATCH 18/76] fs/btrfs: Use inode_sb() helper instead of inode->i_sb
  2018-05-08 18:03 [RFC][PATCH 0/76] vfs: 'views' for filesystems with more than one root Mark Fasheh
                   ` (16 preceding siblings ...)
  2018-05-08 18:03 ` [PATCH 17/76] fs/bfs: " Mark Fasheh
@ 2018-05-08 18:03 ` Mark Fasheh
  2018-05-08 18:03 ` [PATCH 19/76] fs/ceph: " Mark Fasheh
                   ` (58 subsequent siblings)
  76 siblings, 0 replies; 88+ messages in thread
From: Mark Fasheh @ 2018-05-08 18:03 UTC (permalink / raw)
  To: linux-fsdevel; +Cc: linux-kernel, linux-btrfs, Mark Fasheh

Signed-off-by: Mark Fasheh <mfasheh@suse.de>
---
 fs/btrfs/compression.c      |   4 +-
 fs/btrfs/ctree.h            |   2 +-
 fs/btrfs/delayed-inode.c    |   4 +-
 fs/btrfs/disk-io.c          |   8 +--
 fs/btrfs/export.c           |   4 +-
 fs/btrfs/extent-tree.c      |  14 ++---
 fs/btrfs/extent_io.c        |  24 ++++----
 fs/btrfs/file-item.c        |  10 ++--
 fs/btrfs/file.c             |  30 +++++-----
 fs/btrfs/free-space-cache.c |   6 +-
 fs/btrfs/inode.c            | 133 ++++++++++++++++++++++----------------------
 fs/btrfs/ioctl.c            |  72 ++++++++++++------------
 fs/btrfs/ordered-data.c     |  12 ++--
 fs/btrfs/relocation.c       |   6 +-
 fs/btrfs/tree-log.c         |   8 +--
 15 files changed, 169 insertions(+), 168 deletions(-)

diff --git a/fs/btrfs/compression.c b/fs/btrfs/compression.c
index 07d049c0c20f..63ac953b18c3 100644
--- a/fs/btrfs/compression.c
+++ b/fs/btrfs/compression.c
@@ -312,7 +312,7 @@ blk_status_t btrfs_submit_compressed_write(struct inode *inode, u64 start,
 				 unsigned long nr_pages,
 				 unsigned int write_flags)
 {
-	struct btrfs_fs_info *fs_info = btrfs_sb(inode->i_sb);
+	struct btrfs_fs_info *fs_info = btrfs_sb(inode_sb(inode));
 	struct bio *bio = NULL;
 	struct compressed_bio *cb;
 	unsigned long bytes_left;
@@ -547,7 +547,7 @@ static noinline int add_ra_bio_pages(struct inode *inode,
 blk_status_t btrfs_submit_compressed_read(struct inode *inode, struct bio *bio,
 				 int mirror_num, unsigned long bio_flags)
 {
-	struct btrfs_fs_info *fs_info = btrfs_sb(inode->i_sb);
+	struct btrfs_fs_info *fs_info = btrfs_sb(inode_sb(inode));
 	struct extent_io_tree *tree;
 	struct extent_map_tree *em_tree;
 	struct compressed_bio *cb;
diff --git a/fs/btrfs/ctree.h b/fs/btrfs/ctree.h
index da308774b8a4..a3cca35642e2 100644
--- a/fs/btrfs/ctree.h
+++ b/fs/btrfs/ctree.h
@@ -1271,7 +1271,7 @@ struct btrfs_file_private {
 
 static inline u32 btrfs_inode_sectorsize(const struct inode *inode)
 {
-	return btrfs_sb(inode->i_sb)->sectorsize;
+	return btrfs_sb(inode_sb(inode))->sectorsize;
 }
 
 static inline u32 BTRFS_LEAF_DATA_SIZE(const struct btrfs_fs_info *info)
diff --git a/fs/btrfs/delayed-inode.c b/fs/btrfs/delayed-inode.c
index 0530f6f2e4ba..adc07604156e 100644
--- a/fs/btrfs/delayed-inode.c
+++ b/fs/btrfs/delayed-inode.c
@@ -1214,7 +1214,7 @@ int btrfs_commit_inode_delayed_items(struct btrfs_trans_handle *trans,
 
 int btrfs_commit_inode_delayed_inode(struct btrfs_inode *inode)
 {
-	struct btrfs_fs_info *fs_info = btrfs_sb(inode->vfs_inode.i_sb);
+	struct btrfs_fs_info *fs_info = btrfs_sb(inode_sb(&inode->vfs_inode));
 	struct btrfs_trans_handle *trans;
 	struct btrfs_delayed_node *delayed_node = btrfs_get_delayed_node(inode);
 	struct btrfs_path *path;
@@ -1829,7 +1829,7 @@ int btrfs_delayed_update_inode(struct btrfs_trans_handle *trans,
 
 int btrfs_delayed_delete_inode_ref(struct btrfs_inode *inode)
 {
-	struct btrfs_fs_info *fs_info = btrfs_sb(inode->vfs_inode.i_sb);
+	struct btrfs_fs_info *fs_info = btrfs_sb(inode_sb(&inode->vfs_inode));
 	struct btrfs_delayed_node *delayed_node;
 
 	/*
diff --git a/fs/btrfs/disk-io.c b/fs/btrfs/disk-io.c
index 21f34ad0d411..334234da997c 100644
--- a/fs/btrfs/disk-io.c
+++ b/fs/btrfs/disk-io.c
@@ -226,7 +226,7 @@ struct extent_map *btree_get_extent(struct btrfs_inode *inode,
 		struct page *page, size_t pg_offset, u64 start, u64 len,
 		int create)
 {
-	struct btrfs_fs_info *fs_info = btrfs_sb(inode->vfs_inode.i_sb);
+	struct btrfs_fs_info *fs_info = btrfs_sb(inode_sb(&inode->vfs_inode));
 	struct extent_map_tree *em_tree = &inode->extent_tree;
 	struct extent_map *em;
 	int ret;
@@ -829,7 +829,7 @@ static blk_status_t __btree_submit_bio_done(void *private_data, struct bio *bio,
 	 * when we're called for a write, we're already in the async
 	 * submission context.  Just jump into btrfs_map_bio
 	 */
-	ret = btrfs_map_bio(btrfs_sb(inode->i_sb), bio, mirror_num, 1);
+	ret = btrfs_map_bio(btrfs_sb(inode_sb(inode)), bio, mirror_num, 1);
 	if (ret) {
 		bio->bi_status = ret;
 		bio_endio(bio);
@@ -853,7 +853,7 @@ static blk_status_t btree_submit_bio_hook(void *private_data, struct bio *bio,
 					  u64 bio_offset)
 {
 	struct inode *inode = private_data;
-	struct btrfs_fs_info *fs_info = btrfs_sb(inode->i_sb);
+	struct btrfs_fs_info *fs_info = btrfs_sb(inode_sb(inode));
 	int async = check_async_write(BTRFS_I(inode));
 	blk_status_t ret;
 
@@ -4438,7 +4438,7 @@ static int btrfs_cleanup_transaction(struct btrfs_fs_info *fs_info)
 static struct btrfs_fs_info *btree_fs_info(void *private_data)
 {
 	struct inode *inode = private_data;
-	return btrfs_sb(inode->i_sb);
+	return btrfs_sb(inode_sb(inode));
 }
 
 static const struct extent_io_ops btree_extent_io_ops = {
diff --git a/fs/btrfs/export.c b/fs/btrfs/export.c
index ddaccad469f8..2ea5b2368999 100644
--- a/fs/btrfs/export.c
+++ b/fs/btrfs/export.c
@@ -154,7 +154,7 @@ static struct dentry *btrfs_fh_to_dentry(struct super_block *sb, struct fid *fh,
 static struct dentry *btrfs_get_parent(struct dentry *child)
 {
 	struct inode *dir = d_inode(child);
-	struct btrfs_fs_info *fs_info = btrfs_sb(dir->i_sb);
+	struct btrfs_fs_info *fs_info = btrfs_sb(inode_sb(dir));
 	struct btrfs_root *root = BTRFS_I(dir)->root;
 	struct btrfs_path *path;
 	struct extent_buffer *leaf;
@@ -224,7 +224,7 @@ static int btrfs_get_name(struct dentry *parent, char *name,
 {
 	struct inode *inode = d_inode(child);
 	struct inode *dir = d_inode(parent);
-	struct btrfs_fs_info *fs_info = btrfs_sb(inode->i_sb);
+	struct btrfs_fs_info *fs_info = btrfs_sb(inode_sb(inode));
 	struct btrfs_path *path;
 	struct btrfs_root *root = BTRFS_I(dir)->root;
 	struct btrfs_inode_ref *iref;
diff --git a/fs/btrfs/extent-tree.c b/fs/btrfs/extent-tree.c
index c1618ab9fecf..1d86511aec42 100644
--- a/fs/btrfs/extent-tree.c
+++ b/fs/btrfs/extent-tree.c
@@ -4382,7 +4382,7 @@ int btrfs_alloc_data_chunk_ondemand(struct btrfs_inode *inode, u64 bytes)
 int btrfs_check_data_free_space(struct inode *inode,
 			struct extent_changeset **reserved, u64 start, u64 len)
 {
-	struct btrfs_fs_info *fs_info = btrfs_sb(inode->i_sb);
+	struct btrfs_fs_info *fs_info = btrfs_sb(inode_sb(inode));
 	int ret;
 
 	/* align the range */
@@ -4414,7 +4414,7 @@ int btrfs_check_data_free_space(struct inode *inode,
 void btrfs_free_reserved_data_space_noquota(struct inode *inode, u64 start,
 					    u64 len)
 {
-	struct btrfs_fs_info *fs_info = btrfs_sb(inode->i_sb);
+	struct btrfs_fs_info *fs_info = btrfs_sb(inode_sb(inode));
 	struct btrfs_space_info *data_sinfo;
 
 	/* Make sure the range is aligned to sectorsize */
@@ -5934,7 +5934,7 @@ void btrfs_trans_release_chunk_metadata(struct btrfs_trans_handle *trans)
 int btrfs_orphan_reserve_metadata(struct btrfs_trans_handle *trans,
 				  struct btrfs_inode *inode)
 {
-	struct btrfs_fs_info *fs_info = btrfs_sb(inode->vfs_inode.i_sb);
+	struct btrfs_fs_info *fs_info = btrfs_sb(inode_sb(&inode->vfs_inode));
 	struct btrfs_root *root = inode->root;
 	/*
 	 * We always use trans->block_rsv here as we will have reserved space
@@ -5959,7 +5959,7 @@ int btrfs_orphan_reserve_metadata(struct btrfs_trans_handle *trans,
 
 void btrfs_orphan_release_metadata(struct btrfs_inode *inode)
 {
-	struct btrfs_fs_info *fs_info = btrfs_sb(inode->vfs_inode.i_sb);
+	struct btrfs_fs_info *fs_info = btrfs_sb(inode_sb(&inode->vfs_inode));
 	struct btrfs_root *root = inode->root;
 	u64 num_bytes = btrfs_calc_trans_metadata_size(fs_info, 1);
 
@@ -6051,7 +6051,7 @@ static void btrfs_calculate_inode_block_rsv_size(struct btrfs_fs_info *fs_info,
 
 int btrfs_delalloc_reserve_metadata(struct btrfs_inode *inode, u64 num_bytes)
 {
-	struct btrfs_fs_info *fs_info = btrfs_sb(inode->vfs_inode.i_sb);
+	struct btrfs_fs_info *fs_info = btrfs_sb(inode_sb(&inode->vfs_inode));
 	struct btrfs_root *root = inode->root;
 	unsigned nr_extents;
 	enum btrfs_reserve_flush_enum flush = BTRFS_RESERVE_FLUSH_ALL;
@@ -6133,7 +6133,7 @@ int btrfs_delalloc_reserve_metadata(struct btrfs_inode *inode, u64 num_bytes)
  */
 void btrfs_delalloc_release_metadata(struct btrfs_inode *inode, u64 num_bytes)
 {
-	struct btrfs_fs_info *fs_info = btrfs_sb(inode->vfs_inode.i_sb);
+	struct btrfs_fs_info *fs_info = btrfs_sb(inode_sb(&inode->vfs_inode));
 
 	num_bytes = ALIGN(num_bytes, fs_info->sectorsize);
 	spin_lock(&inode->lock);
@@ -6160,7 +6160,7 @@ void btrfs_delalloc_release_metadata(struct btrfs_inode *inode, u64 num_bytes)
  */
 void btrfs_delalloc_release_extents(struct btrfs_inode *inode, u64 num_bytes)
 {
-	struct btrfs_fs_info *fs_info = btrfs_sb(inode->vfs_inode.i_sb);
+	struct btrfs_fs_info *fs_info = btrfs_sb(inode_sb(&inode->vfs_inode));
 	unsigned num_extents;
 
 	spin_lock(&inode->lock);
diff --git a/fs/btrfs/extent_io.c b/fs/btrfs/extent_io.c
index dfeb74a0be77..8db8041cf041 100644
--- a/fs/btrfs/extent_io.c
+++ b/fs/btrfs/extent_io.c
@@ -2174,7 +2174,7 @@ void btrfs_free_io_failure_record(struct btrfs_inode *inode, u64 start, u64 end)
 int btrfs_get_io_failure_record(struct inode *inode, u64 start, u64 end,
 		struct io_failure_record **failrec_ret)
 {
-	struct btrfs_fs_info *fs_info = btrfs_sb(inode->i_sb);
+	struct btrfs_fs_info *fs_info = btrfs_sb(inode_sb(inode));
 	struct io_failure_record *failrec;
 	struct extent_map *em;
 	struct extent_io_tree *failure_tree = &BTRFS_I(inode)->io_failure_tree;
@@ -2261,7 +2261,7 @@ int btrfs_get_io_failure_record(struct inode *inode, u64 start, u64 end,
 bool btrfs_check_repairable(struct inode *inode, unsigned failed_bio_pages,
 			   struct io_failure_record *failrec, int failed_mirror)
 {
-	struct btrfs_fs_info *fs_info = btrfs_sb(inode->i_sb);
+	struct btrfs_fs_info *fs_info = btrfs_sb(inode_sb(inode));
 	int num_copies;
 
 	num_copies = btrfs_num_copies(fs_info, failrec->logical, failrec->len);
@@ -2327,7 +2327,7 @@ struct bio *btrfs_create_repair_bio(struct inode *inode, struct bio *failed_bio,
 				    struct page *page, int pg_offset, int icsum,
 				    bio_end_io_t *endio_func, void *data)
 {
-	struct btrfs_fs_info *fs_info = btrfs_sb(inode->i_sb);
+	struct btrfs_fs_info *fs_info = btrfs_sb(inode_sb(inode));
 	struct bio *bio;
 	struct btrfs_io_bio *btrfs_failed_bio;
 	struct btrfs_io_bio *btrfs_bio;
@@ -2392,16 +2392,16 @@ static int bio_readpage_error(struct bio *failed_bio, u64 phy_offset,
 	if (failed_bio_pages > 1)
 		read_mode |= REQ_FAILFAST_DEV;
 
-	phy_offset >>= inode->i_sb->s_blocksize_bits;
+	phy_offset >>= inode_sb(inode)->s_blocksize_bits;
 	bio = btrfs_create_repair_bio(inode, failed_bio, failrec, page,
 				      start - page_offset(page),
 				      (int)phy_offset, failed_bio->bi_end_io,
 				      NULL);
 	bio_set_op_attrs(bio, REQ_OP_READ, read_mode);
 
-	btrfs_debug(btrfs_sb(inode->i_sb),
-		"Repair Read Error: submitting new read[%#x] to this_mirror=%d, in_validation=%d",
-		read_mode, failrec->this_mirror, failrec->in_validation);
+	btrfs_debug(btrfs_sb(inode_sb(inode)),
+		    "Repair Read Error: submitting new read[%#x] to this_mirror=%d, in_validation=%d",
+		    read_mode, failrec->this_mirror, failrec->in_validation);
 
 	status = tree->ops->submit_bio_hook(tree->private_data, bio, failrec->this_mirror,
 					 failrec->bio_flags, 0);
@@ -2457,7 +2457,7 @@ static void end_bio_extent_writepage(struct bio *bio)
 	bio_for_each_segment_all(bvec, bio, i) {
 		struct page *page = bvec->bv_page;
 		struct inode *inode = page->mapping->host;
-		struct btrfs_fs_info *fs_info = btrfs_sb(inode->i_sb);
+		struct btrfs_fs_info *fs_info = btrfs_sb(inode_sb(inode));
 
 		/* We always issue full-page reads, but if some block
 		 * in a page fails to read, blk_update_request() will
@@ -2528,7 +2528,7 @@ static void end_bio_extent_readpage(struct bio *bio)
 	bio_for_each_segment_all(bvec, bio, i) {
 		struct page *page = bvec->bv_page;
 		struct inode *inode = page->mapping->host;
-		struct btrfs_fs_info *fs_info = btrfs_sb(inode->i_sb);
+		struct btrfs_fs_info *fs_info = btrfs_sb(inode_sb(inode));
 
 		btrfs_debug(fs_info,
 			"end_bio_extent_readpage: bi_sector=%llu, err=%d, mirror=%u",
@@ -2900,7 +2900,7 @@ static int __do_readpage(struct extent_io_tree *tree,
 	size_t pg_offset = 0;
 	size_t iosize;
 	size_t disk_io_size;
-	size_t blocksize = inode->i_sb->s_blocksize;
+	size_t blocksize = inode_sb(inode)->s_blocksize;
 	unsigned long this_bio_flag = 0;
 
 	set_page_extent_mapped(page);
@@ -3358,7 +3358,7 @@ static noinline_for_stack int __extent_writepage_io(struct inode *inode,
 		goto done;
 	}
 
-	blocksize = inode->i_sb->s_blocksize;
+	blocksize = inode_sb(inode)->s_blocksize;
 
 	while (cur <= end) {
 		u64 em_end;
@@ -4176,7 +4176,7 @@ int extent_invalidatepage(struct extent_io_tree *tree,
 	struct extent_state *cached_state = NULL;
 	u64 start = page_offset(page);
 	u64 end = start + PAGE_SIZE - 1;
-	size_t blocksize = page->mapping->host->i_sb->s_blocksize;
+	size_t blocksize = inode_sb(page->mapping->host)->s_blocksize;
 
 	start += ALIGN(offset, blocksize);
 	if (start > end)
diff --git a/fs/btrfs/file-item.c b/fs/btrfs/file-item.c
index fdcb41002623..75f025a2bf4d 100644
--- a/fs/btrfs/file-item.c
+++ b/fs/btrfs/file-item.c
@@ -163,7 +163,7 @@ static void btrfs_io_bio_endio_readpage(struct btrfs_io_bio *bio, int err)
 static blk_status_t __btrfs_lookup_bio_sums(struct inode *inode, struct bio *bio,
 				   u64 logical_offset, u32 *dst, int dio)
 {
-	struct btrfs_fs_info *fs_info = btrfs_sb(inode->i_sb);
+	struct btrfs_fs_info *fs_info = btrfs_sb(inode_sb(inode));
 	struct bio_vec bvec;
 	struct bvec_iter iter;
 	struct btrfs_io_bio *btrfs_bio = btrfs_io_bio(bio);
@@ -185,7 +185,7 @@ static blk_status_t __btrfs_lookup_bio_sums(struct inode *inode, struct bio *bio
 	if (!path)
 		return BLK_STS_RESOURCE;
 
-	nblocks = bio->bi_iter.bi_size >> inode->i_sb->s_blocksize_bits;
+	nblocks = bio->bi_iter.bi_size >> inode_sb(inode)->s_blocksize_bits;
 	if (!dst) {
 		if (nblocks * csum_size > BTRFS_BIO_INLINE_CSUM_SIZE) {
 			btrfs_bio->csum_allocated = kmalloc_array(nblocks,
@@ -280,7 +280,7 @@ static blk_status_t __btrfs_lookup_bio_sums(struct inode *inode, struct bio *bio
 		diff = diff / fs_info->sectorsize;
 		diff = diff * csum_size;
 		count = min_t(int, nblocks, (item_last_offset - disk_bytenr) >>
-					    inode->i_sb->s_blocksize_bits);
+					    inode_sb(inode)->s_blocksize_bits);
 		read_extent_buffer(path->nodes[0], csum,
 				   ((unsigned long)item) + diff,
 				   csum_size * count);
@@ -435,7 +435,7 @@ int btrfs_lookup_csums_range(struct btrfs_root *root, u64 start, u64 end,
 blk_status_t btrfs_csum_one_bio(struct inode *inode, struct bio *bio,
 		       u64 file_start, int contig)
 {
-	struct btrfs_fs_info *fs_info = btrfs_sb(inode->i_sb);
+	struct btrfs_fs_info *fs_info = btrfs_sb(inode_sb(inode));
 	struct btrfs_ordered_sum *sums;
 	struct btrfs_ordered_extent *ordered = NULL;
 	char *data;
@@ -935,7 +935,7 @@ void btrfs_extent_item_to_extent_map(struct btrfs_inode *inode,
 				     const bool new_inline,
 				     struct extent_map *em)
 {
-	struct btrfs_fs_info *fs_info = btrfs_sb(inode->vfs_inode.i_sb);
+	struct btrfs_fs_info *fs_info = btrfs_sb(inode_sb(&inode->vfs_inode));
 	struct btrfs_root *root = inode->root;
 	struct extent_buffer *leaf = path->nodes[0];
 	const int slot = path->slots[0];
diff --git a/fs/btrfs/file.c b/fs/btrfs/file.c
index 41ab9073d1d4..4a7348aed20e 100644
--- a/fs/btrfs/file.c
+++ b/fs/btrfs/file.c
@@ -96,7 +96,7 @@ static int __compare_inode_defrag(struct inode_defrag *defrag1,
 static int __btrfs_add_inode_defrag(struct btrfs_inode *inode,
 				    struct inode_defrag *defrag)
 {
-	struct btrfs_fs_info *fs_info = btrfs_sb(inode->vfs_inode.i_sb);
+	struct btrfs_fs_info *fs_info = btrfs_sb(inode_sb(&inode->vfs_inode));
 	struct inode_defrag *entry;
 	struct rb_node **p;
 	struct rb_node *parent = NULL;
@@ -148,7 +148,7 @@ static inline int __need_auto_defrag(struct btrfs_fs_info *fs_info)
 int btrfs_add_inode_defrag(struct btrfs_trans_handle *trans,
 			   struct btrfs_inode *inode)
 {
-	struct btrfs_fs_info *fs_info = btrfs_sb(inode->vfs_inode.i_sb);
+	struct btrfs_fs_info *fs_info = btrfs_sb(inode_sb(&inode->vfs_inode));
 	struct btrfs_root *root = inode->root;
 	struct inode_defrag *defrag;
 	u64 transid;
@@ -198,7 +198,7 @@ int btrfs_add_inode_defrag(struct btrfs_trans_handle *trans,
 static void btrfs_requeue_inode_defrag(struct btrfs_inode *inode,
 				       struct inode_defrag *defrag)
 {
-	struct btrfs_fs_info *fs_info = btrfs_sb(inode->vfs_inode.i_sb);
+	struct btrfs_fs_info *fs_info = btrfs_sb(inode_sb(&inode->vfs_inode));
 	int ret;
 
 	if (!__need_auto_defrag(fs_info))
@@ -531,7 +531,7 @@ int btrfs_dirty_pages(struct inode *inode, struct page **pages,
 		      size_t num_pages, loff_t pos, size_t write_bytes,
 		      struct extent_state **cached)
 {
-	struct btrfs_fs_info *fs_info = btrfs_sb(inode->i_sb);
+	struct btrfs_fs_info *fs_info = btrfs_sb(inode_sb(inode));
 	int err = 0;
 	int i;
 	u64 num_bytes;
@@ -1146,7 +1146,7 @@ static int extent_mergeable(struct extent_buffer *leaf, int slot,
 int btrfs_mark_extent_written(struct btrfs_trans_handle *trans,
 			      struct btrfs_inode *inode, u64 start, u64 end)
 {
-	struct btrfs_fs_info *fs_info = btrfs_sb(inode->vfs_inode.i_sb);
+	struct btrfs_fs_info *fs_info = btrfs_sb(inode_sb(&inode->vfs_inode));
 	struct btrfs_root *root = inode->root;
 	struct extent_buffer *leaf;
 	struct btrfs_path *path;
@@ -1483,7 +1483,7 @@ lock_and_cleanup_extent_if_need(struct btrfs_inode *inode, struct page **pages,
 				u64 *lockstart, u64 *lockend,
 				struct extent_state **cached_state)
 {
-	struct btrfs_fs_info *fs_info = btrfs_sb(inode->vfs_inode.i_sb);
+	struct btrfs_fs_info *fs_info = btrfs_sb(inode_sb(&inode->vfs_inode));
 	u64 start_pos;
 	u64 last_pos;
 	int i;
@@ -1539,7 +1539,7 @@ lock_and_cleanup_extent_if_need(struct btrfs_inode *inode, struct page **pages,
 static noinline int check_can_nocow(struct btrfs_inode *inode, loff_t pos,
 				    size_t *write_bytes)
 {
-	struct btrfs_fs_info *fs_info = btrfs_sb(inode->vfs_inode.i_sb);
+	struct btrfs_fs_info *fs_info = btrfs_sb(inode_sb(&inode->vfs_inode));
 	struct btrfs_root *root = inode->root;
 	struct btrfs_ordered_extent *ordered;
 	u64 lockstart, lockend;
@@ -1587,7 +1587,7 @@ static noinline ssize_t __btrfs_buffered_write(struct file *file,
 					       loff_t pos)
 {
 	struct inode *inode = file_inode(file);
-	struct btrfs_fs_info *fs_info = btrfs_sb(inode->i_sb);
+	struct btrfs_fs_info *fs_info = btrfs_sb(inode_sb(inode));
 	struct btrfs_root *root = BTRFS_I(inode)->root;
 	struct page **pages = NULL;
 	struct extent_state *cached_state = NULL;
@@ -1875,7 +1875,7 @@ static ssize_t btrfs_file_write_iter(struct kiocb *iocb,
 {
 	struct file *file = iocb->ki_filp;
 	struct inode *inode = file_inode(file);
-	struct btrfs_fs_info *fs_info = btrfs_sb(inode->i_sb);
+	struct btrfs_fs_info *fs_info = btrfs_sb(inode_sb(inode));
 	struct btrfs_root *root = BTRFS_I(inode)->root;
 	u64 start_pos;
 	u64 end_pos;
@@ -2051,7 +2051,7 @@ int btrfs_sync_file(struct file *file, loff_t start, loff_t end, int datasync)
 {
 	struct dentry *dentry = file_dentry(file);
 	struct inode *inode = d_inode(dentry);
-	struct btrfs_fs_info *fs_info = btrfs_sb(inode->i_sb);
+	struct btrfs_fs_info *fs_info = btrfs_sb(inode_sb(inode));
 	struct btrfs_root *root = BTRFS_I(inode)->root;
 	struct btrfs_trans_handle *trans;
 	struct btrfs_log_ctx ctx;
@@ -2330,7 +2330,7 @@ static int fill_holes(struct btrfs_trans_handle *trans,
 		struct btrfs_inode *inode,
 		struct btrfs_path *path, u64 offset, u64 end)
 {
-	struct btrfs_fs_info *fs_info = btrfs_sb(inode->vfs_inode.i_sb);
+	struct btrfs_fs_info *fs_info = btrfs_sb(inode_sb(&inode->vfs_inode));
 	struct btrfs_root *root = inode->root;
 	struct extent_buffer *leaf;
 	struct btrfs_file_extent_item *fi;
@@ -2438,7 +2438,7 @@ static int fill_holes(struct btrfs_trans_handle *trans,
  */
 static int find_first_non_hole(struct inode *inode, u64 *start, u64 *len)
 {
-	struct btrfs_fs_info *fs_info = btrfs_sb(inode->i_sb);
+	struct btrfs_fs_info *fs_info = btrfs_sb(inode_sb(inode));
 	struct extent_map *em;
 	int ret = 0;
 
@@ -2501,7 +2501,7 @@ static int btrfs_punch_hole_lock_range(struct inode *inode,
 
 static int btrfs_punch_hole(struct inode *inode, loff_t offset, loff_t len)
 {
-	struct btrfs_fs_info *fs_info = btrfs_sb(inode->i_sb);
+	struct btrfs_fs_info *fs_info = btrfs_sb(inode_sb(inode));
 	struct btrfs_root *root = BTRFS_I(inode)->root;
 	struct extent_state *cached_state = NULL;
 	struct btrfs_path *path;
@@ -3259,7 +3259,7 @@ static long btrfs_fallocate(struct file *file, int mode,
 
 static int find_desired_extent(struct inode *inode, loff_t *offset, int whence)
 {
-	struct btrfs_fs_info *fs_info = btrfs_sb(inode->i_sb);
+	struct btrfs_fs_info *fs_info = btrfs_sb(inode_sb(inode));
 	struct extent_map *em = NULL;
 	struct extent_state *cached_state = NULL;
 	u64 lockstart;
@@ -3348,7 +3348,7 @@ static loff_t btrfs_file_llseek(struct file *file, loff_t offset, int whence)
 		}
 	}
 
-	offset = vfs_setpos(file, offset, inode->i_sb->s_maxbytes);
+	offset = vfs_setpos(file, offset, inode_sb(inode)->s_maxbytes);
 out:
 	inode_unlock(inode);
 	return offset;
diff --git a/fs/btrfs/free-space-cache.c b/fs/btrfs/free-space-cache.c
index a9f22ac50d6a..a2fd0ea7caa0 100644
--- a/fs/btrfs/free-space-cache.c
+++ b/fs/btrfs/free-space-cache.c
@@ -327,7 +327,7 @@ static int io_ctl_init(struct btrfs_io_ctl *io_ctl, struct inode *inode,
 		return -ENOMEM;
 
 	io_ctl->num_pages = num_pages;
-	io_ctl->fs_info = btrfs_sb(inode->i_sb);
+	io_ctl->fs_info = btrfs_sb(inode_sb(inode));
 	io_ctl->check_crcs = check_crcs;
 	io_ctl->inode = inode;
 
@@ -670,7 +670,7 @@ static int __load_free_space_cache(struct btrfs_root *root, struct inode *inode,
 				   struct btrfs_free_space_ctl *ctl,
 				   struct btrfs_path *path, u64 offset)
 {
-	struct btrfs_fs_info *fs_info = btrfs_sb(inode->i_sb);
+	struct btrfs_fs_info *fs_info = btrfs_sb(inode_sb(inode));
 	struct btrfs_free_space_header *header;
 	struct extent_buffer *leaf;
 	struct btrfs_io_ctl io_ctl;
@@ -1143,7 +1143,7 @@ static int __btrfs_wait_cache_io(struct btrfs_root *root,
 	if (!inode)
 		return 0;
 
-	fs_info = btrfs_sb(inode->i_sb);
+	fs_info = btrfs_sb(inode_sb(inode));
 
 	/* Flush the dirty pages in the cache file. */
 	ret = flush_dirty_cache(inode);
diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c
index f53470112670..1d4a28a4763a 100644
--- a/fs/btrfs/inode.c
+++ b/fs/btrfs/inode.c
@@ -407,7 +407,7 @@ static noinline int add_async_extent(struct async_cow *cow,
 
 static inline int inode_need_compress(struct inode *inode, u64 start, u64 end)
 {
-	struct btrfs_fs_info *fs_info = btrfs_sb(inode->i_sb);
+	struct btrfs_fs_info *fs_info = btrfs_sb(inode_sb(inode));
 
 	/* force compress */
 	if (btrfs_test_opt(fs_info, FORCE_COMPRESS))
@@ -457,7 +457,7 @@ static noinline void compress_file_range(struct inode *inode,
 					struct async_cow *async_cow,
 					int *num_added)
 {
-	struct btrfs_fs_info *fs_info = btrfs_sb(inode->i_sb);
+	struct btrfs_fs_info *fs_info = btrfs_sb(inode_sb(inode));
 	struct btrfs_root *root = BTRFS_I(inode)->root;
 	u64 blocksize = fs_info->sectorsize;
 	u64 actual_end;
@@ -725,7 +725,7 @@ static void free_async_extent_pages(struct async_extent *async_extent)
 static noinline void submit_compressed_extents(struct inode *inode,
 					      struct async_cow *async_cow)
 {
-	struct btrfs_fs_info *fs_info = btrfs_sb(inode->i_sb);
+	struct btrfs_fs_info *fs_info = btrfs_sb(inode_sb(inode));
 	struct async_extent *async_extent;
 	u64 alloc_hint = 0;
 	struct btrfs_key ins;
@@ -956,7 +956,7 @@ static noinline int cow_file_range(struct inode *inode,
 				   int *page_started, unsigned long *nr_written,
 				   int unlock, struct btrfs_dedupe_hash *hash)
 {
-	struct btrfs_fs_info *fs_info = btrfs_sb(inode->i_sb);
+	struct btrfs_fs_info *fs_info = btrfs_sb(inode_sb(inode));
 	struct btrfs_root *root = BTRFS_I(inode)->root;
 	u64 alloc_hint = 0;
 	u64 num_bytes;
@@ -1201,7 +1201,7 @@ static int cow_file_range_async(struct inode *inode, struct page *locked_page,
 				unsigned long *nr_written,
 				unsigned int write_flags)
 {
-	struct btrfs_fs_info *fs_info = btrfs_sb(inode->i_sb);
+	struct btrfs_fs_info *fs_info = btrfs_sb(inode_sb(inode));
 	struct async_cow *async_cow;
 	struct btrfs_root *root = BTRFS_I(inode)->root;
 	unsigned long nr_pages;
@@ -1277,7 +1277,7 @@ static noinline int run_delalloc_nocow(struct inode *inode,
 			      u64 start, u64 end, int *page_started, int force,
 			      unsigned long *nr_written)
 {
-	struct btrfs_fs_info *fs_info = btrfs_sb(inode->i_sb);
+	struct btrfs_fs_info *fs_info = btrfs_sb(inode_sb(inode));
 	struct btrfs_root *root = BTRFS_I(inode)->root;
 	struct extent_buffer *leaf;
 	struct btrfs_path *path;
@@ -1714,7 +1714,7 @@ static void btrfs_merge_extent_hook(void *private_data,
 static void btrfs_add_delalloc_inodes(struct btrfs_root *root,
 				      struct inode *inode)
 {
-	struct btrfs_fs_info *fs_info = btrfs_sb(inode->i_sb);
+	struct btrfs_fs_info *fs_info = btrfs_sb(inode_sb(inode));
 
 	spin_lock(&root->delalloc_lock);
 	if (list_empty(&BTRFS_I(inode)->delalloc_inodes)) {
@@ -1737,7 +1737,7 @@ static void btrfs_add_delalloc_inodes(struct btrfs_root *root,
 static void btrfs_del_delalloc_inode(struct btrfs_root *root,
 				     struct btrfs_inode *inode)
 {
-	struct btrfs_fs_info *fs_info = btrfs_sb(inode->vfs_inode.i_sb);
+	struct btrfs_fs_info *fs_info = btrfs_sb(inode_sb(&inode->vfs_inode));
 
 	spin_lock(&root->delalloc_lock);
 	if (!list_empty(&inode->delalloc_inodes)) {
@@ -1765,7 +1765,7 @@ static void btrfs_set_bit_hook(void *private_data,
 {
 	struct inode *inode = private_data;
 
-	struct btrfs_fs_info *fs_info = btrfs_sb(inode->i_sb);
+	struct btrfs_fs_info *fs_info = btrfs_sb(inode_sb(inode));
 
 	if ((*bits & EXTENT_DEFRAG) && !(*bits & EXTENT_DELALLOC))
 		WARN_ON(1);
@@ -1817,7 +1817,7 @@ static void btrfs_clear_bit_hook(void *private_data,
 				 unsigned *bits)
 {
 	struct btrfs_inode *inode = BTRFS_I((struct inode *)private_data);
-	struct btrfs_fs_info *fs_info = btrfs_sb(inode->vfs_inode.i_sb);
+	struct btrfs_fs_info *fs_info = btrfs_sb(inode_sb(&inode->vfs_inode));
 	u64 len = state->end + 1 - state->start;
 	u32 num_extents = count_max_extents(len);
 
@@ -1893,7 +1893,7 @@ int btrfs_merge_bio_hook(struct page *page, unsigned long offset,
 			 unsigned long bio_flags)
 {
 	struct inode *inode = page->mapping->host;
-	struct btrfs_fs_info *fs_info = btrfs_sb(inode->i_sb);
+	struct btrfs_fs_info *fs_info = btrfs_sb(inode_sb(inode));
 	u64 logical = (u64)bio->bi_iter.bi_sector << 9;
 	u64 length = 0;
 	u64 map_length;
@@ -1946,7 +1946,7 @@ static blk_status_t __btrfs_submit_bio_done(void *private_data, struct bio *bio,
 			  u64 bio_offset)
 {
 	struct inode *inode = private_data;
-	struct btrfs_fs_info *fs_info = btrfs_sb(inode->i_sb);
+	struct btrfs_fs_info *fs_info = btrfs_sb(inode_sb(inode));
 	blk_status_t ret;
 
 	ret = btrfs_map_bio(fs_info, bio, mirror_num, 1);
@@ -1980,7 +1980,7 @@ static blk_status_t btrfs_submit_bio_hook(void *private_data, struct bio *bio,
 				 u64 bio_offset)
 {
 	struct inode *inode = private_data;
-	struct btrfs_fs_info *fs_info = btrfs_sb(inode->i_sb);
+	struct btrfs_fs_info *fs_info = btrfs_sb(inode_sb(inode));
 	struct btrfs_root *root = BTRFS_I(inode)->root;
 	enum btrfs_wq_endio_type metadata = BTRFS_WQ_ENDIO_DATA;
 	blk_status_t ret = 0;
@@ -2159,7 +2159,7 @@ static void btrfs_writepage_fixup_worker(struct btrfs_work *work)
 static int btrfs_writepage_start_hook(struct page *page, u64 start, u64 end)
 {
 	struct inode *inode = page->mapping->host;
-	struct btrfs_fs_info *fs_info = btrfs_sb(inode->i_sb);
+	struct btrfs_fs_info *fs_info = btrfs_sb(inode_sb(inode));
 	struct btrfs_writepage_fixup *fixup;
 
 	/* this page is properly in the ordered list */
@@ -2374,7 +2374,7 @@ static noinline int record_one_backref(u64 inum, u64 offset, u64 root_id,
 	struct sa_defrag_extent_backref *backref;
 	struct extent_buffer *leaf;
 	struct inode *inode = new->inode;
-	struct btrfs_fs_info *fs_info = btrfs_sb(inode->i_sb);
+	struct btrfs_fs_info *fs_info = btrfs_sb(inode_sb(inode));
 	int slot;
 	int ret;
 	u64 extent_offset;
@@ -2485,7 +2485,7 @@ static noinline int record_one_backref(u64 inum, u64 offset, u64 root_id,
 static noinline bool record_extent_backrefs(struct btrfs_path *path,
 				   struct new_sa_defrag_extent *new)
 {
-	struct btrfs_fs_info *fs_info = btrfs_sb(new->inode->i_sb);
+	struct btrfs_fs_info *fs_info = btrfs_sb(inode_sb(new->inode));
 	struct old_sa_defrag_extent *old, *tmp;
 	int ret;
 
@@ -2548,7 +2548,7 @@ static noinline int relink_extent_backref(struct btrfs_path *path,
 	struct extent_buffer *leaf;
 	struct old_sa_defrag_extent *old = backref->old;
 	struct new_sa_defrag_extent *new = old->new;
-	struct btrfs_fs_info *fs_info = btrfs_sb(new->inode->i_sb);
+	struct btrfs_fs_info *fs_info = btrfs_sb(inode_sb(new->inode));
 	struct inode *inode;
 	struct extent_state *cached = NULL;
 	int ret = 0;
@@ -2749,7 +2749,7 @@ static void free_sa_defrag_extent(struct new_sa_defrag_extent *new)
 
 static void relink_file_extents(struct new_sa_defrag_extent *new)
 {
-	struct btrfs_fs_info *fs_info = btrfs_sb(new->inode->i_sb);
+	struct btrfs_fs_info *fs_info = btrfs_sb(inode_sb(new->inode));
 	struct btrfs_path *path;
 	struct sa_defrag_extent_backref *backref;
 	struct sa_defrag_extent_backref *prev = NULL;
@@ -2804,7 +2804,7 @@ static struct new_sa_defrag_extent *
 record_old_file_extents(struct inode *inode,
 			struct btrfs_ordered_extent *ordered)
 {
-	struct btrfs_fs_info *fs_info = btrfs_sb(inode->i_sb);
+	struct btrfs_fs_info *fs_info = btrfs_sb(inode_sb(inode));
 	struct btrfs_root *root = BTRFS_I(inode)->root;
 	struct btrfs_path *path;
 	struct btrfs_key key;
@@ -2936,7 +2936,7 @@ static void btrfs_release_delalloc_bytes(struct btrfs_fs_info *fs_info,
 static int btrfs_finish_ordered_io(struct btrfs_ordered_extent *ordered_extent)
 {
 	struct inode *inode = ordered_extent->inode;
-	struct btrfs_fs_info *fs_info = btrfs_sb(inode->i_sb);
+	struct btrfs_fs_info *fs_info = btrfs_sb(inode_sb(inode));
 	struct btrfs_root *root = BTRFS_I(inode)->root;
 	struct btrfs_trans_handle *trans = NULL;
 	struct extent_io_tree *io_tree = &BTRFS_I(inode)->io_tree;
@@ -3161,7 +3161,7 @@ static void btrfs_writepage_end_io_hook(struct page *page, u64 start, u64 end,
 				struct extent_state *state, int uptodate)
 {
 	struct inode *inode = page->mapping->host;
-	struct btrfs_fs_info *fs_info = btrfs_sb(inode->i_sb);
+	struct btrfs_fs_info *fs_info = btrfs_sb(inode_sb(inode));
 	struct btrfs_ordered_extent *ordered_extent = NULL;
 	struct btrfs_workqueue *wq;
 	btrfs_work_func_t func;
@@ -3242,14 +3242,14 @@ static int btrfs_readpage_end_io_hook(struct btrfs_io_bio *io_bio,
 		return 0;
 	}
 
-	phy_offset >>= inode->i_sb->s_blocksize_bits;
+	phy_offset >>= inode_sb(inode)->s_blocksize_bits;
 	return __readpage_endio_check(inode, io_bio, phy_offset, page, offset,
 				      start, (size_t)(end - start + 1));
 }
 
 void btrfs_add_delayed_iput(struct inode *inode)
 {
-	struct btrfs_fs_info *fs_info = btrfs_sb(inode->i_sb);
+	struct btrfs_fs_info *fs_info = btrfs_sb(inode_sb(inode));
 	struct btrfs_inode *binode = BTRFS_I(inode);
 
 	if (atomic_add_unless(&inode->i_count, -1, 1))
@@ -3346,7 +3346,7 @@ void btrfs_orphan_commit_root(struct btrfs_trans_handle *trans,
 int btrfs_orphan_add(struct btrfs_trans_handle *trans,
 		struct btrfs_inode *inode)
 {
-	struct btrfs_fs_info *fs_info = btrfs_sb(inode->vfs_inode.i_sb);
+	struct btrfs_fs_info *fs_info = btrfs_sb(inode_sb(&inode->vfs_inode));
 	struct btrfs_root *root = inode->root;
 	struct btrfs_block_rsv *block_rsv = NULL;
 	int reserve = 0;
@@ -3758,7 +3758,7 @@ static noinline int acls_after_inode_item(struct extent_buffer *leaf,
  */
 static int btrfs_read_locked_inode(struct inode *inode)
 {
-	struct btrfs_fs_info *fs_info = btrfs_sb(inode->i_sb);
+	struct btrfs_fs_info *fs_info = btrfs_sb(inode_sb(inode));
 	struct btrfs_path *path;
 	struct extent_buffer *leaf;
 	struct btrfs_inode_item *inode_item;
@@ -4774,7 +4774,7 @@ int btrfs_truncate_inode_items(struct btrfs_trans_handle *trans,
 int btrfs_truncate_block(struct inode *inode, loff_t from, loff_t len,
 			int front)
 {
-	struct btrfs_fs_info *fs_info = btrfs_sb(inode->i_sb);
+	struct btrfs_fs_info *fs_info = btrfs_sb(inode_sb(inode));
 	struct address_space *mapping = inode->i_mapping;
 	struct extent_io_tree *io_tree = &BTRFS_I(inode)->io_tree;
 	struct btrfs_ordered_extent *ordered;
@@ -4886,7 +4886,7 @@ int btrfs_truncate_block(struct inode *inode, loff_t from, loff_t len,
 static int maybe_insert_hole(struct btrfs_root *root, struct inode *inode,
 			     u64 offset, u64 len)
 {
-	struct btrfs_fs_info *fs_info = btrfs_sb(inode->i_sb);
+	struct btrfs_fs_info *fs_info = btrfs_sb(inode_sb(inode));
 	struct btrfs_trans_handle *trans;
 	int ret;
 
@@ -4935,7 +4935,7 @@ static int maybe_insert_hole(struct btrfs_root *root, struct inode *inode,
  */
 int btrfs_cont_expand(struct inode *inode, loff_t oldsize, loff_t size)
 {
-	struct btrfs_fs_info *fs_info = btrfs_sb(inode->i_sb);
+	struct btrfs_fs_info *fs_info = btrfs_sb(inode_sb(inode));
 	struct btrfs_root *root = BTRFS_I(inode)->root;
 	struct extent_io_tree *io_tree = &BTRFS_I(inode)->io_tree;
 	struct extent_map *em = NULL;
@@ -5288,7 +5288,7 @@ static void evict_inode_truncate_pages(struct inode *inode)
 
 void btrfs_evict_inode(struct inode *inode)
 {
-	struct btrfs_fs_info *fs_info = btrfs_sb(inode->i_sb);
+	struct btrfs_fs_info *fs_info = btrfs_sb(inode_sb(inode));
 	struct btrfs_trans_handle *trans;
 	struct btrfs_root *root = BTRFS_I(inode)->root;
 	struct btrfs_block_rsv *rsv, *global_rsv;
@@ -5612,7 +5612,7 @@ static void inode_tree_add(struct inode *inode)
 
 static void inode_tree_del(struct inode *inode)
 {
-	struct btrfs_fs_info *fs_info = btrfs_sb(inode->i_sb);
+	struct btrfs_fs_info *fs_info = btrfs_sb(inode_sb(inode));
 	struct btrfs_root *root = BTRFS_I(inode)->root;
 	int empty = 0;
 
@@ -5792,7 +5792,7 @@ static struct inode *new_simple_dir(struct super_block *s,
 
 struct inode *btrfs_lookup_dentry(struct inode *dir, struct dentry *dentry)
 {
-	struct btrfs_fs_info *fs_info = btrfs_sb(dir->i_sb);
+	struct btrfs_fs_info *fs_info = btrfs_sb(inode_sb(dir));
 	struct inode *inode;
 	struct btrfs_root *root = BTRFS_I(dir)->root;
 	struct btrfs_root *sub_root = root;
@@ -5811,7 +5811,7 @@ struct inode *btrfs_lookup_dentry(struct inode *dir, struct dentry *dentry)
 		return ERR_PTR(-ENOENT);
 
 	if (location.type == BTRFS_INODE_ITEM_KEY) {
-		inode = btrfs_iget(dir->i_sb, &location, root, NULL);
+		inode = btrfs_iget(inode_sb(dir), &location, root, NULL);
 		return inode;
 	}
 
@@ -5822,15 +5822,16 @@ struct inode *btrfs_lookup_dentry(struct inode *dir, struct dentry *dentry)
 		if (ret != -ENOENT)
 			inode = ERR_PTR(ret);
 		else
-			inode = new_simple_dir(dir->i_sb, &location, sub_root);
+			inode = new_simple_dir(inode_sb(dir), &location,
+					       sub_root);
 	} else {
-		inode = btrfs_iget(dir->i_sb, &location, sub_root, NULL);
+		inode = btrfs_iget(inode_sb(dir), &location, sub_root, NULL);
 	}
 	srcu_read_unlock(&fs_info->subvol_srcu, index);
 
 	if (!IS_ERR(inode) && root != sub_root) {
 		down_read(&fs_info->cleanup_work_sem);
-		if (!sb_rdonly(inode->i_sb))
+		if (!sb_rdonly(inode_sb(inode)))
 			ret = btrfs_orphan_cleanup(sub_root);
 		up_read(&fs_info->cleanup_work_sem);
 		if (ret) {
@@ -6106,7 +6107,7 @@ int btrfs_write_inode(struct inode *inode, struct writeback_control *wbc)
  */
 static int btrfs_dirty_inode(struct inode *inode)
 {
-	struct btrfs_fs_info *fs_info = btrfs_sb(inode->i_sb);
+	struct btrfs_fs_info *fs_info = btrfs_sb(inode_sb(inode));
 	struct btrfs_root *root = BTRFS_I(inode)->root;
 	struct btrfs_trans_handle *trans;
 	int ret;
@@ -6464,7 +6465,7 @@ int btrfs_add_link(struct btrfs_trans_handle *trans,
 		   struct btrfs_inode *parent_inode, struct btrfs_inode *inode,
 		   const char *name, int name_len, int add_backref, u64 index)
 {
-	struct btrfs_fs_info *fs_info = btrfs_sb(inode->vfs_inode.i_sb);
+	struct btrfs_fs_info *fs_info = btrfs_sb(inode_sb(&inode->vfs_inode));
 	int ret = 0;
 	struct btrfs_key key;
 	struct btrfs_root *root = parent_inode->root;
@@ -6545,7 +6546,7 @@ static int btrfs_add_nondir(struct btrfs_trans_handle *trans,
 static int btrfs_mknod(struct inode *dir, struct dentry *dentry,
 			umode_t mode, dev_t rdev)
 {
-	struct btrfs_fs_info *fs_info = btrfs_sb(dir->i_sb);
+	struct btrfs_fs_info *fs_info = btrfs_sb(inode_sb(dir));
 	struct btrfs_trans_handle *trans;
 	struct btrfs_root *root = BTRFS_I(dir)->root;
 	struct inode *inode = NULL;
@@ -6617,7 +6618,7 @@ static int btrfs_mknod(struct inode *dir, struct dentry *dentry,
 static int btrfs_create(struct inode *dir, struct dentry *dentry,
 			umode_t mode, bool excl)
 {
-	struct btrfs_fs_info *fs_info = btrfs_sb(dir->i_sb);
+	struct btrfs_fs_info *fs_info = btrfs_sb(inode_sb(dir));
 	struct btrfs_trans_handle *trans;
 	struct btrfs_root *root = BTRFS_I(dir)->root;
 	struct inode *inode = NULL;
@@ -6695,7 +6696,7 @@ static int btrfs_link(struct dentry *old_dentry, struct inode *dir,
 	struct btrfs_trans_handle *trans = NULL;
 	struct btrfs_root *root = BTRFS_I(dir)->root;
 	struct inode *inode = d_inode(old_dentry);
-	struct btrfs_fs_info *fs_info = btrfs_sb(inode->i_sb);
+	struct btrfs_fs_info *fs_info = btrfs_sb(inode_sb(inode));
 	u64 index;
 	int err;
 	int drop_inode = 0;
@@ -6767,7 +6768,7 @@ static int btrfs_link(struct dentry *old_dentry, struct inode *dir,
 
 static int btrfs_mkdir(struct inode *dir, struct dentry *dentry, umode_t mode)
 {
-	struct btrfs_fs_info *fs_info = btrfs_sb(dir->i_sb);
+	struct btrfs_fs_info *fs_info = btrfs_sb(inode_sb(dir));
 	struct inode *inode = NULL;
 	struct btrfs_trans_handle *trans;
 	struct btrfs_root *root = BTRFS_I(dir)->root;
@@ -6898,7 +6899,7 @@ struct extent_map *btrfs_get_extent(struct btrfs_inode *inode,
 	    size_t pg_offset, u64 start, u64 len,
 		int create)
 {
-	struct btrfs_fs_info *fs_info = btrfs_sb(inode->vfs_inode.i_sb);
+	struct btrfs_fs_info *fs_info = btrfs_sb(inode_sb(&inode->vfs_inode));
 	int ret;
 	int err = 0;
 	u64 extent_start = 0;
@@ -7279,7 +7280,7 @@ static struct extent_map *btrfs_create_dio_extent(struct inode *inode,
 static struct extent_map *btrfs_new_extent_direct(struct inode *inode,
 						  u64 start, u64 len)
 {
-	struct btrfs_fs_info *fs_info = btrfs_sb(inode->i_sb);
+	struct btrfs_fs_info *fs_info = btrfs_sb(inode_sb(inode));
 	struct btrfs_root *root = BTRFS_I(inode)->root;
 	struct extent_map *em;
 	struct btrfs_key ins;
@@ -7311,7 +7312,7 @@ noinline int can_nocow_extent(struct inode *inode, u64 offset, u64 *len,
 			      u64 *orig_start, u64 *orig_block_len,
 			      u64 *ram_bytes)
 {
-	struct btrfs_fs_info *fs_info = btrfs_sb(inode->i_sb);
+	struct btrfs_fs_info *fs_info = btrfs_sb(inode_sb(inode));
 	struct btrfs_path *path;
 	int ret;
 	struct extent_buffer *leaf;
@@ -7656,7 +7657,7 @@ static struct extent_map *create_io_em(struct inode *inode, u64 start, u64 len,
 static int btrfs_get_blocks_direct(struct inode *inode, sector_t iblock,
 				   struct buffer_head *bh_result, int create)
 {
-	struct btrfs_fs_info *fs_info = btrfs_sb(inode->i_sb);
+	struct btrfs_fs_info *fs_info = btrfs_sb(inode_sb(inode));
 	struct extent_map *em;
 	struct extent_state *cached_state = NULL;
 	struct btrfs_dio_data *dio_data = NULL;
@@ -7850,7 +7851,7 @@ static inline blk_status_t submit_dio_repair_bio(struct inode *inode,
 						 struct bio *bio,
 						 int mirror_num)
 {
-	struct btrfs_fs_info *fs_info = btrfs_sb(inode->i_sb);
+	struct btrfs_fs_info *fs_info = btrfs_sb(inode_sb(inode));
 	blk_status_t ret;
 
 	BUG_ON(bio_op(bio) == REQ_OP_WRITE);
@@ -7869,7 +7870,7 @@ static int btrfs_check_dio_repairable(struct inode *inode,
 				      struct io_failure_record *failrec,
 				      int failed_mirror)
 {
-	struct btrfs_fs_info *fs_info = btrfs_sb(inode->i_sb);
+	struct btrfs_fs_info *fs_info = btrfs_sb(inode_sb(inode));
 	int num_copies;
 
 	num_copies = btrfs_num_copies(fs_info, failrec->logical, failrec->len);
@@ -7936,7 +7937,7 @@ static blk_status_t dio_read_error(struct inode *inode, struct bio *failed_bio,
 		read_mode |= REQ_FAILFAST_DEV;
 
 	isector = start - btrfs_io_bio(failed_bio)->logical;
-	isector >>= inode->i_sb->s_blocksize_bits;
+	isector >>= inode_sb(inode)->s_blocksize_bits;
 	bio = btrfs_create_repair_bio(inode, failed_bio, failrec, page,
 				pgoff, isector, repair_endio, repair_arg);
 	bio_set_op_attrs(bio, REQ_OP_READ, read_mode);
@@ -8209,7 +8210,7 @@ static void __endio_write_update_ordered(struct inode *inode,
 					 const u64 offset, const u64 bytes,
 					 const bool uptodate)
 {
-	struct btrfs_fs_info *fs_info = btrfs_sb(inode->i_sb);
+	struct btrfs_fs_info *fs_info = btrfs_sb(inode_sb(inode));
 	struct btrfs_ordered_extent *ordered = NULL;
 	struct btrfs_workqueue *wq;
 	btrfs_work_func_t func;
@@ -8346,7 +8347,7 @@ static inline blk_status_t btrfs_lookup_and_bind_dio_csum(struct inode *inode,
 		return 0;
 
 	file_offset -= dip->logical_offset;
-	file_offset >>= inode->i_sb->s_blocksize_bits;
+	file_offset >>= inode_sb(inode)->s_blocksize_bits;
 	io_bio->csum = (u8 *)(((u32 *)orig_io_bio->csum) + file_offset);
 
 	return 0;
@@ -8356,7 +8357,7 @@ static inline blk_status_t
 __btrfs_submit_dio_bio(struct bio *bio, struct inode *inode, u64 file_offset,
 		       int async_submit)
 {
-	struct btrfs_fs_info *fs_info = btrfs_sb(inode->i_sb);
+	struct btrfs_fs_info *fs_info = btrfs_sb(inode_sb(inode));
 	struct btrfs_dio_private *dip = bio->bi_private;
 	bool write = bio_op(bio) == REQ_OP_WRITE;
 	blk_status_t ret;
@@ -8403,7 +8404,7 @@ __btrfs_submit_dio_bio(struct bio *bio, struct inode *inode, u64 file_offset,
 static int btrfs_submit_direct_hook(struct btrfs_dio_private *dip)
 {
 	struct inode *inode = dip->inode;
-	struct btrfs_fs_info *fs_info = btrfs_sb(inode->i_sb);
+	struct btrfs_fs_info *fs_info = btrfs_sb(inode_sb(inode));
 	struct bio *bio;
 	struct bio *orig_bio = dip->orig_bio;
 	u64 start_sector = orig_bio->bi_iter.bi_sector;
@@ -8639,7 +8640,7 @@ static ssize_t btrfs_direct_IO(struct kiocb *iocb, struct iov_iter *iter)
 {
 	struct file *file = iocb->ki_filp;
 	struct inode *inode = file->f_mapping->host;
-	struct btrfs_fs_info *fs_info = btrfs_sb(inode->i_sb);
+	struct btrfs_fs_info *fs_info = btrfs_sb(inode_sb(inode));
 	struct btrfs_dio_data dio_data = { 0 };
 	struct extent_changeset *data_reserved = NULL;
 	loff_t offset = iocb->ki_pos;
@@ -8963,7 +8964,7 @@ int btrfs_page_mkwrite(struct vm_fault *vmf)
 {
 	struct page *page = vmf->page;
 	struct inode *inode = file_inode(vmf->vma->vm_file);
-	struct btrfs_fs_info *fs_info = btrfs_sb(inode->i_sb);
+	struct btrfs_fs_info *fs_info = btrfs_sb(inode_sb(inode));
 	struct extent_io_tree *io_tree = &BTRFS_I(inode)->io_tree;
 	struct btrfs_ordered_extent *ordered;
 	struct extent_state *cached_state = NULL;
@@ -8980,7 +8981,7 @@ int btrfs_page_mkwrite(struct vm_fault *vmf)
 
 	reserved_space = PAGE_SIZE;
 
-	sb_start_pagefault(inode->i_sb);
+	sb_start_pagefault(inode_sb(inode));
 	page_start = page_offset(page);
 	page_end = page_start + PAGE_SIZE - 1;
 	end = page_end;
@@ -9096,7 +9097,7 @@ int btrfs_page_mkwrite(struct vm_fault *vmf)
 out_unlock:
 	if (!ret) {
 		btrfs_delalloc_release_extents(BTRFS_I(inode), PAGE_SIZE);
-		sb_end_pagefault(inode->i_sb);
+		sb_end_pagefault(inode_sb(inode));
 		extent_changeset_free(data_reserved);
 		return VM_FAULT_LOCKED;
 	}
@@ -9106,14 +9107,14 @@ int btrfs_page_mkwrite(struct vm_fault *vmf)
 	btrfs_delalloc_release_space(inode, data_reserved, page_start,
 				     reserved_space);
 out_noreserve:
-	sb_end_pagefault(inode->i_sb);
+	sb_end_pagefault(inode_sb(inode));
 	extent_changeset_free(data_reserved);
 	return ret;
 }
 
 static int btrfs_truncate(struct inode *inode)
 {
-	struct btrfs_fs_info *fs_info = btrfs_sb(inode->i_sb);
+	struct btrfs_fs_info *fs_info = btrfs_sb(inode_sb(inode));
 	struct btrfs_root *root = BTRFS_I(inode)->root;
 	struct btrfs_block_rsv *rsv;
 	int ret = 0;
@@ -9385,7 +9386,7 @@ static void btrfs_i_callback(struct rcu_head *head)
 
 void btrfs_destroy_inode(struct inode *inode)
 {
-	struct btrfs_fs_info *fs_info = btrfs_sb(inode->i_sb);
+	struct btrfs_fs_info *fs_info = btrfs_sb(inode_sb(inode));
 	struct btrfs_ordered_extent *ordered;
 	struct btrfs_root *root = BTRFS_I(inode)->root;
 
@@ -9506,7 +9507,7 @@ static int btrfs_getattr(const struct path *path, struct kstat *stat,
 {
 	u64 delalloc_bytes;
 	struct inode *inode = d_inode(path->dentry);
-	u32 blocksize = inode->i_sb->s_blocksize;
+	u32 blocksize = inode_sb(inode)->s_blocksize;
 	u32 bi_flags = BTRFS_I(inode)->flags;
 
 	stat->result_mask |= STATX_BTIME;
@@ -9542,7 +9543,7 @@ static int btrfs_rename_exchange(struct inode *old_dir,
 			      struct inode *new_dir,
 			      struct dentry *new_dentry)
 {
-	struct btrfs_fs_info *fs_info = btrfs_sb(old_dir->i_sb);
+	struct btrfs_fs_info *fs_info = btrfs_sb(inode_sb(old_dir));
 	struct btrfs_trans_handle *trans;
 	struct btrfs_root *root = BTRFS_I(old_dir)->root;
 	struct btrfs_root *dest = BTRFS_I(new_dir)->root;
@@ -9817,7 +9818,7 @@ static int btrfs_rename(struct inode *old_dir, struct dentry *old_dentry,
 			   struct inode *new_dir, struct dentry *new_dentry,
 			   unsigned int flags)
 {
-	struct btrfs_fs_info *fs_info = btrfs_sb(old_dir->i_sb);
+	struct btrfs_fs_info *fs_info = btrfs_sb(inode_sb(old_dir));
 	struct btrfs_trans_handle *trans;
 	unsigned int trans_num_items;
 	struct btrfs_root *root = BTRFS_I(old_dir)->root;
@@ -10226,7 +10227,7 @@ int btrfs_start_delalloc_roots(struct btrfs_fs_info *fs_info, int delay_iput,
 static int btrfs_symlink(struct inode *dir, struct dentry *dentry,
 			 const char *symname)
 {
-	struct btrfs_fs_info *fs_info = btrfs_sb(dir->i_sb);
+	struct btrfs_fs_info *fs_info = btrfs_sb(inode_sb(dir));
 	struct btrfs_trans_handle *trans;
 	struct btrfs_root *root = BTRFS_I(dir)->root;
 	struct btrfs_path *path;
@@ -10357,7 +10358,7 @@ static int __btrfs_prealloc_file_range(struct inode *inode, int mode,
 				       loff_t actual_len, u64 *alloc_hint,
 				       struct btrfs_trans_handle *trans)
 {
-	struct btrfs_fs_info *fs_info = btrfs_sb(inode->i_sb);
+	struct btrfs_fs_info *fs_info = btrfs_sb(inode_sb(inode));
 	struct extent_map_tree *em_tree = &BTRFS_I(inode)->extent_tree;
 	struct extent_map *em;
 	struct btrfs_root *root = BTRFS_I(inode)->root;
@@ -10523,7 +10524,7 @@ static int btrfs_permission(struct inode *inode, int mask)
 
 static int btrfs_tmpfile(struct inode *dir, struct dentry *dentry, umode_t mode)
 {
-	struct btrfs_fs_info *fs_info = btrfs_sb(dir->i_sb);
+	struct btrfs_fs_info *fs_info = btrfs_sb(inode_sb(dir));
 	struct btrfs_trans_handle *trans;
 	struct btrfs_root *root = BTRFS_I(dir)->root;
 	struct inode *inode = NULL;
@@ -10601,7 +10602,7 @@ static int btrfs_readpage_io_failed_hook(struct page *page, int failed_mirror)
 static struct btrfs_fs_info *iotree_fs_info(void *private_data)
 {
 	struct inode *inode = private_data;
-	return btrfs_sb(inode->i_sb);
+	return btrfs_sb(inode_sb(inode));
 }
 
 static void btrfs_check_extent_io_range(void *private_data, const char *caller,
diff --git a/fs/btrfs/ioctl.c b/fs/btrfs/ioctl.c
index 111ee282b777..a8bc097b23a3 100644
--- a/fs/btrfs/ioctl.c
+++ b/fs/btrfs/ioctl.c
@@ -198,7 +198,7 @@ static int check_flags(unsigned int flags)
 static int btrfs_ioctl_setflags(struct file *file, void __user *arg)
 {
 	struct inode *inode = file_inode(file);
-	struct btrfs_fs_info *fs_info = btrfs_sb(inode->i_sb);
+	struct btrfs_fs_info *fs_info = btrfs_sb(inode_sb(inode));
 	struct btrfs_inode *ip = BTRFS_I(inode);
 	struct btrfs_root *root = ip->root;
 	struct btrfs_trans_handle *trans;
@@ -358,7 +358,7 @@ static int btrfs_ioctl_getversion(struct file *file, int __user *arg)
 static noinline int btrfs_ioctl_fitrim(struct file *file, void __user *arg)
 {
 	struct inode *inode = file_inode(file);
-	struct btrfs_fs_info *fs_info = btrfs_sb(inode->i_sb);
+	struct btrfs_fs_info *fs_info = btrfs_sb(inode_sb(inode));
 	struct btrfs_device *device;
 	struct request_queue *q;
 	struct fstrim_range range;
@@ -421,7 +421,7 @@ static noinline int create_subvol(struct inode *dir,
 				  u64 *async_transid,
 				  struct btrfs_qgroup_inherit *inherit)
 {
-	struct btrfs_fs_info *fs_info = btrfs_sb(dir->i_sb);
+	struct btrfs_fs_info *fs_info = btrfs_sb(inode_sb(dir));
 	struct btrfs_trans_handle *trans;
 	struct btrfs_key key;
 	struct btrfs_root_item *root_item;
@@ -626,7 +626,7 @@ static int create_snapshot(struct btrfs_root *root, struct inode *dir,
 			   u64 *async_transid, bool readonly,
 			   struct btrfs_qgroup_inherit *inherit)
 {
-	struct btrfs_fs_info *fs_info = btrfs_sb(dir->i_sb);
+	struct btrfs_fs_info *fs_info = btrfs_sb(inode_sb(dir));
 	struct inode *inode;
 	struct btrfs_pending_snapshot *pending_snapshot;
 	struct btrfs_trans_handle *trans;
@@ -806,7 +806,7 @@ static noinline int btrfs_mksubvol(const struct path *parent,
 				   struct btrfs_qgroup_inherit *inherit)
 {
 	struct inode *dir = d_inode(parent->dentry);
-	struct btrfs_fs_info *fs_info = btrfs_sb(dir->i_sb);
+	struct btrfs_fs_info *fs_info = btrfs_sb(inode_sb(dir));
 	struct dentry *dentry;
 	int error;
 
@@ -1171,7 +1171,7 @@ static int cluster_pages_for_defrag(struct inode *inode,
 	if (!i_done || ret)
 		goto out;
 
-	if (!(inode->i_sb->s_flags & SB_ACTIVE))
+	if (!(inode_sb(inode)->s_flags & SB_ACTIVE))
 		goto out;
 
 	/*
@@ -1236,7 +1236,7 @@ int btrfs_defrag_file(struct inode *inode, struct file *file,
 		      struct btrfs_ioctl_defrag_range_args *range,
 		      u64 newer_than, unsigned long max_to_defrag)
 {
-	struct btrfs_fs_info *fs_info = btrfs_sb(inode->i_sb);
+	struct btrfs_fs_info *fs_info = btrfs_sb(inode_sb(inode));
 	struct btrfs_root *root = BTRFS_I(inode)->root;
 	struct file_ra_state *ra = NULL;
 	unsigned long last_index;
@@ -1331,7 +1331,7 @@ int btrfs_defrag_file(struct inode *inode, struct file *file,
 		 * make sure we stop running if someone unmounts
 		 * the FS
 		 */
-		if (!(inode->i_sb->s_flags & SB_ACTIVE))
+		if (!(inode_sb(inode)->s_flags & SB_ACTIVE))
 			break;
 
 		if (btrfs_defrag_cancelled(fs_info)) {
@@ -1442,7 +1442,7 @@ static noinline int btrfs_ioctl_resize(struct file *file,
 					void __user *arg)
 {
 	struct inode *inode = file_inode(file);
-	struct btrfs_fs_info *fs_info = btrfs_sb(inode->i_sb);
+	struct btrfs_fs_info *fs_info = btrfs_sb(inode_sb(inode));
 	u64 new_size;
 	u64 old_size;
 	u64 devid = 1;
@@ -1621,7 +1621,7 @@ static noinline int btrfs_ioctl_snap_create_transid(struct file *file,
 		}
 
 		src_inode = file_inode(src.file);
-		if (src_inode->i_sb != file_inode(file)->i_sb) {
+		if (inode_sb(src_inode) != inode_sb(file_inode(file))) {
 			btrfs_info(BTRFS_I(file_inode(file))->root->fs_info,
 				   "Snapshot src from another FS");
 			ret = -EXDEV;
@@ -1730,7 +1730,7 @@ static noinline int btrfs_ioctl_subvol_getflags(struct file *file,
 						void __user *arg)
 {
 	struct inode *inode = file_inode(file);
-	struct btrfs_fs_info *fs_info = btrfs_sb(inode->i_sb);
+	struct btrfs_fs_info *fs_info = btrfs_sb(inode_sb(inode));
 	struct btrfs_root *root = BTRFS_I(inode)->root;
 	int ret = 0;
 	u64 flags = 0;
@@ -1753,7 +1753,7 @@ static noinline int btrfs_ioctl_subvol_setflags(struct file *file,
 					      void __user *arg)
 {
 	struct inode *inode = file_inode(file);
-	struct btrfs_fs_info *fs_info = btrfs_sb(inode->i_sb);
+	struct btrfs_fs_info *fs_info = btrfs_sb(inode_sb(inode));
 	struct btrfs_root *root = BTRFS_I(inode)->root;
 	struct btrfs_trans_handle *trans;
 	u64 root_flags;
@@ -2050,7 +2050,7 @@ static noinline int search_ioctl(struct inode *inode,
 				 size_t *buf_size,
 				 char __user *ubuf)
 {
-	struct btrfs_fs_info *info = btrfs_sb(inode->i_sb);
+	struct btrfs_fs_info *info = btrfs_sb(inode_sb(inode));
 	struct btrfs_root *root;
 	struct btrfs_key key;
 	struct btrfs_path *path;
@@ -2647,7 +2647,7 @@ static long btrfs_ioctl_add_dev(struct btrfs_fs_info *fs_info, void __user *arg)
 static long btrfs_ioctl_rm_dev_v2(struct file *file, void __user *arg)
 {
 	struct inode *inode = file_inode(file);
-	struct btrfs_fs_info *fs_info = btrfs_sb(inode->i_sb);
+	struct btrfs_fs_info *fs_info = btrfs_sb(inode_sb(inode));
 	struct btrfs_ioctl_vol_args_v2 *vol_args;
 	int ret;
 
@@ -2699,7 +2699,7 @@ static long btrfs_ioctl_rm_dev_v2(struct file *file, void __user *arg)
 static long btrfs_ioctl_rm_dev(struct file *file, void __user *arg)
 {
 	struct inode *inode = file_inode(file);
-	struct btrfs_fs_info *fs_info = btrfs_sb(inode->i_sb);
+	struct btrfs_fs_info *fs_info = btrfs_sb(inode_sb(inode));
 	struct btrfs_ioctl_vol_args *vol_args;
 	int ret;
 
@@ -3354,7 +3354,7 @@ static int clone_copy_inline_extent(struct inode *dst,
 				    const u64 size,
 				    char *inline_data)
 {
-	struct btrfs_fs_info *fs_info = btrfs_sb(dst->i_sb);
+	struct btrfs_fs_info *fs_info = btrfs_sb(inode_sb(dst));
 	struct btrfs_root *root = BTRFS_I(dst)->root;
 	const u64 aligned_end = ALIGN(new_key->offset + datal,
 				      fs_info->sectorsize);
@@ -3478,7 +3478,7 @@ static int btrfs_clone(struct inode *src, struct inode *inode,
 		       const u64 off, const u64 olen, const u64 olen_aligned,
 		       const u64 destoff, int no_time_update)
 {
-	struct btrfs_fs_info *fs_info = btrfs_sb(inode->i_sb);
+	struct btrfs_fs_info *fs_info = btrfs_sb(inode_sb(inode));
 	struct btrfs_root *root = BTRFS_I(inode)->root;
 	struct btrfs_path *path = NULL;
 	struct extent_buffer *leaf;
@@ -3812,7 +3812,7 @@ static noinline int btrfs_clone_files(struct file *file, struct file *file_src,
 {
 	struct inode *inode = file_inode(file);
 	struct inode *src = file_inode(file_src);
-	struct btrfs_fs_info *fs_info = btrfs_sb(inode->i_sb);
+	struct btrfs_fs_info *fs_info = btrfs_sb(inode_sb(inode));
 	struct btrfs_root *root = BTRFS_I(inode)->root;
 	int ret;
 	u64 len = olen;
@@ -3834,7 +3834,7 @@ static noinline int btrfs_clone_files(struct file *file, struct file *file_src,
 		return -EROFS;
 
 	if (file_src->f_path.mnt != file->f_path.mnt ||
-	    src->i_sb != inode->i_sb)
+	    inode_sb(src) != inode_sb(inode))
 		return -EXDEV;
 
 	/* don't make the dst file partly checksummed */
@@ -3945,7 +3945,7 @@ int btrfs_clone_file_range(struct file *src_file, loff_t off,
 static long btrfs_ioctl_trans_start(struct file *file)
 {
 	struct inode *inode = file_inode(file);
-	struct btrfs_fs_info *fs_info = btrfs_sb(inode->i_sb);
+	struct btrfs_fs_info *fs_info = btrfs_sb(inode_sb(inode));
 	struct btrfs_root *root = BTRFS_I(inode)->root;
 	struct btrfs_trans_handle *trans;
 	struct btrfs_file_private *private;
@@ -4006,7 +4006,7 @@ static long btrfs_ioctl_trans_start(struct file *file)
 static long btrfs_ioctl_default_subvol(struct file *file, void __user *argp)
 {
 	struct inode *inode = file_inode(file);
-	struct btrfs_fs_info *fs_info = btrfs_sb(inode->i_sb);
+	struct btrfs_fs_info *fs_info = btrfs_sb(inode_sb(inode));
 	struct btrfs_root *root = BTRFS_I(inode)->root;
 	struct btrfs_root *new_root;
 	struct btrfs_dir_item *di;
@@ -4313,7 +4313,7 @@ static noinline long btrfs_ioctl_wait_sync(struct btrfs_fs_info *fs_info,
 
 static long btrfs_ioctl_scrub(struct file *file, void __user *arg)
 {
-	struct btrfs_fs_info *fs_info = btrfs_sb(file_inode(file)->i_sb);
+	struct btrfs_fs_info *fs_info = btrfs_sb(inode_sb(file_inode(file)));
 	struct btrfs_ioctl_scrub_args *sa;
 	int ret;
 
@@ -4816,7 +4816,7 @@ static long btrfs_ioctl_balance_progress(struct btrfs_fs_info *fs_info,
 static long btrfs_ioctl_quota_ctl(struct file *file, void __user *arg)
 {
 	struct inode *inode = file_inode(file);
-	struct btrfs_fs_info *fs_info = btrfs_sb(inode->i_sb);
+	struct btrfs_fs_info *fs_info = btrfs_sb(inode_sb(inode));
 	struct btrfs_ioctl_quota_ctl_args *sa;
 	struct btrfs_trans_handle *trans = NULL;
 	int ret;
@@ -4868,7 +4868,7 @@ static long btrfs_ioctl_quota_ctl(struct file *file, void __user *arg)
 static long btrfs_ioctl_qgroup_assign(struct file *file, void __user *arg)
 {
 	struct inode *inode = file_inode(file);
-	struct btrfs_fs_info *fs_info = btrfs_sb(inode->i_sb);
+	struct btrfs_fs_info *fs_info = btrfs_sb(inode_sb(inode));
 	struct btrfs_root *root = BTRFS_I(inode)->root;
 	struct btrfs_ioctl_qgroup_assign_args *sa;
 	struct btrfs_trans_handle *trans;
@@ -4921,7 +4921,7 @@ static long btrfs_ioctl_qgroup_assign(struct file *file, void __user *arg)
 static long btrfs_ioctl_qgroup_create(struct file *file, void __user *arg)
 {
 	struct inode *inode = file_inode(file);
-	struct btrfs_fs_info *fs_info = btrfs_sb(inode->i_sb);
+	struct btrfs_fs_info *fs_info = btrfs_sb(inode_sb(inode));
 	struct btrfs_root *root = BTRFS_I(inode)->root;
 	struct btrfs_ioctl_qgroup_create_args *sa;
 	struct btrfs_trans_handle *trans;
@@ -4972,7 +4972,7 @@ static long btrfs_ioctl_qgroup_create(struct file *file, void __user *arg)
 static long btrfs_ioctl_qgroup_limit(struct file *file, void __user *arg)
 {
 	struct inode *inode = file_inode(file);
-	struct btrfs_fs_info *fs_info = btrfs_sb(inode->i_sb);
+	struct btrfs_fs_info *fs_info = btrfs_sb(inode_sb(inode));
 	struct btrfs_root *root = BTRFS_I(inode)->root;
 	struct btrfs_ioctl_qgroup_limit_args *sa;
 	struct btrfs_trans_handle *trans;
@@ -5021,7 +5021,7 @@ static long btrfs_ioctl_qgroup_limit(struct file *file, void __user *arg)
 static long btrfs_ioctl_quota_rescan(struct file *file, void __user *arg)
 {
 	struct inode *inode = file_inode(file);
-	struct btrfs_fs_info *fs_info = btrfs_sb(inode->i_sb);
+	struct btrfs_fs_info *fs_info = btrfs_sb(inode_sb(inode));
 	struct btrfs_ioctl_quota_rescan_args *qsa;
 	int ret;
 
@@ -5055,7 +5055,7 @@ static long btrfs_ioctl_quota_rescan(struct file *file, void __user *arg)
 static long btrfs_ioctl_quota_rescan_status(struct file *file, void __user *arg)
 {
 	struct inode *inode = file_inode(file);
-	struct btrfs_fs_info *fs_info = btrfs_sb(inode->i_sb);
+	struct btrfs_fs_info *fs_info = btrfs_sb(inode_sb(inode));
 	struct btrfs_ioctl_quota_rescan_args *qsa;
 	int ret = 0;
 
@@ -5081,7 +5081,7 @@ static long btrfs_ioctl_quota_rescan_status(struct file *file, void __user *arg)
 static long btrfs_ioctl_quota_rescan_wait(struct file *file, void __user *arg)
 {
 	struct inode *inode = file_inode(file);
-	struct btrfs_fs_info *fs_info = btrfs_sb(inode->i_sb);
+	struct btrfs_fs_info *fs_info = btrfs_sb(inode_sb(inode));
 
 	if (!capable(CAP_SYS_ADMIN))
 		return -EPERM;
@@ -5093,7 +5093,7 @@ static long _btrfs_ioctl_set_received_subvol(struct file *file,
 					    struct btrfs_ioctl_received_subvol_args *sa)
 {
 	struct inode *inode = file_inode(file);
-	struct btrfs_fs_info *fs_info = btrfs_sb(inode->i_sb);
+	struct btrfs_fs_info *fs_info = btrfs_sb(inode_sb(inode));
 	struct btrfs_root *root = BTRFS_I(inode)->root;
 	struct btrfs_root_item *root_item = &root->root_item;
 	struct btrfs_trans_handle *trans;
@@ -5251,7 +5251,7 @@ static long btrfs_ioctl_set_received_subvol(struct file *file,
 static int btrfs_ioctl_get_fslabel(struct file *file, void __user *arg)
 {
 	struct inode *inode = file_inode(file);
-	struct btrfs_fs_info *fs_info = btrfs_sb(inode->i_sb);
+	struct btrfs_fs_info *fs_info = btrfs_sb(inode_sb(inode));
 	size_t len;
 	int ret;
 	char label[BTRFS_LABEL_SIZE];
@@ -5276,7 +5276,7 @@ static int btrfs_ioctl_get_fslabel(struct file *file, void __user *arg)
 static int btrfs_ioctl_set_fslabel(struct file *file, void __user *arg)
 {
 	struct inode *inode = file_inode(file);
-	struct btrfs_fs_info *fs_info = btrfs_sb(inode->i_sb);
+	struct btrfs_fs_info *fs_info = btrfs_sb(inode_sb(inode));
 	struct btrfs_root *root = BTRFS_I(inode)->root;
 	struct btrfs_super_block *super_block = fs_info->super_copy;
 	struct btrfs_trans_handle *trans;
@@ -5338,7 +5338,7 @@ int btrfs_ioctl_get_supported_features(void __user *arg)
 static int btrfs_ioctl_get_features(struct file *file, void __user *arg)
 {
 	struct inode *inode = file_inode(file);
-	struct btrfs_fs_info *fs_info = btrfs_sb(inode->i_sb);
+	struct btrfs_fs_info *fs_info = btrfs_sb(inode_sb(inode));
 	struct btrfs_super_block *super_block = fs_info->super_copy;
 	struct btrfs_ioctl_feature_flags features;
 
@@ -5420,7 +5420,7 @@ check_feature_bits(fs_info, FEAT_##mask_base, change_mask, flags,	\
 static int btrfs_ioctl_set_features(struct file *file, void __user *arg)
 {
 	struct inode *inode = file_inode(file);
-	struct btrfs_fs_info *fs_info = btrfs_sb(inode->i_sb);
+	struct btrfs_fs_info *fs_info = btrfs_sb(inode_sb(inode));
 	struct btrfs_root *root = BTRFS_I(inode)->root;
 	struct btrfs_super_block *super_block = fs_info->super_copy;
 	struct btrfs_ioctl_feature_flags flags[2];
@@ -5527,7 +5527,7 @@ long btrfs_ioctl(struct file *file, unsigned int
 		cmd, unsigned long arg)
 {
 	struct inode *inode = file_inode(file);
-	struct btrfs_fs_info *fs_info = btrfs_sb(inode->i_sb);
+	struct btrfs_fs_info *fs_info = btrfs_sb(inode_sb(inode));
 	struct btrfs_root *root = BTRFS_I(inode)->root;
 	void __user *argp = (void __user *)arg;
 
@@ -5598,7 +5598,7 @@ long btrfs_ioctl(struct file *file, unsigned int
 		ret = btrfs_start_delalloc_roots(fs_info, 0, -1);
 		if (ret)
 			return ret;
-		ret = btrfs_sync_fs(inode->i_sb, 1);
+		ret = btrfs_sync_fs(inode_sb(inode), 1);
 		/*
 		 * The transaction thread may want to do more work,
 		 * namely it pokes the cleaner kthread that will start
diff --git a/fs/btrfs/ordered-data.c b/fs/btrfs/ordered-data.c
index 5b311aeddcc8..cfe166246ac1 100644
--- a/fs/btrfs/ordered-data.c
+++ b/fs/btrfs/ordered-data.c
@@ -66,7 +66,7 @@ static struct rb_node *tree_insert(struct rb_root *root, u64 file_offset,
 static void ordered_data_tree_panic(struct inode *inode, int errno,
 					       u64 offset)
 {
-	struct btrfs_fs_info *fs_info = btrfs_sb(inode->i_sb);
+	struct btrfs_fs_info *fs_info = btrfs_sb(inode_sb(inode));
 	btrfs_panic(fs_info, errno,
 		    "Inconsistency in ordered tree at offset %llu", offset);
 }
@@ -186,7 +186,7 @@ static int __btrfs_add_ordered_extent(struct inode *inode, u64 file_offset,
 				      u64 start, u64 len, u64 disk_len,
 				      int type, int dio, int compress_type)
 {
-	struct btrfs_fs_info *fs_info = btrfs_sb(inode->i_sb);
+	struct btrfs_fs_info *fs_info = btrfs_sb(inode_sb(inode));
 	struct btrfs_root *root = BTRFS_I(inode)->root;
 	struct btrfs_ordered_inode_tree *tree;
 	struct rb_node *node;
@@ -312,7 +312,7 @@ int btrfs_dec_test_first_ordered_pending(struct inode *inode,
 				   struct btrfs_ordered_extent **cached,
 				   u64 *file_offset, u64 io_size, int uptodate)
 {
-	struct btrfs_fs_info *fs_info = btrfs_sb(inode->i_sb);
+	struct btrfs_fs_info *fs_info = btrfs_sb(inode_sb(inode));
 	struct btrfs_ordered_inode_tree *tree;
 	struct rb_node *node;
 	struct btrfs_ordered_extent *entry = NULL;
@@ -598,7 +598,7 @@ void btrfs_put_ordered_extent(struct btrfs_ordered_extent *entry)
 void btrfs_remove_ordered_extent(struct inode *inode,
 				 struct btrfs_ordered_extent *entry)
 {
-	struct btrfs_fs_info *fs_info = btrfs_sb(inode->i_sb);
+	struct btrfs_fs_info *fs_info = btrfs_sb(inode_sb(inode));
 	struct btrfs_ordered_inode_tree *tree;
 	struct btrfs_inode *btrfs_inode = BTRFS_I(inode);
 	struct btrfs_root *root = btrfs_inode->root;
@@ -1123,9 +1123,9 @@ int btrfs_find_ordered_sum(struct inode *inode, u64 offset, u64 disk_bytenr,
 		if (disk_bytenr >= ordered_sum->bytenr &&
 		    disk_bytenr < ordered_sum->bytenr + ordered_sum->len) {
 			i = (disk_bytenr - ordered_sum->bytenr) >>
-			    inode->i_sb->s_blocksize_bits;
+			    inode_sb(inode)->s_blocksize_bits;
 			num_sectors = ordered_sum->len >>
-				      inode->i_sb->s_blocksize_bits;
+				      inode_sb(inode)->s_blocksize_bits;
 			num_sectors = min_t(int, len - index, num_sectors - i);
 			memcpy(sum + index, ordered_sum->sums + i,
 			       num_sectors);
diff --git a/fs/btrfs/relocation.c b/fs/btrfs/relocation.c
index cd2298d185dd..40e3ae49a746 100644
--- a/fs/btrfs/relocation.c
+++ b/fs/btrfs/relocation.c
@@ -3145,7 +3145,7 @@ static noinline_for_stack
 int setup_extent_mapping(struct inode *inode, u64 start, u64 end,
 			 u64 block_start)
 {
-	struct btrfs_fs_info *fs_info = btrfs_sb(inode->i_sb);
+	struct btrfs_fs_info *fs_info = btrfs_sb(inode_sb(inode));
 	struct extent_map_tree *em_tree = &BTRFS_I(inode)->extent_tree;
 	struct extent_map *em;
 	int ret = 0;
@@ -3179,7 +3179,7 @@ int setup_extent_mapping(struct inode *inode, u64 start, u64 end,
 static int relocate_file_extent_cluster(struct inode *inode,
 					struct file_extent_cluster *cluster)
 {
-	struct btrfs_fs_info *fs_info = btrfs_sb(inode->i_sb);
+	struct btrfs_fs_info *fs_info = btrfs_sb(inode_sb(inode));
 	u64 page_start;
 	u64 page_end;
 	u64 offset = BTRFS_I(inode)->index_cnt;
@@ -4643,7 +4643,7 @@ int btrfs_recover_relocation(struct btrfs_root *root)
  */
 int btrfs_reloc_clone_csums(struct inode *inode, u64 file_pos, u64 len)
 {
-	struct btrfs_fs_info *fs_info = btrfs_sb(inode->i_sb);
+	struct btrfs_fs_info *fs_info = btrfs_sb(inode_sb(inode));
 	struct btrfs_ordered_sum *sums;
 	struct btrfs_ordered_extent *ordered;
 	int ret;
diff --git a/fs/btrfs/tree-log.c b/fs/btrfs/tree-log.c
index 434457794c27..a07ca88b6cc6 100644
--- a/fs/btrfs/tree-log.c
+++ b/fs/btrfs/tree-log.c
@@ -3738,7 +3738,7 @@ static noinline int copy_items(struct btrfs_trans_handle *trans,
 			       int start_slot, int nr, int inode_only,
 			       u64 logged_isize)
 {
-	struct btrfs_fs_info *fs_info = btrfs_sb(inode->vfs_inode.i_sb);
+	struct btrfs_fs_info *fs_info = btrfs_sb(inode_sb(&inode->vfs_inode));
 	unsigned long src_offset;
 	unsigned long dst_offset;
 	struct btrfs_root *log = inode->root->log_root;
@@ -5417,7 +5417,7 @@ static int btrfs_log_all_parents(struct btrfs_trans_handle *trans,
 				 struct btrfs_inode *inode,
 				 struct btrfs_log_ctx *ctx)
 {
-	struct btrfs_fs_info *fs_info = btrfs_sb(inode->vfs_inode.i_sb);
+	struct btrfs_fs_info *fs_info = btrfs_sb(inode_sb(&inode->vfs_inode));
 	int ret;
 	struct btrfs_path *path;
 	struct btrfs_key key;
@@ -5533,7 +5533,7 @@ static int btrfs_log_inode_parent(struct btrfs_trans_handle *trans,
 	bool log_dentries = false;
 	struct btrfs_inode *orig_inode = inode;
 
-	sb = inode->vfs_inode.i_sb;
+	sb = inode_sb(&inode->vfs_inode);
 
 	if (btrfs_test_opt(fs_info, NOTREELOG)) {
 		ret = 1;
@@ -5952,7 +5952,7 @@ int btrfs_log_new_name(struct btrfs_trans_handle *trans,
 			struct btrfs_inode *inode, struct btrfs_inode *old_dir,
 			struct dentry *parent)
 {
-	struct btrfs_fs_info *fs_info = btrfs_sb(inode->vfs_inode.i_sb);
+	struct btrfs_fs_info *fs_info = btrfs_sb(inode_sb(&inode->vfs_inode));
 	struct btrfs_root *root = inode->root;
 
 	/*
-- 
2.15.1

^ permalink raw reply	[flat|nested] 88+ messages in thread

* [PATCH 19/76] fs/ceph: Use inode_sb() helper instead of inode->i_sb
  2018-05-08 18:03 [RFC][PATCH 0/76] vfs: 'views' for filesystems with more than one root Mark Fasheh
                   ` (17 preceding siblings ...)
  2018-05-08 18:03 ` [PATCH 18/76] fs/btrfs: " Mark Fasheh
@ 2018-05-08 18:03 ` Mark Fasheh
  2018-05-08 18:03 ` [PATCH 20/76] fs/cifs: " Mark Fasheh
                   ` (57 subsequent siblings)
  76 siblings, 0 replies; 88+ messages in thread
From: Mark Fasheh @ 2018-05-08 18:03 UTC (permalink / raw)
  To: linux-fsdevel; +Cc: linux-kernel, linux-btrfs, Mark Fasheh

Signed-off-by: Mark Fasheh <mfasheh@suse.de>
---
 fs/ceph/addr.c       |  2 +-
 fs/ceph/caps.c       | 16 ++++++++--------
 fs/ceph/dir.c        | 24 ++++++++++++------------
 fs/ceph/file.c       | 16 ++++++++--------
 fs/ceph/inode.c      | 16 ++++++++--------
 fs/ceph/ioctl.c      |  6 +++---
 fs/ceph/locks.c      |  2 +-
 fs/ceph/mds_client.c |  2 +-
 fs/ceph/snap.c       |  2 +-
 fs/ceph/super.h      |  2 +-
 fs/ceph/xattr.c      |  8 ++++----
 11 files changed, 48 insertions(+), 48 deletions(-)

diff --git a/fs/ceph/addr.c b/fs/ceph/addr.c
index b4336b42ce3b..8741e928fca0 100644
--- a/fs/ceph/addr.c
+++ b/fs/ceph/addr.c
@@ -776,7 +776,7 @@ static void writepages_finish(struct ceph_osd_request *req)
 	osd_data = osd_req_op_extent_osd_data(req, 0);
 	if (osd_data->pages_from_pool)
 		mempool_free(osd_data->pages,
-			     ceph_sb_to_client(inode->i_sb)->wb_pagevec_pool);
+			     ceph_sb_to_client(inode_sb(inode))->wb_pagevec_pool);
 	else
 		kfree(osd_data->pages);
 	ceph_osdc_put_request(req);
diff --git a/fs/ceph/caps.c b/fs/ceph/caps.c
index 0e5bd3e3344e..d92e6e9ff6e2 100644
--- a/fs/ceph/caps.c
+++ b/fs/ceph/caps.c
@@ -977,7 +977,7 @@ static void drop_inode_snap_realm(struct ceph_inode_info *ci)
 	ci->i_snap_realm_counter++;
 	ci->i_snap_realm = NULL;
 	spin_unlock(&realm->inodes_with_caps_lock);
-	ceph_put_snap_realm(ceph_sb_to_client(ci->vfs_inode.i_sb)->mdsc,
+	ceph_put_snap_realm(ceph_sb_to_client(inode_sb(&ci->vfs_inode))->mdsc,
 			    realm);
 }
 
@@ -992,7 +992,7 @@ void __ceph_remove_cap(struct ceph_cap *cap, bool queue_release)
 	struct ceph_mds_session *session = cap->session;
 	struct ceph_inode_info *ci = cap->ci;
 	struct ceph_mds_client *mdsc =
-		ceph_sb_to_client(ci->vfs_inode.i_sb)->mdsc;
+		ceph_sb_to_client(inode_sb(&ci->vfs_inode))->mdsc;
 	int removed = 0;
 
 	dout("__ceph_remove_cap %p from %p\n", cap, &ci->vfs_inode);
@@ -1551,7 +1551,7 @@ int __ceph_mark_dirty_caps(struct ceph_inode_info *ci, int mask,
 			   struct ceph_cap_flush **pcf)
 {
 	struct ceph_mds_client *mdsc =
-		ceph_sb_to_client(ci->vfs_inode.i_sb)->mdsc;
+		ceph_sb_to_client(inode_sb(&ci->vfs_inode))->mdsc;
 	struct inode *inode = &ci->vfs_inode;
 	int was = ci->i_dirty_caps;
 	int dirty = 0;
@@ -1660,7 +1660,7 @@ static int __mark_caps_flushing(struct inode *inode,
 				struct ceph_mds_session *session, bool wake,
 				u64 *flush_tid, u64 *oldest_flush_tid)
 {
-	struct ceph_mds_client *mdsc = ceph_sb_to_client(inode->i_sb)->mdsc;
+	struct ceph_mds_client *mdsc = ceph_sb_to_client(inode_sb(inode))->mdsc;
 	struct ceph_inode_info *ci = ceph_inode(inode);
 	struct ceph_cap_flush *cf = NULL;
 	int flushing;
@@ -2029,7 +2029,7 @@ void ceph_check_caps(struct ceph_inode_info *ci, int flags,
  */
 static int try_flush_caps(struct inode *inode, u64 *ptid)
 {
-	struct ceph_mds_client *mdsc = ceph_sb_to_client(inode->i_sb)->mdsc;
+	struct ceph_mds_client *mdsc = ceph_sb_to_client(inode_sb(inode))->mdsc;
 	struct ceph_inode_info *ci = ceph_inode(inode);
 	struct ceph_mds_session *session = NULL;
 	int flushing = 0;
@@ -2217,7 +2217,7 @@ int ceph_write_inode(struct inode *inode, struct writeback_control *wbc)
 				       caps_are_flushed(inode, flush_tid));
 	} else {
 		struct ceph_mds_client *mdsc =
-			ceph_sb_to_client(inode->i_sb)->mdsc;
+			ceph_sb_to_client(inode_sb(inode))->mdsc;
 
 		spin_lock(&ci->i_ceph_lock);
 		if (__ceph_caps_dirty(ci))
@@ -3228,7 +3228,7 @@ static void handle_cap_flush_ack(struct inode *inode, u64 flush_tid,
 	__releases(ci->i_ceph_lock)
 {
 	struct ceph_inode_info *ci = ceph_inode(inode);
-	struct ceph_mds_client *mdsc = ceph_sb_to_client(inode->i_sb)->mdsc;
+	struct ceph_mds_client *mdsc = ceph_sb_to_client(inode_sb(inode))->mdsc;
 	struct ceph_cap_flush *cf, *tmp_cf;
 	LIST_HEAD(to_remove);
 	unsigned seq = le32_to_cpu(m->seq);
@@ -3331,7 +3331,7 @@ static void handle_cap_flushsnap_ack(struct inode *inode, u64 flush_tid,
 				     struct ceph_mds_session *session)
 {
 	struct ceph_inode_info *ci = ceph_inode(inode);
-	struct ceph_mds_client *mdsc = ceph_sb_to_client(inode->i_sb)->mdsc;
+	struct ceph_mds_client *mdsc = ceph_sb_to_client(inode_sb(inode))->mdsc;
 	u64 follows = le64_to_cpu(m->snap_follows);
 	struct ceph_cap_snap *capsnap;
 	bool flushed = false;
diff --git a/fs/ceph/dir.c b/fs/ceph/dir.c
index f1d9c6cc0491..f41c584cdae7 100644
--- a/fs/ceph/dir.c
+++ b/fs/ceph/dir.c
@@ -317,7 +317,7 @@ static int ceph_readdir(struct file *file, struct dir_context *ctx)
 	if (ctx->pos == 0) {
 		dout("readdir off 0 -> '.'\n");
 		if (!dir_emit(ctx, ".", 1, 
-			    ceph_translate_ino(inode->i_sb, inode->i_ino),
+			    ceph_translate_ino(inode_sb(inode), inode->i_ino),
 			    inode->i_mode >> 12))
 			return 0;
 		ctx->pos = 1;
@@ -326,7 +326,7 @@ static int ceph_readdir(struct file *file, struct dir_context *ctx)
 		ino_t ino = parent_ino(file->f_path.dentry);
 		dout("readdir off 1 -> '..'\n");
 		if (!dir_emit(ctx, "..", 2,
-			    ceph_translate_ino(inode->i_sb, ino),
+			    ceph_translate_ino(inode_sb(inode), ino),
 			    inode->i_mode >> 12))
 			return 0;
 		ctx->pos = 2;
@@ -513,7 +513,7 @@ static int ceph_readdir(struct file *file, struct dir_context *ctx)
 		ino = ceph_vino_to_ino(vino);
 
 		if (!dir_emit(ctx, rde->name, rde->name_len,
-			      ceph_translate_ino(inode->i_sb, ino), ftype)) {
+			      ceph_translate_ino(inode_sb(inode), ino), ftype)) {
 			dout("filldir stopping us...\n");
 			return 0;
 		}
@@ -727,7 +727,7 @@ static bool is_root_ceph_dentry(struct inode *inode, struct dentry *dentry)
 static struct dentry *ceph_lookup(struct inode *dir, struct dentry *dentry,
 				  unsigned int flags)
 {
-	struct ceph_fs_client *fsc = ceph_sb_to_client(dir->i_sb);
+	struct ceph_fs_client *fsc = ceph_sb_to_client(inode_sb(dir));
 	struct ceph_mds_client *mdsc = fsc->mdsc;
 	struct ceph_mds_request *req;
 	int op;
@@ -816,7 +816,7 @@ int ceph_handle_notrace_create(struct inode *dir, struct dentry *dentry)
 static int ceph_mknod(struct inode *dir, struct dentry *dentry,
 		      umode_t mode, dev_t rdev)
 {
-	struct ceph_fs_client *fsc = ceph_sb_to_client(dir->i_sb);
+	struct ceph_fs_client *fsc = ceph_sb_to_client(inode_sb(dir));
 	struct ceph_mds_client *mdsc = fsc->mdsc;
 	struct ceph_mds_request *req;
 	struct ceph_acls_info acls = {};
@@ -870,7 +870,7 @@ static int ceph_create(struct inode *dir, struct dentry *dentry, umode_t mode,
 static int ceph_symlink(struct inode *dir, struct dentry *dentry,
 			    const char *dest)
 {
-	struct ceph_fs_client *fsc = ceph_sb_to_client(dir->i_sb);
+	struct ceph_fs_client *fsc = ceph_sb_to_client(inode_sb(dir));
 	struct ceph_mds_client *mdsc = fsc->mdsc;
 	struct ceph_mds_request *req;
 	int err;
@@ -908,7 +908,7 @@ static int ceph_symlink(struct inode *dir, struct dentry *dentry,
 
 static int ceph_mkdir(struct inode *dir, struct dentry *dentry, umode_t mode)
 {
-	struct ceph_fs_client *fsc = ceph_sb_to_client(dir->i_sb);
+	struct ceph_fs_client *fsc = ceph_sb_to_client(inode_sb(dir));
 	struct ceph_mds_client *mdsc = fsc->mdsc;
 	struct ceph_mds_request *req;
 	struct ceph_acls_info acls = {};
@@ -967,7 +967,7 @@ static int ceph_mkdir(struct inode *dir, struct dentry *dentry, umode_t mode)
 static int ceph_link(struct dentry *old_dentry, struct inode *dir,
 		     struct dentry *dentry)
 {
-	struct ceph_fs_client *fsc = ceph_sb_to_client(dir->i_sb);
+	struct ceph_fs_client *fsc = ceph_sb_to_client(inode_sb(dir));
 	struct ceph_mds_client *mdsc = fsc->mdsc;
 	struct ceph_mds_request *req;
 	int err;
@@ -1007,7 +1007,7 @@ static int ceph_link(struct dentry *old_dentry, struct inode *dir,
  */
 static int ceph_unlink(struct inode *dir, struct dentry *dentry)
 {
-	struct ceph_fs_client *fsc = ceph_sb_to_client(dir->i_sb);
+	struct ceph_fs_client *fsc = ceph_sb_to_client(inode_sb(dir));
 	struct ceph_mds_client *mdsc = fsc->mdsc;
 	struct inode *inode = d_inode(dentry);
 	struct ceph_mds_request *req;
@@ -1049,7 +1049,7 @@ static int ceph_rename(struct inode *old_dir, struct dentry *old_dentry,
 		       struct inode *new_dir, struct dentry *new_dentry,
 		       unsigned int flags)
 {
-	struct ceph_fs_client *fsc = ceph_sb_to_client(old_dir->i_sb);
+	struct ceph_fs_client *fsc = ceph_sb_to_client(inode_sb(old_dir));
 	struct ceph_mds_client *mdsc = fsc->mdsc;
 	struct ceph_mds_request *req;
 	int op = CEPH_MDS_OP_RENAME;
@@ -1232,7 +1232,7 @@ static int ceph_d_revalidate(struct dentry *dentry, unsigned int flags)
 
 	if (!valid) {
 		struct ceph_mds_client *mdsc =
-			ceph_sb_to_client(dir->i_sb)->mdsc;
+			ceph_sb_to_client(inode_sb(dir))->mdsc;
 		struct ceph_mds_request *req;
 		int op, err;
 		u32 mask;
@@ -1358,7 +1358,7 @@ static ssize_t ceph_read_dir(struct file *file, char __user *buf, size_t size,
 	int left;
 	const int bufsize = 1024;
 
-	if (!ceph_test_mount_opt(ceph_sb_to_client(inode->i_sb), DIRSTAT))
+	if (!ceph_test_mount_opt(ceph_sb_to_client(inode_sb(inode)), DIRSTAT))
 		return -EISDIR;
 
 	if (!cf->dir_info) {
diff --git a/fs/ceph/file.c b/fs/ceph/file.c
index b67eec3532a1..7d0984676292 100644
--- a/fs/ceph/file.c
+++ b/fs/ceph/file.c
@@ -218,7 +218,7 @@ static int ceph_init_file(struct inode *inode, struct file *file, int fmode)
  */
 int ceph_renew_caps(struct inode *inode)
 {
-	struct ceph_mds_client *mdsc = ceph_sb_to_client(inode->i_sb)->mdsc;
+	struct ceph_mds_client *mdsc = ceph_sb_to_client(inode_sb(inode))->mdsc;
 	struct ceph_inode_info *ci = ceph_inode(inode);
 	struct ceph_mds_request *req;
 	int err, flags, wanted;
@@ -248,7 +248,7 @@ int ceph_renew_caps(struct inode *inode)
 		flags |= O_LAZY;
 #endif
 
-	req = prepare_open_request(inode->i_sb, flags, 0);
+	req = prepare_open_request(inode_sb(inode), flags, 0);
 	if (IS_ERR(req)) {
 		err = PTR_ERR(req);
 		goto out;
@@ -275,7 +275,7 @@ int ceph_renew_caps(struct inode *inode)
 int ceph_open(struct inode *inode, struct file *file)
 {
 	struct ceph_inode_info *ci = ceph_inode(inode);
-	struct ceph_fs_client *fsc = ceph_sb_to_client(inode->i_sb);
+	struct ceph_fs_client *fsc = ceph_sb_to_client(inode_sb(inode));
 	struct ceph_mds_client *mdsc = fsc->mdsc;
 	struct ceph_mds_request *req;
 	struct ceph_file_info *cf = file->private_data;
@@ -343,7 +343,7 @@ int ceph_open(struct inode *inode, struct file *file)
 	spin_unlock(&ci->i_ceph_lock);
 
 	dout("open fmode %d wants %s\n", fmode, ceph_cap_string(wanted));
-	req = prepare_open_request(inode->i_sb, flags, 0);
+	req = prepare_open_request(inode_sb(inode), flags, 0);
 	if (IS_ERR(req)) {
 		err = PTR_ERR(req);
 		goto out;
@@ -370,7 +370,7 @@ int ceph_atomic_open(struct inode *dir, struct dentry *dentry,
 		     struct file *file, unsigned flags, umode_t mode,
 		     int *opened)
 {
-	struct ceph_fs_client *fsc = ceph_sb_to_client(dir->i_sb);
+	struct ceph_fs_client *fsc = ceph_sb_to_client(inode_sb(dir));
 	struct ceph_mds_client *mdsc = fsc->mdsc;
 	struct ceph_mds_request *req;
 	struct dentry *dn;
@@ -392,7 +392,7 @@ int ceph_atomic_open(struct inode *dir, struct dentry *dentry,
 	}
 
 	/* do the open */
-	req = prepare_open_request(dir->i_sb, flags, mode);
+	req = prepare_open_request(inode_sb(dir), flags, mode);
 	if (IS_ERR(req)) {
 		err = PTR_ERR(req);
 		goto out_acl;
@@ -1307,7 +1307,7 @@ static ssize_t ceph_write_iter(struct kiocb *iocb, struct iov_iter *from)
 	struct inode *inode = file_inode(file);
 	struct ceph_inode_info *ci = ceph_inode(inode);
 	struct ceph_osd_client *osdc =
-		&ceph_sb_to_client(inode->i_sb)->client->osdc;
+		&ceph_sb_to_client(inode_sb(inode))->client->osdc;
 	struct ceph_cap_flush *prealloc_cf;
 	ssize_t count, written = 0;
 	int err, want, got;
@@ -1505,7 +1505,7 @@ static loff_t ceph_llseek(struct file *file, loff_t offset, int whence)
 		break;
 	}
 
-	ret = vfs_setpos(file, offset, inode->i_sb->s_maxbytes);
+	ret = vfs_setpos(file, offset, inode_sb(inode)->s_maxbytes);
 
 out:
 	inode_unlock(inode);
diff --git a/fs/ceph/inode.c b/fs/ceph/inode.c
index c6ec5aa46100..95ef61d0954a 100644
--- a/fs/ceph/inode.c
+++ b/fs/ceph/inode.c
@@ -75,7 +75,7 @@ struct inode *ceph_get_snapdir(struct inode *parent)
 		.ino = ceph_ino(parent),
 		.snap = CEPH_SNAPDIR,
 	};
-	struct inode *inode = ceph_get_inode(parent->i_sb, vino);
+	struct inode *inode = ceph_get_inode(inode_sb(parent), vino);
 	struct ceph_inode_info *ci = ceph_inode(inode);
 
 	BUG_ON(!S_ISDIR(parent->i_mode));
@@ -542,7 +542,7 @@ void ceph_destroy_inode(struct inode *inode)
 	 */
 	if (ci->i_snap_realm) {
 		struct ceph_mds_client *mdsc =
-			ceph_sb_to_client(ci->vfs_inode.i_sb)->mdsc;
+			ceph_sb_to_client(inode_sb(&ci->vfs_inode))->mdsc;
 		struct ceph_snap_realm *realm = ci->i_snap_realm;
 
 		dout(" dropping residual ref to snap realm %p\n", realm);
@@ -1832,7 +1832,7 @@ void ceph_queue_vmtruncate(struct inode *inode)
 
 	ihold(inode);
 
-	if (queue_work(ceph_sb_to_client(inode->i_sb)->trunc_wq,
+	if (queue_work(ceph_sb_to_client(inode_sb(inode))->trunc_wq,
 		       &ci->i_vmtruncate_work)) {
 		dout("ceph_queue_vmtruncate %p\n", inode);
 	} else {
@@ -1882,7 +1882,7 @@ void __ceph_do_pending_vmtruncate(struct inode *inode)
 		truncate_pagecache(inode, to);
 
 		filemap_write_and_wait_range(&inode->i_data, 0,
-					     inode->i_sb->s_maxbytes);
+					     inode_sb(inode)->s_maxbytes);
 		goto retry;
 	}
 
@@ -1929,7 +1929,7 @@ int __ceph_setattr(struct inode *inode, struct iattr *attr)
 	struct ceph_inode_info *ci = ceph_inode(inode);
 	const unsigned int ia_valid = attr->ia_valid;
 	struct ceph_mds_request *req;
-	struct ceph_mds_client *mdsc = ceph_sb_to_client(inode->i_sb)->mdsc;
+	struct ceph_mds_client *mdsc = ceph_sb_to_client(inode_sb(inode))->mdsc;
 	struct ceph_cap_flush *prealloc_cf;
 	int issued;
 	int release = 0, dirtied = 0;
@@ -2167,7 +2167,7 @@ int ceph_setattr(struct dentry *dentry, struct iattr *attr)
 int __ceph_do_getattr(struct inode *inode, struct page *locked_page,
 		      int mask, bool force)
 {
-	struct ceph_fs_client *fsc = ceph_sb_to_client(inode->i_sb);
+	struct ceph_fs_client *fsc = ceph_sb_to_client(inode_sb(inode));
 	struct ceph_mds_client *mdsc = fsc->mdsc;
 	struct ceph_mds_request *req;
 	int err;
@@ -2240,13 +2240,13 @@ int ceph_getattr(const struct path *path, struct kstat *stat,
 	err = ceph_do_getattr(inode, CEPH_STAT_CAP_INODE_ALL, false);
 	if (!err) {
 		generic_fillattr(inode, stat);
-		stat->ino = ceph_translate_ino(inode->i_sb, inode->i_ino);
+		stat->ino = ceph_translate_ino(inode_sb(inode), inode->i_ino);
 		if (ceph_snap(inode) != CEPH_NOSNAP)
 			stat->dev = ceph_snap(inode);
 		else
 			stat->dev = 0;
 		if (S_ISDIR(inode->i_mode)) {
-			if (ceph_test_mount_opt(ceph_sb_to_client(inode->i_sb),
+			if (ceph_test_mount_opt(ceph_sb_to_client(inode_sb(inode)),
 						RBYTES))
 				stat->size = ci->i_rbytes;
 			else
diff --git a/fs/ceph/ioctl.c b/fs/ceph/ioctl.c
index 851aa69ec8f0..ed3401b8bf0a 100644
--- a/fs/ceph/ioctl.c
+++ b/fs/ceph/ioctl.c
@@ -64,7 +64,7 @@ static long __validate_layout(struct ceph_mds_client *mdsc,
 static long ceph_ioctl_set_layout(struct file *file, void __user *arg)
 {
 	struct inode *inode = file_inode(file);
-	struct ceph_mds_client *mdsc = ceph_sb_to_client(inode->i_sb)->mdsc;
+	struct ceph_mds_client *mdsc = ceph_sb_to_client(inode_sb(inode))->mdsc;
 	struct ceph_mds_request *req;
 	struct ceph_ioctl_layout l;
 	struct ceph_inode_info *ci = ceph_inode(file_inode(file));
@@ -139,7 +139,7 @@ static long ceph_ioctl_set_layout_policy (struct file *file, void __user *arg)
 	struct ceph_mds_request *req;
 	struct ceph_ioctl_layout l;
 	int err;
-	struct ceph_mds_client *mdsc = ceph_sb_to_client(inode->i_sb)->mdsc;
+	struct ceph_mds_client *mdsc = ceph_sb_to_client(inode_sb(inode))->mdsc;
 
 	/* copy and validate */
 	if (copy_from_user(&l, arg, sizeof(l)))
@@ -182,7 +182,7 @@ static long ceph_ioctl_get_dataloc(struct file *file, void __user *arg)
 	struct inode *inode = file_inode(file);
 	struct ceph_inode_info *ci = ceph_inode(inode);
 	struct ceph_osd_client *osdc =
-		&ceph_sb_to_client(inode->i_sb)->client->osdc;
+		&ceph_sb_to_client(inode_sb(inode))->client->osdc;
 	struct ceph_object_locator oloc;
 	CEPH_DEFINE_OID_ONSTACK(oid);
 	u64 len = 1, olen;
diff --git a/fs/ceph/locks.c b/fs/ceph/locks.c
index 9e66f69ee8a5..0690fec1b678 100644
--- a/fs/ceph/locks.c
+++ b/fs/ceph/locks.c
@@ -59,7 +59,7 @@ static const struct file_lock_operations ceph_fl_lock_ops = {
 static int ceph_lock_message(u8 lock_type, u16 operation, struct inode *inode,
 			     int cmd, u8 wait, struct file_lock *fl)
 {
-	struct ceph_mds_client *mdsc = ceph_sb_to_client(inode->i_sb)->mdsc;
+	struct ceph_mds_client *mdsc = ceph_sb_to_client(inode_sb(inode))->mdsc;
 	struct ceph_mds_request *req;
 	int err;
 	u64 length = 0;
diff --git a/fs/ceph/mds_client.c b/fs/ceph/mds_client.c
index 2e8f90f96540..b46d25e5586f 100644
--- a/fs/ceph/mds_client.c
+++ b/fs/ceph/mds_client.c
@@ -760,7 +760,7 @@ static int __choose_mds(struct ceph_mds_client *mdsc,
 		parent = req->r_dentry->d_parent;
 		dir = req->r_parent ? : d_inode_rcu(parent);
 
-		if (!dir || dir->i_sb != mdsc->fsc->sb) {
+		if (!dir || inode_sb(dir) != mdsc->fsc->sb) {
 			/*  not this fs or parent went negative */
 			inode = d_inode(req->r_dentry);
 			if (inode)
diff --git a/fs/ceph/snap.c b/fs/ceph/snap.c
index 07cf95e6413d..b370cf0f7218 100644
--- a/fs/ceph/snap.c
+++ b/fs/ceph/snap.c
@@ -590,7 +590,7 @@ int __ceph_finish_cap_snap(struct ceph_inode_info *ci,
 			    struct ceph_cap_snap *capsnap)
 {
 	struct inode *inode = &ci->vfs_inode;
-	struct ceph_mds_client *mdsc = ceph_sb_to_client(inode->i_sb)->mdsc;
+	struct ceph_mds_client *mdsc = ceph_sb_to_client(inode_sb(inode))->mdsc;
 
 	BUG_ON(capsnap->writing);
 	capsnap->size = inode->i_size;
diff --git a/fs/ceph/super.h b/fs/ceph/super.h
index 1c2086e0fec2..49c013180595 100644
--- a/fs/ceph/super.h
+++ b/fs/ceph/super.h
@@ -386,7 +386,7 @@ static inline struct ceph_inode_info *ceph_inode(struct inode *inode)
 
 static inline struct ceph_fs_client *ceph_inode_to_client(struct inode *inode)
 {
-	return (struct ceph_fs_client *)inode->i_sb->s_fs_info;
+	return (struct ceph_fs_client *) inode_sb(inode)->s_fs_info;
 }
 
 static inline struct ceph_fs_client *ceph_sb_to_client(struct super_block *sb)
diff --git a/fs/ceph/xattr.c b/fs/ceph/xattr.c
index e1c4e0b12b4c..a6d4f85d0583 100644
--- a/fs/ceph/xattr.c
+++ b/fs/ceph/xattr.c
@@ -67,7 +67,7 @@ static bool ceph_vxattrcb_layout_exists(struct ceph_inode_info *ci)
 static size_t ceph_vxattrcb_layout(struct ceph_inode_info *ci, char *val,
 				   size_t size)
 {
-	struct ceph_fs_client *fsc = ceph_sb_to_client(ci->vfs_inode.i_sb);
+	struct ceph_fs_client *fsc = ceph_sb_to_client(inode_sb(&ci->vfs_inode));
 	struct ceph_osd_client *osdc = &fsc->client->osdc;
 	struct ceph_string *pool_ns;
 	s64 pool = ci->i_layout.pool_id;
@@ -146,7 +146,7 @@ static size_t ceph_vxattrcb_layout_pool(struct ceph_inode_info *ci,
 					char *val, size_t size)
 {
 	int ret;
-	struct ceph_fs_client *fsc = ceph_sb_to_client(ci->vfs_inode.i_sb);
+	struct ceph_fs_client *fsc = ceph_sb_to_client(inode_sb(&ci->vfs_inode));
 	struct ceph_osd_client *osdc = &fsc->client->osdc;
 	s64 pool = ci->i_layout.pool_id;
 	const char *pool_name;
@@ -885,7 +885,7 @@ ssize_t ceph_listxattr(struct dentry *dentry, char *names, size_t size)
 static int ceph_sync_setxattr(struct inode *inode, const char *name,
 			      const char *value, size_t size, int flags)
 {
-	struct ceph_fs_client *fsc = ceph_sb_to_client(inode->i_sb);
+	struct ceph_fs_client *fsc = ceph_sb_to_client(inode_sb(inode));
 	struct ceph_inode_info *ci = ceph_inode(inode);
 	struct ceph_mds_request *req;
 	struct ceph_mds_client *mdsc = fsc->mdsc;
@@ -953,7 +953,7 @@ int __ceph_setxattr(struct inode *inode, const char *name,
 {
 	struct ceph_vxattr *vxattr;
 	struct ceph_inode_info *ci = ceph_inode(inode);
-	struct ceph_mds_client *mdsc = ceph_sb_to_client(inode->i_sb)->mdsc;
+	struct ceph_mds_client *mdsc = ceph_sb_to_client(inode_sb(inode))->mdsc;
 	struct ceph_cap_flush *prealloc_cf = NULL;
 	int issued;
 	int err;
-- 
2.15.1

^ permalink raw reply	[flat|nested] 88+ messages in thread

* [PATCH 20/76] fs/cifs: Use inode_sb() helper instead of inode->i_sb
  2018-05-08 18:03 [RFC][PATCH 0/76] vfs: 'views' for filesystems with more than one root Mark Fasheh
                   ` (18 preceding siblings ...)
  2018-05-08 18:03 ` [PATCH 19/76] fs/ceph: " Mark Fasheh
@ 2018-05-08 18:03 ` Mark Fasheh
  2018-05-08 18:03 ` [PATCH 21/76] fs/coda: " Mark Fasheh
                   ` (56 subsequent siblings)
  76 siblings, 0 replies; 88+ messages in thread
From: Mark Fasheh @ 2018-05-08 18:03 UTC (permalink / raw)
  To: linux-fsdevel; +Cc: linux-kernel, linux-btrfs, Mark Fasheh

Signed-off-by: Mark Fasheh <mfasheh@suse.de>
---
 fs/cifs/cifsacl.c   |  4 ++--
 fs/cifs/cifsfs.c    |  4 ++--
 fs/cifs/cifsglob.h  |  2 +-
 fs/cifs/dir.c       | 29 ++++++++++++++++-------------
 fs/cifs/file.c      | 42 ++++++++++++++++++++++--------------------
 fs/cifs/fscache.c   |  4 ++--
 fs/cifs/inode.c     | 43 +++++++++++++++++++++++--------------------
 fs/cifs/ioctl.c     |  2 +-
 fs/cifs/link.c      | 10 +++++-----
 fs/cifs/readdir.c   |  2 +-
 fs/cifs/smb1ops.c   |  4 ++--
 fs/cifs/smb2inode.c |  2 +-
 fs/cifs/smb2ops.c   |  4 ++--
 13 files changed, 80 insertions(+), 72 deletions(-)

diff --git a/fs/cifs/cifsacl.c b/fs/cifs/cifsacl.c
index 13a8a77322c9..d7b37ff7d57f 100644
--- a/fs/cifs/cifsacl.c
+++ b/fs/cifs/cifsacl.c
@@ -1081,7 +1081,7 @@ int set_cifs_acl(struct cifs_ntsd *pnntsd, __u32 acllen,
 	unsigned int xid;
 	int rc, access_flags, create_options = 0;
 	struct cifs_tcon *tcon;
-	struct cifs_sb_info *cifs_sb = CIFS_SB(inode->i_sb);
+	struct cifs_sb_info *cifs_sb = CIFS_SB(inode_sb(inode));
 	struct tcon_link *tlink = cifs_sb_tlink(cifs_sb);
 	struct cifs_fid fid;
 	struct cifs_open_parms oparms;
@@ -1178,7 +1178,7 @@ id_mode_to_cifs_acl(struct inode *inode, const char *path, __u64 nmode,
 	__u32 secdesclen = 0;
 	struct cifs_ntsd *pntsd = NULL; /* acl obtained from server */
 	struct cifs_ntsd *pnntsd = NULL; /* modified acl to be sent to server */
-	struct cifs_sb_info *cifs_sb = CIFS_SB(inode->i_sb);
+	struct cifs_sb_info *cifs_sb = CIFS_SB(inode_sb(inode));
 	struct tcon_link *tlink = cifs_sb_tlink(cifs_sb);
 	struct smb_version_operations *ops;
 
diff --git a/fs/cifs/cifsfs.c b/fs/cifs/cifsfs.c
index 32cdea67bbfd..54741739c5e6 100644
--- a/fs/cifs/cifsfs.c
+++ b/fs/cifs/cifsfs.c
@@ -231,7 +231,7 @@ static int cifs_permission(struct inode *inode, int mask)
 {
 	struct cifs_sb_info *cifs_sb;
 
-	cifs_sb = CIFS_SB(inode->i_sb);
+	cifs_sb = CIFS_SB(inode_sb(inode));
 
 	if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_NO_PERM) {
 		if ((mask & MAY_EXEC) && !execute_ok(inode))
@@ -581,7 +581,7 @@ static int cifs_remount(struct super_block *sb, int *flags, char *data)
 
 static int cifs_drop_inode(struct inode *inode)
 {
-	struct cifs_sb_info *cifs_sb = CIFS_SB(inode->i_sb);
+	struct cifs_sb_info *cifs_sb = CIFS_SB(inode_sb(inode));
 
 	/* no serverino => unconditional eviction */
 	return !(cifs_sb->mnt_cifs_flags & CIFS_MOUNT_SERVER_INUM) ||
diff --git a/fs/cifs/cifsglob.h b/fs/cifs/cifsglob.h
index 48f7c197cd2d..35910ece3526 100644
--- a/fs/cifs/cifsglob.h
+++ b/fs/cifs/cifsglob.h
@@ -1265,7 +1265,7 @@ CIFS_SB(struct super_block *sb)
 static inline struct cifs_sb_info *
 CIFS_FILE_SB(struct file *file)
 {
-	return CIFS_SB(file_inode(file)->i_sb);
+	return CIFS_SB(inode_sb(file_inode(file)));
 }
 
 static inline char CIFS_DIR_SEP(const struct cifs_sb_info *cifs_sb)
diff --git a/fs/cifs/dir.c b/fs/cifs/dir.c
index 81ba6e0d88d8..201ec5c3d4fe 100644
--- a/fs/cifs/dir.c
+++ b/fs/cifs/dir.c
@@ -231,7 +231,7 @@ cifs_do_create(struct inode *inode, struct dentry *direntry, unsigned int xid,
 	int rc = -ENOENT;
 	int create_options = CREATE_NOT_DIR;
 	int desired_access;
-	struct cifs_sb_info *cifs_sb = CIFS_SB(inode->i_sb);
+	struct cifs_sb_info *cifs_sb = CIFS_SB(inode_sb(inode));
 	struct cifs_tcon *tcon = tlink_tcon(tlink);
 	char *full_path = NULL;
 	FILE_ALL_INFO *buf = NULL;
@@ -253,7 +253,8 @@ cifs_do_create(struct inode *inode, struct dentry *direntry, unsigned int xid,
 	if (tcon->unix_ext && cap_unix(tcon->ses) && !tcon->broken_posix_open &&
 	    (CIFS_UNIX_POSIX_PATH_OPS_CAP &
 			le64_to_cpu(tcon->fsUnixInfo.Capability))) {
-		rc = cifs_posix_open(full_path, &newinode, inode->i_sb, mode,
+		rc = cifs_posix_open(full_path, &newinode, inode_sb(inode),
+				     mode,
 				     oflags, oplock, &fid->netfid, xid);
 		switch (rc) {
 		case 0:
@@ -414,10 +415,12 @@ cifs_do_create(struct inode *inode, struct dentry *direntry, unsigned int xid,
 cifs_create_get_file_info:
 	/* server might mask mode so we have to query for it */
 	if (tcon->unix_ext)
-		rc = cifs_get_inode_info_unix(&newinode, full_path, inode->i_sb,
+		rc = cifs_get_inode_info_unix(&newinode, full_path,
+					      inode_sb(inode),
 					      xid);
 	else {
-		rc = cifs_get_inode_info(&newinode, full_path, buf, inode->i_sb,
+		rc = cifs_get_inode_info(&newinode, full_path, buf,
+					 inode_sb(inode),
 					 xid, fid);
 		if (newinode) {
 			if (server->ops->set_lease_key)
@@ -511,7 +514,7 @@ cifs_atomic_open(struct inode *inode, struct dentry *direntry,
 	cifs_dbg(FYI, "parent inode = 0x%p name is: %pd and dentry = 0x%p\n",
 		 inode, direntry, direntry);
 
-	tlink = cifs_sb_tlink(CIFS_SB(inode->i_sb));
+	tlink = cifs_sb_tlink(CIFS_SB(inode_sb(inode)));
 	if (IS_ERR(tlink)) {
 		rc = PTR_ERR(tlink);
 		goto out_free_xid;
@@ -550,8 +553,8 @@ cifs_atomic_open(struct inode *inode, struct dentry *direntry,
 	}
 
 	if (file->f_flags & O_DIRECT &&
-	    CIFS_SB(inode->i_sb)->mnt_cifs_flags & CIFS_MOUNT_STRICT_IO) {
-		if (CIFS_SB(inode->i_sb)->mnt_cifs_flags & CIFS_MOUNT_NO_BRL)
+	    CIFS_SB(inode_sb(inode))->mnt_cifs_flags & CIFS_MOUNT_STRICT_IO) {
+		if (CIFS_SB(inode_sb(inode))->mnt_cifs_flags & CIFS_MOUNT_NO_BRL)
 			file->f_op = &cifs_file_direct_nobrl_ops;
 		else
 			file->f_op = &cifs_file_direct_ops;
@@ -595,7 +598,7 @@ int cifs_create(struct inode *inode, struct dentry *direntry, umode_t mode,
 	cifs_dbg(FYI, "cifs_create parent inode = 0x%p name is: %pd and dentry = 0x%p\n",
 		 inode, direntry, direntry);
 
-	tlink = cifs_sb_tlink(CIFS_SB(inode->i_sb));
+	tlink = cifs_sb_tlink(CIFS_SB(inode_sb(inode)));
 	rc = PTR_ERR(tlink);
 	if (IS_ERR(tlink))
 		goto out_free_xid;
@@ -640,7 +643,7 @@ int cifs_mknod(struct inode *inode, struct dentry *direntry, umode_t mode,
 	if (!old_valid_dev(device_number))
 		return -EINVAL;
 
-	cifs_sb = CIFS_SB(inode->i_sb);
+	cifs_sb = CIFS_SB(inode_sb(inode));
 	tlink = cifs_sb_tlink(cifs_sb);
 	if (IS_ERR(tlink))
 		return PTR_ERR(tlink);
@@ -677,7 +680,7 @@ int cifs_mknod(struct inode *inode, struct dentry *direntry, umode_t mode,
 			goto mknod_out;
 
 		rc = cifs_get_inode_info_unix(&newinode, full_path,
-						inode->i_sb, xid);
+						inode_sb(inode), xid);
 
 		if (rc == 0)
 			d_instantiate(direntry, newinode);
@@ -775,7 +778,7 @@ cifs_lookup(struct inode *parent_dir_inode, struct dentry *direntry,
 
 	/* check whether path exists */
 
-	cifs_sb = CIFS_SB(parent_dir_inode->i_sb);
+	cifs_sb = CIFS_SB(inode_sb(parent_dir_inode));
 	tlink = cifs_sb_tlink(cifs_sb);
 	if (IS_ERR(tlink)) {
 		free_xid(xid);
@@ -806,10 +809,10 @@ cifs_lookup(struct inode *parent_dir_inode, struct dentry *direntry,
 
 	if (pTcon->unix_ext) {
 		rc = cifs_get_inode_info_unix(&newInode, full_path,
-					      parent_dir_inode->i_sb, xid);
+					      inode_sb(parent_dir_inode), xid);
 	} else {
 		rc = cifs_get_inode_info(&newInode, full_path, NULL,
-				parent_dir_inode->i_sb, xid, NULL);
+				inode_sb(parent_dir_inode), xid, NULL);
 	}
 
 	if ((rc == 0) && (newInode != NULL)) {
diff --git a/fs/cifs/file.c b/fs/cifs/file.c
index 7cee97b93a61..ecb3bf22bfa0 100644
--- a/fs/cifs/file.c
+++ b/fs/cifs/file.c
@@ -246,10 +246,12 @@ cifs_nt_open(char *full_path, struct inode *inode, struct cifs_sb_info *cifs_sb,
 		goto out;
 
 	if (tcon->unix_ext)
-		rc = cifs_get_inode_info_unix(&inode, full_path, inode->i_sb,
+		rc = cifs_get_inode_info_unix(&inode, full_path,
+					      inode_sb(inode),
 					      xid);
 	else
-		rc = cifs_get_inode_info(&inode, full_path, buf, inode->i_sb,
+		rc = cifs_get_inode_info(&inode, full_path, buf,
+					 inode_sb(inode),
 					 xid, fid);
 
 out:
@@ -314,7 +316,7 @@ cifs_new_fileinfo(struct cifs_fid *fid, struct file *file,
 	mutex_init(&cfile->fh_mutex);
 	spin_lock_init(&cfile->file_info_lock);
 
-	cifs_sb_active(inode->i_sb);
+	cifs_sb_active(inode_sb(inode));
 
 	/*
 	 * If the server returned a read oplock and we have mandatory brlocks,
@@ -369,7 +371,7 @@ void cifsFileInfo_put(struct cifsFileInfo *cifs_file)
 	struct cifs_tcon *tcon = tlink_tcon(cifs_file->tlink);
 	struct TCP_Server_Info *server = tcon->ses->server;
 	struct cifsInodeInfo *cifsi = CIFS_I(inode);
-	struct super_block *sb = inode->i_sb;
+	struct super_block *sb = inode_sb(inode);
 	struct cifs_sb_info *cifs_sb = CIFS_SB(sb);
 	struct cifsLockInfo *li, *tmp;
 	struct cifs_fid fid;
@@ -466,7 +468,7 @@ int cifs_open(struct inode *inode, struct file *file)
 
 	xid = get_xid();
 
-	cifs_sb = CIFS_SB(inode->i_sb);
+	cifs_sb = CIFS_SB(inode_sb(inode));
 	tlink = cifs_sb_tlink(cifs_sb);
 	if (IS_ERR(tlink)) {
 		free_xid(xid);
@@ -501,9 +503,9 @@ int cifs_open(struct inode *inode, struct file *file)
 	    cap_unix(tcon->ses) && (CIFS_UNIX_POSIX_PATH_OPS_CAP &
 				le64_to_cpu(tcon->fsUnixInfo.Capability))) {
 		/* can not refresh inode info since size could be stale */
-		rc = cifs_posix_open(full_path, &inode, inode->i_sb,
-				cifs_sb->mnt_file_mode /* ignored */,
-				file->f_flags, &oplock, &fid.netfid, xid);
+		rc = cifs_posix_open(full_path, &inode, inode_sb(inode),
+				     cifs_sb->mnt_file_mode /* ignored */,
+				     file->f_flags, &oplock, &fid.netfid, xid);
 		if (rc == 0) {
 			cifs_dbg(FYI, "posix open succeeded\n");
 			posix_open_ok = true;
@@ -634,7 +636,7 @@ cifs_reopen_file(struct cifsFileInfo *cfile, bool can_flush)
 	}
 
 	inode = d_inode(cfile->dentry);
-	cifs_sb = CIFS_SB(inode->i_sb);
+	cifs_sb = CIFS_SB(inode_sb(inode));
 	tcon = tlink_tcon(cfile->tlink);
 	server = tcon->ses->server;
 
@@ -670,7 +672,7 @@ cifs_reopen_file(struct cifsFileInfo *cfile, bool can_flush)
 		unsigned int oflags = cfile->f_flags &
 						~(O_CREAT | O_EXCL | O_TRUNC);
 
-		rc = cifs_posix_open(full_path, NULL, inode->i_sb,
+		rc = cifs_posix_open(full_path, NULL, inode_sb(inode),
 				     cifs_sb->mnt_file_mode /* ignored */,
 				     oflags, &oplock, &cfile->fid.netfid, xid);
 		if (rc == 0) {
@@ -734,10 +736,10 @@ cifs_reopen_file(struct cifsFileInfo *cfile, bool can_flush)
 
 		if (tcon->unix_ext)
 			rc = cifs_get_inode_info_unix(&inode, full_path,
-						      inode->i_sb, xid);
+						      inode_sb(inode), xid);
 		else
 			rc = cifs_get_inode_info(&inode, full_path, NULL,
-						 inode->i_sb, xid, NULL);
+						 inode_sb(inode), xid, NULL);
 	}
 	/*
 	 * Else we are writing out data to server already and could deadlock if
@@ -1790,7 +1792,7 @@ struct cifsFileInfo *find_readable_file(struct cifsInodeInfo *cifs_inode,
 					bool fsuid_only)
 {
 	struct cifsFileInfo *open_file = NULL;
-	struct cifs_sb_info *cifs_sb = CIFS_SB(cifs_inode->vfs_inode.i_sb);
+	struct cifs_sb_info *cifs_sb = CIFS_SB(inode_sb(&cifs_inode->vfs_inode));
 	struct cifs_tcon *tcon = cifs_sb_master_tcon(cifs_sb);
 
 	/* only filter by fsuid on multiuser mounts */
@@ -1841,7 +1843,7 @@ struct cifsFileInfo *find_writable_file(struct cifsInodeInfo *cifs_inode,
 		return NULL;
 	}
 
-	cifs_sb = CIFS_SB(cifs_inode->vfs_inode.i_sb);
+	cifs_sb = CIFS_SB(inode_sb(&cifs_inode->vfs_inode));
 	tcon = cifs_sb_master_tcon(cifs_sb);
 
 	/* only filter by fsuid on multiuser mounts */
@@ -2093,7 +2095,7 @@ wdata_send_pages(struct cifs_writedata *wdata, unsigned int nr_pages,
 static int cifs_writepages(struct address_space *mapping,
 			   struct writeback_control *wbc)
 {
-	struct cifs_sb_info *cifs_sb = CIFS_SB(mapping->host->i_sb);
+	struct cifs_sb_info *cifs_sb = CIFS_SB(inode_sb(mapping->host));
 	struct TCP_Server_Info *server;
 	bool done = false, scanned = false, range_whole = false;
 	pgoff_t end, index;
@@ -2321,7 +2323,7 @@ int cifs_strict_fsync(struct file *file, loff_t start, loff_t end,
 	struct TCP_Server_Info *server;
 	struct cifsFileInfo *smbfile = file->private_data;
 	struct inode *inode = file_inode(file);
-	struct cifs_sb_info *cifs_sb = CIFS_SB(inode->i_sb);
+	struct cifs_sb_info *cifs_sb = CIFS_SB(inode_sb(inode));
 
 	rc = file_write_and_wait_range(file, start, end);
 	if (rc)
@@ -2837,7 +2839,7 @@ cifs_strict_writev(struct kiocb *iocb, struct iov_iter *from)
 {
 	struct inode *inode = file_inode(iocb->ki_filp);
 	struct cifsInodeInfo *cinode = CIFS_I(inode);
-	struct cifs_sb_info *cifs_sb = CIFS_SB(inode->i_sb);
+	struct cifs_sb_info *cifs_sb = CIFS_SB(inode_sb(inode));
 	struct cifsFileInfo *cfile = (struct cifsFileInfo *)
 						iocb->ki_filp->private_data;
 	struct cifs_tcon *tcon = tlink_tcon(cfile->tlink);
@@ -3333,7 +3335,7 @@ cifs_strict_readv(struct kiocb *iocb, struct iov_iter *to)
 {
 	struct inode *inode = file_inode(iocb->ki_filp);
 	struct cifsInodeInfo *cinode = CIFS_I(inode);
-	struct cifs_sb_info *cifs_sb = CIFS_SB(inode->i_sb);
+	struct cifs_sb_info *cifs_sb = CIFS_SB(inode_sb(inode));
 	struct cifsFileInfo *cfile = (struct cifsFileInfo *)
 						iocb->ki_filp->private_data;
 	struct cifs_tcon *tcon = tlink_tcon(cfile->tlink);
@@ -3900,7 +3902,7 @@ static int is_inode_writable(struct cifsInodeInfo *cifs_inode)
 {
 	struct cifsFileInfo *open_file;
 	struct cifs_tcon *tcon =
-		cifs_sb_master_tcon(CIFS_SB(cifs_inode->vfs_inode.i_sb));
+		cifs_sb_master_tcon(CIFS_SB(inode_sb(&cifs_inode->vfs_inode)));
 
 	spin_lock(&tcon->open_file_lock);
 	list_for_each_entry(open_file, &cifs_inode->openFileList, flist) {
@@ -3928,7 +3930,7 @@ bool is_size_safe_to_change(struct cifsInodeInfo *cifsInode, __u64 end_of_file)
 		/* This inode is open for write at least once */
 		struct cifs_sb_info *cifs_sb;
 
-		cifs_sb = CIFS_SB(cifsInode->vfs_inode.i_sb);
+		cifs_sb = CIFS_SB(inode_sb(&cifsInode->vfs_inode));
 		if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_DIRECT_IO) {
 			/* since no page cache to corrupt on directio
 			we can change size safely */
diff --git a/fs/cifs/fscache.c b/fs/cifs/fscache.c
index 8d4b7bc8ae91..bb24a08d7edd 100644
--- a/fs/cifs/fscache.c
+++ b/fs/cifs/fscache.c
@@ -61,7 +61,7 @@ void cifs_fscache_release_super_cookie(struct cifs_tcon *tcon)
 static void cifs_fscache_enable_inode_cookie(struct inode *inode)
 {
 	struct cifsInodeInfo *cifsi = CIFS_I(inode);
-	struct cifs_sb_info *cifs_sb = CIFS_SB(inode->i_sb);
+	struct cifs_sb_info *cifs_sb = CIFS_SB(inode_sb(inode));
 	struct cifs_tcon *tcon = cifs_sb_master_tcon(cifs_sb);
 
 	if (cifsi->fscache)
@@ -109,7 +109,7 @@ void cifs_fscache_set_inode_cookie(struct inode *inode, struct file *filp)
 void cifs_fscache_reset_inode_cookie(struct inode *inode)
 {
 	struct cifsInodeInfo *cifsi = CIFS_I(inode);
-	struct cifs_sb_info *cifs_sb = CIFS_SB(inode->i_sb);
+	struct cifs_sb_info *cifs_sb = CIFS_SB(inode_sb(inode));
 	struct fscache_cookie *old = cifsi->fscache;
 
 	if (cifsi->fscache) {
diff --git a/fs/cifs/inode.c b/fs/cifs/inode.c
index 8f9a8cc7cc62..b29d09642214 100644
--- a/fs/cifs/inode.c
+++ b/fs/cifs/inode.c
@@ -39,7 +39,7 @@
 
 static void cifs_set_ops(struct inode *inode)
 {
-	struct cifs_sb_info *cifs_sb = CIFS_SB(inode->i_sb);
+	struct cifs_sb_info *cifs_sb = CIFS_SB(inode_sb(inode));
 
 	switch (inode->i_mode & S_IFMT) {
 	case S_IFREG:
@@ -157,7 +157,7 @@ void
 cifs_fattr_to_inode(struct inode *inode, struct cifs_fattr *fattr)
 {
 	struct cifsInodeInfo *cifs_i = CIFS_I(inode);
-	struct cifs_sb_info *cifs_sb = CIFS_SB(inode->i_sb);
+	struct cifs_sb_info *cifs_sb = CIFS_SB(inode_sb(inode));
 
 	cifs_revalidate_cache(inode, fattr);
 
@@ -340,7 +340,7 @@ cifs_get_file_info_unix(struct file *filp)
 	FILE_UNIX_BASIC_INFO find_data;
 	struct cifs_fattr fattr;
 	struct inode *inode = file_inode(filp);
-	struct cifs_sb_info *cifs_sb = CIFS_SB(inode->i_sb);
+	struct cifs_sb_info *cifs_sb = CIFS_SB(inode_sb(inode));
 	struct cifsFileInfo *cfile = filp->private_data;
 	struct cifs_tcon *tcon = tlink_tcon(cfile->tlink);
 
@@ -349,7 +349,7 @@ cifs_get_file_info_unix(struct file *filp)
 	if (!rc) {
 		cifs_unix_basic_to_fattr(&fattr, &find_data, cifs_sb);
 	} else if (rc == -EREMOTE) {
-		cifs_create_dfs_fattr(&fattr, inode->i_sb);
+		cifs_create_dfs_fattr(&fattr, inode_sb(inode));
 		rc = 0;
 	}
 
@@ -675,11 +675,12 @@ cifs_get_file_info(struct file *filp)
 	rc = server->ops->query_file_info(xid, tcon, &cfile->fid, &find_data);
 	switch (rc) {
 	case 0:
-		cifs_all_info_to_fattr(&fattr, &find_data, inode->i_sb, false,
+		cifs_all_info_to_fattr(&fattr, &find_data, inode_sb(inode),
+				       false,
 				       false);
 		break;
 	case -EREMOTE:
-		cifs_create_dfs_fattr(&fattr, inode->i_sb);
+		cifs_create_dfs_fattr(&fattr, inode_sb(inode));
 		rc = 0;
 		break;
 	case -EOPNOTSUPP:
@@ -1078,7 +1079,7 @@ cifs_set_file_info(struct inode *inode, struct iattr *attrs, unsigned int xid,
 		   char *full_path, __u32 dosattr)
 {
 	bool set_time = false;
-	struct cifs_sb_info *cifs_sb = CIFS_SB(inode->i_sb);
+	struct cifs_sb_info *cifs_sb = CIFS_SB(inode_sb(inode));
 	struct TCP_Server_Info *server;
 	FILE_BASIC_INFO	info_buf;
 
@@ -1137,7 +1138,7 @@ cifs_rename_pending_delete(const char *full_path, struct dentry *dentry,
 	struct cifs_open_parms oparms;
 	struct inode *inode = d_inode(dentry);
 	struct cifsInodeInfo *cifsInode = CIFS_I(inode);
-	struct cifs_sb_info *cifs_sb = CIFS_SB(inode->i_sb);
+	struct cifs_sb_info *cifs_sb = CIFS_SB(inode_sb(inode));
 	struct tcon_link *tlink;
 	struct cifs_tcon *tcon;
 	__u32 dosattr, origattr;
@@ -1277,7 +1278,7 @@ int cifs_unlink(struct inode *dir, struct dentry *dentry)
 	char *full_path = NULL;
 	struct inode *inode = d_inode(dentry);
 	struct cifsInodeInfo *cifs_inode;
-	struct super_block *sb = dir->i_sb;
+	struct super_block *sb = inode_sb(dir);
 	struct cifs_sb_info *cifs_sb = CIFS_SB(sb);
 	struct tcon_link *tlink;
 	struct cifs_tcon *tcon;
@@ -1389,10 +1390,12 @@ cifs_mkdir_qinfo(struct inode *parent, struct dentry *dentry, umode_t mode,
 	struct inode *inode = NULL;
 
 	if (tcon->unix_ext)
-		rc = cifs_get_inode_info_unix(&inode, full_path, parent->i_sb,
+		rc = cifs_get_inode_info_unix(&inode, full_path,
+					      inode_sb(parent),
 					      xid);
 	else
-		rc = cifs_get_inode_info(&inode, full_path, NULL, parent->i_sb,
+		rc = cifs_get_inode_info(&inode, full_path, NULL,
+					 inode_sb(parent),
 					 xid, NULL);
 
 	if (rc)
@@ -1490,8 +1493,8 @@ cifs_posix_mkdir(struct inode *inode, struct dentry *dentry, umode_t mode,
 	 */
 
 	cifs_unix_basic_to_fattr(&fattr, info, cifs_sb);
-	cifs_fill_uniqueid(inode->i_sb, &fattr);
-	newinode = cifs_iget(inode->i_sb, &fattr);
+	cifs_fill_uniqueid(inode_sb(inode), &fattr);
+	newinode = cifs_iget(inode_sb(inode), &fattr);
 	if (!newinode)
 		goto posix_mkdir_get_info;
 
@@ -1528,7 +1531,7 @@ int cifs_mkdir(struct inode *inode, struct dentry *direntry, umode_t mode)
 	cifs_dbg(FYI, "In cifs_mkdir, mode = 0x%hx inode = 0x%p\n",
 		 mode, inode);
 
-	cifs_sb = CIFS_SB(inode->i_sb);
+	cifs_sb = CIFS_SB(inode_sb(inode));
 	tlink = cifs_sb_tlink(cifs_sb);
 	if (IS_ERR(tlink))
 		return PTR_ERR(tlink);
@@ -1600,7 +1603,7 @@ int cifs_rmdir(struct inode *inode, struct dentry *direntry)
 		goto rmdir_exit;
 	}
 
-	cifs_sb = CIFS_SB(inode->i_sb);
+	cifs_sb = CIFS_SB(inode_sb(inode));
 	tlink = cifs_sb_tlink(cifs_sb);
 	if (IS_ERR(tlink)) {
 		rc = PTR_ERR(tlink);
@@ -1722,7 +1725,7 @@ cifs_rename2(struct inode *source_dir, struct dentry *source_dentry,
 	if (flags & ~RENAME_NOREPLACE)
 		return -EINVAL;
 
-	cifs_sb = CIFS_SB(source_dir->i_sb);
+	cifs_sb = CIFS_SB(inode_sb(source_dir));
 	tlink = cifs_sb_tlink(cifs_sb);
 	if (IS_ERR(tlink))
 		return PTR_ERR(tlink);
@@ -1825,7 +1828,7 @@ static bool
 cifs_inode_needs_reval(struct inode *inode)
 {
 	struct cifsInodeInfo *cifs_i = CIFS_I(inode);
-	struct cifs_sb_info *cifs_sb = CIFS_SB(inode->i_sb);
+	struct cifs_sb_info *cifs_sb = CIFS_SB(inode_sb(inode));
 
 	if (CIFS_CACHE_READ(cifs_i))
 		return false;
@@ -2088,7 +2091,7 @@ cifs_set_file_size(struct inode *inode, struct iattr *attrs,
 	int rc;
 	struct cifsFileInfo *open_file;
 	struct cifsInodeInfo *cifsInode = CIFS_I(inode);
-	struct cifs_sb_info *cifs_sb = CIFS_SB(inode->i_sb);
+	struct cifs_sb_info *cifs_sb = CIFS_SB(inode_sb(inode));
 	struct tcon_link *tlink = NULL;
 	struct cifs_tcon *tcon = NULL;
 	struct TCP_Server_Info *server;
@@ -2160,7 +2163,7 @@ cifs_setattr_unix(struct dentry *direntry, struct iattr *attrs)
 	char *full_path = NULL;
 	struct inode *inode = d_inode(direntry);
 	struct cifsInodeInfo *cifsInode = CIFS_I(inode);
-	struct cifs_sb_info *cifs_sb = CIFS_SB(inode->i_sb);
+	struct cifs_sb_info *cifs_sb = CIFS_SB(inode_sb(inode));
 	struct tcon_link *tlink;
 	struct cifs_tcon *pTcon;
 	struct cifs_unix_set_info_args *args = NULL;
@@ -2299,7 +2302,7 @@ cifs_setattr_nounix(struct dentry *direntry, struct iattr *attrs)
 	kuid_t uid = INVALID_UID;
 	kgid_t gid = INVALID_GID;
 	struct inode *inode = d_inode(direntry);
-	struct cifs_sb_info *cifs_sb = CIFS_SB(inode->i_sb);
+	struct cifs_sb_info *cifs_sb = CIFS_SB(inode_sb(inode));
 	struct cifsInodeInfo *cifsInode = CIFS_I(inode);
 	char *full_path = NULL;
 	int rc = -EACCES;
diff --git a/fs/cifs/ioctl.c b/fs/cifs/ioctl.c
index 54f32f9143a9..abb71d967084 100644
--- a/fs/cifs/ioctl.c
+++ b/fs/cifs/ioctl.c
@@ -131,7 +131,7 @@ long cifs_ioctl(struct file *filep, unsigned int command, unsigned long arg)
 
 	xid = get_xid();
 
-	cifs_sb = CIFS_SB(inode->i_sb);
+	cifs_sb = CIFS_SB(inode_sb(inode));
 	cifs_dbg(FYI, "cifs ioctl 0x%x\n", command);
 	switch (command) {
 		case FS_IOC_GETFLAGS:
diff --git a/fs/cifs/link.c b/fs/cifs/link.c
index 60b5a11ee11b..bd4d4ddc40a1 100644
--- a/fs/cifs/link.c
+++ b/fs/cifs/link.c
@@ -535,7 +535,7 @@ cifs_hardlink(struct dentry *old_file, struct inode *inode,
 	unsigned int xid;
 	char *from_name = NULL;
 	char *to_name = NULL;
-	struct cifs_sb_info *cifs_sb = CIFS_SB(inode->i_sb);
+	struct cifs_sb_info *cifs_sb = CIFS_SB(inode_sb(inode));
 	struct tcon_link *tlink;
 	struct cifs_tcon *tcon;
 	struct TCP_Server_Info *server;
@@ -625,7 +625,7 @@ cifs_get_link(struct dentry *direntry, struct inode *inode,
 	unsigned int xid;
 	char *full_path = NULL;
 	char *target_path = NULL;
-	struct cifs_sb_info *cifs_sb = CIFS_SB(inode->i_sb);
+	struct cifs_sb_info *cifs_sb = CIFS_SB(inode_sb(inode));
 	struct tcon_link *tlink = NULL;
 	struct cifs_tcon *tcon;
 	struct TCP_Server_Info *server;
@@ -681,7 +681,7 @@ cifs_symlink(struct inode *inode, struct dentry *direntry, const char *symname)
 {
 	int rc = -EOPNOTSUPP;
 	unsigned int xid;
-	struct cifs_sb_info *cifs_sb = CIFS_SB(inode->i_sb);
+	struct cifs_sb_info *cifs_sb = CIFS_SB(inode_sb(inode));
 	struct tcon_link *tlink;
 	struct cifs_tcon *pTcon;
 	char *full_path = NULL;
@@ -719,10 +719,10 @@ cifs_symlink(struct inode *inode, struct dentry *direntry, const char *symname)
 	if (rc == 0) {
 		if (pTcon->unix_ext)
 			rc = cifs_get_inode_info_unix(&newinode, full_path,
-						      inode->i_sb, xid);
+						      inode_sb(inode), xid);
 		else
 			rc = cifs_get_inode_info(&newinode, full_path, NULL,
-						 inode->i_sb, xid, NULL);
+						 inode_sb(inode), xid, NULL);
 
 		if (rc != 0) {
 			cifs_dbg(FYI, "Create symlink ok, getinodeinfo fail rc = %d\n",
diff --git a/fs/cifs/readdir.c b/fs/cifs/readdir.c
index a27fc8791551..19e3a9f6f89c 100644
--- a/fs/cifs/readdir.c
+++ b/fs/cifs/readdir.c
@@ -689,7 +689,7 @@ static int cifs_filldir(char *find_entry, struct file *file,
 		char *scratch_buf, unsigned int max_len)
 {
 	struct cifsFileInfo *file_info = file->private_data;
-	struct super_block *sb = file_inode(file)->i_sb;
+	struct super_block *sb = inode_sb(file_inode(file));
 	struct cifs_sb_info *cifs_sb = CIFS_SB(sb);
 	struct cifs_dirent de = { NULL, };
 	struct cifs_fattr fattr;
diff --git a/fs/cifs/smb1ops.c b/fs/cifs/smb1ops.c
index 3d495e440c87..a0385106b711 100644
--- a/fs/cifs/smb1ops.c
+++ b/fs/cifs/smb1ops.c
@@ -774,7 +774,7 @@ smb_set_file_info(struct inode *inode, const char *full_path,
 	struct cifs_open_parms oparms;
 	struct cifsFileInfo *open_file;
 	struct cifsInodeInfo *cinode = CIFS_I(inode);
-	struct cifs_sb_info *cifs_sb = CIFS_SB(inode->i_sb);
+	struct cifs_sb_info *cifs_sb = CIFS_SB(inode_sb(inode));
 	struct tcon_link *tlink = NULL;
 	struct cifs_tcon *tcon;
 
@@ -1013,7 +1013,7 @@ cifs_is_read_op(__u32 oplock)
 static unsigned int
 cifs_wp_retry_size(struct inode *inode)
 {
-	return CIFS_SB(inode->i_sb)->wsize;
+	return CIFS_SB(inode_sb(inode))->wsize;
 }
 
 static bool
diff --git a/fs/cifs/smb2inode.c b/fs/cifs/smb2inode.c
index 1238cd3552f9..74ac53fc470b 100644
--- a/fs/cifs/smb2inode.c
+++ b/fs/cifs/smb2inode.c
@@ -262,7 +262,7 @@ int
 smb2_set_file_info(struct inode *inode, const char *full_path,
 		   FILE_BASIC_INFO *buf, const unsigned int xid)
 {
-	struct cifs_sb_info *cifs_sb = CIFS_SB(inode->i_sb);
+	struct cifs_sb_info *cifs_sb = CIFS_SB(inode_sb(inode));
 	struct tcon_link *tlink;
 	int rc;
 
diff --git a/fs/cifs/smb2ops.c b/fs/cifs/smb2ops.c
index eb68e2fcc500..932e8661c2a6 100644
--- a/fs/cifs/smb2ops.c
+++ b/fs/cifs/smb2ops.c
@@ -1608,7 +1608,7 @@ set_smb2_acl(struct cifs_ntsd *pnntsd, __u32 acllen,
 	unsigned int xid;
 	int rc, access_flags = 0;
 	struct cifs_tcon *tcon;
-	struct cifs_sb_info *cifs_sb = CIFS_SB(inode->i_sb);
+	struct cifs_sb_info *cifs_sb = CIFS_SB(inode_sb(inode));
 	struct tcon_link *tlink = cifs_sb_tlink(cifs_sb);
 	struct cifs_fid fid;
 	struct cifs_open_parms oparms;
@@ -2039,7 +2039,7 @@ smb3_parse_lease_buf(void *buf, unsigned int *epoch)
 static unsigned int
 smb2_wp_retry_size(struct inode *inode)
 {
-	return min_t(unsigned int, CIFS_SB(inode->i_sb)->wsize,
+	return min_t(unsigned int, CIFS_SB(inode_sb(inode))->wsize,
 		     SMB2_MAX_BUFFER_SIZE);
 }
 
-- 
2.15.1

^ permalink raw reply	[flat|nested] 88+ messages in thread

* [PATCH 21/76] fs/coda: Use inode_sb() helper instead of inode->i_sb
  2018-05-08 18:03 [RFC][PATCH 0/76] vfs: 'views' for filesystems with more than one root Mark Fasheh
                   ` (19 preceding siblings ...)
  2018-05-08 18:03 ` [PATCH 20/76] fs/cifs: " Mark Fasheh
@ 2018-05-08 18:03 ` Mark Fasheh
  2018-05-08 18:03 ` [PATCH 22/76] fs/configfs: " Mark Fasheh
                   ` (55 subsequent siblings)
  76 siblings, 0 replies; 88+ messages in thread
From: Mark Fasheh @ 2018-05-08 18:03 UTC (permalink / raw)
  To: linux-fsdevel; +Cc: linux-kernel, linux-btrfs, Mark Fasheh

Signed-off-by: Mark Fasheh <mfasheh@suse.de>
---
 fs/coda/dir.c     | 25 +++++++++++++------------
 fs/coda/file.c    |  7 ++++---
 fs/coda/inode.c   |  4 ++--
 fs/coda/pioctl.c  |  4 ++--
 fs/coda/symlink.c |  2 +-
 5 files changed, 22 insertions(+), 20 deletions(-)

diff --git a/fs/coda/dir.c b/fs/coda/dir.c
index 00876ddadb43..89deb3532f5e 100644
--- a/fs/coda/dir.c
+++ b/fs/coda/dir.c
@@ -40,7 +40,7 @@ static int coda_return_EIO(void)
 /* access routines: lookup, readlink, permission */
 static struct dentry *coda_lookup(struct inode *dir, struct dentry *entry, unsigned int flags)
 {
-	struct super_block *sb = dir->i_sb;
+	struct super_block *sb = inode_sb(dir);
 	const char *name = entry->d_name.name;
 	size_t length = entry->d_name.len;
 	struct inode *inode;
@@ -91,7 +91,7 @@ int coda_permission(struct inode *inode, int mask)
 	if (coda_cache_check(inode, mask))
 		return 0;
 
-	error = venus_access(inode->i_sb, coda_i2f(inode), mask);
+	error = venus_access(inode_sb(inode), coda_i2f(inode), mask);
     
 	if (!error)
 		coda_cache_enter(inode, mask);
@@ -144,12 +144,12 @@ static int coda_create(struct inode *dir, struct dentry *de, umode_t mode, bool
 	if (is_root_inode(dir) && coda_iscontrol(name, length))
 		return -EPERM;
 
-	error = venus_create(dir->i_sb, coda_i2f(dir), name, length, 
+	error = venus_create(inode_sb(dir), coda_i2f(dir), name, length, 
 				0, mode, &newfid, &attrs);
 	if (error)
 		goto err_out;
 
-	inode = coda_iget(dir->i_sb, &newfid, &attrs);
+	inode = coda_iget(inode_sb(dir), &newfid, &attrs);
 	if (IS_ERR(inode)) {
 		error = PTR_ERR(inode);
 		goto err_out;
@@ -177,12 +177,12 @@ static int coda_mkdir(struct inode *dir, struct dentry *de, umode_t mode)
 		return -EPERM;
 
 	attrs.va_mode = mode;
-	error = venus_mkdir(dir->i_sb, coda_i2f(dir), 
+	error = venus_mkdir(inode_sb(dir), coda_i2f(dir), 
 			       name, len, &newfid, &attrs);
 	if (error)
 		goto err_out;
          
-	inode = coda_iget(dir->i_sb, &newfid, &attrs);
+	inode = coda_iget(inode_sb(dir), &newfid, &attrs);
 	if (IS_ERR(inode)) {
 		error = PTR_ERR(inode);
 		goto err_out;
@@ -210,7 +210,7 @@ static int coda_link(struct dentry *source_de, struct inode *dir_inode,
 	if (is_root_inode(dir_inode) && coda_iscontrol(name, len))
 		return -EPERM;
 
-	error = venus_link(dir_inode->i_sb, coda_i2f(inode),
+	error = venus_link(inode_sb(dir_inode), coda_i2f(inode),
 			   coda_i2f(dir_inode), (const char *)name, len);
 	if (error) {
 		d_drop(de);
@@ -245,7 +245,8 @@ static int coda_symlink(struct inode *dir_inode, struct dentry *de,
 	 * an inode for the entry we have to drop it.
 	 */
 	d_drop(de);
-	error = venus_symlink(dir_inode->i_sb, coda_i2f(dir_inode), name, len,
+	error = venus_symlink(inode_sb(dir_inode), coda_i2f(dir_inode), name,
+			      len,
 			      symname, symlen);
 
 	/* mtime is no good anymore */
@@ -262,7 +263,7 @@ static int coda_unlink(struct inode *dir, struct dentry *de)
 	const char *name = de->d_name.name;
 	int len = de->d_name.len;
 
-	error = venus_remove(dir->i_sb, coda_i2f(dir), name, len);
+	error = venus_remove(inode_sb(dir), coda_i2f(dir), name, len);
 	if (error)
 		return error;
 
@@ -277,7 +278,7 @@ static int coda_rmdir(struct inode *dir, struct dentry *de)
 	int len = de->d_name.len;
 	int error;
 
-	error = venus_rmdir(dir->i_sb, coda_i2f(dir), name, len);
+	error = venus_rmdir(inode_sb(dir), coda_i2f(dir), name, len);
 	if (!error) {
 		/* VFS may delete the child */
 		if (d_really_is_positive(de))
@@ -304,7 +305,7 @@ static int coda_rename(struct inode *old_dir, struct dentry *old_dentry,
 	if (flags)
 		return -EINVAL;
 
-	error = venus_rename(old_dir->i_sb, coda_i2f(old_dir),
+	error = venus_rename(inode_sb(old_dir), coda_i2f(old_dir),
 			     coda_i2f(new_dir), old_length, new_length,
 			     (const char *) old_name, (const char *)new_name);
 	if (!error) {
@@ -529,7 +530,7 @@ int coda_revalidate_inode(struct inode *inode)
 		return 0;
 
 	if (cii->c_flags & (C_VATTR | C_PURGE | C_FLUSH)) {
-		error = venus_getattr(inode->i_sb, &(cii->c_fid), &attr);
+		error = venus_getattr(inode_sb(inode), &(cii->c_fid), &attr);
 		if (error)
 			return -EIO;
 
diff --git a/fs/coda/file.c b/fs/coda/file.c
index 1cbc1f2298ee..6f84de9d1197 100644
--- a/fs/coda/file.c
+++ b/fs/coda/file.c
@@ -112,7 +112,8 @@ int coda_open(struct inode *coda_inode, struct file *coda_file)
 	if (!cfi)
 		return -ENOMEM;
 
-	error = venus_open(coda_inode->i_sb, coda_i2f(coda_inode), coda_flags,
+	error = venus_open(inode_sb(coda_inode), coda_i2f(coda_inode),
+			   coda_flags,
 			   &host_file);
 	if (!host_file)
 		error = -EIO;
@@ -145,7 +146,7 @@ int coda_release(struct inode *coda_inode, struct file *coda_file)
 	cfi = CODA_FTOC(coda_file);
 	BUG_ON(!cfi || cfi->cfi_magic != CODA_MAGIC);
 
-	err = venus_close(coda_inode->i_sb, coda_i2f(coda_inode),
+	err = venus_close(inode_sb(coda_inode), coda_i2f(coda_inode),
 			  coda_flags, coda_file->f_cred->fsuid);
 
 	host_inode = file_inode(cfi->cfi_container);
@@ -191,7 +192,7 @@ int coda_fsync(struct file *coda_file, loff_t start, loff_t end, int datasync)
 
 	err = vfs_fsync(host_file, datasync);
 	if (!err && !datasync)
-		err = venus_fsync(coda_inode->i_sb, coda_i2f(coda_inode));
+		err = venus_fsync(inode_sb(coda_inode), coda_i2f(coda_inode));
 	inode_unlock(coda_inode);
 
 	return err;
diff --git a/fs/coda/inode.c b/fs/coda/inode.c
index 97424cf206c0..b4f3f9ace9fc 100644
--- a/fs/coda/inode.c
+++ b/fs/coda/inode.c
@@ -218,7 +218,7 @@ static int coda_fill_super(struct super_block *sb, void *data, int silent)
 	} 
 
 	pr_info("%s: rootinode is %ld dev %s\n",
-		__func__, root->i_ino, root->i_sb->s_id);
+		__func__, root->i_ino, inode_sb(root)->s_id);
 	sb->s_root = d_make_root(root);
 	if (!sb->s_root) {
 		error = -EINVAL;
@@ -275,7 +275,7 @@ int coda_setattr(struct dentry *de, struct iattr *iattr)
 	vattr.va_type = C_VNON; /* cannot set type */
 
 	/* Venus is responsible for truncating the container-file!!! */
-	error = venus_setattr(inode->i_sb, coda_i2f(inode), &vattr);
+	error = venus_setattr(inode_sb(inode), coda_i2f(inode), &vattr);
 
 	if (!error) {
 	        coda_vattr_to_iattr(inode, &vattr); 
diff --git a/fs/coda/pioctl.c b/fs/coda/pioctl.c
index e0c17b7dccce..c7158c04aba7 100644
--- a/fs/coda/pioctl.c
+++ b/fs/coda/pioctl.c
@@ -75,7 +75,7 @@ static long coda_pioctl(struct file *filp, unsigned int cmd,
 	target_inode = d_inode(path.dentry);
 
 	/* return if it is not a Coda inode */
-	if (target_inode->i_sb != inode->i_sb) {
+	if (inode_sb(target_inode) != inode_sb(inode)) {
 		error = -EINVAL;
 		goto out;
 	}
@@ -83,7 +83,7 @@ static long coda_pioctl(struct file *filp, unsigned int cmd,
 	/* now proceed to make the upcall */
 	cnp = ITOC(target_inode);
 
-	error = venus_pioctl(inode->i_sb, &(cnp->c_fid), cmd, &data);
+	error = venus_pioctl(inode_sb(inode), &(cnp->c_fid), cmd, &data);
 out:
 	path_put(&path);
 	return error;
diff --git a/fs/coda/symlink.c b/fs/coda/symlink.c
index 202297d156df..68dff2c5df74 100644
--- a/fs/coda/symlink.c
+++ b/fs/coda/symlink.c
@@ -31,7 +31,7 @@ static int coda_symlink_filler(struct file *file, struct page *page)
 
 	cii = ITOC(inode);
 
-	error = venus_readlink(inode->i_sb, &cii->c_fid, p, &len);
+	error = venus_readlink(inode_sb(inode), &cii->c_fid, p, &len);
 	if (error)
 		goto fail;
 	SetPageUptodate(page);
-- 
2.15.1

^ permalink raw reply	[flat|nested] 88+ messages in thread

* [PATCH 22/76] fs/configfs: Use inode_sb() helper instead of inode->i_sb
  2018-05-08 18:03 [RFC][PATCH 0/76] vfs: 'views' for filesystems with more than one root Mark Fasheh
                   ` (20 preceding siblings ...)
  2018-05-08 18:03 ` [PATCH 21/76] fs/coda: " Mark Fasheh
@ 2018-05-08 18:03 ` Mark Fasheh
  2018-05-08 18:03 ` [PATCH 23/76] fs/cramfs: " Mark Fasheh
                   ` (54 subsequent siblings)
  76 siblings, 0 replies; 88+ messages in thread
From: Mark Fasheh @ 2018-05-08 18:03 UTC (permalink / raw)
  To: linux-fsdevel; +Cc: linux-kernel, linux-btrfs, Mark Fasheh

Signed-off-by: Mark Fasheh <mfasheh@suse.de>
---
 fs/configfs/inode.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/fs/configfs/inode.c b/fs/configfs/inode.c
index ad718e5e37bb..4f28a7445336 100644
--- a/fs/configfs/inode.c
+++ b/fs/configfs/inode.c
@@ -91,13 +91,13 @@ int configfs_setattr(struct dentry * dentry, struct iattr * iattr)
 		sd_iattr->ia_gid = iattr->ia_gid;
 	if (ia_valid & ATTR_ATIME)
 		sd_iattr->ia_atime = timespec_trunc(iattr->ia_atime,
-						inode->i_sb->s_time_gran);
+						inode_sb(inode)->s_time_gran);
 	if (ia_valid & ATTR_MTIME)
 		sd_iattr->ia_mtime = timespec_trunc(iattr->ia_mtime,
-						inode->i_sb->s_time_gran);
+						inode_sb(inode)->s_time_gran);
 	if (ia_valid & ATTR_CTIME)
 		sd_iattr->ia_ctime = timespec_trunc(iattr->ia_ctime,
-						inode->i_sb->s_time_gran);
+						inode_sb(inode)->s_time_gran);
 	if (ia_valid & ATTR_MODE) {
 		umode_t mode = iattr->ia_mode;
 
-- 
2.15.1

^ permalink raw reply	[flat|nested] 88+ messages in thread

* [PATCH 23/76] fs/cramfs: Use inode_sb() helper instead of inode->i_sb
  2018-05-08 18:03 [RFC][PATCH 0/76] vfs: 'views' for filesystems with more than one root Mark Fasheh
                   ` (21 preceding siblings ...)
  2018-05-08 18:03 ` [PATCH 22/76] fs/configfs: " Mark Fasheh
@ 2018-05-08 18:03 ` Mark Fasheh
  2018-05-08 18:03 ` [PATCH 24/76] fs/crypto: " Mark Fasheh
                   ` (53 subsequent siblings)
  76 siblings, 0 replies; 88+ messages in thread
From: Mark Fasheh @ 2018-05-08 18:03 UTC (permalink / raw)
  To: linux-fsdevel; +Cc: linux-kernel, linux-btrfs, Mark Fasheh

Signed-off-by: Mark Fasheh <mfasheh@suse.de>
---
 fs/cramfs/inode.c | 19 ++++++++++---------
 1 file changed, 10 insertions(+), 9 deletions(-)

diff --git a/fs/cramfs/inode.c b/fs/cramfs/inode.c
index 017b0ab19bc4..eb633de7ccbe 100644
--- a/fs/cramfs/inode.c
+++ b/fs/cramfs/inode.c
@@ -294,7 +294,7 @@ static void *cramfs_read(struct super_block *sb, unsigned int offset,
  */
 static u32 cramfs_get_block_range(struct inode *inode, u32 pgoff, u32 *pages)
 {
-	struct cramfs_sb_info *sbi = CRAMFS_SB(inode->i_sb);
+	struct cramfs_sb_info *sbi = CRAMFS_SB(inode_sb(inode));
 	int i;
 	u32 *blockptrs, first_block_addr;
 
@@ -335,7 +335,7 @@ static u32 cramfs_get_block_range(struct inode *inode, u32 pgoff, u32 *pages)
  */
 static bool cramfs_last_page_is_shared(struct inode *inode)
 {
-	struct cramfs_sb_info *sbi = CRAMFS_SB(inode->i_sb);
+	struct cramfs_sb_info *sbi = CRAMFS_SB(inode_sb(inode));
 	u32 partial, last_page, blockaddr, *blockptrs;
 	char *tail_data;
 
@@ -353,7 +353,7 @@ static bool cramfs_last_page_is_shared(struct inode *inode)
 static int cramfs_physmem_mmap(struct file *file, struct vm_area_struct *vma)
 {
 	struct inode *inode = file_inode(file);
-	struct cramfs_sb_info *sbi = CRAMFS_SB(inode->i_sb);
+	struct cramfs_sb_info *sbi = CRAMFS_SB(inode_sb(inode));
 	unsigned int pages, max_pages, offset;
 	unsigned long address, pgoff = vma->vm_pgoff;
 	char *bailout_reason;
@@ -451,7 +451,7 @@ static unsigned long cramfs_physmem_get_unmapped_area(struct file *file,
 			unsigned long pgoff, unsigned long flags)
 {
 	struct inode *inode = file_inode(file);
-	struct super_block *sb = inode->i_sb;
+	struct super_block *sb = inode_sb(inode);
 	struct cramfs_sb_info *sbi = CRAMFS_SB(sb);
 	unsigned int pages, block_pages, max_pages, offset;
 
@@ -696,7 +696,7 @@ static int cramfs_statfs(struct dentry *dentry, struct kstatfs *buf)
 static int cramfs_readdir(struct file *file, struct dir_context *ctx)
 {
 	struct inode *inode = file_inode(file);
-	struct super_block *sb = inode->i_sb;
+	struct super_block *sb = inode_sb(inode);
 	char *buf;
 	unsigned int offset;
 
@@ -763,14 +763,15 @@ static struct dentry *cramfs_lookup(struct inode *dir, struct dentry *dentry, un
 	int sorted;
 
 	mutex_lock(&read_mutex);
-	sorted = CRAMFS_SB(dir->i_sb)->flags & CRAMFS_FLAG_SORTED_DIRS;
+	sorted = CRAMFS_SB(inode_sb(dir))->flags & CRAMFS_FLAG_SORTED_DIRS;
 	while (offset < dir->i_size) {
 		struct cramfs_inode *de;
 		char *name;
 		int namelen, retval;
 		int dir_off = OFFSET(dir) + offset;
 
-		de = cramfs_read(dir->i_sb, dir_off, sizeof(*de)+CRAMFS_MAXPATHLEN);
+		de = cramfs_read(inode_sb(dir), dir_off,
+				 sizeof(*de)+CRAMFS_MAXPATHLEN);
 		name = (char *)(de+1);
 
 		/* Try to take advantage of sorted directories */
@@ -799,7 +800,7 @@ static struct dentry *cramfs_lookup(struct inode *dir, struct dentry *dentry, un
 		if (retval > 0)
 			continue;
 		if (!retval) {
-			inode = get_cramfs_inode(dir->i_sb, de, dir_off);
+			inode = get_cramfs_inode(inode_sb(dir), de, dir_off);
 			break;
 		}
 		/* else (retval < 0) */
@@ -826,7 +827,7 @@ static int cramfs_readpage(struct file *file, struct page *page)
 	pgdata = kmap(page);
 
 	if (page->index < maxblock) {
-		struct super_block *sb = inode->i_sb;
+		struct super_block *sb = inode_sb(inode);
 		u32 blkptr_offset = OFFSET(inode) + page->index * 4;
 		u32 block_ptr, block_start, block_len;
 		bool uncompressed, direct;
-- 
2.15.1

^ permalink raw reply	[flat|nested] 88+ messages in thread

* [PATCH 24/76] fs/crypto: Use inode_sb() helper instead of inode->i_sb
  2018-05-08 18:03 [RFC][PATCH 0/76] vfs: 'views' for filesystems with more than one root Mark Fasheh
                   ` (22 preceding siblings ...)
  2018-05-08 18:03 ` [PATCH 23/76] fs/cramfs: " Mark Fasheh
@ 2018-05-08 18:03 ` Mark Fasheh
  2018-05-08 18:03 ` [PATCH 25/76] fs/ecryptfs: " Mark Fasheh
                   ` (52 subsequent siblings)
  76 siblings, 0 replies; 88+ messages in thread
From: Mark Fasheh @ 2018-05-08 18:03 UTC (permalink / raw)
  To: linux-fsdevel; +Cc: linux-kernel, linux-btrfs, Mark Fasheh

Signed-off-by: Mark Fasheh <mfasheh@suse.de>
---
 fs/crypto/bio.c     | 10 +++++-----
 fs/crypto/crypto.c  |  4 ++--
 fs/crypto/fname.c   |  4 ++--
 fs/crypto/keyinfo.c |  8 ++++----
 fs/crypto/policy.c  | 12 ++++++------
 5 files changed, 19 insertions(+), 19 deletions(-)

diff --git a/fs/crypto/bio.c b/fs/crypto/bio.c
index 0d5e6a569d58..0f7daacfa3de 100644
--- a/fs/crypto/bio.c
+++ b/fs/crypto/bio.c
@@ -92,7 +92,7 @@ int fscrypt_zeroout_range(const struct inode *inode, pgoff_t lblk,
 	struct bio *bio;
 	int ret, err = 0;
 
-	BUG_ON(inode->i_sb->s_blocksize != PAGE_SIZE);
+	BUG_ON(inode_sb(inode)->s_blocksize != PAGE_SIZE);
 
 	ctx = fscrypt_get_ctx(inode, GFP_NOFS);
 	if (IS_ERR(ctx))
@@ -116,13 +116,13 @@ int fscrypt_zeroout_range(const struct inode *inode, pgoff_t lblk,
 			err = -ENOMEM;
 			goto errout;
 		}
-		bio_set_dev(bio, inode->i_sb->s_bdev);
+		bio_set_dev(bio, inode_sb(inode)->s_bdev);
 		bio->bi_iter.bi_sector =
-			pblk << (inode->i_sb->s_blocksize_bits - 9);
+			pblk << (inode_sb(inode)->s_blocksize_bits - 9);
 		bio_set_op_attrs(bio, REQ_OP_WRITE, 0);
 		ret = bio_add_page(bio, ciphertext_page,
-					inode->i_sb->s_blocksize, 0);
-		if (ret != inode->i_sb->s_blocksize) {
+					inode_sb(inode)->s_blocksize, 0);
+		if (ret != inode_sb(inode)->s_blocksize) {
 			/* should never happen! */
 			WARN_ON(1);
 			bio_put(bio);
diff --git a/fs/crypto/crypto.c b/fs/crypto/crypto.c
index ce654526c0fb..94b88687fe3f 100644
--- a/fs/crypto/crypto.c
+++ b/fs/crypto/crypto.c
@@ -240,7 +240,7 @@ struct page *fscrypt_encrypt_page(const struct inode *inode,
 
 	BUG_ON(len % FS_CRYPTO_BLOCK_SIZE != 0);
 
-	if (inode->i_sb->s_cop->flags & FS_CFLG_OWN_PAGES) {
+	if (inode_sb(inode)->s_cop->flags & FS_CFLG_OWN_PAGES) {
 		/* with inplace-encryption we just encrypt the page */
 		err = fscrypt_do_page_crypto(inode, FS_ENCRYPT, lblk_num, page,
 					     ciphertext_page, len, offs,
@@ -299,7 +299,7 @@ EXPORT_SYMBOL(fscrypt_encrypt_page);
 int fscrypt_decrypt_page(const struct inode *inode, struct page *page,
 			unsigned int len, unsigned int offs, u64 lblk_num)
 {
-	if (!(inode->i_sb->s_cop->flags & FS_CFLG_OWN_PAGES))
+	if (!(inode_sb(inode)->s_cop->flags & FS_CFLG_OWN_PAGES))
 		BUG_ON(!PageLocked(page));
 
 	return fscrypt_do_page_crypto(inode, FS_DECRYPT, lblk_num, page, page,
diff --git a/fs/crypto/fname.c b/fs/crypto/fname.c
index e33f3d3c5ade..cc0e7632e2d6 100644
--- a/fs/crypto/fname.c
+++ b/fs/crypto/fname.c
@@ -102,7 +102,7 @@ static int fname_decrypt(struct inode *inode,
 	char iv[FS_CRYPTO_BLOCK_SIZE];
 	unsigned lim;
 
-	lim = inode->i_sb->s_cop->max_namelen(inode);
+	lim = inode_sb(inode)->s_cop->max_namelen(inode);
 	if (iname->len <= 0 || iname->len > lim)
 		return -EIO;
 
@@ -346,7 +346,7 @@ int fscrypt_setup_filename(struct inode *dir, const struct qstr *iname,
 
 	if (dir->i_crypt_info) {
 		if (!fscrypt_fname_encrypted_size(dir, iname->len,
-						  dir->i_sb->s_cop->max_namelen(dir),
+						  inode_sb(dir)->s_cop->max_namelen(dir),
 						  &fname->crypto_buf.len))
 			return -ENAMETOOLONG;
 		fname->crypto_buf.name = kmalloc(fname->crypto_buf.len,
diff --git a/fs/crypto/keyinfo.c b/fs/crypto/keyinfo.c
index 05f5ee1f0705..13beafec4355 100644
--- a/fs/crypto/keyinfo.c
+++ b/fs/crypto/keyinfo.c
@@ -253,11 +253,11 @@ int fscrypt_get_encryption_info(struct inode *inode)
 	if (inode->i_crypt_info)
 		return 0;
 
-	res = fscrypt_initialize(inode->i_sb->s_cop->flags);
+	res = fscrypt_initialize(inode_sb(inode)->s_cop->flags);
 	if (res)
 		return res;
 
-	res = inode->i_sb->s_cop->get_context(inode, &ctx, sizeof(ctx));
+	res = inode_sb(inode)->s_cop->get_context(inode, &ctx, sizeof(ctx));
 	if (res < 0) {
 		if (!fscrypt_dummy_context_enabled(inode) ||
 		    IS_ENCRYPTED(inode))
@@ -305,9 +305,9 @@ int fscrypt_get_encryption_info(struct inode *inode)
 
 	res = validate_user_key(crypt_info, &ctx, raw_key, FS_KEY_DESC_PREFIX,
 				keysize);
-	if (res && inode->i_sb->s_cop->key_prefix) {
+	if (res && inode_sb(inode)->s_cop->key_prefix) {
 		int res2 = validate_user_key(crypt_info, &ctx, raw_key,
-					     inode->i_sb->s_cop->key_prefix,
+					     inode_sb(inode)->s_cop->key_prefix,
 					     keysize);
 		if (res2) {
 			if (res2 == -ENOKEY)
diff --git a/fs/crypto/policy.c b/fs/crypto/policy.c
index c6d431a5cce9..76d99e0af39a 100644
--- a/fs/crypto/policy.c
+++ b/fs/crypto/policy.c
@@ -52,7 +52,7 @@ static int create_encryption_context_from_policy(struct inode *inode,
 	BUILD_BUG_ON(sizeof(ctx.nonce) != FS_KEY_DERIVATION_NONCE_SIZE);
 	get_random_bytes(ctx.nonce, FS_KEY_DERIVATION_NONCE_SIZE);
 
-	return inode->i_sb->s_cop->set_context(inode, &ctx, sizeof(ctx), NULL);
+	return inode_sb(inode)->s_cop->set_context(inode, &ctx, sizeof(ctx), NULL);
 }
 
 int fscrypt_ioctl_set_policy(struct file *filp, const void __user *arg)
@@ -77,11 +77,11 @@ int fscrypt_ioctl_set_policy(struct file *filp, const void __user *arg)
 
 	inode_lock(inode);
 
-	ret = inode->i_sb->s_cop->get_context(inode, &ctx, sizeof(ctx));
+	ret = inode_sb(inode)->s_cop->get_context(inode, &ctx, sizeof(ctx));
 	if (ret == -ENODATA) {
 		if (!S_ISDIR(inode->i_mode))
 			ret = -ENOTDIR;
-		else if (!inode->i_sb->s_cop->empty_dir(inode))
+		else if (!inode_sb(inode)->s_cop->empty_dir(inode))
 			ret = -ENOTEMPTY;
 		else
 			ret = create_encryption_context_from_policy(inode,
@@ -113,7 +113,7 @@ int fscrypt_ioctl_get_policy(struct file *filp, void __user *arg)
 	if (!IS_ENCRYPTED(inode))
 		return -ENODATA;
 
-	res = inode->i_sb->s_cop->get_context(inode, &ctx, sizeof(ctx));
+	res = inode_sb(inode)->s_cop->get_context(inode, &ctx, sizeof(ctx));
 	if (res < 0 && res != -ERANGE)
 		return res;
 	if (res != sizeof(ctx))
@@ -156,7 +156,7 @@ EXPORT_SYMBOL(fscrypt_ioctl_get_policy);
  */
 int fscrypt_has_permitted_context(struct inode *parent, struct inode *child)
 {
-	const struct fscrypt_operations *cops = parent->i_sb->s_cop;
+	const struct fscrypt_operations *cops = inode_sb(parent)->s_cop;
 	const struct fscrypt_info *parent_ci, *child_ci;
 	struct fscrypt_context parent_ctx, child_ctx;
 	int res;
@@ -258,7 +258,7 @@ int fscrypt_inherit_context(struct inode *parent, struct inode *child,
 	       FS_KEY_DESCRIPTOR_SIZE);
 	get_random_bytes(ctx.nonce, FS_KEY_DERIVATION_NONCE_SIZE);
 	BUILD_BUG_ON(sizeof(ctx) != FSCRYPT_SET_CONTEXT_MAX_SIZE);
-	res = parent->i_sb->s_cop->set_context(child, &ctx,
+	res = inode_sb(parent)->s_cop->set_context(child, &ctx,
 						sizeof(ctx), fs_data);
 	if (res)
 		return res;
-- 
2.15.1

^ permalink raw reply	[flat|nested] 88+ messages in thread

* [PATCH 25/76] fs/ecryptfs: Use inode_sb() helper instead of inode->i_sb
  2018-05-08 18:03 [RFC][PATCH 0/76] vfs: 'views' for filesystems with more than one root Mark Fasheh
                   ` (23 preceding siblings ...)
  2018-05-08 18:03 ` [PATCH 24/76] fs/crypto: " Mark Fasheh
@ 2018-05-08 18:03 ` Mark Fasheh
  2018-05-08 18:03 ` [PATCH 26/76] fs/efivarfs: " Mark Fasheh
                   ` (51 subsequent siblings)
  76 siblings, 0 replies; 88+ messages in thread
From: Mark Fasheh @ 2018-05-08 18:03 UTC (permalink / raw)
  To: linux-fsdevel; +Cc: linux-kernel, linux-btrfs, Mark Fasheh

Signed-off-by: Mark Fasheh <mfasheh@suse.de>
---
 fs/ecryptfs/crypto.c |  5 ++---
 fs/ecryptfs/file.c   |  5 ++---
 fs/ecryptfs/inode.c  | 15 +++++++--------
 3 files changed, 11 insertions(+), 14 deletions(-)

diff --git a/fs/ecryptfs/crypto.c b/fs/ecryptfs/crypto.c
index 846ca150d52e..ae979420d9d1 100644
--- a/fs/ecryptfs/crypto.c
+++ b/fs/ecryptfs/crypto.c
@@ -800,8 +800,7 @@ int ecryptfs_new_file_context(struct inode *ecryptfs_inode)
 	struct ecryptfs_crypt_stat *crypt_stat =
 	    &ecryptfs_inode_to_private(ecryptfs_inode)->crypt_stat;
 	struct ecryptfs_mount_crypt_stat *mount_crypt_stat =
-	    &ecryptfs_superblock_to_private(
-		    ecryptfs_inode->i_sb)->mount_crypt_stat;
+	    &ecryptfs_superblock_to_private(inode_sb(ecryptfs_inode))->mount_crypt_stat;
 	int cipher_name_len;
 	int rc = 0;
 
@@ -1263,7 +1262,7 @@ void ecryptfs_i_size_init(const char *page_virt, struct inode *inode)
 
 	crypt_stat = &ecryptfs_inode_to_private(inode)->crypt_stat;
 	mount_crypt_stat =
-		&ecryptfs_superblock_to_private(inode->i_sb)->mount_crypt_stat;
+		&ecryptfs_superblock_to_private(inode_sb(inode))->mount_crypt_stat;
 	if (mount_crypt_stat->flags & ECRYPTFS_ENCRYPTED_VIEW_ENABLED) {
 		file_size = i_size_read(ecryptfs_inode_to_lower(inode));
 		if (crypt_stat->flags & ECRYPTFS_METADATA_IN_XATTR)
diff --git a/fs/ecryptfs/file.c b/fs/ecryptfs/file.c
index c74ed3ca3372..0fa5050bcbc2 100644
--- a/fs/ecryptfs/file.c
+++ b/fs/ecryptfs/file.c
@@ -109,7 +109,7 @@ static int ecryptfs_readdir(struct file *file, struct dir_context *ctx)
 	struct ecryptfs_getdents_callback buf = {
 		.ctx.actor = ecryptfs_filldir,
 		.caller = ctx,
-		.sb = inode->i_sb,
+		.sb = inode_sb(inode),
 	};
 	lower_file = ecryptfs_file_to_lower(file);
 	rc = iterate_dir(lower_file, &buf.ctx);
@@ -135,8 +135,7 @@ static int read_or_initialize_metadata(struct dentry *dentry)
 	int rc;
 
 	crypt_stat = &ecryptfs_inode_to_private(inode)->crypt_stat;
-	mount_crypt_stat = &ecryptfs_superblock_to_private(
-						inode->i_sb)->mount_crypt_stat;
+	mount_crypt_stat = &ecryptfs_superblock_to_private(inode_sb(inode))->mount_crypt_stat;
 	mutex_lock(&crypt_stat->cs_mutex);
 
 	if (crypt_stat->flags & ECRYPTFS_POLICY_APPLIED &&
diff --git a/fs/ecryptfs/inode.c b/fs/ecryptfs/inode.c
index 847904aa63a9..ea205c666f5b 100644
--- a/fs/ecryptfs/inode.c
+++ b/fs/ecryptfs/inode.c
@@ -88,7 +88,7 @@ static struct inode *__ecryptfs_get_inode(struct inode *lower_inode,
 {
 	struct inode *inode;
 
-	if (lower_inode->i_sb != ecryptfs_superblock_to_lower(sb))
+	if (inode_sb(lower_inode) != ecryptfs_superblock_to_lower(sb))
 		return ERR_PTR(-EXDEV);
 	if (!igrab(lower_inode))
 		return ERR_PTR(-ESTALE);
@@ -194,7 +194,7 @@ ecryptfs_do_create(struct inode *directory_inode,
 		goto out_lock;
 	}
 	inode = __ecryptfs_get_inode(d_inode(lower_dentry),
-				     directory_inode->i_sb);
+				     inode_sb(directory_inode));
 	if (IS_ERR(inode)) {
 		vfs_unlink(d_inode(lower_dir_dentry), lower_dentry, NULL);
 		goto out_lock;
@@ -441,7 +441,7 @@ static int ecryptfs_link(struct dentry *old_dentry, struct inode *dir,
 		      lower_new_dentry, NULL);
 	if (rc || d_really_is_negative(lower_new_dentry))
 		goto out_lock;
-	rc = ecryptfs_interpose(lower_new_dentry, new_dentry, dir->i_sb);
+	rc = ecryptfs_interpose(lower_new_dentry, new_dentry, inode_sb(dir));
 	if (rc)
 		goto out_lock;
 	fsstack_copy_attr_times(dir, d_inode(lower_dir_dentry));
@@ -474,8 +474,7 @@ static int ecryptfs_symlink(struct inode *dir, struct dentry *dentry,
 	lower_dentry = ecryptfs_dentry_to_lower(dentry);
 	dget(lower_dentry);
 	lower_dir_dentry = lock_parent(lower_dentry);
-	mount_crypt_stat = &ecryptfs_superblock_to_private(
-		dir->i_sb)->mount_crypt_stat;
+	mount_crypt_stat = &ecryptfs_superblock_to_private(inode_sb(dir))->mount_crypt_stat;
 	rc = ecryptfs_encrypt_and_encode_filename(&encoded_symname,
 						  &encoded_symlen,
 						  mount_crypt_stat, symname,
@@ -487,7 +486,7 @@ static int ecryptfs_symlink(struct inode *dir, struct dentry *dentry,
 	kfree(encoded_symname);
 	if (rc || d_really_is_negative(lower_dentry))
 		goto out_lock;
-	rc = ecryptfs_interpose(lower_dentry, dentry, dir->i_sb);
+	rc = ecryptfs_interpose(lower_dentry, dentry, inode_sb(dir));
 	if (rc)
 		goto out_lock;
 	fsstack_copy_attr_times(dir, d_inode(lower_dir_dentry));
@@ -511,7 +510,7 @@ static int ecryptfs_mkdir(struct inode *dir, struct dentry *dentry, umode_t mode
 	rc = vfs_mkdir(d_inode(lower_dir_dentry), lower_dentry, mode);
 	if (rc || d_really_is_negative(lower_dentry))
 		goto out;
-	rc = ecryptfs_interpose(lower_dentry, dentry, dir->i_sb);
+	rc = ecryptfs_interpose(lower_dentry, dentry, inode_sb(dir));
 	if (rc)
 		goto out;
 	fsstack_copy_attr_times(dir, d_inode(lower_dir_dentry));
@@ -559,7 +558,7 @@ ecryptfs_mknod(struct inode *dir, struct dentry *dentry, umode_t mode, dev_t dev
 	rc = vfs_mknod(d_inode(lower_dir_dentry), lower_dentry, mode, dev);
 	if (rc || d_really_is_negative(lower_dentry))
 		goto out;
-	rc = ecryptfs_interpose(lower_dentry, dentry, dir->i_sb);
+	rc = ecryptfs_interpose(lower_dentry, dentry, inode_sb(dir));
 	if (rc)
 		goto out;
 	fsstack_copy_attr_times(dir, d_inode(lower_dir_dentry));
-- 
2.15.1

^ permalink raw reply	[flat|nested] 88+ messages in thread

* [PATCH 26/76] fs/efivarfs: Use inode_sb() helper instead of inode->i_sb
  2018-05-08 18:03 [RFC][PATCH 0/76] vfs: 'views' for filesystems with more than one root Mark Fasheh
                   ` (24 preceding siblings ...)
  2018-05-08 18:03 ` [PATCH 25/76] fs/ecryptfs: " Mark Fasheh
@ 2018-05-08 18:03 ` Mark Fasheh
  2018-05-08 18:03 ` [PATCH 27/76] fs/efs: " Mark Fasheh
                   ` (50 subsequent siblings)
  76 siblings, 0 replies; 88+ messages in thread
From: Mark Fasheh @ 2018-05-08 18:03 UTC (permalink / raw)
  To: linux-fsdevel; +Cc: linux-kernel, linux-btrfs, Mark Fasheh

Signed-off-by: Mark Fasheh <mfasheh@suse.de>
---
 fs/efivarfs/inode.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/fs/efivarfs/inode.c b/fs/efivarfs/inode.c
index 71fccccf317e..5e0de72476bf 100644
--- a/fs/efivarfs/inode.c
+++ b/fs/efivarfs/inode.c
@@ -92,7 +92,7 @@ static int efivarfs_create(struct inode *dir, struct dentry *dentry,
 					 dentry->d_name.name, namelen))
 		is_removable = true;
 
-	inode = efivarfs_get_inode(dir->i_sb, dir, mode, 0, is_removable);
+	inode = efivarfs_get_inode(inode_sb(dir), dir, mode, 0, is_removable);
 	if (!inode) {
 		err = -ENOMEM;
 		goto out;
-- 
2.15.1

^ permalink raw reply	[flat|nested] 88+ messages in thread

* [PATCH 27/76] fs/efs: Use inode_sb() helper instead of inode->i_sb
  2018-05-08 18:03 [RFC][PATCH 0/76] vfs: 'views' for filesystems with more than one root Mark Fasheh
                   ` (25 preceding siblings ...)
  2018-05-08 18:03 ` [PATCH 26/76] fs/efivarfs: " Mark Fasheh
@ 2018-05-08 18:03 ` Mark Fasheh
  2018-05-08 18:03 ` [PATCH 28/76] fs/exofs: " Mark Fasheh
                   ` (49 subsequent siblings)
  76 siblings, 0 replies; 88+ messages in thread
From: Mark Fasheh @ 2018-05-08 18:03 UTC (permalink / raw)
  To: linux-fsdevel; +Cc: linux-kernel, linux-btrfs, Mark Fasheh

Signed-off-by: Mark Fasheh <mfasheh@suse.de>
---
 fs/efs/dir.c     | 2 +-
 fs/efs/file.c    | 2 +-
 fs/efs/inode.c   | 6 +++---
 fs/efs/namei.c   | 4 ++--
 fs/efs/symlink.c | 4 ++--
 5 files changed, 9 insertions(+), 9 deletions(-)

diff --git a/fs/efs/dir.c b/fs/efs/dir.c
index f892ac7c2a35..55663c4f49ce 100644
--- a/fs/efs/dir.c
+++ b/fs/efs/dir.c
@@ -42,7 +42,7 @@ static int efs_readdir(struct file *file, struct dir_context *ctx)
 		struct buffer_head *bh;
 
 		/* read the dir block */
-		bh = sb_bread(inode->i_sb, efs_bmap(inode, block));
+		bh = sb_bread(inode_sb(inode), efs_bmap(inode, block));
 
 		if (!bh) {
 			pr_err("%s(): failed to read dir block %d\n",
diff --git a/fs/efs/file.c b/fs/efs/file.c
index 9e641da6fab2..4e7cf6d70872 100644
--- a/fs/efs/file.c
+++ b/fs/efs/file.c
@@ -30,7 +30,7 @@ int efs_get_block(struct inode *inode, sector_t iblock,
 	}
 	phys = efs_map_block(inode, iblock);
 	if (phys)
-		map_bh(bh_result, inode->i_sb, phys);
+		map_bh(bh_result, inode_sb(inode), phys);
 	return 0;
 }
 
diff --git a/fs/efs/inode.c b/fs/efs/inode.c
index cdf0872382af..a62f6029fc1c 100644
--- a/fs/efs/inode.c
+++ b/fs/efs/inode.c
@@ -87,7 +87,7 @@ struct inode *efs_iget(struct super_block *super, unsigned long ino)
 			(EFS_BLOCKSIZE / sizeof(struct efs_dinode))) *
 		sizeof(struct efs_dinode);
 
-	bh = sb_bread(inode->i_sb, block);
+	bh = sb_bread(inode_sb(inode), block);
 	if (!bh) {
 		pr_warn("%s() failed at block %d\n", __func__, block);
 		goto read_inode_error;
@@ -196,7 +196,7 @@ efs_extent_check(efs_extent *ptr, efs_block_t block, struct efs_sb_info *sb) {
 }
 
 efs_block_t efs_map_block(struct inode *inode, efs_block_t block) {
-	struct efs_sb_info    *sb = SUPER_INFO(inode->i_sb);
+	struct efs_sb_info    *sb = SUPER_INFO(inode_sb(inode));
 	struct efs_inode_info *in = INODE_INFO(inode);
 	struct buffer_head    *bh = NULL;
 
@@ -275,7 +275,7 @@ efs_block_t efs_map_block(struct inode *inode, efs_block_t block) {
 		if (first || lastblock != iblock) {
 			if (bh) brelse(bh);
 
-			bh = sb_bread(inode->i_sb, iblock);
+			bh = sb_bread(inode_sb(inode), iblock);
 			if (!bh) {
 				pr_err("%s() failed at block %d\n",
 				       __func__, iblock);
diff --git a/fs/efs/namei.c b/fs/efs/namei.c
index 38961ee1d1af..d1f3132b50a8 100644
--- a/fs/efs/namei.c
+++ b/fs/efs/namei.c
@@ -30,7 +30,7 @@ static efs_ino_t efs_find_entry(struct inode *inode, const char *name, int len)
 
 	for(block = 0; block < inode->i_blocks; block++) {
 
-		bh = sb_bread(inode->i_sb, efs_bmap(inode, block));
+		bh = sb_bread(inode_sb(inode), efs_bmap(inode, block));
 		if (!bh) {
 			pr_err("%s(): failed to read dir block %d\n",
 			       __func__, block);
@@ -69,7 +69,7 @@ struct dentry *efs_lookup(struct inode *dir, struct dentry *dentry, unsigned int
 
 	inodenum = efs_find_entry(dir, dentry->d_name.name, dentry->d_name.len);
 	if (inodenum)
-		inode = efs_iget(dir->i_sb, inodenum);
+		inode = efs_iget(inode_sb(dir), inodenum);
 
 	return d_splice_alias(inode, dentry);
 }
diff --git a/fs/efs/symlink.c b/fs/efs/symlink.c
index 923eb91654d5..f6b8b33e9600 100644
--- a/fs/efs/symlink.c
+++ b/fs/efs/symlink.c
@@ -26,13 +26,13 @@ static int efs_symlink_readpage(struct file *file, struct page *page)
   
 	/* read first 512 bytes of link target */
 	err = -EIO;
-	bh = sb_bread(inode->i_sb, efs_bmap(inode, 0));
+	bh = sb_bread(inode_sb(inode), efs_bmap(inode, 0));
 	if (!bh)
 		goto fail;
 	memcpy(link, bh->b_data, (size > EFS_BLOCKSIZE) ? EFS_BLOCKSIZE : size);
 	brelse(bh);
 	if (size > EFS_BLOCKSIZE) {
-		bh = sb_bread(inode->i_sb, efs_bmap(inode, 1));
+		bh = sb_bread(inode_sb(inode), efs_bmap(inode, 1));
 		if (!bh)
 			goto fail;
 		memcpy(link + EFS_BLOCKSIZE, bh->b_data, size - EFS_BLOCKSIZE);
-- 
2.15.1

^ permalink raw reply	[flat|nested] 88+ messages in thread

* [PATCH 28/76] fs/exofs: Use inode_sb() helper instead of inode->i_sb
  2018-05-08 18:03 [RFC][PATCH 0/76] vfs: 'views' for filesystems with more than one root Mark Fasheh
                   ` (26 preceding siblings ...)
  2018-05-08 18:03 ` [PATCH 27/76] fs/efs: " Mark Fasheh
@ 2018-05-08 18:03 ` Mark Fasheh
  2018-05-08 18:03 ` [PATCH 29/76] fs/exportfs: " Mark Fasheh
                   ` (48 subsequent siblings)
  76 siblings, 0 replies; 88+ messages in thread
From: Mark Fasheh @ 2018-05-08 18:03 UTC (permalink / raw)
  To: linux-fsdevel; +Cc: linux-kernel, linux-btrfs, Mark Fasheh

Signed-off-by: Mark Fasheh <mfasheh@suse.de>
---
 fs/exofs/dir.c   |  6 +++---
 fs/exofs/inode.c | 12 ++++++------
 fs/exofs/namei.c |  4 ++--
 3 files changed, 11 insertions(+), 11 deletions(-)

diff --git a/fs/exofs/dir.c b/fs/exofs/dir.c
index f0138674c1ed..592471362243 100644
--- a/fs/exofs/dir.c
+++ b/fs/exofs/dir.c
@@ -36,7 +36,7 @@
 
 static inline unsigned exofs_chunk_size(struct inode *inode)
 {
-	return inode->i_sb->s_blocksize;
+	return inode_sb(inode)->s_blocksize;
 }
 
 static inline void exofs_put_page(struct page *page)
@@ -430,7 +430,7 @@ int exofs_add_link(struct dentry *dentry, struct inode *inode)
 	unsigned reclen = EXOFS_DIR_REC_LEN(namelen);
 	unsigned short rec_len, name_len;
 	struct page *page = NULL;
-	struct exofs_sb_info *sbi = inode->i_sb->s_fs_info;
+	struct exofs_sb_info *sbi = inode_sb(inode)->s_fs_info;
 	struct exofs_dir_entry *de;
 	unsigned long npages = dir_pages(dir);
 	unsigned long n;
@@ -520,7 +520,7 @@ int exofs_delete_entry(struct exofs_dir_entry *dir, struct page *page)
 {
 	struct address_space *mapping = page->mapping;
 	struct inode *inode = mapping->host;
-	struct exofs_sb_info *sbi = inode->i_sb->s_fs_info;
+	struct exofs_sb_info *sbi = inode_sb(inode)->s_fs_info;
 	char *kaddr = page_address(page);
 	unsigned from = ((char *)dir - kaddr) & ~(exofs_chunk_size(inode)-1);
 	unsigned to = ((char *)dir - kaddr) + le16_to_cpu(dir->rec_len);
diff --git a/fs/exofs/inode.c b/fs/exofs/inode.c
index 0ac62811b341..c52a83f76a7a 100644
--- a/fs/exofs/inode.c
+++ b/fs/exofs/inode.c
@@ -66,7 +66,7 @@ struct page_collect {
 static void _pcol_init(struct page_collect *pcol, unsigned expected_pages,
 		       struct inode *inode)
 {
-	struct exofs_sb_info *sbi = inode->i_sb->s_fs_info;
+	struct exofs_sb_info *sbi = inode_sb(inode)->s_fs_info;
 
 	pcol->sbi = sbi;
 	pcol->inode = inode;
@@ -996,7 +996,7 @@ static inline int exofs_inode_is_fast_symlink(struct inode *inode)
 static int _do_truncate(struct inode *inode, loff_t newsize)
 {
 	struct exofs_i_info *oi = exofs_i(inode);
-	struct exofs_sb_info *sbi = inode->i_sb->s_fs_info;
+	struct exofs_sb_info *sbi = inode_sb(inode)->s_fs_info;
 	int ret;
 
 	inode->i_mtime = inode->i_ctime = current_time(inode);
@@ -1256,7 +1256,7 @@ static void create_done(struct ore_io_state *ios, void *p)
 {
 	struct inode *inode = p;
 	struct exofs_i_info *oi = exofs_i(inode);
-	struct exofs_sb_info *sbi = inode->i_sb->s_fs_info;
+	struct exofs_sb_info *sbi = inode_sb(inode)->s_fs_info;
 	int ret;
 
 	ret = ore_check_io(ios, NULL);
@@ -1286,7 +1286,7 @@ static void create_done(struct ore_io_state *ios, void *p)
  */
 struct inode *exofs_new_inode(struct inode *dir, umode_t mode)
 {
-	struct super_block *sb = dir->i_sb;
+	struct super_block *sb = inode_sb(dir);
 	struct exofs_sb_info *sbi = sb->s_fs_info;
 	struct inode *inode;
 	struct exofs_i_info *oi;
@@ -1366,7 +1366,7 @@ static void updatei_done(struct ore_io_state *ios, void *p)
 static int exofs_update_inode(struct inode *inode, int do_sync)
 {
 	struct exofs_i_info *oi = exofs_i(inode);
-	struct super_block *sb = inode->i_sb;
+	struct super_block *sb = inode_sb(inode);
 	struct exofs_sb_info *sbi = sb->s_fs_info;
 	struct ore_io_state *ios;
 	struct osd_attr attr;
@@ -1468,7 +1468,7 @@ static void delete_done(struct ore_io_state *ios, void *p)
 void exofs_evict_inode(struct inode *inode)
 {
 	struct exofs_i_info *oi = exofs_i(inode);
-	struct super_block *sb = inode->i_sb;
+	struct super_block *sb = inode_sb(inode);
 	struct exofs_sb_info *sbi = sb->s_fs_info;
 	struct ore_io_state *ios;
 	int ret;
diff --git a/fs/exofs/namei.c b/fs/exofs/namei.c
index 7295cd722770..655400486da5 100644
--- a/fs/exofs/namei.c
+++ b/fs/exofs/namei.c
@@ -55,7 +55,7 @@ static struct dentry *exofs_lookup(struct inode *dir, struct dentry *dentry,
 		return ERR_PTR(-ENAMETOOLONG);
 
 	ino = exofs_inode_by_name(dir, dentry);
-	inode = ino ? exofs_iget(dir->i_sb, ino) : NULL;
+	inode = ino ? exofs_iget(inode_sb(dir), ino) : NULL;
 	return d_splice_alias(inode, dentry);
 }
 
@@ -93,7 +93,7 @@ static int exofs_mknod(struct inode *dir, struct dentry *dentry, umode_t mode,
 static int exofs_symlink(struct inode *dir, struct dentry *dentry,
 			  const char *symname)
 {
-	struct super_block *sb = dir->i_sb;
+	struct super_block *sb = inode_sb(dir);
 	int err = -ENAMETOOLONG;
 	unsigned l = strlen(symname)+1;
 	struct inode *inode;
-- 
2.15.1

^ permalink raw reply	[flat|nested] 88+ messages in thread

* [PATCH 29/76] fs/exportfs: Use inode_sb() helper instead of inode->i_sb
  2018-05-08 18:03 [RFC][PATCH 0/76] vfs: 'views' for filesystems with more than one root Mark Fasheh
                   ` (27 preceding siblings ...)
  2018-05-08 18:03 ` [PATCH 28/76] fs/exofs: " Mark Fasheh
@ 2018-05-08 18:03 ` Mark Fasheh
  2018-05-08 18:03 ` [PATCH 30/76] fs/ext2: " Mark Fasheh
                   ` (47 subsequent siblings)
  76 siblings, 0 replies; 88+ messages in thread
From: Mark Fasheh @ 2018-05-08 18:03 UTC (permalink / raw)
  To: linux-fsdevel; +Cc: linux-kernel, linux-btrfs, Mark Fasheh

Signed-off-by: Mark Fasheh <mfasheh@suse.de>
---
 fs/exportfs/expfs.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/fs/exportfs/expfs.c b/fs/exportfs/expfs.c
index 329a5d103846..d0ce48374bda 100644
--- a/fs/exportfs/expfs.c
+++ b/fs/exportfs/expfs.c
@@ -383,7 +383,7 @@ static int export_encode_fh(struct inode *inode, struct fid *fid,
 int exportfs_encode_inode_fh(struct inode *inode, struct fid *fid,
 			     int *max_len, struct inode *parent)
 {
-	const struct export_operations *nop = inode->i_sb->s_export_op;
+	const struct export_operations *nop = inode_sb(inode)->s_export_op;
 
 	if (nop && nop->encode_fh)
 		return nop->encode_fh(inode, fid->raw, max_len, parent);
-- 
2.15.1

^ permalink raw reply	[flat|nested] 88+ messages in thread

* [PATCH 30/76] fs/ext2: Use inode_sb() helper instead of inode->i_sb
  2018-05-08 18:03 [RFC][PATCH 0/76] vfs: 'views' for filesystems with more than one root Mark Fasheh
                   ` (28 preceding siblings ...)
  2018-05-08 18:03 ` [PATCH 29/76] fs/exportfs: " Mark Fasheh
@ 2018-05-08 18:03 ` Mark Fasheh
  2018-05-08 18:03 ` [PATCH 31/76] fs/ext4: " Mark Fasheh
                   ` (46 subsequent siblings)
  76 siblings, 0 replies; 88+ messages in thread
From: Mark Fasheh @ 2018-05-08 18:03 UTC (permalink / raw)
  To: linux-fsdevel; +Cc: linux-kernel, linux-btrfs, Mark Fasheh

Signed-off-by: Mark Fasheh <mfasheh@suse.de>
---
 fs/ext2/balloc.c     | 10 +++----
 fs/ext2/dir.c        | 32 ++++++++++----------
 fs/ext2/file.c       |  6 ++--
 fs/ext2/ialloc.c     | 16 +++++-----
 fs/ext2/inode.c      | 82 +++++++++++++++++++++++++++-------------------------
 fs/ext2/ioctl.c      |  4 +--
 fs/ext2/namei.c      | 14 ++++-----
 fs/ext2/xattr.c      | 59 ++++++++++++++++++-------------------
 fs/ext2/xattr_user.c |  4 +--
 9 files changed, 115 insertions(+), 112 deletions(-)

diff --git a/fs/ext2/balloc.c b/fs/ext2/balloc.c
index 33db13365c5e..0ac54114ea9a 100644
--- a/fs/ext2/balloc.c
+++ b/fs/ext2/balloc.c
@@ -413,7 +413,7 @@ void ext2_init_block_alloc_info(struct inode *inode)
 {
 	struct ext2_inode_info *ei = EXT2_I(inode);
 	struct ext2_block_alloc_info *block_i;
-	struct super_block *sb = inode->i_sb;
+	struct super_block *sb = inode_sb(inode);
 
 	block_i = kmalloc(sizeof(*block_i), GFP_NOFS);
 	if (block_i) {
@@ -455,7 +455,7 @@ void ext2_discard_reservation(struct inode *inode)
 	struct ext2_inode_info *ei = EXT2_I(inode);
 	struct ext2_block_alloc_info *block_i = ei->i_block_alloc_info;
 	struct ext2_reserve_window_node *rsv;
-	spinlock_t *rsv_lock = &EXT2_SB(inode->i_sb)->s_rsv_window_lock;
+	spinlock_t *rsv_lock = &EXT2_SB(inode_sb(inode))->s_rsv_window_lock;
 
 	if (!block_i)
 		return;
@@ -464,7 +464,7 @@ void ext2_discard_reservation(struct inode *inode)
 	if (!rsv_is_empty(&rsv->rsv_window)) {
 		spin_lock(rsv_lock);
 		if (!rsv_is_empty(&rsv->rsv_window))
-			rsv_window_remove(inode->i_sb, rsv);
+			rsv_window_remove(inode_sb(inode), rsv);
 		spin_unlock(rsv_lock);
 	}
 }
@@ -484,7 +484,7 @@ void ext2_free_blocks (struct inode * inode, unsigned long block,
 	unsigned long bit;
 	unsigned long i;
 	unsigned long overflow;
-	struct super_block * sb = inode->i_sb;
+	struct super_block * sb = inode_sb(inode);
 	struct ext2_sb_info * sbi = EXT2_SB(sb);
 	struct ext2_group_desc * desc;
 	struct ext2_super_block * es = sbi->s_es;
@@ -1255,7 +1255,7 @@ ext2_fsblk_t ext2_new_blocks(struct inode *inode, ext2_fsblk_t goal,
 	int ret;
 
 	*errp = -ENOSPC;
-	sb = inode->i_sb;
+	sb = inode_sb(inode);
 
 	/*
 	 * Check quota for allocation of this block.
diff --git a/fs/ext2/dir.c b/fs/ext2/dir.c
index 3b8114def693..b9565d7b86e8 100644
--- a/fs/ext2/dir.c
+++ b/fs/ext2/dir.c
@@ -63,7 +63,7 @@ static inline __le16 ext2_rec_len_to_disk(unsigned len)
  */
 static inline unsigned ext2_chunk_size(struct inode *inode)
 {
-	return inode->i_sb->s_blocksize;
+	return inode_sb(inode)->s_blocksize;
 }
 
 static inline void ext2_put_page(struct page *page)
@@ -115,7 +115,7 @@ static int ext2_commit_chunk(struct page *page, loff_t pos, unsigned len)
 static bool ext2_check_page(struct page *page, int quiet)
 {
 	struct inode *dir = page->mapping->host;
-	struct super_block *sb = dir->i_sb;
+	struct super_block *sb = inode_sb(dir);
 	unsigned chunk_size = ext2_chunk_size(dir);
 	char *kaddr = page_address(page);
 	u32 max_inumber = le32_to_cpu(EXT2_SB(sb)->s_es->s_inodes_count);
@@ -277,7 +277,7 @@ static unsigned char ext2_type_by_mode[S_IFMT >> S_SHIFT] = {
 static inline void ext2_set_de_type(ext2_dirent *de, struct inode *inode)
 {
 	umode_t mode = inode->i_mode;
-	if (EXT2_HAS_INCOMPAT_FEATURE(inode->i_sb, EXT2_FEATURE_INCOMPAT_FILETYPE))
+	if (EXT2_HAS_INCOMPAT_FEATURE(inode_sb(inode), EXT2_FEATURE_INCOMPAT_FILETYPE))
 		de->file_type = ext2_type_by_mode[(mode & S_IFMT)>>S_SHIFT];
 	else
 		de->file_type = 0;
@@ -288,7 +288,7 @@ ext2_readdir(struct file *file, struct dir_context *ctx)
 {
 	loff_t pos = ctx->pos;
 	struct inode *inode = file_inode(file);
-	struct super_block *sb = inode->i_sb;
+	struct super_block *sb = inode_sb(inode);
 	unsigned int offset = pos & ~PAGE_MASK;
 	unsigned long n = pos >> PAGE_SHIFT;
 	unsigned long npages = dir_pages(inode);
@@ -392,8 +392,8 @@ struct ext2_dir_entry_2 *ext2_find_entry (struct inode *dir,
 			kaddr += ext2_last_byte(dir, n) - reclen;
 			while ((char *) de <= kaddr) {
 				if (de->rec_len == 0) {
-					ext2_error(dir->i_sb, __func__,
-						"zero-length directory entry");
+					ext2_error(inode_sb(dir), __func__,
+						   "zero-length directory entry");
 					ext2_put_page(page);
 					goto out;
 				}
@@ -409,10 +409,10 @@ struct ext2_dir_entry_2 *ext2_find_entry (struct inode *dir,
 			n = 0;
 		/* next page is past the blocks we've got */
 		if (unlikely(n > (dir->i_blocks >> (PAGE_SHIFT - 9)))) {
-			ext2_error(dir->i_sb, __func__,
-				"dir %lu size %lld exceeds block count %llu",
-				dir->i_ino, dir->i_size,
-				(unsigned long long)dir->i_blocks);
+			ext2_error(inode_sb(dir), __func__,
+				   "dir %lu size %lld exceeds block count %llu",
+				   dir->i_ino, dir->i_size,
+				   (unsigned long long)dir->i_blocks);
 			goto out;
 		}
 	} while (n != start);
@@ -524,8 +524,8 @@ int ext2_add_link (struct dentry *dentry, struct inode *inode)
 				goto got_it;
 			}
 			if (de->rec_len == 0) {
-				ext2_error(dir->i_sb, __func__,
-					"zero-length directory entry");
+				ext2_error(inode_sb(dir), __func__,
+					   "zero-length directory entry");
 				err = -EIO;
 				goto out_unlock;
 			}
@@ -594,8 +594,8 @@ int ext2_delete_entry (struct ext2_dir_entry_2 * dir, struct page * page )
 
 	while ((char*)de < (char*)dir) {
 		if (de->rec_len == 0) {
-			ext2_error(inode->i_sb, __func__,
-				"zero-length directory entry");
+			ext2_error(inode_sb(inode), __func__,
+				   "zero-length directory entry");
 			err = -EIO;
 			goto out;
 		}
@@ -686,8 +686,8 @@ int ext2_empty_dir (struct inode * inode)
 
 		while ((char *)de <= kaddr) {
 			if (de->rec_len == 0) {
-				ext2_error(inode->i_sb, __func__,
-					"zero-length directory entry");
+				ext2_error(inode_sb(inode), __func__,
+					   "zero-length directory entry");
 				printk("kaddr=%p, de=%p\n", kaddr, de);
 				goto not_empty;
 			}
diff --git a/fs/ext2/file.c b/fs/ext2/file.c
index 09640220fda8..b7279d6ad130 100644
--- a/fs/ext2/file.c
+++ b/fs/ext2/file.c
@@ -95,7 +95,7 @@ static int ext2_dax_fault(struct vm_fault *vmf)
 	int ret;
 
 	if (vmf->flags & FAULT_FLAG_WRITE) {
-		sb_start_pagefault(inode->i_sb);
+		sb_start_pagefault(inode_sb(inode));
 		file_update_time(vmf->vma->vm_file);
 	}
 	down_read(&ei->dax_sem);
@@ -104,7 +104,7 @@ static int ext2_dax_fault(struct vm_fault *vmf)
 
 	up_read(&ei->dax_sem);
 	if (vmf->flags & FAULT_FLAG_WRITE)
-		sb_end_pagefault(inode->i_sb);
+		sb_end_pagefault(inode_sb(inode));
 	return ret;
 }
 
@@ -151,7 +151,7 @@ static int ext2_release_file (struct inode * inode, struct file * filp)
 int ext2_fsync(struct file *file, loff_t start, loff_t end, int datasync)
 {
 	int ret;
-	struct super_block *sb = file->f_mapping->host->i_sb;
+	struct super_block *sb = inode_sb(file->f_mapping->host);
 
 	ret = generic_file_fsync(file, start, end, datasync);
 	if (ret == -EIO)
diff --git a/fs/ext2/ialloc.c b/fs/ext2/ialloc.c
index 6484199b35d1..549a0e7efec1 100644
--- a/fs/ext2/ialloc.c
+++ b/fs/ext2/ialloc.c
@@ -103,7 +103,7 @@ static void ext2_release_inode(struct super_block *sb, int group, int dir)
  */
 void ext2_free_inode (struct inode * inode)
 {
-	struct super_block * sb = inode->i_sb;
+	struct super_block * sb = inode_sb(inode);
 	int is_directory;
 	unsigned long ino;
 	struct buffer_head *bitmap_bh;
@@ -177,19 +177,19 @@ static void ext2_preread_inode(struct inode *inode)
 	if (bdi_write_congested(bdi))
 		return;
 
-	block_group = (inode->i_ino - 1) / EXT2_INODES_PER_GROUP(inode->i_sb);
-	gdp = ext2_get_group_desc(inode->i_sb, block_group, NULL);
+	block_group = (inode->i_ino - 1) / EXT2_INODES_PER_GROUP(inode_sb(inode));
+	gdp = ext2_get_group_desc(inode_sb(inode), block_group, NULL);
 	if (gdp == NULL)
 		return;
 
 	/*
 	 * Figure out the offset within the block group inode table
 	 */
-	offset = ((inode->i_ino - 1) % EXT2_INODES_PER_GROUP(inode->i_sb)) *
-				EXT2_INODE_SIZE(inode->i_sb);
+	offset = ((inode->i_ino - 1) % EXT2_INODES_PER_GROUP(inode_sb(inode))) *
+				EXT2_INODE_SIZE(inode_sb(inode));
 	block = le32_to_cpu(gdp->bg_inode_table) +
-				(offset >> EXT2_BLOCK_SIZE_BITS(inode->i_sb));
-	sb_breadahead(inode->i_sb, block);
+				(offset >> EXT2_BLOCK_SIZE_BITS(inode_sb(inode)));
+	sb_breadahead(inode_sb(inode), block);
 }
 
 /*
@@ -443,7 +443,7 @@ struct inode *ext2_new_inode(struct inode *dir, umode_t mode,
 	struct ext2_sb_info *sbi;
 	int err;
 
-	sb = dir->i_sb;
+	sb = inode_sb(dir);
 	inode = new_inode(sb);
 	if (!inode)
 		return ERR_PTR(-ENOMEM);
diff --git a/fs/ext2/inode.c b/fs/ext2/inode.c
index 9b2ac55ac34f..47b7129f2db7 100644
--- a/fs/ext2/inode.c
+++ b/fs/ext2/inode.c
@@ -48,7 +48,7 @@ static int __ext2_write_inode(struct inode *inode, int do_sync);
 static inline int ext2_inode_is_fast_symlink(struct inode *inode)
 {
 	int ea_blocks = EXT2_I(inode)->i_file_acl ?
-		(inode->i_sb->s_blocksize >> 9) : 0;
+		(inode_sb(inode)->s_blocksize >> 9) : 0;
 
 	return (S_ISLNK(inode->i_mode) &&
 		inode->i_blocks - ea_blocks == 0);
@@ -84,7 +84,7 @@ void ext2_evict_inode(struct inode * inode)
 	truncate_inode_pages_final(&inode->i_data);
 
 	if (want_delete) {
-		sb_start_intwrite(inode->i_sb);
+		sb_start_intwrite(inode_sb(inode));
 		/* set dtime */
 		EXT2_I(inode)->i_dtime	= get_seconds();
 		mark_inode_dirty(inode);
@@ -107,7 +107,7 @@ void ext2_evict_inode(struct inode * inode)
 
 	if (want_delete) {
 		ext2_free_inode(inode);
-		sb_end_intwrite(inode->i_sb);
+		sb_end_intwrite(inode_sb(inode));
 	}
 }
 
@@ -147,7 +147,7 @@ static inline int verify_chain(Indirect *from, Indirect *to)
  *
  *	Note: function doesn't find node addresses, so no IO is needed. All
  *	we need to know is the capacity of indirect blocks (taken from the
- *	inode->i_sb).
+ *	inode_sb(inode)).
  */
 
 /*
@@ -163,8 +163,8 @@ static inline int verify_chain(Indirect *from, Indirect *to)
 static int ext2_block_to_path(struct inode *inode,
 			long i_block, int offsets[4], int *boundary)
 {
-	int ptrs = EXT2_ADDR_PER_BLOCK(inode->i_sb);
-	int ptrs_bits = EXT2_ADDR_PER_BLOCK_BITS(inode->i_sb);
+	int ptrs = EXT2_ADDR_PER_BLOCK(inode_sb(inode));
+	int ptrs_bits = EXT2_ADDR_PER_BLOCK_BITS(inode_sb(inode));
 	const long direct_blocks = EXT2_NDIR_BLOCKS,
 		indirect_blocks = ptrs,
 		double_blocks = (1 << (ptrs_bits * 2));
@@ -172,8 +172,8 @@ static int ext2_block_to_path(struct inode *inode,
 	int final = 0;
 
 	if (i_block < 0) {
-		ext2_msg(inode->i_sb, KERN_WARNING,
-			"warning: %s: block < 0", __func__);
+		ext2_msg(inode_sb(inode), KERN_WARNING,
+			 "warning: %s: block < 0", __func__);
 	} else if (i_block < direct_blocks) {
 		offsets[n++] = i_block;
 		final = direct_blocks;
@@ -193,8 +193,8 @@ static int ext2_block_to_path(struct inode *inode,
 		offsets[n++] = i_block & (ptrs - 1);
 		final = ptrs;
 	} else {
-		ext2_msg(inode->i_sb, KERN_WARNING,
-			"warning: %s: block is too big", __func__);
+		ext2_msg(inode_sb(inode), KERN_WARNING,
+			 "warning: %s: block is too big", __func__);
 	}
 	if (boundary)
 		*boundary = final - 1 - (i_block & (ptrs - 1));
@@ -237,7 +237,7 @@ static Indirect *ext2_get_branch(struct inode *inode,
 				 Indirect chain[4],
 				 int *err)
 {
-	struct super_block *sb = inode->i_sb;
+	struct super_block *sb = inode_sb(inode);
 	Indirect *p = chain;
 	struct buffer_head *bh;
 
@@ -312,9 +312,10 @@ static ext2_fsblk_t ext2_find_near(struct inode *inode, Indirect *ind)
 	 * It is going to be referred from inode itself? OK, just put it into
 	 * the same cylinder group then.
 	 */
-	bg_start = ext2_group_first_block_no(inode->i_sb, ei->i_block_group);
+	bg_start = ext2_group_first_block_no(inode_sb(inode),
+					     ei->i_block_group);
 	colour = (current->pid % 16) *
-			(EXT2_BLOCKS_PER_GROUP(inode->i_sb) / 16);
+			(EXT2_BLOCKS_PER_GROUP(inode_sb(inode)) / 16);
 	return bg_start + colour;
 }
 
@@ -477,7 +478,7 @@ static int ext2_alloc_branch(struct inode *inode,
 			int indirect_blks, int *blks, ext2_fsblk_t goal,
 			int *offsets, Indirect *branch)
 {
-	int blocksize = inode->i_sb->s_blocksize;
+	int blocksize = inode_sb(inode)->s_blocksize;
 	int i, n = 0;
 	int err = 0;
 	struct buffer_head *bh;
@@ -500,7 +501,7 @@ static int ext2_alloc_branch(struct inode *inode,
 		 * and set the pointer to new one, then send
 		 * parent to disk.
 		 */
-		bh = sb_getblk(inode->i_sb, new_blocks[n-1]);
+		bh = sb_getblk(inode_sb(inode), new_blocks[n-1]);
 		if (unlikely(!bh)) {
 			err = -ENOMEM;
 			goto failed;
@@ -738,7 +739,7 @@ static int ext2_get_blocks(struct inode *inode,
 		 * We must unmap blocks before zeroing so that writeback cannot
 		 * overwrite zeros with stale data from block device page cache.
 		 */
-		clean_bdev_aliases(inode->i_sb->s_bdev,
+		clean_bdev_aliases(inode_sb(inode)->s_bdev,
 				   le32_to_cpu(chain[depth-1].key),
 				   count);
 		/*
@@ -746,9 +747,9 @@ static int ext2_get_blocks(struct inode *inode,
 		 * so that it's not found by another thread before it's
 		 * initialised
 		 */
-		err = sb_issue_zeroout(inode->i_sb,
-				le32_to_cpu(chain[depth-1].key), count,
-				GFP_NOFS);
+		err = sb_issue_zeroout(inode_sb(inode),
+				       le32_to_cpu(chain[depth-1].key), count,
+				       GFP_NOFS);
 		if (err) {
 			mutex_unlock(&ei->truncate_mutex);
 			goto cleanup;
@@ -787,7 +788,7 @@ int ext2_get_block(struct inode *inode, sector_t iblock,
 	if (ret <= 0)
 		return ret;
 
-	map_bh(bh_result, inode->i_sb, bno);
+	map_bh(bh_result, inode_sb(inode), bno);
 	bh_result->b_size = (ret << inode->i_blkbits);
 	if (new)
 		set_buffer_new(bh_result);
@@ -804,7 +805,7 @@ static int ext2_iomap_begin(struct inode *inode, loff_t offset, loff_t length,
 	unsigned int blkbits = inode->i_blkbits;
 	unsigned long first_block = offset >> blkbits;
 	unsigned long max_blocks = (length + (1 << blkbits) - 1) >> blkbits;
-	struct ext2_sb_info *sbi = EXT2_SB(inode->i_sb);
+	struct ext2_sb_info *sbi = EXT2_SB(inode_sb(inode));
 	bool new = false, boundary = false;
 	u32 bno;
 	int ret;
@@ -815,7 +816,7 @@ static int ext2_iomap_begin(struct inode *inode, loff_t offset, loff_t length,
 		return ret;
 
 	iomap->flags = 0;
-	iomap->bdev = inode->i_sb->s_bdev;
+	iomap->bdev = inode_sb(inode)->s_bdev;
 	iomap->offset = (u64)first_block << blkbits;
 	iomap->dax_dev = sbi->s_daxdev;
 
@@ -955,7 +956,7 @@ ext2_writepages(struct address_space *mapping, struct writeback_control *wbc)
 #ifdef CONFIG_FS_DAX
 	if (dax_mapping(mapping)) {
 		return dax_writeback_mapping_range(mapping,
-						   mapping->host->i_sb->s_bdev,
+						   inode_sb(mapping->host)->s_bdev,
 						   wbc);
 	}
 #endif
@@ -1142,21 +1143,22 @@ static void ext2_free_branches(struct inode *inode, __le32 *p, __le32 *q, int de
 	unsigned long nr;
 
 	if (depth--) {
-		int addr_per_block = EXT2_ADDR_PER_BLOCK(inode->i_sb);
+		int addr_per_block = EXT2_ADDR_PER_BLOCK(inode_sb(inode));
 		for ( ; p < q ; p++) {
 			nr = le32_to_cpu(*p);
 			if (!nr)
 				continue;
 			*p = 0;
-			bh = sb_bread(inode->i_sb, nr);
+			bh = sb_bread(inode_sb(inode), nr);
 			/*
 			 * A read failure? Report error and clear slot
 			 * (should be rare).
 			 */ 
 			if (!bh) {
-				ext2_error(inode->i_sb, "ext2_free_branches",
-					"Read failure, inode=%ld, block=%ld",
-					inode->i_ino, nr);
+				ext2_error(inode_sb(inode),
+				           "ext2_free_branches",
+				           "Read failure, inode=%ld, block=%ld",
+				           inode->i_ino, nr);
 				continue;
 			}
 			ext2_free_branches(inode,
@@ -1176,7 +1178,7 @@ static void __ext2_truncate_blocks(struct inode *inode, loff_t offset)
 {
 	__le32 *i_data = EXT2_I(inode)->i_data;
 	struct ext2_inode_info *ei = EXT2_I(inode);
-	int addr_per_block = EXT2_ADDR_PER_BLOCK(inode->i_sb);
+	int addr_per_block = EXT2_ADDR_PER_BLOCK(inode_sb(inode));
 	int offsets[4];
 	Indirect chain[4];
 	Indirect *partial;
@@ -1184,8 +1186,8 @@ static void __ext2_truncate_blocks(struct inode *inode, loff_t offset)
 	int n;
 	long iblock;
 	unsigned blocksize;
-	blocksize = inode->i_sb->s_blocksize;
-	iblock = (offset + blocksize-1) >> EXT2_BLOCK_SIZE_BITS(inode->i_sb);
+	blocksize = inode_sb(inode)->s_blocksize;
+	iblock = (offset + blocksize-1) >> EXT2_BLOCK_SIZE_BITS(inode_sb(inode));
 
 #ifdef CONFIG_FS_DAX
 	WARN_ON(!rwsem_is_locked(&ei->dax_sem));
@@ -1300,7 +1302,7 @@ static int ext2_setsize(struct inode *inode, loff_t newsize)
 		error = iomap_zero_range(inode, newsize,
 					 PAGE_ALIGN(newsize) - newsize, NULL,
 					 &ext2_iomap_ops);
-	} else if (test_opt(inode->i_sb, NOBH))
+	} else if (test_opt(inode_sb(inode), NOBH))
 		error = nobh_truncate_page(inode->i_mapping,
 				newsize, ext2_get_block);
 	else
@@ -1384,7 +1386,7 @@ void ext2_set_inode_flags(struct inode *inode)
 		inode->i_flags |= S_NOATIME;
 	if (flags & EXT2_DIRSYNC_FL)
 		inode->i_flags |= S_DIRSYNC;
-	if (test_opt(inode->i_sb, DAX) && S_ISREG(inode->i_mode))
+	if (test_opt(inode_sb(inode), DAX) && S_ISREG(inode->i_mode))
 		inode->i_flags |= S_DAX;
 }
 
@@ -1408,7 +1410,7 @@ struct inode *ext2_iget (struct super_block *sb, unsigned long ino)
 	ei = EXT2_I(inode);
 	ei->i_block_alloc_info = NULL;
 
-	raw_inode = ext2_get_inode(inode->i_sb, ino, &bh);
+	raw_inode = ext2_get_inode(inode_sb(inode), ino, &bh);
 	if (IS_ERR(raw_inode)) {
 		ret = PTR_ERR(raw_inode);
  		goto bad_inode;
@@ -1417,7 +1419,7 @@ struct inode *ext2_iget (struct super_block *sb, unsigned long ino)
 	inode->i_mode = le16_to_cpu(raw_inode->i_mode);
 	i_uid = (uid_t)le16_to_cpu(raw_inode->i_uid_low);
 	i_gid = (gid_t)le16_to_cpu(raw_inode->i_gid_low);
-	if (!(test_opt (inode->i_sb, NO_UID32))) {
+	if (!(test_opt (inode_sb(inode), NO_UID32))) {
 		i_uid |= le16_to_cpu(raw_inode->i_uid_high) << 16;
 		i_gid |= le16_to_cpu(raw_inode->i_gid_high) << 16;
 	}
@@ -1469,7 +1471,7 @@ struct inode *ext2_iget (struct super_block *sb, unsigned long ino)
 	ei->i_dtime = 0;
 	inode->i_generation = le32_to_cpu(raw_inode->i_generation);
 	ei->i_state = 0;
-	ei->i_block_group = (ino - 1) / EXT2_INODES_PER_GROUP(inode->i_sb);
+	ei->i_block_group = (ino - 1) / EXT2_INODES_PER_GROUP(inode_sb(inode));
 	ei->i_dir_start_lookup = 0;
 
 	/*
@@ -1481,7 +1483,7 @@ struct inode *ext2_iget (struct super_block *sb, unsigned long ino)
 
 	if (S_ISREG(inode->i_mode)) {
 		inode->i_op = &ext2_file_inode_operations;
-		if (test_opt(inode->i_sb, NOBH)) {
+		if (test_opt(inode_sb(inode), NOBH)) {
 			inode->i_mapping->a_ops = &ext2_nobh_aops;
 			inode->i_fop = &ext2_file_operations;
 		} else {
@@ -1491,7 +1493,7 @@ struct inode *ext2_iget (struct super_block *sb, unsigned long ino)
 	} else if (S_ISDIR(inode->i_mode)) {
 		inode->i_op = &ext2_dir_inode_operations;
 		inode->i_fop = &ext2_dir_operations;
-		if (test_opt(inode->i_sb, NOBH))
+		if (test_opt(inode_sb(inode), NOBH))
 			inode->i_mapping->a_ops = &ext2_nobh_aops;
 		else
 			inode->i_mapping->a_ops = &ext2_aops;
@@ -1504,7 +1506,7 @@ struct inode *ext2_iget (struct super_block *sb, unsigned long ino)
 		} else {
 			inode->i_op = &ext2_symlink_inode_operations;
 			inode_nohighmem(inode);
-			if (test_opt(inode->i_sb, NOBH))
+			if (test_opt(inode_sb(inode), NOBH))
 				inode->i_mapping->a_ops = &ext2_nobh_aops;
 			else
 				inode->i_mapping->a_ops = &ext2_aops;
@@ -1531,7 +1533,7 @@ struct inode *ext2_iget (struct super_block *sb, unsigned long ino)
 static int __ext2_write_inode(struct inode *inode, int do_sync)
 {
 	struct ext2_inode_info *ei = EXT2_I(inode);
-	struct super_block *sb = inode->i_sb;
+	struct super_block *sb = inode_sb(inode);
 	ino_t ino = inode->i_ino;
 	uid_t uid = i_uid_read(inode);
 	gid_t gid = i_gid_read(inode);
diff --git a/fs/ext2/ioctl.c b/fs/ext2/ioctl.c
index 0367c0039e68..d927a865d13e 100644
--- a/fs/ext2/ioctl.c
+++ b/fs/ext2/ioctl.c
@@ -113,7 +113,7 @@ long ext2_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
 		return ret;
 	}
 	case EXT2_IOC_GETRSVSZ:
-		if (test_opt(inode->i_sb, RESERVATION)
+		if (test_opt(inode_sb(inode), RESERVATION)
 			&& S_ISREG(inode->i_mode)
 			&& ei->i_block_alloc_info) {
 			rsv_window_size = ei->i_block_alloc_info->rsv_window_node.rsv_goal_size;
@@ -122,7 +122,7 @@ long ext2_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
 		return -ENOTTY;
 	case EXT2_IOC_SETRSVSZ: {
 
-		if (!test_opt(inode->i_sb, RESERVATION) ||!S_ISREG(inode->i_mode))
+		if (!test_opt(inode_sb(inode), RESERVATION) ||!S_ISREG(inode->i_mode))
 			return -ENOTTY;
 
 		if (!inode_owner_or_capable(inode))
diff --git a/fs/ext2/namei.c b/fs/ext2/namei.c
index e078075dc66f..2e5f7d3d371b 100644
--- a/fs/ext2/namei.c
+++ b/fs/ext2/namei.c
@@ -66,9 +66,9 @@ static struct dentry *ext2_lookup(struct inode * dir, struct dentry *dentry, uns
 	ino = ext2_inode_by_name(dir, &dentry->d_name);
 	inode = NULL;
 	if (ino) {
-		inode = ext2_iget(dir->i_sb, ino);
+		inode = ext2_iget(inode_sb(dir), ino);
 		if (inode == ERR_PTR(-ESTALE)) {
-			ext2_error(dir->i_sb, __func__,
+			ext2_error(inode_sb(dir), __func__,
 					"deleted inode referenced: %lu",
 					(unsigned long) ino);
 			return ERR_PTR(-EIO);
@@ -108,7 +108,7 @@ static int ext2_create (struct inode * dir, struct dentry * dentry, umode_t mode
 		return PTR_ERR(inode);
 
 	inode->i_op = &ext2_file_inode_operations;
-	if (test_opt(inode->i_sb, NOBH)) {
+	if (test_opt(inode_sb(inode), NOBH)) {
 		inode->i_mapping->a_ops = &ext2_nobh_aops;
 		inode->i_fop = &ext2_file_operations;
 	} else {
@@ -126,7 +126,7 @@ static int ext2_tmpfile(struct inode *dir, struct dentry *dentry, umode_t mode)
 		return PTR_ERR(inode);
 
 	inode->i_op = &ext2_file_inode_operations;
-	if (test_opt(inode->i_sb, NOBH)) {
+	if (test_opt(inode_sb(inode), NOBH)) {
 		inode->i_mapping->a_ops = &ext2_nobh_aops;
 		inode->i_fop = &ext2_file_operations;
 	} else {
@@ -164,7 +164,7 @@ static int ext2_mknod (struct inode * dir, struct dentry *dentry, umode_t mode,
 static int ext2_symlink (struct inode * dir, struct dentry * dentry,
 	const char * symname)
 {
-	struct super_block * sb = dir->i_sb;
+	struct super_block * sb = inode_sb(dir);
 	int err = -ENAMETOOLONG;
 	unsigned l = strlen(symname)+1;
 	struct inode * inode;
@@ -185,7 +185,7 @@ static int ext2_symlink (struct inode * dir, struct dentry * dentry,
 		/* slow symlink */
 		inode->i_op = &ext2_symlink_inode_operations;
 		inode_nohighmem(inode);
-		if (test_opt(inode->i_sb, NOBH))
+		if (test_opt(inode_sb(inode), NOBH))
 			inode->i_mapping->a_ops = &ext2_nobh_aops;
 		else
 			inode->i_mapping->a_ops = &ext2_aops;
@@ -254,7 +254,7 @@ static int ext2_mkdir(struct inode * dir, struct dentry * dentry, umode_t mode)
 
 	inode->i_op = &ext2_dir_inode_operations;
 	inode->i_fop = &ext2_dir_operations;
-	if (test_opt(inode->i_sb, NOBH))
+	if (test_opt(inode_sb(inode), NOBH))
 		inode->i_mapping->a_ops = &ext2_nobh_aops;
 	else
 		inode->i_mapping->a_ops = &ext2_aops;
diff --git a/fs/ext2/xattr.c b/fs/ext2/xattr.c
index 62d9a659a8ff..613cfcae7b48 100644
--- a/fs/ext2/xattr.c
+++ b/fs/ext2/xattr.c
@@ -73,7 +73,8 @@
 #ifdef EXT2_XATTR_DEBUG
 # define ea_idebug(inode, f...) do { \
 		printk(KERN_DEBUG "inode %s:%ld: ", \
-			inode->i_sb->s_id, inode->i_ino); \
+			inode_sb(inode)->s_id,
+		       inode->i_ino); \
 		printk(f); \
 		printk("\n"); \
 	} while (0)
@@ -122,7 +123,7 @@ const struct xattr_handler *ext2_xattr_handlers[] = {
 	NULL
 };
 
-#define EA_BLOCK_CACHE(inode)	(EXT2_SB(inode->i_sb)->s_ea_block_cache)
+#define EA_BLOCK_CACHE(inode)	(EXT2_SB(inode_sb(inode))->s_ea_block_cache)
 
 static inline const struct xattr_handler *
 ext2_xattr_handler(int name_index)
@@ -169,7 +170,7 @@ ext2_xattr_get(struct inode *inode, int name_index, const char *name,
 	if (!EXT2_I(inode)->i_file_acl)
 		goto cleanup;
 	ea_idebug(inode, "reading block %d", EXT2_I(inode)->i_file_acl);
-	bh = sb_bread(inode->i_sb, EXT2_I(inode)->i_file_acl);
+	bh = sb_bread(inode_sb(inode), EXT2_I(inode)->i_file_acl);
 	error = -EIO;
 	if (!bh)
 		goto cleanup;
@@ -178,9 +179,9 @@ ext2_xattr_get(struct inode *inode, int name_index, const char *name,
 	end = bh->b_data + bh->b_size;
 	if (HDR(bh)->h_magic != cpu_to_le32(EXT2_XATTR_MAGIC) ||
 	    HDR(bh)->h_blocks != cpu_to_le32(1)) {
-bad_block:	ext2_error(inode->i_sb, "ext2_xattr_get",
-			"inode %ld: bad block %d", inode->i_ino,
-			EXT2_I(inode)->i_file_acl);
+bad_block:	ext2_error(inode_sb(inode), "ext2_xattr_get",
+			     "inode %ld: bad block %d", inode->i_ino,
+			     EXT2_I(inode)->i_file_acl);
 		error = -EIO;
 		goto cleanup;
 	}
@@ -207,8 +208,8 @@ bad_block:	ext2_error(inode->i_sb, "ext2_xattr_get",
 	if (entry->e_value_block != 0)
 		goto bad_block;
 	size = le32_to_cpu(entry->e_value_size);
-	if (size > inode->i_sb->s_blocksize ||
-	    le16_to_cpu(entry->e_value_offs) + size > inode->i_sb->s_blocksize)
+	if (size > inode_sb(inode)->s_blocksize ||
+	    le16_to_cpu(entry->e_value_offs) + size > inode_sb(inode)->s_blocksize)
 		goto bad_block;
 
 	if (ext2_xattr_cache_insert(ea_block_cache, bh))
@@ -259,7 +260,7 @@ ext2_xattr_list(struct dentry *dentry, char *buffer, size_t buffer_size)
 	if (!EXT2_I(inode)->i_file_acl)
 		goto cleanup;
 	ea_idebug(inode, "reading block %d", EXT2_I(inode)->i_file_acl);
-	bh = sb_bread(inode->i_sb, EXT2_I(inode)->i_file_acl);
+	bh = sb_bread(inode_sb(inode), EXT2_I(inode)->i_file_acl);
 	error = -EIO;
 	if (!bh)
 		goto cleanup;
@@ -268,9 +269,9 @@ ext2_xattr_list(struct dentry *dentry, char *buffer, size_t buffer_size)
 	end = bh->b_data + bh->b_size;
 	if (HDR(bh)->h_magic != cpu_to_le32(EXT2_XATTR_MAGIC) ||
 	    HDR(bh)->h_blocks != cpu_to_le32(1)) {
-bad_block:	ext2_error(inode->i_sb, "ext2_xattr_list",
-			"inode %ld: bad block %d", inode->i_ino,
-			EXT2_I(inode)->i_file_acl);
+bad_block:	ext2_error(inode_sb(inode), "ext2_xattr_list",
+			     "inode %ld: bad block %d", inode->i_ino,
+			     EXT2_I(inode)->i_file_acl);
 		error = -EIO;
 		goto cleanup;
 	}
@@ -363,7 +364,7 @@ int
 ext2_xattr_set(struct inode *inode, int name_index, const char *name,
 	       const void *value, size_t value_len, int flags)
 {
-	struct super_block *sb = inode->i_sb;
+	struct super_block *sb = inode_sb(inode);
 	struct buffer_head *bh = NULL;
 	struct ext2_xattr_header *header = NULL;
 	struct ext2_xattr_entry *here, *last;
@@ -627,7 +628,7 @@ static int
 ext2_xattr_set2(struct inode *inode, struct buffer_head *old_bh,
 		struct ext2_xattr_header *header)
 {
-	struct super_block *sb = inode->i_sb;
+	struct super_block *sb = inode_sb(inode);
 	struct buffer_head *new_bh = NULL;
 	int error;
 	struct mb_cache *ea_block_cache = EA_BLOCK_CACHE(inode);
@@ -762,32 +763,32 @@ void
 ext2_xattr_delete_inode(struct inode *inode)
 {
 	struct buffer_head *bh = NULL;
-	struct ext2_sb_info *sbi = EXT2_SB(inode->i_sb);
+	struct ext2_sb_info *sbi = EXT2_SB(inode_sb(inode));
 
 	down_write(&EXT2_I(inode)->xattr_sem);
 	if (!EXT2_I(inode)->i_file_acl)
 		goto cleanup;
 
 	if (!ext2_data_block_valid(sbi, EXT2_I(inode)->i_file_acl, 0)) {
-		ext2_error(inode->i_sb, "ext2_xattr_delete_inode",
-			"inode %ld: xattr block %d is out of data blocks range",
-			inode->i_ino, EXT2_I(inode)->i_file_acl);
+		ext2_error(inode_sb(inode), "ext2_xattr_delete_inode",
+			   "inode %ld: xattr block %d is out of data blocks range",
+			   inode->i_ino, EXT2_I(inode)->i_file_acl);
 		goto cleanup;
 	}
 
-	bh = sb_bread(inode->i_sb, EXT2_I(inode)->i_file_acl);
+	bh = sb_bread(inode_sb(inode), EXT2_I(inode)->i_file_acl);
 	if (!bh) {
-		ext2_error(inode->i_sb, "ext2_xattr_delete_inode",
-			"inode %ld: block %d read error", inode->i_ino,
-			EXT2_I(inode)->i_file_acl);
+		ext2_error(inode_sb(inode), "ext2_xattr_delete_inode",
+			   "inode %ld: block %d read error", inode->i_ino,
+			   EXT2_I(inode)->i_file_acl);
 		goto cleanup;
 	}
 	ea_bdebug(bh, "b_count=%d", atomic_read(&(bh->b_count)));
 	if (HDR(bh)->h_magic != cpu_to_le32(EXT2_XATTR_MAGIC) ||
 	    HDR(bh)->h_blocks != cpu_to_le32(1)) {
-		ext2_error(inode->i_sb, "ext2_xattr_delete_inode",
-			"inode %ld: bad block %d", inode->i_ino,
-			EXT2_I(inode)->i_file_acl);
+		ext2_error(inode_sb(inode), "ext2_xattr_delete_inode",
+			   "inode %ld: bad block %d", inode->i_ino,
+			   EXT2_I(inode)->i_file_acl);
 		goto cleanup;
 	}
 	lock_buffer(bh);
@@ -910,11 +911,11 @@ ext2_xattr_cache_find(struct inode *inode, struct ext2_xattr_header *header)
 	while (ce) {
 		struct buffer_head *bh;
 
-		bh = sb_bread(inode->i_sb, ce->e_value);
+		bh = sb_bread(inode_sb(inode), ce->e_value);
 		if (!bh) {
-			ext2_error(inode->i_sb, "ext2_xattr_cache_find",
-				"inode %ld: block %ld read error",
-				inode->i_ino, (unsigned long) ce->e_value);
+			ext2_error(inode_sb(inode), "ext2_xattr_cache_find",
+				   "inode %ld: block %ld read error",
+				   inode->i_ino, (unsigned long) ce->e_value);
 		} else {
 			lock_buffer(bh);
 			/*
diff --git a/fs/ext2/xattr_user.c b/fs/ext2/xattr_user.c
index c243a3b4d69d..e2ca8f4829b1 100644
--- a/fs/ext2/xattr_user.c
+++ b/fs/ext2/xattr_user.c
@@ -22,7 +22,7 @@ ext2_xattr_user_get(const struct xattr_handler *handler,
 		    struct dentry *unused, struct inode *inode,
 		    const char *name, void *buffer, size_t size)
 {
-	if (!test_opt(inode->i_sb, XATTR_USER))
+	if (!test_opt(inode_sb(inode), XATTR_USER))
 		return -EOPNOTSUPP;
 	return ext2_xattr_get(inode, EXT2_XATTR_INDEX_USER,
 			      name, buffer, size);
@@ -34,7 +34,7 @@ ext2_xattr_user_set(const struct xattr_handler *handler,
 		    const char *name, const void *value,
 		    size_t size, int flags)
 {
-	if (!test_opt(inode->i_sb, XATTR_USER))
+	if (!test_opt(inode_sb(inode), XATTR_USER))
 		return -EOPNOTSUPP;
 
 	return ext2_xattr_set(inode, EXT2_XATTR_INDEX_USER,
-- 
2.15.1

^ permalink raw reply	[flat|nested] 88+ messages in thread

* [PATCH 31/76] fs/ext4: Use inode_sb() helper instead of inode->i_sb
  2018-05-08 18:03 [RFC][PATCH 0/76] vfs: 'views' for filesystems with more than one root Mark Fasheh
                   ` (29 preceding siblings ...)
  2018-05-08 18:03 ` [PATCH 30/76] fs/ext2: " Mark Fasheh
@ 2018-05-08 18:03 ` Mark Fasheh
  2018-05-08 18:03 ` [PATCH 32/76] fs/f2fs: " Mark Fasheh
                   ` (45 subsequent siblings)
  76 siblings, 0 replies; 88+ messages in thread
From: Mark Fasheh @ 2018-05-08 18:03 UTC (permalink / raw)
  To: linux-fsdevel; +Cc: linux-kernel, linux-btrfs, Mark Fasheh

Signed-off-by: Mark Fasheh <mfasheh@suse.de>
---
 fs/ext4/acl.c            |   2 +-
 fs/ext4/balloc.c         |  14 +--
 fs/ext4/block_validity.c |   4 +-
 fs/ext4/dir.c            |  12 +-
 fs/ext4/ext4.h           |   8 +-
 fs/ext4/ext4_jbd2.c      |  10 +-
 fs/ext4/ext4_jbd2.h      |  14 +--
 fs/ext4/extents.c        | 107 ++++++++---------
 fs/ext4/extents_status.c |  23 ++--
 fs/ext4/file.c           |  22 ++--
 fs/ext4/fsync.c          |  15 +--
 fs/ext4/ialloc.c         |   7 +-
 fs/ext4/indirect.c       |  53 ++++-----
 fs/ext4/inline.c         |  53 ++++-----
 fs/ext4/inode.c          | 295 ++++++++++++++++++++++++-----------------------
 fs/ext4/ioctl.c          |  24 ++--
 fs/ext4/mballoc.c        |  13 ++-
 fs/ext4/migrate.c        |  44 +++----
 fs/ext4/move_extent.c    |  10 +-
 fs/ext4/namei.c          | 224 +++++++++++++++++------------------
 fs/ext4/page-io.c        |   9 +-
 fs/ext4/readpage.c       |   2 +-
 fs/ext4/resize.c         |   4 +-
 fs/ext4/super.c          |  52 +++++----
 fs/ext4/symlink.c        |   2 +-
 fs/ext4/sysfs.c          |   4 +-
 fs/ext4/truncate.h       |   4 +-
 fs/ext4/xattr.c          | 120 ++++++++++---------
 fs/ext4/xattr_user.c     |   4 +-
 29 files changed, 591 insertions(+), 564 deletions(-)

diff --git a/fs/ext4/acl.c b/fs/ext4/acl.c
index fb50f9aa6ead..651d49de6039 100644
--- a/fs/ext4/acl.c
+++ b/fs/ext4/acl.c
@@ -259,7 +259,7 @@ ext4_set_acl(struct inode *inode, struct posix_acl *acl, int type)
 	}
 out_stop:
 	ext4_journal_stop(handle);
-	if (error == -ENOSPC && ext4_should_retry_alloc(inode->i_sb, &retries))
+	if (error == -ENOSPC && ext4_should_retry_alloc(inode_sb(inode), &retries))
 		goto retry;
 	return error;
 }
diff --git a/fs/ext4/balloc.c b/fs/ext4/balloc.c
index f9b3e0a83526..7ea1ed70bdfe 100644
--- a/fs/ext4/balloc.c
+++ b/fs/ext4/balloc.c
@@ -654,7 +654,7 @@ ext4_fsblk_t ext4_new_meta_blocks(handle_t *handle, struct inode *inode,
 	 */
 	if (!(*errp) && (flags & EXT4_MB_DELALLOC_RESERVED)) {
 		dquot_alloc_block_nofail(inode,
-				EXT4_C2B(EXT4_SB(inode->i_sb), ar.len));
+				EXT4_C2B(EXT4_SB(inode_sb(inode)), ar.len));
 	}
 	return ret;
 }
@@ -855,7 +855,7 @@ ext4_fsblk_t ext4_inode_to_goal_block(struct inode *inode)
 	struct ext4_inode_info *ei = EXT4_I(inode);
 	ext4_group_t block_group;
 	ext4_grpblk_t colour;
-	int flex_size = ext4_flex_bg_size(EXT4_SB(inode->i_sb));
+	int flex_size = ext4_flex_bg_size(EXT4_SB(inode_sb(inode)));
 	ext4_fsblk_t bg_start;
 	ext4_fsblk_t last_block;
 
@@ -873,19 +873,19 @@ ext4_fsblk_t ext4_inode_to_goal_block(struct inode *inode)
 		if (S_ISREG(inode->i_mode))
 			block_group++;
 	}
-	bg_start = ext4_group_first_block_no(inode->i_sb, block_group);
-	last_block = ext4_blocks_count(EXT4_SB(inode->i_sb)->s_es) - 1;
+	bg_start = ext4_group_first_block_no(inode_sb(inode), block_group);
+	last_block = ext4_blocks_count(EXT4_SB(inode_sb(inode))->s_es) - 1;
 
 	/*
 	 * If we are doing delayed allocation, we don't need take
 	 * colour into account.
 	 */
-	if (test_opt(inode->i_sb, DELALLOC))
+	if (test_opt(inode_sb(inode), DELALLOC))
 		return bg_start;
 
-	if (bg_start + EXT4_BLOCKS_PER_GROUP(inode->i_sb) <= last_block)
+	if (bg_start + EXT4_BLOCKS_PER_GROUP(inode_sb(inode)) <= last_block)
 		colour = (current->pid % 16) *
-			(EXT4_BLOCKS_PER_GROUP(inode->i_sb) / 16);
+			(EXT4_BLOCKS_PER_GROUP(inode_sb(inode)) / 16);
 	else
 		colour = (current->pid % 16) * ((last_block - bg_start) / 16);
 	return bg_start + colour;
diff --git a/fs/ext4/block_validity.c b/fs/ext4/block_validity.c
index 913061c0de1b..4ff7e6e93b18 100644
--- a/fs/ext4/block_validity.c
+++ b/fs/ext4/block_validity.c
@@ -223,14 +223,14 @@ int ext4_data_block_valid(struct ext4_sb_info *sbi, ext4_fsblk_t start_blk,
 int ext4_check_blockref(const char *function, unsigned int line,
 			struct inode *inode, __le32 *p, unsigned int max)
 {
-	struct ext4_super_block *es = EXT4_SB(inode->i_sb)->s_es;
+	struct ext4_super_block *es = EXT4_SB(inode_sb(inode))->s_es;
 	__le32 *bref = p;
 	unsigned int blk;
 
 	while (bref < p+max) {
 		blk = le32_to_cpu(*bref++);
 		if (blk &&
-		    unlikely(!ext4_data_block_valid(EXT4_SB(inode->i_sb),
+		    unlikely(!ext4_data_block_valid(EXT4_SB(inode_sb(inode)),
 						    blk, 1))) {
 			es->s_last_error_block = cpu_to_le64(blk);
 			ext4_error_inode(inode, function, line, blk,
diff --git a/fs/ext4/dir.c b/fs/ext4/dir.c
index da87cf757f7d..78097b522abd 100644
--- a/fs/ext4/dir.c
+++ b/fs/ext4/dir.c
@@ -40,9 +40,9 @@ static int ext4_dx_readdir(struct file *, struct dir_context *);
  */
 static int is_dx_dir(struct inode *inode)
 {
-	struct super_block *sb = inode->i_sb;
+	struct super_block *sb = inode_sb(inode);
 
-	if (ext4_has_feature_dir_index(inode->i_sb) &&
+	if (ext4_has_feature_dir_index(inode_sb(inode)) &&
 	    ((ext4_test_inode_flag(inode, EXT4_INODE_INDEX)) ||
 	     ((inode->i_size >> sb->s_blocksize_bits) == 1) ||
 	     ext4_has_inline_data(inode)))
@@ -67,7 +67,7 @@ int __ext4_check_dir_entry(const char *function, unsigned int line,
 {
 	const char *error_msg = NULL;
 	const int rlen = ext4_rec_len_from_disk(de->rec_len,
-						dir->i_sb->s_blocksize);
+						inode_sb(dir)->s_blocksize);
 
 	if (unlikely(rlen < EXT4_DIR_REC_LEN(1)))
 		error_msg = "rec_len is smaller than minimal";
@@ -78,7 +78,7 @@ int __ext4_check_dir_entry(const char *function, unsigned int line,
 	else if (unlikely(((char *) de - buf) + rlen > size))
 		error_msg = "directory entry across range";
 	else if (unlikely(le32_to_cpu(de->inode) >
-			le32_to_cpu(EXT4_SB(dir->i_sb)->s_es->s_inodes_count)))
+			le32_to_cpu(EXT4_SB(inode_sb(dir))->s_es->s_inodes_count)))
 		error_msg = "inode out of bounds";
 	else
 		return 0;
@@ -108,7 +108,7 @@ static int ext4_readdir(struct file *file, struct dir_context *ctx)
 	struct ext4_dir_entry_2 *de;
 	int err;
 	struct inode *inode = file_inode(file);
-	struct super_block *sb = inode->i_sb;
+	struct super_block *sb = inode_sb(inode);
 	struct buffer_head *bh = NULL;
 	int dir_has_error = 0;
 	struct fscrypt_str fstr = FSTR_INIT(NULL, 0);
@@ -502,7 +502,7 @@ static int call_filldir(struct file *file, struct dir_context *ctx,
 {
 	struct dir_private_info *info = file->private_data;
 	struct inode *inode = file_inode(file);
-	struct super_block *sb = inode->i_sb;
+	struct super_block *sb = inode_sb(inode);
 
 	if (!fname) {
 		ext4_msg(sb, KERN_ERR, "%s:%d: inode #%lu: comm %s: "
diff --git a/fs/ext4/ext4.h b/fs/ext4/ext4.h
index 3241475a1733..8a3784d7b51f 100644
--- a/fs/ext4/ext4.h
+++ b/fs/ext4/ext4.h
@@ -1978,10 +1978,10 @@ static inline __le16 ext4_rec_len_to_disk(unsigned len, unsigned blocksize)
  * (c) Daniel Phillips, 2001
  */
 
-#define is_dx(dir) (ext4_has_feature_dir_index((dir)->i_sb) && \
+#define is_dx(dir) (ext4_has_feature_dir_index(inode_sb((dir))) && \
 		    ext4_test_inode_flag((dir), EXT4_INODE_INDEX))
 #define EXT4_DIR_LINK_MAX(dir) unlikely((dir)->i_nlink >= EXT4_LINK_MAX && \
-		    !(ext4_has_feature_dir_nlink((dir)->i_sb) && is_dx(dir)))
+		    !(ext4_has_feature_dir_nlink(inode_sb((dir))) && is_dx(dir)))
 #define EXT4_DIR_LINK_EMPTY(dir) ((dir)->i_nlink == 2 || (dir)->i_nlink == 1)
 
 /* Legal values for the dx_root hash_version field: */
@@ -2341,7 +2341,7 @@ void ext4_insert_dentry(struct inode *inode,
 			struct ext4_filename *fname);
 static inline void ext4_update_dx_flag(struct inode *inode)
 {
-	if (!ext4_has_feature_dir_index(inode->i_sb))
+	if (!ext4_has_feature_dir_index(inode_sb(inode)))
 		ext4_clear_inode_flag(inode, EXT4_INODE_INDEX);
 }
 static const unsigned char ext4_filetype_table[] = {
@@ -2924,7 +2924,7 @@ static inline void ext4_unlock_group(struct super_block *sb,
 #define ext4_check_indirect_blockref(inode, bh)				\
 	ext4_check_blockref(__func__, __LINE__, inode,			\
 			    (__le32 *)(bh)->b_data,			\
-			    EXT4_ADDR_PER_BLOCK((inode)->i_sb))
+			    EXT4_ADDR_PER_BLOCK(inode_sb((inode))))
 
 #define ext4_ind_check_inode(inode)					\
 	ext4_check_blockref(__func__, __LINE__, inode,			\
diff --git a/fs/ext4/ext4_jbd2.c b/fs/ext4/ext4_jbd2.c
index 2d593201cf7a..151323c6844b 100644
--- a/fs/ext4/ext4_jbd2.c
+++ b/fs/ext4/ext4_jbd2.c
@@ -207,7 +207,7 @@ int __ext4_forget(const char *where, unsigned int line, handle_t *handle,
 	jbd_debug(4, "forgetting bh %p: is_metadata = %d, mode %o, "
 		  "data mode %x\n",
 		  bh, is_metadata, inode->i_mode,
-		  test_opt(inode->i_sb, DATA_FLAGS));
+		  test_opt(inode_sb(inode), DATA_FLAGS));
 
 	/* In the no journal case, we can just do a bforget and return */
 	if (!ext4_handle_valid(handle)) {
@@ -220,7 +220,7 @@ int __ext4_forget(const char *where, unsigned int line, handle_t *handle,
 	 * support it.  Otherwise, only skip the revoke on un-journaled
 	 * data blocks. */
 
-	if (test_opt(inode->i_sb, DATA_FLAGS) == EXT4_MOUNT_JOURNAL_DATA ||
+	if (test_opt(inode_sb(inode), DATA_FLAGS) == EXT4_MOUNT_JOURNAL_DATA ||
 	    (!is_metadata && !ext4_should_journal_data(inode))) {
 		if (bh) {
 			BUFFER_TRACE(bh, "call jbd2_journal_forget");
@@ -241,8 +241,8 @@ int __ext4_forget(const char *where, unsigned int line, handle_t *handle,
 	if (err) {
 		ext4_journal_abort_handle(where, line, __func__,
 					  bh, handle, err);
-		__ext4_abort(inode->i_sb, where, line,
-			   "error %d when attempting revoke", err);
+		__ext4_abort(inode_sb(inode), where, line,
+			     "error %d when attempting revoke", err);
 	}
 	BUFFER_TRACE(bh, "exit");
 	return err;
@@ -308,7 +308,7 @@ int __ext4_handle_dirty_metadata(const char *where, unsigned int line,
 			if (buffer_req(bh) && !buffer_uptodate(bh)) {
 				struct ext4_super_block *es;
 
-				es = EXT4_SB(inode->i_sb)->s_es;
+				es = EXT4_SB(inode_sb(inode))->s_es;
 				es->s_last_error_block =
 					cpu_to_le64(bh->b_blocknr);
 				ext4_error_inode(inode, where, line,
diff --git a/fs/ext4/ext4_jbd2.h b/fs/ext4/ext4_jbd2.h
index 15b6dd733780..029cfddd9035 100644
--- a/fs/ext4/ext4_jbd2.h
+++ b/fs/ext4/ext4_jbd2.h
@@ -16,7 +16,7 @@
 #include <linux/jbd2.h>
 #include "ext4.h"
 
-#define EXT4_JOURNAL(inode)	(EXT4_SB((inode)->i_sb)->s_journal)
+#define EXT4_JOURNAL(inode)	(EXT4_SB(inode_sb((inode)))->s_journal)
 
 /* Define the number of blocks we need to account to a transaction to
  * modify one block of data.
@@ -308,7 +308,7 @@ static inline handle_t *__ext4_journal_start(struct inode *inode,
 					     unsigned int line, int type,
 					     int blocks, int rsv_blocks)
 {
-	return __ext4_journal_start_sb(inode->i_sb, line, type, blocks,
+	return __ext4_journal_start_sb(inode_sb(inode), line, type, blocks,
 				       rsv_blocks);
 }
 
@@ -407,17 +407,17 @@ static inline int ext4_inode_journal_mode(struct inode *inode)
 		return EXT4_INODE_WRITEBACK_DATA_MODE;	/* writeback */
 	/* We do not support data journalling with delayed allocation */
 	if (!S_ISREG(inode->i_mode) ||
-	    test_opt(inode->i_sb, DATA_FLAGS) == EXT4_MOUNT_JOURNAL_DATA ||
+	    test_opt(inode_sb(inode), DATA_FLAGS) == EXT4_MOUNT_JOURNAL_DATA ||
 	    (ext4_test_inode_flag(inode, EXT4_INODE_JOURNAL_DATA) &&
-	    !test_opt(inode->i_sb, DELALLOC))) {
+	    !test_opt(inode_sb(inode), DELALLOC))) {
 		/* We do not support data journalling for encrypted data */
 		if (S_ISREG(inode->i_mode) && ext4_encrypted_inode(inode))
 			return EXT4_INODE_ORDERED_DATA_MODE;  /* ordered */
 		return EXT4_INODE_JOURNAL_DATA_MODE;	/* journal data */
 	}
-	if (test_opt(inode->i_sb, DATA_FLAGS) == EXT4_MOUNT_ORDERED_DATA)
+	if (test_opt(inode_sb(inode), DATA_FLAGS) == EXT4_MOUNT_ORDERED_DATA)
 		return EXT4_INODE_ORDERED_DATA_MODE;	/* ordered */
-	if (test_opt(inode->i_sb, DATA_FLAGS) == EXT4_MOUNT_WRITEBACK_DATA)
+	if (test_opt(inode_sb(inode), DATA_FLAGS) == EXT4_MOUNT_WRITEBACK_DATA)
 		return EXT4_INODE_WRITEBACK_DATA_MODE;	/* writeback */
 	BUG();
 }
@@ -448,7 +448,7 @@ static inline int ext4_should_writeback_data(struct inode *inode)
  */
 static inline int ext4_should_dioread_nolock(struct inode *inode)
 {
-	if (!test_opt(inode->i_sb, DIOREAD_NOLOCK))
+	if (!test_opt(inode_sb(inode), DIOREAD_NOLOCK))
 		return 0;
 	if (!S_ISREG(inode->i_mode))
 		return 0;
diff --git a/fs/ext4/extents.c b/fs/ext4/extents.c
index 054416e9d827..5001725876ef 100644
--- a/fs/ext4/extents.c
+++ b/fs/ext4/extents.c
@@ -49,7 +49,7 @@ static __le32 ext4_extent_block_csum(struct inode *inode,
 				     struct ext4_extent_header *eh)
 {
 	struct ext4_inode_info *ei = EXT4_I(inode);
-	struct ext4_sb_info *sbi = EXT4_SB(inode->i_sb);
+	struct ext4_sb_info *sbi = EXT4_SB(inode_sb(inode));
 	__u32 csum;
 
 	csum = ext4_chksum(sbi, ei->i_csum_seed, (__u8 *)eh,
@@ -62,7 +62,7 @@ static int ext4_extent_block_csum_verify(struct inode *inode,
 {
 	struct ext4_extent_tail *et;
 
-	if (!ext4_has_metadata_csum(inode->i_sb))
+	if (!ext4_has_metadata_csum(inode_sb(inode)))
 		return 1;
 
 	et = find_ext4_extent_tail(eh);
@@ -76,7 +76,7 @@ static void ext4_extent_block_csum_set(struct inode *inode,
 {
 	struct ext4_extent_tail *et;
 
-	if (!ext4_has_metadata_csum(inode->i_sb))
+	if (!ext4_has_metadata_csum(inode_sb(inode)))
 		return;
 
 	et = find_ext4_extent_tail(eh);
@@ -233,7 +233,7 @@ static inline int ext4_ext_space_block(struct inode *inode, int check)
 {
 	int size;
 
-	size = (inode->i_sb->s_blocksize - sizeof(struct ext4_extent_header))
+	size = (inode_sb(inode)->s_blocksize - sizeof(struct ext4_extent_header))
 			/ sizeof(struct ext4_extent);
 #ifdef AGGRESSIVE_TEST
 	if (!check && size > 6)
@@ -246,7 +246,7 @@ static inline int ext4_ext_space_block_idx(struct inode *inode, int check)
 {
 	int size;
 
-	size = (inode->i_sb->s_blocksize - sizeof(struct ext4_extent_header))
+	size = (inode_sb(inode)->s_blocksize - sizeof(struct ext4_extent_header))
 			/ sizeof(struct ext4_extent_idx);
 #ifdef AGGRESSIVE_TEST
 	if (!check && size > 5)
@@ -307,7 +307,7 @@ int ext4_ext_calc_metadata_amount(struct inode *inode, ext4_lblk_t lblock)
 	struct ext4_inode_info *ei = EXT4_I(inode);
 	int idxs;
 
-	idxs = ((inode->i_sb->s_blocksize - sizeof(struct ext4_extent_header))
+	idxs = ((inode_sb(inode)->s_blocksize - sizeof(struct ext4_extent_header))
 		/ sizeof(struct ext4_extent_idx));
 
 	/*
@@ -377,7 +377,7 @@ static int ext4_valid_extent(struct inode *inode, struct ext4_extent *ext)
 	 */
 	if (lblock + len <= lblock)
 		return 0;
-	return ext4_data_block_valid(EXT4_SB(inode->i_sb), block, len);
+	return ext4_data_block_valid(EXT4_SB(inode_sb(inode)), block, len);
 }
 
 static int ext4_valid_extent_idx(struct inode *inode,
@@ -385,7 +385,7 @@ static int ext4_valid_extent_idx(struct inode *inode,
 {
 	ext4_fsblk_t block = ext4_idx_pblock(ext_idx);
 
-	return ext4_data_block_valid(EXT4_SB(inode->i_sb), block, 1);
+	return ext4_data_block_valid(EXT4_SB(inode_sb(inode)), block, 1);
 }
 
 static int ext4_valid_extent_entries(struct inode *inode,
@@ -401,7 +401,7 @@ static int ext4_valid_extent_entries(struct inode *inode,
 	if (depth == 0) {
 		/* leaf entries */
 		struct ext4_extent *ext = EXT_FIRST_EXTENT(eh);
-		struct ext4_super_block *es = EXT4_SB(inode->i_sb)->s_es;
+		struct ext4_super_block *es = EXT4_SB(inode_sb(inode))->s_es;
 		ext4_fsblk_t pblock = 0;
 		ext4_lblk_t lblock = 0;
 		ext4_lblk_t prev = 0;
@@ -506,7 +506,7 @@ __read_extent_tree_block(const char *function, unsigned int line,
 	struct buffer_head		*bh;
 	int				err;
 
-	bh = sb_getblk_gfp(inode->i_sb, pblk, __GFP_MOVABLE | GFP_NOFS);
+	bh = sb_getblk_gfp(inode_sb(inode), pblk, __GFP_MOVABLE | GFP_NOFS);
 	if (unlikely(!bh))
 		return ERR_PTR(-ENOMEM);
 
@@ -1000,7 +1000,7 @@ static int ext4_ext_insert_index(handle_t *handle, struct inode *inode,
 	}
 
 	err = ext4_ext_dirty(handle, inode, curp);
-	ext4_std_error(inode->i_sb, err);
+	ext4_std_error(inode_sb(inode), err);
 
 	return err;
 }
@@ -1084,7 +1084,8 @@ static int ext4_ext_split(handle_t *handle, struct inode *inode,
 		err = -EFSCORRUPTED;
 		goto cleanup;
 	}
-	bh = sb_getblk_gfp(inode->i_sb, newblock, __GFP_MOVABLE | GFP_NOFS);
+	bh = sb_getblk_gfp(inode_sb(inode), newblock,
+			   __GFP_MOVABLE | GFP_NOFS);
 	if (unlikely(!bh)) {
 		err = -ENOMEM;
 		goto cleanup;
@@ -1157,7 +1158,7 @@ static int ext4_ext_split(handle_t *handle, struct inode *inode,
 	while (k--) {
 		oldblock = newblock;
 		newblock = ablocks[--a];
-		bh = sb_getblk(inode->i_sb, newblock);
+		bh = sb_getblk(inode_sb(inode), newblock);
 		if (unlikely(!bh)) {
 			err = -ENOMEM;
 			goto cleanup;
@@ -1262,7 +1263,7 @@ static int ext4_ext_grow_indepth(handle_t *handle, struct inode *inode,
 	struct ext4_extent_header *neh;
 	struct buffer_head *bh;
 	ext4_fsblk_t newblock, goal = 0;
-	struct ext4_super_block *es = EXT4_SB(inode->i_sb)->s_es;
+	struct ext4_super_block *es = EXT4_SB(inode_sb(inode))->s_es;
 	int err = 0;
 
 	/* Try to prepend new index to old one */
@@ -1278,7 +1279,8 @@ static int ext4_ext_grow_indepth(handle_t *handle, struct inode *inode,
 	if (newblock == 0)
 		return err;
 
-	bh = sb_getblk_gfp(inode->i_sb, newblock, __GFP_MOVABLE | GFP_NOFS);
+	bh = sb_getblk_gfp(inode_sb(inode), newblock,
+			   __GFP_MOVABLE | GFP_NOFS);
 	if (unlikely(!bh))
 		return -ENOMEM;
 	lock_buffer(bh);
@@ -2154,7 +2156,7 @@ static int ext4_fill_fiemap_extents(struct inode *inode,
 	ext4_lblk_t last = block + num;
 	int exists, depth = 0, err = 0;
 	unsigned int flags = 0;
-	unsigned char blksize_bits = inode->i_sb->s_blocksize_bits;
+	unsigned char blksize_bits = inode_sb(inode)->s_blocksize_bits;
 
 	while (block < last && block != EXT_MAX_BLOCKS) {
 		num = last - block;
@@ -2438,7 +2440,7 @@ int ext4_ext_calc_credits_for_single_extent(struct inode *inode, int nrblocks,
 			 *  accounted.
 			 */
 			/* 1 bitmap, 1 block group descriptor */
-			ret = 2 + EXT4_META_TRANS_BLOCKS(inode->i_sb);
+			ret = 2 + EXT4_META_TRANS_BLOCKS(inode_sb(inode));
 			return ret;
 		}
 	}
@@ -2489,7 +2491,7 @@ static int ext4_remove_blocks(handle_t *handle, struct inode *inode,
 			      long long *partial_cluster,
 			      ext4_lblk_t from, ext4_lblk_t to)
 {
-	struct ext4_sb_info *sbi = EXT4_SB(inode->i_sb);
+	struct ext4_sb_info *sbi = EXT4_SB(inode_sb(inode));
 	unsigned short ee_len = ext4_ext_get_actual_len(ex);
 	ext4_fsblk_t pblk;
 	int flags = get_default_free_blocks_flags(inode);
@@ -2520,7 +2522,7 @@ static int ext4_remove_blocks(handle_t *handle, struct inode *inode,
 
 #ifdef EXTENTS_STATS
 	{
-		struct ext4_sb_info *sbi = EXT4_SB(inode->i_sb);
+		struct ext4_sb_info *sbi = EXT4_SB(inode_sb(inode));
 		spin_lock(&sbi->s_ext_stats_lock);
 		sbi->s_ext_blocks += ee_len;
 		sbi->s_ext_extents++;
@@ -2605,7 +2607,7 @@ ext4_ext_rm_leaf(handle_t *handle, struct inode *inode,
 		 long long *partial_cluster,
 		 ext4_lblk_t start, ext4_lblk_t end)
 {
-	struct ext4_sb_info *sbi = EXT4_SB(inode->i_sb);
+	struct ext4_sb_info *sbi = EXT4_SB(inode_sb(inode));
 	int err = 0, correct_index = 0;
 	int depth = ext_depth(inode), credits;
 	struct ext4_extent_header *eh;
@@ -2693,12 +2695,12 @@ ext4_ext_rm_leaf(handle_t *handle, struct inode *inode,
 		 * groups plus ex_ee_len/blocks_per_block_group for
 		 * the worst case
 		 */
-		credits = 7 + 2*(ex_ee_len/EXT4_BLOCKS_PER_GROUP(inode->i_sb));
+		credits = 7 + 2*(ex_ee_len/EXT4_BLOCKS_PER_GROUP(inode_sb(inode)));
 		if (ex == EXT_FIRST_EXTENT(eh)) {
 			correct_index = 1;
 			credits += (ext_depth(inode)) + 1;
 		}
-		credits += EXT4_MAXQUOTAS_TRANS_BLOCKS(inode->i_sb);
+		credits += EXT4_MAXQUOTAS_TRANS_BLOCKS(inode_sb(inode));
 
 		err = ext4_ext_truncate_extend_restart(handle, inode, credits);
 		if (err)
@@ -2810,7 +2812,7 @@ ext4_ext_more_to_rm(struct ext4_ext_path *path)
 int ext4_ext_remove_space(struct inode *inode, ext4_lblk_t start,
 			  ext4_lblk_t end)
 {
-	struct ext4_sb_info *sbi = EXT4_SB(inode->i_sb);
+	struct ext4_sb_info *sbi = EXT4_SB(inode_sb(inode));
 	int depth = ext_depth(inode);
 	struct ext4_ext_path *path = NULL;
 	long long partial_cluster = 0;
@@ -3414,9 +3416,9 @@ static int ext4_ext_convert_to_initialized(handle_t *handle,
 		"block %llu, max_blocks %u\n", inode->i_ino,
 		(unsigned long long)map->m_lblk, map_len);
 
-	sbi = EXT4_SB(inode->i_sb);
-	eof_block = (inode->i_size + inode->i_sb->s_blocksize - 1) >>
-		inode->i_sb->s_blocksize_bits;
+	sbi = EXT4_SB(inode_sb(inode));
+	eof_block = (inode->i_size + inode_sb(inode)->s_blocksize - 1) >>
+		inode_sb(inode)->s_blocksize_bits;
 	if (eof_block < map->m_lblk + map_len)
 		eof_block = map->m_lblk + map_len;
 
@@ -3561,7 +3563,7 @@ static int ext4_ext_convert_to_initialized(handle_t *handle,
 
 	if (EXT4_EXT_MAY_ZEROOUT & split_flag)
 		max_zeroout = sbi->s_extent_max_zeroout_kb >>
-			(inode->i_sb->s_blocksize_bits - 10);
+			(inode_sb(inode)->s_blocksize_bits - 10);
 
 	if (ext4_encrypted_inode(inode))
 		max_zeroout = 0;
@@ -3671,8 +3673,8 @@ static int ext4_split_convert_extents(handle_t *handle,
 		  __func__, inode->i_ino,
 		  (unsigned long long)map->m_lblk, map->m_len);
 
-	eof_block = (inode->i_size + inode->i_sb->s_blocksize - 1) >>
-		inode->i_sb->s_blocksize_bits;
+	eof_block = (inode->i_size + inode_sb(inode)->s_blocksize - 1) >>
+		inode_sb(inode)->s_blocksize_bits;
 	if (eof_block < map->m_lblk + map->m_len)
 		eof_block = map->m_lblk + map->m_len;
 	/*
@@ -3838,7 +3840,7 @@ int ext4_find_delalloc_range(struct inode *inode,
 
 int ext4_find_delalloc_cluster(struct inode *inode, ext4_lblk_t lblk)
 {
-	struct ext4_sb_info *sbi = EXT4_SB(inode->i_sb);
+	struct ext4_sb_info *sbi = EXT4_SB(inode_sb(inode));
 	ext4_lblk_t lblk_start, lblk_end;
 	lblk_start = EXT4_LBLK_CMASK(sbi, lblk);
 	lblk_end = lblk_start + sbi->s_cluster_ratio - 1;
@@ -3885,7 +3887,7 @@ static unsigned int
 get_reserved_cluster_alloc(struct inode *inode, ext4_lblk_t lblk_start,
 			   unsigned int num_blks)
 {
-	struct ext4_sb_info *sbi = EXT4_SB(inode->i_sb);
+	struct ext4_sb_info *sbi = EXT4_SB(inode_sb(inode));
 	ext4_lblk_t alloc_cluster_start, alloc_cluster_end;
 	ext4_lblk_t lblk_from, lblk_to, c_offset;
 	unsigned int allocated_clusters = 0;
@@ -4096,7 +4098,8 @@ ext4_ext_handle_unwritten_extents(handle_t *handle, struct inode *inode,
 	 * new.
 	 */
 	if (allocated > map->m_len) {
-		clean_bdev_aliases(inode->i_sb->s_bdev, newblock + map->m_len,
+		clean_bdev_aliases(inode_sb(inode)->s_bdev,
+				   newblock + map->m_len,
 				   allocated - map->m_len);
 		allocated = map->m_len;
 	}
@@ -4263,7 +4266,7 @@ int ext4_ext_map_blocks(handle_t *handle, struct inode *inode,
 {
 	struct ext4_ext_path *path = NULL;
 	struct ext4_extent newex, *ex, *ex2;
-	struct ext4_sb_info *sbi = EXT4_SB(inode->i_sb);
+	struct ext4_sb_info *sbi = EXT4_SB(inode_sb(inode));
 	ext4_fsblk_t newblock = 0;
 	int free_on_err = 0, err = 0, depth, ret;
 	unsigned int allocated = 0, offset = 0;
@@ -4382,7 +4385,7 @@ int ext4_ext_map_blocks(handle_t *handle, struct inode *inode,
 	 * by ext4_find_extent() implies a cluster we can use.
 	 */
 	if (cluster_offset && ex &&
-	    get_implied_cluster_alloc(inode->i_sb, map, ex, path)) {
+	    get_implied_cluster_alloc(inode_sb(inode), map, ex, path)) {
 		ar.len = allocated = map->m_len;
 		newblock = map->m_pblk;
 		map_from_cluster = true;
@@ -4403,7 +4406,7 @@ int ext4_ext_map_blocks(handle_t *handle, struct inode *inode,
 	/* Check if the extent after searching to the right implies a
 	 * cluster we can use. */
 	if ((sbi->s_cluster_ratio > 1) && ex2 &&
-	    get_implied_cluster_alloc(inode->i_sb, map, ex2, path)) {
+	    get_implied_cluster_alloc(inode_sb(inode), map, ex2, path)) {
 		ar.len = allocated = map->m_len;
 		newblock = map->m_pblk;
 		map_from_cluster = true;
@@ -4607,7 +4610,7 @@ int ext4_ext_map_blocks(handle_t *handle, struct inode *inode,
 
 int ext4_ext_truncate(handle_t *handle, struct inode *inode)
 {
-	struct super_block *sb = inode->i_sb;
+	struct super_block *sb = inode_sb(inode);
 	ext4_lblk_t last_block;
 	int err = 0;
 
@@ -4716,7 +4719,7 @@ static int ext4_alloc_file_blocks(struct file *file, ext4_lblk_t offset,
 			break;
 	}
 	if (ret == -ENOSPC &&
-			ext4_should_retry_alloc(inode->i_sb, &retries)) {
+			ext4_should_retry_alloc(inode_sb(inode), &retries)) {
 		ret = 0;
 		goto retry;
 	}
@@ -4746,7 +4749,7 @@ static long ext4_zero_range(struct file *file, loff_t offset,
 
 	/* Call ext4_force_commit to flush all data in case of data=journal. */
 	if (ext4_should_journal_data(inode)) {
-		ret = ext4_force_commit(inode->i_sb);
+		ret = ext4_force_commit(inode_sb(inode));
 		if (ret)
 			return ret;
 	}
@@ -4849,7 +4852,7 @@ static long ext4_zero_range(struct file *file, loff_t offset,
 	handle = ext4_journal_start(inode, EXT4_HT_MISC, credits);
 	if (IS_ERR(handle)) {
 		ret = PTR_ERR(handle);
-		ext4_std_error(inode->i_sb, ret);
+		ext4_std_error(inode_sb(inode), ret);
 		goto out_dio;
 	}
 
@@ -4972,8 +4975,8 @@ long ext4_fallocate(struct file *file, int mode, loff_t offset, loff_t len)
 	if (ret)
 		goto out;
 
-	if (file->f_flags & O_SYNC && EXT4_SB(inode->i_sb)->s_journal) {
-		ret = jbd2_complete_transaction(EXT4_SB(inode->i_sb)->s_journal,
+	if (file->f_flags & O_SYNC && EXT4_SB(inode_sb(inode))->s_journal) {
+		ret = jbd2_complete_transaction(EXT4_SB(inode_sb(inode))->s_journal,
 						EXT4_I(inode)->i_sync_tid);
 	}
 out:
@@ -5035,7 +5038,7 @@ int ext4_convert_unwritten_extents(handle_t *handle, struct inode *inode,
 		ret = ext4_map_blocks(handle, inode, &map,
 				      EXT4_GET_BLOCKS_IO_CONVERT_EXT);
 		if (ret <= 0)
-			ext4_warning(inode->i_sb,
+			ext4_warning(inode_sb(inode),
 				     "inode #%lu: block %u: len %u: "
 				     "ext4_ext_map_blocks returned %d",
 				     inode->i_ino, map.m_lblk,
@@ -5106,7 +5109,7 @@ static int ext4_xattr_fiemap(struct inode *inode,
 	__u64 physical = 0;
 	__u64 length;
 	__u32 flags = FIEMAP_EXTENT_LAST;
-	int blockbits = inode->i_sb->s_blocksize_bits;
+	int blockbits = inode_sb(inode)->s_blocksize_bits;
 	int error = 0;
 
 	/* in-inode? */
@@ -5121,12 +5124,12 @@ static int ext4_xattr_fiemap(struct inode *inode,
 		offset = EXT4_GOOD_OLD_INODE_SIZE +
 				EXT4_I(inode)->i_extra_isize;
 		physical += offset;
-		length = EXT4_SB(inode->i_sb)->s_inode_size - offset;
+		length = EXT4_SB(inode_sb(inode))->s_inode_size - offset;
 		flags |= FIEMAP_EXTENT_DATA_INLINE;
 		brelse(iloc.bh);
 	} else { /* external block */
 		physical = (__u64)EXT4_I(inode)->i_file_acl << blockbits;
-		length = inode->i_sb->s_blocksize;
+		length = inode_sb(inode)->s_blocksize;
 	}
 
 	if (physical)
@@ -5171,8 +5174,8 @@ int ext4_fiemap(struct inode *inode, struct fiemap_extent_info *fieinfo,
 		ext4_lblk_t len_blks;
 		__u64 last_blk;
 
-		start_blk = start >> inode->i_sb->s_blocksize_bits;
-		last_blk = (start + len - 1) >> inode->i_sb->s_blocksize_bits;
+		start_blk = start >> inode_sb(inode)->s_blocksize_bits;
+		last_blk = (start + len - 1) >> inode_sb(inode)->s_blocksize_bits;
 		if (last_blk >= EXT_MAX_BLOCKS)
 			last_blk = EXT_MAX_BLOCKS-1;
 		len_blks = ((ext4_lblk_t) last_blk) - start_blk + 1;
@@ -5433,7 +5436,7 @@ ext4_ext_shift_extents(struct inode *inode, handle_t *handle,
  */
 int ext4_collapse_range(struct inode *inode, loff_t offset, loff_t len)
 {
-	struct super_block *sb = inode->i_sb;
+	struct super_block *sb = inode_sb(inode);
 	ext4_lblk_t punch_start, punch_stop;
 	handle_t *handle;
 	unsigned int credits;
@@ -5463,7 +5466,7 @@ int ext4_collapse_range(struct inode *inode, loff_t offset, loff_t len)
 
 	/* Call ext4_force_commit to flush all data in case of data=journal. */
 	if (ext4_should_journal_data(inode)) {
-		ret = ext4_force_commit(inode->i_sb);
+		ret = ext4_force_commit(inode_sb(inode));
 		if (ret)
 			return ret;
 	}
@@ -5578,7 +5581,7 @@ int ext4_collapse_range(struct inode *inode, loff_t offset, loff_t len)
  */
 int ext4_insert_range(struct inode *inode, loff_t offset, loff_t len)
 {
-	struct super_block *sb = inode->i_sb;
+	struct super_block *sb = inode_sb(inode);
 	handle_t *handle;
 	struct ext4_ext_path *path;
 	struct ext4_extent *extent;
@@ -5610,7 +5613,7 @@ int ext4_insert_range(struct inode *inode, loff_t offset, loff_t len)
 
 	/* Call ext4_force_commit to flush all data in case of data=journal */
 	if (ext4_should_journal_data(inode)) {
-		ret = ext4_force_commit(inode->i_sb);
+		ret = ext4_force_commit(inode_sb(inode));
 		if (ret)
 			return ret;
 	}
@@ -5623,7 +5626,7 @@ int ext4_insert_range(struct inode *inode, loff_t offset, loff_t len)
 	}
 
 	/* Check for wrap through zero */
-	if (inode->i_size + len > inode->i_sb->s_maxbytes) {
+	if (inode->i_size + len > inode_sb(inode)->s_maxbytes) {
 		ret = -EFBIG;
 		goto out_mutex;
 	}
diff --git a/fs/ext4/extents_status.c b/fs/ext4/extents_status.c
index 763ef185dd17..56c59000c9cc 100644
--- a/fs/ext4/extents_status.c
+++ b/fs/ext4/extents_status.c
@@ -299,7 +299,7 @@ void ext4_es_find_delayed_extent_range(struct inode *inode,
 static void ext4_es_list_add(struct inode *inode)
 {
 	struct ext4_inode_info *ei = EXT4_I(inode);
-	struct ext4_sb_info *sbi = EXT4_SB(inode->i_sb);
+	struct ext4_sb_info *sbi = EXT4_SB(inode_sb(inode));
 
 	if (!list_empty(&ei->i_es_list))
 		return;
@@ -315,7 +315,7 @@ static void ext4_es_list_add(struct inode *inode)
 static void ext4_es_list_del(struct inode *inode)
 {
 	struct ext4_inode_info *ei = EXT4_I(inode);
-	struct ext4_sb_info *sbi = EXT4_SB(inode->i_sb);
+	struct ext4_sb_info *sbi = EXT4_SB(inode_sb(inode));
 
 	spin_lock(&sbi->s_es_lock);
 	if (!list_empty(&ei->i_es_list)) {
@@ -344,12 +344,12 @@ ext4_es_alloc_extent(struct inode *inode, ext4_lblk_t lblk, ext4_lblk_t len,
 	if (!ext4_es_is_delayed(es)) {
 		if (!EXT4_I(inode)->i_es_shk_nr++)
 			ext4_es_list_add(inode);
-		percpu_counter_inc(&EXT4_SB(inode->i_sb)->
+		percpu_counter_inc(&EXT4_SB(inode_sb(inode))->
 					s_es_stats.es_stats_shk_cnt);
 	}
 
 	EXT4_I(inode)->i_es_all_nr++;
-	percpu_counter_inc(&EXT4_SB(inode->i_sb)->s_es_stats.es_stats_all_cnt);
+	percpu_counter_inc(&EXT4_SB(inode_sb(inode))->s_es_stats.es_stats_all_cnt);
 
 	return es;
 }
@@ -357,14 +357,14 @@ ext4_es_alloc_extent(struct inode *inode, ext4_lblk_t lblk, ext4_lblk_t len,
 static void ext4_es_free_extent(struct inode *inode, struct extent_status *es)
 {
 	EXT4_I(inode)->i_es_all_nr--;
-	percpu_counter_dec(&EXT4_SB(inode->i_sb)->s_es_stats.es_stats_all_cnt);
+	percpu_counter_dec(&EXT4_SB(inode_sb(inode))->s_es_stats.es_stats_all_cnt);
 
 	/* Decrease the shrink counter when this es is not delayed */
 	if (!ext4_es_is_delayed(es)) {
 		BUG_ON(EXT4_I(inode)->i_es_shk_nr == 0);
 		if (!--EXT4_I(inode)->i_es_shk_nr)
 			ext4_es_list_del(inode);
-		percpu_counter_dec(&EXT4_SB(inode->i_sb)->
+		percpu_counter_dec(&EXT4_SB(inode_sb(inode))->
 					s_es_stats.es_stats_shk_cnt);
 	}
 
@@ -706,7 +706,7 @@ int ext4_es_insert_extent(struct inode *inode, ext4_lblk_t lblk,
 
 	if ((status & EXTENT_STATUS_DELAYED) &&
 	    (status & EXTENT_STATUS_WRITTEN)) {
-		ext4_warning(inode->i_sb, "Inserting extent [%u/%u] as "
+		ext4_warning(inode_sb(inode), "Inserting extent [%u/%u] as "
 				" delayed and written which can potentially "
 				" cause data loss.", lblk, len);
 		WARN_ON(1);
@@ -725,7 +725,7 @@ int ext4_es_insert_extent(struct inode *inode, ext4_lblk_t lblk,
 		goto error;
 retry:
 	err = __es_insert_extent(inode, &newes);
-	if (err == -ENOMEM && __es_shrink(EXT4_SB(inode->i_sb),
+	if (err == -ENOMEM && __es_shrink(EXT4_SB(inode_sb(inode)),
 					  128, EXT4_I(inode)))
 		goto retry;
 	if (err == -ENOMEM && !ext4_es_is_delayed(&newes))
@@ -818,7 +818,7 @@ int ext4_es_lookup_extent(struct inode *inode, ext4_lblk_t lblk,
 	}
 
 out:
-	stats = &EXT4_SB(inode->i_sb)->s_es_stats;
+	stats = &EXT4_SB(inode_sb(inode))->s_es_stats;
 	if (found) {
 		BUG_ON(!es1);
 		es->es_lblk = es1->es_lblk;
@@ -885,7 +885,7 @@ static int __es_remove_extent(struct inode *inode, ext4_lblk_t lblk,
 				es->es_lblk = orig_es.es_lblk;
 				es->es_len = orig_es.es_len;
 				if ((err == -ENOMEM) &&
-				    __es_shrink(EXT4_SB(inode->i_sb),
+				    __es_shrink(EXT4_SB(inode_sb(inode)),
 							128, EXT4_I(inode)))
 					goto retry;
 				goto out;
@@ -1244,7 +1244,8 @@ static int es_reclaim_extents(struct ext4_inode_info *ei, int *nr_to_scan)
 
 	if (ext4_test_inode_state(inode, EXT4_STATE_EXT_PRECACHED) &&
 	    __ratelimit(&_rs))
-		ext4_warning(inode->i_sb, "forced shrink of precached extents");
+		ext4_warning(inode_sb(inode),
+			     "forced shrink of precached extents");
 
 	if (!es_do_reclaim_extents(ei, EXT_MAX_BLOCKS, nr_to_scan, &nr_shrunk) &&
 	    start != 0)
diff --git a/fs/ext4/file.c b/fs/ext4/file.c
index fb6f023622fe..d6547085f4d2 100644
--- a/fs/ext4/file.c
+++ b/fs/ext4/file.c
@@ -64,7 +64,7 @@ static ssize_t ext4_dax_read_iter(struct kiocb *iocb, struct iov_iter *to)
 
 static ssize_t ext4_file_read_iter(struct kiocb *iocb, struct iov_iter *to)
 {
-	if (unlikely(ext4_forced_shutdown(EXT4_SB(file_inode(iocb->ki_filp)->i_sb))))
+	if (unlikely(ext4_forced_shutdown(EXT4_SB(inode_sb(file_inode(iocb->ki_filp))))))
 		return -EIO;
 
 	if (!iov_iter_count(to))
@@ -122,7 +122,7 @@ static void ext4_unwritten_wait(struct inode *inode)
 static int
 ext4_unaligned_aio(struct inode *inode, struct iov_iter *from, loff_t pos)
 {
-	struct super_block *sb = inode->i_sb;
+	struct super_block *sb = inode_sb(inode);
 	int blockmask = sb->s_blocksize - 1;
 
 	if (pos >= i_size_read(inode))
@@ -170,7 +170,7 @@ static ssize_t ext4_write_checks(struct kiocb *iocb, struct iov_iter *from)
 	 * is smaller than s_maxbytes, which is for extent-mapped files.
 	 */
 	if (!(ext4_test_inode_flag(inode, EXT4_INODE_EXTENTS))) {
-		struct ext4_sb_info *sbi = EXT4_SB(inode->i_sb);
+		struct ext4_sb_info *sbi = EXT4_SB(inode_sb(inode));
 
 		if (iocb->ki_pos >= sbi->s_bitmap_maxbytes)
 			return -EFBIG;
@@ -219,7 +219,7 @@ ext4_file_write_iter(struct kiocb *iocb, struct iov_iter *from)
 	int overwrite = 0;
 	ssize_t ret;
 
-	if (unlikely(ext4_forced_shutdown(EXT4_SB(inode->i_sb))))
+	if (unlikely(ext4_forced_shutdown(EXT4_SB(inode_sb(inode)))))
 		return -EIO;
 
 #ifdef CONFIG_FS_DAX
@@ -284,7 +284,7 @@ static int ext4_dax_huge_fault(struct vm_fault *vmf,
 	int retries = 0;
 	handle_t *handle = NULL;
 	struct inode *inode = file_inode(vmf->vma->vm_file);
-	struct super_block *sb = inode->i_sb;
+	struct super_block *sb = inode_sb(inode);
 
 	/*
 	 * We have to distinguish real writes from writes which will result in a
@@ -360,7 +360,7 @@ static int ext4_file_mmap(struct file *file, struct vm_area_struct *vma)
 {
 	struct inode *inode = file->f_mapping->host;
 
-	if (unlikely(ext4_forced_shutdown(EXT4_SB(inode->i_sb))))
+	if (unlikely(ext4_forced_shutdown(EXT4_SB(inode_sb(inode)))))
 		return -EIO;
 
 	/*
@@ -382,14 +382,14 @@ static int ext4_file_mmap(struct file *file, struct vm_area_struct *vma)
 
 static int ext4_file_open(struct inode * inode, struct file * filp)
 {
-	struct super_block *sb = inode->i_sb;
-	struct ext4_sb_info *sbi = EXT4_SB(inode->i_sb);
+	struct super_block *sb = inode_sb(inode);
+	struct ext4_sb_info *sbi = EXT4_SB(inode_sb(inode));
 	struct vfsmount *mnt = filp->f_path.mnt;
 	struct path path;
 	char buf[64], *cp;
 	int ret;
 
-	if (unlikely(ext4_forced_shutdown(EXT4_SB(inode->i_sb))))
+	if (unlikely(ext4_forced_shutdown(EXT4_SB(inode_sb(inode)))))
 		return -EIO;
 
 	if (unlikely(!(sbi->s_mount_flags & EXT4_MF_MNTDIR_SAMPLED) &&
@@ -454,9 +454,9 @@ loff_t ext4_llseek(struct file *file, loff_t offset, int whence)
 	loff_t maxbytes;
 
 	if (!(ext4_test_inode_flag(inode, EXT4_INODE_EXTENTS)))
-		maxbytes = EXT4_SB(inode->i_sb)->s_bitmap_maxbytes;
+		maxbytes = EXT4_SB(inode_sb(inode))->s_bitmap_maxbytes;
 	else
-		maxbytes = inode->i_sb->s_maxbytes;
+		maxbytes = inode_sb(inode)->s_maxbytes;
 
 	switch (whence) {
 	default:
diff --git a/fs/ext4/fsync.c b/fs/ext4/fsync.c
index 26a7fe5c4fd3..ad5a1fff59ec 100644
--- a/fs/ext4/fsync.c
+++ b/fs/ext4/fsync.c
@@ -96,22 +96,22 @@ int ext4_sync_file(struct file *file, loff_t start, loff_t end, int datasync)
 {
 	struct inode *inode = file->f_mapping->host;
 	struct ext4_inode_info *ei = EXT4_I(inode);
-	journal_t *journal = EXT4_SB(inode->i_sb)->s_journal;
+	journal_t *journal = EXT4_SB(inode_sb(inode))->s_journal;
 	int ret = 0, err;
 	tid_t commit_tid;
 	bool needs_barrier = false;
 
-	if (unlikely(ext4_forced_shutdown(EXT4_SB(inode->i_sb))))
+	if (unlikely(ext4_forced_shutdown(EXT4_SB(inode_sb(inode)))))
 		return -EIO;
 
 	J_ASSERT(ext4_journal_current_handle() == NULL);
 
 	trace_ext4_sync_file_enter(file, datasync);
 
-	if (sb_rdonly(inode->i_sb)) {
+	if (sb_rdonly(inode_sb(inode))) {
 		/* Make sure that we read updated s_mount_flags value */
 		smp_rmb();
-		if (EXT4_SB(inode->i_sb)->s_mount_flags & EXT4_MF_FS_ABORTED)
+		if (EXT4_SB(inode_sb(inode))->s_mount_flags & EXT4_MF_FS_ABORTED)
 			ret = -EROFS;
 		goto out;
 	}
@@ -120,7 +120,7 @@ int ext4_sync_file(struct file *file, loff_t start, loff_t end, int datasync)
 		ret = __generic_file_fsync(file, start, end, datasync);
 		if (!ret)
 			ret = ext4_sync_parent(inode);
-		if (test_opt(inode->i_sb, BARRIER))
+		if (test_opt(inode_sb(inode), BARRIER))
 			goto issue_flush;
 		goto out;
 	}
@@ -143,7 +143,7 @@ int ext4_sync_file(struct file *file, loff_t start, loff_t end, int datasync)
 	 *  safe in-journal, which is all fsync() needs to ensure.
 	 */
 	if (ext4_should_journal_data(inode)) {
-		ret = ext4_force_commit(inode->i_sb);
+		ret = ext4_force_commit(inode_sb(inode));
 		goto out;
 	}
 
@@ -154,7 +154,8 @@ int ext4_sync_file(struct file *file, loff_t start, loff_t end, int datasync)
 	ret = jbd2_complete_transaction(journal, commit_tid);
 	if (needs_barrier) {
 	issue_flush:
-		err = blkdev_issue_flush(inode->i_sb->s_bdev, GFP_KERNEL, NULL);
+		err = blkdev_issue_flush(inode_sb(inode)->s_bdev, GFP_KERNEL,
+					 NULL);
 		if (!ret)
 			ret = err;
 	}
diff --git a/fs/ext4/ialloc.c b/fs/ext4/ialloc.c
index 7830d28df331..95b8d6077faf 100644
--- a/fs/ext4/ialloc.c
+++ b/fs/ext4/ialloc.c
@@ -255,7 +255,7 @@ ext4_read_inode_bitmap(struct super_block *sb, ext4_group_t block_group)
  */
 void ext4_free_inode(handle_t *handle, struct inode *inode)
 {
-	struct super_block *sb = inode->i_sb;
+	struct super_block *sb = inode_sb(inode);
 	int is_directory;
 	unsigned long ino;
 	struct buffer_head *bitmap_bh = NULL;
@@ -795,7 +795,7 @@ struct inode *__ext4_new_inode(handle_t *handle, struct inode *dir,
 	if (!dir || !dir->i_nlink)
 		return ERR_PTR(-EPERM);
 
-	sb = dir->i_sb;
+	sb = inode_sb(dir);
 	sbi = EXT4_SB(sb);
 
 	if (unlikely(ext4_forced_shutdown(sbi)))
@@ -953,7 +953,8 @@ struct inode *__ext4_new_inode(handle_t *handle, struct inode *dir,
 
 		if (!handle) {
 			BUG_ON(nblocks <= 0);
-			handle = __ext4_journal_start_sb(dir->i_sb, line_no,
+			handle = __ext4_journal_start_sb(inode_sb(dir),
+							 line_no,
 							 handle_type, nblocks,
 							 0);
 			if (IS_ERR(handle)) {
diff --git a/fs/ext4/indirect.c b/fs/ext4/indirect.c
index c32802c956d5..8725e486df18 100644
--- a/fs/ext4/indirect.c
+++ b/fs/ext4/indirect.c
@@ -58,7 +58,7 @@ static inline void add_chain(Indirect *p, struct buffer_head *bh, __le32 *v)
  *
  *	Note: function doesn't find node addresses, so no IO is needed. All
  *	we need to know is the capacity of indirect blocks (taken from the
- *	inode->i_sb).
+ *	inode_sb(inode)).
  */
 
 /*
@@ -75,8 +75,8 @@ static int ext4_block_to_path(struct inode *inode,
 			      ext4_lblk_t i_block,
 			      ext4_lblk_t offsets[4], int *boundary)
 {
-	int ptrs = EXT4_ADDR_PER_BLOCK(inode->i_sb);
-	int ptrs_bits = EXT4_ADDR_PER_BLOCK_BITS(inode->i_sb);
+	int ptrs = EXT4_ADDR_PER_BLOCK(inode_sb(inode));
+	int ptrs_bits = EXT4_ADDR_PER_BLOCK_BITS(inode_sb(inode));
 	const long direct_blocks = EXT4_NDIR_BLOCKS,
 		indirect_blocks = ptrs,
 		double_blocks = (1 << (ptrs_bits * 2));
@@ -102,7 +102,7 @@ static int ext4_block_to_path(struct inode *inode,
 		offsets[n++] = i_block & (ptrs - 1);
 		final = ptrs;
 	} else {
-		ext4_warning(inode->i_sb, "block %lu > max in inode %lu",
+		ext4_warning(inode_sb(inode), "block %lu > max in inode %lu",
 			     i_block + direct_blocks +
 			     indirect_blocks + double_blocks, inode->i_ino);
 	}
@@ -145,7 +145,7 @@ static Indirect *ext4_get_branch(struct inode *inode, int depth,
 				 ext4_lblk_t  *offsets,
 				 Indirect chain[4], int *err)
 {
-	struct super_block *sb = inode->i_sb;
+	struct super_block *sb = inode_sb(inode);
 	Indirect *p = chain;
 	struct buffer_head *bh;
 	int ret = -EIO;
@@ -346,7 +346,8 @@ static int ext4_alloc_branch(handle_t *handle,
 		if (i == 0)
 			continue;
 
-		bh = branch[i].bh = sb_getblk(ar->inode->i_sb, new_blocks[i-1]);
+		bh = branch[i].bh = sb_getblk(inode_sb(ar->inode),
+					      new_blocks[i-1]);
 		if (unlikely(!bh)) {
 			err = -ENOMEM;
 			goto failed;
@@ -558,7 +559,7 @@ int ext4_ind_map_blocks(handle_t *handle, struct inode *inode,
 
 	/* Next simple case - plain lookup failed */
 	if ((flags & EXT4_GET_BLOCKS_CREATE) == 0) {
-		unsigned epb = inode->i_sb->s_blocksize / sizeof(u32);
+		unsigned epb = inode_sb(inode)->s_blocksize / sizeof(u32);
 		int i;
 
 		/* Count number blocks in a subtree under 'partial' */
@@ -578,7 +579,7 @@ int ext4_ind_map_blocks(handle_t *handle, struct inode *inode,
 	/*
 	 * Okay, we need to do block allocation.
 	*/
-	if (ext4_has_feature_bigalloc(inode->i_sb)) {
+	if (ext4_has_feature_bigalloc(inode_sb(inode))) {
 		EXT4_ERROR_INODE(inode, "Can't allocate blocks for "
 				 "non-extent mapped inodes with bigalloc");
 		return -EFSCORRUPTED;
@@ -656,7 +657,7 @@ int ext4_ind_map_blocks(handle_t *handle, struct inode *inode,
 int ext4_ind_calc_metadata_amount(struct inode *inode, sector_t lblock)
 {
 	struct ext4_inode_info *ei = EXT4_I(inode);
-	sector_t dind_mask = ~((sector_t)EXT4_ADDR_PER_BLOCK(inode->i_sb) - 1);
+	sector_t dind_mask = ~((sector_t)EXT4_ADDR_PER_BLOCK(inode_sb(inode)) - 1);
 	int blk_bits;
 
 	if (lblock < EXT4_NDIR_BLOCKS)
@@ -672,7 +673,7 @@ int ext4_ind_calc_metadata_amount(struct inode *inode, sector_t lblock)
 	ei->i_da_metadata_calc_last_lblock = lblock & dind_mask;
 	ei->i_da_metadata_calc_len = 1;
 	blk_bits = order_base_2(lblock);
-	return (blk_bits / EXT4_ADDR_PER_BLOCK_BITS(inode->i_sb)) + 1;
+	return (blk_bits / EXT4_ADDR_PER_BLOCK_BITS(inode_sb(inode))) + 1;
 }
 
 /*
@@ -683,10 +684,10 @@ int ext4_ind_trans_blocks(struct inode *inode, int nrblocks)
 {
 	/*
 	 * With N contiguous data blocks, we need at most
-	 * N/EXT4_ADDR_PER_BLOCK(inode->i_sb) + 1 indirect blocks,
+	 * N/EXT4_ADDR_PER_BLOCK(inode_sb(inode)) + 1 indirect blocks,
 	 * 2 dindirect blocks, and 1 tindirect block
 	 */
-	return DIV_ROUND_UP(nrblocks, EXT4_ADDR_PER_BLOCK(inode->i_sb)) + 4;
+	return DIV_ROUND_UP(nrblocks, EXT4_ADDR_PER_BLOCK(inode_sb(inode))) + 4;
 }
 
 /*
@@ -836,7 +837,7 @@ static int ext4_clear_blocks(handle_t *handle, struct inode *inode,
 	else if (ext4_should_journal_data(inode))
 		flags |= EXT4_FREE_BLOCKS_FORGET;
 
-	if (!ext4_data_block_valid(EXT4_SB(inode->i_sb), block_to_free,
+	if (!ext4_data_block_valid(EXT4_SB(inode_sb(inode)), block_to_free,
 				   count)) {
 		EXT4_ERROR_INODE(inode, "attempt to clear invalid "
 				 "blocks %llu len %lu",
@@ -872,7 +873,7 @@ static int ext4_clear_blocks(handle_t *handle, struct inode *inode,
 	ext4_free_blocks(handle, inode, NULL, block_to_free, count, flags);
 	return 0;
 out_err:
-	ext4_std_error(inode->i_sb, err);
+	ext4_std_error(inode_sb(inode), err);
 	return err;
 }
 
@@ -992,14 +993,14 @@ static void ext4_free_branches(handle_t *handle, struct inode *inode,
 
 	if (depth--) {
 		struct buffer_head *bh;
-		int addr_per_block = EXT4_ADDR_PER_BLOCK(inode->i_sb);
+		int addr_per_block = EXT4_ADDR_PER_BLOCK(inode_sb(inode));
 		p = last;
 		while (--p >= first) {
 			nr = le32_to_cpu(*p);
 			if (!nr)
 				continue;		/* A hole */
 
-			if (!ext4_data_block_valid(EXT4_SB(inode->i_sb),
+			if (!ext4_data_block_valid(EXT4_SB(inode_sb(inode)),
 						   nr, 1)) {
 				EXT4_ERROR_INODE(inode,
 						 "invalid indirect mapped "
@@ -1009,7 +1010,7 @@ static void ext4_free_branches(handle_t *handle, struct inode *inode,
 			}
 
 			/* Go read the buffer for the next level down */
-			bh = sb_bread(inode->i_sb, nr);
+			bh = sb_bread(inode_sb(inode), nr);
 
 			/*
 			 * A read failure? Report error and clear slot
@@ -1096,19 +1097,19 @@ void ext4_ind_truncate(handle_t *handle, struct inode *inode)
 {
 	struct ext4_inode_info *ei = EXT4_I(inode);
 	__le32 *i_data = ei->i_data;
-	int addr_per_block = EXT4_ADDR_PER_BLOCK(inode->i_sb);
+	int addr_per_block = EXT4_ADDR_PER_BLOCK(inode_sb(inode));
 	ext4_lblk_t offsets[4];
 	Indirect chain[4];
 	Indirect *partial;
 	__le32 nr = 0;
 	int n = 0;
 	ext4_lblk_t last_block, max_block;
-	unsigned blocksize = inode->i_sb->s_blocksize;
+	unsigned blocksize = inode_sb(inode)->s_blocksize;
 
 	last_block = (inode->i_size + blocksize-1)
-					>> EXT4_BLOCK_SIZE_BITS(inode->i_sb);
-	max_block = (EXT4_SB(inode->i_sb)->s_bitmap_maxbytes + blocksize-1)
-					>> EXT4_BLOCK_SIZE_BITS(inode->i_sb);
+					>> EXT4_BLOCK_SIZE_BITS(inode_sb(inode));
+	max_block = (EXT4_SB(inode_sb(inode))->s_bitmap_maxbytes + blocksize-1)
+					>> EXT4_BLOCK_SIZE_BITS(inode_sb(inode));
 
 	if (last_block != max_block) {
 		n = ext4_block_to_path(inode, last_block, offsets, NULL);
@@ -1209,17 +1210,17 @@ int ext4_ind_remove_space(handle_t *handle, struct inode *inode,
 {
 	struct ext4_inode_info *ei = EXT4_I(inode);
 	__le32 *i_data = ei->i_data;
-	int addr_per_block = EXT4_ADDR_PER_BLOCK(inode->i_sb);
+	int addr_per_block = EXT4_ADDR_PER_BLOCK(inode_sb(inode));
 	ext4_lblk_t offsets[4], offsets2[4];
 	Indirect chain[4], chain2[4];
 	Indirect *partial, *partial2;
 	ext4_lblk_t max_block;
 	__le32 nr = 0, nr2 = 0;
 	int n = 0, n2 = 0;
-	unsigned blocksize = inode->i_sb->s_blocksize;
+	unsigned blocksize = inode_sb(inode)->s_blocksize;
 
-	max_block = (EXT4_SB(inode->i_sb)->s_bitmap_maxbytes + blocksize-1)
-					>> EXT4_BLOCK_SIZE_BITS(inode->i_sb);
+	max_block = (EXT4_SB(inode_sb(inode))->s_bitmap_maxbytes + blocksize-1)
+					>> EXT4_BLOCK_SIZE_BITS(inode_sb(inode));
 	if (end >= max_block)
 		end = max_block;
 	if ((start >= end) || (start > max_block))
diff --git a/fs/ext4/inline.c b/fs/ext4/inline.c
index 70cf4c7b268a..efd245dccae1 100644
--- a/fs/ext4/inline.c
+++ b/fs/ext4/inline.c
@@ -34,7 +34,7 @@ static int get_max_inline_xattr_value_size(struct inode *inode,
 	struct ext4_inode *raw_inode;
 	int free, min_offs;
 
-	min_offs = EXT4_SB(inode->i_sb)->s_inode_size -
+	min_offs = EXT4_SB(inode_sb(inode))->s_inode_size -
 			EXT4_GOOD_OLD_INODE_SIZE -
 			EXT4_I(inode)->i_extra_isize -
 			sizeof(struct ext4_xattr_ibody_header);
@@ -209,7 +209,7 @@ static void ext4_write_inline_data(struct inode *inode, struct ext4_iloc *iloc,
 	struct ext4_inode *raw_inode;
 	int cp_len = 0;
 
-	if (unlikely(ext4_forced_shutdown(EXT4_SB(inode->i_sb))))
+	if (unlikely(ext4_forced_shutdown(EXT4_SB(inode_sb(inode)))))
 		return;
 
 	BUG_ON(!EXT4_I(inode)->i_inline_off);
@@ -432,7 +432,7 @@ static int ext4_destroy_inline_data_nolock(handle_t *handle,
 	memset((void *)ext4_raw_inode(&is.iloc)->i_block,
 		0, EXT4_MIN_INLINE_DATA_SIZE);
 
-	if (ext4_has_feature_extents(inode->i_sb)) {
+	if (ext4_has_feature_extents(inode_sb(inode))) {
 		if (S_ISDIR(inode->i_mode) ||
 		    S_ISREG(inode->i_mode) || S_ISLNK(inode->i_mode)) {
 			ext4_set_inode_flag(inode, EXT4_INODE_EXTENTS);
@@ -466,7 +466,8 @@ static int ext4_read_inline_page(struct inode *inode, struct page *page)
 	BUG_ON(page->index);
 
 	if (!EXT4_I(inode)->i_inline_off) {
-		ext4_warning(inode->i_sb, "inode %lu doesn't have inline data.",
+		ext4_warning(inode_sb(inode),
+			     "inode %lu doesn't have inline data.",
 			     inode->i_ino);
 		goto out;
 	}
@@ -611,7 +612,7 @@ static int ext4_convert_inline_data_to_extent(struct address_space *mapping,
 			ext4_orphan_del(NULL, inode);
 	}
 
-	if (ret == -ENOSPC && ext4_should_retry_alloc(inode->i_sb, &retries))
+	if (ret == -ENOSPC && ext4_should_retry_alloc(inode_sb(inode), &retries))
 		goto retry;
 
 	if (page)
@@ -728,7 +729,7 @@ int ext4_write_inline_data_end(struct inode *inode, loff_t pos, unsigned len,
 
 	ret = ext4_get_inode_loc(inode, &iloc);
 	if (ret) {
-		ext4_std_error(inode->i_sb, ret);
+		ext4_std_error(inode_sb(inode), ret);
 		copied = 0;
 		goto out;
 	}
@@ -760,7 +761,7 @@ ext4_journalled_write_inline_data(struct inode *inode,
 
 	ret = ext4_get_inode_loc(inode, &iloc);
 	if (ret) {
-		ext4_std_error(inode->i_sb, ret);
+		ext4_std_error(inode_sb(inode), ret);
 		return NULL;
 	}
 
@@ -886,7 +887,7 @@ int ext4_da_write_inline_data_begin(struct address_space *mapping,
 							    fsdata);
 		ext4_journal_stop(handle);
 		if (ret == -ENOSPC &&
-		    ext4_should_retry_alloc(inode->i_sb, &retries))
+		    ext4_should_retry_alloc(inode_sb(inode), &retries))
 			goto retry_journal;
 		goto out;
 	}
@@ -1128,27 +1129,27 @@ static int ext4_finish_convert_inline_dir(handle_t *handle,
 	 */
 	de = (struct ext4_dir_entry_2 *)target;
 	de = ext4_init_dot_dotdot(inode, de,
-		inode->i_sb->s_blocksize, csum_size,
+		inode_sb(inode)->s_blocksize, csum_size,
 		le32_to_cpu(((struct ext4_dir_entry_2 *)buf)->inode), 1);
 	header_size = (void *)de - target;
 
 	memcpy((void *)de, buf + EXT4_INLINE_DOTDOT_SIZE,
 		inline_size - EXT4_INLINE_DOTDOT_SIZE);
 
-	if (ext4_has_metadata_csum(inode->i_sb))
+	if (ext4_has_metadata_csum(inode_sb(inode)))
 		csum_size = sizeof(struct ext4_dir_entry_tail);
 
-	inode->i_size = inode->i_sb->s_blocksize;
-	i_size_write(inode, inode->i_sb->s_blocksize);
-	EXT4_I(inode)->i_disksize = inode->i_sb->s_blocksize;
+	inode->i_size = inode_sb(inode)->s_blocksize;
+	i_size_write(inode, inode_sb(inode)->s_blocksize);
+	EXT4_I(inode)->i_disksize = inode_sb(inode)->s_blocksize;
 	ext4_update_final_de(dir_block->b_data,
 			inline_size - EXT4_INLINE_DOTDOT_SIZE + header_size,
-			inode->i_sb->s_blocksize - csum_size);
+			inode_sb(inode)->s_blocksize - csum_size);
 
 	if (csum_size) {
 		t = EXT4_DIRENT_TAIL(dir_block->b_data,
-				     inode->i_sb->s_blocksize);
-		initialize_dirent_tail(t, inode->i_sb->s_blocksize);
+				     inode_sb(inode)->s_blocksize);
+		initialize_dirent_tail(t, inode_sb(inode)->s_blocksize);
 	}
 	set_buffer_uptodate(dir_block);
 	err = ext4_handle_dirty_dirent_node(handle, inode, dir_block);
@@ -1206,7 +1207,7 @@ static int ext4_convert_inline_data_nolock(handle_t *handle,
 		goto out_restore;
 	}
 
-	data_bh = sb_getblk(inode->i_sb, map.m_pblk);
+	data_bh = sb_getblk(inode_sb(inode), map.m_pblk);
 	if (!data_bh) {
 		error = -ENOMEM;
 		goto out_restore;
@@ -1219,7 +1220,7 @@ static int ext4_convert_inline_data_nolock(handle_t *handle,
 		error = -EIO;
 		goto out_restore;
 	}
-	memset(data_bh->b_data, 0, inode->i_sb->s_blocksize);
+	memset(data_bh->b_data, 0, inode_sb(inode)->s_blocksize);
 
 	if (!S_ISDIR(inode->i_mode)) {
 		memcpy(data_bh->b_data, buf, inline_size);
@@ -1370,7 +1371,7 @@ int htree_inlinedir_to_tree(struct file *dir_file,
 			fake.rec_len = ext4_rec_len_to_disk(
 						EXT4_DIR_REC_LEN(fake.name_len),
 						inline_size);
-			ext4_set_de_type(inode->i_sb, &fake, S_IFDIR);
+			ext4_set_de_type(inode_sb(inode), &fake, S_IFDIR);
 			de = &fake;
 			pos = EXT4_INLINE_DOTDOT_OFFSET;
 		} else if (pos == EXT4_INLINE_DOTDOT_OFFSET) {
@@ -1380,7 +1381,7 @@ int htree_inlinedir_to_tree(struct file *dir_file,
 			fake.rec_len = ext4_rec_len_to_disk(
 						EXT4_DIR_REC_LEN(fake.name_len),
 						inline_size);
-			ext4_set_de_type(inode->i_sb, &fake, S_IFDIR);
+			ext4_set_de_type(inode_sb(inode), &fake, S_IFDIR);
 			de = &fake;
 			pos = EXT4_INLINE_DOTDOT_SIZE;
 		} else {
@@ -1465,7 +1466,7 @@ int ext4_read_inline_dir(struct file *file,
 		goto out;
 
 	ret = 0;
-	sb = inode->i_sb;
+	sb = inode_sb(inode);
 	parent_ino = le32_to_cpu(((struct ext4_dir_entry_2 *)dir_buf)->inode);
 	offset = ctx->pos;
 
@@ -1706,7 +1707,7 @@ int ext4_delete_inline_entry(handle_t *handle,
 		err = ext4_mark_inode_dirty(handle, dir);
 	brelse(iloc.bh);
 	if (err != -ENOENT)
-		ext4_std_error(dir->i_sb, err);
+		ext4_std_error(inode_sb(dir), err);
 	return err;
 }
 
@@ -1763,7 +1764,7 @@ bool empty_inline_dir(struct inode *dir, int *has_inline_data)
 
 	de = (struct ext4_dir_entry_2 *)ext4_raw_inode(&iloc)->i_block;
 	if (!le32_to_cpu(de->inode)) {
-		ext4_warning(dir->i_sb,
+		ext4_warning(inode_sb(dir),
 			     "bad inline directory (dir #%lu) - no `..'",
 			     dir->i_ino);
 		ret = true;
@@ -1777,7 +1778,7 @@ bool empty_inline_dir(struct inode *dir, int *has_inline_data)
 		if (ext4_check_dir_entry(dir, NULL, de,
 					 iloc.bh, inline_pos,
 					 inline_size, offset)) {
-			ext4_warning(dir->i_sb,
+			ext4_warning(inode_sb(dir),
 				     "bad inline directory (dir #%lu) - "
 				     "inode %u, rec_len %u, name_len %d"
 				     "inline size %d",
@@ -1825,7 +1826,7 @@ int ext4_inline_data_iomap(struct inode *inode, struct iomap *iomap)
 	if (error)
 		goto out;
 
-	addr = (__u64)iloc.bh->b_blocknr << inode->i_sb->s_blocksize_bits;
+	addr = (__u64)iloc.bh->b_blocknr << inode_sb(inode)->s_blocksize_bits;
 	addr += (char *)ext4_raw_inode(&iloc) - iloc.bh->b_data;
 	addr += offsetof(struct ext4_inode, i_block);
 
@@ -1871,7 +1872,7 @@ int ext4_inline_data_fiemap(struct inode *inode,
 	if (error)
 		goto out;
 
-	physical = (__u64)iloc.bh->b_blocknr << inode->i_sb->s_blocksize_bits;
+	physical = (__u64)iloc.bh->b_blocknr << inode_sb(inode)->s_blocksize_bits;
 	physical += (char *)ext4_raw_inode(&iloc) - iloc.bh->b_data;
 	physical += offsetof(struct ext4_inode, i_block);
 
diff --git a/fs/ext4/inode.c b/fs/ext4/inode.c
index c94780075b04..89e91fec7cc9 100644
--- a/fs/ext4/inode.c
+++ b/fs/ext4/inode.c
@@ -53,7 +53,7 @@
 static __u32 ext4_inode_csum(struct inode *inode, struct ext4_inode *raw,
 			      struct ext4_inode_info *ei)
 {
-	struct ext4_sb_info *sbi = EXT4_SB(inode->i_sb);
+	struct ext4_sb_info *sbi = EXT4_SB(inode_sb(inode));
 	__u32 csum;
 	__u16 dummy_csum = 0;
 	int offset = offsetof(struct ext4_inode, i_checksum_lo);
@@ -65,7 +65,7 @@ static __u32 ext4_inode_csum(struct inode *inode, struct ext4_inode *raw,
 	csum = ext4_chksum(sbi, csum, (__u8 *)raw + offset,
 			   EXT4_GOOD_OLD_INODE_SIZE - offset);
 
-	if (EXT4_INODE_SIZE(inode->i_sb) > EXT4_GOOD_OLD_INODE_SIZE) {
+	if (EXT4_INODE_SIZE(inode_sb(inode)) > EXT4_GOOD_OLD_INODE_SIZE) {
 		offset = offsetof(struct ext4_inode, i_checksum_hi);
 		csum = ext4_chksum(sbi, csum, (__u8 *)raw +
 				   EXT4_GOOD_OLD_INODE_SIZE,
@@ -76,7 +76,7 @@ static __u32 ext4_inode_csum(struct inode *inode, struct ext4_inode *raw,
 			offset += csum_size;
 		}
 		csum = ext4_chksum(sbi, csum, (__u8 *)raw + offset,
-				   EXT4_INODE_SIZE(inode->i_sb) - offset);
+				   EXT4_INODE_SIZE(inode_sb(inode)) - offset);
 	}
 
 	return csum;
@@ -87,14 +87,14 @@ static int ext4_inode_csum_verify(struct inode *inode, struct ext4_inode *raw,
 {
 	__u32 provided, calculated;
 
-	if (EXT4_SB(inode->i_sb)->s_es->s_creator_os !=
+	if (EXT4_SB(inode_sb(inode))->s_es->s_creator_os !=
 	    cpu_to_le32(EXT4_OS_LINUX) ||
-	    !ext4_has_metadata_csum(inode->i_sb))
+	    !ext4_has_metadata_csum(inode_sb(inode)))
 		return 1;
 
 	provided = le16_to_cpu(raw->i_checksum_lo);
 	calculated = ext4_inode_csum(inode, raw, ei);
-	if (EXT4_INODE_SIZE(inode->i_sb) > EXT4_GOOD_OLD_INODE_SIZE &&
+	if (EXT4_INODE_SIZE(inode_sb(inode)) > EXT4_GOOD_OLD_INODE_SIZE &&
 	    EXT4_FITS_IN_INODE(raw, ei, i_checksum_hi))
 		provided |= ((__u32)le16_to_cpu(raw->i_checksum_hi)) << 16;
 	else
@@ -108,14 +108,14 @@ static void ext4_inode_csum_set(struct inode *inode, struct ext4_inode *raw,
 {
 	__u32 csum;
 
-	if (EXT4_SB(inode->i_sb)->s_es->s_creator_os !=
+	if (EXT4_SB(inode_sb(inode))->s_es->s_creator_os !=
 	    cpu_to_le32(EXT4_OS_LINUX) ||
-	    !ext4_has_metadata_csum(inode->i_sb))
+	    !ext4_has_metadata_csum(inode_sb(inode)))
 		return;
 
 	csum = ext4_inode_csum(inode, raw, ei);
 	raw->i_checksum_lo = cpu_to_le16(csum & 0xFFFF);
-	if (EXT4_INODE_SIZE(inode->i_sb) > EXT4_GOOD_OLD_INODE_SIZE &&
+	if (EXT4_INODE_SIZE(inode_sb(inode)) > EXT4_GOOD_OLD_INODE_SIZE &&
 	    EXT4_FITS_IN_INODE(raw, ei, i_checksum_hi))
 		raw->i_checksum_hi = cpu_to_le16(csum >> 16);
 }
@@ -152,7 +152,7 @@ int ext4_inode_is_fast_symlink(struct inode *inode)
 {
 	if (!(EXT4_I(inode)->i_flags & EXT4_EA_INODE_FL)) {
 		int ea_blocks = EXT4_I(inode)->i_file_acl ?
-				EXT4_CLUSTER_SIZE(inode->i_sb) >> 9 : 0;
+				EXT4_CLUSTER_SIZE(inode_sb(inode)) >> 9 : 0;
 
 		if (ext4_has_inline_data(inode))
 			return 0;
@@ -224,7 +224,7 @@ void ext4_evict_inode(struct inode *inode)
 		    ext4_should_journal_data(inode) &&
 		    (S_ISLNK(inode->i_mode) || S_ISREG(inode->i_mode)) &&
 		    inode->i_data.nrpages) {
-			journal_t *journal = EXT4_SB(inode->i_sb)->s_journal;
+			journal_t *journal = EXT4_SB(inode_sb(inode))->s_journal;
 			tid_t commit_tid = EXT4_I(inode)->i_datasync_tid;
 
 			jbd2_complete_transaction(journal, commit_tid);
@@ -247,22 +247,22 @@ void ext4_evict_inode(struct inode *inode)
 	 * Protect us against freezing - iput() caller didn't have to have any
 	 * protection against it
 	 */
-	sb_start_intwrite(inode->i_sb);
+	sb_start_intwrite(inode_sb(inode));
 
 	if (!IS_NOQUOTA(inode))
-		extra_credits += EXT4_MAXQUOTAS_DEL_BLOCKS(inode->i_sb);
+		extra_credits += EXT4_MAXQUOTAS_DEL_BLOCKS(inode_sb(inode));
 
 	handle = ext4_journal_start(inode, EXT4_HT_TRUNCATE,
 				 ext4_blocks_for_truncate(inode)+extra_credits);
 	if (IS_ERR(handle)) {
-		ext4_std_error(inode->i_sb, PTR_ERR(handle));
+		ext4_std_error(inode_sb(inode), PTR_ERR(handle));
 		/*
 		 * If we're going to skip the normal cleanup, we still need to
 		 * make sure that the in-core orphan linked list is properly
 		 * cleaned up.
 		 */
 		ext4_orphan_del(NULL, inode);
-		sb_end_intwrite(inode->i_sb);
+		sb_end_intwrite(inode_sb(inode));
 		goto no_delete;
 	}
 
@@ -281,14 +281,14 @@ void ext4_evict_inode(struct inode *inode)
 	inode->i_size = 0;
 	err = ext4_mark_inode_dirty(handle, inode);
 	if (err) {
-		ext4_warning(inode->i_sb,
+		ext4_warning(inode_sb(inode),
 			     "couldn't mark inode dirty (err %d)", err);
 		goto stop_handle;
 	}
 	if (inode->i_blocks) {
 		err = ext4_truncate(inode);
 		if (err) {
-			ext4_error(inode->i_sb,
+			ext4_error(inode_sb(inode),
 				   "couldn't truncate inode %lu (err %d)",
 				   inode->i_ino, err);
 			goto stop_handle;
@@ -299,11 +299,11 @@ void ext4_evict_inode(struct inode *inode)
 	err = ext4_xattr_delete_inode(handle, inode, &ea_inode_array,
 				      extra_credits);
 	if (err) {
-		ext4_warning(inode->i_sb, "xattr delete (err %d)", err);
+		ext4_warning(inode_sb(inode), "xattr delete (err %d)", err);
 stop_handle:
 		ext4_journal_stop(handle);
 		ext4_orphan_del(NULL, inode);
-		sb_end_intwrite(inode->i_sb);
+		sb_end_intwrite(inode_sb(inode));
 		ext4_xattr_inode_array_free(ea_inode_array);
 		goto no_delete;
 	}
@@ -332,7 +332,7 @@ void ext4_evict_inode(struct inode *inode)
 	else
 		ext4_free_inode(handle, inode);
 	ext4_journal_stop(handle);
-	sb_end_intwrite(inode->i_sb);
+	sb_end_intwrite(inode_sb(inode));
 	ext4_xattr_inode_array_free(ea_inode_array);
 	return;
 no_delete:
@@ -353,16 +353,16 @@ qsize_t *ext4_get_reserved_space(struct inode *inode)
 void ext4_da_update_reserve_space(struct inode *inode,
 					int used, int quota_claim)
 {
-	struct ext4_sb_info *sbi = EXT4_SB(inode->i_sb);
+	struct ext4_sb_info *sbi = EXT4_SB(inode_sb(inode));
 	struct ext4_inode_info *ei = EXT4_I(inode);
 
 	spin_lock(&ei->i_block_reservation_lock);
 	trace_ext4_da_update_reserve_space(inode, used, quota_claim);
 	if (unlikely(used > ei->i_reserved_data_blocks)) {
-		ext4_warning(inode->i_sb, "%s: ino %lu, used %d "
-			 "with only %d reserved data blocks",
-			 __func__, inode->i_ino, used,
-			 ei->i_reserved_data_blocks);
+		ext4_warning(inode_sb(inode), "%s: ino %lu, used %d "
+		             "with only %d reserved data blocks",
+		             __func__, inode->i_ino, used,
+		             ei->i_reserved_data_blocks);
 		WARN_ON(1);
 		used = ei->i_reserved_data_blocks;
 	}
@@ -399,7 +399,7 @@ static int __check_block_validity(struct inode *inode, const char *func,
 				unsigned int line,
 				struct ext4_map_blocks *map)
 {
-	if (!ext4_data_block_valid(EXT4_SB(inode->i_sb), map->m_pblk,
+	if (!ext4_data_block_valid(EXT4_SB(inode_sb(inode)), map->m_pblk,
 				   map->m_len)) {
 		ext4_error_inode(inode, func, line, map->m_pblk,
 				 "lblock %lu mapped to illegal pblock "
@@ -418,7 +418,7 @@ int ext4_issue_zeroout(struct inode *inode, ext4_lblk_t lblk, ext4_fsblk_t pblk,
 	if (ext4_encrypted_inode(inode))
 		return fscrypt_zeroout_range(inode, lblk, pblk, len);
 
-	ret = sb_issue_zeroout(inode->i_sb, pblk, len, GFP_NOFS);
+	ret = sb_issue_zeroout(inode_sb(inode), pblk, len, GFP_NOFS);
 	if (ret > 0)
 		ret = 0;
 
@@ -566,7 +566,7 @@ int ext4_map_blocks(handle_t *handle, struct inode *inode,
 		unsigned int status;
 
 		if (unlikely(retval != map->m_len)) {
-			ext4_warning(inode->i_sb,
+			ext4_warning(inode_sb(inode),
 				     "ES len assertion failed for inode "
 				     "%lu: retval %d != map->m_len %d",
 				     inode->i_ino, retval, map->m_len);
@@ -661,7 +661,7 @@ int ext4_map_blocks(handle_t *handle, struct inode *inode,
 		unsigned int status;
 
 		if (unlikely(retval != map->m_len)) {
-			ext4_warning(inode->i_sb,
+			ext4_warning(inode_sb(inode),
 				     "ES len assertion failed for inode "
 				     "%lu: retval %d != map->m_len %d",
 				     inode->i_ino, retval, map->m_len);
@@ -678,7 +678,8 @@ int ext4_map_blocks(handle_t *handle, struct inode *inode,
 		if (flags & EXT4_GET_BLOCKS_ZERO &&
 		    map->m_flags & EXT4_MAP_MAPPED &&
 		    map->m_flags & EXT4_MAP_NEW) {
-			clean_bdev_aliases(inode->i_sb->s_bdev, map->m_pblk,
+			clean_bdev_aliases(inode_sb(inode)->s_bdev,
+					   map->m_pblk,
 					   map->m_len);
 			ret = ext4_issue_zeroout(inode, map->m_lblk,
 						 map->m_pblk, map->m_len);
@@ -783,13 +784,13 @@ static int _ext4_get_block(struct inode *inode, sector_t iblock,
 	ret = ext4_map_blocks(ext4_journal_current_handle(), inode, &map,
 			      flags);
 	if (ret > 0) {
-		map_bh(bh, inode->i_sb, map.m_pblk);
+		map_bh(bh, inode_sb(inode), map.m_pblk);
 		ext4_update_bh_state(bh, map.m_flags);
-		bh->b_size = inode->i_sb->s_blocksize * map.m_len;
+		bh->b_size = inode_sb(inode)->s_blocksize * map.m_len;
 		ret = 0;
 	} else if (ret == 0) {
 		/* hole case, need to fill in bh->b_size */
-		bh->b_size = inode->i_sb->s_blocksize * map.m_len;
+		bh->b_size = inode_sb(inode)->s_blocksize * map.m_len;
 	}
 	return ret;
 }
@@ -844,7 +845,7 @@ static int ext4_get_block_trans(struct inode *inode, sector_t iblock,
 	ret = _ext4_get_block(inode, iblock, bh_result, flags);
 	ext4_journal_stop(handle);
 
-	if (ret == -ENOSPC && ext4_should_retry_alloc(inode->i_sb, &retries))
+	if (ret == -ENOSPC && ext4_should_retry_alloc(inode_sb(inode), &retries))
 		goto retry;
 	return ret;
 }
@@ -970,7 +971,7 @@ struct buffer_head *ext4_getblk(handle_t *handle, struct inode *inode,
 	if (err < 0)
 		return ERR_PTR(err);
 
-	bh = sb_getblk(inode->i_sb, map.m_pblk);
+	bh = sb_getblk(inode_sb(inode), map.m_pblk);
 	if (unlikely(!bh))
 		return ERR_PTR(-ENOMEM);
 	if (map.m_flags & EXT4_MAP_NEW) {
@@ -992,7 +993,7 @@ struct buffer_head *ext4_getblk(handle_t *handle, struct inode *inode,
 			goto errout;
 		}
 		if (!buffer_uptodate(bh)) {
-			memset(bh->b_data, 0, inode->i_sb->s_blocksize);
+			memset(bh->b_data, 0, inode_sb(inode)->s_blocksize);
 			set_buffer_uptodate(bh);
 		}
 		unlock_buffer(bh);
@@ -1160,7 +1161,7 @@ static int ext4_block_write_begin(struct page *page, loff_t pos, unsigned len,
 	unsigned block_start, block_end;
 	sector_t block;
 	int err = 0;
-	unsigned blocksize = inode->i_sb->s_blocksize;
+	unsigned blocksize = inode_sb(inode)->s_blocksize;
 	unsigned bbits;
 	struct buffer_head *bh, *head, *wait[2], **wait_bh = wait;
 	bool decrypt = false;
@@ -1250,7 +1251,7 @@ static int ext4_write_begin(struct file *file, struct address_space *mapping,
 	pgoff_t index;
 	unsigned from, to;
 
-	if (unlikely(ext4_forced_shutdown(EXT4_SB(inode->i_sb))))
+	if (unlikely(ext4_forced_shutdown(EXT4_SB(inode_sb(inode)))))
 		return -EIO;
 
 	trace_ext4_write_begin(inode, pos, len, flags);
@@ -1350,7 +1351,7 @@ static int ext4_write_begin(struct file *file, struct address_space *mapping,
 		}
 
 		if (ret == -ENOSPC &&
-		    ext4_should_retry_alloc(inode->i_sb, &retries))
+		    ext4_should_retry_alloc(inode_sb(inode), &retries))
 			goto retry_journal;
 		put_page(page);
 		return ret;
@@ -1567,7 +1568,7 @@ static int ext4_journalled_write_end(struct file *file,
  */
 static int ext4_da_reserve_space(struct inode *inode)
 {
-	struct ext4_sb_info *sbi = EXT4_SB(inode->i_sb);
+	struct ext4_sb_info *sbi = EXT4_SB(inode_sb(inode));
 	struct ext4_inode_info *ei = EXT4_I(inode);
 	int ret;
 
@@ -1595,7 +1596,7 @@ static int ext4_da_reserve_space(struct inode *inode)
 
 static void ext4_da_release_space(struct inode *inode, int to_free)
 {
-	struct ext4_sb_info *sbi = EXT4_SB(inode->i_sb);
+	struct ext4_sb_info *sbi = EXT4_SB(inode_sb(inode));
 	struct ext4_inode_info *ei = EXT4_I(inode);
 
 	if (!to_free)
@@ -1611,10 +1612,10 @@ static void ext4_da_release_space(struct inode *inode, int to_free)
 		 * function is called from invalidate page, it's
 		 * harmless to return without any action.
 		 */
-		ext4_warning(inode->i_sb, "ext4_da_release_space: "
-			 "ino %lu, to_free %d with only %d reserved "
-			 "data blocks", inode->i_ino, to_free,
-			 ei->i_reserved_data_blocks);
+		ext4_warning(inode_sb(inode), "ext4_da_release_space: "
+			     "ino %lu, to_free %d with only %d reserved "
+			     "data blocks", inode->i_ino, to_free,
+			     ei->i_reserved_data_blocks);
 		WARN_ON(1);
 		to_free = ei->i_reserved_data_blocks;
 	}
@@ -1636,7 +1637,7 @@ static void ext4_da_page_release_reservation(struct page *page,
 	struct buffer_head *head, *bh;
 	unsigned int curr_off = 0;
 	struct inode *inode = page->mapping->host;
-	struct ext4_sb_info *sbi = EXT4_SB(inode->i_sb);
+	struct ext4_sb_info *sbi = EXT4_SB(inode_sb(inode));
 	unsigned int stop = offset + length;
 	int num_clusters;
 	ext4_fsblk_t lblk;
@@ -1753,12 +1754,12 @@ static void mpage_release_unused_pages(struct mpage_da_data *mpd,
 
 static void ext4_print_free_blocks(struct inode *inode)
 {
-	struct ext4_sb_info *sbi = EXT4_SB(inode->i_sb);
-	struct super_block *sb = inode->i_sb;
+	struct ext4_sb_info *sbi = EXT4_SB(inode_sb(inode));
+	struct super_block *sb = inode_sb(inode);
 	struct ext4_inode_info *ei = EXT4_I(inode);
 
 	ext4_msg(sb, KERN_CRIT, "Total free blocks count %lld",
-	       EXT4_C2B(EXT4_SB(inode->i_sb),
+	       EXT4_C2B(EXT4_SB(inode_sb(inode)),
 			ext4_count_free_clusters(sb)));
 	ext4_msg(sb, KERN_CRIT, "Free/Dirty block details");
 	ext4_msg(sb, KERN_CRIT, "free_blocks=%lld",
@@ -1797,7 +1798,7 @@ static int ext4_da_map_blocks(struct inode *inode, sector_t iblock,
 	memcpy(&orig_map, map, sizeof(*map));
 #endif
 
-	if (invalid_block < ext4_blocks_count(EXT4_SB(inode->i_sb)->s_es))
+	if (invalid_block < ext4_blocks_count(EXT4_SB(inode_sb(inode))->s_es))
 		invalid_block = ~0;
 
 	map->m_flags = 0;
@@ -1818,7 +1819,7 @@ static int ext4_da_map_blocks(struct inode *inode, sector_t iblock,
 		 * So we need to check it.
 		 */
 		if (ext4_es_is_delayed(&es) && !ext4_es_is_unwritten(&es)) {
-			map_bh(bh, inode->i_sb, invalid_block);
+			map_bh(bh, inode_sb(inode), invalid_block);
 			set_buffer_new(bh);
 			set_buffer_delay(bh);
 			return 0;
@@ -1866,7 +1867,7 @@ static int ext4_da_map_blocks(struct inode *inode, sector_t iblock,
 		 * then we don't need to reserve it again. However we still need
 		 * to reserve metadata for every block we're going to write.
 		 */
-		if (EXT4_SB(inode->i_sb)->s_cluster_ratio == 1 ||
+		if (EXT4_SB(inode_sb(inode))->s_cluster_ratio == 1 ||
 		    !ext4_find_delalloc_cluster(inode, map->m_lblk)) {
 			ret = ext4_da_reserve_space(inode);
 			if (ret) {
@@ -1883,7 +1884,7 @@ static int ext4_da_map_blocks(struct inode *inode, sector_t iblock,
 			goto out_unlock;
 		}
 
-		map_bh(bh, inode->i_sb, invalid_block);
+		map_bh(bh, inode_sb(inode), invalid_block);
 		set_buffer_new(bh);
 		set_buffer_delay(bh);
 	} else if (retval > 0) {
@@ -1891,7 +1892,7 @@ static int ext4_da_map_blocks(struct inode *inode, sector_t iblock,
 		unsigned int status;
 
 		if (unlikely(retval != map->m_len)) {
-			ext4_warning(inode->i_sb,
+			ext4_warning(inode_sb(inode),
 				     "ES len assertion failed for inode "
 				     "%lu: retval %d != map->m_len %d",
 				     inode->i_ino, retval, map->m_len);
@@ -1931,7 +1932,7 @@ int ext4_da_get_block_prep(struct inode *inode, sector_t iblock,
 	int ret = 0;
 
 	BUG_ON(create == 0);
-	BUG_ON(bh->b_size != inode->i_sb->s_blocksize);
+	BUG_ON(bh->b_size != inode_sb(inode)->s_blocksize);
 
 	map.m_lblk = iblock;
 	map.m_len = 1;
@@ -1945,7 +1946,7 @@ int ext4_da_get_block_prep(struct inode *inode, sector_t iblock,
 	if (ret <= 0)
 		return ret;
 
-	map_bh(bh, inode->i_sb, map.m_pblk);
+	map_bh(bh, inode_sb(inode), map.m_pblk);
 	ext4_update_bh_state(bh, map.m_flags);
 
 	if (buffer_unwritten(bh)) {
@@ -2110,7 +2111,7 @@ static int ext4_writepage(struct page *page,
 	struct ext4_io_submit io_submit;
 	bool keep_towrite = false;
 
-	if (unlikely(ext4_forced_shutdown(EXT4_SB(inode->i_sb)))) {
+	if (unlikely(ext4_forced_shutdown(EXT4_SB(inode_sb(inode))))) {
 		ext4_invalidatepage(page, 0, PAGE_SIZE);
 		unlock_page(page);
 		return -EIO;
@@ -2145,7 +2146,7 @@ static int ext4_writepage(struct page *page,
 				   ext4_bh_delay_or_unwritten)) {
 		redirty_page_for_writepage(wbc, page);
 		if ((current->flags & PF_MEMALLOC) ||
-		    (inode->i_sb->s_blocksize == PAGE_SIZE)) {
+		    (inode_sb(inode)->s_blocksize == PAGE_SIZE)) {
 			/*
 			 * For memory cleaning there's no point in writing only
 			 * some buffers. So just bail out. Warn if we came here
@@ -2463,7 +2464,7 @@ static int mpage_map_one_extent(handle_t *handle, struct mpage_da_data *mpd)
 
 	BUG_ON(map->m_len == 0);
 	if (map->m_flags & EXT4_MAP_NEW) {
-		clean_bdev_aliases(inode->i_sb->s_bdev, map->m_pblk,
+		clean_bdev_aliases(inode_sb(inode)->s_bdev, map->m_pblk,
 				   map->m_len);
 	}
 	return 0;
@@ -2504,7 +2505,7 @@ static int mpage_map_and_submit_extent(handle_t *handle,
 	do {
 		err = mpage_map_one_extent(handle, mpd);
 		if (err < 0) {
-			struct super_block *sb = inode->i_sb;
+			struct super_block *sb = inode_sb(inode);
 
 			if (ext4_forced_shutdown(EXT4_SB(sb)) ||
 			    EXT4_SB(sb)->s_mount_flags & EXT4_MF_FS_ABORTED)
@@ -2565,7 +2566,7 @@ static int mpage_map_and_submit_extent(handle_t *handle,
 		up_write(&EXT4_I(inode)->i_data_sem);
 		err2 = ext4_mark_inode_dirty(handle, inode);
 		if (err2)
-			ext4_error(inode->i_sb,
+			ext4_error(inode_sb(inode),
 				   "Failed to mark inode %lu dirty",
 				   inode->i_ino);
 		if (!err)
@@ -2714,19 +2715,20 @@ static int ext4_writepages(struct address_space *mapping,
 	struct mpage_da_data mpd;
 	struct inode *inode = mapping->host;
 	int needed_blocks, rsv_blocks = 0, ret = 0;
-	struct ext4_sb_info *sbi = EXT4_SB(mapping->host->i_sb);
+	struct ext4_sb_info *sbi = EXT4_SB(inode_sb(mapping->host));
 	bool done;
 	struct blk_plug plug;
 	bool give_up_on_write = false;
 
-	if (unlikely(ext4_forced_shutdown(EXT4_SB(inode->i_sb))))
+	if (unlikely(ext4_forced_shutdown(EXT4_SB(inode_sb(inode)))))
 		return -EIO;
 
 	percpu_down_read(&sbi->s_journal_flag_rwsem);
 	trace_ext4_writepages(inode, wbc);
 
 	if (dax_mapping(mapping)) {
-		ret = dax_writeback_mapping_range(mapping, inode->i_sb->s_bdev,
+		ret = dax_writeback_mapping_range(mapping,
+						  inode_sb(inode)->s_bdev,
 						  wbc);
 		goto out_writepages;
 	}
@@ -2758,7 +2760,7 @@ static int ext4_writepages(struct address_space *mapping,
 	 * *never* be called, so if that ever happens, we would want
 	 * the stack trace.
 	 */
-	if (unlikely(ext4_forced_shutdown(EXT4_SB(mapping->host->i_sb)) ||
+	if (unlikely(ext4_forced_shutdown(EXT4_SB(inode_sb(mapping->host))) ||
 		     sbi->s_mount_flags & EXT4_MF_FS_ABORTED)) {
 		ret = -EROFS;
 		goto out_writepages;
@@ -2858,9 +2860,10 @@ static int ext4_writepages(struct address_space *mapping,
 				EXT4_HT_WRITE_PAGE, needed_blocks, rsv_blocks);
 		if (IS_ERR(handle)) {
 			ret = PTR_ERR(handle);
-			ext4_msg(inode->i_sb, KERN_CRIT, "%s: jbd2_start: "
-			       "%ld pages, ino %lu; err %d", __func__,
-				wbc->nr_to_write, inode->i_ino, ret);
+			ext4_msg(inode_sb(inode), KERN_CRIT,
+				 "%s: jbd2_start: "
+				 "%ld pages, ino %lu; err %d", __func__,
+				 wbc->nr_to_write, inode->i_ino, ret);
 			/* Release allocated io_end */
 			ext4_put_io_end(mpd.io_submit.io_end);
 			mpd.io_submit.io_end = NULL;
@@ -2992,7 +2995,7 @@ static int ext4_nonda_switch(struct super_block *sb)
 /* We always reserve for an inode update; the superblock could be there too */
 static int ext4_da_write_credits(struct inode *inode, loff_t pos, unsigned len)
 {
-	if (likely(ext4_has_feature_large_file(inode->i_sb)))
+	if (likely(ext4_has_feature_large_file(inode_sb(inode))))
 		return 1;
 
 	if (pos + len <= 0x7fffffffULL)
@@ -3012,12 +3015,12 @@ static int ext4_da_write_begin(struct file *file, struct address_space *mapping,
 	struct inode *inode = mapping->host;
 	handle_t *handle;
 
-	if (unlikely(ext4_forced_shutdown(EXT4_SB(inode->i_sb))))
+	if (unlikely(ext4_forced_shutdown(EXT4_SB(inode_sb(inode)))))
 		return -EIO;
 
 	index = pos >> PAGE_SHIFT;
 
-	if (ext4_nonda_switch(inode->i_sb) ||
+	if (ext4_nonda_switch(inode_sb(inode)) ||
 	    S_ISLNK(inode->i_mode)) {
 		*fsdata = (void *)FALL_BACK_TO_NONDELALLOC;
 		return ext4_write_begin(file, mapping, pos,
@@ -3092,7 +3095,7 @@ static int ext4_da_write_begin(struct file *file, struct address_space *mapping,
 			ext4_truncate_failed_write(inode);
 
 		if (ret == -ENOSPC &&
-		    ext4_should_retry_alloc(inode->i_sb, &retries))
+		    ext4_should_retry_alloc(inode_sb(inode), &retries))
 			goto retry_journal;
 
 		put_page(page);
@@ -3272,7 +3275,7 @@ static sector_t ext4_bmap(struct address_space *mapping, sector_t block)
 		return 0;
 
 	if (mapping_tagged(mapping, PAGECACHE_TAG_DIRTY) &&
-			test_opt(inode->i_sb, DELALLOC)) {
+			test_opt(inode_sb(inode), DELALLOC)) {
 		/*
 		 * With delalloc we want to sync the file
 		 * so that we can make sure we allocate
@@ -3396,7 +3399,7 @@ static int ext4_releasepage(struct page *page, gfp_t wait)
 
 static bool ext4_inode_datasync_dirty(struct inode *inode)
 {
-	journal_t *journal = EXT4_SB(inode->i_sb)->s_journal;
+	journal_t *journal = EXT4_SB(inode_sb(inode))->s_journal;
 
 	if (journal)
 		return !jbd2_transaction_committed(journal,
@@ -3410,7 +3413,7 @@ static bool ext4_inode_datasync_dirty(struct inode *inode)
 static int ext4_iomap_begin(struct inode *inode, loff_t offset, loff_t length,
 			    unsigned flags, struct iomap *iomap)
 {
-	struct ext4_sb_info *sbi = EXT4_SB(inode->i_sb);
+	struct ext4_sb_info *sbi = EXT4_SB(inode_sb(inode));
 	unsigned int blkbits = inode->i_blkbits;
 	unsigned long first_block = offset >> blkbits;
 	unsigned long last_block = (offset + length - 1) >> blkbits;
@@ -3488,7 +3491,7 @@ static int ext4_iomap_begin(struct inode *inode, loff_t offset, loff_t length,
 		if (ret < 0) {
 			ext4_journal_stop(handle);
 			if (ret == -ENOSPC &&
-			    ext4_should_retry_alloc(inode->i_sb, &retries))
+			    ext4_should_retry_alloc(inode_sb(inode), &retries))
 				goto retry;
 			return ret;
 		}
@@ -3522,7 +3525,7 @@ static int ext4_iomap_begin(struct inode *inode, loff_t offset, loff_t length,
 	iomap->flags = 0;
 	if (ext4_inode_datasync_dirty(inode))
 		iomap->flags |= IOMAP_F_DIRTY;
-	iomap->bdev = inode->i_sb->s_bdev;
+	iomap->bdev = inode_sb(inode)->s_bdev;
 	iomap->dax_dev = sbi->s_daxdev;
 	iomap->offset = first_block << blkbits;
 	iomap->length = (u64)map.m_len << blkbits;
@@ -3735,7 +3738,7 @@ static ssize_t ext4_direct_IO_write(struct kiocb *iocb, struct iov_iter *iter)
 		get_block_func = ext4_dio_get_block_unwritten_async;
 		dio_flags = DIO_LOCKING;
 	}
-	ret = __blockdev_direct_IO(iocb, inode, inode->i_sb->s_bdev, iter,
+	ret = __blockdev_direct_IO(iocb, inode, inode_sb(inode)->s_bdev, iter,
 				   get_block_func, ext4_end_io_dio, NULL,
 				   dio_flags);
 
@@ -3827,7 +3830,7 @@ static ssize_t ext4_direct_IO_read(struct kiocb *iocb, struct iov_iter *iter)
 					   iocb->ki_pos + count - 1);
 	if (ret)
 		goto out_unlock;
-	ret = __blockdev_direct_IO(iocb, inode, inode->i_sb->s_bdev,
+	ret = __blockdev_direct_IO(iocb, inode, inode_sb(inode)->s_bdev,
 				   iter, ext4_dio_get_block, NULL, NULL, 0);
 out_unlock:
 	inode_unlock_shared(inode);
@@ -3958,7 +3961,7 @@ void ext4_set_aops(struct inode *inode)
 	default:
 		BUG();
 	}
-	if (test_opt(inode->i_sb, DELALLOC))
+	if (test_opt(inode_sb(inode), DELALLOC))
 		inode->i_mapping->a_ops = &ext4_da_aops;
 	else
 		inode->i_mapping->a_ops = &ext4_aops;
@@ -3981,9 +3984,9 @@ static int __ext4_block_zero_page_range(handle_t *handle,
 	if (!page)
 		return -ENOMEM;
 
-	blocksize = inode->i_sb->s_blocksize;
+	blocksize = inode_sb(inode)->s_blocksize;
 
-	iblock = index << (PAGE_SHIFT - inode->i_sb->s_blocksize_bits);
+	iblock = index << (PAGE_SHIFT - inode_sb(inode)->s_blocksize_bits);
 
 	if (!page_has_buffers(page))
 		create_empty_buffers(page, blocksize, 0);
@@ -4066,7 +4069,7 @@ static int ext4_block_zero_page_range(handle_t *handle,
 {
 	struct inode *inode = mapping->host;
 	unsigned offset = from & (PAGE_SIZE-1);
-	unsigned blocksize = inode->i_sb->s_blocksize;
+	unsigned blocksize = inode_sb(inode)->s_blocksize;
 	unsigned max = blocksize - (offset & (blocksize - 1));
 
 	/*
@@ -4101,7 +4104,7 @@ static int ext4_block_truncate_page(handle_t *handle,
 	if (ext4_encrypted_inode(inode) && !fscrypt_has_encryption_key(inode))
 		return 0;
 
-	blocksize = inode->i_sb->s_blocksize;
+	blocksize = inode_sb(inode)->s_blocksize;
 	length = blocksize - (offset & (blocksize - 1));
 
 	return ext4_block_zero_page_range(handle, mapping, from, length);
@@ -4110,7 +4113,7 @@ static int ext4_block_truncate_page(handle_t *handle,
 int ext4_zero_partial_blocks(handle_t *handle, struct inode *inode,
 			     loff_t lstart, loff_t length)
 {
-	struct super_block *sb = inode->i_sb;
+	struct super_block *sb = inode_sb(inode);
 	struct address_space *mapping = inode->i_mapping;
 	unsigned partial_start, partial_end;
 	ext4_fsblk_t start, end;
@@ -4198,7 +4201,7 @@ int ext4_update_disksize_before_punch(struct inode *inode, loff_t offset,
 
 int ext4_punch_hole(struct inode *inode, loff_t offset, loff_t length)
 {
-	struct super_block *sb = inode->i_sb;
+	struct super_block *sb = inode_sb(inode);
 	ext4_lblk_t first_block, stop_block;
 	struct address_space *mapping = inode->i_mapping;
 	loff_t first_block_offset, last_block_offset;
@@ -4335,7 +4338,7 @@ int ext4_inode_attach_jinode(struct inode *inode)
 	struct ext4_inode_info *ei = EXT4_I(inode);
 	struct jbd2_inode *jinode;
 
-	if (ei->jinode || !EXT4_SB(inode->i_sb)->s_journal)
+	if (ei->jinode || !EXT4_SB(inode_sb(inode))->s_journal)
 		return 0;
 
 	jinode = jbd2_alloc_inode(GFP_KERNEL);
@@ -4405,7 +4408,7 @@ int ext4_truncate(struct inode *inode)
 
 	ext4_clear_inode_flag(inode, EXT4_INODE_EOFBLOCKS);
 
-	if (inode->i_size == 0 && !test_opt(inode->i_sb, NO_AUTO_DA_ALLOC))
+	if (inode->i_size == 0 && !test_opt(inode_sb(inode), NO_AUTO_DA_ALLOC))
 		ext4_set_inode_state(inode, EXT4_STATE_DA_ALLOC_CLOSE);
 
 	if (ext4_has_inline_data(inode)) {
@@ -4419,7 +4422,7 @@ int ext4_truncate(struct inode *inode)
 	}
 
 	/* If we zero-out tail of the page, we have to create jinode for jbd2 */
-	if (inode->i_size & (inode->i_sb->s_blocksize - 1)) {
+	if (inode->i_size & (inode_sb(inode)->s_blocksize - 1)) {
 		if (ext4_inode_attach_jinode(inode) < 0)
 			return 0;
 	}
@@ -4433,7 +4436,7 @@ int ext4_truncate(struct inode *inode)
 	if (IS_ERR(handle))
 		return PTR_ERR(handle);
 
-	if (inode->i_size & (inode->i_sb->s_blocksize - 1))
+	if (inode->i_size & (inode_sb(inode)->s_blocksize - 1))
 		ext4_block_truncate_page(handle, mapping, inode->i_size);
 
 	/*
@@ -4495,7 +4498,7 @@ static int __ext4_get_inode_loc(struct inode *inode,
 {
 	struct ext4_group_desc	*gdp;
 	struct buffer_head	*bh;
-	struct super_block	*sb = inode->i_sb;
+	struct super_block	*sb = inode_sb(inode);
 	ext4_fsblk_t		block;
 	int			inodes_per_block, inode_offset;
 
@@ -4636,7 +4639,7 @@ int ext4_get_inode_loc(struct inode *inode, struct ext4_iloc *iloc)
 
 static bool ext4_should_use_dax(struct inode *inode)
 {
-	if (!test_opt(inode->i_sb, DAX))
+	if (!test_opt(inode_sb(inode), DAX))
 		return false;
 	if (!S_ISREG(inode->i_mode))
 		return false;
@@ -4678,7 +4681,7 @@ static blkcnt_t ext4_inode_blocks(struct ext4_inode *raw_inode,
 {
 	blkcnt_t i_blocks ;
 	struct inode *inode = &(ei->vfs_inode);
-	struct super_block *sb = inode->i_sb;
+	struct super_block *sb = inode_sb(inode);
 
 	if (ext4_has_feature_huge_file(sb)) {
 		/* we are using combined 48 bit field */
@@ -4702,7 +4705,7 @@ static inline void ext4_iget_extra_inode(struct inode *inode,
 	__le32 *magic = (void *)raw_inode +
 			EXT4_GOOD_OLD_INODE_SIZE + ei->i_extra_isize;
 	if (EXT4_GOOD_OLD_INODE_SIZE + ei->i_extra_isize + sizeof(__le32) <=
-	    EXT4_INODE_SIZE(inode->i_sb) &&
+	    EXT4_INODE_SIZE(inode_sb(inode)) &&
 	    *magic == cpu_to_le32(EXT4_XATTR_MAGIC)) {
 		ext4_set_inode_state(inode, EXT4_STATE_XATTR);
 		ext4_find_inline_data_nolock(inode);
@@ -4712,7 +4715,7 @@ static inline void ext4_iget_extra_inode(struct inode *inode,
 
 int ext4_get_projid(struct inode *inode, kprojid_t *projid)
 {
-	if (!ext4_has_feature_project(inode->i_sb))
+	if (!ext4_has_feature_project(inode_sb(inode)))
 		return -EOPNOTSUPP;
 	*projid = EXT4_I(inode)->i_projid;
 	return 0;
@@ -4746,15 +4749,15 @@ struct inode *ext4_iget(struct super_block *sb, unsigned long ino)
 		goto bad_inode;
 	raw_inode = ext4_raw_inode(&iloc);
 
-	if (EXT4_INODE_SIZE(inode->i_sb) > EXT4_GOOD_OLD_INODE_SIZE) {
+	if (EXT4_INODE_SIZE(inode_sb(inode)) > EXT4_GOOD_OLD_INODE_SIZE) {
 		ei->i_extra_isize = le16_to_cpu(raw_inode->i_extra_isize);
 		if (EXT4_GOOD_OLD_INODE_SIZE + ei->i_extra_isize >
-			EXT4_INODE_SIZE(inode->i_sb) ||
-		    (ei->i_extra_isize & 3)) {
+			EXT4_INODE_SIZE(inode_sb(inode)) ||
+			(ei->i_extra_isize & 3)) {
 			EXT4_ERROR_INODE(inode,
 					 "bad extra_isize %u (inode size %u)",
 					 ei->i_extra_isize,
-					 EXT4_INODE_SIZE(inode->i_sb));
+					 EXT4_INODE_SIZE(inode_sb(inode)));
 			ret = -EFSCORRUPTED;
 			goto bad_inode;
 		}
@@ -4763,7 +4766,7 @@ struct inode *ext4_iget(struct super_block *sb, unsigned long ino)
 
 	/* Precompute checksum seed for inode metadata */
 	if (ext4_has_metadata_csum(sb)) {
-		struct ext4_sb_info *sbi = EXT4_SB(inode->i_sb);
+		struct ext4_sb_info *sbi = EXT4_SB(inode_sb(inode));
 		__u32 csum;
 		__le32 inum = cpu_to_le32(inode->i_ino);
 		__le32 gen = raw_inode->i_generation;
@@ -4789,7 +4792,7 @@ struct inode *ext4_iget(struct super_block *sb, unsigned long ino)
 	else
 		i_projid = EXT4_DEF_PROJID;
 
-	if (!(test_opt(inode->i_sb, NO_UID32))) {
+	if (!(test_opt(inode_sb(inode), NO_UID32))) {
 		i_uid |= le16_to_cpu(raw_inode->i_uid_high) << 16;
 		i_gid |= le16_to_cpu(raw_inode->i_gid_high) << 16;
 	}
@@ -4809,7 +4812,7 @@ struct inode *ext4_iget(struct super_block *sb, unsigned long ino)
 	 */
 	if (inode->i_nlink == 0) {
 		if ((inode->i_mode == 0 ||
-		     !(EXT4_SB(inode->i_sb)->s_mount_state & EXT4_ORPHAN_FS)) &&
+		     !(EXT4_SB(inode_sb(inode))->s_mount_state & EXT4_ORPHAN_FS)) &&
 		    ino != EXT4_BOOT_LOADER_INO) {
 			/* this inode is deleted */
 			ret = -ESTALE;
@@ -4874,7 +4877,7 @@ struct inode *ext4_iget(struct super_block *sb, unsigned long ino)
 		ei->i_datasync_tid = tid;
 	}
 
-	if (EXT4_INODE_SIZE(inode->i_sb) > EXT4_GOOD_OLD_INODE_SIZE) {
+	if (EXT4_INODE_SIZE(inode_sb(inode)) > EXT4_GOOD_OLD_INODE_SIZE) {
 		if (ei->i_extra_isize == 0) {
 			/* The extra space is currently unused. Use it. */
 			BUILD_BUG_ON(sizeof(struct ext4_inode) & 3);
@@ -4890,10 +4893,10 @@ struct inode *ext4_iget(struct super_block *sb, unsigned long ino)
 	EXT4_INODE_GET_XTIME(i_atime, inode, raw_inode);
 	EXT4_EINODE_GET_XTIME(i_crtime, ei, raw_inode);
 
-	if (likely(!test_opt2(inode->i_sb, HURD_COMPAT))) {
+	if (likely(!test_opt2(inode_sb(inode), HURD_COMPAT))) {
 		u64 ivers = le32_to_cpu(raw_inode->i_disk_version);
 
-		if (EXT4_INODE_SIZE(inode->i_sb) > EXT4_GOOD_OLD_INODE_SIZE) {
+		if (EXT4_INODE_SIZE(inode_sb(inode)) > EXT4_GOOD_OLD_INODE_SIZE) {
 			if (EXT4_FITS_IN_INODE(raw_inode, ei, i_version_hi))
 				ivers |=
 		    (__u64)(le32_to_cpu(raw_inode->i_version_hi)) << 32;
@@ -4987,7 +4990,7 @@ static int ext4_inode_blocks_set(handle_t *handle,
 {
 	struct inode *inode = &(ei->vfs_inode);
 	u64 i_blocks = inode->i_blocks;
-	struct super_block *sb = inode->i_sb;
+	struct super_block *sb = inode_sb(inode);
 
 	if (i_blocks <= ~0U) {
 		/*
@@ -5098,7 +5101,7 @@ static int ext4_do_update_inode(handle_t *handle,
 	struct ext4_inode *raw_inode = ext4_raw_inode(iloc);
 	struct ext4_inode_info *ei = EXT4_I(inode);
 	struct buffer_head *bh = iloc->bh;
-	struct super_block *sb = inode->i_sb;
+	struct super_block *sb = inode_sb(inode);
 	int err = 0, rc, block;
 	int need_datasync = 0, set_large_file = 0;
 	uid_t i_uid;
@@ -5110,13 +5113,13 @@ static int ext4_do_update_inode(handle_t *handle,
 	/* For fields not tracked in the in-memory inode,
 	 * initialise them to zero for new inodes. */
 	if (ext4_test_inode_state(inode, EXT4_STATE_NEW))
-		memset(raw_inode, 0, EXT4_SB(inode->i_sb)->s_inode_size);
+		memset(raw_inode, 0, EXT4_SB(inode_sb(inode))->s_inode_size);
 
 	raw_inode->i_mode = cpu_to_le16(inode->i_mode);
 	i_uid = i_uid_read(inode);
 	i_gid = i_gid_read(inode);
 	i_projid = from_kprojid(&init_user_ns, ei->i_projid);
-	if (!(test_opt(inode->i_sb, NO_UID32))) {
+	if (!(test_opt(inode_sb(inode), NO_UID32))) {
 		raw_inode->i_uid_low = cpu_to_le16(low_16_bits(i_uid));
 		raw_inode->i_gid_low = cpu_to_le16(low_16_bits(i_gid));
 /*
@@ -5152,11 +5155,11 @@ static int ext4_do_update_inode(handle_t *handle,
 	}
 	raw_inode->i_dtime = cpu_to_le32(ei->i_dtime);
 	raw_inode->i_flags = cpu_to_le32(ei->i_flags & 0xFFFFFFFF);
-	if (likely(!test_opt2(inode->i_sb, HURD_COMPAT)))
+	if (likely(!test_opt2(inode_sb(inode), HURD_COMPAT)))
 		raw_inode->i_file_acl_high =
 			cpu_to_le16(ei->i_file_acl >> 32);
 	raw_inode->i_file_acl_lo = cpu_to_le32(ei->i_file_acl);
-	if (ei->i_disksize != ext4_isize(inode->i_sb, raw_inode)) {
+	if (ei->i_disksize != ext4_isize(inode_sb(inode), raw_inode)) {
 		ext4_isize_set(raw_inode, ei->i_disksize);
 		need_datasync = 1;
 	}
@@ -5183,7 +5186,7 @@ static int ext4_do_update_inode(handle_t *handle,
 			raw_inode->i_block[block] = ei->i_data[block];
 	}
 
-	if (likely(!test_opt2(inode->i_sb, HURD_COMPAT))) {
+	if (likely(!test_opt2(inode_sb(inode), HURD_COMPAT))) {
 		u64 ivers = inode_peek_iversion(inode);
 
 		raw_inode->i_disk_version = cpu_to_le32(ivers);
@@ -5196,17 +5199,17 @@ static int ext4_do_update_inode(handle_t *handle,
 		}
 	}
 
-	BUG_ON(!ext4_has_feature_project(inode->i_sb) &&
+	BUG_ON(!ext4_has_feature_project(inode_sb(inode)) &&
 	       i_projid != EXT4_DEF_PROJID);
 
-	if (EXT4_INODE_SIZE(inode->i_sb) > EXT4_GOOD_OLD_INODE_SIZE &&
+	if (EXT4_INODE_SIZE(inode_sb(inode)) > EXT4_GOOD_OLD_INODE_SIZE &&
 	    EXT4_FITS_IN_INODE(raw_inode, ei, i_projid))
 		raw_inode->i_projid = cpu_to_le32(i_projid);
 
 	ext4_inode_csum_set(inode, raw_inode, ei);
 	spin_unlock(&ei->i_raw_lock);
-	if (inode->i_sb->s_flags & SB_LAZYTIME)
-		ext4_update_other_inodes_time(inode->i_sb, inode->i_ino,
+	if (inode_sb(inode)->s_flags & SB_LAZYTIME)
+		ext4_update_other_inodes_time(inode_sb(inode), inode->i_ino,
 					      bh->b_data);
 
 	BUFFER_TRACE(bh, "call ext4_handle_dirty_metadata");
@@ -5227,7 +5230,7 @@ static int ext4_do_update_inode(handle_t *handle,
 	ext4_update_inode_fsync_trans(handle, inode, need_datasync);
 out_brelse:
 	brelse(bh);
-	ext4_std_error(inode->i_sb, err);
+	ext4_std_error(inode_sb(inode), err);
 	return err;
 }
 
@@ -5272,7 +5275,7 @@ int ext4_write_inode(struct inode *inode, struct writeback_control *wbc)
 	if (WARN_ON_ONCE(current->flags & PF_MEMALLOC))
 		return 0;
 
-	if (EXT4_SB(inode->i_sb)->s_journal) {
+	if (EXT4_SB(inode_sb(inode))->s_journal) {
 		if (ext4_journal_current_handle()) {
 			jbd_debug(1, "called recursively, non-PF_MEMALLOC!\n");
 			dump_stack();
@@ -5287,7 +5290,7 @@ int ext4_write_inode(struct inode *inode, struct writeback_control *wbc)
 		if (wbc->sync_mode != WB_SYNC_ALL || wbc->for_sync)
 			return 0;
 
-		err = ext4_force_commit(inode->i_sb);
+		err = ext4_force_commit(inode_sb(inode));
 	} else {
 		struct ext4_iloc iloc;
 
@@ -5319,7 +5322,7 @@ static void ext4_wait_for_tail_page_commit(struct inode *inode)
 {
 	struct page *page;
 	unsigned offset;
-	journal_t *journal = EXT4_SB(inode->i_sb)->s_journal;
+	journal_t *journal = EXT4_SB(inode_sb(inode))->s_journal;
 	tid_t commit_tid = 0;
 	int ret;
 
@@ -5383,7 +5386,7 @@ int ext4_setattr(struct dentry *dentry, struct iattr *attr)
 	int orphan = 0;
 	const unsigned int ia_valid = attr->ia_valid;
 
-	if (unlikely(ext4_forced_shutdown(EXT4_SB(inode->i_sb))))
+	if (unlikely(ext4_forced_shutdown(EXT4_SB(inode_sb(inode)))))
 		return -EIO;
 
 	error = setattr_prepare(dentry, attr);
@@ -5406,8 +5409,8 @@ int ext4_setattr(struct dentry *dentry, struct iattr *attr)
 		/* (user+group)*(old+new) structure, inode write (sb,
 		 * inode block, ? - but truncate inode update has it) */
 		handle = ext4_journal_start(inode, EXT4_HT_QUOTA,
-			(EXT4_MAXQUOTAS_INIT_BLOCKS(inode->i_sb) +
-			 EXT4_MAXQUOTAS_DEL_BLOCKS(inode->i_sb)) + 3);
+			(EXT4_MAXQUOTAS_INIT_BLOCKS(inode_sb(inode)) +
+			 EXT4_MAXQUOTAS_DEL_BLOCKS(inode_sb(inode))) + 3);
 		if (IS_ERR(handle)) {
 			error = PTR_ERR(handle);
 			goto err_out;
@@ -5440,7 +5443,7 @@ int ext4_setattr(struct dentry *dentry, struct iattr *attr)
 		int shrink = (attr->ia_size <= inode->i_size);
 
 		if (!(ext4_test_inode_flag(inode, EXT4_INODE_EXTENTS))) {
-			struct ext4_sb_info *sbi = EXT4_SB(inode->i_sb);
+			struct ext4_sb_info *sbi = EXT4_SB(inode_sb(inode));
 
 			if (attr->ia_size > sbi->s_bitmap_maxbytes)
 				return -EFBIG;
@@ -5542,7 +5545,7 @@ int ext4_setattr(struct dentry *dentry, struct iattr *attr)
 		rc = posix_acl_chmod(inode, inode->i_mode);
 
 err_out:
-	ext4_std_error(inode->i_sb, error);
+	ext4_std_error(inode_sb(inode), error);
 	if (!error)
 		error = rc;
 	return error;
@@ -5611,9 +5614,9 @@ int ext4_file_getattr(const struct path *path, struct kstat *stat,
 	 * will return the blocks that include the delayed allocation
 	 * blocks for this file.
 	 */
-	delalloc_blocks = EXT4_C2B(EXT4_SB(inode->i_sb),
+	delalloc_blocks = EXT4_C2B(EXT4_SB(inode_sb(inode)),
 				   EXT4_I(inode)->i_reserved_data_blocks);
-	stat->blocks += delalloc_blocks << (inode->i_sb->s_blocksize_bits - 9);
+	stat->blocks += delalloc_blocks << (inode_sb(inode)->s_blocksize_bits - 9);
 	return 0;
 }
 
@@ -5639,7 +5642,7 @@ static int ext4_index_trans_blocks(struct inode *inode, int lblocks,
 static int ext4_meta_trans_blocks(struct inode *inode, int lblocks,
 				  int pextents)
 {
-	ext4_group_t groups, ngroups = ext4_get_groups_count(inode->i_sb);
+	ext4_group_t groups, ngroups = ext4_get_groups_count(inode_sb(inode));
 	int gdpblocks;
 	int idxblocks;
 	int ret = 0;
@@ -5660,14 +5663,14 @@ static int ext4_meta_trans_blocks(struct inode *inode, int lblocks,
 	gdpblocks = groups;
 	if (groups > ngroups)
 		groups = ngroups;
-	if (groups > EXT4_SB(inode->i_sb)->s_gdb_count)
-		gdpblocks = EXT4_SB(inode->i_sb)->s_gdb_count;
+	if (groups > EXT4_SB(inode_sb(inode))->s_gdb_count)
+		gdpblocks = EXT4_SB(inode_sb(inode))->s_gdb_count;
 
 	/* bitmaps and block group descriptor blocks */
 	ret += groups + gdpblocks;
 
 	/* Blocks for super block, inode, quota and xattr blocks */
-	ret += EXT4_META_TRANS_BLOCKS(inode->i_sb);
+	ret += EXT4_META_TRANS_BLOCKS(inode_sb(inode));
 
 	return ret;
 }
@@ -5718,7 +5721,7 @@ int ext4_mark_iloc_dirty(handle_t *handle,
 {
 	int err = 0;
 
-	if (unlikely(ext4_forced_shutdown(EXT4_SB(inode->i_sb))))
+	if (unlikely(ext4_forced_shutdown(EXT4_SB(inode_sb(inode)))))
 		return -EIO;
 
 	if (IS_I_VERSION(inode))
@@ -5744,7 +5747,7 @@ ext4_reserve_inode_write(handle_t *handle, struct inode *inode,
 {
 	int err;
 
-	if (unlikely(ext4_forced_shutdown(EXT4_SB(inode->i_sb))))
+	if (unlikely(ext4_forced_shutdown(EXT4_SB(inode_sb(inode)))))
 		return -EIO;
 
 	err = ext4_get_inode_loc(inode, iloc);
@@ -5756,7 +5759,7 @@ ext4_reserve_inode_write(handle_t *handle, struct inode *inode,
 			iloc->bh = NULL;
 		}
 	}
-	ext4_std_error(inode->i_sb, err);
+	ext4_std_error(inode_sb(inode), err);
 	return err;
 }
 
@@ -5822,7 +5825,7 @@ static int ext4_try_to_expand_extra_isize(struct inode *inode,
 	 */
 	if (ext4_handle_valid(handle) &&
 	    jbd2_journal_extend(handle,
-				EXT4_DATA_TRANS_BLOCKS(inode->i_sb)) != 0)
+				EXT4_DATA_TRANS_BLOCKS(inode_sb(inode))) != 0)
 		return -ENOSPC;
 
 	if (ext4_write_trylock_xattr(inode, &no_expand) == 0)
@@ -5849,7 +5852,7 @@ int ext4_expand_extra_isize(struct inode *inode,
 	}
 
 	handle = ext4_journal_start(inode, EXT4_HT_INODE,
-				    EXT4_DATA_TRANS_BLOCKS(inode->i_sb));
+				    EXT4_DATA_TRANS_BLOCKS(inode_sb(inode)));
 	if (IS_ERR(handle)) {
 		error = PTR_ERR(handle);
 		brelse(iloc->bh);
@@ -5894,7 +5897,7 @@ int ext4_expand_extra_isize(struct inode *inode,
 int ext4_mark_inode_dirty(handle_t *handle, struct inode *inode)
 {
 	struct ext4_iloc iloc;
-	struct ext4_sb_info *sbi = EXT4_SB(inode->i_sb);
+	struct ext4_sb_info *sbi = EXT4_SB(inode_sb(inode));
 	int err;
 
 	might_sleep();
@@ -5970,7 +5973,7 @@ static int ext4_pin_inode(handle_t *handle, struct inode *inode)
 			brelse(iloc.bh);
 		}
 	}
-	ext4_std_error(inode->i_sb, err);
+	ext4_std_error(inode_sb(inode), err);
 	return err;
 }
 #endif
@@ -5980,7 +5983,7 @@ int ext4_change_inode_journal_flag(struct inode *inode, int val)
 	journal_t *journal;
 	handle_t *handle;
 	int err;
-	struct ext4_sb_info *sbi = EXT4_SB(inode->i_sb);
+	struct ext4_sb_info *sbi = EXT4_SB(inode_sb(inode));
 
 	/*
 	 * We have to be very careful here: changing a data block's
@@ -6061,7 +6064,7 @@ int ext4_change_inode_journal_flag(struct inode *inode, int val)
 	err = ext4_mark_inode_dirty(handle, inode);
 	ext4_handle_sync(handle);
 	ext4_journal_stop(handle);
-	ext4_std_error(inode->i_sb, err);
+	ext4_std_error(inode_sb(inode), err);
 
 	return err;
 }
@@ -6085,7 +6088,7 @@ int ext4_page_mkwrite(struct vm_fault *vmf)
 	get_block_t *get_block;
 	int retries = 0;
 
-	sb_start_pagefault(inode->i_sb);
+	sb_start_pagefault(inode_sb(inode));
 	file_update_time(vma->vm_file);
 
 	down_read(&EXT4_I(inode)->i_mmap_sem);
@@ -6095,14 +6098,14 @@ int ext4_page_mkwrite(struct vm_fault *vmf)
 		goto out_ret;
 
 	/* Delalloc case is easy... */
-	if (test_opt(inode->i_sb, DELALLOC) &&
+	if (test_opt(inode_sb(inode), DELALLOC) &&
 	    !ext4_should_journal_data(inode) &&
-	    !ext4_nonda_switch(inode->i_sb)) {
+	    !ext4_nonda_switch(inode_sb(inode))) {
 		do {
 			ret = block_page_mkwrite(vma, vmf,
 						   ext4_da_get_block_prep);
 		} while (ret == -ENOSPC &&
-		       ext4_should_retry_alloc(inode->i_sb, &retries));
+		       ext4_should_retry_alloc(inode_sb(inode), &retries));
 		goto out_ret;
 	}
 
@@ -6158,13 +6161,13 @@ int ext4_page_mkwrite(struct vm_fault *vmf)
 		ext4_set_inode_state(inode, EXT4_STATE_JDATA);
 	}
 	ext4_journal_stop(handle);
-	if (ret == -ENOSPC && ext4_should_retry_alloc(inode->i_sb, &retries))
+	if (ret == -ENOSPC && ext4_should_retry_alloc(inode_sb(inode), &retries))
 		goto retry_alloc;
 out_ret:
 	ret = block_page_mkwrite_return(ret);
 out:
 	up_read(&EXT4_I(inode)->i_mmap_sem);
-	sb_end_pagefault(inode->i_sb);
+	sb_end_pagefault(inode_sb(inode));
 	return ret;
 }
 
diff --git a/fs/ext4/ioctl.c b/fs/ext4/ioctl.c
index 7e99ad02f1ba..d8a9930f0ff6 100644
--- a/fs/ext4/ioctl.c
+++ b/fs/ext4/ioctl.c
@@ -166,17 +166,17 @@ static long swap_inode_boot_loader(struct super_block *sb,
 
 	err = ext4_mark_inode_dirty(handle, inode);
 	if (err < 0) {
-		ext4_warning(inode->i_sb,
-			"couldn't mark inode #%lu dirty (err %d)",
-			inode->i_ino, err);
+		ext4_warning(inode_sb(inode),
+			     "couldn't mark inode #%lu dirty (err %d)",
+			     inode->i_ino, err);
 		/* Revert all changes: */
 		swap_inode_data(inode, inode_bl);
 	} else {
 		err = ext4_mark_inode_dirty(handle, inode_bl);
 		if (err < 0) {
-			ext4_warning(inode_bl->i_sb,
-				"couldn't mark inode #%lu dirty (err %d)",
-				inode_bl->i_ino, err);
+			ext4_warning(inode_sb(inode_bl),
+				     "couldn't mark inode #%lu dirty (err %d)",
+				     inode_bl->i_ino, err);
 			/* Revert all changes: */
 			swap_inode_data(inode, inode_bl);
 			ext4_mark_inode_dirty(handle, inode);
@@ -295,7 +295,7 @@ static int ext4_ioctl_setflags(struct inode *inode,
 		 * Changes to the journaling mode can cause unsafe changes to
 		 * S_DAX if we are using the DAX mount option.
 		 */
-		if (test_opt(inode->i_sb, DAX)) {
+		if (test_opt(inode_sb(inode), DAX)) {
 			err = -EBUSY;
 			goto flags_out;
 		}
@@ -319,7 +319,7 @@ static int ext4_ioctl_setflags(struct inode *inode,
 static int ext4_ioctl_setproject(struct file *filp, __u32 projid)
 {
 	struct inode *inode = file_inode(filp);
-	struct super_block *sb = inode->i_sb;
+	struct super_block *sb = inode_sb(inode);
 	struct ext4_inode_info *ei = EXT4_I(inode);
 	int err, rc;
 	handle_t *handle;
@@ -596,7 +596,7 @@ static int ext4_ioc_getfsmap(struct super_block *sb,
 static long ext4_ioctl_group_add(struct file *file,
 				 struct ext4_new_group_data *input)
 {
-	struct super_block *sb = file_inode(file)->i_sb;
+	struct super_block *sb = inode_sb(file_inode(file));
 	int err, err2=0;
 
 	err = ext4_resize_begin(sb);
@@ -634,7 +634,7 @@ static long ext4_ioctl_group_add(struct file *file,
 long ext4_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
 {
 	struct inode *inode = file_inode(filp);
-	struct super_block *sb = inode->i_sb;
+	struct super_block *sb = inode_sb(inode);
 	struct ext4_inode_info *ei = EXT4_I(inode);
 	unsigned int flags;
 
@@ -690,7 +690,7 @@ long ext4_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
 		if (!inode_owner_or_capable(inode))
 			return -EPERM;
 
-		if (ext4_has_metadata_csum(inode->i_sb)) {
+		if (ext4_has_metadata_csum(inode_sb(inode))) {
 			ext4_warning(sb, "Setting inode version is not "
 				     "supported with metadata_csum enabled.");
 			return -ENOTTY;
@@ -995,7 +995,7 @@ long ext4_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
 		memset(&fa, 0, sizeof(struct fsxattr));
 		fa.fsx_xflags = ext4_iflags_to_xflags(ei->i_flags & EXT4_FL_USER_VISIBLE);
 
-		if (ext4_has_feature_project(inode->i_sb)) {
+		if (ext4_has_feature_project(inode_sb(inode))) {
 			fa.fsx_projid = (__u32)from_kprojid(&init_user_ns,
 				EXT4_I(inode)->i_projid);
 		}
diff --git a/fs/ext4/mballoc.c b/fs/ext4/mballoc.c
index 769a62708b1c..051379dc75f2 100644
--- a/fs/ext4/mballoc.c
+++ b/fs/ext4/mballoc.c
@@ -822,7 +822,7 @@ static int ext4_mb_init_cache(struct page *page, char *incore, gfp_t gfp)
 	mb_debug(1, "init page %lu\n", page->index);
 
 	inode = page->mapping->host;
-	sb = inode->i_sb;
+	sb = inode_sb(inode);
 	ngroups = ext4_get_groups_count(sb);
 	blocksize = i_blocksize(inode);
 	blocks_per_page = PAGE_SIZE / blocksize;
@@ -4006,7 +4006,7 @@ ext4_mb_discard_group_preallocations(struct super_block *sb,
 void ext4_discard_preallocations(struct inode *inode)
 {
 	struct ext4_inode_info *ei = EXT4_I(inode);
-	struct super_block *sb = inode->i_sb;
+	struct super_block *sb = inode_sb(inode);
 	struct buffer_head *bitmap_bh = NULL;
 	struct ext4_prealloc_space *pa, *tmp;
 	ext4_group_t group = 0;
@@ -4233,7 +4233,7 @@ static noinline_for_stack int
 ext4_mb_initialize_context(struct ext4_allocation_context *ac,
 				struct ext4_allocation_request *ar)
 {
-	struct super_block *sb = ar->inode->i_sb;
+	struct super_block *sb = inode_sb(ar->inode);
 	struct ext4_sb_info *sbi = EXT4_SB(sb);
 	struct ext4_super_block *es = sbi->s_es;
 	ext4_group_t group;
@@ -4490,7 +4490,7 @@ ext4_fsblk_t ext4_mb_new_blocks(handle_t *handle,
 	unsigned int reserv_clstrs = 0;
 
 	might_sleep();
-	sb = ar->inode->i_sb;
+	sb = inode_sb(ar->inode);
 	sbi = EXT4_SB(sb);
 
 	trace_ext4_request_blocks(ar);
@@ -4723,7 +4723,7 @@ void ext4_free_blocks(handle_t *handle, struct inode *inode,
 		      unsigned long count, int flags)
 {
 	struct buffer_head *bitmap_bh = NULL;
-	struct super_block *sb = inode->i_sb;
+	struct super_block *sb = inode_sb(inode);
 	struct ext4_group_desc *gdp;
 	unsigned int overflow;
 	ext4_grpblk_t bit;
@@ -4800,7 +4800,8 @@ void ext4_free_blocks(handle_t *handle, struct inode *inode,
 		for (i = 0; i < count; i++) {
 			cond_resched();
 			if (is_metadata)
-				bh = sb_find_get_block(inode->i_sb, block + i);
+				bh = sb_find_get_block(inode_sb(inode),
+						       block + i);
 			ext4_forget(handle, is_metadata, inode, bh, block + i);
 		}
 	}
diff --git a/fs/ext4/migrate.c b/fs/ext4/migrate.c
index 61a9d1927817..479e3b54d5be 100644
--- a/fs/ext4/migrate.c
+++ b/fs/ext4/migrate.c
@@ -114,9 +114,9 @@ static int update_ind_extent_range(handle_t *handle, struct inode *inode,
 	struct buffer_head *bh;
 	__le32 *i_data;
 	int i, retval = 0;
-	unsigned long max_entries = inode->i_sb->s_blocksize >> 2;
+	unsigned long max_entries = inode_sb(inode)->s_blocksize >> 2;
 
-	bh = sb_bread(inode->i_sb, pblock);
+	bh = sb_bread(inode_sb(inode), pblock);
 	if (!bh)
 		return -EIO;
 
@@ -143,9 +143,9 @@ static int update_dind_extent_range(handle_t *handle, struct inode *inode,
 	struct buffer_head *bh;
 	__le32 *i_data;
 	int i, retval = 0;
-	unsigned long max_entries = inode->i_sb->s_blocksize >> 2;
+	unsigned long max_entries = inode_sb(inode)->s_blocksize >> 2;
 
-	bh = sb_bread(inode->i_sb, pblock);
+	bh = sb_bread(inode_sb(inode), pblock);
 	if (!bh)
 		return -EIO;
 
@@ -173,9 +173,9 @@ static int update_tind_extent_range(handle_t *handle, struct inode *inode,
 	struct buffer_head *bh;
 	__le32 *i_data;
 	int i, retval = 0;
-	unsigned long max_entries = inode->i_sb->s_blocksize >> 2;
+	unsigned long max_entries = inode_sb(inode)->s_blocksize >> 2;
 
-	bh = sb_bread(inode->i_sb, pblock);
+	bh = sb_bread(inode_sb(inode), pblock);
 	if (!bh)
 		return -EIO;
 
@@ -208,7 +208,7 @@ static int extend_credit_for_blkdel(handle_t *handle, struct inode *inode)
 	 * So allocate a credit of 3. We may update
 	 * quota (user and group).
 	 */
-	needed = 3 + EXT4_MAXQUOTAS_TRANS_BLOCKS(inode->i_sb);
+	needed = 3 + EXT4_MAXQUOTAS_TRANS_BLOCKS(inode_sb(inode));
 
 	if (ext4_journal_extend(handle, needed) != 0)
 		retval = ext4_journal_restart(handle, needed);
@@ -222,9 +222,9 @@ static int free_dind_blocks(handle_t *handle,
 	int i;
 	__le32 *tmp_idata;
 	struct buffer_head *bh;
-	unsigned long max_entries = inode->i_sb->s_blocksize >> 2;
+	unsigned long max_entries = inode_sb(inode)->s_blocksize >> 2;
 
-	bh = sb_bread(inode->i_sb, le32_to_cpu(i_data));
+	bh = sb_bread(inode_sb(inode), le32_to_cpu(i_data));
 	if (!bh)
 		return -EIO;
 
@@ -252,9 +252,9 @@ static int free_tind_blocks(handle_t *handle,
 	int i, retval = 0;
 	__le32 *tmp_idata;
 	struct buffer_head *bh;
-	unsigned long max_entries = inode->i_sb->s_blocksize >> 2;
+	unsigned long max_entries = inode_sb(inode)->s_blocksize >> 2;
 
-	bh = sb_bread(inode->i_sb, le32_to_cpu(i_data));
+	bh = sb_bread(inode_sb(inode), le32_to_cpu(i_data));
 	if (!bh)
 		return -EIO;
 
@@ -382,7 +382,7 @@ static int free_ext_idx(handle_t *handle, struct inode *inode,
 	struct ext4_extent_header *eh;
 
 	block = ext4_idx_pblock(ix);
-	bh = sb_bread(inode->i_sb, block);
+	bh = sb_bread(inode_sb(inode), block);
 	if (!bh)
 		return -EIO;
 
@@ -441,7 +441,7 @@ int ext4_ext_migrate(struct inode *inode)
 	 * If the filesystem does not support extents, or the inode
 	 * already is extent-based, error out.
 	 */
-	if (!ext4_has_feature_extents(inode->i_sb) ||
+	if (!ext4_has_feature_extents(inode_sb(inode)) ||
 	    (ext4_test_inode_flag(inode, EXT4_INODE_EXTENTS)))
 		return -EINVAL;
 
@@ -457,17 +457,17 @@ int ext4_ext_migrate(struct inode *inode)
 	 * need to worry about credits for modifying the quota inode.
 	 */
 	handle = ext4_journal_start(inode, EXT4_HT_MIGRATE,
-		4 + EXT4_MAXQUOTAS_TRANS_BLOCKS(inode->i_sb));
+		4 + EXT4_MAXQUOTAS_TRANS_BLOCKS(inode_sb(inode)));
 
 	if (IS_ERR(handle)) {
 		retval = PTR_ERR(handle);
 		return retval;
 	}
-	goal = (((inode->i_ino - 1) / EXT4_INODES_PER_GROUP(inode->i_sb)) *
-		EXT4_INODES_PER_GROUP(inode->i_sb)) + 1;
+	goal = (((inode->i_ino - 1) / EXT4_INODES_PER_GROUP(inode_sb(inode))) *
+		EXT4_INODES_PER_GROUP(inode_sb(inode))) + 1;
 	owner[0] = i_uid_read(inode);
 	owner[1] = i_gid_read(inode);
-	tmp_inode = ext4_new_inode(handle, d_inode(inode->i_sb->s_root),
+	tmp_inode = ext4_new_inode(handle, d_inode(inode_sb(inode)->s_root),
 				   S_IFREG, NULL, goal, owner, 0);
 	if (IS_ERR(tmp_inode)) {
 		retval = PTR_ERR(tmp_inode);
@@ -522,7 +522,7 @@ int ext4_ext_migrate(struct inode *inode)
 	memset(&lb, 0, sizeof(lb));
 
 	/* 32 bit block address 4 bytes */
-	max_entries = inode->i_sb->s_blocksize >> 2;
+	max_entries = inode_sb(inode)->s_blocksize >> 2;
 	for (i = 0; i < EXT4_NDIR_BLOCKS; i++) {
 		if (i_data[i]) {
 			retval = update_extent_range(handle, tmp_inode,
@@ -608,7 +608,7 @@ int ext4_ext_migrate(struct inode *inode)
 int ext4_ind_migrate(struct inode *inode)
 {
 	struct ext4_extent_header	*eh;
-	struct ext4_super_block		*es = EXT4_SB(inode->i_sb)->s_es;
+	struct ext4_super_block		*es = EXT4_SB(inode_sb(inode))->s_es;
 	struct ext4_inode_info		*ei = EXT4_I(inode);
 	struct ext4_extent		*ex;
 	unsigned int			i, len;
@@ -617,11 +617,11 @@ int ext4_ind_migrate(struct inode *inode)
 	handle_t			*handle;
 	int				ret;
 
-	if (!ext4_has_feature_extents(inode->i_sb) ||
+	if (!ext4_has_feature_extents(inode_sb(inode)) ||
 	    (!ext4_test_inode_flag(inode, EXT4_INODE_EXTENTS)))
 		return -EINVAL;
 
-	if (ext4_has_feature_bigalloc(inode->i_sb))
+	if (ext4_has_feature_bigalloc(inode_sb(inode)))
 		return -EOPNOTSUPP;
 
 	/*
@@ -629,7 +629,7 @@ int ext4_ind_migrate(struct inode *inode)
 	 * blocks to be allocated, otherwise delayed allocation blocks may not
 	 * be reflected and bypass the checks on extent header.
 	 */
-	if (test_opt(inode->i_sb, DELALLOC))
+	if (test_opt(inode_sb(inode), DELALLOC))
 		ext4_alloc_da_blocks(inode);
 
 	handle = ext4_journal_start(inode, EXT4_HT_MIGRATE, 1);
diff --git a/fs/ext4/move_extent.c b/fs/ext4/move_extent.c
index b96e4bd3b3ec..670ccca993a0 100644
--- a/fs/ext4/move_extent.c
+++ b/fs/ext4/move_extent.c
@@ -255,13 +255,13 @@ move_extent_per_page(struct file *o_filp, struct inode *donor_inode,
 	struct page *pagep[2] = {NULL, NULL};
 	handle_t *handle;
 	ext4_lblk_t orig_blk_offset, donor_blk_offset;
-	unsigned long blocksize = orig_inode->i_sb->s_blocksize;
+	unsigned long blocksize = inode_sb(orig_inode)->s_blocksize;
 	unsigned int tmp_data_size, data_size, replaced_size;
 	int i, err2, jblocks, retries = 0;
 	int replaced_count = 0;
 	int from = data_offset_in_page << orig_inode->i_blkbits;
 	int blocks_per_page = PAGE_SIZE >> orig_inode->i_blkbits;
-	struct super_block *sb = orig_inode->i_sb;
+	struct super_block *sb = inode_sb(orig_inode);
 	struct buffer_head *bh = NULL;
 
 	/*
@@ -558,7 +558,7 @@ ext4_move_extents(struct file *o_filp, struct file *d_filp, __u64 orig_blk,
 	ext4_lblk_t d_start = donor_blk;
 	int ret;
 
-	if (orig_inode->i_sb != donor_inode->i_sb) {
+	if (inode_sb(orig_inode) != inode_sb(donor_inode)) {
 		ext4_debug("ext4 move extent: The argument files "
 			"should be in same FS [ino:orig %lu, donor %lu]\n",
 			orig_inode->i_ino, donor_inode->i_ino);
@@ -585,14 +585,14 @@ ext4_move_extents(struct file *o_filp, struct file *d_filp, __u64 orig_blk,
 	   journaling enabled */
 	if (ext4_should_journal_data(orig_inode) ||
 	    ext4_should_journal_data(donor_inode)) {
-		ext4_msg(orig_inode->i_sb, KERN_ERR,
+		ext4_msg(inode_sb(orig_inode), KERN_ERR,
 			 "Online defrag not supported with data journaling");
 		return -EOPNOTSUPP;
 	}
 
 	if (ext4_encrypted_inode(orig_inode) ||
 	    ext4_encrypted_inode(donor_inode)) {
-		ext4_msg(orig_inode->i_sb, KERN_ERR,
+		ext4_msg(inode_sb(orig_inode), KERN_ERR,
 			 "Online defrag not supported for encrypted files");
 		return -EOPNOTSUPP;
 	}
diff --git a/fs/ext4/namei.c b/fs/ext4/namei.c
index b1f21e3a0763..68d59adb8590 100644
--- a/fs/ext4/namei.c
+++ b/fs/ext4/namei.c
@@ -56,23 +56,23 @@ static struct buffer_head *ext4_append(handle_t *handle,
 	struct buffer_head *bh;
 	int err;
 
-	if (unlikely(EXT4_SB(inode->i_sb)->s_max_dir_size_kb &&
+	if (unlikely(EXT4_SB(inode_sb(inode))->s_max_dir_size_kb &&
 		     ((inode->i_size >> 10) >=
-		      EXT4_SB(inode->i_sb)->s_max_dir_size_kb)))
+		      EXT4_SB(inode_sb(inode))->s_max_dir_size_kb)))
 		return ERR_PTR(-ENOSPC);
 
-	*block = inode->i_size >> inode->i_sb->s_blocksize_bits;
+	*block = inode->i_size >> inode_sb(inode)->s_blocksize_bits;
 
 	bh = ext4_bread(handle, inode, *block, EXT4_GET_BLOCKS_CREATE);
 	if (IS_ERR(bh))
 		return bh;
-	inode->i_size += inode->i_sb->s_blocksize;
+	inode->i_size += inode_sb(inode)->s_blocksize;
 	EXT4_I(inode)->i_disksize = inode->i_size;
 	BUFFER_TRACE(bh, "get_write_access");
 	err = ext4_journal_get_write_access(handle, bh);
 	if (err) {
 		brelse(bh);
-		ext4_std_error(inode->i_sb, err);
+		ext4_std_error(inode_sb(inode), err);
 		return ERR_PTR(err);
 	}
 	return bh;
@@ -100,7 +100,7 @@ static struct buffer_head *__ext4_read_dirblock(struct inode *inode,
 
 	bh = ext4_bread(NULL, inode, block, 0);
 	if (IS_ERR(bh)) {
-		__ext4_warning(inode->i_sb, func, line,
+		__ext4_warning(inode_sb(inode), func, line,
 			       "inode #%lu: lblock %lu: comm %s: "
 			       "error %ld reading directory block",
 			       inode->i_ino, (unsigned long)block,
@@ -119,8 +119,8 @@ static struct buffer_head *__ext4_read_dirblock(struct inode *inode,
 		if (block == 0)
 			is_dx_block = 1;
 		else if (ext4_rec_len_from_disk(dirent->rec_len,
-						inode->i_sb->s_blocksize) ==
-			 inode->i_sb->s_blocksize)
+						inode_sb(inode)->s_blocksize) ==
+			 inode_sb(inode)->s_blocksize)
 			is_dx_block = 1;
 	}
 	if (!is_dx_block && type == INDEX) {
@@ -128,7 +128,7 @@ static struct buffer_head *__ext4_read_dirblock(struct inode *inode,
 		       "directory leaf block found instead of index block");
 		return ERR_PTR(-EFSCORRUPTED);
 	}
-	if (!ext4_has_metadata_csum(inode->i_sb) ||
+	if (!ext4_has_metadata_csum(inode_sb(inode)) ||
 	    buffer_verified(bh))
 		return bh;
 
@@ -298,8 +298,8 @@ static struct ext4_dir_entry_tail *get_dirent_tail(struct inode *inode,
 
 	d = de;
 	top = (struct ext4_dir_entry *)(((void *)de) +
-		(EXT4_BLOCK_SIZE(inode->i_sb) -
-		sizeof(struct ext4_dir_entry_tail)));
+		(EXT4_BLOCK_SIZE(inode_sb(inode)) -
+		 sizeof(struct ext4_dir_entry_tail)));
 	while (d < top && d->rec_len)
 		d = (struct ext4_dir_entry *)(((void *)d) +
 		    le16_to_cpu(d->rec_len));
@@ -309,7 +309,7 @@ static struct ext4_dir_entry_tail *get_dirent_tail(struct inode *inode,
 
 	t = (struct ext4_dir_entry_tail *)d;
 #else
-	t = EXT4_DIRENT_TAIL(de, EXT4_BLOCK_SIZE(inode->i_sb));
+	t = EXT4_DIRENT_TAIL(de, EXT4_BLOCK_SIZE(inode_sb(inode)));
 #endif
 
 	if (t->det_reserved_zero1 ||
@@ -324,7 +324,7 @@ static struct ext4_dir_entry_tail *get_dirent_tail(struct inode *inode,
 static __le32 ext4_dirent_csum(struct inode *inode,
 			       struct ext4_dir_entry *dirent, int size)
 {
-	struct ext4_sb_info *sbi = EXT4_SB(inode->i_sb);
+	struct ext4_sb_info *sbi = EXT4_SB(inode_sb(inode));
 	struct ext4_inode_info *ei = EXT4_I(inode);
 	__u32 csum;
 
@@ -346,7 +346,7 @@ int ext4_dirent_csum_verify(struct inode *inode, struct ext4_dir_entry *dirent)
 {
 	struct ext4_dir_entry_tail *t;
 
-	if (!ext4_has_metadata_csum(inode->i_sb))
+	if (!ext4_has_metadata_csum(inode_sb(inode)))
 		return 1;
 
 	t = get_dirent_tail(inode, dirent);
@@ -367,7 +367,7 @@ static void ext4_dirent_csum_set(struct inode *inode,
 {
 	struct ext4_dir_entry_tail *t;
 
-	if (!ext4_has_metadata_csum(inode->i_sb))
+	if (!ext4_has_metadata_csum(inode_sb(inode)))
 		return;
 
 	t = get_dirent_tail(inode, dirent);
@@ -396,12 +396,12 @@ static struct dx_countlimit *get_dx_countlimit(struct inode *inode,
 	struct dx_root_info *root;
 	int count_offset;
 
-	if (le16_to_cpu(dirent->rec_len) == EXT4_BLOCK_SIZE(inode->i_sb))
+	if (le16_to_cpu(dirent->rec_len) == EXT4_BLOCK_SIZE(inode_sb(inode)))
 		count_offset = 8;
 	else if (le16_to_cpu(dirent->rec_len) == 12) {
 		dp = (struct ext4_dir_entry *)(((void *)dirent) + 12);
 		if (le16_to_cpu(dp->rec_len) !=
-		    EXT4_BLOCK_SIZE(inode->i_sb) - 12)
+		    EXT4_BLOCK_SIZE(inode_sb(inode)) - 12)
 			return NULL;
 		root = (struct dx_root_info *)(((void *)dp + 12));
 		if (root->reserved_zero ||
@@ -419,7 +419,7 @@ static struct dx_countlimit *get_dx_countlimit(struct inode *inode,
 static __le32 ext4_dx_csum(struct inode *inode, struct ext4_dir_entry *dirent,
 			   int count_offset, int count, struct dx_tail *t)
 {
-	struct ext4_sb_info *sbi = EXT4_SB(inode->i_sb);
+	struct ext4_sb_info *sbi = EXT4_SB(inode_sb(inode));
 	struct ext4_inode_info *ei = EXT4_I(inode);
 	__u32 csum;
 	int size;
@@ -441,7 +441,7 @@ static int ext4_dx_csum_verify(struct inode *inode,
 	struct dx_tail *t;
 	int count_offset, limit, count;
 
-	if (!ext4_has_metadata_csum(inode->i_sb))
+	if (!ext4_has_metadata_csum(inode_sb(inode)))
 		return 1;
 
 	c = get_dx_countlimit(inode, dirent, &count_offset);
@@ -452,7 +452,7 @@ static int ext4_dx_csum_verify(struct inode *inode,
 	limit = le16_to_cpu(c->limit);
 	count = le16_to_cpu(c->count);
 	if (count_offset + (limit * sizeof(struct dx_entry)) >
-	    EXT4_BLOCK_SIZE(inode->i_sb) - sizeof(struct dx_tail)) {
+	    EXT4_BLOCK_SIZE(inode_sb(inode)) - sizeof(struct dx_tail)) {
 		warn_no_space_for_csum(inode);
 		return 0;
 	}
@@ -470,7 +470,7 @@ static void ext4_dx_csum_set(struct inode *inode, struct ext4_dir_entry *dirent)
 	struct dx_tail *t;
 	int count_offset, limit, count;
 
-	if (!ext4_has_metadata_csum(inode->i_sb))
+	if (!ext4_has_metadata_csum(inode_sb(inode)))
 		return;
 
 	c = get_dx_countlimit(inode, dirent, &count_offset);
@@ -481,7 +481,7 @@ static void ext4_dx_csum_set(struct inode *inode, struct ext4_dir_entry *dirent)
 	limit = le16_to_cpu(c->limit);
 	count = le16_to_cpu(c->count);
 	if (count_offset + (limit * sizeof(struct dx_entry)) >
-	    EXT4_BLOCK_SIZE(inode->i_sb) - sizeof(struct dx_tail)) {
+	    EXT4_BLOCK_SIZE(inode_sb(inode)) - sizeof(struct dx_tail)) {
 		warn_no_space_for_csum(inode);
 		return;
 	}
@@ -555,19 +555,19 @@ static inline void dx_set_limit(struct dx_entry *entries, unsigned value)
 
 static inline unsigned dx_root_limit(struct inode *dir, unsigned infosize)
 {
-	unsigned entry_space = dir->i_sb->s_blocksize - EXT4_DIR_REC_LEN(1) -
+	unsigned entry_space = inode_sb(dir)->s_blocksize - EXT4_DIR_REC_LEN(1) -
 		EXT4_DIR_REC_LEN(2) - infosize;
 
-	if (ext4_has_metadata_csum(dir->i_sb))
+	if (ext4_has_metadata_csum(inode_sb(dir)))
 		entry_space -= sizeof(struct dx_tail);
 	return entry_space / sizeof(struct dx_entry);
 }
 
 static inline unsigned dx_node_limit(struct inode *dir)
 {
-	unsigned entry_space = dir->i_sb->s_blocksize - EXT4_DIR_REC_LEN(0);
+	unsigned entry_space = inode_sb(dir)->s_blocksize - EXT4_DIR_REC_LEN(0);
 
-	if (ext4_has_metadata_csum(dir->i_sb))
+	if (ext4_has_metadata_csum(inode_sb(dir)))
 		entry_space -= sizeof(struct dx_tail);
 	return entry_space / sizeof(struct dx_entry);
 }
@@ -689,7 +689,7 @@ static struct stats dx_show_leaf(struct inode *dir,
 struct stats dx_show_entries(struct dx_hash_info *hinfo, struct inode *dir,
 			     struct dx_entry *entries, int levels)
 {
-	unsigned blocksize = dir->i_sb->s_blocksize;
+	unsigned blocksize = inode_sb(dir)->s_blocksize;
 	unsigned count = dx_get_count(entries), names = 0, space = 0, i;
 	unsigned bcount = 0;
 	struct buffer_head *bh;
@@ -758,8 +758,8 @@ dx_probe(struct ext4_filename *fname, struct inode *dir,
 		hinfo = &fname->hinfo;
 	hinfo->hash_version = root->info.hash_version;
 	if (hinfo->hash_version <= DX_HASH_TEA)
-		hinfo->hash_version += EXT4_SB(dir->i_sb)->s_hash_unsigned;
-	hinfo->seed = EXT4_SB(dir->i_sb)->s_hash_seed;
+		hinfo->hash_version += EXT4_SB(inode_sb(dir))->s_hash_unsigned;
+	hinfo->seed = EXT4_SB(inode_sb(dir))->s_hash_seed;
 	if (fname && fname_name(fname))
 		ext4fs_dirhash(fname_name(fname), fname_len(fname), hinfo);
 	hash = hinfo->hash;
@@ -771,13 +771,13 @@ dx_probe(struct ext4_filename *fname, struct inode *dir,
 	}
 
 	indirect = root->info.indirect_levels;
-	if (indirect >= ext4_dir_htree_level(dir->i_sb)) {
-		ext4_warning(dir->i_sb,
+	if (indirect >= ext4_dir_htree_level(inode_sb(dir))) {
+		ext4_warning(inode_sb(dir),
 			     "Directory (ino: %lu) htree depth %#06x exceed"
 			     "supported value", dir->i_ino,
-			     ext4_dir_htree_level(dir->i_sb));
-		if (ext4_dir_htree_level(dir->i_sb) < EXT4_HTREE_LEVEL) {
-			ext4_warning(dir->i_sb, "Enable large directory "
+			     ext4_dir_htree_level(inode_sb(dir)));
+		if (ext4_dir_htree_level(inode_sb(dir)) < EXT4_HTREE_LEVEL) {
+			ext4_warning(inode_sb(dir), "Enable large directory "
 						"feature to access it");
 		}
 		goto fail;
@@ -981,7 +981,7 @@ static int htree_dirblock_to_tree(struct file *dir_file,
 
 	de = (struct ext4_dir_entry_2 *) bh->b_data;
 	top = (struct ext4_dir_entry_2 *) ((char *) de +
-					   dir->i_sb->s_blocksize -
+					   inode_sb(dir)->s_blocksize -
 					   EXT4_DIR_REC_LEN(0));
 #ifdef CONFIG_EXT4_FS_ENCRYPTION
 	/* Check if the directory is encrypted */
@@ -999,11 +999,11 @@ static int htree_dirblock_to_tree(struct file *dir_file,
 		}
 	}
 #endif
-	for (; de < top; de = ext4_next_entry(de, dir->i_sb->s_blocksize)) {
+	for (; de < top; de = ext4_next_entry(de, inode_sb(dir)->s_blocksize)) {
 		if (ext4_check_dir_entry(dir, NULL, de, bh,
 				bh->b_data, bh->b_size,
-				(block<<EXT4_BLOCK_SIZE_BITS(dir->i_sb))
-					 + ((char *)de - bh->b_data))) {
+				(block<<EXT4_BLOCK_SIZE_BITS(inode_sb(dir)))
+				+ ((char *)de - bh->b_data))) {
 			/* silently ignore the rest of the block */
 			break;
 		}
@@ -1078,11 +1078,11 @@ int ext4_htree_fill_tree(struct file *dir_file, __u32 start_hash,
 		       start_hash, start_minor_hash));
 	dir = file_inode(dir_file);
 	if (!(ext4_test_inode_flag(dir, EXT4_INODE_INDEX))) {
-		hinfo.hash_version = EXT4_SB(dir->i_sb)->s_def_hash_version;
+		hinfo.hash_version = EXT4_SB(inode_sb(dir))->s_def_hash_version;
 		if (hinfo.hash_version <= DX_HASH_TEA)
 			hinfo.hash_version +=
-				EXT4_SB(dir->i_sb)->s_hash_unsigned;
-		hinfo.seed = EXT4_SB(dir->i_sb)->s_hash_seed;
+				EXT4_SB(inode_sb(dir))->s_hash_unsigned;
+		hinfo.seed = EXT4_SB(inode_sb(dir))->s_hash_seed;
 		if (ext4_has_inline_data(dir)) {
 			int has_inline_data = 1;
 			count = htree_inlinedir_to_tree(dir_file, dir, 0,
@@ -1118,7 +1118,7 @@ int ext4_htree_fill_tree(struct file *dir_file, __u32 start_hash,
 	}
 	if (start_hash < 2 || (start_hash ==2 && start_minor_hash==0)) {
 		de = (struct ext4_dir_entry_2 *) frames[0].bh->b_data;
-		de = ext4_next_entry(de, dir->i_sb->s_blocksize);
+		de = ext4_next_entry(de, inode_sb(dir)->s_blocksize);
 		tmp_str.name = de->name;
 		tmp_str.len = de->name_len;
 		err = ext4_htree_store_dirent(dir_file, 2, 0,
@@ -1174,7 +1174,8 @@ static inline int search_dirblock(struct buffer_head *bh,
 				  unsigned int offset,
 				  struct ext4_dir_entry_2 **res_dir)
 {
-	return ext4_search_dir(bh, bh->b_data, dir->i_sb->s_blocksize, dir,
+	return ext4_search_dir(bh, bh->b_data, inode_sb(dir)->s_blocksize,
+			       dir,
 			       fname, offset, res_dir);
 }
 
@@ -1300,7 +1301,7 @@ int ext4_search_dir(struct buffer_head *bh, char *search_buf, int buf_size,
 		}
 		/* prevent looping on a bad block */
 		de_len = ext4_rec_len_from_disk(de->rec_len,
-						dir->i_sb->s_blocksize);
+						inode_sb(dir)->s_blocksize);
 		if (de_len <= 0)
 			return -1;
 		offset += de_len;
@@ -1312,7 +1313,7 @@ int ext4_search_dir(struct buffer_head *bh, char *search_buf, int buf_size,
 static int is_dx_internal_node(struct inode *dir, ext4_lblk_t block,
 			       struct ext4_dir_entry *de)
 {
-	struct super_block *sb = dir->i_sb;
+	struct super_block *sb = inode_sb(dir);
 
 	if (!is_dx(dir))
 		return 0;
@@ -1355,7 +1356,7 @@ static struct buffer_head * ext4_find_entry (struct inode *dir,
 	struct ext4_filename fname;
 
 	*res_dir = NULL;
-	sb = dir->i_sb;
+	sb = inode_sb(dir);
 	namelen = d_name->len;
 	if (namelen > EXT4_NAME_LEN)
 		return NULL;
@@ -1490,7 +1491,7 @@ static struct buffer_head * ext4_dx_find_entry(struct inode *dir,
 			struct ext4_filename *fname,
 			struct ext4_dir_entry_2 **res_dir)
 {
-	struct super_block * sb = dir->i_sb;
+	struct super_block * sb = inode_sb(dir);
 	struct dx_frame frames[EXT4_HTREE_LEVEL], *frame;
 	struct buffer_head *bh;
 	ext4_lblk_t block;
@@ -1560,7 +1561,7 @@ static struct dentry *ext4_lookup(struct inode *dir, struct dentry *dentry, unsi
 	if (bh) {
 		__u32 ino = le32_to_cpu(de->inode);
 		brelse(bh);
-		if (!ext4_valid_inum(dir->i_sb, ino)) {
+		if (!ext4_valid_inum(inode_sb(dir), ino)) {
 			EXT4_ERROR_INODE(dir, "bad inode number: %u", ino);
 			return ERR_PTR(-EFSCORRUPTED);
 		}
@@ -1569,7 +1570,7 @@ static struct dentry *ext4_lookup(struct inode *dir, struct dentry *dentry, unsi
 					 dentry);
 			return ERR_PTR(-EFSCORRUPTED);
 		}
-		inode = ext4_iget_normal(dir->i_sb, ino);
+		inode = ext4_iget_normal(inode_sb(dir), ino);
 		if (inode == ERR_PTR(-ESTALE)) {
 			EXT4_ERROR_INODE(dir,
 					 "deleted inode referenced: %u",
@@ -1579,7 +1580,7 @@ static struct dentry *ext4_lookup(struct inode *dir, struct dentry *dentry, unsi
 		if (!IS_ERR(inode) && ext4_encrypted_inode(dir) &&
 		    (S_ISDIR(inode->i_mode) || S_ISLNK(inode->i_mode)) &&
 		    !fscrypt_has_permitted_context(dir, inode)) {
-			ext4_warning(inode->i_sb,
+			ext4_warning(inode_sb(inode),
 				     "Inconsistent encryption contexts: %lu/%lu",
 				     dir->i_ino, inode->i_ino);
 			iput(inode);
@@ -1672,7 +1673,7 @@ static struct ext4_dir_entry_2 *do_split(handle_t *handle, struct inode *dir,
 			struct buffer_head **bh,struct dx_frame *frame,
 			struct dx_hash_info *hinfo)
 {
-	unsigned blocksize = dir->i_sb->s_blocksize;
+	unsigned blocksize = inode_sb(dir)->s_blocksize;
 	unsigned count, continued;
 	struct buffer_head *bh2;
 	ext4_lblk_t newblock;
@@ -1685,7 +1686,7 @@ static struct ext4_dir_entry_2 *do_split(handle_t *handle, struct inode *dir,
 	int	csum_size = 0;
 	int	err = 0, i;
 
-	if (ext4_has_metadata_csum(dir->i_sb))
+	if (ext4_has_metadata_csum(inode_sb(dir)))
 		csum_size = sizeof(struct ext4_dir_entry_tail);
 
 	bh2 = ext4_append(handle, dir, &newblock);
@@ -1774,7 +1775,7 @@ static struct ext4_dir_entry_2 *do_split(handle_t *handle, struct inode *dir,
 	brelse(*bh);
 	brelse(bh2);
 	*bh = NULL;
-	ext4_std_error(dir->i_sb, err);
+	ext4_std_error(inode_sb(dir), err);
 	return ERR_PTR(err);
 }
 
@@ -1831,7 +1832,7 @@ void ext4_insert_dentry(struct inode *inode,
 	}
 	de->file_type = EXT4_FT_UNKNOWN;
 	de->inode = cpu_to_le32(inode->i_ino);
-	ext4_set_de_type(inode->i_sb, de, inode->i_mode);
+	ext4_set_de_type(inode_sb(inode), de, inode->i_mode);
 	de->name_len = fname_len(fname);
 	memcpy(de->name, fname_name(fname), fname_len(fname));
 }
@@ -1849,11 +1850,11 @@ static int add_dirent_to_buf(handle_t *handle, struct ext4_filename *fname,
 			     struct inode *inode, struct ext4_dir_entry_2 *de,
 			     struct buffer_head *bh)
 {
-	unsigned int	blocksize = dir->i_sb->s_blocksize;
+	unsigned int	blocksize = inode_sb(dir)->s_blocksize;
 	int		csum_size = 0;
 	int		err;
 
-	if (ext4_has_metadata_csum(inode->i_sb))
+	if (ext4_has_metadata_csum(inode_sb(inode)))
 		csum_size = sizeof(struct ext4_dir_entry_tail);
 
 	if (!de) {
@@ -1865,7 +1866,7 @@ static int add_dirent_to_buf(handle_t *handle, struct ext4_filename *fname,
 	BUFFER_TRACE(bh, "get_write_access");
 	err = ext4_journal_get_write_access(handle, bh);
 	if (err) {
-		ext4_std_error(dir->i_sb, err);
+		ext4_std_error(inode_sb(dir), err);
 		return err;
 	}
 
@@ -1890,7 +1891,7 @@ static int add_dirent_to_buf(handle_t *handle, struct ext4_filename *fname,
 	BUFFER_TRACE(bh, "call ext4_handle_dirty_metadata");
 	err = ext4_handle_dirty_dirent_node(handle, dir, bh);
 	if (err)
-		ext4_std_error(dir->i_sb, err);
+		ext4_std_error(inode_sb(dir), err);
 	return 0;
 }
 
@@ -1916,15 +1917,15 @@ static int make_indexed_dir(handle_t *handle, struct ext4_filename *fname,
 	struct fake_dirent *fde;
 	int csum_size = 0;
 
-	if (ext4_has_metadata_csum(inode->i_sb))
+	if (ext4_has_metadata_csum(inode_sb(inode)))
 		csum_size = sizeof(struct ext4_dir_entry_tail);
 
-	blocksize =  dir->i_sb->s_blocksize;
+	blocksize =  inode_sb(dir)->s_blocksize;
 	dxtrace(printk(KERN_DEBUG "Creating index: inode %lu\n", dir->i_ino));
 	BUFFER_TRACE(bh, "get_write_access");
 	retval = ext4_journal_get_write_access(handle, bh);
 	if (retval) {
-		ext4_std_error(dir->i_sb, retval);
+		ext4_std_error(inode_sb(dir), retval);
 		brelse(bh);
 		return retval;
 	}
@@ -1970,7 +1971,7 @@ static int make_indexed_dir(handle_t *handle, struct ext4_filename *fname,
 					   blocksize);
 	memset (&root->info, 0, sizeof(root->info));
 	root->info.info_length = sizeof(root->info);
-	root->info.hash_version = EXT4_SB(dir->i_sb)->s_def_hash_version;
+	root->info.hash_version = EXT4_SB(inode_sb(dir))->s_def_hash_version;
 	entries = root->entries;
 	dx_set_block(entries, 1);
 	dx_set_count(entries, 1);
@@ -1979,8 +1980,8 @@ static int make_indexed_dir(handle_t *handle, struct ext4_filename *fname,
 	/* Initialize as for dx_probe */
 	fname->hinfo.hash_version = root->info.hash_version;
 	if (fname->hinfo.hash_version <= DX_HASH_TEA)
-		fname->hinfo.hash_version += EXT4_SB(dir->i_sb)->s_hash_unsigned;
-	fname->hinfo.seed = EXT4_SB(dir->i_sb)->s_hash_seed;
+		fname->hinfo.hash_version += EXT4_SB(inode_sb(dir))->s_hash_unsigned;
+	fname->hinfo.seed = EXT4_SB(inode_sb(dir))->s_hash_seed;
 	ext4fs_dirhash(fname_name(fname), fname_len(fname), &fname->hinfo);
 
 	memset(frames, 0, sizeof(frames));
@@ -2041,10 +2042,10 @@ static int ext4_add_entry(handle_t *handle, struct dentry *dentry,
 	ext4_lblk_t block, blocks;
 	int	csum_size = 0;
 
-	if (ext4_has_metadata_csum(inode->i_sb))
+	if (ext4_has_metadata_csum(inode_sb(inode)))
 		csum_size = sizeof(struct ext4_dir_entry_tail);
 
-	sb = dir->i_sb;
+	sb = inode_sb(dir);
 	blocksize = sb->s_blocksize;
 	if (!dentry->d_name.len)
 		return -EINVAL;
@@ -2126,7 +2127,7 @@ static int ext4_dx_add_entry(handle_t *handle, struct ext4_filename *fname,
 	struct dx_frame frames[EXT4_HTREE_LEVEL], *frame;
 	struct dx_entry *entries, *at;
 	struct buffer_head *bh;
-	struct super_block *sb = dir->i_sb;
+	struct super_block *sb = inode_sb(dir);
 	struct ext4_dir_entry_2 *de;
 	int restart;
 	int err;
@@ -2279,7 +2280,7 @@ static int ext4_dx_add_entry(handle_t *handle, struct ext4_filename *fname,
 	goto cleanup;
 
 journal_error:
-	ext4_std_error(dir->i_sb, err); /* this is a no-op if err == 0 */
+	ext4_std_error(inode_sb(dir), err); /* this is a no-op if err == 0 */
 cleanup:
 	brelse(bh);
 	dx_release(frames);
@@ -2304,7 +2305,7 @@ int ext4_generic_delete_entry(handle_t *handle,
 			      int csum_size)
 {
 	struct ext4_dir_entry_2 *de, *pde;
-	unsigned int blocksize = dir->i_sb->s_blocksize;
+	unsigned int blocksize = inode_sb(dir)->s_blocksize;
 	int i;
 
 	i = 0;
@@ -2349,7 +2350,7 @@ static int ext4_delete_entry(handle_t *handle,
 			return err;
 	}
 
-	if (ext4_has_metadata_csum(dir->i_sb))
+	if (ext4_has_metadata_csum(inode_sb(dir)))
 		csum_size = sizeof(struct ext4_dir_entry_tail);
 
 	BUFFER_TRACE(bh, "get_write_access");
@@ -2359,7 +2360,7 @@ static int ext4_delete_entry(handle_t *handle,
 
 	err = ext4_generic_delete_entry(handle, dir, de_del,
 					bh, bh->b_data,
-					dir->i_sb->s_blocksize, csum_size);
+					inode_sb(dir)->s_blocksize, csum_size);
 	if (err)
 		goto out;
 
@@ -2371,7 +2372,7 @@ static int ext4_delete_entry(handle_t *handle,
 	return 0;
 out:
 	if (err != -ENOENT)
-		ext4_std_error(dir->i_sb, err);
+		ext4_std_error(inode_sb(dir), err);
 	return err;
 }
 
@@ -2440,7 +2441,7 @@ static int ext4_create(struct inode *dir, struct dentry *dentry, umode_t mode,
 	if (err)
 		return err;
 
-	credits = (EXT4_DATA_TRANS_BLOCKS(dir->i_sb) +
+	credits = (EXT4_DATA_TRANS_BLOCKS(inode_sb(dir)) +
 		   EXT4_INDEX_EXTRA_TRANS_BLOCKS + 3);
 retry:
 	inode = ext4_new_inode_start_handle(dir, mode, &dentry->d_name, 0,
@@ -2457,7 +2458,7 @@ static int ext4_create(struct inode *dir, struct dentry *dentry, umode_t mode,
 	}
 	if (handle)
 		ext4_journal_stop(handle);
-	if (err == -ENOSPC && ext4_should_retry_alloc(dir->i_sb, &retries))
+	if (err == -ENOSPC && ext4_should_retry_alloc(inode_sb(dir), &retries))
 		goto retry;
 	return err;
 }
@@ -2473,7 +2474,7 @@ static int ext4_mknod(struct inode *dir, struct dentry *dentry,
 	if (err)
 		return err;
 
-	credits = (EXT4_DATA_TRANS_BLOCKS(dir->i_sb) +
+	credits = (EXT4_DATA_TRANS_BLOCKS(inode_sb(dir)) +
 		   EXT4_INDEX_EXTRA_TRANS_BLOCKS + 3);
 retry:
 	inode = ext4_new_inode_start_handle(dir, mode, &dentry->d_name, 0,
@@ -2489,7 +2490,7 @@ static int ext4_mknod(struct inode *dir, struct dentry *dentry,
 	}
 	if (handle)
 		ext4_journal_stop(handle);
-	if (err == -ENOSPC && ext4_should_retry_alloc(dir->i_sb, &retries))
+	if (err == -ENOSPC && ext4_should_retry_alloc(inode_sb(dir), &retries))
 		goto retry;
 	return err;
 }
@@ -2508,8 +2509,8 @@ static int ext4_tmpfile(struct inode *dir, struct dentry *dentry, umode_t mode)
 	inode = ext4_new_inode_start_handle(dir, mode,
 					    NULL, 0, NULL,
 					    EXT4_HT_DIR,
-			EXT4_MAXQUOTAS_INIT_BLOCKS(dir->i_sb) +
-			  4 + EXT4_XATTR_TRANS_BLOCKS);
+			EXT4_MAXQUOTAS_INIT_BLOCKS(inode_sb(dir)) +
+			4 + EXT4_XATTR_TRANS_BLOCKS);
 	handle = ext4_journal_current_handle();
 	err = PTR_ERR(inode);
 	if (!IS_ERR(inode)) {
@@ -2525,7 +2526,7 @@ static int ext4_tmpfile(struct inode *dir, struct dentry *dentry, umode_t mode)
 	}
 	if (handle)
 		ext4_journal_stop(handle);
-	if (err == -ENOSPC && ext4_should_retry_alloc(dir->i_sb, &retries))
+	if (err == -ENOSPC && ext4_should_retry_alloc(inode_sb(dir), &retries))
 		goto retry;
 	return err;
 err_unlock_inode:
@@ -2544,7 +2545,7 @@ struct ext4_dir_entry_2 *ext4_init_dot_dotdot(struct inode *inode,
 	de->rec_len = ext4_rec_len_to_disk(EXT4_DIR_REC_LEN(de->name_len),
 					   blocksize);
 	strcpy(de->name, ".");
-	ext4_set_de_type(inode->i_sb, de, S_IFDIR);
+	ext4_set_de_type(inode_sb(inode), de, S_IFDIR);
 
 	de = ext4_next_entry(de, blocksize);
 	de->inode = cpu_to_le32(parent_ino);
@@ -2557,7 +2558,7 @@ struct ext4_dir_entry_2 *ext4_init_dot_dotdot(struct inode *inode,
 		de->rec_len = ext4_rec_len_to_disk(
 				EXT4_DIR_REC_LEN(de->name_len), blocksize);
 	strcpy(de->name, "..");
-	ext4_set_de_type(inode->i_sb, de, S_IFDIR);
+	ext4_set_de_type(inode_sb(inode), de, S_IFDIR);
 
 	return ext4_next_entry(de, blocksize);
 }
@@ -2569,11 +2570,11 @@ static int ext4_init_new_dir(handle_t *handle, struct inode *dir,
 	struct ext4_dir_entry_2 *de;
 	struct ext4_dir_entry_tail *t;
 	ext4_lblk_t block = 0;
-	unsigned int blocksize = dir->i_sb->s_blocksize;
+	unsigned int blocksize = inode_sb(dir)->s_blocksize;
 	int csum_size = 0;
 	int err;
 
-	if (ext4_has_metadata_csum(dir->i_sb))
+	if (ext4_has_metadata_csum(inode_sb(dir)))
 		csum_size = sizeof(struct ext4_dir_entry_tail);
 
 	if (ext4_test_inode_state(inode, EXT4_STATE_MAY_INLINE_DATA)) {
@@ -2619,7 +2620,7 @@ static int ext4_mkdir(struct inode *dir, struct dentry *dentry, umode_t mode)
 	if (err)
 		return err;
 
-	credits = (EXT4_DATA_TRANS_BLOCKS(dir->i_sb) +
+	credits = (EXT4_DATA_TRANS_BLOCKS(inode_sb(dir)) +
 		   EXT4_INDEX_EXTRA_TRANS_BLOCKS + 3);
 retry:
 	inode = ext4_new_inode_start_handle(dir, S_IFDIR | mode,
@@ -2659,7 +2660,7 @@ static int ext4_mkdir(struct inode *dir, struct dentry *dentry, umode_t mode)
 out_stop:
 	if (handle)
 		ext4_journal_stop(handle);
-	if (err == -ENOSPC && ext4_should_retry_alloc(dir->i_sb, &retries))
+	if (err == -ENOSPC && ext4_should_retry_alloc(inode_sb(dir), &retries))
 		goto retry;
 	return err;
 }
@@ -2683,7 +2684,7 @@ bool ext4_empty_dir(struct inode *inode)
 			return ret;
 	}
 
-	sb = inode->i_sb;
+	sb = inode_sb(inode);
 	if (inode->i_size < EXT4_DIR_REC_LEN(1) + EXT4_DIR_REC_LEN(2)) {
 		EXT4_ERROR_INODE(inode, "invalid size");
 		return true;
@@ -2746,7 +2747,7 @@ bool ext4_empty_dir(struct inode *inode)
  */
 int ext4_orphan_add(handle_t *handle, struct inode *inode)
 {
-	struct super_block *sb = inode->i_sb;
+	struct super_block *sb = inode_sb(inode);
 	struct ext4_sb_info *sbi = EXT4_SB(sb);
 	struct ext4_iloc iloc;
 	int err = 0, rc;
@@ -2829,7 +2830,7 @@ int ext4_orphan_del(handle_t *handle, struct inode *inode)
 {
 	struct list_head *prev;
 	struct ext4_inode_info *ei = EXT4_I(inode);
-	struct ext4_sb_info *sbi = EXT4_SB(inode->i_sb);
+	struct ext4_sb_info *sbi = EXT4_SB(inode_sb(inode));
 	__u32 ino_next;
 	struct ext4_iloc iloc;
 	int err = 0;
@@ -2874,7 +2875,7 @@ int ext4_orphan_del(handle_t *handle, struct inode *inode)
 		}
 		sbi->s_es->s_last_orphan = cpu_to_le32(ino_next);
 		mutex_unlock(&sbi->s_orphan_lock);
-		err = ext4_handle_dirty_super(handle, inode->i_sb);
+		err = ext4_handle_dirty_super(handle, inode_sb(inode));
 	} else {
 		struct ext4_iloc iloc2;
 		struct inode *i_prev =
@@ -2896,7 +2897,7 @@ int ext4_orphan_del(handle_t *handle, struct inode *inode)
 	NEXT_ORPHAN(inode) = 0;
 	err = ext4_mark_iloc_dirty(handle, inode, &iloc);
 out_err:
-	ext4_std_error(inode->i_sb, err);
+	ext4_std_error(inode_sb(inode), err);
 	return err;
 
 out_brelse:
@@ -2912,7 +2913,7 @@ static int ext4_rmdir(struct inode *dir, struct dentry *dentry)
 	struct ext4_dir_entry_2 *de;
 	handle_t *handle = NULL;
 
-	if (unlikely(ext4_forced_shutdown(EXT4_SB(dir->i_sb))))
+	if (unlikely(ext4_forced_shutdown(EXT4_SB(inode_sb(dir)))))
 		return -EIO;
 
 	/* Initialize quotas before so that eventual writes go in
@@ -2942,7 +2943,7 @@ static int ext4_rmdir(struct inode *dir, struct dentry *dentry)
 		goto end_rmdir;
 
 	handle = ext4_journal_start(dir, EXT4_HT_DIR,
-				    EXT4_DATA_TRANS_BLOCKS(dir->i_sb));
+				    EXT4_DATA_TRANS_BLOCKS(inode_sb(dir)));
 	if (IS_ERR(handle)) {
 		retval = PTR_ERR(handle);
 		handle = NULL;
@@ -2988,7 +2989,7 @@ static int ext4_unlink(struct inode *dir, struct dentry *dentry)
 	struct ext4_dir_entry_2 *de;
 	handle_t *handle = NULL;
 
-	if (unlikely(ext4_forced_shutdown(EXT4_SB(dir->i_sb))))
+	if (unlikely(ext4_forced_shutdown(EXT4_SB(inode_sb(dir)))))
 		return -EIO;
 
 	trace_ext4_unlink_enter(dir, dentry);
@@ -3015,7 +3016,7 @@ static int ext4_unlink(struct inode *dir, struct dentry *dentry)
 		goto end_unlink;
 
 	handle = ext4_journal_start(dir, EXT4_HT_DIR,
-				    EXT4_DATA_TRANS_BLOCKS(dir->i_sb));
+				    EXT4_DATA_TRANS_BLOCKS(inode_sb(dir)));
 	if (IS_ERR(handle)) {
 		retval = PTR_ERR(handle);
 		handle = NULL;
@@ -3059,10 +3060,11 @@ static int ext4_symlink(struct inode *dir,
 	int credits;
 	struct fscrypt_str disk_link;
 
-	if (unlikely(ext4_forced_shutdown(EXT4_SB(dir->i_sb))))
+	if (unlikely(ext4_forced_shutdown(EXT4_SB(inode_sb(dir)))))
 		return -EIO;
 
-	err = fscrypt_prepare_symlink(dir, symname, len, dir->i_sb->s_blocksize,
+	err = fscrypt_prepare_symlink(dir, symname, len,
+				      inode_sb(dir)->s_blocksize,
 				      &disk_link);
 	if (err)
 		return err;
@@ -3078,7 +3080,7 @@ static int ext4_symlink(struct inode *dir,
 		 * group descriptor, sb, inode block, quota blocks, and
 		 * possibly selinux xattr blocks.
 		 */
-		credits = 4 + EXT4_MAXQUOTAS_INIT_BLOCKS(dir->i_sb) +
+		credits = 4 + EXT4_MAXQUOTAS_INIT_BLOCKS(inode_sb(dir)) +
 			  EXT4_XATTR_TRANS_BLOCKS;
 	} else {
 		/*
@@ -3087,7 +3089,7 @@ static int ext4_symlink(struct inode *dir,
 		 * allocate new inode (bitmap, group descriptor, inode block,
 		 * quota blocks, sb is already counted in previous macros).
 		 */
-		credits = EXT4_DATA_TRANS_BLOCKS(dir->i_sb) +
+		credits = EXT4_DATA_TRANS_BLOCKS(inode_sb(dir)) +
 			  EXT4_INDEX_EXTRA_TRANS_BLOCKS + 3;
 	}
 
@@ -3137,7 +3139,7 @@ static int ext4_symlink(struct inode *dir,
 		 * + EXT4_INDEX_EXTRA_TRANS_BLOCKS), inode is also modified
 		 */
 		handle = ext4_journal_start(dir, EXT4_HT_DIR,
-				EXT4_DATA_TRANS_BLOCKS(dir->i_sb) +
+				EXT4_DATA_TRANS_BLOCKS(inode_sb(dir)) +
 				EXT4_INDEX_EXTRA_TRANS_BLOCKS + 1);
 		if (IS_ERR(handle)) {
 			err = PTR_ERR(handle);
@@ -3205,7 +3207,7 @@ static int ext4_link(struct dentry *old_dentry,
 
 retry:
 	handle = ext4_journal_start(dir, EXT4_HT_DIR,
-		(EXT4_DATA_TRANS_BLOCKS(dir->i_sb) +
+		(EXT4_DATA_TRANS_BLOCKS(inode_sb(dir)) +
 		 EXT4_INDEX_EXTRA_TRANS_BLOCKS) + 1);
 	if (IS_ERR(handle))
 		return PTR_ERR(handle);
@@ -3231,7 +3233,7 @@ static int ext4_link(struct dentry *old_dentry,
 		iput(inode);
 	}
 	ext4_journal_stop(handle);
-	if (err == -ENOSPC && ext4_should_retry_alloc(dir->i_sb, &retries))
+	if (err == -ENOSPC && ext4_should_retry_alloc(inode_sb(dir), &retries))
 		goto retry;
 	return err;
 }
@@ -3258,7 +3260,7 @@ static struct buffer_head *ext4_get_first_dir_block(handle_t *handle,
 		}
 		*parent_de = ext4_next_entry(
 					(struct ext4_dir_entry_2 *)bh->b_data,
-					inode->i_sb->s_blocksize);
+					inode_sb(inode)->s_blocksize);
 		return bh;
 	}
 
@@ -3320,7 +3322,7 @@ static int ext4_rename_dir_finish(handle_t *handle, struct ext4_renament *ent,
 		retval = ext4_mark_inode_dirty(handle, ent->inode);
 	}
 	if (retval) {
-		ext4_std_error(ent->dir->i_sb, retval);
+		ext4_std_error(inode_sb(ent->dir), retval);
 		return retval;
 	}
 	return 0;
@@ -3336,7 +3338,7 @@ static int ext4_setent(handle_t *handle, struct ext4_renament *ent,
 	if (retval)
 		return retval;
 	ent->de->inode = cpu_to_le32(ino);
-	if (ext4_has_feature_filetype(ent->dir->i_sb))
+	if (ext4_has_feature_filetype(inode_sb(ent->dir)))
 		ent->de->file_type = file_type;
 	inode_inc_iversion(ent->dir);
 	ent->dir->i_ctime = ent->dir->i_mtime =
@@ -3347,7 +3349,7 @@ static int ext4_setent(handle_t *handle, struct ext4_renament *ent,
 		retval = ext4_handle_dirty_dirent_node(handle,
 						       ent->dir, ent->bh);
 		if (unlikely(retval)) {
-			ext4_std_error(ent->dir->i_sb, retval);
+			ext4_std_error(inode_sb(ent->dir), retval);
 			return retval;
 		}
 	}
@@ -3428,7 +3430,7 @@ static struct inode *ext4_whiteout_for_rename(struct ext4_renament *ent,
 	 * for inode block, sb block, group summaries,
 	 * and inode bitmap
 	 */
-	credits += (EXT4_MAXQUOTAS_TRANS_BLOCKS(ent->dir->i_sb) +
+	credits += (EXT4_MAXQUOTAS_TRANS_BLOCKS(inode_sb(ent->dir)) +
 		    EXT4_XATTR_TRANS_BLOCKS + 4);
 retry:
 	wh = ext4_new_inode_start_handle(ent->dir, S_IFCHR | WHITEOUT_MODE,
@@ -3440,7 +3442,7 @@ static struct inode *ext4_whiteout_for_rename(struct ext4_renament *ent,
 		if (handle)
 			ext4_journal_stop(handle);
 		if (PTR_ERR(wh) == -ENOSPC &&
-		    ext4_should_retry_alloc(ent->dir->i_sb, &retries))
+		    ext4_should_retry_alloc(inode_sb(ent->dir), &retries))
 			goto retry;
 	} else {
 		*h = handle;
@@ -3525,10 +3527,10 @@ static int ext4_rename(struct inode *old_dir, struct dentry *old_dentry,
 			new.bh = NULL;
 		}
 	}
-	if (new.inode && !test_opt(new.dir->i_sb, NO_AUTO_DA_ALLOC))
+	if (new.inode && !test_opt(inode_sb(new.dir), NO_AUTO_DA_ALLOC))
 		ext4_alloc_da_blocks(old.inode);
 
-	credits = (2 * EXT4_DATA_TRANS_BLOCKS(old.dir->i_sb) +
+	credits = (2 * EXT4_DATA_TRANS_BLOCKS(inode_sb(old.dir)) +
 		   EXT4_INDEX_EXTRA_TRANS_BLOCKS + 2);
 	if (!(flags & RENAME_WHITEOUT)) {
 		handle = ext4_journal_start(old.dir, EXT4_HT_DIR, credits);
@@ -3719,7 +3721,7 @@ static int ext4_cross_rename(struct inode *old_dir, struct dentry *old_dentry,
 		goto end_rename;
 
 	handle = ext4_journal_start(old.dir, EXT4_HT_DIR,
-		(2 * EXT4_DATA_TRANS_BLOCKS(old.dir->i_sb) +
+		(2 * EXT4_DATA_TRANS_BLOCKS(inode_sb(old.dir)) +
 		 2 * EXT4_INDEX_EXTRA_TRANS_BLOCKS + 2));
 	if (IS_ERR(handle)) {
 		retval = PTR_ERR(handle);
@@ -3805,7 +3807,7 @@ static int ext4_rename2(struct inode *old_dir, struct dentry *old_dentry,
 {
 	int err;
 
-	if (unlikely(ext4_forced_shutdown(EXT4_SB(old_dir->i_sb))))
+	if (unlikely(ext4_forced_shutdown(EXT4_SB(inode_sb(old_dir)))))
 		return -EIO;
 
 	if (flags & ~(RENAME_NOREPLACE | RENAME_EXCHANGE | RENAME_WHITEOUT))
diff --git a/fs/ext4/page-io.c b/fs/ext4/page-io.c
index db7590178dfc..fb8493a31e94 100644
--- a/fs/ext4/page-io.c
+++ b/fs/ext4/page-io.c
@@ -158,8 +158,8 @@ static int ext4_end_io(ext4_io_end_t *io)
 
 	io->handle = NULL;	/* Following call will use up the handle */
 	ret = ext4_convert_unwritten_extents(handle, inode, offset, size);
-	if (ret < 0 && !ext4_forced_shutdown(EXT4_SB(inode->i_sb))) {
-		ext4_msg(inode->i_sb, KERN_EMERG,
+	if (ret < 0 && !ext4_forced_shutdown(EXT4_SB(inode_sb(inode)))) {
+		ext4_msg(inode_sb(inode), KERN_EMERG,
 			 "failed to convert unwritten extents to written "
 			 "extents -- potential data loss!  "
 			 "(inode %lu, offset %llu, size %zd, error %d)",
@@ -197,7 +197,7 @@ static void dump_completed_IO(struct inode *inode, struct list_head *head)
 static void ext4_add_complete_io(ext4_io_end_t *io_end)
 {
 	struct ext4_inode_info *ei = EXT4_I(io_end->inode);
-	struct ext4_sb_info *sbi = EXT4_SB(io_end->inode->i_sb);
+	struct ext4_sb_info *sbi = EXT4_SB(inode_sb(io_end->inode));
 	struct workqueue_struct *wq;
 	unsigned long flags;
 
@@ -314,7 +314,8 @@ static void ext4_end_bio(struct bio *bio)
 	if (bio->bi_status) {
 		struct inode *inode = io_end->inode;
 
-		ext4_warning(inode->i_sb, "I/O error %d writing to inode %lu "
+		ext4_warning(inode_sb(inode),
+			     "I/O error %d writing to inode %lu "
 			     "(offset %llu size %ld starting block %llu)",
 			     bio->bi_status, inode->i_ino,
 			     (unsigned long long) io_end->offset,
diff --git a/fs/ext4/readpage.c b/fs/ext4/readpage.c
index 9ffa6fad18db..7cfb7bd0fe1d 100644
--- a/fs/ext4/readpage.c
+++ b/fs/ext4/readpage.c
@@ -112,7 +112,7 @@ int ext4_mpage_readpages(struct address_space *mapping,
 	sector_t last_block_in_file;
 	sector_t blocks[MAX_BUF_PER_PAGE];
 	unsigned page_block;
-	struct block_device *bdev = inode->i_sb->s_bdev;
+	struct block_device *bdev = inode_sb(inode)->s_bdev;
 	int length;
 	unsigned relative_block = 0;
 	struct ext4_map_blocks map;
diff --git a/fs/ext4/resize.c b/fs/ext4/resize.c
index b6bec270a8e4..c1cf292c62fc 100644
--- a/fs/ext4/resize.c
+++ b/fs/ext4/resize.c
@@ -776,7 +776,7 @@ static int verify_reserved_gdb(struct super_block *sb,
 static int add_new_gdb(handle_t *handle, struct inode *inode,
 		       ext4_group_t group)
 {
-	struct super_block *sb = inode->i_sb;
+	struct super_block *sb = inode_sb(inode);
 	struct ext4_super_block *es = EXT4_SB(sb)->s_es;
 	unsigned long gdb_num = group / EXT4_DESC_PER_BLOCK(sb);
 	ext4_fsblk_t gdblock = EXT4_SB(sb)->s_sbh->b_blocknr + 1 + gdb_num;
@@ -957,7 +957,7 @@ static int add_new_gdb_meta_bg(struct super_block *sb,
 static int reserve_backup_gdb(handle_t *handle, struct inode *inode,
 			      ext4_group_t group)
 {
-	struct super_block *sb = inode->i_sb;
+	struct super_block *sb = inode_sb(inode);
 	int reserved_gdb =le16_to_cpu(EXT4_SB(sb)->s_es->s_reserved_gdt_blocks);
 	int cluster_bits = EXT4_SB(sb)->s_cluster_bits;
 	struct buffer_head **primary;
diff --git a/fs/ext4/super.c b/fs/ext4/super.c
index 39bf464c35f1..144095b55900 100644
--- a/fs/ext4/super.c
+++ b/fs/ext4/super.c
@@ -467,31 +467,33 @@ void __ext4_error_inode(struct inode *inode, const char *function,
 {
 	va_list args;
 	struct va_format vaf;
-	struct ext4_super_block *es = EXT4_SB(inode->i_sb)->s_es;
+	struct ext4_super_block *es = EXT4_SB(inode_sb(inode))->s_es;
 
-	if (unlikely(ext4_forced_shutdown(EXT4_SB(inode->i_sb))))
+	if (unlikely(ext4_forced_shutdown(EXT4_SB(inode_sb(inode)))))
 		return;
 
 	es->s_last_error_ino = cpu_to_le32(inode->i_ino);
 	es->s_last_error_block = cpu_to_le64(block);
-	if (ext4_error_ratelimit(inode->i_sb)) {
+	if (ext4_error_ratelimit(inode_sb(inode))) {
 		va_start(args, fmt);
 		vaf.fmt = fmt;
 		vaf.va = &args;
 		if (block)
 			printk(KERN_CRIT "EXT4-fs error (device %s): %s:%d: "
 			       "inode #%lu: block %llu: comm %s: %pV\n",
-			       inode->i_sb->s_id, function, line, inode->i_ino,
+			       inode_sb(inode)->s_id, function, line,
+			       inode->i_ino,
 			       block, current->comm, &vaf);
 		else
 			printk(KERN_CRIT "EXT4-fs error (device %s): %s:%d: "
 			       "inode #%lu: comm %s: %pV\n",
-			       inode->i_sb->s_id, function, line, inode->i_ino,
+			       inode_sb(inode)->s_id, function, line,
+			       inode->i_ino,
 			       current->comm, &vaf);
 		va_end(args);
 	}
-	save_error_info(inode->i_sb, function, line);
-	ext4_handle_error(inode->i_sb);
+	save_error_info(inode_sb(inode), function, line);
+	ext4_handle_error(inode_sb(inode));
 }
 
 void __ext4_error_file(struct file *file, const char *function,
@@ -504,12 +506,12 @@ void __ext4_error_file(struct file *file, const char *function,
 	struct inode *inode = file_inode(file);
 	char pathname[80], *path;
 
-	if (unlikely(ext4_forced_shutdown(EXT4_SB(inode->i_sb))))
+	if (unlikely(ext4_forced_shutdown(EXT4_SB(inode_sb(inode)))))
 		return;
 
-	es = EXT4_SB(inode->i_sb)->s_es;
+	es = EXT4_SB(inode_sb(inode))->s_es;
 	es->s_last_error_ino = cpu_to_le32(inode->i_ino);
-	if (ext4_error_ratelimit(inode->i_sb)) {
+	if (ext4_error_ratelimit(inode_sb(inode))) {
 		path = file_path(file, pathname, sizeof(pathname));
 		if (IS_ERR(path))
 			path = "(unknown)";
@@ -520,18 +522,20 @@ void __ext4_error_file(struct file *file, const char *function,
 			printk(KERN_CRIT
 			       "EXT4-fs error (device %s): %s:%d: inode #%lu: "
 			       "block %llu: comm %s: path %s: %pV\n",
-			       inode->i_sb->s_id, function, line, inode->i_ino,
+			       inode_sb(inode)->s_id, function, line,
+			       inode->i_ino,
 			       block, current->comm, path, &vaf);
 		else
 			printk(KERN_CRIT
 			       "EXT4-fs error (device %s): %s:%d: inode #%lu: "
 			       "comm %s: path %s: %pV\n",
-			       inode->i_sb->s_id, function, line, inode->i_ino,
+			       inode_sb(inode)->s_id, function, line,
+			       inode->i_ino,
 			       current->comm, path, &vaf);
 		va_end(args);
 	}
-	save_error_info(inode->i_sb, function, line);
-	ext4_handle_error(inode->i_sb);
+	save_error_info(inode_sb(inode), function, line);
+	ext4_handle_error(inode_sb(inode));
 }
 
 const char *ext4_decode_error(struct super_block *sb, int errno,
@@ -693,14 +697,14 @@ void __ext4_warning_inode(const struct inode *inode, const char *function,
 	struct va_format vaf;
 	va_list args;
 
-	if (!ext4_warning_ratelimit(inode->i_sb))
+	if (!ext4_warning_ratelimit(inode_sb(inode)))
 		return;
 
 	va_start(args, fmt);
 	vaf.fmt = fmt;
 	vaf.va = &args;
 	printk(KERN_WARNING "EXT4-fs warning (device %s): %s:%d: "
-	       "inode #%lu: comm %s: %pV\n", inode->i_sb->s_id,
+	       "inode #%lu: comm %s: %pV\n", inode_sb(inode)->s_id,
 	       function, line, inode->i_ino, current->comm, &vaf);
 	va_end(args);
 }
@@ -840,7 +844,7 @@ static void dump_orphan_list(struct super_block *sb, struct ext4_sb_info *sbi)
 		struct inode *inode = orphan_list_entry(l);
 		printk(KERN_ERR "  "
 		       "inode %s:%lu at %p: mode %o, nlink %d, next %d\n",
-		       inode->i_sb->s_id, inode->i_ino, inode,
+		       inode_sb(inode)->s_id, inode->i_ino, inode,
 		       inode->i_mode, inode->i_nlink,
 		       NEXT_ORPHAN(inode));
 	}
@@ -1014,7 +1018,7 @@ static void ext4_i_callback(struct rcu_head *head)
 static void ext4_destroy_inode(struct inode *inode)
 {
 	if (!list_empty(&(EXT4_I(inode)->i_orphan))) {
-		ext4_msg(inode->i_sb, KERN_ERR,
+		ext4_msg(inode_sb(inode), KERN_ERR,
 			 "Inode %lu (%p): orphan list check failed!",
 			 inode->i_ino, EXT4_I(inode));
 		print_hex_dump(KERN_INFO, "", DUMP_PREFIX_ADDRESS, 16, 4,
@@ -1223,7 +1227,7 @@ static int ext4_set_context(struct inode *inode, const void *ctx, size_t len,
 	}
 	res2 = ext4_journal_stop(handle);
 
-	if (res == -ENOSPC && ext4_should_retry_alloc(inode->i_sb, &retries))
+	if (res == -ENOSPC && ext4_should_retry_alloc(inode_sb(inode), &retries))
 		goto retry;
 	if (!res)
 		res = res2;
@@ -1232,13 +1236,13 @@ static int ext4_set_context(struct inode *inode, const void *ctx, size_t len,
 
 static bool ext4_dummy_context(struct inode *inode)
 {
-	return DUMMY_ENCRYPTION_ENABLED(EXT4_SB(inode->i_sb));
+	return DUMMY_ENCRYPTION_ENABLED(EXT4_SB(inode_sb(inode)));
 }
 
 static unsigned ext4_max_namelen(struct inode *inode)
 {
-	return S_ISLNK(inode->i_mode) ? inode->i_sb->s_blocksize :
-		EXT4_NAME_LEN;
+	return S_ISLNK(inode->i_mode) ? inode_sb(inode)->s_blocksize :
+			EXT4_NAME_LEN;
 }
 
 static const struct fscrypt_operations ext4_cryptops = {
@@ -2509,7 +2513,7 @@ static void ext4_orphan_cleanup(struct super_block *sb,
 			truncate_inode_pages(inode->i_mapping, inode->i_size);
 			ret = ext4_truncate(inode);
 			if (ret)
-				ext4_std_error(inode->i_sb, ret);
+				ext4_std_error(inode_sb(inode), ret);
 			inode_unlock(inode);
 			nr_truncates++;
 		} else {
@@ -5674,7 +5678,7 @@ static ssize_t ext4_quota_write(struct super_block *sb, int type,
 				EXT4_GET_BLOCKS_CREATE |
 				EXT4_GET_BLOCKS_METADATA_NOFAIL);
 	} while (IS_ERR(bh) && (PTR_ERR(bh) == -ENOSPC) &&
-		 ext4_should_retry_alloc(inode->i_sb, &retries));
+		 ext4_should_retry_alloc(inode_sb(inode), &retries));
 	if (IS_ERR(bh))
 		return PTR_ERR(bh);
 	if (!bh)
diff --git a/fs/ext4/symlink.c b/fs/ext4/symlink.c
index dd05af983092..bae9b69192e9 100644
--- a/fs/ext4/symlink.c
+++ b/fs/ext4/symlink.c
@@ -43,7 +43,7 @@ static const char *ext4_encrypted_get_link(struct dentry *dentry,
 		if (IS_ERR(cpage))
 			return ERR_CAST(cpage);
 		caddr = page_address(cpage);
-		max_size = inode->i_sb->s_blocksize;
+		max_size = inode_sb(inode)->s_blocksize;
 	}
 
 	paddr = fscrypt_get_symlink(inode, caddr, max_size, done);
diff --git a/fs/ext4/sysfs.c b/fs/ext4/sysfs.c
index 1205261f130c..d36b4f0a3bf7 100644
--- a/fs/ext4/sysfs.c
+++ b/fs/ext4/sysfs.c
@@ -52,7 +52,7 @@ struct ext4_attr {
 static ssize_t session_write_kbytes_show(struct ext4_attr *a,
 					 struct ext4_sb_info *sbi, char *buf)
 {
-	struct super_block *sb = sbi->s_buddy_cache->i_sb;
+	struct super_block *sb = inode_sb(sbi->s_buddy_cache);
 
 	if (!sb->s_bdev->bd_part)
 		return snprintf(buf, PAGE_SIZE, "0\n");
@@ -64,7 +64,7 @@ static ssize_t session_write_kbytes_show(struct ext4_attr *a,
 static ssize_t lifetime_write_kbytes_show(struct ext4_attr *a,
 					  struct ext4_sb_info *sbi, char *buf)
 {
-	struct super_block *sb = sbi->s_buddy_cache->i_sb;
+	struct super_block *sb = inode_sb(sbi->s_buddy_cache);
 
 	if (!sb->s_bdev->bd_part)
 		return snprintf(buf, PAGE_SIZE, "0\n");
diff --git a/fs/ext4/truncate.h b/fs/ext4/truncate.h
index 0cb13badf473..aa73c6ec827b 100644
--- a/fs/ext4/truncate.h
+++ b/fs/ext4/truncate.h
@@ -25,7 +25,7 @@ static inline unsigned long ext4_blocks_for_truncate(struct inode *inode)
 {
 	ext4_lblk_t needed;
 
-	needed = inode->i_blocks >> (inode->i_sb->s_blocksize_bits - 9);
+	needed = inode->i_blocks >> (inode_sb(inode)->s_blocksize_bits - 9);
 
 	/* Give ourselves just enough room to cope with inodes in which
 	 * i_blocks is corrupt: we've seen disk corruptions in the past
@@ -41,6 +41,6 @@ static inline unsigned long ext4_blocks_for_truncate(struct inode *inode)
 	if (needed > EXT4_MAX_TRANS_DATA)
 		needed = EXT4_MAX_TRANS_DATA;
 
-	return EXT4_DATA_TRANS_BLOCKS(inode->i_sb) + needed;
+	return EXT4_DATA_TRANS_BLOCKS(inode_sb(inode)) + needed;
 }
 
diff --git a/fs/ext4/xattr.c b/fs/ext4/xattr.c
index 63656dbafdc4..26211c1db4cc 100644
--- a/fs/ext4/xattr.c
+++ b/fs/ext4/xattr.c
@@ -65,7 +65,8 @@
 #ifdef EXT4_XATTR_DEBUG
 # define ea_idebug(inode, fmt, ...)					\
 	printk(KERN_DEBUG "inode %s:%lu: " fmt "\n",			\
-	       inode->i_sb->s_id, inode->i_ino, ##__VA_ARGS__)
+	       inode_sb(inode)->s_id, inode->i_ino,
+	       ##__VA_ARGS__)
 # define ea_bdebug(bh, fmt, ...)					\
 	printk(KERN_DEBUG "block %pg:%lu: " fmt "\n",			\
 	       bh->b_bdev, (unsigned long)bh->b_blocknr, ##__VA_ARGS__)
@@ -109,10 +110,10 @@ const struct xattr_handler *ext4_xattr_handlers[] = {
 };
 
 #define EA_BLOCK_CACHE(inode)	(((struct ext4_sb_info *) \
-				inode->i_sb->s_fs_info)->s_ea_block_cache)
+				inode_sb(inode)->s_fs_info)->s_ea_block_cache)
 
 #define EA_INODE_CACHE(inode)	(((struct ext4_sb_info *) \
-				inode->i_sb->s_fs_info)->s_ea_inode_cache)
+				inode_sb(inode)->s_fs_info)->s_ea_inode_cache)
 
 static int
 ext4_expand_inode_array(struct ext4_xattr_inode_array **ea_inode_array,
@@ -129,7 +130,7 @@ static __le32 ext4_xattr_block_csum(struct inode *inode,
 				    sector_t block_nr,
 				    struct ext4_xattr_header *hdr)
 {
-	struct ext4_sb_info *sbi = EXT4_SB(inode->i_sb);
+	struct ext4_sb_info *sbi = EXT4_SB(inode_sb(inode));
 	__u32 csum;
 	__le64 dsk_block_nr = cpu_to_le64(block_nr);
 	__u32 dummy_csum = 0;
@@ -141,7 +142,7 @@ static __le32 ext4_xattr_block_csum(struct inode *inode,
 	csum = ext4_chksum(sbi, csum, (__u8 *)&dummy_csum, sizeof(dummy_csum));
 	offset += sizeof(dummy_csum);
 	csum = ext4_chksum(sbi, csum, (__u8 *)hdr + offset,
-			   EXT4_BLOCK_SIZE(inode->i_sb) - offset);
+			   EXT4_BLOCK_SIZE(inode_sb(inode)) - offset);
 
 	return cpu_to_le32(csum);
 }
@@ -152,7 +153,7 @@ static int ext4_xattr_block_csum_verify(struct inode *inode,
 	struct ext4_xattr_header *hdr = BHDR(bh);
 	int ret = 1;
 
-	if (ext4_has_metadata_csum(inode->i_sb)) {
+	if (ext4_has_metadata_csum(inode_sb(inode))) {
 		lock_buffer(bh);
 		ret = (hdr->h_checksum == ext4_xattr_block_csum(inode,
 							bh->b_blocknr, hdr));
@@ -164,7 +165,7 @@ static int ext4_xattr_block_csum_verify(struct inode *inode,
 static void ext4_xattr_block_csum_set(struct inode *inode,
 				      struct buffer_head *bh)
 {
-	if (ext4_has_metadata_csum(inode->i_sb))
+	if (ext4_has_metadata_csum(inode_sb(inode)))
 		BHDR(bh)->h_checksum = ext4_xattr_block_csum(inode,
 						bh->b_blocknr, BHDR(bh));
 }
@@ -364,17 +365,17 @@ static int ext4_xattr_inode_iget(struct inode *parent, unsigned long ea_ino,
 	struct inode *inode;
 	int err;
 
-	inode = ext4_iget(parent->i_sb, ea_ino);
+	inode = ext4_iget(inode_sb(parent), ea_ino);
 	if (IS_ERR(inode)) {
 		err = PTR_ERR(inode);
-		ext4_error(parent->i_sb,
+		ext4_error(inode_sb(parent),
 			   "error while reading EA inode %lu err=%d", ea_ino,
 			   err);
 		return err;
 	}
 
 	if (is_bad_inode(inode)) {
-		ext4_error(parent->i_sb,
+		ext4_error(inode_sb(parent),
 			   "error while reading EA inode %lu is_bad_inode",
 			   ea_ino);
 		err = -EIO;
@@ -382,7 +383,7 @@ static int ext4_xattr_inode_iget(struct inode *parent, unsigned long ea_ino,
 	}
 
 	if (!(EXT4_I(inode)->i_flags & EXT4_EA_INODE_FL)) {
-		ext4_error(parent->i_sb,
+		ext4_error(inode_sb(parent),
 			   "EA inode %lu does not have EXT4_EA_INODE_FL flag",
 			    ea_ino);
 		err = -EINVAL;
@@ -422,7 +423,8 @@ ext4_xattr_inode_verify_hashes(struct inode *ea_inode,
 	u32 hash;
 
 	/* Verify stored hash matches calculated hash. */
-	hash = ext4_xattr_inode_hash(EXT4_SB(ea_inode->i_sb), buffer, size);
+	hash = ext4_xattr_inode_hash(EXT4_SB(inode_sb(ea_inode)), buffer,
+				     size);
 	if (hash != ext4_xattr_inode_get_hash(ea_inode))
 		return -EFSCORRUPTED;
 
@@ -506,7 +508,7 @@ ext4_xattr_block_get(struct inode *inode, int name_index, const char *name,
 		goto cleanup;
 	ea_idebug(inode, "reading block %llu",
 		  (unsigned long long)EXT4_I(inode)->i_file_acl);
-	bh = sb_bread(inode->i_sb, EXT4_I(inode)->i_file_acl);
+	bh = sb_bread(inode_sb(inode), EXT4_I(inode)->i_file_acl);
 	if (!bh)
 		goto cleanup;
 	ea_bdebug(bh, "b_count=%d, refcount=%d",
@@ -563,7 +565,7 @@ ext4_xattr_ibody_get(struct inode *inode, int name_index, const char *name,
 		return error;
 	raw_inode = ext4_raw_inode(&iloc);
 	header = IHDR(inode, raw_inode);
-	end = (void *)raw_inode + EXT4_SB(inode->i_sb)->s_inode_size;
+	end = (void *)raw_inode + EXT4_SB(inode_sb(inode))->s_inode_size;
 	error = xattr_check_inode(inode, header, end);
 	if (error)
 		goto cleanup;
@@ -609,7 +611,7 @@ ext4_xattr_get(struct inode *inode, int name_index, const char *name,
 {
 	int error;
 
-	if (unlikely(ext4_forced_shutdown(EXT4_SB(inode->i_sb))))
+	if (unlikely(ext4_forced_shutdown(EXT4_SB(inode_sb(inode)))))
 		return -EIO;
 
 	if (strlen(name) > 255)
@@ -670,7 +672,7 @@ ext4_xattr_block_list(struct dentry *dentry, char *buffer, size_t buffer_size)
 		goto cleanup;
 	ea_idebug(inode, "reading block %llu",
 		  (unsigned long long)EXT4_I(inode)->i_file_acl);
-	bh = sb_bread(inode->i_sb, EXT4_I(inode)->i_file_acl);
+	bh = sb_bread(inode_sb(inode), EXT4_I(inode)->i_file_acl);
 	error = -EIO;
 	if (!bh)
 		goto cleanup;
@@ -708,7 +710,7 @@ ext4_xattr_ibody_list(struct dentry *dentry, char *buffer, size_t buffer_size)
 		return error;
 	raw_inode = ext4_raw_inode(&iloc);
 	header = IHDR(inode, raw_inode);
-	end = (void *)raw_inode + EXT4_SB(inode->i_sb)->s_inode_size;
+	end = (void *)raw_inode + EXT4_SB(inode_sb(inode))->s_inode_size;
 	error = xattr_check_inode(inode, header, end);
 	if (error)
 		goto cleanup;
@@ -790,7 +792,7 @@ int ext4_get_inode_usage(struct inode *inode, qsize_t *usage)
 			goto out;
 		raw_inode = ext4_raw_inode(&iloc);
 		header = IHDR(inode, raw_inode);
-		end = (void *)raw_inode + EXT4_SB(inode->i_sb)->s_inode_size;
+		end = (void *)raw_inode + EXT4_SB(inode_sb(inode))->s_inode_size;
 		ret = xattr_check_inode(inode, header, end);
 		if (ret)
 			goto out;
@@ -802,7 +804,7 @@ int ext4_get_inode_usage(struct inode *inode, qsize_t *usage)
 	}
 
 	if (EXT4_I(inode)->i_file_acl) {
-		bh = sb_bread(inode->i_sb, EXT4_I(inode)->i_file_acl);
+		bh = sb_bread(inode_sb(inode), EXT4_I(inode)->i_file_acl);
 		if (!bh) {
 			ret = -EIO;
 			goto out;
@@ -828,7 +830,7 @@ int ext4_get_inode_usage(struct inode *inode, qsize_t *usage)
 
 static inline size_t round_up_cluster(struct inode *inode, size_t length)
 {
-	struct super_block *sb = inode->i_sb;
+	struct super_block *sb = inode_sb(inode);
 	size_t cluster_size = 1 << (EXT4_SB(sb)->s_cluster_bits +
 				    inode->i_blkbits);
 	size_t mask = ~(cluster_size - 1);
@@ -959,7 +961,8 @@ static int ext4_xattr_ensure_credits(handle_t *handle, struct inode *inode,
 	if (!error)
 		return 0;
 	if (error < 0) {
-		ext4_warning(inode->i_sb, "Extend journal (error %d)", error);
+		ext4_warning(inode_sb(inode), "Extend journal (error %d)",
+			     error);
 		return error;
 	}
 
@@ -968,7 +971,8 @@ static int ext4_xattr_ensure_credits(handle_t *handle, struct inode *inode,
 			ext4_xattr_block_csum_set(inode, bh);
 		error = ext4_handle_dirty_metadata(handle, NULL, bh);
 		if (error) {
-			ext4_warning(inode->i_sb, "Handle metadata (error %d)",
+			ext4_warning(inode_sb(inode),
+				     "Handle metadata (error %d)",
 				     error);
 			return error;
 		}
@@ -976,14 +980,15 @@ static int ext4_xattr_ensure_credits(handle_t *handle, struct inode *inode,
 
 	error = ext4_journal_restart(handle, credits);
 	if (error) {
-		ext4_warning(inode->i_sb, "Restart journal (error %d)", error);
+		ext4_warning(inode_sb(inode), "Restart journal (error %d)",
+			     error);
 		return error;
 	}
 
 	if (bh) {
 		error = ext4_journal_get_write_access(handle, bh);
 		if (error) {
-			ext4_warning(inode->i_sb,
+			ext4_warning(inode_sb(inode),
 				     "Get write access failed (error %d)",
 				     error);
 			return error;
@@ -1115,7 +1120,7 @@ static int ext4_xattr_inode_inc_ref_all(handle_t *handle, struct inode *parent,
 					    le32_to_cpu(entry->e_hash),
 					    &ea_inode);
 		if (err) {
-			ext4_warning(parent->i_sb,
+			ext4_warning(inode_sb(parent),
 				     "cleanup ea_ino %u iget error %d", ea_ino,
 				     err);
 			continue;
@@ -1244,7 +1249,7 @@ ext4_xattr_release_block(handle_t *handle, struct inode *inode,
 		get_bh(bh);
 		unlock_buffer(bh);
 
-		if (ext4_has_feature_ea_inode(inode->i_sb))
+		if (ext4_has_feature_ea_inode(inode_sb(inode)))
 			ext4_xattr_inode_dec_ref_all(handle, inode, bh,
 						     BFIRST(bh),
 						     true /* block_csum */,
@@ -1288,12 +1293,12 @@ ext4_xattr_release_block(handle_t *handle, struct inode *inode,
 			error = ext4_handle_dirty_metadata(handle, inode, bh);
 		if (IS_SYNC(inode))
 			ext4_handle_sync(handle);
-		dquot_free_block(inode, EXT4_C2B(EXT4_SB(inode->i_sb), 1));
+		dquot_free_block(inode, EXT4_C2B(EXT4_SB(inode_sb(inode)), 1));
 		ea_bdebug(bh, "refcount now=%d; releasing",
 			  le32_to_cpu(BHDR(bh)->h_refcount));
 	}
 out:
-	ext4_std_error(inode->i_sb, error);
+	ext4_std_error(inode_sb(inode), error);
 	return;
 }
 
@@ -1324,7 +1329,7 @@ static int ext4_xattr_inode_write(handle_t *handle, struct inode *ea_inode,
 {
 	struct buffer_head *bh = NULL;
 	unsigned long block = 0;
-	int blocksize = ea_inode->i_sb->s_blocksize;
+	int blocksize = inode_sb(ea_inode)->s_blocksize;
 	int max_blocks = (bufsize + blocksize - 1) >> ea_inode->i_blkbits;
 	int csize, wsize = 0;
 	int ret = 0;
@@ -1341,7 +1346,7 @@ static int ext4_xattr_inode_write(handle_t *handle, struct inode *ea_inode,
 		if (ret <= 0) {
 			ext4_mark_inode_dirty(handle, ea_inode);
 			if (ret == -ENOSPC &&
-			    ext4_should_retry_alloc(ea_inode->i_sb, &retries)) {
+			    ext4_should_retry_alloc(inode_sb(ea_inode), &retries)) {
 				ret = 0;
 				goto retry;
 			}
@@ -1401,7 +1406,7 @@ static struct inode *ext4_xattr_inode_create(handle_t *handle,
 	 * Let the next inode be the goal, so we try and allocate the EA inode
 	 * in the same group, or nearby one.
 	 */
-	ea_inode = ext4_new_inode(handle, inode->i_sb->s_root->d_inode,
+	ea_inode = ext4_new_inode(handle, inode_sb(inode)->s_root->d_inode,
 				  S_IFREG | 0600, NULL, inode->i_ino + 1, owner,
 				  EXT4_EA_INODE_FL);
 	if (!IS_ERR(ea_inode)) {
@@ -1457,7 +1462,7 @@ ext4_xattr_inode_cache_find(struct inode *inode, const void *value,
 	}
 
 	while (ce) {
-		ea_inode = ext4_iget(inode->i_sb, ce->e_value);
+		ea_inode = ext4_iget(inode_sb(inode), ce->e_value);
 		if (!IS_ERR(ea_inode) &&
 		    !is_bad_inode(ea_inode) &&
 		    (EXT4_I(ea_inode)->i_flags & EXT4_EA_INODE_FL) &&
@@ -1491,7 +1496,8 @@ static int ext4_xattr_inode_lookup_create(handle_t *handle, struct inode *inode,
 	u32 hash;
 	int err;
 
-	hash = ext4_xattr_inode_hash(EXT4_SB(inode->i_sb), value, value_len);
+	hash = ext4_xattr_inode_hash(EXT4_SB(inode_sb(inode)), value,
+				     value_len);
 	ea_inode = ext4_xattr_inode_cache_find(inode, value, value_len, hash);
 	if (ea_inode) {
 		err = ext4_xattr_inode_inc_ref(handle, ea_inode);
@@ -1597,7 +1603,7 @@ static int ext4_xattr_set_entry(struct ext4_xattr_info *i,
 		 * attribute block so that a long value does not occupy the
 		 * whole space and prevent futher entries being added.
 		 */
-		if (ext4_has_feature_ea_inode(inode->i_sb) &&
+		if (ext4_has_feature_ea_inode(inode_sb(inode)) &&
 		    new_size && is_block &&
 		    (min_offs + old_size - new_size) <
 					EXT4_XATTR_BLOCK_RESERVE(inode)) {
@@ -1778,7 +1784,7 @@ static int
 ext4_xattr_block_find(struct inode *inode, struct ext4_xattr_info *i,
 		      struct ext4_xattr_block_find *bs)
 {
-	struct super_block *sb = inode->i_sb;
+	struct super_block *sb = inode_sb(inode);
 	int error;
 
 	ea_idebug(inode, "name=%d.%s, value=%p, value_len=%ld",
@@ -1821,7 +1827,7 @@ ext4_xattr_block_set(handle_t *handle, struct inode *inode,
 		     struct ext4_xattr_info *i,
 		     struct ext4_xattr_block_find *bs)
 {
-	struct super_block *sb = inode->i_sb;
+	struct super_block *sb = inode_sb(inode);
 	struct buffer_head *new_bh = NULL;
 	struct ext4_xattr_search s_copy = bs->s;
 	struct ext4_xattr_search *s = &s_copy;
@@ -2158,7 +2164,7 @@ int ext4_xattr_ibody_find(struct inode *inode, struct ext4_xattr_info *i,
 	header = IHDR(inode, raw_inode);
 	is->s.base = is->s.first = IFIRST(header);
 	is->s.here = is->s.first;
-	is->s.end = (void *)raw_inode + EXT4_SB(inode->i_sb)->s_inode_size;
+	is->s.end = (void *)raw_inode + EXT4_SB(inode_sb(inode))->s_inode_size;
 	if (ext4_test_inode_state(inode, EXT4_STATE_XATTR)) {
 		error = xattr_check_inode(inode, header, is->s.end);
 		if (error)
@@ -2257,7 +2263,7 @@ static struct buffer_head *ext4_xattr_get_block(struct inode *inode)
 
 	if (!EXT4_I(inode)->i_file_acl)
 		return NULL;
-	bh = sb_bread(inode->i_sb, EXT4_I(inode)->i_file_acl);
+	bh = sb_bread(inode_sb(inode), EXT4_I(inode)->i_file_acl);
 	if (!bh)
 		return ERR_PTR(-EIO);
 	error = ext4_xattr_check_block(inode, bh);
@@ -2317,7 +2323,7 @@ ext4_xattr_set_handle(handle_t *handle, struct inode *inode, int name_index,
 			goto cleanup;
 		}
 
-		credits = __ext4_xattr_set_credits(inode->i_sb, inode, bh,
+		credits = __ext4_xattr_set_credits(inode_sb(inode), inode, bh,
 						   value_len,
 						   flags & XATTR_CREATE);
 		brelse(bh);
@@ -2334,7 +2340,7 @@ ext4_xattr_set_handle(handle_t *handle, struct inode *inode, int name_index,
 
 	if (ext4_test_inode_state(inode, EXT4_STATE_NEW)) {
 		struct ext4_inode *raw_inode = ext4_raw_inode(&is.iloc);
-		memset(raw_inode, 0, EXT4_SB(inode->i_sb)->s_inode_size);
+		memset(raw_inode, 0, EXT4_SB(inode_sb(inode))->s_inode_size);
 		ext4_clear_inode_state(inode, EXT4_STATE_NEW);
 	}
 
@@ -2371,9 +2377,9 @@ ext4_xattr_set_handle(handle_t *handle, struct inode *inode, int name_index,
 		if (!bs.s.not_found && ext4_xattr_value_same(&bs.s, &i))
 			goto cleanup;
 
-		if (ext4_has_feature_ea_inode(inode->i_sb) &&
+		if (ext4_has_feature_ea_inode(inode_sb(inode)) &&
 		    (EXT4_XATTR_SIZE(i.value_len) >
-			EXT4_XATTR_MIN_LARGE_EA_SIZE(inode->i_sb->s_blocksize)))
+			EXT4_XATTR_MIN_LARGE_EA_SIZE(inode_sb(inode)->s_blocksize)))
 			i.in_inode = 1;
 retry_inode:
 		error = ext4_xattr_ibody_set(handle, inode, &i, &is);
@@ -2396,7 +2402,7 @@ ext4_xattr_set_handle(handle_t *handle, struct inode *inode, int name_index,
 				 * Xattr does not fit in the block, store at
 				 * external inode if possible.
 				 */
-				if (ext4_has_feature_ea_inode(inode->i_sb) &&
+				if (ext4_has_feature_ea_inode(inode_sb(inode)) &&
 				    !i.in_inode) {
 					i.in_inode = 1;
 					goto retry_inode;
@@ -2405,7 +2411,7 @@ ext4_xattr_set_handle(handle_t *handle, struct inode *inode, int name_index,
 		}
 	}
 	if (!error) {
-		ext4_xattr_update_super_block(handle, inode->i_sb);
+		ext4_xattr_update_super_block(handle, inode_sb(inode));
 		inode->i_ctime = current_time(inode);
 		if (!value)
 			no_expand = 0;
@@ -2434,7 +2440,7 @@ int ext4_xattr_set_credits(struct inode *inode, size_t value_len,
 
 	*credits = 0;
 
-	if (!EXT4_SB(inode->i_sb)->s_journal)
+	if (!EXT4_SB(inode_sb(inode))->s_journal)
 		return 0;
 
 	down_read(&EXT4_I(inode)->xattr_sem);
@@ -2443,7 +2449,8 @@ int ext4_xattr_set_credits(struct inode *inode, size_t value_len,
 	if (IS_ERR(bh)) {
 		err = PTR_ERR(bh);
 	} else {
-		*credits = __ext4_xattr_set_credits(inode->i_sb, inode, bh,
+		*credits = __ext4_xattr_set_credits(inode_sb(inode), inode,
+						    bh,
 						    value_len, is_create);
 		brelse(bh);
 		err = 0;
@@ -2466,7 +2473,7 @@ ext4_xattr_set(struct inode *inode, int name_index, const char *name,
 	       const void *value, size_t value_len, int flags)
 {
 	handle_t *handle;
-	struct super_block *sb = inode->i_sb;
+	struct super_block *sb = inode_sb(inode);
 	int error, retries = 0;
 	int credits;
 
@@ -2677,7 +2684,7 @@ int ext4_expand_extra_isize_ea(struct inode *inode, int new_extra_isize,
 {
 	struct ext4_xattr_ibody_header *header;
 	struct buffer_head *bh;
-	struct ext4_sb_info *sbi = EXT4_SB(inode->i_sb);
+	struct ext4_sb_info *sbi = EXT4_SB(inode_sb(inode));
 	static unsigned int mnt_count;
 	size_t min_offs;
 	size_t ifree, bfree;
@@ -2700,7 +2707,7 @@ int ext4_expand_extra_isize_ea(struct inode *inode, int new_extra_isize,
 	 */
 
 	base = IFIRST(header);
-	end = (void *)raw_inode + EXT4_SB(inode->i_sb)->s_inode_size;
+	end = (void *)raw_inode + EXT4_SB(inode_sb(inode))->s_inode_size;
 	min_offs = end - base;
 	total_ino = sizeof(struct ext4_xattr_ibody_header);
 
@@ -2717,7 +2724,7 @@ int ext4_expand_extra_isize_ea(struct inode *inode, int new_extra_isize,
 	 * EA block can hold new_extra_isize bytes.
 	 */
 	if (EXT4_I(inode)->i_file_acl) {
-		bh = sb_bread(inode->i_sb, EXT4_I(inode)->i_file_acl);
+		bh = sb_bread(inode_sb(inode), EXT4_I(inode)->i_file_acl);
 		error = -EIO;
 		if (!bh)
 			goto cleanup;
@@ -2744,7 +2751,7 @@ int ext4_expand_extra_isize_ea(struct inode *inode, int new_extra_isize,
 			goto cleanup;
 		}
 	} else {
-		bfree = inode->i_sb->s_blocksize;
+		bfree = inode_sb(inode)->s_blocksize;
 	}
 
 	error = ext4_xattr_make_inode_space(handle, inode, raw_inode,
@@ -2769,7 +2776,8 @@ int ext4_expand_extra_isize_ea(struct inode *inode, int new_extra_isize,
 
 cleanup:
 	if (error && (mnt_count != le16_to_cpu(sbi->s_es->s_mnt_count))) {
-		ext4_warning(inode->i_sb, "Unable to expand inode %lu. Delete some EAs or run e2fsck.",
+		ext4_warning(inode_sb(inode),
+			     "Unable to expand inode %lu. Delete some EAs or run e2fsck.",
 			     inode->i_ino);
 		mnt_count = le16_to_cpu(sbi->s_es->s_mnt_count);
 	}
@@ -2849,7 +2857,7 @@ int ext4_xattr_delete_inode(handle_t *handle, struct inode *inode,
 		goto cleanup;
 	}
 
-	if (ext4_has_feature_ea_inode(inode->i_sb) &&
+	if (ext4_has_feature_ea_inode(inode_sb(inode)) &&
 	    ext4_test_inode_state(inode, EXT4_STATE_XATTR)) {
 
 		error = ext4_get_inode_loc(inode, &iloc);
@@ -2876,7 +2884,7 @@ int ext4_xattr_delete_inode(handle_t *handle, struct inode *inode,
 	}
 
 	if (EXT4_I(inode)->i_file_acl) {
-		bh = sb_bread(inode->i_sb, EXT4_I(inode)->i_file_acl);
+		bh = sb_bread(inode_sb(inode), EXT4_I(inode)->i_file_acl);
 		if (!bh) {
 			EXT4_ERROR_INODE(inode, "block %llu read error",
 					 EXT4_I(inode)->i_file_acl);
@@ -2890,7 +2898,7 @@ int ext4_xattr_delete_inode(handle_t *handle, struct inode *inode,
 			goto cleanup;
 		}
 
-		if (ext4_has_feature_ea_inode(inode->i_sb)) {
+		if (ext4_has_feature_ea_inode(inode_sb(inode))) {
 			for (entry = BFIRST(bh); !IS_LAST_ENTRY(entry);
 			     entry = EXT4_XATTR_NEXT(entry)) {
 				if (!entry->e_value_inum)
@@ -3036,7 +3044,7 @@ ext4_xattr_block_cache_find(struct inode *inode,
 	while (ce) {
 		struct buffer_head *bh;
 
-		bh = sb_bread(inode->i_sb, ce->e_value);
+		bh = sb_bread(inode_sb(inode), ce->e_value);
 		if (!bh) {
 			EXT4_ERROR_INODE(inode, "block %lu read error",
 					 (unsigned long)ce->e_value);
diff --git a/fs/ext4/xattr_user.c b/fs/ext4/xattr_user.c
index d4546184b34b..d2d0b8d2c871 100644
--- a/fs/ext4/xattr_user.c
+++ b/fs/ext4/xattr_user.c
@@ -23,7 +23,7 @@ ext4_xattr_user_get(const struct xattr_handler *handler,
 		    struct dentry *unused, struct inode *inode,
 		    const char *name, void *buffer, size_t size)
 {
-	if (!test_opt(inode->i_sb, XATTR_USER))
+	if (!test_opt(inode_sb(inode), XATTR_USER))
 		return -EOPNOTSUPP;
 	return ext4_xattr_get(inode, EXT4_XATTR_INDEX_USER,
 			      name, buffer, size);
@@ -35,7 +35,7 @@ ext4_xattr_user_set(const struct xattr_handler *handler,
 		    const char *name, const void *value,
 		    size_t size, int flags)
 {
-	if (!test_opt(inode->i_sb, XATTR_USER))
+	if (!test_opt(inode_sb(inode), XATTR_USER))
 		return -EOPNOTSUPP;
 	return ext4_xattr_set(inode, EXT4_XATTR_INDEX_USER,
 			      name, value, size, flags);
-- 
2.15.1

^ permalink raw reply	[flat|nested] 88+ messages in thread

* [PATCH 32/76] fs/f2fs: Use inode_sb() helper instead of inode->i_sb
  2018-05-08 18:03 [RFC][PATCH 0/76] vfs: 'views' for filesystems with more than one root Mark Fasheh
                   ` (30 preceding siblings ...)
  2018-05-08 18:03 ` [PATCH 31/76] fs/ext4: " Mark Fasheh
@ 2018-05-08 18:03 ` Mark Fasheh
  2018-05-10 10:10   ` Chao Yu
  2018-05-08 18:03 ` [PATCH 33/76] fs/fat: " Mark Fasheh
                   ` (44 subsequent siblings)
  76 siblings, 1 reply; 88+ messages in thread
From: Mark Fasheh @ 2018-05-08 18:03 UTC (permalink / raw)
  To: linux-fsdevel; +Cc: linux-kernel, linux-btrfs, Mark Fasheh

Signed-off-by: Mark Fasheh <mfasheh@suse.de>
---
 fs/f2fs/data.c     |  6 +++---
 fs/f2fs/f2fs.h     |  2 +-
 fs/f2fs/file.c     | 36 ++++++++++++++++++------------------
 fs/f2fs/inline.c   |  4 ++--
 fs/f2fs/inode.c    |  6 +++---
 fs/f2fs/namei.c    | 11 ++++++-----
 fs/f2fs/recovery.c | 11 ++++++-----
 fs/f2fs/super.c    |  6 +++---
 fs/f2fs/trace.c    |  7 ++++---
 fs/f2fs/xattr.c    |  4 ++--
 10 files changed, 48 insertions(+), 45 deletions(-)

diff --git a/fs/f2fs/data.c b/fs/f2fs/data.c
index 7578ed1a85e0..f3e29f386f6e 100644
--- a/fs/f2fs/data.c
+++ b/fs/f2fs/data.c
@@ -1129,7 +1129,7 @@ static int __get_data_block(struct inode *inode, sector_t iblock,
 
 	err = f2fs_map_blocks(inode, &map, create, flag);
 	if (!err) {
-		map_bh(bh, inode->i_sb, map.m_pblk);
+		map_bh(bh, inode_sb(inode), map.m_pblk);
 		bh->b_state = (bh->b_state & ~F2FS_MAP_FLAGS) | map.m_flags;
 		bh->b_size = (u64)map.m_len << inode->i_blkbits;
 	}
@@ -1225,7 +1225,7 @@ static int f2fs_xattr_fiemap(struct inode *inode,
 		get_node_info(sbi, xnid, &ni);
 
 		phys = (__u64)blk_to_logical(inode, ni.blk_addr);
-		len = inode->i_sb->s_blocksize;
+		len = inode_sb(inode)->s_blocksize;
 
 		f2fs_put_page(page, 1);
 
@@ -2272,7 +2272,7 @@ static int f2fs_write_end(struct file *file,
 static int check_direct_IO(struct inode *inode, struct iov_iter *iter,
 			   loff_t offset)
 {
-	unsigned blocksize_mask = inode->i_sb->s_blocksize - 1;
+	unsigned blocksize_mask = inode_sb(inode)->s_blocksize - 1;
 
 	if (offset & blocksize_mask)
 		return -EINVAL;
diff --git a/fs/f2fs/f2fs.h b/fs/f2fs/f2fs.h
index 6300ac5bcbe4..504c84b68636 100644
--- a/fs/f2fs/f2fs.h
+++ b/fs/f2fs/f2fs.h
@@ -1331,7 +1331,7 @@ static inline struct f2fs_sb_info *F2FS_SB(struct super_block *sb)
 
 static inline struct f2fs_sb_info *F2FS_I_SB(struct inode *inode)
 {
-	return F2FS_SB(inode->i_sb);
+	return F2FS_SB(inode_sb(inode));
 }
 
 static inline struct f2fs_sb_info *F2FS_M_SB(struct address_space *mapping)
diff --git a/fs/f2fs/file.c b/fs/f2fs/file.c
index 672a542e5464..837333b9153d 100644
--- a/fs/f2fs/file.c
+++ b/fs/f2fs/file.c
@@ -58,7 +58,7 @@ static int f2fs_vm_page_mkwrite(struct vm_fault *vmf)
 		goto err;
 	}
 
-	sb_start_pagefault(inode->i_sb);
+	sb_start_pagefault(inode_sb(inode));
 
 	f2fs_bug_on(sbi, f2fs_has_inline_data(inode));
 
@@ -117,7 +117,7 @@ static int f2fs_vm_page_mkwrite(struct vm_fault *vmf)
 out_sem:
 	up_read(&F2FS_I(inode)->i_mmap_sem);
 out:
-	sb_end_pagefault(inode->i_sb);
+	sb_end_pagefault(inode_sb(inode));
 	f2fs_update_time(sbi, REQ_TIME);
 err:
 	return block_page_mkwrite_return(err);
@@ -211,7 +211,7 @@ static int f2fs_do_sync_file(struct file *file, loff_t start, loff_t end,
 		.for_reclaim = 0,
 	};
 
-	if (unlikely(f2fs_readonly(inode->i_sb)))
+	if (unlikely(f2fs_readonly(inode_sb(inode))))
 		return 0;
 
 	trace_f2fs_sync_file_enter(inode);
@@ -259,7 +259,7 @@ static int f2fs_do_sync_file(struct file *file, loff_t start, loff_t end,
 
 	if (cp_reason) {
 		/* all the dirty node pages should be flushed for POR */
-		ret = f2fs_sync_fs(inode->i_sb, 1);
+		ret = f2fs_sync_fs(inode_sb(inode), 1);
 
 		/*
 		 * We've secured consistency through sync_fs. Following pino
@@ -365,7 +365,7 @@ static bool __found_offset(block_t blkaddr, pgoff_t dirty, pgoff_t pgofs,
 static loff_t f2fs_seek_block(struct file *file, loff_t offset, int whence)
 {
 	struct inode *inode = file->f_mapping->host;
-	loff_t maxbytes = inode->i_sb->s_maxbytes;
+	loff_t maxbytes = inode_sb(inode)->s_maxbytes;
 	struct dnode_of_data dn;
 	pgoff_t pgofs, end_offset, dirty;
 	loff_t data_ofs = offset;
@@ -437,7 +437,7 @@ static loff_t f2fs_seek_block(struct file *file, loff_t offset, int whence)
 static loff_t f2fs_llseek(struct file *file, loff_t offset, int whence)
 {
 	struct inode *inode = file->f_mapping->host;
-	loff_t maxbytes = inode->i_sb->s_maxbytes;
+	loff_t maxbytes = inode_sb(inode)->s_maxbytes;
 
 	switch (whence) {
 	case SEEK_SET:
@@ -569,7 +569,7 @@ static int truncate_partial_data_page(struct inode *inode, u64 from,
 int truncate_blocks(struct inode *inode, u64 from, bool lock)
 {
 	struct f2fs_sb_info *sbi = F2FS_I_SB(inode);
-	unsigned int blocksize = inode->i_sb->s_blocksize;
+	unsigned int blocksize = inode_sb(inode)->s_blocksize;
 	struct dnode_of_data dn;
 	pgoff_t free_from;
 	int count = 0, err = 0;
@@ -676,7 +676,7 @@ int f2fs_getattr(const struct path *path, struct kstat *stat,
 	unsigned int flags;
 
 	if (f2fs_has_extra_attr(inode) &&
-			f2fs_sb_has_inode_crtime(inode->i_sb) &&
+			f2fs_sb_has_inode_crtime(inode_sb(inode)) &&
 			F2FS_FITS_IN_INODE(ri, fi->i_extra_isize, i_crtime)) {
 		stat->result_mask |= STATX_BTIME;
 		stat->btime.tv_sec = fi->i_crtime.tv_sec;
@@ -722,13 +722,13 @@ static void __setattr_copy(struct inode *inode, const struct iattr *attr)
 		inode->i_gid = attr->ia_gid;
 	if (ia_valid & ATTR_ATIME)
 		inode->i_atime = timespec_trunc(attr->ia_atime,
-						inode->i_sb->s_time_gran);
+						inode_sb(inode)->s_time_gran);
 	if (ia_valid & ATTR_MTIME)
 		inode->i_mtime = timespec_trunc(attr->ia_mtime,
-						inode->i_sb->s_time_gran);
+						inode_sb(inode)->s_time_gran);
 	if (ia_valid & ATTR_CTIME)
 		inode->i_ctime = timespec_trunc(attr->ia_ctime,
-						inode->i_sb->s_time_gran);
+						inode_sb(inode)->s_time_gran);
 	if (ia_valid & ATTR_MODE) {
 		umode_t mode = attr->ia_mode;
 
@@ -1891,7 +1891,7 @@ static int f2fs_ioc_shutdown(struct file *filp, unsigned long arg)
 static int f2fs_ioc_fitrim(struct file *filp, unsigned long arg)
 {
 	struct inode *inode = file_inode(filp);
-	struct super_block *sb = inode->i_sb;
+	struct super_block *sb = inode_sb(inode);
 	struct request_queue *q = bdev_get_queue(sb->s_bdev);
 	struct fstrim_range range;
 	int ret;
@@ -1938,7 +1938,7 @@ static int f2fs_ioc_set_encryption_policy(struct file *filp, unsigned long arg)
 {
 	struct inode *inode = file_inode(filp);
 
-	if (!f2fs_sb_has_crypto(inode->i_sb))
+	if (!f2fs_sb_has_crypto(inode_sb(inode)))
 		return -EOPNOTSUPP;
 
 	f2fs_update_time(F2FS_I_SB(inode), REQ_TIME);
@@ -1948,7 +1948,7 @@ static int f2fs_ioc_set_encryption_policy(struct file *filp, unsigned long arg)
 
 static int f2fs_ioc_get_encryption_policy(struct file *filp, unsigned long arg)
 {
-	if (!f2fs_sb_has_crypto(file_inode(filp)->i_sb))
+	if (!f2fs_sb_has_crypto(inode_sb(file_inode(filp))))
 		return -EOPNOTSUPP;
 	return fscrypt_ioctl_get_policy(filp, (void __user *)arg);
 }
@@ -1959,7 +1959,7 @@ static int f2fs_ioc_get_encryption_pwsalt(struct file *filp, unsigned long arg)
 	struct f2fs_sb_info *sbi = F2FS_I_SB(inode);
 	int err;
 
-	if (!f2fs_sb_has_crypto(inode->i_sb))
+	if (!f2fs_sb_has_crypto(inode_sb(inode)))
 		return -EOPNOTSUPP;
 
 	if (uuid_is_nonzero(sbi->raw_super->encrypt_pw_salt))
@@ -2290,10 +2290,10 @@ static int f2fs_move_file_range(struct file *file_in, loff_t pos_in,
 	int ret;
 
 	if (file_in->f_path.mnt != file_out->f_path.mnt ||
-				src->i_sb != dst->i_sb)
+				inode_sb(src) != inode_sb(dst))
 		return -EXDEV;
 
-	if (unlikely(f2fs_readonly(src->i_sb)))
+	if (unlikely(f2fs_readonly(inode_sb(src))))
 		return -EROFS;
 
 	if (!S_ISREG(src->i_mode) || !S_ISREG(dst->i_mode))
@@ -2644,7 +2644,7 @@ static int f2fs_ioc_fsgetxattr(struct file *filp, unsigned long arg)
 	fa.fsx_xflags = f2fs_iflags_to_xflags(fi->i_flags &
 				(FS_FL_USER_VISIBLE | FS_PROJINHERIT_FL));
 
-	if (f2fs_sb_has_project_quota(inode->i_sb))
+	if (f2fs_sb_has_project_quota(inode_sb(inode)))
 		fa.fsx_projid = (__u32)from_kprojid(&init_user_ns,
 							fi->i_projid);
 
diff --git a/fs/f2fs/inline.c b/fs/f2fs/inline.c
index 90e38d8ea688..eb8b1a085974 100644
--- a/fs/f2fs/inline.c
+++ b/fs/f2fs/inline.c
@@ -294,7 +294,7 @@ bool recover_inline_data(struct inode *inode, struct page *npage)
 struct f2fs_dir_entry *find_in_inline_dir(struct inode *dir,
 			struct fscrypt_name *fname, struct page **res_page)
 {
-	struct f2fs_sb_info *sbi = F2FS_SB(dir->i_sb);
+	struct f2fs_sb_info *sbi = F2FS_SB(inode_sb(dir));
 	struct qstr name = FSTR_TO_QSTR(&fname->disk_name);
 	struct f2fs_dir_entry *de;
 	struct f2fs_dentry_ptr d;
@@ -674,7 +674,7 @@ int f2fs_inline_data_fiemap(struct inode *inode,
 	ilen -= start;
 
 	get_node_info(F2FS_I_SB(inode), inode->i_ino, &ni);
-	byteaddr = (__u64)ni.blk_addr << inode->i_sb->s_blocksize_bits;
+	byteaddr = (__u64)ni.blk_addr << inode_sb(inode)->s_blocksize_bits;
 	byteaddr += (char *)inline_data_addr(inode, ipage) -
 					(char *)F2FS_INODE(ipage);
 	err = fiemap_fill_next_extent(fieinfo, start, byteaddr, ilen, flags);
diff --git a/fs/f2fs/inode.c b/fs/f2fs/inode.c
index 205add3d0f3a..4bc24cf161d3 100644
--- a/fs/f2fs/inode.c
+++ b/fs/f2fs/inode.c
@@ -195,7 +195,7 @@ static int do_read_inode(struct inode *inode)
 
 	/* Check if ino is within scope */
 	if (check_nid_range(sbi, inode->i_ino)) {
-		f2fs_msg(inode->i_sb, KERN_ERR, "bad inode number: %lu",
+		f2fs_msg(inode_sb(inode), KERN_ERR, "bad inode number: %lu",
 			 (unsigned long) inode->i_ino);
 		WARN_ON(1);
 		return -EINVAL;
@@ -522,7 +522,7 @@ void f2fs_evict_inode(struct inode *inode)
 	remove_ino_entry(sbi, inode->i_ino, UPDATE_INO);
 	remove_ino_entry(sbi, inode->i_ino, FLUSH_INO);
 
-	sb_start_intwrite(inode->i_sb);
+	sb_start_intwrite(inode_sb(inode));
 	set_inode_flag(inode, FI_NO_ALLOC);
 	i_size_write(inode, 0);
 retry:
@@ -552,7 +552,7 @@ void f2fs_evict_inode(struct inode *inode)
 	if (err)
 		update_inode_page(inode);
 	dquot_free_inode(inode);
-	sb_end_intwrite(inode->i_sb);
+	sb_end_intwrite(inode_sb(inode));
 no_delete:
 	dquot_drop(inode);
 
diff --git a/fs/f2fs/namei.c b/fs/f2fs/namei.c
index b68e7b03959f..17a171d258cb 100644
--- a/fs/f2fs/namei.c
+++ b/fs/f2fs/namei.c
@@ -32,7 +32,7 @@ static struct inode *f2fs_new_inode(struct inode *dir, umode_t mode)
 	int xattr_size = 0;
 	int err;
 
-	inode = new_inode(dir->i_sb);
+	inode = new_inode(inode_sb(dir));
 	if (!inode)
 		return ERR_PTR(-ENOMEM);
 
@@ -380,7 +380,7 @@ static struct dentry *f2fs_lookup(struct inode *dir, struct dentry *dentry,
 	f2fs_dentry_kunmap(dir, page);
 	f2fs_put_page(page, 0);
 
-	inode = f2fs_iget(dir->i_sb, ino);
+	inode = f2fs_iget(inode_sb(dir), ino);
 	if (IS_ERR(inode)) {
 		err = PTR_ERR(inode);
 		goto out;
@@ -400,7 +400,7 @@ static struct dentry *f2fs_lookup(struct inode *dir, struct dentry *dentry,
 	if (f2fs_encrypted_inode(dir) &&
 	    (S_ISDIR(inode->i_mode) || S_ISLNK(inode->i_mode)) &&
 	    !fscrypt_has_permitted_context(dir, inode)) {
-		f2fs_msg(inode->i_sb, KERN_WARNING,
+		f2fs_msg(inode_sb(inode), KERN_WARNING,
 			 "Inconsistent encryption contexts: %lu/%lu",
 			 dir->i_ino, inode->i_ino);
 		err = -EPERM;
@@ -492,7 +492,8 @@ static int f2fs_symlink(struct inode *dir, struct dentry *dentry,
 	if (unlikely(f2fs_cp_error(sbi)))
 		return -EIO;
 
-	err = fscrypt_prepare_symlink(dir, symname, len, dir->i_sb->s_blocksize,
+	err = fscrypt_prepare_symlink(dir, symname, len,
+				      inode_sb(dir)->s_blocksize,
 				      &disk_link);
 	if (err)
 		return err;
@@ -1125,7 +1126,7 @@ static const char *f2fs_encrypted_get_link(struct dentry *dentry,
 		return ERR_CAST(page);
 
 	target = fscrypt_get_symlink(inode, page_address(page),
-				     inode->i_sb->s_blocksize, done);
+				     inode_sb(inode)->s_blocksize, done);
 	put_page(page);
 	return target;
 }
diff --git a/fs/f2fs/recovery.c b/fs/f2fs/recovery.c
index 337f3363f48f..060d8259224d 100644
--- a/fs/f2fs/recovery.c
+++ b/fs/f2fs/recovery.c
@@ -147,7 +147,8 @@ static int recover_dentry(struct inode *inode, struct page *ipage,
 		goto out_unmap_put;
 
 	if (de) {
-		einode = f2fs_iget_retry(inode->i_sb, le32_to_cpu(de->ino));
+		einode = f2fs_iget_retry(inode_sb(inode),
+					 le32_to_cpu(de->ino));
 		if (IS_ERR(einode)) {
 			WARN_ON(1);
 			err = PTR_ERR(einode);
@@ -188,7 +189,7 @@ static int recover_dentry(struct inode *inode, struct page *ipage,
 		name = "<encrypted>";
 	else
 		name = raw_inode->i_name;
-	f2fs_msg(inode->i_sb, KERN_NOTICE,
+	f2fs_msg(inode_sb(inode), KERN_NOTICE,
 			"%s: ino = %x, name = %s, dir = %lx, err = %d",
 			__func__, ino_of_node(ipage), name,
 			IS_ERR(dir) ? 0 : dir->i_ino, err);
@@ -232,9 +233,9 @@ static void recover_inode(struct inode *inode, struct page *page)
 	else
 		name = F2FS_INODE(page)->i_name;
 
-	f2fs_msg(inode->i_sb, KERN_NOTICE,
-		"recover_inode: ino = %x, name = %s, inline = %x",
-			ino_of_node(page), name, raw->i_inline);
+	f2fs_msg(inode_sb(inode), KERN_NOTICE,
+		 "recover_inode: ino = %x, name = %s, inline = %x",
+		 ino_of_node(page), name, raw->i_inline);
 }
 
 static int find_fsync_dnodes(struct f2fs_sb_info *sbi, struct list_head *head,
diff --git a/fs/f2fs/super.c b/fs/f2fs/super.c
index 8173ae688814..76cc211194c8 100644
--- a/fs/f2fs/super.c
+++ b/fs/f2fs/super.c
@@ -776,13 +776,13 @@ static int f2fs_drop_inode(struct inode *inode)
 			/* should remain fi->extent_tree for writepage */
 			f2fs_destroy_extent_node(inode);
 
-			sb_start_intwrite(inode->i_sb);
+			sb_start_intwrite(inode_sb(inode));
 			f2fs_i_size_write(inode, 0);
 
 			if (F2FS_HAS_BLOCKS(inode))
 				f2fs_truncate(inode);
 
-			sb_end_intwrite(inode->i_sb);
+			sb_end_intwrite(inode_sb(inode));
 
 			spin_lock(&inode->i_lock);
 			atomic_dec(&inode->i_count);
@@ -1805,7 +1805,7 @@ static int f2fs_set_context(struct inode *inode, const void *ctx, size_t len,
 static unsigned f2fs_max_namelen(struct inode *inode)
 {
 	return S_ISLNK(inode->i_mode) ?
-			inode->i_sb->s_blocksize : F2FS_NAME_LEN;
+			inode_sb(inode)->s_blocksize : F2FS_NAME_LEN;
 }
 
 static const struct fscrypt_operations f2fs_cryptops = {
diff --git a/fs/f2fs/trace.c b/fs/f2fs/trace.c
index a1fcd00bbb2b..235a3bca1f5f 100644
--- a/fs/f2fs/trace.c
+++ b/fs/f2fs/trace.c
@@ -74,7 +74,8 @@ void f2fs_trace_pid(struct page *page)
 	f2fs_radix_tree_insert(&pids, pid, current);
 
 	trace_printk("%3x:%3x %4x %-16s\n",
-			MAJOR(inode->i_sb->s_dev), MINOR(inode->i_sb->s_dev),
+			MAJOR(inode_sb(inode)->s_dev),
+			MINOR(inode_sb(inode)->s_dev),
 			pid, current->comm);
 out:
 	mutex_unlock(&pids_lock);
@@ -95,8 +96,8 @@ void f2fs_trace_ios(struct f2fs_io_info *fio, int flush)
 	inode = fio->page->mapping->host;
 	pid = page_private(fio->page);
 
-	major = MAJOR(inode->i_sb->s_dev);
-	minor = MINOR(inode->i_sb->s_dev);
+	major = MAJOR(inode_sb(inode)->s_dev);
+	minor = MINOR(inode_sb(inode)->s_dev);
 
 	if (last_io.major == major && last_io.minor == minor &&
 			last_io.pid == pid &&
diff --git a/fs/f2fs/xattr.c b/fs/f2fs/xattr.c
index ae2dfa709f5d..9d445f4f5d8b 100644
--- a/fs/f2fs/xattr.c
+++ b/fs/f2fs/xattr.c
@@ -29,7 +29,7 @@ static int f2fs_xattr_generic_get(const struct xattr_handler *handler,
 		struct dentry *unused, struct inode *inode,
 		const char *name, void *buffer, size_t size)
 {
-	struct f2fs_sb_info *sbi = F2FS_SB(inode->i_sb);
+	struct f2fs_sb_info *sbi = F2FS_SB(inode_sb(inode));
 
 	switch (handler->flags) {
 	case F2FS_XATTR_INDEX_USER:
@@ -54,7 +54,7 @@ static int f2fs_xattr_generic_set(const struct xattr_handler *handler,
 		const char *name, const void *value,
 		size_t size, int flags)
 {
-	struct f2fs_sb_info *sbi = F2FS_SB(inode->i_sb);
+	struct f2fs_sb_info *sbi = F2FS_SB(inode_sb(inode));
 
 	switch (handler->flags) {
 	case F2FS_XATTR_INDEX_USER:
-- 
2.15.1

^ permalink raw reply	[flat|nested] 88+ messages in thread

* [PATCH 33/76] fs/fat: Use inode_sb() helper instead of inode->i_sb
  2018-05-08 18:03 [RFC][PATCH 0/76] vfs: 'views' for filesystems with more than one root Mark Fasheh
                   ` (31 preceding siblings ...)
  2018-05-08 18:03 ` [PATCH 32/76] fs/f2fs: " Mark Fasheh
@ 2018-05-08 18:03 ` Mark Fasheh
  2018-05-08 18:03 ` [PATCH 34/76] fs/freevxfs: " Mark Fasheh
                   ` (43 subsequent siblings)
  76 siblings, 0 replies; 88+ messages in thread
From: Mark Fasheh @ 2018-05-08 18:03 UTC (permalink / raw)
  To: linux-fsdevel; +Cc: linux-kernel, linux-btrfs, Mark Fasheh

Signed-off-by: Mark Fasheh <mfasheh@suse.de>
---
 fs/fat/cache.c       | 12 ++++++------
 fs/fat/dir.c         | 26 +++++++++++++-------------
 fs/fat/fat.h         |  2 +-
 fs/fat/fatent.c      | 10 +++++-----
 fs/fat/file.c        | 24 ++++++++++++------------
 fs/fat/inode.c       | 28 ++++++++++++++--------------
 fs/fat/misc.c        |  2 +-
 fs/fat/namei_msdos.c | 22 +++++++++++-----------
 fs/fat/namei_vfat.c  | 18 +++++++++---------
 fs/fat/nfs.c         |  4 ++--
 10 files changed, 74 insertions(+), 74 deletions(-)

diff --git a/fs/fat/cache.c b/fs/fat/cache.c
index e9bed49df6b7..bfe99b4a9ef8 100644
--- a/fs/fat/cache.c
+++ b/fs/fat/cache.c
@@ -224,7 +224,7 @@ static inline void cache_init(struct fat_cache_id *cid, int fclus, int dclus)
 
 int fat_get_cluster(struct inode *inode, int cluster, int *fclus, int *dclus)
 {
-	struct super_block *sb = inode->i_sb;
+	struct super_block *sb = inode_sb(inode);
 	const int limit = sb->s_maxbytes >> MSDOS_SB(sb)->cluster_bits;
 	struct fat_entry fatent;
 	struct fat_cache_id cid;
@@ -285,7 +285,7 @@ int fat_get_cluster(struct inode *inode, int cluster, int *fclus, int *dclus)
 
 static int fat_bmap_cluster(struct inode *inode, int cluster)
 {
-	struct super_block *sb = inode->i_sb;
+	struct super_block *sb = inode_sb(inode);
 	int ret, fclus, dclus;
 
 	if (MSDOS_I(inode)->i_start == 0)
@@ -306,7 +306,7 @@ int fat_get_mapped_cluster(struct inode *inode, sector_t sector,
 			   sector_t last_block,
 			   unsigned long *mapped_blocks, sector_t *bmap)
 {
-	struct super_block *sb = inode->i_sb;
+	struct super_block *sb = inode_sb(inode);
 	struct msdos_sb_info *sbi = MSDOS_SB(sb);
 	int cluster, offset;
 
@@ -328,7 +328,7 @@ int fat_get_mapped_cluster(struct inode *inode, sector_t sector,
 static int is_exceed_eof(struct inode *inode, sector_t sector,
 			 sector_t *last_block, int create)
 {
-	struct super_block *sb = inode->i_sb;
+	struct super_block *sb = inode_sb(inode);
 	const unsigned long blocksize = sb->s_blocksize;
 	const unsigned char blocksize_bits = sb->s_blocksize_bits;
 
@@ -353,7 +353,7 @@ static int is_exceed_eof(struct inode *inode, sector_t sector,
 int fat_bmap(struct inode *inode, sector_t sector, sector_t *phys,
 	     unsigned long *mapped_blocks, int create, bool from_bmap)
 {
-	struct msdos_sb_info *sbi = MSDOS_SB(inode->i_sb);
+	struct msdos_sb_info *sbi = MSDOS_SB(inode_sb(inode));
 	sector_t last_block;
 
 	*phys = 0;
@@ -371,7 +371,7 @@ int fat_bmap(struct inode *inode, sector_t sector, sector_t *phys,
 			return 0;
 	} else {
 		last_block = inode->i_blocks >>
-				(inode->i_sb->s_blocksize_bits - 9);
+				(inode_sb(inode)->s_blocksize_bits - 9);
 		if (sector >= last_block)
 			return 0;
 	}
diff --git a/fs/fat/dir.c b/fs/fat/dir.c
index 8e100c3bf72c..dce4b9f0c754 100644
--- a/fs/fat/dir.c
+++ b/fs/fat/dir.c
@@ -48,7 +48,7 @@ static inline loff_t fat_make_i_pos(struct super_block *sb,
 static inline void fat_dir_readahead(struct inode *dir, sector_t iblock,
 				     sector_t phys)
 {
-	struct super_block *sb = dir->i_sb;
+	struct super_block *sb = inode_sb(dir);
 	struct msdos_sb_info *sbi = MSDOS_SB(sb);
 	struct buffer_head *bh;
 	int sec;
@@ -81,7 +81,7 @@ static inline void fat_dir_readahead(struct inode *dir, sector_t iblock,
 static int fat__get_entry(struct inode *dir, loff_t *pos,
 			  struct buffer_head **bh, struct msdos_dir_entry **de)
 {
-	struct super_block *sb = dir->i_sb;
+	struct super_block *sb = inode_sb(dir);
 	sector_t phys, iblock;
 	unsigned long mapped_blocks;
 	int err, offset;
@@ -121,7 +121,7 @@ static inline int fat_get_entry(struct inode *dir, loff_t *pos,
 	/* Fast stuff first */
 	if (*bh && *de &&
 	   (*de - (struct msdos_dir_entry *)(*bh)->b_data) <
-				MSDOS_SB(dir->i_sb)->dir_per_block - 1) {
+				MSDOS_SB(inode_sb(dir))->dir_per_block - 1) {
 		*pos += sizeof(struct msdos_dir_entry);
 		(*de)++;
 		return 0;
@@ -462,7 +462,7 @@ static int fat_parse_short(struct super_block *sb,
 int fat_search_long(struct inode *inode, const unsigned char *name,
 		    int name_len, struct fat_slot_info *sinfo)
 {
-	struct super_block *sb = inode->i_sb;
+	struct super_block *sb = inode_sb(inode);
 	struct msdos_sb_info *sbi = MSDOS_SB(sb);
 	struct buffer_head *bh = NULL;
 	struct msdos_dir_entry *de;
@@ -553,7 +553,7 @@ static int __fat_readdir(struct inode *inode, struct file *file,
 			 struct dir_context *ctx, int short_only,
 			 struct fat_ioctl_filldir_callback *both)
 {
-	struct super_block *sb = inode->i_sb;
+	struct super_block *sb = inode_sb(inode);
 	struct msdos_sb_info *sbi = MSDOS_SB(sb);
 	struct buffer_head *bh;
 	struct msdos_dir_entry *de;
@@ -954,7 +954,7 @@ int fat_subdirs(struct inode *dir)
 int fat_scan(struct inode *dir, const unsigned char *name,
 	     struct fat_slot_info *sinfo)
 {
-	struct super_block *sb = dir->i_sb;
+	struct super_block *sb = inode_sb(dir);
 
 	sinfo->slot_off = 0;
 	sinfo->bh = NULL;
@@ -978,7 +978,7 @@ EXPORT_SYMBOL_GPL(fat_scan);
 int fat_scan_logstart(struct inode *dir, int i_logstart,
 		      struct fat_slot_info *sinfo)
 {
-	struct super_block *sb = dir->i_sb;
+	struct super_block *sb = inode_sb(dir);
 
 	sinfo->slot_off = 0;
 	sinfo->bh = NULL;
@@ -996,7 +996,7 @@ int fat_scan_logstart(struct inode *dir, int i_logstart,
 
 static int __fat_remove_entries(struct inode *dir, loff_t pos, int nr_slots)
 {
-	struct super_block *sb = dir->i_sb;
+	struct super_block *sb = inode_sb(dir);
 	struct buffer_head *bh;
 	struct msdos_dir_entry *de, *endp;
 	int err = 0, orig_slots;
@@ -1031,7 +1031,7 @@ static int __fat_remove_entries(struct inode *dir, loff_t pos, int nr_slots)
 
 int fat_remove_entries(struct inode *dir, struct fat_slot_info *sinfo)
 {
-	struct super_block *sb = dir->i_sb;
+	struct super_block *sb = inode_sb(dir);
 	struct msdos_dir_entry *de;
 	struct buffer_head *bh;
 	int err = 0, nr_slots;
@@ -1084,7 +1084,7 @@ EXPORT_SYMBOL_GPL(fat_remove_entries);
 static int fat_zeroed_cluster(struct inode *dir, sector_t blknr, int nr_used,
 			      struct buffer_head **bhs, int nr_bhs)
 {
-	struct super_block *sb = dir->i_sb;
+	struct super_block *sb = inode_sb(dir);
 	sector_t last_blknr = blknr + MSDOS_SB(sb)->sec_per_clus;
 	int err, i, n;
 
@@ -1132,7 +1132,7 @@ static int fat_zeroed_cluster(struct inode *dir, sector_t blknr, int nr_used,
 
 int fat_alloc_new_dir(struct inode *dir, struct timespec *ts)
 {
-	struct super_block *sb = dir->i_sb;
+	struct super_block *sb = inode_sb(dir);
 	struct msdos_sb_info *sbi = MSDOS_SB(sb);
 	struct buffer_head *bhs[MAX_BUF_PER_PAGE];
 	struct msdos_dir_entry *de;
@@ -1196,7 +1196,7 @@ static int fat_add_new_entries(struct inode *dir, void *slots, int nr_slots,
 			       int *nr_cluster, struct msdos_dir_entry **de,
 			       struct buffer_head **bh, loff_t *i_pos)
 {
-	struct super_block *sb = dir->i_sb;
+	struct super_block *sb = inode_sb(dir);
 	struct msdos_sb_info *sbi = MSDOS_SB(sb);
 	struct buffer_head *bhs[MAX_BUF_PER_PAGE];
 	sector_t blknr, start_blknr, last_blknr;
@@ -1275,7 +1275,7 @@ static int fat_add_new_entries(struct inode *dir, void *slots, int nr_slots,
 int fat_add_entries(struct inode *dir, void *slots, int nr_slots,
 		    struct fat_slot_info *sinfo)
 {
-	struct super_block *sb = dir->i_sb;
+	struct super_block *sb = inode_sb(dir);
 	struct msdos_sb_info *sbi = MSDOS_SB(sb);
 	struct buffer_head *bh, *prev, *bhs[3]; /* 32*slots (672bytes) */
 	struct msdos_dir_entry *uninitialized_var(de);
diff --git a/fs/fat/fat.h b/fs/fat/fat.h
index 8fc1093da47d..81c3776bc35d 100644
--- a/fs/fat/fat.h
+++ b/fs/fat/fat.h
@@ -156,7 +156,7 @@ static inline struct msdos_inode_info *MSDOS_I(struct inode *inode)
  */
 static inline int fat_mode_can_hold_ro(struct inode *inode)
 {
-	struct msdos_sb_info *sbi = MSDOS_SB(inode->i_sb);
+	struct msdos_sb_info *sbi = MSDOS_SB(inode_sb(inode));
 	umode_t mask;
 
 	if (S_ISDIR(inode->i_mode)) {
diff --git a/fs/fat/fatent.c b/fs/fat/fatent.c
index bac10de678cc..97d3c44eeee1 100644
--- a/fs/fat/fatent.c
+++ b/fs/fat/fatent.c
@@ -347,8 +347,8 @@ static inline int fat_ent_update_ptr(struct super_block *sb,
 
 int fat_ent_read(struct inode *inode, struct fat_entry *fatent, int entry)
 {
-	struct super_block *sb = inode->i_sb;
-	struct msdos_sb_info *sbi = MSDOS_SB(inode->i_sb);
+	struct super_block *sb = inode_sb(inode);
+	struct msdos_sb_info *sbi = MSDOS_SB(inode_sb(inode));
 	const struct fatent_operations *ops = sbi->fatent_ops;
 	int err, offset;
 	sector_t blocknr;
@@ -406,7 +406,7 @@ static int fat_mirror_bhs(struct super_block *sb, struct buffer_head **bhs,
 int fat_ent_write(struct inode *inode, struct fat_entry *fatent,
 		  int new, int wait)
 {
-	struct super_block *sb = inode->i_sb;
+	struct super_block *sb = inode_sb(inode);
 	const struct fatent_operations *ops = MSDOS_SB(sb)->fatent_ops;
 	int err;
 
@@ -461,7 +461,7 @@ static void fat_collect_bhs(struct buffer_head **bhs, int *nr_bhs,
 
 int fat_alloc_clusters(struct inode *inode, int *cluster, int nr_cluster)
 {
-	struct super_block *sb = inode->i_sb;
+	struct super_block *sb = inode_sb(inode);
 	struct msdos_sb_info *sbi = MSDOS_SB(sb);
 	const struct fatent_operations *ops = sbi->fatent_ops;
 	struct fat_entry fatent, prev_ent;
@@ -549,7 +549,7 @@ int fat_alloc_clusters(struct inode *inode, int *cluster, int nr_cluster)
 
 int fat_free_clusters(struct inode *inode, int cluster)
 {
-	struct super_block *sb = inode->i_sb;
+	struct super_block *sb = inode_sb(inode);
 	struct msdos_sb_info *sbi = MSDOS_SB(sb);
 	const struct fatent_operations *ops = sbi->fatent_ops;
 	struct fat_entry fatent;
diff --git a/fs/fat/file.c b/fs/fat/file.c
index 4724cc9ad650..b01165f8df4c 100644
--- a/fs/fat/file.c
+++ b/fs/fat/file.c
@@ -34,7 +34,7 @@ static int fat_ioctl_get_attributes(struct inode *inode, u32 __user *user_attr)
 static int fat_ioctl_set_attributes(struct file *file, u32 __user *user_attr)
 {
 	struct inode *inode = file_inode(file);
-	struct msdos_sb_info *sbi = MSDOS_SB(inode->i_sb);
+	struct msdos_sb_info *sbi = MSDOS_SB(inode_sb(inode));
 	int is_dir = S_ISDIR(inode->i_mode);
 	u32 attr, oldattr;
 	struct iattr ia;
@@ -117,7 +117,7 @@ static int fat_ioctl_set_attributes(struct file *file, u32 __user *user_attr)
 
 static int fat_ioctl_get_volume_id(struct inode *inode, u32 __user *user_attr)
 {
-	struct msdos_sb_info *sbi = MSDOS_SB(inode->i_sb);
+	struct msdos_sb_info *sbi = MSDOS_SB(inode_sb(inode));
 	return put_user(sbi->vol_id, user_attr);
 }
 
@@ -150,8 +150,8 @@ static long fat_generic_compat_ioctl(struct file *filp, unsigned int cmd,
 static int fat_file_release(struct inode *inode, struct file *filp)
 {
 	if ((filp->f_mode & FMODE_WRITE) &&
-	     MSDOS_SB(inode->i_sb)->options.flush) {
-		fat_flush_inodes(inode->i_sb, inode, NULL);
+	     MSDOS_SB(inode_sb(inode))->options.flush) {
+		fat_flush_inodes(inode_sb(inode), inode, NULL);
 		congestion_wait(BLK_RW_ASYNC, HZ/10);
 	}
 	return 0;
@@ -163,7 +163,7 @@ int fat_file_fsync(struct file *filp, loff_t start, loff_t end, int datasync)
 	int res, err;
 
 	res = generic_file_fsync(filp, start, end, datasync);
-	err = sync_mapping_buffers(MSDOS_SB(inode->i_sb)->fat_inode->i_mapping);
+	err = sync_mapping_buffers(MSDOS_SB(inode_sb(inode))->fat_inode->i_mapping);
 
 	return res ? res : err;
 }
@@ -234,7 +234,7 @@ static long fat_fallocate(struct file *file, int mode,
 	loff_t mm_bytes; /* Number of bytes to be allocated for file */
 	loff_t ondisksize; /* block aligned on-disk size in bytes*/
 	struct inode *inode = file->f_mapping->host;
-	struct super_block *sb = inode->i_sb;
+	struct super_block *sb = inode_sb(inode);
 	struct msdos_sb_info *sbi = MSDOS_SB(sb);
 	int err = 0;
 
@@ -279,7 +279,7 @@ static long fat_fallocate(struct file *file, int mode,
 /* Free all clusters after the skip'th cluster. */
 static int fat_free(struct inode *inode, int skip)
 {
-	struct super_block *sb = inode->i_sb;
+	struct super_block *sb = inode_sb(inode);
 	int err, wait, free_start, i_start, i_logstart;
 
 	if (MSDOS_I(inode)->i_start == 0)
@@ -348,7 +348,7 @@ static int fat_free(struct inode *inode, int skip)
 
 void fat_truncate_blocks(struct inode *inode, loff_t offset)
 {
-	struct msdos_sb_info *sbi = MSDOS_SB(inode->i_sb);
+	struct msdos_sb_info *sbi = MSDOS_SB(inode_sb(inode));
 	const unsigned int cluster_size = sbi->cluster_size;
 	int nr_clusters;
 
@@ -362,7 +362,7 @@ void fat_truncate_blocks(struct inode *inode, loff_t offset)
 	nr_clusters = (offset + (cluster_size - 1)) >> sbi->cluster_bits;
 
 	fat_free(inode, nr_clusters);
-	fat_flush_inodes(inode->i_sb, inode, NULL);
+	fat_flush_inodes(inode_sb(inode), inode, NULL);
 }
 
 int fat_getattr(const struct path *path, struct kstat *stat,
@@ -370,11 +370,11 @@ int fat_getattr(const struct path *path, struct kstat *stat,
 {
 	struct inode *inode = d_inode(path->dentry);
 	generic_fillattr(inode, stat);
-	stat->blksize = MSDOS_SB(inode->i_sb)->cluster_size;
+	stat->blksize = MSDOS_SB(inode_sb(inode))->cluster_size;
 
-	if (MSDOS_SB(inode->i_sb)->options.nfs == FAT_NFS_NOSTALE_RO) {
+	if (MSDOS_SB(inode_sb(inode))->options.nfs == FAT_NFS_NOSTALE_RO) {
 		/* Use i_pos for ino. This is used as fileid of nfs. */
-		stat->ino = fat_i_pos_read(MSDOS_SB(inode->i_sb), inode);
+		stat->ino = fat_i_pos_read(MSDOS_SB(inode_sb(inode)), inode);
 	}
 	return 0;
 }
diff --git a/fs/fat/inode.c b/fs/fat/inode.c
index ffbbf0520d9e..09025f390462 100644
--- a/fs/fat/inode.c
+++ b/fs/fat/inode.c
@@ -113,7 +113,7 @@ static inline int __fat_get_block(struct inode *inode, sector_t iblock,
 				  unsigned long *max_blocks,
 				  struct buffer_head *bh_result, int create)
 {
-	struct super_block *sb = inode->i_sb;
+	struct super_block *sb = inode_sb(inode);
 	struct msdos_sb_info *sbi = MSDOS_SB(sb);
 	unsigned long mapped_blocks;
 	sector_t phys, last_block;
@@ -170,7 +170,7 @@ static inline int __fat_get_block(struct inode *inode, sector_t iblock,
 static int fat_get_block(struct inode *inode, sector_t iblock,
 			 struct buffer_head *bh_result, int create)
 {
-	struct super_block *sb = inode->i_sb;
+	struct super_block *sb = inode_sb(inode);
 	unsigned long max_blocks = bh_result->b_size >> inode->i_blkbits;
 	int err;
 
@@ -283,7 +283,7 @@ static ssize_t fat_direct_IO(struct kiocb *iocb, struct iov_iter *iter)
 static int fat_get_block_bmap(struct inode *inode, sector_t iblock,
 		struct buffer_head *bh_result, int create)
 {
-	struct super_block *sb = inode->i_sb;
+	struct super_block *sb = inode_sb(inode);
 	unsigned long max_blocks = bh_result->b_size >> inode->i_blkbits;
 	int err;
 	sector_t bmap;
@@ -391,7 +391,7 @@ static void dir_hash_init(struct super_block *sb)
 
 void fat_attach(struct inode *inode, loff_t i_pos)
 {
-	struct msdos_sb_info *sbi = MSDOS_SB(inode->i_sb);
+	struct msdos_sb_info *sbi = MSDOS_SB(inode_sb(inode));
 
 	if (inode->i_ino != MSDOS_ROOT_INO) {
 		struct hlist_head *head =   sbi->inode_hashtable
@@ -420,7 +420,7 @@ EXPORT_SYMBOL_GPL(fat_attach);
 
 void fat_detach(struct inode *inode)
 {
-	struct msdos_sb_info *sbi = MSDOS_SB(inode->i_sb);
+	struct msdos_sb_info *sbi = MSDOS_SB(inode_sb(inode));
 	spin_lock(&sbi->inode_hash_lock);
 	MSDOS_I(inode)->i_pos = 0;
 	hlist_del_init(&MSDOS_I(inode)->i_fat_hash);
@@ -443,7 +443,7 @@ struct inode *fat_iget(struct super_block *sb, loff_t i_pos)
 
 	spin_lock(&sbi->inode_hash_lock);
 	hlist_for_each_entry(i, head, i_fat_hash) {
-		BUG_ON(i->vfs_inode.i_sb != sb);
+		BUG_ON(inode_sb(&i->vfs_inode) != sb);
 		if (i->i_pos != i_pos)
 			continue;
 		inode = igrab(&i->vfs_inode);
@@ -466,7 +466,7 @@ static int is_exec(unsigned char *extension)
 
 static int fat_calc_dir_size(struct inode *inode)
 {
-	struct msdos_sb_info *sbi = MSDOS_SB(inode->i_sb);
+	struct msdos_sb_info *sbi = MSDOS_SB(inode_sb(inode));
 	int ret, fclus, dclus;
 
 	inode->i_size = 0;
@@ -483,7 +483,7 @@ static int fat_calc_dir_size(struct inode *inode)
 
 static int fat_validate_dir(struct inode *dir)
 {
-	struct super_block *sb = dir->i_sb;
+	struct super_block *sb = inode_sb(dir);
 
 	if (dir->i_nlink < 2) {
 		/* Directory should have "."/".." entries at least. */
@@ -502,7 +502,7 @@ static int fat_validate_dir(struct inode *dir)
 /* doesn't deal with root inode */
 int fat_fill_inode(struct inode *inode, struct msdos_dir_entry *de)
 {
-	struct msdos_sb_info *sbi = MSDOS_SB(inode->i_sb);
+	struct msdos_sb_info *sbi = MSDOS_SB(inode_sb(inode));
 	int error;
 
 	MSDOS_I(inode)->i_pos = 0;
@@ -614,7 +614,7 @@ static void fat_free_eofblocks(struct inode *inode)
 	/* Release unwritten fallocated blocks on inode eviction. */
 	if ((inode->i_blocks << 9) >
 			round_up(MSDOS_I(inode)->mmu_private,
-				MSDOS_SB(inode->i_sb)->cluster_size)) {
+				MSDOS_SB(inode_sb(inode))->cluster_size)) {
 		int err;
 
 		fat_truncate_blocks(inode, MSDOS_I(inode)->mmu_private);
@@ -626,7 +626,7 @@ static void fat_free_eofblocks(struct inode *inode)
 		 */
 		err = __fat_write_inode(inode, inode_needs_sync(inode));
 		if (err) {
-			fat_msg(inode->i_sb, KERN_WARNING, "Failed to "
+			fat_msg(inode_sb(inode), KERN_WARNING, "Failed to "
 					"update on disk inode for unused "
 					"fallocated blocks, inode could be "
 					"corrupted. Please run fsck");
@@ -825,7 +825,7 @@ static int fat_statfs(struct dentry *dentry, struct kstatfs *buf)
 
 static int __fat_write_inode(struct inode *inode, int wait)
 {
-	struct super_block *sb = inode->i_sb;
+	struct super_block *sb = inode_sb(inode);
 	struct msdos_sb_info *sbi = MSDOS_SB(sb);
 	struct buffer_head *bh;
 	struct msdos_dir_entry *raw_entry;
@@ -885,7 +885,7 @@ static int fat_write_inode(struct inode *inode, struct writeback_control *wbc)
 	int err;
 
 	if (inode->i_ino == MSDOS_FSINFO_INO) {
-		struct super_block *sb = inode->i_sb;
+		struct super_block *sb = inode_sb(inode);
 
 		mutex_lock(&MSDOS_SB(sb)->s_lock);
 		err = fat_clusters_flush(sb);
@@ -1372,7 +1372,7 @@ static void fat_dummy_inode_init(struct inode *inode)
 
 static int fat_read_root(struct inode *inode)
 {
-	struct msdos_sb_info *sbi = MSDOS_SB(inode->i_sb);
+	struct msdos_sb_info *sbi = MSDOS_SB(inode_sb(inode));
 	int error;
 
 	MSDOS_I(inode)->i_pos = MSDOS_ROOT_INO;
diff --git a/fs/fat/misc.c b/fs/fat/misc.c
index f9bdc1e01c98..1fb76fac6d41 100644
--- a/fs/fat/misc.c
+++ b/fs/fat/misc.c
@@ -98,7 +98,7 @@ int fat_clusters_flush(struct super_block *sb)
  */
 int fat_chain_add(struct inode *inode, int new_dclus, int nr_cluster)
 {
-	struct super_block *sb = inode->i_sb;
+	struct super_block *sb = inode_sb(inode);
 	struct msdos_sb_info *sbi = MSDOS_SB(sb);
 	int ret, new_fclus, last;
 
diff --git a/fs/fat/namei_msdos.c b/fs/fat/namei_msdos.c
index 582ca731a6c9..b26d3be72b02 100644
--- a/fs/fat/namei_msdos.c
+++ b/fs/fat/namei_msdos.c
@@ -118,7 +118,7 @@ static int msdos_format_name(const unsigned char *name, int len,
 static int msdos_find(struct inode *dir, const unsigned char *name, int len,
 		      struct fat_slot_info *sinfo)
 {
-	struct msdos_sb_info *sbi = MSDOS_SB(dir->i_sb);
+	struct msdos_sb_info *sbi = MSDOS_SB(inode_sb(dir));
 	unsigned char msdos_name[MSDOS_NAME];
 	int err;
 
@@ -200,7 +200,7 @@ static const struct dentry_operations msdos_dentry_operations = {
 static struct dentry *msdos_lookup(struct inode *dir, struct dentry *dentry,
 				   unsigned int flags)
 {
-	struct super_block *sb = dir->i_sb;
+	struct super_block *sb = inode_sb(dir);
 	struct fat_slot_info sinfo;
 	struct inode *inode;
 	int err;
@@ -227,7 +227,7 @@ static int msdos_add_entry(struct inode *dir, const unsigned char *name,
 			   int is_dir, int is_hid, int cluster,
 			   struct timespec *ts, struct fat_slot_info *sinfo)
 {
-	struct msdos_sb_info *sbi = MSDOS_SB(dir->i_sb);
+	struct msdos_sb_info *sbi = MSDOS_SB(inode_sb(dir));
 	struct msdos_dir_entry de;
 	__le16 time, date;
 	int err;
@@ -263,7 +263,7 @@ static int msdos_add_entry(struct inode *dir, const unsigned char *name,
 static int msdos_create(struct inode *dir, struct dentry *dentry, umode_t mode,
 			bool excl)
 {
-	struct super_block *sb = dir->i_sb;
+	struct super_block *sb = inode_sb(dir);
 	struct inode *inode = NULL;
 	struct fat_slot_info sinfo;
 	struct timespec ts;
@@ -308,7 +308,7 @@ static int msdos_create(struct inode *dir, struct dentry *dentry, umode_t mode,
 /***** Remove a directory */
 static int msdos_rmdir(struct inode *dir, struct dentry *dentry)
 {
-	struct super_block *sb = dir->i_sb;
+	struct super_block *sb = inode_sb(dir);
 	struct inode *inode = d_inode(dentry);
 	struct fat_slot_info sinfo;
 	int err;
@@ -344,7 +344,7 @@ static int msdos_rmdir(struct inode *dir, struct dentry *dentry)
 /***** Make a directory */
 static int msdos_mkdir(struct inode *dir, struct dentry *dentry, umode_t mode)
 {
-	struct super_block *sb = dir->i_sb;
+	struct super_block *sb = inode_sb(dir);
 	struct fat_slot_info sinfo;
 	struct inode *inode;
 	unsigned char msdos_name[MSDOS_NAME];
@@ -404,7 +404,7 @@ static int msdos_mkdir(struct inode *dir, struct dentry *dentry, umode_t mode)
 static int msdos_unlink(struct inode *dir, struct dentry *dentry)
 {
 	struct inode *inode = d_inode(dentry);
-	struct super_block *sb = inode->i_sb;
+	struct super_block *sb = inode_sb(inode);
 	struct fat_slot_info sinfo;
 	int err;
 
@@ -588,7 +588,7 @@ static int do_msdos_rename(struct inode *old_dir, unsigned char *old_name,
 		sinfo.bh = NULL;
 	}
 	if (corrupt < 0) {
-		fat_fs_error(new_dir->i_sb,
+		fat_fs_error(inode_sb(new_dir),
 			     "%s: Filesystem corrupted (i_pos %lld)",
 			     __func__, sinfo.i_pos);
 	}
@@ -600,7 +600,7 @@ static int msdos_rename(struct inode *old_dir, struct dentry *old_dentry,
 			struct inode *new_dir, struct dentry *new_dentry,
 			unsigned int flags)
 {
-	struct super_block *sb = old_dir->i_sb;
+	struct super_block *sb = inode_sb(old_dir);
 	unsigned char old_msdos_name[MSDOS_NAME], new_msdos_name[MSDOS_NAME];
 	int err, is_hid;
 
@@ -611,12 +611,12 @@ static int msdos_rename(struct inode *old_dir, struct dentry *old_dentry,
 
 	err = msdos_format_name(old_dentry->d_name.name,
 				old_dentry->d_name.len, old_msdos_name,
-				&MSDOS_SB(old_dir->i_sb)->options);
+				&MSDOS_SB(inode_sb(old_dir))->options);
 	if (err)
 		goto out;
 	err = msdos_format_name(new_dentry->d_name.name,
 				new_dentry->d_name.len, new_msdos_name,
-				&MSDOS_SB(new_dir->i_sb)->options);
+				&MSDOS_SB(inode_sb(new_dir))->options);
 	if (err)
 		goto out;
 
diff --git a/fs/fat/namei_vfat.c b/fs/fat/namei_vfat.c
index 2649759c478a..5113f6703339 100644
--- a/fs/fat/namei_vfat.c
+++ b/fs/fat/namei_vfat.c
@@ -327,7 +327,7 @@ static int vfat_create_shortname(struct inode *dir, struct nls_table *nls,
 				 wchar_t *uname, int ulen,
 				 unsigned char *name_res, unsigned char *lcase)
 {
-	struct fat_mount_options *opts = &MSDOS_SB(dir->i_sb)->options;
+	struct fat_mount_options *opts = &MSDOS_SB(inode_sb(dir))->options;
 	wchar_t *ip, *ext_start, *end, *name_start;
 	unsigned char base[9], ext[4], buf[5], *p;
 	unsigned char charbuf[NLS_MAX_CHARSET_SIZE];
@@ -580,7 +580,7 @@ static int vfat_build_slots(struct inode *dir, const unsigned char *name,
 			    struct timespec *ts,
 			    struct msdos_dir_slot *slots, int *nr_slots)
 {
-	struct msdos_sb_info *sbi = MSDOS_SB(dir->i_sb);
+	struct msdos_sb_info *sbi = MSDOS_SB(inode_sb(dir));
 	struct fat_mount_options *opts = &sbi->options;
 	struct msdos_dir_slot *ps;
 	struct msdos_dir_entry *de;
@@ -709,7 +709,7 @@ static int vfat_d_anon_disconn(struct dentry *dentry)
 static struct dentry *vfat_lookup(struct inode *dir, struct dentry *dentry,
 				  unsigned int flags)
 {
-	struct super_block *sb = dir->i_sb;
+	struct super_block *sb = inode_sb(dir);
 	struct fat_slot_info sinfo;
 	struct inode *inode;
 	struct dentry *alias;
@@ -769,7 +769,7 @@ static struct dentry *vfat_lookup(struct inode *dir, struct dentry *dentry,
 static int vfat_create(struct inode *dir, struct dentry *dentry, umode_t mode,
 		       bool excl)
 {
-	struct super_block *sb = dir->i_sb;
+	struct super_block *sb = inode_sb(dir);
 	struct inode *inode;
 	struct fat_slot_info sinfo;
 	struct timespec ts;
@@ -802,7 +802,7 @@ static int vfat_create(struct inode *dir, struct dentry *dentry, umode_t mode,
 static int vfat_rmdir(struct inode *dir, struct dentry *dentry)
 {
 	struct inode *inode = d_inode(dentry);
-	struct super_block *sb = dir->i_sb;
+	struct super_block *sb = inode_sb(dir);
 	struct fat_slot_info sinfo;
 	int err;
 
@@ -833,7 +833,7 @@ static int vfat_rmdir(struct inode *dir, struct dentry *dentry)
 static int vfat_unlink(struct inode *dir, struct dentry *dentry)
 {
 	struct inode *inode = d_inode(dentry);
-	struct super_block *sb = dir->i_sb;
+	struct super_block *sb = inode_sb(dir);
 	struct fat_slot_info sinfo;
 	int err;
 
@@ -858,7 +858,7 @@ static int vfat_unlink(struct inode *dir, struct dentry *dentry)
 
 static int vfat_mkdir(struct inode *dir, struct dentry *dentry, umode_t mode)
 {
-	struct super_block *sb = dir->i_sb;
+	struct super_block *sb = inode_sb(dir);
 	struct inode *inode;
 	struct fat_slot_info sinfo;
 	struct timespec ts;
@@ -913,7 +913,7 @@ static int vfat_rename(struct inode *old_dir, struct dentry *old_dentry,
 	struct timespec ts;
 	loff_t new_i_pos;
 	int err, is_dir, update_dotdot, corrupt = 0;
-	struct super_block *sb = old_dir->i_sb;
+	struct super_block *sb = inode_sb(old_dir);
 
 	if (flags & ~RENAME_NOREPLACE)
 		return -EINVAL;
@@ -1027,7 +1027,7 @@ static int vfat_rename(struct inode *old_dir, struct dentry *old_dentry,
 		sinfo.bh = NULL;
 	}
 	if (corrupt < 0) {
-		fat_fs_error(new_dir->i_sb,
+		fat_fs_error(inode_sb(new_dir),
 			     "%s: Filesystem corrupted (i_pos %lld)",
 			     __func__, sinfo.i_pos);
 	}
diff --git a/fs/fat/nfs.c b/fs/fat/nfs.c
index eb192656fba2..67f34ed8aeeb 100644
--- a/fs/fat/nfs.c
+++ b/fs/fat/nfs.c
@@ -39,7 +39,7 @@ static struct inode *fat_dget(struct super_block *sb, int i_logstart)
 	head = sbi->dir_hashtable + fat_dir_hash(i_logstart);
 	spin_lock(&sbi->dir_hash_lock);
 	hlist_for_each_entry(i, head, i_dir_hash) {
-		BUG_ON(i->vfs_inode.i_sb != sb);
+		BUG_ON(inode_sb(&i->vfs_inode) != sb);
 		if (i->i_logstart != i_logstart)
 			continue;
 		inode = igrab(&i->vfs_inode);
@@ -110,7 +110,7 @@ fat_encode_fh_nostale(struct inode *inode, __u32 *fh, int *lenp,
 		      struct inode *parent)
 {
 	int len = *lenp;
-	struct msdos_sb_info *sbi = MSDOS_SB(inode->i_sb);
+	struct msdos_sb_info *sbi = MSDOS_SB(inode_sb(inode));
 	struct fat_fid *fid = (struct fat_fid *) fh;
 	loff_t i_pos;
 	int type = FILEID_FAT_WITHOUT_PARENT;
-- 
2.15.1

^ permalink raw reply	[flat|nested] 88+ messages in thread

* [PATCH 34/76] fs/freevxfs: Use inode_sb() helper instead of inode->i_sb
  2018-05-08 18:03 [RFC][PATCH 0/76] vfs: 'views' for filesystems with more than one root Mark Fasheh
                   ` (32 preceding siblings ...)
  2018-05-08 18:03 ` [PATCH 33/76] fs/fat: " Mark Fasheh
@ 2018-05-08 18:03 ` Mark Fasheh
  2018-05-08 18:03 ` [PATCH 35/76] fs/fuse: " Mark Fasheh
                   ` (42 subsequent siblings)
  76 siblings, 0 replies; 88+ messages in thread
From: Mark Fasheh @ 2018-05-08 18:03 UTC (permalink / raw)
  To: linux-fsdevel; +Cc: linux-kernel, linux-btrfs, Mark Fasheh

Signed-off-by: Mark Fasheh <mfasheh@suse.de>
---
 fs/freevxfs/vxfs_bmap.c   | 14 +++++++-------
 fs/freevxfs/vxfs_inode.c  |  2 +-
 fs/freevxfs/vxfs_lookup.c | 10 +++++-----
 fs/freevxfs/vxfs_subr.c   |  4 ++--
 4 files changed, 15 insertions(+), 15 deletions(-)

diff --git a/fs/freevxfs/vxfs_bmap.c b/fs/freevxfs/vxfs_bmap.c
index 1fd41cf98b9f..55cfb03efb35 100644
--- a/fs/freevxfs/vxfs_bmap.c
+++ b/fs/freevxfs/vxfs_bmap.c
@@ -66,7 +66,7 @@ vxfs_typdump(struct vxfs_typed *typ)
 static daddr_t
 vxfs_bmap_ext4(struct inode *ip, long bn)
 {
-	struct super_block *sb = ip->i_sb;
+	struct super_block *sb = inode_sb(ip);
 	struct vxfs_inode_info *vip = VXFS_INO(ip);
 	struct vxfs_sb_info *sbi = VXFS_SBI(sb);
 	unsigned long bsize = sb->s_blocksize;
@@ -130,22 +130,22 @@ vxfs_bmap_ext4(struct inode *ip, long bn)
 static daddr_t
 vxfs_bmap_indir(struct inode *ip, long indir, int size, long block)
 {
-	struct vxfs_sb_info		*sbi = VXFS_SBI(ip->i_sb);
+	struct vxfs_sb_info		*sbi = VXFS_SBI(inode_sb(ip));
 	struct buffer_head		*bp = NULL;
 	daddr_t				pblock = 0;
 	int				i;
 
-	for (i = 0; i < size * VXFS_TYPED_PER_BLOCK(ip->i_sb); i++) {
+	for (i = 0; i < size * VXFS_TYPED_PER_BLOCK(inode_sb(ip)); i++) {
 		struct vxfs_typed	*typ;
 		int64_t			off;
 
-		bp = sb_bread(ip->i_sb,
-				indir + (i / VXFS_TYPED_PER_BLOCK(ip->i_sb)));
+		bp = sb_bread(inode_sb(ip),
+				indir + (i / VXFS_TYPED_PER_BLOCK(inode_sb(ip))));
 		if (!bp || !buffer_mapped(bp))
 			return 0;
 
 		typ = ((struct vxfs_typed *)bp->b_data) +
-			(i % VXFS_TYPED_PER_BLOCK(ip->i_sb));
+			(i % VXFS_TYPED_PER_BLOCK(inode_sb(ip)));
 		off = fs64_to_cpu(sbi, typ->vt_hdr) & VXFS_TYPED_OFFSETMASK;
 
 		if (block < off) {
@@ -210,7 +210,7 @@ static daddr_t
 vxfs_bmap_typed(struct inode *ip, long iblock)
 {
 	struct vxfs_inode_info		*vip = VXFS_INO(ip);
-	struct vxfs_sb_info		*sbi = VXFS_SBI(ip->i_sb);
+	struct vxfs_sb_info		*sbi = VXFS_SBI(inode_sb(ip));
 	daddr_t				pblock = 0;
 	int				i;
 
diff --git a/fs/freevxfs/vxfs_inode.c b/fs/freevxfs/vxfs_inode.c
index 1f41b25ef38b..fdb36340a25f 100644
--- a/fs/freevxfs/vxfs_inode.c
+++ b/fs/freevxfs/vxfs_inode.c
@@ -221,7 +221,7 @@ __vxfs_iget(struct inode *ilistp, struct vxfs_inode_info *vip, ino_t ino)
 		caddr_t			kaddr = (char *)page_address(pp);
 
 		dip = (struct vxfs_dinode *)(kaddr + offset);
-		dip2vip_cpy(VXFS_SBI(ilistp->i_sb), vip, dip);
+		dip2vip_cpy(VXFS_SBI(inode_sb(ilistp)), vip, dip);
 		vip->vfs_inode.i_mapping->a_ops = &vxfs_aops;
 #ifdef DIAGNOSTIC
 		vxfs_dumpi(vip, ino);
diff --git a/fs/freevxfs/vxfs_lookup.c b/fs/freevxfs/vxfs_lookup.c
index ce4785fd81c6..f2011edf525c 100644
--- a/fs/freevxfs/vxfs_lookup.c
+++ b/fs/freevxfs/vxfs_lookup.c
@@ -80,13 +80,13 @@ const struct file_operations vxfs_dir_operations = {
 static struct vxfs_direct *
 vxfs_find_entry(struct inode *ip, struct dentry *dp, struct page **ppp)
 {
-	u_long bsize = ip->i_sb->s_blocksize;
+	u_long bsize = inode_sb(ip)->s_blocksize;
 	const char *name = dp->d_name.name;
 	int namelen = dp->d_name.len;
 	loff_t limit = VXFS_DIRROUND(ip->i_size);
 	struct vxfs_direct *de_exit = NULL;
 	loff_t pos = 0;
-	struct vxfs_sb_info *sbi = VXFS_SBI(ip->i_sb);
+	struct vxfs_sb_info *sbi = VXFS_SBI(inode_sb(ip));
 
 	while (pos < limit) {
 		struct page *pp;
@@ -161,7 +161,7 @@ vxfs_inode_by_name(struct inode *dip, struct dentry *dp)
 
 	de = vxfs_find_entry(dip, dp, &pp);
 	if (de) {
-		ino = fs32_to_cpu(VXFS_SBI(dip->i_sb), de->d_ino);
+		ino = fs32_to_cpu(VXFS_SBI(inode_sb(dip)), de->d_ino);
 		kunmap(pp);
 		put_page(pp);
 	}
@@ -194,7 +194,7 @@ vxfs_lookup(struct inode *dip, struct dentry *dp, unsigned int flags)
 				 
 	ino = vxfs_inode_by_name(dip, dp);
 	if (ino) {
-		ip = vxfs_iget(dip->i_sb, ino);
+		ip = vxfs_iget(inode_sb(dip), ino);
 		if (IS_ERR(ip))
 			return ERR_CAST(ip);
 	}
@@ -219,7 +219,7 @@ static int
 vxfs_readdir(struct file *fp, struct dir_context *ctx)
 {
 	struct inode		*ip = file_inode(fp);
-	struct super_block	*sbp = ip->i_sb;
+	struct super_block	*sbp = inode_sb(ip);
 	u_long			bsize = sbp->s_blocksize;
 	loff_t			pos, limit;
 	struct vxfs_sb_info	*sbi = VXFS_SBI(sbp);
diff --git a/fs/freevxfs/vxfs_subr.c b/fs/freevxfs/vxfs_subr.c
index e806694d4145..8dfa00bd783c 100644
--- a/fs/freevxfs/vxfs_subr.c
+++ b/fs/freevxfs/vxfs_subr.c
@@ -105,7 +105,7 @@ vxfs_bread(struct inode *ip, int block)
 	daddr_t			pblock;
 
 	pblock = vxfs_bmap1(ip, block);
-	bp = sb_bread(ip->i_sb, pblock);
+	bp = sb_bread(inode_sb(ip), pblock);
 
 	return (bp);
 }
@@ -133,7 +133,7 @@ vxfs_getblk(struct inode *ip, sector_t iblock,
 
 	pblock = vxfs_bmap1(ip, iblock);
 	if (pblock != 0) {
-		map_bh(bp, ip->i_sb, pblock);
+		map_bh(bp, inode_sb(ip), pblock);
 		return 0;
 	}
 
-- 
2.15.1

^ permalink raw reply	[flat|nested] 88+ messages in thread

* [PATCH 35/76] fs/fuse: Use inode_sb() helper instead of inode->i_sb
  2018-05-08 18:03 [RFC][PATCH 0/76] vfs: 'views' for filesystems with more than one root Mark Fasheh
                   ` (33 preceding siblings ...)
  2018-05-08 18:03 ` [PATCH 34/76] fs/freevxfs: " Mark Fasheh
@ 2018-05-08 18:03 ` Mark Fasheh
  2018-05-08 18:03 ` [PATCH 36/76] fs/gfs2: " Mark Fasheh
                   ` (41 subsequent siblings)
  76 siblings, 0 replies; 88+ messages in thread
From: Mark Fasheh @ 2018-05-08 18:03 UTC (permalink / raw)
  To: linux-fsdevel; +Cc: linux-kernel, linux-btrfs, Mark Fasheh

Signed-off-by: Mark Fasheh <mfasheh@suse.de>
---
 fs/fuse/dir.c    | 13 +++++++------
 fs/fuse/file.c   |  6 +++---
 fs/fuse/fuse_i.h |  2 +-
 fs/fuse/inode.c  |  7 ++++---
 4 files changed, 15 insertions(+), 13 deletions(-)

diff --git a/fs/fuse/dir.c b/fs/fuse/dir.c
index 24967382a7b1..b68adb3bd70d 100644
--- a/fs/fuse/dir.c
+++ b/fs/fuse/dir.c
@@ -357,7 +357,8 @@ static struct dentry *fuse_lookup(struct inode *dir, struct dentry *entry,
 	bool outarg_valid = true;
 
 	fuse_lock_inode(dir);
-	err = fuse_lookup_name(dir->i_sb, get_node_id(dir), &entry->d_name,
+	err = fuse_lookup_name(inode_sb(dir), get_node_id(dir),
+			       &entry->d_name,
 			       &outarg, &inode);
 	fuse_unlock_inode(dir);
 	if (err == -ENOENT) {
@@ -456,7 +457,7 @@ static int fuse_create_open(struct inode *dir, struct dentry *entry,
 	ff->fh = outopen.fh;
 	ff->nodeid = outentry.nodeid;
 	ff->open_flags = outopen.open_flags;
-	inode = fuse_iget(dir->i_sb, outentry.nodeid, outentry.generation,
+	inode = fuse_iget(inode_sb(dir), outentry.nodeid, outentry.generation,
 			  &outentry.attr, entry_attr_timeout(&outentry), 0);
 	if (!inode) {
 		flags &= ~(O_CREAT | O_EXCL | O_TRUNC);
@@ -562,7 +563,7 @@ static int create_new_entry(struct fuse_conn *fc, struct fuse_args *args,
 	if ((outarg.attr.mode ^ mode) & S_IFMT)
 		goto out_put_forget_req;
 
-	inode = fuse_iget(dir->i_sb, outarg.nodeid, outarg.generation,
+	inode = fuse_iget(inode_sb(dir), outarg.nodeid, outarg.generation,
 			  &outarg.attr, entry_attr_timeout(&outarg), 0);
 	if (!inode) {
 		fuse_queue_forget(fc, forget, outarg.nodeid, 1);
@@ -854,7 +855,7 @@ static void fuse_fillattr(struct inode *inode, struct fuse_attr *attr,
 		attr->ctimensec = inode->i_ctime.tv_nsec;
 	}
 
-	stat->dev = inode->i_sb->s_dev;
+	stat->dev = inode_sb(inode)->s_dev;
 	stat->ino = attr->ino;
 	stat->mode = (inode->i_mode & S_IFMT) | (attr->mode & 07777);
 	stat->nlink = attr->nlink;
@@ -873,7 +874,7 @@ static void fuse_fillattr(struct inode *inode, struct fuse_attr *attr,
 	if (attr->blksize != 0)
 		blkbits = ilog2(attr->blksize);
 	else
-		blkbits = inode->i_sb->s_blocksize_bits;
+		blkbits = inode_sb(inode)->s_blocksize_bits;
 
 	stat->blksize = 1 << blkbits;
 }
@@ -1255,7 +1256,7 @@ static int fuse_direntplus_link(struct file *file,
 		 * which bumps nlookup inside
 		 */
 	} else {
-		inode = fuse_iget(dir->i_sb, o->nodeid, o->generation,
+		inode = fuse_iget(inode_sb(dir), o->nodeid, o->generation,
 				  &o->attr, entry_attr_timeout(o),
 				  attr_version);
 		if (!inode)
diff --git a/fs/fuse/file.c b/fs/fuse/file.c
index a201fb0ac64f..14e55c348da7 100644
--- a/fs/fuse/file.c
+++ b/fs/fuse/file.c
@@ -2250,12 +2250,12 @@ static sector_t fuse_bmap(struct address_space *mapping, sector_t block)
 	struct fuse_bmap_out outarg;
 	int err;
 
-	if (!inode->i_sb->s_bdev || fc->no_bmap)
+	if (!inode_sb(inode)->s_bdev || fc->no_bmap)
 		return 0;
 
 	memset(&inarg, 0, sizeof(inarg));
 	inarg.block = block;
-	inarg.blocksize = inode->i_sb->s_blocksize;
+	inarg.blocksize = inode_sb(inode)->s_blocksize;
 	args.in.h.opcode = FUSE_BMAP;
 	args.in.h.nodeid = get_node_id(inode);
 	args.in.numargs = 1;
@@ -2305,7 +2305,7 @@ static loff_t fuse_lseek(struct file *file, loff_t offset, int whence)
 		return err;
 	}
 
-	return vfs_setpos(file, outarg.offset, inode->i_sb->s_maxbytes);
+	return vfs_setpos(file, outarg.offset, inode_sb(inode)->s_maxbytes);
 
 fallback:
 	err = fuse_update_attributes(inode, file);
diff --git a/fs/fuse/fuse_i.h b/fs/fuse/fuse_i.h
index c4c093bbf456..5ea9ddb9fa19 100644
--- a/fs/fuse/fuse_i.h
+++ b/fs/fuse/fuse_i.h
@@ -674,7 +674,7 @@ static inline struct fuse_conn *get_fuse_conn_super(struct super_block *sb)
 
 static inline struct fuse_conn *get_fuse_conn(struct inode *inode)
 {
-	return get_fuse_conn_super(inode->i_sb);
+	return get_fuse_conn_super(inode_sb(inode));
 }
 
 static inline struct fuse_inode *get_fuse_inode(struct inode *inode)
diff --git a/fs/fuse/inode.c b/fs/fuse/inode.c
index 624f18bbfd2b..d6d2fbe6c3ec 100644
--- a/fs/fuse/inode.c
+++ b/fs/fuse/inode.c
@@ -130,7 +130,7 @@ static void fuse_evict_inode(struct inode *inode)
 {
 	truncate_inode_pages_final(&inode->i_data);
 	clear_inode(inode);
-	if (inode->i_sb->s_flags & SB_ACTIVE) {
+	if (inode_sb(inode)->s_flags & SB_ACTIVE) {
 		struct fuse_conn *fc = get_fuse_conn(inode);
 		struct fuse_inode *fi = get_fuse_inode(inode);
 		fuse_queue_forget(fc, fi->forget, fi->nodeid, fi->nlookup);
@@ -187,7 +187,7 @@ void fuse_change_attributes_common(struct inode *inode, struct fuse_attr *attr,
 	if (attr->blksize != 0)
 		inode->i_blkbits = ilog2(attr->blksize);
 	else
-		inode->i_blkbits = inode->i_sb->s_blocksize_bits;
+		inode->i_blkbits = inode_sb(inode)->s_blocksize_bits;
 
 	/*
 	 * Don't set the sticky bit in i_mode, unless we want the VFS
@@ -778,7 +778,8 @@ static struct dentry *fuse_get_parent(struct dentry *child)
 	if (!fc->export_support)
 		return ERR_PTR(-ESTALE);
 
-	err = fuse_lookup_name(child_inode->i_sb, get_node_id(child_inode),
+	err = fuse_lookup_name(inode_sb(child_inode),
+			       get_node_id(child_inode),
 			       &name, &outarg, &inode);
 	if (err) {
 		if (err == -ENOENT)
-- 
2.15.1

^ permalink raw reply	[flat|nested] 88+ messages in thread

* [PATCH 36/76] fs/gfs2: Use inode_sb() helper instead of inode->i_sb
  2018-05-08 18:03 [RFC][PATCH 0/76] vfs: 'views' for filesystems with more than one root Mark Fasheh
                   ` (34 preceding siblings ...)
  2018-05-08 18:03 ` [PATCH 35/76] fs/fuse: " Mark Fasheh
@ 2018-05-08 18:03 ` Mark Fasheh
  2018-05-08 18:03 ` [PATCH 37/76] fs/hfs: " Mark Fasheh
                   ` (40 subsequent siblings)
  76 siblings, 0 replies; 88+ messages in thread
From: Mark Fasheh @ 2018-05-08 18:03 UTC (permalink / raw)
  To: linux-fsdevel; +Cc: linux-kernel, linux-btrfs, Mark Fasheh

Signed-off-by: Mark Fasheh <mfasheh@suse.de>
---
 fs/gfs2/aops.c    | 9 +++++----
 fs/gfs2/bmap.c    | 9 +++++----
 fs/gfs2/dir.c     | 3 ++-
 fs/gfs2/export.c  | 2 +-
 fs/gfs2/file.c    | 4 ++--
 fs/gfs2/incore.h  | 2 +-
 fs/gfs2/inode.c   | 8 ++++----
 fs/gfs2/meta_io.h | 2 +-
 fs/gfs2/super.c   | 2 +-
 9 files changed, 22 insertions(+), 19 deletions(-)

diff --git a/fs/gfs2/aops.c b/fs/gfs2/aops.c
index 2f725b4a386b..bd771df8b227 100644
--- a/fs/gfs2/aops.c
+++ b/fs/gfs2/aops.c
@@ -189,7 +189,8 @@ static int __gfs2_jdata_writepage(struct page *page, struct writeback_control *w
 	if (PageChecked(page)) {
 		ClearPageChecked(page);
 		if (!page_has_buffers(page)) {
-			create_empty_buffers(page, inode->i_sb->s_blocksize,
+			create_empty_buffers(page,
+					     inode_sb(inode)->s_blocksize,
 					     BIT(BH_Dirty)|BIT(BH_Uptodate));
 		}
 		gfs2_page_add_databufs(ip, page, 0, sdp->sd_vfs->s_blocksize);
@@ -271,7 +272,7 @@ static int gfs2_write_jdata_pagevec(struct address_space *mapping,
 {
 	struct inode *inode = mapping->host;
 	struct gfs2_sbd *sdp = GFS2_SB(inode);
-	unsigned nrblocks = nr_pages * (PAGE_SIZE/inode->i_sb->s_blocksize);
+	unsigned nrblocks = nr_pages * (PAGE_SIZE/inode_sb(inode)->s_blocksize);
 	int i;
 	int ret;
 
@@ -776,7 +777,7 @@ static int gfs2_write_begin(struct file *file, struct address_space *mapping,
  */
 static void adjust_fs_space(struct inode *inode)
 {
-	struct gfs2_sbd *sdp = inode->i_sb->s_fs_info;
+	struct gfs2_sbd *sdp = inode_sb(inode)->s_fs_info;
 	struct gfs2_inode *m_ip = GFS2_I(sdp->sd_statfs_inode);
 	struct gfs2_inode *l_ip = GFS2_I(sdp->sd_sc_inode);
 	struct gfs2_statfs_change_host *m_sc = &sdp->sd_statfs_master;
@@ -1112,7 +1113,7 @@ static ssize_t gfs2_direct_IO(struct kiocb *iocb, struct iov_iter *iter)
 			truncate_inode_pages_range(mapping, lstart, end);
 	}
 
-	rv = __blockdev_direct_IO(iocb, inode, inode->i_sb->s_bdev, iter,
+	rv = __blockdev_direct_IO(iocb, inode, inode_sb(inode)->s_bdev, iter,
 				  gfs2_get_block_direct, NULL, NULL, 0);
 out:
 	gfs2_glock_dq(&gh);
diff --git a/fs/gfs2/bmap.c b/fs/gfs2/bmap.c
index 51f940e76c5e..f523d2e7a71a 100644
--- a/fs/gfs2/bmap.c
+++ b/fs/gfs2/bmap.c
@@ -86,7 +86,7 @@ static int gfs2_unstuffer_page(struct gfs2_inode *ip, struct buffer_head *dibh,
 	bh = page_buffers(page);
 
 	if (!buffer_mapped(bh))
-		map_bh(bh, inode->i_sb, block);
+		map_bh(bh, inode_sb(inode), block);
 
 	set_buffer_uptodate(bh);
 	if (!gfs2_is_jdata(ip))
@@ -856,7 +856,8 @@ int gfs2_block_map(struct inode *inode, sector_t lblock,
 		iomap.flags &= ~IOMAP_F_BOUNDARY;
 	}
 	if (iomap.addr != IOMAP_NULL_ADDR)
-		map_bh(bh_map, inode->i_sb, iomap.addr >> inode->i_blkbits);
+		map_bh(bh_map, inode_sb(inode),
+		       iomap.addr >> inode->i_blkbits);
 	bh_map->b_size = iomap.length;
 	if (iomap.flags & IOMAP_F_BOUNDARY)
 		set_buffer_boundary(bh_map);
@@ -913,8 +914,8 @@ static int gfs2_block_zero_range(struct inode *inode, loff_t from,
 	if (!page)
 		return 0;
 
-	blocksize = inode->i_sb->s_blocksize;
-	iblock = index << (PAGE_SHIFT - inode->i_sb->s_blocksize_bits);
+	blocksize = inode_sb(inode)->s_blocksize;
+	iblock = index << (PAGE_SHIFT - inode_sb(inode)->s_blocksize_bits);
 
 	if (!page_has_buffers(page))
 		create_empty_buffers(page, blocksize, 0);
diff --git a/fs/gfs2/dir.c b/fs/gfs2/dir.c
index 7c21aea0266b..5ab5ed92ce78 100644
--- a/fs/gfs2/dir.c
+++ b/fs/gfs2/dir.c
@@ -1665,7 +1665,8 @@ struct inode *gfs2_dir_search(struct inode *dir, const struct qstr *name,
 		brelse(bh);
 		if (fail_on_exist)
 			return ERR_PTR(-EEXIST);
-		inode = gfs2_inode_lookup(dir->i_sb, dtype, addr, formal_ino,
+		inode = gfs2_inode_lookup(inode_sb(dir), dtype, addr,
+					  formal_ino,
 					  GFS2_BLKST_FREE /* ignore */);
 		if (!IS_ERR(inode))
 			GFS2_I(inode)->i_rahead = rahead;
diff --git a/fs/gfs2/export.c b/fs/gfs2/export.c
index a332f3cd925e..42e7f8e30683 100644
--- a/fs/gfs2/export.c
+++ b/fs/gfs2/export.c
@@ -32,7 +32,7 @@ static int gfs2_encode_fh(struct inode *inode, __u32 *p, int *len,
 			  struct inode *parent)
 {
 	__be32 *fh = (__force __be32 *)p;
-	struct super_block *sb = inode->i_sb;
+	struct super_block *sb = inode_sb(inode);
 	struct gfs2_inode *ip = GFS2_I(inode);
 
 	if (parent && (*len < GFS2_LARGE_FH_SIZE)) {
diff --git a/fs/gfs2/file.c b/fs/gfs2/file.c
index 4f88e201b3f0..ed7dc7ca8cbf 100644
--- a/fs/gfs2/file.c
+++ b/fs/gfs2/file.c
@@ -401,7 +401,7 @@ static int gfs2_page_mkwrite(struct vm_fault *vmf)
 	loff_t size;
 	int ret;
 
-	sb_start_pagefault(inode->i_sb);
+	sb_start_pagefault(inode_sb(inode));
 
 	ret = gfs2_rsqa_alloc(ip);
 	if (ret)
@@ -492,7 +492,7 @@ static int gfs2_page_mkwrite(struct vm_fault *vmf)
 		wait_for_stable_page(page);
 	}
 out:
-	sb_end_pagefault(inode->i_sb);
+	sb_end_pagefault(inode_sb(inode));
 	return block_page_mkwrite_return(ret);
 }
 
diff --git a/fs/gfs2/incore.h b/fs/gfs2/incore.h
index e0557b8a590a..b548684449fa 100644
--- a/fs/gfs2/incore.h
+++ b/fs/gfs2/incore.h
@@ -424,7 +424,7 @@ static inline struct gfs2_inode *GFS2_I(struct inode *inode)
 
 static inline struct gfs2_sbd *GFS2_SB(const struct inode *inode)
 {
-	return inode->i_sb->s_fs_info;
+	return inode_sb(inode)->s_fs_info;
 }
 
 struct gfs2_file {
diff --git a/fs/gfs2/inode.c b/fs/gfs2/inode.c
index 59e0560180ec..9f6f63bb987d 100644
--- a/fs/gfs2/inode.c
+++ b/fs/gfs2/inode.c
@@ -280,7 +280,7 @@ struct inode *gfs2_lookup_simple(struct inode *dip, const char *name)
 struct inode *gfs2_lookupi(struct inode *dir, const struct qstr *name,
 			   int is_root)
 {
-	struct super_block *sb = dir->i_sb;
+	struct super_block *sb = inode_sb(dir);
 	struct gfs2_inode *dip = GFS2_I(dir);
 	struct gfs2_holder d_gh;
 	int error = 0;
@@ -1279,7 +1279,7 @@ static int gfs2_atomic_open(struct inode *dir, struct dentry *dentry,
 static int gfs2_ok_to_move(struct gfs2_inode *this, struct gfs2_inode *to)
 {
 	struct inode *dir = &to->i_inode;
-	struct super_block *sb = dir->i_sb;
+	struct super_block *sb = inode_sb(dir);
 	struct inode *tmp;
 	int error = 0;
 
@@ -2056,7 +2056,7 @@ loff_t gfs2_seek_data(struct file *file, loff_t offset)
 
 	if (ret < 0)
 		return ret;
-	return vfs_setpos(file, ret, inode->i_sb->s_maxbytes);
+	return vfs_setpos(file, ret, inode_sb(inode)->s_maxbytes);
 }
 
 loff_t gfs2_seek_hole(struct file *file, loff_t offset)
@@ -2075,7 +2075,7 @@ loff_t gfs2_seek_hole(struct file *file, loff_t offset)
 
 	if (ret < 0)
 		return ret;
-	return vfs_setpos(file, ret, inode->i_sb->s_maxbytes);
+	return vfs_setpos(file, ret, inode_sb(inode)->s_maxbytes);
 }
 
 const struct inode_operations gfs2_file_iops = {
diff --git a/fs/gfs2/meta_io.h b/fs/gfs2/meta_io.h
index ffdf6aa3509d..fecae733bb95 100644
--- a/fs/gfs2/meta_io.h
+++ b/fs/gfs2/meta_io.h
@@ -48,7 +48,7 @@ static inline struct gfs2_sbd *gfs2_mapping2sbd(struct address_space *mapping)
 	else if (mapping->a_ops == &gfs2_rgrp_aops)
 		return container_of(mapping, struct gfs2_sbd, sd_aspace);
 	else
-		return inode->i_sb->s_fs_info;
+		return inode_sb(inode)->s_fs_info;
 }
 
 extern struct buffer_head *gfs2_meta_new(struct gfs2_glock *gl, u64 blkno);
diff --git a/fs/gfs2/super.c b/fs/gfs2/super.c
index 620be0521866..296952eea729 100644
--- a/fs/gfs2/super.c
+++ b/fs/gfs2/super.c
@@ -1568,7 +1568,7 @@ static void gfs2_glock_put_eventually(struct gfs2_glock *gl)
 
 static void gfs2_evict_inode(struct inode *inode)
 {
-	struct super_block *sb = inode->i_sb;
+	struct super_block *sb = inode_sb(inode);
 	struct gfs2_sbd *sdp = sb->s_fs_info;
 	struct gfs2_inode *ip = GFS2_I(inode);
 	struct gfs2_holder gh;
-- 
2.15.1

^ permalink raw reply	[flat|nested] 88+ messages in thread

* [PATCH 37/76] fs/hfs: Use inode_sb() helper instead of inode->i_sb
  2018-05-08 18:03 [RFC][PATCH 0/76] vfs: 'views' for filesystems with more than one root Mark Fasheh
                   ` (35 preceding siblings ...)
  2018-05-08 18:03 ` [PATCH 36/76] fs/gfs2: " Mark Fasheh
@ 2018-05-08 18:03 ` Mark Fasheh
  2018-05-08 18:03 ` [PATCH 38/76] fs/hfsplus: " Mark Fasheh
                   ` (39 subsequent siblings)
  76 siblings, 0 replies; 88+ messages in thread
From: Mark Fasheh @ 2018-05-08 18:03 UTC (permalink / raw)
  To: linux-fsdevel; +Cc: linux-kernel, linux-btrfs, Mark Fasheh

Signed-off-by: Mark Fasheh <mfasheh@suse.de>
---
 fs/hfs/attr.c    |  4 ++--
 fs/hfs/catalog.c | 10 +++++-----
 fs/hfs/dir.c     | 11 ++++++-----
 fs/hfs/extent.c  | 10 +++++-----
 fs/hfs/inode.c   | 32 ++++++++++++++++----------------
 5 files changed, 34 insertions(+), 33 deletions(-)

diff --git a/fs/hfs/attr.c b/fs/hfs/attr.c
index 74fa62643136..60075ee27192 100644
--- a/fs/hfs/attr.c
+++ b/fs/hfs/attr.c
@@ -30,7 +30,7 @@ static int __hfs_setxattr(struct inode *inode, enum hfs_xattr_type type,
 	if (!S_ISREG(inode->i_mode) || HFS_IS_RSRC(inode))
 		return -EOPNOTSUPP;
 
-	res = hfs_find_init(HFS_SB(inode->i_sb)->cat_tree, &fd);
+	res = hfs_find_init(HFS_SB(inode_sb(inode))->cat_tree, &fd);
 	if (res)
 		return res;
 	fd.search_key->cat = HFS_I(inode)->cat_key;
@@ -77,7 +77,7 @@ static ssize_t __hfs_getxattr(struct inode *inode, enum hfs_xattr_type type,
 		return -EOPNOTSUPP;
 
 	if (size) {
-		res = hfs_find_init(HFS_SB(inode->i_sb)->cat_tree, &fd);
+		res = hfs_find_init(HFS_SB(inode_sb(inode))->cat_tree, &fd);
 		if (res)
 			return res;
 		fd.search_key->cat = HFS_I(inode)->cat_key;
diff --git a/fs/hfs/catalog.c b/fs/hfs/catalog.c
index 8a66405b0f8b..790d488a2c24 100644
--- a/fs/hfs/catalog.c
+++ b/fs/hfs/catalog.c
@@ -56,8 +56,8 @@ static int hfs_cat_build_record(hfs_cat_rec *rec, u32 cnid, struct inode *inode)
 		rec->file.CrDat = mtime;
 		rec->file.MdDat = mtime;
 		rec->file.BkDat = 0;
-		rec->file.UsrWds.fdType = HFS_SB(inode->i_sb)->s_type;
-		rec->file.UsrWds.fdCreator = HFS_SB(inode->i_sb)->s_creator;
+		rec->file.UsrWds.fdType = HFS_SB(inode_sb(inode))->s_type;
+		rec->file.UsrWds.fdCreator = HFS_SB(inode_sb(inode))->s_creator;
 		return sizeof(struct hfs_cat_file);
 	}
 }
@@ -92,7 +92,7 @@ int hfs_cat_create(u32 cnid, struct inode *dir, const struct qstr *str, struct i
 	if (dir->i_size >= HFS_MAX_VALENCE)
 		return -ENOSPC;
 
-	sb = dir->i_sb;
+	sb = inode_sb(dir);
 	err = hfs_find_init(HFS_SB(sb)->cat_tree, &fd);
 	if (err)
 		return err;
@@ -218,7 +218,7 @@ int hfs_cat_delete(u32 cnid, struct inode *dir, const struct qstr *str)
 	int res, type;
 
 	hfs_dbg(CAT_MOD, "delete_cat: %s,%u\n", str ? str->name : NULL, cnid);
-	sb = dir->i_sb;
+	sb = inode_sb(dir);
 	res = hfs_find_init(HFS_SB(sb)->cat_tree, &fd);
 	if (res)
 		return res;
@@ -289,7 +289,7 @@ int hfs_cat_move(u32 cnid, struct inode *src_dir, const struct qstr *src_name,
 	hfs_dbg(CAT_MOD, "rename_cat: %u - %lu,%s - %lu,%s\n",
 		cnid, src_dir->i_ino, src_name->name,
 		dst_dir->i_ino, dst_name->name);
-	sb = src_dir->i_sb;
+	sb = inode_sb(src_dir);
 	err = hfs_find_init(HFS_SB(sb)->cat_tree, &src_fd);
 	if (err)
 		return err;
diff --git a/fs/hfs/dir.c b/fs/hfs/dir.c
index 75b254280ff6..ae29580b3d0c 100644
--- a/fs/hfs/dir.c
+++ b/fs/hfs/dir.c
@@ -25,10 +25,11 @@ static struct dentry *hfs_lookup(struct inode *dir, struct dentry *dentry,
 	struct inode *inode = NULL;
 	int res;
 
-	res = hfs_find_init(HFS_SB(dir->i_sb)->cat_tree, &fd);
+	res = hfs_find_init(HFS_SB(inode_sb(dir))->cat_tree, &fd);
 	if (res)
 		return ERR_PTR(res);
-	hfs_cat_build_key(dir->i_sb, fd.search_key, dir->i_ino, &dentry->d_name);
+	hfs_cat_build_key(inode_sb(dir), fd.search_key, dir->i_ino,
+			  &dentry->d_name);
 	res = hfs_brec_read(&fd, &rec, sizeof(rec));
 	if (res) {
 		hfs_find_exit(&fd);
@@ -39,7 +40,7 @@ static struct dentry *hfs_lookup(struct inode *dir, struct dentry *dentry,
 		}
 		return ERR_PTR(res);
 	}
-	inode = hfs_iget(dir->i_sb, &fd.search_key->cat, &rec);
+	inode = hfs_iget(inode_sb(dir), &fd.search_key->cat, &rec);
 	hfs_find_exit(&fd);
 	if (!inode)
 		return ERR_PTR(-EACCES);
@@ -54,7 +55,7 @@ static struct dentry *hfs_lookup(struct inode *dir, struct dentry *dentry,
 static int hfs_readdir(struct file *file, struct dir_context *ctx)
 {
 	struct inode *inode = file_inode(file);
-	struct super_block *sb = inode->i_sb;
+	struct super_block *sb = inode_sb(inode);
 	int len, err;
 	char strbuf[HFS_MAX_NAMELEN];
 	union hfs_cat_rec entry;
@@ -305,7 +306,7 @@ static int hfs_rename(struct inode *old_dir, struct dentry *old_dentry,
 			   old_dir, &old_dentry->d_name,
 			   new_dir, &new_dentry->d_name);
 	if (!res)
-		hfs_cat_build_key(old_dir->i_sb,
+		hfs_cat_build_key(inode_sb(old_dir),
 				  (btree_key *)&HFS_I(d_inode(old_dentry))->cat_key,
 				  new_dir->i_ino, &new_dentry->d_name);
 	return res;
diff --git a/fs/hfs/extent.c b/fs/hfs/extent.c
index 5d0182654580..03e1f49fee30 100644
--- a/fs/hfs/extent.c
+++ b/fs/hfs/extent.c
@@ -134,7 +134,7 @@ int hfs_ext_write_extent(struct inode *inode)
 	int res = 0;
 
 	if (HFS_I(inode)->flags & HFS_FLG_EXT_DIRTY) {
-		res = hfs_find_init(HFS_SB(inode->i_sb)->ext_tree, &fd);
+		res = hfs_find_init(HFS_SB(inode_sb(inode))->ext_tree, &fd);
 		if (res)
 			return res;
 		res = __hfs_ext_write_extent(inode, &fd);
@@ -193,7 +193,7 @@ static int hfs_ext_read_extent(struct inode *inode, u16 block)
 	    block < HFS_I(inode)->cached_start + HFS_I(inode)->cached_blocks)
 		return 0;
 
-	res = hfs_find_init(HFS_SB(inode->i_sb)->ext_tree, &fd);
+	res = hfs_find_init(HFS_SB(inode_sb(inode))->ext_tree, &fd);
 	if (!res) {
 		res = __hfs_ext_cache_extent(&fd, inode, block);
 		hfs_find_exit(&fd);
@@ -336,7 +336,7 @@ int hfs_get_block(struct inode *inode, sector_t block,
 	u16 dblock, ablock;
 	int res;
 
-	sb = inode->i_sb;
+	sb = inode_sb(inode);
 	/* Convert inode block to disk allocation block */
 	ablock = (u32)block / HFS_SB(sb)->fs_div;
 
@@ -384,7 +384,7 @@ int hfs_get_block(struct inode *inode, sector_t block,
 
 int hfs_extend_file(struct inode *inode)
 {
-	struct super_block *sb = inode->i_sb;
+	struct super_block *sb = inode_sb(inode);
 	u32 start, len, goal;
 	int res;
 
@@ -469,7 +469,7 @@ int hfs_extend_file(struct inode *inode)
 
 void hfs_file_truncate(struct inode *inode)
 {
-	struct super_block *sb = inode->i_sb;
+	struct super_block *sb = inode_sb(inode);
 	struct hfs_find_data fd;
 	u16 blk_cnt, alloc_cnt, start;
 	u32 size;
diff --git a/fs/hfs/inode.c b/fs/hfs/inode.c
index 2538b49cc349..1d8e35f3f72d 100644
--- a/fs/hfs/inode.c
+++ b/fs/hfs/inode.c
@@ -72,7 +72,7 @@ static sector_t hfs_bmap(struct address_space *mapping, sector_t block)
 static int hfs_releasepage(struct page *page, gfp_t mask)
 {
 	struct inode *inode = page->mapping->host;
-	struct super_block *sb = inode->i_sb;
+	struct super_block *sb = inode_sb(inode);
 	struct hfs_btree *tree;
 	struct hfs_bnode *node;
 	u32 nidx;
@@ -181,7 +181,7 @@ const struct address_space_operations hfs_aops = {
  */
 struct inode *hfs_new_inode(struct inode *dir, const struct qstr *name, umode_t mode)
 {
-	struct super_block *sb = dir->i_sb;
+	struct super_block *sb = inode_sb(dir);
 	struct inode *inode = new_inode(sb);
 	if (!inode)
 		return NULL;
@@ -207,7 +207,7 @@ struct inode *hfs_new_inode(struct inode *dir, const struct qstr *name, umode_t
 		inode->i_op = &hfs_dir_inode_operations;
 		inode->i_fop = &hfs_dir_operations;
 		inode->i_mode |= S_IRWXUGO;
-		inode->i_mode &= ~HFS_SB(inode->i_sb)->s_dir_umask;
+		inode->i_mode &= ~HFS_SB(inode_sb(inode))->s_dir_umask;
 	} else if (S_ISREG(mode)) {
 		HFS_I(inode)->clump_blocks = HFS_SB(sb)->clumpablks;
 		HFS_SB(sb)->file_count++;
@@ -219,7 +219,7 @@ struct inode *hfs_new_inode(struct inode *dir, const struct qstr *name, umode_t
 		inode->i_mode |= S_IRUGO|S_IXUGO;
 		if (mode & S_IWUSR)
 			inode->i_mode |= S_IWUGO;
-		inode->i_mode &= ~HFS_SB(inode->i_sb)->s_file_umask;
+		inode->i_mode &= ~HFS_SB(inode_sb(inode))->s_file_umask;
 		HFS_I(inode)->phys_size = 0;
 		HFS_I(inode)->alloc_blocks = 0;
 		HFS_I(inode)->first_blocks = 0;
@@ -238,7 +238,7 @@ struct inode *hfs_new_inode(struct inode *dir, const struct qstr *name, umode_t
 
 void hfs_delete_inode(struct inode *inode)
 {
-	struct super_block *sb = inode->i_sb;
+	struct super_block *sb = inode_sb(inode);
 
 	hfs_dbg(INODE, "delete_inode: %lu\n", inode->i_ino);
 	if (S_ISDIR(inode->i_mode)) {
@@ -265,7 +265,7 @@ void hfs_delete_inode(struct inode *inode)
 void hfs_inode_read_fork(struct inode *inode, struct hfs_extent *ext,
 			 __be32 __log_size, __be32 phys_size, u32 clump_size)
 {
-	struct super_block *sb = inode->i_sb;
+	struct super_block *sb = inode_sb(inode);
 	u32 log_size = be32_to_cpu(__log_size);
 	u16 count;
 	int i;
@@ -313,7 +313,7 @@ static int hfs_test_inode(struct inode *inode, void *data)
 static int hfs_read_inode(struct inode *inode, void *data)
 {
 	struct hfs_iget_data *idata = data;
-	struct hfs_sb_info *hsb = HFS_SB(inode->i_sb);
+	struct hfs_sb_info *hsb = HFS_SB(inode_sb(inode));
 	hfs_cat_rec *rec;
 
 	HFS_I(inode)->flags = 0;
@@ -412,7 +412,7 @@ void hfs_inode_write_fork(struct inode *inode, struct hfs_extent *ext,
 		*log_size = cpu_to_be32(inode->i_size);
 	if (phys_size)
 		*phys_size = cpu_to_be32(HFS_I(inode)->alloc_blocks *
-					 HFS_SB(inode->i_sb)->alloc_blksz);
+					 HFS_SB(inode_sb(inode))->alloc_blksz);
 }
 
 int hfs_write_inode(struct inode *inode, struct writeback_control *wbc)
@@ -432,10 +432,10 @@ int hfs_write_inode(struct inode *inode, struct writeback_control *wbc)
 		case HFS_ROOT_CNID:
 			break;
 		case HFS_EXT_CNID:
-			hfs_btree_write(HFS_SB(inode->i_sb)->ext_tree);
+			hfs_btree_write(HFS_SB(inode_sb(inode))->ext_tree);
 			return 0;
 		case HFS_CAT_CNID:
-			hfs_btree_write(HFS_SB(inode->i_sb)->cat_tree);
+			hfs_btree_write(HFS_SB(inode_sb(inode))->cat_tree);
 			return 0;
 		default:
 			BUG();
@@ -449,7 +449,7 @@ int hfs_write_inode(struct inode *inode, struct writeback_control *wbc)
 	if (!main_inode->i_nlink)
 		return 0;
 
-	if (hfs_find_init(HFS_SB(main_inode->i_sb)->cat_tree, &fd))
+	if (hfs_find_init(HFS_SB(inode_sb(main_inode))->cat_tree, &fd))
 		/* panic? */
 		return -EIO;
 
@@ -518,11 +518,11 @@ static struct dentry *hfs_file_lookup(struct inode *dir, struct dentry *dentry,
 	if (inode)
 		goto out;
 
-	inode = new_inode(dir->i_sb);
+	inode = new_inode(inode_sb(dir));
 	if (!inode)
 		return ERR_PTR(-ENOMEM);
 
-	res = hfs_find_init(HFS_SB(dir->i_sb)->cat_tree, &fd);
+	res = hfs_find_init(HFS_SB(inode_sb(dir))->cat_tree, &fd);
 	if (res) {
 		iput(inode);
 		return ERR_PTR(res);
@@ -568,7 +568,7 @@ static int hfs_file_open(struct inode *inode, struct file *file)
 
 static int hfs_file_release(struct inode *inode, struct file *file)
 {
-	//struct super_block *sb = inode->i_sb;
+	//struct super_block *sb = inode_sb(inode);
 
 	if (HFS_IS_RSRC(inode))
 		inode = HFS_I(inode)->rsrc_inode;
@@ -604,7 +604,7 @@ static int hfs_file_release(struct inode *inode, struct file *file)
 int hfs_inode_setattr(struct dentry *dentry, struct iattr * attr)
 {
 	struct inode *inode = d_inode(dentry);
-	struct hfs_sb_info *hsb = HFS_SB(inode->i_sb);
+	struct hfs_sb_info *hsb = HFS_SB(inode_sb(inode));
 	int error;
 
 	error = setattr_prepare(dentry, attr); /* basic permission checks */
@@ -665,7 +665,7 @@ static int hfs_file_fsync(struct file *filp, loff_t start, loff_t end,
 	ret = write_inode_now(inode, 0);
 
 	/* sync the superblock to buffers */
-	sb = inode->i_sb;
+	sb = inode_sb(inode);
 	flush_delayed_work(&HFS_SB(sb)->mdb_work);
 	/* .. finally sync the buffers to disk */
 	err = sync_blockdev(sb->s_bdev);
-- 
2.15.1

^ permalink raw reply	[flat|nested] 88+ messages in thread

* [PATCH 38/76] fs/hfsplus: Use inode_sb() helper instead of inode->i_sb
  2018-05-08 18:03 [RFC][PATCH 0/76] vfs: 'views' for filesystems with more than one root Mark Fasheh
                   ` (36 preceding siblings ...)
  2018-05-08 18:03 ` [PATCH 37/76] fs/hfs: " Mark Fasheh
@ 2018-05-08 18:03 ` Mark Fasheh
  2018-05-08 18:03 ` [PATCH 39/76] fs/hostfs: " Mark Fasheh
                   ` (38 subsequent siblings)
  76 siblings, 0 replies; 88+ messages in thread
From: Mark Fasheh @ 2018-05-08 18:03 UTC (permalink / raw)
  To: linux-fsdevel; +Cc: linux-kernel, linux-btrfs, Mark Fasheh

Signed-off-by: Mark Fasheh <mfasheh@suse.de>
---
 fs/hfsplus/attributes.c | 12 ++++++------
 fs/hfsplus/bnode.c      |  2 +-
 fs/hfsplus/catalog.c    | 12 ++++++------
 fs/hfsplus/dir.c        | 22 +++++++++++-----------
 fs/hfsplus/extents.c    | 11 ++++++-----
 fs/hfsplus/inode.c      | 18 +++++++++---------
 fs/hfsplus/ioctl.c      |  2 +-
 fs/hfsplus/super.c      | 14 ++++++++------
 fs/hfsplus/xattr.c      | 41 +++++++++++++++++++++--------------------
 9 files changed, 69 insertions(+), 65 deletions(-)

diff --git a/fs/hfsplus/attributes.c b/fs/hfsplus/attributes.c
index 2bab6b3cdba4..24af5a496912 100644
--- a/fs/hfsplus/attributes.c
+++ b/fs/hfsplus/attributes.c
@@ -169,7 +169,7 @@ int hfsplus_find_attr(struct super_block *sb, u32 cnid,
 int hfsplus_attr_exists(struct inode *inode, const char *name)
 {
 	int err = 0;
-	struct super_block *sb = inode->i_sb;
+	struct super_block *sb = inode_sb(inode);
 	struct hfs_find_data fd;
 
 	if (!HFSPLUS_SB(sb)->attr_tree)
@@ -195,7 +195,7 @@ int hfsplus_create_attr(struct inode *inode,
 				const char *name,
 				const void *value, size_t size)
 {
-	struct super_block *sb = inode->i_sb;
+	struct super_block *sb = inode_sb(inode);
 	struct hfs_find_data fd;
 	hfsplus_attr_entry *entry_ptr;
 	int entry_size;
@@ -298,7 +298,7 @@ static int __hfsplus_delete_attr(struct inode *inode, u32 cnid,
 int hfsplus_delete_attr(struct inode *inode, const char *name)
 {
 	int err = 0;
-	struct super_block *sb = inode->i_sb;
+	struct super_block *sb = inode_sb(inode);
 	struct hfs_find_data fd;
 
 	hfs_dbg(ATTR_MOD, "delete_attr: %s,%ld\n",
@@ -344,17 +344,17 @@ int hfsplus_delete_all_attrs(struct inode *dir, u32 cnid)
 
 	hfs_dbg(ATTR_MOD, "delete_all_attrs: %d\n", cnid);
 
-	if (!HFSPLUS_SB(dir->i_sb)->attr_tree) {
+	if (!HFSPLUS_SB(inode_sb(dir))->attr_tree) {
 		pr_err("attributes file doesn't exist\n");
 		return -EINVAL;
 	}
 
-	err = hfs_find_init(HFSPLUS_SB(dir->i_sb)->attr_tree, &fd);
+	err = hfs_find_init(HFSPLUS_SB(inode_sb(dir))->attr_tree, &fd);
 	if (err)
 		return err;
 
 	for (;;) {
-		err = hfsplus_find_attr(dir->i_sb, cnid, NULL, &fd);
+		err = hfsplus_find_attr(inode_sb(dir), cnid, NULL, &fd);
 		if (err) {
 			if (err != -ENOENT)
 				pr_err("xattr search failed\n");
diff --git a/fs/hfsplus/bnode.c b/fs/hfsplus/bnode.c
index 177fae4e6581..9da98a7955a0 100644
--- a/fs/hfsplus/bnode.c
+++ b/fs/hfsplus/bnode.c
@@ -656,7 +656,7 @@ void hfs_bnode_put(struct hfs_bnode *node)
  */
 bool hfs_bnode_need_zeroout(struct hfs_btree *tree)
 {
-	struct super_block *sb = tree->inode->i_sb;
+	struct super_block *sb = inode_sb(tree->inode);
 	struct hfsplus_sb_info *sbi = HFSPLUS_SB(sb);
 	const u32 volume_attr = be32_to_cpu(sbi->s_vhdr->attributes);
 
diff --git a/fs/hfsplus/catalog.c b/fs/hfsplus/catalog.c
index a196369ba779..23336c614b64 100644
--- a/fs/hfsplus/catalog.c
+++ b/fs/hfsplus/catalog.c
@@ -105,7 +105,7 @@ void hfsplus_cat_set_perms(struct inode *inode, struct hfsplus_perm *perms)
 static int hfsplus_cat_build_record(hfsplus_cat_entry *entry,
 		u32 cnid, struct inode *inode)
 {
-	struct hfsplus_sb_info *sbi = HFSPLUS_SB(inode->i_sb);
+	struct hfsplus_sb_info *sbi = HFSPLUS_SB(inode_sb(inode));
 
 	if (S_ISDIR(inode->i_mode)) {
 		struct hfsplus_cat_folder *folder;
@@ -222,7 +222,7 @@ int hfsplus_find_cat(struct super_block *sb, u32 cnid,
 
 static void hfsplus_subfolders_inc(struct inode *dir)
 {
-	struct hfsplus_sb_info *sbi = HFSPLUS_SB(dir->i_sb);
+	struct hfsplus_sb_info *sbi = HFSPLUS_SB(inode_sb(dir));
 
 	if (test_bit(HFSPLUS_SB_HFSX, &sbi->flags)) {
 		/*
@@ -235,7 +235,7 @@ static void hfsplus_subfolders_inc(struct inode *dir)
 
 static void hfsplus_subfolders_dec(struct inode *dir)
 {
-	struct hfsplus_sb_info *sbi = HFSPLUS_SB(dir->i_sb);
+	struct hfsplus_sb_info *sbi = HFSPLUS_SB(inode_sb(dir));
 
 	if (test_bit(HFSPLUS_SB_HFSX, &sbi->flags)) {
 		/*
@@ -253,7 +253,7 @@ static void hfsplus_subfolders_dec(struct inode *dir)
 int hfsplus_create_cat(u32 cnid, struct inode *dir,
 		const struct qstr *str, struct inode *inode)
 {
-	struct super_block *sb = dir->i_sb;
+	struct super_block *sb = inode_sb(dir);
 	struct hfs_find_data fd;
 	hfsplus_cat_entry entry;
 	int entry_size;
@@ -321,7 +321,7 @@ int hfsplus_create_cat(u32 cnid, struct inode *dir,
 
 int hfsplus_delete_cat(u32 cnid, struct inode *dir, const struct qstr *str)
 {
-	struct super_block *sb = dir->i_sb;
+	struct super_block *sb = inode_sb(dir);
 	struct hfs_find_data fd;
 	struct hfsplus_fork_raw fork;
 	struct list_head *pos;
@@ -419,7 +419,7 @@ int hfsplus_rename_cat(u32 cnid,
 		       struct inode *src_dir, const struct qstr *src_name,
 		       struct inode *dst_dir, const struct qstr *dst_name)
 {
-	struct super_block *sb = src_dir->i_sb;
+	struct super_block *sb = inode_sb(src_dir);
 	struct hfs_find_data src_fd, dst_fd;
 	hfsplus_cat_entry entry;
 	int entry_size, type;
diff --git a/fs/hfsplus/dir.c b/fs/hfsplus/dir.c
index 15e06fb552da..9d824fcc6185 100644
--- a/fs/hfsplus/dir.c
+++ b/fs/hfsplus/dir.c
@@ -39,7 +39,7 @@ static struct dentry *hfsplus_lookup(struct inode *dir, struct dentry *dentry,
 	u32 cnid, linkid = 0;
 	u16 type;
 
-	sb = dir->i_sb;
+	sb = inode_sb(dir);
 
 	dentry->d_fsdata = NULL;
 	err = hfs_find_init(HFSPLUS_SB(sb)->cat_tree, &fd);
@@ -116,7 +116,7 @@ static struct dentry *hfsplus_lookup(struct inode *dir, struct dentry *dentry,
 		goto fail;
 	}
 	hfs_find_exit(&fd);
-	inode = hfsplus_iget(dir->i_sb, cnid);
+	inode = hfsplus_iget(inode_sb(dir), cnid);
 	if (IS_ERR(inode))
 		return ERR_CAST(inode);
 	if (S_ISREG(inode->i_mode))
@@ -132,7 +132,7 @@ static struct dentry *hfsplus_lookup(struct inode *dir, struct dentry *dentry,
 static int hfsplus_readdir(struct file *file, struct dir_context *ctx)
 {
 	struct inode *inode = file_inode(file);
-	struct super_block *sb = inode->i_sb;
+	struct super_block *sb = inode_sb(inode);
 	int len, err;
 	char *strbuf;
 	hfsplus_cat_entry entry;
@@ -302,7 +302,7 @@ static int hfsplus_dir_release(struct inode *inode, struct file *file)
 static int hfsplus_link(struct dentry *src_dentry, struct inode *dst_dir,
 			struct dentry *dst_dentry)
 {
-	struct hfsplus_sb_info *sbi = HFSPLUS_SB(dst_dir->i_sb);
+	struct hfsplus_sb_info *sbi = HFSPLUS_SB(inode_sb(dst_dir));
 	struct inode *inode = d_inode(src_dentry);
 	struct inode *src_dir = d_inode(src_dentry->d_parent);
 	struct qstr str;
@@ -351,7 +351,7 @@ static int hfsplus_link(struct dentry *src_dentry, struct inode *dst_dir,
 	inode->i_ctime = current_time(inode);
 	mark_inode_dirty(inode);
 	sbi->file_count++;
-	hfsplus_mark_mdb_dirty(dst_dir->i_sb);
+	hfsplus_mark_mdb_dirty(inode_sb(dst_dir));
 out:
 	mutex_unlock(&sbi->vh_mutex);
 	return res;
@@ -359,7 +359,7 @@ static int hfsplus_link(struct dentry *src_dentry, struct inode *dst_dir,
 
 static int hfsplus_unlink(struct inode *dir, struct dentry *dentry)
 {
-	struct hfsplus_sb_info *sbi = HFSPLUS_SB(dir->i_sb);
+	struct hfsplus_sb_info *sbi = HFSPLUS_SB(inode_sb(dir));
 	struct inode *inode = d_inode(dentry);
 	struct qstr str;
 	char name[32];
@@ -416,7 +416,7 @@ static int hfsplus_unlink(struct inode *dir, struct dentry *dentry)
 
 static int hfsplus_rmdir(struct inode *dir, struct dentry *dentry)
 {
-	struct hfsplus_sb_info *sbi = HFSPLUS_SB(dir->i_sb);
+	struct hfsplus_sb_info *sbi = HFSPLUS_SB(inode_sb(dir));
 	struct inode *inode = d_inode(dentry);
 	int res;
 
@@ -439,12 +439,12 @@ static int hfsplus_rmdir(struct inode *dir, struct dentry *dentry)
 static int hfsplus_symlink(struct inode *dir, struct dentry *dentry,
 			   const char *symname)
 {
-	struct hfsplus_sb_info *sbi = HFSPLUS_SB(dir->i_sb);
+	struct hfsplus_sb_info *sbi = HFSPLUS_SB(inode_sb(dir));
 	struct inode *inode;
 	int res = -ENOMEM;
 
 	mutex_lock(&sbi->vh_mutex);
-	inode = hfsplus_new_inode(dir->i_sb, dir, S_IFLNK | S_IRWXUGO);
+	inode = hfsplus_new_inode(inode_sb(dir), dir, S_IFLNK | S_IRWXUGO);
 	if (!inode)
 		goto out;
 
@@ -481,12 +481,12 @@ static int hfsplus_symlink(struct inode *dir, struct dentry *dentry,
 static int hfsplus_mknod(struct inode *dir, struct dentry *dentry,
 			 umode_t mode, dev_t rdev)
 {
-	struct hfsplus_sb_info *sbi = HFSPLUS_SB(dir->i_sb);
+	struct hfsplus_sb_info *sbi = HFSPLUS_SB(inode_sb(dir));
 	struct inode *inode;
 	int res = -ENOMEM;
 
 	mutex_lock(&sbi->vh_mutex);
-	inode = hfsplus_new_inode(dir->i_sb, dir, mode);
+	inode = hfsplus_new_inode(inode_sb(dir), dir, mode);
 	if (!inode)
 		goto out;
 
diff --git a/fs/hfsplus/extents.c b/fs/hfsplus/extents.c
index e8770935ce6d..288ae891ed8d 100644
--- a/fs/hfsplus/extents.c
+++ b/fs/hfsplus/extents.c
@@ -129,7 +129,8 @@ static int hfsplus_ext_write_extent_locked(struct inode *inode)
 	if (HFSPLUS_I(inode)->extent_state & HFSPLUS_EXT_DIRTY) {
 		struct hfs_find_data fd;
 
-		res = hfs_find_init(HFSPLUS_SB(inode->i_sb)->ext_tree, &fd);
+		res = hfs_find_init(HFSPLUS_SB(inode_sb(inode))->ext_tree,
+				    &fd);
 		if (res)
 			return res;
 		res = __hfsplus_ext_write_extent(inode, &fd);
@@ -209,7 +210,7 @@ static int hfsplus_ext_read_extent(struct inode *inode, u32 block)
 	    block < hip->cached_start + hip->cached_blocks)
 		return 0;
 
-	res = hfs_find_init(HFSPLUS_SB(inode->i_sb)->ext_tree, &fd);
+	res = hfs_find_init(HFSPLUS_SB(inode_sb(inode))->ext_tree, &fd);
 	if (!res) {
 		res = __hfsplus_ext_cache_extent(&fd, inode, block);
 		hfs_find_exit(&fd);
@@ -221,7 +222,7 @@ static int hfsplus_ext_read_extent(struct inode *inode, u32 block)
 int hfsplus_get_block(struct inode *inode, sector_t iblock,
 		      struct buffer_head *bh_result, int create)
 {
-	struct super_block *sb = inode->i_sb;
+	struct super_block *sb = inode_sb(inode);
 	struct hfsplus_sb_info *sbi = HFSPLUS_SB(sb);
 	struct hfsplus_inode_info *hip = HFSPLUS_I(inode);
 	int res = -EIO;
@@ -428,7 +429,7 @@ int hfsplus_free_fork(struct super_block *sb, u32 cnid,
 
 int hfsplus_file_extend(struct inode *inode, bool zeroout)
 {
-	struct super_block *sb = inode->i_sb;
+	struct super_block *sb = inode_sb(inode);
 	struct hfsplus_sb_info *sbi = HFSPLUS_SB(sb);
 	struct hfsplus_inode_info *hip = HFSPLUS_I(inode);
 	u32 start, len, goal;
@@ -531,7 +532,7 @@ int hfsplus_file_extend(struct inode *inode, bool zeroout)
 
 void hfsplus_file_truncate(struct inode *inode)
 {
-	struct super_block *sb = inode->i_sb;
+	struct super_block *sb = inode_sb(inode);
 	struct hfsplus_inode_info *hip = HFSPLUS_I(inode);
 	struct hfs_find_data fd;
 	u32 alloc_cnt, blk_cnt, start;
diff --git a/fs/hfsplus/inode.c b/fs/hfsplus/inode.c
index c0c8d433864f..9ba18604c11f 100644
--- a/fs/hfsplus/inode.c
+++ b/fs/hfsplus/inode.c
@@ -67,7 +67,7 @@ static sector_t hfsplus_bmap(struct address_space *mapping, sector_t block)
 static int hfsplus_releasepage(struct page *page, gfp_t mask)
 {
 	struct inode *inode = page->mapping->host;
-	struct super_block *sb = inode->i_sb;
+	struct super_block *sb = inode_sb(inode);
 	struct hfs_btree *tree;
 	struct hfs_bnode *node;
 	u32 nidx;
@@ -182,7 +182,7 @@ const struct dentry_operations hfsplus_dentry_operations = {
 static void hfsplus_get_perms(struct inode *inode,
 		struct hfsplus_perm *perms, int dir)
 {
-	struct hfsplus_sb_info *sbi = HFSPLUS_SB(inode->i_sb);
+	struct hfsplus_sb_info *sbi = HFSPLUS_SB(inode_sb(inode));
 	u16 mode;
 
 	mode = be16_to_cpu(perms->mode);
@@ -225,7 +225,7 @@ static int hfsplus_file_open(struct inode *inode, struct file *file)
 
 static int hfsplus_file_release(struct inode *inode, struct file *file)
 {
-	struct super_block *sb = inode->i_sb;
+	struct super_block *sb = inode_sb(inode);
 
 	if (HFSPLUS_IS_RSRC(inode))
 		inode = HFSPLUS_I(inode)->rsrc_inode;
@@ -281,7 +281,7 @@ int hfsplus_file_fsync(struct file *file, loff_t start, loff_t end,
 {
 	struct inode *inode = file->f_mapping->host;
 	struct hfsplus_inode_info *hip = HFSPLUS_I(inode);
-	struct hfsplus_sb_info *sbi = HFSPLUS_SB(inode->i_sb);
+	struct hfsplus_sb_info *sbi = HFSPLUS_SB(inode_sb(inode));
 	int error = 0, error2;
 
 	error = file_write_and_wait_range(file, start, end);
@@ -326,7 +326,7 @@ int hfsplus_file_fsync(struct file *file, loff_t start, loff_t end,
 	}
 
 	if (!test_bit(HFSPLUS_SB_NOBARRIER, &sbi->flags))
-		blkdev_issue_flush(inode->i_sb->s_bdev, GFP_KERNEL, NULL);
+		blkdev_issue_flush(inode_sb(inode)->s_bdev, GFP_KERNEL, NULL);
 
 	inode_unlock(inode);
 
@@ -415,7 +415,7 @@ struct inode *hfsplus_new_inode(struct super_block *sb, struct inode *dir,
 
 void hfsplus_delete_inode(struct inode *inode)
 {
-	struct super_block *sb = inode->i_sb;
+	struct super_block *sb = inode_sb(inode);
 
 	if (S_ISDIR(inode->i_mode)) {
 		HFSPLUS_SB(sb)->folder_count--;
@@ -437,7 +437,7 @@ void hfsplus_delete_inode(struct inode *inode)
 
 void hfsplus_inode_read_fork(struct inode *inode, struct hfsplus_fork_raw *fork)
 {
-	struct super_block *sb = inode->i_sb;
+	struct super_block *sb = inode_sb(inode);
 	struct hfsplus_sb_info *sbi = HFSPLUS_SB(sb);
 	struct hfsplus_inode_info *hip = HFSPLUS_I(inode);
 	u32 count;
@@ -554,11 +554,11 @@ int hfsplus_cat_write_inode(struct inode *inode)
 	if (!main_inode->i_nlink)
 		return 0;
 
-	if (hfs_find_init(HFSPLUS_SB(main_inode->i_sb)->cat_tree, &fd))
+	if (hfs_find_init(HFSPLUS_SB(inode_sb(main_inode))->cat_tree, &fd))
 		/* panic? */
 		return -EIO;
 
-	if (hfsplus_find_cat(main_inode->i_sb, main_inode->i_ino, &fd))
+	if (hfsplus_find_cat(inode_sb(main_inode), main_inode->i_ino, &fd))
 		/* panic? */
 		goto out;
 
diff --git a/fs/hfsplus/ioctl.c b/fs/hfsplus/ioctl.c
index 5e6502ef7415..25f5cb0c6416 100644
--- a/fs/hfsplus/ioctl.c
+++ b/fs/hfsplus/ioctl.c
@@ -28,7 +28,7 @@ static int hfsplus_ioctl_bless(struct file *file, int __user *user_flags)
 {
 	struct dentry *dentry = file->f_path.dentry;
 	struct inode *inode = d_inode(dentry);
-	struct hfsplus_sb_info *sbi = HFSPLUS_SB(inode->i_sb);
+	struct hfsplus_sb_info *sbi = HFSPLUS_SB(inode_sb(inode));
 	struct hfsplus_vh *vh = sbi->s_vhdr;
 	struct hfsplus_vh *bvh = sbi->s_backup_vhdr;
 	u32 cnid = (unsigned long)dentry->d_fsdata;
diff --git a/fs/hfsplus/super.c b/fs/hfsplus/super.c
index 513c357c734b..b34f3110f46a 100644
--- a/fs/hfsplus/super.c
+++ b/fs/hfsplus/super.c
@@ -25,7 +25,7 @@ static void hfsplus_destroy_inode(struct inode *inode);
 
 static int hfsplus_system_read_inode(struct inode *inode)
 {
-	struct hfsplus_vh *vhdr = HFSPLUS_SB(inode->i_sb)->s_vhdr;
+	struct hfsplus_vh *vhdr = HFSPLUS_SB(inode_sb(inode))->s_vhdr;
 
 	switch (inode->i_ino) {
 	case HFSPLUS_EXT_CNID:
@@ -76,9 +76,11 @@ struct inode *hfsplus_iget(struct super_block *sb, unsigned long ino)
 
 	if (inode->i_ino >= HFSPLUS_FIRSTUSER_CNID ||
 	    inode->i_ino == HFSPLUS_ROOT_CNID) {
-		err = hfs_find_init(HFSPLUS_SB(inode->i_sb)->cat_tree, &fd);
+		err = hfs_find_init(HFSPLUS_SB(inode_sb(inode))->cat_tree,
+				    &fd);
 		if (!err) {
-			err = hfsplus_find_cat(inode->i_sb, inode->i_ino, &fd);
+			err = hfsplus_find_cat(inode_sb(inode), inode->i_ino,
+					       &fd);
 			if (!err)
 				err = hfsplus_cat_read_inode(inode, &fd);
 			hfs_find_exit(&fd);
@@ -98,7 +100,7 @@ struct inode *hfsplus_iget(struct super_block *sb, unsigned long ino)
 
 static int hfsplus_system_write_inode(struct inode *inode)
 {
-	struct hfsplus_sb_info *sbi = HFSPLUS_SB(inode->i_sb);
+	struct hfsplus_sb_info *sbi = HFSPLUS_SB(inode_sb(inode));
 	struct hfsplus_vh *vhdr = sbi->s_vhdr;
 	struct hfsplus_fork_raw *fork;
 	struct hfs_btree *tree = NULL;
@@ -128,7 +130,7 @@ static int hfsplus_system_write_inode(struct inode *inode)
 
 	if (fork->total_size != cpu_to_be64(inode->i_size)) {
 		set_bit(HFSPLUS_SB_WRITEBACKUP, &sbi->flags);
-		hfsplus_mark_mdb_dirty(inode->i_sb);
+		hfsplus_mark_mdb_dirty(inode_sb(inode));
 	}
 	hfsplus_inode_write_fork(inode, fork);
 	if (tree) {
@@ -254,7 +256,7 @@ static void delayed_sync_fs(struct work_struct *work)
 	sbi->work_queued = 0;
 	spin_unlock(&sbi->work_lock);
 
-	err = hfsplus_sync_fs(sbi->alloc_file->i_sb, 1);
+	err = hfsplus_sync_fs(inode_sb(sbi->alloc_file), 1);
 	if (err)
 		pr_err("delayed sync fs err %d\n", err);
 }
diff --git a/fs/hfsplus/xattr.c b/fs/hfsplus/xattr.c
index e538b758c448..0d03fcee78ae 100644
--- a/fs/hfsplus/xattr.c
+++ b/fs/hfsplus/xattr.c
@@ -281,13 +281,13 @@ int __hfsplus_setxattr(struct inode *inode, const char *name,
 	if (value == NULL)
 		return hfsplus_removexattr(inode, name);
 
-	err = hfs_find_init(HFSPLUS_SB(inode->i_sb)->cat_tree, &cat_fd);
+	err = hfs_find_init(HFSPLUS_SB(inode_sb(inode))->cat_tree, &cat_fd);
 	if (err) {
 		pr_err("can't init xattr find struct\n");
 		return err;
 	}
 
-	err = hfsplus_find_cat(inode->i_sb, inode->i_ino, &cat_fd);
+	err = hfsplus_find_cat(inode_sb(inode), inode->i_ino, &cat_fd);
 	if (err) {
 		pr_err("catalog searching failed\n");
 		goto end_setxattr;
@@ -334,8 +334,8 @@ int __hfsplus_setxattr(struct inode *inode, const char *name,
 		goto end_setxattr;
 	}
 
-	if (!HFSPLUS_SB(inode->i_sb)->attr_tree) {
-		err = hfsplus_create_attributes_file(inode->i_sb);
+	if (!HFSPLUS_SB(inode_sb(inode))->attr_tree) {
+		err = hfsplus_create_attributes_file(inode_sb(inode));
 		if (unlikely(err))
 			goto end_setxattr;
 	}
@@ -456,12 +456,13 @@ static ssize_t hfsplus_getxattr_finder_info(struct inode *inode,
 	u8 file_finder_info[sizeof(struct FInfo) + sizeof(struct FXInfo)];
 
 	if (size >= record_len) {
-		res = hfs_find_init(HFSPLUS_SB(inode->i_sb)->cat_tree, &fd);
+		res = hfs_find_init(HFSPLUS_SB(inode_sb(inode))->cat_tree,
+				    &fd);
 		if (res) {
 			pr_err("can't init xattr find struct\n");
 			return res;
 		}
-		res = hfsplus_find_cat(inode->i_sb, inode->i_ino, &fd);
+		res = hfsplus_find_cat(inode_sb(inode), inode->i_ino, &fd);
 		if (res)
 			goto end_getxattr_finder_info;
 		entry_type = hfs_bnode_read_u16(fd.bnode, fd.entryoffset);
@@ -511,7 +512,7 @@ ssize_t __hfsplus_getxattr(struct inode *inode, const char *name,
 	if (!strcmp_xattr_finder_info(name))
 		return hfsplus_getxattr_finder_info(inode, value, size);
 
-	if (!HFSPLUS_SB(inode->i_sb)->attr_tree)
+	if (!HFSPLUS_SB(inode_sb(inode))->attr_tree)
 		return -EOPNOTSUPP;
 
 	entry = hfsplus_alloc_attr_entry();
@@ -520,13 +521,13 @@ ssize_t __hfsplus_getxattr(struct inode *inode, const char *name,
 		return -ENOMEM;
 	}
 
-	res = hfs_find_init(HFSPLUS_SB(inode->i_sb)->attr_tree, &fd);
+	res = hfs_find_init(HFSPLUS_SB(inode_sb(inode))->attr_tree, &fd);
 	if (res) {
 		pr_err("can't init xattr find struct\n");
 		goto failed_getxattr_init;
 	}
 
-	res = hfsplus_find_attr(inode->i_sb, inode->i_ino, name, &fd);
+	res = hfsplus_find_attr(inode_sb(inode), inode->i_ino, name, &fd);
 	if (res) {
 		if (res == -ENOENT)
 			res = -ENODATA;
@@ -622,13 +623,13 @@ static ssize_t hfsplus_listxattr_finder_info(struct dentry *dentry,
 	unsigned long len, found_bit;
 	int xattr_name_len, symbols_count;
 
-	res = hfs_find_init(HFSPLUS_SB(inode->i_sb)->cat_tree, &fd);
+	res = hfs_find_init(HFSPLUS_SB(inode_sb(inode))->cat_tree, &fd);
 	if (res) {
 		pr_err("can't init xattr find struct\n");
 		return res;
 	}
 
-	res = hfsplus_find_cat(inode->i_sb, inode->i_ino, &fd);
+	res = hfsplus_find_cat(inode_sb(inode), inode->i_ino, &fd);
 	if (res)
 		goto end_listxattr_finder_info;
 
@@ -697,10 +698,10 @@ ssize_t hfsplus_listxattr(struct dentry *dentry, char *buffer, size_t size)
 	res = hfsplus_listxattr_finder_info(dentry, buffer, size);
 	if (res < 0)
 		return res;
-	else if (!HFSPLUS_SB(inode->i_sb)->attr_tree)
+	else if (!HFSPLUS_SB(inode_sb(inode))->attr_tree)
 		return (res == 0) ? -EOPNOTSUPP : res;
 
-	err = hfs_find_init(HFSPLUS_SB(inode->i_sb)->attr_tree, &fd);
+	err = hfs_find_init(HFSPLUS_SB(inode_sb(inode))->attr_tree, &fd);
 	if (err) {
 		pr_err("can't init xattr find struct\n");
 		return err;
@@ -713,7 +714,7 @@ ssize_t hfsplus_listxattr(struct dentry *dentry, char *buffer, size_t size)
 		goto out;
 	}
 
-	err = hfsplus_find_attr(inode->i_sb, inode->i_ino, NULL, &fd);
+	err = hfsplus_find_attr(inode_sb(inode), inode->i_ino, NULL, &fd);
 	if (err) {
 		if (err == -ENOENT) {
 			if (res == 0)
@@ -740,9 +741,9 @@ ssize_t hfsplus_listxattr(struct dentry *dentry, char *buffer, size_t size)
 			goto end_listxattr;
 
 		xattr_name_len = NLS_MAX_CHARSET_SIZE * HFSPLUS_ATTR_MAX_STRLEN;
-		if (hfsplus_uni2asc(inode->i_sb,
-			(const struct hfsplus_unistr *)&fd.key->attr.key_name,
-					strbuf, &xattr_name_len)) {
+		if (hfsplus_uni2asc(inode_sb(inode),
+				    (const struct hfsplus_unistr *)&fd.key->attr.key_name,
+				    strbuf, &xattr_name_len)) {
 			pr_err("unicode conversion failed\n");
 			res = -EIO;
 			goto end_listxattr;
@@ -780,19 +781,19 @@ static int hfsplus_removexattr(struct inode *inode, const char *name)
 	int is_xattr_acl_deleted = 0;
 	int is_all_xattrs_deleted = 0;
 
-	if (!HFSPLUS_SB(inode->i_sb)->attr_tree)
+	if (!HFSPLUS_SB(inode_sb(inode))->attr_tree)
 		return -EOPNOTSUPP;
 
 	if (!strcmp_xattr_finder_info(name))
 		return -EOPNOTSUPP;
 
-	err = hfs_find_init(HFSPLUS_SB(inode->i_sb)->cat_tree, &cat_fd);
+	err = hfs_find_init(HFSPLUS_SB(inode_sb(inode))->cat_tree, &cat_fd);
 	if (err) {
 		pr_err("can't init xattr find struct\n");
 		return err;
 	}
 
-	err = hfsplus_find_cat(inode->i_sb, inode->i_ino, &cat_fd);
+	err = hfsplus_find_cat(inode_sb(inode), inode->i_ino, &cat_fd);
 	if (err) {
 		pr_err("catalog searching failed\n");
 		goto end_removexattr;
-- 
2.15.1

^ permalink raw reply	[flat|nested] 88+ messages in thread

* [PATCH 39/76] fs/hostfs: Use inode_sb() helper instead of inode->i_sb
  2018-05-08 18:03 [RFC][PATCH 0/76] vfs: 'views' for filesystems with more than one root Mark Fasheh
                   ` (37 preceding siblings ...)
  2018-05-08 18:03 ` [PATCH 38/76] fs/hfsplus: " Mark Fasheh
@ 2018-05-08 18:03 ` Mark Fasheh
  2018-05-08 18:04 ` [PATCH 40/76] fs/hpfs: " Mark Fasheh
                   ` (37 subsequent siblings)
  76 siblings, 0 replies; 88+ messages in thread
From: Mark Fasheh @ 2018-05-08 18:03 UTC (permalink / raw)
  To: linux-fsdevel; +Cc: linux-kernel, linux-btrfs, Mark Fasheh

Signed-off-by: Mark Fasheh <mfasheh@suse.de>
---
 fs/hostfs/hostfs_kern.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/fs/hostfs/hostfs_kern.c b/fs/hostfs/hostfs_kern.c
index c148e7f4f451..b99d08b7ef34 100644
--- a/fs/hostfs/hostfs_kern.c
+++ b/fs/hostfs/hostfs_kern.c
@@ -570,7 +570,7 @@ static int hostfs_create(struct inode *dir, struct dentry *dentry, umode_t mode,
 	char *name;
 	int error, fd;
 
-	inode = hostfs_iget(dir->i_sb);
+	inode = hostfs_iget(inode_sb(dir));
 	if (IS_ERR(inode)) {
 		error = PTR_ERR(inode);
 		goto out;
@@ -609,7 +609,7 @@ static struct dentry *hostfs_lookup(struct inode *ino, struct dentry *dentry,
 	char *name;
 	int err;
 
-	inode = hostfs_iget(ino->i_sb);
+	inode = hostfs_iget(inode_sb(ino));
 	if (IS_ERR(inode)) {
 		err = PTR_ERR(inode);
 		goto out;
@@ -717,7 +717,7 @@ static int hostfs_mknod(struct inode *dir, struct dentry *dentry, umode_t mode,
 	char *name;
 	int err;
 
-	inode = hostfs_iget(dir->i_sb);
+	inode = hostfs_iget(inode_sb(dir));
 	if (IS_ERR(inode)) {
 		err = PTR_ERR(inode);
 		goto out;
-- 
2.15.1

^ permalink raw reply	[flat|nested] 88+ messages in thread

* [PATCH 40/76] fs/hpfs: Use inode_sb() helper instead of inode->i_sb
  2018-05-08 18:03 [RFC][PATCH 0/76] vfs: 'views' for filesystems with more than one root Mark Fasheh
                   ` (38 preceding siblings ...)
  2018-05-08 18:03 ` [PATCH 39/76] fs/hostfs: " Mark Fasheh
@ 2018-05-08 18:04 ` Mark Fasheh
  2018-05-08 18:04 ` [PATCH 41/76] fs/hugetlbfs: " Mark Fasheh
                   ` (36 subsequent siblings)
  76 siblings, 0 replies; 88+ messages in thread
From: Mark Fasheh @ 2018-05-08 18:04 UTC (permalink / raw)
  To: linux-fsdevel; +Cc: linux-kernel, linux-btrfs, Mark Fasheh

Signed-off-by: Mark Fasheh <mfasheh@suse.de>
---
 fs/hpfs/dir.c   |  76 +++++++++++++-----------
 fs/hpfs/dnode.c | 176 ++++++++++++++++++++++++++++++++------------------------
 fs/hpfs/ea.c    |   2 +-
 fs/hpfs/file.c  |  45 ++++++++-------
 fs/hpfs/inode.c |  77 +++++++++++++------------
 fs/hpfs/namei.c | 130 ++++++++++++++++++++++-------------------
 fs/hpfs/super.c |   6 +-
 7 files changed, 287 insertions(+), 225 deletions(-)

diff --git a/fs/hpfs/dir.c b/fs/hpfs/dir.c
index c83ece7facc5..416e6e238ee4 100644
--- a/fs/hpfs/dir.c
+++ b/fs/hpfs/dir.c
@@ -12,10 +12,10 @@
 
 static int hpfs_dir_release(struct inode *inode, struct file *filp)
 {
-	hpfs_lock(inode->i_sb);
+	hpfs_lock(inode_sb(inode));
 	hpfs_del_pos(inode, &filp->f_pos);
 	/*hpfs_write_if_changed(inode);*/
-	hpfs_unlock(inode->i_sb);
+	hpfs_unlock(inode_sb(inode));
 	return 0;
 }
 
@@ -28,7 +28,7 @@ static loff_t hpfs_dir_lseek(struct file *filp, loff_t off, int whence)
 	struct quad_buffer_head qbh;
 	struct inode *i = file_inode(filp);
 	struct hpfs_inode_info *hpfs_inode = hpfs_i(i);
-	struct super_block *s = i->i_sb;
+	struct super_block *s = inode_sb(i);
 
 	/* Somebody else will have to figure out what to do here */
 	if (whence == SEEK_DATA || whence == SEEK_HOLE)
@@ -74,34 +74,38 @@ static int hpfs_readdir(struct file *file, struct dir_context *ctx)
 	int c1, c2 = 0;
 	int ret = 0;
 
-	hpfs_lock(inode->i_sb);
+	hpfs_lock(inode_sb(inode));
 
-	if (hpfs_sb(inode->i_sb)->sb_chk) {
-		if (hpfs_chk_sectors(inode->i_sb, inode->i_ino, 1, "dir_fnode")) {
+	if (hpfs_sb(inode_sb(inode))->sb_chk) {
+		if (hpfs_chk_sectors(inode_sb(inode), inode->i_ino, 1, "dir_fnode")) {
 			ret = -EFSERROR;
 			goto out;
 		}
-		if (hpfs_chk_sectors(inode->i_sb, hpfs_inode->i_dno, 4, "dir_dnode")) {
+		if (hpfs_chk_sectors(inode_sb(inode), hpfs_inode->i_dno, 4, "dir_dnode")) {
 			ret = -EFSERROR;
 			goto out;
 		}
 	}
-	if (hpfs_sb(inode->i_sb)->sb_chk >= 2) {
+	if (hpfs_sb(inode_sb(inode))->sb_chk >= 2) {
 		struct buffer_head *bh;
 		struct fnode *fno;
 		int e = 0;
-		if (!(fno = hpfs_map_fnode(inode->i_sb, inode->i_ino, &bh))) {
+		if (!(fno = hpfs_map_fnode(inode_sb(inode), inode->i_ino, &bh))) {
 			ret = -EIOERROR;
 			goto out;
 		}
 		if (!fnode_is_dir(fno)) {
 			e = 1;
-			hpfs_error(inode->i_sb, "not a directory, fnode %08lx",
+			hpfs_error(inode_sb(inode),
+					"not a directory, fnode %08lx",
 					(unsigned long)inode->i_ino);
 		}
 		if (hpfs_inode->i_dno != le32_to_cpu(fno->u.external[0].disk_secno)) {
 			e = 1;
-			hpfs_error(inode->i_sb, "corrupted inode: i_dno == %08x, fnode -> dnode == %08x", hpfs_inode->i_dno, le32_to_cpu(fno->u.external[0].disk_secno));
+			hpfs_error(inode_sb(inode),
+				   "corrupted inode: i_dno == %08x, fnode -> dnode == %08x",
+				   hpfs_inode->i_dno,
+				   le32_to_cpu(fno->u.external[0].disk_secno));
 		}
 		brelse(bh);
 		if (e) {
@@ -109,7 +113,7 @@ static int hpfs_readdir(struct file *file, struct dir_context *ctx)
 			goto out;
 		}
 	}
-	lc = hpfs_sb(inode->i_sb)->sb_lowercase;
+	lc = hpfs_sb(inode_sb(inode))->sb_lowercase;
 	if (ctx->pos == 12) { /* diff -r requires this (note, that diff -r */
 		ctx->pos = 13; /* also fails on msdos filesystem in 2.0) */
 		goto out;
@@ -124,8 +128,8 @@ static int hpfs_readdir(struct file *file, struct dir_context *ctx)
 		/* This won't work when cycle is longer than number of dirents
 		   accepted by filldir, but what can I do?
 		   maybe killall -9 ls helps */
-		if (hpfs_sb(inode->i_sb)->sb_chk)
-			if (hpfs_stop_cycles(inode->i_sb, ctx->pos, &c1, &c2, "hpfs_readdir")) {
+		if (hpfs_sb(inode_sb(inode))->sb_chk)
+			if (hpfs_stop_cycles(inode_sb(inode), ctx->pos, &c1, &c2, "hpfs_readdir")) {
 				ret = -EFSERROR;
 				goto out;
 			}
@@ -149,7 +153,7 @@ static int hpfs_readdir(struct file *file, struct dir_context *ctx)
 			ret = hpfs_add_pos(inode, &file->f_pos);
 			if (unlikely(ret < 0))
 				goto out;
-			ctx->pos = ((loff_t) hpfs_de_as_down_as_possible(inode->i_sb, hpfs_inode->i_dno) << 4) + 1;
+			ctx->pos = ((loff_t) hpfs_de_as_down_as_possible(inode_sb(inode), hpfs_inode->i_dno) << 4) + 1;
 		}
 		next_pos = ctx->pos;
 		if (!(de = map_pos_dirent(inode, &next_pos, &qbh))) {
@@ -158,18 +162,23 @@ static int hpfs_readdir(struct file *file, struct dir_context *ctx)
 			goto out;
 		}
 		if (de->first || de->last) {
-			if (hpfs_sb(inode->i_sb)->sb_chk) {
+			if (hpfs_sb(inode_sb(inode))->sb_chk) {
 				if (de->first && !de->last && (de->namelen != 2
 				    || de ->name[0] != 1 || de->name[1] != 1))
-					hpfs_error(inode->i_sb, "hpfs_readdir: bad ^A^A entry; pos = %08lx", (unsigned long)ctx->pos);
+					hpfs_error(inode_sb(inode),
+						   "hpfs_readdir: bad ^A^A entry; pos = %08lx",
+						   (unsigned long)ctx->pos);
 				if (de->last && (de->namelen != 1 || de ->name[0] != 255))
-					hpfs_error(inode->i_sb, "hpfs_readdir: bad \\377 entry; pos = %08lx", (unsigned long)ctx->pos);
+					hpfs_error(inode_sb(inode),
+						   "hpfs_readdir: bad \\377 entry; pos = %08lx",
+						   (unsigned long)ctx->pos);
 			}
 			hpfs_brelse4(&qbh);
 			ctx->pos = next_pos;
 			goto again;
 		}
-		tempname = hpfs_translate_name(inode->i_sb, de->name, de->namelen, lc, de->not_8x3);
+		tempname = hpfs_translate_name(inode_sb(inode), de->name,
+					       de->namelen, lc, de->not_8x3);
 		if (!dir_emit(ctx, tempname, de->namelen, le32_to_cpu(de->fnode), DT_UNKNOWN)) {
 			if (tempname != de->name) kfree(tempname);
 			hpfs_brelse4(&qbh);
@@ -180,7 +189,7 @@ static int hpfs_readdir(struct file *file, struct dir_context *ctx)
 		hpfs_brelse4(&qbh);
 	}
 out:
-	hpfs_unlock(inode->i_sb);
+	hpfs_unlock(inode_sb(inode));
 	return ret;
 }
 
@@ -210,10 +219,10 @@ struct dentry *hpfs_lookup(struct inode *dir, struct dentry *dentry, unsigned in
 	struct inode *result = NULL;
 	struct hpfs_inode_info *hpfs_result;
 
-	hpfs_lock(dir->i_sb);
+	hpfs_lock(inode_sb(dir));
 	if ((err = hpfs_chk_name(name, &len))) {
 		if (err == -ENAMETOOLONG) {
-			hpfs_unlock(dir->i_sb);
+			hpfs_unlock(inode_sb(dir));
 			return ERR_PTR(-ENAMETOOLONG);
 		}
 		goto end_add;
@@ -241,16 +250,16 @@ struct dentry *hpfs_lookup(struct inode *dir, struct dentry *dentry, unsigned in
 	 * Go find or make an inode.
 	 */
 
-	result = iget_locked(dir->i_sb, ino);
+	result = iget_locked(inode_sb(dir), ino);
 	if (!result) {
-		hpfs_error(dir->i_sb, "hpfs_lookup: can't get inode");
+		hpfs_error(inode_sb(dir), "hpfs_lookup: can't get inode");
 		goto bail1;
 	}
 	if (result->i_state & I_NEW) {
 		hpfs_init_inode(result);
 		if (de->directory)
 			hpfs_read_inode(result);
-		else if (le32_to_cpu(de->ea_size) && hpfs_sb(dir->i_sb)->sb_eas)
+		else if (le32_to_cpu(de->ea_size) && hpfs_sb(inode_sb(dir))->sb_eas)
 			hpfs_read_inode(result);
 		else {
 			result->i_mode |= S_IFREG;
@@ -264,8 +273,9 @@ struct dentry *hpfs_lookup(struct inode *dir, struct dentry *dentry, unsigned in
 	hpfs_result = hpfs_i(result);
 	if (!de->directory) hpfs_result->i_parent_dir = dir->i_ino;
 
-	if (de->has_acl || de->has_xtd_perm) if (!sb_rdonly(dir->i_sb)) {
-		hpfs_error(result->i_sb, "ACLs or XPERM found. This is probably HPFS386. This driver doesn't support it now. Send me some info on these structures");
+	if (de->has_acl || de->has_xtd_perm) if (!sb_rdonly(inode_sb(dir))) {
+		hpfs_error(inode_sb(result),
+			   "ACLs or XPERM found. This is probably HPFS386. This driver doesn't support it now. Send me some info on these structures");
 		goto bail1;
 	}
 
@@ -275,12 +285,14 @@ struct dentry *hpfs_lookup(struct inode *dir, struct dentry *dentry, unsigned in
 	 */
 
 	if (!result->i_ctime.tv_sec) {
-		if (!(result->i_ctime.tv_sec = local_to_gmt(dir->i_sb, le32_to_cpu(de->creation_date))))
+		if (!(result->i_ctime.tv_sec = local_to_gmt(inode_sb(dir), le32_to_cpu(de->creation_date))))
 			result->i_ctime.tv_sec = 1;
 		result->i_ctime.tv_nsec = 0;
-		result->i_mtime.tv_sec = local_to_gmt(dir->i_sb, le32_to_cpu(de->write_date));
+		result->i_mtime.tv_sec = local_to_gmt(inode_sb(dir),
+						      le32_to_cpu(de->write_date));
 		result->i_mtime.tv_nsec = 0;
-		result->i_atime.tv_sec = local_to_gmt(dir->i_sb, le32_to_cpu(de->read_date));
+		result->i_atime.tv_sec = local_to_gmt(inode_sb(dir),
+						      le32_to_cpu(de->read_date));
 		result->i_atime.tv_nsec = 0;
 		hpfs_result->i_ea_size = le32_to_cpu(de->ea_size);
 		if (!hpfs_result->i_ea_mode && de->read_only)
@@ -309,7 +321,7 @@ struct dentry *hpfs_lookup(struct inode *dir, struct dentry *dentry, unsigned in
 
 	end:
 	end_add:
-	hpfs_unlock(dir->i_sb);
+	hpfs_unlock(inode_sb(dir));
 	d_add(dentry, result);
 	return NULL;
 
@@ -322,7 +334,7 @@ struct dentry *hpfs_lookup(struct inode *dir, struct dentry *dentry, unsigned in
 	
 	/*bail:*/
 
-	hpfs_unlock(dir->i_sb);
+	hpfs_unlock(inode_sb(dir));
 	return ERR_PTR(-ENOENT);
 }
 
diff --git a/fs/hpfs/dnode.c b/fs/hpfs/dnode.c
index a4ad18afbdec..085d8582cf14 100644
--- a/fs/hpfs/dnode.c
+++ b/fs/hpfs/dnode.c
@@ -254,19 +254,20 @@ static int hpfs_add_to_dnode(struct inode *i, dnode_secno dno,
 	}
 	go_up:
 	if (namelen >= 256) {
-		hpfs_error(i->i_sb, "%s(): namelen == %d", __func__, namelen);
+		hpfs_error(inode_sb(i), "%s(): namelen == %d", __func__,
+			   namelen);
 		kfree(nd);
 		kfree(nname);
 		return 1;
 	}
-	if (!(d = hpfs_map_dnode(i->i_sb, dno, &qbh))) {
+	if (!(d = hpfs_map_dnode(inode_sb(i), dno, &qbh))) {
 		kfree(nd);
 		kfree(nname);
 		return 1;
 	}
 	go_up_a:
-	if (hpfs_sb(i->i_sb)->sb_chk)
-		if (hpfs_stop_cycles(i->i_sb, dno, &c1, &c2, "hpfs_add_to_dnode")) {
+	if (hpfs_sb(inode_sb(i))->sb_chk)
+		if (hpfs_stop_cycles(inode_sb(i), dno, &c1, &c2, "hpfs_add_to_dnode")) {
 			hpfs_brelse4(&qbh);
 			kfree(nd);
 			kfree(nname);
@@ -274,7 +275,8 @@ static int hpfs_add_to_dnode(struct inode *i, dnode_secno dno,
 		}
 	if (le32_to_cpu(d->first_free) + de_size(namelen, down_ptr) <= 2048) {
 		loff_t t;
-		copy_de(de=hpfs_add_de(i->i_sb, d, name, namelen, down_ptr), new_de);
+		copy_de(de=hpfs_add_de(inode_sb(i), d, name, namelen, down_ptr),
+			new_de);
 		t = get_pos(d, de);
 		for_all_poss(i, hpfs_pos_ins, t, 1);
 		for_all_poss(i, hpfs_pos_subst, 4, t);
@@ -297,11 +299,13 @@ static int hpfs_add_to_dnode(struct inode *i, dnode_secno dno,
 		return 1;
 	}	
 	memcpy(nd, d, le32_to_cpu(d->first_free));
-	copy_de(de = hpfs_add_de(i->i_sb, nd, name, namelen, down_ptr), new_de);
+	copy_de(de = hpfs_add_de(inode_sb(i), nd, name, namelen, down_ptr),
+		new_de);
 	for_all_poss(i, hpfs_pos_ins, get_pos(nd, de), 1);
 	h = ((char *)dnode_last_de(nd) - (char *)nd) / 2 + 10;
-	if (!(ad = hpfs_alloc_dnode(i->i_sb, le32_to_cpu(d->up), &adno, &qbh1))) {
-		hpfs_error(i->i_sb, "unable to alloc dnode - dnode tree will be corrupted");
+	if (!(ad = hpfs_alloc_dnode(inode_sb(i), le32_to_cpu(d->up), &adno, &qbh1))) {
+		hpfs_error(inode_sb(i),
+			   "unable to alloc dnode - dnode tree will be corrupted");
 		hpfs_brelse4(&qbh);
 		kfree(nd);
 		kfree(nname);
@@ -311,7 +315,8 @@ static int hpfs_add_to_dnode(struct inode *i, dnode_secno dno,
 	i->i_blocks += 4;
 	pos = 1;
 	for (de = dnode_first_de(nd); (char *)de_next_de(de) - (char *)nd < h; de = de_next_de(de)) {
-		copy_de(hpfs_add_de(i->i_sb, ad, de->name, de->namelen, de->down ? de_down_pointer(de) : 0), de);
+		copy_de(hpfs_add_de(inode_sb(i), ad, de->name, de->namelen, de->down ? de_down_pointer(de) : 0),
+			de);
 		for_all_poss(i, hpfs_pos_subst, ((loff_t)dno << 4) | pos, ((loff_t)adno << 4) | pos);
 		pos++;
 	}
@@ -321,13 +326,13 @@ static int hpfs_add_to_dnode(struct inode *i, dnode_secno dno,
 	namelen = de->namelen;
 	for_all_poss(i, hpfs_pos_subst, ((loff_t)dno << 4) | pos, 4);
 	down_ptr = adno;
-	set_last_pointer(i->i_sb, ad, de->down ? de_down_pointer(de) : 0);
+	set_last_pointer(inode_sb(i), ad, de->down ? de_down_pointer(de) : 0);
 	de = de_next_de(de);
 	memmove((char *)nd + 20, de, le32_to_cpu(nd->first_free) + (char *)nd - (char *)de);
 	le32_add_cpu(&nd->first_free, -((char *)de - (char *)nd - 20));
 	memcpy(d, nd, le32_to_cpu(nd->first_free));
 	for_all_poss(i, hpfs_pos_del, (loff_t)dno << 4, pos);
-	fix_up_ptrs(i->i_sb, ad);
+	fix_up_ptrs(inode_sb(i), ad);
 	if (!d->root_dnode) {
 		ad->up = d->up;
 		dno = le32_to_cpu(ad->up);
@@ -337,8 +342,9 @@ static int hpfs_add_to_dnode(struct inode *i, dnode_secno dno,
 		hpfs_brelse4(&qbh1);
 		goto go_up;
 	}
-	if (!(rd = hpfs_alloc_dnode(i->i_sb, le32_to_cpu(d->up), &rdno, &qbh2))) {
-		hpfs_error(i->i_sb, "unable to alloc dnode - dnode tree will be corrupted");
+	if (!(rd = hpfs_alloc_dnode(inode_sb(i), le32_to_cpu(d->up), &rdno, &qbh2))) {
+		hpfs_error(inode_sb(i),
+			   "unable to alloc dnode - dnode tree will be corrupted");
 		hpfs_brelse4(&qbh);
 		hpfs_brelse4(&qbh1);
 		kfree(nd);
@@ -349,8 +355,8 @@ static int hpfs_add_to_dnode(struct inode *i, dnode_secno dno,
 	i->i_blocks += 4;
 	rd->root_dnode = 1;
 	rd->up = d->up;
-	if (!(fnode = hpfs_map_fnode(i->i_sb, le32_to_cpu(d->up), &bh))) {
-		hpfs_free_dnode(i->i_sb, rdno);
+	if (!(fnode = hpfs_map_fnode(inode_sb(i), le32_to_cpu(d->up), &bh))) {
+		hpfs_free_dnode(inode_sb(i), rdno);
 		hpfs_brelse4(&qbh);
 		hpfs_brelse4(&qbh1);
 		hpfs_brelse4(&qbh2);
@@ -369,7 +375,7 @@ static int hpfs_add_to_dnode(struct inode *i, dnode_secno dno,
 	hpfs_mark_4buffers_dirty(&qbh1);
 	hpfs_brelse4(&qbh1);
 	qbh = qbh2;
-	set_last_pointer(i->i_sb, rd, dno);
+	set_last_pointer(inode_sb(i), rd, dno);
 	dno = rdno;
 	d = rd;
 	goto go_up_a;
@@ -396,12 +402,12 @@ int hpfs_add_dirent(struct inode *i,
 	int c1, c2 = 0;
 	dno = hpfs_inode->i_dno;
 	down:
-	if (hpfs_sb(i->i_sb)->sb_chk)
-		if (hpfs_stop_cycles(i->i_sb, dno, &c1, &c2, "hpfs_add_dirent")) return 1;
-	if (!(d = hpfs_map_dnode(i->i_sb, dno, &qbh))) return 1;
+	if (hpfs_sb(inode_sb(i))->sb_chk)
+		if (hpfs_stop_cycles(inode_sb(i), dno, &c1, &c2, "hpfs_add_dirent")) return 1;
+	if (!(d = hpfs_map_dnode(inode_sb(i), dno, &qbh))) return 1;
 	de_end = dnode_end_de(d);
 	for (de = dnode_first_de(d); de < de_end; de = de_next_de(de)) {
-		if (!(c = hpfs_compare_names(i->i_sb, name, namelen, de->name, de->namelen, de->last))) {
+		if (!(c = hpfs_compare_names(inode_sb(i), name, namelen, de->name, de->namelen, de->last))) {
 			hpfs_brelse4(&qbh);
 			return -1;
 		}	
@@ -415,7 +421,7 @@ int hpfs_add_dirent(struct inode *i,
 		}
 	}
 	hpfs_brelse4(&qbh);
-	if (hpfs_check_free_dnodes(i->i_sb, FREE_DNODES_ADD)) {
+	if (hpfs_check_free_dnodes(inode_sb(i), FREE_DNODES_ADD)) {
 		c = 1;
 		goto ret;
 	}	
@@ -441,21 +447,25 @@ static secno move_to_top(struct inode *i, dnode_secno from, dnode_secno to)
 	int c1, c2 = 0;
 	dno = from;
 	while (1) {
-		if (hpfs_sb(i->i_sb)->sb_chk)
-			if (hpfs_stop_cycles(i->i_sb, dno, &c1, &c2, "move_to_top"))
+		if (hpfs_sb(inode_sb(i))->sb_chk)
+			if (hpfs_stop_cycles(inode_sb(i), dno, &c1, &c2, "move_to_top"))
 				return 0;
-		if (!(dnode = hpfs_map_dnode(i->i_sb, dno, &qbh))) return 0;
-		if (hpfs_sb(i->i_sb)->sb_chk) {
+		if (!(dnode = hpfs_map_dnode(inode_sb(i), dno, &qbh))) return 0;
+		if (hpfs_sb(inode_sb(i))->sb_chk) {
 			if (le32_to_cpu(dnode->up) != chk_up) {
-				hpfs_error(i->i_sb, "move_to_top: up pointer from %08x should be %08x, is %08x",
-					dno, chk_up, le32_to_cpu(dnode->up));
+				hpfs_error(inode_sb(i),
+					   "move_to_top: up pointer from %08x should be %08x, is %08x",
+					   dno, chk_up,
+					   le32_to_cpu(dnode->up));
 				hpfs_brelse4(&qbh);
 				return 0;
 			}
 			chk_up = dno;
 		}
 		if (!(de = dnode_last_de(dnode))) {
-			hpfs_error(i->i_sb, "move_to_top: dnode %08x has no last de", dno);
+			hpfs_error(inode_sb(i),
+				   "move_to_top: dnode %08x has no last de",
+				   dno);
 			hpfs_brelse4(&qbh);
 			return 0;
 		}
@@ -466,20 +476,24 @@ static secno move_to_top(struct inode *i, dnode_secno from, dnode_secno to)
 	while (!(de = dnode_pre_last_de(dnode))) {
 		dnode_secno up = le32_to_cpu(dnode->up);
 		hpfs_brelse4(&qbh);
-		hpfs_free_dnode(i->i_sb, dno);
+		hpfs_free_dnode(inode_sb(i), dno);
 		i->i_size -= 2048;
 		i->i_blocks -= 4;
 		for_all_poss(i, hpfs_pos_subst, ((loff_t)dno << 4) | 1, 5);
 		if (up == to) return to;
-		if (!(dnode = hpfs_map_dnode(i->i_sb, up, &qbh))) return 0;
+		if (!(dnode = hpfs_map_dnode(inode_sb(i), up, &qbh))) return 0;
 		if (dnode->root_dnode) {
-			hpfs_error(i->i_sb, "move_to_top: got to root_dnode while moving from %08x to %08x", from, to);
+			hpfs_error(inode_sb(i),
+				   "move_to_top: got to root_dnode while moving from %08x to %08x",
+				   from, to);
 			hpfs_brelse4(&qbh);
 			return 0;
 		}
 		de = dnode_last_de(dnode);
 		if (!de || !de->down) {
-			hpfs_error(i->i_sb, "move_to_top: dnode %08x doesn't point down to %08x", up, dno);
+			hpfs_error(inode_sb(i),
+				   "move_to_top: dnode %08x doesn't point down to %08x",
+				   up, dno);
 			hpfs_brelse4(&qbh);
 			return 0;
 		}
@@ -493,14 +507,15 @@ static secno move_to_top(struct inode *i, dnode_secno from, dnode_secno to)
 	for_all_poss(i, hpfs_pos_subst, t, 4);
 	for_all_poss(i, hpfs_pos_subst, t + 1, 5);
 	if (!(nde = kmalloc(le16_to_cpu(de->length), GFP_NOFS))) {
-		hpfs_error(i->i_sb, "out of memory for dirent - directory will be corrupted");
+		hpfs_error(inode_sb(i),
+			   "out of memory for dirent - directory will be corrupted");
 		hpfs_brelse4(&qbh);
 		return 0;
 	}
 	memcpy(nde, de, le16_to_cpu(de->length));
 	ddno = de->down ? de_down_pointer(de) : 0;
-	hpfs_delete_de(i->i_sb, dnode, de);
-	set_last_pointer(i->i_sb, dnode, ddno);
+	hpfs_delete_de(inode_sb(i), dnode, de);
+	set_last_pointer(inode_sb(i), dnode, ddno);
 	hpfs_mark_4buffers_dirty(&qbh);
 	hpfs_brelse4(&qbh);
 	a = hpfs_add_to_dnode(i, to, nde->name, nde->namelen, nde, from);
@@ -524,8 +539,8 @@ static void delete_empty_dnode(struct inode *i, dnode_secno dno)
 	struct hpfs_dirent *de;
 	int c1, c2 = 0;
 	try_it_again:
-	if (hpfs_stop_cycles(i->i_sb, dno, &c1, &c2, "delete_empty_dnode")) return;
-	if (!(dnode = hpfs_map_dnode(i->i_sb, dno, &qbh))) return;
+	if (hpfs_stop_cycles(inode_sb(i), dno, &c1, &c2, "delete_empty_dnode")) return;
+	if (!(dnode = hpfs_map_dnode(inode_sb(i), dno, &qbh))) return;
 	if (le32_to_cpu(dnode->first_free) > 56) goto end;
 	if (le32_to_cpu(dnode->first_free) == 52 || le32_to_cpu(dnode->first_free) == 56) {
 		struct hpfs_dirent *de_end;
@@ -533,12 +548,14 @@ static void delete_empty_dnode(struct inode *i, dnode_secno dno)
 		up = le32_to_cpu(dnode->up);
 		de = dnode_first_de(dnode);
 		down = de->down ? de_down_pointer(de) : 0;
-		if (hpfs_sb(i->i_sb)->sb_chk) if (root && !down) {
-			hpfs_error(i->i_sb, "delete_empty_dnode: root dnode %08x is empty", dno);
+		if (hpfs_sb(inode_sb(i))->sb_chk) if (root && !down) {
+			hpfs_error(inode_sb(i),
+				   "delete_empty_dnode: root dnode %08x is empty",
+				   dno);
 			goto end;
 		}
 		hpfs_brelse4(&qbh);
-		hpfs_free_dnode(i->i_sb, dno);
+		hpfs_free_dnode(inode_sb(i), dno);
 		i->i_size -= 2048;
 		i->i_blocks -= 4;
 		if (root) {
@@ -546,21 +563,21 @@ static void delete_empty_dnode(struct inode *i, dnode_secno dno)
 			struct buffer_head *bh;
 			struct dnode *d1;
 			struct quad_buffer_head qbh1;
-			if (hpfs_sb(i->i_sb)->sb_chk)
+			if (hpfs_sb(inode_sb(i))->sb_chk)
 				if (up != i->i_ino) {
-					hpfs_error(i->i_sb,
+					hpfs_error(inode_sb(i),
 						   "bad pointer to fnode, dnode %08x, pointing to %08x, should be %08lx",
 						   dno, up,
 						   (unsigned long)i->i_ino);
 					return;
 				}
-			if ((d1 = hpfs_map_dnode(i->i_sb, down, &qbh1))) {
+			if ((d1 = hpfs_map_dnode(inode_sb(i), down, &qbh1))) {
 				d1->up = cpu_to_le32(up);
 				d1->root_dnode = 1;
 				hpfs_mark_4buffers_dirty(&qbh1);
 				hpfs_brelse4(&qbh1);
 			}
-			if ((fnode = hpfs_map_fnode(i->i_sb, up, &bh))) {
+			if ((fnode = hpfs_map_fnode(inode_sb(i), up, &bh))) {
 				fnode->u.external[0].disk_secno = cpu_to_le32(down);
 				mark_buffer_dirty(bh);
 				brelse(bh);
@@ -569,12 +586,14 @@ static void delete_empty_dnode(struct inode *i, dnode_secno dno)
 			for_all_poss(i, hpfs_pos_subst, ((loff_t)dno << 4) | 1, (loff_t) 12);
 			return;
 		}
-		if (!(dnode = hpfs_map_dnode(i->i_sb, up, &qbh))) return;
+		if (!(dnode = hpfs_map_dnode(inode_sb(i), up, &qbh))) return;
 		p = 1;
 		de_end = dnode_end_de(dnode);
 		for (de = dnode_first_de(dnode); de < de_end; de = de_next_de(de), p++)
 			if (de->down) if (de_down_pointer(de) == dno) goto fnd;
-		hpfs_error(i->i_sb, "delete_empty_dnode: pointer to dnode %08x not found in dnode %08x", dno, up);
+		hpfs_error(inode_sb(i),
+			   "delete_empty_dnode: pointer to dnode %08x not found in dnode %08x",
+			   dno, up);
 		goto end;
 		fnd:
 		for_all_poss(i, hpfs_pos_subst, ((loff_t)dno << 4) | 1, ((loff_t)up << 4) | p);
@@ -588,14 +607,16 @@ static void delete_empty_dnode(struct inode *i, dnode_secno dno)
 			struct dnode *d1;
 			struct quad_buffer_head qbh1;
 			*(dnode_secno *) ((void *) de + le16_to_cpu(de->length) - 4) = down;
-			if ((d1 = hpfs_map_dnode(i->i_sb, down, &qbh1))) {
+			if ((d1 = hpfs_map_dnode(inode_sb(i), down, &qbh1))) {
 				d1->up = cpu_to_le32(up);
 				hpfs_mark_4buffers_dirty(&qbh1);
 				hpfs_brelse4(&qbh1);
 			}
 		}
 	} else {
-		hpfs_error(i->i_sb, "delete_empty_dnode: dnode %08x, first_free == %03x", dno, le32_to_cpu(dnode->first_free));
+		hpfs_error(inode_sb(i),
+			   "delete_empty_dnode: dnode %08x, first_free == %03x",
+			   dno, le32_to_cpu(dnode->first_free));
 		goto end;
 	}
 
@@ -611,12 +632,12 @@ static void delete_empty_dnode(struct inode *i, dnode_secno dno)
 			goto endm;
 		}
 		memcpy(de_cp, de, le16_to_cpu(de->length));
-		hpfs_delete_de(i->i_sb, dnode, de);
+		hpfs_delete_de(inode_sb(i), dnode, de);
 		hpfs_mark_4buffers_dirty(&qbh);
 		hpfs_brelse4(&qbh);
 		for_all_poss(i, hpfs_pos_subst, ((loff_t)up << 4) | p, 4);
 		for_all_poss(i, hpfs_pos_del, ((loff_t)up << 4) | p, 1);
-		if (de_cp->down) if ((d1 = hpfs_map_dnode(i->i_sb, de_down_pointer(de_cp), &qbh1))) {
+		if (de_cp->down) if ((d1 = hpfs_map_dnode(inode_sb(i), de_down_pointer(de_cp), &qbh1))) {
 			d1->up = cpu_to_le32(ndown);
 			hpfs_mark_4buffers_dirty(&qbh1);
 			hpfs_brelse4(&qbh1);
@@ -634,7 +655,8 @@ static void delete_empty_dnode(struct inode *i, dnode_secno dno)
 		struct quad_buffer_head qbh1;
 		dnode_secno dlp;
 		if (!de_prev) {
-			hpfs_error(i->i_sb, "delete_empty_dnode: empty dnode %08x", up);
+			hpfs_error(inode_sb(i),
+				   "delete_empty_dnode: empty dnode %08x", up);
 			hpfs_mark_4buffers_dirty(&qbh);
 			hpfs_brelse4(&qbh);
 			dno = up;
@@ -642,19 +664,19 @@ static void delete_empty_dnode(struct inode *i, dnode_secno dno)
 		}
 		if (!de_prev->down) goto endm;
 		ndown = de_down_pointer(de_prev);
-		if ((d1 = hpfs_map_dnode(i->i_sb, ndown, &qbh1))) {
+		if ((d1 = hpfs_map_dnode(inode_sb(i), ndown, &qbh1))) {
 			struct hpfs_dirent *del = dnode_last_de(d1);
 			dlp = del->down ? de_down_pointer(del) : 0;
 			if (!dlp && down) {
 				if (le32_to_cpu(d1->first_free) > 2044) {
-					if (hpfs_sb(i->i_sb)->sb_chk >= 2) {
+					if (hpfs_sb(inode_sb(i))->sb_chk >= 2) {
 						pr_err("unbalanced dnode tree, see hpfs.txt 4 more info\n");
 						pr_err("terminating balancing operation\n");
 					}
 					hpfs_brelse4(&qbh1);
 					goto endm;
 				}
-				if (hpfs_sb(i->i_sb)->sb_chk >= 2) {
+				if (hpfs_sb(inode_sb(i))->sb_chk >= 2) {
 					pr_err("unbalanced dnode tree, see hpfs.txt 4 more info\n");
 					pr_err("goin'on\n");
 				}
@@ -677,7 +699,7 @@ static void delete_empty_dnode(struct inode *i, dnode_secno dno)
 		hpfs_mark_4buffers_dirty(&qbh1);
 		hpfs_brelse4(&qbh1);
 		memcpy(de_cp, de_prev, le16_to_cpu(de_prev->length));
-		hpfs_delete_de(i->i_sb, dnode, de_prev);
+		hpfs_delete_de(inode_sb(i), dnode, de_prev);
 		if (!de_prev->down) {
 			le16_add_cpu(&de_prev->length, 4);
 			de_prev->down = 1;
@@ -688,7 +710,7 @@ static void delete_empty_dnode(struct inode *i, dnode_secno dno)
 		hpfs_brelse4(&qbh);
 		for_all_poss(i, hpfs_pos_subst, ((loff_t)up << 4) | (p - 1), 4);
 		for_all_poss(i, hpfs_pos_subst, ((loff_t)up << 4) | p, ((loff_t)up << 4) | (p - 1));
-		if (down) if ((d1 = hpfs_map_dnode(i->i_sb, de_down_pointer(de), &qbh1))) {
+		if (down) if ((d1 = hpfs_map_dnode(inode_sb(i), de_down_pointer(de), &qbh1))) {
 			d1->up = cpu_to_le32(ndown);
 			hpfs_mark_4buffers_dirty(&qbh1);
 			hpfs_brelse4(&qbh1);
@@ -714,19 +736,21 @@ int hpfs_remove_dirent(struct inode *i, dnode_secno dno, struct hpfs_dirent *de,
 	dnode_secno down = 0;
 	loff_t t;
 	if (de->first || de->last) {
-		hpfs_error(i->i_sb, "hpfs_remove_dirent: attempt to delete first or last dirent in dnode %08x", dno);
+		hpfs_error(inode_sb(i),
+			   "hpfs_remove_dirent: attempt to delete first or last dirent in dnode %08x",
+			   dno);
 		hpfs_brelse4(qbh);
 		return 1;
 	}
 	if (de->down) down = de_down_pointer(de);
 	if (depth && (de->down || (de == dnode_first_de(dnode) && de_next_de(de)->last))) {
-		if (hpfs_check_free_dnodes(i->i_sb, FREE_DNODES_DEL)) {
+		if (hpfs_check_free_dnodes(inode_sb(i), FREE_DNODES_DEL)) {
 			hpfs_brelse4(qbh);
 			return 2;
 		}
 	}
 	for_all_poss(i, hpfs_pos_del, (t = get_pos(dnode, de)) + 1, 1);
-	hpfs_delete_de(i->i_sb, dnode, de);
+	hpfs_delete_de(inode_sb(i), dnode, de);
 	hpfs_mark_4buffers_dirty(qbh);
 	hpfs_brelse4(qbh);
 	if (down) {
@@ -856,20 +880,20 @@ struct hpfs_dirent *map_pos_dirent(struct inode *inode, loff_t *posp,
 	pos = *posp;
 	dno = pos >> 6 << 2;
 	pos &= 077;
-	if (!(de = map_nth_dirent(inode->i_sb, dno, pos, qbh, &dnode)))
+	if (!(de = map_nth_dirent(inode_sb(inode), dno, pos, qbh, &dnode)))
 		goto bail;
 
 	/* Going to the next dirent */
 	if ((d = de_next_de(de)) < dnode_end_de(dnode)) {
 		if (!(++*posp & 077)) {
-			hpfs_error(inode->i_sb,
-				"map_pos_dirent: pos crossed dnode boundary; pos = %08llx",
-				(unsigned long long)*posp);
+			hpfs_error(inode_sb(inode),
+				   "map_pos_dirent: pos crossed dnode boundary; pos = %08llx",
+				   (unsigned long long)*posp);
 			goto bail;
 		}
 		/* We're going down the tree */
 		if (d->down) {
-			*posp = ((loff_t) hpfs_de_as_down_as_possible(inode->i_sb, de_down_pointer(d)) << 4) + 1;
+			*posp = ((loff_t) hpfs_de_as_down_as_possible(inode_sb(inode), de_down_pointer(d)) << 4) + 1;
 		}
 	
 		return de;
@@ -878,15 +902,16 @@ struct hpfs_dirent *map_pos_dirent(struct inode *inode, loff_t *posp,
 	/* Going up */
 	if (dnode->root_dnode) goto bail;
 
-	if (!(up_dnode = hpfs_map_dnode(inode->i_sb, le32_to_cpu(dnode->up), &qbh0)))
+	if (!(up_dnode = hpfs_map_dnode(inode_sb(inode), le32_to_cpu(dnode->up), &qbh0)))
 		goto bail;
 
 	end_up_de = dnode_end_de(up_dnode);
 	c = 0;
 	for (up_de = dnode_first_de(up_dnode); up_de < end_up_de;
 	     up_de = de_next_de(up_de)) {
-		if (!(++c & 077)) hpfs_error(inode->i_sb,
-			"map_pos_dirent: pos crossed dnode boundary; dnode = %08x", le32_to_cpu(dnode->up));
+		if (!(++c & 077)) hpfs_error(inode_sb(inode),
+					     "map_pos_dirent: pos crossed dnode boundary; dnode = %08x",
+					     le32_to_cpu(dnode->up));
 		if (up_de->down && de_down_pointer(up_de) == dno) {
 			*posp = ((loff_t) le32_to_cpu(dnode->up) << 4) + c;
 			hpfs_brelse4(&qbh0);
@@ -894,8 +919,9 @@ struct hpfs_dirent *map_pos_dirent(struct inode *inode, loff_t *posp,
 		}
 	}
 	
-	hpfs_error(inode->i_sb, "map_pos_dirent: pointer to dnode %08x not found in parent dnode %08x",
-		dno, le32_to_cpu(dnode->up));
+	hpfs_error(inode_sb(inode),
+		   "map_pos_dirent: pointer to dnode %08x not found in parent dnode %08x",
+		   dno, le32_to_cpu(dnode->up));
 	hpfs_brelse4(&qbh0);
 	
 	bail:
@@ -914,15 +940,17 @@ struct hpfs_dirent *map_dirent(struct inode *inode, dnode_secno dno,
 	struct hpfs_dirent *de_end;
 	int c1, c2 = 0;
 
-	if (!S_ISDIR(inode->i_mode)) hpfs_error(inode->i_sb, "map_dirent: not a directory\n");
+	if (!S_ISDIR(inode->i_mode)) hpfs_error(inode_sb(inode),
+						"map_dirent: not a directory\n");
 	again:
-	if (hpfs_sb(inode->i_sb)->sb_chk)
-		if (hpfs_stop_cycles(inode->i_sb, dno, &c1, &c2, "map_dirent")) return NULL;
-	if (!(dnode = hpfs_map_dnode(inode->i_sb, dno, qbh))) return NULL;
+	if (hpfs_sb(inode_sb(inode))->sb_chk)
+		if (hpfs_stop_cycles(inode_sb(inode), dno, &c1, &c2, "map_dirent")) return NULL;
+	if (!(dnode = hpfs_map_dnode(inode_sb(inode), dno, qbh))) return NULL;
 	
 	de_end = dnode_end_de(dnode);
 	for (de = dnode_first_de(dnode); de < de_end; de = de_next_de(de)) {
-		int t = hpfs_compare_names(inode->i_sb, name, len, de->name, de->namelen, de->last);
+		int t = hpfs_compare_names(inode_sb(inode), name, len,
+					   de->name, de->namelen, de->last);
 		if (!t) {
 			if (dd) *dd = dno;
 			return de;
diff --git a/fs/hpfs/ea.c b/fs/hpfs/ea.c
index 102ba18e561f..4c973239b948 100644
--- a/fs/hpfs/ea.c
+++ b/fs/hpfs/ea.c
@@ -191,7 +191,7 @@ void hpfs_set_ea(struct inode *inode, struct fnode *fnode, const char *key,
 		 const char *data, int size)
 {
 	fnode_secno fno = inode->i_ino;
-	struct super_block *s = inode->i_sb;
+	struct super_block *s = inode_sb(inode);
 	unsigned pos;
 	int ano, len;
 	secno a;
diff --git a/fs/hpfs/file.c b/fs/hpfs/file.c
index 1ecec124e76f..3877807b08f4 100644
--- a/fs/hpfs/file.c
+++ b/fs/hpfs/file.c
@@ -14,9 +14,9 @@
 
 static int hpfs_file_release(struct inode *inode, struct file *file)
 {
-	hpfs_lock(inode->i_sb);
+	hpfs_lock(inode_sb(inode));
 	hpfs_write_if_changed(inode);
-	hpfs_unlock(inode->i_sb);
+	hpfs_unlock(inode_sb(inode));
 	return 0;
 }
 
@@ -28,7 +28,7 @@ int hpfs_file_fsync(struct file *file, loff_t start, loff_t end, int datasync)
 	ret = file_write_and_wait_range(file, start, end);
 	if (ret)
 		return ret;
-	return sync_blockdev(inode->i_sb->s_bdev);
+	return sync_blockdev(inode_sb(inode)->s_bdev);
 }
 
 /*
@@ -48,10 +48,11 @@ static secno hpfs_bmap(struct inode *inode, unsigned file_secno, unsigned *n_sec
 		*n_secs = hpfs_inode->i_n_secs - n;
 		return hpfs_inode->i_disk_sec + n;
 	}
-	if (!(fnode = hpfs_map_fnode(inode->i_sb, inode->i_ino, &bh))) return 0;
-	disk_secno = hpfs_bplus_lookup(inode->i_sb, inode, &fnode->btree, file_secno, bh);
+	if (!(fnode = hpfs_map_fnode(inode_sb(inode), inode->i_ino, &bh))) return 0;
+	disk_secno = hpfs_bplus_lookup(inode_sb(inode), inode, &fnode->btree,
+				       file_secno, bh);
 	if (disk_secno == -1) return 0;
-	if (hpfs_chk_sectors(inode->i_sb, disk_secno, 1, "bmap")) return 0;
+	if (hpfs_chk_sectors(inode_sb(inode), disk_secno, 1, "bmap")) return 0;
 	n = file_secno - hpfs_inode->i_file_sec;
 	if (n < hpfs_inode->i_n_secs) {
 		*n_secs = hpfs_inode->i_n_secs - n;
@@ -64,12 +65,13 @@ static secno hpfs_bmap(struct inode *inode, unsigned file_secno, unsigned *n_sec
 void hpfs_truncate(struct inode *i)
 {
 	if (IS_IMMUTABLE(i)) return /*-EPERM*/;
-	hpfs_lock_assert(i->i_sb);
+	hpfs_lock_assert(inode_sb(i));
 
 	hpfs_i(i)->i_n_secs = 0;
 	i->i_blocks = 1 + ((i->i_size + 511) >> 9);
 	hpfs_i(i)->mmu_private = i->i_size;
-	hpfs_truncate_btree(i->i_sb, i->i_ino, 1, ((i->i_size + 511) >> 9));
+	hpfs_truncate_btree(inode_sb(i), i->i_ino, 1,
+			    ((i->i_size + 511) >> 9));
 	hpfs_write_inode(i);
 	hpfs_i(i)->i_n_secs = 0;
 }
@@ -79,17 +81,18 @@ static int hpfs_get_block(struct inode *inode, sector_t iblock, struct buffer_he
 	int r;
 	secno s;
 	unsigned n_secs;
-	hpfs_lock(inode->i_sb);
+	hpfs_lock(inode_sb(inode));
 	s = hpfs_bmap(inode, iblock, &n_secs);
 	if (s) {
 		if (bh_result->b_size >> 9 < n_secs)
 			n_secs = bh_result->b_size >> 9;
-		n_secs = hpfs_search_hotfix_map_for_range(inode->i_sb, s, n_secs);
+		n_secs = hpfs_search_hotfix_map_for_range(inode_sb(inode), s,
+							  n_secs);
 		if (unlikely(!n_secs)) {
-			s = hpfs_search_hotfix_map(inode->i_sb, s);
+			s = hpfs_search_hotfix_map(inode_sb(inode), s);
 			n_secs = 1;
 		}
-		map_bh(bh_result, inode->i_sb, s);
+		map_bh(bh_result, inode_sb(inode), s);
 		bh_result->b_size = n_secs << 9;
 		goto ret_0;
 	}
@@ -99,19 +102,21 @@ static int hpfs_get_block(struct inode *inode, sector_t iblock, struct buffer_he
 		r = -EIO;
 		goto ret_r;
 	}
-	if ((s = hpfs_add_sector_to_btree(inode->i_sb, inode->i_ino, 1, inode->i_blocks - 1)) == -1) {
-		hpfs_truncate_btree(inode->i_sb, inode->i_ino, 1, inode->i_blocks - 1);
+	if ((s = hpfs_add_sector_to_btree(inode_sb(inode), inode->i_ino, 1, inode->i_blocks - 1)) == -1) {
+		hpfs_truncate_btree(inode_sb(inode), inode->i_ino, 1,
+				    inode->i_blocks - 1);
 		r = -ENOSPC;
 		goto ret_r;
 	}
 	inode->i_blocks++;
 	hpfs_i(inode)->mmu_private += 512;
 	set_buffer_new(bh_result);
-	map_bh(bh_result, inode->i_sb, hpfs_search_hotfix_map(inode->i_sb, s));
+	map_bh(bh_result, inode_sb(inode),
+	       hpfs_search_hotfix_map(inode_sb(inode), s));
 	ret_0:
 	r = 0;
 	ret_r:
-	hpfs_unlock(inode->i_sb);
+	hpfs_unlock(inode_sb(inode));
 	return r;
 }
 
@@ -141,14 +146,14 @@ static void hpfs_write_failed(struct address_space *mapping, loff_t to)
 {
 	struct inode *inode = mapping->host;
 
-	hpfs_lock(inode->i_sb);
+	hpfs_lock(inode_sb(inode));
 
 	if (to > inode->i_size) {
 		truncate_pagecache(inode, inode->i_size);
 		hpfs_truncate(inode);
 	}
 
-	hpfs_unlock(inode->i_sb);
+	hpfs_unlock(inode_sb(inode));
 }
 
 static int hpfs_write_begin(struct file *file, struct address_space *mapping,
@@ -178,9 +183,9 @@ static int hpfs_write_end(struct file *file, struct address_space *mapping,
 		hpfs_write_failed(mapping, pos + len);
 	if (!(err < 0)) {
 		/* make sure we write it on close, if not earlier */
-		hpfs_lock(inode->i_sb);
+		hpfs_lock(inode_sb(inode));
 		hpfs_i(inode)->i_dirty = 1;
-		hpfs_unlock(inode->i_sb);
+		hpfs_unlock(inode_sb(inode));
 	}
 	return err;
 }
diff --git a/fs/hpfs/inode.c b/fs/hpfs/inode.c
index eb8b4baf0f2e..eab8df9daa8c 100644
--- a/fs/hpfs/inode.c
+++ b/fs/hpfs/inode.c
@@ -13,7 +13,7 @@
 
 void hpfs_init_inode(struct inode *i)
 {
-	struct super_block *sb = i->i_sb;
+	struct super_block *sb = inode_sb(i);
 	struct hpfs_inode_info *hpfs_inode = hpfs_i(i);
 
 	i->i_uid = hpfs_sb(sb)->sb_uid;
@@ -45,7 +45,7 @@ void hpfs_read_inode(struct inode *i)
 {
 	struct buffer_head *bh;
 	struct fnode *fnode;
-	struct super_block *sb = i->i_sb;
+	struct super_block *sb = inode_sb(i);
 	struct hpfs_inode_info *hpfs_inode = hpfs_i(i);
 	void *ea;
 	int ea_size;
@@ -59,22 +59,22 @@ void hpfs_read_inode(struct inode *i)
 		make_bad_inode(i);
 		return;
 	}
-	if (hpfs_sb(i->i_sb)->sb_eas) {
-		if ((ea = hpfs_get_ea(i->i_sb, fnode, "UID", &ea_size))) {
+	if (hpfs_sb(inode_sb(i))->sb_eas) {
+		if ((ea = hpfs_get_ea(inode_sb(i), fnode, "UID", &ea_size))) {
 			if (ea_size == 2) {
 				i_uid_write(i, le16_to_cpu(*(__le16*)ea));
 				hpfs_inode->i_ea_uid = 1;
 			}
 			kfree(ea);
 		}
-		if ((ea = hpfs_get_ea(i->i_sb, fnode, "GID", &ea_size))) {
+		if ((ea = hpfs_get_ea(inode_sb(i), fnode, "GID", &ea_size))) {
 			if (ea_size == 2) {
 				i_gid_write(i, le16_to_cpu(*(__le16*)ea));
 				hpfs_inode->i_ea_gid = 1;
 			}
 			kfree(ea);
 		}
-		if ((ea = hpfs_get_ea(i->i_sb, fnode, "SYMLINK", &ea_size))) {
+		if ((ea = hpfs_get_ea(inode_sb(i), fnode, "SYMLINK", &ea_size))) {
 			kfree(ea);
 			i->i_mode = S_IFLNK | 0777;
 			i->i_op = &page_symlink_inode_operations;
@@ -86,7 +86,7 @@ void hpfs_read_inode(struct inode *i)
 			brelse(bh);
 			return;
 		}
-		if ((ea = hpfs_get_ea(i->i_sb, fnode, "MODE", &ea_size))) {
+		if ((ea = hpfs_get_ea(inode_sb(i), fnode, "MODE", &ea_size))) {
 			int rdev = 0;
 			umode_t mode = hpfs_sb(sb)->sb_mode;
 			if (ea_size == 2) {
@@ -96,7 +96,7 @@ void hpfs_read_inode(struct inode *i)
 			kfree(ea);
 			i->i_mode = mode;
 			if (S_ISBLK(mode) || S_ISCHR(mode)) {
-				if ((ea = hpfs_get_ea(i->i_sb, fnode, "DEV", &ea_size))) {
+				if ((ea = hpfs_get_ea(inode_sb(i), fnode, "DEV", &ea_size))) {
 					if (ea_size == 4)
 						rdev = le32_to_cpu(*(__le32*)ea);
 					kfree(ea);
@@ -125,7 +125,8 @@ void hpfs_read_inode(struct inode *i)
 			if (hpfs_map_fnode(sb, hpfs_inode->i_parent_dir, &bh0)) brelse(bh0);
 		}
 		n_dnodes = 0; n_subdirs = 0;
-		hpfs_count_dnodes(i->i_sb, hpfs_inode->i_dno, &n_dnodes, &n_subdirs, NULL);
+		hpfs_count_dnodes(inode_sb(i), hpfs_inode->i_dno, &n_dnodes,
+				  &n_subdirs, NULL);
 		i->i_blocks = 4 * n_dnodes;
 		i->i_size = 2048 * n_dnodes;
 		set_nlink(i, 2 + n_subdirs);
@@ -149,24 +150,24 @@ static void hpfs_write_inode_ea(struct inode *i, struct fnode *fnode)
 	/*if (le32_to_cpu(fnode->acl_size_l) || le16_to_cpu(fnode->acl_size_s)) {
 		   Some unknown structures like ACL may be in fnode,
 		   we'd better not overwrite them
-		hpfs_error(i->i_sb, "fnode %08x has some unknown HPFS386 structures", i->i_ino);
-	} else*/ if (hpfs_sb(i->i_sb)->sb_eas >= 2) {
+		hpfs_error(inode_sb(i), "fnode %08x has some unknown HPFS386 structures", i->i_ino);
+	} else*/ if (hpfs_sb(inode_sb(i))->sb_eas >= 2) {
 		__le32 ea;
-		if (!uid_eq(i->i_uid, hpfs_sb(i->i_sb)->sb_uid) || hpfs_inode->i_ea_uid) {
+		if (!uid_eq(i->i_uid, hpfs_sb(inode_sb(i))->sb_uid) || hpfs_inode->i_ea_uid) {
 			ea = cpu_to_le32(i_uid_read(i));
 			hpfs_set_ea(i, fnode, "UID", (char*)&ea, 2);
 			hpfs_inode->i_ea_uid = 1;
 		}
-		if (!gid_eq(i->i_gid, hpfs_sb(i->i_sb)->sb_gid) || hpfs_inode->i_ea_gid) {
+		if (!gid_eq(i->i_gid, hpfs_sb(inode_sb(i))->sb_gid) || hpfs_inode->i_ea_gid) {
 			ea = cpu_to_le32(i_gid_read(i));
 			hpfs_set_ea(i, fnode, "GID", (char *)&ea, 2);
 			hpfs_inode->i_ea_gid = 1;
 		}
 		if (!S_ISLNK(i->i_mode))
-			if ((i->i_mode != ((hpfs_sb(i->i_sb)->sb_mode & ~(S_ISDIR(i->i_mode) ? 0 : 0111))
-			  | (S_ISDIR(i->i_mode) ? S_IFDIR : S_IFREG))
-			  && i->i_mode != ((hpfs_sb(i->i_sb)->sb_mode & ~(S_ISDIR(i->i_mode) ? 0222 : 0333))
-			  | (S_ISDIR(i->i_mode) ? S_IFDIR : S_IFREG))) || hpfs_inode->i_ea_mode) {
+			if ((i->i_mode != ((hpfs_sb(inode_sb(i))->sb_mode & ~(S_ISDIR(i->i_mode) ? 0 : 0111))
+					   | (S_ISDIR(i->i_mode) ? S_IFDIR : S_IFREG))
+			     && i->i_mode != ((hpfs_sb(inode_sb(i))->sb_mode & ~(S_ISDIR(i->i_mode) ? 0222 : 0333))
+					      | (S_ISDIR(i->i_mode) ? S_IFDIR : S_IFREG))) || hpfs_inode->i_ea_mode) {
 				ea = cpu_to_le32(i->i_mode);
 				/* sick, but legal */
 				hpfs_set_ea(i, fnode, "MODE", (char *)&ea, 2);
@@ -183,7 +184,7 @@ void hpfs_write_inode(struct inode *i)
 {
 	struct hpfs_inode_info *hpfs_inode = hpfs_i(i);
 	struct inode *parent;
-	if (i->i_ino == hpfs_sb(i->i_sb)->sb_root) return;
+	if (i->i_ino == hpfs_sb(inode_sb(i))->sb_root) return;
 	if (hpfs_inode->i_rddir_off && !atomic_read(&i->i_count)) {
 		if (*hpfs_inode->i_rddir_off)
 			pr_err("write_inode: some position still there\n");
@@ -193,7 +194,7 @@ void hpfs_write_inode(struct inode *i)
 	if (!i->i_nlink) {
 		return;
 	}
-	parent = iget_locked(i->i_sb, hpfs_inode->i_parent_dir);
+	parent = iget_locked(inode_sb(i), hpfs_inode->i_parent_dir);
 	if (parent) {
 		hpfs_inode->i_dirty = 0;
 		if (parent->i_state & I_NEW) {
@@ -213,10 +214,10 @@ void hpfs_write_inode_nolock(struct inode *i)
 	struct fnode *fnode;
 	struct quad_buffer_head qbh;
 	struct hpfs_dirent *de;
-	if (i->i_ino == hpfs_sb(i->i_sb)->sb_root) return;
-	if (!(fnode = hpfs_map_fnode(i->i_sb, i->i_ino, &bh))) return;
-	if (i->i_ino != hpfs_sb(i->i_sb)->sb_root && i->i_nlink) {
-		if (!(de = map_fnode_dirent(i->i_sb, i->i_ino, fnode, &qbh))) {
+	if (i->i_ino == hpfs_sb(inode_sb(i))->sb_root) return;
+	if (!(fnode = hpfs_map_fnode(inode_sb(i), i->i_ino, &bh))) return;
+	if (i->i_ino != hpfs_sb(inode_sb(i))->sb_root && i->i_nlink) {
+		if (!(de = map_fnode_dirent(inode_sb(i), i->i_ino, fnode, &qbh))) {
 			brelse(bh);
 			return;
 		}
@@ -230,9 +231,9 @@ void hpfs_write_inode_nolock(struct inode *i)
 	}
 	hpfs_write_inode_ea(i, fnode);
 	if (de) {
-		de->write_date = cpu_to_le32(gmt_to_local(i->i_sb, i->i_mtime.tv_sec));
-		de->read_date = cpu_to_le32(gmt_to_local(i->i_sb, i->i_atime.tv_sec));
-		de->creation_date = cpu_to_le32(gmt_to_local(i->i_sb, i->i_ctime.tv_sec));
+		de->write_date = cpu_to_le32(gmt_to_local(inode_sb(i), i->i_mtime.tv_sec));
+		de->read_date = cpu_to_le32(gmt_to_local(inode_sb(i), i->i_atime.tv_sec));
+		de->creation_date = cpu_to_le32(gmt_to_local(inode_sb(i), i->i_ctime.tv_sec));
 		de->read_only = !(i->i_mode & 0222);
 		de->ea_size = cpu_to_le32(hpfs_inode->i_ea_size);
 		hpfs_mark_4buffers_dirty(&qbh);
@@ -240,18 +241,18 @@ void hpfs_write_inode_nolock(struct inode *i)
 	}
 	if (S_ISDIR(i->i_mode)) {
 		if ((de = map_dirent(i, hpfs_inode->i_dno, "\001\001", 2, NULL, &qbh))) {
-			de->write_date = cpu_to_le32(gmt_to_local(i->i_sb, i->i_mtime.tv_sec));
-			de->read_date = cpu_to_le32(gmt_to_local(i->i_sb, i->i_atime.tv_sec));
-			de->creation_date = cpu_to_le32(gmt_to_local(i->i_sb, i->i_ctime.tv_sec));
+			de->write_date = cpu_to_le32(gmt_to_local(inode_sb(i), i->i_mtime.tv_sec));
+			de->read_date = cpu_to_le32(gmt_to_local(inode_sb(i), i->i_atime.tv_sec));
+			de->creation_date = cpu_to_le32(gmt_to_local(inode_sb(i), i->i_ctime.tv_sec));
 			de->read_only = !(i->i_mode & 0222);
 			de->ea_size = cpu_to_le32(/*hpfs_inode->i_ea_size*/0);
 			de->file_size = cpu_to_le32(0);
 			hpfs_mark_4buffers_dirty(&qbh);
 			hpfs_brelse4(&qbh);
 		} else
-			hpfs_error(i->i_sb,
-				"directory %08lx doesn't have '.' entry",
-				(unsigned long)i->i_ino);
+			hpfs_error(inode_sb(i),
+				   "directory %08lx doesn't have '.' entry",
+				   (unsigned long)i->i_ino);
 	}
 	mark_buffer_dirty(bh);
 	brelse(bh);
@@ -262,8 +263,8 @@ int hpfs_setattr(struct dentry *dentry, struct iattr *attr)
 	struct inode *inode = d_inode(dentry);
 	int error = -EINVAL;
 
-	hpfs_lock(inode->i_sb);
-	if (inode->i_ino == hpfs_sb(inode->i_sb)->sb_root)
+	hpfs_lock(inode_sb(inode));
+	if (inode->i_ino == hpfs_sb(inode_sb(inode))->sb_root)
 		goto out_unlock;
 	if ((attr->ia_valid & ATTR_UID) &&
 	    from_kuid(&init_user_ns, attr->ia_uid) >= 0x10000)
@@ -293,7 +294,7 @@ int hpfs_setattr(struct dentry *dentry, struct iattr *attr)
 	hpfs_write_inode(inode);
 
  out_unlock:
-	hpfs_unlock(inode->i_sb);
+	hpfs_unlock(inode_sb(inode));
 	return error;
 }
 
@@ -310,8 +311,8 @@ void hpfs_evict_inode(struct inode *inode)
 	truncate_inode_pages_final(&inode->i_data);
 	clear_inode(inode);
 	if (!inode->i_nlink) {
-		hpfs_lock(inode->i_sb);
-		hpfs_remove_fnode(inode->i_sb, inode->i_ino);
-		hpfs_unlock(inode->i_sb);
+		hpfs_lock(inode_sb(inode));
+		hpfs_remove_fnode(inode_sb(inode), inode->i_ino);
+		hpfs_unlock(inode_sb(inode));
 	}
 }
diff --git a/fs/hpfs/namei.c b/fs/hpfs/namei.c
index a3615e4c730d..605fe8f2ad9c 100644
--- a/fs/hpfs/namei.c
+++ b/fs/hpfs/namei.c
@@ -36,12 +36,12 @@ static int hpfs_mkdir(struct inode *dir, struct dentry *dentry, umode_t mode)
 	struct hpfs_dirent dee;
 	int err;
 	if ((err = hpfs_chk_name(name, &len))) return err==-ENOENT ? -EINVAL : err;
-	hpfs_lock(dir->i_sb);
+	hpfs_lock(inode_sb(dir));
 	err = -ENOSPC;
-	fnode = hpfs_alloc_fnode(dir->i_sb, hpfs_i(dir)->i_dno, &fno, &bh);
+	fnode = hpfs_alloc_fnode(inode_sb(dir), hpfs_i(dir)->i_dno, &fno, &bh);
 	if (!fnode)
 		goto bail;
-	dnode = hpfs_alloc_dnode(dir->i_sb, fno, &dno, &qbh0);
+	dnode = hpfs_alloc_dnode(inode_sb(dir), fno, &dno, &qbh0);
 	if (!dnode)
 		goto bail1;
 	memset(&dee, 0, sizeof dee);
@@ -50,15 +50,16 @@ static int hpfs_mkdir(struct inode *dir, struct dentry *dentry, umode_t mode)
 	/*dee.archive = 0;*/
 	dee.hidden = name[0] == '.';
 	dee.fnode = cpu_to_le32(fno);
-	dee.creation_date = dee.write_date = dee.read_date = cpu_to_le32(gmt_to_local(dir->i_sb, get_seconds()));
-	result = new_inode(dir->i_sb);
+	dee.creation_date = dee.write_date = dee.read_date = cpu_to_le32(gmt_to_local(inode_sb(dir), get_seconds()));
+	result = new_inode(inode_sb(dir));
 	if (!result)
 		goto bail2;
 	hpfs_init_inode(result);
 	result->i_ino = fno;
 	hpfs_i(result)->i_parent_dir = dir->i_ino;
 	hpfs_i(result)->i_dno = dno;
-	result->i_ctime.tv_sec = result->i_mtime.tv_sec = result->i_atime.tv_sec = local_to_gmt(dir->i_sb, le32_to_cpu(dee.creation_date));
+	result->i_ctime.tv_sec = result->i_mtime.tv_sec = result->i_atime.tv_sec = local_to_gmt(inode_sb(dir),
+												le32_to_cpu(dee.creation_date));
 	result->i_ctime.tv_nsec = 0; 
 	result->i_mtime.tv_nsec = 0; 
 	result->i_atime.tv_nsec = 0; 
@@ -90,8 +91,8 @@ static int hpfs_mkdir(struct inode *dir, struct dentry *dentry, umode_t mode)
 	fnode->u.external[0].file_secno = cpu_to_le32(-1);
 	dnode->root_dnode = 1;
 	dnode->up = cpu_to_le32(fno);
-	de = hpfs_add_de(dir->i_sb, dnode, "\001\001", 2, 0);
-	de->creation_date = de->write_date = de->read_date = cpu_to_le32(gmt_to_local(dir->i_sb, get_seconds()));
+	de = hpfs_add_de(inode_sb(dir), dnode, "\001\001", 2, 0);
+	de->creation_date = de->write_date = de->read_date = cpu_to_le32(gmt_to_local(inode_sb(dir), get_seconds()));
 	if (!(mode & 0222)) de->read_only = 1;
 	de->first = de->directory = 1;
 	/*de->hidden = de->system = 0;*/
@@ -113,18 +114,18 @@ static int hpfs_mkdir(struct inode *dir, struct dentry *dentry, umode_t mode)
 	}
 	hpfs_update_directory_times(dir);
 	d_instantiate(dentry, result);
-	hpfs_unlock(dir->i_sb);
+	hpfs_unlock(inode_sb(dir));
 	return 0;
 bail3:
 	iput(result);
 bail2:
 	hpfs_brelse4(&qbh0);
-	hpfs_free_dnode(dir->i_sb, dno);
+	hpfs_free_dnode(inode_sb(dir), dno);
 bail1:
 	brelse(bh);
-	hpfs_free_sectors(dir->i_sb, fno, 1);
+	hpfs_free_sectors(inode_sb(dir), fno, 1);
 bail:
-	hpfs_unlock(dir->i_sb);
+	hpfs_unlock(inode_sb(dir));
 	return err;
 }
 
@@ -141,9 +142,9 @@ static int hpfs_create(struct inode *dir, struct dentry *dentry, umode_t mode, b
 	int err;
 	if ((err = hpfs_chk_name(name, &len)))
 		return err==-ENOENT ? -EINVAL : err;
-	hpfs_lock(dir->i_sb);
+	hpfs_lock(inode_sb(dir));
 	err = -ENOSPC;
-	fnode = hpfs_alloc_fnode(dir->i_sb, hpfs_i(dir)->i_dno, &fno, &bh);
+	fnode = hpfs_alloc_fnode(inode_sb(dir), hpfs_i(dir)->i_dno, &fno, &bh);
 	if (!fnode)
 		goto bail;
 	memset(&dee, 0, sizeof dee);
@@ -151,9 +152,9 @@ static int hpfs_create(struct inode *dir, struct dentry *dentry, umode_t mode, b
 	dee.archive = 1;
 	dee.hidden = name[0] == '.';
 	dee.fnode = cpu_to_le32(fno);
-	dee.creation_date = dee.write_date = dee.read_date = cpu_to_le32(gmt_to_local(dir->i_sb, get_seconds()));
+	dee.creation_date = dee.write_date = dee.read_date = cpu_to_le32(gmt_to_local(inode_sb(dir), get_seconds()));
 
-	result = new_inode(dir->i_sb);
+	result = new_inode(inode_sb(dir));
 	if (!result)
 		goto bail1;
 	
@@ -165,7 +166,8 @@ static int hpfs_create(struct inode *dir, struct dentry *dentry, umode_t mode, b
 	result->i_fop = &hpfs_file_ops;
 	set_nlink(result, 1);
 	hpfs_i(result)->i_parent_dir = dir->i_ino;
-	result->i_ctime.tv_sec = result->i_mtime.tv_sec = result->i_atime.tv_sec = local_to_gmt(dir->i_sb, le32_to_cpu(dee.creation_date));
+	result->i_ctime.tv_sec = result->i_mtime.tv_sec = result->i_atime.tv_sec = local_to_gmt(inode_sb(dir),
+												le32_to_cpu(dee.creation_date));
 	result->i_ctime.tv_nsec = 0;
 	result->i_mtime.tv_nsec = 0;
 	result->i_atime.tv_nsec = 0;
@@ -202,16 +204,16 @@ static int hpfs_create(struct inode *dir, struct dentry *dentry, umode_t mode, b
 	}
 	hpfs_update_directory_times(dir);
 	d_instantiate(dentry, result);
-	hpfs_unlock(dir->i_sb);
+	hpfs_unlock(inode_sb(dir));
 	return 0;
 
 bail2:
 	iput(result);
 bail1:
 	brelse(bh);
-	hpfs_free_sectors(dir->i_sb, fno, 1);
+	hpfs_free_sectors(inode_sb(dir), fno, 1);
 bail:
-	hpfs_unlock(dir->i_sb);
+	hpfs_unlock(inode_sb(dir));
 	return err;
 }
 
@@ -227,10 +229,10 @@ static int hpfs_mknod(struct inode *dir, struct dentry *dentry, umode_t mode, de
 	struct inode *result = NULL;
 	int err;
 	if ((err = hpfs_chk_name(name, &len))) return err==-ENOENT ? -EINVAL : err;
-	if (hpfs_sb(dir->i_sb)->sb_eas < 2) return -EPERM;
-	hpfs_lock(dir->i_sb);
+	if (hpfs_sb(inode_sb(dir))->sb_eas < 2) return -EPERM;
+	hpfs_lock(inode_sb(dir));
 	err = -ENOSPC;
-	fnode = hpfs_alloc_fnode(dir->i_sb, hpfs_i(dir)->i_dno, &fno, &bh);
+	fnode = hpfs_alloc_fnode(inode_sb(dir), hpfs_i(dir)->i_dno, &fno, &bh);
 	if (!fnode)
 		goto bail;
 	memset(&dee, 0, sizeof dee);
@@ -238,16 +240,17 @@ static int hpfs_mknod(struct inode *dir, struct dentry *dentry, umode_t mode, de
 	dee.archive = 1;
 	dee.hidden = name[0] == '.';
 	dee.fnode = cpu_to_le32(fno);
-	dee.creation_date = dee.write_date = dee.read_date = cpu_to_le32(gmt_to_local(dir->i_sb, get_seconds()));
+	dee.creation_date = dee.write_date = dee.read_date = cpu_to_le32(gmt_to_local(inode_sb(dir), get_seconds()));
 
-	result = new_inode(dir->i_sb);
+	result = new_inode(inode_sb(dir));
 	if (!result)
 		goto bail1;
 
 	hpfs_init_inode(result);
 	result->i_ino = fno;
 	hpfs_i(result)->i_parent_dir = dir->i_ino;
-	result->i_ctime.tv_sec = result->i_mtime.tv_sec = result->i_atime.tv_sec = local_to_gmt(dir->i_sb, le32_to_cpu(dee.creation_date));
+	result->i_ctime.tv_sec = result->i_mtime.tv_sec = result->i_atime.tv_sec = local_to_gmt(inode_sb(dir),
+												le32_to_cpu(dee.creation_date));
 	result->i_ctime.tv_nsec = 0;
 	result->i_mtime.tv_nsec = 0;
 	result->i_atime.tv_nsec = 0;
@@ -277,15 +280,15 @@ static int hpfs_mknod(struct inode *dir, struct dentry *dentry, umode_t mode, de
 	hpfs_update_directory_times(dir);
 	d_instantiate(dentry, result);
 	brelse(bh);
-	hpfs_unlock(dir->i_sb);
+	hpfs_unlock(inode_sb(dir));
 	return 0;
 bail2:
 	iput(result);
 bail1:
 	brelse(bh);
-	hpfs_free_sectors(dir->i_sb, fno, 1);
+	hpfs_free_sectors(inode_sb(dir), fno, 1);
 bail:
-	hpfs_unlock(dir->i_sb);
+	hpfs_unlock(inode_sb(dir));
 	return err;
 }
 
@@ -301,28 +304,29 @@ static int hpfs_symlink(struct inode *dir, struct dentry *dentry, const char *sy
 	struct inode *result;
 	int err;
 	if ((err = hpfs_chk_name(name, &len))) return err==-ENOENT ? -EINVAL : err;
-	hpfs_lock(dir->i_sb);
-	if (hpfs_sb(dir->i_sb)->sb_eas < 2) {
-		hpfs_unlock(dir->i_sb);
+	hpfs_lock(inode_sb(dir));
+	if (hpfs_sb(inode_sb(dir))->sb_eas < 2) {
+		hpfs_unlock(inode_sb(dir));
 		return -EPERM;
 	}
 	err = -ENOSPC;
-	fnode = hpfs_alloc_fnode(dir->i_sb, hpfs_i(dir)->i_dno, &fno, &bh);
+	fnode = hpfs_alloc_fnode(inode_sb(dir), hpfs_i(dir)->i_dno, &fno, &bh);
 	if (!fnode)
 		goto bail;
 	memset(&dee, 0, sizeof dee);
 	dee.archive = 1;
 	dee.hidden = name[0] == '.';
 	dee.fnode = cpu_to_le32(fno);
-	dee.creation_date = dee.write_date = dee.read_date = cpu_to_le32(gmt_to_local(dir->i_sb, get_seconds()));
+	dee.creation_date = dee.write_date = dee.read_date = cpu_to_le32(gmt_to_local(inode_sb(dir), get_seconds()));
 
-	result = new_inode(dir->i_sb);
+	result = new_inode(inode_sb(dir));
 	if (!result)
 		goto bail1;
 	result->i_ino = fno;
 	hpfs_init_inode(result);
 	hpfs_i(result)->i_parent_dir = dir->i_ino;
-	result->i_ctime.tv_sec = result->i_mtime.tv_sec = result->i_atime.tv_sec = local_to_gmt(dir->i_sb, le32_to_cpu(dee.creation_date));
+	result->i_ctime.tv_sec = result->i_mtime.tv_sec = result->i_atime.tv_sec = local_to_gmt(inode_sb(dir),
+												le32_to_cpu(dee.creation_date));
 	result->i_ctime.tv_nsec = 0;
 	result->i_mtime.tv_nsec = 0;
 	result->i_atime.tv_nsec = 0;
@@ -356,15 +360,15 @@ static int hpfs_symlink(struct inode *dir, struct dentry *dentry, const char *sy
 	hpfs_write_inode_nolock(result);
 	hpfs_update_directory_times(dir);
 	d_instantiate(dentry, result);
-	hpfs_unlock(dir->i_sb);
+	hpfs_unlock(inode_sb(dir));
 	return 0;
 bail2:
 	iput(result);
 bail1:
 	brelse(bh);
-	hpfs_free_sectors(dir->i_sb, fno, 1);
+	hpfs_free_sectors(inode_sb(dir), fno, 1);
 bail:
-	hpfs_unlock(dir->i_sb);
+	hpfs_unlock(inode_sb(dir));
 	return err;
 }
 
@@ -379,7 +383,7 @@ static int hpfs_unlink(struct inode *dir, struct dentry *dentry)
 	int r;
 	int err;
 
-	hpfs_lock(dir->i_sb);
+	hpfs_lock(inode_sb(dir));
 	hpfs_adjust_length(name, &len);
 
 	err = -ENOENT;
@@ -398,7 +402,8 @@ static int hpfs_unlink(struct inode *dir, struct dentry *dentry)
 	r = hpfs_remove_dirent(dir, dno, de, &qbh, 1);
 	switch (r) {
 	case 1:
-		hpfs_error(dir->i_sb, "there was error when removing dirent");
+		hpfs_error(inode_sb(dir),
+			   "there was error when removing dirent");
 		err = -EFSERROR;
 		break;
 	case 2:		/* no space for deleting */
@@ -415,7 +420,7 @@ static int hpfs_unlink(struct inode *dir, struct dentry *dentry)
 out:
 	if (!err)
 		hpfs_update_directory_times(dir);
-	hpfs_unlock(dir->i_sb);
+	hpfs_unlock(inode_sb(dir));
 	return err;
 }
 
@@ -432,7 +437,7 @@ static int hpfs_rmdir(struct inode *dir, struct dentry *dentry)
 	int r;
 
 	hpfs_adjust_length(name, &len);
-	hpfs_lock(dir->i_sb);
+	hpfs_lock(inode_sb(dir));
 	err = -ENOENT;
 	de = map_dirent(dir, hpfs_i(dir)->i_dno, name, len, &dno, &qbh);
 	if (!de)
@@ -446,7 +451,8 @@ static int hpfs_rmdir(struct inode *dir, struct dentry *dentry)
 	if (!de->directory)
 		goto out1;
 
-	hpfs_count_dnodes(dir->i_sb, hpfs_i(inode)->i_dno, NULL, NULL, &n_items);
+	hpfs_count_dnodes(inode_sb(dir), hpfs_i(inode)->i_dno, NULL, NULL,
+			  &n_items);
 	err = -ENOTEMPTY;
 	if (n_items)
 		goto out1;
@@ -454,7 +460,8 @@ static int hpfs_rmdir(struct inode *dir, struct dentry *dentry)
 	r = hpfs_remove_dirent(dir, dno, de, &qbh, 1);
 	switch (r) {
 	case 1:
-		hpfs_error(dir->i_sb, "there was error when removing dirent");
+		hpfs_error(inode_sb(dir),
+			   "there was error when removing dirent");
 		err = -EFSERROR;
 		break;
 	case 2:
@@ -471,7 +478,7 @@ static int hpfs_rmdir(struct inode *dir, struct dentry *dentry)
 out:
 	if (!err)
 		hpfs_update_directory_times(dir);
-	hpfs_unlock(dir->i_sb);
+	hpfs_unlock(inode_sb(dir));
 	return err;
 }
 
@@ -484,20 +491,20 @@ static int hpfs_symlink_readpage(struct file *file, struct page *page)
 	int err;
 
 	err = -EIO;
-	hpfs_lock(i->i_sb);
-	if (!(fnode = hpfs_map_fnode(i->i_sb, i->i_ino, &bh)))
+	hpfs_lock(inode_sb(i));
+	if (!(fnode = hpfs_map_fnode(inode_sb(i), i->i_ino, &bh)))
 		goto fail;
-	err = hpfs_read_ea(i->i_sb, fnode, "SYMLINK", link, PAGE_SIZE);
+	err = hpfs_read_ea(inode_sb(i), fnode, "SYMLINK", link, PAGE_SIZE);
 	brelse(bh);
 	if (err)
 		goto fail;
-	hpfs_unlock(i->i_sb);
+	hpfs_unlock(inode_sb(i));
 	SetPageUptodate(page);
 	unlock_page(page);
 	return 0;
 
 fail:
-	hpfs_unlock(i->i_sb);
+	hpfs_unlock(inode_sb(i));
 	SetPageError(page);
 	unlock_page(page);
 	return err;
@@ -533,7 +540,7 @@ static int hpfs_rename(struct inode *old_dir, struct dentry *old_dentry,
 	err = 0;
 	hpfs_adjust_length(old_name, &old_len);
 
-	hpfs_lock(i->i_sb);
+	hpfs_lock(inode_sb(i));
 	/* order doesn't matter, due to VFS exclusion */
 	
 	/* Erm? Moving over the empty non-busy directory is perfectly legal */
@@ -543,7 +550,8 @@ static int hpfs_rename(struct inode *old_dir, struct dentry *old_dentry,
 	}
 
 	if (!(dep = map_dirent(old_dir, hpfs_i(old_dir)->i_dno, old_name, old_len, &dno, &qbh))) {
-		hpfs_error(i->i_sb, "lookup succeeded but map dirent failed");
+		hpfs_error(inode_sb(i),
+			   "lookup succeeded but map dirent failed");
 		err = -ENOENT;
 		goto end1;
 	}
@@ -561,7 +569,8 @@ static int hpfs_rename(struct inode *old_dir, struct dentry *old_dentry,
 				hpfs_brelse4(&qbh1);
 				goto end;
 			}
-			hpfs_error(new_dir->i_sb, "hpfs_rename: could not find dirent");
+			hpfs_error(inode_sb(new_dir),
+				   "hpfs_rename: could not find dirent");
 			err = -EFSERROR;
 			goto end1;
 		}
@@ -572,7 +581,8 @@ static int hpfs_rename(struct inode *old_dir, struct dentry *old_dentry,
 	if (new_dir == old_dir) hpfs_brelse4(&qbh);
 
 	if ((r = hpfs_add_dirent(new_dir, new_name, new_len, &de))) {
-		if (r == -1) hpfs_error(new_dir->i_sb, "hpfs_rename: dirent already exists!");
+		if (r == -1) hpfs_error(inode_sb(new_dir),
+					"hpfs_rename: dirent already exists!");
 		err = r == 1 ? -ENOSPC : -EFSERROR;
 		if (new_dir != old_dir) hpfs_brelse4(&qbh);
 		goto end1;
@@ -580,13 +590,15 @@ static int hpfs_rename(struct inode *old_dir, struct dentry *old_dentry,
 	
 	if (new_dir == old_dir)
 		if (!(dep = map_dirent(old_dir, hpfs_i(old_dir)->i_dno, old_name, old_len, &dno, &qbh))) {
-			hpfs_error(i->i_sb, "lookup succeeded but map dirent failed at #2");
+			hpfs_error(inode_sb(i),
+				   "lookup succeeded but map dirent failed at #2");
 			err = -ENOENT;
 			goto end1;
 		}
 
 	if ((r = hpfs_remove_dirent(old_dir, dno, dep, &qbh, 0))) {
-		hpfs_error(i->i_sb, "hpfs_rename: could not remove dirent");
+		hpfs_error(inode_sb(i),
+			   "hpfs_rename: could not remove dirent");
 		err = r == 2 ? -ENOSPC : -EFSERROR;
 		goto end1;
 	}
@@ -597,7 +609,7 @@ static int hpfs_rename(struct inode *old_dir, struct dentry *old_dentry,
 		inc_nlink(new_dir);
 		drop_nlink(old_dir);
 	}
-	if ((fnode = hpfs_map_fnode(i->i_sb, i->i_ino, &bh))) {
+	if ((fnode = hpfs_map_fnode(inode_sb(i), i->i_ino, &bh))) {
 		fnode->up = cpu_to_le32(new_dir->i_ino);
 		fnode->len = new_len;
 		memcpy(fnode->name, new_name, new_len>15?15:new_len);
@@ -610,7 +622,7 @@ static int hpfs_rename(struct inode *old_dir, struct dentry *old_dentry,
 		hpfs_update_directory_times(old_dir);
 		hpfs_update_directory_times(new_dir);
 	}
-	hpfs_unlock(i->i_sb);
+	hpfs_unlock(inode_sb(i));
 	return err;
 }
 
diff --git a/fs/hpfs/super.c b/fs/hpfs/super.c
index f2c3ebcd309c..74351b3ca304 100644
--- a/fs/hpfs/super.c
+++ b/fs/hpfs/super.c
@@ -212,7 +212,11 @@ long hpfs_ioctl(struct file *file, unsigned cmd, unsigned long arg)
 				return -EPERM;
 			if (copy_from_user(&range, (struct fstrim_range __user *)arg, sizeof(range)))
 				return -EFAULT;
-			r = hpfs_trim_fs(file_inode(file)->i_sb, range.start >> 9, (range.start + range.len) >> 9, (range.minlen + 511) >> 9, &n_trimmed);
+			r = hpfs_trim_fs(inode_sb(file_inode(file)),
+					 range.start >> 9,
+					 (range.start + range.len) >> 9,
+					 (range.minlen + 511) >> 9,
+					 &n_trimmed);
 			if (r)
 				return r;
 			range.len = (u64)n_trimmed << 9;
-- 
2.15.1

^ permalink raw reply	[flat|nested] 88+ messages in thread

* [PATCH 41/76] fs/hugetlbfs: Use inode_sb() helper instead of inode->i_sb
  2018-05-08 18:03 [RFC][PATCH 0/76] vfs: 'views' for filesystems with more than one root Mark Fasheh
                   ` (39 preceding siblings ...)
  2018-05-08 18:04 ` [PATCH 40/76] fs/hpfs: " Mark Fasheh
@ 2018-05-08 18:04 ` Mark Fasheh
  2018-05-08 18:04 ` [PATCH 42/76] fs/isofs: " Mark Fasheh
                   ` (35 subsequent siblings)
  76 siblings, 0 replies; 88+ messages in thread
From: Mark Fasheh @ 2018-05-08 18:04 UTC (permalink / raw)
  To: linux-fsdevel; +Cc: linux-kernel, linux-btrfs, Mark Fasheh

Signed-off-by: Mark Fasheh <mfasheh@suse.de>
---
 fs/hugetlbfs/inode.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/fs/hugetlbfs/inode.c b/fs/hugetlbfs/inode.c
index b9a254dcc0e7..31d2a6051bea 100644
--- a/fs/hugetlbfs/inode.c
+++ b/fs/hugetlbfs/inode.c
@@ -791,7 +791,7 @@ static int hugetlbfs_mknod(struct inode *dir,
 	struct inode *inode;
 	int error = -ENOSPC;
 
-	inode = hugetlbfs_get_inode(dir->i_sb, dir, mode, dev);
+	inode = hugetlbfs_get_inode(inode_sb(dir), dir, mode, dev);
 	if (inode) {
 		dir->i_ctime = dir->i_mtime = current_time(dir);
 		d_instantiate(dentry, inode);
@@ -820,7 +820,7 @@ static int hugetlbfs_symlink(struct inode *dir,
 	struct inode *inode;
 	int error = -ENOSPC;
 
-	inode = hugetlbfs_get_inode(dir->i_sb, dir, S_IFLNK|S_IRWXUGO, 0);
+	inode = hugetlbfs_get_inode(inode_sb(dir), dir, S_IFLNK|S_IRWXUGO, 0);
 	if (inode) {
 		int l = strlen(symname)+1;
 		error = page_symlink(inode, symname, l);
@@ -1021,7 +1021,7 @@ static void hugetlbfs_i_callback(struct rcu_head *head)
 
 static void hugetlbfs_destroy_inode(struct inode *inode)
 {
-	hugetlbfs_inc_free_inodes(HUGETLBFS_SB(inode->i_sb));
+	hugetlbfs_inc_free_inodes(HUGETLBFS_SB(inode_sb(inode)));
 	mpol_free_shared_policy(&HUGETLBFS_I(inode)->policy);
 	call_rcu(&inode->i_rcu, hugetlbfs_i_callback);
 }
-- 
2.15.1

^ permalink raw reply	[flat|nested] 88+ messages in thread

* [PATCH 42/76] fs/isofs: Use inode_sb() helper instead of inode->i_sb
  2018-05-08 18:03 [RFC][PATCH 0/76] vfs: 'views' for filesystems with more than one root Mark Fasheh
                   ` (40 preceding siblings ...)
  2018-05-08 18:04 ` [PATCH 41/76] fs/hugetlbfs: " Mark Fasheh
@ 2018-05-08 18:04 ` Mark Fasheh
  2018-05-08 18:04 ` [PATCH 43/76] fs/jbd2: " Mark Fasheh
                   ` (34 subsequent siblings)
  76 siblings, 0 replies; 88+ messages in thread
From: Mark Fasheh @ 2018-05-08 18:04 UTC (permalink / raw)
  To: linux-fsdevel; +Cc: linux-kernel, linux-btrfs, Mark Fasheh

Signed-off-by: Mark Fasheh <mfasheh@suse.de>
---
 fs/isofs/dir.c    |  2 +-
 fs/isofs/export.c |  6 +++---
 fs/isofs/inode.c  | 22 ++++++++++++----------
 fs/isofs/joliet.c |  4 ++--
 fs/isofs/namei.c  |  4 ++--
 fs/isofs/rock.c   | 29 +++++++++++++++--------------
 6 files changed, 35 insertions(+), 32 deletions(-)

diff --git a/fs/isofs/dir.c b/fs/isofs/dir.c
index 947ce22f5b3c..1d3f1d10bea3 100644
--- a/fs/isofs/dir.c
+++ b/fs/isofs/dir.c
@@ -93,7 +93,7 @@ static int do_isofs_readdir(struct inode *inode, struct file *file,
 	int first_de = 1;
 	char *p = NULL;		/* Quiet GCC */
 	struct iso_directory_record *de;
-	struct isofs_sb_info *sbi = ISOFS_SB(inode->i_sb);
+	struct isofs_sb_info *sbi = ISOFS_SB(inode_sb(inode));
 
 	offset = ctx->pos & (bufsize - 1);
 	block = ctx->pos >> bufbits;
diff --git a/fs/isofs/export.c b/fs/isofs/export.c
index 85a9093769a9..2bb64a3c1130 100644
--- a/fs/isofs/export.c
+++ b/fs/isofs/export.c
@@ -75,7 +75,7 @@ static struct dentry *isofs_export_get_parent(struct dentry *child)
 	parent_block = e_child_inode->i_iget5_block;
 
 	/* Get the block in question. */
-	bh = sb_bread(child_inode->i_sb, parent_block);
+	bh = sb_bread(inode_sb(child_inode), parent_block);
 	if (bh == NULL) {
 		rv = ERR_PTR(-EACCES);
 		goto out;
@@ -99,8 +99,8 @@ static struct dentry *isofs_export_get_parent(struct dentry *child)
 	/* Normalize */
 	isofs_normalize_block_and_offset(de, &parent_block, &parent_offset);
 
-	rv = d_obtain_alias(isofs_iget(child_inode->i_sb, parent_block,
-				     parent_offset));
+	rv = d_obtain_alias(isofs_iget(inode_sb(child_inode), parent_block,
+				       parent_offset));
  out:
 	if (bh)
 		brelse(bh);
diff --git a/fs/isofs/inode.c b/fs/isofs/inode.c
index bc258a4402f6..295830250d4b 100644
--- a/fs/isofs/inode.c
+++ b/fs/isofs/inode.c
@@ -1090,7 +1090,7 @@ int isofs_get_blocks(struct inode *inode, sector_t iblock,
 			struct inode *ninode;
 
 			offset += sect_size;
-			ninode = isofs_iget(inode->i_sb, nextblk, nextoff);
+			ninode = isofs_iget(inode_sb(inode), nextblk, nextoff);
 			if (IS_ERR(ninode)) {
 				error = PTR_ERR(ninode);
 				goto abort;
@@ -1113,9 +1113,11 @@ int isofs_get_blocks(struct inode *inode, sector_t iblock,
 		}
 
 		if (*bh) {
-			map_bh(*bh, inode->i_sb, firstext + b_off - offset);
+			map_bh(*bh, inode_sb(inode),
+			       firstext + b_off - offset);
 		} else {
-			*bh = sb_getblk(inode->i_sb, firstext+b_off-offset);
+			*bh = sb_getblk(inode_sb(inode),
+					firstext+b_off-offset);
 			if (!*bh)
 				goto abort;
 		}
@@ -1165,7 +1167,7 @@ struct buffer_head *isofs_bread(struct inode *inode, sector_t block)
 	sector_t blknr = isofs_bmap(inode, block);
 	if (!blknr)
 		return NULL;
-	return sb_bread(inode->i_sb, blknr);
+	return sb_bread(inode_sb(inode), blknr);
 }
 
 static int isofs_readpage(struct file *file, struct page *page)
@@ -1193,7 +1195,7 @@ static const struct address_space_operations isofs_aops = {
 static int isofs_read_level3_size(struct inode *inode)
 {
 	unsigned long bufsize = ISOFS_BUFFER_SIZE(inode);
-	int high_sierra = ISOFS_SB(inode->i_sb)->s_high_sierra;
+	int high_sierra = ISOFS_SB(inode_sb(inode))->s_high_sierra;
 	struct buffer_head *bh = NULL;
 	unsigned long block, offset, block_saved, offset_saved;
 	int i = 0;
@@ -1217,7 +1219,7 @@ static int isofs_read_level3_size(struct inode *inode)
 		unsigned int de_len;
 
 		if (!bh) {
-			bh = sb_bread(inode->i_sb, block);
+			bh = sb_bread(inode_sb(inode), block);
 			if (!bh)
 				goto out_noread;
 		}
@@ -1250,7 +1252,7 @@ static int isofs_read_level3_size(struct inode *inode)
 			brelse(bh);
 			bh = NULL;
 			if (offset) {
-				bh = sb_bread(inode->i_sb, block);
+				bh = sb_bread(inode_sb(inode), block);
 				if (!bh)
 					goto out_noread;
 				memcpy((void *)tmpde+slop, bh->b_data, offset);
@@ -1295,7 +1297,7 @@ static int isofs_read_level3_size(struct inode *inode)
 
 static int isofs_read_inode(struct inode *inode, int relocated)
 {
-	struct super_block *sb = inode->i_sb;
+	struct super_block *sb = inode_sb(inode);
 	struct isofs_sb_info *sbi = ISOFS_SB(sb);
 	unsigned long bufsize = ISOFS_BUFFER_SIZE(inode);
 	unsigned long block;
@@ -1309,7 +1311,7 @@ static int isofs_read_inode(struct inode *inode, int relocated)
 	int ret = -EIO;
 
 	block = ei->i_iget5_block;
-	bh = sb_bread(inode->i_sb, block);
+	bh = sb_bread(inode_sb(inode), block);
 	if (!bh)
 		goto out_badread;
 
@@ -1328,7 +1330,7 @@ static int isofs_read_inode(struct inode *inode, int relocated)
 		}
 		memcpy(tmpde, bh->b_data + offset, frag1);
 		brelse(bh);
-		bh = sb_bread(inode->i_sb, ++block);
+		bh = sb_bread(inode_sb(inode), ++block);
 		if (!bh)
 			goto out_badread;
 		memcpy((char *)tmpde+frag1, bh->b_data, de_len - frag1);
diff --git a/fs/isofs/joliet.c b/fs/isofs/joliet.c
index be8b6a9d0b92..47b0ac950a14 100644
--- a/fs/isofs/joliet.c
+++ b/fs/isofs/joliet.c
@@ -45,8 +45,8 @@ get_joliet_filename(struct iso_directory_record * de, unsigned char *outname, st
 	struct nls_table *nls;
 	unsigned char len = 0;
 
-	utf8 = ISOFS_SB(inode->i_sb)->s_utf8;
-	nls = ISOFS_SB(inode->i_sb)->s_nls_iocharset;
+	utf8 = ISOFS_SB(inode_sb(inode))->s_utf8;
+	nls = ISOFS_SB(inode_sb(inode))->s_nls_iocharset;
 
 	if (utf8) {
 		len = utf16s_to_utf8s((const wchar_t *) de->name,
diff --git a/fs/isofs/namei.c b/fs/isofs/namei.c
index cac468f04820..ae74cba9b3e8 100644
--- a/fs/isofs/namei.c
+++ b/fs/isofs/namei.c
@@ -41,7 +41,7 @@ isofs_find_entry(struct inode *dir, struct dentry *dentry,
 	unsigned char bufbits = ISOFS_BUFFER_BITS(dir);
 	unsigned long block, f_pos, offset, block_saved, offset_saved;
 	struct buffer_head *bh = NULL;
-	struct isofs_sb_info *sbi = ISOFS_SB(dir->i_sb);
+	struct isofs_sb_info *sbi = ISOFS_SB(inode_sb(dir));
 
 	if (!ISOFS_I(dir)->i_first_extent)
 		return 0;
@@ -167,7 +167,7 @@ struct dentry *isofs_lookup(struct inode *dir, struct dentry *dentry, unsigned i
 				1024 + page_address(page));
 	__free_page(page);
 
-	inode = found ? isofs_iget(dir->i_sb, block, offset) : NULL;
+	inode = found ? isofs_iget(inode_sb(dir), block, offset) : NULL;
 
 	return d_splice_alias(inode, dentry);
 }
diff --git a/fs/isofs/rock.c b/fs/isofs/rock.c
index 94ef92fe806c..3f398cd95143 100644
--- a/fs/isofs/rock.c
+++ b/fs/isofs/rock.c
@@ -46,7 +46,7 @@ static int check_sp(struct rock_ridge *rr, struct inode *inode)
 		return -1;
 	if (rr->u.SP.magic[1] != 0xef)
 		return -1;
-	ISOFS_SB(inode->i_sb)->s_rock_offset = rr->u.SP.skip;
+	ISOFS_SB(inode_sb(inode))->s_rock_offset = rr->u.SP.skip;
 	return 0;
 }
 
@@ -61,9 +61,9 @@ static void setup_rock_ridge(struct iso_directory_record *de,
 	if (rs->len < 0)
 		rs->len = 0;
 
-	if (ISOFS_SB(inode->i_sb)->s_rock_offset != -1) {
-		rs->len -= ISOFS_SB(inode->i_sb)->s_rock_offset;
-		rs->chr += ISOFS_SB(inode->i_sb)->s_rock_offset;
+	if (ISOFS_SB(inode_sb(inode))->s_rock_offset != -1) {
+		rs->len -= ISOFS_SB(inode_sb(inode))->s_rock_offset;
+		rs->chr += ISOFS_SB(inode_sb(inode))->s_rock_offset;
 		if (rs->len < 0)
 			rs->len = 0;
 	}
@@ -112,7 +112,7 @@ static int rock_continue(struct rock_state *rs)
 		ret = -EIO;
 		if (++rs->cont_loops >= RR_MAX_CE_ENTRIES)
 			goto out;
-		bh = sb_bread(rs->inode->i_sb, rs->cont_extent);
+		bh = sb_bread(inode_sb(rs->inode), rs->cont_extent);
 		if (bh) {
 			memcpy(rs->buffer, bh->b_data + rs->cont_offset,
 					rs->cont_size);
@@ -207,7 +207,7 @@ int get_rock_ridge_filename(struct iso_directory_record *de,
 	char *p;
 	int len;
 
-	if (!ISOFS_SB(inode->i_sb)->s_rock)
+	if (!ISOFS_SB(inode_sb(inode))->s_rock)
 		return 0;
 	*retname = 0;
 
@@ -318,7 +318,7 @@ parse_rock_ridge_inode_internal(struct iso_directory_record *de,
 	struct rock_state rs;
 	int ret = 0;
 
-	if (!ISOFS_SB(inode->i_sb)->s_rock)
+	if (!ISOFS_SB(inode_sb(inode))->s_rock)
 		return 0;
 
 	init_rock_state(&rs, inode);
@@ -373,7 +373,7 @@ parse_rock_ridge_inode_internal(struct iso_directory_record *de,
 			/* Invalid length of ER tag id? */
 			if (rr->u.ER.len_id + offsetof(struct rock_ridge, u.ER.data) > rr->len)
 				goto out;
-			ISOFS_SB(inode->i_sb)->s_rock = 1;
+			ISOFS_SB(inode_sb(inode))->s_rock = 1;
 			printk(KERN_DEBUG "ISO 9660 Extensions: ");
 			{
 				int p;
@@ -521,7 +521,8 @@ parse_rock_ridge_inode_internal(struct iso_directory_record *de,
 				goto eio;
 			}
 			ISOFS_I(inode)->i_first_extent = reloc_block;
-			reloc = isofs_iget_reloc(inode->i_sb, reloc_block, 0);
+			reloc = isofs_iget_reloc(inode_sb(inode), reloc_block,
+						 0);
 			if (IS_ERR(reloc)) {
 				ret = PTR_ERR(reloc);
 				goto out;
@@ -542,7 +543,7 @@ parse_rock_ridge_inode_internal(struct iso_directory_record *de,
 		case SIG('Z', 'F'): {
 			int algo;
 
-			if (ISOFS_SB(inode->i_sb)->s_nocompress)
+			if (ISOFS_SB(inode_sb(inode))->s_nocompress)
 				break;
 			algo = isonum_721(rr->u.ZF.algorithm);
 			if (algo == SIG('p', 'z')) {
@@ -678,8 +679,8 @@ int parse_rock_ridge_inode(struct iso_directory_record *de, struct inode *inode,
 	 * if rockridge flag was reset and we didn't look for attributes
 	 * behind eventual XA attributes, have a look there
 	 */
-	if ((ISOFS_SB(inode->i_sb)->s_rock_offset == -1)
-	    && (ISOFS_SB(inode->i_sb)->s_rock == 2)) {
+	if ((ISOFS_SB(inode_sb(inode))->s_rock_offset == -1)
+	    && (ISOFS_SB(inode_sb(inode))->s_rock == 2)) {
 		result = parse_rock_ridge_inode_internal(de, inode,
 							 flags | RR_REGARD_XA);
 	}
@@ -694,7 +695,7 @@ static int rock_ridge_symlink_readpage(struct file *file, struct page *page)
 {
 	struct inode *inode = page->mapping->host;
 	struct iso_inode_info *ei = ISOFS_I(inode);
-	struct isofs_sb_info *sbi = ISOFS_SB(inode->i_sb);
+	struct isofs_sb_info *sbi = ISOFS_SB(inode_sb(inode));
 	char *link = page_address(page);
 	unsigned long bufsize = ISOFS_BUFFER_SIZE(inode);
 	struct buffer_head *bh;
@@ -712,7 +713,7 @@ static int rock_ridge_symlink_readpage(struct file *file, struct page *page)
 
 	init_rock_state(&rs, inode);
 	block = ei->i_iget5_block;
-	bh = sb_bread(inode->i_sb, block);
+	bh = sb_bread(inode_sb(inode), block);
 	if (!bh)
 		goto out_noread;
 
-- 
2.15.1

^ permalink raw reply	[flat|nested] 88+ messages in thread

* [PATCH 43/76] fs/jbd2: Use inode_sb() helper instead of inode->i_sb
  2018-05-08 18:03 [RFC][PATCH 0/76] vfs: 'views' for filesystems with more than one root Mark Fasheh
                   ` (41 preceding siblings ...)
  2018-05-08 18:04 ` [PATCH 42/76] fs/isofs: " Mark Fasheh
@ 2018-05-08 18:04 ` Mark Fasheh
  2018-05-08 18:04 ` [PATCH 44/76] fs/jffs2: " Mark Fasheh
                   ` (33 subsequent siblings)
  76 siblings, 0 replies; 88+ messages in thread
From: Mark Fasheh @ 2018-05-08 18:04 UTC (permalink / raw)
  To: linux-fsdevel; +Cc: linux-kernel, linux-btrfs, Mark Fasheh

Signed-off-by: Mark Fasheh <mfasheh@suse.de>
---
 fs/jbd2/journal.c | 18 +++++++++++-------
 1 file changed, 11 insertions(+), 7 deletions(-)

diff --git a/fs/jbd2/journal.c b/fs/jbd2/journal.c
index 3fbf48ec2188..e1834a69cd41 100644
--- a/fs/jbd2/journal.c
+++ b/fs/jbd2/journal.c
@@ -1262,12 +1262,16 @@ journal_t *jbd2_journal_init_inode(struct inode *inode)
 	}
 
 	jbd_debug(1, "JBD2: inode %s/%ld, size %lld, bits %d, blksize %ld\n",
-		  inode->i_sb->s_id, inode->i_ino, (long long) inode->i_size,
-		  inode->i_sb->s_blocksize_bits, inode->i_sb->s_blocksize);
-
-	journal = journal_init_common(inode->i_sb->s_bdev, inode->i_sb->s_bdev,
-			blocknr, inode->i_size >> inode->i_sb->s_blocksize_bits,
-			inode->i_sb->s_blocksize);
+		  inode_sb(inode)->s_id, inode->i_ino,
+		  (long long) inode->i_size,
+		  inode_sb(inode)->s_blocksize_bits,
+		  inode_sb(inode)->s_blocksize);
+
+	journal = journal_init_common(inode_sb(inode)->s_bdev,
+				      inode_sb(inode)->s_bdev,
+				      blocknr,
+				      inode->i_size >> inode_sb(inode)->s_blocksize_bits,
+				      inode_sb(inode)->s_blocksize);
 	if (!journal)
 		return NULL;
 
@@ -2233,7 +2237,7 @@ void jbd2_journal_ack_err(journal_t *journal)
 
 int jbd2_journal_blocks_per_page(struct inode *inode)
 {
-	return 1 << (PAGE_SHIFT - inode->i_sb->s_blocksize_bits);
+	return 1 << (PAGE_SHIFT - inode_sb(inode)->s_blocksize_bits);
 }
 
 /*
-- 
2.15.1

^ permalink raw reply	[flat|nested] 88+ messages in thread

* [PATCH 44/76] fs/jffs2: Use inode_sb() helper instead of inode->i_sb
  2018-05-08 18:03 [RFC][PATCH 0/76] vfs: 'views' for filesystems with more than one root Mark Fasheh
                   ` (42 preceding siblings ...)
  2018-05-08 18:04 ` [PATCH 43/76] fs/jbd2: " Mark Fasheh
@ 2018-05-08 18:04 ` Mark Fasheh
  2018-05-08 18:04 ` [PATCH 45/76] fs/jfs: " Mark Fasheh
                   ` (32 subsequent siblings)
  76 siblings, 0 replies; 88+ messages in thread
From: Mark Fasheh @ 2018-05-08 18:04 UTC (permalink / raw)
  To: linux-fsdevel; +Cc: linux-kernel, linux-btrfs, Mark Fasheh

Signed-off-by: Mark Fasheh <mfasheh@suse.de>
---
 fs/jffs2/dir.c   | 16 ++++++++--------
 fs/jffs2/file.c  |  8 ++++----
 fs/jffs2/fs.c    |  8 ++++----
 fs/jffs2/xattr.c |  6 +++---
 4 files changed, 19 insertions(+), 19 deletions(-)

diff --git a/fs/jffs2/dir.c b/fs/jffs2/dir.c
index 0a754f38462e..e539bb4e4687 100644
--- a/fs/jffs2/dir.c
+++ b/fs/jffs2/dir.c
@@ -106,7 +106,7 @@ static struct dentry *jffs2_lookup(struct inode *dir_i, struct dentry *target,
 		ino = fd->ino;
 	mutex_unlock(&dir_f->sem);
 	if (ino) {
-		inode = jffs2_iget(dir_i->i_sb, ino);
+		inode = jffs2_iget(inode_sb(dir_i), ino);
 		if (IS_ERR(inode))
 			pr_warn("iget() failed for ino #%u\n", ino);
 	}
@@ -170,7 +170,7 @@ static int jffs2_create(struct inode *dir_i, struct dentry *dentry,
 	if (!ri)
 		return -ENOMEM;
 
-	c = JFFS2_SB_INFO(dir_i->i_sb);
+	c = JFFS2_SB_INFO(inode_sb(dir_i));
 
 	jffs2_dbg(1, "%s()\n", __func__);
 
@@ -224,7 +224,7 @@ static int jffs2_create(struct inode *dir_i, struct dentry *dentry,
 
 static int jffs2_unlink(struct inode *dir_i, struct dentry *dentry)
 {
-	struct jffs2_sb_info *c = JFFS2_SB_INFO(dir_i->i_sb);
+	struct jffs2_sb_info *c = JFFS2_SB_INFO(inode_sb(dir_i));
 	struct jffs2_inode_info *dir_f = JFFS2_INODE_INFO(dir_i);
 	struct jffs2_inode_info *dead_f = JFFS2_INODE_INFO(d_inode(dentry));
 	int ret;
@@ -300,7 +300,7 @@ static int jffs2_symlink (struct inode *dir_i, struct dentry *dentry, const char
 	if (!ri)
 		return -ENOMEM;
 
-	c = JFFS2_SB_INFO(dir_i->i_sb);
+	c = JFFS2_SB_INFO(inode_sb(dir_i));
 
 	/* Try to reserve enough space for both node and dirent.
 	 * Just the node will do for now, though
@@ -459,7 +459,7 @@ static int jffs2_mkdir (struct inode *dir_i, struct dentry *dentry, umode_t mode
 	if (!ri)
 		return -ENOMEM;
 
-	c = JFFS2_SB_INFO(dir_i->i_sb);
+	c = JFFS2_SB_INFO(inode_sb(dir_i));
 
 	/* Try to reserve enough space for both node and dirent.
 	 * Just the node will do for now, though
@@ -586,7 +586,7 @@ static int jffs2_mkdir (struct inode *dir_i, struct dentry *dentry, umode_t mode
 
 static int jffs2_rmdir (struct inode *dir_i, struct dentry *dentry)
 {
-	struct jffs2_sb_info *c = JFFS2_SB_INFO(dir_i->i_sb);
+	struct jffs2_sb_info *c = JFFS2_SB_INFO(inode_sb(dir_i));
 	struct jffs2_inode_info *dir_f = JFFS2_INODE_INFO(dir_i);
 	struct jffs2_inode_info *f = JFFS2_INODE_INFO(d_inode(dentry));
 	struct jffs2_full_dirent *fd;
@@ -627,7 +627,7 @@ static int jffs2_mknod (struct inode *dir_i, struct dentry *dentry, umode_t mode
 	if (!ri)
 		return -ENOMEM;
 
-	c = JFFS2_SB_INFO(dir_i->i_sb);
+	c = JFFS2_SB_INFO(inode_sb(dir_i));
 
 	if (S_ISBLK(mode) || S_ISCHR(mode))
 		devlen = jffs2_encode_dev(&dev, rdev);
@@ -761,7 +761,7 @@ static int jffs2_rename (struct inode *old_dir_i, struct dentry *old_dentry,
 			 unsigned int flags)
 {
 	int ret;
-	struct jffs2_sb_info *c = JFFS2_SB_INFO(old_dir_i->i_sb);
+	struct jffs2_sb_info *c = JFFS2_SB_INFO(inode_sb(old_dir_i));
 	struct jffs2_inode_info *victim_f = NULL;
 	uint8_t type;
 	uint32_t now;
diff --git a/fs/jffs2/file.c b/fs/jffs2/file.c
index bd0428bebe9b..cfab0b294897 100644
--- a/fs/jffs2/file.c
+++ b/fs/jffs2/file.c
@@ -32,7 +32,7 @@ static int jffs2_readpage (struct file *filp, struct page *pg);
 int jffs2_fsync(struct file *filp, loff_t start, loff_t end, int datasync)
 {
 	struct inode *inode = filp->f_mapping->host;
-	struct jffs2_sb_info *c = JFFS2_SB_INFO(inode->i_sb);
+	struct jffs2_sb_info *c = JFFS2_SB_INFO(inode_sb(inode));
 	int ret;
 
 	ret = file_write_and_wait_range(filp, start, end);
@@ -79,7 +79,7 @@ const struct address_space_operations jffs2_file_address_operations =
 static int jffs2_do_readpage_nolock (struct inode *inode, struct page *pg)
 {
 	struct jffs2_inode_info *f = JFFS2_INODE_INFO(inode);
-	struct jffs2_sb_info *c = JFFS2_SB_INFO(inode->i_sb);
+	struct jffs2_sb_info *c = JFFS2_SB_INFO(inode_sb(inode));
 	unsigned char *pg_buf;
 	int ret;
 
@@ -148,7 +148,7 @@ static int jffs2_write_begin(struct file *filp, struct address_space *mapping,
 
 	if (pageofs > inode->i_size) {
 		/* Make new hole frag from old EOF to new page */
-		struct jffs2_sb_info *c = JFFS2_SB_INFO(inode->i_sb);
+		struct jffs2_sb_info *c = JFFS2_SB_INFO(inode_sb(inode));
 		struct jffs2_raw_inode ri;
 		struct jffs2_full_dnode *fn;
 		uint32_t alloc_len;
@@ -241,7 +241,7 @@ static int jffs2_write_end(struct file *filp, struct address_space *mapping,
 	 */
 	struct inode *inode = mapping->host;
 	struct jffs2_inode_info *f = JFFS2_INODE_INFO(inode);
-	struct jffs2_sb_info *c = JFFS2_SB_INFO(inode->i_sb);
+	struct jffs2_sb_info *c = JFFS2_SB_INFO(inode_sb(inode));
 	struct jffs2_raw_inode *ri;
 	unsigned start = pos & (PAGE_SIZE - 1);
 	unsigned end = start + copied;
diff --git a/fs/jffs2/fs.c b/fs/jffs2/fs.c
index eab04eca95a3..2e03accff2f5 100644
--- a/fs/jffs2/fs.c
+++ b/fs/jffs2/fs.c
@@ -32,7 +32,7 @@ int jffs2_do_setattr (struct inode *inode, struct iattr *iattr)
 {
 	struct jffs2_full_dnode *old_metadata, *new_metadata;
 	struct jffs2_inode_info *f = JFFS2_INODE_INFO(inode);
-	struct jffs2_sb_info *c = JFFS2_SB_INFO(inode->i_sb);
+	struct jffs2_sb_info *c = JFFS2_SB_INFO(inode_sb(inode));
 	struct jffs2_raw_inode *ri;
 	union jffs2_device_node dev;
 	unsigned char *mdata = NULL;
@@ -238,7 +238,7 @@ void jffs2_evict_inode (struct inode *inode)
 	/* We can forget about this inode for now - drop all
 	 *  the nodelists associated with it, etc.
 	 */
-	struct jffs2_sb_info *c = JFFS2_SB_INFO(inode->i_sb);
+	struct jffs2_sb_info *c = JFFS2_SB_INFO(inode_sb(inode));
 	struct jffs2_inode_info *f = JFFS2_INODE_INFO(inode);
 
 	jffs2_dbg(1, "%s(): ino #%lu mode %o\n",
@@ -267,7 +267,7 @@ struct inode *jffs2_iget(struct super_block *sb, unsigned long ino)
 		return inode;
 
 	f = JFFS2_INODE_INFO(inode);
-	c = JFFS2_SB_INFO(inode->i_sb);
+	c = JFFS2_SB_INFO(inode_sb(inode));
 
 	jffs2_init_inode_info(f);
 	mutex_lock(&f->sem);
@@ -420,7 +420,7 @@ int jffs2_do_remount_fs(struct super_block *sb, int *flags, char *data)
 struct inode *jffs2_new_inode (struct inode *dir_i, umode_t mode, struct jffs2_raw_inode *ri)
 {
 	struct inode *inode;
-	struct super_block *sb = dir_i->i_sb;
+	struct super_block *sb = inode_sb(dir_i);
 	struct jffs2_sb_info *c;
 	struct jffs2_inode_info *f;
 	int ret;
diff --git a/fs/jffs2/xattr.c b/fs/jffs2/xattr.c
index da3e18503c65..880c32676ffc 100644
--- a/fs/jffs2/xattr.c
+++ b/fs/jffs2/xattr.c
@@ -962,7 +962,7 @@ ssize_t jffs2_listxattr(struct dentry *dentry, char *buffer, size_t size)
 {
 	struct inode *inode = d_inode(dentry);
 	struct jffs2_inode_info *f = JFFS2_INODE_INFO(inode);
-	struct jffs2_sb_info *c = JFFS2_SB_INFO(inode->i_sb);
+	struct jffs2_sb_info *c = JFFS2_SB_INFO(inode_sb(inode));
 	struct jffs2_inode_cache *ic = f->inocache;
 	struct jffs2_xattr_ref *ref, **pref;
 	struct jffs2_xattr_datum *xd;
@@ -1032,7 +1032,7 @@ int do_jffs2_getxattr(struct inode *inode, int xprefix, const char *xname,
 		      char *buffer, size_t size)
 {
 	struct jffs2_inode_info *f = JFFS2_INODE_INFO(inode);
-	struct jffs2_sb_info *c = JFFS2_SB_INFO(inode->i_sb);
+	struct jffs2_sb_info *c = JFFS2_SB_INFO(inode_sb(inode));
 	struct jffs2_inode_cache *ic = f->inocache;
 	struct jffs2_xattr_datum *xd;
 	struct jffs2_xattr_ref *ref, **pref;
@@ -1094,7 +1094,7 @@ int do_jffs2_setxattr(struct inode *inode, int xprefix, const char *xname,
 		      const char *buffer, size_t size, int flags)
 {
 	struct jffs2_inode_info *f = JFFS2_INODE_INFO(inode);
-	struct jffs2_sb_info *c = JFFS2_SB_INFO(inode->i_sb);
+	struct jffs2_sb_info *c = JFFS2_SB_INFO(inode_sb(inode));
 	struct jffs2_inode_cache *ic = f->inocache;
 	struct jffs2_xattr_datum *xd;
 	struct jffs2_xattr_ref *ref, *newref, **pref;
-- 
2.15.1

^ permalink raw reply	[flat|nested] 88+ messages in thread

* [PATCH 45/76] fs/jfs: Use inode_sb() helper instead of inode->i_sb
  2018-05-08 18:03 [RFC][PATCH 0/76] vfs: 'views' for filesystems with more than one root Mark Fasheh
                   ` (43 preceding siblings ...)
  2018-05-08 18:04 ` [PATCH 44/76] fs/jffs2: " Mark Fasheh
@ 2018-05-08 18:04 ` Mark Fasheh
  2018-05-08 18:04 ` [PATCH 46/76] fs/kernfs: " Mark Fasheh
                   ` (31 subsequent siblings)
  76 siblings, 0 replies; 88+ messages in thread
From: Mark Fasheh @ 2018-05-08 18:04 UTC (permalink / raw)
  To: linux-fsdevel; +Cc: linux-kernel, linux-btrfs, Mark Fasheh

Signed-off-by: Mark Fasheh <mfasheh@suse.de>
---
 fs/jfs/acl.c          |   2 +-
 fs/jfs/file.c         |   6 +--
 fs/jfs/inode.c        |  14 +++----
 fs/jfs/ioctl.c        |   2 +-
 fs/jfs/jfs_discard.c  |  12 +++---
 fs/jfs/jfs_dmap.c     | 104 +++++++++++++++++++++++++------------------------
 fs/jfs/jfs_dmap.h     |   2 +-
 fs/jfs/jfs_dtree.c    |  30 +++++++--------
 fs/jfs/jfs_dtree.h    |   2 +-
 fs/jfs/jfs_extent.c   |  18 ++++-----
 fs/jfs/jfs_imap.c     | 105 ++++++++++++++++++++++++++------------------------
 fs/jfs/jfs_incore.h   |   2 +-
 fs/jfs/jfs_inode.c    |   2 +-
 fs/jfs/jfs_metapage.c |  20 +++++-----
 fs/jfs/jfs_txnmgr.c   |  12 +++---
 fs/jfs/jfs_xtree.c    |  65 ++++++++++++++++---------------