linux-ext4.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jan Kara <jack@suse.cz>
To: Ted Tso <tytso@mit.edu>
Cc: linux-ext4@vger.kernel.org, Dave Chinner <david@fromorbit.com>,
	Jan Kara <jack@suse.cz>
Subject: [PATCH 10/11] ext4: Remove (almost) unused variables from ext4_expand_extra_isize_ea()
Date: Wed,  3 Aug 2016 12:39:54 +0200	[thread overview]
Message-ID: <1470220795-17045-11-git-send-email-jack@suse.cz> (raw)
In-Reply-To: <1470220795-17045-1-git-send-email-jack@suse.cz>

'start' variable is completely unused in ext4_expand_extra_isize_ea().
Variable 'first' is used only once in one place. So just remove them.
Variables 'entry' and 'last' are only really used later in the function
inside a loop. Move their declarations there.

Signed-off-by: Jan Kara <jack@suse.cz>
---
 fs/ext4/xattr.c | 20 ++++++++------------
 1 file changed, 8 insertions(+), 12 deletions(-)

diff --git a/fs/ext4/xattr.c b/fs/ext4/xattr.c
index 8f582ae1032d..2ef687620205 100644
--- a/fs/ext4/xattr.c
+++ b/fs/ext4/xattr.c
@@ -1425,12 +1425,11 @@ int ext4_expand_extra_isize_ea(struct inode *inode, int new_extra_isize,
 			       struct ext4_inode *raw_inode, handle_t *handle)
 {
 	struct ext4_xattr_ibody_header *header;
-	struct ext4_xattr_entry *entry, *last, *first;
 	struct buffer_head *bh = NULL;
 	size_t min_offs;
 	size_t ifree, bfree;
 	int total_ino;
-	void *base, *start, *end;
+	void *base, *end;
 	int error = 0, tried_min_extra_isize = 0;
 	int s_min_extra_isize = le16_to_cpu(EXT4_SB(inode->i_sb)->s_es->s_min_extra_isize);
 	int isize_diff;	/* How much do we need to grow i_extra_isize */
@@ -1446,24 +1445,22 @@ retry:
 		goto out;
 
 	header = IHDR(inode, raw_inode);
-	entry = IFIRST(header);
 
 	/*
 	 * Check if enough free space is available in the inode to shift the
 	 * entries ahead by new_extra_isize.
 	 */
 
-	base = start = entry;
+	base = IFIRST(header);
 	end = (void *)raw_inode + EXT4_SB(inode->i_sb)->s_inode_size;
 	min_offs = end - base;
-	last = entry;
 	total_ino = sizeof(struct ext4_xattr_ibody_header);
 
 	error = xattr_check_inode(inode, header, end);
 	if (error)
 		goto cleanup;
 
-	ifree = ext4_xattr_free_space(last, &min_offs, base, &total_ino);
+	ifree = ext4_xattr_free_space(base, &min_offs, base, &total_ino);
 	if (ifree >= isize_diff)
 		goto shift;
 
@@ -1483,10 +1480,10 @@ retry:
 			goto cleanup;
 		}
 		base = BHDR(bh);
-		first = BFIRST(bh);
 		end = bh->b_data + bh->b_size;
 		min_offs = end - base;
-		bfree = ext4_xattr_free_space(first, &min_offs, base, NULL);
+		bfree = ext4_xattr_free_space(BFIRST(bh), &min_offs, base,
+					      NULL);
 		if (bfree + ifree < isize_diff) {
 			if (!tried_min_extra_isize && s_min_extra_isize) {
 				tried_min_extra_isize++;
@@ -1502,14 +1499,14 @@ retry:
 	}
 
 	while (isize_diff > ifree) {
-		struct ext4_xattr_entry *small_entry = NULL;
+		struct ext4_xattr_entry *small_entry = NULL, *entry = NULL;
+		struct ext4_xattr_entry *last;
 		unsigned int entry_size;	/* EA entry size */
 		unsigned int total_size;	/* EA entry size + value size */
 		unsigned int min_total_size = ~0U;
 
 		last = IFIRST(header);
 		/* Find the entry best suited to be pushed into EA block */
-		entry = NULL;
 		for (; !IS_LAST_ENTRY(last); last = EXT4_XATTR_NEXT(last)) {
 			total_size =
 			EXT4_XATTR_SIZE(le32_to_cpu(last->e_value_size)) +
@@ -1556,8 +1553,7 @@ retry:
 
 shift:
 	/* Adjust the offsets and shift the remaining entries ahead */
-	entry = IFIRST(header);
-	ext4_xattr_shift_entries(entry,	EXT4_I(inode)->i_extra_isize
+	ext4_xattr_shift_entries(IFIRST(header), EXT4_I(inode)->i_extra_isize
 			- new_extra_isize, (void *)raw_inode +
 			EXT4_GOOD_OLD_INODE_SIZE + new_extra_isize,
 			(void *)header, total_ino);
-- 
2.6.6


  parent reply	other threads:[~2016-08-03 10:41 UTC|newest]

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-08-03 10:39 [PATCH 0/11] ext4: Fix inode expansion code Jan Kara
2016-08-03 10:39 ` [PATCH 01/11] ext4: Fix xattr shifting when expanding inodes Jan Kara
2016-08-03 23:25   ` Andreas Dilger
2016-08-04  8:43     ` Jan Kara
2016-08-11 17:32   ` Theodore Ts'o
2016-08-03 10:39 ` [PATCH 02/11] ext4: Fix xattr shifting when expanding inodes (2) Jan Kara
2016-08-11 17:32   ` Theodore Ts'o
2016-08-03 10:39 ` [PATCH 03/11] ext4: Properly align shifted xattrs when expanding inodes Jan Kara
2016-08-11 17:32   ` Theodore Ts'o
2016-08-03 10:39 ` [PATCH 04/11] ext4: Avoid deadlock when expanding inode size Jan Kara
2016-08-11 17:32   ` Theodore Ts'o
2016-08-03 10:39 ` [PATCH 05/11] ext4: Fixup free space calculations when expanding inodes Jan Kara
2016-08-11 17:33   ` Theodore Ts'o
2016-08-03 10:39 ` [PATCH 06/11] ext4: Check that external xattr value block is 0 Jan Kara
2016-08-11 17:33   ` Theodore Ts'o
2016-08-03 10:39 ` [PATCH 07/11] ext4: Remove checks for e_value_block Jan Kara
2016-08-11 17:33   ` Theodore Ts'o
2016-08-03 10:39 ` [PATCH 08/11] ext4: Replace bogus assertion in ext4_xattr_shift_entries() Jan Kara
2016-08-11 17:33   ` Theodore Ts'o
2016-08-03 10:39 ` [PATCH 09/11] ext4: Factor out xattr moving Jan Kara
2016-08-11 17:33   ` Theodore Ts'o
2016-08-03 10:39 ` Jan Kara [this message]
2016-08-11 17:34   ` [PATCH 10/11] ext4: Remove (almost) unused variables from ext4_expand_extra_isize_ea() Theodore Ts'o
2016-08-03 10:39 ` [PATCH 11/11] ext4: Factor out loop for freeing inode xattr space Jan Kara
2016-08-11 17:34   ` Theodore Ts'o

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=1470220795-17045-11-git-send-email-jack@suse.cz \
    --to=jack@suse.cz \
    --cc=david@fromorbit.com \
    --cc=linux-ext4@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).