ceph: misc fix size truncate for fscrypt
v2 cover ceph: misc fix size truncate for fscrypt
From: Xiubo Li <[email protected]>
Hi Jeff,
This series could be squashed into the same previous commit:
e90dc20d37a3 ceph: add truncate size handling support for fscrypt
V2:
- remove the filemap lock related patch.
- fix caps reference leakage
Xiubo Li (2):
ceph: flush small range instead of the whole map for truncate
ceph: fix caps reference leakage for fscrypt size truncating
fs/ceph/inode.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-)
Signature · 1 line
2.27.0
PATCH v2 1/2 ceph: flush small range instead of the whole map for truncate
From: Xiubo Li <[email protected]>
--- fs/ceph/inode.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-)
fs/ceph/inode.c +7 -2
@@ -2275,8 +2275,13 @@ static int fill_fscrypt_truncate(struct inode *inode, ceph_cap_string(issued));/* Try to writeback the dirty pagecaches */ -if (issued & (CEPH_CAP_FILE_BUFFER )) -filemap_write_and_wait (inode->i_mapping); +if (issued & (CEPH_CAP_FILE_BUFFER )) { +loff_t lend = orig_pos +CEPH_FSCRYPT_BLOCK_SHIFT -1 ; + ret =filemap_write_and_wait_range (inode->i_mapping, + orig_pos, lend); +if (ret <0 ) + goto out; + } page =__page_cache_alloc (GFP_KERNEL );if (page ==NULL ) {
Signature · 1 line
2.27.0
PATCH v2 2/2 ceph: fix caps reference leakage for fscrypt size truncating
In reply to [email protected]From: Xiubo Li <[email protected]>
--- fs/ceph/inode.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
fs/ceph/inode.c +1 -1
@@ -2301,7 +2301,6 @@ static int fill_fscrypt_truncate(struct inode *inode, pos = orig_pos; ret =__ceph_sync_read (inode, &pos, &iter, &retry_op, &objver); -ceph_put_cap_refs (ci, got);if (ret <0 ) goto out;
@@ -2365,6 +2364,7 @@ static int fill_fscrypt_truncate(struct inode *inode, out:dout ("%s %p size dropping cap refs on %s\n" , __func__, inode,ceph_cap_string (got)); +ceph_put_cap_refs (ci, got);kunmap_local (iov.iov_base);if (page)__free_pages (page,0 );
Signature · 1 line
2.27.0
Re: [PATCH v2 2/2] ceph: fix caps reference leakage for fscrypt size truncating
Quoted 30 lines · On Mon, Apr 11, 2022 at 08:14:26AM +0800, [email protected] wrote:
From: Xiubo Li <[email protected]>
Signed-off-by Xiubo Li <[email protected]>--- fs/ceph/inode.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)fs/ceph/inode.c +1
-1@@ -2301,7 +2301,6 @@ static int fill_fscrypt_truncate(struct inode *inode, pos = orig_pos; ret =__ceph_sync_read (inode, &pos, &iter, &retry_op, &objver); -ceph_put_cap_refs (ci, got);if (ret <0 ) goto out;@@ -2365,6 +2364,7 @@ static int fill_fscrypt_truncate(struct inode *inode, out:dout ("%s %p size dropping cap refs on %s\n" , __func__, inode,ceph_cap_string (got)); +ceph_put_cap_refs (ci, got);kunmap_local (iov.iov_base);if (page)__free_pages (page,0 );Signature · 1 line
2.27.0
If the plan is to squash this into commit "ceph: add truncate size handling support for fscrypt" it may be worth also fix the kmap_local_page()/kunmap_local() as the first few 'goto out' jumps shouldn't be doing the kunmap.
Cheers,
--
Luís
Re: [PATCH v2 2/2] ceph: fix caps reference leakage for fscrypt size truncating
Quoted 20 lines · Luís Henriques
Quoted 19 lines · On Mon, Apr 11, 2022 at 08:14:26AM +0800, [email protected] wrote:
From: Xiubo Li <[email protected]>
Signed-off-by Xiubo Li <[email protected]>--- fs/ceph/inode.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)fs/ceph/inode.c +0
-1@@ -2301,7 +2301,6 @@ static int fill_fscrypt_truncate(struct inode *inode, pos = orig_pos; ret =__ceph_sync_read (inode, &pos, &iter, &retry_op, &objver); -ceph_put_cap_refs (ci, got);if (ret <0 ) goto out;
Quoted 15 lines
Quoted 11 lines
fs/ceph/inode.c +1
-0@@ -2365,6 +2364,7 @@ static int fill_fscrypt_truncate(struct inode *inode, out:dout ("%s %p size dropping cap refs on %s\n" , __func__, inode,ceph_cap_string (got)); +ceph_put_cap_refs (ci, got);kunmap_local (iov.iov_base);if (page)__free_pages (page,0 );Signature · 1 line
2.27.0If the plan is to squash this into commit "ceph: add truncate size handling support for fscrypt" it may be worth also fix the kmap_local_page()/kunmap_local() as the first few 'goto out' jumps shouldn't be doing the kunmap.
Good catch, will fix it in V3.
-- Xiubo
Quoted 4 lines
Cheers,
--
Luís