dm-log: unify rw_header to read/write_header
RFC PATCH 2/4 dm-log: unify rw_header to read/write_header
rw_header function updates three members of io_req data every time when I/O is processed. bi_rw and notify.fn are never modified once they get initialized, and also they can be set in advance. This patch removes unnecessary update operations.
--- drivers/md/dm-log.c | 23 +++++++++++------------ 1 file changed, 11 insertions(+), 12 deletions(-)
drivers/md/dm-log.c +11 -12
@@ -323,20 +323,13 @@ static void header_from_disk(struct log_ core->nr_regions =le64_to_cpu (disk->nr_regions); } -static int rw_header (struct log_c *lc,int rw) -{ - lc->io_req.bi_rw = rw; - lc->io_req.mem.ptr.vma = lc->disk_header; - lc->io_req.notify.fn =NULL ; - -return dm_io (&lc->io_req,1 , &lc->header_location,NULL ); -} -static int read_header (struct log_c *log) {int r; - r =rw_header (log,READ ); + log->io_req.bi_rw =READ ; + + r =dm_io (&log->io_req,1 , &log->header_location,NULL );if (r)return r;
@@ -364,8 +357,8 @@ static int read_header(struct log_c *logstatic inline int write_header (struct log_c *log) { -header_to_disk (&log->header, log->disk_header); -return rw_header (log,WRITE ); + log->io_req.bi_rw =WRITE ; +return dm_io (&log->io_req,1 , &log->header_location,NULL ); }/*----------------------------------------------------------------
@@ -454,7 +447,10 @@ static int create_log_context(struct dm_ buf_size =dm_round_up ((LOG_OFFSET <<SECTOR_SHIFT ) + bitset_size, ti->limits.hardsect_size); lc->header_location.count = buf_size >>SECTOR_SHIFT ; + lc->io_req.mem.type =DM_IO_VMA ; + lc->io_req.mem.ptr.vma = lc->disk_header; + lc->io_req.notify.fn =NULL ; lc->io_req.client =dm_io_client_create (dm_div_up (buf_size,PAGE_SIZE ));if (IS_ERR (lc->io_req.client)) {
@@ -636,6 +632,9 @@ static int disk_resume(struct dm_dirty_l/* set the correct number of regions in the header */ lc->header.nr_regions = lc->region_count; +/* update disk headers */ +header_to_disk (&lc->header, lc->disk_header); +/* write the new header */ r =write_header (lc);if (r) {
Alasdair G Kergon
maintainerQuoted 4 lines · Takahiro Yasui
rw_headerfunction updates three members ofio_reqdata every time when I/O is processed.bi_rwand notify.fn are never modified once they get initialized, and also they can be set in advance. This patch removes unnecessary update operations.
Indeed.
And it also removes header_to_disk() from the disk_flush() code path but doesn't mention changing that:-) I assume that's also OK because there'll always have been a resume before the flush and the data can only change during a resume?
drivers/md/dm-log.c static void header_from_disk(struct log_ · line 324
Quoted 4 lines
+++
linux-2.6.28-rc4/drivers/md/dm-log.cdrivers/md/dm-log.c +0
-1@@ -323,20 +323,13 @@ static void header_from_disk(struct log_ -static int rw_header (struct log_c *lc,int rw)
I reckon that little function improves readability/maintainability and I've left it in.
http://www.kernel.org/pub/linux/kernel/people/agk/patches/2.6/editing/
dm-log-avoid-reinitialising-io_req-on-every-operation.patch
Alasdair
Signature · 1 line
[email protected]
Quoted 6 lines · Alasdair G Kergon
Quoted 4 lines · Takahiro Yasui
rw_headerfunction updates three members ofio_reqdata every time when I/O is processed.bi_rwand notify.fn are never modified once they get initialized, and also they can be set in advance. This patch removes unnecessary update operations.
Quoted 6 lines
Indeed.
And it also removes
header_to_disk()from thedisk_flush()code path but doesn't mention changing that:-) I assume that's also OK because there'll always have been a resume before the flush and the data can only change during a resume?
Oh, I'm sorry not to mention it on the patch description, but your explanation is exactly what I need to do.
Quoted 10 lines
drivers/md/dm-log.c static void header_from_disk(struct log_ · line 324
Quoted 4 lines
+++
linux-2.6.28-rc4/drivers/md/dm-log.cdrivers/md/dm-log.c +0
-1@@ -323,20 +323,13 @@ static void header_from_disk(struct log_ -static int rw_header (struct log_c *lc,int rw)I reckon that little function improves readability/maintainability and I've left it in.
http://www.kernel.org/pub/linux/kernel/people/agk/patches/2.6/editing/
dm-log-avoid-reinitialising-io_req-on-every-operation.patch
Thanks, Alasdair. I have removed rw_header function in my patch since the last two patches don't use it, but your improvement is fine as a separate patch.
Thanks,
---
Takahiro Yasui
Hitachi Computer Products (America) Inc.