Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

nilfs2: get rid of NILFS_I_NILFS

This replaces all references of NILFS_I_NILFS(inode)->ns_bdev with
inode->i_sb->s_bdev and unfolds remaining uses of NILFS_I_NILFS inline
function.

Before 2.6.37, referring to a nilfs object from inodes needed a
conditional judgement, and NILFS_I_NILFS was helpful to simplify it.
But now we can simply do it by going through a super block instance
like inode->i_sb->s_fs_info.

Signed-off-by: Ryusuke Konishi <konishi.ryusuke@lab.ntt.co.jp>

+20 -22
+3 -1
fs/nilfs2/bmap.c
··· 34 34 35 35 struct inode *nilfs_bmap_get_dat(const struct nilfs_bmap *bmap) 36 36 { 37 - return NILFS_I_NILFS(bmap->b_inode)->ns_dat; 37 + struct the_nilfs *nilfs = bmap->b_inode->i_sb->s_fs_info; 38 + 39 + return nilfs->ns_dat; 38 40 } 39 41 40 42 static int nilfs_bmap_convert_error(struct nilfs_bmap *bmap,
+5 -4
fs/nilfs2/btnode.c
··· 62 62 BUG(); 63 63 } 64 64 memset(bh->b_data, 0, 1 << inode->i_blkbits); 65 - bh->b_bdev = NILFS_I_NILFS(inode)->ns_bdev; 65 + bh->b_bdev = inode->i_sb->s_bdev; 66 66 bh->b_blocknr = blocknr; 67 67 set_buffer_mapped(bh); 68 68 set_buffer_uptodate(bh); ··· 94 94 if (pblocknr == 0) { 95 95 pblocknr = blocknr; 96 96 if (inode->i_ino != NILFS_DAT_INO) { 97 - struct inode *dat = NILFS_I_NILFS(inode)->ns_dat; 97 + struct the_nilfs *nilfs = inode->i_sb->s_fs_info; 98 98 99 99 /* blocknr is a virtual block number */ 100 - err = nilfs_dat_translate(dat, blocknr, &pblocknr); 100 + err = nilfs_dat_translate(nilfs->ns_dat, blocknr, 101 + &pblocknr); 101 102 if (unlikely(err)) { 102 103 brelse(bh); 103 104 goto out_locked; ··· 121 120 goto found; 122 121 } 123 122 set_buffer_mapped(bh); 124 - bh->b_bdev = NILFS_I_NILFS(inode)->ns_bdev; 123 + bh->b_bdev = inode->i_sb->s_bdev; 125 124 bh->b_blocknr = pblocknr; /* set block address for read */ 126 125 bh->b_end_io = end_buffer_read_sync; 127 126 get_bh(bh);
+4 -4
fs/nilfs2/gcinode.c
··· 84 84 goto out; 85 85 86 86 if (pbn == 0) { 87 - struct inode *dat_inode = NILFS_I_NILFS(inode)->ns_dat; 88 - /* use original dat, not gc dat. */ 89 - err = nilfs_dat_translate(dat_inode, vbn, &pbn); 87 + struct the_nilfs *nilfs = inode->i_sb->s_fs_info; 88 + 89 + err = nilfs_dat_translate(nilfs->ns_dat, vbn, &pbn); 90 90 if (unlikely(err)) { /* -EIO, -ENOMEM, -ENOENT */ 91 91 brelse(bh); 92 92 goto failed; ··· 100 100 } 101 101 102 102 if (!buffer_mapped(bh)) { 103 - bh->b_bdev = NILFS_I_NILFS(inode)->ns_bdev; 103 + bh->b_bdev = inode->i_sb->s_bdev; 104 104 set_buffer_mapped(bh); 105 105 } 106 106 bh->b_blocknr = pbn;
+4 -4
fs/nilfs2/inode.c
··· 74 74 struct buffer_head *bh_result, int create) 75 75 { 76 76 struct nilfs_inode_info *ii = NILFS_I(inode); 77 + struct the_nilfs *nilfs = inode->i_sb->s_fs_info; 77 78 __u64 blknum = 0; 78 79 int err = 0, ret; 79 - struct inode *dat = NILFS_I_NILFS(inode)->ns_dat; 80 80 unsigned maxblocks = bh_result->b_size >> inode->i_blkbits; 81 81 82 - down_read(&NILFS_MDT(dat)->mi_sem); 82 + down_read(&NILFS_MDT(nilfs->ns_dat)->mi_sem); 83 83 ret = nilfs_bmap_lookup_contig(ii->i_bmap, blkoff, &blknum, maxblocks); 84 - up_read(&NILFS_MDT(dat)->mi_sem); 84 + up_read(&NILFS_MDT(nilfs->ns_dat)->mi_sem); 85 85 if (ret >= 0) { /* found */ 86 86 map_bh(bh_result, inode->i_sb, blknum); 87 87 if (ret > 0) ··· 940 940 int nilfs_fiemap(struct inode *inode, struct fiemap_extent_info *fieinfo, 941 941 __u64 start, __u64 len) 942 942 { 943 - struct the_nilfs *nilfs = NILFS_I_NILFS(inode); 943 + struct the_nilfs *nilfs = inode->i_sb->s_fs_info; 944 944 __u64 logical = 0, phys = 0, size = 0; 945 945 __u32 flags = 0; 946 946 loff_t isize;
+1 -6
fs/nilfs2/mdt.h
··· 64 64 return inode->i_private; 65 65 } 66 66 67 - static inline struct the_nilfs *NILFS_I_NILFS(struct inode *inode) 68 - { 69 - return inode->i_sb->s_fs_info; 70 - } 71 - 72 67 /* Default GFP flags using highmem */ 73 68 #define NILFS_MDT_GFP (__GFP_WAIT | __GFP_IO | __GFP_HIGHMEM) 74 69 ··· 103 108 104 109 static inline __u64 nilfs_mdt_cno(struct inode *inode) 105 110 { 106 - return NILFS_I_NILFS(inode)->ns_cno; 111 + return ((struct the_nilfs *)inode->i_sb->s_fs_info)->ns_cno; 107 112 } 108 113 109 114 #define nilfs_mdt_bgl_lock(inode, bg) \
+2 -2
fs/nilfs2/sufile.c
··· 562 562 { 563 563 struct buffer_head *header_bh; 564 564 struct nilfs_sufile_header *header; 565 - struct the_nilfs *nilfs = NILFS_I_NILFS(sufile); 565 + struct the_nilfs *nilfs = sufile->i_sb->s_fs_info; 566 566 void *kaddr; 567 567 int ret; 568 568 ··· 812 812 struct nilfs_segment_usage *su; 813 813 struct nilfs_suinfo *si = buf; 814 814 size_t susz = NILFS_MDT(sufile)->mi_entry_size; 815 - struct the_nilfs *nilfs = NILFS_I_NILFS(sufile); 815 + struct the_nilfs *nilfs = sufile->i_sb->s_fs_info; 816 816 void *kaddr; 817 817 unsigned long nsegs, segusages_per_block; 818 818 ssize_t n;
+1 -1
fs/nilfs2/sufile.h
··· 31 31 32 32 static inline unsigned long nilfs_sufile_get_nsegments(struct inode *sufile) 33 33 { 34 - return NILFS_I_NILFS(sufile)->ns_nsegments; 34 + return ((struct the_nilfs *)sufile->i_sb->s_fs_info)->ns_nsegments; 35 35 } 36 36 37 37 unsigned long nilfs_sufile_get_ncleansegs(struct inode *sufile);