aboutsummaryrefslogtreecommitdiffstats
path: root/fs/xfs/xfs_attr_leaf.c
diff options
context:
space:
mode:
Diffstat (limited to 'fs/xfs/xfs_attr_leaf.c')
-rw-r--r--fs/xfs/xfs_attr_leaf.c54
1 files changed, 26 insertions, 28 deletions
diff --git a/fs/xfs/xfs_attr_leaf.c b/fs/xfs/xfs_attr_leaf.c
index 81f45dae1c57..b08e2a2a8add 100644
--- a/fs/xfs/xfs_attr_leaf.c
+++ b/fs/xfs/xfs_attr_leaf.c
@@ -226,17 +226,15 @@ xfs_attr_shortform_bytesfit(xfs_inode_t *dp, int bytes)
226STATIC void 226STATIC void
227xfs_sbversion_add_attr2(xfs_mount_t *mp, xfs_trans_t *tp) 227xfs_sbversion_add_attr2(xfs_mount_t *mp, xfs_trans_t *tp)
228{ 228{
229 unsigned long s;
230
231 if ((mp->m_flags & XFS_MOUNT_ATTR2) && 229 if ((mp->m_flags & XFS_MOUNT_ATTR2) &&
232 !(XFS_SB_VERSION_HASATTR2(&mp->m_sb))) { 230 !(XFS_SB_VERSION_HASATTR2(&mp->m_sb))) {
233 s = XFS_SB_LOCK(mp); 231 spin_lock(&mp->m_sb_lock);
234 if (!XFS_SB_VERSION_HASATTR2(&mp->m_sb)) { 232 if (!XFS_SB_VERSION_HASATTR2(&mp->m_sb)) {
235 XFS_SB_VERSION_ADDATTR2(&mp->m_sb); 233 XFS_SB_VERSION_ADDATTR2(&mp->m_sb);
236 XFS_SB_UNLOCK(mp, s); 234 spin_unlock(&mp->m_sb_lock);
237 xfs_mod_sb(tp, XFS_SB_VERSIONNUM | XFS_SB_FEATURES2); 235 xfs_mod_sb(tp, XFS_SB_VERSIONNUM | XFS_SB_FEATURES2);
238 } else 236 } else
239 XFS_SB_UNLOCK(mp, s); 237 spin_unlock(&mp->m_sb_lock);
240 } 238 }
241} 239}
242 240
@@ -319,7 +317,7 @@ xfs_attr_shortform_add(xfs_da_args_t *args, int forkoff)
319 memcpy(sfe->nameval, args->name, args->namelen); 317 memcpy(sfe->nameval, args->name, args->namelen);
320 memcpy(&sfe->nameval[args->namelen], args->value, args->valuelen); 318 memcpy(&sfe->nameval[args->namelen], args->value, args->valuelen);
321 sf->hdr.count++; 319 sf->hdr.count++;
322 be16_add(&sf->hdr.totsize, size); 320 be16_add_cpu(&sf->hdr.totsize, size);
323 xfs_trans_log_inode(args->trans, dp, XFS_ILOG_CORE | XFS_ILOG_ADATA); 321 xfs_trans_log_inode(args->trans, dp, XFS_ILOG_CORE | XFS_ILOG_ADATA);
324 322
325 xfs_sbversion_add_attr2(mp, args->trans); 323 xfs_sbversion_add_attr2(mp, args->trans);
@@ -365,7 +363,7 @@ xfs_attr_shortform_remove(xfs_da_args_t *args)
365 if (end != totsize) 363 if (end != totsize)
366 memmove(&((char *)sf)[base], &((char *)sf)[end], totsize - end); 364 memmove(&((char *)sf)[base], &((char *)sf)[end], totsize - end);
367 sf->hdr.count--; 365 sf->hdr.count--;
368 be16_add(&sf->hdr.totsize, -size); 366 be16_add_cpu(&sf->hdr.totsize, -size);
369 367
370 /* 368 /*
371 * Fix up the start offset of the attribute fork 369 * Fix up the start offset of the attribute fork
@@ -1135,7 +1133,7 @@ xfs_attr_leaf_add_work(xfs_dabuf_t *bp, xfs_da_args_t *args, int mapindex)
1135 xfs_da_log_buf(args->trans, bp, 1133 xfs_da_log_buf(args->trans, bp,
1136 XFS_DA_LOGRANGE(leaf, entry, tmp + sizeof(*entry))); 1134 XFS_DA_LOGRANGE(leaf, entry, tmp + sizeof(*entry)));
1137 } 1135 }
1138 be16_add(&hdr->count, 1); 1136 be16_add_cpu(&hdr->count, 1);
1139 1137
1140 /* 1138 /*
1141 * Allocate space for the new string (at the end of the run). 1139 * Allocate space for the new string (at the end of the run).
@@ -1149,7 +1147,7 @@ xfs_attr_leaf_add_work(xfs_dabuf_t *bp, xfs_da_args_t *args, int mapindex)
1149 mp->m_sb.sb_blocksize, NULL)); 1147 mp->m_sb.sb_blocksize, NULL));
1150 ASSERT(be16_to_cpu(map->size) < XFS_LBSIZE(mp)); 1148 ASSERT(be16_to_cpu(map->size) < XFS_LBSIZE(mp));
1151 ASSERT((be16_to_cpu(map->size) & 0x3) == 0); 1149 ASSERT((be16_to_cpu(map->size) & 0x3) == 0);
1152 be16_add(&map->size, 1150 be16_add_cpu(&map->size,
1153 -xfs_attr_leaf_newentsize(args->namelen, args->valuelen, 1151 -xfs_attr_leaf_newentsize(args->namelen, args->valuelen,
1154 mp->m_sb.sb_blocksize, &tmp)); 1152 mp->m_sb.sb_blocksize, &tmp));
1155 entry->nameidx = cpu_to_be16(be16_to_cpu(map->base) + 1153 entry->nameidx = cpu_to_be16(be16_to_cpu(map->base) +
@@ -1216,12 +1214,12 @@ xfs_attr_leaf_add_work(xfs_dabuf_t *bp, xfs_da_args_t *args, int mapindex)
1216 map = &hdr->freemap[0]; 1214 map = &hdr->freemap[0];
1217 for (i = 0; i < XFS_ATTR_LEAF_MAPSIZE; map++, i++) { 1215 for (i = 0; i < XFS_ATTR_LEAF_MAPSIZE; map++, i++) {
1218 if (be16_to_cpu(map->base) == tmp) { 1216 if (be16_to_cpu(map->base) == tmp) {
1219 be16_add(&map->base, sizeof(xfs_attr_leaf_entry_t)); 1217 be16_add_cpu(&map->base, sizeof(xfs_attr_leaf_entry_t));
1220 be16_add(&map->size, 1218 be16_add_cpu(&map->size,
1221 -((int)sizeof(xfs_attr_leaf_entry_t))); 1219 -((int)sizeof(xfs_attr_leaf_entry_t)));
1222 } 1220 }
1223 } 1221 }
1224 be16_add(&hdr->usedbytes, xfs_attr_leaf_entsize(leaf, args->index)); 1222 be16_add_cpu(&hdr->usedbytes, xfs_attr_leaf_entsize(leaf, args->index));
1225 xfs_da_log_buf(args->trans, bp, 1223 xfs_da_log_buf(args->trans, bp,
1226 XFS_DA_LOGRANGE(leaf, hdr, sizeof(*hdr))); 1224 XFS_DA_LOGRANGE(leaf, hdr, sizeof(*hdr)));
1227 return(0); 1225 return(0);
@@ -1729,9 +1727,9 @@ xfs_attr_leaf_remove(xfs_dabuf_t *bp, xfs_da_args_t *args)
1729 ASSERT(be16_to_cpu(map->base) < XFS_LBSIZE(mp)); 1727 ASSERT(be16_to_cpu(map->base) < XFS_LBSIZE(mp));
1730 ASSERT(be16_to_cpu(map->size) < XFS_LBSIZE(mp)); 1728 ASSERT(be16_to_cpu(map->size) < XFS_LBSIZE(mp));
1731 if (be16_to_cpu(map->base) == tablesize) { 1729 if (be16_to_cpu(map->base) == tablesize) {
1732 be16_add(&map->base, 1730 be16_add_cpu(&map->base,
1733 -((int)sizeof(xfs_attr_leaf_entry_t))); 1731 -((int)sizeof(xfs_attr_leaf_entry_t)));
1734 be16_add(&map->size, sizeof(xfs_attr_leaf_entry_t)); 1732 be16_add_cpu(&map->size, sizeof(xfs_attr_leaf_entry_t));
1735 } 1733 }
1736 1734
1737 if ((be16_to_cpu(map->base) + be16_to_cpu(map->size)) 1735 if ((be16_to_cpu(map->base) + be16_to_cpu(map->size))
@@ -1753,19 +1751,19 @@ xfs_attr_leaf_remove(xfs_dabuf_t *bp, xfs_da_args_t *args)
1753 if ((before >= 0) || (after >= 0)) { 1751 if ((before >= 0) || (after >= 0)) {
1754 if ((before >= 0) && (after >= 0)) { 1752 if ((before >= 0) && (after >= 0)) {
1755 map = &hdr->freemap[before]; 1753 map = &hdr->freemap[before];
1756 be16_add(&map->size, entsize); 1754 be16_add_cpu(&map->size, entsize);
1757 be16_add(&map->size, 1755 be16_add_cpu(&map->size,
1758 be16_to_cpu(hdr->freemap[after].size)); 1756 be16_to_cpu(hdr->freemap[after].size));
1759 hdr->freemap[after].base = 0; 1757 hdr->freemap[after].base = 0;
1760 hdr->freemap[after].size = 0; 1758 hdr->freemap[after].size = 0;
1761 } else if (before >= 0) { 1759 } else if (before >= 0) {
1762 map = &hdr->freemap[before]; 1760 map = &hdr->freemap[before];
1763 be16_add(&map->size, entsize); 1761 be16_add_cpu(&map->size, entsize);
1764 } else { 1762 } else {
1765 map = &hdr->freemap[after]; 1763 map = &hdr->freemap[after];
1766 /* both on-disk, don't endian flip twice */ 1764 /* both on-disk, don't endian flip twice */
1767 map->base = entry->nameidx; 1765 map->base = entry->nameidx;
1768 be16_add(&map->size, entsize); 1766 be16_add_cpu(&map->size, entsize);
1769 } 1767 }
1770 } else { 1768 } else {
1771 /* 1769 /*
@@ -1790,7 +1788,7 @@ xfs_attr_leaf_remove(xfs_dabuf_t *bp, xfs_da_args_t *args)
1790 * Compress the remaining entries and zero out the removed stuff. 1788 * Compress the remaining entries and zero out the removed stuff.
1791 */ 1789 */
1792 memset(XFS_ATTR_LEAF_NAME(leaf, args->index), 0, entsize); 1790 memset(XFS_ATTR_LEAF_NAME(leaf, args->index), 0, entsize);
1793 be16_add(&hdr->usedbytes, -entsize); 1791 be16_add_cpu(&hdr->usedbytes, -entsize);
1794 xfs_da_log_buf(args->trans, bp, 1792 xfs_da_log_buf(args->trans, bp,
1795 XFS_DA_LOGRANGE(leaf, XFS_ATTR_LEAF_NAME(leaf, args->index), 1793 XFS_DA_LOGRANGE(leaf, XFS_ATTR_LEAF_NAME(leaf, args->index),
1796 entsize)); 1794 entsize));
@@ -1798,7 +1796,7 @@ xfs_attr_leaf_remove(xfs_dabuf_t *bp, xfs_da_args_t *args)
1798 tmp = (be16_to_cpu(hdr->count) - args->index) 1796 tmp = (be16_to_cpu(hdr->count) - args->index)
1799 * sizeof(xfs_attr_leaf_entry_t); 1797 * sizeof(xfs_attr_leaf_entry_t);
1800 memmove((char *)entry, (char *)(entry+1), tmp); 1798 memmove((char *)entry, (char *)(entry+1), tmp);
1801 be16_add(&hdr->count, -1); 1799 be16_add_cpu(&hdr->count, -1);
1802 xfs_da_log_buf(args->trans, bp, 1800 xfs_da_log_buf(args->trans, bp,
1803 XFS_DA_LOGRANGE(leaf, entry, tmp + sizeof(*entry))); 1801 XFS_DA_LOGRANGE(leaf, entry, tmp + sizeof(*entry)));
1804 entry = &leaf->entries[be16_to_cpu(hdr->count)]; 1802 entry = &leaf->entries[be16_to_cpu(hdr->count)];
@@ -2184,15 +2182,15 @@ xfs_attr_leaf_moveents(xfs_attr_leafblock_t *leaf_s, int start_s,
2184 */ 2182 */
2185 if (entry_s->flags & XFS_ATTR_INCOMPLETE) { /* skip partials? */ 2183 if (entry_s->flags & XFS_ATTR_INCOMPLETE) { /* skip partials? */
2186 memset(XFS_ATTR_LEAF_NAME(leaf_s, start_s + i), 0, tmp); 2184 memset(XFS_ATTR_LEAF_NAME(leaf_s, start_s + i), 0, tmp);
2187 be16_add(&hdr_s->usedbytes, -tmp); 2185 be16_add_cpu(&hdr_s->usedbytes, -tmp);
2188 be16_add(&hdr_s->count, -1); 2186 be16_add_cpu(&hdr_s->count, -1);
2189 entry_d--; /* to compensate for ++ in loop hdr */ 2187 entry_d--; /* to compensate for ++ in loop hdr */
2190 desti--; 2188 desti--;
2191 if ((start_s + i) < offset) 2189 if ((start_s + i) < offset)
2192 result++; /* insertion index adjustment */ 2190 result++; /* insertion index adjustment */
2193 } else { 2191 } else {
2194#endif /* GROT */ 2192#endif /* GROT */
2195 be16_add(&hdr_d->firstused, -tmp); 2193 be16_add_cpu(&hdr_d->firstused, -tmp);
2196 /* both on-disk, don't endian flip twice */ 2194 /* both on-disk, don't endian flip twice */
2197 entry_d->hashval = entry_s->hashval; 2195 entry_d->hashval = entry_s->hashval;
2198 /* both on-disk, don't endian flip twice */ 2196 /* both on-disk, don't endian flip twice */
@@ -2205,10 +2203,10 @@ xfs_attr_leaf_moveents(xfs_attr_leafblock_t *leaf_s, int start_s,
2205 ASSERT(be16_to_cpu(entry_s->nameidx) + tmp 2203 ASSERT(be16_to_cpu(entry_s->nameidx) + tmp
2206 <= XFS_LBSIZE(mp)); 2204 <= XFS_LBSIZE(mp));
2207 memset(XFS_ATTR_LEAF_NAME(leaf_s, start_s + i), 0, tmp); 2205 memset(XFS_ATTR_LEAF_NAME(leaf_s, start_s + i), 0, tmp);
2208 be16_add(&hdr_s->usedbytes, -tmp); 2206 be16_add_cpu(&hdr_s->usedbytes, -tmp);
2209 be16_add(&hdr_d->usedbytes, tmp); 2207 be16_add_cpu(&hdr_d->usedbytes, tmp);
2210 be16_add(&hdr_s->count, -1); 2208 be16_add_cpu(&hdr_s->count, -1);
2211 be16_add(&hdr_d->count, 1); 2209 be16_add_cpu(&hdr_d->count, 1);
2212 tmp = be16_to_cpu(hdr_d->count) 2210 tmp = be16_to_cpu(hdr_d->count)
2213 * sizeof(xfs_attr_leaf_entry_t) 2211 * sizeof(xfs_attr_leaf_entry_t)
2214 + sizeof(xfs_attr_leaf_hdr_t); 2212 + sizeof(xfs_attr_leaf_hdr_t);
@@ -2249,7 +2247,7 @@ xfs_attr_leaf_moveents(xfs_attr_leafblock_t *leaf_s, int start_s,
2249 * Fill in the freemap information 2247 * Fill in the freemap information
2250 */ 2248 */
2251 hdr_d->freemap[0].base = cpu_to_be16(sizeof(xfs_attr_leaf_hdr_t)); 2249 hdr_d->freemap[0].base = cpu_to_be16(sizeof(xfs_attr_leaf_hdr_t));
2252 be16_add(&hdr_d->freemap[0].base, be16_to_cpu(hdr_d->count) * 2250 be16_add_cpu(&hdr_d->freemap[0].base, be16_to_cpu(hdr_d->count) *
2253 sizeof(xfs_attr_leaf_entry_t)); 2251 sizeof(xfs_attr_leaf_entry_t));
2254 hdr_d->freemap[0].size = cpu_to_be16(be16_to_cpu(hdr_d->firstused) 2252 hdr_d->freemap[0].size = cpu_to_be16(be16_to_cpu(hdr_d->firstused)
2255 - be16_to_cpu(hdr_d->freemap[0].base)); 2253 - be16_to_cpu(hdr_d->freemap[0].base));