1 From: Tiger Yang <tiger.yang@oracle.com>
2 Date: Fri, 14 Nov 2008 11:16:03 +0800
3 Subject: ocfs2: add ocfs2_xattr_set_handle
6 This function is used to set xattr's in a started transaction. It is only
7 called during inode creation inode for initial security/acl xattrs of the
8 new inode. These xattrs could be put into ibody or extent block, so xattr
9 bucket would not be use in this case.
11 Signed-off-by: Tiger Yang <tiger.yang@oracle.com>
12 Signed-off-by: Mark Fasheh <mfasheh@suse.com>
14 fs/ocfs2/xattr.c | 68 ++++++++++++++++++++++++++++++++++++++++++++++++++++++
15 fs/ocfs2/xattr.h | 4 +++
16 2 files changed, 72 insertions(+), 0 deletions(-)
18 diff --git a/fs/ocfs2/xattr.c b/fs/ocfs2/xattr.c
19 index 7a90892..6480254 100644
20 --- a/fs/ocfs2/xattr.c
21 +++ b/fs/ocfs2/xattr.c
22 @@ -2326,6 +2326,74 @@ out:
26 + * This function only called duing creating inode
27 + * for init security/acl xattrs of the new inode.
28 + * The xattrs could be put into ibody or extent block,
29 + * xattr bucket would not be use in this case.
30 + * transanction credits also be reserved in here.
32 +int ocfs2_xattr_set_handle(handle_t *handle,
33 + struct inode *inode,
34 + struct buffer_head *di_bh,
40 + struct ocfs2_alloc_context *meta_ac,
41 + struct ocfs2_alloc_context *data_ac)
43 + struct ocfs2_dinode *di;
46 + struct ocfs2_xattr_info xi = {
47 + .name_index = name_index,
50 + .value_len = value_len,
53 + struct ocfs2_xattr_search xis = {
54 + .not_found = -ENODATA,
57 + struct ocfs2_xattr_search xbs = {
58 + .not_found = -ENODATA,
61 + struct ocfs2_xattr_set_ctxt ctxt = {
67 + if (!ocfs2_supports_xattr(OCFS2_SB(inode->i_sb)))
70 + xis.inode_bh = xbs.inode_bh = di_bh;
71 + di = (struct ocfs2_dinode *)di_bh->b_data;
73 + down_write(&OCFS2_I(inode)->ip_xattr_sem);
75 + ret = ocfs2_xattr_ibody_find(inode, name_index, name, &xis);
78 + if (xis.not_found) {
79 + ret = ocfs2_xattr_block_find(inode, name_index, name, &xbs);
84 + ret = __ocfs2_xattr_set_handle(inode, di, &xi, &xis, &xbs, &ctxt);
87 + up_write(&OCFS2_I(inode)->ip_xattr_sem);
88 + brelse(xbs.xattr_bh);
96 * Set, replace or remove an extended attribute for this inode.
97 diff --git a/fs/ocfs2/xattr.h b/fs/ocfs2/xattr.h
98 index 1d8314c..8fbdc16 100644
99 --- a/fs/ocfs2/xattr.h
100 +++ b/fs/ocfs2/xattr.h
101 @@ -37,6 +37,10 @@ extern struct xattr_handler *ocfs2_xattr_handlers[];
102 ssize_t ocfs2_listxattr(struct dentry *, char *, size_t);
103 int ocfs2_xattr_set(struct inode *, int, const char *, const void *,
105 +int ocfs2_xattr_set_handle(handle_t *, struct inode *, struct buffer_head *,
106 + int, const char *, const void *, size_t, int,
107 + struct ocfs2_alloc_context *,
108 + struct ocfs2_alloc_context *);
109 int ocfs2_xattr_remove(struct inode *, struct buffer_head *);
111 #endif /* OCFS2_XATTR_H */