* [PATCH] Btrfs: cleanup redundant code in __btrfs_close_devices()
@ 2013-09-07 16:15 Azat Khuzhin
[not found] ` <522D4061.3060404@cn.fujitsu.com>
0 siblings, 1 reply; 4+ messages in thread
From: Azat Khuzhin @ 2013-09-07 16:15 UTC (permalink / raw)
To: linux-kernel; +Cc: Azat Khuzhin, Chris Mason, open list:BTRFS FILE SYSTEM
Signed-off-by: Azat Khuzhin <a3at.mail@gmail.com>
---
fs/btrfs/volumes.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/fs/btrfs/volumes.c b/fs/btrfs/volumes.c
index 1d1b595..124228e 100644
--- a/fs/btrfs/volumes.c
+++ b/fs/btrfs/volumes.c
@@ -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;
--
1.7.10.4
^ permalink raw reply related [flat|nested] 4+ messages in thread[parent not found: <522D4061.3060404@cn.fujitsu.com>]
* Re: [PATCH] Btrfs: cleanup redundant code in __btrfs_close_devices() [not found] ` <522D4061.3060404@cn.fujitsu.com> @ 2013-09-10 11:39 ` Azat Khuzhin 2013-09-10 13:15 ` Wang Shilong 0 siblings, 1 reply; 4+ messages in thread From: Azat Khuzhin @ 2013-09-10 11:39 UTC (permalink / raw) To: Wang Shilong; +Cc: open list, Chris Mason, open list:BTRFS FILE SYSTEM On Mon, Sep 9, 2013 at 7:28 AM, Wang Shilong <wangsl.fnst@cn.fujitsu.com> wrote: > On 09/08/2013 12:15 AM, Azat Khuzhin wrote: >> >> Signed-off-by: Azat Khuzhin <a3at.mail@gmail.com> >> --- >> fs/btrfs/volumes.c | 2 +- >> 1 file changed, 1 insertion(+), 1 deletion(-) >> >> diff --git a/fs/btrfs/volumes.c b/fs/btrfs/volumes.c >> index 1d1b595..124228e 100644 >> --- a/fs/btrfs/volumes.c >> +++ b/fs/btrfs/volumes.c >> @@ -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 ? > > Thanks, > Wang > >> rcu_assign_pointer(new_device->name, name); >> } >> new_device->bdev = NULL; > > -- Respectfully Azat Khuzhin ^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] Btrfs: cleanup redundant code in __btrfs_close_devices() 2013-09-10 11:39 ` Azat Khuzhin @ 2013-09-10 13:15 ` Wang Shilong 2013-09-10 20:40 ` Azat Khuzhin 0 siblings, 1 reply; 4+ messages in thread From: Wang Shilong @ 2013-09-10 13:15 UTC (permalink / raw) To: Azat Khuzhin Cc: Wang Shilong, open list, Chris Mason, open list:BTRFS FILE SYSTEM > On Mon, Sep 9, 2013 at 7:28 AM, Wang Shilong <wangsl.fnst@cn.fujitsu.com> wrote: >> On 09/08/2013 12:15 AM, Azat Khuzhin wrote: >>> >>> Signed-off-by: Azat Khuzhin <a3at.mail@gmail.com> >>> --- >>> fs/btrfs/volumes.c | 2 +- >>> 1 file changed, 1 insertion(+), 1 deletion(-) >>> >>> diff --git a/fs/btrfs/volumes.c b/fs/btrfs/volumes.c >>> index 1d1b595..124228e 100644 >>> --- a/fs/btrfs/volumes.c >>> +++ b/fs/btrfs/volumes.c >>> @@ -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 ? 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 > >> >> Thanks, >> Wang >> >>> 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 majordomo@vger.kernel.org > More majordomo info at http://vger.kernel.org/majordomo-info.html ^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] Btrfs: cleanup redundant code in __btrfs_close_devices() 2013-09-10 13:15 ` Wang Shilong @ 2013-09-10 20:40 ` Azat Khuzhin 0 siblings, 0 replies; 4+ messages in thread From: Azat Khuzhin @ 2013-09-10 20:40 UTC (permalink / raw) To: Wang Shilong Cc: Wang Shilong, open list, Chris Mason, open list:BTRFS FILE SYSTEM On Tue, Sep 10, 2013 at 5:15 PM, Wang Shilong <wangshilong1991@gmail.com> wrote: >> On Mon, Sep 9, 2013 at 7:28 AM, Wang Shilong <wangsl.fnst@cn.fujitsu.com> wrote: >>> On 09/08/2013 12:15 AM, Azat Khuzhin wrote: >>>> >>>> Signed-off-by: Azat Khuzhin <a3at.mail@gmail.com> >>>> --- >>>> fs/btrfs/volumes.c | 2 +- >>>> 1 file changed, 1 insertion(+), 1 deletion(-) >>>> >>>> diff --git a/fs/btrfs/volumes.c b/fs/btrfs/volumes.c >>>> index 1d1b595..124228e 100644 >>>> --- a/fs/btrfs/volumes.c >>>> +++ b/fs/btrfs/volumes.c >>>> @@ -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 ? > > 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(). > > Thanks, > Wang >> >>> >>> Thanks, >>> Wang >>> >>>> 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 majordomo@vger.kernel.org >> More majordomo info at http://vger.kernel.org/majordomo-info.html > -- Respectfully Azat Khuzhin ^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2013-09-10 20:40 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-09-07 16:15 [PATCH] Btrfs: cleanup redundant code in __btrfs_close_devices() Azat Khuzhin
[not found] ` <522D4061.3060404@cn.fujitsu.com>
2013-09-10 11:39 ` Azat Khuzhin
2013-09-10 13:15 ` Wang Shilong
2013-09-10 20:40 ` Azat Khuzhin
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for NNTP newsgroup(s).