* [PATCH v3] erofs: support STATX_DIOALIGN [not found] <20240718063756.2982763-1-lihongbo22@huawei.com> @ 2024-07-18 8:32 ` Gao Xiang 2024-07-18 8:35 ` Gao Xiang 0 siblings, 1 reply; 3+ messages in thread From: Gao Xiang @ 2024-07-18 8:32 UTC (permalink / raw) To: linux-erofs, Chao Yu; +Cc: LKML, Hongbo Li, Gao Xiang From: Hongbo Li via Linux-erofs <linux-erofs@lists.ozlabs.org> Add support for STATX_DIOALIGN to erofs, so that direct I/O alignment restrictions are exposed to userspace in a generic way. [Before] ``` ./statx_test /mnt/erofs/testfile statx(/mnt/erofs/testfile) = 0 dio mem align:0 dio offset align:0 ``` [After] ``` ./statx_test /mnt/erofs/testfile statx(/mnt/erofs/testfile) = 0 dio mem align:512 dio offset align:512 ``` Signed-off-by: Hongbo Li <lihongbo22@huawei.com> Signed-off-by: Gao Xiang <hsiangkao@linux.alibaba.com> --- Hi Hongbo, I tidy up the patch a bit according to the current codebase, I will apply this later for this cycle. Also r-v-bs are always welcome... Thanks, Gao Xiang fs/erofs/inode.c | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/fs/erofs/inode.c b/fs/erofs/inode.c index 5f6439a63af7..43c09aae2afc 100644 --- a/fs/erofs/inode.c +++ b/fs/erofs/inode.c @@ -334,14 +334,29 @@ int erofs_getattr(struct mnt_idmap *idmap, const struct path *path, unsigned int query_flags) { struct inode *const inode = d_inode(path->dentry); + bool compressed = + erofs_inode_is_data_compressed(EROFS_I(inode)->datalayout); - if (erofs_inode_is_data_compressed(EROFS_I(inode)->datalayout)) + if (compressed) stat->attributes |= STATX_ATTR_COMPRESSED; - stat->attributes |= STATX_ATTR_IMMUTABLE; stat->attributes_mask |= (STATX_ATTR_COMPRESSED | STATX_ATTR_IMMUTABLE); + /* + * Return the DIO alignment restrictions if requested. + * + * In EROFS, STATX_DIOALIGN is not supported in ondemand mode and + * compressed files, so in these cases we report no DIO support. + */ + if ((request_mask & STATX_DIOALIGN) && S_ISREG(inode->i_mode)) { + stat->result_mask |= STATX_DIOALIGN; + if (!erofs_is_fscache_mode(inode->i_sb) && !compressed) { + stat->dio_mem_align = + bdev_logical_block_size(inode->i_sb->s_bdev); + stat->dio_offset_align = stat->dio_mem_align; + } + } generic_fillattr(idmap, request_mask, inode, stat); return 0; } -- 2.43.5 ^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH v3] erofs: support STATX_DIOALIGN 2024-07-18 8:32 ` [PATCH v3] erofs: support STATX_DIOALIGN Gao Xiang @ 2024-07-18 8:35 ` Gao Xiang 2024-07-26 9:50 ` Chao Yu 0 siblings, 1 reply; 3+ messages in thread From: Gao Xiang @ 2024-07-18 8:35 UTC (permalink / raw) To: linux-erofs, Chao Yu; +Cc: LKML On 2024/7/18 16:32, Gao Xiang wrote: > From: Hongbo Li via Linux-erofs <linux-erofs@lists.ozlabs.org> Also I will fix the email address issue (Hongbo Li <lihongbo22@huawei.com>) when applying too. > > Add support for STATX_DIOALIGN to erofs, so that direct I/O > alignment restrictions are exposed to userspace in a generic > way. > > [Before] > ``` > ./statx_test /mnt/erofs/testfile > statx(/mnt/erofs/testfile) = 0 > dio mem align:0 > dio offset align:0 > ``` > > [After] > ``` > ./statx_test /mnt/erofs/testfile > statx(/mnt/erofs/testfile) = 0 > dio mem align:512 > dio offset align:512 > ``` > > Signed-off-by: Hongbo Li <lihongbo22@huawei.com> > Signed-off-by: Gao Xiang <hsiangkao@linux.alibaba.com> > --- > Hi Hongbo, > > I tidy up the patch a bit according to the current codebase, > I will apply this later for this cycle. > > Also r-v-bs are always welcome... > > Thanks, > Gao Xiang > > fs/erofs/inode.c | 19 +++++++++++++++++-- > 1 file changed, 17 insertions(+), 2 deletions(-) > > diff --git a/fs/erofs/inode.c b/fs/erofs/inode.c > index 5f6439a63af7..43c09aae2afc 100644 > --- a/fs/erofs/inode.c > +++ b/fs/erofs/inode.c > @@ -334,14 +334,29 @@ int erofs_getattr(struct mnt_idmap *idmap, const struct path *path, > unsigned int query_flags) > { > struct inode *const inode = d_inode(path->dentry); > + bool compressed = > + erofs_inode_is_data_compressed(EROFS_I(inode)->datalayout); > > - if (erofs_inode_is_data_compressed(EROFS_I(inode)->datalayout)) > + if (compressed) > stat->attributes |= STATX_ATTR_COMPRESSED; > - > stat->attributes |= STATX_ATTR_IMMUTABLE; > stat->attributes_mask |= (STATX_ATTR_COMPRESSED | > STATX_ATTR_IMMUTABLE); > > + /* > + * Return the DIO alignment restrictions if requested. > + * > + * In EROFS, STATX_DIOALIGN is not supported in ondemand mode and > + * compressed files, so in these cases we report no DIO support. > + */ > + if ((request_mask & STATX_DIOALIGN) && S_ISREG(inode->i_mode)) { > + stat->result_mask |= STATX_DIOALIGN; > + if (!erofs_is_fscache_mode(inode->i_sb) && !compressed) { > + stat->dio_mem_align = > + bdev_logical_block_size(inode->i_sb->s_bdev); > + stat->dio_offset_align = stat->dio_mem_align; > + } > + } > generic_fillattr(idmap, request_mask, inode, stat); > return 0; > } ^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH v3] erofs: support STATX_DIOALIGN 2024-07-18 8:35 ` Gao Xiang @ 2024-07-26 9:50 ` Chao Yu 0 siblings, 0 replies; 3+ messages in thread From: Chao Yu @ 2024-07-26 9:50 UTC (permalink / raw) To: Gao Xiang, linux-erofs; +Cc: LKML On 2024/7/18 16:35, Gao Xiang wrote: > > > On 2024/7/18 16:32, Gao Xiang wrote: >> From: Hongbo Li via Linux-erofs <linux-erofs@lists.ozlabs.org> > > Also I will fix the email address issue > (Hongbo Li <lihongbo22@huawei.com>) when applying too. > >> >> Add support for STATX_DIOALIGN to erofs, so that direct I/O >> alignment restrictions are exposed to userspace in a generic >> way. >> >> [Before] >> ``` >> ./statx_test /mnt/erofs/testfile >> statx(/mnt/erofs/testfile) = 0 >> dio mem align:0 >> dio offset align:0 >> ``` >> >> [After] >> ``` >> ./statx_test /mnt/erofs/testfile >> statx(/mnt/erofs/testfile) = 0 >> dio mem align:512 >> dio offset align:512 >> ``` >> >> Signed-off-by: Hongbo Li <lihongbo22@huawei.com> >> Signed-off-by: Gao Xiang <hsiangkao@linux.alibaba.com> Reviewed-by: Chao Yu <chao@kernel.org> Thanks, ^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2024-07-26 9:51 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
[not found] <20240718063756.2982763-1-lihongbo22@huawei.com>
2024-07-18 8:32 ` [PATCH v3] erofs: support STATX_DIOALIGN Gao Xiang
2024-07-18 8:35 ` Gao Xiang
2024-07-26 9:50 ` Chao Yu
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox