Skip to contentSkip to conversation

raid5: For write performance, remove REQ_SYNC when write was odirect.

PATCH In review majianpeng 2 participants 8 messages Jul 16, 2012

Subsystems (2)
lore
Share & tools
lore

majianpeng

author
#0 lore raw

PATCH 2/2 raid5: For write performance, remove REQ_SYNC when write was odirect.

In commit e9c7469bb4f502dafc092166201bea1ad5fc0fbf:
Tejun Heo introduced "implment REQ_FLUSH/FUA support".
But for direct-write-blocks, it maybe for other purpose which like the regular file.
And this flag will set STRIPE_PREREAD_ACTIVE which decreaed the change to full write.

But this patch remove REQ_SYNC only judging the WRITE_ODIRECT,it will contail regular file.So it maybe not correctly.
How can difference odriect_write between regular file or block file?

---
 drivers/md/raid5.c |    3 +++
 1 files changed, 3 insertions(+), 0 deletions(-)
drivers/md/raid5.c +3 -0
index 04348d7..8d2d4d1 100644
@@ -4010,6 +4010,9 @@ static void make_request(struct mddev *mddev, struct bio * bi)
 	     chunk_aligned_read(mddev,bi))
 		return;
 
+	if (bi->bi_rw & WRITE_ODIRECT)
+		bi->bi_rw &= ~REQ_SYNC;
+
 	logical_sector = bi->bi_sector & ~((sector_t)STRIPE_SECTORS-1);
 	last_sector = bi->bi_sector + (bi->bi_size>>9);
 	bi->bi_next = NULL;
Signature · 1 line
1.7.5.4
#1 lore raw
Quoted 10 lines · On Mon, 16 Jul 2012 09:31:55 +0800 majianpeng <[email protected]> wrote:

In commit e9c7469bb4f502dafc092166201bea1ad5fc0fbf:
Tejun Heo introduced "implment REQ_FLUSH/FUA support".
But for direct-write-blocks, it maybe for other purpose which like the regular file.
And this flag will set STRIPE_PREREAD_ACTIVE which decreaed the change to full write.

But this patch remove REQ_SYNC only judging the WRITE_ODIRECT,it will contail regular file.So it maybe not correctly.
How can difference odriect_write between regular file or block file?

Hi,
I think you are saying the when REQ_SYNC is used with O_DIRECT writes it is having a negative effect on throughput because it allows the stripe to be processed immediately without waiting for more requests to be added to the stripe.

Normal 'sync' requests use WRITE_SYNC which includes "REQ_NOIDLE" which means
/* don't anticipate more IO after this one */
O_DIRECT request use WRITE_ODIRECT which does not include this flag.

So maybe we should simply change raid5 to only set STRIPE_PREREAD_ACTIVE if REQ_NOIDLE is set on the bio. I think this would have the same effect as what you are trying to achieve.

Could you please try that and see if it has the desired effect on performance?

Thanks,
NeilBrown

i.e. something like this:

drivers/md/raid5.c +1 -1
index d56d74d..2d72a57 100644
@@ -4178,7 +4178,7 @@ static void make_request(struct mddev *mddev, struct bio * bi)
 			finish_wait(&conf->wait_for_overlap, &w);
 			set_bit(STRIPE_HANDLE, &sh->state);
 			clear_bit(STRIPE_DELAYED, &sh->state);
-			if ((bi->bi_rw & REQ_SYNC) &&
+			if ((bi->bi_rw & REQ_NOIDLE) &&
 			    !test_and_set_bit(STRIPE_PREREAD_ACTIVE, &sh->state))
 				atomic_inc(&conf->preread_active_stripes);
 			release_stripe_plug(mddev, sh);
Quoted 20 lines
---
 drivers/md/raid5.c |    3 +++
 1 files changed, 3 insertions(+), 0 deletions(-)
drivers/md/raid5.c +3 -0
index 04348d7..8d2d4d1 100644
@@ -4010,6 +4010,9 @@ static void make_request(struct mddev *mddev, struct bio * bi)
 	     chunk_aligned_read(mddev,bi))
 		return;
 
