Skip to contentSkip to conversation

ext4: remove unused variable in ext4_free_blocks()

PATCH Applied Lukas Czerner 2 participants 8 messages Mar 8, 2013 – Mar 11, 2013 ext4 file system

lore
Share & tools
lore
#0 lore raw

PATCH 1/3 ext4: remove unused variable in ext4_free_blocks()

Remove unused variable 'freed' in ext4_free_blocks().

---
 fs/ext4/mballoc.c |    3 ---
 1 files changed, 0 insertions(+), 3 deletions(-)
fs/ext4/mballoc.c +0 -2
index 6540ebe..0a493a1 100644
@@ -4464,7 +4464,6 @@ void ext4_free_blocks(handle_t *handle, struct inode *inode,
 	struct buffer_head *bitmap_bh = NULL;
 	struct super_block *sb = inode->i_sb;
 	struct ext4_group_desc *gdp;
-	unsigned long freed = 0;
 	unsigned int overflow;
 	ext4_grpblk_t bit;
 	struct buffer_head *gd_bh;
@@ -4672,8 +4671,6 @@ do_more:
 
 	ext4_mb_unload_buddy(&e4b);
 
-	freed += count;
#1 lore raw

PATCH 2/3 ext4: Use kstrtoul() instead of deprecated simple_strtoul()

In parse_strtoul() we're still using deprecated simple_strtoul(). Change that in favour of kstrtoul().

---
 fs/ext4/super.c |   12 +++++-------
 1 files changed, 5 insertions(+), 7 deletions(-)
fs/ext4/super.c +0 -1
index 620cf56..7bcdef1 100644
@@ -2359,14 +2359,12 @@ struct ext4_attr {
 static int parse_strtoul(const char *buf,
 		unsigned long max, unsigned long *value)
 {
-	char *endp;
maintainer
#2 lore raw

Re: [PATCH 2/3] ext4: Use kstrtoul() instead of deprecated simple_strtoul()

Quoted 4 lines · Lukas Czerner

In parse_strtoul() we're still using deprecated simple_strtoul(). Change that in favour of kstrtoul().

Once you make this change, wouldn't it be better and even more simplifying to replace the two places where we call parse_strtoul() with kstrtoul()?

- Ted

#3 lore raw

Re: [PATCH 2/3] ext4: Use kstrtoul() instead of deprecated simple_strtoul()

Quoted 11 lines · Theodore Ts'o

Date: Sun, 10 Mar 2013 22:26:35 -0400
From: Theodore Ts'o <[email protected]>
To: Lukas Czerner <[email protected]>
Cc: [email protected]
Subject: Re: [PATCH 2/3] ext4: Use kstrtoul() instead of deprecated
simple_strtoul()

Quoted 3 lines · Lukas Czerner

In parse_strtoul() we're still using deprecated simple_strtoul(). Change that in favour of kstrtoul().

Quoted 7 lines
Quoted 1 line

Once you make this change, wouldn't it be better and even more simplifying to replace the two places where we call parse_strtoul() with kstrtoul()?

- Ted

I think that parse_strtoul() is still useful to have because we check the "max" value as well and return -EINVAL if it is exceeded. Removing it we would have to add the check to the callers where we're using is now, which seems unnecessary, especially since we might expect more users of the helper.

-Lukas

maintainer
#4 lore raw

Re: [PATCH 2/3] ext4: Use kstrtoul() instead of deprecated simple_strtoul()

Quoted 5 lines · Lukáš Czerner

I think that parse_strtoul() is still useful to have because we check the "max" value as well and return -EINVAL if it is exceeded. Removing it we would have to add the check to the callers where we're using is now, which seems unnecessary, especially since we might expect more users of the helper.

Well, at the moment only one of the two users of parse_strtoul() is using the "max" value check feature. I see one other potential user of parse_strtoul (there's one use of simple_strtoul in get_sb_block() which wasn't converted in your patch), but it wouldn't need the max value check feature either.

So I don't have a super strong feeling about this, since this isn't performance critical code, and it's probably not going to cost a large amount of object code or stack space, but sometimes extra levels of abstraction end up hurting more than they help.

Regards,

- Ted
--
To unsubscribe from this list: send the line "unsubscribe linux-ext4" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

#5 lore raw

PATCH 3/3 ext4: Do no use yield() in ext4 code

In reply to Lukas Czerner

Using yield() is strongly discouraged (see sched/core.c) especially since we can just use cond_resched().

Replace all use of yield() with cond_resched().

---
 fs/ext4/inode.c   |    2 +-
 fs/ext4/mballoc.c |    8 ++------
 2 files changed, 3 insertions(+), 7 deletions(-)
fs/ext4/inode.c +1 -1
index 9ea0cde..ab28090 100644
@@ -1263,7 +1263,7 @@ repeat:
 		ei->i_da_metadata_calc_last_lblock = save_last_lblock;
 		spin_unlock(&ei->i_block_reservation_lock);
 		if (ext4_should_retry_alloc(inode->i_sb, &retries)) {
-			yield();
+			cond_resched();
 			goto repeat;
 		}
 		dquot_release_reservation_block(inode, EXT4_C2B(sbi, 1));
fs/ext4/mballoc.c +2 -6
index 0a493a1..d2ec0d8 100644
@@ -3692,11 +3692,7 @@ repeat:
 	if (free < needed && busy) {
 		busy = 0;
 		ext4_unlock_group(sb, group);
-		/*
-		 * Yield the CPU here so that we don't get soft lockup
-		 * in non preempt case.
-		 */
-		yield();
+		cond_resched();
 		goto repeat;
 	}
 
@@ -4246,7 +4242,7 @@ ext4_fsblk_t ext4_mb_new_blocks(handle_t *handle,
 			ext4_claim_free_clusters(sbi, ar->len, ar->flags)) {
 
 			/* let others to free the space */
-			yield();
+			cond_resched();
 			ar->len = ar->len >> 1;
 		}
 		if (!ar->len) {
Signature · 1 line
1.7.7.6
maintainer Applied
#6 lore raw

Re: [PATCH 3/3] ext4: Do no use yield() in ext4 code

Quoted 6 lines · Lukas Czerner

Using yield() is strongly discouraged (see sched/core.c) especially since we can just use cond_resched().

Replace all use of yield() with cond_resched().

Thanks, applied.

- Ted