aboutsummaryrefslogtreecommitdiffstats
path: root/fs
diff options
context:
space:
mode:
authorTiger Yang <tiger.yang@oracle.com>2008-11-13 22:16:03 -0500
committerMark Fasheh <mfasheh@suse.com>2009-01-05 11:34:19 -0500
commit6c3faba4421e230d77a181c260972229c542dec9 (patch)
treea36c271b5cd82a696cac6b3c774d62fddb997801 /fs
parentf5d362022a947e84b0a3dd656d09c6b2322e234f (diff)
ocfs2: add ocfs2_xattr_set_handle
This function is used to set xattr's in a started transaction. It is only called during inode creation inode for initial security/acl xattrs of the new inode. These xattrs could be put into ibody or extent block, so xattr bucket would not be use in this case. Signed-off-by: Tiger Yang <tiger.yang@oracle.com> Signed-off-by: Mark Fasheh <mfasheh@suse.com>
Diffstat (limited to 'fs')
-rw-r--r--fs/ocfs2/xattr.c68
-rw-r--r--fs/ocfs2/xattr.h4
2 files changed, 72 insertions, 0 deletions
diff --git a/fs/ocfs2/xattr.c b/fs/ocfs2/xattr.c
index 7a9089255a87..6480254fe396 100644
--- a/fs/ocfs2/xattr.c
+++ b/fs/ocfs2/xattr.c
@@ -2326,6 +2326,74 @@ out:
2326} 2326}
2327 2327
2328/* 2328/*
2329 * This function only called duing creating inode
2330 * for init security/acl xattrs of the new inode.
2331 * The xattrs could be put into ibody or extent block,
2332 * xattr bucket would not be use in this case.
2333 * transanction credits also be reserved in here.
2334 */
2335int ocfs2_xattr_set_handle(handle_t *handle,
2336 struct inode *inode,
2337 struct buffer_head *di_bh,
2338 int name_index,
2339 const char *name,
2340 const void *value,
2341 size_t value_len,
2342 int flags,
2343 struct ocfs2_alloc_context *meta_ac,
2344 struct ocfs2_alloc_context *data_ac)
2345{
2346 struct ocfs2_dinode *di;
2347 int ret;
2348
2349 struct ocfs2_xattr_info xi = {
2350 .name_index = name_index,
2351 .name = name,
2352 .value = value,
2353 .value_len = value_len,
2354 };
2355
2356 struct ocfs2_xattr_search xis = {
2357 .not_found = -ENODATA,
2358 };
2359
2360 struct ocfs2_xattr_search xbs = {
2361 .not_found = -ENODATA,
2362 };
2363
2364 struct ocfs2_xattr_set_ctxt ctxt = {
2365 .handle = handle,
2366 .meta_ac = meta_ac,
2367 .data_ac = data_ac,
2368 };
2369
2370 if (!ocfs2_supports_xattr(OCFS2_SB(inode->i_sb)))
2371 return -EOPNOTSUPP;
2372
2373 xis.inode_bh = xbs.inode_bh = di_bh;
2374 di = (struct ocfs2_dinode *)di_bh->b_data;
2375
2376 down_write(&OCFS2_I(inode)->ip_xattr_sem);
2377
2378 ret = ocfs2_xattr_ibody_find(inode, name_index, name, &xis);
2379 if (ret)
2380 goto cleanup;
2381 if (xis.not_found) {
2382 ret = ocfs2_xattr_block_find(inode, name_index, name, &xbs);
2383 if (ret)
2384 goto cleanup;
2385 }
2386
2387 ret = __ocfs2_xattr_set_handle(inode, di, &xi, &xis, &xbs, &ctxt);
2388
2389cleanup:
2390 up_write(&OCFS2_I(inode)->ip_xattr_sem);
2391 brelse(xbs.xattr_bh);
2392
2393 return ret;
2394}
2395
2396/*
2329 * ocfs2_xattr_set() 2397 * ocfs2_xattr_set()
2330 * 2398 *
2331 * Set, replace or remove an extended attribute for this inode. 2399 * Set, replace or remove an extended attribute for this inode.
diff --git a/fs/ocfs2/xattr.h b/fs/ocfs2/xattr.h
index 1d8314c7656d..8fbdc163c839 100644
--- a/fs/ocfs2/xattr.h
+++ b/fs/ocfs2/xattr.h
@@ -37,6 +37,10 @@ extern struct xattr_handler *ocfs2_xattr_handlers[];
37ssize_t ocfs2_listxattr(struct dentry *, char *, size_t); 37ssize_t ocfs2_listxattr(struct dentry *, char *, size_t);
38int ocfs2_xattr_set(struct inode *, int, const char *, const void *, 38int ocfs2_xattr_set(struct inode *, int, const char *, const void *,
39 size_t, int); 39 size_t, int);
40int ocfs2_xattr_set_handle(handle_t *, struct inode *, struct buffer_head *,
41 int, const char *, const void *, size_t, int,
42 struct ocfs2_alloc_context *,
43 struct ocfs2_alloc_context *);
40int ocfs2_xattr_remove(struct inode *, struct buffer_head *); 44int ocfs2_xattr_remove(struct inode *, struct buffer_head *);
41 45
42#endif /* OCFS2_XATTR_H */ 46#endif /* OCFS2_XATTR_H */