+	if (bi->bi_rw & WRITE_ODIRECT)
+		bi->bi_rw &= ~REQ_SYNC;
+
 	logical_sector = bi->bi_sector & ~((sector_t)STRIPE_SECTORS-1);
 	last_sector = bi->bi_sector + (bi->bi_size>>9);
 	bi->bi_next = NULL;
author
#2 lore raw

On 2012-07-16 13:40 NeilBrown <[email protected]> Wrote:

Quoted 19 lines · On Mon, 16 Jul 2012 09:31:55 +0800 majianpeng <[email protected]> wrote:
Quoted 11 lines

In commit e9c7469bb4f502dafc092166201bea1ad5fc0fbf:
Tejun Heo introduced "implment REQ_FLUSH/FUA support".
But for direct-write-blocks, it maybe for other purpose which like the regular file.
And this flag will set STRIPE_PREREAD_ACTIVE which decreaed the change to full write.

But this patch remove REQ_SYNC only judging the WRITE_ODIRECT,it will contail regular file.So it maybe not correctly.
How can difference odriect_write between regular file or block file?

Hi,
I think you are saying the when REQ_SYNC is used with O_DIRECT writes it is having a negative effect on throughput because it allows the stripe to be processed immediately without waiting for more requests to be added to the stripe.

Quoted 8 lines

Normal 'sync' requests use WRITE_SYNC which includes "REQ_NOIDLE" which means
/* don't anticipate more IO after this one */
O_DIRECT request use WRITE_ODIRECT which does not include this flag.

So maybe we should simply change raid5 to only set STRIPE_PREREAD_ACTIVE if REQ_NOIDLE is set on the bio. I think this would have the same effect as what you are trying to achieve.

Yes, thanks. my object is to so.But i didn't notice the REQ_NOIDLE so i used the REQ_FLAG. I'll tested and resend the patch.

Quoted 45 lines

Could you please try that and see if it has the desired effect on performance?

Thanks,
NeilBrown

i.e. something like this:

drivers/md/raid5.c +1 -1
index d56d74d..2d72a57 100644
@@ -4178,7 +4178,7 @@ static void make_request(struct mddev *mddev, struct bio * bi)
 			finish_wait(&conf->wait_for_overlap, &w);
 			set_bit(STRIPE_HANDLE, &sh->state);
 			clear_bit(STRIPE_DELAYED, &sh->state);
-			if ((bi->bi_rw & REQ_SYNC) &&
+			if ((bi->bi_rw & REQ_NOIDLE) &&
 			    !test_and_set_bit(STRIPE_PREREAD_ACTIVE, &sh->state))
 				atomic_inc(&conf->preread_active_stripes);
 			release_stripe_plug(mddev, sh);
Quoted 22 lines
---
 drivers/md/raid5.c |    3 +++
 1 files changed, 3 insertions(+), 0 deletions(-)
drivers/md/raid5.c +3 -0
index 04348d7..8d2d4d1 100644
@@ -4010,6 +4010,9 @@ static void make_request(struct mddev *mddev, struct bio * bi)
 	     chunk_aligned_read(mddev,bi))
 		return;
 
+	if (bi->bi_rw & WRITE_ODIRECT)
+		bi->bi_rw &= ~REQ_SYNC;
+
 	logical_sector = bi->bi_sector & ~((sector_t)STRIPE_SECTORS-1);
 	last_sector = bi->bi_sector + (bi->bi_size>>9);
 	bi->bi_next = NULL;
author
#3 lore raw
In reply to NeilBrown

On 2012-07-16 13:40 NeilBrown <[email protected]> Wrote:

Quoted 19 lines · On Mon, 16 Jul 2012 09:31:55 +0800 majianpeng <[email protected]> wrote:
Quoted 11 lines

