diff options
author | Martin Brandenburg <martin@omnibond.com> | 2015-12-15 22:54:27 +0300 |
---|---|---|
committer | Mike Marshall <hubcap@omnibond.com> | 2015-12-17 22:35:45 +0300 |
commit | b09d10df5a39b17ec12ecc0dc230a4d71c8a9996 (patch) | |
tree | 6002d58c327f35e654309ec8ddc58b77b074197c /fs/orangefs/orangefs-bufmap.c | |
parent | 765a75b34a9d72aca875d85d4dc40945afd2939e (diff) | |
download | linux-b09d10df5a39b17ec12ecc0dc230a4d71c8a9996.tar.xz |
orangefs: Do not unref if there is no bufmap.
Signed-off-by: Mike Marshall <hubcap@omnibond.com>
Signed-off-by: Martin Brandenburg <martin@omnibond.com>
Diffstat (limited to 'fs/orangefs/orangefs-bufmap.c')
-rw-r--r-- | fs/orangefs/orangefs-bufmap.c | 27 |
1 files changed, 19 insertions, 8 deletions
diff --git a/fs/orangefs/orangefs-bufmap.c b/fs/orangefs/orangefs-bufmap.c index cf3ffb57334b..888aa28136ee 100644 --- a/fs/orangefs/orangefs-bufmap.c +++ b/fs/orangefs/orangefs-bufmap.c @@ -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; } |