diff mbox

ceph: update readpages osd request according to size of pages.

Message ID 20170119082423.44545-1-zyan@redhat.com (mailing list archive)
State New, archived
Headers show

Commit Message

Yan, Zheng Jan. 19, 2017, 8:24 a.m. UTC
add_to_page_cache_lru() can fails, so the actual pages to read
can be smaller than the initial size of osd request. We need to
update osd request size in that case.

Signed-off-by: "Yan, Zheng" <zyan@redhat.com>
---
 fs/ceph/addr.c        | 1 +
 net/ceph/osd_client.c | 3 ++-
 2 files changed, 3 insertions(+), 1 deletion(-)

Comments

Jeff Layton Jan. 19, 2017, 12:39 p.m. UTC | #1
On Thu, 2017-01-19 at 16:24 +0800, Yan, Zheng wrote:
> add_to_page_cache_lru() can fails, so the actual pages to read
> can be smaller than the initial size of osd request. We need to
> update osd request size in that case.
> 
> Signed-off-by: "Yan, Zheng" <zyan@redhat.com>
> ---
>  fs/ceph/addr.c        | 1 +
>  net/ceph/osd_client.c | 3 ++-
>  2 files changed, 3 insertions(+), 1 deletion(-)
> 
> diff --git a/fs/ceph/addr.c b/fs/ceph/addr.c
> index 3985256..4547bbf 100644
> --- a/fs/ceph/addr.c
> +++ b/fs/ceph/addr.c
> @@ -391,6 +391,7 @@ static int start_read(struct inode *inode, struct list_head *page_list, int max)
>  			nr_pages = i;
>  			if (nr_pages > 0) {
>  				len = nr_pages << PAGE_SHIFT;
> +				osd_req_op_extent_update(req, 0, len);
>  				break;
>  			}
>  			goto out_pages;
> diff --git a/net/ceph/osd_client.c b/net/ceph/osd_client.c
> index 842f049..3a2417b 100644
> --- a/net/ceph/osd_client.c
> +++ b/net/ceph/osd_client.c
> @@ -672,7 +672,8 @@ void osd_req_op_extent_update(struct ceph_osd_request *osd_req,
>  	BUG_ON(length > previous);
>  
>  	op->extent.length = length;
> -	op->indata_len -= previous - length;
> +	if (op->op == CEPH_OSD_OP_WRITE || op->op == CEPH_OSD_OP_WRITEFULL)
> +		op->indata_len -= previous - length;
>  }
>  EXPORT_SYMBOL(osd_req_op_extent_update);
>  

Looks right, but this special casing of the request types at this layer
just seems so nasty. I guess it's unavoidable given the way the protocol
works, but I can't help feeling like it's a layering violation when I
look at it:
 
Reviewed-by: Jeff Layton <jlayton@redhat.com>
--
To unsubscribe from this list: send the line "unsubscribe ceph-devel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

diff --git a/fs/ceph/addr.c b/fs/ceph/addr.c
index 3985256..4547bbf 100644
--- a/fs/ceph/addr.c
+++ b/fs/ceph/addr.c
@@ -391,6 +391,7 @@  static int start_read(struct inode *inode, struct list_head *page_list, int max)
 			nr_pages = i;
 			if (nr_pages > 0) {
 				len = nr_pages << PAGE_SHIFT;
+				osd_req_op_extent_update(req, 0, len);
 				break;
 			}
 			goto out_pages;
diff --git a/net/ceph/osd_client.c b/net/ceph/osd_client.c
index 842f049..3a2417b 100644
--- a/net/ceph/osd_client.c
+++ b/net/ceph/osd_client.c
@@ -672,7 +672,8 @@  void osd_req_op_extent_update(struct ceph_osd_request *osd_req,
 	BUG_ON(length > previous);
 
 	op->extent.length = length;
-	op->indata_len -= previous - length;
+	if (op->op == CEPH_OSD_OP_WRITE || op->op == CEPH_OSD_OP_WRITEFULL)
+		op->indata_len -= previous - length;
 }
 EXPORT_SYMBOL(osd_req_op_extent_update);