In commit e9c7469bb4f502dafc092166201bea1ad5fc0fbf:
Tejun Heo introduced "implment REQ_FLUSH/FUA support".
But for direct-write-blocks, it maybe for other purpose which like the regular file.
And this flag will set STRIPE_PREREAD_ACTIVE which decreaed the change to full write.

But this patch remove REQ_SYNC only judging the WRITE_ODIRECT,it will contail regular file.So it maybe not correctly.
How can difference odriect_write between regular file or block file?

Hi,
I think you are saying the when REQ_SYNC is used with O_DIRECT writes it is having a negative effect on throughput because it allows the stripe to be processed immediately without waiting for more requests to be added to the stripe.

Quoted 4 lines

Normal 'sync' requests use WRITE_SYNC which includes "REQ_NOIDLE" which means
/* don't anticipate more IO after this one */
O_DIRECT request use WRITE_ODIRECT which does not include this flag.

Using REQ_NOIDEL to difference odirect and sync.Why not using:
+ if (bi->bi_rw & WRITE_ODIRECT)
+ bi->bi_rw &= ~REQ_SYNC;

The flag WRITE_ODIRECT is only used in odirect-write.

Quoted 7 lines

So maybe we should simply change raid5 to only set STRIPE_PREREAD_ACTIVE if REQ_NOIDLE is set on the bio. I think this would have the same effect as what you are trying to achieve.

Could you please try that and see if it has the desired effect on performance?

I tested and the performance is the same.

Quoted 42 lines

Thanks,
NeilBrown

i.e. something like this:

drivers/md/raid5.c +1 -1
index d56d74d..2d72a57 100644
@@ -4178,7 +4178,7 @@ static void make_request(struct mddev *mddev, struct bio * bi)
 			finish_wait(&conf->wait_for_overlap, &w);
 			set_bit(STRIPE_HANDLE, &sh->state);
 			clear_bit(STRIPE_DELAYED, &sh->state);
-			if ((bi->bi_rw & REQ_SYNC) &&
+			if ((bi->bi_rw & REQ_NOIDLE) &&
 			    !test_and_set_bit(STRIPE_PREREAD_ACTIVE, &sh->state))
 				atomic_inc(&conf->preread_active_stripes);
 			release_stripe_plug(mddev, sh);
Quoted 22 lines
---
 drivers/md/raid5.c |    3 +++
 1 files changed, 3 insertions(+), 0 deletions(-)
drivers/md/raid5.c +3 -0
index 04348d7..8d2d4d1 100644
@@ -4010,6 +4010,9 @@ static void make_request(struct mddev *mddev, struct bio * bi)
 	     chunk_aligned_read(mddev,bi))
 		return;
 
+	if (bi->bi_rw & WRITE_ODIRECT)
+		bi->bi_rw &= ~REQ_SYNC;
+
 	logical_sector = bi->bi_sector & ~((sector_t)STRIPE_SECTORS-1);
 	last_sector = bi->bi_sector + (bi->bi_size>>9);
 	bi->bi_next = NULL;
#4 lore raw
Quoted 20 lines · On Mon, 16 Jul 2012 14:42:54 +0800 majianpeng <[email protected]> wrote:

On 2012-07-16 13:40 NeilBrown <[email protected]> Wrote:

Quoted 19 lines · On Mon, 16 Jul 2012 09:31:55 +0800 majianpeng <[email protected]> wrote:
Quoted 11 lines

In commit e9c7469bb4f502dafc092166201bea1ad5fc0fbf:
Tejun Heo introduced "implment REQ_FLUSH/FUA support".
But for direct-write-blocks, it maybe for other purpose which like the regular file.
And this flag will set STRIPE_PREREAD_ACTIVE which decreaed the change to full write.

But this patch remove REQ_SYNC only judging the WRITE_ODIRECT,it will contail regular file.So it maybe not correctly.
How can difference odriect_write between regular file or block file?

Hi,
I think you are saying the when REQ_SYNC is used with O_DIRECT writes it is having a negative effect on throughput because it allows the stripe to be processed immediately without waiting for more requests to be added to the stripe.

Quoted 8 lines
Quoted 4 lines

