* [RFC][PATCH 2/4] dm-log: unify rw_header to read/write_header
@ 2008-11-26 0:01 Takahiro Yasui
2008-11-28 23:37 ` Alasdair G Kergon
0 siblings, 1 reply; 3+ messages in thread
From: Takahiro Yasui @ 2008-11-26 0:01 UTC (permalink / raw)
To: dm-devel; +Cc: Alasdair G Kergon, Masami Hiramatsu
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.
Signed-off-by: Takahiro Yasui <tyasui@redhat.com>
---
drivers/md/dm-log.c | 23 +++++++++++------------
1 file changed, 11 insertions(+), 12 deletions(-)
Index: linux-2.6.28-rc4/drivers/md/dm-log.c
===================================================================
--- linux-2.6.28-rc4.orig/drivers/md/dm-log.c
+++ linux-2.6.28-rc4/drivers/md/dm-log.c
@@ -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 *log
static 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) {
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [RFC][PATCH 2/4] dm-log: unify rw_header to read/write_header
2008-11-26 0:01 [RFC][PATCH 2/4] dm-log: unify rw_header to read/write_header Takahiro Yasui
@ 2008-11-28 23:37 ` Alasdair G Kergon
2008-12-01 7:24 ` Takahiro Yasui
0 siblings, 1 reply; 3+ messages in thread
From: Alasdair G Kergon @ 2008-11-28 23:37 UTC (permalink / raw)
To: Takahiro Yasui; +Cc: dm-devel, Masami Hiramatsu
On Tue, Nov 25, 2008 at 07:01:39PM -0500, Takahiro Yasui wrote:
> 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.
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?
> +++ linux-2.6.28-rc4/drivers/md/dm-log.c
> @@ -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
--
agk@redhat.com
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [RFC][PATCH 2/4] dm-log: unify rw_header to read/write_header
2008-11-28 23:37 ` Alasdair G Kergon
@ 2008-12-01 7:24 ` Takahiro Yasui
0 siblings, 0 replies; 3+ messages in thread
From: Takahiro Yasui @ 2008-12-01 7:24 UTC (permalink / raw)
To: Alasdair G Kergon; +Cc: dm-devel
Alasdair G Kergon wrote:
> On Tue, Nov 25, 2008 at 07:01:39PM -0500, Takahiro Yasui wrote:
>> 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.
>
> 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?
Oh, I'm sorry not to mention it on the patch description, but
your explanation is exactly what I need to do.
>> +++ linux-2.6.28-rc4/drivers/md/dm-log.c
>> @@ -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.
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2008-12-01 7:24 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-11-26 0:01 [RFC][PATCH 2/4] dm-log: unify rw_header to read/write_header Takahiro Yasui
2008-11-28 23:37 ` Alasdair G Kergon
2008-12-01 7:24 ` Takahiro Yasui
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.