* [PATCH] Btrfs: adjust outstanding_extents counter properly when dio write is split @ 2016-12-23 1:13 Liu Bo 2016-12-23 3:18 ` Anand Jain 2017-01-06 11:28 ` Filipe Manana 0 siblings, 2 replies; 4+ messages in thread From: Liu Bo @ 2016-12-23 1:13 UTC (permalink / raw) To: linux-btrfs; +Cc: David Sterba, Anand.Jain.anand.jain Currently how btrfs dio deals with split dio write is not good enough if dio write is split into several segments due to the lack of contiguous space, a large dio write like 'dd bs=1G count=1' can end up with incorrect outstanding_extents counter and endio would complain loudly with an assertion. This fixes the problem by compensating the outstanding_extents counter in inode if a large dio write gets split. Reported-by: Anand Jain <anand.jain@oracle.com> Signed-off-by: Liu Bo <bo.li.liu@oracle.com> --- fs/btrfs/inode.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c index a4c8796..4175987 100644 --- a/fs/btrfs/inode.c +++ b/fs/btrfs/inode.c @@ -7641,11 +7641,18 @@ static void adjust_dio_outstanding_extents(struct inode *inode, * within our reservation, otherwise we need to adjust our inode * counter appropriately. */ - if (dio_data->outstanding_extents) { + if (dio_data->outstanding_extents >= num_extents) { dio_data->outstanding_extents -= num_extents; } else { + /* + * If dio write length has been split due to no large enough + * contiguous space, we need to compensate our inode counter + * appropriately. + */ + u64 num_needed = num_extents - dio_data->outstanding_extents; + spin_lock(&BTRFS_I(inode)->lock); - BTRFS_I(inode)->outstanding_extents += num_extents; + BTRFS_I(inode)->outstanding_extents += num_needed; spin_unlock(&BTRFS_I(inode)->lock); } } -- 2.5.5 ^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH] Btrfs: adjust outstanding_extents counter properly when dio write is split 2016-12-23 1:13 [PATCH] Btrfs: adjust outstanding_extents counter properly when dio write is split Liu Bo @ 2016-12-23 3:18 ` Anand Jain 2017-01-06 11:28 ` Filipe Manana 1 sibling, 0 replies; 4+ messages in thread From: Anand Jain @ 2016-12-23 3:18 UTC (permalink / raw) To: Liu Bo, linux-btrfs; +Cc: David Sterba, Anand.Jain.anand.jain On 12/23/16 09:13, Liu Bo wrote: > Currently how btrfs dio deals with split dio write is not good > enough if dio write is split into several segments due to the > lack of contiguous space, a large dio write like 'dd bs=1G count=1' > can end up with incorrect outstanding_extents counter and endio > would complain loudly with an assertion. > > This fixes the problem by compensating the outstanding_extents > counter in inode if a large dio write gets split. Fix works. Thanks Liu bo for working on this. Tested-by: Anand Jain <anand.jain@oracle.com> > Reported-by: Anand Jain <anand.jain@oracle.com> > Signed-off-by: Liu Bo <bo.li.liu@oracle.com> > --- > fs/btrfs/inode.c | 11 +++++++++-- > 1 file changed, 9 insertions(+), 2 deletions(-) > > diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c > index a4c8796..4175987 100644 > --- a/fs/btrfs/inode.c > +++ b/fs/btrfs/inode.c > @@ -7641,11 +7641,18 @@ static void adjust_dio_outstanding_extents(struct inode *inode, > * within our reservation, otherwise we need to adjust our inode > * counter appropriately. > */ > - if (dio_data->outstanding_extents) { > + if (dio_data->outstanding_extents >= num_extents) { > dio_data->outstanding_extents -= num_extents; > } else { > + /* > + * If dio write length has been split due to no large enough > + * contiguous space, we need to compensate our inode counter > + * appropriately. > + */ > + u64 num_needed = num_extents - dio_data->outstanding_extents; > + > spin_lock(&BTRFS_I(inode)->lock); > - BTRFS_I(inode)->outstanding_extents += num_extents; > + BTRFS_I(inode)->outstanding_extents += num_needed; > spin_unlock(&BTRFS_I(inode)->lock); > } > } > ^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] Btrfs: adjust outstanding_extents counter properly when dio write is split 2016-12-23 1:13 [PATCH] Btrfs: adjust outstanding_extents counter properly when dio write is split Liu Bo 2016-12-23 3:18 ` Anand Jain @ 2017-01-06 11:28 ` Filipe Manana 2017-01-12 22:24 ` Liu Bo 1 sibling, 1 reply; 4+ messages in thread From: Filipe Manana @ 2017-01-06 11:28 UTC (permalink / raw) To: Liu Bo; +Cc: linux-btrfs@vger.kernel.org, David Sterba, Anand.Jain.anand.jain On Fri, Dec 23, 2016 at 1:13 AM, Liu Bo <bo.li.liu@oracle.com> wrote: > Currently how btrfs dio deals with split dio write is not good > enough if dio write is split into several segments due to the > lack of contiguous space, a large dio write like 'dd bs=1G count=1' > can end up with incorrect outstanding_extents counter and endio > would complain loudly with an assertion. > > This fixes the problem by compensating the outstanding_extents > counter in inode if a large dio write gets split. > > Reported-by: Anand Jain <anand.jain@oracle.com> > Signed-off-by: Liu Bo <bo.li.liu@oracle.com> Bo, can you please create a test case for fstests? Thanks > --- > fs/btrfs/inode.c | 11 +++++++++-- > 1 file changed, 9 insertions(+), 2 deletions(-) > > diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c > index a4c8796..4175987 100644 > --- a/fs/btrfs/inode.c > +++ b/fs/btrfs/inode.c > @@ -7641,11 +7641,18 @@ static void adjust_dio_outstanding_extents(struct inode *inode, > * within our reservation, otherwise we need to adjust our inode > * counter appropriately. > */ > - if (dio_data->outstanding_extents) { > + if (dio_data->outstanding_extents >= num_extents) { > dio_data->outstanding_extents -= num_extents; > } else { > + /* > + * If dio write length has been split due to no large enough > + * contiguous space, we need to compensate our inode counter > + * appropriately. > + */ > + u64 num_needed = num_extents - dio_data->outstanding_extents; > + > spin_lock(&BTRFS_I(inode)->lock); > - BTRFS_I(inode)->outstanding_extents += num_extents; > + BTRFS_I(inode)->outstanding_extents += num_needed; > spin_unlock(&BTRFS_I(inode)->lock); > } > } > -- > 2.5.5 > > -- > To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in > the body of a message to majordomo@vger.kernel.org > More majordomo info at http://vger.kernel.org/majordomo-info.html -- Filipe David Manana, "People will forget what you said, people will forget what you did, but people will never forget how you made them feel." ^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] Btrfs: adjust outstanding_extents counter properly when dio write is split 2017-01-06 11:28 ` Filipe Manana @ 2017-01-12 22:24 ` Liu Bo 0 siblings, 0 replies; 4+ messages in thread From: Liu Bo @ 2017-01-12 22:24 UTC (permalink / raw) To: Filipe Manana Cc: linux-btrfs@vger.kernel.org, David Sterba, Anand.Jain.anand.jain On Fri, Jan 06, 2017 at 11:28:06AM +0000, Filipe Manana wrote: > On Fri, Dec 23, 2016 at 1:13 AM, Liu Bo <bo.li.liu@oracle.com> wrote: > > Currently how btrfs dio deals with split dio write is not good > > enough if dio write is split into several segments due to the > > lack of contiguous space, a large dio write like 'dd bs=1G count=1' > > can end up with incorrect outstanding_extents counter and endio > > would complain loudly with an assertion. > > > > This fixes the problem by compensating the outstanding_extents > > counter in inode if a large dio write gets split. > > > > Reported-by: Anand Jain <anand.jain@oracle.com> > > Signed-off-by: Liu Bo <bo.li.liu@oracle.com> > > Bo, can you please create a test case for fstests? It took me some time to recall all the details, anyway, I've sent out a fstests case for it[1]. [1]: https://patchwork.kernel.org/patch/9514277/ Thanks, -liubo > > Thanks > > > --- > > fs/btrfs/inode.c | 11 +++++++++-- > > 1 file changed, 9 insertions(+), 2 deletions(-) > > > > diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c > > index a4c8796..4175987 100644 > > --- a/fs/btrfs/inode.c > > +++ b/fs/btrfs/inode.c > > @@ -7641,11 +7641,18 @@ static void adjust_dio_outstanding_extents(struct inode *inode, > > * within our reservation, otherwise we need to adjust our inode > > * counter appropriately. > > */ > > - if (dio_data->outstanding_extents) { > > + if (dio_data->outstanding_extents >= num_extents) { > > dio_data->outstanding_extents -= num_extents; > > } else { > > + /* > > + * If dio write length has been split due to no large enough > > + * contiguous space, we need to compensate our inode counter > > + * appropriately. > > + */ > > + u64 num_needed = num_extents - dio_data->outstanding_extents; > > + > > spin_lock(&BTRFS_I(inode)->lock); > > - BTRFS_I(inode)->outstanding_extents += num_extents; > > + BTRFS_I(inode)->outstanding_extents += num_needed; > > spin_unlock(&BTRFS_I(inode)->lock); > > } > > } > > -- > > 2.5.5 > > > > -- > > To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in > > the body of a message to majordomo@vger.kernel.org > > More majordomo info at http://vger.kernel.org/majordomo-info.html > > > > -- > Filipe David Manana, > > "People will forget what you said, > people will forget what you did, > but people will never forget how you made them feel." ^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2017-01-12 22:17 UTC | newest] Thread overview: 4+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2016-12-23 1:13 [PATCH] Btrfs: adjust outstanding_extents counter properly when dio write is split Liu Bo 2016-12-23 3:18 ` Anand Jain 2017-01-06 11:28 ` Filipe Manana 2017-01-12 22:24 ` Liu Bo
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.