linux-next.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Stephen Rothwell <sfr@canb.auug.org.au>
To: Theodore Ts'o <tytso@mit.edu>
Cc: Eric Biggers <ebiggers@google.com>,
	Harshad Shirwadkar <harshadshirwadkar@gmail.com>,
	Linux Kernel Mailing List <linux-kernel@vger.kernel.org>,
	Linux Next Mailing List <linux-next@vger.kernel.org>
Subject: linux-next: manual merge of the ext4 tree with Linus' tree
Date: Wed, 21 Oct 2020 10:03:58 +1100	[thread overview]
Message-ID: <20201021100358.1ef28ca2@canb.auug.org.au> (raw)

[-- Attachment #1: Type: text/plain, Size: 6392 bytes --]

Hi all,

Today's linux-next merge of the ext4 tree got a conflict in:

  fs/ext4/ialloc.c

between commits:

  177cc0e71008 ("ext4: factor out ext4_xattr_credits_for_new_inode()")
  02ce5316afc8 ("ext4: use fscrypt_prepare_new_inode() and fscrypt_set_context()")

from Linus' tree and commit:

  44059e503b03 ("ext4: fast commit recovery path")

from the ext4 tree.

I fixed it up (see below) and can carry the fix as necessary. This
is now fixed as far as linux-next is concerned, but any non trivial
conflicts should be mentioned to your upstream maintainer when your tree
is submitted for merging.  You may also want to consider cooperating
with the maintainer of the conflicting tree to minimise any particularly
complex conflicts.

-- 
Cheers,
Stephen Rothwell

diff --cc fs/ext4/ialloc.c
index 698ca4a4db5f,2400a8200435..000000000000
--- a/fs/ext4/ialloc.c
+++ b/fs/ext4/ialloc.c
@@@ -742,53 -746,122 +746,169 @@@ not_found
  	return 1;
  }
  
 +static int ext4_xattr_credits_for_new_inode(struct inode *dir, mode_t mode,
 +					    bool encrypt)
 +{
 +	struct super_block *sb = dir->i_sb;
 +	int nblocks = 0;
 +#ifdef CONFIG_EXT4_FS_POSIX_ACL
 +	struct posix_acl *p = get_acl(dir, ACL_TYPE_DEFAULT);
 +
 +	if (IS_ERR(p))
 +		return PTR_ERR(p);
 +	if (p) {
 +		int acl_size = p->a_count * sizeof(ext4_acl_entry);
 +
 +		nblocks += (S_ISDIR(mode) ? 2 : 1) *
 +			__ext4_xattr_set_credits(sb, NULL /* inode */,
 +						 NULL /* block_bh */, acl_size,
 +						 true /* is_create */);
 +		posix_acl_release(p);
 +	}
 +#endif
 +
 +#ifdef CONFIG_SECURITY
 +	{
 +		int num_security_xattrs = 1;
 +
 +#ifdef CONFIG_INTEGRITY
 +		num_security_xattrs++;
 +#endif
 +		/*
 +		 * We assume that security xattrs are never more than 1k.
 +		 * In practice they are under 128 bytes.
 +		 */
 +		nblocks += num_security_xattrs *
 +			__ext4_xattr_set_credits(sb, NULL /* inode */,
 +						 NULL /* block_bh */, 1024,
 +						 true /* is_create */);
 +	}
 +#endif
 +	if (encrypt)
 +		nblocks += __ext4_xattr_set_credits(sb,
 +						    NULL /* inode */,
 +						    NULL /* block_bh */,
 +						    FSCRYPT_SET_CONTEXT_MAX_SIZE,
 +						    true /* is_create */);
 +	return nblocks;
 +}
 +
