public inbox for linux-ext4@vger.kernel.org
 help / color / mirror / Atom feed
From: Andreas Dilger <adilger@dilger.ca>
To: Konstantin Khlebnikov <khlebnikov@yandex-team.ru>
Cc: "linux-ext4@vger.kernel.org" <linux-ext4@vger.kernel.org>,
	Theodore Ts'o <tytso@mit.edu>, Li Xi <pkuelelixi@gmail.com>
Subject: Re: How to add new fields into inode?
Date: Fri, 27 Feb 2015 00:52:43 -0700	[thread overview]
Message-ID: <38ED78B4-149F-4C6F-A2EC-634C71ED9ADF@dilger.ca> (raw)
In-Reply-To: <54EDABB5.5020806@yandex-team.ru>

On Feb 25, 2015, at 4:02 AM, Konstantin Khlebnikov <khlebnikov@yandex-team.ru> wrote:
> 
> Currently I'm working on (yet another attempt of) project id and quota
> for ext4. Obviously I want to add new u32 field into inode for holding
> it's project id.
> 
> As I see policy for that isn't well defined:
> 
> Kernel tries to allocate extra space according to sizeof(struct
> ext4_inode). If EXT4_FEATURE_RO_COMPAT_EXTRA_ISIZE is set then it takes
> maximum of sizeof, s_want_extra_isize and s_min_extra_isize.
> 
> Libext2fs always allocates space for it's own structure and in some
> cases checks s_want_extra_isize but without checking related feature.

That is likely a bug in libext2fs.  This feature was written because
some people were concerned about requiring extra inode features on a
filesystem that was upgraded from an older kernel where the reserved
fields were fewer.  In many cases, it is not critical if some field
at the end of the inode is present or not, but in other cases (maybe
project quota?) it is important that there is always space for saving
this data.

We have a patch for e2fsck which allows expanding the i_extra_size on
all in-use inodes in the filesystem to ensure that it meets at least
s_min_extra_isize.  New inodes will always reserve the needed space.

http://git.hpdd.intel.com/tools/e2fsprogs.git/commitdiff/6a7efec02c4d01b6bd951fef7d1c8c78f0426aa4
http://git.hpdd.intel.com/tools/e2fsprogs.git/commitdiff/89555784b583ff1dd48e31ff276a4ad0421172b0

If there isn't enough space in the inode for the extra bytes, then
e2fsck will prompt the user to delete an xattr from the inode, or
abort e2fsck (in a safe manner, nothing will be one in preen mode).

> Thus in some cases default extra size of inodes doesn't depend on
> present features and changes if we add new fields into structure.
> For example expected output of some unit tests depends on that value.
> 
> Question is: it's ok to waste some bytes for unused fields at the of
> inode or default extra size should depend on actually enabled features?

I think it is preferable that the i_extra_size not be larger than what
is actually used.  If some feature like project quota is enabled on an
existing filesystem, then e2fsck could be run to expand the inode size
to the needed size,  It would also be possible for the kernel to grow
i_extra_size to cover the new field, or return an error to userspace
at the time the new project quota is being set on the file (either
explicitly or by rename into a project quota-enabled directory).

Cheers, Andreas






      reply	other threads:[~2015-02-27  7:52 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-02-25 11:02 How to add new fields into inode? Konstantin Khlebnikov
2015-02-27  7:52 ` Andreas Dilger [this message]

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=38ED78B4-149F-4C6F-A2EC-634C71ED9ADF@dilger.ca \
    --to=adilger@dilger.ca \
    --cc=khlebnikov@yandex-team.ru \
    --cc=linux-ext4@vger.kernel.org \
    --cc=pkuelelixi@gmail.com \
    --cc=tytso@mit.edu \
    /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