]> pilppa.org Git - linux-2.6-omap-h63xx.git/blobdiff - fs/ocfs2/slot_map.c
Driver core: accept all valid action-strings in uevent-trigger
[linux-2.6-omap-h63xx.git] / fs / ocfs2 / slot_map.c
index d921a28329dcb81e21525b51e0da41a2aceeec9e..af4882b62cfae7c914fb4c22aad90761d039dc96 100644 (file)
@@ -26,7 +26,6 @@
 #include <linux/types.h>
 #include <linux/slab.h>
 #include <linux/highmem.h>
-#include <linux/smp_lock.h>
 
 #define MLOG_MASK_PREFIX ML_SUPER
 #include <cluster/masklog.h>
@@ -122,17 +121,25 @@ static s16 __ocfs2_node_num_to_slot(struct ocfs2_slot_info *si,
        return ret;
 }
 
-static s16 __ocfs2_find_empty_slot(struct ocfs2_slot_info *si)
+static s16 __ocfs2_find_empty_slot(struct ocfs2_slot_info *si, s16 preferred)
 {
        int i;
        s16 ret = OCFS2_INVALID_SLOT;
 
+       if (preferred >= 0 && preferred < si->si_num_slots) {
+               if (OCFS2_INVALID_SLOT == si->si_global_node_nums[preferred]) {
+                       ret = preferred;
+                       goto out;
+               }
+       }
+
        for(i = 0; i < si->si_num_slots; i++) {
                if (OCFS2_INVALID_SLOT == si->si_global_node_nums[i]) {
                        ret = (s16) i;
                        break;
                }
        }
+out:
        return ret;
 }
 
@@ -249,7 +256,7 @@ int ocfs2_find_slot(struct ocfs2_super *osb)
        if (slot == OCFS2_INVALID_SLOT) {
                /* if no slot yet, then just take 1st available
                 * one. */
-               slot = __ocfs2_find_empty_slot(si);
+               slot = __ocfs2_find_empty_slot(si, osb->preferred_slot);
                if (slot == OCFS2_INVALID_SLOT) {
                        spin_unlock(&si->si_lock);
                        mlog(ML_ERROR, "no free slots available!\n");