[6/7] ceph: Switch to page_mkwrite_check_truncate in ceph_page_mkwrite
diff mbox series

Message ID 20200213202423.23455-7-agruenba@redhat.com
State New
Headers show
Series
  • Switch to page_mkwrite_check_truncate
Related show

Commit Message

Andreas Gruenbacher Feb. 13, 2020, 8:24 p.m. UTC
Use the "page has been truncated" logic in page_mkwrite_check_truncate
instead of reimplementing it here.  Other than with the existing code,
fail with -EFAULT / VM_FAULT_NOPAGE when page_offset(page) == size here
as well, as should be expected.

Signed-off-by: Andreas Gruenbacher <agruenba@redhat.com>
Acked-by: Jeff Layton <jlayton@kernel.org>
---
 fs/ceph/addr.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Jeff Layton Feb. 14, 2020, midnight UTC | #1
On Thu, 2020-02-13 at 21:24 +0100, Andreas Gruenbacher wrote:
> Use the "page has been truncated" logic in page_mkwrite_check_truncate
> instead of reimplementing it here.  Other than with the existing code,
> fail with -EFAULT / VM_FAULT_NOPAGE when page_offset(page) == size here
> as well, as should be expected.
> 
> Signed-off-by: Andreas Gruenbacher <agruenba@redhat.com>
> Acked-by: Jeff Layton <jlayton@kernel.org>
> ---
>  fs/ceph/addr.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/fs/ceph/addr.c b/fs/ceph/addr.c
> index 7ab616601141..ef958aa4adb4 100644
> --- a/fs/ceph/addr.c
> +++ b/fs/ceph/addr.c
> @@ -1575,7 +1575,7 @@ static vm_fault_t ceph_page_mkwrite(struct vm_fault *vmf)
>  	do {
>  		lock_page(page);
>  
> -		if ((off > size) || (page->mapping != inode->i_mapping)) {
> +		if (page_mkwrite_check_truncate(page, inode) < 0) {
>  			unlock_page(page);
>  			ret = VM_FAULT_NOPAGE;
>  			break;

Thanks Andreas. Merged into the ceph-client/testing branch and should
make v5.7.

Thanks,

Patch
diff mbox series

diff --git a/fs/ceph/addr.c b/fs/ceph/addr.c
index 7ab616601141..ef958aa4adb4 100644
--- a/fs/ceph/addr.c
+++ b/fs/ceph/addr.c
@@ -1575,7 +1575,7 @@  static vm_fault_t ceph_page_mkwrite(struct vm_fault *vmf)
 	do {
 		lock_page(page);
 
-		if ((off > size) || (page->mapping != inode->i_mapping)) {
+		if (page_mkwrite_check_truncate(page, inode) < 0) {
 			unlock_page(page);
 			ret = VM_FAULT_NOPAGE;
 			break;