Normal 'sync' requests use WRITE_SYNC which includes "REQ_NOIDLE" which means
/* don't anticipate more IO after this one */
O_DIRECT request use WRITE_ODIRECT which does not include this flag.

Using REQ_NOIDEL to difference odirect and sync.Why not using:
+ if (bi->bi_rw & WRITE_ODIRECT)
+ bi->bi_rw &= ~REQ_SYNC;

Because that code is wrong. WRITE_ODIRECT is not one flag, it is two flags 'or'ed together. So this code does not do what you expect.

Quoted 11 lines

The flag WRITE_ODIRECT is only used in odirect-write.

Quoted 7 lines

So maybe we should simply change raid5 to only set STRIPE_PREREAD_ACTIVE if REQ_NOIDLE is set on the bio. I think this would have the same effect as what you are trying to achieve.

Could you please try that and see if it has the desired effect on performance?

I tested and the performance is the same.

"The same" as what? The same are your original patch, or the same as without any patch?

NeilBrown

Quoted 42 lines
Quoted 42 lines

Thanks,
NeilBrown

i.e. something like this:

drivers/md/raid5.c +1 -1
index d56d74d..2d72a57 100644
@@ -4178,7 +4178,7 @@ static void make_request(struct mddev *mddev, struct bio * bi)
 			finish_wait(&conf->wait_for_overlap, &w);
 			set_bit(STRIPE_HANDLE, &sh->state);
 			clear_bit(STRIPE_DELAYED, &sh->state);
-			if ((bi->bi_rw & REQ_SYNC) &&
+			if ((bi->bi_rw & REQ_NOIDLE) &&
 			    !test_and_set_bit(STRIPE_PREREAD_ACTIVE, &sh->state))
 				atomic_inc(&conf->preread_active_stripes);
 			release_stripe_plug(mddev, sh);
Quoted 22 lines
---
 drivers/md/raid5.c |    3 +++
 1 files changed, 3 insertions(+), 0 deletions(-)
drivers/md/raid5.c +3 -0
index 04348d7..8d2d4d1 100644
@@ -4010,6 +4010,9 @@ static void make_request(struct mddev *mddev, struct bio * bi)
 	     chunk_aligned_read(mddev,bi))
 		return;
 
+	if (bi->bi_rw & WRITE_ODIRECT)
+		bi->bi_rw &= ~REQ_SYNC;
+
 	logical_sector = bi->bi_sector & ~((sector_t)STRIPE_SECTORS-1);
 	last_sector = bi->bi_sector + (bi->bi_size>>9);
 	bi->bi_next = NULL;
author
#5 lore raw

On 2012-07-16 15:07 NeilBrown <[email protected]> Wrote:

Quoted 5 lines · On Mon, 16 Jul 2012 14:42:54 +0800 majianpeng <[email protected]> wrote:
Quoted 4 lines

On 2012-07-16 13:40 NeilBrown <[email protected]> Wrote:

Quoted 2 lines · On Mon, 16 Jul 2012 09:31:55 +0800 majianpeng <[email protected]> wrote:

[snip]

Quoted 5 lines
Quoted 4 lines
Quoted 4 lines

Normal 'sync' requests use WRITE_SYNC which includes "REQ_NOIDLE" which means
/* don't anticipate more IO after this one */
O_DIRECT request use WRITE_ODIRECT which does not include this flag.

Quoted 7 lines
Quoted 3 lines

Using REQ_NOIDEL to difference odirect and sync.Why not using:
+ if (bi->bi_rw & WRITE_ODIRECT)
+ bi->bi_rw &= ~REQ_SYNC;

Because that code is wrong. WRITE_ODIRECT is not one flag, it is two flags 'or'ed together. So this code does not do what you expect.

No, I used those code test and it's ok.
The code used & not &&.
Maybe I wrong?

Quoted 2 lines
Quoted 2 lines

[snip]

#6 lore raw
Quoted 16 lines · On Mon, 16 Jul 2012 15:11:29 +0800 majianpeng <[email protected]> wrote:

