]> git.karo-electronics.de Git - karo-tx-linux.git/blobdiff - fs/nfs/pnfs_dev.c
Merge tag 'disintegrate-raid-20121009' of git://git.infradead.org/users/dhowells...
[karo-tx-linux.git] / fs / nfs / pnfs_dev.c
index 73f701f1f4d3325e2c54efb68e14b1df40eb90e1..d35b62e83ea638e9736587bfaec61c612221f579 100644 (file)
@@ -40,6 +40,8 @@
 #define NFS4_DEVICE_ID_HASH_SIZE       (1 << NFS4_DEVICE_ID_HASH_BITS)
 #define NFS4_DEVICE_ID_HASH_MASK       (NFS4_DEVICE_ID_HASH_SIZE - 1)
 
+#define PNFS_DEVICE_RETRY_TIMEOUT (120*HZ)
+
 static struct hlist_head nfs4_deviceid_cache[NFS4_DEVICE_ID_HASH_SIZE];
 static DEFINE_SPINLOCK(nfs4_deviceid_lock);
 
@@ -218,6 +220,30 @@ nfs4_put_deviceid_node(struct nfs4_deviceid_node *d)
 }
 EXPORT_SYMBOL_GPL(nfs4_put_deviceid_node);
 
+void
+nfs4_mark_deviceid_unavailable(struct nfs4_deviceid_node *node)
+{
+       node->timestamp_unavailable = jiffies;
+       set_bit(NFS_DEVICEID_UNAVAILABLE, &node->flags);
+}
+EXPORT_SYMBOL_GPL(nfs4_mark_deviceid_unavailable);
+
+bool
+nfs4_test_deviceid_unavailable(struct nfs4_deviceid_node *node)
+{
+       if (test_bit(NFS_DEVICEID_UNAVAILABLE, &node->flags)) {
+               unsigned long start, end;
+
+               end = jiffies;
+               start = end - PNFS_DEVICE_RETRY_TIMEOUT;
+               if (time_in_range(node->timestamp_unavailable, start, end))
+                       return true;
+               clear_bit(NFS_DEVICEID_UNAVAILABLE, &node->flags);
+       }
+       return false;
+}
+EXPORT_SYMBOL_GPL(nfs4_test_deviceid_unavailable);
+
 static void
 _deviceid_purge_client(const struct nfs_client *clp, long hash)
 {
@@ -276,3 +302,4 @@ nfs4_deviceid_mark_client_invalid(struct nfs_client *clp)
        }
        rcu_read_unlock();
 }
+