linux-btrfs.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH]  Btrfs: return EUCLEAN rather than ENXIO once internal error has occurred for SEEK_DATA/SEEK_HOLE inquiry
@ 2012-02-09  3:46 Jeff Liu
  2012-02-09  4:08 ` Jeff Liu
  0 siblings, 1 reply; 4+ messages in thread
From: Jeff Liu @ 2012-02-09  3:46 UTC (permalink / raw)
  To: linux-btrfs@vger.kernel.org; +Cc: Dave Chinner

By referring to http://linux.die.net/man/2/lseek, return ENXIO only
when "offset beyond EOF" for either SEEK_DATA or SEEK_HOLE inquiry.
But we return it in case of internal issue too if btrfs_get_extent_fiemap() failed
due to other issues.  This will confuse the user applications to be expecting ENXIO when
trying to find a specific data or hole location once it has occurred.

Thanks Dave for pointing that out in XFS thread.

This patch fix it to return EUCLEAN, or maybe another particular errno is more reasonable in Btrfs to indicate this fatal error?

Thanks,
-Jeff


Cc: david@fromorbit.com
Signed-off-by: Jie Liu <jeff.liu@oracle.com>

---
 fs/btrfs/file.c |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/fs/btrfs/file.c b/fs/btrfs/file.c
index 97fbe93..6693040 100644
--- a/fs/btrfs/file.c
+++ b/fs/btrfs/file.c
@@ -1761,7 +1761,7 @@ static int find_desired_extent(struct inode *inode, loff_t *offset, int origin)
 						     start - root->sectorsize,
 						     root->sectorsize, 0);
 		if (IS_ERR(em)) {
-			ret = -ENXIO;
+			ret = -EUCLEAN;
 			goto out;
 		}
 		last_end = em->start + em->len;
@@ -1773,7 +1773,7 @@ static int find_desired_extent(struct inode *inode, loff_t *offset, int origin)
 	while (1) {
 		em = btrfs_get_extent_fiemap(inode, NULL, 0, start, len, 0);
 		if (IS_ERR(em)) {
-			ret = -ENXIO;
+			ret = -EUCLEAN;
 			break;
 		}
 
-- 
1.7.9

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH]  Btrfs: return EUCLEAN rather than ENXIO once internal error has occurred for SEEK_DATA/SEEK_HOLE inquiry
  2012-02-09  3:46 [PATCH] Btrfs: return EUCLEAN rather than ENXIO once internal error has occurred for SEEK_DATA/SEEK_HOLE inquiry Jeff Liu
@ 2012-02-09  4:08 ` Jeff Liu
  2012-02-09  4:51   ` Dave Chinner
  0 siblings, 1 reply; 4+ messages in thread
From: Jeff Liu @ 2012-02-09  4:08 UTC (permalink / raw)
  To: linux-btrfs@vger.kernel.org; +Cc: Dave Chinner

On 02/09/2012 11:46 AM, Jeff Liu wrote:

> By referring to http://linux.die.net/man/2/lseek, return ENXIO only
> when "offset beyond EOF" for either SEEK_DATA or SEEK_HOLE inquiry.
> But we return it in case of internal issue too if btrfs_get_extent_fiemap() failed
> due to other issues.  This will confuse the user applications to be expecting ENXIO when
> trying to find a specific data or hole location once it has occurred.
> 
> Thanks Dave for pointing that out in XFS thread.
> 
> This patch fix it to return EUCLEAN, or maybe another particular errno is more reasonable in Btrfs to indicate this fatal error?

Or maybe just return the error that was happened at internal routine, to
give user more accurate error info, which is better?

Thanks,
-Jeff

> 
> Thanks,
> -Jeff
> 
> 
> Cc: david@fromorbit.com
> Signed-off-by: Jie Liu <jeff.liu@oracle.com>
> 
> ---
>  fs/btrfs/file.c |    4 ++--
>  1 files changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/fs/btrfs/file.c b/fs/btrfs/file.c
> index 97fbe93..6693040 100644
> --- a/fs/btrfs/file.c
> +++ b/fs/btrfs/file.c
> @@ -1761,7 +1761,7 @@ static int find_desired_extent(struct inode *inode, loff_t *offset, int origin)
>  						     start - root->sectorsize,
>  						     root->sectorsize, 0);
>  		if (IS_ERR(em)) {
> -			ret = -ENXIO;
> +			ret = -EUCLEAN;
>  			goto out;
>  		}
>  		last_end = em->start + em->len;
> @@ -1773,7 +1773,7 @@ static int find_desired_extent(struct inode *inode, loff_t *offset, int origin)
>  	while (1) {
>  		em = btrfs_get_extent_fiemap(inode, NULL, 0, start, len, 0);
>  		if (IS_ERR(em)) {
> -			ret = -ENXIO;
> +			ret = -EUCLEAN;
>  			break;
>  		}
>  



^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH]  Btrfs: return EUCLEAN rather than ENXIO once internal error has occurred for SEEK_DATA/SEEK_HOLE inquiry
  2012-02-09  4:08 ` Jeff Liu
