aboutsummaryrefslogtreecommitdiffstats
path: root/fs/jfs/xattr.c
diff options
context:
space:
mode:
authorDave Kleikamp <shaggy@austin.ibm.com>2005-09-01 10:02:43 -0400
committerDave Kleikamp <shaggy@austin.ibm.com>2005-09-01 10:02:43 -0400
commit4f4b401bfaa97edbea41a1fcab794148e7ac0421 (patch)
treed58dcf9d90e15364398a3a4584f2892439295b64 /fs/jfs/xattr.c
parentb1b5d7f9b7ac6a8e3452ac43a53eebf69fdf5a77 (diff)
JFS: allow extended attributes to be set within a existing transaction
Signed-off-by: Dave Kleikamp <shaggy@austin.ibm.com>
Diffstat (limited to 'fs/jfs/xattr.c')
-rw-r--r--fs/jfs/xattr.c58
1 files changed, 41 insertions, 17 deletions
diff --git a/fs/jfs/xattr.c b/fs/jfs/xattr.c
index 554ec739e49b..35674b2a0e6c 100644
--- a/fs/jfs/xattr.c
+++ b/fs/jfs/xattr.c
@@ -633,12 +633,12 @@ static void ea_release(struct inode *inode, struct ea_buffer *ea_buf)
633 } 633 }
634} 634}
635 635
636static int ea_put(struct inode *inode, struct ea_buffer *ea_buf, int new_size) 636static int ea_put(tid_t tid, struct inode *inode, struct ea_buffer *ea_buf,
637 int new_size)
637{ 638{
638 struct jfs_inode_info *ji = JFS_IP(inode); 639 struct jfs_inode_info *ji = JFS_IP(inode);
639 unsigned long old_blocks, new_blocks; 640 unsigned long old_blocks, new_blocks;
640 int rc = 0; 641 int rc = 0;
641 tid_t tid;
642 642
643 if (new_size == 0) { 643 if (new_size == 0) {
644 ea_release(inode, ea_buf); 644 ea_release(inode, ea_buf);
@@ -664,9 +664,6 @@ static int ea_put(struct inode *inode, struct ea_buffer *ea_buf, int new_size)
664 if (rc) 664 if (rc)
665 return rc; 665 return rc;
666 666
667 tid = txBegin(inode->i_sb, 0);
668 down(&ji->commit_sem);
669
670 old_blocks = new_blocks = 0; 667 old_blocks = new_blocks = 0;
671 668
672 if (ji->ea.flag & DXD_EXTENT) { 669 if (ji->ea.flag & DXD_EXTENT) {
@@ -695,11 +692,8 @@ static int ea_put(struct inode *inode, struct ea_buffer *ea_buf, int new_size)
695 DQUOT_FREE_BLOCK(inode, old_blocks); 692 DQUOT_FREE_BLOCK(inode, old_blocks);
696 693
697 inode->i_ctime = CURRENT_TIME; 694 inode->i_ctime = CURRENT_TIME;
698 rc = txCommit(tid, 1, &inode, 0);
699 txEnd(tid);
700 up(&ji->commit_sem);
701 695
702 return rc; 696 return 0;
703} 697}
704 698
705/* 699/*
@@ -810,8 +804,8 @@ static int can_set_xattr(struct inode *inode, const char *name,
810 return permission(inode, MAY_WRITE, NULL); 804 return permission(inode, MAY_WRITE, NULL);
811} 805}
812 806
813int __jfs_setxattr(struct inode *inode, const char *name, const void *value, 807int __jfs_setxattr(tid_t tid, struct inode *inode, const char *name,
814 size_t value_len, int flags) 808 const void *value, size_t value_len, int flags)
815{ 809{
816 struct jfs_ea_list *ealist; 810 struct jfs_ea_list *ealist;
817 struct jfs_ea *ea, *old_ea = NULL, *next_ea = NULL; 811 struct jfs_ea *ea, *old_ea = NULL, *next_ea = NULL;
@@ -825,9 +819,6 @@ int __jfs_setxattr(struct inode *inode, const char *name, const void *value,
825 int rc; 819 int rc;
826 int length; 820 int length;
827 821
828 if ((rc = can_set_xattr(inode, name, value, value_len)))
829 return rc;
830
831 if (strncmp(name, XATTR_OS2_PREFIX, XATTR_OS2_PREFIX_LEN) == 0) { 822 if (strncmp(name, XATTR_OS2_PREFIX, XATTR_OS2_PREFIX_LEN) == 0) {
832 os2name = kmalloc(namelen - XATTR_OS2_PREFIX_LEN + 1, 823 os2name = kmalloc(namelen - XATTR_OS2_PREFIX_LEN + 1,
833 GFP_KERNEL); 824 GFP_KERNEL);
@@ -939,7 +930,7 @@ int __jfs_setxattr(struct inode *inode, const char *name, const void *value,
939 930
940 ealist->size = cpu_to_le32(new_size); 931 ealist->size = cpu_to_le32(new_size);
941 932
942 rc = ea_put(inode, &ea_buf, new_size); 933 rc = ea_put(tid, inode, &ea_buf, new_size);
943 934
944 goto out; 935 goto out;
945 release: 936 release:
@@ -955,12 +946,29 @@ int __jfs_setxattr(struct inode *inode, const char *name, const void *value,
955int jfs_setxattr(struct dentry *dentry, const char *name, const void *value, 946int jfs_setxattr(struct dentry *dentry, const char *name, const void *value,
956 size_t value_len, int flags) 947 size_t value_len, int flags)
957{ 948{
949 struct inode *inode = dentry->d_inode;
950 struct jfs_inode_info *ji = JFS_IP(inode);
951 int rc;
952 tid_t tid;
953
954 if ((rc = can_set_xattr(inode, name, value, value_len)))
955 return rc;
956
958 if (value == NULL) { /* empty EA, do not remove */ 957 if (value == NULL) { /* empty EA, do not remove */
959 value = ""; 958 value = "";
960 value_len = 0; 959 value_len = 0;
961 } 960 }
962 961
963 return __jfs_setxattr(dentry->d_inode, name, value, value_len, flags); 962 tid = txBegin(inode->i_sb, 0);
963 down(&ji->commit_sem);
964 rc = __jfs_setxattr(tid, dentry->d_inode, name, value, value_len,
965 flags);
966 if (!rc)
967 rc = txCommit(tid, 1, &inode, 0);
968 txEnd(tid);
969 up(&ji->commit_sem);
970
971 return rc;
964} 972}
965 973
966static int can_get_xattr(struct inode *inode, const char *name) 974static int can_get_xattr(struct inode *inode, const char *name)
@@ -1122,5 +1130,21 @@ ssize_t jfs_listxattr(struct dentry * dentry, char *data, size_t buf_size)
1122 1130
1123int jfs_removexattr(struct dentry *dentry, const char *name) 1131int jfs_removexattr(struct dentry *dentry, const char *name)
1124{ 1132{
1125 return __jfs_setxattr(dentry->d_inode, name, NULL, 0, XATTR_REPLACE); 1133 struct inode *inode = dentry->d_inode;
1134 struct jfs_inode_info *ji = JFS_IP(inode);
1135 int rc;
1136 tid_t tid;
1137
1138 if ((rc = can_set_xattr(inode, name, NULL, 0)))
1139 return rc;
1140
1141 tid = txBegin(inode->i_sb, 0);
1142 down(&ji->commit_sem);
1143 rc = __jfs_setxattr(tid, dentry->d_inode, name, NULL, 0, XATTR_REPLACE);
1144 if (!rc)
1145 rc = txCommit(tid, 1, &inode, 0);
1146 txEnd(tid);
1147 up(&ji->commit_sem);
1148
1149 return rc;
1126} 1150}