Skip to contentSkip to conversation

fs/buffer.c: call __block_write_begin() if we have page

PATCH New Namhyung Kim 2 participants 5 messages Oct 23, 2010 – Oct 26, 2010 VFS

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 fs/buffer.c: call __block_write_begin() if we have page

If we have the appropriate page already, call __block_write_begin() directly instead of releasing and regrabbing it inside of block_write_begin().

---
 fs/buffer.c |    9 ++++-----
 1 files changed, 4 insertions(+), 5 deletions(-)
fs/buffer.c +4 -5
index 7f0b9b0..d4b3ada 100644
@@ -2466,11 +2466,10 @@ int nobh_write_begin(struct address_space *mapping,
 	*fsdata = NULL;
 
 	if (page_has_buffers(page)) {
-		unlock_page(page);
-		page_cache_release(page);
-		*pagep = NULL;
-		return block_write_begin(mapping, pos, len, flags, pagep,
-					 get_block);
+		ret = __block_write_begin(page, pos, len, get_block);
+		if (unlikely(ret))
+			*pagep = NULL;
+		return ret;
 	}
 
 	if (PageMappedToDisk(page))
Signature · 1 line
1.7.0.4
#1 lore raw

PATCH 1/1 fs/buffer.c: call __block_write_begin() if we have page

If we have the appropriate page already, call __block_write_begin() directly instead of releasing and regrabbing it inside of block_write_begin().

---
Fix error path.

 fs/buffer.c |   12 +++++++-----
 1 files changed, 7 insertions(+), 5 deletions(-)
fs/buffer.c +7 -5
index 7f0b9b0..f5755f7 100644
@@ -2466,11 +2466,13 @@ int nobh_write_begin(struct address_space *mapping,
 	*fsdata = NULL;
 
 	if (page_has_buffers(page)) {
-		unlock_page(page);
-		page_cache_release(page);
-		*pagep = NULL;
-		return block_write_begin(mapping, pos, len, flags, pagep,
-					 get_block);
+		ret = __block_write_begin(page, pos, len, get_block);
+		if (unlikely(ret)) {
+			unlock_page(page);
+			page_cache_release(page);
+			*pagep = NULL;
+		}
+		return ret;
 	}
 
 	if (PageMappedToDisk(page))
Signature · 1 line
1.7.0.4
#2 lore raw

PATCH RESEND 1/1 fs/buffer.c: call __block_write_begin() if we have page

If we have the appropriate page already, call __block_write_begin() directly instead of releasing and regrabbing it inside of block_write_begin().

---
Shared error path.

 fs/buffer.c |    9 ++++-----
 1 files changed, 4 insertions(+), 5 deletions(-)
fs/buffer.c +4 -5
index 7f0b9b0..a132c2b 100644
@@ -2466,11 +2466,10 @@ int nobh_write_begin(struct address_space *mapping,
 	*fsdata = NULL;
 
 	if (page_has_buffers(page)) {
-		unlock_page(page);
-		page_cache_release(page);
-		*pagep = NULL;
-		return block_write_begin(mapping, pos, len, flags, pagep,
-					 get_block);
+		ret = __block_write_begin(page, pos, len, get_block);
+		if (unlikely(ret))
+			goto out_release;
+		return ret;
 	}
 
 	if (PageMappedToDisk(page))
Signature · 1 line
1.7.0.4
#3 lore raw
In reply to Namhyung Kim
Quoted 24 lines · On Sun, 24 Oct 2010 01:11:54 +0900 Namhyung Kim <[email protected]> wrote:

If we have the appropriate page already, call __block_write_begin() directly instead of releasing and regrabbing it inside of block_write_begin().

---
Fix error path.

 fs/buffer.c |   12 +++++++-----
 1 files changed, 7 insertions(+), 5 deletions(-)
fs/buffer.c +0 -5
index 7f0b9b0..f5755f7 100644
@@ -2466,11 +2466,13 @@ int nobh_write_begin(struct address_space *mapping,
 	*fsdata = NULL;
 
 	if (page_has_buffers(page)) {
-		unlock_page(page);
-		page_cache_release(page);
-		*pagep = NULL;
-		return block_write_begin(mapping, pos, len, flags, pagep,
-					 get_block);

fs/buffer.c int nobh_write_begin(struct address_space *mapping, · line 2478

Quoted 10 lines
fs/buffer.c +7 -0
+		ret = __block_write_begin(page, pos, len, get_block);
+		if (unlikely(ret)) {
+			unlock_page(page);
+			page_cache_release(page);
+			*pagep = NULL;
+		}
+		return ret;
 	}
 
 	if (PageMappedToDisk(page))

It looks OK. Was it tested? (ext2 mounted with -o nobh)

#4 lore raw

2010-10-25 (월), 16:11 -0700, Andrew Morton:

Quoted 36 lines
Quoted 33 lines · On Sun, 24 Oct 2010 01:11:54 +0900 Namhyung Kim <[email protected]> wrote:

If we have the appropriate page already, call __block_write_begin() directly instead of releasing and regrabbing it inside of block_write_begin().

---
Fix error path.

 fs/buffer.c |   12 +++++++-----
 1 files changed, 7 insertions(+), 5 deletions(-)
fs/buffer.c +7 -5
index 7f0b9b0..f5755f7 100644
@@ -2466,11 +2466,13 @@ int nobh_write_begin(struct address_space *mapping,
 	*fsdata = NULL;
 
 	if (page_has_buffers(page)) {
-		unlock_page(page);
-		page_cache_release(page);
-		*pagep = NULL;
-		return block_write_begin(mapping, pos, len, flags, pagep,
-					 get_block);
+		ret = __block_write_begin(page, pos, len, get_block);
+		if (unlikely(ret)) {
+			unlock_page(page);
+			page_cache_release(page);
+			*pagep = NULL;
+		}
+		return ret;
 	}
 
Quoted 3 lines

fs/buffer.c int nobh_write_begin(struct address_space *mapping, · line 2478

Quoted 1 line
fs/buffer.c +0 -0
 	if (PageMappedToDisk(page))

It looks OK. Was it tested? (ext2 mounted with -o nobh)

I just did tar && untar with current kernel source several times on UML. It worked find for me. Thanks.

Signature · 8 lines
Regards,
Namhyung Kim


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