diff mbox series

fs/ceph: pass inclusive 'lend' parameter to filemap_write_and_wait_range

Message ID 1548991155-124485-1-git-send-email-zhengbin13@huawei.com (mailing list archive)
State New, archived
Headers show
Series fs/ceph: pass inclusive 'lend' parameter to filemap_write_and_wait_range | expand

Commit Message

Zheng Bin Feb. 1, 2019, 3:19 a.m. UTC
The 'lend' parameter of filemap_write_and_wait_range is required to be
inclusive, so follow the rule. Same for invalidate_inode_pages2_range.

Signed-off-by: zhengbin <zhengbin13@huawei.com>
---
 fs/ceph/file.c  | 13 ++++++++-----
 fs/ceph/inode.c |  2 +-
 2 files changed, 9 insertions(+), 6 deletions(-)

--
2.7.4

Comments

Yan, Zheng Feb. 1, 2019, 8:47 a.m. UTC | #1
On Fri, Feb 1, 2019 at 11:38 AM zhengbin <zhengbin13@huawei.com> wrote:
>
> The 'lend' parameter of filemap_write_and_wait_range is required to be
> inclusive, so follow the rule. Same for invalidate_inode_pages2_range.
>
> Signed-off-by: zhengbin <zhengbin13@huawei.com>
> ---
>  fs/ceph/file.c  | 13 ++++++++-----
>  fs/ceph/inode.c |  2 +-
>  2 files changed, 9 insertions(+), 6 deletions(-)
>
> diff --git a/fs/ceph/file.c b/fs/ceph/file.c
> index 189df66..e23ed43 100644
> --- a/fs/ceph/file.c
> +++ b/fs/ceph/file.c
> @@ -590,7 +590,8 @@ static ssize_t ceph_sync_read(struct kiocb *iocb, struct iov_iter *to,
>          * but it will at least behave sensibly when they are
>          * in sequence.
>          */
> -       ret = filemap_write_and_wait_range(inode->i_mapping, off, off + len);
> +       ret = filemap_write_and_wait_range(inode->i_mapping, off,
> +                                          off + len - 1);
>         if (ret < 0)
>                 return ret;
>
> @@ -929,14 +930,15 @@ ceph_direct_read_write(struct kiocb *iocb, struct iov_iter *iter,
>              (write ? "write" : "read"), file, pos, (unsigned)count,
>              snapc, snapc->seq);
>
> -       ret = filemap_write_and_wait_range(inode->i_mapping, pos, pos + count);
> +       ret = filemap_write_and_wait_range(inode->i_mapping, pos,
> +                                          pos + count - 1);
>         if (ret < 0)
>                 return ret;
>
>         if (write) {
>                 int ret2 = invalidate_inode_pages2_range(inode->i_mapping,
>                                         pos >> PAGE_SHIFT,
> -                                       (pos + count) >> PAGE_SHIFT);
> +                                       (pos + count - 1) >> PAGE_SHIFT);
>                 if (ret2 < 0)
>                         dout("invalidate_inode_pages2_range returned %d\n", ret2);
>
> @@ -1132,13 +1134,14 @@ ceph_sync_write(struct kiocb *iocb, struct iov_iter *from, loff_t pos,
>         dout("sync_write on file %p %lld~%u snapc %p seq %lld\n",
>              file, pos, (unsigned)count, snapc, snapc->seq);
>
> -       ret = filemap_write_and_wait_range(inode->i_mapping, pos, pos + count);
> +       ret = filemap_write_and_wait_range(inode->i_mapping, pos,
> +                                          pos + count - 1);
>         if (ret < 0)
>                 return ret;
>
>         ret = invalidate_inode_pages2_range(inode->i_mapping,
>                                             pos >> PAGE_SHIFT,
> -                                           (pos + count) >> PAGE_SHIFT);
> +                                           (pos + count - 1) >> PAGE_SHIFT);
>         if (ret < 0)
>                 dout("invalidate_inode_pages2_range returned %d\n", ret);
>
> diff --git a/fs/ceph/inode.c b/fs/ceph/inode.c
> index 9d1f34d..76de582 100644
> --- a/fs/ceph/inode.c
> +++ b/fs/ceph/inode.c
> @@ -1889,7 +1889,7 @@ void __ceph_do_pending_vmtruncate(struct inode *inode)
>                 dout("__do_pending_vmtruncate %p flushing snaps first\n",
>                      inode);
>                 filemap_write_and_wait_range(&inode->i_data, 0,
> -                                            inode->i_sb->s_maxbytes);
> +                                            inode->i_sb->s_maxbytes - 1);
>                 goto retry;
>         }
>
> --
> 2.7.4
>

