Skip to contentSkip to conversation

DAX: use proper length when the range is not aligned to PAGE_SIZE

PATCH In review Liu Bo 2 participants 3 messages Nov 4, 2016

Subsystems (2)
lore
Share & tools
lore

Liu Bo

author
#0 lore raw

PATCH 1/1 DAX: use proper length when the range is not aligned to PAGE_SIZE

Currently if we write to [2k, 6k] where pos is 2k and end is 6k, get_block() will be called twice, but we can save one get_block by sending two blocks together to get_block.

---
 fs/dax.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
fs/dax.c +1 -1
index 53eb6a0..8d4bd5f 100644
@@ -172,7 +172,7 @@ static ssize_t dax_io(struct inode *inode, struct iov_iter *iter,
 			long size;
 
 			if (pos == bh_max) {
-				bh->b_size = PAGE_ALIGN(end - pos);
+				bh->b_size = PAGE_ALIGN(end - (pos - first));
 				bh->b_state = 0;
 				rc = get_block(inode, block, bh, rw == WRITE);
 				if (rc)
Signature · 1 line
2.5.5
reviewer
#1 lore raw
Quoted 5 lines · Liu Bo

Currently if we write to [2k, 6k] where pos is 2k and end is 6k, get_block() will be called twice, but we can save one get_block by sending two blocks together to get_block.

Thanks for the patch but this code is going to be ripped out soon (in the next merge window) in favor of iomap DAX implementation. So there's not much point in fixing this...

Honza

Quoted 20 lines
---
 fs/dax.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
fs/dax.c +1 -1
index 53eb6a0..8d4bd5f 100644
@@ -172,7 +172,7 @@ static ssize_t dax_io(struct inode *inode, struct iov_iter *iter,
 			long size;
 
 			if (pos == bh_max) {
-				bh->b_size = PAGE_ALIGN(end - pos);
+				bh->b_size = PAGE_ALIGN(end - (pos - first));
 				bh->b_state = 0;
 				rc = get_block(inode, block, bh, rw == WRITE);
 				if (rc)
Signature · 1 line
2.5.5
Signature · 2 lines
Jan Kara <[email protected]>
SUSE Labs, CR
author
#2 lore raw
Quoted 10 lines · Jan Kara
Quoted 5 lines · Liu Bo

Currently if we write to [2k, 6k] where pos is 2k and end is 6k, get_block() will be called twice, but we can save one get_block by sending two blocks together to get_block.

Thanks for the patch but this code is going to be ripped out soon (in the next merge window) in favor of iomap DAX implementation. So there's not much point in fixing this...

I see, thanks for the explanation.

Thanks,

-liubo

Quoted 26 lines

Honza

Quoted 20 lines
---
 fs/dax.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
fs/dax.c +1 -1
index 53eb6a0..8d4bd5f 100644
@@ -172,7 +172,7 @@ static ssize_t dax_io(struct inode *inode, struct iov_iter *iter,
 			long size;
 
 			if (pos == bh_max) {
-				bh->b_size = PAGE_ALIGN(end - pos);
+				bh->b_size = PAGE_ALIGN(end - (pos - first));
 				bh->b_state = 0;
 				rc = get_block(inode, block, bh, rw == WRITE);
 				if (rc)
Signature · 1 line
2.5.5
Signature · 2 lines
Jan Kara <[email protected]>
SUSE Labs, CR