]> git.karo-electronics.de Git - linux-beck.git/commitdiff
nfs: add nfs_pgio_current_mirror helper
authorPeng Tao <tao.peng@primarydata.com>
Mon, 10 Nov 2014 00:35:35 +0000 (08:35 +0800)
committerTom Haynes <loghyr@primarydata.com>
Tue, 3 Feb 2015 19:06:48 +0000 (11:06 -0800)
Let it return current nfs_pgio_mirror in use depending on pg_mirror_count.
For read, we always use pg_mirrors[0], so this effectively gives us freedom
to use pg_mirror_idx to track the actual mirror to read from through out the
IO stack.

Signed-off-by: Peng Tao <tao.peng@primarydata.com>
Signed-off-by: Tom Haynes <loghyr@primarydata.com>
fs/nfs/internal.h
fs/nfs/objlayout/objio_osd.c
fs/nfs/pagelist.c
fs/nfs/pnfs.c

index 5be06bcafa2f749bf6f476e2500cdff3ecde38e8..ffe4b7ac9e6beb6ae1b202b8c0c6d93a9d8fe4ff 100644 (file)
@@ -255,6 +255,8 @@ int nfs_initiate_pgio(struct rpc_clnt *clnt, struct nfs_pgio_header *hdr,
                      struct rpc_cred *cred, const struct nfs_rpc_ops *rpc_ops,
                      const struct rpc_call_ops *call_ops, int how, int flags);
 void nfs_free_request(struct nfs_page *req);
