Commit b9e028fd authored by Trond Myklebust's avatar Trond Myklebust

NFSv4.1: Add helpers for setting/reading the I/O fail bit

...and make them local to the pnfs.c file.
Signed-off-by: default avatarTrond Myklebust <Trond.Myklebust@netapp.com>
parent f86bbcf8
...@@ -238,6 +238,27 @@ pnfs_put_layout_hdr(struct pnfs_layout_hdr *lo) ...@@ -238,6 +238,27 @@ pnfs_put_layout_hdr(struct pnfs_layout_hdr *lo)
} }
} }
static int
pnfs_iomode_to_fail_bit(u32 iomode)
{
return iomode == IOMODE_RW ?
NFS_LAYOUT_RW_FAILED : NFS_LAYOUT_RO_FAILED;
}
static void
pnfs_layout_io_set_failed(struct pnfs_layout_hdr *lo, u32 iomode)
{
set_bit(pnfs_iomode_to_fail_bit(iomode), &lo->plh_flags);
dprintk("%s Setting layout IOMODE_%s fail bit\n", __func__,
iomode == IOMODE_RW ? "RW" : "READ");
}
static bool
pnfs_layout_io_test_failed(struct pnfs_layout_hdr *lo, u32 iomode)
{
return test_bit(pnfs_iomode_to_fail_bit(iomode), &lo->plh_flags) != 0;
}
static void static void
init_lseg(struct pnfs_layout_hdr *lo, struct pnfs_layout_segment *lseg) init_lseg(struct pnfs_layout_hdr *lo, struct pnfs_layout_segment *lseg)
{ {
...@@ -612,7 +633,7 @@ send_layoutget(struct pnfs_layout_hdr *lo, ...@@ -612,7 +633,7 @@ send_layoutget(struct pnfs_layout_hdr *lo,
break; break;
default: default:
/* remember that LAYOUTGET failed and suspend trying */ /* remember that LAYOUTGET failed and suspend trying */
set_bit(lo_fail_bit(range->iomode), &lo->plh_flags); pnfs_layout_io_set_failed(lo, range->iomode);
} }
return NULL; return NULL;
} }
...@@ -669,8 +690,8 @@ _pnfs_return_layout(struct inode *ino) ...@@ -669,8 +690,8 @@ _pnfs_return_layout(struct inode *ino)
lrp = kzalloc(sizeof(*lrp), GFP_KERNEL); lrp = kzalloc(sizeof(*lrp), GFP_KERNEL);
if (unlikely(lrp == NULL)) { if (unlikely(lrp == NULL)) {
status = -ENOMEM; status = -ENOMEM;
set_bit(NFS_LAYOUT_RW_FAILED, &lo->plh_flags); pnfs_layout_io_set_failed(lo, IOMODE_RW);
set_bit(NFS_LAYOUT_RO_FAILED, &lo->plh_flags); pnfs_layout_io_set_failed(lo, IOMODE_READ);
pnfs_clear_layout_returned(lo); pnfs_clear_layout_returned(lo);
pnfs_put_layout_hdr(lo); pnfs_put_layout_hdr(lo);
goto out; goto out;
...@@ -1019,7 +1040,6 @@ pnfs_update_layout(struct inode *ino, ...@@ -1019,7 +1040,6 @@ pnfs_update_layout(struct inode *ino,
.length = count, .length = count,
}; };
unsigned pg_offset; unsigned pg_offset;
struct nfs_inode *nfsi = NFS_I(ino);
struct nfs_server *server = NFS_SERVER(ino); struct nfs_server *server = NFS_SERVER(ino);
struct nfs_client *clp = server->nfs_client; struct nfs_client *clp = server->nfs_client;
struct pnfs_layout_hdr *lo; struct pnfs_layout_hdr *lo;
...@@ -1044,7 +1064,7 @@ pnfs_update_layout(struct inode *ino, ...@@ -1044,7 +1064,7 @@ pnfs_update_layout(struct inode *ino,
} }
/* if LAYOUTGET already failed once we don't try again */ /* if LAYOUTGET already failed once we don't try again */
if (test_bit(lo_fail_bit(iomode), &nfsi->layout->plh_flags)) if (pnfs_layout_io_test_failed(lo, iomode))
goto out_unlock; goto out_unlock;
/* Check to see if the layout for the given range already exists */ /* 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,13 +1605,7 @@ static void pnfs_list_write_lseg(struct inode *inode, struct list_head *listp)
void pnfs_set_lo_fail(struct pnfs_layout_segment *lseg) void pnfs_set_lo_fail(struct pnfs_layout_segment *lseg)
{ {
if (lseg->pls_range.iomode == IOMODE_RW) { pnfs_layout_io_set_failed(lseg->pls_layout, lseg->pls_range.iomode);
dprintk("%s Setting layout IOMODE_RW fail bit\n", __func__);
set_bit(lo_fail_bit(IOMODE_RW), &lseg->pls_layout->plh_flags);
} else {
dprintk("%s Setting layout IOMODE_READ fail bit\n", __func__);
set_bit(lo_fail_bit(IOMODE_READ), &lseg->pls_layout->plh_flags);
}
} }
EXPORT_SYMBOL_GPL(pnfs_set_lo_fail); EXPORT_SYMBOL_GPL(pnfs_set_lo_fail);
......
...@@ -274,12 +274,6 @@ pnfs_test_layout_returned(struct pnfs_layout_hdr *lo) ...@@ -274,12 +274,6 @@ pnfs_test_layout_returned(struct pnfs_layout_hdr *lo)
return test_bit(NFS_LAYOUT_RETURNED, &lo->plh_flags); return test_bit(NFS_LAYOUT_RETURNED, &lo->plh_flags);
} }
static inline int lo_fail_bit(u32 iomode)
{
return iomode == IOMODE_RW ?
NFS_LAYOUT_RW_FAILED : NFS_LAYOUT_RO_FAILED;
}
static inline struct pnfs_layout_segment * static inline struct pnfs_layout_segment *
pnfs_get_lseg(struct pnfs_layout_segment *lseg) pnfs_get_lseg(struct pnfs_layout_segment *lseg)
{ {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment