From: Karel Zak <kzak@redhat.com>
To: Stanislav Brabec <sbrabec@suse.cz>
Cc: util-linux@vger.kernel.org
Subject: Re: [PATCH 3/3] fstrim -a/-A: Skip read-only volumes
Date: Tue, 11 Jun 2019 10:15:13 +0200 [thread overview]
Message-ID: <20190611081513.gvwpgg74qup2yg6w@ws.net.home> (raw)
In-Reply-To: <a46df663-bdfd-6f53-45e9-c4547e4ee108@suse.cz>
On Mon, Jun 10, 2019 at 09:59:45PM +0200, Stanislav Brabec wrote:
> Calling TRIM on some read-only volumes can fail with:
> fstrim: /win: FITRIM ioctl failed: Bad file descriptor
Did you try it with the current version from git? ... because we
interpret EBADF as "the discard operation is not supported" warning
rather than an error.
> Skipping all read-only mounts seems to be safe and logical strategy.
>
> Fixes opensuse#1106214.
>
> Signed-off-by: Stanislav Brabec <sbrabec@suse.cz>
> ---
> sys-utils/fstrim.c | 8 ++++++++
> 1 file changed, 8 insertions(+)
>
> diff --git a/sys-utils/fstrim.c b/sys-utils/fstrim.c
> index 0491e2b54..e0e9e57a9 100644
> --- a/sys-utils/fstrim.c
> +++ b/sys-utils/fstrim.c
> @@ -328,6 +328,14 @@ static int fstrim_all(struct fstrim_control *ctl)
> if (rc)
> continue; /* overlaying mount */
>
> + /* FSTRIM on read-only filesystem can fail, and it can fail */
> + if (access(path, W_OK) != 0) {
> + if (errno == EROFS)
> + continue;
> + if (errno == EACCES)
> + continue;
> + }
> +
Anyway, for fstrim_all() it's probably good idea to call access().
Karel
--
Karel Zak <kzak@redhat.com>
http://karelzak.blogspot.com
next prev parent reply other threads:[~2019-06-11 8:15 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-06-10 19:59 [PATCH 3/3] fstrim -a/-A: Skip read-only volumes Stanislav Brabec
2019-06-11 8:15 ` Karel Zak [this message]
2019-06-11 13:23 ` Stanislav Brabec
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=20190611081513.gvwpgg74qup2yg6w@ws.net.home \
--to=kzak@redhat.com \
--cc=sbrabec@suse.cz \
--cc=util-linux@vger.kernel.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).