Applied, thanks

Yan, Zheng
Zheng Bin Feb. 2, 2019, 1:46 a.m. UTC | #2
Thank you for quick reply, Applied to? ceph-client, linux-next?

On 2019/2/1 16:47, Yan, Zheng wrote:
> On Fri, Feb 1, 2019 at 11:38 AM zhengbin <zhengbin13@huawei.com> wrote:
>>
>> The 'lend' parameter of filemap_write_and_wait_range is required to be
>> inclusive, so follow the rule. Same for invalidate_inode_pages2_range.
>>
>> Signed-off-by: zhengbin <zhengbin13@huawei.com>
>> ---
>>  fs/ceph/file.c  | 13 ++++++++-----
>>  fs/ceph/inode.c |  2 +-
>>  2 files changed, 9 insertions(+), 6 deletions(-)
>>
>> diff --git a/fs/ceph/file.c b/fs/ceph/file.c
>> index 189df66..e23ed43 100644
>> --- a/fs/ceph/file.c
>> +++ b/fs/ceph/file.c
>> @@ -590,7 +590,8 @@ static ssize_t ceph_sync_read(struct kiocb *iocb, struct iov_iter *to,
>>          * but it will at least behave sensibly when they are
>>          * in sequence.
>>          */
>> -       ret = filemap_write_and_wait_range(inode->i_mapping, off, off + len);
>> +       ret = filemap_write_and_wait_range(inode->i_mapping, off,
>> +                                          off + len - 1);
>>         if (ret < 0)
>>                 return ret;
>>
>> @@ -929,14 +930,15 @@ ceph_direct_read_write(struct kiocb *iocb, struct iov_iter *iter,
>>              (write ? "write" : "read"), file, pos, (unsigned)count,
>>              snapc, snapc->seq);
>>
>> -       ret = filemap_write_and_wait_range(inode->i_mapping, pos, pos + count);
>> +       ret = filemap_write_and_wait_range(inode->i_mapping, pos,
>> +                                          pos + count - 1);
>>         if (ret < 0)
>>                 return ret;
>>
>>         if (write) {
>>                 int ret2 = invalidate_inode_pages2_range(inode->i_mapping,
>>                                         pos >> PAGE_SHIFT,
>> -                                       (pos + count) >> PAGE_SHIFT);
>> +                                       (pos + count - 1) >> PAGE_SHIFT);
>>                 if (ret2 < 0)
>>                         dout("invalidate_inode_pages2_range returned %d\n", ret2);
>>
>> @@ -1132,13 +1134,14 @@ ceph_sync_write(struct kiocb *iocb, struct iov_iter *from, loff_t pos,
>>         dout("sync_write on file %p %lld~%u snapc %p seq %lld\n",
>>              file, pos, (unsigned)count, snapc, snapc->seq);
>>
>> -       ret = filemap_write_and_wait_range(inode->i_mapping, pos, pos + count);
>> +       ret = filemap_write_and_wait_range(inode->i_mapping, pos,
>> +                                          pos + count - 1);
>>         if (ret < 0)
>>                 return ret;
>>
>>         ret = invalidate_inode_pages2_range(inode->i_mapping,
>>                                             pos >> PAGE_SHIFT,
>> -                                           (pos + count) >> PAGE_SHIFT);
>> +                                           (pos + count - 1) >> PAGE_SHIFT);
>>         if (ret < 0)
>>                 dout("invalidate_inode_pages2_range returned %d\n", ret);
>>
>> diff --git a/fs/ceph/inode.c b/fs/ceph/inode.c
>> index 9d1f34d..76de582 100644
>> --- a/fs/ceph/inode.c
>> +++ b/fs/ceph/inode.c
>> @@ -1889,7 +1889,7 @@ void __ceph_do_pending_vmtruncate(struct inode *inode)
>>                 dout("__do_pending_vmtruncate %p flushing snaps first\n",
>>                      inode);
>>                 filemap_write_and_wait_range(&inode->i_data, 0,
>> -                                            inode->i_sb->s_maxbytes);
>> +                                            inode->i_sb->s_maxbytes - 1);
>>                 goto retry;
>>         }
>>
>> --
>> 2.7.4
>>
> 
> Applied, thanks
> 
> Yan, Zheng
> 
> .
>
Ilya Dryomov Feb. 3, 2019, 9:33 a.m. UTC | #3
On Sat, Feb 2, 2019 at 2:47 AM zhengbin (A) <zhengbin13@huawei.com> wrote:
>
> Thank you for quick reply, Applied to? ceph-client, linux-next?

