From mboxrd@z Thu Jan 1 00:00:00 1970 From: Al Viro Date: Fri, 10 Mar 2023 03:26:11 +0000 Subject: [Cluster-devel] [PATCH v3 5/6] ocfs2: convert to use i_blockmask() In-Reply-To: <20230309152127.41427-5-frank.li@vivo.com> References: <20230309152127.41427-1-frank.li@vivo.com> <20230309152127.41427-5-frank.li@vivo.com> Message-ID: <20230310032611.GF3390869@ZenIV> List-Id: To: cluster-devel.redhat.com MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit On Thu, Mar 09, 2023 at 11:21:26PM +0800, Yangtao Li wrote: > Use i_blockmask() to simplify code. BTW convert ocfs2_is_io_unaligned > to return bool type. > > Signed-off-by: Yangtao Li > --- > v3: > -none > fs/ocfs2/file.c | 8 ++++---- > 1 file changed, 4 insertions(+), 4 deletions(-) > > diff --git a/fs/ocfs2/file.c b/fs/ocfs2/file.c > index efb09de4343d..baefab3b12c9 100644 > --- a/fs/ocfs2/file.c > +++ b/fs/ocfs2/file.c > @@ -2159,14 +2159,14 @@ int ocfs2_check_range_for_refcount(struct inode *inode, loff_t pos, > return ret; > } > > -static int ocfs2_is_io_unaligned(struct inode *inode, size_t count, loff_t pos) > +static bool ocfs2_is_io_unaligned(struct inode *inode, size_t count, loff_t pos) > { > - int blockmask = inode->i_sb->s_blocksize - 1; > + int blockmask = i_blockmask(inode); > loff_t final_size = pos + count; > > if ((pos & blockmask) || (final_size & blockmask)) > - return 1; > - return 0; > + return true; > + return false; > } Ugh... return (pos | count) & blockmask; surely? Conversion to bool will take care of the rest. Or you could make that return ((pos | count) & blockmask) != 0; And the fact that the value will be the same (i.e. that ->i_blkbits is never changed by ocfs2) is worth mentioning in commit message...