* [Ocfs2-devel] [PATCH] ocfs2: Don't retry xattr set in case value extension fails.
@ 2010-05-13 14:49 Tao Ma
2010-05-18 19:15 ` Joel Becker
0 siblings, 1 reply; 2+ messages in thread
From: Tao Ma @ 2010-05-13 14:49 UTC (permalink / raw)
To: ocfs2-devel
In normal xattr set, the set sequence is inode, xattr block
and finally xattr bucket if we meet with a ENOSPC. But there
is a corner case.
So consider we will set a xattr whose value will be stored in
a cluster, and there is no xattr block by now. So we will
reserve 1 xattr block and 1 cluster for setting it. Now if we
fail in value extension(in case the volume is almost full and
we can't allocate the cluster because the check in
ocfs2_test_bg_bit_allocatable), ENOSPC will be returned. So
we will try to create a bucket(this time there is a chance that
the reserved cluster will be used), and when we try value extension
again, kernel bug happens. We did meet with it. Check the bug below.
http://oss.oracle.com/bugzilla/show_bug.cgi?id=1251
This patch just try to avoid this by adding a set_abort in
ocfs2_xattr_set_ctxt, so in case ENOSPC happens in value extension,
we will check whether it is caused by the real ENOSPC or just the
full of inode or xattr block. If it is the first case, we set set_abort
so that we don't try any further. we are safe to exit directly here
ince it is really ENOSPC.
Signed-off-by: Tao Ma <tao.ma@oracle.com>
---
fs/ocfs2/xattr.c | 6 ++++--
1 files changed, 4 insertions(+), 2 deletions(-)
diff --git a/fs/ocfs2/xattr.c b/fs/ocfs2/xattr.c
index 60e608e..741f850 100644
--- a/fs/ocfs2/xattr.c
+++ b/fs/ocfs2/xattr.c
@@ -79,6 +79,7 @@ struct ocfs2_xattr_set_ctxt {
struct ocfs2_alloc_context *meta_ac;
struct ocfs2_alloc_context *data_ac;
struct ocfs2_cached_dealloc_ctxt dealloc;
+ int set_abort;
};
#define OCFS2_XATTR_ROOT_SIZE (sizeof(struct ocfs2_xattr_def_value_root))
@@ -2135,6 +2136,7 @@ alloc_value:
orig_clusters = ocfs2_xa_value_clusters(loc);
rc = ocfs2_xa_value_truncate(loc, xi->xi_value_len, ctxt);
if (rc < 0) {
+ ctxt->set_abort = 1;
ocfs2_xa_cleanup_value_truncate(loc, "growing",
orig_clusters);
/*
@@ -2945,7 +2947,7 @@ static int ocfs2_xattr_block_set(struct inode *inode,
ret = ocfs2_xa_set(&loc, xi, ctxt);
if (!ret)
xs->here = loc.xl_entry;
- else if (ret != -ENOSPC)
+ else if ((ret != -ENOSPC) || ctxt->set_abort)
goto end;
else {
ret = ocfs2_xattr_create_index_block(inode, xs, ctxt);
@@ -3307,7 +3309,7 @@ static int __ocfs2_xattr_set_handle(struct inode *inode,
goto out;
}
ret = ocfs2_xattr_block_set(inode, xi, xbs, ctxt);
- } else if (ret == -ENOSPC) {
+ } else if ((ret == -ENOSPC) && !ctxt->set_abort) {
if (di->i_xattr_loc && !xbs->xattr_bh) {
ret = ocfs2_xattr_block_find(inode,
xi->xi_name_index,
--
1.5.5
^ permalink raw reply related [flat|nested] 2+ messages in thread
* [Ocfs2-devel] [PATCH] ocfs2: Don't retry xattr set in case value extension fails.
2010-05-13 14:49 [Ocfs2-devel] [PATCH] ocfs2: Don't retry xattr set in case value extension fails Tao Ma
@ 2010-05-18 19:15 ` Joel Becker
0 siblings, 0 replies; 2+ messages in thread
From: Joel Becker @ 2010-05-18 19:15 UTC (permalink / raw)
To: ocfs2-devel
On Thu, May 13, 2010 at 10:49:05PM +0800, Tao Ma wrote:
> In normal xattr set, the set sequence is inode, xattr block
> and finally xattr bucket if we meet with a ENOSPC. But there
> is a corner case.
> So consider we will set a xattr whose value will be stored in
> a cluster, and there is no xattr block by now. So we will
> reserve 1 xattr block and 1 cluster for setting it. Now if we
> fail in value extension(in case the volume is almost full and
> we can't allocate the cluster because the check in
> ocfs2_test_bg_bit_allocatable), ENOSPC will be returned. So
> we will try to create a bucket(this time there is a chance that
> the reserved cluster will be used), and when we try value extension
> again, kernel bug happens. We did meet with it. Check the bug below.
> http://oss.oracle.com/bugzilla/show_bug.cgi?id=1251
>
> This patch just try to avoid this by adding a set_abort in
> ocfs2_xattr_set_ctxt, so in case ENOSPC happens in value extension,
> we will check whether it is caused by the real ENOSPC or just the
> full of inode or xattr block. If it is the first case, we set set_abort
> so that we don't try any further. we are safe to exit directly here
> ince it is really ENOSPC.
>
> Signed-off-by: Tao Ma <tao.ma@oracle.com>
This patch is now in the 'fixes' branch of ocfs2.git.
Joel
--
Life's Little Instruction Book #314
"Never underestimate the power of forgiveness."
Joel Becker
Principal Software Developer
Oracle
E-mail: joel.becker at oracle.com
Phone: (650) 506-8127
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2010-05-18 19:15 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-05-13 14:49 [Ocfs2-devel] [PATCH] ocfs2: Don't retry xattr set in case value extension fails Tao Ma
2010-05-18 19:15 ` Joel Becker
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).