From: Andreas Dilger <adilger@dilger.ca>
To: Wang Shilong <wangshilong1991@gmail.com>
Cc: linux-ext4 <linux-ext4@vger.kernel.org>,
Theodore Ts'o <tytso@mit.edu>, Li Xi <lixi@ddn.com>,
"zhangyi (F)" <yi.zhang@huawei.com>,
miaoxie@huawei.com, wshilong@ddn.com,
Shuichi Ihara <sihara@ddn.com>
Subject: Re: [PATCH v2 1/2] ext4, project: expand inode extra size if possible
Date: Wed, 5 Jul 2017 10:31:02 -0600 [thread overview]
Message-ID: <987151C3-9E9D-4ACD-84BB-B9DC33C08822@dilger.ca> (raw)
In-Reply-To: <20170704074210.77918-1-wshilong@ddn.com>
[-- Attachment #1: Type: text/plain, Size: 3936 bytes --]
On Jul 4, 2017, at 1:42 AM, Wang Shilong <wangshilong1991@gmail.com> wrote:
>
> when upgrading from old format, try to set project id
> to old file first time, it will return EOVERFLOW, but if
> that file is dirtied(touch etc), changing project id will
> be allowed, this might be confusing for users, we could
> try to expand @i_extra_iszie here too.
>
> Reported-by: zhangyi(F) <yi.zhang@huawei.com>
> Signed-off-by: Wang Shilong <wshilong@ddn.com>
Reviewed-by: Andreas Dilger <adilger@dilger.ca>
> ---
> v1->v2:
> ext4_expand_extra_isize should be invoked after ext4_reserve_inode_write
> ---
> fs/ext4/ext4.h | 3 +++
> fs/ext4/inode.c | 8 ++++----
> fs/ext4/ioctl.c | 17 +++++++++++++++--
> 3 files changed, 22 insertions(+), 6 deletions(-)
>
> diff --git a/fs/ext4/ext4.h b/fs/ext4/ext4.h
> index 3219154..640f006 100644
> --- a/fs/ext4/ext4.h
> +++ b/fs/ext4/ext4.h
> @@ -2453,6 +2453,9 @@ int ext4_walk_page_buffers(handle_t *handle,
> int *partial,
> int (*fn)(handle_t *handle,
> struct buffer_head *bh));
> +int ext4_expand_extra_isize(struct inode *inode,
> + unsigned int new_extra_isize,
> + struct ext4_iloc iloc, handle_t *handle);
> int do_journal_get_write_access(handle_t *handle,
> struct buffer_head *bh);
> #define FALL_BACK_TO_NONDELALLOC 1
> diff --git a/fs/ext4/inode.c b/fs/ext4/inode.c
> index 5cf82d0..9d07554 100644
> --- a/fs/ext4/inode.c
> +++ b/fs/ext4/inode.c
> @@ -5632,10 +5632,10 @@ ext4_reserve_inode_write(handle_t *handle, struct inode *inode,
> * Expand an inode by new_extra_isize bytes.
> * Returns 0 on success or negative error number on failure.
> */
> -static int ext4_expand_extra_isize(struct inode *inode,
> - unsigned int new_extra_isize,
> - struct ext4_iloc iloc,
> - handle_t *handle)
> +int ext4_expand_extra_isize(struct inode *inode,
> + unsigned int new_extra_isize,
> + struct ext4_iloc iloc,
> + handle_t *handle)
> {
> struct ext4_inode *raw_inode;
> struct ext4_xattr_ibody_header *header;
> diff --git a/fs/ext4/ioctl.c b/fs/ext4/ioctl.c
> index 0c21e22..d413008 100644
> --- a/fs/ext4/ioctl.c
> +++ b/fs/ext4/ioctl.c
> @@ -319,6 +319,7 @@ static int ext4_ioctl_setproject(struct file *filp, __u32 projid)
> struct ext4_iloc iloc;
> struct ext4_inode *raw_inode;
> struct dquot *transfer_to[MAXQUOTAS] = { };
> + bool need_expand = false;
>
> if (!ext4_has_feature_project(sb)) {
> if (projid != EXT4_DEF_PROJID)
> @@ -350,7 +351,10 @@ static int ext4_ioctl_setproject(struct file *filp, __u32 projid)
> goto out_unlock;
>
> raw_inode = ext4_raw_inode(&iloc);
> - if (!EXT4_FITS_IN_INODE(raw_inode, ei, i_projid)) {
> + if (!EXT4_FITS_IN_INODE(raw_inode, ei, i_projid) &&
> + !ext4_test_inode_state(inode, EXT4_STATE_NO_EXPAND)) {
> + need_expand = true;
> + } else if (!EXT4_FITS_IN_INODE(raw_inode, ei, i_projid)) {
> err = -EOVERFLOW;
> brelse(iloc.bh);
> goto out_unlock;
> @@ -361,7 +365,8 @@ static int ext4_ioctl_setproject(struct file *filp, __u32 projid)
>
> handle = ext4_journal_start(inode, EXT4_HT_QUOTA,
> EXT4_QUOTA_INIT_BLOCKS(sb) +
> - EXT4_QUOTA_DEL_BLOCKS(sb) + 3);
> + EXT4_QUOTA_DEL_BLOCKS(sb) + 3 +
> + need_expand ? EXT4_DATA_TRANS_BLOCKS(sb) : 0);
> if (IS_ERR(handle)) {
> err = PTR_ERR(handle);
> goto out_unlock;
> @@ -371,6 +376,14 @@ static int ext4_ioctl_setproject(struct file *filp, __u32 projid)
> if (err)
> goto out_stop;
>
> + if (need_expand) {
> + err = ext4_expand_extra_isize(inode,
> + EXT4_SB(sb)->s_want_extra_isize,
> + iloc, handle);
> + if (err)
> + goto out_stop;
> + }
> +
> transfer_to[PRJQUOTA] = dqget(sb, make_kqid_projid(kprojid));
> if (!IS_ERR(transfer_to[PRJQUOTA])) {
> err = __dquot_transfer(inode, transfer_to);
> --
> 2.9.3
>
Cheers, Andreas
[-- Attachment #2: Message signed with OpenPGP --]
[-- Type: application/pgp-signature, Size: 195 bytes --]
next prev parent reply other threads:[~2017-07-05 16:29 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-07-04 7:42 [PATCH v2 1/2] ext4, project: expand inode extra size if possible Wang Shilong
2017-07-05 16:31 ` Andreas Dilger [this message]
2017-07-06 3:51 ` Miao Xie
2017-07-06 7:32 ` Wang Shilong
2017-07-06 7:34 ` Andreas Dilger
2017-07-06 8:36 ` Miao Xie
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=987151C3-9E9D-4ACD-84BB-B9DC33C08822@dilger.ca \
--to=adilger@dilger.ca \
--cc=linux-ext4@vger.kernel.org \
--cc=lixi@ddn.com \
--cc=miaoxie@huawei.com \
--cc=sihara@ddn.com \
--cc=tytso@mit.edu \
--cc=wangshilong1991@gmail.com \
--cc=wshilong@ddn.com \
--cc=yi.zhang@huawei.com \
/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