Skip to contentSkip to conversation

Use negative error code

PATCH In review Lukas Czerner 2 participants 4 messages Sep 10, 2010 – Sep 20, 2010 ext4 file system

lore
Share & tools
lore
#0 lore raw

PATCH 1/2 Use negative error code

sb_issue_discard() is returning negative error code, so check for -EOPNOTSUPP.

---
 fs/ext4/mballoc.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
fs/ext4/mballoc.c +1 -1
index 4b4ad4b..ec2793a 100644
@@ -2567,7 +2567,7 @@ static inline void ext4_issue_discard(struct super_block *sb,
 	trace_ext4_discard_blocks(sb,
 			(unsigned long long) discard_block, count);
 	ret = sb_issue_discard(sb, discard_block, count);
-	if (ret == EOPNOTSUPP) {
+	if (ret == -EOPNOTSUPP) {
 		ext4_warning(sb, "discard not supported, disabling");
 		clear_opt(EXT4_SB(sb)->s_mount_opt, DISCARD);
 	}
Signature · 1 line
1.7.2.2
#1 lore raw

PATCH 2/2 Don't hold spinlock while calling ext4_issue_discard()

We can't hold spinlock because we can get rescheduled.

---
 fs/ext4/mballoc.c |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)
fs/ext4/mballoc.c +2 -2
index ec2793a..c214cfc 100644
@@ -4640,12 +4640,12 @@ do_more:
 		 * with group lock held. generate_buddy look at
 		 * them with group lock_held
 		 */
+		if (test_opt(sb, DISCARD))
+			ext4_issue_discard(sb, block_group, bit, count);
 		ext4_lock_group(sb, block_group);
 		mb_clear_bits(bitmap_bh->b_data, bit, count);
 		mb_free_blocks(inode, &e4b, bit, count);
 		ext4_mb_return_to_preallocation(inode, &e4b, block, count);
-		if (test_opt(sb, DISCARD))
-			ext4_issue_discard(sb, block_group, bit, count);
 	}
 
 	ret = ext4_free_blks_count(sb, gdp) + count;
Signature · 1 line
1.7.2.2
maintainer
#2 lore raw

Re: [PATCH 2/2] Don't hold spinlock while calling ext4_issue_discard()

Quoted 3 lines · Lukas Czerner

We can't hold spinlock because we can get rescheduled.

Thanks, added to the ext4 patch queue. For both patches I adjusted the patch summary to be a bit more descriptive:

0dc23a4 ext4: don't hold spinlock while calling ext4_issue_discard() 9c54307 ext4: Check for negative error code from sb_issue_discard

It makes it easier to figure out which patches are which when you use "git log --oneline".

- Ted