diff options
author | Trond Myklebust <Trond.Myklebust@netapp.com> | 2012-09-18 16:41:18 -0400 |
---|---|---|
committer | Trond Myklebust <Trond.Myklebust@netapp.com> | 2012-09-28 16:03:09 -0400 |
commit | b9e028fd89d6834558aa2a5bb30e5cff5c6c1059 (patch) | |
tree | 7333094e4b4e388c36bfb7f69683f46ae714051b /fs | |
parent | f86bbcf85db32596a0484477d1b8042005709049 (diff) |
NFSv4.1: Add helpers for setting/reading the I/O fail bit
...and make them local to the pnfs.c file.
Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
Diffstat (limited to 'fs')
-rw-r--r-- | fs/nfs/pnfs.c | 38 | ||||
-rw-r--r-- | fs/nfs/pnfs.h | 6 |
2 files changed, 26 insertions, 18 deletions
diff --git a/fs/nfs/pnfs.c b/fs/nfs/pnfs.c index df45acaf91f..f46f9bc4f76 100644 --- a/fs/nfs/pnfs.c +++ b/fs/nfs/pnfs.c | |||
@@ -238,6 +238,27 @@ pnfs_put_layout_hdr(struct pnfs_layout_hdr *lo) | |||
238 | } | 238 | } |
239 | } | 239 | } |
240 | 240 | ||
241 | static int | ||
242 | pnfs_iomode_to_fail_bit(u32 iomode) | ||
243 | { | ||
244 | return iomode == IOMODE_RW ? | ||
245 | NFS_LAYOUT_RW_FAILED : NFS_LAYOUT_RO_FAILED; | ||
246 | } | ||
247 | |||
248 | static void | ||
249 | pnfs_layout_io_set_failed(struct pnfs_layout_hdr *lo, u32 iomode) | ||
250 | { | ||
251 | set_bit(pnfs_iomode_to_fail_bit(iomode), &lo->plh_flags); | ||
252 | dprintk("%s Setting layout IOMODE_%s fail bit\n", __func__, | ||
253 | iomode == IOMODE_RW ? "RW" : "READ"); | ||
254 | } | ||
255 | |||
256 | static bool | ||
257 | pnfs_layout_io_test_failed(struct pnfs_layout_hdr *lo, u32 iomode) | ||
258 | { | ||
259 | return test_bit(pnfs_iomode_to_fail_bit(iomode), &lo->plh_flags) != 0; | ||
260 | } | ||
261 | |||
241 | static void | 262 | static void |
242 | init_lseg(struct pnfs_layout_hdr *lo, struct pnfs_layout_segment *lseg) | 263 | init_lseg(struct pnfs_layout_hdr *lo, struct pnfs_layout_segment *lseg) |
243 | { | 264 | { |
@@ -612,7 +633,7 @@ send_layoutget(struct pnfs_layout_hdr *lo, | |||
612 | break; | 633 | break; |
613 | default: | 634 | default: |
614 | /* remember that LAYOUTGET failed and suspend trying */ | 635 | /* remember that LAYOUTGET failed and suspend trying */ |
615 | set_bit(lo_fail_bit(range->iomode), &lo->plh_flags); | 636 | pnfs_layout_io_set_failed(lo, range->iomode); |
616 | } | 637 | } |
617 | return NULL; | 638 | return NULL; |
618 | } | 639 | } |
@@ -669,8 +690,8 @@ _pnfs_return_layout(struct inode *ino) | |||
669 | lrp = kzalloc(sizeof(*lrp), GFP_KERNEL); | 690 | lrp = kzalloc(sizeof(*lrp), GFP_KERNEL); |
670 | if (unlikely(lrp == NULL)) { | 691 | if (unlikely(lrp == NULL)) { |
671 | status = -ENOMEM; | 692 | status = -ENOMEM; |
672 | set_bit(NFS_LAYOUT_RW_FAILED, &lo->plh_flags); | 693 | pnfs_layout_io_set_failed(lo, IOMODE_RW); |
673 | set_bit(NFS_LAYOUT_RO_FAILED, &lo->plh_flags); | 694 | pnfs_layout_io_set_failed(lo, IOMODE_READ); |
674 | pnfs_clear_layout_returned(lo); | 695 | pnfs_clear_layout_returned(lo); |
675 | pnfs_put_layout_hdr(lo); | 696 | pnfs_put_layout_hdr(lo); |
676 | goto out; | 697 | goto out; |
@@ -1019,7 +1040,6 @@ pnfs_update_layout(struct inode *ino, | |||
1019 | .length = count, | 1040 | .length = count, |
1020 | }; | 1041 | }; |
1021 | unsigned pg_offset; | 1042 | unsigned pg_offset; |
1022 | struct nfs_inode *nfsi = NFS_I(ino); | ||
1023 | struct nfs_server *server = NFS_SERVER(ino); | 1043 | struct nfs_server *server = NFS_SERVER(ino); |
1024 | struct nfs_client *clp = server->nfs_client; | 1044 | struct nfs_client *clp = server->nfs_client; |
1025 | struct pnfs_layout_hdr *lo; | 1045 | struct pnfs_layout_hdr *lo; |
@@ -1044,7 +1064,7 @@ pnfs_update_layout(struct inode *ino, | |||
1044 | } | 1064 | } |
1045 | 1065 | ||
1046 | /* if LAYOUTGET already failed once we don't try again */ | 1066 | /* if LAYOUTGET already failed once we don't try again */ |
1047 | if (test_bit(lo_fail_bit(iomode), &nfsi->layout->plh_flags)) | 1067 | if (pnfs_layout_io_test_failed(lo, iomode)) |
1048 | goto out_unlock; | 1068 | goto out_unlock; |
1049 | 1069 | ||
1050 | /* Check to see if the layout for the given range already exists */ | 1070 | /* Check to see if the layout for the given range already exists */ |
@@ -1585,13 +1605,7 @@ static void pnfs_list_write_lseg(struct inode *inode, struct list_head *listp) | |||
1585 | 1605 | ||
1586 | void pnfs_set_lo_fail(struct pnfs_layout_segment *lseg) | 1606 | void pnfs_set_lo_fail(struct pnfs_layout_segment *lseg) |
1587 | { | 1607 | { |
1588 | if (lseg->pls_range.iomode == IOMODE_RW) { | 1608 | pnfs_layout_io_set_failed(lseg->pls_layout, lseg->pls_range.iomode); |
1589 | dprintk("%s Setting layout IOMODE_RW fail bit\n", __func__); | ||
1590 | set_bit(lo_fail_bit(IOMODE_RW), &lseg->pls_layout->plh_flags); | ||
1591 | } else { | ||
1592 | dprintk("%s Setting layout IOMODE_READ fail bit\n", __func__); | ||
1593 | set_bit(lo_fail_bit(IOMODE_READ), &lseg->pls_layout->plh_flags); | ||
1594 | } | ||
1595 | } | 1609 | } |
1596 | EXPORT_SYMBOL_GPL(pnfs_set_lo_fail); | 1610 | EXPORT_SYMBOL_GPL(pnfs_set_lo_fail); |
1597 | 1611 | ||
diff --git a/fs/nfs/pnfs.h b/fs/nfs/pnfs.h index 04958797fad..e3eb7d1b17a 100644 --- a/fs/nfs/pnfs.h +++ b/fs/nfs/pnfs.h | |||
@@ -274,12 +274,6 @@ pnfs_test_layout_returned(struct pnfs_layout_hdr *lo) | |||
274 | return test_bit(NFS_LAYOUT_RETURNED, &lo->plh_flags); | 274 | return test_bit(NFS_LAYOUT_RETURNED, &lo->plh_flags); |
275 | } | 275 | } |
276 | 276 | ||
277 | static inline int lo_fail_bit(u32 iomode) | ||
278 | { | ||
279 | return iomode == IOMODE_RW ? | ||
280 | NFS_LAYOUT_RW_FAILED : NFS_LAYOUT_RO_FAILED; | ||
281 | } | ||
282 | |||
283 | static inline struct pnfs_layout_segment * | 277 | static inline struct pnfs_layout_segment * |
284 | pnfs_get_lseg(struct pnfs_layout_segment *lseg) | 278 | pnfs_get_lseg(struct pnfs_layout_segment *lseg) |
285 | { | 279 | { |