ceph-client:

https://github.com/ceph/ceph-client/commits/testing

Thanks,

                Ilya
diff mbox series

Patch

diff --git a/fs/ceph/file.c b/fs/ceph/file.c
index 189df66..e23ed43 100644
--- a/fs/ceph/file.c
+++ b/fs/ceph/file.c
@@ -590,7 +590,8 @@  static ssize_t ceph_sync_read(struct kiocb *iocb, struct iov_iter *to,
 	 * but it will at least behave sensibly when they are
 	 * in sequence.
 	 */
-	ret = filemap_write_and_wait_range(inode->i_mapping, off, off + len);
+	ret = filemap_write_and_wait_range(inode->i_mapping, off,
+					   off + len - 1);
 	if (ret < 0)
 		return ret;

@@ -929,14 +930,15 @@  ceph_direct_read_write(struct kiocb *iocb, struct iov_iter *iter,
 	     (write ? "write" : "read"), file, pos, (unsigned)count,
 	     snapc, snapc->seq);

-	ret = filemap_write_and_wait_range(inode->i_mapping, pos, pos + count);
+	ret = filemap_write_and_wait_range(inode->i_mapping, pos,
+					   pos + count - 1);
 	if (ret < 0)
 		return ret;

 	if (write) {
 		int ret2 = invalidate_inode_pages2_range(inode->i_mapping,
 					pos >> PAGE_SHIFT,
-					(pos + count) >> PAGE_SHIFT);
+					(pos + count - 1) >> PAGE_SHIFT);
 		if (ret2 < 0)
 			dout("invalidate_inode_pages2_range returned %d\n", ret2);

@@ -1132,13 +1134,14 @@  ceph_sync_write(struct kiocb *iocb, struct iov_iter *from, loff_t pos,
 	dout("sync_write on file %p %lld~%u snapc %p seq %lld\n",
 	     file, pos, (unsigned)count, snapc, snapc->seq);

-	ret = filemap_write_and_wait_range(inode->i_mapping, pos, pos + count);
+	ret = filemap_write_and_wait_range(inode->i_mapping, pos,
+					   pos + count - 1);
 	if (ret < 0)
 		return ret;

 	ret = invalidate_inode_pages2_range(inode->i_mapping,
 					    pos >> PAGE_SHIFT,
-					    (pos + count) >> PAGE_SHIFT);
+					    (pos + count - 1) >> PAGE_SHIFT);
 	if (ret < 0)
 		dout("invalidate_inode_pages2_range returned %d\n", ret);

diff --git a/fs/ceph/inode.c b/fs/ceph/inode.c
index 9d1f34d..76de582 100644
--- a/fs/ceph/inode.c
+++ b/fs/ceph/inode.c
@@ -1889,7 +1889,7 @@  void __ceph_do_pending_vmtruncate(struct inode *inode)
 		dout("__do_pending_vmtruncate %p flushing snaps first\n",
 		     inode);
 		filemap_write_and_wait_range(&inode->i_data, 0,
-					     inode->i_sb->s_maxbytes);
+					     inode->i_sb->s_maxbytes - 1);
 		goto retry;
 	}