@ 2012-02-09  4:51   ` Dave Chinner
  2012-02-09  6:06     ` Jeff Liu
  0 siblings, 1 reply; 4+ messages in thread
From: Dave Chinner @ 2012-02-09  4:51 UTC (permalink / raw)
  To: Jeff Liu; +Cc: linux-btrfs@vger.kernel.org

On Thu, Feb 09, 2012 at 12:08:47PM +0800, Jeff Liu wrote:
> On 02/09/2012 11:46 AM, Jeff Liu wrote:
> 
> > By referring to http://linux.die.net/man/2/lseek, return ENXIO only
> > when "offset beyond EOF" for either SEEK_DATA or SEEK_HOLE inquiry.
> > But we return it in case of internal issue too if btrfs_get_extent_fiemap() failed
> > due to other issues.  This will confuse the user applications to be expecting ENXIO when
> > trying to find a specific data or hole location once it has occurred.
> > 
> > Thanks Dave for pointing that out in XFS thread.
> > 
> > This patch fix it to return EUCLEAN, or maybe another particular errno is more reasonable in Btrfs to indicate this fatal error?
> 
> Or maybe just return the error that was happened at internal routine, to
> give user more accurate error info, which is better?

Return the internal error unchanged - a failure to read the extent
list (EIO) is different to a corruption detected in the extent
map read from disk (EUCLEAN). Having a user report the appropriate
error makes our life much simpler when it comes to trying to
understand their problem....

Cheers,

Dave.
-- 
Dave Chinner
david@fromorbit.com

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH]  Btrfs: return EUCLEAN rather than ENXIO once internal error has occurred for SEEK_DATA/SEEK_HOLE inquiry
  2012-02-09  4:51   ` Dave Chinner
@ 2012-02-09  6:06     ` Jeff Liu
  0 siblings, 0 replies; 4+ messages in thread
From: Jeff Liu @ 2012-02-09  6:06 UTC (permalink / raw)
  To: Dave Chinner; +Cc: linux-btrfs@vger.kernel.org

On 02/09/2012 12:51 PM, Dave Chinner wrote:

> On Thu, Feb 09, 2012 at 12:08:47PM +0800, Jeff Liu wrote:
>> On 02/09/2012 11:46 AM, Jeff Liu wrote:
>>
>>> By referring to http://linux.die.net/man/2/lseek, return ENXIO only
>>> when "offset beyond EOF" for either SEEK_DATA or SEEK_HOLE inquiry.
>>> But we return it in case of internal issue too if btrfs_get_extent_fiemap() failed
>>> due to other issues.  This will confuse the user applications to be expecting ENXIO when
>>> trying to find a specific data or hole location once it has occurred.
>>>
>>> Thanks Dave for pointing that out in XFS thread.
>>>
>>> This patch fix it to return EUCLEAN, or maybe another particular errno is more reasonable in Btrfs to indicate this fatal error?
>>
>> Or maybe just return the error that was happened at internal routine, to
>> give user more accurate error info, which is better?
> 
> Return the internal error unchanged - a failure to read the extent
> list (EIO) is different to a corruption detected in the extent
> map read from disk (EUCLEAN). Having a user report the appropriate
> error makes our life much simpler when it comes to trying to
> understand their problem....

Definitely. I will repost this patch later.

Thanks,
-Jeff

> 
> Cheers,
> 
> Dave.



^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2012-02-09  6:06 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-02-09  3:46 [PATCH] Btrfs: return EUCLEAN rather than ENXIO once internal error has occurred for SEEK_DATA/SEEK_HOLE inquiry Jeff Liu
2012-02-09  4:08 ` Jeff Liu
2012-02-09  4:51   ` Dave Chinner
2012-02-09  6:06     ` Jeff Liu

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).