[Ocfs2-tools-devel] [PATCH 3/7] libocfs2: add function for xattr value shrink
Tiger Yang
tiger.yang at oracle.com
Tue Oct 20 01:41:32 PDT 2009
ocfs2_xattr_value_truncate only truncate value to zero.
So revise it to ocfs2_xattr_value_shrink, thus we can specify
the new size of clusters.
Signed-off-by: Tiger Yang <tiger.yang at oracle.com>
---
include/ocfs2/ocfs2.h | 7 +++++--
libocfs2/truncate.c | 20 ++++++++++++++++----
tunefs.ocfs2/feature_xattr.c | 2 +-
3 files changed, 22 insertions(+), 7 deletions(-)
diff --git a/include/ocfs2/ocfs2.h b/include/ocfs2/ocfs2.h
index bb23982..046a2f2 100644
--- a/include/ocfs2/ocfs2.h
+++ b/include/ocfs2/ocfs2.h
@@ -1302,8 +1302,8 @@ errcode_t ocfs2_read_xattr_bucket(ocfs2_filesys *fs,
errcode_t ocfs2_write_xattr_bucket(ocfs2_filesys *fs,
uint64_t blkno,
char *bucket_buf);
-errcode_t ocfs2_xattr_value_truncate(ocfs2_filesys *fs,
- struct ocfs2_xattr_value_root *xv);
+errcode_t ocfs2_xattr_remove_value(ocfs2_filesys *fs,
+ struct ocfs2_xattr_value_root *xv);
errcode_t ocfs2_xattr_tree_truncate(ocfs2_filesys *fs,
struct ocfs2_xattr_tree_root *xt);
errcode_t ocfs2_extent_iterate_xattr(ocfs2_filesys *fs,
@@ -1328,5 +1328,8 @@ errcode_t ocfs2_xattr_get_clusters(ocfs2_cached_inode *cinode,
struct ocfs2_extent_list *el,
uint64_t el_blkno,
char *el_blk);
+errcode_t ocfs2_xattr_value_shrink(ocfs2_filesys *fs,
+ struct ocfs2_xattr_value_root *xv,
+ uint32_t new_clusters);
#endif /* _FILESYS_H */
diff --git a/libocfs2/truncate.c b/libocfs2/truncate.c
index 680fca5..45fd70d 100644
--- a/libocfs2/truncate.c
+++ b/libocfs2/truncate.c
@@ -299,20 +299,32 @@ errcode_t ocfs2_truncate(ocfs2_filesys *fs, uint64_t ino, uint64_t new_i_size)
return ocfs2_truncate_full(fs, ino, new_i_size, NULL, NULL);
}
-errcode_t ocfs2_xattr_value_truncate(ocfs2_filesys *fs,
- struct ocfs2_xattr_value_root *xv)
+errcode_t ocfs2_xattr_value_shrink(ocfs2_filesys *fs,
+ struct ocfs2_xattr_value_root *xv,
+ uint32_t new_clusters)
{
+ errcode_t ret;
struct truncate_ctxt ctxt;
int changed;
struct ocfs2_extent_list *el = &xv->xr_list;
ctxt.new_i_clusters = xv->xr_clusters;
- ctxt.new_size_in_clusters = 0;
+ ctxt.new_size_in_clusters = new_clusters;
- return ocfs2_extent_iterate_xattr(fs, el, xv->xr_last_eb_blk,
+ ret = ocfs2_extent_iterate_xattr(fs, el, xv->xr_last_eb_blk,
OCFS2_EXTENT_FLAG_DEPTH_TRAVERSE,
truncate_iterate,
&ctxt, &changed);
+ if (ret)
+ return ret;
+ xv->xr_clusters = new_clusters;
+ return 0;
+}
+
+errcode_t ocfs2_xattr_remove_value(ocfs2_filesys *fs,
+ struct ocfs2_xattr_value_root *xv)
+{
+ return ocfs2_xattr_value_shrink(fs, xv, 0);
}
errcode_t ocfs2_xattr_tree_truncate(ocfs2_filesys *fs,
diff --git a/tunefs.ocfs2/feature_xattr.c b/tunefs.ocfs2/feature_xattr.c
index 8eef7df..b978caf 100644
--- a/tunefs.ocfs2/feature_xattr.c
+++ b/tunefs.ocfs2/feature_xattr.c
@@ -65,7 +65,7 @@ static errcode_t remove_xattr_entry(ocfs2_filesys *fs,
(struct ocfs2_xattr_value_root *)
((void *)xh + xe->xe_name_offset +
OCFS2_XATTR_SIZE(xe->xe_name_len));
- ret = ocfs2_xattr_value_truncate(fs, xv);
+ ret = ocfs2_xattr_remove_value(fs, xv);
if (ret)
break;
}
--
1.5.4.1
More information about the Ocfs2-tools-devel
mailing list