+struct nfs_pgio_mirror *
+nfs_pgio_current_mirror(struct nfs_pageio_descriptor *desc);
 
 static inline void nfs_iocounter_init(struct nfs_io_counter *c)
 {
index 9a5f2ee6001f92f6d6cca782a01c2a73caab93a1..24e1d7403c0be241fa90dd6645f86dddadf0add9 100644 (file)
@@ -537,7 +537,7 @@ int objio_write_pagelist(struct nfs_pgio_header *hdr, int how)
 static size_t objio_pg_test(struct nfs_pageio_descriptor *pgio,
                          struct nfs_page *prev, struct nfs_page *req)
 {
-       struct nfs_pgio_mirror *mirror = &pgio->pg_mirrors[pgio->pg_mirror_idx];
+       struct nfs_pgio_mirror *mirror = nfs_pgio_current_mirror(pgio);
        unsigned int size;
 
        size = pnfs_generic_pg_test(pgio, prev, req);
index f9d8c4691149709d894596ea432d213edd25ddf3..960c99f75d3f28abe3e44a74cd195eed6fda7c21 100644 (file)
@@ -42,11 +42,20 @@ static bool nfs_pgarray_set(struct nfs_page_array *p, unsigned int pagecount)
        return p->pagevec != NULL;
 }
 
+struct nfs_pgio_mirror *
+nfs_pgio_current_mirror(struct nfs_pageio_descriptor *desc)
+{
+       return nfs_pgio_has_mirroring(desc) ?
+               &desc->pg_mirrors[desc->pg_mirror_idx] :
+               &desc->pg_mirrors[0];
+}
+EXPORT_SYMBOL_GPL(nfs_pgio_current_mirror);
+
 void nfs_pgheader_init(struct nfs_pageio_descriptor *desc,
                       struct nfs_pgio_header *hdr,
                       void (*release)(struct nfs_pgio_header *hdr))
 {
-       struct nfs_pgio_mirror *mirror = &desc->pg_mirrors[desc->pg_mirror_idx];
+       struct nfs_pgio_mirror *mirror = nfs_pgio_current_mirror(desc);
 
 
        hdr->req = nfs_list_entry(mirror->pg_list.next);
@@ -485,7 +494,7 @@ nfs_wait_on_request(struct nfs_page *req)
 size_t nfs_generic_pg_test(struct nfs_pageio_descriptor *desc,
                           struct nfs_page *prev, struct nfs_page *req)
 {
-       struct nfs_pgio_mirror *mirror = &desc->pg_mirrors[desc->pg_mirror_idx];
+       struct nfs_pgio_mirror *mirror = nfs_pgio_current_mirror(desc);
 
 
        if (mirror->pg_count > mirror->pg_bsize) {
@@ -782,7 +791,7 @@ static void nfs_pgio_result(struct rpc_task *task, void *calldata)
 int nfs_generic_pgio(struct nfs_pageio_descriptor *desc,
                     struct nfs_pgio_header *hdr)
 {
-       struct nfs_pgio_mirror *mirror = &desc->pg_mirrors[desc->pg_mirror_idx];
+       struct nfs_pgio_mirror *mirror = nfs_pgio_current_mirror(desc);
 
        struct nfs_page         *req;
        struct page             **pages,
@@ -831,7 +840,7 @@ static int nfs_generic_pg_pgios(struct nfs_pageio_descriptor *desc)
        struct nfs_pgio_header *hdr;
        int ret;
 
-       mirror = &desc->pg_mirrors[desc->pg_mirror_idx];
+       mirror = nfs_pgio_current_mirror(desc);
 
        hdr = nfs_pgio_header_alloc(desc->pg_rw_ops);
        if (!hdr) {
@@ -961,7 +970,7 @@ static bool nfs_can_coalesce_requests(struct nfs_page *prev,
 static int nfs_pageio_do_add_request(struct nfs_pageio_descriptor *desc,
                                     struct nfs_page *req)
 {
-       struct nfs_pgio_mirror *mirror = &desc->pg_mirrors[desc->pg_mirror_idx];
+       struct nfs_pgio_mirror *mirror = nfs_pgio_current_mirror(desc);
 
        struct nfs_page *prev = NULL;
 
@@ -985,7 +994,7 @@ static int nfs_pageio_do_add_request(struct nfs_pageio_descriptor *desc,
  */
 static void nfs_pageio_doio(struct nfs_pageio_descriptor *desc)
 {
-       struct nfs_pgio_mirror *mirror = &desc->pg_mirrors[desc->pg_mirror_idx];
+       struct nfs_pgio_mirror *mirror = nfs_pgio_current_mirror(desc);
 
 
        if (!list_empty(&mirror->pg_list)) {
@@ -1015,7 +1024,7 @@ static void nfs_pageio_doio(struct nfs_pageio_descriptor *desc)
 static int __nfs_pageio_add_request(struct nfs_pageio_descriptor *desc,
                           struct nfs_page *req)
 {
-       struct nfs_pgio_mirror *mirror = &desc->pg_mirrors[desc->pg_mirror_idx];
+       struct nfs_pgio_mirror *mirror = nfs_pgio_current_mirror(desc);
 
        struct nfs_page *subreq;
        unsigned int bytes_left = 0;
@@ -1078,7 +1087,7 @@ err_ptr:
 
 static int nfs_do_recoalesce(struct nfs_pageio_descriptor *desc)
 {
-       struct nfs_pgio_mirror *mirror = &desc->pg_mirrors[desc->pg_mirror_idx];
+       struct nfs_pgio_mirror *mirror = nfs_pgio_current_mirror(desc);
        LIST_HEAD(head);
 
        do {
index e123cfce54ee621fec0a4b466cf0f455658a3dc0..b822b1749643dcf485b5b2dd94eda17093e53676 100644 (file)
@@ -1731,7 +1731,7 @@ static void
 pnfs_write_through_mds(struct nfs_pageio_descriptor *desc,
                struct nfs_pgio_header *hdr)
 {
-       struct nfs_pgio_mirror *mirror = &desc->pg_mirrors[desc->pg_mirror_idx];
+       struct nfs_pgio_mirror *mirror = nfs_pgio_current_mirror(desc);
 
        if (!test_and_set_bit(NFS_IOHDR_REDO, &hdr->flags)) {
                list_splice_tail_init(&hdr->pages, &mirror->pg_list);
@@ -1785,7 +1785,7 @@ EXPORT_SYMBOL_GPL(pnfs_writehdr_free);
 int
 pnfs_generic_pg_writepages(struct nfs_pageio_descriptor *desc)
 {
-       struct nfs_pgio_mirror *mirror = &desc->pg_mirrors[desc->pg_mirror_idx];
+       struct nfs_pgio_mirror *mirror = nfs_pgio_current_mirror(desc);
 
        struct nfs_pgio_header *hdr;
        int ret;
@@ -1846,8 +1846,7 @@ static void
 pnfs_read_through_mds(struct nfs_pageio_descriptor *desc,
                struct nfs_pgio_header *hdr)
 {
-       struct nfs_pgio_mirror *mirror = &desc->pg_mirrors[desc->pg_mirror_idx];
-
+       struct nfs_pgio_mirror *mirror = nfs_pgio_current_mirror(desc);
 
        if (!test_and_set_bit(NFS_IOHDR_REDO, &hdr->flags)) {
                list_splice_tail_init(&hdr->pages, &mirror->pg_list);
@@ -1903,7 +1902,7 @@ EXPORT_SYMBOL_GPL(pnfs_readhdr_free);
 int
 pnfs_generic_pg_readpages(struct nfs_pageio_descriptor *desc)
 {
-       struct nfs_pgio_mirror *mirror = &desc->pg_mirrors[desc->pg_mirror_idx];
+       struct nfs_pgio_mirror *mirror = nfs_pgio_current_mirror(desc);
 
        struct nfs_pgio_header *hdr;
        int ret;