Message ID | 20220407144112.8455-2-xiubli@redhat.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | ceph: misc fix size truncate for fscrypt | expand |
On Thu, 2022-04-07 at 22:41 +0800, xiubli@redhat.com wrote: > From: Xiubo Li <xiubli@redhat.com> > > Signed-off-by: Xiubo Li <xiubli@redhat.com> > --- > fs/ceph/inode.c | 8 ++++++-- > 1 file changed, 6 insertions(+), 2 deletions(-) > > diff --git a/fs/ceph/inode.c b/fs/ceph/inode.c > index 45ca4e598ef0..f4059d73edd5 100644 > --- a/fs/ceph/inode.c > +++ b/fs/ceph/inode.c > @@ -2275,8 +2275,12 @@ 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)) { > + ret = filemap_write_and_wait_range(inode->i_mapping, > + orig_pos, LLONG_MAX); > + if (ret < 0) > + goto out; > + } > > Not much point in writing back blocks we're just going to truncate away anyhow. Maybe this should be writing with this range? orig_pos, orig_pos + CEPH_FSCRYPT_BLOCK_SIZE - 1 > > page = __page_cache_alloc(GFP_KERNEL); > if (page == NULL) {
On 4/7/22 11:45 PM, Jeff Layton wrote: > On Thu, 2022-04-07 at 22:41 +0800, xiubli@redhat.com wrote: >> From: Xiubo Li <xiubli@redhat.com> >> >> Signed-off-by: Xiubo Li <xiubli@redhat.com> >> --- >> fs/ceph/inode.c | 8 ++++++-- >> 1 file changed, 6 insertions(+), 2 deletions(-) >> >> diff --git a/fs/ceph/inode.c b/fs/ceph/inode.c >> index 45ca4e598ef0..f4059d73edd5 100644 >> --- a/fs/ceph/inode.c >> +++ b/fs/ceph/inode.c >> @@ -2275,8 +2275,12 @@ 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)) { >> + ret = filemap_write_and_wait_range(inode->i_mapping, >> + orig_pos, LLONG_MAX); >> + if (ret < 0) >> + goto out; >> + } >> >> > > Not much point in writing back blocks we're just going to truncate away > anyhow. Maybe this should be writing with this range? > > orig_pos, orig_pos + CEPH_FSCRYPT_BLOCK_SIZE - 1 We need to make sure the last block is not buffered in pagecache, because we will aways sync read that from Rados. Yeah, this looks much better. I will fix and test it again. Thanks >> >> page = __page_cache_alloc(GFP_KERNEL); >> if (page == NULL) {
diff --git a/fs/ceph/inode.c b/fs/ceph/inode.c index 45ca4e598ef0..f4059d73edd5 100644 --- a/fs/ceph/inode.c +++ b/fs/ceph/inode.c @@ -2275,8 +2275,12 @@ 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)) { + ret = filemap_write_and_wait_range(inode->i_mapping, + orig_pos, LLONG_MAX); + if (ret < 0) + goto out; + } page = __page_cache_alloc(GFP_KERNEL); if (page == NULL) {