ocfs2: Gell into ocfs2_xa_set()
ocfs2_xa_set() wraps the ocfs2_xa_prepare_entry()/ocfs2_xa_store_value() logic. Both callers can now use the same routine. ocfs2_xa_remove() moves directly into ocfs2_xa_set(). Signed-off-by: Joel Becker <joel.becker@oracle.com>
This commit is contained in:
parent
73857ee0b5
commit
bca5e9bd1e
1 changed files with 42 additions and 46 deletions
|
@ -2017,8 +2017,6 @@ out:
|
|||
* Prepares loc->xl_entry to receive the new xattr. This includes
|
||||
* properly setting up the name+value pair region. If loc->xl_entry
|
||||
* already exists, it will take care of modifying it appropriately.
|
||||
* This also includes deleting entries, but don't call this to remove
|
||||
* a non-existant entry. That's just a bug.
|
||||
*
|
||||
* Note that this modifies the data. You did journal_access already,
|
||||
* right?
|
||||
|
@ -2030,11 +2028,6 @@ static int ocfs2_xa_prepare_entry(struct ocfs2_xa_loc *loc,
|
|||
{
|
||||
int rc = 0;
|
||||
|
||||
if (!xi->xi_value) {
|
||||
rc = ocfs2_xa_remove(loc, ctxt);
|
||||
goto out;
|
||||
}
|
||||
|
||||
rc = ocfs2_xa_check_space(loc, xi);
|
||||
if (rc)
|
||||
goto out;
|
||||
|
@ -2092,9 +2085,6 @@ static int ocfs2_xa_store_value(struct ocfs2_xa_loc *loc,
|
|||
char *nameval_buf;
|
||||
struct ocfs2_xattr_value_buf vb;
|
||||
|
||||
if (!xi->xi_value)
|
||||
goto out;
|
||||
|
||||
nameval_buf = ocfs2_xa_offset_pointer(loc, nameval_offset);
|
||||
if (xi->xi_value_len > OCFS2_XATTR_INLINE_SIZE) {
|
||||
ocfs2_xa_fill_value_buf(loc, &vb);
|
||||
|
@ -2105,10 +2095,49 @@ static int ocfs2_xa_store_value(struct ocfs2_xa_loc *loc,
|
|||
} else
|
||||
memcpy(nameval_buf + name_size, xi->xi_value, xi->xi_value_len);
|
||||
|
||||
out:
|
||||
return rc;
|
||||
}
|
||||
|
||||
static int ocfs2_xa_set(struct ocfs2_xa_loc *loc,
|
||||
struct ocfs2_xattr_info *xi,
|
||||
struct ocfs2_xattr_set_ctxt *ctxt)
|
||||
{
|
||||
int ret;
|
||||
u32 name_hash = ocfs2_xattr_name_hash(loc->xl_inode, xi->xi_name,
|
||||
xi->xi_name_len);
|
||||
|
||||
ret = ocfs2_xa_journal_access(ctxt->handle, loc,
|
||||
OCFS2_JOURNAL_ACCESS_WRITE);
|
||||
if (ret) {
|
||||
mlog_errno(ret);
|
||||
goto out;
|
||||
}
|
||||
|
||||
/* Don't worry, we are never called with !xi_value and !xl_entry */
|
||||
if (!xi->xi_value) {
|
||||
ret = ocfs2_xa_remove(loc, ctxt);
|
||||
goto out;
|
||||
}
|
||||
|
||||
ret = ocfs2_xa_prepare_entry(loc, xi, name_hash, ctxt);
|
||||
if (ret) {
|
||||
if (ret != -ENOSPC)
|
||||
mlog_errno(ret);
|
||||
goto out;
|
||||
}
|
||||
|
||||
ret = ocfs2_xa_store_value(loc, xi, ctxt);
|
||||
if (ret) {
|
||||
mlog_errno(ret);
|
||||
goto out;
|
||||
}
|
||||
|
||||
ocfs2_xa_journal_dirty(ctxt->handle, loc);
|
||||
|
||||
out:
|
||||
return ret;
|
||||
}
|
||||
|
||||
static void ocfs2_init_dinode_xa_loc(struct ocfs2_xa_loc *loc,
|
||||
struct inode *inode,
|
||||
struct buffer_head *bh,
|
||||
|
@ -2183,8 +2212,6 @@ static int ocfs2_xattr_set_entry(struct inode *inode,
|
|||
struct ocfs2_dinode *di = (struct ocfs2_dinode *)xs->inode_bh->b_data;
|
||||
handle_t *handle = ctxt->handle;
|
||||
int ret;
|
||||
u32 name_hash = ocfs2_xattr_name_hash(inode, xi->xi_name,
|
||||
xi->xi_name_len);
|
||||
struct ocfs2_xa_loc loc;
|
||||
|
||||
if (!(flag & OCFS2_INLINE_XATTR_FL))
|
||||
|
@ -2205,14 +2232,8 @@ static int ocfs2_xattr_set_entry(struct inode *inode,
|
|||
else
|
||||
ocfs2_init_xattr_block_xa_loc(&loc, inode, xs->xattr_bh,
|
||||
xs->not_found ? NULL : xs->here);
|
||||
ret = ocfs2_xa_journal_access(handle, &loc,
|
||||
OCFS2_JOURNAL_ACCESS_WRITE);
|
||||
if (ret) {
|
||||
mlog_errno(ret);
|
||||
goto out;
|
||||
}
|
||||
|
||||
ret = ocfs2_xa_prepare_entry(&loc, xi, name_hash, ctxt);
|
||||
ret = ocfs2_xa_set(&loc, xi, ctxt);
|
||||
if (ret) {
|
||||
if (ret != -ENOSPC)
|
||||
mlog_errno(ret);
|
||||
|
@ -2220,14 +2241,6 @@ static int ocfs2_xattr_set_entry(struct inode *inode,
|
|||
}
|
||||
xs->here = loc.xl_entry;
|
||||
|
||||
ret = ocfs2_xa_store_value(&loc, xi, ctxt);
|
||||
if (ret) {
|
||||
mlog_errno(ret);
|
||||
goto out;
|
||||
}
|
||||
|
||||
ocfs2_xa_journal_dirty(handle, &loc);
|
||||
|
||||
if (!(oi->ip_dyn_features & OCFS2_INLINE_XATTR_FL) &&
|
||||
(flag & OCFS2_INLINE_XATTR_FL)) {
|
||||
struct ocfs2_super *osb = OCFS2_SB(inode->i_sb);
|
||||
|
@ -5415,8 +5428,6 @@ static int ocfs2_xattr_set_in_bucket(struct inode *inode,
|
|||
int ret;
|
||||
u64 blkno;
|
||||
struct ocfs2_xa_loc loc;
|
||||
u32 name_hash = ocfs2_xattr_name_hash(inode, xi->xi_name,
|
||||
xi->xi_name_len);
|
||||
|
||||
if (!xs->bucket->bu_bhs[1]) {
|
||||
blkno = bucket_blkno(xs->bucket);
|
||||
|
@ -5430,14 +5441,7 @@ static int ocfs2_xattr_set_in_bucket(struct inode *inode,
|
|||
|
||||
ocfs2_init_xattr_bucket_xa_loc(&loc, xs->bucket,
|
||||
xs->not_found ? NULL : xs->here);
|
||||
ret = ocfs2_xa_journal_access(ctxt->handle, &loc,
|
||||
OCFS2_JOURNAL_ACCESS_WRITE);
|
||||
if (ret < 0) {
|
||||
mlog_errno(ret);
|
||||
goto out;
|
||||
}
|
||||
|
||||
ret = ocfs2_xa_prepare_entry(&loc, xi, name_hash, ctxt);
|
||||
ret = ocfs2_xa_set(&loc, xi, ctxt);
|
||||
if (ret) {
|
||||
if (ret != -ENOSPC)
|
||||
mlog_errno(ret);
|
||||
|
@ -5445,14 +5449,6 @@ static int ocfs2_xattr_set_in_bucket(struct inode *inode,
|
|||
}
|
||||
xs->here = loc.xl_entry;
|
||||
|
||||
ret = ocfs2_xa_store_value(&loc, xi, ctxt);
|
||||
if (ret) {
|
||||
mlog_errno(ret);
|
||||
goto out;
|
||||
}
|
||||
|
||||
ocfs2_xa_journal_dirty(ctxt->handle, &loc);
|
||||
|
||||
out:
|
||||
return ret;
|
||||
}
|
||||
|
|
Reference in a new issue