linux-fscrypt.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Josef Bacik <josef@toxicpanda.com>
To: Sweet Tea Dorminy <sweettea-kernel@dorminy.me>
Cc: "Theodore Y. Ts'o" <tytso@mit.edu>,
	Jaegeuk Kim <jaegeuk@kernel.org>,
	Eric Biggers <ebiggers@kernel.org>, Chris Mason <clm@fb.com>,
	David Sterba <dsterba@suse.com>,
	linux-fscrypt@vger.kernel.org, linux-btrfs@vger.kernel.org,
	kernel-team@meta.com
Subject: Re: [PATCH v2 09/14] fscrypt: move function call warning of busy inodes
Date: Mon, 17 Jul 2023 10:59:35 -0400	[thread overview]
Message-ID: <20230717145935.GD691303@perftesting> (raw)
In-Reply-To: <cde56d55c6546a7861165acb8299e413d815e794.1688927487.git.sweettea-kernel@dorminy.me>

On Sun, Jul 09, 2023 at 02:53:42PM -0400, Sweet Tea Dorminy wrote:
> Extent encryption will want to attempt to evict inodes, and not warn of
> busy ones, before removing the key instead of after as it is at present.
> Therefore pull the call for check_for_busy_inodes() out of
> try_to_lock_encrypted_files() into its only callsite.
> 
> Signed-off-by: Sweet Tea Dorminy <sweettea-kernel@dorminy.me>
> ---
>  fs/crypto/keyring.c | 26 +++++++++++++-------------
>  1 file changed, 13 insertions(+), 13 deletions(-)
> 
> diff --git a/fs/crypto/keyring.c b/fs/crypto/keyring.c
> index bfcd2ecbe481..c4499248b6cc 100644
> --- a/fs/crypto/keyring.c
> +++ b/fs/crypto/keyring.c
> @@ -947,8 +947,7 @@ static int check_for_busy_inodes(struct super_block *sb,
>  static int try_to_lock_encrypted_files(struct super_block *sb,
>  				       struct fscrypt_master_key *mk)
>  {
> -	int err1;
> -	int err2;
> +	int err;
>  
>  	/*
>  	 * An inode can't be evicted while it is dirty or has dirty pages.
> @@ -960,7 +959,7 @@ static int try_to_lock_encrypted_files(struct super_block *sb,
>  	 * already call sync_filesystem() via sys_syncfs() or sys_sync().
>  	 */
>  	down_read(&sb->s_umount);
> -	err1 = sync_filesystem(sb);
> +	err = sync_filesystem(sb);
>  	up_read(&sb->s_umount);
>  	/* If a sync error occurs, still try to evict as much as possible. */
>  
> @@ -972,16 +971,7 @@ static int try_to_lock_encrypted_files(struct super_block *sb,
>  	 */
>  	evict_dentries_for_decrypted_inodes(mk);
>  
> -	/*
> -	 * evict_dentries_for_decrypted_inodes() already iput() each inode in
> -	 * the list; any inodes for which that dropped the last reference will
> -	 * have been evicted due to fscrypt_drop_inode() detecting the key
> -	 * removal and telling the VFS to evict the inode.  So to finish, we
> -	 * just need to check whether any inodes couldn't be evicted.
> -	 */
> -	err2 = check_for_busy_inodes(sb, mk);
> -
> -	return err1 ?: err2;
> +	return err;
>  }
>  
>  /*
> @@ -1073,14 +1063,24 @@ static int do_remove_key(struct file *filp, void __user *_uarg, bool all_users)
>  	up_write(&mk->mk_sem);
>  
>  	if (inodes_remain) {
> +		int err2;
>  		/* Some inodes still reference this key; try to evict them. */
>  		err = try_to_lock_encrypted_files(sb, mk);
> +		/* We already tried to iput() each inode referencing this key
> +		 * which would cause the inode to be evicted if that was the
> +		 * last reference (since fscrypt_drop_inode() would see the
> +		 * key removal). So the only remaining inodes referencing this
> +		 * key are still busy and couldn't be evicted; check for them.
> +		 */
> +		err2 = check_for_busy_inodes(sb, mk);
> +		err = err ?: err2;
>  		if (err == -EBUSY) {
>  			status_flags |=
>  				FSCRYPT_KEY_REMOVAL_STATUS_FLAG_FILES_BUSY;
>  			err = 0;
>  		}
>  	}
> +

Extra whitespace.  Thanks,

Josef

  reply	other threads:[~2023-07-17 14:59 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-07-09 18:53 [PATCH v2 00/14] fscrypt: add extent encryption Sweet Tea Dorminy
2023-07-09 18:53 ` [PATCH v2 01/14] fscrypt: factor helper for locking master key Sweet Tea Dorminy
2023-07-09 18:53 ` [PATCH v2 02/14] fscrypt: factor getting info for a specific block Sweet Tea Dorminy
2023-07-09 18:53 ` [PATCH v2 03/14] fscrypt: adjust effective lblks based on extents Sweet Tea Dorminy
2023-07-14 18:13   ` Josef Bacik
2023-07-09 18:53 ` [PATCH v2 04/14] fscrypt: add a super_block pointer to fscrypt_info Sweet Tea Dorminy
2023-07-09 18:53 ` [PATCH v2 05/14] fscrypt: setup leaf inodes for extent encryption Sweet Tea Dorminy
2023-07-14 18:16   ` Josef Bacik
2023-07-09 18:53 ` [PATCH v2 06/14] fscrypt: allow infos to be owned by extents Sweet Tea Dorminy
2023-07-09 18:53 ` [PATCH v2 07/14] fscrypt: notify per-extent infos if master key vanishes Sweet Tea Dorminy
2023-07-17 14:54   ` Josef Bacik
2023-07-09 18:53 ` [PATCH v2 08/14] fscrypt: use an optional ino equivalent for per-extent infos Sweet Tea Dorminy
2023-07-09 18:53 ` [PATCH v2 09/14] fscrypt: move function call warning of busy inodes Sweet Tea Dorminy
2023-07-17 14:59   ` Josef Bacik [this message]
2023-07-09 18:53 ` [PATCH v2 10/14] fscrypt: revamp key removal for extent encryption Sweet Tea Dorminy
2023-07-17 15:18   ` Josef Bacik
2023-07-09 18:53 ` [PATCH v2 11/14] fscrypt: add creation/usage/freeing of per-extent infos Sweet Tea Dorminy
2023-07-17 15:21   ` Josef Bacik
2023-07-09 18:53 ` [PATCH v2 12/14] fscrypt: allow load/save of extent contexts Sweet Tea Dorminy
2023-07-17 15:23   ` Josef Bacik
2023-07-09 18:53 ` [PATCH v2 13/14] fscrypt: save session key credentials for extent infos Sweet Tea Dorminy
2023-07-17 14:31   ` Josef Bacik
2023-07-09 18:53 ` [PATCH v2 14/14] fscrypt: update documentation for per-extent keys Sweet Tea Dorminy

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=20230717145935.GD691303@perftesting \
    --to=josef@toxicpanda.com \
    --cc=clm@fb.com \
    --cc=dsterba@suse.com \
    --cc=ebiggers@kernel.org \
    --cc=jaegeuk@kernel.org \
    --cc=kernel-team@meta.com \
    --cc=linux-btrfs@vger.kernel.org \
    --cc=linux-fscrypt@vger.kernel.org \
    --cc=sweettea-kernel@dorminy.me \
    --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;
as well as URLs for NNTP newsgroup(s).