orangefs: Do not unref if there is no bufmap.
authorMartin Brandenburg <martin@omnibond.com>
Tue, 15 Dec 2015 19:54:27 +0000 (14:54 -0500)
committerMike Marshall <hubcap@omnibond.com>
Thu, 17 Dec 2015 19:35:45 +0000 (14:35 -0500)
Signed-off-by: Mike Marshall <hubcap@omnibond.com>
Signed-off-by: Martin Brandenburg <martin@omnibond.com>
fs/orangefs/orangefs-bufmap.c

index cf3ffb57334bead562cc378e269a596f7d23b7b7..888aa28136ee094fa0823c422e44b447e97686e8 100644 (file)
@@ -82,21 +82,32 @@ static void orangefs_bufmap_unref(struct orangefs_bufmap *bufmap)
        }
 }
 
+/*
+ * XXX: Can the size and shift change while the caller gives up the 
+ * XXX: lock between calling this and doing something useful?
+ */
+
 int orangefs_bufmap_size_query(void)
 {
-       struct orangefs_bufmap *bufmap = orangefs_bufmap_ref();
-       int size = bufmap ? bufmap->desc_size : 0;
-
-       orangefs_bufmap_unref(bufmap);
+       struct orangefs_bufmap *bufmap;
+       int size = 0;
+       bufmap = orangefs_bufmap_ref();
+       if (bufmap) {
+               size = bufmap->desc_size;
+               orangefs_bufmap_unref(bufmap);
+       }
        return size;
 }
 
 int orangefs_bufmap_shift_query(void)
 {
-       struct orangefs_bufmap *bufmap = orangefs_bufmap_ref();
-       int shift = bufmap ? bufmap->desc_shift : 0;
-
-       orangefs_bufmap_unref(bufmap);
+       struct orangefs_bufmap *bufmap;
+       int shift = 0;
+       bufmap = orangefs_bufmap_ref();
+       if (bufmap) {
+               shift = bufmap->desc_shift;
+               orangefs_bufmap_unref(bufmap);
+       }
        return shift;
 }