diff mbox

[ndctl,4/8] ndctl, create-namespace: report failures due to namespace being mounted

Message ID 146135444310.4228.7151000859132505494.stgit@dwillia2-desk3.amr.corp.intel.com (mailing list archive)
State New, archived
Headers show

Commit Message

Dan Williams April 22, 2016, 7:47 p.m. UTC
In the case when a filesystem is mounted on a namespace targeted for
reconfiguration or destruction, emit a message so the user knows to
unmount the filesystem.

Signed-off-by: Dan Williams <dan.j.williams@intel.com>
---
 builtin-xaction-namespace.c |    2 ++
 1 file changed, 2 insertions(+)

Comments

Linda Knippers April 22, 2016, 11 p.m. UTC | #1
On 4/22/2016 3:47 PM, Dan Williams wrote:
> In the case when a filesystem is mounted on a namespace targeted for
> reconfiguration or destruction, emit a message so the user knows to
> unmount the filesystem.
> 
> Signed-off-by: Dan Williams <dan.j.williams@intel.com>
> ---
>  builtin-xaction-namespace.c |    2 ++
>  1 file changed, 2 insertions(+)
> 
> diff --git a/builtin-xaction-namespace.c b/builtin-xaction-namespace.c
> index 53ff82bc2c8d..e2e6d518c64d 100644
> --- a/builtin-xaction-namespace.c
> +++ b/builtin-xaction-namespace.c
> @@ -550,6 +550,8 @@ static int namespace_destroy(struct ndctl_region *region,
>  			 * stopping the !bdev case from racing to mount an fs or
>  			 * re-enabling the namepace.
>  			 */
> +			error("%s: %s is mounted, failing operation\n",
> +					devname, bdev);

I'm seeing this error message in cases where the device is not mounted,
such as when I forget to run ndctl as root/sudo.  That's a more
likely reason that the open() may fail.  Perhaps you could check the
errno from the open() failure and display an error based on that?
You might simply do a perror().

-- ljk

>  			return -EBUSY;
>  		}
>  	}
> 
> _______________________________________________
> Linux-nvdimm mailing list
> Linux-nvdimm@lists.01.org
> https://lists.01.org/mailman/listinfo/linux-nvdimm
>
Dan Williams April 22, 2016, 11:10 p.m. UTC | #2
On Fri, Apr 22, 2016 at 4:00 PM, Linda Knippers <linda.knippers@hpe.com> wrote:
> On 4/22/2016 3:47 PM, Dan Williams wrote:
>> In the case when a filesystem is mounted on a namespace targeted for
>> reconfiguration or destruction, emit a message so the user knows to
>> unmount the filesystem.
>>
>> Signed-off-by: Dan Williams <dan.j.williams@intel.com>
>> ---
>>  builtin-xaction-namespace.c |    2 ++
>>  1 file changed, 2 insertions(+)
>>
>> diff --git a/builtin-xaction-namespace.c b/builtin-xaction-namespace.c
>> index 53ff82bc2c8d..e2e6d518c64d 100644
>> --- a/builtin-xaction-namespace.c
>> +++ b/builtin-xaction-namespace.c
>> @@ -550,6 +550,8 @@ static int namespace_destroy(struct ndctl_region *region,
>>                        * stopping the !bdev case from racing to mount an fs or
>>                        * re-enabling the namepace.
>>                        */
>> +                     error("%s: %s is mounted, failing operation\n",
>> +                                     devname, bdev);
>
> I'm seeing this error message in cases where the device is not mounted,
> such as when I forget to run ndctl as root/sudo.  That's a more
> likely reason that the open() may fail.  Perhaps you could check the
> errno from the open() failure and display an error based on that?
> You might simply do a perror().
>

Ah, thanks Linda!  Yes, checking for EACESS vs EBUSY should do the trick here.
diff mbox

Patch

diff --git a/builtin-xaction-namespace.c b/builtin-xaction-namespace.c
index 53ff82bc2c8d..e2e6d518c64d 100644
--- a/builtin-xaction-namespace.c
+++ b/builtin-xaction-namespace.c
@@ -550,6 +550,8 @@  static int namespace_destroy(struct ndctl_region *region,
 			 * stopping the !bdev case from racing to mount an fs or
 			 * re-enabling the namepace.
 			 */
+			error("%s: %s is mounted, failing operation\n",
+					devname, bdev);
 			return -EBUSY;
 		}
 	}