raid5: For write performance, remove REQ_SYNC when write was odirect.
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
@@ -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
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 setSTRIPE_PREREAD_ACTIVEwhich decreaed the change to full write.But this patch remove
REQ_SYNConly judging the WRITE_ODIRECT,it will contail regular file.So it maybe not correctly.
How can differenceodriect_writebetween 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
@@ -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
Signed-off-by Jianpeng Ma <[email protected]>--- drivers/md/raid5.c | 3 +++ 1 files changed, 3 insertions(+), 0 deletions(-)drivers/md/raid5.c +3
-0@@ -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 ;
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 setSTRIPE_PREREAD_ACTIVEwhich decreaed the change to full write.But this patch remove
REQ_SYNConly judging the WRITE_ODIRECT,it will contail regular file.So it maybe not correctly.
How can differenceodriect_writebetween regular file or block file?Hi,
I think you are saying the whenREQ_SYNCis used withO_DIRECTwrites 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_SYNCwhich includes "REQ_NOIDLE" which means
/* don't anticipate more IO after this one */O_DIRECTrequest useWRITE_ODIRECTwhich does not include this flag.So maybe we should simply change raid5 to only set
STRIPE_PREREAD_ACTIVEifREQ_NOIDLEis 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,
NeilBrowni.e. something like this:
drivers/md/raid5.c +1
-1@@ -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
Signed-off-by Jianpeng Ma <[email protected]>--- drivers/md/raid5.c | 3 +++ 1 files changed, 3 insertions(+), 0 deletions(-)drivers/md/raid5.c +3
-0@@ -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 ;
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 setSTRIPE_PREREAD_ACTIVEwhich decreaed the change to full write.But this patch remove
REQ_SYNConly judging the WRITE_ODIRECT,it will contail regular file.So it maybe not correctly.
How can differenceodriect_writebetween regular file or block file?Hi,
I think you are saying the whenREQ_SYNCis used withO_DIRECTwrites 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_SYNCwhich includes "REQ_NOIDLE" which means
/* don't anticipate more IO after this one */O_DIRECTrequest useWRITE_ODIRECTwhich 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_ACTIVEifREQ_NOIDLEis 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,
NeilBrowni.e. something like this:
drivers/md/raid5.c +1
-1@@ -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
Signed-off-by Jianpeng Ma <[email protected]>--- drivers/md/raid5.c | 3 +++ 1 files changed, 3 insertions(+), 0 deletions(-)drivers/md/raid5.c +3
-0@@ -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 ;
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 setSTRIPE_PREREAD_ACTIVEwhich decreaed the change to full write.But this patch remove
REQ_SYNConly judging the WRITE_ODIRECT,it will contail regular file.So it maybe not correctly.
How can differenceodriect_writebetween regular file or block file?Hi,
I think you are saying the whenREQ_SYNCis used withO_DIRECTwrites 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_SYNCwhich includes "REQ_NOIDLE" which means
/* don't anticipate more IO after this one */O_DIRECTrequest useWRITE_ODIRECTwhich does not include this flag.Using
REQ_NOIDELto 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_ODIRECTis only used in odirect-write.Quoted 7 lines
So maybe we should simply change raid5 to only set
STRIPE_PREREAD_ACTIVEifREQ_NOIDLEis 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,
NeilBrowni.e. something like this:
drivers/md/raid5.c +1
-1@@ -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
Signed-off-by Jianpeng Ma <[email protected]>--- drivers/md/raid5.c | 3 +++ 1 files changed, 3 insertions(+), 0 deletions(-)drivers/md/raid5.c +3
-0@@ -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 ;
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_SYNCwhich includes "REQ_NOIDLE" which means
/* don't anticipate more IO after this one */O_DIRECTrequest useWRITE_ODIRECTwhich does not include this flag.
Quoted 7 lines
Quoted 3 lines
Using
REQ_NOIDELto difference odirect and sync.Why not using:
+ if (bi->bi_rw&WRITE_ODIRECT)
+bi->bi_rw&= ~REQ_SYNC;Because that code is wrong.
WRITE_ODIRECTis 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]
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_SYNCwhich includes "REQ_NOIDLE" which means
/* don't anticipate more IO after this one */O_DIRECTrequest useWRITE_ODIRECTwhich does not include this flag.Using
REQ_NOIDELto 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_ODIRECTis 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
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_SYNCwhich includes "REQ_NOIDLE" which means
/* don't anticipate more IO after this one */O_DIRECTrequest useWRITE_ODIRECTwhich does not include this flag.Using
REQ_NOIDELto 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_ODIRECTis 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)
#defineREQ_SYNC(1 <<__REQ_SYNC)#define
RW_MASKREQ_WRITE
#define WRITERW_MASK#define
WRITE_ODIRECT(WRITE |REQ_SYNC)So
(bi->bi_rw&WRITE_ODIRECT)
Quoted 9 lines
will be true if either
REQ_WRITEorREQ_SYNCare set inbi_rwSo wheneverREQ_SYNCis set, your code clears the flag. So your code is functionally identical tobi->bi_rw &= ~REQ_SYNC;NeilBrown
Yes, thanks your time.I maked a stupid mistake. I'll corrected by your suggestion and resend to you.