Hi, I split the previous support security EA patch into four patches for review. Them besed on joel's xattr-28 branch and tao's patch "Merge xattr set transaction". 1: move new_inode out of the transaction. 2: add ocfs2_xattr_set_handle. 3: add security xattr APIs 4: add init_security in mknod. Best regards, tiger
Hi, I split the previous support security EA patch into four patches for review. Them besed on joel's xattr-28 branch and tao's patch "Merge xattr set transaction". 1: move new_inode out of the transaction. 2: add ocfs2_xattr_set_handle. 3: add security xattr APIs 4: add init_security in mknod. Best regards, tiger
Tiger Yang
2008-Oct-27 08:43 UTC
[Ocfs2-devel] [PATCH 2/4] ocfs2: add ocfs2_xattr_set_handle
This function used to set xattr in a started transaction. Signed-off-by: Tiger Yang <tiger.yang at oracle.com> --- fs/ocfs2/xattr.c | 71 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ fs/ocfs2/xattr.h | 4 +++ 2 files changed, 75 insertions(+), 0 deletions(-) diff --git a/fs/ocfs2/xattr.c b/fs/ocfs2/xattr.c index 20ddf50..3567182 100644 --- a/fs/ocfs2/xattr.c +++ b/fs/ocfs2/xattr.c @@ -2065,6 +2065,77 @@ out: return ret; } +int ocfs2_xattr_set_handle(handle_t *handle, + struct inode *inode, + struct buffer_head *di_bh, + int name_index, + const char *name, + const void *value, + size_t value_len, + int flags, + struct ocfs2_alloc_context *meta_ac, + struct ocfs2_alloc_context *data_ac) +{ + struct ocfs2_dinode *di; + u16 i, blk_per_bucket = ocfs2_blocks_per_xattr_bucket(inode->i_sb); + int ret, credits; + + struct ocfs2_xattr_info xi = { + .name_index = name_index, + .name = name, + .value = value, + .value_len = value_len, + }; + + struct ocfs2_xattr_search xis = { + .not_found = -ENODATA, + }; + + struct ocfs2_xattr_search xbs = { + .not_found = -ENODATA, + }; + + struct ocfs2_xattr_set_ctxt ctxt = { + .meta_ac = meta_ac, + .data_ac = data_ac, + }; + + if (!ocfs2_supports_xattr(OCFS2_SB(inode->i_sb))) + return -EOPNOTSUPP; + + xis.inode_bh = xbs.inode_bh = di_bh; + di = (struct ocfs2_dinode *)di_bh->b_data; + + down_write(&OCFS2_I(inode)->ip_xattr_sem); + + ret = ocfs2_xattr_ibody_find(inode, name_index, name, &xis); + if (ret) + goto cleanup; + if (xis.not_found) { + ret = ocfs2_xattr_block_find(inode, name_index, name, &xbs); + if (ret) + goto cleanup; + } + + credits = ocfs2_calc_xattr_set_credits(inode, &xi, &xis, &xbs); + ret = ocfs2_extend_trans(handle, credits); + if (ret) { + mlog_errno(ret); + goto cleanup; + } + + ret = __ocfs2_xattr_set_handle(inode, handle, di, &xi, + &xis, &xbs, &ctxt); + +cleanup: + up_write(&OCFS2_I(inode)->ip_xattr_sem); + brelse(xbs.xattr_bh); + for (i = 0; i < blk_per_bucket; i++) + brelse(xbs.bucket.bhs[i]); + + return ret; +} + /* * ocfs2_xattr_set() * diff --git a/fs/ocfs2/xattr.h b/fs/ocfs2/xattr.h index 1d8314c..8fbdc16 100644 --- a/fs/ocfs2/xattr.h +++ b/fs/ocfs2/xattr.h @@ -37,6 +37,10 @@ extern struct xattr_handler *ocfs2_xattr_handlers[]; ssize_t ocfs2_listxattr(struct dentry *, char *, size_t); int ocfs2_xattr_set(struct inode *, int, const char *, const void *, size_t, int); +int ocfs2_xattr_set_handle(handle_t *, struct inode *, struct buffer_head *, + int, const char *, const void *, size_t, int, + struct ocfs2_alloc_context *, + struct ocfs2_alloc_context *); int ocfs2_xattr_remove(struct inode *, struct buffer_head *); #endif /* OCFS2_XATTR_H */ -- 1.5.4.1
Hi tiger, I am still working on the patch of "merge xattr set transaction" according to Joel's review advice, but I will not modify the interface. So feel free to use it. Regards, Tao Tiger Yang wrote:> Hi, > I split the previous support security EA patch into four patches for > review. Them besed on joel's xattr-28 branch and tao's patch "Merge > xattr set transaction". > > 1: move new_inode out of the transaction. > 2: add ocfs2_xattr_set_handle. > 3: add security xattr APIs > 4: add init_security in mknod. > > Best regards, > tiger > > _______________________________________________ > Ocfs2-devel mailing list > Ocfs2-devel at oss.oracle.com > http://oss.oracle.com/mailman/listinfo/ocfs2-devel