From: Dan McGee <dan-fd97jBR+K/6hPH1hqNUYSQ@public.gmane.org>
To: Ryusuke Konishi
<konishi.ryusuke-Zyj7fXuS5i5L9jVzuh4AOg@public.gmane.org>
Cc: linux-nilfs-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
Subject: Re: [PATCH 7/7] rmcp: print sensible error message on permission failure
Date: Fri, 23 Dec 2011 10:00:54 -0500 [thread overview]
Message-ID: <CAEik5nNHs1Lp-Wz_p9k_Xt1-CBu4L=Agsf28vVC7iBp4mSsuwA@mail.gmail.com> (raw)
In-Reply-To: <20111223.145629.123971064.ryusuke-sG5X7nlA6pw@public.gmane.org>
On Fri, Dec 23, 2011 at 12:56 AM, Ryusuke Konishi
<konishi.ryusuke-Zyj7fXuS5i5L9jVzuh4AOg@public.gmane.org> wrote:
> On Wed, 21 Dec 2011 15:34:09 -0600, Dan McGee wrote:
>> When running as non-root, the error message seems to indicate a
>> checkpoint is a snapshot, rather than the actual problem, which is that
>> I do not have permission to delete the checkpoints.
>>
>> Before:
>> $ rmcp 29..35
>> rmcp: 29: cannot remove snapshot
>> rmcp: 30: cannot remove snapshot
>> rmcp: 31: cannot remove snapshot
>> rmcp: 32: cannot remove snapshot
>> rmcp: 33: cannot remove snapshot
>> rmcp: 34: cannot remove snapshot
>> rmcp: 35: cannot remove snapshot
>>
>> To delete snapshot(s), change them into checkpoints with
>> chcp command before removal.
>>
>> After:
>> $ ./bin/rmcp 29..35
>> lt-rmcp: 29: cannot remove checkpoint: Operation not permitted
>> lt-rmcp: 30: cannot remove checkpoint: Operation not permitted
>> lt-rmcp: 31: cannot remove checkpoint: Operation not permitted
>> lt-rmcp: 32: cannot remove checkpoint: Operation not permitted
>> lt-rmcp: 33: cannot remove checkpoint: Operation not permitted
>> lt-rmcp: 34: cannot remove checkpoint: Operation not permitted
>> lt-rmcp: 35: cannot remove checkpoint: Operation not permitted
>>
>> Since May 2009 the kernel has returned EBUSY instead of EPERM for
>> removal requests against snapshots, commit 30c25be71fcbd87fd. We should
>> be able to treat EPERM as expected now, as the commit message there
>> indicates.
>>
>> Signed-off-by: Dan McGee <dan-fd97jBR+K/6hPH1hqNUYSQ@public.gmane.org>
>> ---
>>
>> This does introduce a behavior change as well- we no longer exit the range loop
>> immediately on an error code, instead we continue the loop and attempt to
>> delete the rest of the checkpoints in the range. Objections to this? I'm not an
>> expert by any means.
>>
>> bin/rmcp.c | 10 ++++++----
>> 1 files changed, 6 insertions(+), 4 deletions(-)
>>
>> diff --git a/bin/rmcp.c b/bin/rmcp.c
>> index 780a192..3c5c184 100644
>> --- a/bin/rmcp.c
>> +++ b/bin/rmcp.c
>> @@ -105,7 +105,7 @@ static int rmcp_remove_range(struct nilfs *nilfs,
>> nd++;
>> continue;
>> }
>> - if (errno == EBUSY || errno == EPERM) {
>> + if (errno == EBUSY) {
>
> OK, let's stop regarding the EPERM error as EBUSY. For most kernels,
> it's more important to distinguish real permission errors from the
> snapshot removal error.
>
> We have only recently bumped the version of nilfs-utils to 2.1.x from
> 2.0.x. It's a good opportunity for this change.
>
>> nss++;
>> if (!force) {
>> fprintf(stderr,
>> @@ -115,14 +115,16 @@ static int rmcp_remove_range(struct nilfs *nilfs,
>> } else if (errno == ENOENT) {
>> nocp++;
>> } else {
>> - fprintf(stderr, "%s: %s\n", progname, strerror(errno));
>> + fprintf(stderr,
>> + "%s: %llu: cannot remove checkpoint: %s\n",
>> + progname, (unsigned long long)cno,
>> + strerror(errno));
>> ret = -1;
>
>> - goto out;
>
> Could you revise this ?
>
> I think the loop should abort immidiately when the rmcp meets an
> important error even though it will change behavior for the real
> permission error.
1. Please define "important"- is EPERM important? I would tend to say
the error should be printed once per checkpoint as it is now in this
case for EPERM, and then restore the prior behavior for other actions.
2. I'm not very fond of the error messages with the immediate exit:
$ ./bin/rmcp 100..105 115..125
lt-rmcp: 100: cannot remove checkpoint: Operation not permitted
$ echo $?
1
Did 101-105 succeed? Did the second range succeed? Judging from this
(lack of) output, I would think it did, which is quite obviously not
the case.
So I would vote to not exit early in at least the semi-normal EPERM
case; perhaps we do for the others. What is the reasoning behind
exiting early in even the abnormal error cases?
>> }
>> }
>> if (!force && (nss > 0 || (nocp > 0 && nd == 0)))
>> ret = 1;
>> - out:
>> +
>> *ndeleted = nd;
>> *nsnapshots = nss;
>> return ret;
>> --
--
To unsubscribe from this list: send the line "unsubscribe linux-nilfs" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
next prev parent reply other threads:[~2011-12-23 15:00 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-12-21 21:34 [PATCH 0/7] A handful of small cleanups and improvements Dan McGee
[not found] ` <1324503249-17432-1-git-send-email-dan-fd97jBR+K/6hPH1hqNUYSQ@public.gmane.org>
2011-12-21 21:34 ` [PATCH 1/7] Add .gitignore rules for generated binaries Dan McGee
2011-12-21 21:34 ` [PATCH 2/7] umount.nilfs2 (libmount): send proper error code to complain function Dan McGee
2011-12-21 21:34 ` [PATCH 3/7] Remove kern_compat.h Dan McGee
[not found] ` <1324503249-17432-4-git-send-email-dan-fd97jBR+K/6hPH1hqNUYSQ@public.gmane.org>
2011-12-23 5:25 ` Ryusuke Konishi
2011-12-21 21:34 ` [PATCH 4/7] Alpha sort AC_CHECK_FUNCS list in configure.ac Dan McGee
2011-12-21 21:34 ` [PATCH 5/7] Use strtoull instead of strtoul where applicable Dan McGee
2011-12-21 21:34 ` [PATCH 6/7] rmcp/chcp: sanity check for positive checkpoint number Dan McGee
2011-12-21 21:34 ` [PATCH 7/7] rmcp: print sensible error message on permission failure Dan McGee
[not found] ` <1324503249-17432-8-git-send-email-dan-fd97jBR+K/6hPH1hqNUYSQ@public.gmane.org>
2011-12-23 5:56 ` Ryusuke Konishi
[not found] ` <20111223.145629.123971064.ryusuke-sG5X7nlA6pw@public.gmane.org>
2011-12-23 15:00 ` Dan McGee [this message]
[not found] ` <CAEik5nNHs1Lp-Wz_p9k_Xt1-CBu4L=Agsf28vVC7iBp4mSsuwA-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2011-12-24 7:20 ` Ryusuke Konishi
[not found] ` <20111224.162041.267403683.ryusuke-sG5X7nlA6pw@public.gmane.org>
2012-01-03 19:46 ` [PATCH] " Dan McGee
[not found] ` <1325619960-9715-1-git-send-email-dan-fd97jBR+K/6hPH1hqNUYSQ@public.gmane.org>
2012-01-05 5:14 ` Ryusuke Konishi
2011-12-22 16:35 ` [PATCH 0/7] A handful of small cleanups and improvements Ryusuke Konishi
[not found] ` <20111223.013541.163265429.ryusuke-sG5X7nlA6pw@public.gmane.org>
2011-12-23 6:40 ` Ryusuke Konishi
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to='CAEik5nNHs1Lp-Wz_p9k_Xt1-CBu4L=Agsf28vVC7iBp4mSsuwA@mail.gmail.com' \
--to=dan-fd97jbr+k/6hph1hqnuysq@public.gmane.org \
--cc=konishi.ryusuke-Zyj7fXuS5i5L9jVzuh4AOg@public.gmane.org \
--cc=linux-nilfs-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).