[Ocfs2-devel] [PATCH 02/14] ocfs2: Remove xattrs via ocfs2_xa_loc
Tao Ma
tao.ma at oracle.com
Mon Aug 31 23:03:55 PDT 2009
Joel Becker wrote:
> Add ocfs2_xa_remove_entry(), which will remove an xattr entry from its
> storage via the ocfs2_xa_loc descriptor.
>
> Signed-off-by: Joel Becker <joel.becker at oracle.com>
> ---
> fs/ocfs2/xattr.c | 61 ++++++++++++++++++++++++-----------------------------
> 1 files changed, 28 insertions(+), 33 deletions(-)
>
> diff --git a/fs/ocfs2/xattr.c b/fs/ocfs2/xattr.c
> index 848f24e..333d384 100644
> --- a/fs/ocfs2/xattr.c
> +++ b/fs/ocfs2/xattr.c
> @@ -1580,7 +1580,28 @@ static const struct ocfs2_xa_loc_operations ocfs2_xa_bucket_loc_ops = {
>
> static void ocfs2_xa_remove_entry(struct ocfs2_xa_loc *loc)
> {
> + int index, count;
> + struct ocfs2_xattr_header *xh = loc->xl_header;
> + struct ocfs2_xattr_entry *entry = loc->xl_entry;
> +
> ocfs2_xa_wipe_namevalue(loc);
> +
> + le16_add_cpu(&xh->xh_count, -1);
> + count = le16_to_cpu(xh->xh_count);
> +
> + /*
> + * Only zero out the entry if there are more remaining. This is
> + * important for an empty bucket, as it keeps track of the
> + * bucket's hash value. It doesn't hurt empty block storage.
> + */
> + if (count) {
> + index = ((char *)entry - (char *)&xh->xh_entries) /
> + sizeof(struct ocfs2_xattr_entry);
index = entry - xh->xh_entries should work?
> + memmove(&xh->xh_entries[index], &xh->xh_entries[index + 1],
> + (count - index) * sizeof(struct ocfs2_xattr_entry));
> + memset(&xh->xh_entries[count], 0,
> + sizeof(struct ocfs2_xattr_entry));
> + }
> }
Regards,
Tao
More information about the Ocfs2-devel
mailing list