All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jaegeuk Kim <jaegeuk@kernel.org>
To: Kinglong Mee <kinglongmee@gmail.com>
Cc: linux-f2fs-devel@lists.sourceforge.net
Subject: Re: [PATCH v2] f2fs: sync the enc name flags with disk level filename
Date: Thu, 9 Mar 2017 18:23:30 -0800	[thread overview]
Message-ID: <20170310022330.GA17988@jaegeuk.local> (raw)
In-Reply-To: <481d729a-c82f-0542-c73f-93c73fa9a3a8@gmail.com>

On 03/10, Kinglong Mee wrote:
> On 3/8/2017 18:56, Kinglong Mee wrote:
> > On 3/8/2017 03:30, Jaegeuk Kim wrote:
> >> Hi Kinglong,
> >>
> >> Can we make a testcase in xfstests to check this clearly?
> >> 1. creat A under encrypted dir
> >> 2. rename A to B
> >> 3. fsync B
> >> 4. power-cut
> >>
> >> Is this your concern?
> > 
> > Yes, it is.
> > If B isn't exist, rename A to B means create a new A (unlink the old).
> > B is exist, the inode (include disk node) will be replace by A, but,
> > for the file_enc_name, the disk i_name/i_namelen isn't updated.
> > 
> > For the rename, A and B lost there parent, so the 3 step will cause checkpoint, 
> > after that, everything is updated to disk (with the unchanged filename), 
> > so that the 4 step of power-cut can't cause a roll_forward.
> > 
> > If fsync A for flags the inode and then rename as,
> > 1. creat A and B under encrypted dir
> > 2. fsync A          (after rename, B will be unlink)
> > 3. rename A to B
> > 4. godown 
> > 5. umount/mount
> > 
> > A roll_forward (recover_dentry) happens, the result is same as after setp1,
> > that's not my needs.
> > 
> > For the IS_CHECKPOINTED flag, after a new created file sync to the disk,
> > it's cleared, and never appears again, after that a roll_forward of 
> > recover_dentry will never happen (it means the disk i_name will not be
> > used forever). Am I right?
> > 
> > If that's right, next update_dent_inode after file created is useless,
> > we can remove them include the FADVISE_ENC_NAME_BIT.
> 
> Hi Jaegeuk, 
> 
> What's your opinion?
> If you agree that they are useless of the disk-level filename updating, 
> I will cleanup them.

Agreed to that. Indeed, once checkpoint is done, we don't need to update
there-in filename at all. You may need to check whether inode is checkpointed
or not to detect that. BTW, it doesn't need to consider encrypted names only
though.

Thanks,

> 
> thanks,
> Kinglong Mee
> 
> > 
> >>
> >> Hmm, on-disk filename is used when doing roll-forward recovery, and it seems
> >> there is a hole in try_to_fix_pino() to recover its pino without filename.
> >>
> >> Like this?
> >>
> >> >From 7efde035d9f930fc63c30b25327e870b021750f3 Mon Sep 17 00:00:00 2001
> >> From: Jaegeuk Kim <jaegeuk@kernel.org>
> >> Date: Tue, 7 Mar 2017 11:22:45 -0800
> >> Subject: [PATCH] f2fS: don't allow to get pino when filename is encrypted
> >>
> >> After renaming an encrypted file, we have no way to get its
> >> encrypted filename from its dentry.
> >>
> >> Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
> >> ---
> >>  fs/f2fs/file.c | 3 +++
> >>  1 file changed, 3 insertions(+)
> >>
> >> diff --git a/fs/f2fs/file.c b/fs/f2fs/file.c
> >> index e0b2378f8519..852195b3bcce 100644
> >> --- a/fs/f2fs/file.c
> >> +++ b/fs/f2fs/file.c
> >> @@ -110,6 +110,9 @@ static int get_parent_ino(struct inode *inode, nid_t *pino)
> >>  {
> >>  	struct dentry *dentry;
> >>  
> >> +	if (file_enc_name(inode))
> >> +		return 0;
> >> +
> >>  	inode = igrab(inode);
> >>  	dentry = d_find_any_alias(inode);
> >>  	iput(inode);
> >>
> 
> Yes, this patch is needed, but it causes the following problem of 
> the forever lost parent inode flags for encrypted files after rename.
> 
> thanks,
> Kinglong Mee
> 
> > 
> > The renamed inode will lost their parent ino, and try to fix it when fsync.
> > With the file_enc_name checking, get_parent_ino return 0 without parent ino
> > for encrypted inode, after that the FADVISE_COLD_BIT will exist forever, 
> > fsync the encrypted inode causing do_checkpoint every time.
> > 
> > static void try_to_fix_pino(struct inode *inode)
> > {
> >         struct f2fs_inode_info *fi = F2FS_I(inode);
> >         nid_t pino;
> > 
> >         down_write(&fi->i_sem);
> >         if (file_wrong_pino(inode) && inode->i_nlink == 1 &&
> >                         get_parent_ino(inode, &pino)) {
> >                 f2fs_i_pino_write(inode, pino);
> >                 file_got_pino(inode);
> >         }
> >         up_write(&fi->i_sem);
> > }
> > 
> > thanks,
> > Kinglong Mee
> > 

------------------------------------------------------------------------------
Announcing the Oxford Dictionaries API! The API offers world-renowned
dictionary content that is easy and intuitive to access. Sign up for an
account today to start using our lexical data to power your apps and
projects. Get started today and enter our developer competition.
http://sdm.link/oxford

  reply	other threads:[~2017-03-10  2:23 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-03-04 13:44 [PATCH 2/2] f2fs: avoid new_inode's flags overwrite the old_node Kinglong Mee
2017-03-05 12:33 ` Kinglong Mee
2017-03-06  6:57   ` [PATCH] f2fs: sync the enc name flags with disk level filename Kinglong Mee
2017-03-06  8:11     ` [PATCH v2] " Kinglong Mee
2017-03-07 19:30       ` Jaegeuk Kim
2017-03-08 10:56         ` Kinglong Mee
2017-03-10  2:00           ` Kinglong Mee
2017-03-10  2:23             ` Jaegeuk Kim [this message]
2017-03-10  8:28               ` [PATCH v3] f2fs: cleanup the disk level filename updating Kinglong Mee
2017-03-13 18:23                 ` Jaegeuk Kim
2017-03-13 23:14                   ` Kinglong Mee
2017-03-14 19:53                     ` Jaegeuk Kim
2017-03-17  7:04                 ` Chao Yu
2017-03-17  7:30                   ` Kinglong Mee
2017-03-17 10:24                     ` Chao Yu
2017-03-08 12:14       ` [PATCH v2] f2fs: sync the enc name flags with disk level filename Chao Yu
2017-03-08 13:16         ` Kinglong Mee
2017-03-09  1:30           ` Chao Yu
2017-03-06 11:06 ` [PATCH 2/2] f2fs: avoid new_inode's flags overwrite the old_node Chao Yu
2017-03-06 11:10   ` Kinglong Mee

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=20170310022330.GA17988@jaegeuk.local \
    --to=jaegeuk@kernel.org \
    --cc=kinglongmee@gmail.com \
    --cc=linux-f2fs-devel@lists.sourceforge.net \
    /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.