Skip to contentSkip to conversation

vfs: 'views' for filesystems with more than one root

RFC PATCH In review Mark Fasheh 5 participants 88 messages May 8, 2018 – Jun 7, 2018 Page 2 of 2

Subsystems (85)
lore
Share & tools
lore
#52 lore raw

PATCH 51/76 fs/nilfs2: Use inode_sb() helper instead of inode->i_sb

In reply to Mark Fasheh
---
 fs/nilfs2/alloc.c   | 10 ++++-----
 fs/nilfs2/bmap.c    |  4 ++--
 fs/nilfs2/btnode.c  |  6 +++---
 fs/nilfs2/btree.c   | 12 +++++------
 fs/nilfs2/cpfile.c  |  6 +++---
 fs/nilfs2/dat.c     |  2 +-
 fs/nilfs2/dir.c     | 24 ++++++++++-----------
 fs/nilfs2/direct.c  |  4 ++--
 fs/nilfs2/file.c    | 19 ++++++++--------
 fs/nilfs2/gcinode.c |  6 +++---
 fs/nilfs2/ifile.c   |  2 +-
 fs/nilfs2/inode.c   | 62 ++++++++++++++++++++++++++---------------------------
 fs/nilfs2/ioctl.c   | 60 +++++++++++++++++++++++++--------------------------
 fs/nilfs2/mdt.c     | 10 ++++-----
 fs/nilfs2/mdt.h     |  2 +-
 fs/nilfs2/namei.c   | 54 +++++++++++++++++++++++-----------------------
 fs/nilfs2/page.c    |  2 +-
 fs/nilfs2/sufile.c  | 20 ++++++++---------
 fs/nilfs2/sufile.h  |  2 +-
 19 files changed, 154 insertions(+), 153 deletions(-)
fs/nilfs2/alloc.c +5 -5
index 03b8ba933eb2..3b3af2e7b2fb 100644
@@ -622,7 +622,7 @@ void nilfs_palloc_commit_free_entry(struct inode *inode,
 	lock = nilfs_mdt_bgl_lock(inode, group);
 
 	if (!nilfs_clear_bit_atomic(lock, group_offset, bitmap))
-		nilfs_msg(inode->i_sb, KERN_WARNING,
+		nilfs_msg(inode_sb(inode), KERN_WARNING,
 			  "%s (ino=%lu): entry number %llu already freed",
 			  __func__, inode->i_ino,
 			  (unsigned long long)req->pr_entry_nr);
@@ -663,7 +663,7 @@ void nilfs_palloc_abort_alloc_entry(struct inode *inode,
 	lock = nilfs_mdt_bgl_lock(inode, group);
 
 	if (!nilfs_clear_bit_atomic(lock, group_offset, bitmap))
-		nilfs_msg(inode->i_sb, KERN_WARNING,
+		nilfs_msg(inode_sb(inode), KERN_WARNING,
 			  "%s (ino=%lu): entry number %llu already freed",
 			  __func__, inode->i_ino,
 			  (unsigned long long)req->pr_entry_nr);
@@ -772,7 +772,7 @@ int nilfs_palloc_freev(struct inode *inode, __u64 *entry_nrs, size_t nitems)
 		do {
 			if (!nilfs_clear_bit_atomic(lock, group_offset,
 						    bitmap)) {
-				nilfs_msg(inode->i_sb, KERN_WARNING,
+				nilfs_msg(inode_sb(inode), KERN_WARNING,
 					  "%s (ino=%lu): entry number %llu already freed",
 					  __func__, inode->i_ino,
 					  (unsigned long long)entry_nrs[j]);
@@ -817,7 +817,7 @@ int nilfs_palloc_freev(struct inode *inode, __u64 *entry_nrs, size_t nitems)
 			ret = nilfs_palloc_delete_entry_block(inode,
 							      last_nrs[k]);
 			if (ret && ret != -ENOENT)
-				nilfs_msg(inode->i_sb, KERN_WARNING,
+				nilfs_msg(inode_sb(inode), KERN_WARNING,
 					  "error %d deleting block that object (entry=%llu, ino=%lu) belongs to",
 					  ret, (unsigned long long)last_nrs[k],
 					  inode->i_ino);
@@ -835,7 +835,7 @@ int nilfs_palloc_freev(struct inode *inode, __u64 *entry_nrs, size_t nitems)
 		if (nfree == nilfs_palloc_entries_per_group(inode)) {
 			ret = nilfs_palloc_delete_bitmap_block(inode, group);
 			if (ret && ret != -ENOENT)
-				nilfs_msg(inode->i_sb, KERN_WARNING,
+				nilfs_msg(inode_sb(inode), KERN_WARNING,
 					  "error %d deleting bitmap block of group=%lu, ino=%lu",
 					  ret, group, inode->i_ino);
 		}
fs/nilfs2/bmap.c +2 -2
index 01fb1831ca25..9d466fb6e65f 100644
@@ -30,7 +30,7 @@
 
 struct inode *nilfs_bmap_get_dat(const struct nilfs_bmap *bmap)
 {
-	struct the_nilfs *nilfs = bmap->b_inode->i_sb->s_fs_info;
+	struct the_nilfs *nilfs = inode_sb(bmap->b_inode)->s_fs_info;
 
 	return nilfs->ns_dat;
 }
@@ -41,7 +41,7 @@ static int nilfs_bmap_convert_error(struct nilfs_bmap *bmap,
 	struct inode *inode = bmap->b_inode;
 
 	if (err == -EINVAL) {
-		__nilfs_error(inode->i_sb, fname,
+		__nilfs_error(inode_sb(inode), fname,
 			      "broken bmap (inode number=%lu)", inode->i_ino);
 		err = -EIO;
 	}
fs/nilfs2/btnode.c +3 -3
index c21e0b4454a6..87bc94f23271 100644
@@ -51,7 +51,7 @@ nilfs_btnode_create_block(struct address_space *btnc, __u64 blocknr)
 		BUG();
 	}
 	memset(bh->b_data, 0, i_blocksize(inode));
-	bh->b_bdev = inode->i_sb->s_bdev;
+	bh->b_bdev = inode_sb(inode)->s_bdev;
 	bh->b_blocknr = blocknr;
 	set_buffer_mapped(bh);
 	set_buffer_uptodate(bh);
@@ -83,7 +83,7 @@ int nilfs_btnode_submit_block(struct address_space *btnc, __u64 blocknr,
 	if (pblocknr == 0) {
 		pblocknr = blocknr;
 		if (inode->i_ino != NILFS_DAT_INO) {
-			struct the_nilfs *nilfs = inode->i_sb->s_fs_info;
+			struct the_nilfs *nilfs = inode_sb(inode)->s_fs_info;
 
 			/* blocknr is a virtual block number */
 			err = nilfs_dat_translate(nilfs->ns_dat, blocknr,
@@ -110,7 +110,7 @@ int nilfs_btnode_submit_block(struct address_space *btnc, __u64 blocknr,
 		goto found;
 	}
 	set_buffer_mapped(bh);
-	bh->b_bdev = inode->i_sb->s_bdev;
+	bh->b_bdev = inode_sb(inode)->s_bdev;
 	bh->b_blocknr = pblocknr; /* set block address for read */
 	bh->b_end_io = end_buffer_read_sync;
 	get_bh(bh);
fs/nilfs2/btree.c +6 -6
index 16a7a67a11c9..e8c90e0b3f1f 100644
@@ -360,7 +360,7 @@ static int nilfs_btree_node_broken(const struct nilfs_btree_node *node,
 		     (flags & NILFS_BTREE_NODE_ROOT) ||
 		     nchildren < 0 ||
 		     nchildren > NILFS_BTREE_NODE_NCHILDREN_MAX(size))) {
-		nilfs_msg(inode->i_sb, KERN_CRIT,
+		nilfs_msg(inode_sb(inode), KERN_CRIT,
 			  "bad btree node (ino=%lu, blocknr=%llu): level = %d, flags = 0x%x, nchildren = %d",
 			  inode->i_ino, (unsigned long long)blocknr, level,
 			  flags, nchildren);
@@ -390,7 +390,7 @@ static int nilfs_btree_root_broken(const struct nilfs_btree_node *node,
 		     level >= NILFS_BTREE_LEVEL_MAX ||
 		     nchildren < 0 ||
 		     nchildren > NILFS_BTREE_ROOT_NCHILDREN_MAX)) {
-		nilfs_msg(inode->i_sb, KERN_CRIT,
+		nilfs_msg(inode_sb(inode), KERN_CRIT,
 			  "bad btree root (ino=%lu): level = %d, flags = 0x%x, nchildren = %d",
 			  inode->i_ino, level, flags, nchildren);
 		ret = 1;
@@ -459,7 +459,7 @@ static int nilfs_btree_bad_node(const struct nilfs_bmap *btree,
 {
 	if (unlikely(nilfs_btree_node_get_level(node) != level)) {
 		dump_stack();
-		nilfs_msg(btree->b_inode->i_sb, KERN_CRIT,
+		nilfs_msg(inode_sb(btree->b_inode), KERN_CRIT,
 			  "btree level mismatch (ino=%lu): %d != %d",
 			  btree->b_inode->i_ino,
 			  nilfs_btree_node_get_level(node), level);
@@ -517,7 +517,7 @@ static int __nilfs_btree_get_block(const struct nilfs_bmap *btree, __u64 ptr,
 
  out_no_wait:
 	if (!buffer_uptodate(bh)) {
-		nilfs_msg(btree->b_inode->i_sb, KERN_ERR,
+		nilfs_msg(inode_sb(btree->b_inode), KERN_ERR,
 			  "I/O error reading b-tree node block (ino=%lu, blocknr=%llu)",
 			  btree->b_inode->i_ino, (unsigned long long)ptr);
 		brelse(bh);
@@ -2083,7 +2083,7 @@ static int nilfs_btree_propagate(struct nilfs_bmap *btree,
 	ret = nilfs_btree_do_lookup(btree, path, key, NULL, level + 1, 0);
 	if (ret < 0) {
 		if (unlikely(ret == -ENOENT))
-			nilfs_msg(btree->b_inode->i_sb, KERN_CRIT,
+			nilfs_msg(inode_sb(btree->b_inode), KERN_CRIT,
 				  "writing node/leaf block does not appear in b-tree (ino=%lu) at key=%llu, level=%d",
 				  btree->b_inode->i_ino,
 				  (unsigned long long)key, level);
@@ -2123,7 +2123,7 @@ static void nilfs_btree_add_dirty_buffer(struct nilfs_bmap *btree,
 	if (level < NILFS_BTREE_LEVEL_NODE_MIN ||
 	    level >= NILFS_BTREE_LEVEL_MAX) {
 		dump_stack();
-		nilfs_msg(btree->b_inode->i_sb, KERN_WARNING,
+		nilfs_msg(inode_sb(btree->b_inode), KERN_WARNING,
 			  "invalid btree level: %d (key=%llu, ino=%lu, blocknr=%llu)",
 			  level, (unsigned long long)key,
 			  btree->b_inode->i_ino,
fs/nilfs2/cpfile.c +3 -3
index a15a1601e931..c63985f7955e 100644
@@ -331,7 +331,7 @@ int nilfs_cpfile_delete_checkpoints(struct inode *cpfile,
 	int ret, ncps, nicps, nss, count, i;
 
 	if (unlikely(start == 0 || start > end)) {
-		nilfs_msg(cpfile->i_sb, KERN_ERR,
+		nilfs_msg(inode_sb(cpfile), KERN_ERR,
 			  "cannot delete checkpoints: invalid range [%llu, %llu)",
 			  (unsigned long long)start, (unsigned long long)end);
 		return -EINVAL;
@@ -385,7 +385,7 @@ int nilfs_cpfile_delete_checkpoints(struct inode *cpfile,
 								   cpfile, cno);
 					if (ret == 0)
 						continue;
-					nilfs_msg(cpfile->i_sb, KERN_ERR,
+					nilfs_msg(inode_sb(cpfile), KERN_ERR,
 						  "error %d deleting checkpoint block",
 						  ret);
 					break;
@@ -918,7 +918,7 @@ int nilfs_cpfile_change_cpmode(struct inode *cpfile, __u64 cno, int mode)
 
 	switch (mode) {
 	case NILFS_CHECKPOINT:
-		if (nilfs_checkpoint_is_mounted(cpfile->i_sb, cno))
+		if (nilfs_checkpoint_is_mounted(inode_sb(cpfile), cno))
 			/*
 			 * Current implementation does not have to protect
 			 * plain read-only mounts since they are exclusive
fs/nilfs2/dat.c +1 -1
index dffedb2f8817..7f90bce3750b 100644
@@ -349,7 +349,7 @@ int nilfs_dat_move(struct inode *dat, __u64 vblocknr, sector_t blocknr)
 	kaddr = kmap_atomic(entry_bh->b_page);
 	entry = nilfs_palloc_block_get_entry(dat, vblocknr, entry_bh, kaddr);
 	if (unlikely(entry->de_blocknr == cpu_to_le64(0))) {
-		nilfs_msg(dat->i_sb, KERN_CRIT,
+		nilfs_msg(inode_sb(dat), KERN_CRIT,
 			  "%s: invalid vblocknr = %llu, [%llu, %llu)",
 			  __func__, (unsigned long long)vblocknr,
 			  (unsigned long long)le64_to_cpu(entry->de_start),
fs/nilfs2/dir.c +12 -12
index 582831ab3eb9..c805564d6893 100644
@@ -70,7 +70,7 @@ static inline __le16 nilfs_rec_len_to_disk(unsigned int len)
  */
 static inline unsigned int nilfs_chunk_size(struct inode *inode)
 {
-	return inode->i_sb->s_blocksize;
+	return inode_sb(inode)->s_blocksize;
 }
 
 static inline void nilfs_put_page(struct page *page)
@@ -125,7 +125,7 @@ static void nilfs_commit_chunk(struct page *page,
 static bool nilfs_check_page(struct page *page)
 {
 	struct inode *dir = page->mapping->host;
-	struct super_block *sb = dir->i_sb;
+	struct super_block *sb = inode_sb(dir);
 	unsigned int chunk_size = nilfs_chunk_size(dir);
 	char *kaddr = page_address(page);
 	unsigned int offs, rec_len;
@@ -273,7 +273,7 @@ static int nilfs_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);
@@ -363,8 +363,8 @@ nilfs_find_entry(struct inode *dir, const struct qstr *qstr,
 			kaddr += nilfs_last_byte(dir, n) - reclen;
 			while ((char *) de <= kaddr) {
 				if (de->rec_len == 0) {
-					nilfs_error(dir->i_sb,
-						"zero-length directory entry");
+					nilfs_error(inode_sb(dir),
+						    "zero-length directory entry");
 					nilfs_put_page(page);
 					goto out;
 				}
@@ -378,10 +378,10 @@ nilfs_find_entry(struct inode *dir, const struct qstr *qstr,
 			n = 0;
 		/* next page is past the blocks we've got */
 		if (unlikely(n > (dir->i_blocks >> (PAGE_SHIFT - 9)))) {
-			nilfs_error(dir->i_sb,
-			       "dir %lu size %lld exceeds block count %llu",
-			       dir->i_ino, dir->i_size,
-			       (unsigned long long)dir->i_blocks);
+			nilfs_error(inode_sb(dir),
+				    "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);
@@ -487,7 +487,7 @@ int nilfs_add_link(struct dentry *dentry, struct inode *inode)
 				goto got_it;
 			}
 			if (de->rec_len == 0) {
-				nilfs_error(dir->i_sb,
+				nilfs_error(inode_sb(dir),
 					    "zero-length directory entry");
 				err = -EIO;
 				goto out_unlock;
@@ -559,7 +559,7 @@ int nilfs_delete_entry(struct nilfs_dir_entry *dir, struct page *page)
 
 	while ((char *)de < (char *)dir) {
 		if (de->rec_len == 0) {
-			nilfs_error(inode->i_sb,
+			nilfs_error(inode_sb(inode),
 				    "zero-length directory entry");
 			err = -EIO;
 			goto out;
@@ -646,7 +646,7 @@ int nilfs_empty_dir(struct inode *inode)
 
 		while ((char *)de <= kaddr) {
 			if (de->rec_len == 0) {
-				nilfs_error(inode->i_sb,
+				nilfs_error(inode_sb(inode),
 					    "zero-length directory entry (kaddr=%p, de=%p)",
 					    kaddr, de);
 				goto not_empty;
fs/nilfs2/direct.c +2 -2
index 96e3ed0d9652..5feca9aa47f4 100644
@@ -337,14 +337,14 @@ static int nilfs_direct_assign(struct nilfs_bmap *bmap,
 
 	key = nilfs_bmap_data_get_key(bmap, *bh);
 	if (unlikely(key > NILFS_DIRECT_KEY_MAX)) {
-		nilfs_msg(bmap->b_inode->i_sb, KERN_CRIT,
+		nilfs_msg(inode_sb(bmap->b_inode), KERN_CRIT,
 			  "%s (ino=%lu): invalid key: %llu", __func__,
 			  bmap->b_inode->i_ino, (unsigned long long)key);
 		return -EINVAL;
 	}
 	ptr = nilfs_direct_get_ptr(bmap, key);
 	if (unlikely(ptr == NILFS_BMAP_INVALID_PTR)) {
-		nilfs_msg(bmap->b_inode->i_sb, KERN_CRIT,
+		nilfs_msg(inode_sb(bmap->b_inode), KERN_CRIT,
 			  "%s (ino=%lu): invalid pointer: %llu", __func__,
 			  bmap->b_inode->i_ino, (unsigned long long)ptr);
 		return -EINVAL;
fs/nilfs2/file.c +10 -9
index c5fa3dee72fc..a4f813024483 100644
@@ -38,13 +38,14 @@ int nilfs_sync_file(struct file *file, loff_t start, loff_t end, int datasync)
 
 	if (nilfs_inode_dirty(inode)) {
 		if (datasync)
-			err = nilfs_construct_dsync_segment(inode->i_sb, inode,
+			err = nilfs_construct_dsync_segment(inode_sb(inode),
+							    inode,
 							    start, end);
 		else
-			err = nilfs_construct_segment(inode->i_sb);
+			err = nilfs_construct_segment(inode_sb(inode));
 	}
 
-	nilfs = inode->i_sb->s_fs_info;
+	nilfs = inode_sb(inode)->s_fs_info;
 	if (!err)
 		err = nilfs_flush_device(nilfs);
 
@@ -59,10 +60,10 @@ static int nilfs_page_mkwrite(struct vm_fault *vmf)
 	struct nilfs_transaction_info ti;
 	int ret = 0;
 
-	if (unlikely(nilfs_near_disk_full(inode->i_sb->s_fs_info)))
+	if (unlikely(nilfs_near_disk_full(inode_sb(inode)->s_fs_info)))
 		return VM_FAULT_SIGBUS; /* -ENOSPC */
 
-	sb_start_pagefault(inode->i_sb);
+	sb_start_pagefault(inode_sb(inode));
 	lock_page(page);
 	if (page->mapping != inode->i_mapping ||
 	    page_offset(page) >= i_size_read(inode) || !PageUptodate(page)) {
@@ -99,7 +100,7 @@ static int nilfs_page_mkwrite(struct vm_fault *vmf)
 	/*
 	 * fill hole blocks
 	 */
-	ret = nilfs_transaction_begin(inode->i_sb, &ti, 1);
+	ret = nilfs_transaction_begin(inode_sb(inode), &ti, 1);
 	/* never returns -ENOMEM, but may return -ENOSPC */
 	if (unlikely(ret))
 		goto out;
@@ -107,16 +108,16 @@ static int nilfs_page_mkwrite(struct vm_fault *vmf)
 	file_update_time(vma->vm_file);
 	ret = block_page_mkwrite(vma, vmf, nilfs_get_block);
 	if (ret) {
-		nilfs_transaction_abort(inode->i_sb);
+		nilfs_transaction_abort(inode_sb(inode));
 		goto out;
 	}
 	nilfs_set_file_dirty(inode, 1 << (PAGE_SHIFT - inode->i_blkbits));
-	nilfs_transaction_commit(inode->i_sb);
+	nilfs_transaction_commit(inode_sb(inode));
 
  mapped:
 	wait_for_stable_page(page);
  out:
-	sb_end_pagefault(inode->i_sb);
+	sb_end_pagefault(inode_sb(inode));
 	return block_page_mkwrite_return(ret);
 }
 
fs/nilfs2/gcinode.c +3 -3
index 853a831dcde0..af751dd4fa54 100644
@@ -79,7 +79,7 @@ int nilfs_gccache_submit_read_data(struct inode *inode, sector_t blkoff,
 		goto out;
 
 	if (pbn == 0) {
-		struct the_nilfs *nilfs = inode->i_sb->s_fs_info;
+		struct the_nilfs *nilfs = inode_sb(inode)->s_fs_info;
 
 		err = nilfs_dat_translate(nilfs->ns_dat, vbn, &pbn);
 		if (unlikely(err)) { /* -EIO, -ENOMEM, -ENOENT */
@@ -95,7 +95,7 @@ int nilfs_gccache_submit_read_data(struct inode *inode, sector_t blkoff,
 	}
 
 	if (!buffer_mapped(bh)) {
-		bh->b_bdev = inode->i_sb->s_bdev;
+		bh->b_bdev = inode_sb(inode)->s_bdev;
 		set_buffer_mapped(bh);
 	}
 	bh->b_blocknr = pbn;
@@ -151,7 +151,7 @@ int nilfs_gccache_wait_and_mark_dirty(struct buffer_head *bh)
 	if (!buffer_uptodate(bh)) {
 		struct inode *inode = bh->b_page->mapping->host;
 
-		nilfs_msg(inode->i_sb, KERN_ERR,
+		nilfs_msg(inode_sb(inode), KERN_ERR,
 			  "I/O error reading %s block for GC (ino=%lu, vblocknr=%llu)",
 			  buffer_nilfs_node(bh) ? "node" : "data",
 			  inode->i_ino, (unsigned long long)bh->b_blocknr);
fs/nilfs2/ifile.c +1 -1
index b8fa45c20c63..841f7f6c5e29 100644
@@ -141,7 +141,7 @@ int nilfs_ifile_delete_inode(struct inode *ifile, ino_t ino)
 int nilfs_ifile_get_inode_block(struct inode *ifile, ino_t ino,
 				struct buffer_head **out_bh)
 {
-	struct super_block *sb = ifile->i_sb;
+	struct super_block *sb = inode_sb(ifile);
 	int err;
 
 	if (unlikely(!NILFS_VALID_INODE(sb, ino))) {
fs/nilfs2/inode.c +31 -31

230 lines not on this page · raw message

fs/nilfs2/ioctl.c +30 -30

206 lines not on this page · raw message

fs/nilfs2/mdt.c +5 -5
index c6bc1033e7d2..d208de0e8fd4 100644
@@ -78,7 +78,7 @@ static int nilfs_mdt_create_block(struct inode *inode, unsigned long block,
 						     struct buffer_head *,
 						     void *))
 {
-	struct super_block *sb = inode->i_sb;
+	struct super_block *sb = inode_sb(inode);
 	struct nilfs_transaction_info ti;
 	struct buffer_head *bh;
 	int err;
@@ -153,7 +153,7 @@ nilfs_mdt_submit_block(struct inode *inode, unsigned long blkoff,
 		unlock_buffer(bh);
 		goto failed_bh;
 	}
-	map_bh(bh, inode->i_sb, (sector_t)blknum);
+	map_bh(bh, inode_sb(inode), (sector_t)blknum);
 
 	bh->b_end_io = end_buffer_read_sync;
 	get_bh(bh);
@@ -208,7 +208,7 @@ static int nilfs_mdt_read_block(struct inode *inode, unsigned long block,
  out_no_wait:
 	err = -EIO;
 	if (!buffer_uptodate(first_bh)) {
-		nilfs_msg(inode->i_sb, KERN_ERR,
+		nilfs_msg(inode_sb(inode), KERN_ERR,
 			  "I/O error reading meta-data file (ino=%lu, block-offset=%lu)",
 			  inode->i_ino, block);
 		goto failed_bh;
@@ -413,7 +413,7 @@ nilfs_mdt_write_page(struct page *page, struct writeback_control *wbc)
 	struct super_block *sb;
 	int err = 0;
 
-	if (inode && sb_rdonly(inode->i_sb)) {
+	if (inode && sb_rdonly(inode_sb(inode))) {
 		/*
 		 * It means that filesystem was remounted in read-only
 		 * mode because of error or metadata corruption. But we
@@ -431,7 +431,7 @@ nilfs_mdt_write_page(struct page *page, struct writeback_control *wbc)
 	if (!inode)
 		return 0;
 
-	sb = inode->i_sb;
+	sb = inode_sb(inode);
 
 	if (wbc->sync_mode == WB_SYNC_ALL)
 		err = nilfs_construct_segment(sb);
fs/nilfs2/mdt.h +1 -1
index 3f67f3932097..cf9f18dd0b66 100644
@@ -114,7 +114,7 @@ static inline void nilfs_mdt_clear_dirty(struct inode *inode)
 
 static inline __u64 nilfs_mdt_cno(struct inode *inode)
 {
-	return ((struct the_nilfs *)inode->i_sb->s_fs_info)->ns_cno;
+	return ((struct the_nilfs *) inode_sb(inode)->s_fs_info)->ns_cno;
 }
 
 static inline spinlock_t *
fs/nilfs2/namei.c +27 -27

183 lines not on this page · raw message

fs/nilfs2/page.c +1 -1
index 68241512d7c1..2c0a5bd69d72 100644
@@ -397,7 +397,7 @@ void nilfs_clear_dirty_pages(struct address_space *mapping, bool silent)
 void nilfs_clear_dirty_page(struct page *page, bool silent)
 {
 	struct inode *inode = page->mapping->host;
-	struct super_block *sb = inode->i_sb;
+	struct super_block *sb = inode_sb(inode);
 
 	BUG_ON(!PageLocked(page));
 
fs/nilfs2/sufile.c +10 -10
index c7fa139d50e8..c280be52cea3 100644
@@ -180,7 +180,7 @@ int nilfs_sufile_updatev(struct inode *sufile, __u64 *segnumv, size_t nsegs,
 	down_write(&NILFS_MDT(sufile)->mi_sem);
 	for (seg = segnumv; seg < segnumv + nsegs; seg++) {
 		if (unlikely(*seg >= nilfs_sufile_get_nsegments(sufile))) {
-			nilfs_msg(sufile->i_sb, KERN_WARNING,
+			nilfs_msg(inode_sb(sufile), KERN_WARNING,
 				  "%s: invalid segment number: %llu",
 				  __func__, (unsigned long long)*seg);
 			nerr++;
@@ -239,7 +239,7 @@ int nilfs_sufile_update(struct inode *sufile, __u64 segnum, int create,
 	int ret;
 
 	if (unlikely(segnum >= nilfs_sufile_get_nsegments(sufile))) {
-		nilfs_msg(sufile->i_sb, KERN_WARNING,
+		nilfs_msg(inode_sb(sufile), KERN_WARNING,
 			  "%s: invalid segment number: %llu",
 			  __func__, (unsigned long long)segnum);
 		return -EINVAL;
@@ -419,7 +419,7 @@ void nilfs_sufile_do_cancel_free(struct inode *sufile, __u64 segnum,
 	kaddr = kmap_atomic(su_bh->b_page);
 	su = nilfs_sufile_block_get_segment_usage(sufile, segnum, su_bh, kaddr);
 	if (unlikely(!nilfs_segment_usage_clean(su))) {
-		nilfs_msg(sufile->i_sb, KERN_WARNING,
+		nilfs_msg(inode_sb(sufile), KERN_WARNING,
 			  "%s: segment %llu must be clean", __func__,
 			  (unsigned long long)segnum);
 		kunmap_atomic(kaddr);
@@ -477,7 +477,7 @@ void nilfs_sufile_do_free(struct inode *sufile, __u64 segnum,
 	kaddr = kmap_atomic(su_bh->b_page);
 	su = nilfs_sufile_block_get_segment_usage(sufile, segnum, su_bh, kaddr);
 	if (nilfs_segment_usage_clean(su)) {
-		nilfs_msg(sufile->i_sb, KERN_WARNING,
+		nilfs_msg(inode_sb(sufile), KERN_WARNING,
 			  "%s: segment %llu is already clean",
 			  __func__, (unsigned long long)segnum);
 		kunmap_atomic(kaddr);
@@ -575,7 +575,7 @@ int nilfs_sufile_get_stat(struct inode *sufile, struct nilfs_sustat *sustat)
 {
 	struct buffer_head *header_bh;
 	struct nilfs_sufile_header *header;
-	struct the_nilfs *nilfs = sufile->i_sb->s_fs_info;
+	struct the_nilfs *nilfs = inode_sb(sufile)->s_fs_info;
 	void *kaddr;
 	int ret;
 
@@ -649,7 +649,7 @@ void nilfs_sufile_do_set_error(struct inode *sufile, __u64 segnum,
 static int nilfs_sufile_truncate_range(struct inode *sufile,
 				       __u64 start, __u64 end)
 {
-	struct the_nilfs *nilfs = sufile->i_sb->s_fs_info;
+	struct the_nilfs *nilfs = inode_sb(sufile)->s_fs_info;
 	struct buffer_head *header_bh;
 	struct buffer_head *su_bh;
 	struct nilfs_segment_usage *su, *su2;
@@ -752,7 +752,7 @@ static int nilfs_sufile_truncate_range(struct inode *sufile,
  */
 int nilfs_sufile_resize(struct inode *sufile, __u64 newnsegs)
 {
-	struct the_nilfs *nilfs = sufile->i_sb->s_fs_info;
+	struct the_nilfs *nilfs = inode_sb(sufile)->s_fs_info;
 	struct buffer_head *header_bh;
 	struct nilfs_sufile_header *header;
 	struct nilfs_sufile_info *sui = NILFS_SUI(sufile);
@@ -825,7 +825,7 @@ ssize_t nilfs_sufile_get_suinfo(struct inode *sufile, __u64 segnum, void *buf,
 	struct nilfs_segment_usage *su;
 	struct nilfs_suinfo *si = buf;
 	size_t susz = NILFS_MDT(sufile)->mi_entry_size;
-	struct the_nilfs *nilfs = sufile->i_sb->s_fs_info;
+	struct the_nilfs *nilfs = inode_sb(sufile)->s_fs_info;
 	void *kaddr;
 	unsigned long nsegs, segusages_per_block;
 	ssize_t n;
@@ -899,7 +899,7 @@ ssize_t nilfs_sufile_get_suinfo(struct inode *sufile, __u64 segnum, void *buf,
 ssize_t nilfs_sufile_set_suinfo(struct inode *sufile, void *buf,
 				unsigned int supsz, size_t nsup)
 {
-	struct the_nilfs *nilfs = sufile->i_sb->s_fs_info;
+	struct the_nilfs *nilfs = inode_sb(sufile)->s_fs_info;
 	struct buffer_head *header_bh, *bh;
 	struct nilfs_suinfo_update *sup, *supend = buf + supsz * nsup;
 	struct nilfs_segment_usage *su;
@@ -1025,7 +1025,7 @@ ssize_t nilfs_sufile_set_suinfo(struct inode *sufile, void *buf,
  */
 int nilfs_sufile_trim_fs(struct inode *sufile, struct fstrim_range *range)
 {
-	struct the_nilfs *nilfs = sufile->i_sb->s_fs_info;
+	struct the_nilfs *nilfs = inode_sb(sufile)->s_fs_info;
 	struct buffer_head *su_bh;
 	struct nilfs_segment_usage *su;
 	void *kaddr;
fs/nilfs2/sufile.h +1 -1
index 673a891350f4..0ed86ae80b32 100644
@@ -26,7 +26,7 @@
 
 static inline unsigned long nilfs_sufile_get_nsegments(struct inode *sufile)
 {
-	return ((struct the_nilfs *)sufile->i_sb->s_fs_info)->ns_nsegments;
+	return ((struct the_nilfs *) inode_sb(sufile)->s_fs_info)->ns_nsegments;
 }
 
 unsigned long nilfs_sufile_get_ncleansegs(struct inode *sufile);
Signature · 1 line
2.15.1
#53 lore raw

PATCH 52/76 fs/notify: Use inode_sb() helper instead of inode->i_sb

In reply to Mark Fasheh
---
 fs/notify/fdinfo.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
fs/notify/fdinfo.c +3 -2
index d478629c728b..857df5ce27ac 100644
@@ -91,7 +91,8 @@ static void inotify_fdinfo(struct seq_file *m, struct fsnotify_mark *mark)
 		 */
 		u32 mask = mark->mask & IN_ALL_EVENTS;
 		seq_printf(m, "inotify wd:%x ino:%lx sdev:%x mask:%x ignored_mask:%x ",
-			   inode_mark->wd, inode->i_ino, inode->i_sb->s_dev,
+			   inode_mark->wd, inode->i_ino,
+			   inode_sb(inode)->s_dev,
 			   mask, mark->ignored_mask);
 		show_mark_fhandle(m, inode);
 		seq_putc(m, '\n');
@@ -121,7 +122,7 @@ static void fanotify_fdinfo(struct seq_file *m, struct fsnotify_mark *mark)
 		if (!inode)
 			return;
 		seq_printf(m, "fanotify ino:%lx sdev:%x mflags:%x mask:%x ignored_mask:%x ",
-			   inode->i_ino, inode->i_sb->s_dev,
+			   inode->i_ino, inode_sb(inode)->s_dev,
 			   mflags, mark->mask, mark->ignored_mask);
 		show_mark_fhandle(m, inode);
 		seq_putc(m, '\n');
Signature · 1 line
2.15.1
#54 lore raw

PATCH 53/76 fs/ntfs: Use inode_sb() helper instead of inode->i_sb

In reply to Mark Fasheh
---
 fs/ntfs/aops.c    |  16 ++--
 fs/ntfs/bitmap.c  |  11 ++-
 fs/ntfs/dir.c     |  10 ++-
 fs/ntfs/file.c    |  30 ++++---
 fs/ntfs/inode.c   | 231 +++++++++++++++++++++++++++++++++---------------------
 fs/ntfs/inode.h   |   2 +-
 fs/ntfs/logfile.c |  46 ++++++-----
 fs/ntfs/namei.c   |   7 +-
 8 files changed, 214 insertions(+), 139 deletions(-)
fs/ntfs/aops.c +10 -6
index 3a2e509c77c5..f8817dfdc2b8 100644
@@ -1400,14 +1400,16 @@ static int ntfs_writepage(struct page *page, struct writeback_control *wbc)
 			// TODO: Implement and replace this with
 			// return ntfs_write_compressed_block(page);
 			unlock_page(page);
-			ntfs_error(vi->i_sb, "Writing to compressed files is "
+			ntfs_error(inode_sb(vi),
+					"Writing to compressed files is "
 					"not supported yet.  Sorry.");
 			return -EOPNOTSUPP;
 		}
 		// TODO: Implement and remove this check.
 		if (NInoNonResident(ni) && NInoSparse(ni)) {
 			unlock_page(page);
-			ntfs_error(vi->i_sb, "Writing to sparse files is not "
+			ntfs_error(inode_sb(vi),
+					"Writing to sparse files is not "
 					"supported yet.  Sorry.");
 			return -EOPNOTSUPP;
 		}
@@ -1437,7 +1439,7 @@ static int ntfs_writepage(struct page *page, struct writeback_control *wbc)
 	BUG_ON(page_has_buffers(page));
 	BUG_ON(!PageUptodate(page));
 	if (unlikely(page->index > 0)) {
-		ntfs_error(vi->i_sb, "BUG()! page->index (0x%lx) > 0.  "
+		ntfs_error(inode_sb(vi), "BUG()! page->index (0x%lx) > 0.  "
 				"Aborting write.", page->index);
 		BUG_ON(PageWriteback(page));
 		set_page_writeback(page);
@@ -1514,7 +1516,8 @@ static int ntfs_writepage(struct page *page, struct writeback_control *wbc)
 	return 0;
 err_out:
 	if (err == -ENOMEM) {
-		ntfs_warning(vi->i_sb, "Error allocating memory. Redirtying "
+		ntfs_warning(inode_sb(vi),
+				"Error allocating memory. Redirtying "
 				"page so we try again later.");
 		/*
 		 * Put the page back on mapping->dirty_pages, but leave its
@@ -1523,7 +1526,8 @@ static int ntfs_writepage(struct page *page, struct writeback_control *wbc)
 		redirty_page_for_writepage(wbc, page);
 		err = 0;
 	} else {
-		ntfs_error(vi->i_sb, "Resident attribute write failed with "
+		ntfs_error(inode_sb(vi),
+				"Resident attribute write failed with "
 				"error %i.", err);
 		SetPageError(page);
 		NVolSetErrors(ni->vol);
@@ -1735,7 +1739,7 @@ void mark_ntfs_record_dirty(struct page *page, const unsigned int ofs) {
 
 	BUG_ON(!PageUptodate(page));
 	end = ofs + ni->itype.index.block_size;
-	bh_size = VFS_I(ni)->i_sb->s_blocksize;
+	bh_size = inode_sb(VFS_I(ni))->s_blocksize;
 	spin_lock(&mapping->private_lock);
 	if (unlikely(!page_has_buffers(page))) {
 		spin_unlock(&mapping->private_lock);
fs/ntfs/bitmap.c +7 -4
index ec130c588d2b..7584c413bdb5 100644
@@ -75,7 +75,8 @@ int __ntfs_bitmap_set_bits_in_run(struct inode *vi, const s64 start_bit,
 	page = ntfs_map_page(mapping, index);
 	if (IS_ERR(page)) {
 		if (!is_rollback)
-			ntfs_error(vi->i_sb, "Failed to map first page (error "
+			ntfs_error(inode_sb(vi),
+					"Failed to map first page (error "
 					"%li), aborting.", PTR_ERR(page));
 		return PTR_ERR(page);
 	}
@@ -177,15 +178,17 @@ int __ntfs_bitmap_set_bits_in_run(struct inode *vi, const s64 start_bit,
 		pos = 0;
 	if (!pos) {
 		/* Rollback was successful. */
-		ntfs_error(vi->i_sb, "Failed to map subsequent page (error "
+		ntfs_error(inode_sb(vi),
+				"Failed to map subsequent page (error "
 				"%li), aborting.", PTR_ERR(page));
 	} else {
 		/* Rollback failed. */
-		ntfs_error(vi->i_sb, "Failed to map subsequent page (error "
+		ntfs_error(inode_sb(vi),
+				"Failed to map subsequent page (error "
 				"%li) and rollback failed (error %i).  "
 				"Aborting and leaving inconsistent metadata.  "
 				"Unmount and run chkdsk.", PTR_ERR(page), pos);
-		NVolSetErrors(NTFS_SB(vi->i_sb));
+		NVolSetErrors(NTFS_SB(inode_sb(vi)));
 	}
 	return PTR_ERR(page);
 }
fs/ntfs/dir.c +6 -4
index 1a24be9e8405..27505db99278 100644
@@ -1101,7 +1101,7 @@ static int ntfs_readdir(struct file *file, struct dir_context *actor)
 	s64 ia_pos, ia_start, prev_ia_pos, bmp_pos;
 	loff_t i_size;
 	struct inode *bmp_vi, *vdir = file_inode(file);
-	struct super_block *sb = vdir->i_sb;
+	struct super_block *sb = inode_sb(vdir);
 	ntfs_inode *ndir = NTFS_I(vdir);
 	ntfs_volume *vol = NTFS_SB(sb);
 	MFT_RECORD *m;
@@ -1517,20 +1517,22 @@ static int ntfs_dir_fsync(struct file *filp, loff_t start, loff_t end,
 	na.type = AT_BITMAP;
 	na.name = I30;
 	na.name_len = 4;
-	bmp_vi = ilookup5(vi->i_sb, vi->i_ino, (test_t)ntfs_test_inode, &na);
+	bmp_vi = ilookup5(inode_sb(vi), vi->i_ino, (test_t)ntfs_test_inode,
+			  &na);
 	if (bmp_vi) {
  		write_inode_now(bmp_vi, !datasync);
 		iput(bmp_vi);
 	}
 	ret = __ntfs_write_inode(vi, 1);
 	write_inode_now(vi, !datasync);
-	err = sync_blockdev(vi->i_sb->s_bdev);
+	err = sync_blockdev(inode_sb(vi)->s_bdev);
 	if (unlikely(err && !ret))
 		ret = err;
 	if (likely(!ret))
 		ntfs_debug("Done.");
 	else
-		ntfs_warning(vi->i_sb, "Failed to f%ssync inode 0x%lx.  Error "
+		ntfs_warning(inode_sb(vi),
+				"Failed to f%ssync inode 0x%lx.  Error "
 				"%u.", datasync ? "data" : "", vi->i_ino, -ret);
 	inode_unlock(vi);
 	return ret;
fs/ntfs/file.c +19 -11
index 331910fa8442..8955ab0c2869 100644
@@ -374,7 +374,7 @@ static ssize_t ntfs_prepare_file_for_write(struct kiocb *iocb,
 		 * compression kick in.  This is in contrast to encrypted files
 		 * (see above).
 		 */
-		ntfs_error(vi->i_sb, "Writing to compressed files is not "
+		ntfs_error(inode_sb(vi), "Writing to compressed files is not "
 				"implemented yet.  Sorry.");
 		err = -EOPNOTSUPP;
 		goto out;
@@ -439,7 +439,8 @@ static ssize_t ntfs_prepare_file_for_write(struct kiocb *iocb,
 				iov_iter_truncate(from, ll - pos);
 			} else {
 				if (err != -ENOSPC)
-					ntfs_error(vi->i_sb, "Cannot perform "
+					ntfs_error(inode_sb(vi),
+							"Cannot perform "
 							"write to inode "
 							"0x%lx, attribute "
 							"type 0x%x, because "
@@ -479,7 +480,8 @@ static ssize_t ntfs_prepare_file_for_write(struct kiocb *iocb,
 		inode_dio_wait(vi);
 		err = ntfs_attr_extend_initialized(ni, pos);
 		if (unlikely(err < 0))
-			ntfs_error(vi->i_sb, "Cannot perform write to inode "
+			ntfs_error(inode_sb(vi),
+					"Cannot perform write to inode "
 					"0x%lx, attribute type 0x%x, because "
 					"extending the initialized size "
 					"failed (error %d).", vi->i_ino,
@@ -1412,7 +1414,7 @@ static inline int ntfs_commit_pages_after_non_resident_write(
 
 	vi = pages[0]->mapping->host;
 	ni = NTFS_I(vi);
-	blocksize = vi->i_sb->s_blocksize;
+	blocksize = inode_sb(vi)->s_blocksize;
 	end = pos + bytes;
 	u = 0;
 	do {
@@ -1507,7 +1509,8 @@ static inline int ntfs_commit_pages_after_non_resident_write(
 		ntfs_attr_put_search_ctx(ctx);
 	if (m)
 		unmap_mft_record(base_ni);
-	ntfs_error(vi->i_sb, "Failed to update initialized_size/i_size (error "
+	ntfs_error(inode_sb(vi),
+			"Failed to update initialized_size/i_size (error "
 			"code %i).", err);
 	if (err != -ENOMEM)
 		NVolSetErrors(ni->vol);
@@ -1664,10 +1667,12 @@ static int ntfs_commit_pages_after_write(struct page **pages,
 	return 0;
 err_out:
 	if (err == -ENOMEM) {
-		ntfs_warning(vi->i_sb, "Error allocating memory required to "
+		ntfs_warning(inode_sb(vi),
+				"Error allocating memory required to "
 				"commit the write.");
 		if (PageUptodate(page)) {
-			ntfs_warning(vi->i_sb, "Page is uptodate, setting "
+			ntfs_warning(inode_sb(vi),
+					"Page is uptodate, setting "
 					"dirty so the write will be retried "
 					"later on by the VM.");
 			/*
@@ -1677,10 +1682,12 @@ static int ntfs_commit_pages_after_write(struct page **pages,
 			__set_page_dirty_nobuffers(page);
 			err = 0;
 		} else
-			ntfs_error(vi->i_sb, "Page is not uptodate.  Written "
+			ntfs_error(inode_sb(vi),
+					"Page is not uptodate.  Written "
 					"data has been lost.");
 	} else {
-		ntfs_error(vi->i_sb, "Resident attribute commit write failed "
+		ntfs_error(inode_sb(vi),
+				"Resident attribute commit write failed "
 				"with error %i.", err);
 		NVolSetErrors(ni->vol);
 	}
@@ -2003,13 +2010,14 @@ static int ntfs_file_fsync(struct file *filp, loff_t start, loff_t end,
 	 * fs/buffer.c) for dirty blocks then we could optimize the below to be
 	 * sync_mapping_buffers(vi->i_mapping).
 	 */
-	err = sync_blockdev(vi->i_sb->s_bdev);
+	err = sync_blockdev(inode_sb(vi)->s_bdev);
 	if (unlikely(err && !ret))
 		ret = err;
 	if (likely(!ret))
 		ntfs_debug("Done.");
 	else
-		ntfs_warning(vi->i_sb, "Failed to f%ssync inode 0x%lx.  Error "
+		ntfs_warning(inode_sb(vi),
+				"Failed to f%ssync inode 0x%lx.  Error "
 				"%u.", datasync ? "data" : "", vi->i_ino, -ret);
 	inode_unlock(vi);
 	return ret;
fs/ntfs/inode.c +141 -90

709 lines not on this page · raw message

fs/ntfs/inode.h +1 -1
index b3c3469de6cb..d22743c94763 100644
@@ -288,7 +288,7 @@ static inline void ntfs_init_big_inode(struct inode *vi)
 	ntfs_inode *ni = NTFS_I(vi);
 
 	ntfs_debug("Entering.");
-	__ntfs_init_inode(vi->i_sb, ni);
+	__ntfs_init_inode(inode_sb(vi), ni);
 	ni->mft_no = vi->i_ino;
 }
 
fs/ntfs/logfile.c +26 -20

166 lines not on this page · raw message

fs/ntfs/namei.c +4 -3
index 4690cd75d8d7..b55c2fb0ed56 100644
@@ -103,7 +103,7 @@
 static struct dentry *ntfs_lookup(struct inode *dir_ino, struct dentry *dent,
 		unsigned int flags)
 {
-	ntfs_volume *vol = NTFS_SB(dir_ino->i_sb);
+	ntfs_volume *vol = NTFS_SB(inode_sb(dir_ino));
 	struct inode *dent_inode;
 	ntfschar *uname;
 	ntfs_name *name = NULL;
@@ -326,7 +326,8 @@ static struct dentry *ntfs_get_parent(struct dentry *child_dent)
 		ntfs_attr_put_search_ctx(ctx);
 		unmap_mft_record(ni);
 		if (err == -ENOENT)
-			ntfs_error(vi->i_sb, "Inode 0x%lx does not have a "
+			ntfs_error(inode_sb(vi),
+					"Inode 0x%lx does not have a "
 					"file name attribute.  Run chkdsk.",
 					vi->i_ino);
 		return ERR_PTR(err);
@@ -345,7 +346,7 @@ static struct dentry *ntfs_get_parent(struct dentry *child_dent)
 	ntfs_attr_put_search_ctx(ctx);
 	unmap_mft_record(ni);
 
-	return d_obtain_alias(ntfs_iget(vi->i_sb, parent_ino));
+	return d_obtain_alias(ntfs_iget(inode_sb(vi), parent_ino));
 }
 
 static struct inode *ntfs_nfs_get_inode(struct super_block *sb,
Signature · 1 line
2.15.1
#55 lore raw

PATCH 54/76 fs/ocfs2: Use inode_sb() helper instead of inode->i_sb

In reply to Mark Fasheh
---
 fs/ocfs2/acl.c          |  10 +-
 fs/ocfs2/alloc.c        |  47 +++----
 fs/ocfs2/aops.c         |  85 ++++++------
 fs/ocfs2/dcache.c       |   2 +-
 fs/ocfs2/dir.c          | 127 +++++++++---------
 fs/ocfs2/dlmfs/dlmfs.c  |   2 +-
 fs/ocfs2/dlmglue.c      |  62 ++++-----
 fs/ocfs2/export.c       |   2 +-
 fs/ocfs2/extent_map.c   |  48 +++----
 fs/ocfs2/file.c         |  93 ++++++-------
 fs/ocfs2/inode.c        |  30 ++---
 fs/ocfs2/inode.h        |   2 +-
 fs/ocfs2/ioctl.c        |  22 ++--
 fs/ocfs2/journal.c      |   5 +-
 fs/ocfs2/journal.h      |   4 +-
 fs/ocfs2/localalloc.c   |   2 +-
 fs/ocfs2/locks.c        |   4 +-
 fs/ocfs2/mmap.c         |   4 +-
 fs/ocfs2/move_extents.c |  47 +++----
 fs/ocfs2/namei.c        |  24 ++--
 fs/ocfs2/ocfs2.h        |   2 +-
 fs/ocfs2/quota_global.c |   2 +-
 fs/ocfs2/quota_local.c  |  12 +-
 fs/ocfs2/refcounttree.c | 117 +++++++++--------
 fs/ocfs2/resize.c       |  27 ++--
 fs/ocfs2/slot_map.c     |   2 +-
 fs/ocfs2/suballoc.c     |  71 +++++-----
 fs/ocfs2/suballoc.h     |   2 +-
 fs/ocfs2/symlink.c      |   2 +-
 fs/ocfs2/xattr.c        | 339 ++++++++++++++++++++++++------------------------
 30 files changed, 620 insertions(+), 578 deletions(-)
fs/ocfs2/acl.c +5 -5
index 917fadca8a7b..20bd414b4cfd 100644
@@ -181,7 +181,7 @@ static int ocfs2_acl_set_mode(struct inode *inode, struct buffer_head *di_bh,
 		get_bh(di_bh);
 
 	if (handle == NULL) {
-		handle = ocfs2_start_trans(OCFS2_SB(inode->i_sb),
+		handle = ocfs2_start_trans(OCFS2_SB(inode_sb(inode)),
 					   OCFS2_INODE_UPDATE_CREDITS);
 		if (IS_ERR(handle)) {
 			ret = PTR_ERR(handle);
@@ -211,7 +211,7 @@ static int ocfs2_acl_set_mode(struct inode *inode, struct buffer_head *di_bh,
 
 out_commit:
 	if (commit_handle)
-		ocfs2_commit_trans(OCFS2_SB(inode->i_sb), handle);
+		ocfs2_commit_trans(OCFS2_SB(inode_sb(inode)), handle);
 out_brelse:
 	brelse(di_bh);
 out:
@@ -303,7 +303,7 @@ struct posix_acl *ocfs2_iop_get_acl(struct inode *inode, int type)
 	int had_lock;
 	struct ocfs2_lock_holder oh;
 
-	osb = OCFS2_SB(inode->i_sb);
+	osb = OCFS2_SB(inode_sb(inode));
 	if (!(osb->s_mount_opt & OCFS2_MOUNT_POSIX_ACL))
 		return NULL;
 
@@ -322,7 +322,7 @@ struct posix_acl *ocfs2_iop_get_acl(struct inode *inode, int type)
 
 int ocfs2_acl_chmod(struct inode *inode, struct buffer_head *bh)
 {
-	struct ocfs2_super *osb = OCFS2_SB(inode->i_sb);
+	struct ocfs2_super *osb = OCFS2_SB(inode_sb(inode));
 	struct posix_acl *acl;
 	int ret;
 
@@ -358,7 +358,7 @@ int ocfs2_init_acl(handle_t *handle,
 		   struct ocfs2_alloc_context *meta_ac,
 		   struct ocfs2_alloc_context *data_ac)
 {
-	struct ocfs2_super *osb = OCFS2_SB(inode->i_sb);
+	struct ocfs2_super *osb = OCFS2_SB(inode_sb(inode));
 	struct posix_acl *acl = NULL;
 	int ret = 0, ret2;
 	umode_t mode;
fs/ocfs2/alloc.c +25 -22

161 lines not on this page · raw message

fs/ocfs2/aops.c +44 -41

298 lines not on this page · raw message

fs/ocfs2/dcache.c +1 -1
index 290373024d9d..a39ccd03fc83 100644
@@ -445,7 +445,7 @@ void ocfs2_dentry_move(struct dentry *dentry, struct dentry *target,
 		       struct inode *old_dir, struct inode *new_dir)
 {
 	int ret;
-	struct ocfs2_super *osb = OCFS2_SB(old_dir->i_sb);
+	struct ocfs2_super *osb = OCFS2_SB(inode_sb(old_dir));
 	struct inode *inode = d_inode(dentry);
 
 	/*
fs/ocfs2/dir.c +66 -61

475 lines not on this page · raw message

fs/ocfs2/dlmfs/dlmfs.c +1 -1
index 602c71f32740..a434f7e143cf 100644
@@ -412,7 +412,7 @@ static struct inode *dlmfs_get_inode(struct inode *parent,
 				     struct dentry *dentry,
 				     umode_t mode)
 {
-	struct super_block *sb = parent->i_sb;
+	struct super_block *sb = inode_sb(parent);
 	struct inode * inode = new_inode(sb);
 	struct dlmfs_inode_private *ip;
 
fs/ocfs2/dlmglue.c +33 -29

226 lines not on this page · raw message

fs/ocfs2/export.c +1 -1
index 9f88188060db..f54d262627ae 100644
@@ -166,7 +166,7 @@ static struct dentry *ocfs2_get_parent(struct dentry *child)
 		goto bail_unlock;
 	}
 
-	parent = d_obtain_alias(ocfs2_iget(OCFS2_SB(dir->i_sb), blkno, 0, 0));
+	parent = d_obtain_alias(ocfs2_iget(OCFS2_SB(inode_sb(dir)), blkno, 0, 0));
 
 bail_unlock:
 	ocfs2_inode_unlock(dir, 0);
fs/ocfs2/extent_map.c +25 -23

175 lines not on this page · raw message

fs/ocfs2/file.c +49 -44

321 lines not on this page · raw message

fs/ocfs2/inode.c +15 -15
index d51b80edd972..ebceb88328ee 100644
@@ -280,7 +280,7 @@ void ocfs2_populate_inode(struct inode *inode, struct ocfs2_dinode *fe,
 	struct ocfs2_super *osb;
 	int use_plocks = 1;
 
-	sb = inode->i_sb;
+	sb = inode_sb(inode);
 	osb = OCFS2_SB(sb);
 
 	if ((osb->s_mount_opt & OCFS2_MOUNT_LOCALFLOCKS) ||
@@ -383,8 +383,8 @@ void ocfs2_populate_inode(struct inode *inode, struct ocfs2_dinode *fe,
 	}
 
 	if (create_ino) {
-		inode->i_ino = ino_from_blkno(inode->i_sb,
-			       le64_to_cpu(fe->i_blkno));
+		inode->i_ino = ino_from_blkno(inode_sb(inode),
+				              le64_to_cpu(fe->i_blkno));
 
 		/*
 		 * If we ever want to create system files from kernel,
@@ -425,7 +425,7 @@ static int ocfs2_read_locked_inode(struct inode *inode,
 	u32 generation = 0;
 
 	status = -EINVAL;
-	sb = inode->i_sb;
+	sb = inode_sb(inode);
 	osb = OCFS2_SB(sb);
 
 	/*
@@ -658,7 +658,7 @@ static int ocfs2_remove_inode(struct inode *inode,
 	struct inode *inode_alloc_inode = NULL;
 	struct buffer_head *inode_alloc_bh = NULL;
 	handle_t *handle;
-	struct ocfs2_super *osb = OCFS2_SB(inode->i_sb);
+	struct ocfs2_super *osb = OCFS2_SB(inode_sb(inode));
 	struct ocfs2_dinode *di = (struct ocfs2_dinode *) di_bh->b_data;
 
 	inode_alloc_inode =
@@ -680,7 +680,7 @@ static int ocfs2_remove_inode(struct inode *inode,
 	}
 
 	handle = ocfs2_start_trans(osb, OCFS2_DELETE_INODE_CREDITS +
-				   ocfs2_quota_trans_credits(inode->i_sb));
+				   ocfs2_quota_trans_credits(inode_sb(inode)));
 	if (IS_ERR(handle)) {
 		status = PTR_ERR(handle);
 		mlog_errno(status);
@@ -769,7 +769,7 @@ static int ocfs2_wipe_inode(struct inode *inode,
 	int status, orphaned_slot = -1;
 	struct inode *orphan_dir_inode = NULL;
 	struct buffer_head *orphan_dir_bh = NULL;
-	struct ocfs2_super *osb = OCFS2_SB(inode->i_sb);
+	struct ocfs2_super *osb = OCFS2_SB(inode_sb(inode));
 	struct ocfs2_dinode *di = (struct ocfs2_dinode *) di_bh->b_data;
 
 	if (!(OCFS2_I(inode)->ip_flags & OCFS2_INODE_SKIP_ORPHAN_DIR)) {
@@ -858,7 +858,7 @@ static int ocfs2_inode_is_valid_to_delete(struct inode *inode)
 {
 	int ret = 0;
 	struct ocfs2_inode_info *oi = OCFS2_I(inode);
-	struct ocfs2_super *osb = OCFS2_SB(inode->i_sb);
+	struct ocfs2_super *osb = OCFS2_SB(inode_sb(inode));
 
 	trace_ocfs2_inode_is_valid_to_delete(current, osb->dc_task,
 					     (unsigned long long)oi->ip_blkno,
@@ -1045,7 +1045,7 @@ static void ocfs2_delete_inode(struct inode *inode)
 	 * shared mode so that all nodes can still concurrently
 	 * process deletes.
 	 */
-	status = ocfs2_nfs_sync_lock(OCFS2_SB(inode->i_sb), 0);
+	status = ocfs2_nfs_sync_lock(OCFS2_SB(inode_sb(inode)), 0);
 	if (status < 0) {
 		mlog(ML_ERROR, "getting nfs sync lock(PR) failed %d\n", status);
 		ocfs2_cleanup_delete_inode(inode, 0);
@@ -1117,7 +1117,7 @@ static void ocfs2_delete_inode(struct inode *inode)
 	brelse(di_bh);
 
 bail_unlock_nfs_sync:
-	ocfs2_nfs_sync_unlock(OCFS2_SB(inode->i_sb), 0);
+	ocfs2_nfs_sync_unlock(OCFS2_SB(inode_sb(inode)), 0);
 
 bail_unblock:
 	ocfs2_unblock_signals(&oldset);
@@ -1129,13 +1129,13 @@ static void ocfs2_clear_inode(struct inode *inode)
 {
 	int status;
 	struct ocfs2_inode_info *oi = OCFS2_I(inode);
-	struct ocfs2_super *osb = OCFS2_SB(inode->i_sb);
+	struct ocfs2_super *osb = OCFS2_SB(inode_sb(inode));
 
 	clear_inode(inode);
 	trace_ocfs2_clear_inode((unsigned long long)oi->ip_blkno,
 				inode->i_nlink);
 
-	mlog_bug_on_msg(OCFS2_SB(inode->i_sb) == NULL,
+	mlog_bug_on_msg(OCFS2_SB(inode_sb(inode)) == NULL,
 			"Inode=%lu\n", inode->i_ino);
 
 	dquot_drop(inode);
@@ -1150,7 +1150,7 @@ static void ocfs2_clear_inode(struct inode *inode)
 	ocfs2_mark_lockres_freeing(osb, &oi->ip_inode_lockres);
 	ocfs2_mark_lockres_freeing(osb, &oi->ip_open_lockres);
 
-	ocfs2_resv_discard(&OCFS2_SB(inode->i_sb)->osb_la_resmap,
+	ocfs2_resv_discard(&OCFS2_SB(inode_sb(inode))->osb_la_resmap,
 			   &oi->ip_la_data_resv);
 	ocfs2_resv_init_once(&oi->ip_la_data_resv);
 
@@ -1223,7 +1223,7 @@ static void ocfs2_clear_inode(struct inode *inode)
 	 * the journal is flushed before journal shutdown. Thus it is safe to
 	 * have inodes get cleaned up after journal shutdown.
 	 */
-	jbd2_journal_release_jbd_inode(OCFS2_SB(inode->i_sb)->journal->j_journal,
+	jbd2_journal_release_jbd_inode(OCFS2_SB(inode_sb(inode))->journal->j_journal,
 				       &oi->ip_jinode);
 }
 
@@ -1636,7 +1636,7 @@ static struct super_block *ocfs2_inode_cache_get_super(struct ocfs2_caching_info
 {
 	struct ocfs2_inode_info *oi = cache_info_to_inode(ci);
 
-	return oi->vfs_inode.i_sb;
+	return inode_sb(&oi->vfs_inode);
 }
 
 static void ocfs2_inode_cache_lock(struct ocfs2_caching_info *ci)
fs/ocfs2/inode.h +1 -1
index 9b955f732bca..740204816ff7 100644
@@ -158,7 +158,7 @@ void ocfs2_get_inode_flags(struct ocfs2_inode_info *oi);
 
 static inline blkcnt_t ocfs2_inode_sector_count(struct inode *inode)
 {
-	int c_to_s_bits = OCFS2_SB(inode->i_sb)->s_clustersize_bits - 9;
+	int c_to_s_bits = OCFS2_SB(inode_sb(inode))->s_clustersize_bits - 9;
 
 	return (blkcnt_t)OCFS2_I(inode)->ip_clusters << c_to_s_bits;
 }
fs/ocfs2/ioctl.c +11 -11
index ab30c005cc4b..9be6d9d1390d 100644
@@ -81,7 +81,7 @@ static int ocfs2_set_inode_attr(struct inode *inode, unsigned flags,
 				unsigned mask)
 {
 	struct ocfs2_inode_info *ocfs2_inode = OCFS2_I(inode);
-	struct ocfs2_super *osb = OCFS2_SB(inode->i_sb);
+	struct ocfs2_super *osb = OCFS2_SB(inode_sb(inode));
 	handle_t *handle = NULL;
 	struct buffer_head *bh = NULL;
 	unsigned oldflags;
@@ -151,7 +151,7 @@ static int ocfs2_info_handle_blocksize(struct inode *inode,
 	if (o2info_from_user(oib, req))
 		return -EFAULT;
 
-	oib.ib_blocksize = inode->i_sb->s_blocksize;
+	oib.ib_blocksize = inode_sb(inode)->s_blocksize;
 
 	o2info_set_request_filled(&oib.ib_req);
 
@@ -165,7 +165,7 @@ static int ocfs2_info_handle_clustersize(struct inode *inode,
 					 struct ocfs2_info_request __user *req)
 {
 	struct ocfs2_info_clustersize oic;
-	struct ocfs2_super *osb = OCFS2_SB(inode->i_sb);
+	struct ocfs2_super *osb = OCFS2_SB(inode_sb(inode));
 
 	if (o2info_from_user(oic, req))
 		return -EFAULT;
@@ -184,7 +184,7 @@ static int ocfs2_info_handle_maxslots(struct inode *inode,
 				      struct ocfs2_info_request __user *req)
 {
 	struct ocfs2_info_maxslots oim;
-	struct ocfs2_super *osb = OCFS2_SB(inode->i_sb);
+	struct ocfs2_super *osb = OCFS2_SB(inode_sb(inode));
 
 	if (o2info_from_user(oim, req))
 		return -EFAULT;
@@ -203,7 +203,7 @@ static int ocfs2_info_handle_label(struct inode *inode,
 				   struct ocfs2_info_request __user *req)
 {
 	struct ocfs2_info_label oil;
-	struct ocfs2_super *osb = OCFS2_SB(inode->i_sb);
+	struct ocfs2_super *osb = OCFS2_SB(inode_sb(inode));
 
 	if (o2info_from_user(oil, req))
 		return -EFAULT;
@@ -222,7 +222,7 @@ static int ocfs2_info_handle_uuid(struct inode *inode,
 				  struct ocfs2_info_request __user *req)
 {
 	struct ocfs2_info_uuid oiu;
-	struct ocfs2_super *osb = OCFS2_SB(inode->i_sb);
+	struct ocfs2_super *osb = OCFS2_SB(inode_sb(inode));
 
 	if (o2info_from_user(oiu, req))
 		return -EFAULT;
@@ -241,7 +241,7 @@ static int ocfs2_info_handle_fs_features(struct inode *inode,
 					 struct ocfs2_info_request __user *req)
 {
 	struct ocfs2_info_fs_features oif;
-	struct ocfs2_super *osb = OCFS2_SB(inode->i_sb);
+	struct ocfs2_super *osb = OCFS2_SB(inode_sb(inode));
 
 	if (o2info_from_user(oif, req))
 		return -EFAULT;
@@ -262,7 +262,7 @@ static int ocfs2_info_handle_journal_size(struct inode *inode,
 					  struct ocfs2_info_request __user *req)
 {
 	struct ocfs2_info_journal_size oij;
-	struct ocfs2_super *osb = OCFS2_SB(inode->i_sb);
+	struct ocfs2_super *osb = OCFS2_SB(inode_sb(inode));
 
 	if (o2info_from_user(oij, req))
 		return -EFAULT;
@@ -333,7 +333,7 @@ static int ocfs2_info_handle_freeinode(struct inode *inode,
 	char namebuf[40];
 	int status, type = INODE_ALLOC_SYSTEM_INODE;
 	struct ocfs2_info_freeinode *oifi = NULL;
-	struct ocfs2_super *osb = OCFS2_SB(inode->i_sb);
+	struct ocfs2_super *osb = OCFS2_SB(inode_sb(inode));
 	struct inode *inode_alloc = NULL;
 
 	oifi = kzalloc(sizeof(struct ocfs2_info_freeinode), GFP_KERNEL);
@@ -621,7 +621,7 @@ static int ocfs2_info_handle_freefrag(struct inode *inode,
 	int status, type = GLOBAL_BITMAP_SYSTEM_INODE;
 
 	struct ocfs2_info_freefrag *oiff;
-	struct ocfs2_super *osb = OCFS2_SB(inode->i_sb);
+	struct ocfs2_super *osb = OCFS2_SB(inode_sb(inode));
 	struct inode *gb_inode = NULL;
 
 	oiff = kzalloc(sizeof(struct ocfs2_info_freefrag), GFP_KERNEL);
@@ -924,7 +924,7 @@ long ocfs2_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
 		return ocfs2_info_handle(inode, &info, 0);
 	case FITRIM:
 	{
-		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 = 0;
fs/ocfs2/journal.c +3 -2
index e5dcea6cee5f..e0047816c7b7 100644
@@ -1161,9 +1161,10 @@ static int ocfs2_force_read_journal(struct inode *inode)
 	int i;
 	u64 v_blkno, p_blkno, p_blocks, num_blocks;
 	struct buffer_head *bh = NULL;
-	struct ocfs2_super *osb = OCFS2_SB(inode->i_sb);
+	struct ocfs2_super *osb = OCFS2_SB(inode_sb(inode));
 
-	num_blocks = ocfs2_blocks_for_bytes(inode->i_sb, i_size_read(inode));
+	num_blocks = ocfs2_blocks_for_bytes(inode_sb(inode),
+					    i_size_read(inode));
 	v_blkno = 0;
 	while (v_blkno < num_blocks) {
 		status = ocfs2_extent_map_get_blocks(inode, v_blkno,
fs/ocfs2/journal.h +2 -2
index 497a4171ef61..504560ccfa94 100644
@@ -205,7 +205,7 @@ static inline void ocfs2_start_checkpoint(struct ocfs2_super *osb)
 
 static inline void ocfs2_checkpoint_inode(struct inode *inode)
 {
-	struct ocfs2_super *osb = OCFS2_SB(inode->i_sb);
+	struct ocfs2_super *osb = OCFS2_SB(inode_sb(inode));
 
 	if (ocfs2_mount_local(osb))
 		return;
@@ -626,7 +626,7 @@ static inline int ocfs2_begin_ordered_truncate(struct inode *inode,
 					       loff_t new_size)
 {
 	return jbd2_journal_begin_ordered_truncate(
-				OCFS2_SB(inode->i_sb)->journal->j_journal,
+				OCFS2_SB(inode_sb(inode))->journal->j_journal,
 				&OCFS2_I(inode)->ip_jinode,
 				new_size);
 }
fs/ocfs2/localalloc.c +1 -1
index fe0d1f9571bb..579b6a5848aa 100644
@@ -330,7 +330,7 @@ int ocfs2_load_local_alloc(struct ocfs2_super *osb)
 	}
 
 	if ((la->la_size == 0) ||
-	    (le16_to_cpu(la->la_size) > ocfs2_local_alloc_size(inode->i_sb))) {
+	    (le16_to_cpu(la->la_size) > ocfs2_local_alloc_size(inode_sb(inode)))) {
 		mlog(ML_ERROR, "Local alloc size is invalid (la_size = %u)\n",
 		     le16_to_cpu(la->la_size));
 		status = -EINVAL;
fs/ocfs2/locks.c +2 -2
index d56f0079b858..91888b521133 100644
@@ -113,7 +113,7 @@ static int ocfs2_do_funlock(struct file *file, int cmd, struct file_lock *fl)
 int ocfs2_flock(struct file *file, int cmd, struct file_lock *fl)
 {
 	struct inode *inode = file->f_mapping->host;
-	struct ocfs2_super *osb = OCFS2_SB(inode->i_sb);
+	struct ocfs2_super *osb = OCFS2_SB(inode_sb(inode));
 
 	if (!(fl->fl_flags & FL_FLOCK))
 		return -ENOLCK;
@@ -133,7 +133,7 @@ int ocfs2_flock(struct file *file, int cmd, struct file_lock *fl)
 int ocfs2_lock(struct file *file, int cmd, struct file_lock *fl)
 {
 	struct inode *inode = file->f_mapping->host;
-	struct ocfs2_super *osb = OCFS2_SB(inode->i_sb);
+	struct ocfs2_super *osb = OCFS2_SB(inode_sb(inode));
 
 	if (!(fl->fl_flags & FL_POSIX))
 		return -ENOLCK;
fs/ocfs2/mmap.c +2 -2
index fb9a20e3d608..83aa18171e29 100644
@@ -136,7 +136,7 @@ static int ocfs2_page_mkwrite(struct vm_fault *vmf)
 	sigset_t oldset;
 	int ret;
 
-	sb_start_pagefault(inode->i_sb);
+	sb_start_pagefault(inode_sb(inode));
 	ocfs2_block_signals(&oldset);
 
 	/*
@@ -170,7 +170,7 @@ static int ocfs2_page_mkwrite(struct vm_fault *vmf)
 
 out:
 	ocfs2_unblock_signals(&oldset);
-	sb_end_pagefault(inode->i_sb);
+	sb_end_pagefault(inode_sb(inode));
 	return ret;
 }
 
fs/ocfs2/move_extents.c +25 -22

164 lines not on this page · raw message

fs/ocfs2/namei.c +12 -12
index c801eddc4bf3..5e8eaf059b93 100644
@@ -139,7 +139,7 @@ static struct dentry *ocfs2_lookup(struct inode *dir, struct dentry *dentry,
 	if (status < 0)
 		goto bail_add;
 
-	inode = ocfs2_iget(OCFS2_SB(dir->i_sb), blkno, 0, 0);
+	inode = ocfs2_iget(OCFS2_SB(inode_sb(dir)), blkno, 0, 0);
 	if (IS_ERR(inode)) {
 		ret = ERR_PTR(-EACCES);
 		goto bail_unlock;
@@ -201,7 +201,7 @@ static struct inode *ocfs2_get_init_inode(struct inode *dir, umode_t mode)
 	struct inode *inode;
 	int status;
 
-	inode = new_inode(dir->i_sb);
+	inode = new_inode(inode_sb(dir));
 	if (!inode) {
 		mlog(ML_ERROR, "new_inode failed!\n");
 		return ERR_PTR(-ENOMEM);
@@ -273,7 +273,7 @@ static int ocfs2_mknod(struct inode *dir,
 	}
 
 	/* get our super block */
-	osb = OCFS2_SB(dir->i_sb);
+	osb = OCFS2_SB(inode_sb(dir));
 
 	status = ocfs2_inode_lock(dir, &parent_fe_bh, 1);
 	if (status < 0) {
@@ -512,7 +512,7 @@ static int __ocfs2_mknod_locked(struct inode *dir,
 				u64 fe_blkno, u64 suballoc_loc, u16 suballoc_bit)
 {
 	int status = 0;
-	struct ocfs2_super *osb = OCFS2_SB(dir->i_sb);
+	struct ocfs2_super *osb = OCFS2_SB(inode_sb(dir));
 	struct ocfs2_dinode *fe = NULL;
 	struct ocfs2_extent_list *fel;
 	u16 feat;
@@ -696,7 +696,7 @@ static int ocfs2_link(struct dentry *old_dentry,
 	struct buffer_head *old_dir_bh = NULL;
 	struct buffer_head *parent_fe_bh = NULL;
 	struct ocfs2_dinode *fe = NULL;
-	struct ocfs2_super *osb = OCFS2_SB(dir->i_sb);
+	struct ocfs2_super *osb = OCFS2_SB(inode_sb(dir));
 	struct ocfs2_dir_lookup_result lookup = { NULL, };
 	sigset_t oldset;
 	u64 old_de_ino;
@@ -885,7 +885,7 @@ static int ocfs2_unlink(struct inode *dir,
 	bool is_unlinkable = false;
 	struct inode *inode = d_inode(dentry);
 	struct inode *orphan_dir = NULL;
-	struct ocfs2_super *osb = OCFS2_SB(dir->i_sb);
+	struct ocfs2_super *osb = OCFS2_SB(inode_sb(dir));
 	u64 blkno;
 	struct ocfs2_dinode *fe = NULL;
 	struct buffer_head *fe_bh = NULL;
@@ -1253,7 +1253,7 @@ static int ocfs2_rename(struct inode *old_dir,
 		goto bail;
 	}
 
-	osb = OCFS2_SB(old_dir->i_sb);
+	osb = OCFS2_SB(inode_sb(old_dir));
 
 	if (new_inode) {
 		if (!igrab(new_inode))
@@ -1829,7 +1829,7 @@ static int ocfs2_symlink(struct inode *dir,
 		goto bail;
 	}
 
-	sb = dir->i_sb;
+	sb = inode_sb(dir);
 	osb = OCFS2_SB(sb);
 
 	l = strlen(symname) + 1;
@@ -2134,7 +2134,7 @@ static int __ocfs2_prepare_orphan_dir(struct inode *orphan_dir_inode,
 				      bool dio)
 {
 	int ret;
-	struct ocfs2_super *osb = OCFS2_SB(orphan_dir_inode->i_sb);
+	struct ocfs2_super *osb = OCFS2_SB(inode_sb(orphan_dir_inode));
 	int namelen = dio ?
 			(OCFS2_DIO_ORPHAN_PREFIX_LEN + OCFS2_ORPHAN_NAMELEN) :
 			OCFS2_ORPHAN_NAMELEN;
@@ -2434,7 +2434,7 @@ static int ocfs2_prep_new_orphaned_file(struct inode *dir,
 {
 	int ret;
 	u64 di_blkno;
-	struct ocfs2_super *osb = OCFS2_SB(dir->i_sb);
+	struct ocfs2_super *osb = OCFS2_SB(inode_sb(dir));
 	struct inode *orphan_dir = NULL;
 	struct buffer_head *orphan_dir_bh = NULL;
 	struct ocfs2_alloc_context *inode_ac = NULL;
@@ -2500,7 +2500,7 @@ int ocfs2_create_inode_in_orphan(struct inode *dir,
 	int status, did_quota_inode = 0;
 	struct inode *inode = NULL;
 	struct inode *orphan_dir = NULL;
-	struct ocfs2_super *osb = OCFS2_SB(dir->i_sb);
+	struct ocfs2_super *osb = OCFS2_SB(inode_sb(dir));
 	struct ocfs2_dinode *di = NULL;
 	handle_t *handle = NULL;
 	char orphan_name[OCFS2_ORPHAN_NAMELEN + 1];
@@ -2773,7 +2773,7 @@ int ocfs2_mv_orphaned_inode_to_new(struct inode *dir,
 	int status = 0;
 	struct buffer_head *parent_di_bh = NULL;
 	handle_t *handle = NULL;
-	struct ocfs2_super *osb = OCFS2_SB(dir->i_sb);
+	struct ocfs2_super *osb = OCFS2_SB(inode_sb(dir));
 	struct ocfs2_dinode *dir_di, *di;
 	struct inode *orphan_dir_inode = NULL;
 	struct buffer_head *orphan_dir_bh = NULL;
fs/ocfs2/ocfs2.h +1 -1
index 6867eef2e06b..ec6501f88b75 100644
@@ -485,7 +485,7 @@ static inline int ocfs2_should_order_data(struct inode *inode)
 {
 	if (!S_ISREG(inode->i_mode))
 		return 0;
-	if (OCFS2_SB(inode->i_sb)->s_mount_opt & OCFS2_MOUNT_DATA_WRITEBACK)
+	if (OCFS2_SB(inode_sb(inode))->s_mount_opt & OCFS2_MOUNT_DATA_WRITEBACK)
 		return 0;
 	return 1;
 }
fs/ocfs2/quota_global.c +1 -1
index 7a922190a8c7..aa80eb17f73a 100644
@@ -638,7 +638,7 @@ static void qsync_work_fn(struct work_struct *work)
 	struct ocfs2_mem_dqinfo *oinfo = container_of(work,
 						      struct ocfs2_mem_dqinfo,
 						      dqi_sync_work.work);
-	struct super_block *sb = oinfo->dqi_gqinode->i_sb;
+	struct super_block *sb = inode_sb(oinfo->dqi_gqinode);
 
 	/*
 	 * We have to be careful here not to deadlock on s_umount as umount
fs/ocfs2/quota_local.c +6 -6
index 16c42ed0dca8..25e59756fec1 100644
@@ -94,7 +94,7 @@ static int ol_dqblk_chunk_off(struct super_block *sb, int c, loff_t off)
 static int ocfs2_modify_bh(struct inode *inode, struct buffer_head *bh,
 		void (*modify)(struct buffer_head *, void *), void *private)
 {
-	struct super_block *sb = inode->i_sb;
+	struct super_block *sb = inode_sb(inode);
 	handle_t *handle;
 	int status;
 
@@ -137,8 +137,8 @@ static int ocfs2_read_quota_block(struct inode *inode, u64 v_block,
 	int rc = 0;
 	struct buffer_head *tmp = *bh;
 
-	if (i_size_read(inode) >> inode->i_sb->s_blocksize_bits <= v_block) {
-		ocfs2_error(inode->i_sb,
+	if (i_size_read(inode) >> inode_sb(inode)->s_blocksize_bits <= v_block) {
+		ocfs2_error(inode_sb(inode),
 			    "Quota file %llu is probably corrupted! Requested to read block %Lu but file has size only %Lu\n",
 			    (unsigned long long)OCFS2_I(inode)->ip_blkno,
 			    (unsigned long long)v_block,
@@ -264,7 +264,7 @@ static int ocfs2_load_local_quota_bitmaps(struct inode *inode,
 		newchunk->qc_num = i;
 		newchunk->qc_headerbh = NULL;
 		status = ocfs2_read_quota_block(inode,
-				ol_quota_chunk_block(inode->i_sb, i),
+				ol_quota_chunk_block(inode_sb(inode), i),
 				&newchunk->qc_headerbh);
 		if (status) {
 			mlog_errno(status);
@@ -341,7 +341,7 @@ static int ocfs2_recovery_load_quota(struct inode *lqinode,
 				     int type,
 				     struct list_head *head)
 {
-	struct super_block *sb = lqinode->i_sb;
+	struct super_block *sb = inode_sb(lqinode);
 	struct buffer_head *hbh;
 	struct ocfs2_local_disk_chunk *dchunk;
 	int i, chunks = le32_to_cpu(ldinfo->dqi_chunks);
@@ -460,7 +460,7 @@ static int ocfs2_recover_local_quota_file(struct inode *lqinode,
 					  int type,
 					  struct ocfs2_quota_recovery *rec)
 {
-	struct super_block *sb = lqinode->i_sb;
+	struct super_block *sb = inode_sb(lqinode);
 	struct ocfs2_mem_dqinfo *oinfo = sb_dqinfo(sb, type)->dqi_priv;
 	struct ocfs2_local_disk_chunk *dchunk;
 	struct ocfs2_local_disk_dqblk *dqblk;
fs/ocfs2/refcounttree.c +61 -56

397 lines not on this page · raw message

fs/ocfs2/resize.c +14 -13
index 18451e0fab81..ae75edf88a65 100644
@@ -63,8 +63,8 @@ static u16 ocfs2_calc_new_backup_super(struct inode *inode,
 	u64 blkno, gd_blkno, lgd_blkno = le64_to_cpu(gd->bg_blkno);
 
 	for (i = 0; i < OCFS2_MAX_BACKUP_SUPERBLOCKS; i++) {
-		blkno = ocfs2_backup_super_blkno(inode->i_sb, i);
-		cluster = ocfs2_blocks_to_clusters(inode->i_sb, blkno);
+		blkno = ocfs2_backup_super_blkno(inode_sb(inode), i);
+		cluster = ocfs2_blocks_to_clusters(inode_sb(inode), blkno);
 
 		gd_blkno = ocfs2_which_cluster_group(inode, cluster);
 		if (gd_blkno < lgd_blkno)
@@ -73,7 +73,8 @@ static u16 ocfs2_calc_new_backup_super(struct inode *inode,
 			break;
 
 		/* check if already done backup super */
-		lgd_cluster = ocfs2_blocks_to_clusters(inode->i_sb, lgd_blkno);
+		lgd_cluster = ocfs2_blocks_to_clusters(inode_sb(inode),
+						       lgd_blkno);
 		lgd_cluster += old_bg_clusters;
 		if (lgd_cluster >= cluster)
 			continue;
@@ -98,7 +99,7 @@ static int ocfs2_update_last_group_and_inode(handle_t *handle,
 					     int new_clusters)
 {
 	int ret = 0;
-	struct ocfs2_super *osb = OCFS2_SB(bm_inode->i_sb);
+	struct ocfs2_super *osb = OCFS2_SB(inode_sb(bm_inode));
 	struct ocfs2_dinode *fe = (struct ocfs2_dinode *) bm_bh->b_data;
 	struct ocfs2_chain_list *cl = &fe->id2.i_chain;
 	struct ocfs2_chain_rec *cr;
@@ -190,12 +191,12 @@ static int update_backups(struct inode * inode, u32 clusters, char *data)
 	u64 blkno;
 	struct buffer_head *backup = NULL;
 	struct ocfs2_dinode *backup_di = NULL;
-	struct ocfs2_super *osb = OCFS2_SB(inode->i_sb);
+	struct ocfs2_super *osb = OCFS2_SB(inode_sb(inode));
 
 	/* calculate the real backups we need to update. */
 	for (i = 0; i < OCFS2_MAX_BACKUP_SUPERBLOCKS; i++) {
-		blkno = ocfs2_backup_super_blkno(inode->i_sb, i);
-		cluster = ocfs2_blocks_to_clusters(inode->i_sb, blkno);
+		blkno = ocfs2_backup_super_blkno(inode_sb(inode), i);
+		cluster = ocfs2_blocks_to_clusters(inode_sb(inode), blkno);
 		if (cluster >= clusters)
 			break;
 
@@ -205,7 +206,7 @@ static int update_backups(struct inode * inode, u32 clusters, char *data)
 			break;
 		}
 
-		memcpy(backup->b_data, data, inode->i_sb->s_blocksize);
+		memcpy(backup->b_data, data, inode_sb(inode)->s_blocksize);
 
 		backup_di = (struct ocfs2_dinode *)backup->b_data;
 		backup_di->i_blkno = cpu_to_le64(blkno);
@@ -229,7 +230,7 @@ static void ocfs2_update_super_and_backups(struct inode *inode,
 	u32 clusters = 0;
 	struct buffer_head *super_bh = NULL;
 	struct ocfs2_dinode *super_di = NULL;
-	struct ocfs2_super *osb = OCFS2_SB(inode->i_sb);
+	struct ocfs2_super *osb = OCFS2_SB(inode_sb(inode));
 
 	/*
 	 * update the superblock last.
@@ -279,7 +280,7 @@ int ocfs2_group_extend(struct inode * inode, int new_clusters)
 	struct inode *main_bm_inode = NULL;
 	struct ocfs2_dinode *fe = NULL;
 	struct ocfs2_group_desc *group = NULL;
-	struct ocfs2_super *osb = OCFS2_SB(inode->i_sb);
+	struct ocfs2_super *osb = OCFS2_SB(inode_sb(inode));
 	u16 cl_bpc;
 	u32 first_new_cluster;
 	u64 lgd_blkno;
@@ -392,7 +393,7 @@ static int ocfs2_check_new_group(struct inode *inode,
 		(struct ocfs2_group_desc *)group_bh->b_data;
 	u16 cl_bpc = le16_to_cpu(di->id2.i_chain.cl_bpc);
 
-	ret = ocfs2_check_group_descriptor(inode->i_sb, di, group_bh);
+	ret = ocfs2_check_group_descriptor(inode_sb(inode), di, group_bh);
 	if (ret)
 		goto out;
 
@@ -428,7 +429,7 @@ static int ocfs2_verify_group_and_input(struct inode *inode,
 	u16 cl_count = le16_to_cpu(di->id2.i_chain.cl_count);
 	u16 cl_cpg = le16_to_cpu(di->id2.i_chain.cl_cpg);
 	u16 next_free = le16_to_cpu(di->id2.i_chain.cl_next_free_rec);
-	u32 cluster = ocfs2_blocks_to_clusters(inode->i_sb, input->group);
+	u32 cluster = ocfs2_blocks_to_clusters(inode_sb(inode), input->group);
 	u32 total_clusters = le32_to_cpu(di->i_clusters);
 	int ret = -EINVAL;
 
@@ -466,7 +467,7 @@ int ocfs2_group_add(struct inode *inode, struct ocfs2_new_group_input *input)
 	struct buffer_head *main_bm_bh = NULL;
 	struct inode *main_bm_inode = NULL;
 	struct ocfs2_dinode *fe = NULL;
-	struct ocfs2_super *osb = OCFS2_SB(inode->i_sb);
+	struct ocfs2_super *osb = OCFS2_SB(inode_sb(inode));
 	struct buffer_head *group_bh = NULL;
 	struct ocfs2_group_desc *group = NULL;
 	struct ocfs2_chain_list *cl;
fs/ocfs2/slot_map.c +1 -1
index d7407994f308..3c0018119153 100644
@@ -363,7 +363,7 @@ static int ocfs2_map_slot_buffers(struct ocfs2_super *osb,
 	if (status)
 		goto bail;
 
-	blocks = ocfs2_blocks_for_bytes(si->si_inode->i_sb, bytes);
+	blocks = ocfs2_blocks_for_bytes(inode_sb(si->si_inode), bytes);
 	BUG_ON(blocks > UINT_MAX);
 	si->si_blocks = blocks;
 	if (!si->si_blocks)
fs/ocfs2/suballoc.c +37 -34

190 lines not on this page · raw message

fs/ocfs2/suballoc.h +1 -1
index 2d2501767c0c..95ad9e247205 100644

Lines of this file are not shown. View the raw message.

fs/ocfs2/symlink.c +1 -1
index 94cfacc9bad7..a3386fcdf699 100644

Lines of this file are not shown. View the raw message.

fs/ocfs2/xattr.c +173 -166

339 lines not on this page · raw message

The rest of this diff is not shown. View the raw message.

Signature · 1 line
2.15.1

Part of the diff is not shown here. View the raw message.

#56 lore raw

PATCH 55/76 fs/omfs: Use inode_sb() helper instead of inode->i_sb

In reply to Mark Fasheh
---
 fs/omfs/dir.c   | 24 ++++++++++++------------
 fs/omfs/file.c  | 37 +++++++++++++++++++------------------
 fs/omfs/inode.c | 19 ++++++++++---------
 3 files changed, 41 insertions(+), 39 deletions(-)
fs/omfs/dir.c +12 -12
index b7146526afff..5a589c5a852f 100644
@@ -28,7 +28,7 @@ static struct buffer_head *omfs_get_bucket(struct inode *dir,
 	int bucket = omfs_hash(name, namelen, nbuckets);
 
 	*ofs = OMFS_DIR_START + bucket * 8;
-	return omfs_bread(dir->i_sb, dir->i_ino);
+	return omfs_bread(inode_sb(dir), dir->i_ino);
 }
 
 static struct buffer_head *omfs_scan_list(struct inode *dir, u64 block,
@@ -41,14 +41,14 @@ static struct buffer_head *omfs_scan_list(struct inode *dir, u64 block,
 	*prev_block = ~0;
 
 	while (block != ~0) {
-		bh = omfs_bread(dir->i_sb, block);
+		bh = omfs_bread(inode_sb(dir), block);
 		if (!bh) {
 			err = -EIO;
 			goto err;
 		}
 
 		oi = (struct omfs_inode *) bh->b_data;
-		if (omfs_is_bad(OMFS_SB(dir->i_sb), &oi->i_head, block)) {
+		if (omfs_is_bad(OMFS_SB(inode_sb(dir)), &oi->i_head, block)) {
 			brelse(bh);
 			goto err;
 		}
@@ -131,7 +131,7 @@ static int omfs_add_link(struct dentry *dentry, struct inode *inode)
 	brelse(bh);
 
 	/* now set the sibling and parent pointers on the new inode */
-	bh = omfs_bread(dir->i_sb, inode->i_ino);
+	bh = omfs_bread(inode_sb(dir), inode->i_ino);
 	if (!bh)
 		goto out;
 
@@ -187,7 +187,7 @@ static int omfs_delete_entry(struct dentry *dentry)
 	if (prev != ~0) {
 		/* found in middle of list, get list ptr */
 		brelse(bh);
-		bh = omfs_bread(dir->i_sb, prev);
+		bh = omfs_bread(inode_sb(dir), prev);
 		if (!bh)
 			goto out;
 
@@ -199,7 +199,7 @@ static int omfs_delete_entry(struct dentry *dentry)
 	mark_buffer_dirty(bh);
 
 	if (prev != ~0) {
-		dirty = omfs_iget(dir->i_sb, prev);
+		dirty = omfs_iget(inode_sb(dir), prev);
 		if (!IS_ERR(dirty)) {
 			mark_inode_dirty(dirty);
 			iput(dirty);
@@ -220,7 +220,7 @@ static int omfs_dir_is_empty(struct inode *inode)
 	u64 *ptr;
 	int i;
 
-	bh = omfs_bread(inode->i_sb, inode->i_ino);
+	bh = omfs_bread(inode_sb(inode), inode->i_ino);
 
 	if (!bh)
 		return 0;
@@ -263,7 +263,7 @@ static int omfs_add_node(struct inode *dir, struct dentry *dentry, umode_t mode)
 	if (IS_ERR(inode))
 		return PTR_ERR(inode);
 
-	err = omfs_make_empty(inode, dir->i_sb);
+	err = omfs_make_empty(inode, inode_sb(dir));
 	if (err)
 		goto out_free_inode;
 
@@ -304,7 +304,7 @@ static struct dentry *omfs_lookup(struct inode *dir, struct dentry *dentry,
 		struct omfs_inode *oi = (struct omfs_inode *)bh->b_data;
 		ino_t ino = be64_to_cpu(oi->i_head.h_self);
 		brelse(bh);
-		inode = omfs_iget(dir->i_sb, ino);
+		inode = omfs_iget(inode_sb(dir), ino);
 		if (IS_ERR(inode))
 			return ERR_CAST(inode);
 	}
@@ -332,7 +332,7 @@ static bool omfs_fill_chain(struct inode *dir, struct dir_context *ctx,
 {
 	/* follow chain in this bucket */
 	while (fsblock != ~0) {
-		struct buffer_head *bh = omfs_bread(dir->i_sb, fsblock);
+		struct buffer_head *bh = omfs_bread(inode_sb(dir), fsblock);
 		struct omfs_inode *oi;
 		u64 self;
 		unsigned char d_type;
@@ -341,7 +341,7 @@ static bool omfs_fill_chain(struct inode *dir, struct dir_context *ctx,
 			return true;
 
 		oi = (struct omfs_inode *) bh->b_data;
-		if (omfs_is_bad(OMFS_SB(dir->i_sb), &oi->i_head, fsblock)) {
+		if (omfs_is_bad(OMFS_SB(inode_sb(dir)), &oi->i_head, fsblock)) {
 			brelse(bh);
 			return true;
 		}
@@ -428,7 +428,7 @@ static int omfs_readdir(struct file *file, struct dir_context *ctx)
 	hchain = (ctx->pos >> 20) - 1;
 	hindex = ctx->pos & 0xfffff;
 
-	bh = omfs_bread(dir->i_sb, dir->i_ino);
+	bh = omfs_bread(inode_sb(dir), dir->i_ino);
 	if (!bh)
 		return -EINVAL;
 
fs/omfs/file.c +19 -18
index bf83e6644333..a714a3ba6d6a 100644
@@ -30,7 +30,7 @@ void omfs_make_empty_table(struct buffer_head *bh, int offset)
 
 int omfs_shrink_inode(struct inode *inode)
 {
-	struct omfs_sb_info *sbi = OMFS_SB(inode->i_sb);
+	struct omfs_sb_info *sbi = OMFS_SB(inode_sb(inode));
 	struct omfs_extent *oe;
 	struct omfs_extent_entry *entry;
 	struct buffer_head *bh;
@@ -49,7 +49,7 @@ int omfs_shrink_inode(struct inode *inode)
 	if (inode->i_size != 0)
 		goto out;
 
-	bh = omfs_bread(inode->i_sb, next);
+	bh = omfs_bread(inode_sb(inode), next);
 	if (!bh)
 		goto out;
 
@@ -76,7 +76,7 @@ int omfs_shrink_inode(struct inode *inode)
 			start = be64_to_cpu(entry->e_cluster);
 			count = be64_to_cpu(entry->e_blocks);
 
-			omfs_clear_range(inode->i_sb, start, (int) count);
+			omfs_clear_range(inode_sb(inode), start, (int) count);
 			entry++;
 		}
 		omfs_make_empty_table(bh, (char *) oe - bh->b_data);
@@ -84,12 +84,13 @@ int omfs_shrink_inode(struct inode *inode)
 		brelse(bh);
 
 		if (last != inode->i_ino)
-			omfs_clear_range(inode->i_sb, last, sbi->s_mirrors);
+			omfs_clear_range(inode_sb(inode), last,
+					 sbi->s_mirrors);
 
 		if (next == ~0)
 			break;
 
-		bh = omfs_bread(inode->i_sb, next);
+		bh = omfs_bread(inode_sb(inode), next);
 		if (!bh)
 			goto out;
 		oe = (struct omfs_extent *) (&bh->b_data[OMFS_EXTENT_CONT]);
@@ -118,7 +119,7 @@ static int omfs_grow_extent(struct inode *inode, struct omfs_extent *oe,
 {
 	struct omfs_extent_entry *terminator;
 	struct omfs_extent_entry *entry = &oe->e_entry;
-	struct omfs_sb_info *sbi = OMFS_SB(inode->i_sb);
+	struct omfs_sb_info *sbi = OMFS_SB(inode_sb(inode));
 	u32 extent_count = be32_to_cpu(oe->e_extent_count);
 	u64 new_block = 0;
 	u32 max_count;
@@ -145,7 +146,7 @@ static int omfs_grow_extent(struct inode *inode, struct omfs_extent *oe,
 		new_block = be64_to_cpu(entry->e_cluster) +
 			be64_to_cpu(entry->e_blocks);
 
-		if (omfs_allocate_block(inode->i_sb, new_block)) {
+		if (omfs_allocate_block(inode_sb(inode), new_block)) {
 			be64_add_cpu(&entry->e_blocks, 1);
 			terminator->e_blocks = ~(cpu_to_be64(
 				be64_to_cpu(~terminator->e_blocks) + 1));
@@ -159,8 +160,8 @@ static int omfs_grow_extent(struct inode *inode, struct omfs_extent *oe,
 		return -EIO;
 
 	/* try to allocate a new cluster */
-	ret = omfs_allocate_range(inode->i_sb, 1, sbi->s_clustersize,
-		&new_block, &new_count);
+	ret = omfs_allocate_range(inode_sb(inode), 1, sbi->s_clustersize,
+				  &new_block, &new_count);
 	if (ret)
 		goto out_fail;
 
@@ -194,8 +195,8 @@ static sector_t find_block(struct inode *inode, struct omfs_extent_entry *ent,
 	/* count > 1 because of terminator */
 	sector_t searched = 0;
 	for (; count > 1; count--) {
-		int numblocks = clus_to_blk(OMFS_SB(inode->i_sb),
-			be64_to_cpu(ent->e_blocks));
+		int numblocks = clus_to_blk(OMFS_SB(inode_sb(inode)),
+					    be64_to_cpu(ent->e_blocks));
 
 		if (block >= searched  &&
 		    block < searched + numblocks) {
@@ -204,8 +205,8 @@ static sector_t find_block(struct inode *inode, struct omfs_extent_entry *ent,
 			 * numblocks - (block - searched) is remainder
 			 */
 			*left = numblocks - (block - searched);
-			return clus_to_blk(OMFS_SB(inode->i_sb),
-				be64_to_cpu(ent->e_cluster)) +
+			return clus_to_blk(OMFS_SB(inode_sb(inode)),
+					   be64_to_cpu(ent->e_cluster)) +
 				block - searched;
 		}
 		searched += numblocks;
@@ -225,12 +226,12 @@ static int omfs_get_block(struct inode *inode, sector_t block,
 	int extent_count;
 	struct omfs_extent *oe;
 	struct omfs_extent_entry *entry;
-	struct omfs_sb_info *sbi = OMFS_SB(inode->i_sb);
+	struct omfs_sb_info *sbi = OMFS_SB(inode_sb(inode));
 	int max_blocks = bh_result->b_size >> inode->i_blkbits;
 	int remain;
 
 	ret = -EIO;
-	bh = omfs_bread(inode->i_sb, inode->i_ino);
+	bh = omfs_bread(inode_sb(inode), inode->i_ino);
 	if (!bh)
 		goto out;
 
@@ -253,7 +254,7 @@ static int omfs_get_block(struct inode *inode, sector_t block,
 		offset = find_block(inode, entry, block, extent_count, &remain);
 		if (offset > 0) {
 			ret = 0;
-			map_bh(bh_result, inode->i_sb, offset);
+			map_bh(bh_result, inode_sb(inode), offset);
 			if (remain > max_blocks)
 				remain = max_blocks;
 			bh_result->b_size = (remain << inode->i_blkbits);
@@ -263,7 +264,7 @@ static int omfs_get_block(struct inode *inode, sector_t block,
 			break;
 
 		brelse(bh);
-		bh = omfs_bread(inode->i_sb, next);
+		bh = omfs_bread(inode_sb(inode), next);
 		if (!bh)
 			goto out;
 		oe = (struct omfs_extent *) (&bh->b_data[OMFS_EXTENT_CONT]);
@@ -274,7 +275,7 @@ static int omfs_get_block(struct inode *inode, sector_t block,
 		if (ret == 0) {
 			mark_buffer_dirty(bh);
 			mark_inode_dirty(inode);
-			map_bh(bh_result, inode->i_sb,
+			map_bh(bh_result, inode_sb(inode),
 					clus_to_blk(sbi, new_block));
 		}
 	}
fs/omfs/inode.c +10 -9
index ee14af9e26f2..4e319c7712c9 100644
@@ -36,14 +36,15 @@ struct inode *omfs_new_inode(struct inode *dir, umode_t mode)
 	u64 new_block;
 	int err;
 	int len;
-	struct omfs_sb_info *sbi = OMFS_SB(dir->i_sb);
+	struct omfs_sb_info *sbi = OMFS_SB(inode_sb(dir));
 
-	inode = new_inode(dir->i_sb);
+	inode = new_inode(inode_sb(dir));
 	if (!inode)
 		return ERR_PTR(-ENOMEM);
 
-	err = omfs_allocate_range(dir->i_sb, sbi->s_mirrors, sbi->s_mirrors,
-			&new_block, &len);
+	err = omfs_allocate_range(inode_sb(dir), sbi->s_mirrors,
+				  sbi->s_mirrors,
+				  &new_block, &len);
 	if (err)
 		goto fail;
 
@@ -102,7 +103,7 @@ static void omfs_update_checksums(struct omfs_inode *oi)
 static int __omfs_write_inode(struct inode *inode, int wait)
 {
 	struct omfs_inode *oi;
-	struct omfs_sb_info *sbi = OMFS_SB(inode->i_sb);
+	struct omfs_sb_info *sbi = OMFS_SB(inode_sb(inode));
 	struct buffer_head *bh, *bh2;
 	u64 ctime;
 	int i;
@@ -110,7 +111,7 @@ static int __omfs_write_inode(struct inode *inode, int wait)
 	int sync_failed = 0;
 
 	/* get current inode since we may have written sibling ptrs etc. */
-	bh = omfs_bread(inode->i_sb, inode->i_ino);
+	bh = omfs_bread(inode_sb(inode), inode->i_ino);
 	if (!bh)
 		goto out;
 
@@ -149,7 +150,7 @@ static int __omfs_write_inode(struct inode *inode, int wait)
 
 	/* if mirroring writes, copy to next fsblock */
 	for (i = 1; i < sbi->s_mirrors; i++) {
-		bh2 = omfs_bread(inode->i_sb, inode->i_ino + i);
+		bh2 = omfs_bread(inode_sb(inode), inode->i_ino + i);
 		if (!bh2)
 			goto out_brelse;
 
@@ -196,7 +197,7 @@ static void omfs_evict_inode(struct inode *inode)
 		omfs_shrink_inode(inode);
 	}
 
-	omfs_clear_range(inode->i_sb, inode->i_ino, 2);
+	omfs_clear_range(inode_sb(inode), inode->i_ino, 2);
 }
 
 struct inode *omfs_iget(struct super_block *sb, ino_t ino)
@@ -214,7 +215,7 @@ struct inode *omfs_iget(struct super_block *sb, ino_t ino)
 	if (!(inode->i_state & I_NEW))
 		return inode;
 
-	bh = omfs_bread(inode->i_sb, ino);
+	bh = omfs_bread(inode_sb(inode), ino);
 	if (!bh)
 		goto iget_failed;
 
Signature · 1 line
2.15.1
#57 lore raw

PATCH 56/76 fs/openpromfs: Use inode_sb() helper instead of inode->i_sb

In reply to Mark Fasheh
---
 fs/openpromfs/inode.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
fs/openpromfs/inode.c +1 -1
index 2200662a9bf1..d1c59e6252c5 100644
@@ -229,7 +229,7 @@ static struct dentry *openpromfs_lookup(struct inode *dir, struct dentry *dentry
 	return ERR_PTR(-ENOENT);
 
 found:
-	inode = openprom_iget(dir->i_sb, ino);
+	inode = openprom_iget(inode_sb(dir), ino);
 	mutex_unlock(&op_mutex);
 	if (IS_ERR(inode))
 		return ERR_CAST(inode);
Signature · 1 line
2.15.1
#58 lore raw

PATCH 57/76 fs/orangefs: Use inode_sb() helper instead of inode->i_sb

In reply to Mark Fasheh
---
 fs/orangefs/file.c            |  2 +-
 fs/orangefs/namei.c           | 12 ++++++++----
 fs/orangefs/orangefs-kernel.h |  8 ++++----
 3 files changed, 13 insertions(+), 9 deletions(-)
fs/orangefs/file.c +1 -1
index 0d228cd087e6..123a0c5b4a22 100644
@@ -722,7 +722,7 @@ static int orangefs_lock(struct file *filp, int cmd, struct file_lock *fl)
 {
 	int rc = -EINVAL;
 
-	if (ORANGEFS_SB(file_inode(filp)->i_sb)->flags & ORANGEFS_OPT_LOCAL_LOCK) {
+	if (ORANGEFS_SB(inode_sb(file_inode(filp)))->flags & ORANGEFS_OPT_LOCAL_LOCK) {
 		if (cmd == F_GETLK) {
 			rc = 0;
 			posix_test_lock(filp, fl);
fs/orangefs/namei.c +8 -4
index 6e3134e6d98a..79b76f8f0ba8 100644
@@ -60,7 +60,8 @@ static int orangefs_create(struct inode *dir,
 	ref = new_op->downcall.resp.create.refn;
 	op_release(new_op);
 
-	inode = orangefs_new_inode(dir->i_sb, dir, S_IFREG | mode, 0, &ref);
+	inode = orangefs_new_inode(inode_sb(dir), dir, S_IFREG | mode, 0,
+				   &ref);
 	if (IS_ERR(inode)) {
 		gossip_err("%s: Failed to allocate inode for file :%pd:\n",
 			   __func__,
@@ -192,7 +193,8 @@ static struct dentry *orangefs_lookup(struct inode *dir, struct dentry *dentry,
 
 	orangefs_set_timeout(dentry);
 
-	inode = orangefs_iget(dir->i_sb, &new_op->downcall.resp.lookup.refn);
+	inode = orangefs_iget(inode_sb(dir),
+			      &new_op->downcall.resp.lookup.refn);
 	if (IS_ERR(inode)) {
 		gossip_debug(GOSSIP_NAME_DEBUG,
 			"error %ld from iget\n", PTR_ERR(inode));
@@ -320,7 +322,8 @@ static int orangefs_symlink(struct inode *dir,
 	ref = new_op->downcall.resp.sym.refn;
 	op_release(new_op);
 
-	inode = orangefs_new_inode(dir->i_sb, dir, S_IFLNK | mode, 0, &ref);
+	inode = orangefs_new_inode(inode_sb(dir), dir, S_IFLNK | mode, 0,
+				   &ref);
 	if (IS_ERR(inode)) {
 		gossip_err
 		    ("*** Failed to allocate orangefs symlink inode\n");
@@ -391,7 +394,8 @@ static int orangefs_mkdir(struct inode *dir, struct dentry *dentry, umode_t mode
 	ref = new_op->downcall.resp.mkdir.refn;
 	op_release(new_op);
 
-	inode = orangefs_new_inode(dir->i_sb, dir, S_IFDIR | mode, 0, &ref);
+	inode = orangefs_new_inode(inode_sb(dir), dir, S_IFDIR | mode, 0,
+				   &ref);
 	if (IS_ERR(inode)) {
 		gossip_err("*** Failed to allocate orangefs dir inode\n");
 		ret = PTR_ERR(inode);
fs/orangefs/orangefs-kernel.h +4 -4
index eebbaece85ef..c006a3f6dedd 100644
@@ -325,11 +325,11 @@ static inline int is_root_handle(struct inode *inode)
 	gossip_debug(GOSSIP_DCACHE_DEBUG,
 		     "%s: root handle: %pU, this handle: %pU:\n",
 		     __func__,
-		     &ORANGEFS_SB(inode->i_sb)->root_khandle,
+		     &ORANGEFS_SB(inode_sb(inode))->root_khandle,
 		     get_khandle_from_ino(inode));
 
-	if (ORANGEFS_khandle_cmp(&(ORANGEFS_SB(inode->i_sb)->root_khandle),
-			     get_khandle_from_ino(inode)))
+	if (ORANGEFS_khandle_cmp(&(ORANGEFS_SB(inode_sb(inode))->root_khandle),
+				 get_khandle_from_ino(inode)))
 		return 0;
 	else
 		return 1;
@@ -513,7 +513,7 @@ int service_operation(struct orangefs_kernel_op_s *op,
 		      int flags);
 
 #define get_interruptible_flag(inode) \
-	((ORANGEFS_SB(inode->i_sb)->flags & ORANGEFS_OPT_INTR) ? \
+	((ORANGEFS_SB(inode_sb(inode))->flags & ORANGEFS_OPT_INTR) ? \
 		ORANGEFS_OP_INTERRUPTIBLE : 0)
 
 #define fill_default_sys_attrs(sys_attr, type, mode)			\
Signature · 1 line
2.15.1
#59 lore raw

PATCH 58/76 fs/overlayfs: Use inode_sb() helper instead of inode->i_sb

In reply to Mark Fasheh
---
 fs/overlayfs/export.c | 2 +-
 fs/overlayfs/inode.c  | 6 +++---
 fs/overlayfs/super.c  | 2 +-
 3 files changed, 5 insertions(+), 5 deletions(-)
fs/overlayfs/export.c +1 -1
index 87bd4148f4fb..41b23510f5b9 100644
@@ -316,7 +316,7 @@ static struct dentry *ovl_obtain_alias(struct super_block *sb,
 
 	dentry = d_find_any_alias(inode);
 	if (!dentry) {
-		dentry = d_alloc_anon(inode->i_sb);
+		dentry = d_alloc_anon(inode_sb(inode));
 		if (!dentry)
 			goto nomem;
 		oe = ovl_alloc_entry(lower ? 1 : 0);
fs/overlayfs/inode.c +3 -3
index 3b1bd469accd..ebf2a857d547 100644
@@ -199,7 +199,7 @@ int ovl_permission(struct inode *inode, int mask)
 	if (err)
 		return err;
 
-	old_cred = ovl_override_creds(inode->i_sb);
+	old_cred = ovl_override_creds(inode_sb(inode));
 	if (!upperinode &&
 	    !special_file(realinode->i_mode) && mask & MAY_WRITE) {
 		mask &= ~(MAY_WRITE | MAY_APPEND);
@@ -342,7 +342,7 @@ struct posix_acl *ovl_get_acl(struct inode *inode, int type)
 	if (!IS_ENABLED(CONFIG_FS_POSIX_ACL) || !IS_POSIXACL(realinode))
 		return NULL;
 
-	old_cred = ovl_override_creds(inode->i_sb);
+	old_cred = ovl_override_creds(inode_sb(inode));
 	acl = get_acl(realinode, type);
 	revert_creds(old_cred);
 
@@ -445,7 +445,7 @@ static inline void ovl_lockdep_annotate_inode_mutex_key(struct inode *inode)
 	static struct lock_class_key ovl_i_mutex_dir_key[OVL_MAX_NESTING];
 	static struct lock_class_key ovl_i_lock_key[OVL_MAX_NESTING];
 
-	int depth = inode->i_sb->s_stack_depth - 1;
+	int depth = inode_sb(inode)->s_stack_depth - 1;
 
 	if (WARN_ON_ONCE(depth < 0 || depth >= OVL_MAX_NESTING))
 		depth = 0;
fs/overlayfs/super.c +1 -1
index 7c24619ae7fc..bc04230f3ffb 100644
@@ -127,7 +127,7 @@ static struct dentry *ovl_d_real(struct dentry *dentry,
 		return real;
 bug:
 	WARN(1, "ovl_d_real(%pd4, %s:%lu): real dentry not found\n", dentry,
-	     inode ? inode->i_sb->s_id : "NULL", inode ? inode->i_ino : 0);
+	     inode ? inode_sb(inode)->s_id : "NULL", inode ? inode->i_ino : 0);
 	return dentry;
 }
 
Signature · 1 line
2.15.1
#60 lore raw

PATCH 59/76 fs/proc: Use inode_sb() helper instead of inode->i_sb

In reply to Mark Fasheh
---
 fs/proc/array.c       |  2 +-
 fs/proc/base.c        | 22 ++++++++++++----------
 fs/proc/fd.c          |  4 ++--
 fs/proc/generic.c     |  2 +-
 fs/proc/namespaces.c  |  2 +-
 fs/proc/nommu.c       |  2 +-
 fs/proc/proc_sysctl.c |  4 ++--
 fs/proc/self.c        |  2 +-
 fs/proc/task_mmu.c    |  2 +-
 fs/proc/task_nommu.c  |  2 +-
 fs/proc/thread_self.c |  2 +-
 11 files changed, 24 insertions(+), 22 deletions(-)
fs/proc/array.c +1 -1
index 598803576e4c..e7a668a89caf 100644
@@ -687,7 +687,7 @@ static int children_seq_show(struct seq_file *seq, void *v)
 	struct inode *inode = seq->private;
 	pid_t pid;
 
-	pid = pid_nr_ns(v, inode->i_sb->s_fs_info);
+	pid = pid_nr_ns(v, inode_sb(inode)->s_fs_info);
 	seq_printf(seq, "%d ", pid);
 
 	return 0;
fs/proc/base.c +12 -10
index 9298324325ed..a39fdd56f5d9 100644
@@ -698,7 +698,7 @@ static bool has_pid_permissions(struct pid_namespace *pid,
 
 static int proc_pid_permission(struct inode *inode, int mask)
 {
-	struct pid_namespace *pid = inode->i_sb->s_fs_info;
+	struct pid_namespace *pid = inode_sb(inode)->s_fs_info;
 	struct task_struct *task;
 	bool has_perms;
 
@@ -738,7 +738,7 @@ static int proc_single_show(struct seq_file *m, void *v)
 	struct task_struct *task;
 	int ret;
 
-	ns = inode->i_sb->s_fs_info;
+	ns = inode_sb(inode)->s_fs_info;
 	pid = proc_pid(inode);
 	task = get_pid_task(pid, PIDTYPE_PID);
 	if (!task)
@@ -1410,7 +1410,7 @@ static const struct file_operations proc_fail_nth_operations = {
 static int sched_show(struct seq_file *m, void *v)
 {
 	struct inode *inode = m->private;
-	struct pid_namespace *ns = inode->i_sb->s_fs_info;
+	struct pid_namespace *ns = inode_sb(inode)->s_fs_info;
 	struct task_struct *p;
 
 	p = get_proc_task(inode);
@@ -2065,7 +2065,7 @@ proc_map_files_instantiate(struct inode *dir, struct dentry *dentry,
 	struct proc_inode *ei;
 	struct inode *inode;
 
-	inode = proc_pid_make_inode(dir->i_sb, task, S_IFLNK |
+	inode = proc_pid_make_inode(inode_sb(dir), task, S_IFLNK |
 				    ((mode & FMODE_READ ) ? S_IRUSR : 0) |
 				    ((mode & FMODE_WRITE) ? S_IWUSR : 0));
 	if (!inode)
@@ -2327,7 +2327,7 @@ static int proc_timers_open(struct inode *inode, struct file *file)
 		return -ENOMEM;
 
 	tp->pid = proc_pid(inode);
-	tp->ns = inode->i_sb->s_fs_info;
+	tp->ns = inode_sb(inode)->s_fs_info;
 	return 0;
 }
 
@@ -2432,7 +2432,7 @@ static int proc_pident_instantiate(struct inode *dir,
 	struct inode *inode;
 	struct proc_inode *ei;
 
-	inode = proc_pid_make_inode(dir->i_sb, task, p->mode);
+	inode = proc_pid_make_inode(inode_sb(dir), task, p->mode);
 	if (!inode)
 		goto out;
 
@@ -3137,7 +3137,8 @@ static int proc_pid_instantiate(struct inode *dir,
 {
 	struct inode *inode;
 
-	inode = proc_pid_make_inode(dir->i_sb, task, S_IFDIR | S_IRUGO | S_IXUGO);
+	inode = proc_pid_make_inode(inode_sb(dir), task,
+				    S_IFDIR | S_IRUGO | S_IXUGO);
 	if (!inode)
 		goto out;
 
@@ -3232,7 +3233,7 @@ static struct tgid_iter next_tgid(struct pid_namespace *ns, struct tgid_iter ite
 int proc_pid_readdir(struct file *file, struct dir_context *ctx)
 {
 	struct tgid_iter iter;
-	struct pid_namespace *ns = file_inode(file)->i_sb->s_fs_info;
+	struct pid_namespace *ns = inode_sb(file_inode(file))->s_fs_info;
 	loff_t pos = ctx->pos;
 
 	if (pos >= PID_MAX_LIMIT + TGID_OFFSET)
@@ -3435,7 +3436,8 @@ static int proc_task_instantiate(struct inode *dir,
 	struct dentry *dentry, struct task_struct *task, const void *ptr)
 {
 	struct inode *inode;
-	inode = proc_pid_make_inode(dir->i_sb, task, S_IFDIR | S_IRUGO | S_IXUGO);
+	inode = proc_pid_make_inode(inode_sb(dir), task,
+				    S_IFDIR | S_IRUGO | S_IXUGO);
 
 	if (!inode)
 		goto out;
@@ -3584,7 +3586,7 @@ static int proc_task_readdir(struct file *file, struct dir_context *ctx)
 	/* f_version caches the tgid value that the last readdir call couldn't
 	 * return. lseek aka telldir automagically resets f_version to 0.
 	 */
-	ns = inode->i_sb->s_fs_info;
+	ns = inode_sb(inode)->s_fs_info;
 	tid = (int)file->f_version;
 	file->f_version = 0;
 	for (task = first_tid(proc_pid(inode), tid, ctx->pos - 2, ns);
fs/proc/fd.c +2 -2
index 6b80cd1e419a..818fe341c3e7 100644
@@ -174,7 +174,7 @@ proc_fd_instantiate(struct inode *dir, struct dentry *dentry,
 	struct proc_inode *ei;
 	struct inode *inode;
 
-	inode = proc_pid_make_inode(dir->i_sb, task, S_IFLNK);
+	inode = proc_pid_make_inode(inode_sb(dir), task, S_IFLNK);
 	if (!inode)
 		goto out;
 
@@ -312,7 +312,7 @@ proc_fdinfo_instantiate(struct inode *dir, struct dentry *dentry,
 	struct proc_inode *ei;
 	struct inode *inode;
 
-	inode = proc_pid_make_inode(dir->i_sb, task, S_IFREG | S_IRUSR);
+	inode = proc_pid_make_inode(inode_sb(dir), task, S_IFREG | S_IRUSR);
 	if (!inode)
 		goto out;
 
fs/proc/generic.c +1 -1
index 5d709fa8f3a2..9da0c07329ea 100644
@@ -221,7 +221,7 @@ struct dentry *proc_lookup_de(struct inode *dir, struct dentry *dentry,
 	if (de) {
 		pde_get(de);
 		read_unlock(&proc_subdir_lock);
-		inode = proc_get_inode(dir->i_sb, de);
+		inode = proc_get_inode(inode_sb(dir), de);
 		if (!inode)
 			return ERR_PTR(-ENOMEM);
 		d_set_d_op(dentry, &simple_dentry_operations);
fs/proc/namespaces.c +1 -1
index 59b17e509f46..3d624af32bb2 100644
@@ -94,7 +94,7 @@ static int proc_ns_instantiate(struct inode *dir,
 	struct inode *inode;
 	struct proc_inode *ei;
 
-	inode = proc_pid_make_inode(dir->i_sb, task, S_IFLNK | S_IRWXUGO);
+	inode = proc_pid_make_inode(inode_sb(dir), task, S_IFLNK | S_IRWXUGO);
 	if (!inode)
 		goto out;
 
fs/proc/nommu.c +1 -1
index 75634379f82e..5c979fc49662 100644
@@ -46,7 +46,7 @@ static int nommu_region_show(struct seq_file *m, struct vm_region *region)
 
 	if (file) {
 		struct inode *inode = file_inode(region->vm_file);
-		dev = inode->i_sb->s_dev;
+		dev = inode_sb(inode)->s_dev;
 		ino = inode->i_ino;
 	}
 
fs/proc/proc_sysctl.c +2 -2
index c41ab261397d..a989afed4b1e 100644
@@ -280,7 +280,7 @@ static void proc_sys_prune_dcache(struct ctl_table_header *head)
 		spin_unlock(&sysctl_lock);
 
 		inode = &ei->vfs_inode;
-		sb = inode->i_sb;
+		sb = inode_sb(inode);
 		if (!atomic_inc_not_zero(&sb->s_active))
 			continue;
 		inode = igrab(inode);
@@ -550,7 +550,7 @@ static struct dentry *proc_sys_lookup(struct inode *dir, struct dentry *dentry,
 	}
 
 	err = ERR_PTR(-ENOMEM);
-	inode = proc_sys_make_inode(dir->i_sb, h ? h : head, p);
+	inode = proc_sys_make_inode(inode_sb(dir), h ? h : head, p);
 	if (!inode)
 		goto out;
 
fs/proc/self.c +1 -1
index 4d7d061696b3..43875daa8e16 100644
@@ -12,7 +12,7 @@ static const char *proc_self_get_link(struct dentry *dentry,
 				      struct inode *inode,
 				      struct delayed_call *done)
 {
-	struct pid_namespace *ns = inode->i_sb->s_fs_info;
+	struct pid_namespace *ns = inode_sb(inode)->s_fs_info;
 	pid_t tgid = task_tgid_nr_ns(current, ns);
 	char *name;
 
fs/proc/task_mmu.c +1 -1
index ec6d2983a5cb..27bf744e8da9 100644
@@ -312,7 +312,7 @@ show_map_vma(struct seq_file *m, struct vm_area_struct *vma, int is_pid)
 
 	if (file) {
 		struct inode *inode = file_inode(vma->vm_file);
-		dev = inode->i_sb->s_dev;
+		dev = inode_sb(inode)->s_dev;
 		ino = inode->i_ino;
 		pgoff = ((loff_t)vma->vm_pgoff) << PAGE_SHIFT;
 	}
fs/proc/task_nommu.c +1 -1
index 5b62f57bd9bc..d3acd4433d9d 100644
@@ -157,7 +157,7 @@ static int nommu_vma_show(struct seq_file *m, struct vm_area_struct *vma,
 
 	if (file) {
 		struct inode *inode = file_inode(vma->vm_file);
-		dev = inode->i_sb->s_dev;
+		dev = inode_sb(inode)->s_dev;
 		ino = inode->i_ino;
 		pgoff = (loff_t)vma->vm_pgoff << PAGE_SHIFT;
 	}
fs/proc/thread_self.c +1 -1
index 9d2efaca499f..fdcf057eab38 100644
@@ -12,7 +12,7 @@ static const char *proc_thread_self_get_link(struct dentry *dentry,
 					     struct inode *inode,
 					     struct delayed_call *done)
 {
-	struct pid_namespace *ns = inode->i_sb->s_fs_info;
+	struct pid_namespace *ns = inode_sb(inode)->s_fs_info;
 	pid_t tgid = task_tgid_nr_ns(current, ns);
 	pid_t pid = task_pid_nr_ns(current, ns);
 	char *name;
Signature · 1 line
2.15.1
#61 lore raw

PATCH 60/76 fs/qnx4: Use inode_sb() helper instead of inode->i_sb

In reply to Mark Fasheh
---
 fs/qnx4/dir.c   | 2 +-
 fs/qnx4/inode.c | 4 ++--
 fs/qnx4/namei.c | 4 ++--
 3 files changed, 5 insertions(+), 5 deletions(-)
fs/qnx4/dir.c +1 -1
index a6ee23aadd28..c0e764ce79dd 100644
@@ -31,7 +31,7 @@ static int qnx4_readdir(struct file *file, struct dir_context *ctx)
 
 	while (ctx->pos < inode->i_size) {
 		blknum = qnx4_block_map(inode, ctx->pos >> QNX4_BLOCK_SIZE_BITS);
-		bh = sb_bread(inode->i_sb, blknum);
+		bh = sb_bread(inode_sb(inode), blknum);
 		if (bh == NULL) {
 			printk(KERN_ERR "qnx4_readdir: bread failed (%ld)\n", blknum);
 			return 0;
fs/qnx4/inode.c +2 -2
index 3d46fe302fcb..2b5e5b18e084 100644
@@ -60,7 +60,7 @@ static int qnx4_get_block( struct inode *inode, sector_t iblock, struct buffer_h
 	phys = qnx4_block_map( inode, iblock );
 	if ( phys ) {
 		// logical block is before EOF
-		map_bh(bh, inode->i_sb, phys);
+		map_bh(bh, inode_sb(inode), phys);
 	}
 	return 0;
 }
@@ -94,7 +94,7 @@ unsigned long qnx4_block_map( struct inode *inode, long iblock )
 		while ( --nxtnt > 0 ) {
 			if ( ix == 0 ) {
 				// read next xtnt block.
-				bh = sb_bread(inode->i_sb, i_xblk - 1);
+				bh = sb_bread(inode_sb(inode), i_xblk - 1);
 				if ( !bh ) {
 					QNX4DEBUG((KERN_ERR "qnx4: I/O error reading xtnt block [%ld])\n", i_xblk - 1));
 					return -EIO;
fs/qnx4/namei.c +2 -2
index eca27878079d..3a84a8f6c6a7 100644
@@ -67,7 +67,7 @@ static struct buffer_head *qnx4_find_entry(int len, struct inode *dir,
 		if (!bh) {
 			block = qnx4_block_map(dir, blkofs);
 			if (block)
-				bh = sb_bread(dir->i_sb, block);
+				bh = sb_bread(inode_sb(dir), block);
 			if (!bh) {
 				blkofs++;
 				continue;
@@ -113,7 +113,7 @@ struct dentry * qnx4_lookup(struct inode *dir, struct dentry *dentry, unsigned i
 	}
 	brelse(bh);
 
-	foundinode = qnx4_iget(dir->i_sb, ino);
+	foundinode = qnx4_iget(inode_sb(dir), ino);
 	if (IS_ERR(foundinode)) {
 		QNX4DEBUG((KERN_ERR "qnx4: lookup->iget -> error %ld\n",
 			   PTR_ERR(foundinode)));
Signature · 1 line
2.15.1
#62 lore raw

PATCH 61/76 fs/qnx6: Use inode_sb() helper instead of inode->i_sb

In reply to Mark Fasheh
---
 fs/qnx6/dir.c   | 8 ++++----
 fs/qnx6/inode.c | 4 ++--
 fs/qnx6/namei.c | 2 +-
 3 files changed, 7 insertions(+), 7 deletions(-)
fs/qnx6/dir.c +4 -4
index c1cfb8a19e9d..655d0eb9d82a 100644
@@ -65,7 +65,7 @@ static int qnx6_dir_longfilename(struct inode *inode,
 			unsigned de_inode)
 {
 	struct qnx6_long_filename *lf;
-	struct super_block *s = inode->i_sb;
+	struct super_block *s = inode_sb(inode);
 	struct qnx6_sb_info *sbi = QNX6_SB(s);
 	struct page *page;
 	int lf_size;
@@ -112,7 +112,7 @@ static int qnx6_dir_longfilename(struct inode *inode,
 static int qnx6_readdir(struct file *file, struct dir_context *ctx)
 {
 	struct inode *inode = file_inode(file);
-	struct super_block *s = inode->i_sb;
+	struct super_block *s = inode_sb(inode);
 	struct qnx6_sb_info *sbi = QNX6_SB(s);
 	loff_t pos = ctx->pos & ~(QNX6_DIR_ENTRY_SIZE - 1);
 	unsigned long npages = dir_pages(inode);
@@ -175,7 +175,7 @@ static int qnx6_readdir(struct file *file, struct dir_context *ctx)
 static unsigned qnx6_long_match(int len, const char *name,
 			struct qnx6_long_dir_entry *de, struct inode *dir)
 {
-	struct super_block *s = dir->i_sb;
+	struct super_block *s = inode_sb(dir);
 	struct qnx6_sb_info *sbi = QNX6_SB(s);
 	struct page *page;
 	int thislen;
@@ -213,7 +213,7 @@ static unsigned qnx6_match(struct super_block *s, int len, const char *name,
 unsigned qnx6_find_entry(int len, struct inode *dir, const char *name,
 			 struct page **res_page)
 {
-	struct super_block *s = dir->i_sb;
+	struct super_block *s = inode_sb(dir);
 	struct qnx6_inode_info *ei = QNX6_I(dir);
 	struct page *page = NULL;
 	unsigned long start, n;
fs/qnx6/inode.c +2 -2
index 4aeb26bcb4d0..4be77b89f11d 100644
@@ -79,7 +79,7 @@ static int qnx6_get_block(struct inode *inode, sector_t iblock,
 	phys = qnx6_block_map(inode, iblock);
 	if (phys) {
 		/* logical block is before EOF */
-		map_bh(bh, inode->i_sb, phys);
+		map_bh(bh, inode_sb(inode), phys);
 	}
 	return 0;
 }
@@ -110,7 +110,7 @@ static int qnx6_readpages(struct file *file, struct address_space *mapping,
  */
 static unsigned qnx6_block_map(struct inode *inode, unsigned no)
 {
-	struct super_block *s = inode->i_sb;
+	struct super_block *s = inode_sb(inode);
 	struct qnx6_sb_info *sbi = QNX6_SB(s);
 	struct qnx6_inode_info *ei = QNX6_I(inode);
 	unsigned block = 0;
fs/qnx6/namei.c +1 -1
index 72c2770830be..0b1a626c20d8 100644
@@ -27,7 +27,7 @@ struct dentry *qnx6_lookup(struct inode *dir, struct dentry *dentry,
 
 	ino = qnx6_find_entry(len, dir, name, &page);
 	if (ino) {
-		foundinode = qnx6_iget(dir->i_sb, ino);
+		foundinode = qnx6_iget(inode_sb(dir), ino);
 		qnx6_put_page(page);
 		if (IS_ERR(foundinode)) {
 			pr_debug("lookup->iget ->  error %ld\n",
Signature · 1 line
2.15.1
#63 lore raw

PATCH 62/76 fs/quota: Use inode_sb() helper instead of inode->i_sb

In reply to Mark Fasheh
---
 fs/quota/dquot.c | 30 +++++++++++++++---------------
 1 file changed, 15 insertions(+), 15 deletions(-)
fs/quota/dquot.c +15 -15
index 020c597ef9b6..ba6d549323cb 100644
@@ -920,7 +920,7 @@ EXPORT_SYMBOL(dqget);
 
 static inline struct dquot **i_dquot(struct inode *inode)
 {
-	return inode->i_sb->s_op->get_dquots(inode);
+	return inode_sb(inode)->s_op->get_dquots(inode);
 }
 
 static int dqinit_needed(struct inode *inode, int type)
@@ -1406,7 +1406,7 @@ static int info_bdq_free(struct dquot *dquot, qsize_t space)
 
 static int dquot_active(const struct inode *inode)
 {
-	struct super_block *sb = inode->i_sb;
+	struct super_block *sb = inode_sb(inode);
 
 	if (IS_NOQUOTA(inode))
 		return 0;
@@ -1423,7 +1423,7 @@ static int __dquot_initialize(struct inode *inode, int type)
 {
 	int cnt, init_needed = 0;
 	struct dquot **dquots, *got[MAXQUOTAS] = {};
-	struct super_block *sb = inode->i_sb;
+	struct super_block *sb = inode_sb(inode);
 	qsize_t rsv;
 	int ret = 0;
 
@@ -1462,7 +1462,7 @@ static int __dquot_initialize(struct inode *inode, int type)
 			qid = make_kqid_gid(inode->i_gid);
 			break;
 		case PRJQUOTA:
-			rc = inode->i_sb->dq_op->get_projid(inode, &projid);
+			rc = inode_sb(inode)->dq_op->get_projid(inode, &projid);
 			if (rc)
 				continue;
 			qid = make_kqid_projid(projid);
@@ -1540,7 +1540,7 @@ bool dquot_initialize_needed(struct inode *inode)
 
 	dquots = i_dquot(inode);
 	for (i = 0; i < MAXQUOTAS; i++)
-		if (!dquots[i] && sb_has_quota_active(inode->i_sb, i))
+		if (!dquots[i] && sb_has_quota_active(inode_sb(inode), i))
 			return true;
 	return false;
 }
@@ -1603,13 +1603,13 @@ static qsize_t *inode_reserved_space(struct inode * inode)
 {
 	/* Filesystem must explicitly define it's own method in order to use
 	 * quota reservation interface */
-	BUG_ON(!inode->i_sb->dq_op->get_reserved_space);
-	return inode->i_sb->dq_op->get_reserved_space(inode);
+	BUG_ON(!inode_sb(inode)->dq_op->get_reserved_space);
+	return inode_sb(inode)->dq_op->get_reserved_space(inode);
 }
 
 static qsize_t __inode_get_rsv_space(struct inode *inode)
 {
-	if (!inode->i_sb->dq_op->get_reserved_space)
+	if (!inode_sb(inode)->dq_op->get_reserved_space)
 		return 0;
 	return *inode_reserved_space(inode);
 }
@@ -1618,7 +1618,7 @@ static qsize_t inode_get_rsv_space(struct inode *inode)
 {
 	qsize_t ret;
 
-	if (!inode->i_sb->dq_op->get_reserved_space)
+	if (!inode_sb(inode)->dq_op->get_reserved_space)
 		return 0;
 	spin_lock(&inode->i_lock);
 	ret = __inode_get_rsv_space(inode);
@@ -1955,8 +1955,8 @@ int __dquot_transfer(struct inode *inode, struct dquot **transfer_to)
 	if (IS_NOQUOTA(inode))
 		return 0;
 
-	if (inode->i_sb->dq_op->get_inode_usage) {
-		ret = inode->i_sb->dq_op->get_inode_usage(inode, &inode_usage);
+	if (inode_sb(inode)->dq_op->get_inode_usage) {
+		ret = inode_sb(inode)->dq_op->get_inode_usage(inode, &inode_usage);
 		if (ret)
 			return ret;
 	}
@@ -1988,7 +1988,7 @@ int __dquot_transfer(struct inode *inode, struct dquot **transfer_to)
 		if (!transfer_to[cnt])
 			continue;
 		/* Avoid races with quotaoff() */
-		if (!sb_has_quota_active(inode->i_sb, cnt))
+		if (!sb_has_quota_active(inode_sb(inode), cnt))
 			continue;
 		is_valid[cnt] = 1;
 		transfer_from[cnt] = i_dquot(inode)[cnt];
@@ -2070,7 +2070,7 @@ int dquot_transfer(struct inode *inode, struct iattr *iattr)
 {
 	struct dquot *transfer_to[MAXQUOTAS] = {};
 	struct dquot *dquot;
-	struct super_block *sb = inode->i_sb;
+	struct super_block *sb = inode_sb(inode);
 	int ret;
 
 	if (!dquot_active(inode))
@@ -2302,7 +2302,7 @@ static int vfs_load_quota_inode(struct inode *inode, int type, int format_id,
 	unsigned int flags)
 {
 	struct quota_format_type *fmt = find_quota_format(format_id);
-	struct super_block *sb = inode->i_sb;
+	struct super_block *sb = inode_sb(inode);
 	struct quota_info *dqopt = sb_dqopt(sb);
 	int error;
 
@@ -2464,7 +2464,7 @@ EXPORT_SYMBOL(dquot_quota_on);
 int dquot_enable(struct inode *inode, int type, int format_id,
 		 unsigned int flags)
 {
-	struct super_block *sb = inode->i_sb;
+	struct super_block *sb = inode_sb(inode);
 
 	/* Just unsuspend quotas? */
 	BUG_ON(flags & DQUOT_SUSPENDED);
Signature · 1 line
2.15.1
#64 lore raw

PATCH 63/76 fs/ramfs: Use inode_sb() helper instead of inode->i_sb

In reply to Mark Fasheh
---
 fs/ramfs/inode.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
fs/ramfs/inode.c +2 -2
index 11201b2d06b9..57b78ae51ed1 100644
@@ -101,7 +101,7 @@ struct inode *ramfs_get_inode(struct super_block *sb,
 static int
 ramfs_mknod(struct inode *dir, struct dentry *dentry, umode_t mode, dev_t dev)
 {
-	struct inode * inode = ramfs_get_inode(dir->i_sb, dir, mode, dev);
+	struct inode * inode = ramfs_get_inode(inode_sb(dir), dir, mode, dev);
 	int error = -ENOSPC;
 
 	if (inode) {
@@ -131,7 +131,7 @@ static int ramfs_symlink(struct inode * dir, struct dentry *dentry, const char *
 	struct inode *inode;
 	int error = -ENOSPC;
 
-	inode = ramfs_get_inode(dir->i_sb, dir, S_IFLNK|S_IRWXUGO, 0);
+	inode = ramfs_get_inode(inode_sb(dir), dir, S_IFLNK|S_IRWXUGO, 0);
 	if (inode) {
 		int l = strlen(symname)+1;
 		error = page_symlink(inode, symname, l);
Signature · 1 line
2.15.1
#65 lore raw

PATCH 64/76 fs/read: Use inode_sb() helper instead of inode->i_sb

In reply to Mark Fasheh
---
 fs/read_write.c | 11 ++++++-----
 1 file changed, 6 insertions(+), 5 deletions(-)
fs/read_write.c +6 -5
index f8547b82dfb3..cf9900707558 100644
@@ -146,7 +146,7 @@ loff_t generic_file_llseek(struct file *file, loff_t offset, int whence)
 	struct inode *inode = file->f_mapping->host;
 
 	return generic_file_llseek_size(file, offset, whence,
-					inode->i_sb->s_maxbytes,
+					inode_sb(inode)->s_maxbytes,
 					i_size_read(inode));
 }
 EXPORT_SYMBOL(generic_file_llseek);
@@ -1389,7 +1389,8 @@ static ssize_t do_sendfile(int out_fd, int in_fd, loff_t *ppos,
 		goto fput_out;
 
 	if (!max)
-		max = min(in_inode->i_sb->s_maxbytes, out_inode->i_sb->s_maxbytes);
+		max = min(inode_sb(in_inode)->s_maxbytes,
+			  inode_sb(out_inode)->s_maxbytes);
 
 	if (unlikely(pos + count > max)) {
 		retval = -EOVERFLOW;
@@ -1549,7 +1550,7 @@ ssize_t vfs_copy_file_range(struct file *file_in, loff_t pos_in,
 		return -EBADF;
 
 	/* this could be relaxed once a method supports cross-fs copies */
-	if (inode_in->i_sb != inode_out->i_sb)
+	if (inode_sb(inode_in) != inode_sb(inode_out))
 		return -EXDEV;
 
 	if (len == 0)
@@ -1694,7 +1695,7 @@ int vfs_clone_file_prep_inodes(struct inode *inode_in, loff_t pos_in,
 			       struct inode *inode_out, loff_t pos_out,
 			       u64 *len, bool is_dedupe)
 {
-	loff_t bs = inode_out->i_sb->s_blocksize;
+	loff_t bs = inode_sb(inode_out)->s_blocksize;
 	loff_t blen;
 	loff_t isize;
 	bool same_inode = (inode_in == inode_out);
@@ -1808,7 +1809,7 @@ int vfs_clone_file_range(struct file *file_in, loff_t pos_in,
 	 * the same mount. Practically, they only need to be on the same file
 	 * system.
 	 */
-	if (inode_in->i_sb != inode_out->i_sb)
+	if (inode_sb(inode_in) != inode_sb(inode_out))
 		return -EXDEV;
 
 	if (!(file_in->f_mode & FMODE_READ) ||
Signature · 1 line
2.15.1
#66 lore raw

PATCH 65/76 fs/reiserfs: Use inode_sb() helper instead of inode->i_sb

In reply to Mark Fasheh
---
 fs/reiserfs/bitmap.c          |  12 +-
 fs/reiserfs/dir.c             |  27 ++--
 fs/reiserfs/file.c            |  22 +--
 fs/reiserfs/inode.c           | 321 +++++++++++++++++++++---------------------
 fs/reiserfs/ioctl.c           |  18 +--
 fs/reiserfs/journal.c         |  10 +-
 fs/reiserfs/namei.c           | 190 +++++++++++++------------
 fs/reiserfs/reiserfs.h        |   8 +-
 fs/reiserfs/stree.c           |  69 ++++-----
 fs/reiserfs/super.c           |  31 ++--
 fs/reiserfs/tail_conversion.c |   6 +-
 fs/reiserfs/xattr.c           |  36 ++---
 fs/reiserfs/xattr.h           |  13 +-
 fs/reiserfs/xattr_acl.c       |  14 +-
 fs/reiserfs/xattr_security.c  |   2 +-
 fs/reiserfs/xattr_user.c      |   4 +-
 16 files changed, 397 insertions(+), 386 deletions(-)
fs/reiserfs/bitmap.c +6 -6
index edc8ef78b63f..9d73c0df3bf3 100644
@@ -325,13 +325,13 @@ static inline int block_group_used(struct super_block *s, u32 id)
 __le32 reiserfs_choose_packing(struct inode * dir)
 {
 	__le32 packing;
-	if (TEST_OPTION(packing_groups, dir->i_sb)) {
+	if (TEST_OPTION(packing_groups, inode_sb(dir))) {
 		u32 parent_dir = le32_to_cpu(INODE_PKEY(dir)->k_dir_id);
 		/*
 		 * some versions of reiserfsck expect packing locality 1 to be
 		 * special
 		 */
-		if (parent_dir == 1 || block_group_used(dir->i_sb, parent_dir))
+		if (parent_dir == 1 || block_group_used(inode_sb(dir), parent_dir))
 			packing = INODE_PKEY(dir)->k_objectid;
 		else
 			packing = INODE_PKEY(dir)->k_dir_id;
@@ -837,11 +837,11 @@ static void oid_groups(reiserfs_blocknr_hint_t * hint)
 		 * the start of the disk
 		 */
 		if (dirid <= 2)
-			hash = (hint->inode->i_sb->s_blocksize << 3);
+			hash = (inode_sb(hint->inode)->s_blocksize << 3);
 		else {
 			oid = le32_to_cpu(INODE_PKEY(hint->inode)->k_objectid);
-			bm = bmap_hash_id(hint->inode->i_sb, oid);
-			hash = bm * (hint->inode->i_sb->s_blocksize << 3);
+			bm = bmap_hash_id(inode_sb(hint->inode), oid);
+			hash = bm * (inode_sb(hint->inode)->s_blocksize << 3);
 		}
 		hint->search_start = hash;
 	}
@@ -1139,7 +1139,7 @@ static int determine_prealloc_size(reiserfs_blocknr_hint_t * hint)
 		if (S_ISREG(hint->inode->i_mode) && !IS_PRIVATE(hint->inode)
 		    && hint->inode->i_size >=
 		    REISERFS_SB(hint->th->t_super)->s_alloc_options.
-		    preallocmin * hint->inode->i_sb->s_blocksize)
+		    preallocmin * inode_sb(hint->inode)->s_blocksize)
 			hint->prealloc_size =
 			    REISERFS_SB(hint->th->t_super)->s_alloc_options.
 			    preallocsize - 1;
fs/reiserfs/dir.c +15 -12
index 5b50689d8539..d9aff9f826cc 100644
@@ -39,9 +39,9 @@ static int reiserfs_dir_fsync(struct file *filp, loff_t start, loff_t end,
 		return err;
 
 	inode_lock(inode);
-	reiserfs_write_lock(inode->i_sb);
+	reiserfs_write_lock(inode_sb(inode));
 	err = reiserfs_commit_for_inode(inode);
-	reiserfs_write_unlock(inode->i_sb);
+	reiserfs_write_unlock(inode_sb(inode));
 	inode_unlock(inode);
 	if (err < 0)
 		return err;
@@ -52,7 +52,7 @@ static int reiserfs_dir_fsync(struct file *filp, loff_t start, loff_t end,
 
 static inline bool is_privroot_deh(struct inode *dir, struct reiserfs_de_head *deh)
 {
-	struct dentry *privroot = REISERFS_SB(dir->i_sb)->priv_root;
+	struct dentry *privroot = REISERFS_SB(inode_sb(dir))->priv_root;
 	return (d_really_is_positive(privroot) &&
 	        deh->deh_objectid == INODE_PKEY(d_inode(privroot))->k_objectid);
 }
@@ -76,9 +76,9 @@ int reiserfs_readdir_inode(struct inode *inode, struct dir_context *ctx)
 	int ret = 0;
 	int depth;
 
-	reiserfs_write_lock(inode->i_sb);
+	reiserfs_write_lock(inode_sb(inode));
 
-	reiserfs_check_lock_depth(inode->i_sb, "readdir");
+	reiserfs_check_lock_depth(inode_sb(inode), "readdir");
 
 	/*
 	 * form key for search the next directory entry using
@@ -95,7 +95,8 @@ int reiserfs_readdir_inode(struct inode *inode, struct dir_context *ctx)
 		 * specified key
 		 */
 		search_res =
-		    search_by_entry_key(inode->i_sb, &pos_key, &path_to_entry,
+		    search_by_entry_key(inode_sb(inode), &pos_key,
+					&path_to_entry,
 					&de);
 		if (search_res == IO_ERROR) {
 			/*
@@ -165,7 +166,7 @@ int reiserfs_readdir_inode(struct inode *inode, struct dir_context *ctx)
 
 				/* too big to send back to VFS */
 				if (d_reclen >
-				    REISERFS_MAX_NAME(inode->i_sb->
+				    REISERFS_MAX_NAME(inode_sb(inode)->
 						      s_blocksize)) {
 					continue;
 				}
@@ -205,17 +206,19 @@ int reiserfs_readdir_inode(struct inode *inode, struct dir_context *ctx)
 				 * Since filldir might sleep, we can release
 				 * the write lock here for other waiters
 				 */
-				depth = reiserfs_write_unlock_nested(inode->i_sb);
+				depth = reiserfs_write_unlock_nested(inode_sb(inode));
 				if (!dir_emit
 				    (ctx, local_buf, d_reclen, d_ino,
 				     DT_UNKNOWN)) {
-					reiserfs_write_lock_nested(inode->i_sb, depth);
+					reiserfs_write_lock_nested(inode_sb(inode),
+								   depth);
 					if (local_buf != small_buf) {
 						kfree(local_buf);
 					}
 					goto end;
 				}
-				reiserfs_write_lock_nested(inode->i_sb, depth);
+				reiserfs_write_lock_nested(inode_sb(inode),
+							   depth);
 				if (local_buf != small_buf) {
 					kfree(local_buf);
 				}
@@ -239,7 +242,7 @@ int reiserfs_readdir_inode(struct inode *inode, struct dir_context *ctx)
 		 * item we went through is last item of node. Using right
 		 * delimiting key check is it directory end
 		 */
-		rkey = get_rkey(&path_to_entry, inode->i_sb);
+		rkey = get_rkey(&path_to_entry, inode_sb(inode));
 		if (!comp_le_keys(rkey, &MIN_KEY)) {
 			/*
 			 * set pos_key to key, that is the smallest and greater
@@ -265,7 +268,7 @@ int reiserfs_readdir_inode(struct inode *inode, struct dir_context *ctx)
 	pathrelse(&path_to_entry);
 	reiserfs_check_path(&path_to_entry);
 out:
-	reiserfs_write_unlock(inode->i_sb);
+	reiserfs_write_unlock(inode_sb(inode));
 	return ret;
 }
 
fs/reiserfs/file.c +11 -11
index 843aadcc123c..8b41044bbd12 100644
@@ -56,14 +56,14 @@ static int reiserfs_file_release(struct inode *inode, struct file *filp)
 		return 0;
 	}
 
-	reiserfs_write_lock(inode->i_sb);
+	reiserfs_write_lock(inode_sb(inode));
 	/*
 	 * freeing preallocation only involves relogging blocks that
 	 * are already in the current transaction.  preallocation gets
 	 * freed at the end of each transaction, so it is impossible for
 	 * us to log any additional blocks (including quota blocks)
 	 */
-	err = journal_begin(&th, inode->i_sb, 1);
+	err = journal_begin(&th, inode_sb(inode), 1);
 	if (err) {
 		/*
 		 * uh oh, we can't allow the inode to go away while there
@@ -71,7 +71,7 @@ static int reiserfs_file_release(struct inode *inode, struct file *filp)
 		 * aborted transaction
 		 */
 		jbegin_failure = err;
-		err = journal_join_abort(&th, inode->i_sb);
+		err = journal_join_abort(&th, inode_sb(inode));
 
 		if (err) {
 			/*
@@ -84,7 +84,7 @@ static int reiserfs_file_release(struct inode *inode, struct file *filp)
 			 * and let the admin know what is going on.
 			 */
 			igrab(inode);
-			reiserfs_warning(inode->i_sb, "clm-9001",
+			reiserfs_warning(inode_sb(inode), "clm-9001",
 					 "pinning inode %lu because the "
 					 "preallocation can't be freed",
 					 inode->i_ino);
@@ -115,7 +115,7 @@ static int reiserfs_file_release(struct inode *inode, struct file *filp)
 		err = reiserfs_truncate_file(inode, 0);
 	}
 out:
-	reiserfs_write_unlock(inode->i_sb);
+	reiserfs_write_unlock(inode_sb(inode));
 	mutex_unlock(&REISERFS_I(inode)->tailpack);
 	return err;
 }
@@ -161,11 +161,11 @@ static int reiserfs_sync_file(struct file *filp, loff_t start, loff_t end,
 	inode_lock(inode);
 	BUG_ON(!S_ISREG(inode->i_mode));
 	err = sync_mapping_buffers(inode->i_mapping);
-	reiserfs_write_lock(inode->i_sb);
+	reiserfs_write_lock(inode_sb(inode));
 	barrier_done = reiserfs_commit_for_inode(inode);
-	reiserfs_write_unlock(inode->i_sb);
-	if (barrier_done != 1 && reiserfs_barrier_flush(inode->i_sb))
-		blkdev_issue_flush(inode->i_sb->s_bdev, GFP_KERNEL, NULL);
+	reiserfs_write_unlock(inode_sb(inode));
+	if (barrier_done != 1 && reiserfs_barrier_flush(inode_sb(inode)))
+		blkdev_issue_flush(inode_sb(inode)->s_bdev, GFP_KERNEL, NULL);
 	inode_unlock(inode);
 	if (barrier_done < 0)
 		return barrier_done;
@@ -183,7 +183,7 @@ int reiserfs_commit_page(struct inode *inode, struct page *page,
 	unsigned long i_size_index = inode->i_size >> PAGE_SHIFT;
 	int new;
 	int logit = reiserfs_file_data_log(inode);
-	struct super_block *s = inode->i_sb;
+	struct super_block *s = inode_sb(inode);
 	int bh_per_page = PAGE_SIZE / s->s_blocksize;
 	struct reiserfs_transaction_handle th;
 	int ret = 0;
@@ -219,7 +219,7 @@ int reiserfs_commit_page(struct inode *inode, struct page *page,
 				 * do data=ordered on any page past the end
 				 * of file and any buffer marked BH_New.
 				 */
-				if (reiserfs_data_ordered(inode->i_sb) &&
+				if (reiserfs_data_ordered(inode_sb(inode)) &&
 				    (new || page->index >= i_size_index)) {
 					reiserfs_add_ordered_list(inode, bh);
 				}
fs/reiserfs/inode.c +164 -157

975 lines not on this page · raw message

fs/reiserfs/ioctl.c +9 -9
index acbbaf7a0bb2..122dfdfe69c9 100644
@@ -26,7 +26,7 @@ long reiserfs_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
 	unsigned int flags;
 	int err = 0;
 
-	reiserfs_write_lock(inode->i_sb);
+	reiserfs_write_lock(inode_sb(inode));
 
 	switch (cmd) {
 	case REISERFS_IOC_UNPACK:
@@ -41,7 +41,7 @@ long reiserfs_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
 		 * Card ([email protected])
 		 */
 	case REISERFS_IOC_GETFLAGS:
-		if (!reiserfs_attrs(inode->i_sb)) {
+		if (!reiserfs_attrs(inode_sb(inode))) {
 			err = -ENOTTY;
 			break;
 		}
@@ -50,7 +50,7 @@ long reiserfs_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
 		err = put_user(flags, (int __user *)arg);
 		break;
 	case REISERFS_IOC_SETFLAGS:{
-			if (!reiserfs_attrs(inode->i_sb)) {
+			if (!reiserfs_attrs(inode_sb(inode))) {
 				err = -ENOTTY;
 				break;
 			}
@@ -123,7 +123,7 @@ long reiserfs_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
 		err = -ENOTTY;
 	}
 
-	reiserfs_write_unlock(inode->i_sb);
+	reiserfs_write_unlock(inode_sb(inode));
 
 	return err;
 }
@@ -174,7 +174,7 @@ int reiserfs_unpack(struct inode *inode, struct file *filp)
 	struct page *page;
 	struct address_space *mapping;
 	unsigned long write_from;
-	unsigned long blocksize = inode->i_sb->s_blocksize;
+	unsigned long blocksize = inode_sb(inode)->s_blocksize;
 
 	if (inode->i_size == 0) {
 		REISERFS_I(inode)->i_flags |= i_nopack_mask;
@@ -187,12 +187,12 @@ int reiserfs_unpack(struct inode *inode, struct file *filp)
 
 	/* we need to make sure nobody is changing the file size beneath us */
 {
-	int depth = reiserfs_write_unlock_nested(inode->i_sb);
+	int depth = reiserfs_write_unlock_nested(inode_sb(inode));
 	inode_lock(inode);
-	reiserfs_write_lock_nested(inode->i_sb, depth);
+	reiserfs_write_lock_nested(inode_sb(inode), depth);
 }
 
-	reiserfs_write_lock(inode->i_sb);
+	reiserfs_write_lock(inode_sb(inode));
 
 	write_from = inode->i_size & (blocksize - 1);
 	/* if we are on a block boundary, we are already unpacked.  */
@@ -228,6 +228,6 @@ int reiserfs_unpack(struct inode *inode, struct file *filp)
 
 out:
 	inode_unlock(inode);
-	reiserfs_write_unlock(inode->i_sb);
+	reiserfs_write_unlock(inode_sb(inode));
 	return retval;
 }
fs/reiserfs/journal.c +5 -5
index 70057359fbaf..aefcb77de3fd 100644
@@ -782,11 +782,11 @@ static inline int __add_jh(struct reiserfs_journal *j, struct buffer_head *bh,
 
 int reiserfs_add_tail_list(struct inode *inode, struct buffer_head *bh)
 {
-	return __add_jh(SB_JOURNAL(inode->i_sb), bh, 1);
+	return __add_jh(SB_JOURNAL(inode_sb(inode)), bh, 1);
 }
 int reiserfs_add_ordered_list(struct inode *inode, struct buffer_head *bh)
 {
-	return __add_jh(SB_JOURNAL(inode->i_sb), bh, 0);
+	return __add_jh(SB_JOURNAL(inode_sb(inode)), bh, 0);
 }
 
 #define JH_ENTRY(l) list_entry((l), struct reiserfs_jh, list)
@@ -3825,7 +3825,7 @@ int journal_mark_freed(struct reiserfs_transaction_handle *th,
 
 void reiserfs_update_inode_transaction(struct inode *inode)
 {
-	struct reiserfs_journal *journal = SB_JOURNAL(inode->i_sb);
+	struct reiserfs_journal *journal = SB_JOURNAL(inode_sb(inode));
 	REISERFS_I(inode)->i_jl = journal->j_current_jl;
 	REISERFS_I(inode)->i_trans_id = journal->j_trans_id;
 }
@@ -3838,7 +3838,7 @@ static int __commit_trans_jl(struct inode *inode, unsigned long id,
 			     struct reiserfs_journal_list *jl)
 {
 	struct reiserfs_transaction_handle th;
-	struct super_block *sb = inode->i_sb;
+	struct super_block *sb = inode_sb(inode);
 	struct reiserfs_journal *journal = SB_JOURNAL(sb);
 	int ret = 0;
 
@@ -3881,7 +3881,7 @@ static int __commit_trans_jl(struct inode *inode, unsigned long id,
 		 * if we've got a larger transaction id than the oldest list
 		 */
 flush_commit_only:
-		if (journal_list_still_alive(inode->i_sb, id)) {
+		if (journal_list_still_alive(inode_sb(inode), id)) {
 			/*
 			 * we only set ret to 1 when we know for sure
 			 * the barrier hasn't been started yet on the commit
fs/reiserfs/namei.c +94 -96

594 lines not on this page · raw message

fs/reiserfs/reiserfs.h +4 -4
index 48835a659948..2523d838588c 100644
@@ -2886,7 +2886,7 @@ int journal_mark_dirty(struct reiserfs_transaction_handle *,
 
 static inline int reiserfs_file_data_log(struct inode *inode)
 {
-	if (reiserfs_data_log(inode->i_sb) ||
+	if (reiserfs_data_log(inode_sb(inode)) ||
 	    (REISERFS_I(inode)->i_flags & i_data_log))
 		return 1;
 	return 0;
@@ -3042,12 +3042,12 @@ int reiserfs_do_truncate(struct reiserfs_transaction_handle *th,
 			 struct inode *inode, struct page *,
 			 int update_timestamps);
 
-#define i_block_size(inode) ((inode)->i_sb->s_blocksize)
+#define i_block_size(inode) (inode_sb((inode))->s_blocksize)
 #define file_size(inode) ((inode)->i_size)
 #define tail_size(inode) (file_size (inode) & (i_block_size (inode) - 1))
 
-#define tail_has_to_be_packed(inode) (have_large_tails ((inode)->i_sb)?\
-!STORE_TAIL_IN_UNFM_S1(file_size (inode), tail_size(inode), inode->i_sb->s_blocksize):have_small_tails ((inode)->i_sb)?!STORE_TAIL_IN_UNFM_S2(file_size (inode), tail_size(inode), inode->i_sb->s_blocksize):0 )
+#define tail_has_to_be_packed(inode) (have_large_tails (inode_sb((inode)))?\
+!STORE_TAIL_IN_UNFM_S1(file_size (inode), tail_size(inode), inode_sb(inode)->s_blocksize):have_small_tails (inode_sb((inode)))?!STORE_TAIL_IN_UNFM_S2(file_size (inode), tail_size(inode), inode_sb(inode)->s_blocksize):0 )
 
 void padd_item(char *item, int total_length, int length);
 
fs/reiserfs/stree.c +35 -34

236 lines not on this page · raw message

fs/reiserfs/super.c +16 -15
index 1fc934d24459..031010fe79f9 100644
@@ -340,9 +340,9 @@ static int finish_unfinished(struct super_block *s)
 			retval = remove_save_link_only(s, &save_link_key, 0);
 			continue;
 		}
-		depth = reiserfs_write_unlock_nested(inode->i_sb);
+		depth = reiserfs_write_unlock_nested(inode_sb(inode));
 		dquot_initialize(inode);
-		reiserfs_write_lock_nested(inode->i_sb, depth);
+		reiserfs_write_lock_nested(inode_sb(inode), depth);
 
 		if (truncate && S_ISDIR(inode->i_mode)) {
 			/*
@@ -453,17 +453,18 @@ void add_save_link(struct reiserfs_transaction_handle *th,
 	key.on_disk_key.k_objectid = inode->i_ino;
 	if (!truncate) {
 		/* unlink, rmdir, rename */
-		set_cpu_key_k_offset(&key, 1 + inode->i_sb->s_blocksize);
+		set_cpu_key_k_offset(&key, 1 + inode_sb(inode)->s_blocksize);
 		set_cpu_key_k_type(&key, TYPE_DIRECT);
 
 		/* item head of "safe" link */
 		make_le_item_head(&ih, &key, key.version,
-				  1 + inode->i_sb->s_blocksize, TYPE_DIRECT,
+				  1 + inode_sb(inode)->s_blocksize,
+				  TYPE_DIRECT,
 				  4 /*length */ , 0xffff /*free space */ );
 	} else {
 		/* truncate */
 		if (S_ISDIR(inode->i_mode))
-			reiserfs_warning(inode->i_sb, "green-2102",
+			reiserfs_warning(inode_sb(inode), "green-2102",
 					 "Adding a truncate savelink for "
 					 "a directory %k! Please report",
 					 INODE_PKEY(inode));
@@ -477,10 +478,10 @@ void add_save_link(struct reiserfs_transaction_handle *th,
 	key.key_length = 3;
 
 	/* look for its place in the tree */
-	retval = search_item(inode->i_sb, &key, &path);
+	retval = search_item(inode_sb(inode), &key, &path);
 	if (retval != ITEM_NOT_FOUND) {
 		if (retval != -ENOSPC)
-			reiserfs_error(inode->i_sb, "vs-2100",
+			reiserfs_error(inode_sb(inode), "vs-2100",
 				       "search_by_key (%K) returned %d", &key,
 				       retval);
 		pathrelse(&path);
@@ -495,7 +496,7 @@ void add_save_link(struct reiserfs_transaction_handle *th,
 	    reiserfs_insert_item(th, &path, &key, &ih, NULL, (char *)&link);
 	if (retval) {
 		if (retval != -ENOSPC)
-			reiserfs_error(inode->i_sb, "vs-2120",
+			reiserfs_error(inode_sb(inode), "vs-2120",
 				       "insert_item returned %d", retval);
 	} else {
 		if (truncate)
@@ -514,7 +515,7 @@ int remove_save_link(struct inode *inode, int truncate)
 	int err;
 
 	/* we are going to do one balancing only */
-	err = journal_begin(&th, inode->i_sb, JOURNAL_PER_BALANCE_CNT);
+	err = journal_begin(&th, inode_sb(inode), JOURNAL_PER_BALANCE_CNT);
 	if (err)
 		return err;
 
@@ -524,7 +525,7 @@ int remove_save_link(struct inode *inode, int truncate)
 	if (!truncate) {
 		/* unlink, rmdir, rename */
 		set_le_key_k_offset(KEY_FORMAT_3_5, &key,
-				    1 + inode->i_sb->s_blocksize);
+				    1 + inode_sb(inode)->s_blocksize);
 		set_le_key_k_type(KEY_FORMAT_3_5, &key, TYPE_DIRECT);
 	} else {
 		/* truncate */
@@ -700,19 +701,19 @@ static void reiserfs_dirty_inode(struct inode *inode, int flags)
 
 	int err = 0;
 
-	if (sb_rdonly(inode->i_sb)) {
-		reiserfs_warning(inode->i_sb, "clm-6006",
+	if (sb_rdonly(inode_sb(inode))) {
+		reiserfs_warning(inode_sb(inode), "clm-6006",
 				 "writing inode %lu on readonly FS",
 				 inode->i_ino);
 		return;
 	}
-	reiserfs_write_lock(inode->i_sb);
+	reiserfs_write_lock(inode_sb(inode));
 
 	/*
 	 * this is really only used for atime updates, so they don't have
 	 * to be included in O_SYNC or fsync
 	 */
-	err = journal_begin(&th, inode->i_sb, 1);
+	err = journal_begin(&th, inode_sb(inode), 1);
 	if (err)
 		goto out;
 
@@ -720,7 +721,7 @@ static void reiserfs_dirty_inode(struct inode *inode, int flags)
 	journal_end(&th);
 
 out:
-	reiserfs_write_unlock(inode->i_sb);
+	reiserfs_write_unlock(inode_sb(inode));
 }
 
 static int reiserfs_show_options(struct seq_file *seq, struct dentry *root)
fs/reiserfs/tail_conversion.c +3 -3
index b0ae088dffc7..a6635188890a 100644
@@ -26,7 +26,7 @@ int direct2indirect(struct reiserfs_transaction_handle *th, struct inode *inode,
 		    struct treepath *path, struct buffer_head *unbh,
 		    loff_t tail_offset)
 {
-	struct super_block *sb = inode->i_sb;
+	struct super_block *sb = inode_sb(inode);
 	struct buffer_head *up_to_date_bh;
 	struct item_head *p_le_ih = tp_item_head(path);
 	unsigned long total_tail = 0;
@@ -178,7 +178,7 @@ void reiserfs_unmap_buffer(struct buffer_head *bh)
 	 */
 	if ((!list_empty(&bh->b_assoc_buffers) || bh->b_private) && bh->b_page) {
 		struct inode *inode = bh->b_page->mapping->host;
-		struct reiserfs_journal *j = SB_JOURNAL(inode->i_sb);
+		struct reiserfs_journal *j = SB_JOURNAL(inode_sb(inode));
 		spin_lock(&j->j_dirty_buffers_lock);
 		list_del_init(&bh->b_assoc_buffers);
 		reiserfs_free_jh(bh);
@@ -208,7 +208,7 @@ int indirect2direct(struct reiserfs_transaction_handle *th,
 		    loff_t n_new_file_size,	/* New file size. */
 		    char *mode)
 {
-	struct super_block *sb = inode->i_sb;
+	struct super_block *sb = inode_sb(inode);
 	struct item_head s_ih;
 	unsigned long block_size = sb->s_blocksize;
 	char *tail;
fs/reiserfs/xattr.c +18 -18
index 5dbf5324bdda..e73afd1703ef 100644
@@ -149,7 +149,7 @@ static struct dentry *open_xa_dir(const struct inode *inode, int flags)
 	struct dentry *xaroot, *xadir;
 	char namebuf[17];
 
-	xaroot = open_xa_root(inode->i_sb, flags);
+	xaroot = open_xa_root(inode_sb(inode), flags);
 	if (IS_ERR(xaroot))
 		return xaroot;
 
@@ -290,21 +290,21 @@ static int reiserfs_for_each_xattr(struct inode *inode,
 		 * outer transaction.
 		 */
 		int blocks = JOURNAL_PER_BALANCE_CNT * 2 + 2 +
-			     4 * REISERFS_QUOTA_TRANS_BLOCKS(inode->i_sb);
+			     4 * REISERFS_QUOTA_TRANS_BLOCKS(inode_sb(inode));
 		struct reiserfs_transaction_handle th;
 
-		reiserfs_write_lock(inode->i_sb);
-		err = journal_begin(&th, inode->i_sb, blocks);
-		reiserfs_write_unlock(inode->i_sb);
+		reiserfs_write_lock(inode_sb(inode));
+		err = journal_begin(&th, inode_sb(inode), blocks);
+		reiserfs_write_unlock(inode_sb(inode));
 		if (!err) {
 			int jerror;
 
 			inode_lock_nested(d_inode(dir->d_parent),
 					  I_MUTEX_XATTR);
 			err = action(dir, data);
-			reiserfs_write_lock(inode->i_sb);
+			reiserfs_write_lock(inode_sb(inode));
 			jerror = journal_end(&th);
-			reiserfs_write_unlock(inode->i_sb);
+			reiserfs_write_unlock(inode_sb(inode));
 			inode_unlock(d_inode(dir->d_parent));
 			err = jerror ?: err;
 		}
@@ -353,7 +353,7 @@ int reiserfs_delete_xattrs(struct inode *inode)
 	int err = reiserfs_for_each_xattr(inode, delete_one_xattr, NULL);
 
 	if (err)
-		reiserfs_warning(inode->i_sb, "jdm-20004",
+		reiserfs_warning(inode_sb(inode), "jdm-20004",
 				 "Couldn't delete all xattrs (%d)\n", err);
 	return err;
 }
@@ -364,7 +364,7 @@ int reiserfs_chown_xattrs(struct inode *inode, struct iattr *attrs)
 	int err = reiserfs_for_each_xattr(inode, chown_one_xattr, attrs);
 
 	if (err)
-		reiserfs_warning(inode->i_sb, "jdm-20007",
+		reiserfs_warning(inode_sb(inode), "jdm-20007",
 				 "Couldn't chown all xattrs (%d)\n", err);
 	return err;
 }
@@ -554,7 +554,7 @@ reiserfs_xattr_set_handle(struct reiserfs_transaction_handle *th,
 			rxh->h_hash = cpu_to_le32(xahash);
 		}
 
-		reiserfs_write_lock(inode->i_sb);
+		reiserfs_write_lock(inode_sb(inode));
 		err = __reiserfs_write_begin(page, page_offset, chunk + skip);
 		if (!err) {
 			if (buffer)
@@ -563,7 +563,7 @@ reiserfs_xattr_set_handle(struct reiserfs_transaction_handle *th,
 						    page_offset + chunk +
 						    skip);
 		}
-		reiserfs_write_unlock(inode->i_sb);
+		reiserfs_write_unlock(inode_sb(inode));
 		unlock_page(page);
 		reiserfs_put_page(page);
 		buffer_pos += chunk;
@@ -606,9 +606,9 @@ int reiserfs_xattr_set(struct inode *inode, const char *name,
 	if (!(flags & XATTR_REPLACE))
 		jbegin_count += reiserfs_xattr_jcreate_nblocks(inode);
 
-	reiserfs_write_lock(inode->i_sb);
-	error = journal_begin(&th, inode->i_sb, jbegin_count);
-	reiserfs_write_unlock(inode->i_sb);
+	reiserfs_write_lock(inode_sb(inode));
+	error = journal_begin(&th, inode_sb(inode), jbegin_count);
+	reiserfs_write_unlock(inode_sb(inode));
 	if (error) {
 		return error;
 	}
@@ -616,9 +616,9 @@ int reiserfs_xattr_set(struct inode *inode, const char *name,
 	error = reiserfs_xattr_set_handle(&th, inode, name,
 					  buffer, buffer_size, flags);
 
-	reiserfs_write_lock(inode->i_sb);
+	reiserfs_write_lock(inode_sb(inode));
 	error2 = journal_end(&th);
-	reiserfs_write_unlock(inode->i_sb);
+	reiserfs_write_unlock(inode_sb(inode));
 	if (error == 0)
 		error = error2;
 
@@ -698,7 +698,7 @@ reiserfs_xattr_get(struct inode *inode, const char *name, void *buffer,
 			if (rxh->h_magic != cpu_to_le32(REISERFS_XATTR_MAGIC)) {
 				unlock_page(page);
 				reiserfs_put_page(page);
-				reiserfs_warning(inode->i_sb, "jdm-20001",
+				reiserfs_warning(inode_sb(inode), "jdm-20001",
 						 "Invalid magic for xattr (%s) "
 						 "associated with %k", name,
 						 INODE_PKEY(inode));
@@ -718,7 +718,7 @@ reiserfs_xattr_get(struct inode *inode, const char *name, void *buffer,
 
 	if (xattr_hash(buffer, isize - sizeof(struct reiserfs_xattr_header)) !=
 	    hash) {
-		reiserfs_warning(inode->i_sb, "jdm-20002",
+		reiserfs_warning(inode_sb(inode), "jdm-20002",
 				 "Invalid hash for xattr (%s) associated "
 				 "with %k", name, INODE_PKEY(inode));
 		err = -EIO;
fs/reiserfs/xattr.h +7 -6
index c764352447ba..7b7c55d603a6 100644
@@ -51,8 +51,9 @@ static inline loff_t reiserfs_xattr_nblocks(struct inode *inode, loff_t size)
 {
 	loff_t ret = 0;
 	if (reiserfs_file_data_log(inode)) {
-		ret = _ROUND_UP(xattr_size(size), inode->i_sb->s_blocksize);
-		ret >>= inode->i_sb->s_blocksize_bits;
+		ret = _ROUND_UP(xattr_size(size),
+				inode_sb(inode)->s_blocksize);
+		ret >>= inode_sb(inode)->s_blocksize_bits;
 	}
 	return ret;
 }
@@ -71,12 +72,12 @@ static inline loff_t reiserfs_xattr_nblocks(struct inode *inode, loff_t size)
  */
 static inline size_t reiserfs_xattr_jcreate_nblocks(struct inode *inode)
 {
-	size_t nblocks = JOURNAL_BLOCKS_PER_OBJECT(inode->i_sb);
+	size_t nblocks = JOURNAL_BLOCKS_PER_OBJECT(inode_sb(inode));
 
 	if ((REISERFS_I(inode)->i_flags & i_has_xattr_dir) == 0) {
-		nblocks += JOURNAL_BLOCKS_PER_OBJECT(inode->i_sb);
-		if (d_really_is_negative(REISERFS_SB(inode->i_sb)->xattr_root))
-			nblocks += JOURNAL_BLOCKS_PER_OBJECT(inode->i_sb);
+		nblocks += JOURNAL_BLOCKS_PER_OBJECT(inode_sb(inode));
+		if (d_really_is_negative(REISERFS_SB(inode_sb(inode))->xattr_root))
+			nblocks += JOURNAL_BLOCKS_PER_OBJECT(inode_sb(inode));
 	}
 
 	return nblocks;
fs/reiserfs/xattr_acl.c +7 -7
index aa9380bac196..3bebe8b2064b 100644
@@ -35,9 +35,9 @@ reiserfs_set_acl(struct inode *inode, struct posix_acl *acl, int type)
 	jcreate_blocks = reiserfs_xattr_jcreate_nblocks(inode) +
 			 reiserfs_xattr_nblocks(inode, size) * 2;
 
-	reiserfs_write_lock(inode->i_sb);
-	error = journal_begin(&th, inode->i_sb, jcreate_blocks);
-	reiserfs_write_unlock(inode->i_sb);
+	reiserfs_write_lock(inode_sb(inode));
+	error = journal_begin(&th, inode_sb(inode), jcreate_blocks);
+	reiserfs_write_unlock(inode_sb(inode));
 	if (error == 0) {
 		if (type == ACL_TYPE_ACCESS && acl) {
 			error = posix_acl_update_mode(inode, &mode, &acl);
@@ -49,9 +49,9 @@ reiserfs_set_acl(struct inode *inode, struct posix_acl *acl, int type)
 		if (!error && update_mode)
 			inode->i_mode = mode;
 unlock:
-		reiserfs_write_lock(inode->i_sb);
+		reiserfs_write_lock(inode_sb(inode));
 		error2 = journal_end(&th);
-		reiserfs_write_unlock(inode->i_sb);
+		reiserfs_write_unlock(inode_sb(inode));
 		if (error2)
 			error = error2;
 	}
@@ -378,7 +378,7 @@ int reiserfs_cache_default_acl(struct inode *inode)
 		 * we need to create the tree to the xattrs, and then we
 		 * just want two files. */
 		nblocks = reiserfs_xattr_jcreate_nblocks(inode);
-		nblocks += JOURNAL_BLOCKS_PER_OBJECT(inode->i_sb);
+		nblocks += JOURNAL_BLOCKS_PER_OBJECT(inode_sb(inode));
 
 		REISERFS_I(inode)->i_flags |= i_has_xattr_dir;
 
@@ -398,7 +398,7 @@ int reiserfs_acl_chmod(struct inode *inode)
 	if (IS_PRIVATE(inode))
 		return 0;
 	if (get_inode_sd_version(inode) == STAT_DATA_V1 ||
-	    !reiserfs_posixacl(inode->i_sb))
+	    !reiserfs_posixacl(inode_sb(inode)))
 		return 0;
 
 	return posix_acl_chmod(inode, inode->i_mode);
fs/reiserfs/xattr_security.c +1 -1
index 20be9a0e5870..c0a096637536 100644
@@ -66,7 +66,7 @@ int reiserfs_security_init(struct inode *dir, struct inode *inode,
 		return error;
 	}
 
-	if (sec->length && reiserfs_xattrs_initialized(inode->i_sb)) {
+	if (sec->length && reiserfs_xattrs_initialized(inode_sb(inode))) {
 		blocks = reiserfs_xattr_jcreate_nblocks(inode) +
 			 reiserfs_xattr_nblocks(inode, sec->length);
 		/* We don't want to count the directories twice if we have
fs/reiserfs/xattr_user.c +2 -2
index a573ca45bacc..baf8f21dd844 100644
@@ -11,7 +11,7 @@ static int
 user_get(const struct xattr_handler *handler, struct dentry *unused,
 	 struct inode *inode, const char *name, void *buffer, size_t size)
 {
-	if (!reiserfs_xattrs_user(inode->i_sb))
+	if (!reiserfs_xattrs_user(inode_sb(inode)))
 		return -EOPNOTSUPP;
 	return reiserfs_xattr_get(inode, xattr_full_name(handler, name),
 				  buffer, size);
@@ -22,7 +22,7 @@ user_set(const struct xattr_handler *handler, struct dentry *unused,
 	 struct inode *inode, const char *name, const void *buffer,
 	 size_t size, int flags)
 {
-	if (!reiserfs_xattrs_user(inode->i_sb))
+	if (!reiserfs_xattrs_user(inode_sb(inode)))
 		return -EOPNOTSUPP;
 	return reiserfs_xattr_set(inode,
 				  xattr_full_name(handler, name),
Signature · 1 line
2.15.1
#67 lore raw

PATCH 66/76 fs/romfs: Use inode_sb() helper instead of inode->i_sb

In reply to Mark Fasheh
---
 fs/romfs/mmap-nommu.c |  4 ++--
 fs/romfs/super.c      | 24 +++++++++++++-----------
 2 files changed, 15 insertions(+), 13 deletions(-)
fs/romfs/mmap-nommu.c +2 -2
index 1118a0dc6b45..0dbf9be30283 100644
@@ -26,7 +26,7 @@ static unsigned long romfs_get_unmapped_area(struct file *file,
 					     unsigned long flags)
 {
 	struct inode *inode = file->f_mapping->host;
-	struct mtd_info *mtd = inode->i_sb->s_mtd;
+	struct mtd_info *mtd = inode_sb(inode)->s_mtd;
 	unsigned long isize, offset, maxpages, lpages;
 	int ret;
 
@@ -72,7 +72,7 @@ static int romfs_mmap(struct file *file, struct vm_area_struct *vma)
 
 static unsigned romfs_mmap_capabilities(struct file *file)
 {
-	struct mtd_info *mtd = file_inode(file)->i_sb->s_mtd;
+	struct mtd_info *mtd = inode_sb(file_inode(file))->s_mtd;
 
 	if (!mtd)
 		return NOMMU_MAP_COPY;
fs/romfs/super.c +13 -11
index 8f06fd1f3d69..eb0b7d3775bb 100644
@@ -122,7 +122,7 @@ static int romfs_readpage(struct file *file, struct page *page)
 
 		pos = ROMFS_I(inode)->i_dataoffset + offset;
 
-		ret = romfs_dev_read(inode->i_sb, pos, buf, fillsize);
+		ret = romfs_dev_read(inode_sb(inode), pos, buf, fillsize);
 		if (ret < 0) {
 			SetPageError(page);
 			fillsize = 0;
@@ -157,12 +157,12 @@ static int romfs_readdir(struct file *file, struct dir_context *ctx)
 	char fsname[ROMFS_MAXFN];	/* XXX dynamic? */
 	int ret;
 
-	maxoff = romfs_maxsize(i->i_sb);
+	maxoff = romfs_maxsize(inode_sb(i));
 
 	offset = ctx->pos;
 	if (!offset) {
 		offset = i->i_ino & ROMFH_MASK;
-		ret = romfs_dev_read(i->i_sb, offset, &ri, ROMFH_SIZE);
+		ret = romfs_dev_read(inode_sb(i), offset, &ri, ROMFH_SIZE);
 		if (ret < 0)
 			goto out;
 		offset = be32_to_cpu(ri.spec) & ROMFH_MASK;
@@ -178,16 +178,17 @@ static int romfs_readdir(struct file *file, struct dir_context *ctx)
 		ctx->pos = offset;
 
 		/* Fetch inode info */
-		ret = romfs_dev_read(i->i_sb, offset, &ri, ROMFH_SIZE);
+		ret = romfs_dev_read(inode_sb(i), offset, &ri, ROMFH_SIZE);
 		if (ret < 0)
 			goto out;
 
-		j = romfs_dev_strnlen(i->i_sb, offset + ROMFH_SIZE,
+		j = romfs_dev_strnlen(inode_sb(i), offset + ROMFH_SIZE,
 				      sizeof(fsname) - 1);
 		if (j < 0)
 			goto out;
 
-		ret = romfs_dev_read(i->i_sb, offset + ROMFH_SIZE, fsname, j);
+		ret = romfs_dev_read(inode_sb(i), offset + ROMFH_SIZE, fsname,
+				     j);
 		if (ret < 0)
 			goto out;
 		fsname[j] = '\0';
@@ -219,13 +220,13 @@ static struct dentry *romfs_lookup(struct inode *dir, struct dentry *dentry,
 	int len, ret;
 
 	offset = dir->i_ino & ROMFH_MASK;
-	ret = romfs_dev_read(dir->i_sb, offset, &ri, ROMFH_SIZE);
+	ret = romfs_dev_read(inode_sb(dir), offset, &ri, ROMFH_SIZE);
 	if (ret < 0)
 		goto error;
 
 	/* search all the file entries in the list starting from the one
 	 * pointed to by the directory's special data */
-	maxoff = romfs_maxsize(dir->i_sb);
+	maxoff = romfs_maxsize(inode_sb(dir));
 	offset = be32_to_cpu(ri.spec) & ROMFH_MASK;
 
 	name = dentry->d_name.name;
@@ -235,12 +236,13 @@ static struct dentry *romfs_lookup(struct inode *dir, struct dentry *dentry,
 		if (!offset || offset >= maxoff)
 			goto out0;
 
-		ret = romfs_dev_read(dir->i_sb, offset, &ri, sizeof(ri));
+		ret = romfs_dev_read(inode_sb(dir), offset, &ri, sizeof(ri));
 		if (ret < 0)
 			goto error;
 
 		/* try to match the first 16 bytes of name */
-		ret = romfs_dev_strcmp(dir->i_sb, offset + ROMFH_SIZE, name,
+		ret = romfs_dev_strcmp(inode_sb(dir), offset + ROMFH_SIZE,
+				       name,
 				       len);
 		if (ret < 0)
 			goto error;
@@ -255,7 +257,7 @@ static struct dentry *romfs_lookup(struct inode *dir, struct dentry *dentry,
 	if ((be32_to_cpu(ri.next) & ROMFH_TYPE) == ROMFH_HRD)
 		offset = be32_to_cpu(ri.spec) & ROMFH_MASK;
 
-	inode = romfs_iget(dir->i_sb, offset);
+	inode = romfs_iget(inode_sb(dir), offset);
 	if (IS_ERR(inode)) {
 		ret = PTR_ERR(inode);
 		goto error;
Signature · 1 line
2.15.1
#68 lore raw

PATCH 67/76 fs/squashfs: Use inode_sb() helper instead of inode->i_sb

In reply to Mark Fasheh
---
 fs/squashfs/dir.c         | 26 ++++++++++++++------------
 fs/squashfs/export.c      |  2 +-
 fs/squashfs/file.c        | 34 ++++++++++++++++++----------------
 fs/squashfs/file_cache.c  |  5 +++--
 fs/squashfs/file_direct.c |  9 +++++----
 fs/squashfs/inode.c       |  2 +-
 fs/squashfs/namei.c       | 28 ++++++++++++++++------------
 fs/squashfs/symlink.c     |  2 +-
 fs/squashfs/xattr.c       |  4 ++--
 9 files changed, 61 insertions(+), 51 deletions(-)
fs/squashfs/dir.c +14 -12
index a5845f94a2a1..c184017e4e70 100644
@@ -110,7 +110,7 @@ static int get_dir_index_using_offset(struct super_block *sb,
 static int squashfs_readdir(struct file *file, struct dir_context *ctx)
 {
 	struct inode *inode = file_inode(file);
-	struct squashfs_sb_info *msblk = inode->i_sb->s_fs_info;
+	struct squashfs_sb_info *msblk = inode_sb(inode)->s_fs_info;
 	u64 block = squashfs_i(inode)->start + msblk->directory_table;
 	int offset = squashfs_i(inode)->offset, length, err;
 	unsigned int inode_number, dir_count, size, type;
@@ -154,18 +154,18 @@ static int squashfs_readdir(struct file *file, struct dir_context *ctx)
 		ctx->pos += size;
 	}
 
-	length = get_dir_index_using_offset(inode->i_sb, &block, &offset,
-				squashfs_i(inode)->dir_idx_start,
-				squashfs_i(inode)->dir_idx_offset,
-				squashfs_i(inode)->dir_idx_cnt,
-				ctx->pos);
+	length = get_dir_index_using_offset(inode_sb(inode), &block, &offset,
+					    squashfs_i(inode)->dir_idx_start,
+					    squashfs_i(inode)->dir_idx_offset,
+					    squashfs_i(inode)->dir_idx_cnt,
+					    ctx->pos);
 
 	while (length < i_size_read(inode)) {
 		/*
 		 * Read directory header
 		 */
-		err = squashfs_read_metadata(inode->i_sb, &dirh, &block,
-					&offset, sizeof(dirh));
+		err = squashfs_read_metadata(inode_sb(inode), &dirh, &block,
+					     &offset, sizeof(dirh));
 		if (err < 0)
 			goto failed_read;
 
@@ -180,8 +180,9 @@ static int squashfs_readdir(struct file *file, struct dir_context *ctx)
 			/*
 			 * Read directory entry.
 			 */
-			err = squashfs_read_metadata(inode->i_sb, dire, &block,
-					&offset, sizeof(*dire));
+			err = squashfs_read_metadata(inode_sb(inode), dire,
+						     &block,
+						     &offset, sizeof(*dire));
 			if (err < 0)
 				goto failed_read;
 
@@ -191,8 +192,9 @@ static int squashfs_readdir(struct file *file, struct dir_context *ctx)
 			if (size > SQUASHFS_NAME_LEN)
 				goto failed_read;
 
-			err = squashfs_read_metadata(inode->i_sb, dire->name,
-					&block, &offset, size);
+			err = squashfs_read_metadata(inode_sb(inode),
+						     dire->name,
+						     &block, &offset, size);
 			if (err < 0)
 				goto failed_read;
 
fs/squashfs/export.c +1 -1
index 8073b6532cf0..ce7615f66d5c 100644
@@ -113,7 +113,7 @@ static struct dentry *squashfs_get_parent(struct dentry *child)
 	struct inode *inode = d_inode(child);
 	unsigned int parent_ino = squashfs_i(inode)->parent;
 
-	return squashfs_export_iget(inode->i_sb, parent_ino);
+	return squashfs_export_iget(inode_sb(inode), parent_ino);
 }
 
 
fs/squashfs/file.c +18 -16
index 13d80947bf9e..afad108e0d36 100644
@@ -61,7 +61,7 @@ static struct meta_index *locate_meta_index(struct inode *inode, int offset,
 				int index)
 {
 	struct meta_index *meta = NULL;
-	struct squashfs_sb_info *msblk = inode->i_sb->s_fs_info;
+	struct squashfs_sb_info *msblk = inode_sb(inode)->s_fs_info;
 	int i;
 
 	mutex_lock(&msblk->meta_index_mutex);
@@ -99,7 +99,7 @@ static struct meta_index *locate_meta_index(struct inode *inode, int offset,
 static struct meta_index *empty_meta_index(struct inode *inode, int offset,
 				int skip)
 {
-	struct squashfs_sb_info *msblk = inode->i_sb->s_fs_info;
+	struct squashfs_sb_info *msblk = inode_sb(inode)->s_fs_info;
 	struct meta_index *meta = NULL;
 	int i;
 
@@ -159,7 +159,7 @@ static struct meta_index *empty_meta_index(struct inode *inode, int offset,
 
 static void release_meta_index(struct inode *inode, struct meta_index *meta)
 {
-	struct squashfs_sb_info *msblk = inode->i_sb->s_fs_info;
+	struct squashfs_sb_info *msblk = inode_sb(inode)->s_fs_info;
 	mutex_lock(&msblk->meta_index_mutex);
 	meta->locked = 0;
 	mutex_unlock(&msblk->meta_index_mutex);
@@ -236,7 +236,7 @@ static inline int calculate_skip(int blocks)
 static int fill_meta_index(struct inode *inode, int index,
 		u64 *index_block, int *index_offset, u64 *data_block)
 {
-	struct squashfs_sb_info *msblk = inode->i_sb->s_fs_info;
+	struct squashfs_sb_info *msblk = inode_sb(inode)->s_fs_info;
 	int skip = calculate_skip(i_size_read(inode) >> msblk->block_log);
 	int offset = 0;
 	struct meta_index *meta;
@@ -282,8 +282,9 @@ static int fill_meta_index(struct inode *inode, int index,
 		for (i = meta->offset + meta->entries; i <= index &&
 				i < meta->offset + SQUASHFS_META_ENTRIES; i++) {
 			int blocks = skip * SQUASHFS_META_INDEXES;
-			long long res = read_indexes(inode->i_sb, blocks,
-					&cur_index_block, &cur_offset);
+			long long res = read_indexes(inode_sb(inode), blocks,
+						     &cur_index_block,
+						     &cur_offset);
 
 			if (res < 0) {
 				if (meta->entries == 0)
@@ -354,7 +355,8 @@ static int read_blocklist(struct inode *inode, int index, u64 *block)
 	 * extra block indexes needed.
 	 */
 	if (res < index) {
-		blks = read_indexes(inode->i_sb, index - res, &start, &offset);
+		blks = read_indexes(inode_sb(inode), index - res, &start,
+				    &offset);
 		if (blks < 0)
 			return (int) blks;
 		*block += blks;
@@ -363,8 +365,8 @@ static int read_blocklist(struct inode *inode, int index, u64 *block)
 	/*
 	 * Read length of block specified by index.
 	 */
-	res = squashfs_read_metadata(inode->i_sb, &size, &start, &offset,
-			sizeof(size));
+	res = squashfs_read_metadata(inode_sb(inode), &size, &start, &offset,
+				     sizeof(size));
 	if (res < 0)
 		return res;
 	return le32_to_cpu(size);
@@ -375,7 +377,7 @@ void squashfs_copy_cache(struct page *page, struct squashfs_cache_entry *buffer,
 	int bytes, int offset)
 {
 	struct inode *inode = page->mapping->host;
-	struct squashfs_sb_info *msblk = inode->i_sb->s_fs_info;
+	struct squashfs_sb_info *msblk = inode_sb(inode)->s_fs_info;
 	void *pageaddr;
 	int i, mask = (1 << (msblk->block_log - PAGE_SHIFT)) - 1;
 	int start_index = page->index & ~mask, end_index = start_index | mask;
@@ -419,10 +421,10 @@ void squashfs_copy_cache(struct page *page, struct squashfs_cache_entry *buffer,
 static int squashfs_readpage_fragment(struct page *page)
 {
 	struct inode *inode = page->mapping->host;
-	struct squashfs_sb_info *msblk = inode->i_sb->s_fs_info;
-	struct squashfs_cache_entry *buffer = squashfs_get_fragment(inode->i_sb,
-		squashfs_i(inode)->fragment_block,
-		squashfs_i(inode)->fragment_size);
+	struct squashfs_sb_info *msblk = inode_sb(inode)->s_fs_info;
+	struct squashfs_cache_entry *buffer = squashfs_get_fragment(inode_sb(inode),
+								    squashfs_i(inode)->fragment_block,
+								    squashfs_i(inode)->fragment_size);
 	int res = buffer->error;
 
 	if (res)
@@ -441,7 +443,7 @@ static int squashfs_readpage_fragment(struct page *page)
 static int squashfs_readpage_sparse(struct page *page, int index, int file_end)
 {
 	struct inode *inode = page->mapping->host;
-	struct squashfs_sb_info *msblk = inode->i_sb->s_fs_info;
+	struct squashfs_sb_info *msblk = inode_sb(inode)->s_fs_info;
 	int bytes = index == file_end ?
 			(i_size_read(inode) & (msblk->block_size - 1)) :
 			 msblk->block_size;
@@ -453,7 +455,7 @@ static int squashfs_readpage_sparse(struct page *page, int index, int file_end)
 static int squashfs_readpage(struct file *file, struct page *page)
 {
 	struct inode *inode = page->mapping->host;
-	struct squashfs_sb_info *msblk = inode->i_sb->s_fs_info;
+	struct squashfs_sb_info *msblk = inode_sb(inode)->s_fs_info;
 	int index = page->index >> (msblk->block_log - PAGE_SHIFT);
 	int file_end = i_size_read(inode) >> msblk->block_log;
 	int res;
fs/squashfs/file_cache.c +3 -2
index f2310d2a2019..7aedf57d500d 100644
@@ -23,8 +23,9 @@
 int squashfs_readpage_block(struct page *page, u64 block, int bsize)
 {
 	struct inode *i = page->mapping->host;
-	struct squashfs_cache_entry *buffer = squashfs_get_datablock(i->i_sb,
-		block, bsize);
+	struct squashfs_cache_entry *buffer = squashfs_get_datablock(inode_sb(i),
+								     block,
+								     bsize);
 	int res = buffer->error;
 
 	if (res)
fs/squashfs/file_direct.c +5 -4
index cb485d8e0e91..b336f6872816 100644
@@ -28,7 +28,7 @@ int squashfs_readpage_block(struct page *target_page, u64 block, int bsize)
 
 {
 	struct inode *inode = target_page->mapping->host;
-	struct squashfs_sb_info *msblk = inode->i_sb->s_fs_info;
+	struct squashfs_sb_info *msblk = inode_sb(inode)->s_fs_info;
 
 	int file_end = (i_size_read(inode) - 1) >> PAGE_SHIFT;
 	int mask = (1 << (msblk->block_log - PAGE_SHIFT)) - 1;
@@ -91,7 +91,7 @@ int squashfs_readpage_block(struct page *target_page, u64 block, int bsize)
 	}
 
 	/* Decompress directly into the page cache buffers */
-	res = squashfs_read_data(inode->i_sb, block, bsize, NULL, actor);
+	res = squashfs_read_data(inode_sb(inode), block, bsize, NULL, actor);
 	if (res < 0)
 		goto mark_errored;
 
@@ -141,8 +141,9 @@ static int squashfs_read_cache(struct page *target_page, u64 block, int bsize,
 	int pages, struct page **page)
 {
 	struct inode *i = target_page->mapping->host;
-	struct squashfs_cache_entry *buffer = squashfs_get_datablock(i->i_sb,
-						 block, bsize);
+	struct squashfs_cache_entry *buffer = squashfs_get_datablock(inode_sb(i),
+								     block,
+								     bsize);
 	int bytes = buffer->length, res = buffer->error, n, offset = 0;
 	void *pageaddr;
 
fs/squashfs/inode.c +1 -1
index e9793b1e49a5..686083434be3 100644
@@ -112,7 +112,7 @@ struct inode *squashfs_iget(struct super_block *sb, long long ino,
  */
 int squashfs_read_inode(struct inode *inode, long long ino)
 {
-	struct super_block *sb = inode->i_sb;
+	struct super_block *sb = inode_sb(inode);
 	struct squashfs_sb_info *msblk = sb->s_fs_info;
 	u64 block = SQUASHFS_INODE_BLK(ino) + msblk->inode_table;
 	int err, type, offset = SQUASHFS_INODE_OFFSET(ino);
fs/squashfs/namei.c +16 -12
index 40c10d9974c9..82bd0f01630b 100644
@@ -142,7 +142,7 @@ static struct dentry *squashfs_lookup(struct inode *dir, struct dentry *dentry,
 	const unsigned char *name = dentry->d_name.name;
 	int len = dentry->d_name.len;
 	struct inode *inode = NULL;
-	struct squashfs_sb_info *msblk = dir->i_sb->s_fs_info;
+	struct squashfs_sb_info *msblk = inode_sb(dir)->s_fs_info;
 	struct squashfs_dir_header dirh;
 	struct squashfs_dir_entry *dire;
 	u64 block = squashfs_i(dir)->start + msblk->directory_table;
@@ -163,17 +163,18 @@ static struct dentry *squashfs_lookup(struct inode *dir, struct dentry *dentry,
 		goto failed;
 	}
 
-	length = get_dir_index_using_name(dir->i_sb, &block, &offset,
-				squashfs_i(dir)->dir_idx_start,
-				squashfs_i(dir)->dir_idx_offset,
-				squashfs_i(dir)->dir_idx_cnt, name, len);
+	length = get_dir_index_using_name(inode_sb(dir), &block, &offset,
+					  squashfs_i(dir)->dir_idx_start,
+					  squashfs_i(dir)->dir_idx_offset,
+					  squashfs_i(dir)->dir_idx_cnt, name,
+					  len);
 
 	while (length < i_size_read(dir)) {
 		/*
 		 * Read directory header.
 		 */
-		err = squashfs_read_metadata(dir->i_sb, &dirh, &block,
-				&offset, sizeof(dirh));
+		err = squashfs_read_metadata(inode_sb(dir), &dirh, &block,
+					     &offset, sizeof(dirh));
 		if (err < 0)
 			goto read_failure;
 
@@ -188,8 +189,9 @@ static struct dentry *squashfs_lookup(struct inode *dir, struct dentry *dentry,
 			/*
 			 * Read directory entry.
 			 */
-			err = squashfs_read_metadata(dir->i_sb, dire, &block,
-					&offset, sizeof(*dire));
+			err = squashfs_read_metadata(inode_sb(dir), dire,
+						     &block,
+						     &offset, sizeof(*dire));
 			if (err < 0)
 				goto read_failure;
 
@@ -199,8 +201,9 @@ static struct dentry *squashfs_lookup(struct inode *dir, struct dentry *dentry,
 			if (size > SQUASHFS_NAME_LEN)
 				goto data_error;
 
-			err = squashfs_read_metadata(dir->i_sb, dire->name,
-					&block, &offset, size);
+			err = squashfs_read_metadata(inode_sb(dir),
+						     dire->name,
+						     &block, &offset, size);
 			if (err < 0)
 				goto read_failure;
 
@@ -222,7 +225,8 @@ static struct dentry *squashfs_lookup(struct inode *dir, struct dentry *dentry,
 					"entry %s, inode  %x:%x, %d\n", name,
 					blk, off, ino_num);
 
-				inode = squashfs_iget(dir->i_sb, ino, ino_num);
+				inode = squashfs_iget(inode_sb(dir), ino,
+						      ino_num);
 				goto exit_lookup;
 			}
 		}
fs/squashfs/symlink.c +1 -1
index befeba0fa70a..76a5af382016 100644
@@ -46,7 +46,7 @@
 static int squashfs_symlink_readpage(struct file *file, struct page *page)
 {
 	struct inode *inode = page->mapping->host;
-	struct super_block *sb = inode->i_sb;
+	struct super_block *sb = inode_sb(inode);
 	struct squashfs_sb_info *msblk = sb->s_fs_info;
 	int index = page->index << PAGE_SHIFT;
 	u64 block = squashfs_i(inode)->start;
fs/squashfs/xattr.c +2 -2
index 1548b3784548..b6eec3779af4 100644
@@ -40,7 +40,7 @@ ssize_t squashfs_listxattr(struct dentry *d, char *buffer,
 	size_t buffer_size)
 {
 	struct inode *inode = d_inode(d);
-	struct super_block *sb = inode->i_sb;
+	struct super_block *sb = inode_sb(inode);
 	struct squashfs_sb_info *msblk = sb->s_fs_info;
 	u64 start = SQUASHFS_XATTR_BLK(squashfs_i(inode)->xattr)
 						 + msblk->xattr_table;
@@ -118,7 +118,7 @@ ssize_t squashfs_listxattr(struct dentry *d, char *buffer,
 static int squashfs_xattr_get(struct inode *inode, int name_index,
 	const char *name, void *buffer, size_t buffer_size)
 {
-	struct super_block *sb = inode->i_sb;
+	struct super_block *sb = inode_sb(inode);
 	struct squashfs_sb_info *msblk = sb->s_fs_info;
 	u64 start = SQUASHFS_XATTR_BLK(squashfs_i(inode)->xattr)
 						 + msblk->xattr_table;
Signature · 1 line
2.15.1
#69 lore raw

PATCH 68/76 fs/sysv: Use inode_sb() helper instead of inode->i_sb

In reply to Mark Fasheh
---
 fs/sysv/dir.c    | 12 ++++++------
 fs/sysv/ialloc.c |  8 ++++----
 fs/sysv/inode.c  |  6 +++---
 fs/sysv/itree.c  | 29 +++++++++++++++--------------
 fs/sysv/namei.c  |  4 ++--
 5 files changed, 30 insertions(+), 29 deletions(-)
fs/sysv/dir.c +6 -6
index 88e38cd8f5c9..84a11fda6a28 100644
@@ -65,7 +65,7 @@ static int sysv_readdir(struct file *file, struct dir_context *ctx)
 {
 	unsigned long pos = ctx->pos;
 	struct inode *inode = file_inode(file);
-	struct super_block *sb = inode->i_sb;
+	struct super_block *sb = inode_sb(inode);
 	unsigned long npages = dir_pages(inode);
 	unsigned offset;
 	unsigned long n;
@@ -214,7 +214,7 @@ int sysv_add_link(struct dentry *dentry, struct inode *inode)
 		goto out_unlock;
 	memcpy (de->name, name, namelen);
 	memset (de->name + namelen, 0, SYSV_DIRSIZE - namelen - 2);
-	de->inode = cpu_to_fs16(SYSV_SB(inode->i_sb), inode->i_ino);
+	de->inode = cpu_to_fs16(SYSV_SB(inode_sb(inode)), inode->i_ino);
 	err = dir_commit_chunk(page, pos, SYSV_DIRSIZE);
 	dir->i_mtime = dir->i_ctime = current_time(dir);
 	mark_inode_dirty(dir);
@@ -265,10 +265,10 @@ int sysv_make_empty(struct inode *inode, struct inode *dir)
 	memset(base, 0, PAGE_SIZE);
 
 	de = (struct sysv_dir_entry *) base;
-	de->inode = cpu_to_fs16(SYSV_SB(inode->i_sb), inode->i_ino);
+	de->inode = cpu_to_fs16(SYSV_SB(inode_sb(inode)), inode->i_ino);
 	strcpy(de->name,".");
 	de++;
-	de->inode = cpu_to_fs16(SYSV_SB(inode->i_sb), dir->i_ino);
+	de->inode = cpu_to_fs16(SYSV_SB(inode_sb(inode)), dir->i_ino);
 	strcpy(de->name,"..");
 
 	kunmap(page);
@@ -283,7 +283,7 @@ int sysv_make_empty(struct inode *inode, struct inode *dir)
  */
 int sysv_empty_dir(struct inode * inode)
 {
-	struct super_block *sb = inode->i_sb;
+	struct super_block *sb = inode_sb(inode);
 	struct page *page = NULL;
 	unsigned long i, npages = dir_pages(inode);
 
@@ -335,7 +335,7 @@ void sysv_set_link(struct sysv_dir_entry *de, struct page *page,
 	lock_page(page);
 	err = sysv_prepare_chunk(page, pos, SYSV_DIRSIZE);
 	BUG_ON(err);
-	de->inode = cpu_to_fs16(SYSV_SB(inode->i_sb), inode->i_ino);
+	de->inode = cpu_to_fs16(SYSV_SB(inode_sb(inode)), inode->i_ino);
 	err = dir_commit_chunk(page, pos, SYSV_DIRSIZE);
 	dir_put_page(page);
 	dir->i_mtime = dir->i_ctime = current_time(dir);
fs/sysv/ialloc.c +4 -4
index 6c9801986af6..2515367bf047 100644
@@ -100,14 +100,14 @@ static int refill_free_cache(struct super_block *sb)
 
 void sysv_free_inode(struct inode * inode)
 {
-	struct super_block *sb = inode->i_sb;
+	struct super_block *sb = inode_sb(inode);
 	struct sysv_sb_info *sbi = SYSV_SB(sb);
 	unsigned int ino;
 	struct buffer_head * bh;
 	struct sysv_inode * raw_inode;
 	unsigned count;
 
-	sb = inode->i_sb;
+	sb = inode_sb(inode);
 	ino = inode->i_ino;
 	if (ino <= SYSV_ROOT_INO || ino > sbi->s_ninodes) {
 		printk("sysv_free_inode: inode 0,1,2 or nonexistent inode\n");
@@ -116,7 +116,7 @@ void sysv_free_inode(struct inode * inode)
 	raw_inode = sysv_raw_inode(sb, ino, &bh);
 	if (!raw_inode) {
 		printk("sysv_free_inode: unable to read inode block on device "
-		       "%s\n", inode->i_sb->s_id);
+		       "%s\n", inode_sb(inode)->s_id);
 		return;
 	}
 	mutex_lock(&sbi->s_lock);
@@ -135,7 +135,7 @@ void sysv_free_inode(struct inode * inode)
 
 struct inode * sysv_new_inode(const struct inode * dir, umode_t mode)
 {
-	struct super_block *sb = dir->i_sb;
+	struct super_block *sb = inode_sb(dir);
 	struct sysv_sb_info *sbi = SYSV_SB(sb);
 	struct inode *inode;
 	sysv_ino_t ino;
fs/sysv/inode.c +3 -3
index bec9f79adb25..9d04a4a2c248 100644
@@ -192,7 +192,7 @@ struct inode *sysv_iget(struct super_block *sb, unsigned int ino)
 	raw_inode = sysv_raw_inode(sb, ino, &bh);
 	if (!raw_inode) {
 		printk("Major problem: unable to read inode from dev %s\n",
-		       inode->i_sb->s_id);
+		       inode_sb(inode)->s_id);
 		goto bad_inode;
 	}
 	/* SystemV FS: kludge permissions if ino==SYSV_ROOT_INO ?? */
@@ -230,7 +230,7 @@ struct inode *sysv_iget(struct super_block *sb, unsigned int ino)
 
 static int __sysv_write_inode(struct inode *inode, int wait)
 {
-	struct super_block * sb = inode->i_sb;
+	struct super_block * sb = inode_sb(inode);
 	struct sysv_sb_info * sbi = SYSV_SB(sb);
 	struct buffer_head * bh;
 	struct sysv_inode * raw_inode;
@@ -241,7 +241,7 @@ static int __sysv_write_inode(struct inode *inode, int wait)
 	ino = inode->i_ino;
 	if (!ino || ino > sbi->s_ninodes) {
 		printk("Bad inode number on dev %s: %d is out of range\n",
-		       inode->i_sb->s_id, ino);
+		       inode_sb(inode)->s_id, ino);
 		return -EIO;
 	}
 	raw_inode = sysv_raw_inode(sb, ino, &bh);
fs/sysv/itree.c +15 -14
index bcb67b0cabe7..f69d30bc4217 100644
@@ -22,7 +22,7 @@ static inline void dirty_indirect(struct buffer_head *bh, struct inode *inode)
 
 static int block_to_path(struct inode *inode, long block, int offsets[DEPTH])
 {
-	struct super_block *sb = inode->i_sb;
+	struct super_block *sb = inode_sb(inode);
 	struct sysv_sb_info *sbi = SYSV_SB(sb);
 	int ptrs_bits = sbi->s_ind_per_block_bits;
 	unsigned long	indirect_blocks = sbi->s_ind_per_block,
@@ -91,7 +91,7 @@ static Indirect *get_branch(struct inode *inode,
 			    Indirect chain[],
 			    int *err)
 {
-	struct super_block *sb = inode->i_sb;
+	struct super_block *sb = inode_sb(inode);
 	Indirect *p = chain;
 	struct buffer_head *bh;
 
@@ -127,24 +127,25 @@ static int alloc_branch(struct inode *inode,
 			int *offsets,
 			Indirect *branch)
 {
-	int blocksize = inode->i_sb->s_blocksize;
+	int blocksize = inode_sb(inode)->s_blocksize;
 	int n = 0;
 	int i;
 
-	branch[0].key = sysv_new_block(inode->i_sb);
+	branch[0].key = sysv_new_block(inode_sb(inode));
 	if (branch[0].key) for (n = 1; n < num; n++) {
 		struct buffer_head *bh;
 		int parent;
 		/* Allocate the next block */
-		branch[n].key = sysv_new_block(inode->i_sb);
+		branch[n].key = sysv_new_block(inode_sb(inode));
 		if (!branch[n].key)
 			break;
 		/*
 		 * Get buffer_head for parent block, zero it out and set 
 		 * the pointer to new one, then send parent to disk.
 		 */
-		parent = block_to_cpu(SYSV_SB(inode->i_sb), branch[n-1].key);
-		bh = sb_getblk(inode->i_sb, parent);
+		parent = block_to_cpu(SYSV_SB(inode_sb(inode)),
+				      branch[n-1].key);
+		bh = sb_getblk(inode_sb(inode), parent);
 		lock_buffer(bh);
 		memset(bh->b_data, 0, blocksize);
 		branch[n].bh = bh;
@@ -161,7 +162,7 @@ static int alloc_branch(struct inode *inode,
 	for (i = 1; i < n; i++)
 		bforget(branch[i].bh);
 	for (i = 0; i < n; i++)
-		sysv_free_block(inode->i_sb, branch[i].key);
+		sysv_free_block(inode_sb(inode), branch[i].key);
 	return -ENOSPC;
 }
 
@@ -196,7 +197,7 @@ static inline int splice_branch(struct inode *inode,
 	for (i = 1; i < num; i++)
 		bforget(where[i].bh);
 	for (i = 0; i < num; i++)
-		sysv_free_block(inode->i_sb, where[i].key);
+		sysv_free_block(inode_sb(inode), where[i].key);
 	return -EAGAIN;
 }
 
@@ -205,7 +206,7 @@ static int get_block(struct inode *inode, sector_t iblock, struct buffer_head *b
 	int err = -EIO;
 	int offsets[DEPTH];
 	Indirect chain[DEPTH];
-	struct super_block *sb = inode->i_sb;
+	struct super_block *sb = inode_sb(inode);
 	Indirect *partial;
 	int left;
 	int depth = block_to_path(inode, iblock, offsets);
@@ -329,7 +330,7 @@ static inline void free_data(struct inode *inode, sysv_zone_t *p, sysv_zone_t *q
 		sysv_zone_t nr = *p;
 		if (nr) {
 			*p = 0;
-			sysv_free_block(inode->i_sb, nr);
+			sysv_free_block(inode_sb(inode), nr);
 			mark_inode_dirty(inode);
 		}
 	}
@@ -338,7 +339,7 @@ static inline void free_data(struct inode *inode, sysv_zone_t *p, sysv_zone_t *q
 static void free_branches(struct inode *inode, sysv_zone_t *p, sysv_zone_t *q, int depth)
 {
 	struct buffer_head * bh;
-	struct super_block *sb = inode->i_sb;
+	struct super_block *sb = inode_sb(inode);
 
 	if (depth--) {
 		for ( ; p < q ; p++) {
@@ -376,9 +377,9 @@ void sysv_truncate (struct inode * inode)
 	    S_ISLNK(inode->i_mode)))
 		return;
 
-	blocksize = inode->i_sb->s_blocksize;
+	blocksize = inode_sb(inode)->s_blocksize;
 	iblock = (inode->i_size + blocksize-1)
-					>> inode->i_sb->s_blocksize_bits;
+					>> inode_sb(inode)->s_blocksize_bits;
 
 	block_truncate_page(inode->i_mapping, inode->i_size, get_block);
 
fs/sysv/namei.c +2 -2
index 250b0755b908..31f0fa48e273 100644
@@ -53,7 +53,7 @@ static struct dentry *sysv_lookup(struct inode * dir, struct dentry * dentry, un
 	ino = sysv_inode_by_name(dentry);
 
 	if (ino) {
-		inode = sysv_iget(dir->i_sb, ino);
+		inode = sysv_iget(inode_sb(dir), ino);
 		if (IS_ERR(inode))
 			return ERR_CAST(inode);
 	}
@@ -92,7 +92,7 @@ static int sysv_symlink(struct inode * dir, struct dentry * dentry,
 	int l = strlen(symname)+1;
 	struct inode * inode;
 
-	if (l > dir->i_sb->s_blocksize)
+	if (l > inode_sb(dir)->s_blocksize)
 		goto out;
 
 	inode = sysv_new_inode(dir, S_IFLNK|0777);
Signature · 1 line
2.15.1
#70 lore raw

PATCH 69/76 fs/ubifs: Use inode_sb() helper instead of inode->i_sb

In reply to Mark Fasheh
---
 fs/ubifs/crypto.c |  4 ++--
 fs/ubifs/dir.c    | 30 +++++++++++++++---------------
 fs/ubifs/file.c   | 42 +++++++++++++++++++++---------------------
 fs/ubifs/ioctl.c  |  4 ++--
 fs/ubifs/super.c  |  4 ++--
 fs/ubifs/xattr.c  | 10 +++++-----
 6 files changed, 47 insertions(+), 47 deletions(-)
fs/ubifs/crypto.c +2 -2
index 616a688f5d8f..3c8122065ed5 100644
@@ -35,7 +35,7 @@ static unsigned int ubifs_crypt_max_namelen(struct inode *inode)
 int ubifs_encrypt(const struct inode *inode, struct ubifs_data_node *dn,
 		  unsigned int in_len, unsigned int *out_len, int block)
 {
-	struct ubifs_info *c = inode->i_sb->s_fs_info;
+	struct ubifs_info *c = inode_sb(inode)->s_fs_info;
 	void *p = &dn->data;
 	struct page *ret;
 	unsigned int pad_len = round_up(in_len, UBIFS_CIPHER_BLOCK_SIZE);
@@ -61,7 +61,7 @@ int ubifs_encrypt(const struct inode *inode, struct ubifs_data_node *dn,
 int ubifs_decrypt(const struct inode *inode, struct ubifs_data_node *dn,
 		  unsigned int *out_len, int block)
 {
-	struct ubifs_info *c = inode->i_sb->s_fs_info;
+	struct ubifs_info *c = inode_sb(inode)->s_fs_info;
 	int err;
 	unsigned int clen = le16_to_cpu(dn->compr_size);
 	unsigned int dlen = *out_len;
fs/ubifs/dir.c +15 -15
index 9d7fb88e172e..6d168f5cc8ff 100644
@@ -215,7 +215,7 @@ static struct dentry *ubifs_lookup(struct inode *dir, struct dentry *dentry,
 	union ubifs_key key;
 	struct inode *inode = NULL;
 	struct ubifs_dent_node *dent;
-	struct ubifs_info *c = dir->i_sb->s_fs_info;
+	struct ubifs_info *c = inode_sb(dir)->s_fs_info;
 	struct fscrypt_name nm;
 
 	dbg_gen("'%pd' in dir ino %lu", dentry, dir->i_ino);
@@ -262,7 +262,7 @@ static struct dentry *ubifs_lookup(struct inode *dir, struct dentry *dentry,
 		goto out_dent;
 	}
 
-	inode = ubifs_iget(dir->i_sb, le64_to_cpu(dent->inum));
+	inode = ubifs_iget(inode_sb(dir), le64_to_cpu(dent->inum));
 	if (IS_ERR(inode)) {
 		/*
 		 * This should not happen. Probably the file-system needs
@@ -307,7 +307,7 @@ static int ubifs_create(struct inode *dir, struct dentry *dentry, umode_t mode,
 			bool excl)
 {
 	struct inode *inode;
-	struct ubifs_info *c = dir->i_sb->s_fs_info;
+	struct ubifs_info *c = inode_sb(dir)->s_fs_info;
 	struct ubifs_budget_req req = { .new_ino = 1, .new_dent = 1,
 					.dirtied_ino = 1 };
 	struct ubifs_inode *dir_ui = ubifs_inode(dir);
@@ -376,7 +376,7 @@ static int do_tmpfile(struct inode *dir, struct dentry *dentry,
 		      umode_t mode, struct inode **whiteout)
 {
 	struct inode *inode;
-	struct ubifs_info *c = dir->i_sb->s_fs_info;
+	struct ubifs_info *c = inode_sb(dir)->s_fs_info;
 	struct ubifs_budget_req req = { .new_ino = 1, .new_dent = 1};
 	struct ubifs_budget_req ino_req = { .dirtied_ino = 1 };
 	struct ubifs_inode *ui, *dir_ui = ubifs_inode(dir);
@@ -525,7 +525,7 @@ static int ubifs_readdir(struct file *file, struct dir_context *ctx)
 	union ubifs_key key;
 	struct ubifs_dent_node *dent;
 	struct inode *dir = file_inode(file);
-	struct ubifs_info *c = dir->i_sb->s_fs_info;
+	struct ubifs_info *c = inode_sb(dir)->s_fs_info;
 	bool encrypted = ubifs_crypt_is_encrypted(dir);
 
 	dbg_gen("dir ino %lu, f_pos %#llx", dir->i_ino, ctx->pos);
@@ -712,7 +712,7 @@ static void unlock_2_inodes(struct inode *inode1, struct inode *inode2)
 static int ubifs_link(struct dentry *old_dentry, struct inode *dir,
 		      struct dentry *dentry)
 {
-	struct ubifs_info *c = dir->i_sb->s_fs_info;
+	struct ubifs_info *c = inode_sb(dir)->s_fs_info;
 	struct inode *inode = d_inode(old_dentry);
 	struct ubifs_inode *ui = ubifs_inode(inode);
 	struct ubifs_inode *dir_ui = ubifs_inode(dir);
@@ -786,7 +786,7 @@ static int ubifs_link(struct dentry *old_dentry, struct inode *dir,
 
 static int ubifs_unlink(struct inode *dir, struct dentry *dentry)
 {
-	struct ubifs_info *c = dir->i_sb->s_fs_info;
+	struct ubifs_info *c = inode_sb(dir)->s_fs_info;
 	struct inode *inode = d_inode(dentry);
 	struct ubifs_inode *dir_ui = ubifs_inode(dir);
 	int err, sz_change, budgeted = 1;
@@ -873,7 +873,7 @@ static int ubifs_unlink(struct inode *dir, struct dentry *dentry)
  */
 int ubifs_check_dir_empty(struct inode *dir)
 {
-	struct ubifs_info *c = dir->i_sb->s_fs_info;
+	struct ubifs_info *c = inode_sb(dir)->s_fs_info;
 	struct fscrypt_name nm = { 0 };
 	struct ubifs_dent_node *dent;
 	union ubifs_key key;
@@ -894,7 +894,7 @@ int ubifs_check_dir_empty(struct inode *dir)
 
 static int ubifs_rmdir(struct inode *dir, struct dentry *dentry)
 {
-	struct ubifs_info *c = dir->i_sb->s_fs_info;
+	struct ubifs_info *c = inode_sb(dir)->s_fs_info;
 	struct inode *inode = d_inode(dentry);
 	int err, sz_change, budgeted = 1;
 	struct ubifs_inode *dir_ui = ubifs_inode(dir);
@@ -973,7 +973,7 @@ static int ubifs_mkdir(struct inode *dir, struct dentry *dentry, umode_t mode)
 {
 	struct inode *inode;
 	struct ubifs_inode *dir_ui = ubifs_inode(dir);
-	struct ubifs_info *c = dir->i_sb->s_fs_info;
+	struct ubifs_info *c = inode_sb(dir)->s_fs_info;
 	int err, sz_change;
 	struct ubifs_budget_req req = { .new_ino = 1, .new_dent = 1 };
 	struct fscrypt_name nm;
@@ -1046,7 +1046,7 @@ static int ubifs_mknod(struct inode *dir, struct dentry *dentry,
 	struct inode *inode;
 	struct ubifs_inode *ui;
 	struct ubifs_inode *dir_ui = ubifs_inode(dir);
-	struct ubifs_info *c = dir->i_sb->s_fs_info;
+	struct ubifs_info *c = inode_sb(dir)->s_fs_info;
 	union ubifs_dev_desc *dev = NULL;
 	int sz_change;
 	int err, devlen = 0;
@@ -1135,7 +1135,7 @@ static int ubifs_symlink(struct inode *dir, struct dentry *dentry,
 	struct inode *inode;
 	struct ubifs_inode *ui;
 	struct ubifs_inode *dir_ui = ubifs_inode(dir);
-	struct ubifs_info *c = dir->i_sb->s_fs_info;
+	struct ubifs_info *c = inode_sb(dir)->s_fs_info;
 	int err, len = strlen(symname);
 	int sz_change = CALC_DENT_SIZE(len);
 	struct fscrypt_str disk_link;
@@ -1276,7 +1276,7 @@ static int do_rename(struct inode *old_dir, struct dentry *old_dentry,
 		     struct inode *new_dir, struct dentry *new_dentry,
 		     unsigned int flags)
 {
-	struct ubifs_info *c = old_dir->i_sb->s_fs_info;
+	struct ubifs_info *c = inode_sb(old_dir)->s_fs_info;
 	struct inode *old_inode = d_inode(old_dentry);
 	struct inode *new_inode = d_inode(new_dentry);
 	struct inode *whiteout = NULL;
@@ -1470,7 +1470,7 @@ static int do_rename(struct inode *old_dir, struct dentry *old_dentry,
 	if (release)
 		ubifs_release_budget(c, &ino_req);
 	if (IS_SYNC(old_inode))
-		err = old_inode->i_sb->s_op->write_inode(old_inode, NULL);
+		err = inode_sb(old_inode)->s_op->write_inode(old_inode, NULL);
 
 	fscrypt_free_filename(&old_nm);
 	fscrypt_free_filename(&new_nm);
@@ -1511,7 +1511,7 @@ static int do_rename(struct inode *old_dir, struct dentry *old_dentry,
 static int ubifs_xrename(struct inode *old_dir, struct dentry *old_dentry,
 			struct inode *new_dir, struct dentry *new_dentry)
 {
-	struct ubifs_info *c = old_dir->i_sb->s_fs_info;
+	struct ubifs_info *c = inode_sb(old_dir)->s_fs_info;
 	struct ubifs_budget_req req = { .new_dent = 1, .mod_dent = 1,
 				.dirtied_ino = 2 };
 	int sync = IS_DIRSYNC(old_dir) || IS_DIRSYNC(new_dir);
fs/ubifs/file.c +21 -21

160 lines not on this page · raw message

fs/ubifs/ioctl.c +2 -2
index 0164bcc827f8..78859adf6302 100644
@@ -106,7 +106,7 @@ static int setflags(struct inode *inode, int flags)
 {
 	int oldflags, err, release;
 	struct ubifs_inode *ui = ubifs_inode(inode);
-	struct ubifs_info *c = inode->i_sb->s_fs_info;
+	struct ubifs_info *c = inode_sb(inode)->s_fs_info;
 	struct ubifs_budget_req req = { .dirtied_ino = 1,
 					.dirtied_ino_d = ui->data_len };
 
@@ -186,7 +186,7 @@ long ubifs_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
 	}
 	case FS_IOC_SET_ENCRYPTION_POLICY: {
 #ifdef CONFIG_UBIFS_FS_ENCRYPTION
-		struct ubifs_info *c = inode->i_sb->s_fs_info;
+		struct ubifs_info *c = inode_sb(inode)->s_fs_info;
 
 		err = ubifs_enable_encryption(c);
 		if (err)
fs/ubifs/super.c +2 -2
index b16ef162344a..6568653ee596 100644
@@ -293,7 +293,7 @@ static void ubifs_destroy_inode(struct inode *inode)
 static int ubifs_write_inode(struct inode *inode, struct writeback_control *wbc)
 {
 	int err = 0;
-	struct ubifs_info *c = inode->i_sb->s_fs_info;
+	struct ubifs_info *c = inode_sb(inode)->s_fs_info;
 	struct ubifs_inode *ui = ubifs_inode(inode);
 
 	ubifs_assert(!ui->xattr);
@@ -337,7 +337,7 @@ static int ubifs_write_inode(struct inode *inode, struct writeback_control *wbc)
 static void ubifs_evict_inode(struct inode *inode)
 {
 	int err;
-	struct ubifs_info *c = inode->i_sb->s_fs_info;
+	struct ubifs_info *c = inode_sb(inode)->s_fs_info;
 	struct ubifs_inode *ui = ubifs_inode(inode);
 
 	if (ui->xattr)
fs/ubifs/xattr.c +5 -5
index 759f1a209dbb..2e2de2f3f290 100644
@@ -284,7 +284,7 @@ int ubifs_xattr_set(struct inode *host, const char *name, const void *value,
 		    size_t size, int flags, bool check_lock)
 {
 	struct inode *inode;
-	struct ubifs_info *c = host->i_sb->s_fs_info;
+	struct ubifs_info *c = inode_sb(host)->s_fs_info;
 	struct fscrypt_name nm = { .disk_name = FSTR_INIT((char *)name, strlen(name))};
 	struct ubifs_dent_node *xent;
 	union ubifs_key key;
@@ -345,7 +345,7 @@ ssize_t ubifs_xattr_get(struct inode *host, const char *name, void *buf,
 			size_t size)
 {
 	struct inode *inode;
-	struct ubifs_info *c = host->i_sb->s_fs_info;
+	struct ubifs_info *c = inode_sb(host)->s_fs_info;
 	struct fscrypt_name nm = { .disk_name = FSTR_INIT((char *)name, strlen(name))};
 	struct ubifs_inode *ui;
 	struct ubifs_dent_node *xent;
@@ -415,7 +415,7 @@ ssize_t ubifs_listxattr(struct dentry *dentry, char *buffer, size_t size)
 {
 	union ubifs_key key;
 	struct inode *host = d_inode(dentry);
-	struct ubifs_info *c = host->i_sb->s_fs_info;
+	struct ubifs_info *c = inode_sb(host)->s_fs_info;
 	struct ubifs_inode *host_ui = ubifs_inode(host);
 	struct ubifs_dent_node *xent, *pxent = NULL;
 	int err, len, written = 0;
@@ -532,7 +532,7 @@ void ubifs_evict_xattr_inode(struct ubifs_info *c, ino_t xattr_inum)
 static int ubifs_xattr_remove(struct inode *host, const char *name)
 {
 	struct inode *inode;
-	struct ubifs_info *c = host->i_sb->s_fs_info;
+	struct ubifs_info *c = inode_sb(host)->s_fs_info;
 	struct fscrypt_name nm = { .disk_name = FSTR_INIT((char *)name, strlen(name))};
 	struct ubifs_dent_node *xent;
 	union ubifs_key key;
@@ -614,7 +614,7 @@ int ubifs_init_security(struct inode *dentry, struct inode *inode,
 	err = security_inode_init_security(inode, dentry, qstr,
 					   &init_xattrs, 0);
 	if (err) {
-		struct ubifs_info *c = dentry->i_sb->s_fs_info;
+		struct ubifs_info *c = inode_sb(dentry)->s_fs_info;
 		ubifs_err(c, "cannot initialize security for inode %lu, error %d",
 			  inode->i_ino, err);
 	}
Signature · 1 line
2.15.1
#71 lore raw

PATCH 70/76 fs/udf: Use inode_sb() helper instead of inode->i_sb

In reply to Mark Fasheh
---
 fs/udf/dir.c       |   2 +-
 fs/udf/directory.c |  30 ++++----
 fs/udf/file.c      |   6 +-
 fs/udf/ialloc.c    |  24 +++---
 fs/udf/inode.c     | 209 +++++++++++++++++++++++++++--------------------------
 fs/udf/misc.c      |   4 +-
 fs/udf/namei.c     |  76 ++++++++++---------
 fs/udf/partition.c |   2 +-
 fs/udf/super.c     |   2 +-
 fs/udf/symlink.c   |   7 +-
 fs/udf/truncate.c  |  26 +++----
 11 files changed, 199 insertions(+), 189 deletions(-)
fs/udf/dir.c +1 -1
index c19dba45aa20..ef5b632da782 100644
@@ -57,7 +57,7 @@ static int udf_readdir(struct file *file, struct dir_context *ctx)
 	sector_t offset;
 	int i, num, ret = 0;
 	struct extent_position epos = { NULL, 0, {0, 0} };
-	struct super_block *sb = dir->i_sb;
+	struct super_block *sb = inode_sb(dir);
 
 	if (ctx->pos == 0) {
 		if (!dir_emit_dot(file, ctx))
fs/udf/directory.c +15 -15
index 0a98a2369738..d5d490eaba6c 100644
@@ -38,7 +38,7 @@ struct fileIdentDesc *udf_fileident_read(struct inode *dir, loff_t *nf_pos,
 				       (iinfo->i_efe ?
 					sizeof(struct extendedFileEntry) :
 					sizeof(struct fileEntry)),
-				       dir->i_sb->s_blocksize,
+				       inode_sb(dir)->s_blocksize,
 				       &(fibh->eoffset));
 		if (!fi)
 			return NULL;
@@ -51,15 +51,15 @@ struct fileIdentDesc *udf_fileident_read(struct inode *dir, loff_t *nf_pos,
 		return fi;
 	}
 
-	if (fibh->eoffset == dir->i_sb->s_blocksize) {
+	if (fibh->eoffset == inode_sb(dir)->s_blocksize) {
 		uint32_t lextoffset = epos->offset;
-		unsigned char blocksize_bits = dir->i_sb->s_blocksize_bits;
+		unsigned char blocksize_bits = inode_sb(dir)->s_blocksize_bits;
 
 		if (udf_next_aext(dir, epos, eloc, elen, 1) !=
 		    (EXT_RECORDED_ALLOCATED >> 30))
 			return NULL;
 
-		block = udf_get_lb_pblock(dir->i_sb, eloc, *offset);
+		block = udf_get_lb_pblock(inode_sb(dir), eloc, *offset);
 
 		(*offset)++;
 
@@ -69,7 +69,7 @@ struct fileIdentDesc *udf_fileident_read(struct inode *dir, loff_t *nf_pos,
 			epos->offset = lextoffset;
 
 		brelse(fibh->sbh);
-		fibh->sbh = fibh->ebh = udf_tread(dir->i_sb, block);
+		fibh->sbh = fibh->ebh = udf_tread(inode_sb(dir), block);
 		if (!fibh->sbh)
 			return NULL;
 		fibh->soffset = fibh->eoffset = 0;
@@ -79,9 +79,9 @@ struct fileIdentDesc *udf_fileident_read(struct inode *dir, loff_t *nf_pos,
 			if (i + *offset > (*elen >> blocksize_bits))
 				i = (*elen >> blocksize_bits)-*offset;
 			for (num = 0; i > 0; i--) {
-				block = udf_get_lb_pblock(dir->i_sb, eloc,
+				block = udf_get_lb_pblock(inode_sb(dir), eloc,
 							  *offset + i);
-				tmp = udf_tgetblk(dir->i_sb, block);
+				tmp = udf_tgetblk(inode_sb(dir), block);
 				if (tmp && !buffer_uptodate(tmp) &&
 						!buffer_locked(tmp))
 					bha[num++] = tmp;
@@ -99,7 +99,7 @@ struct fileIdentDesc *udf_fileident_read(struct inode *dir, loff_t *nf_pos,
 		fibh->sbh = fibh->ebh;
 	}
 
-	fi = udf_get_fileident(fibh->sbh->b_data, dir->i_sb->s_blocksize,
+	fi = udf_get_fileident(fibh->sbh->b_data, inode_sb(dir)->s_blocksize,
 			       &(fibh->eoffset));
 
 	if (!fi)
@@ -107,29 +107,29 @@ struct fileIdentDesc *udf_fileident_read(struct inode *dir, loff_t *nf_pos,
 
 	*nf_pos += fibh->eoffset - fibh->soffset;
 
-	if (fibh->eoffset <= dir->i_sb->s_blocksize) {
+	if (fibh->eoffset <= inode_sb(dir)->s_blocksize) {
 		memcpy((uint8_t *)cfi, (uint8_t *)fi,
 		       sizeof(struct fileIdentDesc));
-	} else if (fibh->eoffset > dir->i_sb->s_blocksize) {
+	} else if (fibh->eoffset > inode_sb(dir)->s_blocksize) {
 		uint32_t lextoffset = epos->offset;
 
 		if (udf_next_aext(dir, epos, eloc, elen, 1) !=
 		    (EXT_RECORDED_ALLOCATED >> 30))
 			return NULL;
 
-		block = udf_get_lb_pblock(dir->i_sb, eloc, *offset);
+		block = udf_get_lb_pblock(inode_sb(dir), eloc, *offset);
 
 		(*offset)++;
 
-		if ((*offset << dir->i_sb->s_blocksize_bits) >= *elen)
+		if ((*offset << inode_sb(dir)->s_blocksize_bits) >= *elen)
 			*offset = 0;
 		else
 			epos->offset = lextoffset;
 
-		fibh->soffset -= dir->i_sb->s_blocksize;
-		fibh->eoffset -= dir->i_sb->s_blocksize;
+		fibh->soffset -= inode_sb(dir)->s_blocksize;
+		fibh->eoffset -= inode_sb(dir)->s_blocksize;
 
-		fibh->ebh = udf_tread(dir->i_sb, block);
+		fibh->ebh = udf_tread(inode_sb(dir), block);
 		if (!fibh->ebh)
 			return NULL;
 
fs/udf/file.c +3 -3
index 356c2bf148a5..d28bb49a2d87 100644
@@ -151,7 +151,7 @@ static ssize_t udf_file_write_iter(struct kiocb *iocb, struct iov_iter *from)
 	if (iinfo->i_alloc_type == ICBTAG_FLAG_AD_IN_ICB) {
 		loff_t end = iocb->ki_pos + iov_iter_count(from);
 
-		if (inode->i_sb->s_blocksize <
+		if (inode_sb(inode)->s_blocksize <
 				(udf_file_entry_alloc_offset(inode) + end)) {
 			err = udf_expand_file_adinicb(inode);
 			if (err) {
@@ -198,7 +198,7 @@ long udf_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
 	switch (cmd) {
 	case UDF_GETVOLIDENT:
 		if (copy_to_user((char __user *)arg,
-				 UDF_SB(inode->i_sb)->s_volume_ident, 32))
+				 UDF_SB(inode_sb(inode))->s_volume_ident, 32))
 			return -EFAULT;
 		return 0;
 	case UDF_RELOCATE_BLOCKS:
@@ -206,7 +206,7 @@ long udf_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
 			return -EPERM;
 		if (get_user(old_block, (long __user *)arg))
 			return -EFAULT;
-		result = udf_relocate_blocks(inode->i_sb,
+		result = udf_relocate_blocks(inode_sb(inode),
 						old_block, &new_block);
 		if (result == 0)
 			result = put_user(new_block, (long __user *)arg);
fs/udf/ialloc.c +12 -12
index b6e420c1bfeb..eb37faceb405 100644
@@ -28,7 +28,7 @@
 
 void udf_free_inode(struct inode *inode)
 {
-	struct super_block *sb = inode->i_sb;
+	struct super_block *sb = inode_sb(inode);
 	struct udf_sb_info *sbi = UDF_SB(sb);
 	struct logicalVolIntegrityDescImpUse *lvidiu = udf_sb_lvidiu(sb);
 
@@ -47,7 +47,7 @@ void udf_free_inode(struct inode *inode)
 
 struct inode *udf_new_inode(struct inode *dir, umode_t mode)
 {
-	struct super_block *sb = dir->i_sb;
+	struct super_block *sb = inode_sb(dir);
 	struct udf_sb_info *sbi = UDF_SB(sb);
 	struct inode *inode;
 	udf_pblk_t block;
@@ -63,18 +63,18 @@ struct inode *udf_new_inode(struct inode *dir, umode_t mode)
 		return ERR_PTR(-ENOMEM);
 
 	iinfo = UDF_I(inode);
-	if (UDF_QUERY_FLAG(inode->i_sb, UDF_FLAG_USE_EXTENDED_FE)) {
+	if (UDF_QUERY_FLAG(inode_sb(inode), UDF_FLAG_USE_EXTENDED_FE)) {
 		iinfo->i_efe = 1;
 		if (UDF_VERS_USE_EXTENDED_FE > sbi->s_udfrev)
 			sbi->s_udfrev = UDF_VERS_USE_EXTENDED_FE;
-		iinfo->i_ext.i_data = kzalloc(inode->i_sb->s_blocksize -
-					    sizeof(struct extendedFileEntry),
-					    GFP_KERNEL);
+		iinfo->i_ext.i_data = kzalloc(inode_sb(inode)->s_blocksize -
+					      sizeof(struct extendedFileEntry),
+					      GFP_KERNEL);
 	} else {
 		iinfo->i_efe = 0;
-		iinfo->i_ext.i_data = kzalloc(inode->i_sb->s_blocksize -
-					    sizeof(struct fileEntry),
-					    GFP_KERNEL);
+		iinfo->i_ext.i_data = kzalloc(inode_sb(inode)->s_blocksize -
+					      sizeof(struct fileEntry),
+					      GFP_KERNEL);
 	}
 	if (!iinfo->i_ext.i_data) {
 		iput(inode);
@@ -82,7 +82,7 @@ struct inode *udf_new_inode(struct inode *dir, umode_t mode)
 	}
 
 	err = -ENOSPC;
-	block = udf_new_block(dir->i_sb, NULL,
+	block = udf_new_block(inode_sb(dir), NULL,
 			      dinfo->i_location.partitionReferenceNum,
 			      start, &err);
 	if (err) {
@@ -114,9 +114,9 @@ struct inode *udf_new_inode(struct inode *dir, umode_t mode)
 	iinfo->i_lenAlloc = 0;
 	iinfo->i_use = 0;
 	iinfo->i_checkpoint = 1;
-	if (UDF_QUERY_FLAG(inode->i_sb, UDF_FLAG_USE_AD_IN_ICB))
+	if (UDF_QUERY_FLAG(inode_sb(inode), UDF_FLAG_USE_AD_IN_ICB))
 		iinfo->i_alloc_type = ICBTAG_FLAG_AD_IN_ICB;
-	else if (UDF_QUERY_FLAG(inode->i_sb, UDF_FLAG_USE_SHORT_AD))
+	else if (UDF_QUERY_FLAG(inode_sb(inode), UDF_FLAG_USE_SHORT_AD))
 		iinfo->i_alloc_type = ICBTAG_FLAG_AD_SHORT;
 	else
 		iinfo->i_alloc_type = ICBTAG_FLAG_AD_LONG;
fs/udf/inode.c +107 -102

603 lines not on this page · raw message

fs/udf/misc.c +2 -2
index 401e64cde1be..9aaae9329f27 100644
@@ -60,7 +60,7 @@ struct genericFormat *udf_add_extendedattr(struct inode *inode, uint32_t size,
 		size += sizeof(struct extendedAttrHeaderDesc);
 	}
 
-	offset = inode->i_sb->s_blocksize - udf_file_entry_alloc_offset(inode) -
+	offset = inode_sb(inode)->s_blocksize - udf_file_entry_alloc_offset(inode) -
 		iinfo->i_lenAlloc;
 
 	/* TODO - Check for FreeEASpace */
@@ -80,7 +80,7 @@ struct genericFormat *udf_add_extendedattr(struct inode *inode, uint32_t size,
 					iinfo->i_location.logicalBlockNum)
 				return NULL;
 		} else {
-			struct udf_sb_info *sbi = UDF_SB(inode->i_sb);
+			struct udf_sb_info *sbi = UDF_SB(inode_sb(inode));
 
 			size -= sizeof(struct extendedAttrHeaderDesc);
 			iinfo->i_lenEAttr +=
fs/udf/namei.c +40 -36

230 lines not on this page · raw message

fs/udf/partition.c +1 -1
index 090baff83990..ed7e8a9503da 100644
@@ -280,7 +280,7 @@ int udf_relocate_blocks(struct super_block *sb, long old_block, long *new_block)
 static uint32_t udf_try_read_meta(struct inode *inode, uint32_t block,
 					uint16_t partition, uint32_t offset)
 {
-	struct super_block *sb = inode->i_sb;
+	struct super_block *sb = inode_sb(inode);
 	struct udf_part_map *map;
 	struct kernel_lb_addr eloc;
 	uint32_t elen;
fs/udf/super.c +1 -1
index f73239a9a97d..41f42951126a 100644
@@ -2451,7 +2451,7 @@ static unsigned int udf_count_free_table(struct super_block *sb,
 	epos.bh = NULL;
 
 	while ((etype = udf_next_aext(table, &epos, &eloc, &elen, 1)) != -1)
-		accum += (elen >> table->i_sb->s_blocksize_bits);
+		accum += (elen >> inode_sb(table)->s_blocksize_bits);
 
 	brelse(epos.bh);
 	mutex_unlock(&UDF_SB(sb)->s_alloc_mutex);
fs/udf/symlink.c +4 -3
index 6023c97c6da2..22b521053b5d 100644
@@ -112,7 +112,7 @@ static int udf_symlink_filler(struct file *file, struct page *page)
 	uint32_t pos;
 
 	/* We don't support symlinks longer than one block */
-	if (inode->i_size > inode->i_sb->s_blocksize) {
+	if (inode->i_size > inode_sb(inode)->s_blocksize) {
 		err = -ENAMETOOLONG;
 		goto out_unmap;
 	}
@@ -124,7 +124,7 @@ static int udf_symlink_filler(struct file *file, struct page *page)
 	if (iinfo->i_alloc_type == ICBTAG_FLAG_AD_IN_ICB) {
 		symlink = iinfo->i_ext.i_data + iinfo->i_lenEAttr;
 	} else {
-		bh = sb_bread(inode->i_sb, pos);
+		bh = sb_bread(inode_sb(inode), pos);
 
 		if (!bh) {
 			err = -EIO;
@@ -134,7 +134,8 @@ static int udf_symlink_filler(struct file *file, struct page *page)
 		symlink = bh->b_data;
 	}
 
-	err = udf_pc_to_char(inode->i_sb, symlink, inode->i_size, p, PAGE_SIZE);
+	err = udf_pc_to_char(inode_sb(inode), symlink, inode->i_size, p,
+			     PAGE_SIZE);
 	brelse(bh);
 	if (err)
 		goto out_unlock_inode;
fs/udf/truncate.c +13 -13
index b647f0bd150c..cbb31c433908 100644
@@ -31,14 +31,14 @@ static void extent_trunc(struct inode *inode, struct extent_position *epos,
 			 uint32_t nelen)
 {
 	struct kernel_lb_addr neloc = {};
-	int last_block = (elen + inode->i_sb->s_blocksize - 1) >>
-		inode->i_sb->s_blocksize_bits;
-	int first_block = (nelen + inode->i_sb->s_blocksize - 1) >>
-		inode->i_sb->s_blocksize_bits;
+	int last_block = (elen + inode_sb(inode)->s_blocksize - 1) >>
+		inode_sb(inode)->s_blocksize_bits;
+	int first_block = (nelen + inode_sb(inode)->s_blocksize - 1) >>
+		inode_sb(inode)->s_blocksize_bits;
 
 	if (nelen) {
 		if (etype == (EXT_NOT_RECORDED_ALLOCATED >> 30)) {
-			udf_free_blocks(inode->i_sb, inode, eloc, 0,
+			udf_free_blocks(inode_sb(inode), inode, eloc, 0,
 					last_block);
 			etype = (EXT_NOT_RECORDED_NOT_ALLOCATED >> 30);
 		} else
@@ -53,7 +53,7 @@ static void extent_trunc(struct inode *inode, struct extent_position *epos,
 				mark_inode_dirty(inode);
 
 			if (etype != (EXT_NOT_RECORDED_NOT_ALLOCATED >> 30))
-				udf_free_blocks(inode->i_sb, inode, eloc,
+				udf_free_blocks(inode_sb(inode), inode, eloc,
 						first_block,
 						last_block - first_block);
 		}
@@ -93,8 +93,8 @@ void udf_truncate_tail_extent(struct inode *inode)
 		etype = netype;
 		lbcount += elen;
 		if (lbcount > inode->i_size) {
-			if (lbcount - inode->i_size >= inode->i_sb->s_blocksize)
-				udf_warn(inode->i_sb,
+			if (lbcount - inode->i_size >= inode_sb(inode)->s_blocksize)
+				udf_warn(inode_sb(inode),
 					 "Too long extent after EOF in inode %u: i_size: %lld lbcount: %lld extent %u+%u\n",
 					 (unsigned)inode->i_ino,
 					 (long long)inode->i_size,
@@ -106,7 +106,7 @@ void udf_truncate_tail_extent(struct inode *inode)
 			extent_trunc(inode, &epos, &eloc, etype, elen, nelen);
 			epos.offset += adsize;
 			if (udf_next_aext(inode, &epos, &eloc, &elen, 1) != -1)
-				udf_err(inode->i_sb,
+				udf_err(inode_sb(inode),
 					"Extent after EOF in inode %u\n",
 					(unsigned)inode->i_ino);
 			break;
@@ -161,8 +161,8 @@ void udf_discard_prealloc(struct inode *inode)
 			aed->lengthAllocDescs =
 				cpu_to_le32(epos.offset -
 					    sizeof(struct allocExtDesc));
-			if (!UDF_QUERY_FLAG(inode->i_sb, UDF_FLAG_STRICT) ||
-			    UDF_SB(inode->i_sb)->s_udfrev >= 0x0201)
+			if (!UDF_QUERY_FLAG(inode_sb(inode), UDF_FLAG_STRICT) ||
+			    UDF_SB(inode_sb(inode))->s_udfrev >= 0x0201)
 				udf_update_tag(epos.bh->b_data, epos.offset);
 			else
 				udf_update_tag(epos.bh->b_data,
@@ -180,7 +180,7 @@ static void udf_update_alloc_ext_desc(struct inode *inode,
 				      struct extent_position *epos,
 				      u32 lenalloc)
 {
-	struct super_block *sb = inode->i_sb;
+	struct super_block *sb = inode_sb(inode);
 	struct udf_sb_info *sbi = UDF_SB(sb);
 
 	struct allocExtDesc *aed = (struct allocExtDesc *) (epos->bh->b_data);
@@ -205,7 +205,7 @@ void udf_truncate_extents(struct inode *inode)
 	struct kernel_lb_addr eloc, neloc = {};
 	uint32_t elen, nelen = 0, indirect_ext_len = 0, lenalloc;
 	int8_t etype;
-	struct super_block *sb = inode->i_sb;
+	struct super_block *sb = inode_sb(inode);
 	sector_t first_block = inode->i_size >> sb->s_blocksize_bits, offset;
 	loff_t byte_offset;
 	int adsize;
Signature · 1 line
2.15.1
#72 lore raw

PATCH 71/76 fs/ufs: Use inode_sb() helper instead of inode->i_sb

In reply to Mark Fasheh
---
 fs/ufs/balloc.c | 23 ++++++++++++-----------
 fs/ufs/dir.c    | 34 +++++++++++++++++-----------------
 fs/ufs/ialloc.c |  4 ++--
 fs/ufs/inode.c  | 37 +++++++++++++++++++------------------
 fs/ufs/namei.c  |  6 +++---
 5 files changed, 53 insertions(+), 51 deletions(-)
fs/ufs/balloc.c +12 -11
index e727ee07dbe4..b6053d9c0e64 100644
@@ -45,7 +45,7 @@ void ufs_free_fragments(struct inode *inode, u64 fragment, unsigned count)
 	unsigned cgno, bit, end_bit, bbase, blkmap, i;
 	u64 blkno;
 	
-	sb = inode->i_sb;
+	sb = inode_sb(inode);
 	uspi = UFS_SB(sb)->s_uspi;
 	
 	UFSD("ENTER, fragment %llu, count %u\n",
@@ -141,7 +141,7 @@ void ufs_free_blocks(struct inode *inode, u64 fragment, unsigned count)
 	unsigned overflow, cgno, bit, end_bit, i;
 	u64 blkno;
 	
-	sb = inode->i_sb;
+	sb = inode_sb(inode);
 	uspi = UFS_SB(sb)->s_uspi;
 
 	UFSD("ENTER, fragment %llu, count %u\n",
@@ -268,7 +268,7 @@ static void ufs_change_blocknr(struct inode *inode, sector_t beg,
 			if (!page)/* it was truncated */
 				continue;
 			if (IS_ERR(page)) {/* or EIO */
-				ufs_error(inode->i_sb, __func__,
+				ufs_error(inode_sb(inode), __func__,
 					  "read of page %llu failed\n",
 					  (unsigned long long)index);
 				continue;
@@ -294,12 +294,13 @@ static void ufs_change_blocknr(struct inode *inode, sector_t beg,
 			pos = (i - beg) + j;
 
 			if (!buffer_mapped(bh))
-					map_bh(bh, inode->i_sb, oldb + pos);
+					map_bh(bh, inode_sb(inode),
+					       oldb + pos);
 			if (!buffer_uptodate(bh)) {
 				ll_rw_block(REQ_OP_READ, 0, 1, &bh);
 				wait_on_buffer(bh);
 				if (!buffer_uptodate(bh)) {
-					ufs_error(inode->i_sb, __func__,
+					ufs_error(inode_sb(inode), __func__,
 						  "read of block failed\n");
 					break;
 				}
@@ -329,9 +330,9 @@ static void ufs_clear_frags(struct inode *inode, sector_t beg, unsigned int n,
 	sector_t end = beg + n;
 
 	for (; beg < end; ++beg) {
-		bh = sb_getblk(inode->i_sb, beg);
+		bh = sb_getblk(inode_sb(inode), beg);
 		lock_buffer(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);
 		mark_buffer_dirty(bh);
 		unlock_buffer(bh);
@@ -355,7 +356,7 @@ u64 ufs_new_fragments(struct inode *inode, void *p, u64 fragment,
 	     inode->i_ino, (unsigned long long)fragment,
 	     (unsigned long long)goal, count);
 	
-	sb = inode->i_sb;
+	sb = inode_sb(inode);
 	uspi = UFS_SB(sb)->s_uspi;
 	usb1 = ubh_get_usb_first(uspi);
 	*err = -ENOSPC;
@@ -517,7 +518,7 @@ static u64 ufs_add_fragments(struct inode *inode, u64 fragment,
 	UFSD("ENTER, fragment %llu, oldcount %u, newcount %u\n",
 	     (unsigned long long)fragment, oldcount, newcount);
 	
-	sb = inode->i_sb;
+	sb = inode_sb(inode);
 	uspi = UFS_SB(sb)->s_uspi;
 	count = newcount - oldcount;
 	
@@ -597,7 +598,7 @@ static u64 ufs_alloc_fragments(struct inode *inode, unsigned cgno,
 	UFSD("ENTER, ino %lu, cgno %u, goal %llu, count %u\n",
 	     inode->i_ino, cgno, (unsigned long long)goal, count);
 
-	sb = inode->i_sb;
+	sb = inode_sb(inode);
 	uspi = UFS_SB(sb)->s_uspi;
 	oldcg = cgno;
 	
@@ -708,7 +709,7 @@ static u64 ufs_alloccg_block(struct inode *inode,
 
 	UFSD("ENTER, goal %llu\n", (unsigned long long)goal);
 
-	sb = inode->i_sb;
+	sb = inode_sb(inode);
 	uspi = UFS_SB(sb)->s_uspi;
 	ucg = ubh_get_ucg(UCPI_UBH(ucpi));
 
fs/ufs/dir.c +17 -17
index b721d0bda5e5..ebe0ddc8b708 100644
@@ -75,7 +75,7 @@ ino_t ufs_inode_by_name(struct inode *dir, const struct qstr *qstr)
 	
 	de = ufs_find_entry(dir, qstr, &page);
 	if (de) {
-		res = fs32_to_cpu(dir->i_sb, de->d_ino);
+		res = fs32_to_cpu(inode_sb(dir), de->d_ino);
 		ufs_put_page(page);
 	}
 	return res;
@@ -89,15 +89,15 @@ void ufs_set_link(struct inode *dir, struct ufs_dir_entry *de,
 {
 	loff_t pos = page_offset(page) +
 			(char *) de - (char *) page_address(page);
-	unsigned len = fs16_to_cpu(dir->i_sb, de->d_reclen);
+	unsigned len = fs16_to_cpu(inode_sb(dir), de->d_reclen);
 	int err;
 
 	lock_page(page);
 	err = ufs_prepare_chunk(page, pos, len);
 	BUG_ON(err);
 
-	de->d_ino = cpu_to_fs32(dir->i_sb, inode->i_ino);
-	ufs_set_de_type(dir->i_sb, de, inode->i_mode);
+	de->d_ino = cpu_to_fs32(inode_sb(dir), inode->i_ino);
+	ufs_set_de_type(inode_sb(dir), de, inode->i_mode);
 
 	err = ufs_commit_chunk(page, pos, len);
 	ufs_put_page(page);
@@ -110,7 +110,7 @@ void ufs_set_link(struct inode *dir, struct ufs_dir_entry *de,
 static bool ufs_check_page(struct page *page)
 {
 	struct inode *dir = page->mapping->host;
-	struct super_block *sb = dir->i_sb;
+	struct super_block *sb = inode_sb(dir);
 	char *kaddr = page_address(page);
 	unsigned offs, rec_len;
 	unsigned limit = PAGE_SIZE;
@@ -232,7 +232,7 @@ struct ufs_dir_entry *ufs_dotdot(struct inode *dir, struct page **p)
 	struct ufs_dir_entry *de = NULL;
 
 	if (!IS_ERR(page)) {
-		de = ufs_next_entry(dir->i_sb,
+		de = ufs_next_entry(inode_sb(dir),
 				    (struct ufs_dir_entry *)page_address(page));
 		*p = page;
 	}
@@ -250,7 +250,7 @@ struct ufs_dir_entry *ufs_dotdot(struct inode *dir, struct page **p)
 struct ufs_dir_entry *ufs_find_entry(struct inode *dir, const struct qstr *qstr,
 				     struct page **res_page)
 {
-	struct super_block *sb = dir->i_sb;
+	struct super_block *sb = inode_sb(dir);
 	const unsigned char *name = qstr->name;
 	int namelen = qstr->len;
 	unsigned reclen = UFS_DIR_REC_LEN(namelen);
@@ -307,7 +307,7 @@ int ufs_add_link(struct dentry *dentry, struct inode *inode)
 	struct inode *dir = d_inode(dentry->d_parent);
 	const unsigned char *name = dentry->d_name.name;
 	int namelen = dentry->d_name.len;
-	struct super_block *sb = dir->i_sb;
+	struct super_block *sb = inode_sb(dir);
 	unsigned reclen = UFS_DIR_REC_LEN(namelen);
 	const unsigned int chunk_size = UFS_SB(sb)->s_uspi->s_dirblksize;
 	unsigned short rec_len, name_len;
@@ -348,7 +348,7 @@ int ufs_add_link(struct dentry *dentry, struct inode *inode)
 				goto got_it;
 			}
 			if (de->d_reclen == 0) {
-				ufs_error(dir->i_sb, __func__,
+				ufs_error(inode_sb(dir), __func__,
 					  "zero-length directory entry");
 				err = -EIO;
 				goto out_unlock;
@@ -424,7 +424,7 @@ ufs_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);
@@ -495,7 +495,7 @@ ufs_readdir(struct file *file, struct dir_context *ctx)
 int ufs_delete_entry(struct inode *inode, struct ufs_dir_entry *dir,
 		     struct page * page)
 {
-	struct super_block *sb = inode->i_sb;
+	struct super_block *sb = inode_sb(inode);
 	char *kaddr = page_address(page);
 	unsigned from = ((char*)dir - kaddr) & ~(UFS_SB(sb)->s_uspi->s_dirblksize - 1);
 	unsigned to = ((char*)dir - kaddr) + fs16_to_cpu(sb, dir->d_reclen);
@@ -513,7 +513,7 @@ int ufs_delete_entry(struct inode *inode, struct ufs_dir_entry *dir,
 
 	while ((char*)de < (char*)dir) {
 		if (de->d_reclen == 0) {
-			ufs_error(inode->i_sb, __func__,
+			ufs_error(inode_sb(inode), __func__,
 				  "zero-length directory entry");
 			err = -EIO;
 			goto out;
@@ -542,7 +542,7 @@ int ufs_delete_entry(struct inode *inode, struct ufs_dir_entry *dir,
 
 int ufs_make_empty(struct inode * inode, struct inode *dir)
 {
-	struct super_block * sb = dir->i_sb;
+	struct super_block * sb = inode_sb(dir);
 	struct address_space *mapping = inode->i_mapping;
 	struct page *page = grab_cache_page(mapping, 0);
 	const unsigned int chunk_size = UFS_SB(sb)->s_uspi->s_dirblksize;
@@ -590,7 +590,7 @@ int ufs_make_empty(struct inode * inode, struct inode *dir)
  */
 int ufs_empty_dir(struct inode * inode)
 {
-	struct super_block *sb = inode->i_sb;
+	struct super_block *sb = inode_sb(inode);
 	struct page *page = NULL;
 	unsigned long i, npages = dir_pages(inode);
 
@@ -608,9 +608,9 @@ int ufs_empty_dir(struct inode * inode)
 
 		while ((char *)de <= kaddr) {
 			if (de->d_reclen == 0) {
-				ufs_error(inode->i_sb, __func__,
-					"zero-length directory entry: "
-					"kaddr=%p, de=%p\n", kaddr, de);
+				ufs_error(inode_sb(inode), __func__,
+					  "zero-length directory entry: "
+					  "kaddr=%p, de=%p\n", kaddr, de);
 				goto not_empty;
 			}
 			if (de->d_ino) {
fs/ufs/ialloc.c +2 -2
index e1ef0f0a1353..077fb36d5f3e 100644
@@ -65,7 +65,7 @@ void ufs_free_inode (struct inode * inode)
 	
 	UFSD("ENTER, ino %lu\n", inode->i_ino);
 
-	sb = inode->i_sb;
+	sb = inode_sb(inode);
 	uspi = UFS_SB(sb)->s_uspi;
 	
 	ino = inode->i_ino;
@@ -187,7 +187,7 @@ struct inode *ufs_new_inode(struct inode *dir, umode_t mode)
 	/* Cannot create files in a deleted directory */
 	if (!dir || !dir->i_nlink)
 		return ERR_PTR(-EPERM);
-	sb = dir->i_sb;
+	sb = inode_sb(dir);
 	inode = new_inode(sb);
 	if (!inode)
 		return ERR_PTR(-ENOMEM);
fs/ufs/inode.c +19 -18
index c843ec858cf7..eb606975737e 100644
@@ -45,7 +45,7 @@
 
 static int ufs_block_to_path(struct inode *inode, sector_t i_block, unsigned offsets[4])
 {
-	struct ufs_sb_private_info *uspi = UFS_SB(inode->i_sb)->s_uspi;
+	struct ufs_sb_private_info *uspi = UFS_SB(inode_sb(inode))->s_uspi;
 	int ptrs = uspi->s_apb;
 	int ptrs_bits = uspi->s_apbshift;
 	const long direct_blocks = UFS_NDADDR,
@@ -70,7 +70,8 @@ static int ufs_block_to_path(struct inode *inode, sector_t i_block, unsigned off
 		offsets[n++] = (i_block >> ptrs_bits) & (ptrs - 1);
 		offsets[n++] = i_block & (ptrs - 1);
 	} else {
-		ufs_warning(inode->i_sb, "ufs_block_to_path", "block > big");
+		ufs_warning(inode_sb(inode), "ufs_block_to_path",
+			    "block > big");
 	}
 	return n;
 }
@@ -124,7 +125,7 @@ static inline int grow_chain64(struct ufs_inode_info *ufsi,
 static u64 ufs_frag_map(struct inode *inode, unsigned offsets[4], int depth)
 {
 	struct ufs_inode_info *ufsi = UFS_I(inode);
-	struct super_block *sb = inode->i_sb;
+	struct super_block *sb = inode_sb(inode);
 	struct ufs_sb_private_info *uspi = UFS_SB(sb)->s_uspi;
 	u64 mask = (u64) uspi->s_apbmask>>uspi->s_fpbshift;
 	int shift = uspi->s_apbshift-uspi->s_fpbshift;
@@ -222,7 +223,7 @@ ufs_extend_tail(struct inode *inode, u64 writes_to,
 		  int *err, struct page *locked_page)
 {
 	struct ufs_inode_info *ufsi = UFS_I(inode);
-	struct super_block *sb = inode->i_sb;
+	struct super_block *sb = inode_sb(inode);
 	struct ufs_sb_private_info *uspi = UFS_SB(sb)->s_uspi;
 	unsigned lastfrag = ufsi->i_lastfrag;	/* it's a short file, so unsigned is enough */
 	unsigned block = ufs_fragstoblks(lastfrag);
@@ -257,7 +258,7 @@ ufs_inode_getfrag(struct inode *inode, unsigned index,
 		  int *new, struct page *locked_page)
 {
 	struct ufs_inode_info *ufsi = UFS_I(inode);
-	struct super_block *sb = inode->i_sb;
+	struct super_block *sb = inode_sb(inode);
 	struct ufs_sb_private_info *uspi = UFS_SB(sb)->s_uspi;
 	u64 tmp, goal, lastfrag;
 	unsigned nfrags = uspi->s_fpb;
@@ -335,7 +336,7 @@ ufs_inode_getblock(struct inode *inode, u64 ind_block,
 		  unsigned index, sector_t new_fragment, int *err,
 		  int *new, struct page *locked_page)
 {
-	struct super_block *sb = inode->i_sb;
+	struct super_block *sb = inode_sb(inode);
 	struct ufs_sb_private_info *uspi = UFS_SB(sb)->s_uspi;
 	int shift = uspi->s_apbshift - uspi->s_fpbshift;
 	u64 tmp = 0, goal;
@@ -395,7 +396,7 @@ ufs_inode_getblock(struct inode *inode, u64 ind_block,
 
 static int ufs_getfrag_block(struct inode *inode, sector_t fragment, struct buffer_head *bh_result, int create)
 {
-	struct super_block *sb = inode->i_sb;
+	struct super_block *sb = inode_sb(inode);
 	struct ufs_sb_private_info *uspi = UFS_SB(sb)->s_uspi;
 	int err = 0, new = 0;
 	unsigned offsets[4];
@@ -554,13 +555,13 @@ static void ufs_set_inode_ops(struct inode *inode)
 		}
 	} else
 		init_special_inode(inode, inode->i_mode,
-				   ufs_get_inode_dev(inode->i_sb, UFS_I(inode)));
+				   ufs_get_inode_dev(inode_sb(inode), UFS_I(inode)));
 }
 
 static int ufs1_read_inode(struct inode *inode, struct ufs_inode *ufs_inode)
 {
 	struct ufs_inode_info *ufsi = UFS_I(inode);
-	struct super_block *sb = inode->i_sb;
+	struct super_block *sb = inode_sb(inode);
 	umode_t mode;
 
 	/*
@@ -605,7 +606,7 @@ static int ufs1_read_inode(struct inode *inode, struct ufs_inode *ufs_inode)
 static int ufs2_read_inode(struct inode *inode, struct ufs2_inode *ufs2_inode)
 {
 	struct ufs_inode_info *ufsi = UFS_I(inode);
-	struct super_block *sb = inode->i_sb;
+	struct super_block *sb = inode_sb(inode);
 	umode_t mode;
 
 	UFSD("Reading ufs2 inode, ino %lu\n", inode->i_ino);
@@ -713,7 +714,7 @@ struct inode *ufs_iget(struct super_block *sb, unsigned long ino)
 
 static void ufs1_update_inode(struct inode *inode, struct ufs_inode *ufs_inode)
 {
-	struct super_block *sb = inode->i_sb;
+	struct super_block *sb = inode_sb(inode);
  	struct ufs_inode_info *ufsi = UFS_I(inode);
 
 	ufs_inode->ui_mode = cpu_to_fs16(sb, inode->i_mode);
@@ -756,7 +757,7 @@ static void ufs1_update_inode(struct inode *inode, struct ufs_inode *ufs_inode)
 
 static void ufs2_update_inode(struct inode *inode, struct ufs2_inode *ufs_inode)
 {
-	struct super_block *sb = inode->i_sb;
+	struct super_block *sb = inode_sb(inode);
  	struct ufs_inode_info *ufsi = UFS_I(inode);
 
 	UFSD("ENTER\n");
@@ -796,7 +797,7 @@ static void ufs2_update_inode(struct inode *inode, struct ufs2_inode *ufs_inode)
 
 static int ufs_update_inode(struct inode * inode, int do_sync)
 {
-	struct super_block *sb = inode->i_sb;
+	struct super_block *sb = inode_sb(inode);
 	struct ufs_sb_private_info *uspi = UFS_SB(sb)->s_uspi;
 	struct buffer_head * bh;
 
@@ -897,7 +898,7 @@ static void ufs_trunc_direct(struct inode *inode)
 
 	UFSD("ENTER: ino %lu\n", inode->i_ino);
 
-	sb = inode->i_sb;
+	sb = inode_sb(inode);
 	uspi = UFS_SB(sb)->s_uspi;
 
 	frag1 = DIRECT_FRAGMENT;
@@ -975,7 +976,7 @@ static void ufs_trunc_direct(struct inode *inode)
 
 static void free_full_branch(struct inode *inode, u64 ind_block, int depth)
 {
-	struct super_block *sb = inode->i_sb;
+	struct super_block *sb = inode_sb(inode);
 	struct ufs_sb_private_info *uspi = UFS_SB(sb)->s_uspi;
 	struct ufs_buffer_head *ubh = ubh_bread(sb, ind_block, uspi->s_bsize);
 	unsigned i;
@@ -1008,7 +1009,7 @@ static void free_full_branch(struct inode *inode, u64 ind_block, int depth)
 
 static void free_branch_tail(struct inode *inode, unsigned from, struct ufs_buffer_head *ubh, int depth)
 {
-	struct super_block *sb = inode->i_sb;
+	struct super_block *sb = inode_sb(inode);
 	struct ufs_sb_private_info *uspi = UFS_SB(sb)->s_uspi;
 	unsigned i;
 
@@ -1048,7 +1049,7 @@ static void free_branch_tail(struct inode *inode, unsigned from, struct ufs_buff
 static int ufs_alloc_lastblock(struct inode *inode, loff_t size)
 {
 	int err = 0;
-	struct super_block *sb = inode->i_sb;
+	struct super_block *sb = inode_sb(inode);
 	struct address_space *mapping = inode->i_mapping;
 	struct ufs_sb_private_info *uspi = UFS_SB(sb)->s_uspi;
 	unsigned i, end;
@@ -1117,7 +1118,7 @@ static int ufs_alloc_lastblock(struct inode *inode, loff_t size)
 static void ufs_truncate_blocks(struct inode *inode)
 {
 	struct ufs_inode_info *ufsi = UFS_I(inode);
-	struct super_block *sb = inode->i_sb;
+	struct super_block *sb = inode_sb(inode);
 	struct ufs_sb_private_info *uspi = UFS_SB(sb)->s_uspi;
 	unsigned offsets[4];
 	int depth;
fs/ufs/namei.c +3 -3
index 32545cd00ceb..4a672aca7f53 100644
@@ -59,7 +59,7 @@ static struct dentry *ufs_lookup(struct inode * dir, struct dentry *dentry, unsi
 
 	ino = ufs_inode_by_name(dir, &dentry->d_name);
 	if (ino)
-		inode = ufs_iget(dir->i_sb, ino);
+		inode = ufs_iget(inode_sb(dir), ino);
 	return d_splice_alias(inode, dentry);
 }
 
@@ -99,7 +99,7 @@ static int ufs_mknod(struct inode *dir, struct dentry *dentry, umode_t mode, dev
 	err = PTR_ERR(inode);
 	if (!IS_ERR(inode)) {
 		init_special_inode(inode, mode, rdev);
-		ufs_set_inode_dev(inode->i_sb, UFS_I(inode), rdev);
+		ufs_set_inode_dev(inode_sb(inode), UFS_I(inode), rdev);
 		mark_inode_dirty(inode);
 		err = ufs_add_nondir(dentry, inode);
 	}
@@ -109,7 +109,7 @@ static int ufs_mknod(struct inode *dir, struct dentry *dentry, umode_t mode, dev
 static int ufs_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;
 	unsigned l = strlen(symname)+1;
 	struct inode * inode;
Signature · 1 line
2.15.1
#73 lore raw

PATCH 72/76 fs/xfs: Use inode_sb() helper instead of inode->i_sb

In reply to Mark Fasheh
---
 fs/xfs/xfs_acl.c    |  2 +-
 fs/xfs/xfs_aops.c   |  4 ++--
 fs/xfs/xfs_export.c |  4 ++--
 fs/xfs/xfs_file.c   | 10 ++++-----
 fs/xfs/xfs_ioctl.c  |  8 +++----
 fs/xfs/xfs_iops.c   |  6 ++---
 fs/xfs/xfs_pnfs.c   |  2 +-
 fs/xfs/xfs_trace.h  | 64 ++++++++++++++++++++++++++---------------------------
 8 files changed, 50 insertions(+), 50 deletions(-)
fs/xfs/xfs_acl.c +1 -1
index 3354140de07e..42b00b01ea1a 100644
@@ -255,7 +255,7 @@ xfs_set_acl(struct inode *inode, struct posix_acl *acl, int type)
 		goto set_acl;
 
 	error = -E2BIG;
-	if (acl->a_count > XFS_ACL_MAX_ENTRIES(XFS_M(inode->i_sb)))
+	if (acl->a_count > XFS_ACL_MAX_ENTRIES(XFS_M(inode_sb(inode))))
 		return error;
 
 	if (type == ACL_TYPE_ACCESS) {
fs/xfs/xfs_aops.c +2 -2
index 9c6a830da0ee..951ca9c4ed9e 100644
@@ -219,7 +219,7 @@ xfs_setfilesize_trans_alloc(
 	 * We may pass freeze protection with a transaction.  So tell lockdep
 	 * we released it.
 	 */
-	__sb_writers_release(ioend->io_inode->i_sb, SB_FREEZE_FS);
+	__sb_writers_release(inode_sb(ioend->io_inode), SB_FREEZE_FS);
 	/*
 	 * We hand off the transaction to the completion thread now, so
 	 * clear the flag here.
@@ -288,7 +288,7 @@ xfs_setfilesize_ioend(
 	 * Similarly for freeze protection.
 	 */
 	current_set_flags_nested(&tp->t_pflags, PF_MEMALLOC_NOFS);
-	__sb_writers_acquired(VFS_I(ip)->i_sb, SB_FREEZE_FS);
+	__sb_writers_acquired(inode_sb(VFS_I(ip)), SB_FREEZE_FS);
 
 	/* we abort the update if there was an IO error */
 	if (error) {
fs/xfs/xfs_export.c +2 -2
index fe1bfee35898..a78f6eb9987b 100644
@@ -78,8 +78,8 @@ xfs_fs_encode_fh(
 	 * large enough filesystem may contain them, thus the slightly
 	 * confusing looking conditional below.
 	 */
-	if (!(XFS_M(inode->i_sb)->m_flags & XFS_MOUNT_SMALL_INUMS) ||
-	    (XFS_M(inode->i_sb)->m_flags & XFS_MOUNT_32BITINODES))
+	if (!(XFS_M(inode_sb(inode))->m_flags & XFS_MOUNT_SMALL_INUMS) ||
+	    (XFS_M(inode_sb(inode))->m_flags & XFS_MOUNT_32BITINODES))
 		fileid_type |= XFS_FILEID_TYPE_64FLAG;
 
 	/*
fs/xfs/xfs_file.c +5 -5
index 9ea08326f876..7b805a8a031e 100644
@@ -821,7 +821,7 @@ xfs_file_fallocate(
 		}
 
 		/* check the new inode size does not wrap through zero */
-		if (new_size > inode->i_sb->s_maxbytes) {
+		if (new_size > inode_sb(inode)->s_maxbytes) {
 			error = -EFBIG;
 			goto out_unlock;
 		}
@@ -926,7 +926,7 @@ xfs_file_open(
 {
 	if (!(file->f_flags & O_LARGEFILE) && i_size_read(inode) > MAX_NON_LFS)
 		return -EFBIG;
-	if (XFS_FORCED_SHUTDOWN(XFS_M(inode->i_sb)))
+	if (XFS_FORCED_SHUTDOWN(XFS_M(inode_sb(inode))))
 		return -EIO;
 	file->f_mode |= FMODE_NOWAIT;
 	return 0;
@@ -1014,7 +1014,7 @@ xfs_file_llseek(
 
 	if (offset < 0)
 		return offset;
-	return vfs_setpos(file, offset, inode->i_sb->s_maxbytes);
+	return vfs_setpos(file, offset, inode_sb(inode)->s_maxbytes);
 }
 
 /*
@@ -1040,7 +1040,7 @@ __xfs_filemap_fault(
 	trace_xfs_filemap_fault(ip, pe_size, write_fault);
 
 	if (write_fault) {
-		sb_start_pagefault(inode->i_sb);
+		sb_start_pagefault(inode_sb(inode));
 		file_update_time(vmf->vma->vm_file);
 	}
 
@@ -1060,7 +1060,7 @@ __xfs_filemap_fault(
 	xfs_iunlock(XFS_I(inode), XFS_MMAPLOCK_SHARED);
 
 	if (write_fault)
-		sb_end_pagefault(inode->i_sb);
+		sb_end_pagefault(inode_sb(inode));
 	return ret;
 }
 
fs/xfs/xfs_ioctl.c +4 -4
index 89fb1eb80aae..8e492a123815 100644
@@ -98,7 +98,7 @@ xfs_find_handle(
 	 * and only for regular files, directories or symbolic links.
 	 */
 	error = -EINVAL;
-	if (inode->i_sb->s_magic != XFS_SB_MAGIC)
+	if (inode_sb(inode)->s_magic != XFS_SB_MAGIC)
 		goto out_put;
 
 	error = -EBADF;
@@ -688,9 +688,9 @@ xfs_ioc_space(
 	}
 
 	if (bf->l_start < 0 ||
-	    bf->l_start > inode->i_sb->s_maxbytes ||
+	    bf->l_start > inode_sb(inode)->s_maxbytes ||
 	    bf->l_start + bf->l_len < 0 ||
-	    bf->l_start + bf->l_len >= inode->i_sb->s_maxbytes) {
+	    bf->l_start + bf->l_len >= inode_sb(inode)->s_maxbytes) {
 		error = -EINVAL;
 		goto out_unlock;
 	}
@@ -1090,7 +1090,7 @@ xfs_ioctl_setattr_dax_invalidate(
 	int			*join_flags)
 {
 	struct inode		*inode = VFS_I(ip);
-	struct super_block	*sb = inode->i_sb;
+	struct super_block	*sb = inode_sb(inode);
 	int			error;
 
 	*join_flags = 0;
fs/xfs/xfs_iops.c +3 -3
index 56475fcd76f2..7aed2ad33d07 100644
@@ -360,7 +360,7 @@ xfs_vn_unlink(
 	 * but still hashed. This is incompatible with case-insensitive
 	 * mode, so invalidate (unhash) the dentry in CI-mode.
 	 */
-	if (xfs_sb_version_hasasciici(&XFS_M(dir->i_sb)->m_sb))
+	if (xfs_sb_version_hasasciici(&XFS_M(inode_sb(dir))->m_sb))
 		d_invalidate(dentry);
 	return 0;
 }
@@ -503,7 +503,7 @@ xfs_vn_getattr(
 		return -EIO;
 
 	stat->size = XFS_ISIZE(ip);
-	stat->dev = inode->i_sb->s_dev;
+	stat->dev = inode_sb(inode)->s_dev;
 	stat->mode = inode->i_mode;
 	stat->nlink = inode->i_nlink;
 	stat->uid = inode->i_uid;
@@ -1275,7 +1275,7 @@ xfs_setup_iops(
 		inode->i_mapping->a_ops = &xfs_address_space_operations;
 		break;
 	case S_IFDIR:
-		if (xfs_sb_version_hasasciici(&XFS_M(inode->i_sb)->m_sb))
+		if (xfs_sb_version_hasasciici(&XFS_M(inode_sb(inode))->m_sb))
 			inode->i_op = &xfs_dir_ci_inode_operations;
 		else
 			inode->i_op = &xfs_dir_inode_operations;
fs/xfs/xfs_pnfs.c +1 -1
index aa6c5c193f45..c3e90d20bfcf 100644
@@ -129,7 +129,7 @@ xfs_fs_map_blocks(
 	limit = mp->m_super->s_maxbytes;
 	if (!write)
 		limit = max(limit, round_up(i_size_read(inode),
-				     inode->i_sb->s_blocksize));
+				     inode_sb(inode)->s_blocksize));
 	if (offset > limit)
 		goto out_unlock;
 	if (offset > limit - length)
fs/xfs/xfs_trace.h +32 -32

256 lines not on this page · raw message

Signature · 1 line
2.15.1
#74 lore raw

PATCH 73/76 vfs: Move s_dev to to struct fs_view

In reply to Mark Fasheh

There are many places where a dev_t:ino_t pair are passed to userspace to uniquely describe an inode. Some file systems, like btrfs, have multiple inode namespace internally and use a separate dev_t to make the distinction between them.

The kernel typically uses sb->s_dev for the inode device. Most filesystems are fine with that but btrfs needs to use the device beloning to the root which that inode resides on. By moving s_dev into the fs_view we allow btrfs and any similar filesystems to set this field on a per inode basis.

This patch adds a dev_t field to struct fs_view, v_dev and removes s_dev from struct super_block. I also include a helper, inode_view() to make referencing inode->i_view fields less clunky.

---
 include/linux/fs.h | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)
include/linux/fs.h +6 -1
index 5d4bb19b2a43..c93486505084 100644
@@ -1351,6 +1351,7 @@ struct sb_writers {
  */
 struct fs_view {
 	struct super_block	*v_sb;
+	dev_t			v_dev;		/* search index; _not_ kdev_t */
 };
 
 static inline struct super_block *inode_sb(const struct inode *inode)
@@ -1358,9 +1359,13 @@ static inline struct super_block *inode_sb(const struct inode *inode)
 	return inode->i_view->v_sb;
 }
 
+static inline struct fs_view *inode_view(const struct inode *inode)
+{
+	return inode->i_view;
+}
+
 struct super_block {
 	struct list_head	s_list;		/* Keep this first */
-	dev_t			s_dev;		/* search index; _not_ kdev_t */
 	unsigned char		s_blocksize_bits;
 	unsigned long		s_blocksize;
 	loff_t			s_maxbytes;	/* Max file size */
Signature · 1 line
2.15.1
#75 lore raw

PATCH 74/76 fs: Use fs_view device from struct inode.

In reply to Mark Fasheh

Replace calls of inode_sb(inode)->s_dev with inode_view(inode)->v_dev.

---
 arch/arc/kernel/troubleshoot.c             |   2 +-
 drivers/staging/lustre/lustre/llite/dir.c  |   2 +-
 drivers/staging/lustre/lustre/llite/file.c |   2 +-
 fs/eventpoll.c                             |   2 +-
 fs/f2fs/trace.c                            |   8 +-
 fs/fuse/dir.c                              |   2 +-
 fs/locks.c                                 |  12 +--
 fs/nfs/nfs4trace.h                         |  36 ++++-----
 fs/nfs/nfstrace.h                          |  42 +++++-----
 fs/nfsd/vfs.c                              |   6 +-
 fs/notify/fdinfo.c                         |   4 +-
 fs/proc/nommu.c                            |   2 +-
 fs/proc/task_mmu.c                         |   2 +-
 fs/proc/task_nommu.c                       |   2 +-
 fs/stat.c                                  |   2 +-
 fs/xfs/xfs_iops.c                          |   2 +-
 fs/xfs/xfs_trace.h                         |  64 ++++++++--------
 include/trace/events/ext4.h                | 118 ++++++++++++++---------------
 include/trace/events/f2fs.h                |  52 ++++++-------
 include/trace/events/filelock.h            |   8 +-
 include/trace/events/filemap.h             |   6 +-
 include/trace/events/fs_dax.h              |  14 ++--
 include/trace/events/jbd2.h                |   2 +-
 include/trace/events/writeback.h           |   2 +-
 kernel/audit.c                             |   2 +-
 kernel/audit_fsnotify.c                    |   2 +-
 kernel/audit_watch.c                       |   4 +-
 kernel/auditsc.c                           |   4 +-
 kernel/bpf/offload.c                       |   4 +-
 kernel/events/core.c                       |   4 +-
 mm/memory-failure.c                        |   2 +-
 security/tomoyo/condition.c                |   2 +-
 32 files changed, 209 insertions(+), 209 deletions(-)
arch/arc/kernel/troubleshoot.c +1 -1
index 18eb4984d555..b3aa20be118e 100644
@@ -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_sb(inode)->s_dev;
+			dev = inode_view(inode)->v_dev;
 			ino = inode->i_ino;
 		}
 		pr_info("    @off 0x%lx in [%s]\n"
drivers/staging/lustre/lustre/llite/dir.c +1 -1
index 809e493b61da..cb50d04327d4 100644
@@ -1364,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_sb(inode)->s_dev;
+			st.st_dev     = inode_view(inode)->v_dev;
 			st.st_mode    = body->mbo_mode;
 			st.st_nlink   = body->mbo_nlink;
 			st.st_uid     = body->mbo_uid;
drivers/staging/lustre/lustre/llite/file.c +1 -1
index 64df47bd1118..749a74e49e61 100644
@@ -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_sb(inode)->s_dev;
+	stat->dev = inode_view(inode)->v_dev;
 	if (ll_need_32bit_api(sbi))
 		stat->ino = cl_fid_build_ino(&lli->lli_fid, 1);
 	else
fs/eventpoll.c +1 -1
index a7e3dbc83bbc..39487ae0eabd 100644
@@ -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_sb(inode)->s_dev);
+			   inode->i_ino, inode_view(inode)->v_dev);
 		if (seq_has_overflowed(m))
 			break;
 	}
fs/f2fs/trace.c +4 -4
index 235a3bca1f5f..601cf0cb723e 100644
@@ -74,8 +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_sb(inode)->s_dev),
-			MINOR(inode_sb(inode)->s_dev),
+			MAJOR(inode_view(inode)->v_dev),
+			MINOR(inode_view(inode)->v_dev),
 			pid, current->comm);
 out:
 	mutex_unlock(&pids_lock);
@@ -96,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_sb(inode)->s_dev);
-	minor = MINOR(inode_sb(inode)->s_dev);
+	major = MAJOR(inode_view(inode)->v_dev);
+	minor = MINOR(inode_view(inode)->v_dev);
 
 	if (last_io.major == major && last_io.minor == minor &&
 			last_io.pid == pid &&
fs/fuse/dir.c +1 -1
index b68adb3bd70d..f3dfca9a59ac 100644
@@ -855,7 +855,7 @@ static void fuse_fillattr(struct inode *inode, struct fuse_attr *attr,
 		attr->ctimensec = inode->i_ctime.tv_nsec;
 	}
 
-	stat->dev = inode_sb(inode)->s_dev;
+	stat->dev = inode_view(inode)->v_dev;
 	stat->ino = attr->ino;
 	stat->mode = (inode->i_mode & S_IFMT) | (attr->mode & 07777);
 	stat->nlink = attr->nlink;
fs/locks.c +6 -6
index 2a86a18c0523..86ef062c3ea1 100644
@@ -263,8 +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_sb(inode)->s_dev),
-			MINOR(inode_sb(inode)->s_dev),
+			MAJOR(inode_view(inode)->v_dev),
+			MINOR(inode_view(inode)->v_dev),
 			inode->i_ino);
 		locks_dump_ctx_list(&ctx->flc_flock, "FLOCK");
 		locks_dump_ctx_list(&ctx->flc_posix, "POSIX");
@@ -283,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_sb(inode)->s_dev),
-				MINOR(inode_sb(inode)->s_dev), inode->i_ino,
+				list_type, MAJOR(inode_view(inode)->v_dev),
+				MINOR(inode_view(inode)->v_dev), inode->i_ino,
 				fl->fl_owner, fl->fl_flags, fl->fl_type, fl->fl_pid);
 }
 
@@ -2684,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_sb(inode)->s_dev),
-				MINOR(inode_sb(inode)->s_dev), inode->i_ino);
+				MAJOR(inode_view(inode)->v_dev),
+				MINOR(inode_view(inode)->v_dev), inode->i_ino);
 	} else {
 		seq_printf(f, "%d <none>:0 ", fl_pid);
 	}
fs/nfs/nfs4trace.h +18 -18
index 517f3194b055..07f81f981792 100644
@@ -488,7 +488,7 @@ TRACE_EVENT(nfs4_cached_open,
 		TP_fast_assign(
 			const struct inode *inode = state->inode;
 
-			__entry->dev = inode_sb(inode)->s_dev;
+			__entry->dev = inode_view(inode)->v_dev;
 			__entry->fileid = NFS_FILEID(inode);
 			__entry->fhandle = nfs_fhandle_hash(NFS_FH(inode));
 			__entry->fmode = (__force unsigned int)state->state;
@@ -533,7 +533,7 @@ TRACE_EVENT(nfs4_close,
 		TP_fast_assign(
 			const struct inode *inode = state->inode;
 
-			__entry->dev = inode_sb(inode)->s_dev;
+			__entry->dev = inode_view(inode)->v_dev;
 			__entry->fileid = NFS_FILEID(inode);
 			__entry->fhandle = nfs_fhandle_hash(NFS_FH(inode));
 			__entry->fmode = (__force unsigned int)state->state;
@@ -600,7 +600,7 @@ DECLARE_EVENT_CLASS(nfs4_lock_event,
 			__entry->type = request->fl_type;
 			__entry->start = request->fl_start;
 			__entry->end = request->fl_end;
-			__entry->dev = inode_sb(inode)->s_dev;
+			__entry->dev = inode_view(inode)->v_dev;
 			__entry->fileid = NFS_FILEID(inode);
 			__entry->fhandle = nfs_fhandle_hash(NFS_FH(inode));
 			__entry->stateid_seq =
@@ -672,7 +672,7 @@ TRACE_EVENT(nfs4_set_lock,
 			__entry->type = request->fl_type;
 			__entry->start = request->fl_start;
 			__entry->end = request->fl_end;
-			__entry->dev = inode_sb(inode)->s_dev;
+			__entry->dev = inode_view(inode)->v_dev;
 			__entry->fileid = NFS_FILEID(inode);
 			__entry->fhandle = nfs_fhandle_hash(NFS_FH(inode));
 			__entry->stateid_seq =
@@ -719,7 +719,7 @@ DECLARE_EVENT_CLASS(nfs4_set_delegation_event,
 		),
 
 		TP_fast_assign(
-			__entry->dev = inode_sb(inode)->s_dev;
+			__entry->dev = inode_view(inode)->v_dev;
 			__entry->fileid = NFS_FILEID(inode);
 			__entry->fhandle = nfs_fhandle_hash(NFS_FH(inode));
 			__entry->fmode = (__force unsigned int)fmode;
@@ -804,7 +804,7 @@ DECLARE_EVENT_CLASS(nfs4_test_stateid_event,
 			const struct inode *inode = state->inode;
 
 			__entry->error = error;
-			__entry->dev = inode_sb(inode)->s_dev;
+			__entry->dev = inode_view(inode)->v_dev;
 			__entry->fileid = NFS_FILEID(inode);
 			__entry->fhandle = nfs_fhandle_hash(NFS_FH(inode));
 			__entry->stateid_seq =
@@ -855,7 +855,7 @@ DECLARE_EVENT_CLASS(nfs4_lookup_event,
 		),
 
 		TP_fast_assign(
-			__entry->dev = inode_sb(dir)->s_dev;
+			__entry->dev = inode_view(dir)->v_dev;
 			__entry->dir = NFS_FILEID(dir);
 			__entry->error = error;
 			__assign_str(name, name->name);
@@ -903,7 +903,7 @@ TRACE_EVENT(nfs4_lookupp,
 		),
 
 		TP_fast_assign(
-			__entry->dev = inode_sb(inode)->s_dev;
+			__entry->dev = inode_view(inode)->v_dev;
 			__entry->ino = NFS_FILEID(inode);
 			__entry->error = error;
 		),
@@ -938,7 +938,7 @@ TRACE_EVENT(nfs4_rename,
 		),
 
 		TP_fast_assign(
-			__entry->dev = inode_sb(olddir)->s_dev;
+			__entry->dev = inode_view(olddir)->v_dev;
 			__entry->olddir = NFS_FILEID(olddir);
 			__entry->newdir = NFS_FILEID(newdir);
 			__entry->error = error;
@@ -976,7 +976,7 @@ DECLARE_EVENT_CLASS(nfs4_inode_event,
 		),
 
 		TP_fast_assign(
-			__entry->dev = inode_sb(inode)->s_dev;
+			__entry->dev = inode_view(inode)->v_dev;
 			__entry->fileid = NFS_FILEID(inode);
 			__entry->fhandle = nfs_fhandle_hash(NFS_FH(inode));
 			__entry->error = error;
@@ -1029,7 +1029,7 @@ DECLARE_EVENT_CLASS(nfs4_inode_stateid_event,
 		),
 
 		TP_fast_assign(
-			__entry->dev = inode_sb(inode)->s_dev;
+			__entry->dev = inode_view(inode)->v_dev;
 			__entry->fileid = NFS_FILEID(inode);
 			__entry->fhandle = nfs_fhandle_hash(NFS_FH(inode));
 			__entry->error = error;
@@ -1139,7 +1139,7 @@ DECLARE_EVENT_CLASS(nfs4_inode_callback_event,
 			__entry->fhandle = nfs_fhandle_hash(fhandle);
 			if (inode != NULL) {
 				__entry->fileid = NFS_FILEID(inode);
-				__entry->dev = inode_sb(inode)->s_dev;
+				__entry->dev = inode_view(inode)->v_dev;
 			} else {
 				__entry->fileid = 0;
 				__entry->dev = 0;
@@ -1196,7 +1196,7 @@ DECLARE_EVENT_CLASS(nfs4_inode_stateid_callback_event,
 			__entry->fhandle = nfs_fhandle_hash(fhandle);
 			if (inode != NULL) {
 				__entry->fileid = NFS_FILEID(inode);
-				__entry->dev = inode_sb(inode)->s_dev;
+				__entry->dev = inode_view(inode)->v_dev;
 			} else {
 				__entry->fileid = 0;
 				__entry->dev = 0;
@@ -1303,7 +1303,7 @@ DECLARE_EVENT_CLASS(nfs4_read_event,
 			const struct inode *inode = hdr->inode;
 			const struct nfs4_state *state =
 				hdr->args.context->state;
-			__entry->dev = inode_sb(inode)->s_dev;
+			__entry->dev = inode_view(inode)->v_dev;
 			__entry->fileid = NFS_FILEID(inode);
 			__entry->fhandle = nfs_fhandle_hash(NFS_FH(inode));
 			__entry->offset = hdr->args.offset;
@@ -1363,7 +1363,7 @@ DECLARE_EVENT_CLASS(nfs4_write_event,
 			const struct inode *inode = hdr->inode;
 			const struct nfs4_state *state =
 				hdr->args.context->state;
-			__entry->dev = inode_sb(inode)->s_dev;
+			__entry->dev = inode_view(inode)->v_dev;
 			__entry->fileid = NFS_FILEID(inode);
 			__entry->fhandle = nfs_fhandle_hash(NFS_FH(inode));
 			__entry->offset = hdr->args.offset;
@@ -1420,7 +1420,7 @@ DECLARE_EVENT_CLASS(nfs4_commit_event,
 
 		TP_fast_assign(
 			const struct inode *inode = data->inode;
-			__entry->dev = inode_sb(inode)->s_dev;
+			__entry->dev = inode_view(inode)->v_dev;
 			__entry->fileid = NFS_FILEID(inode);
 			__entry->fhandle = nfs_fhandle_hash(NFS_FH(inode));
 			__entry->offset = data->args.offset;
@@ -1485,7 +1485,7 @@ TRACE_EVENT(nfs4_layoutget,
 		TP_fast_assign(
 			const struct inode *inode = d_inode(ctx->dentry);
 			const struct nfs4_state *state = ctx->state;
-			__entry->dev = inode_sb(inode)->s_dev;
+			__entry->dev = inode_view(inode)->v_dev;
 			__entry->fileid = NFS_FILEID(inode);
 			__entry->fhandle = nfs_fhandle_hash(NFS_FH(inode));
 			__entry->iomode = args->iomode;
@@ -1567,7 +1567,7 @@ TRACE_EVENT(pnfs_update_layout,
 			__field(enum pnfs_update_layout_reason, reason)
 		),
 		TP_fast_assign(
-			__entry->dev = inode_sb(inode)->s_dev;
+			__entry->dev = inode_view(inode)->v_dev;
 			__entry->fileid = NFS_FILEID(inode);
 			__entry->fhandle = nfs_fhandle_hash(NFS_FH(inode));
 			__entry->pos = pos;
fs/nfs/nfstrace.h +21 -21

168 lines not on this page · raw message

fs/nfsd/vfs.c +3 -3
index 393159739b95..9ea609b0ca8e 100644
@@ -786,7 +786,7 @@ struct raparms *
 nfsd_init_raparms(struct file *file)
 {
 	struct inode *inode = file_inode(file);
-	dev_t dev = inode_sb(inode)->s_dev;
+	dev_t dev = inode_view(inode)->v_dev;
 	ino_t ino = inode->i_ino;
 	struct raparms	*ra, **rap, **frap = NULL;
 	int depth = 0;
@@ -943,7 +943,7 @@ static int wait_for_concurrent_writes(struct file *file)
 	int err = 0;
 
 	if (atomic_read(&inode->i_writecount) > 1
-	    || (last_ino == inode->i_ino && last_dev == inode_sb(inode)->s_dev)) {
+	    || (last_ino == inode->i_ino && last_dev == inode_view(inode)->v_dev)) {
 		dprintk("nfsd: write defer %d\n", task_pid_nr(current));
 		msleep(10);
 		dprintk("nfsd: write resume %d\n", task_pid_nr(current));
@@ -954,7 +954,7 @@ static int wait_for_concurrent_writes(struct file *file)
 		err = vfs_fsync(file, 0);
 	}
 	last_ino = inode->i_ino;
-	last_dev = inode_sb(inode)->s_dev;
+	last_dev = inode_view(inode)->v_dev;
 	return err;
 }
 
fs/notify/fdinfo.c +2 -2
index 857df5ce27ac..9a6ad77fbe6f 100644
@@ -92,7 +92,7 @@ static void inotify_fdinfo(struct seq_file *m, struct fsnotify_mark *mark)
 		u32 mask = mark->mask & IN_ALL_EVENTS;
 		seq_printf(m, "inotify wd:%x ino:%lx sdev:%x mask:%x ignored_mask:%x ",
 			   inode_mark->wd, inode->i_ino,
-			   inode_sb(inode)->s_dev,
+			   inode_view(inode)->v_dev,
 			   mask, mark->ignored_mask);
 		show_mark_fhandle(m, inode);
 		seq_putc(m, '\n');
@@ -122,7 +122,7 @@ static void fanotify_fdinfo(struct seq_file *m, struct fsnotify_mark *mark)
 		if (!inode)
 			return;
 		seq_printf(m, "fanotify ino:%lx sdev:%x mflags:%x mask:%x ignored_mask:%x ",
-			   inode->i_ino, inode_sb(inode)->s_dev,
+			   inode->i_ino, inode_view(inode)->v_dev,
 			   mflags, mark->mask, mark->ignored_mask);
 		show_mark_fhandle(m, inode);
 		seq_putc(m, '\n');
fs/proc/nommu.c +1 -1
index 5c979fc49662..1278548e099f 100644
@@ -46,7 +46,7 @@ static int nommu_region_show(struct seq_file *m, struct vm_region *region)
 
 	if (file) {
 		struct inode *inode = file_inode(region->vm_file);
-		dev = inode_sb(inode)->s_dev;
+		dev = inode_view(inode)->v_dev;
 		ino = inode->i_ino;
 	}
 
fs/proc/task_mmu.c +1 -1
index 27bf744e8da9..10ac40e87939 100644
@@ -312,7 +312,7 @@ show_map_vma(struct seq_file *m, struct vm_area_struct *vma, int is_pid)
 
 	if (file) {
 		struct inode *inode = file_inode(vma->vm_file);
-		dev = inode_sb(inode)->s_dev;
+		dev = inode_view(inode)->v_dev;
 		ino = inode->i_ino;
 		pgoff = ((loff_t)vma->vm_pgoff) << PAGE_SHIFT;
 	}
fs/proc/task_nommu.c +1 -1
index d3acd4433d9d..a109df40fa3c 100644
@@ -157,7 +157,7 @@ static int nommu_vma_show(struct seq_file *m, struct vm_area_struct *vma,
 
 	if (file) {
 		struct inode *inode = file_inode(vma->vm_file);
-		dev = inode_sb(inode)->s_dev;
+		dev = inode_view(inode)->v_dev;
 		ino = inode->i_ino;
 		pgoff = (loff_t)vma->vm_pgoff << PAGE_SHIFT;
 	}
fs/stat.c +1 -1
index 178b81d4359e..48787ee00e9c 100644
@@ -32,7 +32,7 @@
  */
 void generic_fillattr(struct inode *inode, struct kstat *stat)
 {
-	stat->dev = inode_sb(inode)->s_dev;
+	stat->dev = inode_view(inode)->v_dev;
 	stat->ino = inode->i_ino;
 	stat->mode = inode->i_mode;
 	stat->nlink = inode->i_nlink;
fs/xfs/xfs_iops.c +1 -1
index 7aed2ad33d07..be323e17a302 100644
@@ -503,7 +503,7 @@ xfs_vn_getattr(
 		return -EIO;
 
 	stat->size = XFS_ISIZE(ip);
-	stat->dev = inode_sb(inode)->s_dev;
+	stat->dev = inode_view(inode)->v_dev;
 	stat->mode = inode->i_mode;
 	stat->nlink = inode->i_nlink;
 	stat->uid = inode->i_uid;
fs/xfs/xfs_trace.h +32 -32

256 lines not on this page · raw message

include/trace/events/ext4.h +59 -59

472 lines not on this page · raw message

include/trace/events/f2fs.h +26 -26

208 lines not on this page · raw message

include/trace/events/filelock.h +4 -4
index 522d2740a56f..cbd545058cf3 100644
@@ -48,7 +48,7 @@ TRACE_EVENT(locks_get_lock_context,
 	),
 
 	TP_fast_assign(
-		__entry->s_dev = inode_sb(inode)->s_dev;
+		__entry->s_dev = inode_view(inode)->v_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_sb(inode)->s_dev;
+		__entry->s_dev = inode_view(inode)->v_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_sb(inode)->s_dev;
+		__entry->s_dev = inode_view(inode)->v_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_sb(inode)->s_dev;
+		__entry->s_dev = inode_view(inode)->v_dev;
 		__entry->i_ino = inode->i_ino;
 		__entry->wcount = atomic_read(&inode->i_writecount);
 		__entry->dcount = d_count(fl->fl_file->f_path.dentry);
include/trace/events/filemap.h +3 -3
index 0517759b4b8f..1e32f104ac54 100644
@@ -31,7 +31,7 @@ DECLARE_EVENT_CLASS(mm_filemap_op_page_cache,
 		__entry->i_ino = page->mapping->host->i_ino;
 		__entry->index = page->index;
 		if (inode_sb(page->mapping->host))
-			__entry->s_dev = inode_sb(page->mapping->host)->s_dev;
+			__entry->s_dev = inode_view(page->mapping->host)->v_dev;
 		else
 			__entry->s_dev = page->mapping->host->i_rdev;
 	),
@@ -69,7 +69,7 @@ TRACE_EVENT(filemap_set_wb_err,
 			__entry->i_ino = mapping->host->i_ino;
 			__entry->errseq = eseq;
 			if (inode_sb(mapping->host))
-				__entry->s_dev = inode_sb(mapping->host)->s_dev;
+				__entry->s_dev = inode_view(mapping->host)->v_dev;
 			else
 				__entry->s_dev = mapping->host->i_rdev;
 		),
@@ -97,7 +97,7 @@ TRACE_EVENT(file_check_and_advance_wb_err,
 			__entry->i_ino = file->f_mapping->host->i_ino;
 			if (inode_sb(file->f_mapping->host))
 				__entry->s_dev =
-					inode_sb(file->f_mapping->host)->s_dev;
+					inode_view(file->f_mapping->host)->v_dev;
 			else
 				__entry->s_dev =
 					file->f_mapping->host->i_rdev;
include/trace/events/fs_dax.h +7 -7
index d3173cae131d..d287a210119a 100644
@@ -24,7 +24,7 @@ DECLARE_EVENT_CLASS(dax_pmd_fault_class,
 		__field(int, result)
 	),
 	TP_fast_assign(
-		__entry->dev = inode_sb(inode)->s_dev;
+		__entry->dev = inode_view(inode)->v_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_sb(inode)->s_dev;
+		__entry->dev = inode_view(inode)->v_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_sb(inode)->s_dev;
+		__entry->dev = inode_view(inode)->v_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_sb(inode)->s_dev;
+		__entry->dev = inode_view(inode)->v_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_sb(inode)->s_dev;
+		__entry->dev = inode_view(inode)->v_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_sb(inode)->s_dev;
+		__entry->dev = inode_view(inode)->v_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_sb(inode)->s_dev;
+		__entry->dev = inode_view(inode)->v_dev;
 		__entry->ino = inode->i_ino;
 		__entry->pgoff = pgoff;
 		__entry->pglen = pglen;
include/trace/events/jbd2.h +1 -1
index 95e0cb226d30..9c6b6c595835 100644
@@ -124,7 +124,7 @@ TRACE_EVENT(jbd2_submit_inode_data,
 	),
 
 	TP_fast_assign(
-		__entry->dev	= inode_sb(inode)->s_dev;
+		__entry->dev	= inode_view(inode)->v_dev;
 		__entry->ino	= inode->i_ino;
 	),
 
include/trace/events/writeback.h +1 -1
index d5ae5ea65bc4..7a5bfa93f938 100644
@@ -710,7 +710,7 @@ DECLARE_EVENT_CLASS(writeback_inode_template,
 	),
 
 	TP_fast_assign(
-		__entry->dev	= inode_sb(inode)->s_dev;
+		__entry->dev	= inode_view(inode)->v_dev;
 		__entry->ino	= inode->i_ino;
 		__entry->state	= inode->i_state;
 		__entry->mode	= inode->i_mode;
kernel/audit.c +1 -1
index 23159573aafd..b28999994512 100644
@@ -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_sb(inode)->s_dev;
+	name->dev   = inode_view(inode)->v_dev;
 	name->mode  = inode->i_mode;
 	name->uid   = inode->i_uid;
 	name->gid   = inode->i_gid;
kernel/audit_fsnotify.c +1 -1
index 981432cef19c..5daffedbfd67 100644
@@ -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_sb(inode)->s_dev : AUDIT_DEV_UNSET;
+	audit_mark->dev = inode ? inode_view(inode)->v_dev : AUDIT_DEV_UNSET;
 	audit_mark->ino = inode ? inode->i_ino : AUDIT_INO_UNSET;
 }
 
kernel/audit_watch.c +2 -2
index 3e785d4cf8aa..b9f571cc6a7f 100644
@@ -499,7 +499,7 @@ static int audit_watch_handle_event(struct fsnotify_group *group,
 	}
 
 	if (mask & (FS_CREATE|FS_MOVED_TO) && inode)
-		audit_update_watch(parent, dname, inode_sb(inode)->s_dev,
+		audit_update_watch(parent, dname, inode_view(inode)->v_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);
@@ -554,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 = inode_sb(file_inode(exe_file))->s_dev;
+	dev = inode_view(file_inode(exe_file))->v_dev;
 	fput(exe_file);
 	return audit_mark_compare(mark, ino, dev);
 }
kernel/auditsc.c +2 -2
index 9cb16a1ebedd..36b7cca89ec5 100644
@@ -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_sb(inode)->s_dev)
+			    n->dev != inode_view(inode)->v_dev)
 				continue;
 		} else if (n->name) {
 			/* inode number has not been set, check the name */
@@ -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 == inode_sb(parent)->s_dev &&
+		if (n->ino == parent->i_ino && n->dev == inode_view(parent)->v_dev &&
 		    !audit_compare_dname_path(dname,
 					      n->name->name, n->name_len)) {
 			if (n->type == AUDIT_TYPE_UNKNOWN)
kernel/bpf/offload.c +2 -2
index 6ff86b395175..6aed7bade9fd 100644
@@ -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(inode_sb(ns_inode)->s_dev);
+	info->netns_dev = new_encode_dev(inode_view(ns_inode)->v_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(inode_sb(ns_inode)->s_dev);
+	info->netns_dev = new_encode_dev(inode_view(ns_inode)->v_dev);
 	info->netns_ino = ns_inode->i_ino;
 	path_put(&ns_path);
 
kernel/events/core.c +2 -2
index 58c02221e066..9c1e45243007 100644
@@ -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(inode_sb(ns_inode)->s_dev);
+		ns_link_info->dev = new_encode_dev(inode_view(ns_inode)->v_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_sb(inode)->s_dev;
+		dev = inode_view(inode)->v_dev;
 		ino = inode->i_ino;
 		gen = inode->i_generation;
 		maj = MAJOR(dev);
mm/memory-failure.c +1 -1
index 08e2367985f8..64e8626df474 100644
@@ -98,7 +98,7 @@ static int hwpoison_filter_dev(struct page *p)
 	if (mapping == NULL || mapping->host == NULL)
 		return -EINVAL;
 
-	dev = inode_sb(mapping->host)->s_dev;
+	dev = inode_view(mapping->host)->v_dev;
 	if (hwpoison_filter_dev_major != ~0U &&
 	    hwpoison_filter_dev_major != MAJOR(dev))
 		return -EINVAL;
security/tomoyo/condition.c +1 -1
index 3422f5f57e43..b8419d9ac789 100644
@@ -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_sb(inode)->s_dev;
+			stat->dev  = inode_view(inode)->v_dev;
 			stat->rdev = inode->i_rdev;
 			obj->stat_valid[i] = true;
 		}
Signature · 1 line
2.15.1
#76 lore raw

PATCH 75/76 fs: Use fs view device from struct super_block

In reply to Mark Fasheh

We have some places which access s_dev directly from struct super_block.

Convert those to get v_dev from the default super block view.

---
 drivers/mtd/mtdsuper.c                          |  2 +-
 drivers/staging/lustre/lustre/llite/llite_lib.c |  6 +-
 fs/autofs4/autofs_i.h                           |  2 +-
 fs/autofs4/dev-ioctl.c                          | 10 +--
 fs/ceph/super.c                                 |  2 +-
 fs/cramfs/inode.c                               |  4 +-
 fs/exofs/super.c                                |  2 +-
 fs/fuse/inode.c                                 |  2 +-
 fs/gfs2/ops_fstype.c                            |  2 +-
 fs/gfs2/quota.c                                 |  5 +-
 fs/gfs2/sys.c                                   |  3 +-
 fs/gfs2/trace_gfs2.h                            | 30 ++++-----
 fs/nfs/nfs4trace.h                              |  2 +-
 fs/nfs/super.c                                  |  6 +-
 fs/nfsd/nfs3xdr.c                               |  2 +-
 fs/nfsd/nfsfh.c                                 |  6 +-
 fs/nilfs2/super.c                               |  2 +-
 fs/ocfs2/journal.c                              | 13 ++--
 fs/ocfs2/ocfs2_trace.h                          |  4 +-
 fs/ocfs2/super.c                                |  4 +-
 fs/overlayfs/inode.c                            |  4 +-
 fs/overlayfs/readdir.c                          |  4 +-
 fs/proc_namespace.c                             |  2 +-
 fs/quota/dquot.c                                |  2 +-
 fs/reiserfs/journal.c                           |  6 +-
 fs/romfs/super.c                                |  6 +-
 fs/super.c                                      |  8 +--
 fs/xfs/scrub/trace.h                            | 26 ++++----
 fs/xfs/xfs_trace.h                              | 84 ++++++++++++-------------
 fs/xfs/xfs_trans_dquot.c                        |  2 +-
 include/trace/events/ext4.h                     | 36 +++++------
 include/trace/events/f2fs.h                     | 18 +++---
 include/trace/events/writeback.h                |  2 +-
 init/do_mounts.c                                |  2 +-
 kernel/audit_watch.c                            |  2 +-
 net/unix/diag.c                                 |  2 +-
 security/tomoyo/realpath.c                      |  4 +-
 37 files changed, 162 insertions(+), 157 deletions(-)
drivers/mtd/mtdsuper.c +1 -1
index d58a61c09304..f5346de9b29d 100644
@@ -51,7 +51,7 @@ static int get_sb_mtd_set(struct super_block *sb, void *_mtd)
 	struct mtd_info *mtd = _mtd;
 
 	sb->s_mtd = mtd;
-	sb->s_dev = MKDEV(MTD_BLOCK_MAJOR, mtd->index);
+	sb->s_view.v_dev = MKDEV(MTD_BLOCK_MAJOR, mtd->index);
 	sb->s_bdi = bdi_get(mtd_bdi);
 
 	return 0;
drivers/staging/lustre/lustre/llite/llite_lib.c +3 -3
index 6f6df27635d4..ffa6e7d92080 100644
@@ -524,7 +524,7 @@ static int client_common_fill_super(struct super_block *sb, char *md, char *dt)
 		goto out_lock_cn_cb;
 	}
 
-	sbi->ll_sdev_orig = sb->s_dev;
+	sbi->ll_sdev_orig = sb->s_view.v_dev;
 
 	/* We set sb->s_dev equal on all lustre clients in order to support
 	 * NFS export clustering.  NFSD requires that the FSID be the same
@@ -535,7 +535,7 @@ static int client_common_fill_super(struct super_block *sb, char *md, char *dt)
 	 */
 	uuid = obd_get_uuid(sbi->ll_md_exp);
 	if (uuid) {
-		sb->s_dev = get_uuid2int(uuid->uuid, strlen(uuid->uuid));
+		sb->s_view.v_dev = get_uuid2int(uuid->uuid, strlen(uuid->uuid));
 		get_uuid2fsid(uuid->uuid, strlen(uuid->uuid), &sbi->ll_fsid);
 	}
 
@@ -670,7 +670,7 @@ void ll_kill_super(struct super_block *sb)
 	 * in put_super not affected real removing devices
 	 */
 	if (sbi) {
-		sb->s_dev = sbi->ll_sdev_orig;
+		sb->s_view.v_dev = sbi->ll_sdev_orig;
 		sbi->ll_umounting = 1;
 
 		/* wait running statahead threads to quit */
fs/autofs4/autofs_i.h +1 -1
index 4737615f0eaa..31fcf15108eb 100644
@@ -225,7 +225,7 @@ void autofs4_catatonic_mode(struct autofs_sb_info *);
 
 static inline u32 autofs4_get_dev(struct autofs_sb_info *sbi)
 {
-	return new_encode_dev(sbi->sb->s_dev);
+	return new_encode_dev(sbi->sb->s_view.v_dev);
 }
 
 static inline u64 autofs4_get_ino(struct autofs_sb_info *sbi)
fs/autofs4/dev-ioctl.c +5 -5
index 6b28b01e5022..6d1f1bc5db06 100644
@@ -231,7 +231,7 @@ static int find_autofs_mount(const char *pathname,
 
 static int test_by_dev(const struct path *path, void *p)
 {
-	return path->dentry->d_sb->s_dev == *(dev_t *)p;
+	return path->dentry->d_sb->s_view.v_dev == *(dev_t *)p;
 }
 
 static int test_by_type(const struct path *path, void *p)
@@ -243,7 +243,7 @@ static int test_by_type(const struct path *path, void *p)
 
 /*
  * Open a file descriptor on the autofs mount point corresponding
- * to the given path and device number (aka. new_encode_dev(sb->s_dev)).
+ * to the given path and device number (aka. new_encode_dev(sb->s_view.v_dev)).
  */
 static int autofs_dev_ioctl_open_mountpoint(const char *name, dev_t devid)
 {
@@ -451,7 +451,7 @@ static int autofs_dev_ioctl_requester(struct file *fp,
 		goto out;
 	}
 
-	devid = sbi->sb->s_dev;
+	devid = sbi->sb->s_view.v_dev;
 
 	param->requester.uid = param->requester.gid = -1;
 
@@ -554,14 +554,14 @@ static int autofs_dev_ioctl_ismountpoint(struct file *fp,
 						test_by_type, &type);
 		if (err)
 			goto out;
-		devid = new_encode_dev(path.dentry->d_sb->s_dev);
+		devid = new_encode_dev(path.dentry->d_sb->s_view.v_dev);
 		err = 0;
 		if (path.mnt->mnt_root == path.dentry) {
 			err = 1;
 			magic = path.dentry->d_sb->s_magic;
 		}
 	} else {
-		dev_t dev = sbi->sb->s_dev;
+		dev_t dev = sbi->sb->s_view.v_dev;
 
 		err = find_autofs_mount(name, &path, test_by_dev, &dev);
 		if (err)
fs/ceph/super.c +1 -1
index fb2bc9c15a23..2f6c4c16a5ad 100644
@@ -1055,7 +1055,7 @@ static struct dentry *ceph_mount(struct file_system_type *fs_type,
 static void ceph_kill_sb(struct super_block *s)
 {
 	struct ceph_fs_client *fsc = ceph_sb_to_client(s);
-	dev_t dev = s->s_dev;
+	dev_t dev = s->s_view.v_dev;
 
 	dout("kill_sb %p\n", s);
 
fs/cramfs/inode.c +2 -2
index eb633de7ccbe..239ec223433f 100644
@@ -674,8 +674,8 @@ static int cramfs_statfs(struct dentry *dentry, struct kstatfs *buf)
 
 	if (sb->s_bdev)
 		id = huge_encode_dev(sb->s_bdev->bd_dev);
-	else if (sb->s_dev)
-		id = huge_encode_dev(sb->s_dev);
+	else if (sb->s_view.v_dev)
+		id = huge_encode_dev(sb->s_view.v_dev);
 
 	buf->f_type = CRAMFS_MAGIC;
 	buf->f_bsize = PAGE_SIZE;
fs/exofs/super.c +1 -1
index 179cd5c2f52a..6149c1bc02ff 100644
@@ -760,7 +760,7 @@ static int exofs_fill_super(struct super_block *sb, void *data, int silent)
 	sb->s_max_links = EXOFS_LINK_MAX;
 	atomic_set(&sbi->s_curr_pending, 0);
 	sb->s_bdev = NULL;
-	sb->s_dev = 0;
+	sb->s_view.v_dev = 0;
 
 	comp.obj.partition = sbi->one_comp.obj.partition;
 	comp.obj.id = EXOFS_SUPER_ID;
fs/fuse/inode.c +1 -1
index d6d2fbe6c3ec..3b4d753b8c70 100644
@@ -1103,7 +1103,7 @@ static int fuse_fill_super(struct super_block *sb, void *data, int silent)
 	if (!fud)
 		goto err_put_conn;
 
-	fc->dev = sb->s_dev;
+	fc->dev = sb->s_view.v_dev;
 	fc->sb = sb;
 	err = fuse_bdi_init(fc, sb);
 	if (err)
fs/gfs2/ops_fstype.c +1 -1
index e6a0a8a89ea7..25a93cacaa1d 100644
@@ -1222,7 +1222,7 @@ static int fill_super(struct super_block *sb, struct gfs2_args *args, int silent
 static int set_gfs2_super(struct super_block *s, void *data)
 {
 	s->s_bdev = data;
-	s->s_dev = s->s_bdev->bd_dev;
+	s->s_view.v_dev = s->s_bdev->bd_dev;
 	s->s_bdi = bdi_get(s->s_bdev->bd_bdi);
 	return 0;
 }
fs/gfs2/quota.c +3 -2
index 7a98abd340ee..21499dd4ad5c 100644
@@ -1227,7 +1227,7 @@ int gfs2_quota_check(struct gfs2_inode *ip, kuid_t uid, kgid_t gid,
 						      &qd->qd_flags)) {
 					print_message(qd, "exceeded");
 					quota_send_warning(qd->qd_id,
-							   sdp->sd_vfs->s_dev,
+							   sdp->sd_vfs->s_view.v_dev,
 							   QUOTA_NL_BHARDWARN);
 				}
 				error = -EDQUOT;
@@ -1238,7 +1238,8 @@ int gfs2_quota_check(struct gfs2_inode *ip, kuid_t uid, kgid_t gid,
 					 gfs2_tune_get(sdp, gt_quota_warn_period)
 					 * HZ)) {
 			quota_send_warning(qd->qd_id,
-					   sdp->sd_vfs->s_dev, QUOTA_NL_BSOFTWARN);
+					   sdp->sd_vfs->s_view.v_dev,
+					   QUOTA_NL_BSOFTWARN);
 			error = print_message(qd, "warning");
 			qd->qd_last_warn = jiffies;
 		}
fs/gfs2/sys.c +2 -1
index c191fa58a1df..d5036ad407b6 100644
@@ -63,7 +63,8 @@ static struct kset *gfs2_kset;
 static ssize_t id_show(struct gfs2_sbd *sdp, char *buf)
 {
 	return snprintf(buf, PAGE_SIZE, "%u:%u\n",
-			MAJOR(sdp->sd_vfs->s_dev), MINOR(sdp->sd_vfs->s_dev));
+			MAJOR(sdp->sd_vfs->s_view.v_dev),
+			MINOR(sdp->sd_vfs->s_view.v_dev));
 }
 
 static ssize_t fsname_show(struct gfs2_sbd *sdp, char *buf)
fs/gfs2/trace_gfs2.h +15 -15
index b9318b49ff8f..b25112935281 100644
@@ -106,7 +106,7 @@ TRACE_EVENT(gfs2_glock_state_change,
 	),
 
 	TP_fast_assign(
-		__entry->dev		= gl->gl_name.ln_sbd->sd_vfs->s_dev;
+		__entry->dev		= gl->gl_name.ln_sbd->sd_vfs->s_view.v_dev;
 		__entry->glnum		= gl->gl_name.ln_number;
 		__entry->gltype		= gl->gl_name.ln_type;
 		__entry->cur_state	= glock_trace_state(gl->gl_state);
@@ -142,7 +142,7 @@ TRACE_EVENT(gfs2_glock_put,
 	),
 
 	TP_fast_assign(
-		__entry->dev		= gl->gl_name.ln_sbd->sd_vfs->s_dev;
+		__entry->dev		= gl->gl_name.ln_sbd->sd_vfs->s_view.v_dev;
 		__entry->gltype		= gl->gl_name.ln_type;
 		__entry->glnum		= gl->gl_name.ln_number;
 		__entry->cur_state	= glock_trace_state(gl->gl_state);
@@ -176,7 +176,7 @@ TRACE_EVENT(gfs2_demote_rq,
 	),
 
 	TP_fast_assign(
-		__entry->dev		= gl->gl_name.ln_sbd->sd_vfs->s_dev;
+		__entry->dev		= gl->gl_name.ln_sbd->sd_vfs->s_view.v_dev;
 		__entry->gltype		= gl->gl_name.ln_type;
 		__entry->glnum		= gl->gl_name.ln_number;
 		__entry->cur_state	= glock_trace_state(gl->gl_state);
@@ -211,7 +211,7 @@ TRACE_EVENT(gfs2_promote,
 	),
 
 	TP_fast_assign(
-		__entry->dev	= gh->gh_gl->gl_name.ln_sbd->sd_vfs->s_dev;
+		__entry->dev	= gh->gh_gl->gl_name.ln_sbd->sd_vfs->s_view.v_dev;
 		__entry->glnum	= gh->gh_gl->gl_name.ln_number;
 		__entry->gltype	= gh->gh_gl->gl_name.ln_type;
 		__entry->first	= first;
@@ -241,7 +241,7 @@ TRACE_EVENT(gfs2_glock_queue,
 	),
 
 	TP_fast_assign(
-		__entry->dev	= gh->gh_gl->gl_name.ln_sbd->sd_vfs->s_dev;
+		__entry->dev	= gh->gh_gl->gl_name.ln_sbd->sd_vfs->s_view.v_dev;
 		__entry->glnum	= gh->gh_gl->gl_name.ln_number;
 		__entry->gltype	= gh->gh_gl->gl_name.ln_type;
 		__entry->queue	= queue;
@@ -280,7 +280,7 @@ TRACE_EVENT(gfs2_glock_lock_time,
 	),
 
 	TP_fast_assign(
-		__entry->dev            = gl->gl_name.ln_sbd->sd_vfs->s_dev;
+		__entry->dev            = gl->gl_name.ln_sbd->sd_vfs->s_view.v_dev;
 		__entry->glnum          = gl->gl_name.ln_number;
 		__entry->gltype         = gl->gl_name.ln_type;
 		__entry->status		= gl->gl_lksb.sb_status;
@@ -335,7 +335,7 @@ TRACE_EVENT(gfs2_pin,
 	),
 
 	TP_fast_assign(
-		__entry->dev		= bd->bd_gl->gl_name.ln_sbd->sd_vfs->s_dev;
+		__entry->dev		= bd->bd_gl->gl_name.ln_sbd->sd_vfs->s_view.v_dev;
 		__entry->pin		= pin;
 		__entry->len		= bd->bd_bh->b_size;
 		__entry->block		= bd->bd_bh->b_blocknr;
@@ -365,7 +365,7 @@ TRACE_EVENT(gfs2_log_flush,
 	),
 
 	TP_fast_assign(
-		__entry->dev            = sdp->sd_vfs->s_dev;
+		__entry->dev            = sdp->sd_vfs->s_view.v_dev;
 		__entry->start		= start;
 		__entry->log_seq	= sdp->sd_log_sequence;
 		__entry->flags		= flags;
@@ -391,7 +391,7 @@ TRACE_EVENT(gfs2_log_blocks,
 	),
 
 	TP_fast_assign(
-		__entry->dev		= sdp->sd_vfs->s_dev;
+		__entry->dev		= sdp->sd_vfs->s_view.v_dev;
 		__entry->blocks		= blocks;
 	),
 
@@ -414,7 +414,7 @@ TRACE_EVENT(gfs2_ail_flush,
 	),
 
 	TP_fast_assign(
-		__entry->dev		= sdp->sd_vfs->s_dev;
+		__entry->dev		= sdp->sd_vfs->s_view.v_dev;
 		__entry->start		= start;
 		__entry->sync_mode	= wbc->sync_mode;
 		__entry->nr_to_write	= wbc->nr_to_write;
@@ -454,7 +454,7 @@ TRACE_EVENT(gfs2_bmap,
 	),
 
 	TP_fast_assign(
-		__entry->dev            = ip->i_gl->gl_name.ln_sbd->sd_vfs->s_dev;
+		__entry->dev            = ip->i_gl->gl_name.ln_sbd->sd_vfs->s_view.v_dev;
 		__entry->lblock		= lblock;
 		__entry->pblock		= buffer_mapped(bh) ?  bh->b_blocknr : 0;
 		__entry->inum		= ip->i_no_addr;
@@ -490,7 +490,7 @@ TRACE_EVENT(gfs2_iomap_start,
 	),
 
 	TP_fast_assign(
-		__entry->dev            = ip->i_gl->gl_name.ln_sbd->sd_vfs->s_dev;
+		__entry->dev            = ip->i_gl->gl_name.ln_sbd->sd_vfs->s_view.v_dev;
 		__entry->inum		= ip->i_no_addr;
 		__entry->pos		= pos;
 		__entry->length		= length;
@@ -521,7 +521,7 @@ TRACE_EVENT(gfs2_iomap_end,
 	),
 
 	TP_fast_assign(
-		__entry->dev            = ip->i_gl->gl_name.ln_sbd->sd_vfs->s_dev;
+		__entry->dev            = ip->i_gl->gl_name.ln_sbd->sd_vfs->s_view.v_dev;
 		__entry->inum		= ip->i_no_addr;
 		__entry->offset		= iomap->offset;
 		__entry->length		= iomap->length;
@@ -558,7 +558,7 @@ TRACE_EVENT(gfs2_block_alloc,
 	),
 
 	TP_fast_assign(
-		__entry->dev		= rgd->rd_gl->gl_name.ln_sbd->sd_vfs->s_dev;
+		__entry->dev		= rgd->rd_gl->gl_name.ln_sbd->sd_vfs->s_view.v_dev;
 		__entry->start		= block;
 		__entry->inum		= ip->i_no_addr;
 		__entry->len		= len;
@@ -597,7 +597,7 @@ TRACE_EVENT(gfs2_rs,
 	),
 
 	TP_fast_assign(
-		__entry->dev		= rs->rs_rbm.rgd->rd_sbd->sd_vfs->s_dev;
+		__entry->dev		= rs->rs_rbm.rgd->rd_sbd->sd_vfs->s_view.v_dev;
 		__entry->rd_addr	= rs->rs_rbm.rgd->rd_addr;
 		__entry->rd_free_clone	= rs->rs_rbm.rgd->rd_free_clone;
 		__entry->rd_reserved	= rs->rs_rbm.rgd->rd_reserved;
fs/nfs/nfs4trace.h +1 -1
index 07f81f981792..4cdb6e356742 100644
@@ -410,7 +410,7 @@ DECLARE_EVENT_CLASS(nfs4_open_event,
 			__entry->error = error;
 			__entry->flags = flags;
 			__entry->fmode = (__force unsigned int)ctx->mode;
-			__entry->dev = ctx->dentry->d_sb->s_dev;
+			__entry->dev = ctx->dentry->d_sb->s_view.v_dev;
 			if (!IS_ERR_OR_NULL(state)) {
 				inode = state->inode;
 				__entry->stateid_seq =
fs/nfs/super.c +3 -3
index 5e470e233c83..5dc8226409f1 100644
@@ -2321,7 +2321,7 @@ static void nfs_initialise_sb(struct super_block *sb)
 
 	/* We probably want something more informative here */
 	snprintf(sb->s_id, sizeof(sb->s_id),
-		 "%u:%u", MAJOR(sb->s_dev), MINOR(sb->s_dev));
+		 "%u:%u", MAJOR(sb->s_view.v_dev), MINOR(sb->s_view.v_dev));
 
 	if (sb->s_blocksize == 0)
 		sb->s_blocksize = nfs_block_bits(server->wsize,
@@ -2433,7 +2433,7 @@ static int nfs_set_super(struct super_block *s, void *data)
 	s->s_d_op = server->nfs_client->rpc_ops->dentry_ops;
 	ret = set_anon_super(s, server);
 	if (ret == 0)
-		server->s_dev = s->s_dev;
+		server->s_dev = s->s_view.v_dev;
 	return ret;
 }
 
@@ -2708,7 +2708,7 @@ EXPORT_SYMBOL_GPL(nfs_fs_mount);
 void nfs_kill_super(struct super_block *s)
 {
 	struct nfs_server *server = NFS_SB(s);
-	dev_t dev = s->s_dev;
+	dev_t dev = s->s_view.v_dev;
 
 	generic_shutdown_super(s);
 
fs/nfsd/nfs3xdr.c +1 -1
index 1a70581e1cb2..d432f7020d39 100644
@@ -147,7 +147,7 @@ static __be32 *encode_fsid(__be32 *p, struct svc_fh *fhp)
 	default:
 	case FSIDSOURCE_DEV:
 		p = xdr_encode_hyper(p, (u64)huge_encode_dev
-				     (fhp->fh_dentry->d_sb->s_dev));
+				     (fhp->fh_dentry->d_sb->s_view.v_dev));
 		break;
 	case FSIDSOURCE_FSID:
 		p = xdr_encode_hyper(p, (u64) fhp->fh_export->ex_fsid);
fs/nfsd/nfsfh.c +3 -3
index 8aa011820c4a..2f819ae8f47e 100644
@@ -440,7 +440,7 @@ static bool fsid_type_ok_for_exp(u8 fsid_type, struct svc_export *exp)
 {
 	switch (fsid_type) {
 	case FSID_DEV:
-		if (!old_valid_dev(exp_sb(exp)->s_dev))
+		if (!old_valid_dev(exp_sb(exp)->s_view.v_dev))
 			return 0;
 		/* FALL THROUGH */
 	case FSID_MAJOR_MINOR:
@@ -505,7 +505,7 @@ static void set_version_and_fsid_type(struct svc_fh *fhp, struct svc_export *exp
 			else
 				fsid_type = FSID_UUID4_INUM;
 		}
-	} else if (!old_valid_dev(exp_sb(exp)->s_dev))
+	} else if (!old_valid_dev(exp_sb(exp)->s_view.v_dev))
 		/* for newer device numbers, we must use a newer fsid format */
 		fsid_type = FSID_ENCODE_DEV;
 	else
@@ -528,7 +528,7 @@ fh_compose(struct svc_fh *fhp, struct svc_export *exp, struct dentry *dentry,
 	 */
 
 	struct inode * inode = d_inode(dentry);
-	dev_t ex_dev = exp_sb(exp)->s_dev;
+	dev_t ex_dev = exp_sb(exp)->s_view.v_dev;
 
 	dprintk("nfsd: fh_compose(exp %02x:%02x/%ld %pd2, ino=%ld)\n",
 		MAJOR(ex_dev), MINOR(ex_dev),
fs/nilfs2/super.c +1 -1
index 6ffeca84d7c3..0239b1b495db 100644
@@ -1267,7 +1267,7 @@ static int nilfs_identify(char *data, struct nilfs_super_data *sd)
 static int nilfs_set_bdev_super(struct super_block *s, void *data)
 {
 	s->s_bdev = data;
-	s->s_dev = s->s_bdev->bd_dev;
+	s->s_view.v_dev = s->s_bdev->bd_dev;
 	return 0;
 }
 
fs/ocfs2/journal.c +8 -5
index e0047816c7b7..520c3cdee1e1 100644
@@ -1435,7 +1435,8 @@ static int __ocfs2_recovery_thread(void *arg)
 			mlog(ML_ERROR,
 			     "Error %d recovering node %d on device (%u,%u)!\n",
 			     status, node_num,
-			     MAJOR(osb->sb->s_dev), MINOR(osb->sb->s_dev));
+			     MAJOR(osb->sb->s_view.v_dev),
+			     MINOR(osb->sb->s_view.v_dev));
 			mlog(ML_ERROR, "Volume requires unmount.\n");
 		}
 
@@ -1624,8 +1625,9 @@ static int ocfs2_replay_journal(struct ocfs2_super *osb,
 	ocfs2_replay_map_set_state(osb, REPLAY_NEEDED);
 
 	printk(KERN_NOTICE "ocfs2: Begin replay journal (node %d, slot %d) on "\
-	       "device (%u,%u)\n", node_num, slot_num, MAJOR(osb->sb->s_dev),
-	       MINOR(osb->sb->s_dev));
+	       "device (%u,%u)\n", node_num, slot_num,
+	       MAJOR(osb->sb->s_view.v_dev),
+	       MINOR(osb->sb->s_view.v_dev));
 
 	OCFS2_I(inode)->ip_clusters = le32_to_cpu(fe->i_clusters);
 
@@ -1681,8 +1683,9 @@ static int ocfs2_replay_journal(struct ocfs2_super *osb,
 	jbd2_journal_destroy(journal);
 
 	printk(KERN_NOTICE "ocfs2: End replay journal (node %d, slot %d) on "\
-	       "device (%u,%u)\n", node_num, slot_num, MAJOR(osb->sb->s_dev),
-	       MINOR(osb->sb->s_dev));
+	       "device (%u,%u)\n", node_num, slot_num,
+	       MAJOR(osb->sb->s_view.v_dev),
+	       MINOR(osb->sb->s_view.v_dev));
 done:
 	/* drop the lock on this nodes journal */
 	if (got_lock)
fs/ocfs2/ocfs2_trace.h +2 -2
index e2a11aaece10..cb9b7bd9e0c4 100644
@@ -700,8 +700,8 @@ TRACE_EVENT(ocfs2_trim_extent,
 		__field(__u64,	count)
 	),
 	TP_fast_assign(
-		__entry->dev_major = MAJOR(sb->s_dev);
-		__entry->dev_minor = MINOR(sb->s_dev);
+		__entry->dev_major = MAJOR(sb->s_view.v_dev);
+		__entry->dev_minor = MINOR(sb->s_view.v_dev);
 		__entry->blk = blk;
 		__entry->count = count;
 	),
fs/ocfs2/super.c +2 -2
index ffa4952d432b..7d9d34c360e4 100644
@@ -1973,7 +1973,7 @@ static void ocfs2_dismount_volume(struct super_block *sb, int mnt_err)
 
 	ocfs2_delete_osb(osb);
 	kfree(osb);
-	sb->s_dev = 0;
+	sb->s_view.v_dev = 0;
 	sb->s_fs_info = NULL;
 }
 
@@ -2102,7 +2102,7 @@ static int ocfs2_initialize_super(struct super_block *sb,
 	ocfs2_init_node_maps(osb);
 
 	snprintf(osb->dev_str, sizeof(osb->dev_str), "%u,%u",
-		 MAJOR(osb->sb->s_dev), MINOR(osb->sb->s_dev));
+		 MAJOR(osb->sb->s_view.v_dev), MINOR(osb->sb->s_view.v_dev));
 
 	osb->max_slots = le16_to_cpu(di->id2.i_super.s_max_slots);
 	if (osb->max_slots > OCFS2_MAX_SLOTS || osb->max_slots == 0) {
fs/overlayfs/inode.c +2 -2
index ebf2a857d547..6169f36337bf 100644
@@ -132,7 +132,7 @@ int ovl_getattr(const struct path *path, struct kstat *stat,
 			 * number are unique, so we use the overlay st_dev,
 			 * which is friendly to du -x.
 			 */
-			stat->dev = dentry->d_sb->s_dev;
+			stat->dev = dentry->d_sb->s_view.v_dev;
 		} else if (!OVL_TYPE_UPPER(type)) {
 			/*
 			 * For non-samefs setup, to make sure that st_dev/st_ino
@@ -151,7 +151,7 @@ int ovl_getattr(const struct path *path, struct kstat *stat,
 		 * overlay st_dev} is not unique, so use the non persistent
 		 * overlay st_ino for directories.
 		 */
-		stat->dev = dentry->d_sb->s_dev;
+		stat->dev = dentry->d_sb->s_view.v_dev;
 		stat->ino = dentry->d_inode->i_ino;
 	}
 
fs/overlayfs/readdir.c +2 -2
index c11f5c0906c3..3b2ce71de48d 100644
@@ -489,7 +489,7 @@ static int ovl_cache_update_ino(struct path *path, struct ovl_cache_entry *p)
 		if (err)
 			goto fail;
 
-		WARN_ON_ONCE(dir->d_sb->s_dev != stat.dev);
+		WARN_ON_ONCE(dir->d_sb->s_view.v_dev != stat.dev);
 		ino = stat.ino;
 	}
 
@@ -660,7 +660,7 @@ static int ovl_iterate_real(struct file *file, struct dir_context *ctx)
 		if (err)
 			return err;
 
-		WARN_ON_ONCE(dir->d_sb->s_dev != stat.dev);
+		WARN_ON_ONCE(dir->d_sb->s_view.v_dev != stat.dev);
 		rdt.parent_ino = stat.ino;
 	}
 
fs/proc_namespace.c +1 -1
index e16fb8f2049e..842d6f4fe014 100644
@@ -137,7 +137,7 @@ static int show_mountinfo(struct seq_file *m, struct vfsmount *mnt)
 	int err;
 
 	seq_printf(m, "%i %i %u:%u ", r->mnt_id, r->mnt_parent->mnt_id,
-		   MAJOR(sb->s_dev), MINOR(sb->s_dev));
+		   MAJOR(sb->s_view.v_dev), MINOR(sb->s_view.v_dev));
 	if (sb->s_op->show_path) {
 		err = sb->s_op->show_path(m, mnt->mnt_root);
 		if (err)
fs/quota/dquot.c +1 -1
index ba6d549323cb..124f8dff5214 100644
@@ -1242,7 +1242,7 @@ static void flush_warnings(struct dquot_warn *warn)
 		print_warning(&warn[i]);
 #endif
 		quota_send_warning(warn[i].w_dq_id,
-				   warn[i].w_sb->s_dev, warn[i].w_type);
+				   warn[i].w_sb->s_view.v_dev, warn[i].w_type);
 	}
 }
 
fs/reiserfs/journal.c +3 -3
index aefcb77de3fd..7c20afe62014 100644
@@ -2613,14 +2613,14 @@ static int journal_init_dev(struct super_block *super,
 
 	journal->j_dev_bd = NULL;
 	jdev = SB_ONDISK_JOURNAL_DEVICE(super) ?
-	    new_decode_dev(SB_ONDISK_JOURNAL_DEVICE(super)) : super->s_dev;
+	    new_decode_dev(SB_ONDISK_JOURNAL_DEVICE(super)) : super->s_view.v_dev;
 
 	if (bdev_read_only(super->s_bdev))
 		blkdev_mode = FMODE_READ;
 
 	/* there is no "jdev" option and journal is on separate device */
 	if ((!jdev_name || !jdev_name[0])) {
-		if (jdev == super->s_dev)
+		if (jdev == super->s_view.v_dev)
 			blkdev_mode &= ~FMODE_EXCL;
 		journal->j_dev_bd = blkdev_get_by_dev(jdev, blkdev_mode,
 						      journal);
@@ -2632,7 +2632,7 @@ static int journal_init_dev(struct super_block *super,
 					 "cannot init journal device '%s': %i",
 					 __bdevname(jdev, b), result);
 			return result;
-		} else if (jdev != super->s_dev)
+		} else if (jdev != super->s_view.v_dev)
 			set_blocksize(journal->j_dev_bd, super->s_blocksize);
 
 		return 0;
fs/romfs/super.c +3 -3
index eb0b7d3775bb..f9d9d99a32e9 100644
@@ -433,8 +433,8 @@ static int romfs_statfs(struct dentry *dentry, struct kstatfs *buf)
 	 */
 	if (sb->s_bdev)
 		id = huge_encode_dev(sb->s_bdev->bd_dev);
-	else if (sb->s_dev)
-		id = huge_encode_dev(sb->s_dev);
+	else if (sb->s_view.v_dev)
+		id = huge_encode_dev(sb->s_view.v_dev);
 
 	buf->f_type = ROMFS_MAGIC;
 	buf->f_namelen = ROMFS_MAXFN;
@@ -510,7 +510,7 @@ static int romfs_fill_super(struct super_block *sb, void *data, int silent)
 #ifdef CONFIG_ROMFS_ON_MTD
 	/* Use same dev ID from the underlying mtdblock device */
 	if (sb->s_mtd)
-		sb->s_dev = MKDEV(MTD_BLOCK_MAJOR, sb->s_mtd->index);
+		sb->s_view.v_dev = MKDEV(MTD_BLOCK_MAJOR, sb->s_mtd->index);
 #endif
 	/* read the image superblock and check it */
 	rsb = kmalloc(512, GFP_KERNEL);
fs/super.c +4 -4
index 5258a57d410a..dfb5b1c8ef20 100644
@@ -781,7 +781,7 @@ struct super_block *user_get_super(dev_t dev)
 	list_for_each_entry(sb, &super_blocks, s_list) {
 		if (hlist_unhashed(&sb->s_instances))
 			continue;
-		if (sb->s_dev ==  dev) {
+		if (sb->s_view.v_dev ==  dev) {
 			sb->s_count++;
 			spin_unlock(&sb_lock);
 			down_read(&sb->s_umount);
@@ -981,14 +981,14 @@ EXPORT_SYMBOL(free_anon_bdev);
 
 int set_anon_super(struct super_block *s, void *data)
 {
-	return get_anon_bdev(&s->s_dev);
+	return get_anon_bdev(&s->s_view.v_dev);
 }
 
 EXPORT_SYMBOL(set_anon_super);
 
 void kill_anon_super(struct super_block *sb)
 {
-	dev_t dev = sb->s_dev;
+	dev_t dev = sb->s_view.v_dev;
 	generic_shutdown_super(sb);
 	free_anon_bdev(dev);
 }
@@ -1052,7 +1052,7 @@ EXPORT_SYMBOL(mount_ns);
 static int set_bdev_super(struct super_block *s, void *data)
 {
 	s->s_bdev = data;
-	s->s_dev = s->s_bdev->bd_dev;
+	s->s_view.v_dev = s->s_bdev->bd_dev;
 	s->s_bdi = bdi_get(s->s_bdev->bd_bdi);
 
 	return 0;
fs/xfs/scrub/trace.h +13 -13
index 4dc896852bf0..57e6610e29d6 100644
@@ -41,7 +41,7 @@ DECLARE_EVENT_CLASS(xfs_scrub_class,
 		__field(int, error)
 	),
 	TP_fast_assign(
-		__entry->dev = ip->i_mount->m_super->s_dev;
+		__entry->dev = ip->i_mount->m_super->s_view.v_dev;
 		__entry->ino = ip->i_ino;
 		__entry->type = sm->sm_type;
 		__entry->agno = sm->sm_agno;
@@ -83,7 +83,7 @@ TRACE_EVENT(xfs_scrub_op_error,
 		__field(void *, ret_ip)
 	),
 	TP_fast_assign(
-		__entry->dev = sc->mp->m_super->s_dev;
+		__entry->dev = sc->mp->m_super->s_view.v_dev;
 		__entry->type = sc->sm->sm_type;
 		__entry->agno = agno;
 		__entry->bno = bno;
@@ -113,7 +113,7 @@ TRACE_EVENT(xfs_scrub_file_op_error,
 		__field(void *, ret_ip)
 	),
 	TP_fast_assign(
-		__entry->dev = sc->ip->i_mount->m_super->s_dev;
+		__entry->dev = sc->ip->i_mount->m_super->s_view.v_dev;
 		__entry->ino = sc->ip->i_ino;
 		__entry->whichfork = whichfork;
 		__entry->type = sc->sm->sm_type;
@@ -150,7 +150,7 @@ DECLARE_EVENT_CLASS(xfs_scrub_block_error_class,
 		agno = XFS_FSB_TO_AGNO(sc->mp, fsbno);
 		bno = XFS_FSB_TO_AGBNO(sc->mp, fsbno);
 
-		__entry->dev = sc->mp->m_super->s_dev;
+		__entry->dev = sc->mp->m_super->s_view.v_dev;
 		__entry->type = sc->sm->sm_type;
 		__entry->agno = agno;
 		__entry->bno = bno;
@@ -200,7 +200,7 @@ DECLARE_EVENT_CLASS(xfs_scrub_ino_error_class,
 					XFS_INO_TO_AGINO(sc->mp, ino));
 		}
 
-		__entry->dev = sc->mp->m_super->s_dev;
+		__entry->dev = sc->mp->m_super->s_view.v_dev;
 		__entry->ino = ino;
 		__entry->type = sc->sm->sm_type;
 		__entry->agno = agno;
@@ -239,7 +239,7 @@ DECLARE_EVENT_CLASS(xfs_scrub_fblock_error_class,
 		__field(void *, ret_ip)
 	),
 	TP_fast_assign(
-		__entry->dev = sc->ip->i_mount->m_super->s_dev;
+		__entry->dev = sc->ip->i_mount->m_super->s_view.v_dev;
 		__entry->ino = sc->ip->i_ino;
 		__entry->whichfork = whichfork;
 		__entry->type = sc->sm->sm_type;
@@ -273,7 +273,7 @@ TRACE_EVENT(xfs_scrub_incomplete,
 		__field(void *, ret_ip)
 	),
 	TP_fast_assign(
-		__entry->dev = sc->mp->m_super->s_dev;
+		__entry->dev = sc->mp->m_super->s_view.v_dev;
 		__entry->type = sc->sm->sm_type;
 		__entry->ret_ip = ret_ip;
 	),
@@ -301,7 +301,7 @@ TRACE_EVENT(xfs_scrub_btree_op_error,
 	TP_fast_assign(
 		xfs_fsblock_t fsbno = xfs_scrub_btree_cur_fsbno(cur, level);
 
-		__entry->dev = sc->mp->m_super->s_dev;
+		__entry->dev = sc->mp->m_super->s_view.v_dev;
 		__entry->type = sc->sm->sm_type;
 		__entry->btnum = cur->bc_btnum;
 		__entry->level = level;
@@ -342,7 +342,7 @@ TRACE_EVENT(xfs_scrub_ifork_btree_op_error,
 	),
 	TP_fast_assign(
 		xfs_fsblock_t fsbno = xfs_scrub_btree_cur_fsbno(cur, level);
-		__entry->dev = sc->mp->m_super->s_dev;
+		__entry->dev = sc->mp->m_super->s_view.v_dev;
 		__entry->ino = sc->ip->i_ino;
 		__entry->whichfork = cur->bc_private.b.whichfork;
 		__entry->type = sc->sm->sm_type;
@@ -384,7 +384,7 @@ TRACE_EVENT(xfs_scrub_btree_error,
 	),
 	TP_fast_assign(
 		xfs_fsblock_t fsbno = xfs_scrub_btree_cur_fsbno(cur, level);
-		__entry->dev = sc->mp->m_super->s_dev;
+		__entry->dev = sc->mp->m_super->s_view.v_dev;
 		__entry->type = sc->sm->sm_type;
 		__entry->btnum = cur->bc_btnum;
 		__entry->level = level;
@@ -422,7 +422,7 @@ TRACE_EVENT(xfs_scrub_ifork_btree_error,
 	),
 	TP_fast_assign(
 		xfs_fsblock_t fsbno = xfs_scrub_btree_cur_fsbno(cur, level);
-		__entry->dev = sc->mp->m_super->s_dev;
+		__entry->dev = sc->mp->m_super->s_view.v_dev;
 		__entry->ino = sc->ip->i_ino;
 		__entry->whichfork = cur->bc_private.b.whichfork;
 		__entry->type = sc->sm->sm_type;
@@ -463,7 +463,7 @@ DECLARE_EVENT_CLASS(xfs_scrub_sbtree_class,
 	TP_fast_assign(
 		xfs_fsblock_t fsbno = xfs_scrub_btree_cur_fsbno(cur, level);
 
-		__entry->dev = sc->mp->m_super->s_dev;
+		__entry->dev = sc->mp->m_super->s_view.v_dev;
 		__entry->type = sc->sm->sm_type;
 		__entry->btnum = cur->bc_btnum;
 		__entry->agno = XFS_FSB_TO_AGNO(cur->bc_mp, fsbno);
@@ -501,7 +501,7 @@ TRACE_EVENT(xfs_scrub_xref_error,
 		__field(void *, ret_ip)
 	),
 	TP_fast_assign(
-		__entry->dev = sc->mp->m_super->s_dev;
+		__entry->dev = sc->mp->m_super->s_view.v_dev;
 		__entry->type = sc->sm->sm_type;
 		__entry->error = error;
 		__entry->ret_ip = ret_ip;
fs/xfs/xfs_trace.h +42 -42

336 lines not on this page · raw message

fs/xfs/xfs_trans_dquot.c +1 -1
index c3d547211d16..be0850fdbe50 100644
@@ -583,7 +583,7 @@ xfs_quota_warn(
 
 	quota_send_warning(make_kqid(&init_user_ns, qtype,
 				     be32_to_cpu(dqp->q_core.d_id)),
-			   mp->m_super->s_dev, type);
+			   mp->m_super->s_view.v_dev, type);
 }
 
 /*
include/trace/events/ext4.h +18 -18
index 500ae412f483..003844d10b86 100644
@@ -599,7 +599,7 @@ TRACE_EVENT(ext4_discard_blocks,
 	),
 
 	TP_fast_assign(
-		__entry->dev	= sb->s_dev;
+		__entry->dev	= sb->s_view.v_dev;
 		__entry->blk	= blk;
 		__entry->count	= count;
 	),
@@ -625,7 +625,7 @@ DECLARE_EVENT_CLASS(ext4__mb_new_pa,
 	),
 
 	TP_fast_assign(
-		__entry->dev		= ac->ac_sb->s_dev;
+		__entry->dev		= ac->ac_sb->s_view.v_dev;
 		__entry->ino		= ac->ac_inode->i_ino;
 		__entry->pa_pstart	= pa->pa_pstart;
 		__entry->pa_lstart	= pa->pa_lstart;
@@ -694,7 +694,7 @@ TRACE_EVENT(ext4_mb_release_group_pa,
 	),
 
 	TP_fast_assign(
-		__entry->dev		= sb->s_dev;
+		__entry->dev		= sb->s_view.v_dev;
 		__entry->pa_pstart	= pa->pa_pstart;
 		__entry->pa_len		= pa->pa_len;
 	),
@@ -737,7 +737,7 @@ TRACE_EVENT(ext4_mb_discard_preallocations,
 	),
 
 	TP_fast_assign(
-		__entry->dev	= sb->s_dev;
+		__entry->dev	= sb->s_view.v_dev;
 		__entry->needed	= needed;
 	),
 
@@ -874,7 +874,7 @@ TRACE_EVENT(ext4_sync_file_enter,
 	TP_fast_assign(
 		struct dentry *dentry = file->f_path.dentry;
 
-		__entry->dev		= dentry->d_sb->s_dev;
+		__entry->dev		= dentry->d_sb->s_view.v_dev;
 		__entry->ino		= d_inode(dentry)->i_ino;
 		__entry->datasync	= datasync;
 		__entry->parent		= d_inode(dentry->d_parent)->i_ino;
@@ -921,7 +921,7 @@ TRACE_EVENT(ext4_sync_fs,
 	),
 
 	TP_fast_assign(
-		__entry->dev	= sb->s_dev;
+		__entry->dev	= sb->s_view.v_dev;
 		__entry->wait	= wait;
 	),
 
@@ -1078,7 +1078,7 @@ DECLARE_EVENT_CLASS(ext4__mballoc,
 	),
 
 	TP_fast_assign(
-		__entry->dev		= sb->s_dev;
+		__entry->dev		= sb->s_view.v_dev;
 		__entry->ino		= inode ? inode->i_ino : 0;
 		__entry->result_start	= start;
 		__entry->result_group	= group;
@@ -1248,7 +1248,7 @@ DECLARE_EVENT_CLASS(ext4__bitmap_load,
 	),
 
 	TP_fast_assign(
-		__entry->dev	= sb->s_dev;
+		__entry->dev	= sb->s_view.v_dev;
 		__entry->group	= group;
 	),
 
@@ -1434,7 +1434,7 @@ TRACE_EVENT(ext4_unlink_enter,
 	),
 
 	TP_fast_assign(
-		__entry->dev		= dentry->d_sb->s_dev;
+		__entry->dev		= dentry->d_sb->s_view.v_dev;
 		__entry->ino		= d_inode(dentry)->i_ino;
 		__entry->parent		= parent->i_ino;
 		__entry->size		= d_inode(dentry)->i_size;
@@ -1458,7 +1458,7 @@ TRACE_EVENT(ext4_unlink_exit,
 	),
 
 	TP_fast_assign(
-		__entry->dev		= dentry->d_sb->s_dev;
+		__entry->dev		= dentry->d_sb->s_view.v_dev;
 		__entry->ino		= d_inode(dentry)->i_ino;
 		__entry->ret		= ret;
 	),
@@ -1737,7 +1737,7 @@ TRACE_EVENT(ext4_journal_start,
 	),
 
 	TP_fast_assign(
-		__entry->dev		 = sb->s_dev;
+		__entry->dev		 = sb->s_view.v_dev;
 		__entry->ip		 = IP;
 		__entry->blocks		 = blocks;
 		__entry->rsv_blocks	 = rsv_blocks;
@@ -1760,7 +1760,7 @@ TRACE_EVENT(ext4_journal_start_reserved,
 	),
 
 	TP_fast_assign(
-		__entry->dev		 = sb->s_dev;
+		__entry->dev		 = sb->s_view.v_dev;
 		__entry->ip		 = IP;
 		__entry->blocks		 = blocks;
 	),
@@ -1787,8 +1787,8 @@ DECLARE_EVENT_CLASS(ext4__trim,
 	),
 
 	TP_fast_assign(
-		__entry->dev_major	= MAJOR(sb->s_dev);
-		__entry->dev_minor	= MINOR(sb->s_dev);
+		__entry->dev_major	= MAJOR(sb->s_view.v_dev);
+		__entry->dev_minor	= MINOR(sb->s_view.v_dev);
 		__entry->group		= group;
 		__entry->start		= start;
 		__entry->len		= len;
@@ -1872,7 +1872,7 @@ TRACE_EVENT(ext4_get_implied_cluster_alloc_exit,
 	),
 
 	TP_fast_assign(
-		__entry->dev	= sb->s_dev;
+		__entry->dev	= sb->s_view.v_dev;
 		__entry->flags	= map->m_flags;
 		__entry->lblk	= map->m_lblk;
 		__entry->pblk	= map->m_pblk;
@@ -2390,7 +2390,7 @@ DECLARE_EVENT_CLASS(ext4__es_shrink_enter,
 	),
 
 	TP_fast_assign(
-		__entry->dev		= sb->s_dev;
+		__entry->dev		= sb->s_view.v_dev;
 		__entry->nr_to_scan	= nr_to_scan;
 		__entry->cache_cnt	= cache_cnt;
 	),
@@ -2424,7 +2424,7 @@ TRACE_EVENT(ext4_es_shrink_scan_exit,
 	),
 
 	TP_fast_assign(
-		__entry->dev		= sb->s_dev;
+		__entry->dev		= sb->s_view.v_dev;
 		__entry->nr_shrunk	= nr_shrunk;
 		__entry->cache_cnt	= cache_cnt;
 	),
@@ -2499,7 +2499,7 @@ TRACE_EVENT(ext4_es_shrink,
 	),
 
 	TP_fast_assign(
-		__entry->dev		= sb->s_dev;
+		__entry->dev		= sb->s_view.v_dev;
 		__entry->nr_shrunk	= nr_shrunk;
 		__entry->scan_time	= div_u64(scan_time, 1000);
 		__entry->nr_skipped	= nr_skipped;
include/trace/events/f2fs.h +9 -9
index effb2704f3ae..9d67ed3d4dc8 100644
@@ -265,7 +265,7 @@ TRACE_EVENT(f2fs_sync_fs,
 	),
 
 	TP_fast_assign(
-		__entry->dev	= sb->s_dev;
+		__entry->dev	= sb->s_view.v_dev;
 		__entry->dirty	= is_sbi_flag_set(F2FS_SB(sb), SBI_IS_DIRTY);
 		__entry->wait	= wait;
 	),
@@ -570,7 +570,7 @@ TRACE_EVENT(f2fs_background_gc,
 	),
 
 	TP_fast_assign(
-		__entry->dev		= sb->s_dev;
+		__entry->dev		= sb->s_view.v_dev;
 		__entry->wait_ms	= wait_ms;
 		__entry->prefree	= prefree;
 		__entry->free		= free;
@@ -608,7 +608,7 @@ TRACE_EVENT(f2fs_gc_begin,
 	),
 
 	TP_fast_assign(
-		__entry->dev		= sb->s_dev;
+		__entry->dev		= sb->s_view.v_dev;
 		__entry->sync		= sync;
 		__entry->background	= background;
 		__entry->dirty_nodes	= dirty_nodes;
@@ -661,7 +661,7 @@ TRACE_EVENT(f2fs_gc_end,
 	),
 
 	TP_fast_assign(
-		__entry->dev		= sb->s_dev;
+		__entry->dev		= sb->s_view.v_dev;
 		__entry->ret		= ret;
 		__entry->seg_freed	= seg_freed;
 		__entry->sec_freed	= sec_freed;
@@ -713,7 +713,7 @@ TRACE_EVENT(f2fs_get_victim,
 	),
 
 	TP_fast_assign(
-		__entry->dev		= sb->s_dev;
+		__entry->dev		= sb->s_view.v_dev;
 		__entry->type		= type;
 		__entry->gc_type	= gc_type;
 		__entry->alloc_mode	= p->alloc_mode;
@@ -1034,7 +1034,7 @@ DECLARE_EVENT_CLASS(f2fs__bio,
 	),
 
 	TP_fast_assign(
-		__entry->dev		= sb->s_dev;
+		__entry->dev		= sb->s_view.v_dev;
 		__entry->target		= bio_dev(bio);
 		__entry->op		= bio_op(bio);
 		__entry->op_flags	= bio->bi_opf;
@@ -1336,7 +1336,7 @@ TRACE_EVENT(f2fs_write_checkpoint,
 	),
 
 	TP_fast_assign(
-		__entry->dev		= sb->s_dev;
+		__entry->dev		= sb->s_view.v_dev;
 		__entry->reason		= reason;
 		__entry->msg		= msg;
 	),
@@ -1545,7 +1545,7 @@ TRACE_EVENT(f2fs_shrink_extent_tree,
 	),
 
 	TP_fast_assign(
-		__entry->dev = sbi->sb->s_dev;
+		__entry->dev = sbi->sb->s_view.v_dev;
 		__entry->node_cnt = node_cnt;
 		__entry->tree_cnt = tree_cnt;
 	),
@@ -1592,7 +1592,7 @@ DECLARE_EVENT_CLASS(f2fs_sync_dirty_inodes,
 	),
 
 	TP_fast_assign(
-		__entry->dev	= sb->s_dev;
+		__entry->dev	= sb->s_view.v_dev;
 		__entry->type	= type;
 		__entry->count	= count;
 	),
include/trace/events/writeback.h +1 -1
index 7a5bfa93f938..242d1cc3b58f 100644
@@ -223,7 +223,7 @@ DECLARE_EVENT_CLASS(writeback_work_class,
 		strncpy(__entry->name,
 			wb->bdi->dev ? dev_name(wb->bdi->dev) : "(unknown)", 32);
 		__entry->nr_pages = work->nr_pages;
-		__entry->sb_dev = work->sb ? work->sb->s_dev : 0;
+		__entry->sb_dev = work->sb ? work->sb->s_view.v_dev : 0;
 		__entry->sync_mode = work->sync_mode;
 		__entry->for_kupdate = work->for_kupdate;
 		__entry->range_cyclic = work->range_cyclic;
init/do_mounts.c +1 -1
index 7cf4f6dafd5f..724f3b071d62 100644
@@ -369,7 +369,7 @@ static int __init do_mount_root(char *name, char *fs, int flags, void *data)
 
 	sys_chdir("/root");
 	s = current->fs->pwd.dentry->d_sb;
-	ROOT_DEV = s->s_dev;
+	ROOT_DEV = s->s_view.v_dev;
 	printk(KERN_INFO
 	       "VFS: Mounted root (%s filesystem)%s on device %u:%u.\n",
 	       s->s_type->name,
kernel/audit_watch.c +1 -1
index b9f571cc6a7f..72b82db95ecf 100644
@@ -368,7 +368,7 @@ static int audit_get_nd(struct audit_watch *watch, struct path *parent)
 	inode_unlock(d_backing_inode(parent->dentry));
 	if (d_is_positive(d)) {
 		/* update watch filter fields */
-		watch->dev = d->d_sb->s_dev;
+		watch->dev = d->d_sb->s_view.v_dev;
 		watch->ino = d_backing_inode(d)->i_ino;
 	}
 	dput(d);
net/unix/diag.c +1 -1
index 384c84e83462..26b4486c41da 100644
@@ -26,7 +26,7 @@ static int sk_diag_dump_vfs(struct sock *sk, struct sk_buff *nlskb)
 	if (dentry) {
 		struct unix_diag_vfs uv = {
 			.udiag_vfs_ino = d_backing_inode(dentry)->i_ino,
-			.udiag_vfs_dev = dentry->d_sb->s_dev,
+			.udiag_vfs_dev = dentry->d_sb->s_view.v_dev,
 		};
 
 		return nla_put(nlskb, UNIX_DIAG_VFS, sizeof(uv), &uv);
security/tomoyo/realpath.c +2 -2
index 6ff8c21e4fff..dc7eff734fa9 100644
@@ -166,7 +166,7 @@ static char *tomoyo_get_local_path(struct dentry *dentry, char * const buffer,
 		goto prepend_filesystem_name;
 	}
 	/* Use filesystem name for unnamed devices. */
-	if (!MAJOR(sb->s_dev))
+	if (!MAJOR(sb->s_view.v_dev))
 		goto prepend_filesystem_name;
 	{
 		struct inode *inode = d_backing_inode(sb->s_root);
@@ -181,7 +181,7 @@ static char *tomoyo_get_local_path(struct dentry *dentry, char * const buffer,
 	{
 		char name[64];
 		int name_len;
-		const dev_t dev = sb->s_dev;
+		const dev_t dev = sb->s_view.v_dev;
 		name[sizeof(name) - 1] = '\0';
 		snprintf(name, sizeof(name) - 1, "dev(%u,%u):", MAJOR(dev),
 			 MINOR(dev));
Signature · 1 line
2.15.1
#77 lore raw

PATCH 76/76 btrfs: Use fs_view in roots, point inodes to it

In reply to Mark Fasheh

Ensure that our per-subvolume anonymous dev_t gets published to userspace, instead of the global device in struct super_block. We do this by embedding a struct fs_view in btrfs_root. The anonymous device number is placed in view->v_dev. Each inode is then pointed to the view embedded in their owning root.

---
 fs/btrfs/ctree.h     |  7 ++-----
 fs/btrfs/disk-io.c   | 14 ++++++++------
 fs/btrfs/disk-io.h   |  2 +-
 fs/btrfs/inode.c     |  5 +++--
 fs/btrfs/root-tree.c |  2 +-
 5 files changed, 15 insertions(+), 15 deletions(-)
fs/btrfs/ctree.h +2 -5
index a3cca35642e2..cffd3aa51e93 100644
@@ -1216,11 +1216,6 @@ struct btrfs_root {
 	 * protected by inode_lock
 	 */
 	struct radix_tree_root delayed_nodes_tree;
-	/*
-	 * right now this just gets used so that a root has its own devid
-	 * for stat.  It may be used for more later
-	 */
-	dev_t anon_dev;
 
 	spinlock_t root_item_lock;
 	refcount_t refs;
@@ -1262,6 +1257,8 @@ struct btrfs_root {
 
 	/* For qgroup metadata space reserve */
 	atomic64_t qgroup_meta_rsv;
+
+	struct fs_view view; /* fill in and link to inodes for vfs usage */
 };
 
 struct btrfs_file_private {
fs/btrfs/disk-io.c +8 -6
index 334234da997c..c50af14b5856 100644
@@ -1191,7 +1191,8 @@ static void __setup_root(struct btrfs_root *root, struct btrfs_fs_info *fs_info,
 	else
 		root->defrag_trans_start = 0;
 	root->root_key.objectid = objectid;
-	root->anon_dev = 0;
+	memset(&root->view, 0, sizeof(struct fs_view));
+	root->view.v_sb = fs_info->sb;
 
 	spin_lock_init(&root->root_item_lock);
 }
@@ -1463,7 +1464,7 @@ struct btrfs_root *btrfs_read_fs_root(struct btrfs_root *tree_root,
 	return root;
 }
 
-int btrfs_init_fs_root(struct btrfs_root *root)
+int btrfs_init_fs_root(struct btrfs_root *root, struct super_block *sb)
 {
 	int ret;
 	struct btrfs_subvolume_writers *writers;
@@ -1487,7 +1488,8 @@ int btrfs_init_fs_root(struct btrfs_root *root)
 	spin_lock_init(&root->ino_cache_lock);
 	init_waitqueue_head(&root->ino_cache_wait);
 
-	ret = get_anon_bdev(&root->anon_dev);
+	root->view.v_sb = sb;
+	ret = get_anon_bdev(&root->view.v_dev);
 	if (ret)
 		goto fail;
 
@@ -1587,7 +1589,7 @@ struct btrfs_root *btrfs_get_fs_root(struct btrfs_fs_info *fs_info,
 		goto fail;
 	}
 
-	ret = btrfs_init_fs_root(root);
+	ret = btrfs_init_fs_root(root, fs_info->sb);
 	if (ret)
 		goto fail;
 
@@ -3603,8 +3605,8 @@ static void free_fs_root(struct btrfs_root *root)
 	WARN_ON(!RB_EMPTY_ROOT(&root->inode_tree));
 	btrfs_free_block_rsv(root->fs_info, root->orphan_block_rsv);
 	root->orphan_block_rsv = NULL;
-	if (root->anon_dev)
-		free_anon_bdev(root->anon_dev);
+	if (root->view.v_dev)
+		free_anon_bdev(root->view.v_dev);
 	if (root->subv_writers)
 		btrfs_free_subvolume_writers(root->subv_writers);
 	free_extent_buffer(root->node);
fs/btrfs/disk-io.h +1 -1
index 301151a50ac1..af60e7d76449 100644
@@ -72,7 +72,7 @@ int btrfs_read_dev_one_super(struct block_device *bdev, int copy_num,
 int btrfs_commit_super(struct btrfs_fs_info *fs_info);
 struct btrfs_root *btrfs_read_fs_root(struct btrfs_root *tree_root,
 				      struct btrfs_key *location);
-int btrfs_init_fs_root(struct btrfs_root *root);
+int btrfs_init_fs_root(struct btrfs_root *root, struct super_block *sb);
 struct btrfs_root *btrfs_lookup_fs_root(struct btrfs_fs_info *fs_info,
 					u64 root_id);
 int btrfs_insert_fs_root(struct btrfs_fs_info *fs_info,
fs/btrfs/inode.c +3 -2
index 1d4a28a4763a..17e93fb6d871 100644
@@ -5705,6 +5705,7 @@ static int btrfs_init_locked_inode(struct inode *inode, void *p)
 	memcpy(&BTRFS_I(inode)->location, args->location,
 	       sizeof(*args->location));
 	BTRFS_I(inode)->root = args->root;
+	inode->i_view = &args->root->view;
 	return 0;
 }
 
@@ -6346,6 +6347,7 @@ static struct inode *btrfs_new_inode(struct btrfs_trans_handle *trans,
 	BTRFS_I(inode)->root = root;
 	BTRFS_I(inode)->generation = trans->transid;
 	inode->i_generation = BTRFS_I(inode)->generation;
+	inode->i_view = &root->view;
 
 	/*
 	 * We could have gotten an inode number from somebody who was fsynced
@@ -9528,8 +9530,7 @@ static int btrfs_getattr(const struct path *path, struct kstat *stat,
 				  STATX_ATTR_NODUMP);
 
 	generic_fillattr(inode, stat);
-	stat->dev = BTRFS_I(inode)->root->anon_dev;
-
+	stat->dev = inode->i_view->v_dev;
 	spin_lock(&BTRFS_I(inode)->lock);
 	delalloc_bytes = BTRFS_I(inode)->new_delalloc_bytes;
 	spin_unlock(&BTRFS_I(inode)->lock);
fs/btrfs/root-tree.c +1 -1
index aab0194efe46..1e6f820c0974 100644
@@ -308,7 +308,7 @@ int btrfs_find_orphan_roots(struct btrfs_fs_info *fs_info)
 			continue;
 		}
 
-		err = btrfs_init_fs_root(root);
+		err = btrfs_init_fs_root(root, fs_info->sb);
 		if (err) {
 			btrfs_free_fs_root(root);
 			break;
Signature · 1 line
2.15.1
#78 lore raw
In reply to Mark Fasheh
Quoted 11 lines · Mark Fasheh

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.

Devil's Advocate - I'm not looking at the code, I'm commenting on architectural issues I see here.

The XFS subvolume work I've been doing explicitly uses a superblock per subvolume. That's because subvolumes are designed to be completely independent of the backing storage - they know nothing about the underlying storage except to share a BDI for writeback purposes and write to whatever block device the remapping layer gives them at IO time. Hence XFS subvolumes have (at this point) their own unique s_dev, on-disk format configuration, journal, space accounting, etc. i.e. They are fully independent filesystems in their own right, and as such we do not have multiple inode namespaces per superblock.

So this doesn't sound like a "subvolume problem" - it's a "how do we sanely support multiple independent namespaces per superblock" problem. AFAICT, this same problem exists with bind mounts and mount namespaces - they are effectively multiple roots on a single superblock, but it's done at the vfsmount level and so the superblock knows nothing about them.

So this kinda feel like there's still a impedence mismatch between btrfs subvolumes being mounted as subtrees on the underlying root vfsmount rather than being created as truly independent vfs namespaces that share a superblock. To put that as a question: why aren't btrfs subvolumes vfsmounts in their own right, and the unique information subvolume information get stored in (or obtained from) the vfsmount?

Quoted 5 lines

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.

Again, XFS subvolumes don't have this problem. So really we need to frame this discussion in terms of supporting multiple namespaces within a superblock sanely, not subvolumes.

Quoted 11 lines

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:

Quoted 5 lines

- 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.

That's no different to using individual overlay mounts for the thousands of containers that are on the system. This doesn't seem to be a major problem...

Quoted 2 lines

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

Background writeback is backing device focussed, not superblock focussed. It will only iterate the superblocks that have dirty inodes on the bdi writeback lists, not all the superblocks on the bdi. IOWs, this isn't a major problem except for sync() operations that iterate superblocks.....

Quoted 4 lines

- 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.

Not with XFS subvolumes. Freezing the underlying parent filesystem will effectively stop all IO from the mounted subvolumes by freezing remapping calls before IO. Sure, those subvolumes aren't in a consistent state, but we don't freeze userspace so none of the application data is ever in a consistent state when filesystems are frozen.

So, again, I'm not sure there's /subvolume/ problem here. There's definitely a "freeze heirarchy" problem, but that already exists and it's something we talked about at LSFMM because we need to solve it for reliable hibernation.

Quoted 2 lines

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

I'm not convinced yet - it still feels like it's the wrong layer to be solving the multiple namespace per superblock problem....

Cheers,

Dave.

Signature · 2 lines
Dave Chinner
[email protected]
#79 lore raw
Quoted 16 lines · Dave Chinner
Quoted 11 lines · Mark Fasheh

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.

Devil's Advocate - I'm not looking at the code, I'm commenting on architectural issues I see here.

Quoted 10 lines

The XFS subvolume work I've been doing explicitly uses a superblock per subvolume. That's because subvolumes are designed to be completely independent of the backing storage - they know nothing about the underlying storage except to share a BDI for writeback purposes and write to whatever block device the remapping layer gives them at IO time. Hence XFS subvolumes have (at this point) their own unique s_dev, on-disk format configuration, journal, space accounting, etc. i.e. They are fully independent filesystems in their own right, and as such we do not have multiple inode namespaces per superblock.

That's a fundamental difference between how your XFS subvolumes work and how btrfs subvolumes do. There is no independence among btrfs subvolumes. When a snapshot is created, it has a few new blocks but otherwise shares the metadata of the source subvolume. The metadata trees are shared across all of the subvolumes and there are several internal trees used to manage all of it. It's a single storage pool and a single transaction engine. There are housekeeping and maintenance tasks that operate across the entire file system internally. I understand that there are several problems you need to solve at the VFS layer to get your version of subvolumes up and running, but trying to shoehorn one into the other is bound to fail.

Quoted 6 lines

So this doesn't sound like a "subvolume problem" - it's a "how do we sanely support multiple independent namespaces per superblock" problem. AFAICT, this same problem exists with bind mounts and mount namespaces - they are effectively multiple roots on a single superblock, but it's done at the vfsmount level and so the superblock knows nothing about them.

In this case, you're talking about the user-visible file system hierarchy namespace that has no bearing on the underlying file system outside of per-mount flags. It makes sense for that to be above the superblock because the file system doesn't care about them. We're interested in the inode namespace, which for every other file system can be described using an inode and a superblock pair, but btrfs has another layer in the middle: inode -> btrfs_root -> superblock. The lifetime rules for e.g. the s_dev follow that middle layer and a vfsmount can disappear well before the inode does.

Quoted 7 lines

So this kinda feel like there's still a impedence mismatch between btrfs subvolumes being mounted as subtrees on the underlying root vfsmount rather than being created as truly independent vfs namespaces that share a superblock. To put that as a question: why aren't btrfs subvolumes vfsmounts in their own right, and the unique information subvolume information get stored in (or obtained from) the vfsmount?

Those are two separate problems. Using a vfsmount to export the
btrfs_root is on my roadmap. I have a WIP patch set that automounts the subvolumes when stepping into a new one, but it's to fix a longstanding UX wart. Ultimately, vfsmounts are at the wrong level to solve the inode namespace problem. Again, there's the lifetime issue. There are also many places where we only have an inode and need the s_dev associated with it. Most of these sites are well removed from having access to a vfsmount and pinning one and passing it around carries no other benefit.

Quoted 27 lines
Quoted 5 lines

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.

Again, XFS subvolumes don't have this problem. So really we need to frame this discussion in terms of supporting multiple namespaces within a superblock sanely, not subvolumes.

Quoted 11 lines

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:

Quoted 5 lines

- 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.

Quoted 3 lines

That's no different to using individual overlay mounts for the thousands of containers that are on the system. This doesn't seem to be a major problem...

Overlay mounts are indepedent of one another and don't need coordination among them. The memory usage is relatively unimportant. The important part is having a bunch of superblocks that all correspond to the same resources and coordinating them at the VFS level. Your assumptions below follow how your XFS subvolumes work, where there's a clear hierarchy between the subvolumes and the master filesystem with a mapping layer between them. Btrfs subvolumes have no such hierarchy. Everything is shared. So while we could use a writeback hierarchy to merge all of the inode lists before doing writeback on the 'master' superblock, we'd gain nothing by it. Handling anything involving s_umount with a superblock per subvolume would be a nightmare. Ultimately, it would be a ton of effort that amounts to working around the VFS instead of with it.

Quoted 21 lines
Quoted 2 lines

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

Background writeback is backing device focussed, not superblock focussed. It will only iterate the superblocks that have dirty inodes on the bdi writeback lists, not all the superblocks on the bdi. IOWs, this isn't a major problem except for sync() operations that iterate superblocks.....

Quoted 4 lines

- 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.

Not with XFS subvolumes. Freezing the underlying parent filesystem will effectively stop all IO from the mounted subvolumes by freezing remapping calls before IO. Sure, those subvolumes aren't in a consistent state, but we don't freeze userspace so none of the application data is ever in a consistent state when filesystems are frozen.

Quoted 4 lines

So, again, I'm not sure there's /subvolume/ problem here. There's definitely a "freeze heirarchy" problem, but that already exists and it's something we talked about at LSFMM because we need to solve it for reliable hibernation.

There's only a freeze hierarchy problem if we have to use multiple superblocks. Otherwise, we freeze the whole thing or we don't. Trying to freeze a single subvolume would be an illusion for the user since the underlying file system would still be active underneath it. Under the hood, things like relocation don't even look at what subvolume owns a particular extent until it must. So it could be coordinating thousands of superblocks to do what a single lock does now and for what benefit?

Quoted 5 lines
Quoted 2 lines

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

I'm not convinced yet - it still feels like it's the wrong layer to be solving the multiple namespace per superblock problem....

It needs to be between the inode and the superblock. If there are multiple user-visible namespaces, each will still get the same underlying file system namespace.

-Jeff

Signature · 2 lines
Jeff Mahoney
SUSE Labs
#80 lore raw
Quoted 28 lines · Jeff Mahoney
Quoted 16 lines · Dave Chinner
Quoted 11 lines · Mark Fasheh

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.

Devil's Advocate - I'm not looking at the code, I'm commenting on architectural issues I see here.

Quoted 10 lines

The XFS subvolume work I've been doing explicitly uses a superblock per subvolume. That's because subvolumes are designed to be completely independent of the backing storage - they know nothing about the underlying storage except to share a BDI for writeback purposes and write to whatever block device the remapping layer gives them at IO time. Hence XFS subvolumes have (at this point) their own unique s_dev, on-disk format configuration, journal, space accounting, etc. i.e. They are fully independent filesystems in their own right, and as such we do not have multiple inode namespaces per superblock.

Quoted 2 lines

That's a fundamental difference between how your XFS subvolumes work and how btrfs subvolumes do.

Yup, you've just proved my point: this is not a "subvolume problem"; but rather a "multiple namespace per root" problem.

Quoted 5 lines

There is no independence among btrfs
subvolumes. When a snapshot is created, it has a few new blocks but otherwise shares the metadata of the source subvolume. The metadata trees are shared across all of the subvolumes and there are several internal trees used to manage all of it.

I don't need btrfs 101 stuff explained to me. :/

Quoted 5 lines

a single transaction engine. There are housekeeping and maintenance tasks that operate across the entire file system internally. I understand that there are several problems you need to solve at the VFS layer to get your version of subvolumes up and running, but trying to shoehorn one into the other is bound to fail.

Actually, the VFS has provided everything I need for XFS subvolumes so far without requiring any sort of modifications. That's the perspective I'm approaching this from - if the VFS can do what we need for XFS subvolumes, as well as overlay (which are effectively VFS-based COW subvolumes), then lets see if we can make that work for btrfs too.

Quoted 10 lines
Quoted 6 lines

So this doesn't sound like a "subvolume problem" - it's a "how do we sanely support multiple independent namespaces per superblock" problem. AFAICT, this same problem exists with bind mounts and mount namespaces - they are effectively multiple roots on a single superblock, but it's done at the vfsmount level and so the superblock knows nothing about them.

In this case, you're talking about the user-visible file system hierarchy namespace that has no bearing on the underlying file system outside of per-mount flags.

Except that it tracks and provides infrastructure that allows user visible "multiple namespace per root" constructs. Subvolumes - as a user visible namespace construct - are little different to bind mounts in behaviour and functionality.

How the underlying filesystem implements subvolumes is really up to the filesystem, but we should be trying to implement a clean model for "multiple namespaces on a single root" at the VFS so we have consistent behaviour across all filesystems that implement similar functionality.

FWIW, bind mounts and overlay also have similar inode number namespace problems to what Mark describes for btrfs subvolumes. e.g. overlay recently introduce the "xino" mount option to separate the user presented inode number namespace for overlay inode from the underlying parent filesystem inodes. How is that different to btrfs subvolumes needing to present different inode number namespaces from the underlying parent?

This sort of "namespace shifting" is needed for several different pieces of information the kernel reports to userspace. The VFS replacement for shiftfs is an example of this. So is inode number remapping. I'm sure there's more.

My point is that if we are talking about infrastructure to remap what userspace sees from different mountpoint views into a filesystem, then it should be done above the filesystem layers in the VFS so all filesystems behave the same way. And in this case, the vfsmount maps exactly to the "fs_view" that Mark has proposed we add to the superblock.....

Quoted 5 lines

It makes sense for that to be above the
superblock because the file system doesn't care about them. We're interested in the inode namespace, which for every other file system can be described using an inode and a superblock pair, but btrfs has another layer in the middle: inode -> btrfs_root -> superblock.

Which seems to me to be irrelevant if there's a vfsmount per subvolume that can hold per-subvolume information.

Quoted 8 lines
Quoted 7 lines

So this kinda feel like there's still a impedence mismatch between btrfs subvolumes being mounted as subtrees on the underlying root vfsmount rather than being created as truly independent vfs namespaces that share a superblock. To put that as a question: why aren't btrfs subvolumes vfsmounts in their own right, and the unique information subvolume information get stored in (or obtained from) the vfsmount?

Quoted 4 lines

Those are two separate problems. Using a vfsmount to export the
btrfs_root is on my roadmap. I have a WIP patch set that automounts the subvolumes when stepping into a new one, but it's to fix a longstanding UX wart.

IMO that's more than a UX wart - th elack of vfsmounts for internal subvolume mount point traversals could be considered the root cause of the issues we are discussing here. Extending the mounted namespace should trigger vfs mounts, not be hidden deep inside the filesystem. Hence I'd suggest this needs changing before anything else....

Quoted 14 lines
Quoted 10 lines
Quoted 9 lines

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.

Quoted 3 lines

That's no different to using individual overlay mounts for the thousands of containers that are on the system. This doesn't seem to be a major problem...

Quoted 8 lines

Overlay mounts are indepedent of one another and don't need coordination among them. The memory usage is relatively unimportant. The important part is having a bunch of superblocks that all correspond to the same resources and coordinating them at the VFS level. Your assumptions below follow how your XFS subvolumes work, where there's a clear hierarchy between the subvolumes and the master filesystem with a mapping layer between them. Btrfs subvolumes have no such hierarchy. Everything is shared.

Yup, that's the impedence mismatch between the VFS infrastructure and btrfs that I was talking about. What I'm trying to communicate is that I think the proposal is attacking the impedence mismatch from the wrong direction.

i.e. The proposal is to modify btrfs code to propagate stuff that btrfs needs to know to deal with it's internal "everything is shared" problems up into the VFS where it's probably not useful to anything other than btrfs. We already have the necessary construct in the VFS - I think we should be trying to use the information held by the generic VFS infrastructure to solve the solve the specific btrfs issue at hand....

Quoted 6 lines

So while we could use a writeback hierarchy to
merge all of the inode lists before doing writeback on the 'master' superblock, we'd gain nothing by it. Handling anything involving s_umount with a superblock per subvolume would be a nightmare. Ultimately, it would be a ton of effort that amounts to working around the VFS instead of with it.

I'm not suggesting that btrfs needs to use a superblock per subvolume. Please don't confuse my statements along the lines of "this doesn't seem to be a problem for others" with "you must change btrfs to do this". I'm just saying that the problems arising from using a superblock per subvolume are not as dire as is being implied.

Cheers,

Dave.

Signature · 2 lines
Dave Chinner
[email protected]
#81 lore raw

cover vfs: 'views' for filesystems with more than one root

Sorry, just getting back to this.

Quoted 29 lines · Dave Chinner
Quoted 28 lines · Jeff Mahoney
Quoted 26 lines · Dave Chinner
Quoted 11 lines · Mark Fasheh

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.

Devil's Advocate - I'm not looking at the code, I'm commenting on architectural issues I see here.

The XFS subvolume work I've been doing explicitly uses a superblock per subvolume. That's because subvolumes are designed to be completely independent of the backing storage - they know nothing about the underlying storage except to share a BDI for writeback purposes and write to whatever block device the remapping layer gives them at IO time. Hence XFS subvolumes have (at this point) their own unique s_dev, on-disk format configuration, journal, space accounting, etc. i.e. They are fully independent filesystems in their own right, and as such we do not have multiple inode namespaces per superblock.

Quoted 5 lines
Quoted 2 lines

That's a fundamental difference between how your XFS subvolumes work and how btrfs subvolumes do.

Yup, you've just proved my point: this is not a "subvolume problem"; but rather a "multiple namespace per root" problem.

Mark framed it as a namespace issue initially. The btrfs subvolume problem is the biggest one we're concerned with. More below.

Quoted 7 lines
Quoted 5 lines

There is no independence among btrfs
subvolumes. When a snapshot is created, it has a few new blocks but otherwise shares the metadata of the source subvolume. The metadata trees are shared across all of the subvolumes and there are several internal trees used to manage all of it.

I don't need btrfs 101 stuff explained to me. :/

No offense meant. This was crossposted to a few lists.

Quoted 6 lines
Quoted 5 lines

a single transaction engine. There are housekeeping and maintenance tasks that operate across the entire file system internally. I understand that there are several problems you need to solve at the VFS layer to get your version of subvolumes up and running, but trying to shoehorn one into the other is bound to fail.

Quoted 6 lines

Actually, the VFS has provided everything I need for XFS subvolumes so far without requiring any sort of modifications. That's the perspective I'm approaching this from - if the VFS can do what we need for XFS subvolumes, as well as overlay (which are effectively VFS-based COW subvolumes), then lets see if we can make that work for btrfs too.

I'm glad that the VFS provides what you need for XFS subvolumes, but you're effectively creating independent file systems using a backend storage remapping technique. That's pretty much exactly what the VFS is already designed to do. Overlayfs is definitely not just VFS-based CoW subvolumes. I ended up having to wade more deeply into overlayfs than I would've liked to respond to your email. I'd say it's better described as Overlayfs can abuse what the VFS offers just enough to work well in common cases. It has a similar disconnect between the superblock and inode to btrfs except that it's not as easily resolved since the dentry belongs to overlayfs and the inode belongs to the underlying file system. There are still places getting this wrong in the kernel. In order to reliably present the right inode/dev pair for overlayfs, we need the dentry to go with it. We don't always have it and, even if we did, we'd need both the dentry and inode.

At any rate, anything with a ->getattr that modifies dev or ino so that it's different from inode->i_sb->s_dev or inode->i_ino will misbehave somehow. The question is just how badly, which depends on the context. It could be something simple like /proc/pid/maps not showing the right device/ino pair. Many file systems that use 64-bit inode numbers already remap them on 32-bit systems, which can already cause collisions (even inside the kernel) when comparisons are made. There's no excuse to not use 64-bit inode numbers everywhere inside the kernel now, especially since we have the capability to export them as 64-bit inode numbers on 32-bit systems now via statx.

One thing is clear: If we want to solve the btrfs and overlayfs problems in the same way, the view approach with a simple static mapping doesn't work. Sticking something between the inode and superblock doesn't get the job done when the belongs to a different file system. Overlayfs needs a per-object remapper, which means a callback that takes a path. Suddenly the way we do things in the SUSE kernel doesn't seem so hacky anymore.

I'm not sure we need the same solution for btrfs and overlayfs. It's not the same problem. Every object in overlayfs as a unique mapping already. If we report s_dev and i_ino from the inode, it still maps to a unique user-visible object. It may not map back to the overlayfs name, but that's a separate issue that's more difficult to solve. The btrfs issue isn't one of presenting an alternative namespace to the user. Btrfs has multiple internal namespaces and no way to publish them to the rest of the kernel.

Quoted 30 lines
Quoted 10 lines
Quoted 6 lines

So this doesn't sound like a "subvolume problem" - it's a "how do we sanely support multiple independent namespaces per superblock" problem. AFAICT, this same problem exists with bind mounts and mount namespaces - they are effectively multiple roots on a single superblock, but it's done at the vfsmount level and so the superblock knows nothing about them.

In this case, you're talking about the user-visible file system hierarchy namespace that has no bearing on the underlying file system outside of per-mount flags.

Except that it tracks and provides infrastructure that allows user visible "multiple namespace per root" constructs. Subvolumes - as a user visible namespace construct - are little different to bind mounts in behaviour and functionality.

How the underlying filesystem implements subvolumes is really up to the filesystem, but we should be trying to implement a clean model for "multiple namespaces on a single root" at the VFS so we have consistent behaviour across all filesystems that implement similar functionality.

FWIW, bind mounts and overlay also have similar inode number namespace problems to what Mark describes for btrfs subvolumes. e.g. overlay recently introduce the "xino" mount option to separate the user presented inode number namespace for overlay inode from the underlying parent filesystem inodes. How is that different to btrfs subvolumes needing to present different inode number namespaces from the underlying parent?

Quoted 4 lines

This sort of "namespace shifting" is needed for several different pieces of information the kernel reports to userspace. The VFS replacement for shiftfs is an example of this. So is inode number remapping. I'm sure there's more.

Djalal's work? That rightfully belongs above the file system layer. The only bit that's needed within the file system is the part that sets the super flag to enable it. The different namespaces have nothing to do with the file system below it.

Quoted 6 lines

My point is that if we are talking about infrastructure to remap what userspace sees from different mountpoint views into a filesystem, then it should be done above the filesystem layers in the VFS so all filesystems behave the same way. And in this case, the vfsmount maps exactly to the "fs_view" that Mark has proposed we add to the superblock.....

It's proposed to be above the superblock with a default view in the superblock. It would sit between the inode and the superblock so we have access to it anywhere we already have an inode. That's the main difference. We already have the inode everywhere it's needed. Plumbing a vfsmount everywhere needed means changing code that only requires an inode and doesn't need a vfsmount.

The two biggest problem areas:
- Writeback tracepoints print a dev/inode pair. Do we want to plumb a vfsmount into __mark_inode_dirty, super_operations->write_inode, __writeback_single_inode, writeback_sb_inodes, etc?
- Audit. As it happens, most of audit has a path or file that can be used. We do run into problems with fsnotify. fsnotify_move is called from vfs_rename which turns into a can of worms pretty quickly.

Quoted 8 lines
Quoted 5 lines

It makes sense for that to be above the
superblock because the file system doesn't care about them. We're interested in the inode namespace, which for every other file system can be described using an inode and a superblock pair, but btrfs has another layer in the middle: inode -> btrfs_root -> superblock.

Which seems to me to be irrelevant if there's a vfsmount per subvolume that can hold per-subvolume information.

I disagree. There are a ton of places where we only have access to an inode and only need access to an inode. It also doesn't solve the overlayfs issue.

Quoted 13 lines
Quoted 8 lines
Quoted 7 lines

So this kinda feel like there's still a impedence mismatch between btrfs subvolumes being mounted as subtrees on the underlying root vfsmount rather than being created as truly independent vfs namespaces that share a superblock. To put that as a question: why aren't btrfs subvolumes vfsmounts in their own right, and the unique information subvolume information get stored in (or obtained from) the vfsmount?

Quoted 4 lines

Those are two separate problems. Using a vfsmount to export the
btrfs_root is on my roadmap. I have a WIP patch set that automounts the subvolumes when stepping into a new one, but it's to fix a longstanding UX wart.

Quoted 6 lines

IMO that's more than a UX wart - th elack of vfsmounts for internal subvolume mount point traversals could be considered the root cause of the issues we are discussing here. Extending the mounted namespace should trigger vfs mounts, not be hidden deep inside the filesystem. Hence I'd suggest this needs changing before anything else....

I disagree. Yes, it would be nice if btrfs did this, but it doesn't get us the dev/ino pair to places where we need one, like the depths of audit.

Quoted 28 lines
Quoted 14 lines
Quoted 10 lines
Quoted 9 lines

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.

Quoted 3 lines

That's no different to using individual overlay mounts for the thousands of containers that are on the system. This doesn't seem to be a major problem...

Quoted 8 lines

Overlay mounts are indepedent of one another and don't need coordination among them. The memory usage is relatively unimportant. The important part is having a bunch of superblocks that all correspond to the same resources and coordinating them at the VFS level. Your assumptions below follow how your XFS subvolumes work, where there's a clear hierarchy between the subvolumes and the master filesystem with a mapping layer between them. Btrfs subvolumes have no such hierarchy. Everything is shared.

Yup, that's the impedence mismatch between the VFS infrastructure and btrfs that I was talking about. What I'm trying to communicate is that I think the proposal is attacking the impedence mismatch from the wrong direction.

Quoted 7 lines

i.e. The proposal is to modify btrfs code to propagate stuff that btrfs needs to know to deal with it's internal "everything is shared" problems up into the VFS where it's probably not useful to anything other than btrfs. We already have the necessary construct in the VFS - I think we should be trying to use the information held by the generic VFS infrastructure to solve the solve the specific btrfs issue at hand....

The many namespaces to one I/O domain relationship isn't a btrfs-internal problem. It's visible to the user and it's visible inside the kernel. The view implementation gives the VFS a generic mechanism to allow it to represent that. The plan isn't to only use the view for that but to also allow separate security contexts for things like containers. Those have a similar issue to the inode availability discussed above. We have superblocks where we need them. We could have a view just as a easily. Plumbing a vfsmount is the wrong approach.

Quoted 7 lines
Quoted 6 lines

So while we could use a writeback hierarchy to
merge all of the inode lists before doing writeback on the 'master' superblock, we'd gain nothing by it. Handling anything involving s_umount with a superblock per subvolume would be a nightmare. Ultimately, it would be a ton of effort that amounts to working around the VFS instead of with it.

Quoted 6 lines

I'm not suggesting that btrfs needs to use a superblock per subvolume. Please don't confuse my statements along the lines of "this doesn't seem to be a problem for others" with "you must change btrfs to do this". I'm just saying that the problems arising from using a superblock per subvolume are not as dire as is being implied.

It's possible to solve the btrfs problem this way but it adds a bunch of complexity for... what benefit, exactly? As I said, it's working around the VFS instead of working with it. As Mark initially stated, we handle I/O and namespace domains. Btrfs has many namespaces and only one I/O domain.

-Jeff

Signature · 2 lines
Jeff Mahoney
SUSE Labs
maintainer
#82 lore raw
Quoted 18 lines · Jeff Mahoney

Sorry, just getting back to this.

Quoted 15 lines · Dave Chinner
Quoted 14 lines · Jeff Mahoney
Quoted 13 lines · Dave Chinner
Quoted 11 lines · Mark Fasheh

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.

Speaking as someone who joined this discussion late, maybe years after it started, it would help to get an overview of existing problems and how fs_view aims to solve them.

I do believe that both Overlayfs and Btrfs can benefit from a layer of abstraction
in the VFS, but I think it is best if we start with laying all the common problems
and then see how a solution would look like.

Even the name of the abstraction (fs_view) doesn't make it clear to me what it is we are abstracting (security context? st_dev? what else?). probably best to try to describe the abstraction from user POV rather then give sporadic examples of what MAY go into fs_view.

While at it, need to see if this discussion has any intersections with David Howell's fs_context work, because if we consider adding sub volume support to VFS, we may want to leave some reserved bits in the API for it.

[...]

Quoted 8 lines

One thing is clear: If we want to solve the btrfs and overlayfs problems in the same way, the view approach with a simple static mapping doesn't work. Sticking something between the inode and superblock doesn't get the job done when the belongs to a different file system. Overlayfs needs a per-object remapper, which means a callback that takes a path. Suddenly the way we do things in the SUSE kernel doesn't seem so hacky anymore.

And what is the SUSE way?

Quoted 9 lines

I'm not sure we need the same solution for btrfs and overlayfs. It's not the same problem. Every object in overlayfs as a unique mapping already. If we report s_dev and i_ino from the inode, it still maps to a unique user-visible object. It may not map back to the overlayfs name, but that's a separate issue that's more difficult to solve. The btrfs issue isn't one of presenting an alternative namespace to the user. Btrfs has multiple internal namespaces and no way to publish them to the rest of the kernel.

FYI, the Overlayfs file/inode mapping is about to change with many VFS hacks queued for removal, so stay tuned.

[...]

Quoted 14 lines
Quoted 6 lines

My point is that if we are talking about infrastructure to remap what userspace sees from different mountpoint views into a filesystem, then it should be done above the filesystem layers in the VFS so all filesystems behave the same way. And in this case, the vfsmount maps exactly to the "fs_view" that Mark has proposed we add to the superblock.....

It's proposed to be above the superblock with a default view in the superblock. It would sit between the inode and the superblock so we have access to it anywhere we already have an inode. That's the main difference. We already have the inode everywhere it's needed. Plumbing a vfsmount everywhere needed means changing code that only requires an inode and doesn't need a vfsmount.

Quoted 8 lines

The two biggest problem areas:
- Writeback tracepoints print a dev/inode pair. Do we want to plumb a vfsmount into __mark_inode_dirty, super_operations->write_inode, __writeback_single_inode, writeback_sb_inodes, etc?
- Audit. As it happens, most of audit has a path or file that can be used. We do run into problems with fsnotify. fsnotify_move is called from vfs_rename which turns into a can of worms pretty quickly.

Can you please elaborate on that problem.
Do you mean when watching a directory for changes, you need to be able to tell in which fs_view the directory inode that is being watched?

Quoted 6 lines
Quoted 6 lines
Quoted 5 lines

It makes sense for that to be above the
superblock because the file system doesn't care about them. We're interested in the inode namespace, which for every other file system can be described using an inode and a superblock pair, but btrfs has another layer in the middle: inode -> btrfs_root -> superblock.

Quoted 7 lines
Quoted 2 lines

Which seems to me to be irrelevant if there's a vfsmount per subvolume that can hold per-subvolume information.

I disagree. There are a ton of places where we only have access to an inode and only need access to an inode. It also doesn't solve the overlayfs issue.

I have an interest of solving another problem.
In VFS operations where only inode is available, I would like to be able to report fsnotify events (e.g. fsnotify_move()) only in directories under a certain subtree root. That could be achieved either by bind mount the subtree root and passing vfsmount into vfs_rename() or by defining an fs_view on the subtree and mounting that fs_view.

Thanks,
Amir.

#83 lore raw

Hi Amir, thanks for the comments!

Quoted 30 lines · Amir Goldstein
Quoted 18 lines · Jeff Mahoney

Sorry, just getting back to this.

Quoted 15 lines · Dave Chinner
Quoted 14 lines · Jeff Mahoney
Quoted 13 lines · Dave Chinner
Quoted 11 lines · Mark Fasheh

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.

Speaking as someone who joined this discussion late, maybe years after it started, it would help to get an overview of existing problems and how fs_view aims to solve them.

I do believe that both Overlayfs and Btrfs can benefit from a layer of abstraction
in the VFS, but I think it is best if we start with laying all the common problems
and then see how a solution would look like.

Quoted 4 lines

Even the name of the abstraction (fs_view) doesn't make it clear to me what it is we are abstracting (security context? st_dev? what else?). probably best to try to describe the abstraction from user POV rather then give sporadic examples of what MAY go into fs_view.

The first problem fs_view intended to fix was the s_dev issue, where some filesystems return a different device from stat(2) than what the rest of the kernel exports. If you look at the e-mail record I referenced:

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

you'll see how that can confuse some userspace software when they try to take the ino/dev pair they get from one portion of the kernel (for example, /proc/pid/maps) then use it to resolve to an inode on the system.

As it turns out, there's other places where we might want to decouple some superblock fields, hence why I mention security contexts. I am admittedly less familiar with that particular problem but as I understand it, containers on a btrfs subvolume have to go through an overlay to route around the default security context. With fs_view we could point subvolumes to their own security contexts.

Btw, sorry that the name is confusing. I've never been good at picking them. That said, if you have a minute to check out the first patch or two you'll see that the patches are basically putting a struct in between the super block and the inode.

One thing I'd like to politely suggest is that anyone now following this conversation to please read the at least the first patch. It's an easy read and I feel like the conversation overall would be much more clear if everyone understood what we're going for. I worry that I didn't do a particularly good job explaining the actual code changes.

https://www.spinics.net/lists/linux-fsdevel/msg125492.html

Regarding a layout of the problems, I have a more complete e-mail coming soon which should describe in detail the issues I've seen with respect to how the kernel is exporting ino/dev pairs (outside of statx). fs_view alone is not enough to solve that problem. I'd be happy to CC you on that one if you'd like.

Quoted 15 lines

While at it, need to see if this discussion has any intersections with David Howell's fs_context work, because if we consider adding sub volume support to VFS, we may want to leave some reserved bits in the API for it.

[...]

Quoted 8 lines

One thing is clear: If we want to solve the btrfs and overlayfs problems in the same way, the view approach with a simple static mapping doesn't work. Sticking something between the inode and superblock doesn't get the job done when the belongs to a different file system. Overlayfs needs a per-object remapper, which means a callback that takes a path. Suddenly the way we do things in the SUSE kernel doesn't seem so hacky anymore.

Quoted 1 line

And what is the SUSE way?

At SUSE, we carry a version of this patch:

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

Essentially a callback which was rejected for various reasons.

The fs_view work was intended to replace that patch with an upstream solution.

Quoted 10 lines
Quoted 9 lines

I'm not sure we need the same solution for btrfs and overlayfs. It's not the same problem. Every object in overlayfs as a unique mapping already. If we report s_dev and i_ino from the inode, it still maps to a unique user-visible object. It may not map back to the overlayfs name, but that's a separate issue that's more difficult to solve. The btrfs issue isn't one of presenting an alternative namespace to the user. Btrfs has multiple internal namespaces and no way to publish them to the rest of the kernel.

Quoted 4 lines

FYI, the Overlayfs file/inode mapping is about to change with many VFS hacks queued for removal, so stay tuned.

[...]

Actually, would you mind giving me a pointer to this work? I'd be very interested to see what exactly might be changing.

Quoted 23 lines
Quoted 14 lines
Quoted 6 lines

My point is that if we are talking about infrastructure to remap what userspace sees from different mountpoint views into a filesystem, then it should be done above the filesystem layers in the VFS so all filesystems behave the same way. And in this case, the vfsmount maps exactly to the "fs_view" that Mark has proposed we add to the superblock.....

It's proposed to be above the superblock with a default view in the superblock. It would sit between the inode and the superblock so we have access to it anywhere we already have an inode. That's the main difference. We already have the inode everywhere it's needed. Plumbing a vfsmount everywhere needed means changing code that only requires an inode and doesn't need a vfsmount.

Quoted 8 lines

The two biggest problem areas:
- Writeback tracepoints print a dev/inode pair. Do we want to plumb a vfsmount into __mark_inode_dirty, super_operations->write_inode, __writeback_single_inode, writeback_sb_inodes, etc?
- Audit. As it happens, most of audit has a path or file that can be used. We do run into problems with fsnotify. fsnotify_move is called from vfs_rename which turns into a can of worms pretty quickly.

Quoted 3 lines

Can you please elaborate on that problem.
Do you mean when watching a directory for changes, you need to be able to tell in which fs_view the directory inode that is being watched?

Here Jeff is responding to Dave's suggestion that we use a vfsmount instead of the fs_view. You cannot get to a vfsmount from an inode or even dentry alone, so this implies that we'd be passing a vfsmount down a ton of code that otherwise doesn't care about it.

fs_view has the advantage that it is accesible from the inode so those places which ONLY have an inode can easily get to the correct device (the code changes make this pretty clear).

Quoted 14 lines
Quoted 6 lines
Quoted 6 lines
Quoted 5 lines

It makes sense for that to be above the
superblock because the file system doesn't care about them. We're interested in the inode namespace, which for every other file system can be described using an inode and a superblock pair, but btrfs has another layer in the middle: inode -> btrfs_root -> superblock.

Quoted 7 lines
Quoted 2 lines

Which seems to me to be irrelevant if there's a vfsmount per subvolume that can hold per-subvolume information.

I disagree. There are a ton of places where we only have access to an inode and only need access to an inode. It also doesn't solve the overlayfs issue.

Quoted 6 lines

I have an interest of solving another problem.
In VFS operations where only inode is available, I would like to be able to report fsnotify events (e.g. fsnotify_move()) only in directories under a certain subtree root. That could be achieved either by bind mount the subtree root and passing vfsmount into vfs_rename() or by defining an fs_view on the subtree and mounting that fs_view.

I'm not sure whether fs_view works for this. Taking a quick look at fsnotify, the state is already on the inode? If there's a globabl fsnotify state that needs to be per subtree than yes we could move that to the fs_view and you'd simply deref it from the inode struct.

I hope this helps,

	--Mark
maintainer
#84 lore raw
Quoted 2 lines · Mark Fasheh

Hi Amir, thanks for the comments!

Hi Mark,

[...]

Quoted 2 lines

Btw, sorry that the name is confusing. I've never been good at picking them.

Didn't say that it was confusing. It might very well be the perfect name... if I only knew what sort of thing we are trying to name...

Quoted 5 lines

That said, if you have a minute to check out the first patch or two you'll see that the patches are basically putting a struct in between the super block and the inode.

Quoted 8 lines

One thing I'd like to politely suggest is that anyone now following this conversation to please read the at least the first patch. It's an easy read and I feel like the conversation overall would be much more clear if everyone understood what we're going for. I worry that I didn't do a particularly good job explaining the actual code changes.

https://www.spinics.net/lists/linux-fsdevel/msg125492.html

I did look at the patches. They look simple and clean and they solve A problem. All I'm saying is that we should look at the set of problems that we know of before we design an abstraction layer.

Quoted 7 lines

Regarding a layout of the problems, I have a more complete e-mail coming soon which should describe in detail the issues I've seen with respect to how the kernel is exporting ino/dev pairs (outside of statx). fs_view alone is not enough to solve that problem. I'd be happy to CC you on that one if you'd like.

Sure.

[...]

Quoted 9 lines
Quoted 2 lines

And what is the SUSE way?

At SUSE, we carry a version of this patch:

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

Essentially a callback which was rejected for various reasons.

Don't see a patch here. Wrong link?

Quoted 4 lines

The fs_view work was intended to replace that patch with an upstream solution.

[...]

Quoted 9 lines
Quoted 5 lines

FYI, the Overlayfs file/inode mapping is about to change with many VFS hacks queued for removal, so stay tuned.

[...]

Actually, would you mind giving me a pointer to this work? I'd be very interested to see what exactly might be changing.

Mostly, less VFS code is going to be exposed to underlying inode:

https://marc.info/?l=linux-fsdevel&m=152760014530531&w=2

[...]

Quoted 7 lines
Quoted 6 lines

I have an interest of solving another problem.
In VFS operations where only inode is available, I would like to be able to report fsnotify events (e.g. fsnotify_move()) only in directories under a certain subtree root. That could be achieved either by bind mount the subtree root and passing vfsmount into vfs_rename() or by defining an fs_view on the subtree and mounting that fs_view.

Quoted 5 lines

I'm not sure whether fs_view works for this. Taking a quick look at fsnotify, the state is already on the inode? If there's a globabl fsnotify state that needs to be per subtree than yes we could move that to the fs_view and you'd simply deref it from the inode struct.

That was my thinking. I have patches to attach an fsnotify mark to super block. If fs_view could have a root that is different than super block's root and if file system can guaranty that objects cannot be moved outside of fs_view root, then fsnotify mark could be attached to fs_view.

Thanks,
Amir.

#85 lore raw
Quoted 4 lines · Amir Goldstein
Quoted 2 lines · Mark Fasheh

Hi Amir, thanks for the comments!

Quoted 8 lines

Hi Mark,

[...]

Quoted 2 lines

Btw, sorry that the name is confusing. I've never been good at picking them.

Didn't say that it was confusing. It might very well be the perfect name... if I only knew what sort of thing we are trying to name...

Fair enough :)

Quoted 11 lines
Quoted 11 lines

That said, if you have a minute to check out the first patch or two you'll see that the patches are basically putting a struct in between the super block and the inode.

One thing I'd like to politely suggest is that anyone now following this conversation to please read the at least the first patch. It's an easy read and I feel like the conversation overall would be much more clear if everyone understood what we're going for. I worry that I didn't do a particularly good job explaining the actual code changes.

Quoted 7 lines
Quoted 2 lines

https://www.spinics.net/lists/linux-fsdevel/msg125492.html

I did look at the patches. They look simple and clean and they solve A problem. All I'm saying is that we should look at the set of problems that we know of before we design an abstraction layer.

Agreed, I think my more recent e-mail does a much better job of laying out the issues we're seeing here.

Quoted 10 lines
Quoted 8 lines
Quoted 1 line

And what is the SUSE way?

At SUSE, we carry a version of this patch:

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

Essentially a callback which was rejected for various reasons.

Don't see a patch here. Wrong link?

That was the 0/2 mail in the patch series. Here are the next two, which contain the actual patches:

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

Keep in mind that the patch has evolved since then though it's essentially the same idea - use a callback where we need to get the correct device.

Quoted 17 lines
Quoted 4 lines

The fs_view work was intended to replace that patch with an upstream solution.

[...]

Quoted 9 lines
Quoted 5 lines

FYI, the Overlayfs file/inode mapping is about to change with many VFS hacks queued for removal, so stay tuned.

[...]

Actually, would you mind giving me a pointer to this work? I'd be very interested to see what exactly might be changing.

Quoted 5 lines

Mostly, less VFS code is going to be exposed to underlying inode:

https://marc.info/?l=linux-fsdevel&m=152760014530531&w=2

[...]

Awesome, thanks for the link Amir.

Quoted 11 lines
Quoted 5 lines

I'm not sure whether fs_view works for this. Taking a quick look at fsnotify, the state is already on the inode? If there's a globabl fsnotify state that needs to be per subtree than yes we could move that to the fs_view and you'd simply deref it from the inode struct.

That was my thinking. I have patches to attach an fsnotify mark to super block. If fs_view could have a root that is different than super block's root and if file system can guaranty that objects cannot be moved outside of fs_view root, then fsnotify mark could be attached to fs_view.

Ahh yeah so in that case we could have the mark on the fs_view instead of the superblock and you'd deref it from the inode to get to that inodes root.

Thanks,

	--Mark
#86 lore raw
In reply to Amir Goldstein

Hi Amir -

Mark's answered some of your questions already, so I'll skip those.

Quoted 62 lines · Amir Goldstein
Quoted 18 lines · Jeff Mahoney

Sorry, just getting back to this.

Quoted 15 lines · Dave Chinner
Quoted 14 lines · Jeff Mahoney
Quoted 13 lines · Dave Chinner
Quoted 11 lines · Mark Fasheh

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.

Speaking as someone who joined this discussion late, maybe years after it started, it would help to get an overview of existing problems and how fs_view aims to solve them.

I do believe that both Overlayfs and Btrfs can benefit from a layer of abstraction
in the VFS, but I think it is best if we start with laying all the common problems
and then see how a solution would look like.

Even the name of the abstraction (fs_view) doesn't make it clear to me what it is we are abstracting (security context? st_dev? what else?). probably best to try to describe the abstraction from user POV rather then give sporadic examples of what MAY go into fs_view.

While at it, need to see if this discussion has any intersections with David Howell's fs_context work, because if we consider adding sub volume support to VFS, we may want to leave some reserved bits in the API for it.

[...]

Quoted 8 lines

One thing is clear: If we want to solve the btrfs and overlayfs problems in the same way, the view approach with a simple static mapping doesn't work. Sticking something between the inode and superblock doesn't get the job done when the belongs to a different file system. Overlayfs needs a per-object remapper, which means a callback that takes a path. Suddenly the way we do things in the SUSE kernel doesn't seem so hacky anymore.

And what is the SUSE way?

Quoted 9 lines

I'm not sure we need the same solution for btrfs and overlayfs. It's not the same problem. Every object in overlayfs as a unique mapping already. If we report s_dev and i_ino from the inode, it still maps to a unique user-visible object. It may not map back to the overlayfs name, but that's a separate issue that's more difficult to solve. The btrfs issue isn't one of presenting an alternative namespace to the user. Btrfs has multiple internal namespaces and no way to publish them to the rest of the kernel.

Quoted 4 lines

FYI, the Overlayfs file/inode mapping is about to change with many VFS hacks queued for removal, so stay tuned.

[...]

I have to admit I'm curious how this will work. I've heard rumor of using overlayfs inodes and calling the underlying file system's inode_operations. If part of that work removes the danger of overlayfs inode numbers colliding with xino mode, I'm definitely interested.

Quoted 23 lines
Quoted 14 lines
Quoted 6 lines

My point is that if we are talking about infrastructure to remap what userspace sees from different mountpoint views into a filesystem, then it should be done above the filesystem layers in the VFS so all filesystems behave the same way. And in this case, the vfsmount maps exactly to the "fs_view" that Mark has proposed we add to the superblock.....

It's proposed to be above the superblock with a default view in the superblock. It would sit between the inode and the superblock so we have access to it anywhere we already have an inode. That's the main difference. We already have the inode everywhere it's needed. Plumbing a vfsmount everywhere needed means changing code that only requires an inode and doesn't need a vfsmount.

Quoted 8 lines

The two biggest problem areas:
- Writeback tracepoints print a dev/inode pair. Do we want to plumb a vfsmount into __mark_inode_dirty, super_operations->write_inode, __writeback_single_inode, writeback_sb_inodes, etc?
- Audit. As it happens, most of audit has a path or file that can be used. We do run into problems with fsnotify. fsnotify_move is called from vfs_rename which turns into a can of worms pretty quickly.

Quoted 3 lines

Can you please elaborate on that problem.
Do you mean when watching a directory for changes, you need to be able to tell in which fs_view the directory inode that is being watched?

I was investigating whether Dave's suggestion of using a vfsmount was feasible. When following the audit call graph up, I found fsnotify_move, called by vfs_rename. Piping a vfsmount into the vfs_* operations has historically been rejected by Al (see Apparmor discussions, among others), and with good reason. The file system implementation shouldn't care about where it's mounted. While piping it into vfs_rename doesn't seem too invasive, it's called by various file systems' ->rename callback, so then we're stuck piping vfsmounts into inode_operations, which is what Al's been wanting to avoid for years.

Quoted 14 lines
Quoted 6 lines
Quoted 6 lines
Quoted 5 lines

It makes sense for that to be above the
superblock because the file system doesn't care about them. We're interested in the inode namespace, which for every other file system can be described using an inode and a superblock pair, but btrfs has another layer in the middle: inode -> btrfs_root -> superblock.

Quoted 7 lines
Quoted 2 lines

Which seems to me to be irrelevant if there's a vfsmount per subvolume that can hold per-subvolume information.

I disagree. There are a ton of places where we only have access to an inode and only need access to an inode. It also doesn't solve the overlayfs issue.

Quoted 6 lines

I have an interest of solving another problem.
In VFS operations where only inode is available, I would like to be able to report fsnotify events (e.g. fsnotify_move()) only in directories under a certain subtree root. That could be achieved either by bind mount the subtree root and passing vfsmount into vfs_rename() or by defining an fs_view on the subtree and mounting that fs_view.

I'm not sure there's a lot of overlap, but I expect that this will end up running into the same review feedback that Al gave during the AppArmor merge: vfsmounts have no business at the lower level and you can get the same behavior by hooking in at a higher level. See security_path_* vs security_inode_* for how that was resolved.

What you're talking about isn't really what we had in mind for the fs_view. In our case, it sits between the inode and superblock, which would be at too low a level for determining whether an inode is under a certain subtree. In any event, wouldn't you need a path instead of an inode to do what you're proposing?

-Jeff

Signature · 2 lines
Jeff Mahoney
SUSE Labs
maintainer
#87 lore raw

On Thu, Jun 7, 2018 at 12:19 AM, Jeff Mahoney <[email protected]> wrote:
[...]

Quoted 10 lines
Quoted 5 lines

FYI, the Overlayfs file/inode mapping is about to change with many VFS hacks queued for removal, so stay tuned.

[...]

I have to admit I'm curious how this will work. I've heard rumor of using overlayfs inodes and calling the underlying file system's inode_operations. If part of that work removes the danger of overlayfs inode numbers colliding with xino mode, I'm definitely interested.

See https://marc.info/?l=linux-fsdevel&m=152760014530531&w=2

It doesn't remove the need to maintain a unique and persistent inode number namespace in overlayfs. It just reduces exposure of the underlying inode to VFS.

[...]

Quoted 9 lines
Quoted 8 lines
Quoted 4 lines

- Audit. As it happens, most of audit has a path or file that can be used. We do run into problems with fsnotify. fsnotify_move is called from vfs_rename which turns into a can of worms pretty quickly.

Can you please elaborate on that problem.
Do you mean when watching a directory for changes, you need to be able to tell in which fs_view the directory inode that is being watched?

Quoted 10 lines

I was investigating whether Dave's suggestion of using a vfsmount was feasible. When following the audit call graph up, I found fsnotify_move, called by vfs_rename. Piping a vfsmount into the vfs_* operations has historically been rejected by Al (see Apparmor discussions, among others), and with good reason. The file system implementation shouldn't care about where it's mounted. While piping it into vfs_rename doesn't seem too invasive, it's called by various file systems' ->rename callback, so then we're stuck piping vfsmounts into inode_operations, which is what Al's been wanting to avoid for years.

Yes, I've heard about this objection, thought didn't have a reference.

[...]

Quoted 14 lines
Quoted 7 lines

I have an interest of solving another problem.
In VFS operations where only inode is available, I would like to be able to report fsnotify events (e.g. fsnotify_move()) only in directories under a certain subtree root. That could be achieved either by bind mount the subtree root and passing vfsmount into vfs_rename() or by defining an fs_view on the subtree and mounting that fs_view.

I'm not sure there's a lot of overlap, but I expect that this will end up running into the same review feedback that Al gave during the AppArmor merge: vfsmounts have no business at the lower level and you can get the same behavior by hooking in at a higher level. See security_path_* vs security_inode_* for how that was resolved.

Quoted 6 lines

What you're talking about isn't really what we had in mind for the fs_view. In our case, it sits between the inode and superblock, which would be at too low a level for determining whether an inode is under a certain subtree. In any event, wouldn't you need a path instead of an inode to do what you're proposing?

Not if the fs_view could have a root that is different than sb root then I could attach fsnotify mark to fs_view instead of say vfsmount and I have the information I need inside fsnotify_move().

Thanks,
Amir.