@@ -276,7 +276,7 @@ init_lseg(struct pnfs_layout_hdr *lo, struct pnfs_layout_segment *lseg)
INIT_LIST_HEAD(&lseg->fi_list);
atomic_set(&lseg->pls_refcount, 1);
smp_mb();
- lseg->valid = true;
+ set_bit(NFS_LSEG_VALID, &lseg->pls_flags);
lseg->layout = lo;
lseg->pls_notify_count = 0;
}
@@ -286,7 +286,7 @@ _put_lseg_common(struct pnfs_layout_segment *lseg)
{
struct inode *ino = lseg->layout->inode;
- BUG_ON(lseg->valid == true);
+ BUG_ON(test_bit(NFS_LSEG_VALID, &lseg->pls_flags));
list_del(&lseg->fi_list);
if (list_empty(&lseg->layout->segs)) {
struct nfs_client *clp;
@@ -309,7 +309,8 @@ put_lseg_locked(struct pnfs_layout_segment *lseg,
struct list_head *tmp_list)
{
dprintk("%s: lseg %p ref %d valid %d\n", __func__, lseg,
- atomic_read(&lseg->pls_refcount), lseg->valid);
+ atomic_read(&lseg->pls_refcount),
+ test_bit(NFS_LSEG_VALID, &lseg->pls_flags));
if (atomic_dec_and_test(&lseg->pls_refcount)) {
_put_lseg_common(lseg);
list_add(&lseg->fi_list, tmp_list);
@@ -325,7 +326,8 @@ put_lseg(struct pnfs_layout_segment *lseg)
return;
dprintk("%s: lseg %p ref %d valid %d\n", __func__, lseg,
- atomic_read(&lseg->pls_refcount), lseg->valid);
+ atomic_read(&lseg->pls_refcount),
+ test_bit(NFS_LSEG_VALID, &lseg->pls_flags));
ino = lseg->layout->inode;
if (atomic_dec_and_lock(&lseg->pls_refcount, &ino->i_lock)) {
int count = lseg->pls_notify_count;
@@ -363,8 +365,7 @@ static void mark_lseg_invalid(struct pnfs_layout_segment *lseg,
struct list_head *tmp_list)
{
assert_spin_locked(&lseg->layout->inode->i_lock);
- if (lseg->valid) {
- lseg->valid = false;
+ if (test_and_clear_bit(NFS_LSEG_VALID, &lseg->pls_flags)) {
/* Remove the reference keeping the lseg in the
* list. It will now be removed when all
* outstanding io is finished.
@@ -809,7 +810,8 @@ pnfs_find_lseg(struct pnfs_layout_hdr *lo,
assert_spin_locked(&lo->inode->i_lock);
list_for_each_entry(lseg, &lo->segs, fi_list) {
- if (lseg->valid && is_matching_lseg(lseg, range)) {
+ if (test_bit(NFS_LSEG_VALID, &lseg->pls_flags) &&
+ is_matching_lseg(lseg, range)) {
get_lseg(lseg);
ret = lseg;
break;
@@ -820,7 +822,7 @@ pnfs_find_lseg(struct pnfs_layout_hdr *lo,
dprintk("%s:Return lseg %p ref %d valid %d\n",
__func__, ret, ret ? atomic_read(&ret->pls_refcount) : 0,
- ret ? ret->valid : 0);
+ ret ? test_bit(NFS_LSEG_VALID, &ret->pls_flags) : 0);
return ret;
}
@@ -33,11 +33,15 @@
#include <linux/nfs_page.h>
#include "callback.h" /* for cb_layoutrecallargs */
+enum {
+ NFS_LSEG_VALID = 0, /* cleared when lseg is recalled/returned */
+};
+
struct pnfs_layout_segment {
struct list_head fi_list;
struct pnfs_layout_range range;
atomic_t pls_refcount;
- bool valid;
+ unsigned long pls_flags;
struct pnfs_layout_hdr *layout;
int pls_notify_count;
};