+ int ext4_mark_inode_used(struct super_block *sb, int ino)
+ {
+ 	unsigned long max_ino = le32_to_cpu(EXT4_SB(sb)->s_es->s_inodes_count);
+ 	struct buffer_head *inode_bitmap_bh = NULL, *group_desc_bh = NULL;
+ 	struct ext4_group_desc *gdp;
+ 	ext4_group_t group;
+ 	int bit;
+ 	int err = -EFSCORRUPTED;
+ 
+ 	if (ino < EXT4_FIRST_INO(sb) || ino > max_ino)
+ 		goto out;
+ 
+ 	group = (ino - 1) / EXT4_INODES_PER_GROUP(sb);
+ 	bit = (ino - 1) % EXT4_INODES_PER_GROUP(sb);
+ 	inode_bitmap_bh = ext4_read_inode_bitmap(sb, group);
+ 	if (IS_ERR(inode_bitmap_bh))
+ 		return PTR_ERR(inode_bitmap_bh);
+ 
+ 	if (ext4_test_bit(bit, inode_bitmap_bh->b_data)) {
+ 		err = 0;
+ 		goto out;
+ 	}
+ 
+ 	gdp = ext4_get_group_desc(sb, group, &group_desc_bh);
+ 	if (!gdp || !group_desc_bh) {
+ 		err = -EINVAL;
+ 		goto out;
+ 	}
+ 
+ 	ext4_set_bit(bit, inode_bitmap_bh->b_data);
+ 
+ 	BUFFER_TRACE(inode_bitmap_bh, "call ext4_handle_dirty_metadata");
+ 	err = ext4_handle_dirty_metadata(NULL, NULL, inode_bitmap_bh);
+ 	if (err) {
+ 		ext4_std_error(sb, err);
+ 		goto out;
+ 	}
+ 	err = sync_dirty_buffer(inode_bitmap_bh);
+ 	if (err) {
+ 		ext4_std_error(sb, err);
+ 		goto out;
+ 	}
+ 
+ 	/* We may have to initialize the block bitmap if it isn't already */
+ 	if (ext4_has_group_desc_csum(sb) &&
+ 	    gdp->bg_flags & cpu_to_le16(EXT4_BG_BLOCK_UNINIT)) {
+ 		struct buffer_head *block_bitmap_bh;
+ 
+ 		block_bitmap_bh = ext4_read_block_bitmap(sb, group);
+ 		if (IS_ERR(block_bitmap_bh)) {
+ 			err = PTR_ERR(block_bitmap_bh);
+ 			goto out;
+ 		}
+ 
+ 		BUFFER_TRACE(block_bitmap_bh, "dirty block bitmap");
+ 		err = ext4_handle_dirty_metadata(NULL, NULL, block_bitmap_bh);
+ 		sync_dirty_buffer(block_bitmap_bh);
+ 
+ 		/* recheck and clear flag under lock if we still need to */
+ 		ext4_lock_group(sb, group);
+ 		if (ext4_has_group_desc_csum(sb) &&
+ 		    (gdp->bg_flags & cpu_to_le16(EXT4_BG_BLOCK_UNINIT))) {
+ 			gdp->bg_flags &= cpu_to_le16(~EXT4_BG_BLOCK_UNINIT);
+ 			ext4_free_group_clusters_set(sb, gdp,
+ 				ext4_free_clusters_after_init(sb, group, gdp));
+ 			ext4_block_bitmap_csum_set(sb, group, gdp,
+ 						   block_bitmap_bh);
+ 			ext4_group_desc_csum_set(sb, group, gdp);
+ 		}
+ 		ext4_unlock_group(sb, group);
+ 		brelse(block_bitmap_bh);
+ 
+ 		if (err) {
+ 			ext4_std_error(sb, err);
+ 			goto out;
+ 		}
+ 	}
+ 
+ 	/* Update the relevant bg descriptor fields */
+ 	if (ext4_has_group_desc_csum(sb)) {
+ 		int free;
+ 
+ 		ext4_lock_group(sb, group); /* while we modify the bg desc */
+ 		free = EXT4_INODES_PER_GROUP(sb) -
+ 			ext4_itable_unused_count(sb, gdp);
+ 		if (gdp->bg_flags & cpu_to_le16(EXT4_BG_INODE_UNINIT)) {
+ 			gdp->bg_flags &= cpu_to_le16(~EXT4_BG_INODE_UNINIT);
+ 			free = 0;
+ 		}
+ 
+ 		/*
+ 		 * Check the relative inode number against the last used
+ 		 * relative inode number in this group. if it is greater
+ 		 * we need to update the bg_itable_unused count
+ 		 */
+ 		if (bit >= free)
+ 			ext4_itable_unused_set(sb, gdp,
+ 					(EXT4_INODES_PER_GROUP(sb) - bit - 1));
+ 	} else {
+ 		ext4_lock_group(sb, group);
+ 	}
+ 
+ 	ext4_free_inodes_set(sb, gdp, ext4_free_inodes_count(sb, gdp) - 1);
+ 	if (ext4_has_group_desc_csum(sb)) {
+ 		ext4_inode_bitmap_csum_set(sb, group, gdp, inode_bitmap_bh,
+ 					   EXT4_INODES_PER_GROUP(sb) / 8);
+ 		ext4_group_desc_csum_set(sb, group, gdp);
+ 	}
+ 
+ 	ext4_unlock_group(sb, group);
+ 	err = ext4_handle_dirty_metadata(NULL, NULL, group_desc_bh);
+ 	sync_dirty_buffer(group_desc_bh);
+ out:
+ 	return err;
+ }
+ 
  /*
   * There are two policies for allocating an inode.  If the new inode is
   * a directory, then a forward search is made for a block group with both
@@@ -818,8 -891,8 +938,8 @@@ struct inode *__ext4_new_inode(handle_
  	struct inode *ret;
  	ext4_group_t i;
  	ext4_group_t flex_group;
- 	struct ext4_group_info *grp;
+ 	struct ext4_group_info *grp = NULL;
 -	int encrypt = 0;
 +	bool encrypt = false;
  
  	/* Cannot create files in a deleted directory */
  	if (!dir || !dir->i_nlink)

[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

             reply	other threads:[~2020-10-20 23:04 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-10-20 23:03 Stephen Rothwell [this message]
  -- strict thread matches above, loose matches on Subject: below --
2023-06-27  0:39 linux-next: manual merge of the ext4 tree with Linus' tree Stephen Rothwell
2023-06-27  6:37 ` Christoph Hellwig
2023-06-27  7:26   ` Stephen Rothwell
2021-06-07  0:27 Stephen Rothwell
2020-12-17 23:12 Stephen Rothwell
2019-09-19 11:44 Mark Brown
2016-03-21  0:29 Stephen Rothwell
2013-08-13  1:33 Stephen Rothwell
2011-03-25  1:56 Stephen Rothwell
2011-03-25 14:45 ` Tejun Heo
2011-03-25 16:30   ` Sedat Dilek
2011-03-25 19:58   ` Ted Ts'o
2011-02-14  2:19 Stephen Rothwell
2010-10-28  0:45 Stephen Rothwell
2010-05-22  5:50 Stephen Rothwell
2009-09-17  1:56 linux-next: manual merge of the ext4 tree with Linus tree Stephen Rothwell
2009-09-17 13:22 ` Theodore Tso
2009-09-17 13:30   ` Stephen Rothwell
2009-02-02  2:56 linux-next: manual merge of the ext4 tree with Linus' tree Stephen Rothwell

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=20201021100358.1ef28ca2@canb.auug.org.au \
    --to=sfr@canb.auug.org.au \
    --cc=ebiggers@google.com \
    --cc=harshadshirwadkar@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-next@vger.kernel.org \
    --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).