linux-ext4.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/4] fs: add i_blocksize_mask()
@ 2023-03-09  9:43 Yangtao Li
  2023-03-09  9:43 ` [PATCH 2/4] erofs: convert to use i_blocksize_mask() Yangtao Li
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: Yangtao Li @ 2023-03-09  9:43 UTC (permalink / raw)
  To: xiang, chao, huyue2, jefflexu, tytso, adilger.kernel, rpeterso,
	agruenba, viro, brauner
  Cc: linux-erofs, linux-kernel, linux-ext4, cluster-devel,
	linux-fsdevel, Yangtao Li

Introduce i_blocksize_mask() to simplify code, which replace
(i_blocksize(node) - 1). Like done in commit
93407472a21b("fs: add i_blocksize()").

Signed-off-by: Yangtao Li <frank.li@vivo.com>
---
 include/linux/fs.h | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/include/linux/fs.h b/include/linux/fs.h
index c85916e9f7db..db335bd9c256 100644
--- a/include/linux/fs.h
+++ b/include/linux/fs.h
@@ -711,6 +711,11 @@ static inline unsigned int i_blocksize(const struct inode *node)
 	return (1 << node->i_blkbits);
 }
 
+static inline unsigned int i_blocksize_mask(const struct inode *node)
+{
+	return i_blocksize(node) - 1;
+}
+
 static inline int inode_unhashed(struct inode *inode)
 {
 	return hlist_unhashed(&inode->i_hash);
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [PATCH 2/4] erofs: convert to use i_blocksize_mask()
  2023-03-09  9:43 [PATCH 1/4] fs: add i_blocksize_mask() Yangtao Li
@ 2023-03-09  9:43 ` Yangtao Li
  2023-03-09  9:43 ` [PATCH 3/4] gfs2: " Yangtao Li
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 5+ messages in thread
From: Yangtao Li @ 2023-03-09  9:43 UTC (permalink / raw)
  To: xiang, chao, huyue2, jefflexu, tytso, adilger.kernel, rpeterso,
	agruenba, viro, brauner
  Cc: linux-erofs, linux-kernel, linux-ext4, cluster-devel,
	linux-fsdevel, Yangtao Li

Use i_blocksize_mask() to simplify code.

Signed-off-by: Yangtao Li <frank.li@vivo.com>
---
 fs/erofs/data.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/fs/erofs/data.c b/fs/erofs/data.c
index 7e8baf56faa5..234ca4dd5053 100644
--- a/fs/erofs/data.c
+++ b/fs/erofs/data.c
@@ -380,7 +380,7 @@ static ssize_t erofs_file_read_iter(struct kiocb *iocb, struct iov_iter *to)
 		if (bdev)
 			blksize_mask = bdev_logical_block_size(bdev) - 1;
 		else
-			blksize_mask = i_blocksize(inode) - 1;
+			blksize_mask = i_blocksize_mask(inode);
 
 		if ((iocb->ki_pos | iov_iter_count(to) |
 		     iov_iter_alignment(to)) & blksize_mask)
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [PATCH 3/4] gfs2: convert to use i_blocksize_mask()
  2023-03-09  9:43 [PATCH 1/4] fs: add i_blocksize_mask() Yangtao Li
  2023-03-09  9:43 ` [PATCH 2/4] erofs: convert to use i_blocksize_mask() Yangtao Li
