]> 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 d8b79067dc14778a5d67556c20c62fec9a5e4de7..af4882b62cfae7c914fb4c22aad90761d039dc96 100644 (file)
@@ -121,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;
 }
 
@@ -248,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");