All of lore.kernel.org
 help / color / mirror / Atom feed
From: Theodore Ts'o <tytso@mit.edu>
To: Amir Goldstein <amir73il@gmail.com>
Cc: Dave Chinner <david@fromorbit.com>,
	"Darrick J. Wong" <darrick.wong@oracle.com>,
	Jan Kara <jack@suse.com>, Chris Mason <clm@fb.com>,
	Boaz Harrosh <boaz@plexistor.com>,
	Jaegeuk Kim <jaegeuk@kernel.org>,
	Ryusuke Konishi <konishi.ryusuke@lab.ntt.co.jp>,
	Mark Fasheh <mfasheh@versity.com>,
	Evgeniy Dushistov <dushistov@mail.ru>,
	Miklos Szeredi <miklos@szeredi.hu>,
	Al Viro <viro@zeniv.linux.org.uk>,
	linux-fsdevel <linux-fsdevel@vger.kernel.org>
Subject: Re: [RFC][PATCH 11/11] xfs: use common file type conversion
Date: Wed, 21 Dec 2016 17:56:05 -0500	[thread overview]
Message-ID: <20161221225605.qcgpwkyrugwmjnza@thunk.org> (raw)
In-Reply-To: <CAOQ4uxjnUNQWiwx_rExePs_S_eTZWbVkqY1UgBUzbehKn4LxWQ@mail.gmail.com>

On Wed, Dec 21, 2016 at 06:37:42PM +0200, Amir Goldstein wrote:
> 
> Right. never claimed that saving data segment space is the issue
> here. To be completely honest, I started looking at ways to optimize
> whiteout iteration and was appalled to see all that code copy&paste,
> so went on an OCD cleanup spree.
> 
> So it is really a lot more about clumsiness of the current code then
> about saving actual lines on code or space in data segment.
> 
> Perhaps I should have settled with defining this common section:

> +#define DT_WHT         14

What are you trying to accomplish here?  Unless we actually encoding
DT_WHT into the on-disk format, it's not really going to buy you much.

And if you are going to encode this into the on-disk format, each file
system is going to have to set some kind of flag in the superblock to
indicate whether it's doing this new thing or not.  And this is
*precisely* why Dave and Darrick are objecting --- if we are going to
make any kind of file system encoding change, the file system has to
know about it.

> Note that all those file system copy&pasted a potential bug.
> 
> This is an array of size 15:
> 
> static unsigned char ext2_type_by_mode[S_IFMT >> S_SHIFT] = {
> 
> and it is always addressed this way:
> 
> ext2_type_by_mode[(inode->i_mode & S_IFMT)>>S_SHIFT];
> 
> Which *can* try to address ext2_type_by_mode[15]
> 
> Now, can you say for certain that you can never get a malformed i_mode
> with ((inode->i_mode & S_IFMT) == S_IFMT) either from disk or from
> some code calling into VFS functions, which do not sanity check the
> file type of the mode argument.

It's not a problem and not a bug, because we only assign the file type
when the inode is created, and at that point, the i_mode is set by the
*kernel*, and not by the on-disk encoding.

And BTW this is why DT_WHT makes no sense.  We the DT encodings come
from the directory entry, and *never* come from the inode i_mode read
from disk --- since at the time when we do the readdir(2), the inode
may not have been read into memory.  So we can't add DT_WHT unless we
also change the on-disk encoding of the directory entry on a file
system by file system basis.

Cheers,

						- Ted

  reply	other threads:[~2016-12-21 22:56 UTC|newest]

Thread overview: 35+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-12-19 20:10 [RFC][PATCH 00/11] common implementation of dirent file types Amir Goldstein
2016-12-19 20:10 ` [RFC][PATCH 01/11] fs: common implementation of file type conversions Amir Goldstein
2016-12-19 21:13   ` Darrick J. Wong
2016-12-20  5:01     ` Amir Goldstein
2016-12-20  7:37   ` [RFC][PATCH v2 " Amir Goldstein
2016-12-19 20:10 ` [RFC][PATCH 02/11] ufs: use fs_umode_to_dtype() helper Amir Goldstein
2016-12-19 20:11 ` [RFC][PATCH 03/11] hfsplus: " Amir Goldstein
2016-12-19 20:11 ` [RFC][PATCH 04/11] ext2: use common file type conversion Amir Goldstein
2016-12-19 20:11 ` [RFC][PATCH 05/11] exofs: " Amir Goldstein
2016-12-19 21:50   ` Boaz Harrosh
2016-12-19 20:11 ` [RFC][PATCH 06/11] ext4: " Amir Goldstein
2016-12-19 20:11 ` [RFC][PATCH 07/11] ocfs2: " Amir Goldstein
2016-12-19 20:11 ` [RFC][PATCH 08/11] f2fs: " Amir Goldstein
2016-12-19 20:11 ` [RFC][PATCH 09/11] nilfs2: " Amir Goldstein
2016-12-19 20:11 ` [RFC][PATCH 10/11] btrfs: " Amir Goldstein
2016-12-19 20:11 ` [RFC][PATCH 11/11] xfs: " Amir Goldstein
2016-12-19 21:55   ` Darrick J. Wong
2016-12-20  6:17     ` Amir Goldstein
2016-12-20 14:07       ` Amir Goldstein
2016-12-20  0:28   ` Darrick J. Wong
2016-12-20  5:20     ` Amir Goldstein
2016-12-21  5:23       ` Dave Chinner
2016-12-21  6:37         ` Amir Goldstein
2016-12-21 10:12           ` [RFC][PATCH v2 " Amir Goldstein
2016-12-21 18:01             ` [PATCH v3 " Amir Goldstein
2016-12-22 21:07               ` [PATCH v4] xfs: fix the size of xfs_mode_to_ftype table Amir Goldstein
2016-12-23 21:01                 ` Darrick J. Wong
2016-12-24  7:31                   ` Amir Goldstein
2016-12-24 14:11                 ` Brian Foster
2016-12-21 15:06         ` [RFC][PATCH 11/11] xfs: use common file type conversion Theodore Ts'o
2016-12-21 16:37           ` Amir Goldstein
2016-12-21 22:56             ` Theodore Ts'o [this message]
2016-12-22  5:54               ` Amir Goldstein
2016-12-22 20:30                 ` Amir Goldstein
2016-12-21 16:59           ` Miklos Szeredi

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=20161221225605.qcgpwkyrugwmjnza@thunk.org \
    --to=tytso@mit.edu \
    --cc=amir73il@gmail.com \
    --cc=boaz@plexistor.com \
    --cc=clm@fb.com \
    --cc=darrick.wong@oracle.com \
    --cc=david@fromorbit.com \
    --cc=dushistov@mail.ru \
    --cc=jack@suse.com \
    --cc=jaegeuk@kernel.org \
    --cc=konishi.ryusuke@lab.ntt.co.jp \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=mfasheh@versity.com \
    --cc=miklos@szeredi.hu \
    --cc=viro@zeniv.linux.org.uk \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.