@ 2023-03-09  9:43 ` Yangtao Li
  2023-03-09  9:43 ` [PATCH 4/4] ext4: " Yangtao Li
  2023-03-09 10:21 ` [PATCH 1/4] fs: add i_blocksize_mask() Andreas Gruenbacher
  3 siblings, 0 replies; 5+ messages in thread
From: Yangtao Li @ 2023-03-09  9:43 UTC (permalink / raw)
  To: xiang, chao, huyue2, jefflexu, tytso, adilger.kernel, rpeterso,
	agruenba, viro, brauner
  Cc: linux-erofs, linux-kernel, linux-ext4, cluster-devel,
	linux-fsdevel, Yangtao Li

Use i_blocksize_mask() to simplify code.

Signed-off-by: Yangtao Li <frank.li@vivo.com>
---
 fs/gfs2/bmap.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/fs/gfs2/bmap.c b/fs/gfs2/bmap.c
index eedf6926c652..d59f9b3f0b85 100644
--- a/fs/gfs2/bmap.c
+++ b/fs/gfs2/bmap.c
@@ -960,7 +960,7 @@ static struct folio *
 gfs2_iomap_get_folio(struct iomap_iter *iter, loff_t pos, unsigned len)
 {
 	struct inode *inode = iter->inode;
-	unsigned int blockmask = i_blocksize(inode) - 1;
+	unsigned int blockmask = i_blocksize_mask(inode);
 	struct gfs2_sbd *sdp = GFS2_SB(inode);
 	unsigned int blocks;
 	struct folio *folio;
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [PATCH 4/4] ext4: convert to use i_blocksize_mask()
  2023-03-09  9:43 [PATCH 1/4] fs: add i_blocksize_mask() Yangtao Li
  2023-03-09  9:43 ` [PATCH 2/4] erofs: convert to use i_blocksize_mask() Yangtao Li
  2023-03-09  9:43 ` [PATCH 3/4] gfs2: " Yangtao Li
@ 2023-03-09  9:43 ` Yangtao Li
  2023-03-09 10:21 ` [PATCH 1/4] fs: add i_blocksize_mask() Andreas Gruenbacher
  3 siblings, 0 replies; 5+ messages in thread
From: Yangtao Li @ 2023-03-09  9:43 UTC (permalink / raw)
  To: xiang, chao, huyue2, jefflexu, tytso, adilger.kernel, rpeterso,
	agruenba, viro, brauner
  Cc: linux-erofs, linux-kernel, linux-ext4, cluster-devel,
	linux-fsdevel, Yangtao Li

Use i_blocksize_mask() to simplify code.

Signed-off-by: Yangtao Li <frank.li@vivo.com>
---
 fs/ext4/inode.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/fs/ext4/inode.c b/fs/ext4/inode.c
index d251d705c276..c33f91f3b749 100644
--- a/fs/ext4/inode.c
+++ b/fs/ext4/inode.c
@@ -2218,7 +2218,7 @@ static int mpage_process_page_bufs(struct mpage_da_data *mpd,
 {
 	struct inode *inode = mpd->inode;
 	int err;
-	ext4_lblk_t blocks = (i_size_read(inode) + i_blocksize(inode) - 1)
+	ext4_lblk_t blocks = (i_size_read(inode) + i_blocksize_mask(inode))
 							>> inode->i_blkbits;
 
 	if (ext4_verity_in_progress(inode))
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH 1/4] fs: add i_blocksize_mask()
  2023-03-09  9:43 [PATCH 1/4] fs: add i_blocksize_mask() Yangtao Li
                   ` (2 preceding siblings ...)
  2023-03-09  9:43 ` [PATCH 4/4] ext4: " Yangtao Li
@ 2023-03-09 10:21 ` Andreas Gruenbacher
  3 siblings, 0 replies; 5+ messages in thread
From: Andreas Gruenbacher @ 2023-03-09 10:21 UTC (permalink / raw)
  To: Yangtao Li
  Cc: xiang, chao, huyue2, jefflexu, tytso, adilger.kernel, rpeterso,
	viro, brauner, linux-erofs, linux-kernel, linux-ext4,
	cluster-devel, linux-fsdevel

On Thu, Mar 9, 2023 at 10:43 AM Yangtao Li <frank.li@vivo.com> wrote:
> Introduce i_blocksize_mask() to simplify code, which replace
> (i_blocksize(node) - 1). Like done in commit
> 93407472a21b("fs: add i_blocksize()").

I would call this i_blockmask().

Note that it could be used in ocfs2_is_io_unaligned() as well.

>
> Signed-off-by: Yangtao Li <frank.li@vivo.com>
> ---
>  include/linux/fs.h | 5 +++++
>  1 file changed, 5 insertions(+)
>
> diff --git a/include/linux/fs.h b/include/linux/fs.h
> index c85916e9f7db..db335bd9c256 100644
> --- a/include/linux/fs.h
> +++ b/include/linux/fs.h
> @@ -711,6 +711,11 @@ static inline unsigned int i_blocksize(const struct inode *node)
>         return (1 << node->i_blkbits);
>  }
>
> +static inline unsigned int i_blocksize_mask(const struct inode *node)
> +{
> +       return i_blocksize(node) - 1;
> +}
> +
>  static inline int inode_unhashed(struct inode *inode)
>  {
>         return hlist_unhashed(&inode->i_hash);
> --
> 2.25.1
>

Thanks,
Andreas


^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2023-03-09 10:22 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-03-09  9:43 [PATCH 1/4] fs: add i_blocksize_mask() Yangtao Li
2023-03-09  9:43 ` [PATCH 2/4] erofs: convert to use i_blocksize_mask() Yangtao Li
2023-03-09  9:43 ` [PATCH 3/4] gfs2: " Yangtao Li
2023-03-09  9:43 ` [PATCH 4/4] ext4: " Yangtao Li
2023-03-09 10:21 ` [PATCH 1/4] fs: add i_blocksize_mask() Andreas Gruenbacher

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).