linux-ext4.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Theodore Y. Ts'o" <tytso@mit.edu>
To: Andreas Dilger <adilger@dilger.ca>
Cc: Ext4 Developers List <linux-ext4@vger.kernel.org>, stable@kernel.org
Subject: Re: [PATCH] ext4: avoid declaring fs inconsistent due to invalid file handles
Date: Mon, 17 Dec 2018 23:45:41 -0500	[thread overview]
Message-ID: <20181218044541.GB25775@mit.edu> (raw)
In-Reply-To: <A3D72248-487E-412E-B341-7450C773E81F@dilger.ca>

On Mon, Dec 17, 2018 at 03:53:46PM -0700, Andreas Dilger wrote:
> > +#define EXT4_IGET_NORMAL	1
> > +#define EXT4_IGET_HANDLE	2
> 
> It would be better to make this:
> 
>  enum ext4_iget_flags {
>         EXT4_IGET_RESERVED = 0x00,	/* just guessing, see further below */
> 	EXT4_IGET_NORMAL   = 0x01,
> 	EXT4_IGET_HANDLE   = 0x02,
>  };
> 
> > -	inode = ext4_iget(sb, ino);
> > +	inode = ext4_iget(sb, ino, 0);
> 
> What does "0" mean?  It isn't in the list of EXT4_IGET_* flags.  I'm guessing it
> means that access to reserved or otherwise invalid inodes is allowed?

The flags are boolean OR'ed together, much like O_TRUNC | O_CREAT,
etc.  So an enum isn't really appropriate.  So 0 means we're not
enforcing "must be a normal inode" rules, and we're also not going to
avoid throwing an EXT4_ERROR if the inode number is invalid.

I had thought it was obvious that flags can be or'ed together, and
that "modes" are what might use an enum.  I personally like flags
because the can be more expressive, although I can see that "modes"
are simpler since there is a much smaller set of valid modes, and you
don't have to worry about define what happens when flags interact in
unusual/unexpected ways.

It sounds like should add more explicit documentation at the very
least so it's more clear what's going on.

      	      	   	 	      - Ted

  reply	other threads:[~2018-12-18  4:45 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-12-13 17:51 [PATCH] ext4: avoid declaring fs inconsistent due to invalid file handles Theodore Ts'o
2018-12-17 22:53 ` Andreas Dilger
2018-12-18  4:45   ` Theodore Y. Ts'o [this message]
2018-12-18  5:43     ` Andreas Dilger
2018-12-18 16:35       ` Theodore Y. Ts'o
2018-12-19 17:31         ` [PATCH -v2] " Theodore Ts'o

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=20181218044541.GB25775@mit.edu \
    --to=tytso@mit.edu \
    --cc=adilger@dilger.ca \
    --cc=linux-ext4@vger.kernel.org \
    --cc=stable@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).