Skip to content

Commit 0444702

Browse files
Fabian Frederickgregkh
authored andcommitted
fs: add i_blocksize()
commit 93407472a21b82f39c955ea7787e5bc7da100642 upstream. Replace all 1 << inode->i_blkbits and (1 << inode->i_blkbits) in fs branch. This patch also fixes multiple checkpatch warnings: WARNING: Prefer 'unsigned int' to bare use of 'unsigned' Thanks to Andrew Morton for suggesting more appropriate function instead of macro. [geliangtang@gmail.com: truncate: use i_blocksize()] Link: http://lkml.kernel.org/r/9c8b2cd83c8f5653805d43debde9fa8817e02fc4.1484895804.git.geliangtang@gmail.com Link: http://lkml.kernel.org/r/1481319905-10126-1-git-send-email-fabf@skynet.be Signed-off-by: Fabian Frederick <fabf@skynet.be> Signed-off-by: Geliang Tang <geliangtang@gmail.com> Cc: Alexander Viro <viro@zeniv.linux.org.uk> Cc: Ross Zwisler <ross.zwisler@linux.intel.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent c8acec9 commit 0444702

23 files changed

Lines changed: 41 additions & 36 deletions

File tree

fs/btrfs/file.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2771,7 +2771,7 @@ static long btrfs_fallocate(struct file *file, int mode,
27712771
if (!ret)
27722772
ret = btrfs_prealloc_file_range(inode, mode,
27732773
range->start,
2774-
range->len, 1 << inode->i_blkbits,
2774+
range->len, i_blocksize(inode),
27752775
offset + len, &alloc_hint);
27762776
list_del(&range->list);
27772777
kfree(range);

fs/buffer.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2298,7 +2298,7 @@ static int cont_expand_zero(struct file *file, struct address_space *mapping,
22982298
loff_t pos, loff_t *bytes)
22992299
{
23002300
struct inode *inode = mapping->host;
2301-
unsigned blocksize = 1 << inode->i_blkbits;
2301+
unsigned int blocksize = i_blocksize(inode);
23022302
struct page *page;
23032303
void *fsdata;
23042304
pgoff_t index, curidx;
@@ -2378,8 +2378,8 @@ int cont_write_begin(struct file *file, struct address_space *mapping,
23782378
get_block_t *get_block, loff_t *bytes)
23792379
{
23802380
struct inode *inode = mapping->host;
2381-
unsigned blocksize = 1 << inode->i_blkbits;
2382-
unsigned zerofrom;
2381+
unsigned int blocksize = i_blocksize(inode);
2382+
unsigned int zerofrom;
23832383
int err;
23842384

23852385
err = cont_expand_zero(file, mapping, pos, bytes);
@@ -2741,7 +2741,7 @@ int nobh_truncate_page(struct address_space *mapping,
27412741
struct buffer_head map_bh;
27422742
int err;
27432743

2744-
blocksize = 1 << inode->i_blkbits;
2744+
blocksize = i_blocksize(inode);
27452745
length = offset & (blocksize - 1);
27462746

27472747
/* Block boundary? Nothing to do */
@@ -2819,7 +2819,7 @@ int block_truncate_page(struct address_space *mapping,
28192819
struct buffer_head *bh;
28202820
int err;
28212821

2822-
blocksize = 1 << inode->i_blkbits;
2822+
blocksize = i_blocksize(inode);
28232823
length = offset & (blocksize - 1);
28242824

28252825
/* Block boundary? Nothing to do */
@@ -2931,7 +2931,7 @@ sector_t generic_block_bmap(struct address_space *mapping, sector_t block,
29312931
struct inode *inode = mapping->host;
29322932
tmp.b_state = 0;
29332933
tmp.b_blocknr = 0;
2934-
tmp.b_size = 1 << inode->i_blkbits;
2934+
tmp.b_size = i_blocksize(inode);
29352935
get_block(inode, block, &tmp, 0);
29362936
return tmp.b_blocknr;
29372937
}

fs/ceph/addr.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -697,7 +697,7 @@ static int ceph_writepages_start(struct address_space *mapping,
697697
struct pagevec pvec;
698698
int done = 0;
699699
int rc = 0;
700-
unsigned wsize = 1 << inode->i_blkbits;
700+
unsigned int wsize = i_blocksize(inode);
701701
struct ceph_osd_request *req = NULL;
702702
int do_sync = 0;
703703
loff_t snap_size, i_size;

fs/direct-io.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -575,7 +575,7 @@ static int dio_set_defer_completion(struct dio *dio)
575575
/*
576576
* Call into the fs to map some more disk blocks. We record the current number
577577
* of available blocks at sdio->blocks_available. These are in units of the
578-
* fs blocksize, (1 << inode->i_blkbits).
578+
* fs blocksize, i_blocksize(inode).
579579
*
580580
* The fs is allowed to map lots of blocks at once. If it wants to do that,
581581
* it uses the passed inode-relative block number as the file offset, as usual.

fs/ext4/inode.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2044,7 +2044,7 @@ static int mpage_process_page_bufs(struct mpage_da_data *mpd,
20442044
{
20452045
struct inode *inode = mpd->inode;
20462046
int err;
2047-
ext4_lblk_t blocks = (i_size_read(inode) + (1 << inode->i_blkbits) - 1)
2047+
ext4_lblk_t blocks = (i_size_read(inode) + i_blocksize(inode) - 1)
20482048
>> inode->i_blkbits;
20492049

20502050
do {

fs/ext4/move_extent.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,7 @@ mext_page_mkuptodate(struct page *page, unsigned from, unsigned to)
187187
if (PageUptodate(page))
188188
return 0;
189189

190-
blocksize = 1 << inode->i_blkbits;
190+
blocksize = i_blocksize(inode);
191191
if (!page_has_buffers(page))
192192
create_empty_buffers(page, blocksize, 0);
193193

fs/jfs/super.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -758,7 +758,7 @@ static ssize_t jfs_quota_read(struct super_block *sb, int type, char *data,
758758
sb->s_blocksize - offset : toread;
759759

760760
tmp_bh.b_state = 0;
761-
tmp_bh.b_size = 1 << inode->i_blkbits;
761+
tmp_bh.b_size = i_blocksize(inode);
762762
err = jfs_get_block(inode, blk, &tmp_bh, 0);
763763
if (err)
764764
return err;
@@ -798,7 +798,7 @@ static ssize_t jfs_quota_write(struct super_block *sb, int type,
798798
sb->s_blocksize - offset : towrite;
799799

800800
tmp_bh.b_state = 0;
801-
tmp_bh.b_size = 1 << inode->i_blkbits;
801+
tmp_bh.b_size = i_blocksize(inode);
802802
err = jfs_get_block(inode, blk, &tmp_bh, 1);
803803
if (err)
804804
goto out;

fs/mpage.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ map_buffer_to_page(struct page *page, struct buffer_head *bh, int page_block)
111111
SetPageUptodate(page);
112112
return;
113113
}
114-
create_empty_buffers(page, 1 << inode->i_blkbits, 0);
114+
create_empty_buffers(page, i_blocksize(inode), 0);
115115
}
116116
head = page_buffers(page);
117117
page_bh = head;

fs/nfsd/blocklayout.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ nfsd4_block_proc_layoutget(struct inode *inode, const struct svc_fh *fhp,
5050
{
5151
struct nfsd4_layout_seg *seg = &args->lg_seg;
5252
struct super_block *sb = inode->i_sb;
53-
u32 block_size = (1 << inode->i_blkbits);
53+
u32 block_size = i_blocksize(inode);
5454
struct pnfs_block_extent *bex;
5555
struct iomap iomap;
5656
u32 device_generation = 0;
@@ -151,7 +151,7 @@ nfsd4_block_proc_layoutcommit(struct inode *inode,
151151
int error;
152152

153153
nr_iomaps = nfsd4_block_decode_layoutupdate(lcp->lc_up_layout,
154-
lcp->lc_up_len, &iomaps, 1 << inode->i_blkbits);
154+
lcp->lc_up_len, &iomaps, i_blocksize(inode));
155155
if (nr_iomaps < 0)
156156
return nfserrno(nr_iomaps);
157157

fs/nilfs2/btnode.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ nilfs_btnode_create_block(struct address_space *btnc, __u64 blocknr)
5555
brelse(bh);
5656
BUG();
5757
}
58-
memset(bh->b_data, 0, 1 << inode->i_blkbits);
58+
memset(bh->b_data, 0, i_blocksize(inode));
5959
bh->b_bdev = inode->i_sb->s_bdev;
6060
bh->b_blocknr = blocknr;
6161
set_buffer_mapped(bh);

0 commit comments

Comments
 (0)