On Tue, Nov 07, 2023 at 07:41:52PM +0000, Matthew Wilcox (Oracle) wrote: > If i_blkbits is larger than PAGE_SHIFT, we shift by a negative number, > which is undefined. It is safe to shift the block left as a block > device must be smaller than MAX_LFS_FILESIZE, which is guaranteed to > fit in loff_t. > > Signed-off-by: Matthew Wilcox (Oracle) <willy@xxxxxxxxxxxxx> Looks good, Reviewed-by: Pankaj Raghav <p.raghav@xxxxxxxxxxx> > --- > fs/buffer.c | 10 +++++----- > 1 file changed, 5 insertions(+), 5 deletions(-) > > diff --git a/fs/buffer.c b/fs/buffer.c > index 2f08af3c47a2..5bdfcf8c6fe6 100644 > --- a/fs/buffer.c > +++ b/fs/buffer.c > @@ -199,7 +199,7 @@ __find_get_block_slow(struct block_device *bdev, sector_t block) > int all_mapped = 1; > static DEFINE_RATELIMIT_STATE(last_warned, HZ, 1); > > - index = block >> (PAGE_SHIFT - bd_inode->i_blkbits); > + index = ((loff_t)block << bd_inode->i_blkbits) / PAGE_SIZE;