Skip to contentSkip to conversation

Btrfs: cleanup redundant code in __btrfs_close_devices()

PATCH In review Azat Khuzhin 2 participants 4 messages Sep 7, 2013 – Sep 10, 2013 1 message not in the archive Btrfs file system

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Btrfs: cleanup redundant code in __btrfs_close_devices()

---
 fs/btrfs/volumes.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
fs/btrfs/volumes.c +1 -1
index 1d1b595..124228e 100644
@@ -644,7 +644,7 @@ static int __btrfs_close_devices(struct btrfs_fs_devices *fs_devices)
 		/* Safe because we are under uuid_mutex */
 		if (device->name) {
 			name = rcu_string_strdup(device->name->str, GFP_NOFS);
-			BUG_ON(device->name && !name); /* -ENOMEM */
+			BUG_ON(!name); /* -ENOMEM */
 			rcu_assign_pointer(new_device->name, name);
 		}
 		new_device->bdev = NULL;
Signature · 1 line
1.7.10.4

A message that is not in the archive (sent off-list or not yet received): [email protected]

#2 lore raw
Quoted 7 lines · Wang Shilong
Quoted 6 lines · Azat Khuzhin
---
  fs/btrfs/volumes.c |    2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
Quoted 15 lines

fs/btrfs/volumes.c static int __btrfs_close_devices(struct · line 649

Quoted 12 lines
fs/btrfs/volumes.c +1 -1
index 1d1b595..124228e 100644
@@ -644,7 +644,7 @@ static int __btrfs_close_devices(struct
 btrfs_fs_devices *fs_devices)
                /* Safe because we are under uuid_mutex */
                if (device->name) {
                        name = rcu_string_strdup(device->name->str,
 GFP_NOFS);
-                       BUG_ON(device->name && !name); /* -ENOMEM */
+                       BUG_ON(!name); /* -ENOMEM *

Nice catch! out of memory should not trigger BUG_ON().. Maybe we can handle it gracefully.

Maybe return -ENOMEM ?

Quoted 9 lines

Thanks,
Wang

Quoted 3 lines
fs/btrfs/volumes.c +0 -0
                        rcu_assign_pointer(new_device->name, name);
                }
                new_device->bdev = NULL;
Signature · 2 lines
Respectfully
Azat Khuzhin
#3 lore raw
Quoted 24 lines · Wang Shilong
Quoted 7 lines · Azat Khuzhin
Quoted 6 lines
---
 fs/btrfs/volumes.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
Quoted 15 lines

fs/btrfs/volumes.c static int __btrfs_close_devices(struct · line 649

Quoted 12 lines
fs/btrfs/volumes.c +1 -1
index 1d1b595..124228e 100644
@@ -644,7 +644,7 @@ static int __btrfs_close_devices(struct
 btrfs_fs_devices *fs_devices)
               /* Safe because we are under uuid_mutex */
               if (device->name) {
                       name = rcu_string_strdup(device->name->str,
 GFP_NOFS);
-                       BUG_ON(device->name && !name); /* -ENOMEM */
+                       BUG_ON(!name); /* -ENOMEM *

Nice catch! out of memory should not trigger BUG_ON().. Maybe we can handle it gracefully.

Quoted 1 line

Maybe return -ENOMEM ?

Yeah, BUG_On is really unfriendly. And here ENOMEM triggers BUG_ON() is a lazy approach.

I think we can return -ENOMEM rather than BUG_ON(), the caller can handle this.

Thanks,
Wang

Quoted 20 lines
Quoted 10 lines

Thanks,
Wang

Quoted 3 lines
fs/btrfs/volumes.c +0 -0
                       rcu_assign_pointer(new_device->name, name);
               }
               new_device->bdev = NULL;
Signature · 6 lines
Respectfully
Azat Khuzhin
--
To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
#4 lore raw
Quoted 24 lines · Wang Shilong
Quoted 24 lines · Wang Shilong
Quoted 22 lines · Azat Khuzhin
Quoted 11 lines
---
 fs/btrfs/volumes.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
fs/btrfs/volumes.c +0 -0
index 1d1b595..124228e 100644

fs/btrfs/volumes.c static int __btrfs_close_devices(struct · line 649

Quoted 7 lines
fs/btrfs/volumes.c +1 -1
@@ -644,7 +644,7 @@ static int __btrfs_close_devices(struct
 btrfs_fs_devices *fs_devices)
               /* Safe because we are under uuid_mutex */
               if (device->name) {
                       name = rcu_string_strdup(device->name->str,
 GFP_NOFS);
-                       BUG_ON(device->name && !name); /* -ENOMEM */
+                       BUG_ON(!name); /* -ENOMEM *

Nice catch! out of memory should not trigger BUG_ON().. Maybe we can handle it gracefully.

Quoted 6 lines
Quoted 1 line

Maybe return -ENOMEM ?

Yeah, BUG_On is really unfriendly. And here ENOMEM triggers BUG_ON() is a lazy approach.

I think we can return -ENOMEM rather than BUG_ON(), the caller can handle this.

I will write a patch, when this one will be merged, to avoid conflicts, and also because the issue that this patch solves is different from BUG_ON().

Quoted 24 lines

Thanks,
Wang

Quoted 20 lines
Quoted 10 lines

Thanks,
Wang

Quoted 3 lines
fs/btrfs/volumes.c +0 -0
                       rcu_assign_pointer(new_device->name, name);
               }
               new_device->bdev = NULL;

--
Respectfully
Azat Khuzhin
--
To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

Signature · 2 lines
Respectfully
Azat Khuzhin