2008-08-18 11:11:00 +02:00
|
|
|
/* -*- mode: c; c-basic-offset: 8; -*-
|
|
|
|
* vim: noexpandtab sw=8 ts=8 sts=0:
|
|
|
|
*
|
|
|
|
* xattr.h
|
|
|
|
*
|
2008-10-23 10:33:03 +02:00
|
|
|
* Copyright (C) 2004, 2008 Oracle. All rights reserved.
|
2008-08-18 11:11:00 +02: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 10:33:03 +02:00
|
|
|
* License version 2 as published by the Free Software Foundation.
|
2008-08-18 11:11:00 +02: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
|
|
|
|
};
|
|
|
|
|
|
|
|
extern struct xattr_handler ocfs2_xattr_user_handler;
|
|
|
|
extern struct xattr_handler ocfs2_xattr_trusted_handler;
|
|
|
|
extern struct xattr_handler *ocfs2_xattr_handlers[];
|
|
|
|
|
2008-10-23 10:33:33 +02:00
|
|
|
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_remove(struct inode *, struct buffer_head *);
|
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 11:38:53 +02:00
|
|
|
|
2008-08-18 11:11:00 +02:00
|
|
|
#endif /* OCFS2_XATTR_H */
|