Whamcloud - gitweb
LU-12542 handle: move refcount into the lustre_handle.
[fs/lustre-release.git] / lustre / llite / range_lock.c
index 27fbbef..7a4c9c4 100644 (file)
  * Author: Prakash Surya <surya1@llnl.gov>
  * Author: Bobi Jam <bobijam.xu@intel.com>
  */
+#ifdef HAVE_SCHED_HEADERS
+#include <linux/sched/signal.h>
+#endif
 #include "range_lock.h"
-#include <lustre/lustre_user.h>
+#include <uapi/linux/lustre/lustre_user.h>
 
 /**
  * Initialize a range lock tree
@@ -61,17 +64,23 @@ void range_lock_tree_init(struct range_lock_tree *tree)
  * Pre:  Caller should have allocated the range lock node.
  * Post: The range lock node is meant to cover [start, end] region
  */
-void range_lock_init(struct range_lock *lock, __u64 start, __u64 end)
+int range_lock_init(struct range_lock *lock, __u64 start, __u64 end)
 {
+       int rc;
+
        interval_init(&lock->rl_node);
        if (end != LUSTRE_EOF)
                end >>= PAGE_SHIFT;
-       interval_set(&lock->rl_node, start >> PAGE_SHIFT, end);
+       rc = interval_set(&lock->rl_node, start >> PAGE_SHIFT, end);
+       if (rc)
+               return rc;
+
        INIT_LIST_HEAD(&lock->rl_next_lock);
        lock->rl_task = NULL;
        lock->rl_lock_count = 0;
        lock->rl_blocking_ranges = 0;
        lock->rl_sequence = 0;
+       return rc;
 }
 
 static inline struct range_lock *next_lock(struct range_lock *lock)
@@ -228,7 +237,7 @@ int range_lock(struct range_lock_tree *tree, struct range_lock *lock)
 
                if (signal_pending(current)) {
                        range_unlock(tree, lock);
-                       GOTO(out, rc = -EINTR);
+                       GOTO(out, rc = -ERESTARTSYS);
                }
                spin_lock(&tree->rlt_lock);
        }