On 2012-07-16 15:07 NeilBrown <[email protected]> Wrote:

Quoted 5 lines · On Mon, 16 Jul 2012 14:42:54 +0800 majianpeng <[email protected]> wrote:
Quoted 4 lines

On 2012-07-16 13:40 NeilBrown <[email protected]> Wrote:

Quoted 2 lines · On Mon, 16 Jul 2012 09:31:55 +0800 majianpeng <[email protected]> wrote:

[snip]

Quoted 9 lines
Quoted 8 lines
Quoted 4 lines

Normal 'sync' requests use WRITE_SYNC which includes "REQ_NOIDLE" which means
/* don't anticipate more IO after this one */
O_DIRECT request use WRITE_ODIRECT which does not include this flag.

Using REQ_NOIDEL to difference odirect and sync.Why not using:
+ if (bi->bi_rw & WRITE_ODIRECT)
+ bi->bi_rw &= ~REQ_SYNC;

Quoted 6 lines
Quoted 3 lines

Because that code is wrong. WRITE_ODIRECT is not one flag, it is two flags 'or'ed together. So this code does not do what you expect.

No, I used those code test and it's ok.
The code used & not &&.
Maybe I wrong?

Think about it...

#define REQ_WRITE (1 << __REQ_WRITE)
#define REQ_SYNC (1 << __REQ_SYNC)

#define RW_MASK REQ_WRITE
#define WRITE RW_MASK

#define WRITE_ODIRECT (WRITE | REQ_SYNC)

So

    (bi->bi_rw & WRITE_ODIRECT)

will be true if either REQ_WRITE or REQ_SYNC are set in bi_rw So whenever REQ_SYNC is set, your code clears the flag. So your code is functionally identical to

   bi->bi_rw &= ~REQ_SYNC;

NeilBrown

author
#7 lore raw

On 2012-07-16 15:30 NeilBrown <[email protected]> Wrote:

Quoted 38 lines · On Mon, 16 Jul 2012 15:11:29 +0800 majianpeng <[email protected]> wrote:
Quoted 17 lines

On 2012-07-16 15:07 NeilBrown <[email protected]> Wrote:

Quoted 5 lines · On Mon, 16 Jul 2012 14:42:54 +0800 majianpeng <[email protected]> wrote:
Quoted 4 lines

On 2012-07-16 13:40 NeilBrown <[email protected]> Wrote:

Quoted 2 lines · On Mon, 16 Jul 2012 09:31:55 +0800 majianpeng <[email protected]> wrote:

[snip]

Quoted 9 lines
Quoted 8 lines
Quoted 4 lines

Normal 'sync' requests use WRITE_SYNC which includes "REQ_NOIDLE" which means
/* don't anticipate more IO after this one */
O_DIRECT request use WRITE_ODIRECT which does not include this flag.

Using REQ_NOIDEL to difference odirect and sync.Why not using:
+ if (bi->bi_rw & WRITE_ODIRECT)
+ bi->bi_rw &= ~REQ_SYNC;

Quoted 6 lines
Quoted 3 lines

Because that code is wrong. WRITE_ODIRECT is not one flag, it is two flags 'or'ed together. So this code does not do what you expect.

No, I used those code test and it's ok.
The code used & not &&.
Maybe I wrong?

Think about it...

#define REQ_WRITE (1 << __REQ_WRITE)
#define REQ_SYNC (1 << __REQ_SYNC)

#define RW_MASK REQ_WRITE
#define WRITE RW_MASK

#define WRITE_ODIRECT (WRITE | REQ_SYNC)

So
(bi->bi_rw & WRITE_ODIRECT)

Quoted 9 lines

will be true if either REQ_WRITE or REQ_SYNC are set in bi_rw So whenever REQ_SYNC is set, your code clears the flag. So your code is functionally identical to

  bi->bi_rw &= ~REQ_SYNC;

NeilBrown

Yes, thanks your time.I maked a stupid mistake. I'll corrected by your suggestion and resend to you.