aboutsummaryrefslogtreecommitdiffstats
path: root/fs/ocfs2
diff options
context:
space:
mode:
authorJoel Becker <joel.becker@oracle.com>2009-08-18 23:40:14 -0400
committerJoel Becker <joel.becker@oracle.com>2010-02-26 18:41:11 -0500
commitbca5e9bd1eb2a9422a2ff29e822a956310653754 (patch)
tree593e82a8bc6782141eb31f5d2274c0597f950c2f /fs/ocfs2
parent73857ee0b548017f9632a0d0e6fe2dabbdc11d31 (diff)
ocfs2: Gell into ocfs2_xa_set()
ocfs2_xa_set() wraps the ocfs2_xa_prepare_entry()/ocfs2_xa_store_value() logic. Both callers can now use the same routine. ocfs2_xa_remove() moves directly into ocfs2_xa_set(). Signed-off-by: Joel Becker <joel.becker@oracle.com>
Diffstat (limited to 'fs/ocfs2')
-rw-r--r--fs/ocfs2/xattr.c88
1 files changed, 42 insertions, 46 deletions
diff --git a/fs/ocfs2/xattr.c b/fs/ocfs2/xattr.c
index 550a3e86c971..98c18fbfc289 100644
--- a/fs/ocfs2/xattr.c
+++ b/fs/ocfs2/xattr.c
@@ -2017,8 +2017,6 @@ out:
2017 * Prepares loc->xl_entry to receive the new xattr. This includes 2017 * Prepares loc->xl_entry to receive the new xattr. This includes
2018 * properly setting up the name+value pair region. If loc->xl_entry 2018 * properly setting up the name+value pair region. If loc->xl_entry
2019 * already exists, it will take care of modifying it appropriately. 2019 * already exists, it will take care of modifying it appropriately.
2020 * This also includes deleting entries, but don't call this to remove
2021 * a non-existant entry. That's just a bug.
2022 * 2020 *
2023 * Note that this modifies the data. You did journal_access already, 2021 * Note that this modifies the data. You did journal_access already,
2024 * right? 2022 * right?
@@ -2030,11 +2028,6 @@ static int ocfs2_xa_prepare_entry(struct ocfs2_xa_loc *loc,
2030{ 2028{
2031 int rc = 0; 2029 int rc = 0;
2032 2030
2033 if (!xi->xi_value) {
2034 rc = ocfs2_xa_remove(loc, ctxt);
2035 goto out;
2036 }
2037
2038 rc = ocfs2_xa_check_space(loc, xi); 2031 rc = ocfs2_xa_check_space(loc, xi);
2039 if (rc) 2032 if (rc)
2040 goto out; 2033 goto out;
@@ -2092,9 +2085,6 @@ static int ocfs2_xa_store_value(struct ocfs2_xa_loc *loc,
2092 char *nameval_buf; 2085 char *nameval_buf;
2093 struct ocfs2_xattr_value_buf vb; 2086 struct ocfs2_xattr_value_buf vb;
2094 2087
2095 if (!xi->xi_value)
2096 goto out;
2097
2098 nameval_buf = ocfs2_xa_offset_pointer(loc, nameval_offset); 2088 nameval_buf = ocfs2_xa_offset_pointer(loc, nameval_offset);
2099 if (xi->xi_value_len > OCFS2_XATTR_INLINE_SIZE) { 2089 if (xi->xi_value_len > OCFS2_XATTR_INLINE_SIZE) {
2100 ocfs2_xa_fill_value_buf(loc, &vb); 2090 ocfs2_xa_fill_value_buf(loc, &vb);
@@ -2105,10 +2095,49 @@ static int ocfs2_xa_store_value(struct ocfs2_xa_loc *loc,
2105 } else 2095 } else
2106 memcpy(nameval_buf + name_size, xi->xi_value, xi->xi_value_len); 2096 memcpy(nameval_buf + name_size, xi->xi_value, xi->xi_value_len);
2107 2097
2108out:
2109 return rc; 2098 return rc;
2110} 2099}
2111 2100
2101static int ocfs2_xa_set(struct ocfs2_xa_loc *loc,
2102 struct ocfs2_xattr_info *xi,
2103 struct ocfs2_xattr_set_ctxt *ctxt)
2104{
2105 int ret;
2106 u32 name_hash = ocfs2_xattr_name_hash(loc->xl_inode, xi->xi_name,
2107 xi->xi_name_len);
2108
2109 ret = ocfs2_xa_journal_access(ctxt->handle, loc,
2110 OCFS2_JOURNAL_ACCESS_WRITE);
2111 if (ret) {
2112 mlog_errno(ret);
2113 goto out;
2114 }
2115
2116 /* Don't worry, we are never called with !xi_value and !xl_entry */
2117 if (!xi->xi_value) {
2118 ret = ocfs2_xa_remove(loc, ctxt);
2119 goto out;
2120 }
2121
2122 ret = ocfs2_xa_prepare_entry(loc, xi, name_hash, ctxt);
2123 if (ret) {
2124 if (ret != -ENOSPC)
2125 mlog_errno(ret);
2126 goto out;
2127 }
2128
2129 ret = ocfs2_xa_store_value(loc, xi, ctxt);
2130 if (ret) {
2131 mlog_errno(ret);
2132 goto out;
2133 }
2134
2135 ocfs2_xa_journal_dirty(ctxt->handle, loc);
2136
2137out:
2138 return ret;
2139}
2140
2112static void ocfs2_init_dinode_xa_loc(struct ocfs2_xa_loc *loc, 2141static void ocfs2_init_dinode_xa_loc(struct ocfs2_xa_loc *loc,
2113 struct inode *inode, 2142 struct inode *inode,
2114 struct buffer_head *bh, 2143 struct buffer_head *bh,
@@ -2183,8 +2212,6 @@ static int ocfs2_xattr_set_entry(struct inode *inode,
2183 struct ocfs2_dinode *di = (struct ocfs2_dinode *)xs->inode_bh->b_data; 2212 struct ocfs2_dinode *di = (struct ocfs2_dinode *)xs->inode_bh->b_data;
2184 handle_t *handle = ctxt->handle; 2213 handle_t *handle = ctxt->handle;
2185 int ret; 2214 int ret;
2186 u32 name_hash = ocfs2_xattr_name_hash(inode, xi->xi_name,
2187 xi->xi_name_len);
2188 struct ocfs2_xa_loc loc; 2215 struct ocfs2_xa_loc loc;
2189 2216
2190 if (!(flag & OCFS2_INLINE_XATTR_FL)) 2217 if (!(flag & OCFS2_INLINE_XATTR_FL))
@@ -2205,14 +2232,8 @@ static int ocfs2_xattr_set_entry(struct inode *inode,
2205 else 2232 else
2206 ocfs2_init_xattr_block_xa_loc(&loc, inode, xs->xattr_bh, 2233 ocfs2_init_xattr_block_xa_loc(&loc, inode, xs->xattr_bh,
2207 xs->not_found ? NULL : xs->here); 2234 xs->not_found ? NULL : xs->here);
2208 ret = ocfs2_xa_journal_access(handle, &loc,
2209 OCFS2_JOURNAL_ACCESS_WRITE);
2210 if (ret) {
2211 mlog_errno(ret);
2212 goto out;
2213 }
2214 2235
2215 ret = ocfs2_xa_prepare_entry(&loc, xi, name_hash, ctxt); 2236 ret = ocfs2_xa_set(&loc, xi, ctxt);
2216 if (ret) { 2237 if (ret) {
2217 if (ret != -ENOSPC) 2238 if (ret != -ENOSPC)
2218 mlog_errno(ret); 2239 mlog_errno(ret);
@@ -2220,14 +2241,6 @@ static int ocfs2_xattr_set_entry(struct inode *inode,
2220 } 2241 }
2221 xs->here = loc.xl_entry; 2242 xs->here = loc.xl_entry;
2222 2243
2223 ret = ocfs2_xa_store_value(&loc, xi, ctxt);
2224 if (ret) {
2225 mlog_errno(ret);
2226 goto out;
2227 }
2228
2229 ocfs2_xa_journal_dirty(handle, &loc);
2230
2231 if (!(oi->ip_dyn_features & OCFS2_INLINE_XATTR_FL) && 2244 if (!(oi->ip_dyn_features & OCFS2_INLINE_XATTR_FL) &&
2232 (flag & OCFS2_INLINE_XATTR_FL)) { 2245 (flag & OCFS2_INLINE_XATTR_FL)) {
2233 struct ocfs2_super *osb = OCFS2_SB(inode->i_sb); 2246 struct ocfs2_super *osb = OCFS2_SB(inode->i_sb);
@@ -5415,8 +5428,6 @@ static int ocfs2_xattr_set_in_bucket(struct inode *inode,
5415 int ret; 5428 int ret;
5416 u64 blkno; 5429 u64 blkno;
5417 struct ocfs2_xa_loc loc; 5430 struct ocfs2_xa_loc loc;
5418 u32 name_hash = ocfs2_xattr_name_hash(inode, xi->xi_name,
5419 xi->xi_name_len);
5420 5431
5421 if (!xs->bucket->bu_bhs[1]) { 5432 if (!xs->bucket->bu_bhs[1]) {
5422 blkno = bucket_blkno(xs->bucket); 5433 blkno = bucket_blkno(xs->bucket);
@@ -5430,14 +5441,7 @@ static int ocfs2_xattr_set_in_bucket(struct inode *inode,
5430 5441
5431 ocfs2_init_xattr_bucket_xa_loc(&loc, xs->bucket, 5442 ocfs2_init_xattr_bucket_xa_loc(&loc, xs->bucket,
5432 xs->not_found ? NULL : xs->here); 5443 xs->not_found ? NULL : xs->here);
5433 ret = ocfs2_xa_journal_access(ctxt->handle, &loc, 5444 ret = ocfs2_xa_set(&loc, xi, ctxt);
5434 OCFS2_JOURNAL_ACCESS_WRITE);
5435 if (ret < 0) {
5436 mlog_errno(ret);
5437 goto out;
5438 }
5439
5440 ret = ocfs2_xa_prepare_entry(&loc, xi, name_hash, ctxt);
5441 if (ret) { 5445 if (ret) {
5442 if (ret != -ENOSPC) 5446 if (ret != -ENOSPC)
5443 mlog_errno(ret); 5447 mlog_errno(ret);
@@ -5445,14 +5449,6 @@ static int ocfs2_xattr_set_in_bucket(struct inode *inode,
5445 } 5449 }
5446 xs->here = loc.xl_entry; 5450 xs->here = loc.xl_entry;
5447 5451
5448 ret = ocfs2_xa_store_value(&loc, xi, ctxt);
5449 if (ret) {
5450 mlog_errno(ret);
5451 goto out;
5452 }
5453
5454 ocfs2_xa_journal_dirty(ctxt->handle, &loc);
5455
5456out: 5452out:
5457 return ret; 5453 return ret;
5458} 5454}