mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
synced 2024-09-06 10:57:46 +00:00
ocfs2: make xattr extension work with new local alloc reservation.
The old ocfs2_xattr_extent_allocation is too optimistic about the clusters we can get. So actually if the file system is too fragmented, ocfs2_add_clusters_in_btree will return us with EGAIN and we need to allocate clusters once again. So this patch change it to a while loop so that we can allocate clusters until we reach clusters_to_add. Signed-off-by: Tao Ma <tao.ma@oracle.com> Signed-off-by: Joel Becker <joel.becker@oracle.com> Cc: stable@kernel.org
This commit is contained in:
parent
0a463b74e7
commit
a78f9f4668
1 changed files with 48 additions and 32 deletions
|
@ -709,7 +709,7 @@ static int ocfs2_xattr_extend_allocation(struct inode *inode,
|
||||||
struct ocfs2_xattr_value_buf *vb,
|
struct ocfs2_xattr_value_buf *vb,
|
||||||
struct ocfs2_xattr_set_ctxt *ctxt)
|
struct ocfs2_xattr_set_ctxt *ctxt)
|
||||||
{
|
{
|
||||||
int status = 0;
|
int status = 0, credits;
|
||||||
handle_t *handle = ctxt->handle;
|
handle_t *handle = ctxt->handle;
|
||||||
enum ocfs2_alloc_restarted why;
|
enum ocfs2_alloc_restarted why;
|
||||||
u32 prev_clusters, logical_start = le32_to_cpu(vb->vb_xv->xr_clusters);
|
u32 prev_clusters, logical_start = le32_to_cpu(vb->vb_xv->xr_clusters);
|
||||||
|
@ -719,39 +719,55 @@ static int ocfs2_xattr_extend_allocation(struct inode *inode,
|
||||||
|
|
||||||
ocfs2_init_xattr_value_extent_tree(&et, INODE_CACHE(inode), vb);
|
ocfs2_init_xattr_value_extent_tree(&et, INODE_CACHE(inode), vb);
|
||||||
|
|
||||||
status = vb->vb_access(handle, INODE_CACHE(inode), vb->vb_bh,
|
while (clusters_to_add) {
|
||||||
OCFS2_JOURNAL_ACCESS_WRITE);
|
status = vb->vb_access(handle, INODE_CACHE(inode), vb->vb_bh,
|
||||||
if (status < 0) {
|
OCFS2_JOURNAL_ACCESS_WRITE);
|
||||||
mlog_errno(status);
|
if (status < 0) {
|
||||||
goto leave;
|
mlog_errno(status);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
prev_clusters = le32_to_cpu(vb->vb_xv->xr_clusters);
|
||||||
|
status = ocfs2_add_clusters_in_btree(handle,
|
||||||
|
&et,
|
||||||
|
&logical_start,
|
||||||
|
clusters_to_add,
|
||||||
|
0,
|
||||||
|
ctxt->data_ac,
|
||||||
|
ctxt->meta_ac,
|
||||||
|
&why);
|
||||||
|
if ((status < 0) && (status != -EAGAIN)) {
|
||||||
|
if (status != -ENOSPC)
|
||||||
|
mlog_errno(status);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
ocfs2_journal_dirty(handle, vb->vb_bh);
|
||||||
|
|
||||||
|
clusters_to_add -= le32_to_cpu(vb->vb_xv->xr_clusters) -
|
||||||
|
prev_clusters;
|
||||||
|
|
||||||
|
if (why != RESTART_NONE && clusters_to_add) {
|
||||||
|
/*
|
||||||
|
* We can only fail in case the alloc file doesn't give
|
||||||
|
* up enough clusters.
|
||||||
|
*/
|
||||||
|
BUG_ON(why == RESTART_META);
|
||||||
|
|
||||||
|
mlog(0, "restarting xattr value extension for %u"
|
||||||
|
" clusters,.\n", clusters_to_add);
|
||||||
|
credits = ocfs2_calc_extend_credits(inode->i_sb,
|
||||||
|
&vb->vb_xv->xr_list,
|
||||||
|
clusters_to_add);
|
||||||
|
status = ocfs2_extend_trans(handle, credits);
|
||||||
|
if (status < 0) {
|
||||||
|
status = -ENOMEM;
|
||||||
|
mlog_errno(status);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
prev_clusters = le32_to_cpu(vb->vb_xv->xr_clusters);
|
|
||||||
status = ocfs2_add_clusters_in_btree(handle,
|
|
||||||
&et,
|
|
||||||
&logical_start,
|
|
||||||
clusters_to_add,
|
|
||||||
0,
|
|
||||||
ctxt->data_ac,
|
|
||||||
ctxt->meta_ac,
|
|
||||||
&why);
|
|
||||||
if (status < 0) {
|
|
||||||
mlog_errno(status);
|
|
||||||
goto leave;
|
|
||||||
}
|
|
||||||
|
|
||||||
ocfs2_journal_dirty(handle, vb->vb_bh);
|
|
||||||
|
|
||||||
clusters_to_add -= le32_to_cpu(vb->vb_xv->xr_clusters) - prev_clusters;
|
|
||||||
|
|
||||||
/*
|
|
||||||
* We should have already allocated enough space before the transaction,
|
|
||||||
* so no need to restart.
|
|
||||||
*/
|
|
||||||
BUG_ON(why != RESTART_NONE || clusters_to_add);
|
|
||||||
|
|
||||||
leave:
|
|
||||||
|
|
||||||
return status;
|
return status;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue