Skip to contentSkip to conversation

fix page number calculation bug for block layout decode buffer

PATCH Superseded Jim Rees 4 participants 4 messages Apr 9, 2012 – Apr 10, 2012

Subsystems (2)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore

Jim Rees

author
#0 lore raw

PATCH 1/1 fix page number calculation bug for block layout decode buffer

---
 fs/nfs/blocklayout/blocklayout.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
fs/nfs/blocklayout/blocklayout.c +1 -1
index 48cfac3..576da5b 100644
@@ -872,7 +872,7 @@ nfs4_blk_get_deviceinfo(struct nfs_server *server, const struct nfs_fh *fh,
 	 * GETDEVICEINFO's maxcount
 	 */
 	max_resp_sz = server->nfs_client->cl_session->fc_attrs.max_resp_sz;
-	max_pages = max_resp_sz >> PAGE_SHIFT;
+	max_pages = (max_resp_sz  + PAGE_SIZE - 1) >> PAGE_SHIFT;
 	dprintk("%s max_resp_sz %u max_pages %d\n",
 		__func__, max_resp_sz, max_pages);
 
Signature · 1 line
1.7.5.4
#1 lore raw

Hi-

Since all the layouts (and I'm guessing the non-pNFS path too) seem to need this calculation, would it make sense to create an inline function in a header somewhere?

Quoted 26 lines · Jim Rees

---
fs/nfs/blocklayout/blocklayout.c | 2 +-

1 files changed, 1 insertions(+), 1 deletions(-)
fs/nfs/blocklayout/blocklayout.c +1 -1
index 48cfac3..576da5b 100644
@@ -872,7 +872,7 @@ nfs4_blk_get_deviceinfo(struct nfs_server *server, const struct nfs_fh *fh,
 	 * GETDEVICEINFO's maxcount
 	 */
 	max_resp_sz = server->nfs_client->cl_session->fc_attrs.max_resp_sz;
-	max_pages = max_resp_sz >> PAGE_SHIFT;
+	max_pages = (max_resp_sz  + PAGE_SIZE - 1) >> PAGE_SHIFT;
 	dprintk("%s max_resp_sz %u max_pages %d\n",
 		__func__, max_resp_sz, max_pages);
 
Signature · 6 lines
1.7.5.4

--
To unsubscribe from this list: send the line "unsubscribe linux-nfs" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Signature · 2 lines
Chuck Lever
chuck[dot]lever[at]oracle[dot]com
#2 lore raw
Quoted 4 lines · Chuck Lever

Hi-

Since all the layouts (and I'm guessing the non-pNFS path too) seem to need this calculation, would it make sense to create an inline function in a header somewhere?

nfs_page_array_len(0, size) would work.

Fred

#3 lore raw
In reply to Jim Rees
Quoted 11 lines · On Mon, 9 Apr 2012 19:22:07 -0400 Jim Rees <[email protected]> wrote:
---
 fs/nfs/blocklayout/blocklayout.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
fs/nfs/blocklayout/blocklayout.c +0 -0
index 48cfac3..576da5b 100644

fs/nfs/blocklayout/blocklayout.c nfs4_blk_get_deviceinfo(struct nfs_server *server, const struct nfs_fh *fh, · line 875

Quoted 5 lines
fs/nfs/blocklayout/blocklayout.c +1 -1
@@ -872,7 +872,7 @@ nfs4_blk_get_deviceinfo(struct nfs_server *server, const struct nfs_fh *fh,
 	 * GETDEVICEINFO's maxcount
 	 */
 	max_resp_sz = server->nfs_client->cl_session->fc_attrs.max_resp_sz;
-	max_pages = max_resp_sz >> PAGE_SHIFT;
+	max_pages = (max_resp_sz  + PAGE_SIZE - 1) >> PAGE_SHIFT;
        max_pages = DIV_ROUND_UP(max_resp_sz, PAGE_SIZE);

??

compiler should optimise the constant-divide into a shift, and it is more "obviously correct" this way.

NeilBrown

Quoted 3 lines
fs/nfs/blocklayout/blocklayout.c +0 -0
 	dprintk("%s max_resp_sz %u max_pages %d\n",
 		__func__, max_resp_sz, max_pages);