2008-08-18 03:11:00 -06:00
|
|
|
/* -*- mode: c; c-basic-offset: 8; -*-
|
|
|
|
* vim: noexpandtab sw=8 ts=8 sts=0:
|
|
|
|
*
|
|
|
|
* xattr.h
|
|
|
|
*
|
2008-10-23 02:33:03 -06:00
|
|
|
* Copyright (C) 2004, 2008 Oracle. All rights reserved.
|
2008-08-18 03:11:00 -06:00
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU General Public
|
2008-10-23 02:33:03 -06:00
|
|
|
* License version 2 as published by the Free Software Foundation.
|
2008-08-18 03:11:00 -06:00
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* General Public License for more details.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef OCFS2_XATTR_H
|
|
|
|
#define OCFS2_XATTR_H
|
|
|
|
|
|
|
|
#include <linux/init.h>
|
|
|
|
#include <linux/xattr.h>
|
|
|
|
|
|
|
|
enum ocfs2_xattr_type {
|
|
|
|
OCFS2_XATTR_INDEX_USER = 1,
|
|
|
|
OCFS2_XATTR_INDEX_POSIX_ACL_ACCESS,
|
|
|
|
OCFS2_XATTR_INDEX_POSIX_ACL_DEFAULT,
|
|
|
|
OCFS2_XATTR_INDEX_TRUSTED,
|
|
|
|
OCFS2_XATTR_INDEX_SECURITY,
|
|
|
|
OCFS2_XATTR_MAX
|
|
|
|
};
|
|
|
|
|
2008-11-13 20:16:41 -07:00
|
|
|
struct ocfs2_security_xattr_info {
|
|
|
|
int enable;
|
|
|
|
char *name;
|
|
|
|
void *value;
|
|
|
|
size_t value_len;
|
|
|
|
};
|
|
|
|
|
2008-08-18 03:11:00 -06:00
|
|
|
extern struct xattr_handler ocfs2_xattr_user_handler;
|
|
|
|
extern struct xattr_handler ocfs2_xattr_trusted_handler;
|
2008-11-13 20:16:27 -07:00
|
|
|
extern struct xattr_handler ocfs2_xattr_security_handler;
|
2008-11-13 20:17:04 -07:00
|
|
|
#ifdef CONFIG_OCFS2_FS_POSIX_ACL
|
|
|
|
extern struct xattr_handler ocfs2_xattr_acl_access_handler;
|
|
|
|
extern struct xattr_handler ocfs2_xattr_acl_default_handler;
|
|
|
|
#endif
|
2008-08-18 03:11:00 -06:00
|
|
|
extern struct xattr_handler *ocfs2_xattr_handlers[];
|
|
|
|
|
2008-10-23 02:33:33 -06:00
|
|
|
ssize_t ocfs2_listxattr(struct dentry *, char *, size_t);
|
2008-11-13 20:16:53 -07:00
|
|
|
int ocfs2_xattr_get_nolock(struct inode *, struct buffer_head *, int,
|
|
|
|
const char *, void *, size_t);
|
2008-10-23 02:33:33 -06:00
|
|
|
int ocfs2_xattr_set(struct inode *, int, const char *, const void *,
|
|
|
|
size_t, int);
|
2008-11-13 20:16:03 -07:00
|
|
|
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 *);
|
2008-10-23 02:33:33 -06:00
|
|
|
int ocfs2_xattr_remove(struct inode *, struct buffer_head *);
|
2008-11-13 20:16:41 -07:00
|
|
|
int ocfs2_init_security_get(struct inode *, struct inode *,
|
|
|
|
struct ocfs2_security_xattr_info *);
|
|
|
|
int ocfs2_init_security_set(handle_t *, struct inode *,
|
|
|
|
struct buffer_head *,
|
|
|
|
struct ocfs2_security_xattr_info *,
|
|
|
|
struct ocfs2_alloc_context *,
|
|
|
|
struct ocfs2_alloc_context *);
|
|
|
|
int ocfs2_calc_security_init(struct inode *,
|
|
|
|
struct ocfs2_security_xattr_info *,
|
|
|
|
int *, int *, struct ocfs2_alloc_context **);
|
2008-11-13 20:17:41 -07:00
|
|
|
int ocfs2_calc_xattr_init(struct inode *, struct buffer_head *,
|
|
|
|
int, struct ocfs2_security_xattr_info *,
|
2008-11-12 17:27:44 -07:00
|
|
|
int *, int *, int *);
|
ocfs2: Enable xattr set in index btree
Where the previous patches added the ability of list/get xattr in buckets
for ocfs2, this patch enables ocfs2 to store large numbers of EAs.
The original design doc is written by Mark Fasheh, and it can be found in
http://oss.oracle.com/osswiki/OCFS2/DesignDocs/IndexedEATrees. I only had to
make small modifications to it.
First, because the bucket size is 4K, a new field named xh_free_start is added
in ocfs2_xattr_header to indicate the next valid name/value offset in a bucket.
It is used when we store new EA name/value. With this field, we can find the
place more quickly and what's more, we don't need to sort the name/value every
time to let the last entry indicate the next unused space. This makes the
insert operation more efficient for blocksizes smaller than 4k.
Because of the new xh_free_start, another field named as xh_name_value_len is
also added in ocfs2_xattr_header. It records the total length of all the
name/values in the bucket. We need this so that we can check it and defragment
the bucket if there is not enough contiguous free space.
An xattr insertion looks like this:
1. xattr_index_block_find: find the right bucket by the name_hash, say bucketA.
2. check whether there is enough space in bucketA. If yes, insert it directly
and modify xh_free_start and xh_name_value_len accordingly. If not, check
xh_name_value_len to see whether we can store this by defragment the bucket.
If yes, defragment it and go on insertion.
3. If defragement doesn't work, check whether there is new empty bucket in
the clusters within this extent record. If yes, init the new bucket and move
all the buckets after bucketA one by one to the next bucket. Move half of the
entries in bucketA to the next bucket and go on insertion.
4. If there is no new bucket, grow the extent tree.
As for xattr deletion, we will delete an xattr bucket when all it's xattrs
are removed and move all the buckets after it to the previous one. When all
the xattr buckets in an extend record are freed, free this extend records
from ocfs2_xattr_tree.
Signed-off-by: Tao Ma <tao.ma@oracle.com>
Signed-off-by: Mark Fasheh <mfasheh@suse.com>
2008-08-18 03:38:53 -06:00
|
|
|
|
2008-12-09 15:24:33 -07:00
|
|
|
/*
|
|
|
|
* xattrs can live inside an inode, as part of an external xattr block,
|
|
|
|
* or inside an xattr bucket, which is the leaf of a tree rooted in an
|
|
|
|
* xattr block. Some of the xattr calls, especially the value setting
|
|
|
|
* functions, want to treat each of these locations as equal. Let's wrap
|
|
|
|
* them in a structure that we can pass around instead of raw buffer_heads.
|
|
|
|
*/
|
|
|
|
struct ocfs2_xattr_value_buf {
|
|
|
|
struct buffer_head *vb_bh;
|
|
|
|
ocfs2_journal_access_func vb_access;
|
|
|
|
struct ocfs2_xattr_value_root *vb_xv;
|
|
|
|
};
|
|
|
|
|
|
|
|
|
2008-08-18 03:11:00 -06:00
|
|
|
#endif /* OCFS2_XATTR_H */
|