Skip to contentSkip to conversation

ceph: reset "err = 0" after iov_get_pages_alloc in ceph_netfs_issue_read

PATCH In review Jeff Layton 2 participants 4 messages Jul 7, 2022 – Jul 11, 2022 Ceph client

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 ceph: reset "err = 0" after iov_get_pages_alloc in ceph_netfs_issue_read

Currently, when we call ceph_netfs_issue_read for an encrypted inode, we'll call iov_iter_get_pages_alloc and assign its result to "err". Later we'll end up inappropriately calling netfs_subreq_terminated with that value after submitting the request. Ensure we reset "err = 0;" after calling iov_iter_get_pages_alloc.

---
 fs/ceph/addr.c | 1 +
 1 file changed, 1 insertion(+)

Probably this should get squashed into the patch that adds fscrypt support to buffered reads.

fs/ceph/addr.c +1 -0
index c713b5491012..64facef79883 100644
@@ -376,6 +376,7 @@ static void ceph_netfs_issue_read(struct netfs_io_subrequest *subreq)
 		/* should always give us a page-aligned read */
 		WARN_ON_ONCE(page_off);
 		len = err;
+		err = 0;
 
 		osd_req_op_extent_osd_data_pages(req, 0, pages, len, 0, false, false);
 	} else {
Signature · 1 line
2.36.1
#1 lore raw
Quoted 19 lines · Jeff Layton

Currently, when we call ceph_netfs_issue_read for an encrypted inode, we'll call iov_iter_get_pages_alloc and assign its result to "err". Later we'll end up inappropriately calling netfs_subreq_terminated with that value after submitting the request. Ensure we reset "err = 0;" after calling iov_iter_get_pages_alloc.

---
  fs/ceph/addr.c | 1 +
  1 file changed, 1 insertion(+)

Probably this should get squashed into the patch that adds fscrypt support to buffered reads.

fs/ceph/addr.c +0 -0
index c713b5491012..64facef79883 100644

fs/ceph/addr.c static void ceph_netfs_issue_read(struct netfs_io_subrequest *subreq) · line 382

Quoted 7 lines
fs/ceph/addr.c +1 -0
@@ -376,6 +376,7 @@ static void ceph_netfs_issue_read(struct netfs_io_subrequest *subreq)
  		/* should always give us a page-aligned read */
  		WARN_ON_ONCE(page_off);
  		len = err;
+		err = 0;
 
  		osd_req_op_extent_osd_data_pages(req, 0, pages, len, 0, false, false);
  	} else {

Looks good. Thanks Jeff!

Show we fold it into the previous patch ?

-- Xiubo

#2 lore raw
Quoted 25 lines · Xiubo Li
Quoted 24 lines · Jeff Layton

Currently, when we call ceph_netfs_issue_read for an encrypted inode, we'll call iov_iter_get_pages_alloc and assign its result to "err". Later we'll end up inappropriately calling netfs_subreq_terminated with that value after submitting the request. Ensure we reset "err = 0;" after calling iov_iter_get_pages_alloc.

---
  fs/ceph/addr.c | 1 +
  1 file changed, 1 insertion(+)

Probably this should get squashed into the patch that adds fscrypt support to buffered reads.

fs/ceph/addr.c +1 -0
index c713b5491012..64facef79883 100644
@@ -376,6 +376,7 @@ static void ceph_netfs_issue_read(struct netfs_io_subrequest *subreq)
  		/* should always give us a page-aligned read */
  		WARN_ON_ONCE(page_off);
  		len = err;
+		err = 0;
 
Quoted 9 lines

fs/ceph/addr.c static void ceph_netfs_issue_read(struct netfs_io_subrequest *subreq) · line 382

Quoted 2 lines
fs/ceph/addr.c +0 -0
  		osd_req_op_extent_osd_data_pages(req, 0, pages, len, 0, false, false);
  	} else {

Looks good. Thanks Jeff!

Show we fold it into the previous patch ?

-- Xiubo

Yes, please do.

Signature · 1 line
Jeff Layton <[email protected]>
#3 lore raw
Quoted 30 lines · Jeff Layton
Quoted 29 lines · Xiubo Li
Quoted 19 lines · Jeff Layton

Currently, when we call ceph_netfs_issue_read for an encrypted inode, we'll call iov_iter_get_pages_alloc and assign its result to "err". Later we'll end up inappropriately calling netfs_subreq_terminated with that value after submitting the request. Ensure we reset "err = 0;" after calling iov_iter_get_pages_alloc.

---
   fs/ceph/addr.c | 1 +
   1 file changed, 1 insertion(+)

Probably this should get squashed into the patch that adds fscrypt support to buffered reads.

fs/ceph/addr.c +0 -0
index c713b5491012..64facef79883 100644

fs/ceph/addr.c static void ceph_netfs_issue_read(struct netfs_io_subrequest *subreq) · line 382

Quoted 7 lines
fs/ceph/addr.c +1 -0
@@ -376,6 +376,7 @@ static void ceph_netfs_issue_read(struct netfs_io_subrequest *subreq)
   		/* should always give us a page-aligned read */
   		WARN_ON_ONCE(page_off);
   		len = err;
+		err = 0;
 
   		osd_req_op_extent_osd_data_pages(req, 0, pages, len, 0, false, false);
   	} else {

Looks good. Thanks Jeff!

Quoted 6 lines
Quoted 5 lines

Show we fold it into the previous patch ?

-- Xiubo

Yes, please do.

Folded it into:

commit 7487b08568482dd113429134a2219e203214ae0d
Author: Jeff Layton <[email protected]>
Date:   Sun Mar 20 09:35:58 2022 -0400

    ceph: add fscrypt decryption support to ceph_netfs_issue_op

    Force the use of sparse reads when the inode is encrypted, and add the appropriate code to decrypt the extent map after receiving.

Thanks!