Merge branch 'drm-next-4.6' of git://people.freedesktop.org/~agd5f/linux into drm...
[deliverable/linux.git] / fs / orangefs / devorangefs-req.c
index 0f9a12ac74588b06b71c8fc5cc54b9be76130ec1..db170beba7974c3d5d4491df452f0d75ca15ea13 100644 (file)
@@ -74,6 +74,44 @@ static struct orangefs_kernel_op_s *orangefs_devreq_remove_op(__u64 tag)
        return NULL;
 }
 
+/* Returns whether any FS are still pending remounted */
+static int mark_all_pending_mounts(void)
+{
+       int unmounted = 1;
+       struct orangefs_sb_info_s *orangefs_sb = NULL;
+
+       spin_lock(&orangefs_superblocks_lock);
+       list_for_each_entry(orangefs_sb, &orangefs_superblocks, list) {
+               /* All of these file system require a remount */
+               orangefs_sb->mount_pending = 1;
+               unmounted = 0;
+       }
+       spin_unlock(&orangefs_superblocks_lock);
+       return unmounted;
+}
+
+/*
+ * Determine if a given file system needs to be remounted or not
+ *  Returns -1 on error
+ *           0 if already mounted
+ *           1 if needs remount
+ */
+static int fs_mount_pending(__s32 fsid)
+{
+       int mount_pending = -1;
+       struct orangefs_sb_info_s *orangefs_sb = NULL;
+
+       spin_lock(&orangefs_superblocks_lock);
+       list_for_each_entry(orangefs_sb, &orangefs_superblocks, list) {
+               if (orangefs_sb->fs_id == fsid) {
+                       mount_pending = orangefs_sb->mount_pending;
+                       break;
+               }
+       }
+       spin_unlock(&orangefs_superblocks_lock);
+       return mount_pending;
+}
+
 static int orangefs_devreq_open(struct inode *inode, struct file *file)
 {
        int ret = -EINVAL;
@@ -449,44 +487,6 @@ Enomem:
        goto wakeup;
 }
 
-/* Returns whether any FS are still pending remounted */
-static int mark_all_pending_mounts(void)
-{
-       int unmounted = 1;
-       struct orangefs_sb_info_s *orangefs_sb = NULL;
-
-       spin_lock(&orangefs_superblocks_lock);
-       list_for_each_entry(orangefs_sb, &orangefs_superblocks, list) {
-               /* All of these file system require a remount */
-               orangefs_sb->mount_pending = 1;
-               unmounted = 0;
-       }
-       spin_unlock(&orangefs_superblocks_lock);
-       return unmounted;
-}
-
-/*
- * Determine if a given file system needs to be remounted or not
- *  Returns -1 on error
- *           0 if already mounted
- *           1 if needs remount
- */
-int fs_mount_pending(__s32 fsid)
-{
-       int mount_pending = -1;
-       struct orangefs_sb_info_s *orangefs_sb = NULL;
-
-       spin_lock(&orangefs_superblocks_lock);
-       list_for_each_entry(orangefs_sb, &orangefs_superblocks, list) {
-               if (orangefs_sb->fs_id == fsid) {
-                       mount_pending = orangefs_sb->mount_pending;
-                       break;
-               }
-       }
-       spin_unlock(&orangefs_superblocks_lock);
-       return mount_pending;
-}
-
 /*
  * NOTE: gets called when the last reference to this device is dropped.
  * Using the open_access_count variable, we enforce a reference count
@@ -572,8 +572,7 @@ static long dispatch_ioctl_command(unsigned int command, unsigned long arg)
        struct dev_mask_info_s mask_info = { 0 };
        struct dev_mask2_info_s mask2_info = { 0, 0 };
        int upstream_kmod = 1;
-       struct list_head *tmp = NULL;
-       struct orangefs_sb_info_s *orangefs_sb = NULL;
+       struct orangefs_sb_info_s *orangefs_sb;
 
        /* mtmoore: add locking here */
 
@@ -619,26 +618,32 @@ static long dispatch_ioctl_command(unsigned int command, unsigned long arg)
                gossip_debug(GOSSIP_DEV_DEBUG,
                             "%s: priority remount in progress\n",
                             __func__);
-               list_for_each(tmp, &orangefs_superblocks) {
-                       orangefs_sb =
-                               list_entry(tmp,
-                                          struct orangefs_sb_info_s,
-                                          list);
-                       if (orangefs_sb && (orangefs_sb->sb)) {
+               spin_lock(&orangefs_superblocks_lock);
+               list_for_each_entry(orangefs_sb, &orangefs_superblocks, list) {
+                       /*
+                        * We have to drop the spinlock, so entries can be
+                        * removed.  They can't be freed, though, so we just
+                        * keep the forward pointers and zero the back ones -
+                        * that way we can get to the rest of the list.
+                        */
+                       if (!orangefs_sb->list.prev)
+                               continue;
+                       gossip_debug(GOSSIP_DEV_DEBUG,
+                                    "%s: Remounting SB %p\n",
+                                    __func__,
+                                    orangefs_sb);
+
+                       spin_unlock(&orangefs_superblocks_lock);
+                       ret = orangefs_remount(orangefs_sb);
+                       spin_lock(&orangefs_superblocks_lock);
+                       if (ret) {
                                gossip_debug(GOSSIP_DEV_DEBUG,
-                                            "%s: Remounting SB %p\n",
-                                            __func__,
+                                            "SB %p remount failed\n",
                                             orangefs_sb);
-
-                               ret = orangefs_remount(orangefs_sb->sb);
-                               if (ret) {
-                                       gossip_debug(GOSSIP_DEV_DEBUG,
-                                                    "SB %p remount failed\n",
-                                                    orangefs_sb);
-                                       break;
-                               }
+                               break;
                        }
                }
+               spin_unlock(&orangefs_superblocks_lock);
                gossip_debug(GOSSIP_DEV_DEBUG,
                             "%s: priority remount complete\n",
                             __func__);
@@ -678,6 +683,19 @@ static long dispatch_ioctl_command(unsigned int command, unsigned long arg)
                ret = copy_from_user(&client_debug_array_string,
                                     (void __user *)arg,
                                     ORANGEFS_MAX_DEBUG_STRING_LEN);
+               /*
+                * The real client-core makes an effort to ensure
+                * that actual strings that aren't too long to fit in
+                * this buffer is what we get here. We're going to use
+                * string functions on the stuff we got, so we'll make
+                * this extra effort to try and keep from
+                * flowing out of this buffer when we use the string
+                * functions, even if somehow the stuff we end up
+                * with here is garbage.
+                */
+               client_debug_array_string[ORANGEFS_MAX_DEBUG_STRING_LEN - 1] =
+                       '\0';
+               
                if (ret != 0) {
                        pr_info("%s: CLIENT_STRING: copy_from_user failed\n",
                                __func__);
This page took 0.025659 seconds and 5 git commands to generate.