diff options
author | Joel Becker <joel.becker@oracle.com> | 2009-08-18 16:20:27 -0400 |
---|---|---|
committer | Joel Becker <joel.becker@oracle.com> | 2010-02-26 18:41:11 -0500 |
commit | 3fc12afa0cea5dc8845487b685165c89934ca1eb (patch) | |
tree | 170fc4aa9c3d0e8d0d95c69de53a0ea689450bf5 /fs/ocfs2 | |
parent | 9dc474005d0e34cf21d4b510f347e3942f24b021 (diff) |
ocfs2: Provide ocfs2_xa_fill_value_buf() for external value processing
We use the ocfs2_xattr_value_buf structure to manage external values.
It lets the value tree code do its work regardless of the containing
storage. ocfs2_xa_fill_value_buf() initializes a value buf from an
ocfs2_xa_loc entry.
Signed-off-by: Joel Becker <joel.becker@oracle.com>
Diffstat (limited to 'fs/ocfs2')
-rw-r--r-- | fs/ocfs2/xattr.c | 59 |
1 files changed, 59 insertions, 0 deletions
diff --git a/fs/ocfs2/xattr.c b/fs/ocfs2/xattr.c index 6d362e2d3960..e0d0fa23a19b 100644 --- a/fs/ocfs2/xattr.c +++ b/fs/ocfs2/xattr.c | |||
@@ -172,6 +172,13 @@ struct ocfs2_xa_loc_operations { | |||
172 | 172 | ||
173 | /* Add name+value storage to an entry */ | 173 | /* Add name+value storage to an entry */ |
174 | void (*xlo_add_namevalue)(struct ocfs2_xa_loc *loc, int size); | 174 | void (*xlo_add_namevalue)(struct ocfs2_xa_loc *loc, int size); |
175 | |||
176 | /* | ||
177 | * Initialize the value buf's access and bh fields for this entry. | ||
178 | * ocfs2_xa_fill_value_buf() will handle the xv pointer. | ||
179 | */ | ||
180 | void (*xlo_fill_value_buf)(struct ocfs2_xa_loc *loc, | ||
181 | struct ocfs2_xattr_value_buf *vb); | ||
175 | }; | 182 | }; |
176 | 183 | ||
177 | /* | 184 | /* |
@@ -1605,6 +1612,23 @@ static void ocfs2_xa_add_namevalue(struct ocfs2_xa_loc *loc, | |||
1605 | memcpy(nameval_buf, xi->xi_name, xi->xi_name_len); | 1612 | memcpy(nameval_buf, xi->xi_name, xi->xi_name_len); |
1606 | } | 1613 | } |
1607 | 1614 | ||
1615 | static void ocfs2_xa_fill_value_buf(struct ocfs2_xa_loc *loc, | ||
1616 | struct ocfs2_xattr_value_buf *vb) | ||
1617 | { | ||
1618 | int nameval_offset = le16_to_cpu(loc->xl_entry->xe_name_offset); | ||
1619 | int name_size = OCFS2_XATTR_SIZE(loc->xl_entry->xe_name_len); | ||
1620 | |||
1621 | /* Value bufs are for value trees */ | ||
1622 | BUG_ON(namevalue_size_xe(loc->xl_entry) != | ||
1623 | (name_size + OCFS2_XATTR_ROOT_SIZE)); | ||
1624 | |||
1625 | loc->xl_ops->xlo_fill_value_buf(loc, vb); | ||
1626 | vb->vb_xv = | ||
1627 | (struct ocfs2_xattr_value_root *)ocfs2_xa_offset_pointer(loc, | ||
1628 | nameval_offset + | ||
1629 | name_size); | ||
1630 | } | ||
1631 | |||
1608 | static void *ocfs2_xa_block_offset_pointer(struct ocfs2_xa_loc *loc, | 1632 | static void *ocfs2_xa_block_offset_pointer(struct ocfs2_xa_loc *loc, |
1609 | int offset) | 1633 | int offset) |
1610 | { | 1634 | { |
@@ -1712,6 +1736,20 @@ static void ocfs2_xa_block_add_namevalue(struct ocfs2_xa_loc *loc, int size) | |||
1712 | loc->xl_entry->xe_name_offset = cpu_to_le16(free_start - size); | 1736 | loc->xl_entry->xe_name_offset = cpu_to_le16(free_start - size); |
1713 | } | 1737 | } |
1714 | 1738 | ||
1739 | static void ocfs2_xa_block_fill_value_buf(struct ocfs2_xa_loc *loc, | ||
1740 | struct ocfs2_xattr_value_buf *vb) | ||
1741 | { | ||
1742 | struct buffer_head *bh = loc->xl_storage; | ||
1743 | |||
1744 | if (loc->xl_size == (bh->b_size - | ||
1745 | offsetof(struct ocfs2_xattr_block, | ||
1746 | xb_attrs.xb_header))) | ||
1747 | vb->vb_access = ocfs2_journal_access_xb; | ||
1748 | else | ||
1749 | vb->vb_access = ocfs2_journal_access_di; | ||
1750 | vb->vb_bh = bh; | ||
1751 | } | ||
1752 | |||
1715 | /* | 1753 | /* |
1716 | * Operations for xattrs stored in blocks. This includes inline inode | 1754 | * Operations for xattrs stored in blocks. This includes inline inode |
1717 | * storage and unindexed ocfs2_xattr_blocks. | 1755 | * storage and unindexed ocfs2_xattr_blocks. |
@@ -1724,6 +1762,7 @@ static const struct ocfs2_xa_loc_operations ocfs2_xa_block_loc_ops = { | |||
1724 | .xlo_wipe_namevalue = ocfs2_xa_block_wipe_namevalue, | 1762 | .xlo_wipe_namevalue = ocfs2_xa_block_wipe_namevalue, |
1725 | .xlo_add_entry = ocfs2_xa_block_add_entry, | 1763 | .xlo_add_entry = ocfs2_xa_block_add_entry, |
1726 | .xlo_add_namevalue = ocfs2_xa_block_add_namevalue, | 1764 | .xlo_add_namevalue = ocfs2_xa_block_add_namevalue, |
1765 | .xlo_fill_value_buf = ocfs2_xa_block_fill_value_buf, | ||
1727 | }; | 1766 | }; |
1728 | 1767 | ||
1729 | static void *ocfs2_xa_bucket_offset_pointer(struct ocfs2_xa_loc *loc, | 1768 | static void *ocfs2_xa_bucket_offset_pointer(struct ocfs2_xa_loc *loc, |
@@ -1869,6 +1908,25 @@ static void ocfs2_xa_bucket_add_namevalue(struct ocfs2_xa_loc *loc, int size) | |||
1869 | 1908 | ||
1870 | } | 1909 | } |
1871 | 1910 | ||
1911 | static void ocfs2_xa_bucket_fill_value_buf(struct ocfs2_xa_loc *loc, | ||
1912 | struct ocfs2_xattr_value_buf *vb) | ||
1913 | { | ||
1914 | struct ocfs2_xattr_bucket *bucket = loc->xl_storage; | ||
1915 | struct super_block *sb = bucket->bu_inode->i_sb; | ||
1916 | int nameval_offset = le16_to_cpu(loc->xl_entry->xe_name_offset); | ||
1917 | int size = namevalue_size_xe(loc->xl_entry); | ||
1918 | int block_offset = nameval_offset >> sb->s_blocksize_bits; | ||
1919 | |||
1920 | /* Values are not allowed to straddle block boundaries */ | ||
1921 | BUG_ON(block_offset != | ||
1922 | ((nameval_offset + size - 1) >> sb->s_blocksize_bits)); | ||
1923 | /* We expect the bucket to be filled in */ | ||
1924 | BUG_ON(!bucket->bu_bhs[block_offset]); | ||
1925 | |||
1926 | vb->vb_access = ocfs2_journal_access; | ||
1927 | vb->vb_bh = bucket->bu_bhs[block_offset]; | ||
1928 | } | ||
1929 | |||
1872 | /* Operations for xattrs stored in buckets. */ | 1930 | /* Operations for xattrs stored in buckets. */ |
1873 | static const struct ocfs2_xa_loc_operations ocfs2_xa_bucket_loc_ops = { | 1931 | static const struct ocfs2_xa_loc_operations ocfs2_xa_bucket_loc_ops = { |
1874 | .xlo_offset_pointer = ocfs2_xa_bucket_offset_pointer, | 1932 | .xlo_offset_pointer = ocfs2_xa_bucket_offset_pointer, |
@@ -1878,6 +1936,7 @@ static const struct ocfs2_xa_loc_operations ocfs2_xa_bucket_loc_ops = { | |||
1878 | .xlo_wipe_namevalue = ocfs2_xa_bucket_wipe_namevalue, | 1936 | .xlo_wipe_namevalue = ocfs2_xa_bucket_wipe_namevalue, |
1879 | .xlo_add_entry = ocfs2_xa_bucket_add_entry, | 1937 | .xlo_add_entry = ocfs2_xa_bucket_add_entry, |
1880 | .xlo_add_namevalue = ocfs2_xa_bucket_add_namevalue, | 1938 | .xlo_add_namevalue = ocfs2_xa_bucket_add_namevalue, |
1939 | .xlo_fill_value_buf = ocfs2_xa_bucket_fill_value_buf, | ||
1881 | }; | 1940 | }; |
1882 | 1941 | ||
1883 | static void ocfs2_xa_remove_entry(struct ocfs2_xa_loc *loc) | 1942 | static void ocfs2_xa_remove_entry(struct ocfs2_xa_loc *loc) |