diff options
Diffstat (limited to 'fs/xfs')
57 files changed, 1692 insertions, 857 deletions
diff --git a/fs/xfs/Makefile b/fs/xfs/Makefile index 6313b69b6644..4a4508023a3c 100644 --- a/fs/xfs/Makefile +++ b/fs/xfs/Makefile | |||
@@ -71,6 +71,7 @@ xfs-y += xfs_alloc.o \ | |||
71 | xfs_dir2_sf.o \ | 71 | xfs_dir2_sf.o \ |
72 | xfs_ialloc.o \ | 72 | xfs_ialloc.o \ |
73 | xfs_ialloc_btree.o \ | 73 | xfs_ialloc_btree.o \ |
74 | xfs_icreate_item.o \ | ||
74 | xfs_inode.o \ | 75 | xfs_inode.o \ |
75 | xfs_log_recover.o \ | 76 | xfs_log_recover.o \ |
76 | xfs_mount.o \ | 77 | xfs_mount.o \ |
diff --git a/fs/xfs/xfs_alloc.c b/fs/xfs/xfs_alloc.c index 5673bcfda2f0..71596e57283a 100644 --- a/fs/xfs/xfs_alloc.c +++ b/fs/xfs/xfs_alloc.c | |||
@@ -175,6 +175,7 @@ xfs_alloc_compute_diff( | |||
175 | xfs_agblock_t wantbno, /* target starting block */ | 175 | xfs_agblock_t wantbno, /* target starting block */ |
176 | xfs_extlen_t wantlen, /* target length */ | 176 | xfs_extlen_t wantlen, /* target length */ |
177 | xfs_extlen_t alignment, /* target alignment */ | 177 | xfs_extlen_t alignment, /* target alignment */ |
178 | char userdata, /* are we allocating data? */ | ||
178 | xfs_agblock_t freebno, /* freespace's starting block */ | 179 | xfs_agblock_t freebno, /* freespace's starting block */ |
179 | xfs_extlen_t freelen, /* freespace's length */ | 180 | xfs_extlen_t freelen, /* freespace's length */ |
180 | xfs_agblock_t *newbnop) /* result: best start block from free */ | 181 | xfs_agblock_t *newbnop) /* result: best start block from free */ |
@@ -189,7 +190,14 @@ xfs_alloc_compute_diff( | |||
189 | ASSERT(freelen >= wantlen); | 190 | ASSERT(freelen >= wantlen); |
190 | freeend = freebno + freelen; | 191 | freeend = freebno + freelen; |
191 | wantend = wantbno + wantlen; | 192 | wantend = wantbno + wantlen; |
192 | if (freebno >= wantbno) { | 193 | /* |
194 | * We want to allocate from the start of a free extent if it is past | ||
195 | * the desired block or if we are allocating user data and the free | ||
196 | * extent is before desired block. The second case is there to allow | ||
197 | * for contiguous allocation from the remaining free space if the file | ||
198 | * grows in the short term. | ||
199 | */ | ||
200 | if (freebno >= wantbno || (userdata && freeend < wantend)) { | ||
193 | if ((newbno1 = roundup(freebno, alignment)) >= freeend) | 201 | if ((newbno1 = roundup(freebno, alignment)) >= freeend) |
194 | newbno1 = NULLAGBLOCK; | 202 | newbno1 = NULLAGBLOCK; |
195 | } else if (freeend >= wantend && alignment > 1) { | 203 | } else if (freeend >= wantend && alignment > 1) { |
@@ -805,7 +813,8 @@ xfs_alloc_find_best_extent( | |||
805 | xfs_alloc_fix_len(args); | 813 | xfs_alloc_fix_len(args); |
806 | 814 | ||
807 | sdiff = xfs_alloc_compute_diff(args->agbno, args->len, | 815 | sdiff = xfs_alloc_compute_diff(args->agbno, args->len, |
808 | args->alignment, *sbnoa, | 816 | args->alignment, |
817 | args->userdata, *sbnoa, | ||
809 | *slena, &new); | 818 | *slena, &new); |
810 | 819 | ||
811 | /* | 820 | /* |
@@ -976,7 +985,8 @@ restart: | |||
976 | if (args->len < blen) | 985 | if (args->len < blen) |
977 | continue; | 986 | continue; |
978 | ltdiff = xfs_alloc_compute_diff(args->agbno, args->len, | 987 | ltdiff = xfs_alloc_compute_diff(args->agbno, args->len, |
979 | args->alignment, ltbnoa, ltlena, <new); | 988 | args->alignment, args->userdata, ltbnoa, |
989 | ltlena, <new); | ||
980 | if (ltnew != NULLAGBLOCK && | 990 | if (ltnew != NULLAGBLOCK && |
981 | (args->len > blen || ltdiff < bdiff)) { | 991 | (args->len > blen || ltdiff < bdiff)) { |
982 | bdiff = ltdiff; | 992 | bdiff = ltdiff; |
@@ -1128,7 +1138,8 @@ restart: | |||
1128 | args->len = XFS_EXTLEN_MIN(ltlena, args->maxlen); | 1138 | args->len = XFS_EXTLEN_MIN(ltlena, args->maxlen); |
1129 | xfs_alloc_fix_len(args); | 1139 | xfs_alloc_fix_len(args); |
1130 | ltdiff = xfs_alloc_compute_diff(args->agbno, args->len, | 1140 | ltdiff = xfs_alloc_compute_diff(args->agbno, args->len, |
1131 | args->alignment, ltbnoa, ltlena, <new); | 1141 | args->alignment, args->userdata, ltbnoa, |
1142 | ltlena, <new); | ||
1132 | 1143 | ||
1133 | error = xfs_alloc_find_best_extent(args, | 1144 | error = xfs_alloc_find_best_extent(args, |
1134 | &bno_cur_lt, &bno_cur_gt, | 1145 | &bno_cur_lt, &bno_cur_gt, |
@@ -1144,7 +1155,8 @@ restart: | |||
1144 | args->len = XFS_EXTLEN_MIN(gtlena, args->maxlen); | 1155 | args->len = XFS_EXTLEN_MIN(gtlena, args->maxlen); |
1145 | xfs_alloc_fix_len(args); | 1156 | xfs_alloc_fix_len(args); |
1146 | gtdiff = xfs_alloc_compute_diff(args->agbno, args->len, | 1157 | gtdiff = xfs_alloc_compute_diff(args->agbno, args->len, |
1147 | args->alignment, gtbnoa, gtlena, >new); | 1158 | args->alignment, args->userdata, gtbnoa, |
1159 | gtlena, >new); | ||
1148 | 1160 | ||
1149 | error = xfs_alloc_find_best_extent(args, | 1161 | error = xfs_alloc_find_best_extent(args, |
1150 | &bno_cur_gt, &bno_cur_lt, | 1162 | &bno_cur_gt, &bno_cur_lt, |
@@ -1203,7 +1215,7 @@ restart: | |||
1203 | } | 1215 | } |
1204 | rlen = args->len; | 1216 | rlen = args->len; |
1205 | (void)xfs_alloc_compute_diff(args->agbno, rlen, args->alignment, | 1217 | (void)xfs_alloc_compute_diff(args->agbno, rlen, args->alignment, |
1206 | ltbnoa, ltlena, <new); | 1218 | args->userdata, ltbnoa, ltlena, <new); |
1207 | ASSERT(ltnew >= ltbno); | 1219 | ASSERT(ltnew >= ltbno); |
1208 | ASSERT(ltnew + rlen <= ltbnoa + ltlena); | 1220 | ASSERT(ltnew + rlen <= ltbnoa + ltlena); |
1209 | ASSERT(ltnew + rlen <= be32_to_cpu(XFS_BUF_TO_AGF(args->agbp)->agf_length)); | 1221 | ASSERT(ltnew + rlen <= be32_to_cpu(XFS_BUF_TO_AGF(args->agbp)->agf_length)); |
diff --git a/fs/xfs/xfs_aops.c b/fs/xfs/xfs_aops.c index 41a695048be7..596ec71da00e 100644 --- a/fs/xfs/xfs_aops.c +++ b/fs/xfs/xfs_aops.c | |||
@@ -843,10 +843,12 @@ xfs_cluster_write( | |||
843 | STATIC void | 843 | STATIC void |
844 | xfs_vm_invalidatepage( | 844 | xfs_vm_invalidatepage( |
845 | struct page *page, | 845 | struct page *page, |
846 | unsigned long offset) | 846 | unsigned int offset, |
847 | unsigned int length) | ||
847 | { | 848 | { |
848 | trace_xfs_invalidatepage(page->mapping->host, page, offset); | 849 | trace_xfs_invalidatepage(page->mapping->host, page, offset, |
849 | block_invalidatepage(page, offset); | 850 | length); |
851 | block_invalidatepage(page, offset, length); | ||
850 | } | 852 | } |
851 | 853 | ||
852 | /* | 854 | /* |
@@ -910,7 +912,7 @@ next_buffer: | |||
910 | 912 | ||
911 | xfs_iunlock(ip, XFS_ILOCK_EXCL); | 913 | xfs_iunlock(ip, XFS_ILOCK_EXCL); |
912 | out_invalidate: | 914 | out_invalidate: |
913 | xfs_vm_invalidatepage(page, 0); | 915 | xfs_vm_invalidatepage(page, 0, PAGE_CACHE_SIZE); |
914 | return; | 916 | return; |
915 | } | 917 | } |
916 | 918 | ||
@@ -940,7 +942,7 @@ xfs_vm_writepage( | |||
940 | int count = 0; | 942 | int count = 0; |
941 | int nonblocking = 0; | 943 | int nonblocking = 0; |
942 | 944 | ||
943 | trace_xfs_writepage(inode, page, 0); | 945 | trace_xfs_writepage(inode, page, 0, 0); |
944 | 946 | ||
945 | ASSERT(page_has_buffers(page)); | 947 | ASSERT(page_has_buffers(page)); |
946 | 948 | ||
@@ -1171,7 +1173,7 @@ xfs_vm_releasepage( | |||
1171 | { | 1173 | { |
1172 | int delalloc, unwritten; | 1174 | int delalloc, unwritten; |
1173 | 1175 | ||
1174 | trace_xfs_releasepage(page->mapping->host, page, 0); | 1176 | trace_xfs_releasepage(page->mapping->host, page, 0, 0); |
1175 | 1177 | ||
1176 | xfs_count_page_state(page, &delalloc, &unwritten); | 1178 | xfs_count_page_state(page, &delalloc, &unwritten); |
1177 | 1179 | ||
diff --git a/fs/xfs/xfs_attr_leaf.c b/fs/xfs/xfs_attr_leaf.c index 31d3cd129269..b800fbcafc7f 100644 --- a/fs/xfs/xfs_attr_leaf.c +++ b/fs/xfs/xfs_attr_leaf.c | |||
@@ -690,6 +690,8 @@ xfs_attr_shortform_to_leaf(xfs_da_args_t *args) | |||
690 | sf = (xfs_attr_shortform_t *)tmpbuffer; | 690 | sf = (xfs_attr_shortform_t *)tmpbuffer; |
691 | 691 | ||
692 | xfs_idata_realloc(dp, -size, XFS_ATTR_FORK); | 692 | xfs_idata_realloc(dp, -size, XFS_ATTR_FORK); |
693 | xfs_bmap_local_to_extents_empty(dp, XFS_ATTR_FORK); | ||
694 | |||
693 | bp = NULL; | 695 | bp = NULL; |
694 | error = xfs_da_grow_inode(args, &blkno); | 696 | error = xfs_da_grow_inode(args, &blkno); |
695 | if (error) { | 697 | if (error) { |
diff --git a/fs/xfs/xfs_bmap.c b/fs/xfs/xfs_bmap.c index 89042848f9ec..05c698ccb238 100644 --- a/fs/xfs/xfs_bmap.c +++ b/fs/xfs/xfs_bmap.c | |||
@@ -1161,6 +1161,24 @@ xfs_bmap_extents_to_btree( | |||
1161 | * since the file data needs to get logged so things will stay consistent. | 1161 | * since the file data needs to get logged so things will stay consistent. |
1162 | * (The bmap-level manipulations are ok, though). | 1162 | * (The bmap-level manipulations are ok, though). |
1163 | */ | 1163 | */ |
1164 | void | ||
1165 | xfs_bmap_local_to_extents_empty( | ||
1166 | struct xfs_inode *ip, | ||
1167 | int whichfork) | ||
1168 | { | ||
1169 | struct xfs_ifork *ifp = XFS_IFORK_PTR(ip, whichfork); | ||
1170 | |||
1171 | ASSERT(XFS_IFORK_FORMAT(ip, whichfork) == XFS_DINODE_FMT_LOCAL); | ||
1172 | ASSERT(ifp->if_bytes == 0); | ||
1173 | ASSERT(XFS_IFORK_NEXTENTS(ip, whichfork) == 0); | ||
1174 | |||
1175 | xfs_bmap_forkoff_reset(ip->i_mount, ip, whichfork); | ||
1176 | ifp->if_flags &= ~XFS_IFINLINE; | ||
1177 | ifp->if_flags |= XFS_IFEXTENTS; | ||
1178 | XFS_IFORK_FMT_SET(ip, whichfork, XFS_DINODE_FMT_EXTENTS); | ||
1179 | } | ||
1180 | |||
1181 | |||
1164 | STATIC int /* error */ | 1182 | STATIC int /* error */ |
1165 | xfs_bmap_local_to_extents( | 1183 | xfs_bmap_local_to_extents( |
1166 | xfs_trans_t *tp, /* transaction pointer */ | 1184 | xfs_trans_t *tp, /* transaction pointer */ |
@@ -1174,9 +1192,12 @@ xfs_bmap_local_to_extents( | |||
1174 | struct xfs_inode *ip, | 1192 | struct xfs_inode *ip, |
1175 | struct xfs_ifork *ifp)) | 1193 | struct xfs_ifork *ifp)) |
1176 | { | 1194 | { |
1177 | int error; /* error return value */ | 1195 | int error = 0; |
1178 | int flags; /* logging flags returned */ | 1196 | int flags; /* logging flags returned */ |
1179 | xfs_ifork_t *ifp; /* inode fork pointer */ | 1197 | xfs_ifork_t *ifp; /* inode fork pointer */ |
1198 | xfs_alloc_arg_t args; /* allocation arguments */ | ||
1199 | xfs_buf_t *bp; /* buffer for extent block */ | ||
1200 | xfs_bmbt_rec_host_t *ep; /* extent record pointer */ | ||
1180 | 1201 | ||
1181 | /* | 1202 | /* |
1182 | * We don't want to deal with the case of keeping inode data inline yet. | 1203 | * We don't want to deal with the case of keeping inode data inline yet. |
@@ -1185,68 +1206,65 @@ xfs_bmap_local_to_extents( | |||
1185 | ASSERT(!(S_ISREG(ip->i_d.di_mode) && whichfork == XFS_DATA_FORK)); | 1206 | ASSERT(!(S_ISREG(ip->i_d.di_mode) && whichfork == XFS_DATA_FORK)); |
1186 | ifp = XFS_IFORK_PTR(ip, whichfork); | 1207 | ifp = XFS_IFORK_PTR(ip, whichfork); |
1187 | ASSERT(XFS_IFORK_FORMAT(ip, whichfork) == XFS_DINODE_FMT_LOCAL); | 1208 | ASSERT(XFS_IFORK_FORMAT(ip, whichfork) == XFS_DINODE_FMT_LOCAL); |
1209 | |||
1210 | if (!ifp->if_bytes) { | ||
1211 | xfs_bmap_local_to_extents_empty(ip, whichfork); | ||
1212 | flags = XFS_ILOG_CORE; | ||
1213 | goto done; | ||
1214 | } | ||
1215 | |||
1188 | flags = 0; | 1216 | flags = 0; |
1189 | error = 0; | 1217 | error = 0; |
1190 | if (ifp->if_bytes) { | 1218 | ASSERT((ifp->if_flags & (XFS_IFINLINE|XFS_IFEXTENTS|XFS_IFEXTIREC)) == |
1191 | xfs_alloc_arg_t args; /* allocation arguments */ | 1219 | XFS_IFINLINE); |
1192 | xfs_buf_t *bp; /* buffer for extent block */ | 1220 | memset(&args, 0, sizeof(args)); |
1193 | xfs_bmbt_rec_host_t *ep;/* extent record pointer */ | 1221 | args.tp = tp; |
1194 | 1222 | args.mp = ip->i_mount; | |
1195 | ASSERT((ifp->if_flags & | 1223 | args.firstblock = *firstblock; |
1196 | (XFS_IFINLINE|XFS_IFEXTENTS|XFS_IFEXTIREC)) == XFS_IFINLINE); | 1224 | /* |
1197 | memset(&args, 0, sizeof(args)); | 1225 | * Allocate a block. We know we need only one, since the |
1198 | args.tp = tp; | 1226 | * file currently fits in an inode. |
1199 | args.mp = ip->i_mount; | 1227 | */ |
1200 | args.firstblock = *firstblock; | 1228 | if (*firstblock == NULLFSBLOCK) { |
1201 | /* | 1229 | args.fsbno = XFS_INO_TO_FSB(args.mp, ip->i_ino); |
1202 | * Allocate a block. We know we need only one, since the | 1230 | args.type = XFS_ALLOCTYPE_START_BNO; |
1203 | * file currently fits in an inode. | ||
1204 | */ | ||
1205 | if (*firstblock == NULLFSBLOCK) { | ||
1206 | args.fsbno = XFS_INO_TO_FSB(args.mp, ip->i_ino); | ||
1207 | args.type = XFS_ALLOCTYPE_START_BNO; | ||
1208 | } else { | ||
1209 | args.fsbno = *firstblock; | ||
1210 | args.type = XFS_ALLOCTYPE_NEAR_BNO; | ||
1211 | } | ||
1212 | args.total = total; | ||
1213 | args.minlen = args.maxlen = args.prod = 1; | ||
1214 | error = xfs_alloc_vextent(&args); | ||
1215 | if (error) | ||
1216 | goto done; | ||
1217 | |||
1218 | /* Can't fail, the space was reserved. */ | ||
1219 | ASSERT(args.fsbno != NULLFSBLOCK); | ||
1220 | ASSERT(args.len == 1); | ||
1221 | *firstblock = args.fsbno; | ||
1222 | bp = xfs_btree_get_bufl(args.mp, tp, args.fsbno, 0); | ||
1223 | |||
1224 | /* initialise the block and copy the data */ | ||
1225 | init_fn(tp, bp, ip, ifp); | ||
1226 | |||
1227 | /* account for the change in fork size and log everything */ | ||
1228 | xfs_trans_log_buf(tp, bp, 0, ifp->if_bytes - 1); | ||
1229 | xfs_bmap_forkoff_reset(args.mp, ip, whichfork); | ||
1230 | xfs_idata_realloc(ip, -ifp->if_bytes, whichfork); | ||
1231 | xfs_iext_add(ifp, 0, 1); | ||
1232 | ep = xfs_iext_get_ext(ifp, 0); | ||
1233 | xfs_bmbt_set_allf(ep, 0, args.fsbno, 1, XFS_EXT_NORM); | ||
1234 | trace_xfs_bmap_post_update(ip, 0, | ||
1235 | whichfork == XFS_ATTR_FORK ? BMAP_ATTRFORK : 0, | ||
1236 | _THIS_IP_); | ||
1237 | XFS_IFORK_NEXT_SET(ip, whichfork, 1); | ||
1238 | ip->i_d.di_nblocks = 1; | ||
1239 | xfs_trans_mod_dquot_byino(tp, ip, | ||
1240 | XFS_TRANS_DQ_BCOUNT, 1L); | ||
1241 | flags |= xfs_ilog_fext(whichfork); | ||
1242 | } else { | 1231 | } else { |
1243 | ASSERT(XFS_IFORK_NEXTENTS(ip, whichfork) == 0); | 1232 | args.fsbno = *firstblock; |
1244 | xfs_bmap_forkoff_reset(ip->i_mount, ip, whichfork); | 1233 | args.type = XFS_ALLOCTYPE_NEAR_BNO; |
1245 | } | 1234 | } |
1246 | ifp->if_flags &= ~XFS_IFINLINE; | 1235 | args.total = total; |
1247 | ifp->if_flags |= XFS_IFEXTENTS; | 1236 | args.minlen = args.maxlen = args.prod = 1; |
1248 | XFS_IFORK_FMT_SET(ip, whichfork, XFS_DINODE_FMT_EXTENTS); | 1237 | error = xfs_alloc_vextent(&args); |
1238 | if (error) | ||
1239 | goto done; | ||
1240 | |||
1241 | /* Can't fail, the space was reserved. */ | ||
1242 | ASSERT(args.fsbno != NULLFSBLOCK); | ||
1243 | ASSERT(args.len == 1); | ||
1244 | *firstblock = args.fsbno; | ||
1245 | bp = xfs_btree_get_bufl(args.mp, tp, args.fsbno, 0); | ||
1246 | |||
1247 | /* initialise the block and copy the data */ | ||
1248 | init_fn(tp, bp, ip, ifp); | ||
1249 | |||
1250 | /* account for the change in fork size and log everything */ | ||
1251 | xfs_trans_log_buf(tp, bp, 0, ifp->if_bytes - 1); | ||
1252 | xfs_idata_realloc(ip, -ifp->if_bytes, whichfork); | ||
1253 | xfs_bmap_local_to_extents_empty(ip, whichfork); | ||
1249 | flags |= XFS_ILOG_CORE; | 1254 | flags |= XFS_ILOG_CORE; |
1255 | |||
1256 | xfs_iext_add(ifp, 0, 1); | ||
1257 | ep = xfs_iext_get_ext(ifp, 0); | ||
1258 | xfs_bmbt_set_allf(ep, 0, args.fsbno, 1, XFS_EXT_NORM); | ||
1259 | trace_xfs_bmap_post_update(ip, 0, | ||
1260 | whichfork == XFS_ATTR_FORK ? BMAP_ATTRFORK : 0, | ||
1261 | _THIS_IP_); | ||
1262 | XFS_IFORK_NEXT_SET(ip, whichfork, 1); | ||
1263 | ip->i_d.di_nblocks = 1; | ||
1264 | xfs_trans_mod_dquot_byino(tp, ip, | ||
1265 | XFS_TRANS_DQ_BCOUNT, 1L); | ||
1266 | flags |= xfs_ilog_fext(whichfork); | ||
1267 | |||
1250 | done: | 1268 | done: |
1251 | *logflagsp = flags; | 1269 | *logflagsp = flags; |
1252 | return error; | 1270 | return error; |
@@ -1323,25 +1341,6 @@ xfs_bmap_add_attrfork_extents( | |||
1323 | } | 1341 | } |
1324 | 1342 | ||
1325 | /* | 1343 | /* |
1326 | * Block initialisation function for local to extent format conversion. | ||
1327 | * | ||
1328 | * This shouldn't actually be called by anyone, so make sure debug kernels cause | ||
1329 | * a noticable failure. | ||
1330 | */ | ||
1331 | STATIC void | ||
1332 | xfs_bmap_local_to_extents_init_fn( | ||
1333 | struct xfs_trans *tp, | ||
1334 | struct xfs_buf *bp, | ||
1335 | struct xfs_inode *ip, | ||
1336 | struct xfs_ifork *ifp) | ||
1337 | { | ||
1338 | ASSERT(0); | ||
1339 | bp->b_ops = &xfs_bmbt_buf_ops; | ||
1340 | memcpy(bp->b_addr, ifp->if_u1.if_data, ifp->if_bytes); | ||
1341 | xfs_trans_buf_set_type(tp, bp, XFS_BLFT_BTREE_BUF); | ||
1342 | } | ||
1343 | |||
1344 | /* | ||
1345 | * Called from xfs_bmap_add_attrfork to handle local format files. Each | 1344 | * Called from xfs_bmap_add_attrfork to handle local format files. Each |
1346 | * different data fork content type needs a different callout to do the | 1345 | * different data fork content type needs a different callout to do the |
1347 | * conversion. Some are basic and only require special block initialisation | 1346 | * conversion. Some are basic and only require special block initialisation |
@@ -1381,9 +1380,9 @@ xfs_bmap_add_attrfork_local( | |||
1381 | flags, XFS_DATA_FORK, | 1380 | flags, XFS_DATA_FORK, |
1382 | xfs_symlink_local_to_remote); | 1381 | xfs_symlink_local_to_remote); |
1383 | 1382 | ||
1384 | return xfs_bmap_local_to_extents(tp, ip, firstblock, 1, flags, | 1383 | /* should only be called for types that support local format data */ |
1385 | XFS_DATA_FORK, | 1384 | ASSERT(0); |
1386 | xfs_bmap_local_to_extents_init_fn); | 1385 | return EFSCORRUPTED; |
1387 | } | 1386 | } |
1388 | 1387 | ||
1389 | /* | 1388 | /* |
@@ -4907,20 +4906,19 @@ xfs_bmapi_write( | |||
4907 | orig_mval = mval; | 4906 | orig_mval = mval; |
4908 | orig_nmap = *nmap; | 4907 | orig_nmap = *nmap; |
4909 | #endif | 4908 | #endif |
4909 | whichfork = (flags & XFS_BMAPI_ATTRFORK) ? | ||
4910 | XFS_ATTR_FORK : XFS_DATA_FORK; | ||
4910 | 4911 | ||
4911 | ASSERT(*nmap >= 1); | 4912 | ASSERT(*nmap >= 1); |
4912 | ASSERT(*nmap <= XFS_BMAP_MAX_NMAP); | 4913 | ASSERT(*nmap <= XFS_BMAP_MAX_NMAP); |
4913 | ASSERT(!(flags & XFS_BMAPI_IGSTATE)); | 4914 | ASSERT(!(flags & XFS_BMAPI_IGSTATE)); |
4914 | ASSERT(tp != NULL); | 4915 | ASSERT(tp != NULL); |
4915 | ASSERT(len > 0); | 4916 | ASSERT(len > 0); |
4916 | 4917 | ASSERT(XFS_IFORK_FORMAT(ip, whichfork) != XFS_DINODE_FMT_LOCAL); | |
4917 | whichfork = (flags & XFS_BMAPI_ATTRFORK) ? | ||
4918 | XFS_ATTR_FORK : XFS_DATA_FORK; | ||
4919 | 4918 | ||
4920 | if (unlikely(XFS_TEST_ERROR( | 4919 | if (unlikely(XFS_TEST_ERROR( |
4921 | (XFS_IFORK_FORMAT(ip, whichfork) != XFS_DINODE_FMT_EXTENTS && | 4920 | (XFS_IFORK_FORMAT(ip, whichfork) != XFS_DINODE_FMT_EXTENTS && |
4922 | XFS_IFORK_FORMAT(ip, whichfork) != XFS_DINODE_FMT_BTREE && | 4921 | XFS_IFORK_FORMAT(ip, whichfork) != XFS_DINODE_FMT_BTREE), |
4923 | XFS_IFORK_FORMAT(ip, whichfork) != XFS_DINODE_FMT_LOCAL), | ||
4924 | mp, XFS_ERRTAG_BMAPIFORMAT, XFS_RANDOM_BMAPIFORMAT))) { | 4922 | mp, XFS_ERRTAG_BMAPIFORMAT, XFS_RANDOM_BMAPIFORMAT))) { |
4925 | XFS_ERROR_REPORT("xfs_bmapi_write", XFS_ERRLEVEL_LOW, mp); | 4923 | XFS_ERROR_REPORT("xfs_bmapi_write", XFS_ERRLEVEL_LOW, mp); |
4926 | return XFS_ERROR(EFSCORRUPTED); | 4924 | return XFS_ERROR(EFSCORRUPTED); |
@@ -4933,37 +4931,6 @@ xfs_bmapi_write( | |||
4933 | 4931 | ||
4934 | XFS_STATS_INC(xs_blk_mapw); | 4932 | XFS_STATS_INC(xs_blk_mapw); |
4935 | 4933 | ||
4936 | if (XFS_IFORK_FORMAT(ip, whichfork) == XFS_DINODE_FMT_LOCAL) { | ||
4937 | /* | ||
4938 | * XXX (dgc): This assumes we are only called for inodes that | ||
4939 | * contain content neutral data in local format. Anything that | ||
4940 | * contains caller-specific data in local format that needs | ||
4941 | * transformation to move to a block format needs to do the | ||
4942 | * conversion to extent format itself. | ||
4943 | * | ||
4944 | * Directory data forks and attribute forks handle this | ||
4945 | * themselves, but with the addition of metadata verifiers every | ||
4946 | * data fork in local format now contains caller specific data | ||
4947 | * and as such conversion through this function is likely to be | ||
4948 | * broken. | ||
4949 | * | ||
4950 | * The only likely user of this branch is for remote symlinks, | ||
4951 | * but we cannot overwrite the data fork contents of the symlink | ||
4952 | * (EEXIST occurs higher up the stack) and so it will never go | ||
4953 | * from local format to extent format here. Hence I don't think | ||
4954 | * this branch is ever executed intentionally and we should | ||
4955 | * consider removing it and asserting that xfs_bmapi_write() | ||
4956 | * cannot be called directly on local format forks. i.e. callers | ||
4957 | * are completely responsible for local to extent format | ||
4958 | * conversion, not xfs_bmapi_write(). | ||
4959 | */ | ||
4960 | error = xfs_bmap_local_to_extents(tp, ip, firstblock, total, | ||
4961 | &bma.logflags, whichfork, | ||
4962 | xfs_bmap_local_to_extents_init_fn); | ||
4963 | if (error) | ||
4964 | goto error0; | ||
4965 | } | ||
4966 | |||
4967 | if (*firstblock == NULLFSBLOCK) { | 4934 | if (*firstblock == NULLFSBLOCK) { |
4968 | if (XFS_IFORK_FORMAT(ip, whichfork) == XFS_DINODE_FMT_BTREE) | 4935 | if (XFS_IFORK_FORMAT(ip, whichfork) == XFS_DINODE_FMT_BTREE) |
4969 | bma.minleft = be16_to_cpu(ifp->if_broot->bb_level) + 1; | 4936 | bma.minleft = be16_to_cpu(ifp->if_broot->bb_level) + 1; |
diff --git a/fs/xfs/xfs_bmap.h b/fs/xfs/xfs_bmap.h index 5f469c3516eb..1cf1292d29b7 100644 --- a/fs/xfs/xfs_bmap.h +++ b/fs/xfs/xfs_bmap.h | |||
@@ -172,6 +172,7 @@ void xfs_bmap_trace_exlist(struct xfs_inode *ip, xfs_extnum_t cnt, | |||
172 | #endif | 172 | #endif |
173 | 173 | ||
174 | int xfs_bmap_add_attrfork(struct xfs_inode *ip, int size, int rsvd); | 174 | int xfs_bmap_add_attrfork(struct xfs_inode *ip, int size, int rsvd); |
175 | void xfs_bmap_local_to_extents_empty(struct xfs_inode *ip, int whichfork); | ||
175 | void xfs_bmap_add_free(xfs_fsblock_t bno, xfs_filblks_t len, | 176 | void xfs_bmap_add_free(xfs_fsblock_t bno, xfs_filblks_t len, |
176 | struct xfs_bmap_free *flist, struct xfs_mount *mp); | 177 | struct xfs_bmap_free *flist, struct xfs_mount *mp); |
177 | void xfs_bmap_cancel(struct xfs_bmap_free *flist); | 178 | void xfs_bmap_cancel(struct xfs_bmap_free *flist); |
diff --git a/fs/xfs/xfs_bmap_btree.h b/fs/xfs/xfs_bmap_btree.h index 70c43d9f72c1..1b726d626941 100644 --- a/fs/xfs/xfs_bmap_btree.h +++ b/fs/xfs/xfs_bmap_btree.h | |||
@@ -196,6 +196,8 @@ typedef __be64 xfs_bmbt_ptr_t, xfs_bmdr_ptr_t; | |||
196 | #define XFS_BMDR_SPACE_CALC(nrecs) \ | 196 | #define XFS_BMDR_SPACE_CALC(nrecs) \ |
197 | (int)(sizeof(xfs_bmdr_block_t) + \ | 197 | (int)(sizeof(xfs_bmdr_block_t) + \ |
198 | ((nrecs) * (sizeof(xfs_bmbt_key_t) + sizeof(xfs_bmbt_ptr_t)))) | 198 | ((nrecs) * (sizeof(xfs_bmbt_key_t) + sizeof(xfs_bmbt_ptr_t)))) |
199 | #define XFS_BMAP_BMDR_SPACE(bb) \ | ||
200 | (XFS_BMDR_SPACE_CALC(be16_to_cpu((bb)->bb_numrecs))) | ||
199 | 201 | ||
200 | /* | 202 | /* |
201 | * Maximum number of bmap btree levels. | 203 | * Maximum number of bmap btree levels. |
diff --git a/fs/xfs/xfs_buf_item.c b/fs/xfs/xfs_buf_item.c index 4ec431777048..bfc4e0c26fd3 100644 --- a/fs/xfs/xfs_buf_item.c +++ b/fs/xfs/xfs_buf_item.c | |||
@@ -140,6 +140,16 @@ xfs_buf_item_size( | |||
140 | 140 | ||
141 | ASSERT(bip->bli_flags & XFS_BLI_LOGGED); | 141 | ASSERT(bip->bli_flags & XFS_BLI_LOGGED); |
142 | 142 | ||
143 | if (bip->bli_flags & XFS_BLI_ORDERED) { | ||
144 | /* | ||
145 | * The buffer has been logged just to order it. | ||
146 | * It is not being included in the transaction | ||
147 | * commit, so no vectors are used at all. | ||
148 | */ | ||
149 | trace_xfs_buf_item_size_ordered(bip); | ||
150 | return XFS_LOG_VEC_ORDERED; | ||
151 | } | ||
152 | |||
143 | /* | 153 | /* |
144 | * the vector count is based on the number of buffer vectors we have | 154 | * the vector count is based on the number of buffer vectors we have |
145 | * dirty bits in. This will only be greater than one when we have a | 155 | * dirty bits in. This will only be greater than one when we have a |
@@ -212,6 +222,7 @@ xfs_buf_item_format_segment( | |||
212 | goto out; | 222 | goto out; |
213 | } | 223 | } |
214 | 224 | ||
225 | |||
215 | /* | 226 | /* |
216 | * Fill in an iovec for each set of contiguous chunks. | 227 | * Fill in an iovec for each set of contiguous chunks. |
217 | */ | 228 | */ |
@@ -299,18 +310,36 @@ xfs_buf_item_format( | |||
299 | 310 | ||
300 | /* | 311 | /* |
301 | * If it is an inode buffer, transfer the in-memory state to the | 312 | * If it is an inode buffer, transfer the in-memory state to the |
302 | * format flags and clear the in-memory state. We do not transfer | 313 | * format flags and clear the in-memory state. |
314 | * | ||
315 | * For buffer based inode allocation, we do not transfer | ||
303 | * this state if the inode buffer allocation has not yet been committed | 316 | * this state if the inode buffer allocation has not yet been committed |
304 | * to the log as setting the XFS_BLI_INODE_BUF flag will prevent | 317 | * to the log as setting the XFS_BLI_INODE_BUF flag will prevent |
305 | * correct replay of the inode allocation. | 318 | * correct replay of the inode allocation. |
319 | * | ||
320 | * For icreate item based inode allocation, the buffers aren't written | ||
321 | * to the journal during allocation, and hence we should always tag the | ||
322 | * buffer as an inode buffer so that the correct unlinked list replay | ||
323 | * occurs during recovery. | ||
306 | */ | 324 | */ |
307 | if (bip->bli_flags & XFS_BLI_INODE_BUF) { | 325 | if (bip->bli_flags & XFS_BLI_INODE_BUF) { |
308 | if (!((bip->bli_flags & XFS_BLI_INODE_ALLOC_BUF) && | 326 | if (xfs_sb_version_hascrc(&lip->li_mountp->m_sb) || |
327 | !((bip->bli_flags & XFS_BLI_INODE_ALLOC_BUF) && | ||
309 | xfs_log_item_in_current_chkpt(lip))) | 328 | xfs_log_item_in_current_chkpt(lip))) |
310 | bip->__bli_format.blf_flags |= XFS_BLF_INODE_BUF; | 329 | bip->__bli_format.blf_flags |= XFS_BLF_INODE_BUF; |
311 | bip->bli_flags &= ~XFS_BLI_INODE_BUF; | 330 | bip->bli_flags &= ~XFS_BLI_INODE_BUF; |
312 | } | 331 | } |
313 | 332 | ||
333 | if ((bip->bli_flags & (XFS_BLI_ORDERED|XFS_BLI_STALE)) == | ||
334 | XFS_BLI_ORDERED) { | ||
335 | /* | ||
336 | * The buffer has been logged just to order it. It is not being | ||
337 | * included in the transaction commit, so don't format it. | ||
338 | */ | ||
339 | trace_xfs_buf_item_format_ordered(bip); | ||
340 | return; | ||
341 | } | ||
342 | |||
314 | for (i = 0; i < bip->bli_format_count; i++) { | 343 | for (i = 0; i < bip->bli_format_count; i++) { |
315 | vecp = xfs_buf_item_format_segment(bip, vecp, offset, | 344 | vecp = xfs_buf_item_format_segment(bip, vecp, offset, |
316 | &bip->bli_formats[i]); | 345 | &bip->bli_formats[i]); |
@@ -340,6 +369,7 @@ xfs_buf_item_pin( | |||
340 | 369 | ||
341 | ASSERT(atomic_read(&bip->bli_refcount) > 0); | 370 | ASSERT(atomic_read(&bip->bli_refcount) > 0); |
342 | ASSERT((bip->bli_flags & XFS_BLI_LOGGED) || | 371 | ASSERT((bip->bli_flags & XFS_BLI_LOGGED) || |
372 | (bip->bli_flags & XFS_BLI_ORDERED) || | ||
343 | (bip->bli_flags & XFS_BLI_STALE)); | 373 | (bip->bli_flags & XFS_BLI_STALE)); |
344 | 374 | ||
345 | trace_xfs_buf_item_pin(bip); | 375 | trace_xfs_buf_item_pin(bip); |
@@ -512,8 +542,9 @@ xfs_buf_item_unlock( | |||
512 | { | 542 | { |
513 | struct xfs_buf_log_item *bip = BUF_ITEM(lip); | 543 | struct xfs_buf_log_item *bip = BUF_ITEM(lip); |
514 | struct xfs_buf *bp = bip->bli_buf; | 544 | struct xfs_buf *bp = bip->bli_buf; |
515 | int aborted, clean, i; | 545 | bool clean; |
516 | uint hold; | 546 | bool aborted; |
547 | int flags; | ||
517 | 548 | ||
518 | /* Clear the buffer's association with this transaction. */ | 549 | /* Clear the buffer's association with this transaction. */ |
519 | bp->b_transp = NULL; | 550 | bp->b_transp = NULL; |
@@ -524,23 +555,21 @@ xfs_buf_item_unlock( | |||
524 | * (cancelled) buffers at unpin time, but we'll never go through the | 555 | * (cancelled) buffers at unpin time, but we'll never go through the |
525 | * pin/unpin cycle if we abort inside commit. | 556 | * pin/unpin cycle if we abort inside commit. |
526 | */ | 557 | */ |
527 | aborted = (lip->li_flags & XFS_LI_ABORTED) != 0; | 558 | aborted = (lip->li_flags & XFS_LI_ABORTED) ? true : false; |
528 | |||
529 | /* | 559 | /* |
530 | * Before possibly freeing the buf item, determine if we should | 560 | * Before possibly freeing the buf item, copy the per-transaction state |
531 | * release the buffer at the end of this routine. | 561 | * so we can reference it safely later after clearing it from the |
562 | * buffer log item. | ||
532 | */ | 563 | */ |
533 | hold = bip->bli_flags & XFS_BLI_HOLD; | 564 | flags = bip->bli_flags; |
534 | 565 | bip->bli_flags &= ~(XFS_BLI_LOGGED | XFS_BLI_HOLD | XFS_BLI_ORDERED); | |
535 | /* Clear the per transaction state. */ | ||
536 | bip->bli_flags &= ~(XFS_BLI_LOGGED | XFS_BLI_HOLD); | ||
537 | 566 | ||
538 | /* | 567 | /* |
539 | * If the buf item is marked stale, then don't do anything. We'll | 568 | * If the buf item is marked stale, then don't do anything. We'll |
540 | * unlock the buffer and free the buf item when the buffer is unpinned | 569 | * unlock the buffer and free the buf item when the buffer is unpinned |
541 | * for the last time. | 570 | * for the last time. |
542 | */ | 571 | */ |
543 | if (bip->bli_flags & XFS_BLI_STALE) { | 572 | if (flags & XFS_BLI_STALE) { |
544 | trace_xfs_buf_item_unlock_stale(bip); | 573 | trace_xfs_buf_item_unlock_stale(bip); |
545 | ASSERT(bip->__bli_format.blf_flags & XFS_BLF_CANCEL); | 574 | ASSERT(bip->__bli_format.blf_flags & XFS_BLF_CANCEL); |
546 | if (!aborted) { | 575 | if (!aborted) { |
@@ -557,13 +586,19 @@ xfs_buf_item_unlock( | |||
557 | * be the only reference to the buf item, so we free it anyway | 586 | * be the only reference to the buf item, so we free it anyway |
558 | * regardless of whether it is dirty or not. A dirty abort implies a | 587 | * regardless of whether it is dirty or not. A dirty abort implies a |
559 | * shutdown, anyway. | 588 | * shutdown, anyway. |
589 | * | ||
590 | * Ordered buffers are dirty but may have no recorded changes, so ensure | ||
591 | * we only release clean items here. | ||
560 | */ | 592 | */ |
561 | clean = 1; | 593 | clean = (flags & XFS_BLI_DIRTY) ? false : true; |
562 | for (i = 0; i < bip->bli_format_count; i++) { | 594 | if (clean) { |
563 | if (!xfs_bitmap_empty(bip->bli_formats[i].blf_data_map, | 595 | int i; |
564 | bip->bli_formats[i].blf_map_size)) { | 596 | for (i = 0; i < bip->bli_format_count; i++) { |
565 | clean = 0; | 597 | if (!xfs_bitmap_empty(bip->bli_formats[i].blf_data_map, |
566 | break; | 598 | bip->bli_formats[i].blf_map_size)) { |
599 | clean = false; | ||
600 | break; | ||
601 | } | ||
567 | } | 602 | } |
568 | } | 603 | } |
569 | if (clean) | 604 | if (clean) |
@@ -576,7 +611,7 @@ xfs_buf_item_unlock( | |||
576 | } else | 611 | } else |
577 | atomic_dec(&bip->bli_refcount); | 612 | atomic_dec(&bip->bli_refcount); |
578 | 613 | ||
579 | if (!hold) | 614 | if (!(flags & XFS_BLI_HOLD)) |
580 | xfs_buf_relse(bp); | 615 | xfs_buf_relse(bp); |
581 | } | 616 | } |
582 | 617 | ||
@@ -842,12 +877,6 @@ xfs_buf_item_log( | |||
842 | struct xfs_buf *bp = bip->bli_buf; | 877 | struct xfs_buf *bp = bip->bli_buf; |
843 | 878 | ||
844 | /* | 879 | /* |
845 | * Mark the item as having some dirty data for | ||
846 | * quick reference in xfs_buf_item_dirty. | ||
847 | */ | ||
848 | bip->bli_flags |= XFS_BLI_DIRTY; | ||
849 | |||
850 | /* | ||
851 | * walk each buffer segment and mark them dirty appropriately. | 880 | * walk each buffer segment and mark them dirty appropriately. |
852 | */ | 881 | */ |
853 | start = 0; | 882 | start = 0; |
@@ -873,7 +902,7 @@ xfs_buf_item_log( | |||
873 | 902 | ||
874 | 903 | ||
875 | /* | 904 | /* |
876 | * Return 1 if the buffer has some data that has been logged (at any | 905 | * Return 1 if the buffer has been logged or ordered in a transaction (at any |
877 | * point, not just the current transaction) and 0 if not. | 906 | * point, not just the current transaction) and 0 if not. |
878 | */ | 907 | */ |
879 | uint | 908 | uint |
@@ -907,11 +936,11 @@ void | |||
907 | xfs_buf_item_relse( | 936 | xfs_buf_item_relse( |
908 | xfs_buf_t *bp) | 937 | xfs_buf_t *bp) |
909 | { | 938 | { |
910 | xfs_buf_log_item_t *bip; | 939 | xfs_buf_log_item_t *bip = bp->b_fspriv; |
911 | 940 | ||
912 | trace_xfs_buf_item_relse(bp, _RET_IP_); | 941 | trace_xfs_buf_item_relse(bp, _RET_IP_); |
942 | ASSERT(!(bip->bli_item.li_flags & XFS_LI_IN_AIL)); | ||
913 | 943 | ||
914 | bip = bp->b_fspriv; | ||
915 | bp->b_fspriv = bip->bli_item.li_bio_list; | 944 | bp->b_fspriv = bip->bli_item.li_bio_list; |
916 | if (bp->b_fspriv == NULL) | 945 | if (bp->b_fspriv == NULL) |
917 | bp->b_iodone = NULL; | 946 | bp->b_iodone = NULL; |
diff --git a/fs/xfs/xfs_buf_item.h b/fs/xfs/xfs_buf_item.h index 2573d2a75fc8..0f1c247dc680 100644 --- a/fs/xfs/xfs_buf_item.h +++ b/fs/xfs/xfs_buf_item.h | |||
@@ -120,6 +120,7 @@ xfs_blft_from_flags(struct xfs_buf_log_format *blf) | |||
120 | #define XFS_BLI_INODE_ALLOC_BUF 0x10 | 120 | #define XFS_BLI_INODE_ALLOC_BUF 0x10 |
121 | #define XFS_BLI_STALE_INODE 0x20 | 121 | #define XFS_BLI_STALE_INODE 0x20 |
122 | #define XFS_BLI_INODE_BUF 0x40 | 122 | #define XFS_BLI_INODE_BUF 0x40 |
123 | #define XFS_BLI_ORDERED 0x80 | ||
123 | 124 | ||
124 | #define XFS_BLI_FLAGS \ | 125 | #define XFS_BLI_FLAGS \ |
125 | { XFS_BLI_HOLD, "HOLD" }, \ | 126 | { XFS_BLI_HOLD, "HOLD" }, \ |
@@ -128,7 +129,8 @@ xfs_blft_from_flags(struct xfs_buf_log_format *blf) | |||
128 | { XFS_BLI_LOGGED, "LOGGED" }, \ | 129 | { XFS_BLI_LOGGED, "LOGGED" }, \ |
129 | { XFS_BLI_INODE_ALLOC_BUF, "INODE_ALLOC" }, \ | 130 | { XFS_BLI_INODE_ALLOC_BUF, "INODE_ALLOC" }, \ |
130 | { XFS_BLI_STALE_INODE, "STALE_INODE" }, \ | 131 | { XFS_BLI_STALE_INODE, "STALE_INODE" }, \ |
131 | { XFS_BLI_INODE_BUF, "INODE_BUF" } | 132 | { XFS_BLI_INODE_BUF, "INODE_BUF" }, \ |
133 | { XFS_BLI_ORDERED, "ORDERED" } | ||
132 | 134 | ||
133 | 135 | ||
134 | #ifdef __KERNEL__ | 136 | #ifdef __KERNEL__ |
diff --git a/fs/xfs/xfs_dfrag.c b/fs/xfs/xfs_dfrag.c index c407e1ccff43..e36445ceaf80 100644 --- a/fs/xfs/xfs_dfrag.c +++ b/fs/xfs/xfs_dfrag.c | |||
@@ -24,6 +24,9 @@ | |||
24 | #include "xfs_ag.h" | 24 | #include "xfs_ag.h" |
25 | #include "xfs_mount.h" | 25 | #include "xfs_mount.h" |
26 | #include "xfs_bmap_btree.h" | 26 | #include "xfs_bmap_btree.h" |
27 | #include "xfs_alloc_btree.h" | ||
28 | #include "xfs_ialloc_btree.h" | ||
29 | #include "xfs_btree.h" | ||
27 | #include "xfs_dinode.h" | 30 | #include "xfs_dinode.h" |
28 | #include "xfs_inode.h" | 31 | #include "xfs_inode.h" |
29 | #include "xfs_inode_item.h" | 32 | #include "xfs_inode_item.h" |
@@ -182,7 +185,7 @@ xfs_swap_extents_check_format( | |||
182 | */ | 185 | */ |
183 | if (tip->i_d.di_format == XFS_DINODE_FMT_BTREE) { | 186 | if (tip->i_d.di_format == XFS_DINODE_FMT_BTREE) { |
184 | if (XFS_IFORK_BOFF(ip) && | 187 | if (XFS_IFORK_BOFF(ip) && |
185 | tip->i_df.if_broot_bytes > XFS_IFORK_BOFF(ip)) | 188 | XFS_BMAP_BMDR_SPACE(tip->i_df.if_broot) > XFS_IFORK_BOFF(ip)) |
186 | return EINVAL; | 189 | return EINVAL; |
187 | if (XFS_IFORK_NEXTENTS(tip, XFS_DATA_FORK) <= | 190 | if (XFS_IFORK_NEXTENTS(tip, XFS_DATA_FORK) <= |
188 | XFS_IFORK_MAXEXT(ip, XFS_DATA_FORK)) | 191 | XFS_IFORK_MAXEXT(ip, XFS_DATA_FORK)) |
@@ -192,9 +195,8 @@ xfs_swap_extents_check_format( | |||
192 | /* Reciprocal target->temp btree format checks */ | 195 | /* Reciprocal target->temp btree format checks */ |
193 | if (ip->i_d.di_format == XFS_DINODE_FMT_BTREE) { | 196 | if (ip->i_d.di_format == XFS_DINODE_FMT_BTREE) { |
194 | if (XFS_IFORK_BOFF(tip) && | 197 | if (XFS_IFORK_BOFF(tip) && |
195 | ip->i_df.if_broot_bytes > XFS_IFORK_BOFF(tip)) | 198 | XFS_BMAP_BMDR_SPACE(ip->i_df.if_broot) > XFS_IFORK_BOFF(tip)) |
196 | return EINVAL; | 199 | return EINVAL; |
197 | |||
198 | if (XFS_IFORK_NEXTENTS(ip, XFS_DATA_FORK) <= | 200 | if (XFS_IFORK_NEXTENTS(ip, XFS_DATA_FORK) <= |
199 | XFS_IFORK_MAXEXT(tip, XFS_DATA_FORK)) | 201 | XFS_IFORK_MAXEXT(tip, XFS_DATA_FORK)) |
200 | return EINVAL; | 202 | return EINVAL; |
diff --git a/fs/xfs/xfs_dinode.h b/fs/xfs/xfs_dinode.h index f7a0e95d197a..e5869b50dc41 100644 --- a/fs/xfs/xfs_dinode.h +++ b/fs/xfs/xfs_dinode.h | |||
@@ -39,6 +39,9 @@ typedef struct xfs_timestamp { | |||
39 | * There is a very similar struct icdinode in xfs_inode which matches the | 39 | * There is a very similar struct icdinode in xfs_inode which matches the |
40 | * layout of the first 96 bytes of this structure, but is kept in native | 40 | * layout of the first 96 bytes of this structure, but is kept in native |
41 | * format instead of big endian. | 41 | * format instead of big endian. |
42 | * | ||
43 | * Note: di_flushiter is only used by v1/2 inodes - it's effectively a zeroed | ||
44 | * padding field for v3 inodes. | ||
42 | */ | 45 | */ |
43 | typedef struct xfs_dinode { | 46 | typedef struct xfs_dinode { |
44 | __be16 di_magic; /* inode magic # = XFS_DINODE_MAGIC */ | 47 | __be16 di_magic; /* inode magic # = XFS_DINODE_MAGIC */ |
@@ -132,9 +135,6 @@ typedef enum xfs_dinode_fmt { | |||
132 | #define XFS_LITINO(mp, version) \ | 135 | #define XFS_LITINO(mp, version) \ |
133 | ((int)(((mp)->m_sb.sb_inodesize) - xfs_dinode_size(version))) | 136 | ((int)(((mp)->m_sb.sb_inodesize) - xfs_dinode_size(version))) |
134 | 137 | ||
135 | #define XFS_BROOT_SIZE_ADJ(ip) \ | ||
136 | (XFS_BMBT_BLOCK_LEN((ip)->i_mount) - sizeof(xfs_bmdr_block_t)) | ||
137 | |||
138 | /* | 138 | /* |
139 | * Inode data & attribute fork sizes, per inode. | 139 | * Inode data & attribute fork sizes, per inode. |
140 | */ | 140 | */ |
diff --git a/fs/xfs/xfs_dir2.c b/fs/xfs/xfs_dir2.c index b26a50f9921d..8f023dee404d 100644 --- a/fs/xfs/xfs_dir2.c +++ b/fs/xfs/xfs_dir2.c | |||
@@ -368,10 +368,8 @@ xfs_dir_removename( | |||
368 | int | 368 | int |
369 | xfs_readdir( | 369 | xfs_readdir( |
370 | xfs_inode_t *dp, | 370 | xfs_inode_t *dp, |
371 | void *dirent, | 371 | struct dir_context *ctx, |
372 | size_t bufsize, | 372 | size_t bufsize) |
373 | xfs_off_t *offset, | ||
374 | filldir_t filldir) | ||
375 | { | 373 | { |
376 | int rval; /* return value */ | 374 | int rval; /* return value */ |
377 | int v; /* type-checking value */ | 375 | int v; /* type-checking value */ |
@@ -385,14 +383,13 @@ xfs_readdir( | |||
385 | XFS_STATS_INC(xs_dir_getdents); | 383 | XFS_STATS_INC(xs_dir_getdents); |
386 | 384 | ||
387 | if (dp->i_d.di_format == XFS_DINODE_FMT_LOCAL) | 385 | if (dp->i_d.di_format == XFS_DINODE_FMT_LOCAL) |
388 | rval = xfs_dir2_sf_getdents(dp, dirent, offset, filldir); | 386 | rval = xfs_dir2_sf_getdents(dp, ctx); |
389 | else if ((rval = xfs_dir2_isblock(NULL, dp, &v))) | 387 | else if ((rval = xfs_dir2_isblock(NULL, dp, &v))) |
390 | ; | 388 | ; |
391 | else if (v) | 389 | else if (v) |
392 | rval = xfs_dir2_block_getdents(dp, dirent, offset, filldir); | 390 | rval = xfs_dir2_block_getdents(dp, ctx); |
393 | else | 391 | else |
394 | rval = xfs_dir2_leaf_getdents(dp, dirent, bufsize, offset, | 392 | rval = xfs_dir2_leaf_getdents(dp, ctx, bufsize); |
395 | filldir); | ||
396 | return rval; | 393 | return rval; |
397 | } | 394 | } |
398 | 395 | ||
diff --git a/fs/xfs/xfs_dir2_block.c b/fs/xfs/xfs_dir2_block.c index e59f5fc816fe..5e7fbd72cf52 100644 --- a/fs/xfs/xfs_dir2_block.c +++ b/fs/xfs/xfs_dir2_block.c | |||
@@ -29,6 +29,7 @@ | |||
29 | #include "xfs_dinode.h" | 29 | #include "xfs_dinode.h" |
30 | #include "xfs_inode.h" | 30 | #include "xfs_inode.h" |
31 | #include "xfs_inode_item.h" | 31 | #include "xfs_inode_item.h" |
32 | #include "xfs_bmap.h" | ||
32 | #include "xfs_buf_item.h" | 33 | #include "xfs_buf_item.h" |
33 | #include "xfs_dir2.h" | 34 | #include "xfs_dir2.h" |
34 | #include "xfs_dir2_format.h" | 35 | #include "xfs_dir2_format.h" |
@@ -569,9 +570,7 @@ xfs_dir2_block_addname( | |||
569 | int /* error */ | 570 | int /* error */ |
570 | xfs_dir2_block_getdents( | 571 | xfs_dir2_block_getdents( |
571 | xfs_inode_t *dp, /* incore inode */ | 572 | xfs_inode_t *dp, /* incore inode */ |
572 | void *dirent, | 573 | struct dir_context *ctx) |
573 | xfs_off_t *offset, | ||
574 | filldir_t filldir) | ||
575 | { | 574 | { |
576 | xfs_dir2_data_hdr_t *hdr; /* block header */ | 575 | xfs_dir2_data_hdr_t *hdr; /* block header */ |
577 | struct xfs_buf *bp; /* buffer for block */ | 576 | struct xfs_buf *bp; /* buffer for block */ |
@@ -589,7 +588,7 @@ xfs_dir2_block_getdents( | |||
589 | /* | 588 | /* |
590 | * If the block number in the offset is out of range, we're done. | 589 | * If the block number in the offset is out of range, we're done. |
591 | */ | 590 | */ |
592 | if (xfs_dir2_dataptr_to_db(mp, *offset) > mp->m_dirdatablk) | 591 | if (xfs_dir2_dataptr_to_db(mp, ctx->pos) > mp->m_dirdatablk) |
593 | return 0; | 592 | return 0; |
594 | 593 | ||
595 | error = xfs_dir3_block_read(NULL, dp, &bp); | 594 | error = xfs_dir3_block_read(NULL, dp, &bp); |
@@ -600,7 +599,7 @@ xfs_dir2_block_getdents( | |||
600 | * Extract the byte offset we start at from the seek pointer. | 599 | * Extract the byte offset we start at from the seek pointer. |
601 | * We'll skip entries before this. | 600 | * We'll skip entries before this. |
602 | */ | 601 | */ |
603 | wantoff = xfs_dir2_dataptr_to_off(mp, *offset); | 602 | wantoff = xfs_dir2_dataptr_to_off(mp, ctx->pos); |
604 | hdr = bp->b_addr; | 603 | hdr = bp->b_addr; |
605 | xfs_dir3_data_check(dp, bp); | 604 | xfs_dir3_data_check(dp, bp); |
606 | /* | 605 | /* |
@@ -639,13 +638,12 @@ xfs_dir2_block_getdents( | |||
639 | cook = xfs_dir2_db_off_to_dataptr(mp, mp->m_dirdatablk, | 638 | cook = xfs_dir2_db_off_to_dataptr(mp, mp->m_dirdatablk, |
640 | (char *)dep - (char *)hdr); | 639 | (char *)dep - (char *)hdr); |
641 | 640 | ||
641 | ctx->pos = cook & 0x7fffffff; | ||
642 | /* | 642 | /* |
643 | * If it didn't fit, set the final offset to here & return. | 643 | * If it didn't fit, set the final offset to here & return. |
644 | */ | 644 | */ |
645 | if (filldir(dirent, (char *)dep->name, dep->namelen, | 645 | if (!dir_emit(ctx, (char *)dep->name, dep->namelen, |
646 | cook & 0x7fffffff, be64_to_cpu(dep->inumber), | 646 | be64_to_cpu(dep->inumber), DT_UNKNOWN)) { |
647 | DT_UNKNOWN)) { | ||
648 | *offset = cook & 0x7fffffff; | ||
649 | xfs_trans_brelse(NULL, bp); | 647 | xfs_trans_brelse(NULL, bp); |
650 | return 0; | 648 | return 0; |
651 | } | 649 | } |
@@ -655,7 +653,7 @@ xfs_dir2_block_getdents( | |||
655 | * Reached the end of the block. | 653 | * Reached the end of the block. |
656 | * Set the offset to a non-existent block 1 and return. | 654 | * Set the offset to a non-existent block 1 and return. |
657 | */ | 655 | */ |
658 | *offset = xfs_dir2_db_off_to_dataptr(mp, mp->m_dirdatablk + 1, 0) & | 656 | ctx->pos = xfs_dir2_db_off_to_dataptr(mp, mp->m_dirdatablk + 1, 0) & |
659 | 0x7fffffff; | 657 | 0x7fffffff; |
660 | xfs_trans_brelse(NULL, bp); | 658 | xfs_trans_brelse(NULL, bp); |
661 | return 0; | 659 | return 0; |
@@ -1167,13 +1165,15 @@ xfs_dir2_sf_to_block( | |||
1167 | __be16 *tagp; /* end of data entry */ | 1165 | __be16 *tagp; /* end of data entry */ |
1168 | xfs_trans_t *tp; /* transaction pointer */ | 1166 | xfs_trans_t *tp; /* transaction pointer */ |
1169 | struct xfs_name name; | 1167 | struct xfs_name name; |
1168 | struct xfs_ifork *ifp; | ||
1170 | 1169 | ||
1171 | trace_xfs_dir2_sf_to_block(args); | 1170 | trace_xfs_dir2_sf_to_block(args); |
1172 | 1171 | ||
1173 | dp = args->dp; | 1172 | dp = args->dp; |
1174 | tp = args->trans; | 1173 | tp = args->trans; |
1175 | mp = dp->i_mount; | 1174 | mp = dp->i_mount; |
1176 | ASSERT(dp->i_df.if_flags & XFS_IFINLINE); | 1175 | ifp = XFS_IFORK_PTR(dp, XFS_DATA_FORK); |
1176 | ASSERT(ifp->if_flags & XFS_IFINLINE); | ||
1177 | /* | 1177 | /* |
1178 | * Bomb out if the shortform directory is way too short. | 1178 | * Bomb out if the shortform directory is way too short. |
1179 | */ | 1179 | */ |
@@ -1182,22 +1182,23 @@ xfs_dir2_sf_to_block( | |||
1182 | return XFS_ERROR(EIO); | 1182 | return XFS_ERROR(EIO); |
1183 | } | 1183 | } |
1184 | 1184 | ||
1185 | oldsfp = (xfs_dir2_sf_hdr_t *)dp->i_df.if_u1.if_data; | 1185 | oldsfp = (xfs_dir2_sf_hdr_t *)ifp->if_u1.if_data; |
1186 | 1186 | ||
1187 | ASSERT(dp->i_df.if_bytes == dp->i_d.di_size); | 1187 | ASSERT(ifp->if_bytes == dp->i_d.di_size); |
1188 | ASSERT(dp->i_df.if_u1.if_data != NULL); | 1188 | ASSERT(ifp->if_u1.if_data != NULL); |
1189 | ASSERT(dp->i_d.di_size >= xfs_dir2_sf_hdr_size(oldsfp->i8count)); | 1189 | ASSERT(dp->i_d.di_size >= xfs_dir2_sf_hdr_size(oldsfp->i8count)); |
1190 | ASSERT(dp->i_d.di_nextents == 0); | ||
1190 | 1191 | ||
1191 | /* | 1192 | /* |
1192 | * Copy the directory into a temporary buffer. | 1193 | * Copy the directory into a temporary buffer. |
1193 | * Then pitch the incore inode data so we can make extents. | 1194 | * Then pitch the incore inode data so we can make extents. |
1194 | */ | 1195 | */ |
1195 | sfp = kmem_alloc(dp->i_df.if_bytes, KM_SLEEP); | 1196 | sfp = kmem_alloc(ifp->if_bytes, KM_SLEEP); |
1196 | memcpy(sfp, oldsfp, dp->i_df.if_bytes); | 1197 | memcpy(sfp, oldsfp, ifp->if_bytes); |
1197 | 1198 | ||
1198 | xfs_idata_realloc(dp, -dp->i_df.if_bytes, XFS_DATA_FORK); | 1199 | xfs_idata_realloc(dp, -ifp->if_bytes, XFS_DATA_FORK); |
1200 | xfs_bmap_local_to_extents_empty(dp, XFS_DATA_FORK); | ||
1199 | dp->i_d.di_size = 0; | 1201 | dp->i_d.di_size = 0; |
1200 | xfs_trans_log_inode(tp, dp, XFS_ILOG_CORE); | ||
1201 | 1202 | ||
1202 | /* | 1203 | /* |
1203 | * Add block 0 to the inode. | 1204 | * Add block 0 to the inode. |
diff --git a/fs/xfs/xfs_dir2_leaf.c b/fs/xfs/xfs_dir2_leaf.c index da71a1819d78..2aed25cae04d 100644 --- a/fs/xfs/xfs_dir2_leaf.c +++ b/fs/xfs/xfs_dir2_leaf.c | |||
@@ -1108,6 +1108,7 @@ xfs_dir2_leaf_readbuf( | |||
1108 | struct xfs_mount *mp = dp->i_mount; | 1108 | struct xfs_mount *mp = dp->i_mount; |
1109 | struct xfs_buf *bp = *bpp; | 1109 | struct xfs_buf *bp = *bpp; |
1110 | struct xfs_bmbt_irec *map = mip->map; | 1110 | struct xfs_bmbt_irec *map = mip->map; |
1111 | struct blk_plug plug; | ||
1111 | int error = 0; | 1112 | int error = 0; |
1112 | int length; | 1113 | int length; |
1113 | int i; | 1114 | int i; |
@@ -1236,6 +1237,7 @@ xfs_dir2_leaf_readbuf( | |||
1236 | /* | 1237 | /* |
1237 | * Do we need more readahead? | 1238 | * Do we need more readahead? |
1238 | */ | 1239 | */ |
1240 | blk_start_plug(&plug); | ||
1239 | for (mip->ra_index = mip->ra_offset = i = 0; | 1241 | for (mip->ra_index = mip->ra_offset = i = 0; |
1240 | mip->ra_want > mip->ra_current && i < mip->map_blocks; | 1242 | mip->ra_want > mip->ra_current && i < mip->map_blocks; |
1241 | i += mp->m_dirblkfsbs) { | 1243 | i += mp->m_dirblkfsbs) { |
@@ -1287,6 +1289,7 @@ xfs_dir2_leaf_readbuf( | |||
1287 | } | 1289 | } |
1288 | } | 1290 | } |
1289 | } | 1291 | } |
1292 | blk_finish_plug(&plug); | ||
1290 | 1293 | ||
1291 | out: | 1294 | out: |
1292 | *bpp = bp; | 1295 | *bpp = bp; |
@@ -1300,10 +1303,8 @@ out: | |||
1300 | int /* error */ | 1303 | int /* error */ |
1301 | xfs_dir2_leaf_getdents( | 1304 | xfs_dir2_leaf_getdents( |
1302 | xfs_inode_t *dp, /* incore directory inode */ | 1305 | xfs_inode_t *dp, /* incore directory inode */ |
1303 | void *dirent, | 1306 | struct dir_context *ctx, |
1304 | size_t bufsize, | 1307 | size_t bufsize) |
1305 | xfs_off_t *offset, | ||
1306 | filldir_t filldir) | ||
1307 | { | 1308 | { |
1308 | struct xfs_buf *bp = NULL; /* data block buffer */ | 1309 | struct xfs_buf *bp = NULL; /* data block buffer */ |
1309 | xfs_dir2_data_hdr_t *hdr; /* data block header */ | 1310 | xfs_dir2_data_hdr_t *hdr; /* data block header */ |
@@ -1322,7 +1323,7 @@ xfs_dir2_leaf_getdents( | |||
1322 | * If the offset is at or past the largest allowed value, | 1323 | * If the offset is at or past the largest allowed value, |
1323 | * give up right away. | 1324 | * give up right away. |
1324 | */ | 1325 | */ |
1325 | if (*offset >= XFS_DIR2_MAX_DATAPTR) | 1326 | if (ctx->pos >= XFS_DIR2_MAX_DATAPTR) |
1326 | return 0; | 1327 | return 0; |
1327 | 1328 | ||
1328 | mp = dp->i_mount; | 1329 | mp = dp->i_mount; |
@@ -1343,7 +1344,7 @@ xfs_dir2_leaf_getdents( | |||
1343 | * Inside the loop we keep the main offset value as a byte offset | 1344 | * Inside the loop we keep the main offset value as a byte offset |
1344 | * in the directory file. | 1345 | * in the directory file. |
1345 | */ | 1346 | */ |
1346 | curoff = xfs_dir2_dataptr_to_byte(mp, *offset); | 1347 | curoff = xfs_dir2_dataptr_to_byte(mp, ctx->pos); |
1347 | 1348 | ||
1348 | /* | 1349 | /* |
1349 | * Force this conversion through db so we truncate the offset | 1350 | * Force this conversion through db so we truncate the offset |
@@ -1444,8 +1445,8 @@ xfs_dir2_leaf_getdents( | |||
1444 | dep = (xfs_dir2_data_entry_t *)ptr; | 1445 | dep = (xfs_dir2_data_entry_t *)ptr; |
1445 | length = xfs_dir2_data_entsize(dep->namelen); | 1446 | length = xfs_dir2_data_entsize(dep->namelen); |
1446 | 1447 | ||
1447 | if (filldir(dirent, (char *)dep->name, dep->namelen, | 1448 | ctx->pos = xfs_dir2_byte_to_dataptr(mp, curoff) & 0x7fffffff; |
1448 | xfs_dir2_byte_to_dataptr(mp, curoff) & 0x7fffffff, | 1449 | if (!dir_emit(ctx, (char *)dep->name, dep->namelen, |
1449 | be64_to_cpu(dep->inumber), DT_UNKNOWN)) | 1450 | be64_to_cpu(dep->inumber), DT_UNKNOWN)) |
1450 | break; | 1451 | break; |
1451 | 1452 | ||
@@ -1462,9 +1463,9 @@ xfs_dir2_leaf_getdents( | |||
1462 | * All done. Set output offset value to current offset. | 1463 | * All done. Set output offset value to current offset. |
1463 | */ | 1464 | */ |
1464 | if (curoff > xfs_dir2_dataptr_to_byte(mp, XFS_DIR2_MAX_DATAPTR)) | 1465 | if (curoff > xfs_dir2_dataptr_to_byte(mp, XFS_DIR2_MAX_DATAPTR)) |
1465 | *offset = XFS_DIR2_MAX_DATAPTR & 0x7fffffff; | 1466 | ctx->pos = XFS_DIR2_MAX_DATAPTR & 0x7fffffff; |
1466 | else | 1467 | else |
1467 | *offset = xfs_dir2_byte_to_dataptr(mp, curoff) & 0x7fffffff; | 1468 | ctx->pos = xfs_dir2_byte_to_dataptr(mp, curoff) & 0x7fffffff; |
1468 | kmem_free(map_info); | 1469 | kmem_free(map_info); |
1469 | if (bp) | 1470 | if (bp) |
1470 | xfs_trans_brelse(NULL, bp); | 1471 | xfs_trans_brelse(NULL, bp); |
diff --git a/fs/xfs/xfs_dir2_priv.h b/fs/xfs/xfs_dir2_priv.h index 7cf573c88aad..0511cda4a712 100644 --- a/fs/xfs/xfs_dir2_priv.h +++ b/fs/xfs/xfs_dir2_priv.h | |||
@@ -33,8 +33,8 @@ extern int xfs_dir_cilookup_result(struct xfs_da_args *args, | |||
33 | extern const struct xfs_buf_ops xfs_dir3_block_buf_ops; | 33 | extern const struct xfs_buf_ops xfs_dir3_block_buf_ops; |
34 | 34 | ||
35 | extern int xfs_dir2_block_addname(struct xfs_da_args *args); | 35 | extern int xfs_dir2_block_addname(struct xfs_da_args *args); |
36 | extern int xfs_dir2_block_getdents(struct xfs_inode *dp, void *dirent, | 36 | extern int xfs_dir2_block_getdents(struct xfs_inode *dp, |
37 | xfs_off_t *offset, filldir_t filldir); | 37 | struct dir_context *ctx); |
38 | extern int xfs_dir2_block_lookup(struct xfs_da_args *args); | 38 | extern int xfs_dir2_block_lookup(struct xfs_da_args *args); |
39 | extern int xfs_dir2_block_removename(struct xfs_da_args *args); | 39 | extern int xfs_dir2_block_removename(struct xfs_da_args *args); |
40 | extern int xfs_dir2_block_replace(struct xfs_da_args *args); | 40 | extern int xfs_dir2_block_replace(struct xfs_da_args *args); |
@@ -91,8 +91,8 @@ extern void xfs_dir3_leaf_compact(struct xfs_da_args *args, | |||
91 | extern void xfs_dir3_leaf_compact_x1(struct xfs_dir3_icleaf_hdr *leafhdr, | 91 | extern void xfs_dir3_leaf_compact_x1(struct xfs_dir3_icleaf_hdr *leafhdr, |
92 | struct xfs_dir2_leaf_entry *ents, int *indexp, | 92 | struct xfs_dir2_leaf_entry *ents, int *indexp, |
93 | int *lowstalep, int *highstalep, int *lowlogp, int *highlogp); | 93 | int *lowstalep, int *highstalep, int *lowlogp, int *highlogp); |
94 | extern int xfs_dir2_leaf_getdents(struct xfs_inode *dp, void *dirent, | 94 | extern int xfs_dir2_leaf_getdents(struct xfs_inode *dp, struct dir_context *ctx, |
95 | size_t bufsize, xfs_off_t *offset, filldir_t filldir); | 95 | size_t bufsize); |
96 | extern int xfs_dir3_leaf_get_buf(struct xfs_da_args *args, xfs_dir2_db_t bno, | 96 | extern int xfs_dir3_leaf_get_buf(struct xfs_da_args *args, xfs_dir2_db_t bno, |
97 | struct xfs_buf **bpp, __uint16_t magic); | 97 | struct xfs_buf **bpp, __uint16_t magic); |
98 | extern void xfs_dir3_leaf_log_ents(struct xfs_trans *tp, struct xfs_buf *bp, | 98 | extern void xfs_dir3_leaf_log_ents(struct xfs_trans *tp, struct xfs_buf *bp, |
@@ -153,8 +153,7 @@ extern int xfs_dir2_block_to_sf(struct xfs_da_args *args, struct xfs_buf *bp, | |||
153 | int size, xfs_dir2_sf_hdr_t *sfhp); | 153 | int size, xfs_dir2_sf_hdr_t *sfhp); |
154 | extern int xfs_dir2_sf_addname(struct xfs_da_args *args); | 154 | extern int xfs_dir2_sf_addname(struct xfs_da_args *args); |
155 | extern int xfs_dir2_sf_create(struct xfs_da_args *args, xfs_ino_t pino); | 155 | extern int xfs_dir2_sf_create(struct xfs_da_args *args, xfs_ino_t pino); |
156 | extern int xfs_dir2_sf_getdents(struct xfs_inode *dp, void *dirent, | 156 | extern int xfs_dir2_sf_getdents(struct xfs_inode *dp, struct dir_context *ctx); |
157 | xfs_off_t *offset, filldir_t filldir); | ||
158 | extern int xfs_dir2_sf_lookup(struct xfs_da_args *args); | 157 | extern int xfs_dir2_sf_lookup(struct xfs_da_args *args); |
159 | extern int xfs_dir2_sf_removename(struct xfs_da_args *args); | 158 | extern int xfs_dir2_sf_removename(struct xfs_da_args *args); |
160 | extern int xfs_dir2_sf_replace(struct xfs_da_args *args); | 159 | extern int xfs_dir2_sf_replace(struct xfs_da_args *args); |
diff --git a/fs/xfs/xfs_dir2_sf.c b/fs/xfs/xfs_dir2_sf.c index 6157424dbf8f..97676a347da1 100644 --- a/fs/xfs/xfs_dir2_sf.c +++ b/fs/xfs/xfs_dir2_sf.c | |||
@@ -768,9 +768,7 @@ xfs_dir2_sf_create( | |||
768 | int /* error */ | 768 | int /* error */ |
769 | xfs_dir2_sf_getdents( | 769 | xfs_dir2_sf_getdents( |
770 | xfs_inode_t *dp, /* incore directory inode */ | 770 | xfs_inode_t *dp, /* incore directory inode */ |
771 | void *dirent, | 771 | struct dir_context *ctx) |
772 | xfs_off_t *offset, | ||
773 | filldir_t filldir) | ||
774 | { | 772 | { |
775 | int i; /* shortform entry number */ | 773 | int i; /* shortform entry number */ |
776 | xfs_mount_t *mp; /* filesystem mount point */ | 774 | xfs_mount_t *mp; /* filesystem mount point */ |
@@ -802,7 +800,7 @@ xfs_dir2_sf_getdents( | |||
802 | /* | 800 | /* |
803 | * If the block number in the offset is out of range, we're done. | 801 | * If the block number in the offset is out of range, we're done. |
804 | */ | 802 | */ |
805 | if (xfs_dir2_dataptr_to_db(mp, *offset) > mp->m_dirdatablk) | 803 | if (xfs_dir2_dataptr_to_db(mp, ctx->pos) > mp->m_dirdatablk) |
806 | return 0; | 804 | return 0; |
807 | 805 | ||
808 | /* | 806 | /* |
@@ -819,22 +817,20 @@ xfs_dir2_sf_getdents( | |||
819 | /* | 817 | /* |
820 | * Put . entry unless we're starting past it. | 818 | * Put . entry unless we're starting past it. |
821 | */ | 819 | */ |
822 | if (*offset <= dot_offset) { | 820 | if (ctx->pos <= dot_offset) { |
823 | if (filldir(dirent, ".", 1, dot_offset & 0x7fffffff, dp->i_ino, DT_DIR)) { | 821 | ctx->pos = dot_offset & 0x7fffffff; |
824 | *offset = dot_offset & 0x7fffffff; | 822 | if (!dir_emit(ctx, ".", 1, dp->i_ino, DT_DIR)) |
825 | return 0; | 823 | return 0; |
826 | } | ||
827 | } | 824 | } |
828 | 825 | ||
829 | /* | 826 | /* |
830 | * Put .. entry unless we're starting past it. | 827 | * Put .. entry unless we're starting past it. |
831 | */ | 828 | */ |
832 | if (*offset <= dotdot_offset) { | 829 | if (ctx->pos <= dotdot_offset) { |
833 | ino = xfs_dir2_sf_get_parent_ino(sfp); | 830 | ino = xfs_dir2_sf_get_parent_ino(sfp); |
834 | if (filldir(dirent, "..", 2, dotdot_offset & 0x7fffffff, ino, DT_DIR)) { | 831 | ctx->pos = dotdot_offset & 0x7fffffff; |
835 | *offset = dotdot_offset & 0x7fffffff; | 832 | if (!dir_emit(ctx, "..", 2, ino, DT_DIR)) |
836 | return 0; | 833 | return 0; |
837 | } | ||
838 | } | 834 | } |
839 | 835 | ||
840 | /* | 836 | /* |
@@ -845,21 +841,20 @@ xfs_dir2_sf_getdents( | |||
845 | off = xfs_dir2_db_off_to_dataptr(mp, mp->m_dirdatablk, | 841 | off = xfs_dir2_db_off_to_dataptr(mp, mp->m_dirdatablk, |
846 | xfs_dir2_sf_get_offset(sfep)); | 842 | xfs_dir2_sf_get_offset(sfep)); |
847 | 843 | ||
848 | if (*offset > off) { | 844 | if (ctx->pos > off) { |
849 | sfep = xfs_dir2_sf_nextentry(sfp, sfep); | 845 | sfep = xfs_dir2_sf_nextentry(sfp, sfep); |
850 | continue; | 846 | continue; |
851 | } | 847 | } |
852 | 848 | ||
853 | ino = xfs_dir2_sfe_get_ino(sfp, sfep); | 849 | ino = xfs_dir2_sfe_get_ino(sfp, sfep); |
854 | if (filldir(dirent, (char *)sfep->name, sfep->namelen, | 850 | ctx->pos = off & 0x7fffffff; |
855 | off & 0x7fffffff, ino, DT_UNKNOWN)) { | 851 | if (!dir_emit(ctx, (char *)sfep->name, sfep->namelen, |
856 | *offset = off & 0x7fffffff; | 852 | ino, DT_UNKNOWN)) |
857 | return 0; | 853 | return 0; |
858 | } | ||
859 | sfep = xfs_dir2_sf_nextentry(sfp, sfep); | 854 | sfep = xfs_dir2_sf_nextentry(sfp, sfep); |
860 | } | 855 | } |
861 | 856 | ||
862 | *offset = xfs_dir2_db_off_to_dataptr(mp, mp->m_dirdatablk + 1, 0) & | 857 | ctx->pos = xfs_dir2_db_off_to_dataptr(mp, mp->m_dirdatablk + 1, 0) & |
863 | 0x7fffffff; | 858 | 0x7fffffff; |
864 | return 0; | 859 | return 0; |
865 | } | 860 | } |
diff --git a/fs/xfs/xfs_dquot.c b/fs/xfs/xfs_dquot.c index 044e97a33c8d..0adf27ecf3f1 100644 --- a/fs/xfs/xfs_dquot.c +++ b/fs/xfs/xfs_dquot.c | |||
@@ -570,13 +570,13 @@ xfs_qm_dqtobp( | |||
570 | xfs_buf_t **O_bpp, | 570 | xfs_buf_t **O_bpp, |
571 | uint flags) | 571 | uint flags) |
572 | { | 572 | { |
573 | xfs_bmbt_irec_t map; | 573 | struct xfs_bmbt_irec map; |
574 | int nmaps = 1, error; | 574 | int nmaps = 1, error; |
575 | xfs_buf_t *bp; | 575 | struct xfs_buf *bp; |
576 | xfs_inode_t *quotip = XFS_DQ_TO_QIP(dqp); | 576 | struct xfs_inode *quotip = xfs_dq_to_quota_inode(dqp); |
577 | xfs_mount_t *mp = dqp->q_mount; | 577 | struct xfs_mount *mp = dqp->q_mount; |
578 | xfs_dqid_t id = be32_to_cpu(dqp->q_core.d_id); | 578 | xfs_dqid_t id = be32_to_cpu(dqp->q_core.d_id); |
579 | xfs_trans_t *tp = (tpp ? *tpp : NULL); | 579 | struct xfs_trans *tp = (tpp ? *tpp : NULL); |
580 | 580 | ||
581 | dqp->q_fileoffset = (xfs_fileoff_t)id / mp->m_quotainfo->qi_dqperchunk; | 581 | dqp->q_fileoffset = (xfs_fileoff_t)id / mp->m_quotainfo->qi_dqperchunk; |
582 | 582 | ||
@@ -804,7 +804,7 @@ xfs_qm_dqget( | |||
804 | xfs_dquot_t **O_dqpp) /* OUT : locked incore dquot */ | 804 | xfs_dquot_t **O_dqpp) /* OUT : locked incore dquot */ |
805 | { | 805 | { |
806 | struct xfs_quotainfo *qi = mp->m_quotainfo; | 806 | struct xfs_quotainfo *qi = mp->m_quotainfo; |
807 | struct radix_tree_root *tree = XFS_DQUOT_TREE(qi, type); | 807 | struct radix_tree_root *tree = xfs_dquot_tree(qi, type); |
808 | struct xfs_dquot *dqp; | 808 | struct xfs_dquot *dqp; |
809 | int error; | 809 | int error; |
810 | 810 | ||
@@ -936,6 +936,7 @@ xfs_qm_dqput_final( | |||
936 | { | 936 | { |
937 | struct xfs_quotainfo *qi = dqp->q_mount->m_quotainfo; | 937 | struct xfs_quotainfo *qi = dqp->q_mount->m_quotainfo; |
938 | struct xfs_dquot *gdqp; | 938 | struct xfs_dquot *gdqp; |
939 | struct xfs_dquot *pdqp; | ||
939 | 940 | ||
940 | trace_xfs_dqput_free(dqp); | 941 | trace_xfs_dqput_free(dqp); |
941 | 942 | ||
@@ -949,21 +950,29 @@ xfs_qm_dqput_final( | |||
949 | 950 | ||
950 | /* | 951 | /* |
951 | * If we just added a udquot to the freelist, then we want to release | 952 | * If we just added a udquot to the freelist, then we want to release |
952 | * the gdquot reference that it (probably) has. Otherwise it'll keep | 953 | * the gdquot/pdquot reference that it (probably) has. Otherwise it'll |
953 | * the gdquot from getting reclaimed. | 954 | * keep the gdquot/pdquot from getting reclaimed. |
954 | */ | 955 | */ |
955 | gdqp = dqp->q_gdquot; | 956 | gdqp = dqp->q_gdquot; |
956 | if (gdqp) { | 957 | if (gdqp) { |
957 | xfs_dqlock(gdqp); | 958 | xfs_dqlock(gdqp); |
958 | dqp->q_gdquot = NULL; | 959 | dqp->q_gdquot = NULL; |
959 | } | 960 | } |
961 | |||
962 | pdqp = dqp->q_pdquot; | ||
963 | if (pdqp) { | ||
964 | xfs_dqlock(pdqp); | ||
965 | dqp->q_pdquot = NULL; | ||
966 | } | ||
960 | xfs_dqunlock(dqp); | 967 | xfs_dqunlock(dqp); |
961 | 968 | ||
962 | /* | 969 | /* |
963 | * If we had a group quota hint, release it now. | 970 | * If we had a group/project quota hint, release it now. |
964 | */ | 971 | */ |
965 | if (gdqp) | 972 | if (gdqp) |
966 | xfs_qm_dqput(gdqp); | 973 | xfs_qm_dqput(gdqp); |
974 | if (pdqp) | ||
975 | xfs_qm_dqput(pdqp); | ||
967 | } | 976 | } |
968 | 977 | ||
969 | /* | 978 | /* |
diff --git a/fs/xfs/xfs_dquot.h b/fs/xfs/xfs_dquot.h index 4f0ebfc43cc9..55abbca2883d 100644 --- a/fs/xfs/xfs_dquot.h +++ b/fs/xfs/xfs_dquot.h | |||
@@ -53,6 +53,7 @@ typedef struct xfs_dquot { | |||
53 | xfs_fileoff_t q_fileoffset; /* offset in quotas file */ | 53 | xfs_fileoff_t q_fileoffset; /* offset in quotas file */ |
54 | 54 | ||
55 | struct xfs_dquot*q_gdquot; /* group dquot, hint only */ | 55 | struct xfs_dquot*q_gdquot; /* group dquot, hint only */ |
56 | struct xfs_dquot*q_pdquot; /* project dquot, hint only */ | ||
56 | xfs_disk_dquot_t q_core; /* actual usage & quotas */ | 57 | xfs_disk_dquot_t q_core; /* actual usage & quotas */ |
57 | xfs_dq_logitem_t q_logitem; /* dquot log item */ | 58 | xfs_dq_logitem_t q_logitem; /* dquot log item */ |
58 | xfs_qcnt_t q_res_bcount; /* total regular nblks used+reserved */ | 59 | xfs_qcnt_t q_res_bcount; /* total regular nblks used+reserved */ |
@@ -118,8 +119,9 @@ static inline int xfs_this_quota_on(struct xfs_mount *mp, int type) | |||
118 | case XFS_DQ_USER: | 119 | case XFS_DQ_USER: |
119 | return XFS_IS_UQUOTA_ON(mp); | 120 | return XFS_IS_UQUOTA_ON(mp); |
120 | case XFS_DQ_GROUP: | 121 | case XFS_DQ_GROUP: |
122 | return XFS_IS_GQUOTA_ON(mp); | ||
121 | case XFS_DQ_PROJ: | 123 | case XFS_DQ_PROJ: |
122 | return XFS_IS_OQUOTA_ON(mp); | 124 | return XFS_IS_PQUOTA_ON(mp); |
123 | default: | 125 | default: |
124 | return 0; | 126 | return 0; |
125 | } | 127 | } |
@@ -131,8 +133,9 @@ static inline xfs_dquot_t *xfs_inode_dquot(struct xfs_inode *ip, int type) | |||
131 | case XFS_DQ_USER: | 133 | case XFS_DQ_USER: |
132 | return ip->i_udquot; | 134 | return ip->i_udquot; |
133 | case XFS_DQ_GROUP: | 135 | case XFS_DQ_GROUP: |
134 | case XFS_DQ_PROJ: | ||
135 | return ip->i_gdquot; | 136 | return ip->i_gdquot; |
137 | case XFS_DQ_PROJ: | ||
138 | return ip->i_pdquot; | ||
136 | default: | 139 | default: |
137 | return NULL; | 140 | return NULL; |
138 | } | 141 | } |
@@ -143,10 +146,6 @@ static inline xfs_dquot_t *xfs_inode_dquot(struct xfs_inode *ip, int type) | |||
143 | #define XFS_QM_ISUDQ(dqp) ((dqp)->dq_flags & XFS_DQ_USER) | 146 | #define XFS_QM_ISUDQ(dqp) ((dqp)->dq_flags & XFS_DQ_USER) |
144 | #define XFS_QM_ISPDQ(dqp) ((dqp)->dq_flags & XFS_DQ_PROJ) | 147 | #define XFS_QM_ISPDQ(dqp) ((dqp)->dq_flags & XFS_DQ_PROJ) |
145 | #define XFS_QM_ISGDQ(dqp) ((dqp)->dq_flags & XFS_DQ_GROUP) | 148 | #define XFS_QM_ISGDQ(dqp) ((dqp)->dq_flags & XFS_DQ_GROUP) |
146 | #define XFS_DQ_TO_QINF(dqp) ((dqp)->q_mount->m_quotainfo) | ||
147 | #define XFS_DQ_TO_QIP(dqp) (XFS_QM_ISUDQ(dqp) ? \ | ||
148 | XFS_DQ_TO_QINF(dqp)->qi_uquotaip : \ | ||
149 | XFS_DQ_TO_QINF(dqp)->qi_gquotaip) | ||
150 | 149 | ||
151 | extern int xfs_qm_dqread(struct xfs_mount *, xfs_dqid_t, uint, | 150 | extern int xfs_qm_dqread(struct xfs_mount *, xfs_dqid_t, uint, |
152 | uint, struct xfs_dquot **); | 151 | uint, struct xfs_dquot **); |
diff --git a/fs/xfs/xfs_file.c b/fs/xfs/xfs_file.c index a5f2042aec8b..de3dc98f4e8f 100644 --- a/fs/xfs/xfs_file.c +++ b/fs/xfs/xfs_file.c | |||
@@ -906,11 +906,10 @@ xfs_file_release( | |||
906 | 906 | ||
907 | STATIC int | 907 | STATIC int |
908 | xfs_file_readdir( | 908 | xfs_file_readdir( |
909 | struct file *filp, | 909 | struct file *file, |
910 | void *dirent, | 910 | struct dir_context *ctx) |
911 | filldir_t filldir) | ||
912 | { | 911 | { |
913 | struct inode *inode = file_inode(filp); | 912 | struct inode *inode = file_inode(file); |
914 | xfs_inode_t *ip = XFS_I(inode); | 913 | xfs_inode_t *ip = XFS_I(inode); |
915 | int error; | 914 | int error; |
916 | size_t bufsize; | 915 | size_t bufsize; |
@@ -929,8 +928,7 @@ xfs_file_readdir( | |||
929 | */ | 928 | */ |
930 | bufsize = (size_t)min_t(loff_t, 32768, ip->i_d.di_size); | 929 | bufsize = (size_t)min_t(loff_t, 32768, ip->i_d.di_size); |
931 | 930 | ||
932 | error = xfs_readdir(ip, dirent, bufsize, | 931 | error = xfs_readdir(ip, ctx, bufsize); |
933 | (xfs_off_t *)&filp->f_pos, filldir); | ||
934 | if (error) | 932 | if (error) |
935 | return -error; | 933 | return -error; |
936 | return 0; | 934 | return 0; |
@@ -1270,8 +1268,7 @@ xfs_seek_data( | |||
1270 | } | 1268 | } |
1271 | 1269 | ||
1272 | out: | 1270 | out: |
1273 | if (offset != file->f_pos) | 1271 | offset = vfs_setpos(file, offset, inode->i_sb->s_maxbytes); |
1274 | file->f_pos = offset; | ||
1275 | 1272 | ||
1276 | out_unlock: | 1273 | out_unlock: |
1277 | xfs_iunlock_map_shared(ip, lock); | 1274 | xfs_iunlock_map_shared(ip, lock); |
@@ -1379,8 +1376,7 @@ out: | |||
1379 | * situation in particular. | 1376 | * situation in particular. |
1380 | */ | 1377 | */ |
1381 | offset = min_t(loff_t, offset, isize); | 1378 | offset = min_t(loff_t, offset, isize); |
1382 | if (offset != file->f_pos) | 1379 | offset = vfs_setpos(file, offset, inode->i_sb->s_maxbytes); |
1383 | file->f_pos = offset; | ||
1384 | 1380 | ||
1385 | out_unlock: | 1381 | out_unlock: |
1386 | xfs_iunlock_map_shared(ip, lock); | 1382 | xfs_iunlock_map_shared(ip, lock); |
@@ -1432,7 +1428,7 @@ const struct file_operations xfs_file_operations = { | |||
1432 | const struct file_operations xfs_dir_file_operations = { | 1428 | const struct file_operations xfs_dir_file_operations = { |
1433 | .open = xfs_dir_open, | 1429 | .open = xfs_dir_open, |
1434 | .read = generic_read_dir, | 1430 | .read = generic_read_dir, |
1435 | .readdir = xfs_file_readdir, | 1431 | .iterate = xfs_file_readdir, |
1436 | .llseek = generic_file_llseek, | 1432 | .llseek = generic_file_llseek, |
1437 | .unlocked_ioctl = xfs_file_ioctl, | 1433 | .unlocked_ioctl = xfs_file_ioctl, |
1438 | #ifdef CONFIG_COMPAT | 1434 | #ifdef CONFIG_COMPAT |
diff --git a/fs/xfs/xfs_fsops.c b/fs/xfs/xfs_fsops.c index 3c3644ea825b..614eb0cc3608 100644 --- a/fs/xfs/xfs_fsops.c +++ b/fs/xfs/xfs_fsops.c | |||
@@ -176,7 +176,7 @@ xfs_growfs_data_private( | |||
176 | if (!bp) | 176 | if (!bp) |
177 | return EIO; | 177 | return EIO; |
178 | if (bp->b_error) { | 178 | if (bp->b_error) { |
179 | int error = bp->b_error; | 179 | error = bp->b_error; |
180 | xfs_buf_relse(bp); | 180 | xfs_buf_relse(bp); |
181 | return error; | 181 | return error; |
182 | } | 182 | } |
diff --git a/fs/xfs/xfs_ialloc.c b/fs/xfs/xfs_ialloc.c index c8f5ae1debf2..7a0c17d7ec09 100644 --- a/fs/xfs/xfs_ialloc.c +++ b/fs/xfs/xfs_ialloc.c | |||
@@ -38,6 +38,7 @@ | |||
38 | #include "xfs_bmap.h" | 38 | #include "xfs_bmap.h" |
39 | #include "xfs_cksum.h" | 39 | #include "xfs_cksum.h" |
40 | #include "xfs_buf_item.h" | 40 | #include "xfs_buf_item.h" |
41 | #include "xfs_icreate_item.h" | ||
41 | 42 | ||
42 | 43 | ||
43 | /* | 44 | /* |
@@ -150,12 +151,16 @@ xfs_check_agi_freecount( | |||
150 | #endif | 151 | #endif |
151 | 152 | ||
152 | /* | 153 | /* |
153 | * Initialise a new set of inodes. | 154 | * Initialise a new set of inodes. When called without a transaction context |
155 | * (e.g. from recovery) we initiate a delayed write of the inode buffers rather | ||
156 | * than logging them (which in a transaction context puts them into the AIL | ||
157 | * for writeback rather than the xfsbufd queue). | ||
154 | */ | 158 | */ |
155 | STATIC int | 159 | int |
156 | xfs_ialloc_inode_init( | 160 | xfs_ialloc_inode_init( |
157 | struct xfs_mount *mp, | 161 | struct xfs_mount *mp, |
158 | struct xfs_trans *tp, | 162 | struct xfs_trans *tp, |
163 | struct list_head *buffer_list, | ||
159 | xfs_agnumber_t agno, | 164 | xfs_agnumber_t agno, |
160 | xfs_agblock_t agbno, | 165 | xfs_agblock_t agbno, |
161 | xfs_agblock_t length, | 166 | xfs_agblock_t length, |
@@ -208,6 +213,18 @@ xfs_ialloc_inode_init( | |||
208 | version = 3; | 213 | version = 3; |
209 | ino = XFS_AGINO_TO_INO(mp, agno, | 214 | ino = XFS_AGINO_TO_INO(mp, agno, |
210 | XFS_OFFBNO_TO_AGINO(mp, agbno, 0)); | 215 | XFS_OFFBNO_TO_AGINO(mp, agbno, 0)); |
216 | |||
217 | /* | ||
218 | * log the initialisation that is about to take place as an | ||
219 | * logical operation. This means the transaction does not | ||
220 | * need to log the physical changes to the inode buffers as log | ||
221 | * recovery will know what initialisation is actually needed. | ||
222 | * Hence we only need to log the buffers as "ordered" buffers so | ||
223 | * they track in the AIL as if they were physically logged. | ||
224 | */ | ||
225 | if (tp) | ||
226 | xfs_icreate_log(tp, agno, agbno, XFS_IALLOC_INODES(mp), | ||
227 | mp->m_sb.sb_inodesize, length, gen); | ||
211 | } else if (xfs_sb_version_hasnlink(&mp->m_sb)) | 228 | } else if (xfs_sb_version_hasnlink(&mp->m_sb)) |
212 | version = 2; | 229 | version = 2; |
213 | else | 230 | else |
@@ -223,13 +240,8 @@ xfs_ialloc_inode_init( | |||
223 | XBF_UNMAPPED); | 240 | XBF_UNMAPPED); |
224 | if (!fbuf) | 241 | if (!fbuf) |
225 | return ENOMEM; | 242 | return ENOMEM; |
226 | /* | 243 | |
227 | * Initialize all inodes in this buffer and then log them. | 244 | /* Initialize the inode buffers and log them appropriately. */ |
228 | * | ||
229 | * XXX: It would be much better if we had just one transaction | ||
230 | * to log a whole cluster of inodes instead of all the | ||
231 | * individual transactions causing a lot of log traffic. | ||
232 | */ | ||
233 | fbuf->b_ops = &xfs_inode_buf_ops; | 245 | fbuf->b_ops = &xfs_inode_buf_ops; |
234 | xfs_buf_zero(fbuf, 0, BBTOB(fbuf->b_length)); | 246 | xfs_buf_zero(fbuf, 0, BBTOB(fbuf->b_length)); |
235 | for (i = 0; i < ninodes; i++) { | 247 | for (i = 0; i < ninodes; i++) { |
@@ -247,18 +259,39 @@ xfs_ialloc_inode_init( | |||
247 | ino++; | 259 | ino++; |
248 | uuid_copy(&free->di_uuid, &mp->m_sb.sb_uuid); | 260 | uuid_copy(&free->di_uuid, &mp->m_sb.sb_uuid); |
249 | xfs_dinode_calc_crc(mp, free); | 261 | xfs_dinode_calc_crc(mp, free); |
250 | } else { | 262 | } else if (tp) { |
251 | /* just log the inode core */ | 263 | /* just log the inode core */ |
252 | xfs_trans_log_buf(tp, fbuf, ioffset, | 264 | xfs_trans_log_buf(tp, fbuf, ioffset, |
253 | ioffset + isize - 1); | 265 | ioffset + isize - 1); |
254 | } | 266 | } |
255 | } | 267 | } |
256 | if (version == 3) { | 268 | |
257 | /* need to log the entire buffer */ | 269 | if (tp) { |
258 | xfs_trans_log_buf(tp, fbuf, 0, | 270 | /* |
259 | BBTOB(fbuf->b_length) - 1); | 271 | * Mark the buffer as an inode allocation buffer so it |
272 | * sticks in AIL at the point of this allocation | ||
273 | * transaction. This ensures the they are on disk before | ||
274 | * the tail of the log can be moved past this | ||
275 | * transaction (i.e. by preventing relogging from moving | ||
276 | * it forward in the log). | ||
277 | */ | ||
278 | xfs_trans_inode_alloc_buf(tp, fbuf); | ||
279 | if (version == 3) { | ||
280 | /* | ||
281 | * Mark the buffer as ordered so that they are | ||
282 | * not physically logged in the transaction but | ||
283 | * still tracked in the AIL as part of the | ||
284 | * transaction and pin the log appropriately. | ||
285 | */ | ||
286 | xfs_trans_ordered_buf(tp, fbuf); | ||
287 | xfs_trans_log_buf(tp, fbuf, 0, | ||
288 | BBTOB(fbuf->b_length) - 1); | ||
289 | } | ||
290 | } else { | ||
291 | fbuf->b_flags |= XBF_DONE; | ||
292 | xfs_buf_delwri_queue(fbuf, buffer_list); | ||
293 | xfs_buf_relse(fbuf); | ||
260 | } | 294 | } |
261 | xfs_trans_inode_alloc_buf(tp, fbuf); | ||
262 | } | 295 | } |
263 | return 0; | 296 | return 0; |
264 | } | 297 | } |
@@ -303,7 +336,7 @@ xfs_ialloc_ag_alloc( | |||
303 | * First try to allocate inodes contiguous with the last-allocated | 336 | * First try to allocate inodes contiguous with the last-allocated |
304 | * chunk of inodes. If the filesystem is striped, this will fill | 337 | * chunk of inodes. If the filesystem is striped, this will fill |
305 | * an entire stripe unit with inodes. | 338 | * an entire stripe unit with inodes. |
306 | */ | 339 | */ |
307 | agi = XFS_BUF_TO_AGI(agbp); | 340 | agi = XFS_BUF_TO_AGI(agbp); |
308 | newino = be32_to_cpu(agi->agi_newino); | 341 | newino = be32_to_cpu(agi->agi_newino); |
309 | agno = be32_to_cpu(agi->agi_seqno); | 342 | agno = be32_to_cpu(agi->agi_seqno); |
@@ -402,7 +435,7 @@ xfs_ialloc_ag_alloc( | |||
402 | * rather than a linear progression to prevent the next generation | 435 | * rather than a linear progression to prevent the next generation |
403 | * number from being easily guessable. | 436 | * number from being easily guessable. |
404 | */ | 437 | */ |
405 | error = xfs_ialloc_inode_init(args.mp, tp, agno, args.agbno, | 438 | error = xfs_ialloc_inode_init(args.mp, tp, NULL, agno, args.agbno, |
406 | args.len, prandom_u32()); | 439 | args.len, prandom_u32()); |
407 | 440 | ||
408 | if (error) | 441 | if (error) |
@@ -615,8 +648,7 @@ xfs_ialloc_get_rec( | |||
615 | struct xfs_btree_cur *cur, | 648 | struct xfs_btree_cur *cur, |
616 | xfs_agino_t agino, | 649 | xfs_agino_t agino, |
617 | xfs_inobt_rec_incore_t *rec, | 650 | xfs_inobt_rec_incore_t *rec, |
618 | int *done, | 651 | int *done) |
619 | int left) | ||
620 | { | 652 | { |
621 | int error; | 653 | int error; |
622 | int i; | 654 | int i; |
@@ -724,12 +756,12 @@ xfs_dialloc_ag( | |||
724 | pag->pagl_leftrec != NULLAGINO && | 756 | pag->pagl_leftrec != NULLAGINO && |
725 | pag->pagl_rightrec != NULLAGINO) { | 757 | pag->pagl_rightrec != NULLAGINO) { |
726 | error = xfs_ialloc_get_rec(tcur, pag->pagl_leftrec, | 758 | error = xfs_ialloc_get_rec(tcur, pag->pagl_leftrec, |
727 | &trec, &doneleft, 1); | 759 | &trec, &doneleft); |
728 | if (error) | 760 | if (error) |
729 | goto error1; | 761 | goto error1; |
730 | 762 | ||
731 | error = xfs_ialloc_get_rec(cur, pag->pagl_rightrec, | 763 | error = xfs_ialloc_get_rec(cur, pag->pagl_rightrec, |
732 | &rec, &doneright, 0); | 764 | &rec, &doneright); |
733 | if (error) | 765 | if (error) |
734 | goto error1; | 766 | goto error1; |
735 | } else { | 767 | } else { |
diff --git a/fs/xfs/xfs_ialloc.h b/fs/xfs/xfs_ialloc.h index c8da3df271e6..68c07320f096 100644 --- a/fs/xfs/xfs_ialloc.h +++ b/fs/xfs/xfs_ialloc.h | |||
@@ -150,6 +150,14 @@ int xfs_inobt_lookup(struct xfs_btree_cur *cur, xfs_agino_t ino, | |||
150 | int xfs_inobt_get_rec(struct xfs_btree_cur *cur, | 150 | int xfs_inobt_get_rec(struct xfs_btree_cur *cur, |
151 | xfs_inobt_rec_incore_t *rec, int *stat); | 151 | xfs_inobt_rec_incore_t *rec, int *stat); |
152 | 152 | ||
153 | /* | ||
154 | * Inode chunk initialisation routine | ||
155 | */ | ||
156 | int xfs_ialloc_inode_init(struct xfs_mount *mp, struct xfs_trans *tp, | ||
157 | struct list_head *buffer_list, | ||
158 | xfs_agnumber_t agno, xfs_agblock_t agbno, | ||
159 | xfs_agblock_t length, unsigned int gen); | ||
160 | |||
153 | extern const struct xfs_buf_ops xfs_agi_buf_ops; | 161 | extern const struct xfs_buf_ops xfs_agi_buf_ops; |
154 | 162 | ||
155 | #endif /* __XFS_IALLOC_H__ */ | 163 | #endif /* __XFS_IALLOC_H__ */ |
diff --git a/fs/xfs/xfs_icache.c b/fs/xfs/xfs_icache.c index 96e344e3e927..3f90e1ceb8d6 100644 --- a/fs/xfs/xfs_icache.c +++ b/fs/xfs/xfs_icache.c | |||
@@ -335,7 +335,9 @@ xfs_iget_cache_miss( | |||
335 | iflags = XFS_INEW; | 335 | iflags = XFS_INEW; |
336 | if (flags & XFS_IGET_DONTCACHE) | 336 | if (flags & XFS_IGET_DONTCACHE) |
337 | iflags |= XFS_IDONTCACHE; | 337 | iflags |= XFS_IDONTCACHE; |
338 | ip->i_udquot = ip->i_gdquot = NULL; | 338 | ip->i_udquot = NULL; |
339 | ip->i_gdquot = NULL; | ||
340 | ip->i_pdquot = NULL; | ||
339 | xfs_iflags_set(ip, iflags); | 341 | xfs_iflags_set(ip, iflags); |
340 | 342 | ||
341 | /* insert the new inode */ | 343 | /* insert the new inode */ |
diff --git a/fs/xfs/xfs_icache.h b/fs/xfs/xfs_icache.h index e0f138c70a2f..a01afbb3909a 100644 --- a/fs/xfs/xfs_icache.h +++ b/fs/xfs/xfs_icache.h | |||
@@ -40,7 +40,6 @@ void xfs_inode_clear_eofblocks_tag(struct xfs_inode *ip); | |||
40 | int xfs_icache_free_eofblocks(struct xfs_mount *, struct xfs_eofblocks *); | 40 | int xfs_icache_free_eofblocks(struct xfs_mount *, struct xfs_eofblocks *); |
41 | void xfs_eofblocks_worker(struct work_struct *); | 41 | void xfs_eofblocks_worker(struct work_struct *); |
42 | 42 | ||
43 | int xfs_sync_inode_grab(struct xfs_inode *ip); | ||
44 | int xfs_inode_ag_iterator(struct xfs_mount *mp, | 43 | int xfs_inode_ag_iterator(struct xfs_mount *mp, |
45 | int (*execute)(struct xfs_inode *ip, struct xfs_perag *pag, | 44 | int (*execute)(struct xfs_inode *ip, struct xfs_perag *pag, |
46 | int flags, void *args), | 45 | int flags, void *args), |
diff --git a/fs/xfs/xfs_icreate_item.c b/fs/xfs/xfs_icreate_item.c new file mode 100644 index 000000000000..7716a4e7375e --- /dev/null +++ b/fs/xfs/xfs_icreate_item.c | |||
@@ -0,0 +1,195 @@ | |||
1 | /* | ||
2 | * Copyright (c) 2008-2010, 2013 Dave Chinner | ||
3 | * All Rights Reserved. | ||
4 | * | ||
5 | * This program is free software; you can redistribute it and/or | ||
6 | * modify it under the terms of the GNU General Public License as | ||
7 | * published by the Free Software Foundation. | ||
8 | * | ||
9 | * This program is distributed in the hope that it would be useful, | ||
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
12 | * GNU General Public License for more details. | ||
13 | * | ||
14 | * You should have received a copy of the GNU General Public License | ||
15 | * along with this program; if not, write the Free Software Foundation, | ||
16 | * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA | ||
17 | */ | ||
18 | #include "xfs.h" | ||
19 | #include "xfs_fs.h" | ||
20 | #include "xfs_types.h" | ||
21 | #include "xfs_bit.h" | ||
22 | #include "xfs_log.h" | ||
23 | #include "xfs_inum.h" | ||
24 | #include "xfs_trans.h" | ||
25 | #include "xfs_buf_item.h" | ||
26 | #include "xfs_sb.h" | ||
27 | #include "xfs_ag.h" | ||
28 | #include "xfs_dir2.h" | ||
29 | #include "xfs_mount.h" | ||
30 | #include "xfs_trans_priv.h" | ||
31 | #include "xfs_bmap_btree.h" | ||
32 | #include "xfs_alloc_btree.h" | ||
33 | #include "xfs_ialloc_btree.h" | ||
34 | #include "xfs_attr_sf.h" | ||
35 | #include "xfs_dinode.h" | ||
36 | #include "xfs_inode.h" | ||
37 | #include "xfs_inode_item.h" | ||
38 | #include "xfs_btree.h" | ||
39 | #include "xfs_ialloc.h" | ||
40 | #include "xfs_error.h" | ||
41 | #include "xfs_icreate_item.h" | ||
42 | |||
43 | kmem_zone_t *xfs_icreate_zone; /* inode create item zone */ | ||
44 | |||
45 | static inline struct xfs_icreate_item *ICR_ITEM(struct xfs_log_item *lip) | ||
46 | { | ||
47 | return container_of(lip, struct xfs_icreate_item, ic_item); | ||
48 | } | ||
49 | |||
50 | /* | ||
51 | * This returns the number of iovecs needed to log the given inode item. | ||
52 | * | ||
53 | * We only need one iovec for the icreate log structure. | ||
54 | */ | ||
55 | STATIC uint | ||
56 | xfs_icreate_item_size( | ||
57 | struct xfs_log_item *lip) | ||
58 | { | ||
59 | return 1; | ||
60 | } | ||
61 | |||
62 | /* | ||
63 | * This is called to fill in the vector of log iovecs for the | ||
64 | * given inode create log item. | ||
65 | */ | ||
66 | STATIC void | ||
67 | xfs_icreate_item_format( | ||
68 | struct xfs_log_item *lip, | ||
69 | struct xfs_log_iovec *log_vector) | ||
70 | { | ||
71 | struct xfs_icreate_item *icp = ICR_ITEM(lip); | ||
72 | |||
73 | log_vector->i_addr = (xfs_caddr_t)&icp->ic_format; | ||
74 | log_vector->i_len = sizeof(struct xfs_icreate_log); | ||
75 | log_vector->i_type = XLOG_REG_TYPE_ICREATE; | ||
76 | } | ||
77 | |||
78 | |||
79 | /* Pinning has no meaning for the create item, so just return. */ | ||
80 | STATIC void | ||
81 | xfs_icreate_item_pin( | ||
82 | struct xfs_log_item *lip) | ||
83 | { | ||
84 | } | ||
85 | |||
86 | |||
87 | /* pinning has no meaning for the create item, so just return. */ | ||
88 | STATIC void | ||
89 | xfs_icreate_item_unpin( | ||
90 | struct xfs_log_item *lip, | ||
91 | int remove) | ||
92 | { | ||
93 | } | ||
94 | |||
95 | STATIC void | ||
96 | xfs_icreate_item_unlock( | ||
97 | struct xfs_log_item *lip) | ||
98 | { | ||
99 | struct xfs_icreate_item *icp = ICR_ITEM(lip); | ||
100 | |||
101 | if (icp->ic_item.li_flags & XFS_LI_ABORTED) | ||
102 | kmem_zone_free(xfs_icreate_zone, icp); | ||
103 | return; | ||
104 | } | ||
105 | |||
106 | /* | ||
107 | * Because we have ordered buffers being tracked in the AIL for the inode | ||
108 | * creation, we don't need the create item after this. Hence we can free | ||
109 | * the log item and return -1 to tell the caller we're done with the item. | ||
110 | */ | ||
111 | STATIC xfs_lsn_t | ||
112 | xfs_icreate_item_committed( | ||
113 | struct xfs_log_item *lip, | ||
114 | xfs_lsn_t lsn) | ||
115 | { | ||
116 | struct xfs_icreate_item *icp = ICR_ITEM(lip); | ||
117 | |||
118 | kmem_zone_free(xfs_icreate_zone, icp); | ||
119 | return (xfs_lsn_t)-1; | ||
120 | } | ||
121 | |||
122 | /* item can never get into the AIL */ | ||
123 | STATIC uint | ||
124 | xfs_icreate_item_push( | ||
125 | struct xfs_log_item *lip, | ||
126 | struct list_head *buffer_list) | ||
127 | { | ||
128 | ASSERT(0); | ||
129 | return XFS_ITEM_SUCCESS; | ||
130 | } | ||
131 | |||
132 | /* Ordered buffers do the dependency tracking here, so this does nothing. */ | ||
133 | STATIC void | ||
134 | xfs_icreate_item_committing( | ||
135 | struct xfs_log_item *lip, | ||
136 | xfs_lsn_t lsn) | ||
137 | { | ||
138 | } | ||
139 | |||
140 | /* | ||
141 | * This is the ops vector shared by all buf log items. | ||
142 | */ | ||
143 | static struct xfs_item_ops xfs_icreate_item_ops = { | ||
144 | .iop_size = xfs_icreate_item_size, | ||
145 | .iop_format = xfs_icreate_item_format, | ||
146 | .iop_pin = xfs_icreate_item_pin, | ||
147 | .iop_unpin = xfs_icreate_item_unpin, | ||
148 | .iop_push = xfs_icreate_item_push, | ||
149 | .iop_unlock = xfs_icreate_item_unlock, | ||
150 | .iop_committed = xfs_icreate_item_committed, | ||
151 | .iop_committing = xfs_icreate_item_committing, | ||
152 | }; | ||
153 | |||
154 | |||
155 | /* | ||
156 | * Initialize the inode log item for a newly allocated (in-core) inode. | ||
157 | * | ||
158 | * Inode extents can only reside within an AG. Hence specify the starting | ||
159 | * block for the inode chunk by offset within an AG as well as the | ||
160 | * length of the allocated extent. | ||
161 | * | ||
162 | * This joins the item to the transaction and marks it dirty so | ||
163 | * that we don't need a separate call to do this, nor does the | ||
164 | * caller need to know anything about the icreate item. | ||
165 | */ | ||
166 | void | ||
167 | xfs_icreate_log( | ||
168 | struct xfs_trans *tp, | ||
169 | xfs_agnumber_t agno, | ||
170 | xfs_agblock_t agbno, | ||
171 | unsigned int count, | ||
172 | unsigned int inode_size, | ||
173 | xfs_agblock_t length, | ||
174 | unsigned int generation) | ||
175 | { | ||
176 | struct xfs_icreate_item *icp; | ||
177 | |||
178 | icp = kmem_zone_zalloc(xfs_icreate_zone, KM_SLEEP); | ||
179 | |||
180 | xfs_log_item_init(tp->t_mountp, &icp->ic_item, XFS_LI_ICREATE, | ||
181 | &xfs_icreate_item_ops); | ||
182 | |||
183 | icp->ic_format.icl_type = XFS_LI_ICREATE; | ||
184 | icp->ic_format.icl_size = 1; /* single vector */ | ||
185 | icp->ic_format.icl_ag = cpu_to_be32(agno); | ||
186 | icp->ic_format.icl_agbno = cpu_to_be32(agbno); | ||
187 | icp->ic_format.icl_count = cpu_to_be32(count); | ||
188 | icp->ic_format.icl_isize = cpu_to_be32(inode_size); | ||
189 | icp->ic_format.icl_length = cpu_to_be32(length); | ||
190 | icp->ic_format.icl_gen = cpu_to_be32(generation); | ||
191 | |||
192 | xfs_trans_add_item(tp, &icp->ic_item); | ||
193 | tp->t_flags |= XFS_TRANS_DIRTY; | ||
194 | icp->ic_item.li_desc->lid_flags |= XFS_LID_DIRTY; | ||
195 | } | ||
diff --git a/fs/xfs/xfs_icreate_item.h b/fs/xfs/xfs_icreate_item.h new file mode 100644 index 000000000000..88ba8aa0bc41 --- /dev/null +++ b/fs/xfs/xfs_icreate_item.h | |||
@@ -0,0 +1,52 @@ | |||
1 | /* | ||
2 | * Copyright (c) 2008-2010, Dave Chinner | ||
3 | * All Rights Reserved. | ||
4 | * | ||
5 | * This program is free software; you can redistribute it and/or | ||
6 | * modify it under the terms of the GNU General Public License as | ||
7 | * published by the Free Software Foundation. | ||
8 | * | ||
9 | * This program is distributed in the hope that it would be useful, | ||
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
12 | * GNU General Public License for more details. | ||
13 | * | ||
14 | * You should have received a copy of the GNU General Public License | ||
15 | * along with this program; if not, write the Free Software Foundation, | ||
16 | * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA | ||
17 | */ | ||
18 | #ifndef XFS_ICREATE_ITEM_H | ||
19 | #define XFS_ICREATE_ITEM_H 1 | ||
20 | |||
21 | /* | ||
22 | * on disk log item structure | ||
23 | * | ||
24 | * Log recovery assumes the first two entries are the type and size and they fit | ||
25 | * in 32 bits. Also in host order (ugh) so they have to be 32 bit aligned so | ||
26 | * decoding can be done correctly. | ||
27 | */ | ||
28 | struct xfs_icreate_log { | ||
29 | __uint16_t icl_type; /* type of log format structure */ | ||
30 | __uint16_t icl_size; /* size of log format structure */ | ||
31 | __be32 icl_ag; /* ag being allocated in */ | ||
32 | __be32 icl_agbno; /* start block of inode range */ | ||
33 | __be32 icl_count; /* number of inodes to initialise */ | ||
34 | __be32 icl_isize; /* size of inodes */ | ||
35 | __be32 icl_length; /* length of extent to initialise */ | ||
36 | __be32 icl_gen; /* inode generation number to use */ | ||
37 | }; | ||
38 | |||
39 | /* in memory log item structure */ | ||
40 | struct xfs_icreate_item { | ||
41 | struct xfs_log_item ic_item; | ||
42 | struct xfs_icreate_log ic_format; | ||
43 | }; | ||
44 | |||
45 | extern kmem_zone_t *xfs_icreate_zone; /* inode create item zone */ | ||
46 | |||
47 | void xfs_icreate_log(struct xfs_trans *tp, xfs_agnumber_t agno, | ||
48 | xfs_agblock_t agbno, unsigned int count, | ||
49 | unsigned int inode_size, xfs_agblock_t length, | ||
50 | unsigned int generation); | ||
51 | |||
52 | #endif /* XFS_ICREATE_ITEM_H */ | ||
diff --git a/fs/xfs/xfs_inode.c b/fs/xfs/xfs_inode.c index 7f7be5f98f52..bb262c25c8de 100644 --- a/fs/xfs/xfs_inode.c +++ b/fs/xfs/xfs_inode.c | |||
@@ -896,7 +896,6 @@ xfs_dinode_to_disk( | |||
896 | to->di_projid_lo = cpu_to_be16(from->di_projid_lo); | 896 | to->di_projid_lo = cpu_to_be16(from->di_projid_lo); |
897 | to->di_projid_hi = cpu_to_be16(from->di_projid_hi); | 897 | to->di_projid_hi = cpu_to_be16(from->di_projid_hi); |
898 | memcpy(to->di_pad, from->di_pad, sizeof(to->di_pad)); | 898 | memcpy(to->di_pad, from->di_pad, sizeof(to->di_pad)); |
899 | to->di_flushiter = cpu_to_be16(from->di_flushiter); | ||
900 | to->di_atime.t_sec = cpu_to_be32(from->di_atime.t_sec); | 899 | to->di_atime.t_sec = cpu_to_be32(from->di_atime.t_sec); |
901 | to->di_atime.t_nsec = cpu_to_be32(from->di_atime.t_nsec); | 900 | to->di_atime.t_nsec = cpu_to_be32(from->di_atime.t_nsec); |
902 | to->di_mtime.t_sec = cpu_to_be32(from->di_mtime.t_sec); | 901 | to->di_mtime.t_sec = cpu_to_be32(from->di_mtime.t_sec); |
@@ -924,6 +923,9 @@ xfs_dinode_to_disk( | |||
924 | to->di_lsn = cpu_to_be64(from->di_lsn); | 923 | to->di_lsn = cpu_to_be64(from->di_lsn); |
925 | memcpy(to->di_pad2, from->di_pad2, sizeof(to->di_pad2)); | 924 | memcpy(to->di_pad2, from->di_pad2, sizeof(to->di_pad2)); |
926 | uuid_copy(&to->di_uuid, &from->di_uuid); | 925 | uuid_copy(&to->di_uuid, &from->di_uuid); |
926 | to->di_flushiter = 0; | ||
927 | } else { | ||
928 | to->di_flushiter = cpu_to_be16(from->di_flushiter); | ||
927 | } | 929 | } |
928 | } | 930 | } |
929 | 931 | ||
@@ -1028,6 +1030,15 @@ xfs_dinode_calc_crc( | |||
1028 | 1030 | ||
1029 | /* | 1031 | /* |
1030 | * Read the disk inode attributes into the in-core inode structure. | 1032 | * Read the disk inode attributes into the in-core inode structure. |
1033 | * | ||
1034 | * For version 5 superblocks, if we are initialising a new inode and we are not | ||
1035 | * utilising the XFS_MOUNT_IKEEP inode cluster mode, we can simple build the new | ||
1036 | * inode core with a random generation number. If we are keeping inodes around, | ||
1037 | * we need to read the inode cluster to get the existing generation number off | ||
1038 | * disk. Further, if we are using version 4 superblocks (i.e. v1/v2 inode | ||
1039 | * format) then log recovery is dependent on the di_flushiter field being | ||
1040 | * initialised from the current on-disk value and hence we must also read the | ||
1041 | * inode off disk. | ||
1031 | */ | 1042 | */ |
1032 | int | 1043 | int |
1033 | xfs_iread( | 1044 | xfs_iread( |
@@ -1047,6 +1058,23 @@ xfs_iread( | |||
1047 | if (error) | 1058 | if (error) |
1048 | return error; | 1059 | return error; |
1049 | 1060 | ||
1061 | /* shortcut IO on inode allocation if possible */ | ||
1062 | if ((iget_flags & XFS_IGET_CREATE) && | ||
1063 | xfs_sb_version_hascrc(&mp->m_sb) && | ||
1064 | !(mp->m_flags & XFS_MOUNT_IKEEP)) { | ||
1065 | /* initialise the on-disk inode core */ | ||
1066 | memset(&ip->i_d, 0, sizeof(ip->i_d)); | ||
1067 | ip->i_d.di_magic = XFS_DINODE_MAGIC; | ||
1068 | ip->i_d.di_gen = prandom_u32(); | ||
1069 | if (xfs_sb_version_hascrc(&mp->m_sb)) { | ||
1070 | ip->i_d.di_version = 3; | ||
1071 | ip->i_d.di_ino = ip->i_ino; | ||
1072 | uuid_copy(&ip->i_d.di_uuid, &mp->m_sb.sb_uuid); | ||
1073 | } else | ||
1074 | ip->i_d.di_version = 2; | ||
1075 | return 0; | ||
1076 | } | ||
1077 | |||
1050 | /* | 1078 | /* |
1051 | * Get pointers to the on-disk inode and the buffer containing it. | 1079 | * Get pointers to the on-disk inode and the buffer containing it. |
1052 | */ | 1080 | */ |
@@ -1133,17 +1161,16 @@ xfs_iread( | |||
1133 | xfs_buf_set_ref(bp, XFS_INO_REF); | 1161 | xfs_buf_set_ref(bp, XFS_INO_REF); |
1134 | 1162 | ||
1135 | /* | 1163 | /* |
1136 | * Use xfs_trans_brelse() to release the buffer containing the | 1164 | * Use xfs_trans_brelse() to release the buffer containing the on-disk |
1137 | * on-disk inode, because it was acquired with xfs_trans_read_buf() | 1165 | * inode, because it was acquired with xfs_trans_read_buf() in |
1138 | * in xfs_imap_to_bp() above. If tp is NULL, this is just a normal | 1166 | * xfs_imap_to_bp() above. If tp is NULL, this is just a normal |
1139 | * brelse(). If we're within a transaction, then xfs_trans_brelse() | 1167 | * brelse(). If we're within a transaction, then xfs_trans_brelse() |
1140 | * will only release the buffer if it is not dirty within the | 1168 | * will only release the buffer if it is not dirty within the |
1141 | * transaction. It will be OK to release the buffer in this case, | 1169 | * transaction. It will be OK to release the buffer in this case, |
1142 | * because inodes on disk are never destroyed and we will be | 1170 | * because inodes on disk are never destroyed and we will be locking the |
1143 | * locking the new in-core inode before putting it in the hash | 1171 | * new in-core inode before putting it in the cache where other |
1144 | * table where other processes can find it. Thus we don't have | 1172 | * processes can find it. Thus we don't have to worry about the inode |
1145 | * to worry about the inode being changed just because we released | 1173 | * being changed just because we released the buffer. |
1146 | * the buffer. | ||
1147 | */ | 1174 | */ |
1148 | out_brelse: | 1175 | out_brelse: |
1149 | xfs_trans_brelse(tp, bp); | 1176 | xfs_trans_brelse(tp, bp); |
@@ -2028,8 +2055,6 @@ xfs_ifree( | |||
2028 | int error; | 2055 | int error; |
2029 | int delete; | 2056 | int delete; |
2030 | xfs_ino_t first_ino; | 2057 | xfs_ino_t first_ino; |
2031 | xfs_dinode_t *dip; | ||
2032 | xfs_buf_t *ibp; | ||
2033 | 2058 | ||
2034 | ASSERT(xfs_isilocked(ip, XFS_ILOCK_EXCL)); | 2059 | ASSERT(xfs_isilocked(ip, XFS_ILOCK_EXCL)); |
2035 | ASSERT(ip->i_d.di_nlink == 0); | 2060 | ASSERT(ip->i_d.di_nlink == 0); |
@@ -2042,14 +2067,13 @@ xfs_ifree( | |||
2042 | * Pull the on-disk inode from the AGI unlinked list. | 2067 | * Pull the on-disk inode from the AGI unlinked list. |
2043 | */ | 2068 | */ |
2044 | error = xfs_iunlink_remove(tp, ip); | 2069 | error = xfs_iunlink_remove(tp, ip); |
2045 | if (error != 0) { | 2070 | if (error) |
2046 | return error; | 2071 | return error; |
2047 | } | ||
2048 | 2072 | ||
2049 | error = xfs_difree(tp, ip->i_ino, flist, &delete, &first_ino); | 2073 | error = xfs_difree(tp, ip->i_ino, flist, &delete, &first_ino); |
2050 | if (error != 0) { | 2074 | if (error) |
2051 | return error; | 2075 | return error; |
2052 | } | 2076 | |
2053 | ip->i_d.di_mode = 0; /* mark incore inode as free */ | 2077 | ip->i_d.di_mode = 0; /* mark incore inode as free */ |
2054 | ip->i_d.di_flags = 0; | 2078 | ip->i_d.di_flags = 0; |
2055 | ip->i_d.di_dmevmask = 0; | 2079 | ip->i_d.di_dmevmask = 0; |
@@ -2061,31 +2085,10 @@ xfs_ifree( | |||
2061 | * by reincarnations of this inode. | 2085 | * by reincarnations of this inode. |
2062 | */ | 2086 | */ |
2063 | ip->i_d.di_gen++; | 2087 | ip->i_d.di_gen++; |
2064 | |||
2065 | xfs_trans_log_inode(tp, ip, XFS_ILOG_CORE); | 2088 | xfs_trans_log_inode(tp, ip, XFS_ILOG_CORE); |
2066 | 2089 | ||
2067 | error = xfs_imap_to_bp(ip->i_mount, tp, &ip->i_imap, &dip, &ibp, | 2090 | if (delete) |
2068 | 0, 0); | ||
2069 | if (error) | ||
2070 | return error; | ||
2071 | |||
2072 | /* | ||
2073 | * Clear the on-disk di_mode. This is to prevent xfs_bulkstat | ||
2074 | * from picking up this inode when it is reclaimed (its incore state | ||
2075 | * initialzed but not flushed to disk yet). The in-core di_mode is | ||
2076 | * already cleared and a corresponding transaction logged. | ||
2077 | * The hack here just synchronizes the in-core to on-disk | ||
2078 | * di_mode value in advance before the actual inode sync to disk. | ||
2079 | * This is OK because the inode is already unlinked and would never | ||
2080 | * change its di_mode again for this inode generation. | ||
2081 | * This is a temporary hack that would require a proper fix | ||
2082 | * in the future. | ||
2083 | */ | ||
2084 | dip->di_mode = 0; | ||
2085 | |||
2086 | if (delete) { | ||
2087 | error = xfs_ifree_cluster(ip, tp, first_ino); | 2091 | error = xfs_ifree_cluster(ip, tp, first_ino); |
2088 | } | ||
2089 | 2092 | ||
2090 | return error; | 2093 | return error; |
2091 | } | 2094 | } |
@@ -2160,8 +2163,8 @@ xfs_iroot_realloc( | |||
2160 | np = (char *)XFS_BMAP_BROOT_PTR_ADDR(mp, ifp->if_broot, 1, | 2163 | np = (char *)XFS_BMAP_BROOT_PTR_ADDR(mp, ifp->if_broot, 1, |
2161 | (int)new_size); | 2164 | (int)new_size); |
2162 | ifp->if_broot_bytes = (int)new_size; | 2165 | ifp->if_broot_bytes = (int)new_size; |
2163 | ASSERT(ifp->if_broot_bytes <= | 2166 | ASSERT(XFS_BMAP_BMDR_SPACE(ifp->if_broot) <= |
2164 | XFS_IFORK_SIZE(ip, whichfork) + XFS_BROOT_SIZE_ADJ(ip)); | 2167 | XFS_IFORK_SIZE(ip, whichfork)); |
2165 | memmove(np, op, cur_max * (uint)sizeof(xfs_dfsbno_t)); | 2168 | memmove(np, op, cur_max * (uint)sizeof(xfs_dfsbno_t)); |
2166 | return; | 2169 | return; |
2167 | } | 2170 | } |
@@ -2214,8 +2217,9 @@ xfs_iroot_realloc( | |||
2214 | kmem_free(ifp->if_broot); | 2217 | kmem_free(ifp->if_broot); |
2215 | ifp->if_broot = new_broot; | 2218 | ifp->if_broot = new_broot; |
2216 | ifp->if_broot_bytes = (int)new_size; | 2219 | ifp->if_broot_bytes = (int)new_size; |
2217 | ASSERT(ifp->if_broot_bytes <= | 2220 | if (ifp->if_broot) |
2218 | XFS_IFORK_SIZE(ip, whichfork) + XFS_BROOT_SIZE_ADJ(ip)); | 2221 | ASSERT(XFS_BMAP_BMDR_SPACE(ifp->if_broot) <= |
2222 | XFS_IFORK_SIZE(ip, whichfork)); | ||
2219 | return; | 2223 | return; |
2220 | } | 2224 | } |
2221 | 2225 | ||
@@ -2526,9 +2530,8 @@ xfs_iflush_fork( | |||
2526 | if ((iip->ili_fields & brootflag[whichfork]) && | 2530 | if ((iip->ili_fields & brootflag[whichfork]) && |
2527 | (ifp->if_broot_bytes > 0)) { | 2531 | (ifp->if_broot_bytes > 0)) { |
2528 | ASSERT(ifp->if_broot != NULL); | 2532 | ASSERT(ifp->if_broot != NULL); |
2529 | ASSERT(ifp->if_broot_bytes <= | 2533 | ASSERT(XFS_BMAP_BMDR_SPACE(ifp->if_broot) <= |
2530 | (XFS_IFORK_SIZE(ip, whichfork) + | 2534 | XFS_IFORK_SIZE(ip, whichfork)); |
2531 | XFS_BROOT_SIZE_ADJ(ip))); | ||
2532 | xfs_bmbt_to_bmdr(mp, ifp->if_broot, ifp->if_broot_bytes, | 2535 | xfs_bmbt_to_bmdr(mp, ifp->if_broot, ifp->if_broot_bytes, |
2533 | (xfs_bmdr_block_t *)cp, | 2536 | (xfs_bmdr_block_t *)cp, |
2534 | XFS_DFORK_SIZE(dip, mp, whichfork)); | 2537 | XFS_DFORK_SIZE(dip, mp, whichfork)); |
@@ -2886,12 +2889,18 @@ xfs_iflush_int( | |||
2886 | __func__, ip->i_ino, ip->i_d.di_forkoff, ip); | 2889 | __func__, ip->i_ino, ip->i_d.di_forkoff, ip); |
2887 | goto corrupt_out; | 2890 | goto corrupt_out; |
2888 | } | 2891 | } |
2892 | |||
2889 | /* | 2893 | /* |
2890 | * bump the flush iteration count, used to detect flushes which | 2894 | * Inode item log recovery for v1/v2 inodes are dependent on the |
2891 | * postdate a log record during recovery. This is redundant as we now | 2895 | * di_flushiter count for correct sequencing. We bump the flush |
2892 | * log every change and hence this can't happen. Still, it doesn't hurt. | 2896 | * iteration count so we can detect flushes which postdate a log record |
2897 | * during recovery. This is redundant as we now log every change and | ||
2898 | * hence this can't happen but we need to still do it to ensure | ||
2899 | * backwards compatibility with old kernels that predate logging all | ||
2900 | * inode changes. | ||
2893 | */ | 2901 | */ |
2894 | ip->i_d.di_flushiter++; | 2902 | if (ip->i_d.di_version < 3) |
2903 | ip->i_d.di_flushiter++; | ||
2895 | 2904 | ||
2896 | /* | 2905 | /* |
2897 | * Copy the dirty parts of the inode into the on-disk | 2906 | * Copy the dirty parts of the inode into the on-disk |
diff --git a/fs/xfs/xfs_inode.h b/fs/xfs/xfs_inode.h index 91129794aaec..b55fd347ab5b 100644 --- a/fs/xfs/xfs_inode.h +++ b/fs/xfs/xfs_inode.h | |||
@@ -250,6 +250,7 @@ typedef struct xfs_inode { | |||
250 | struct xfs_mount *i_mount; /* fs mount struct ptr */ | 250 | struct xfs_mount *i_mount; /* fs mount struct ptr */ |
251 | struct xfs_dquot *i_udquot; /* user dquot */ | 251 | struct xfs_dquot *i_udquot; /* user dquot */ |
252 | struct xfs_dquot *i_gdquot; /* group dquot */ | 252 | struct xfs_dquot *i_gdquot; /* group dquot */ |
253 | struct xfs_dquot *i_pdquot; /* project dquot */ | ||
253 | 254 | ||
254 | /* Inode location stuff */ | 255 | /* Inode location stuff */ |
255 | xfs_ino_t i_ino; /* inode number (agno/agino)*/ | 256 | xfs_ino_t i_ino; /* inode number (agno/agino)*/ |
diff --git a/fs/xfs/xfs_ioctl.c b/fs/xfs/xfs_ioctl.c index 5e999680094a..6e2bca5d44d6 100644 --- a/fs/xfs/xfs_ioctl.c +++ b/fs/xfs/xfs_ioctl.c | |||
@@ -248,7 +248,7 @@ xfs_open_by_handle( | |||
248 | goto out_dput; | 248 | goto out_dput; |
249 | } | 249 | } |
250 | 250 | ||
251 | fd = get_unused_fd(); | 251 | fd = get_unused_fd_flags(0); |
252 | if (fd < 0) { | 252 | if (fd < 0) { |
253 | error = fd; | 253 | error = fd; |
254 | goto out_dput; | 254 | goto out_dput; |
@@ -928,7 +928,7 @@ xfs_ioctl_setattr( | |||
928 | struct xfs_trans *tp; | 928 | struct xfs_trans *tp; |
929 | unsigned int lock_flags = 0; | 929 | unsigned int lock_flags = 0; |
930 | struct xfs_dquot *udqp = NULL; | 930 | struct xfs_dquot *udqp = NULL; |
931 | struct xfs_dquot *gdqp = NULL; | 931 | struct xfs_dquot *pdqp = NULL; |
932 | struct xfs_dquot *olddquot = NULL; | 932 | struct xfs_dquot *olddquot = NULL; |
933 | int code; | 933 | int code; |
934 | 934 | ||
@@ -957,7 +957,7 @@ xfs_ioctl_setattr( | |||
957 | if (XFS_IS_QUOTA_ON(mp) && (mask & FSX_PROJID)) { | 957 | if (XFS_IS_QUOTA_ON(mp) && (mask & FSX_PROJID)) { |
958 | code = xfs_qm_vop_dqalloc(ip, ip->i_d.di_uid, | 958 | code = xfs_qm_vop_dqalloc(ip, ip->i_d.di_uid, |
959 | ip->i_d.di_gid, fa->fsx_projid, | 959 | ip->i_d.di_gid, fa->fsx_projid, |
960 | XFS_QMOPT_PQUOTA, &udqp, &gdqp); | 960 | XFS_QMOPT_PQUOTA, &udqp, NULL, &pdqp); |
961 | if (code) | 961 | if (code) |
962 | return code; | 962 | return code; |
963 | } | 963 | } |
@@ -994,8 +994,8 @@ xfs_ioctl_setattr( | |||
994 | XFS_IS_PQUOTA_ON(mp) && | 994 | XFS_IS_PQUOTA_ON(mp) && |
995 | xfs_get_projid(ip) != fa->fsx_projid) { | 995 | xfs_get_projid(ip) != fa->fsx_projid) { |
996 | ASSERT(tp); | 996 | ASSERT(tp); |
997 | code = xfs_qm_vop_chown_reserve(tp, ip, udqp, gdqp, | 997 | code = xfs_qm_vop_chown_reserve(tp, ip, udqp, NULL, |
998 | capable(CAP_FOWNER) ? | 998 | pdqp, capable(CAP_FOWNER) ? |
999 | XFS_QMOPT_FORCE_RES : 0); | 999 | XFS_QMOPT_FORCE_RES : 0); |
1000 | if (code) /* out of quota */ | 1000 | if (code) /* out of quota */ |
1001 | goto error_return; | 1001 | goto error_return; |
@@ -1113,7 +1113,7 @@ xfs_ioctl_setattr( | |||
1113 | if (xfs_get_projid(ip) != fa->fsx_projid) { | 1113 | if (xfs_get_projid(ip) != fa->fsx_projid) { |
1114 | if (XFS_IS_QUOTA_RUNNING(mp) && XFS_IS_PQUOTA_ON(mp)) { | 1114 | if (XFS_IS_QUOTA_RUNNING(mp) && XFS_IS_PQUOTA_ON(mp)) { |
1115 | olddquot = xfs_qm_vop_chown(tp, ip, | 1115 | olddquot = xfs_qm_vop_chown(tp, ip, |
1116 | &ip->i_gdquot, gdqp); | 1116 | &ip->i_pdquot, pdqp); |
1117 | } | 1117 | } |
1118 | xfs_set_projid(ip, fa->fsx_projid); | 1118 | xfs_set_projid(ip, fa->fsx_projid); |
1119 | 1119 | ||
@@ -1160,13 +1160,13 @@ xfs_ioctl_setattr( | |||
1160 | */ | 1160 | */ |
1161 | xfs_qm_dqrele(olddquot); | 1161 | xfs_qm_dqrele(olddquot); |
1162 | xfs_qm_dqrele(udqp); | 1162 | xfs_qm_dqrele(udqp); |
1163 | xfs_qm_dqrele(gdqp); | 1163 | xfs_qm_dqrele(pdqp); |
1164 | 1164 | ||
1165 | return code; | 1165 | return code; |
1166 | 1166 | ||
1167 | error_return: | 1167 | error_return: |
1168 | xfs_qm_dqrele(udqp); | 1168 | xfs_qm_dqrele(udqp); |
1169 | xfs_qm_dqrele(gdqp); | 1169 | xfs_qm_dqrele(pdqp); |
1170 | xfs_trans_cancel(tp, 0); | 1170 | xfs_trans_cancel(tp, 0); |
1171 | if (lock_flags) | 1171 | if (lock_flags) |
1172 | xfs_iunlock(ip, lock_flags); | 1172 | xfs_iunlock(ip, lock_flags); |
diff --git a/fs/xfs/xfs_iomap.c b/fs/xfs/xfs_iomap.c index 8f8aaee7f379..6a7096422295 100644 --- a/fs/xfs/xfs_iomap.c +++ b/fs/xfs/xfs_iomap.c | |||
@@ -284,6 +284,15 @@ xfs_iomap_eof_want_preallocate( | |||
284 | return 0; | 284 | return 0; |
285 | 285 | ||
286 | /* | 286 | /* |
287 | * If the file is smaller than the minimum prealloc and we are using | ||
288 | * dynamic preallocation, don't do any preallocation at all as it is | ||
289 | * likely this is the only write to the file that is going to be done. | ||
290 | */ | ||
291 | if (!(mp->m_flags & XFS_MOUNT_DFLT_IOSIZE) && | ||
292 | XFS_ISIZE(ip) < XFS_FSB_TO_B(mp, mp->m_writeio_blocks)) | ||
293 | return 0; | ||
294 | |||
295 | /* | ||
287 | * If there are any real blocks past eof, then don't | 296 | * If there are any real blocks past eof, then don't |
288 | * do any speculative allocation. | 297 | * do any speculative allocation. |
289 | */ | 298 | */ |
@@ -345,6 +354,10 @@ xfs_iomap_eof_prealloc_initial_size( | |||
345 | if (mp->m_flags & XFS_MOUNT_DFLT_IOSIZE) | 354 | if (mp->m_flags & XFS_MOUNT_DFLT_IOSIZE) |
346 | return 0; | 355 | return 0; |
347 | 356 | ||
357 | /* If the file is small, then use the minimum prealloc */ | ||
358 | if (XFS_ISIZE(ip) < XFS_FSB_TO_B(mp, mp->m_dalign)) | ||
359 | return 0; | ||
360 | |||
348 | /* | 361 | /* |
349 | * As we write multiple pages, the offset will always align to the | 362 | * As we write multiple pages, the offset will always align to the |
350 | * start of a page and hence point to a hole at EOF. i.e. if the size is | 363 | * start of a page and hence point to a hole at EOF. i.e. if the size is |
diff --git a/fs/xfs/xfs_iops.c b/fs/xfs/xfs_iops.c index ca9ecaa81112..96dda62d497b 100644 --- a/fs/xfs/xfs_iops.c +++ b/fs/xfs/xfs_iops.c | |||
@@ -467,9 +467,6 @@ xfs_setattr_mode( | |||
467 | ASSERT(tp); | 467 | ASSERT(tp); |
468 | ASSERT(xfs_isilocked(ip, XFS_ILOCK_EXCL)); | 468 | ASSERT(xfs_isilocked(ip, XFS_ILOCK_EXCL)); |
469 | 469 | ||
470 | if (!in_group_p(inode->i_gid) && !capable(CAP_FSETID)) | ||
471 | mode &= ~S_ISGID; | ||
472 | |||
473 | ip->i_d.di_mode &= S_IFMT; | 470 | ip->i_d.di_mode &= S_IFMT; |
474 | ip->i_d.di_mode |= mode & ~S_IFMT; | 471 | ip->i_d.di_mode |= mode & ~S_IFMT; |
475 | 472 | ||
@@ -495,15 +492,18 @@ xfs_setattr_nonsize( | |||
495 | 492 | ||
496 | trace_xfs_setattr(ip); | 493 | trace_xfs_setattr(ip); |
497 | 494 | ||
498 | if (mp->m_flags & XFS_MOUNT_RDONLY) | 495 | /* If acls are being inherited, we already have this checked */ |
499 | return XFS_ERROR(EROFS); | 496 | if (!(flags & XFS_ATTR_NOACL)) { |
497 | if (mp->m_flags & XFS_MOUNT_RDONLY) | ||
498 | return XFS_ERROR(EROFS); | ||
500 | 499 | ||
501 | if (XFS_FORCED_SHUTDOWN(mp)) | 500 | if (XFS_FORCED_SHUTDOWN(mp)) |
502 | return XFS_ERROR(EIO); | 501 | return XFS_ERROR(EIO); |
503 | 502 | ||
504 | error = -inode_change_ok(inode, iattr); | 503 | error = -inode_change_ok(inode, iattr); |
505 | if (error) | 504 | if (error) |
506 | return XFS_ERROR(error); | 505 | return XFS_ERROR(error); |
506 | } | ||
507 | 507 | ||
508 | ASSERT((mask & ATTR_SIZE) == 0); | 508 | ASSERT((mask & ATTR_SIZE) == 0); |
509 | 509 | ||
@@ -539,7 +539,7 @@ xfs_setattr_nonsize( | |||
539 | ASSERT(udqp == NULL); | 539 | ASSERT(udqp == NULL); |
540 | ASSERT(gdqp == NULL); | 540 | ASSERT(gdqp == NULL); |
541 | error = xfs_qm_vop_dqalloc(ip, uid, gid, xfs_get_projid(ip), | 541 | error = xfs_qm_vop_dqalloc(ip, uid, gid, xfs_get_projid(ip), |
542 | qflags, &udqp, &gdqp); | 542 | qflags, &udqp, &gdqp, NULL); |
543 | if (error) | 543 | if (error) |
544 | return error; | 544 | return error; |
545 | } | 545 | } |
@@ -575,7 +575,7 @@ xfs_setattr_nonsize( | |||
575 | (XFS_IS_GQUOTA_ON(mp) && igid != gid))) { | 575 | (XFS_IS_GQUOTA_ON(mp) && igid != gid))) { |
576 | ASSERT(tp); | 576 | ASSERT(tp); |
577 | error = xfs_qm_vop_chown_reserve(tp, ip, udqp, gdqp, | 577 | error = xfs_qm_vop_chown_reserve(tp, ip, udqp, gdqp, |
578 | capable(CAP_FOWNER) ? | 578 | NULL, capable(CAP_FOWNER) ? |
579 | XFS_QMOPT_FORCE_RES : 0); | 579 | XFS_QMOPT_FORCE_RES : 0); |
580 | if (error) /* out of quota */ | 580 | if (error) /* out of quota */ |
581 | goto out_trans_cancel; | 581 | goto out_trans_cancel; |
@@ -987,7 +987,8 @@ xfs_fiemap_format( | |||
987 | if (bmv->bmv_oflags & BMV_OF_PREALLOC) | 987 | if (bmv->bmv_oflags & BMV_OF_PREALLOC) |
988 | fiemap_flags |= FIEMAP_EXTENT_UNWRITTEN; | 988 | fiemap_flags |= FIEMAP_EXTENT_UNWRITTEN; |
989 | else if (bmv->bmv_oflags & BMV_OF_DELALLOC) { | 989 | else if (bmv->bmv_oflags & BMV_OF_DELALLOC) { |
990 | fiemap_flags |= FIEMAP_EXTENT_DELALLOC; | 990 | fiemap_flags |= (FIEMAP_EXTENT_DELALLOC | |
991 | FIEMAP_EXTENT_UNKNOWN); | ||
991 | physical = 0; /* no block yet */ | 992 | physical = 0; /* no block yet */ |
992 | } | 993 | } |
993 | if (bmv->bmv_oflags & BMV_OF_LAST) | 994 | if (bmv->bmv_oflags & BMV_OF_LAST) |
diff --git a/fs/xfs/xfs_itable.c b/fs/xfs/xfs_itable.c index 2ea7d402188d..b93e14b86754 100644 --- a/fs/xfs/xfs_itable.c +++ b/fs/xfs/xfs_itable.c | |||
@@ -43,7 +43,7 @@ xfs_internal_inum( | |||
43 | { | 43 | { |
44 | return (ino == mp->m_sb.sb_rbmino || ino == mp->m_sb.sb_rsumino || | 44 | return (ino == mp->m_sb.sb_rbmino || ino == mp->m_sb.sb_rsumino || |
45 | (xfs_sb_version_hasquota(&mp->m_sb) && | 45 | (xfs_sb_version_hasquota(&mp->m_sb) && |
46 | (ino == mp->m_sb.sb_uquotino || ino == mp->m_sb.sb_gquotino))); | 46 | xfs_is_quota_inode(&mp->m_sb, ino))); |
47 | } | 47 | } |
48 | 48 | ||
49 | /* | 49 | /* |
@@ -221,7 +221,6 @@ xfs_bulkstat( | |||
221 | char __user *ubufp; /* pointer into user's buffer */ | 221 | char __user *ubufp; /* pointer into user's buffer */ |
222 | int ubelem; /* spaces used in user's buffer */ | 222 | int ubelem; /* spaces used in user's buffer */ |
223 | int ubused; /* bytes used by formatter */ | 223 | int ubused; /* bytes used by formatter */ |
224 | xfs_buf_t *bp; /* ptr to on-disk inode cluster buf */ | ||
225 | 224 | ||
226 | /* | 225 | /* |
227 | * Get the last inode value, see if there's nothing to do. | 226 | * Get the last inode value, see if there's nothing to do. |
@@ -263,7 +262,6 @@ xfs_bulkstat( | |||
263 | rval = 0; | 262 | rval = 0; |
264 | while (XFS_BULKSTAT_UBLEFT(ubleft) && agno < mp->m_sb.sb_agcount) { | 263 | while (XFS_BULKSTAT_UBLEFT(ubleft) && agno < mp->m_sb.sb_agcount) { |
265 | cond_resched(); | 264 | cond_resched(); |
266 | bp = NULL; | ||
267 | error = xfs_ialloc_read_agi(mp, NULL, agno, &agbp); | 265 | error = xfs_ialloc_read_agi(mp, NULL, agno, &agbp); |
268 | if (error) { | 266 | if (error) { |
269 | /* | 267 | /* |
@@ -383,11 +381,13 @@ xfs_bulkstat( | |||
383 | * Also start read-ahead now for this chunk. | 381 | * Also start read-ahead now for this chunk. |
384 | */ | 382 | */ |
385 | if (r.ir_freecount < XFS_INODES_PER_CHUNK) { | 383 | if (r.ir_freecount < XFS_INODES_PER_CHUNK) { |
384 | struct blk_plug plug; | ||
386 | /* | 385 | /* |
387 | * Loop over all clusters in the next chunk. | 386 | * Loop over all clusters in the next chunk. |
388 | * Do a readahead if there are any allocated | 387 | * Do a readahead if there are any allocated |
389 | * inodes in that cluster. | 388 | * inodes in that cluster. |
390 | */ | 389 | */ |
390 | blk_start_plug(&plug); | ||
391 | agbno = XFS_AGINO_TO_AGBNO(mp, r.ir_startino); | 391 | agbno = XFS_AGINO_TO_AGBNO(mp, r.ir_startino); |
392 | for (chunkidx = 0; | 392 | for (chunkidx = 0; |
393 | chunkidx < XFS_INODES_PER_CHUNK; | 393 | chunkidx < XFS_INODES_PER_CHUNK; |
@@ -399,6 +399,7 @@ xfs_bulkstat( | |||
399 | agbno, nbcluster, | 399 | agbno, nbcluster, |
400 | &xfs_inode_buf_ops); | 400 | &xfs_inode_buf_ops); |
401 | } | 401 | } |
402 | blk_finish_plug(&plug); | ||
402 | irbp->ir_startino = r.ir_startino; | 403 | irbp->ir_startino = r.ir_startino; |
403 | irbp->ir_freecount = r.ir_freecount; | 404 | irbp->ir_freecount = r.ir_freecount; |
404 | irbp->ir_free = r.ir_free; | 405 | irbp->ir_free = r.ir_free; |
@@ -433,27 +434,7 @@ xfs_bulkstat( | |||
433 | irbp->ir_freecount < XFS_INODES_PER_CHUNK; | 434 | irbp->ir_freecount < XFS_INODES_PER_CHUNK; |
434 | chunkidx++, clustidx++, agino++) { | 435 | chunkidx++, clustidx++, agino++) { |
435 | ASSERT(chunkidx < XFS_INODES_PER_CHUNK); | 436 | ASSERT(chunkidx < XFS_INODES_PER_CHUNK); |
436 | /* | 437 | |
437 | * Recompute agbno if this is the | ||
438 | * first inode of the cluster. | ||
439 | * | ||
440 | * Careful with clustidx. There can be | ||
441 | * multiple clusters per chunk, a single | ||
442 | * cluster per chunk or a cluster that has | ||
443 | * inodes represented from several different | ||
444 | * chunks (if blocksize is large). | ||
445 | * | ||
446 | * Because of this, the starting clustidx is | ||
447 | * initialized to zero in this loop but must | ||
448 | * later be reset after reading in the cluster | ||
449 | * buffer. | ||
450 | */ | ||
451 | if ((chunkidx & (nicluster - 1)) == 0) { | ||
452 | agbno = XFS_AGINO_TO_AGBNO(mp, | ||
453 | irbp->ir_startino) + | ||
454 | ((chunkidx & nimask) >> | ||
455 | mp->m_sb.sb_inopblog); | ||
456 | } | ||
457 | ino = XFS_AGINO_TO_INO(mp, agno, agino); | 438 | ino = XFS_AGINO_TO_INO(mp, agno, agino); |
458 | /* | 439 | /* |
459 | * Skip if this inode is free. | 440 | * Skip if this inode is free. |
@@ -499,10 +480,6 @@ xfs_bulkstat( | |||
499 | 480 | ||
500 | cond_resched(); | 481 | cond_resched(); |
501 | } | 482 | } |
502 | |||
503 | if (bp) | ||
504 | xfs_buf_relse(bp); | ||
505 | |||
506 | /* | 483 | /* |
507 | * Set up for the next loop iteration. | 484 | * Set up for the next loop iteration. |
508 | */ | 485 | */ |
diff --git a/fs/xfs/xfs_log.c b/fs/xfs/xfs_log.c index b345a7c85153..d852a2b3e1fd 100644 --- a/fs/xfs/xfs_log.c +++ b/fs/xfs/xfs_log.c | |||
@@ -1963,6 +1963,10 @@ xlog_write_calc_vec_length( | |||
1963 | headers++; | 1963 | headers++; |
1964 | 1964 | ||
1965 | for (lv = log_vector; lv; lv = lv->lv_next) { | 1965 | for (lv = log_vector; lv; lv = lv->lv_next) { |
1966 | /* we don't write ordered log vectors */ | ||
1967 | if (lv->lv_buf_len == XFS_LOG_VEC_ORDERED) | ||
1968 | continue; | ||
1969 | |||
1966 | headers += lv->lv_niovecs; | 1970 | headers += lv->lv_niovecs; |
1967 | 1971 | ||
1968 | for (i = 0; i < lv->lv_niovecs; i++) { | 1972 | for (i = 0; i < lv->lv_niovecs; i++) { |
@@ -2216,7 +2220,7 @@ xlog_write( | |||
2216 | index = 0; | 2220 | index = 0; |
2217 | lv = log_vector; | 2221 | lv = log_vector; |
2218 | vecp = lv->lv_iovecp; | 2222 | vecp = lv->lv_iovecp; |
2219 | while (lv && index < lv->lv_niovecs) { | 2223 | while (lv && (!lv->lv_niovecs || index < lv->lv_niovecs)) { |
2220 | void *ptr; | 2224 | void *ptr; |
2221 | int log_offset; | 2225 | int log_offset; |
2222 | 2226 | ||
@@ -2236,13 +2240,22 @@ xlog_write( | |||
2236 | * This loop writes out as many regions as can fit in the amount | 2240 | * This loop writes out as many regions as can fit in the amount |
2237 | * of space which was allocated by xlog_state_get_iclog_space(). | 2241 | * of space which was allocated by xlog_state_get_iclog_space(). |
2238 | */ | 2242 | */ |
2239 | while (lv && index < lv->lv_niovecs) { | 2243 | while (lv && (!lv->lv_niovecs || index < lv->lv_niovecs)) { |
2240 | struct xfs_log_iovec *reg = &vecp[index]; | 2244 | struct xfs_log_iovec *reg; |
2241 | struct xlog_op_header *ophdr; | 2245 | struct xlog_op_header *ophdr; |
2242 | int start_rec_copy; | 2246 | int start_rec_copy; |
2243 | int copy_len; | 2247 | int copy_len; |
2244 | int copy_off; | 2248 | int copy_off; |
2249 | bool ordered = false; | ||
2250 | |||
2251 | /* ordered log vectors have no regions to write */ | ||
2252 | if (lv->lv_buf_len == XFS_LOG_VEC_ORDERED) { | ||
2253 | ASSERT(lv->lv_niovecs == 0); | ||
2254 | ordered = true; | ||
2255 | goto next_lv; | ||
2256 | } | ||
2245 | 2257 | ||
2258 | reg = &vecp[index]; | ||
2246 | ASSERT(reg->i_len % sizeof(__int32_t) == 0); | 2259 | ASSERT(reg->i_len % sizeof(__int32_t) == 0); |
2247 | ASSERT((unsigned long)ptr % sizeof(__int32_t) == 0); | 2260 | ASSERT((unsigned long)ptr % sizeof(__int32_t) == 0); |
2248 | 2261 | ||
@@ -2302,12 +2315,13 @@ xlog_write( | |||
2302 | break; | 2315 | break; |
2303 | 2316 | ||
2304 | if (++index == lv->lv_niovecs) { | 2317 | if (++index == lv->lv_niovecs) { |
2318 | next_lv: | ||
2305 | lv = lv->lv_next; | 2319 | lv = lv->lv_next; |
2306 | index = 0; | 2320 | index = 0; |
2307 | if (lv) | 2321 | if (lv) |
2308 | vecp = lv->lv_iovecp; | 2322 | vecp = lv->lv_iovecp; |
2309 | } | 2323 | } |
2310 | if (record_cnt == 0) { | 2324 | if (record_cnt == 0 && ordered == false) { |
2311 | if (!lv) | 2325 | if (!lv) |
2312 | return 0; | 2326 | return 0; |
2313 | break; | 2327 | break; |
diff --git a/fs/xfs/xfs_log.h b/fs/xfs/xfs_log.h index 5caee96059df..fb630e496c12 100644 --- a/fs/xfs/xfs_log.h +++ b/fs/xfs/xfs_log.h | |||
@@ -88,7 +88,8 @@ static inline xfs_lsn_t _lsn_cmp(xfs_lsn_t lsn1, xfs_lsn_t lsn2) | |||
88 | #define XLOG_REG_TYPE_UNMOUNT 17 | 88 | #define XLOG_REG_TYPE_UNMOUNT 17 |
89 | #define XLOG_REG_TYPE_COMMIT 18 | 89 | #define XLOG_REG_TYPE_COMMIT 18 |
90 | #define XLOG_REG_TYPE_TRANSHDR 19 | 90 | #define XLOG_REG_TYPE_TRANSHDR 19 |
91 | #define XLOG_REG_TYPE_MAX 19 | 91 | #define XLOG_REG_TYPE_ICREATE 20 |
92 | #define XLOG_REG_TYPE_MAX 20 | ||
92 | 93 | ||
93 | typedef struct xfs_log_iovec { | 94 | typedef struct xfs_log_iovec { |
94 | void *i_addr; /* beginning address of region */ | 95 | void *i_addr; /* beginning address of region */ |
@@ -105,6 +106,8 @@ struct xfs_log_vec { | |||
105 | int lv_buf_len; /* size of formatted buffer */ | 106 | int lv_buf_len; /* size of formatted buffer */ |
106 | }; | 107 | }; |
107 | 108 | ||
109 | #define XFS_LOG_VEC_ORDERED (-1) | ||
110 | |||
108 | /* | 111 | /* |
109 | * Structure used to pass callback function and the function's argument | 112 | * Structure used to pass callback function and the function's argument |
110 | * to the log manager. | 113 | * to the log manager. |
diff --git a/fs/xfs/xfs_log_cil.c b/fs/xfs/xfs_log_cil.c index d0833b54e55d..02b9cf3f8252 100644 --- a/fs/xfs/xfs_log_cil.c +++ b/fs/xfs/xfs_log_cil.c | |||
@@ -127,6 +127,7 @@ xlog_cil_prepare_log_vecs( | |||
127 | int index; | 127 | int index; |
128 | int len = 0; | 128 | int len = 0; |
129 | uint niovecs; | 129 | uint niovecs; |
130 | bool ordered = false; | ||
130 | 131 | ||
131 | /* Skip items which aren't dirty in this transaction. */ | 132 | /* Skip items which aren't dirty in this transaction. */ |
132 | if (!(lidp->lid_flags & XFS_LID_DIRTY)) | 133 | if (!(lidp->lid_flags & XFS_LID_DIRTY)) |
@@ -137,14 +138,30 @@ xlog_cil_prepare_log_vecs( | |||
137 | if (!niovecs) | 138 | if (!niovecs) |
138 | continue; | 139 | continue; |
139 | 140 | ||
141 | /* | ||
142 | * Ordered items need to be tracked but we do not wish to write | ||
143 | * them. We need a logvec to track the object, but we do not | ||
144 | * need an iovec or buffer to be allocated for copying data. | ||
145 | */ | ||
146 | if (niovecs == XFS_LOG_VEC_ORDERED) { | ||
147 | ordered = true; | ||
148 | niovecs = 0; | ||
149 | } | ||
150 | |||
140 | new_lv = kmem_zalloc(sizeof(*new_lv) + | 151 | new_lv = kmem_zalloc(sizeof(*new_lv) + |
141 | niovecs * sizeof(struct xfs_log_iovec), | 152 | niovecs * sizeof(struct xfs_log_iovec), |
142 | KM_SLEEP|KM_NOFS); | 153 | KM_SLEEP|KM_NOFS); |
143 | 154 | ||
155 | new_lv->lv_item = lidp->lid_item; | ||
156 | new_lv->lv_niovecs = niovecs; | ||
157 | if (ordered) { | ||
158 | /* track as an ordered logvec */ | ||
159 | new_lv->lv_buf_len = XFS_LOG_VEC_ORDERED; | ||
160 | goto next; | ||
161 | } | ||
162 | |||
144 | /* The allocated iovec region lies beyond the log vector. */ | 163 | /* The allocated iovec region lies beyond the log vector. */ |
145 | new_lv->lv_iovecp = (struct xfs_log_iovec *)&new_lv[1]; | 164 | new_lv->lv_iovecp = (struct xfs_log_iovec *)&new_lv[1]; |
146 | new_lv->lv_niovecs = niovecs; | ||
147 | new_lv->lv_item = lidp->lid_item; | ||
148 | 165 | ||
149 | /* build the vector array and calculate it's length */ | 166 | /* build the vector array and calculate it's length */ |
150 | IOP_FORMAT(new_lv->lv_item, new_lv->lv_iovecp); | 167 | IOP_FORMAT(new_lv->lv_item, new_lv->lv_iovecp); |
@@ -165,6 +182,7 @@ xlog_cil_prepare_log_vecs( | |||
165 | } | 182 | } |
166 | ASSERT(ptr == new_lv->lv_buf + new_lv->lv_buf_len); | 183 | ASSERT(ptr == new_lv->lv_buf + new_lv->lv_buf_len); |
167 | 184 | ||
185 | next: | ||
168 | if (!ret_lv) | 186 | if (!ret_lv) |
169 | ret_lv = new_lv; | 187 | ret_lv = new_lv; |
170 | else | 188 | else |
@@ -191,8 +209,18 @@ xfs_cil_prepare_item( | |||
191 | 209 | ||
192 | if (old) { | 210 | if (old) { |
193 | /* existing lv on log item, space used is a delta */ | 211 | /* existing lv on log item, space used is a delta */ |
194 | ASSERT(!list_empty(&lv->lv_item->li_cil)); | 212 | ASSERT((old->lv_buf && old->lv_buf_len && old->lv_niovecs) || |
195 | ASSERT(old->lv_buf && old->lv_buf_len && old->lv_niovecs); | 213 | old->lv_buf_len == XFS_LOG_VEC_ORDERED); |
214 | |||
215 | /* | ||
216 | * If the new item is ordered, keep the old one that is already | ||
217 | * tracking dirty or ordered regions | ||
218 | */ | ||
219 | if (lv->lv_buf_len == XFS_LOG_VEC_ORDERED) { | ||
220 | ASSERT(!lv->lv_buf); | ||
221 | kmem_free(lv); | ||
222 | return; | ||
223 | } | ||
196 | 224 | ||
197 | *len += lv->lv_buf_len - old->lv_buf_len; | 225 | *len += lv->lv_buf_len - old->lv_buf_len; |
198 | *diff_iovecs += lv->lv_niovecs - old->lv_niovecs; | 226 | *diff_iovecs += lv->lv_niovecs - old->lv_niovecs; |
@@ -201,10 +229,11 @@ xfs_cil_prepare_item( | |||
201 | } else { | 229 | } else { |
202 | /* new lv, must pin the log item */ | 230 | /* new lv, must pin the log item */ |
203 | ASSERT(!lv->lv_item->li_lv); | 231 | ASSERT(!lv->lv_item->li_lv); |
204 | ASSERT(list_empty(&lv->lv_item->li_cil)); | ||
205 | 232 | ||
206 | *len += lv->lv_buf_len; | 233 | if (lv->lv_buf_len != XFS_LOG_VEC_ORDERED) { |
207 | *diff_iovecs += lv->lv_niovecs; | 234 | *len += lv->lv_buf_len; |
235 | *diff_iovecs += lv->lv_niovecs; | ||
236 | } | ||
208 | IOP_PIN(lv->lv_item); | 237 | IOP_PIN(lv->lv_item); |
209 | 238 | ||
210 | } | 239 | } |
@@ -259,18 +288,24 @@ xlog_cil_insert_items( | |||
259 | * We can do this safely because the context can't checkpoint until we | 288 | * We can do this safely because the context can't checkpoint until we |
260 | * are done so it doesn't matter exactly how we update the CIL. | 289 | * are done so it doesn't matter exactly how we update the CIL. |
261 | */ | 290 | */ |
262 | for (lv = log_vector; lv; lv = lv->lv_next) | ||
263 | xfs_cil_prepare_item(log, lv, &len, &diff_iovecs); | ||
264 | |||
265 | /* account for space used by new iovec headers */ | ||
266 | len += diff_iovecs * sizeof(xlog_op_header_t); | ||
267 | |||
268 | spin_lock(&cil->xc_cil_lock); | 291 | spin_lock(&cil->xc_cil_lock); |
292 | for (lv = log_vector; lv; ) { | ||
293 | struct xfs_log_vec *next = lv->lv_next; | ||
269 | 294 | ||
270 | /* move the items to the tail of the CIL */ | 295 | ASSERT(lv->lv_item->li_lv || list_empty(&lv->lv_item->li_cil)); |
271 | for (lv = log_vector; lv; lv = lv->lv_next) | 296 | lv->lv_next = NULL; |
297 | |||
298 | /* | ||
299 | * xfs_cil_prepare_item() may free the lv, so move the item on | ||
300 | * the CIL first. | ||
301 | */ | ||
272 | list_move_tail(&lv->lv_item->li_cil, &cil->xc_cil); | 302 | list_move_tail(&lv->lv_item->li_cil, &cil->xc_cil); |
303 | xfs_cil_prepare_item(log, lv, &len, &diff_iovecs); | ||
304 | lv = next; | ||
305 | } | ||
273 | 306 | ||
307 | /* account for space used by new iovec headers */ | ||
308 | len += diff_iovecs * sizeof(xlog_op_header_t); | ||
274 | ctx->nvecs += diff_iovecs; | 309 | ctx->nvecs += diff_iovecs; |
275 | 310 | ||
276 | /* | 311 | /* |
@@ -381,9 +416,7 @@ xlog_cil_push( | |||
381 | struct xfs_cil_ctx *new_ctx; | 416 | struct xfs_cil_ctx *new_ctx; |
382 | struct xlog_in_core *commit_iclog; | 417 | struct xlog_in_core *commit_iclog; |
383 | struct xlog_ticket *tic; | 418 | struct xlog_ticket *tic; |
384 | int num_lv; | ||
385 | int num_iovecs; | 419 | int num_iovecs; |
386 | int len; | ||
387 | int error = 0; | 420 | int error = 0; |
388 | struct xfs_trans_header thdr; | 421 | struct xfs_trans_header thdr; |
389 | struct xfs_log_iovec lhdr; | 422 | struct xfs_log_iovec lhdr; |
@@ -428,12 +461,9 @@ xlog_cil_push( | |||
428 | * side which is currently locked out by the flush lock. | 461 | * side which is currently locked out by the flush lock. |
429 | */ | 462 | */ |
430 | lv = NULL; | 463 | lv = NULL; |
431 | num_lv = 0; | ||
432 | num_iovecs = 0; | 464 | num_iovecs = 0; |
433 | len = 0; | ||
434 | while (!list_empty(&cil->xc_cil)) { | 465 | while (!list_empty(&cil->xc_cil)) { |
435 | struct xfs_log_item *item; | 466 | struct xfs_log_item *item; |
436 | int i; | ||
437 | 467 | ||
438 | item = list_first_entry(&cil->xc_cil, | 468 | item = list_first_entry(&cil->xc_cil, |
439 | struct xfs_log_item, li_cil); | 469 | struct xfs_log_item, li_cil); |
@@ -444,11 +474,7 @@ xlog_cil_push( | |||
444 | lv->lv_next = item->li_lv; | 474 | lv->lv_next = item->li_lv; |
445 | lv = item->li_lv; | 475 | lv = item->li_lv; |
446 | item->li_lv = NULL; | 476 | item->li_lv = NULL; |
447 | |||
448 | num_lv++; | ||
449 | num_iovecs += lv->lv_niovecs; | 477 | num_iovecs += lv->lv_niovecs; |
450 | for (i = 0; i < lv->lv_niovecs; i++) | ||
451 | len += lv->lv_iovecp[i].i_len; | ||
452 | } | 478 | } |
453 | 479 | ||
454 | /* | 480 | /* |
@@ -701,6 +727,7 @@ xfs_log_commit_cil( | |||
701 | if (commit_lsn) | 727 | if (commit_lsn) |
702 | *commit_lsn = log->l_cilp->xc_ctx->sequence; | 728 | *commit_lsn = log->l_cilp->xc_ctx->sequence; |
703 | 729 | ||
730 | /* xlog_cil_insert_items() destroys log_vector list */ | ||
704 | xlog_cil_insert_items(log, log_vector, tp->t_ticket); | 731 | xlog_cil_insert_items(log, log_vector, tp->t_ticket); |
705 | 732 | ||
706 | /* check we didn't blow the reservation */ | 733 | /* check we didn't blow the reservation */ |
diff --git a/fs/xfs/xfs_log_recover.c b/fs/xfs/xfs_log_recover.c index 7cf5e4eafe28..7681b19aa5dc 100644 --- a/fs/xfs/xfs_log_recover.c +++ b/fs/xfs/xfs_log_recover.c | |||
@@ -45,6 +45,7 @@ | |||
45 | #include "xfs_cksum.h" | 45 | #include "xfs_cksum.h" |
46 | #include "xfs_trace.h" | 46 | #include "xfs_trace.h" |
47 | #include "xfs_icache.h" | 47 | #include "xfs_icache.h" |
48 | #include "xfs_icreate_item.h" | ||
48 | 49 | ||
49 | /* Need all the magic numbers and buffer ops structures from these headers */ | 50 | /* Need all the magic numbers and buffer ops structures from these headers */ |
50 | #include "xfs_symlink.h" | 51 | #include "xfs_symlink.h" |
@@ -1617,7 +1618,10 @@ xlog_recover_add_to_trans( | |||
1617 | * form the cancelled buffer table. Hence they have tobe done last. | 1618 | * form the cancelled buffer table. Hence they have tobe done last. |
1618 | * | 1619 | * |
1619 | * 3. Inode allocation buffers must be replayed before inode items that | 1620 | * 3. Inode allocation buffers must be replayed before inode items that |
1620 | * read the buffer and replay changes into it. | 1621 | * read the buffer and replay changes into it. For filesystems using the |
1622 | * ICREATE transactions, this means XFS_LI_ICREATE objects need to get | ||
1623 | * treated the same as inode allocation buffers as they create and | ||
1624 | * initialise the buffers directly. | ||
1621 | * | 1625 | * |
1622 | * 4. Inode unlink buffers must be replayed after inode items are replayed. | 1626 | * 4. Inode unlink buffers must be replayed after inode items are replayed. |
1623 | * This ensures that inodes are completely flushed to the inode buffer | 1627 | * This ensures that inodes are completely flushed to the inode buffer |
@@ -1632,10 +1636,17 @@ xlog_recover_add_to_trans( | |||
1632 | * from all the other buffers and move them to last. | 1636 | * from all the other buffers and move them to last. |
1633 | * | 1637 | * |
1634 | * Hence, 4 lists, in order from head to tail: | 1638 | * Hence, 4 lists, in order from head to tail: |
1635 | * - buffer_list for all buffers except cancelled/inode unlink buffers | 1639 | * - buffer_list for all buffers except cancelled/inode unlink buffers |
1636 | * - item_list for all non-buffer items | 1640 | * - item_list for all non-buffer items |
1637 | * - inode_buffer_list for inode unlink buffers | 1641 | * - inode_buffer_list for inode unlink buffers |
1638 | * - cancel_list for the cancelled buffers | 1642 | * - cancel_list for the cancelled buffers |
1643 | * | ||
1644 | * Note that we add objects to the tail of the lists so that first-to-last | ||
1645 | * ordering is preserved within the lists. Adding objects to the head of the | ||
1646 | * list means when we traverse from the head we walk them in last-to-first | ||
1647 | * order. For cancelled buffers and inode unlink buffers this doesn't matter, | ||
1648 | * but for all other items there may be specific ordering that we need to | ||
1649 | * preserve. | ||
1639 | */ | 1650 | */ |
1640 | STATIC int | 1651 | STATIC int |
1641 | xlog_recover_reorder_trans( | 1652 | xlog_recover_reorder_trans( |
@@ -1655,6 +1666,9 @@ xlog_recover_reorder_trans( | |||
1655 | xfs_buf_log_format_t *buf_f = item->ri_buf[0].i_addr; | 1666 | xfs_buf_log_format_t *buf_f = item->ri_buf[0].i_addr; |
1656 | 1667 | ||
1657 | switch (ITEM_TYPE(item)) { | 1668 | switch (ITEM_TYPE(item)) { |
1669 | case XFS_LI_ICREATE: | ||
1670 | list_move_tail(&item->ri_list, &buffer_list); | ||
1671 | break; | ||
1658 | case XFS_LI_BUF: | 1672 | case XFS_LI_BUF: |
1659 | if (buf_f->blf_flags & XFS_BLF_CANCEL) { | 1673 | if (buf_f->blf_flags & XFS_BLF_CANCEL) { |
1660 | trace_xfs_log_recover_item_reorder_head(log, | 1674 | trace_xfs_log_recover_item_reorder_head(log, |
@@ -2578,8 +2592,16 @@ xlog_recover_inode_pass2( | |||
2578 | goto error; | 2592 | goto error; |
2579 | } | 2593 | } |
2580 | 2594 | ||
2581 | /* Skip replay when the on disk inode is newer than the log one */ | 2595 | /* |
2582 | if (dicp->di_flushiter < be16_to_cpu(dip->di_flushiter)) { | 2596 | * di_flushiter is only valid for v1/2 inodes. All changes for v3 inodes |
2597 | * are transactional and if ordering is necessary we can determine that | ||
2598 | * more accurately by the LSN field in the V3 inode core. Don't trust | ||
2599 | * the inode versions we might be changing them here - use the | ||
2600 | * superblock flag to determine whether we need to look at di_flushiter | ||
2601 | * to skip replay when the on disk inode is newer than the log one | ||
2602 | */ | ||
2603 | if (!xfs_sb_version_hascrc(&mp->m_sb) && | ||
2604 | dicp->di_flushiter < be16_to_cpu(dip->di_flushiter)) { | ||
2583 | /* | 2605 | /* |
2584 | * Deal with the wrap case, DI_MAX_FLUSH is less | 2606 | * Deal with the wrap case, DI_MAX_FLUSH is less |
2585 | * than smaller numbers | 2607 | * than smaller numbers |
@@ -2594,6 +2616,7 @@ xlog_recover_inode_pass2( | |||
2594 | goto error; | 2616 | goto error; |
2595 | } | 2617 | } |
2596 | } | 2618 | } |
2619 | |||
2597 | /* Take the opportunity to reset the flush iteration count */ | 2620 | /* Take the opportunity to reset the flush iteration count */ |
2598 | dicp->di_flushiter = 0; | 2621 | dicp->di_flushiter = 0; |
2599 | 2622 | ||
@@ -2982,6 +3005,93 @@ xlog_recover_efd_pass2( | |||
2982 | } | 3005 | } |
2983 | 3006 | ||
2984 | /* | 3007 | /* |
3008 | * This routine is called when an inode create format structure is found in a | ||
3009 | * committed transaction in the log. It's purpose is to initialise the inodes | ||
3010 | * being allocated on disk. This requires us to get inode cluster buffers that | ||
3011 | * match the range to be intialised, stamped with inode templates and written | ||
3012 | * by delayed write so that subsequent modifications will hit the cached buffer | ||
3013 | * and only need writing out at the end of recovery. | ||
3014 | */ | ||
3015 | STATIC int | ||
3016 | xlog_recover_do_icreate_pass2( | ||
3017 | struct xlog *log, | ||
3018 | struct list_head *buffer_list, | ||
3019 | xlog_recover_item_t *item) | ||
3020 | { | ||
3021 | struct xfs_mount *mp = log->l_mp; | ||
3022 | struct xfs_icreate_log *icl; | ||
3023 | xfs_agnumber_t agno; | ||
3024 | xfs_agblock_t agbno; | ||
3025 | unsigned int count; | ||
3026 | unsigned int isize; | ||
3027 | xfs_agblock_t length; | ||
3028 | |||
3029 | icl = (struct xfs_icreate_log *)item->ri_buf[0].i_addr; | ||
3030 | if (icl->icl_type != XFS_LI_ICREATE) { | ||
3031 | xfs_warn(log->l_mp, "xlog_recover_do_icreate_trans: bad type"); | ||
3032 | return EINVAL; | ||
3033 | } | ||
3034 | |||
3035 | if (icl->icl_size != 1) { | ||
3036 | xfs_warn(log->l_mp, "xlog_recover_do_icreate_trans: bad icl size"); | ||
3037 | return EINVAL; | ||
3038 | } | ||
3039 | |||
3040 | agno = be32_to_cpu(icl->icl_ag); | ||
3041 | if (agno >= mp->m_sb.sb_agcount) { | ||
3042 | xfs_warn(log->l_mp, "xlog_recover_do_icreate_trans: bad agno"); | ||
3043 | return EINVAL; | ||
3044 | } | ||
3045 | agbno = be32_to_cpu(icl->icl_agbno); | ||
3046 | if (!agbno || agbno == NULLAGBLOCK || agbno >= mp->m_sb.sb_agblocks) { | ||
3047 | xfs_warn(log->l_mp, "xlog_recover_do_icreate_trans: bad agbno"); | ||
3048 | return EINVAL; | ||
3049 | } | ||
3050 | isize = be32_to_cpu(icl->icl_isize); | ||
3051 | if (isize != mp->m_sb.sb_inodesize) { | ||
3052 | xfs_warn(log->l_mp, "xlog_recover_do_icreate_trans: bad isize"); | ||
3053 | return EINVAL; | ||
3054 | } | ||
3055 | count = be32_to_cpu(icl->icl_count); | ||
3056 | if (!count) { | ||
3057 | xfs_warn(log->l_mp, "xlog_recover_do_icreate_trans: bad count"); | ||
3058 | return EINVAL; | ||
3059 | } | ||
3060 | length = be32_to_cpu(icl->icl_length); | ||
3061 | if (!length || length >= mp->m_sb.sb_agblocks) { | ||
3062 | xfs_warn(log->l_mp, "xlog_recover_do_icreate_trans: bad length"); | ||
3063 | return EINVAL; | ||
3064 | } | ||
3065 | |||
3066 | /* existing allocation is fixed value */ | ||
3067 | ASSERT(count == XFS_IALLOC_INODES(mp)); | ||
3068 | ASSERT(length == XFS_IALLOC_BLOCKS(mp)); | ||
3069 | if (count != XFS_IALLOC_INODES(mp) || | ||
3070 | length != XFS_IALLOC_BLOCKS(mp)) { | ||
3071 | xfs_warn(log->l_mp, "xlog_recover_do_icreate_trans: bad count 2"); | ||
3072 | return EINVAL; | ||
3073 | } | ||
3074 | |||
3075 | /* | ||
3076 | * Inode buffers can be freed. Do not replay the inode initialisation as | ||
3077 | * we could be overwriting something written after this inode buffer was | ||
3078 | * cancelled. | ||
3079 | * | ||
3080 | * XXX: we need to iterate all buffers and only init those that are not | ||
3081 | * cancelled. I think that a more fine grained factoring of | ||
3082 | * xfs_ialloc_inode_init may be appropriate here to enable this to be | ||
3083 | * done easily. | ||
3084 | */ | ||
3085 | if (xlog_check_buffer_cancelled(log, | ||
3086 | XFS_AGB_TO_DADDR(mp, agno, agbno), length, 0)) | ||
3087 | return 0; | ||
3088 | |||
3089 | xfs_ialloc_inode_init(mp, NULL, buffer_list, agno, agbno, length, | ||
3090 | be32_to_cpu(icl->icl_gen)); | ||
3091 | return 0; | ||
3092 | } | ||
3093 | |||
3094 | /* | ||
2985 | * Free up any resources allocated by the transaction | 3095 | * Free up any resources allocated by the transaction |
2986 | * | 3096 | * |
2987 | * Remember that EFIs, EFDs, and IUNLINKs are handled later. | 3097 | * Remember that EFIs, EFDs, and IUNLINKs are handled later. |
@@ -3023,6 +3133,7 @@ xlog_recover_commit_pass1( | |||
3023 | case XFS_LI_EFI: | 3133 | case XFS_LI_EFI: |
3024 | case XFS_LI_EFD: | 3134 | case XFS_LI_EFD: |
3025 | case XFS_LI_DQUOT: | 3135 | case XFS_LI_DQUOT: |
3136 | case XFS_LI_ICREATE: | ||
3026 | /* nothing to do in pass 1 */ | 3137 | /* nothing to do in pass 1 */ |
3027 | return 0; | 3138 | return 0; |
3028 | default: | 3139 | default: |
@@ -3053,6 +3164,8 @@ xlog_recover_commit_pass2( | |||
3053 | return xlog_recover_efd_pass2(log, item); | 3164 | return xlog_recover_efd_pass2(log, item); |
3054 | case XFS_LI_DQUOT: | 3165 | case XFS_LI_DQUOT: |
3055 | return xlog_recover_dquot_pass2(log, buffer_list, item); | 3166 | return xlog_recover_dquot_pass2(log, buffer_list, item); |
3167 | case XFS_LI_ICREATE: | ||
3168 | return xlog_recover_do_icreate_pass2(log, buffer_list, item); | ||
3056 | case XFS_LI_QUOTAOFF: | 3169 | case XFS_LI_QUOTAOFF: |
3057 | /* nothing to do in pass2 */ | 3170 | /* nothing to do in pass2 */ |
3058 | return 0; | 3171 | return 0; |
diff --git a/fs/xfs/xfs_mount.c b/fs/xfs/xfs_mount.c index e8e310c05097..2b0ba3581656 100644 --- a/fs/xfs/xfs_mount.c +++ b/fs/xfs/xfs_mount.c | |||
@@ -336,6 +336,14 @@ xfs_mount_validate_sb( | |||
336 | return XFS_ERROR(EWRONGFS); | 336 | return XFS_ERROR(EWRONGFS); |
337 | } | 337 | } |
338 | 338 | ||
339 | if ((sbp->sb_qflags & (XFS_OQUOTA_ENFD | XFS_OQUOTA_CHKD)) && | ||
340 | (sbp->sb_qflags & (XFS_PQUOTA_ENFD | XFS_GQUOTA_ENFD | | ||
341 | XFS_PQUOTA_CHKD | XFS_GQUOTA_CHKD))) { | ||
342 | xfs_notice(mp, | ||
343 | "Super block has XFS_OQUOTA bits along with XFS_PQUOTA and/or XFS_GQUOTA bits.\n"); | ||
344 | return XFS_ERROR(EFSCORRUPTED); | ||
345 | } | ||
346 | |||
339 | /* | 347 | /* |
340 | * Version 5 superblock feature mask validation. Reject combinations the | 348 | * Version 5 superblock feature mask validation. Reject combinations the |
341 | * kernel cannot support up front before checking anything else. For | 349 | * kernel cannot support up front before checking anything else. For |
@@ -561,6 +569,18 @@ out_unwind: | |||
561 | return error; | 569 | return error; |
562 | } | 570 | } |
563 | 571 | ||
572 | static void | ||
573 | xfs_sb_quota_from_disk(struct xfs_sb *sbp) | ||
574 | { | ||
575 | if (sbp->sb_qflags & XFS_OQUOTA_ENFD) | ||
576 | sbp->sb_qflags |= (sbp->sb_qflags & XFS_PQUOTA_ACCT) ? | ||
577 | XFS_PQUOTA_ENFD : XFS_GQUOTA_ENFD; | ||
578 | if (sbp->sb_qflags & XFS_OQUOTA_CHKD) | ||
579 | sbp->sb_qflags |= (sbp->sb_qflags & XFS_PQUOTA_ACCT) ? | ||
580 | XFS_PQUOTA_CHKD : XFS_GQUOTA_CHKD; | ||
581 | sbp->sb_qflags &= ~(XFS_OQUOTA_ENFD | XFS_OQUOTA_CHKD); | ||
582 | } | ||
583 | |||
564 | void | 584 | void |
565 | xfs_sb_from_disk( | 585 | xfs_sb_from_disk( |
566 | struct xfs_sb *to, | 586 | struct xfs_sb *to, |
@@ -622,6 +642,35 @@ xfs_sb_from_disk( | |||
622 | to->sb_lsn = be64_to_cpu(from->sb_lsn); | 642 | to->sb_lsn = be64_to_cpu(from->sb_lsn); |
623 | } | 643 | } |
624 | 644 | ||
645 | static inline void | ||
646 | xfs_sb_quota_to_disk( | ||
647 | xfs_dsb_t *to, | ||
648 | xfs_sb_t *from, | ||
649 | __int64_t *fields) | ||
650 | { | ||
651 | __uint16_t qflags = from->sb_qflags; | ||
652 | |||
653 | if (*fields & XFS_SB_QFLAGS) { | ||
654 | /* | ||
655 | * The in-core version of sb_qflags do not have | ||
656 | * XFS_OQUOTA_* flags, whereas the on-disk version | ||
657 | * does. So, convert incore XFS_{PG}QUOTA_* flags | ||
658 | * to on-disk XFS_OQUOTA_* flags. | ||
659 | */ | ||
660 | qflags &= ~(XFS_PQUOTA_ENFD | XFS_PQUOTA_CHKD | | ||
661 | XFS_GQUOTA_ENFD | XFS_GQUOTA_CHKD); | ||
662 | |||
663 | if (from->sb_qflags & | ||
664 | (XFS_PQUOTA_ENFD | XFS_GQUOTA_ENFD)) | ||
665 | qflags |= XFS_OQUOTA_ENFD; | ||
666 | if (from->sb_qflags & | ||
667 | (XFS_PQUOTA_CHKD | XFS_GQUOTA_CHKD)) | ||
668 | qflags |= XFS_OQUOTA_CHKD; | ||
669 | to->sb_qflags = cpu_to_be16(qflags); | ||
670 | *fields &= ~XFS_SB_QFLAGS; | ||
671 | } | ||
672 | } | ||
673 | |||
625 | /* | 674 | /* |
626 | * Copy in core superblock to ondisk one. | 675 | * Copy in core superblock to ondisk one. |
627 | * | 676 | * |
@@ -643,6 +692,7 @@ xfs_sb_to_disk( | |||
643 | if (!fields) | 692 | if (!fields) |
644 | return; | 693 | return; |
645 | 694 | ||
695 | xfs_sb_quota_to_disk(to, from, &fields); | ||
646 | while (fields) { | 696 | while (fields) { |
647 | f = (xfs_sb_field_t)xfs_lowbit64((__uint64_t)fields); | 697 | f = (xfs_sb_field_t)xfs_lowbit64((__uint64_t)fields); |
648 | first = xfs_sb_info[f].offset; | 698 | first = xfs_sb_info[f].offset; |
@@ -835,6 +885,7 @@ reread: | |||
835 | */ | 885 | */ |
836 | xfs_sb_from_disk(&mp->m_sb, XFS_BUF_TO_SBP(bp)); | 886 | xfs_sb_from_disk(&mp->m_sb, XFS_BUF_TO_SBP(bp)); |
837 | 887 | ||
888 | xfs_sb_quota_from_disk(&mp->m_sb); | ||
838 | /* | 889 | /* |
839 | * We must be able to do sector-sized and sector-aligned IO. | 890 | * We must be able to do sector-sized and sector-aligned IO. |
840 | */ | 891 | */ |
@@ -987,42 +1038,27 @@ xfs_update_alignment(xfs_mount_t *mp) | |||
987 | */ | 1038 | */ |
988 | if ((BBTOB(mp->m_dalign) & mp->m_blockmask) || | 1039 | if ((BBTOB(mp->m_dalign) & mp->m_blockmask) || |
989 | (BBTOB(mp->m_swidth) & mp->m_blockmask)) { | 1040 | (BBTOB(mp->m_swidth) & mp->m_blockmask)) { |
990 | if (mp->m_flags & XFS_MOUNT_RETERR) { | 1041 | xfs_warn(mp, |
991 | xfs_warn(mp, "alignment check failed: " | 1042 | "alignment check failed: sunit/swidth vs. blocksize(%d)", |
992 | "(sunit/swidth vs. blocksize)"); | 1043 | sbp->sb_blocksize); |
993 | return XFS_ERROR(EINVAL); | 1044 | return XFS_ERROR(EINVAL); |
994 | } | ||
995 | mp->m_dalign = mp->m_swidth = 0; | ||
996 | } else { | 1045 | } else { |
997 | /* | 1046 | /* |
998 | * Convert the stripe unit and width to FSBs. | 1047 | * Convert the stripe unit and width to FSBs. |
999 | */ | 1048 | */ |
1000 | mp->m_dalign = XFS_BB_TO_FSBT(mp, mp->m_dalign); | 1049 | mp->m_dalign = XFS_BB_TO_FSBT(mp, mp->m_dalign); |
1001 | if (mp->m_dalign && (sbp->sb_agblocks % mp->m_dalign)) { | 1050 | if (mp->m_dalign && (sbp->sb_agblocks % mp->m_dalign)) { |
1002 | if (mp->m_flags & XFS_MOUNT_RETERR) { | ||
1003 | xfs_warn(mp, "alignment check failed: " | ||
1004 | "(sunit/swidth vs. ag size)"); | ||
1005 | return XFS_ERROR(EINVAL); | ||
1006 | } | ||
1007 | xfs_warn(mp, | 1051 | xfs_warn(mp, |
1008 | "stripe alignment turned off: sunit(%d)/swidth(%d) " | 1052 | "alignment check failed: sunit/swidth vs. agsize(%d)", |
1009 | "incompatible with agsize(%d)", | 1053 | sbp->sb_agblocks); |
1010 | mp->m_dalign, mp->m_swidth, | 1054 | return XFS_ERROR(EINVAL); |
1011 | sbp->sb_agblocks); | ||
1012 | |||
1013 | mp->m_dalign = 0; | ||
1014 | mp->m_swidth = 0; | ||
1015 | } else if (mp->m_dalign) { | 1055 | } else if (mp->m_dalign) { |
1016 | mp->m_swidth = XFS_BB_TO_FSBT(mp, mp->m_swidth); | 1056 | mp->m_swidth = XFS_BB_TO_FSBT(mp, mp->m_swidth); |
1017 | } else { | 1057 | } else { |
1018 | if (mp->m_flags & XFS_MOUNT_RETERR) { | 1058 | xfs_warn(mp, |
1019 | xfs_warn(mp, "alignment check failed: " | 1059 | "alignment check failed: sunit(%d) less than bsize(%d)", |
1020 | "sunit(%d) less than bsize(%d)", | 1060 | mp->m_dalign, sbp->sb_blocksize); |
1021 | mp->m_dalign, | 1061 | return XFS_ERROR(EINVAL); |
1022 | mp->m_blockmask +1); | ||
1023 | return XFS_ERROR(EINVAL); | ||
1024 | } | ||
1025 | mp->m_swidth = 0; | ||
1026 | } | 1062 | } |
1027 | } | 1063 | } |
1028 | 1064 | ||
@@ -1039,6 +1075,10 @@ xfs_update_alignment(xfs_mount_t *mp) | |||
1039 | sbp->sb_width = mp->m_swidth; | 1075 | sbp->sb_width = mp->m_swidth; |
1040 | mp->m_update_flags |= XFS_SB_WIDTH; | 1076 | mp->m_update_flags |= XFS_SB_WIDTH; |
1041 | } | 1077 | } |
1078 | } else { | ||
1079 | xfs_warn(mp, | ||
1080 | "cannot change alignment: superblock does not support data alignment"); | ||
1081 | return XFS_ERROR(EINVAL); | ||
1042 | } | 1082 | } |
1043 | } else if ((mp->m_flags & XFS_MOUNT_NOALIGN) != XFS_MOUNT_NOALIGN && | 1083 | } else if ((mp->m_flags & XFS_MOUNT_NOALIGN) != XFS_MOUNT_NOALIGN && |
1044 | xfs_sb_version_hasdalign(&mp->m_sb)) { | 1084 | xfs_sb_version_hasdalign(&mp->m_sb)) { |
diff --git a/fs/xfs/xfs_mount.h b/fs/xfs/xfs_mount.h index b004cecdfb04..4e374d4a9189 100644 --- a/fs/xfs/xfs_mount.h +++ b/fs/xfs/xfs_mount.h | |||
@@ -192,8 +192,6 @@ typedef struct xfs_mount { | |||
192 | xfs_dablk_t m_dirleafblk; /* blockno of dir non-data v2 */ | 192 | xfs_dablk_t m_dirleafblk; /* blockno of dir non-data v2 */ |
193 | xfs_dablk_t m_dirfreeblk; /* blockno of dirfreeindex v2 */ | 193 | xfs_dablk_t m_dirfreeblk; /* blockno of dirfreeindex v2 */ |
194 | uint m_chsize; /* size of next field */ | 194 | uint m_chsize; /* size of next field */ |
195 | struct xfs_chash *m_chash; /* fs private inode per-cluster | ||
196 | * hash table */ | ||
197 | atomic_t m_active_trans; /* number trans frozen */ | 195 | atomic_t m_active_trans; /* number trans frozen */ |
198 | #ifdef HAVE_PERCPU_SB | 196 | #ifdef HAVE_PERCPU_SB |
199 | xfs_icsb_cnts_t __percpu *m_sb_cnts; /* per-cpu superblock counters */ | 197 | xfs_icsb_cnts_t __percpu *m_sb_cnts; /* per-cpu superblock counters */ |
@@ -229,8 +227,6 @@ typedef struct xfs_mount { | |||
229 | operations, typically for | 227 | operations, typically for |
230 | disk errors in metadata */ | 228 | disk errors in metadata */ |
231 | #define XFS_MOUNT_DISCARD (1ULL << 5) /* discard unused blocks */ | 229 | #define XFS_MOUNT_DISCARD (1ULL << 5) /* discard unused blocks */ |
232 | #define XFS_MOUNT_RETERR (1ULL << 6) /* return alignment errors to | ||
233 | user */ | ||
234 | #define XFS_MOUNT_NOALIGN (1ULL << 7) /* turn off stripe alignment | 230 | #define XFS_MOUNT_NOALIGN (1ULL << 7) /* turn off stripe alignment |
235 | allocations */ | 231 | allocations */ |
236 | #define XFS_MOUNT_ATTR2 (1ULL << 8) /* allow use of attr2 format */ | 232 | #define XFS_MOUNT_ATTR2 (1ULL << 8) /* allow use of attr2 format */ |
diff --git a/fs/xfs/xfs_qm.c b/fs/xfs/xfs_qm.c index b75c9bb6e71e..d320794d03ce 100644 --- a/fs/xfs/xfs_qm.c +++ b/fs/xfs/xfs_qm.c | |||
@@ -70,7 +70,7 @@ xfs_qm_dquot_walk( | |||
70 | void *data) | 70 | void *data) |
71 | { | 71 | { |
72 | struct xfs_quotainfo *qi = mp->m_quotainfo; | 72 | struct xfs_quotainfo *qi = mp->m_quotainfo; |
73 | struct radix_tree_root *tree = XFS_DQUOT_TREE(qi, type); | 73 | struct radix_tree_root *tree = xfs_dquot_tree(qi, type); |
74 | uint32_t next_index; | 74 | uint32_t next_index; |
75 | int last_error = 0; | 75 | int last_error = 0; |
76 | int skipped; | 76 | int skipped; |
@@ -137,6 +137,7 @@ xfs_qm_dqpurge( | |||
137 | struct xfs_mount *mp = dqp->q_mount; | 137 | struct xfs_mount *mp = dqp->q_mount; |
138 | struct xfs_quotainfo *qi = mp->m_quotainfo; | 138 | struct xfs_quotainfo *qi = mp->m_quotainfo; |
139 | struct xfs_dquot *gdqp = NULL; | 139 | struct xfs_dquot *gdqp = NULL; |
140 | struct xfs_dquot *pdqp = NULL; | ||
140 | 141 | ||
141 | xfs_dqlock(dqp); | 142 | xfs_dqlock(dqp); |
142 | if ((dqp->dq_flags & XFS_DQ_FREEING) || dqp->q_nrefs != 0) { | 143 | if ((dqp->dq_flags & XFS_DQ_FREEING) || dqp->q_nrefs != 0) { |
@@ -145,8 +146,7 @@ xfs_qm_dqpurge( | |||
145 | } | 146 | } |
146 | 147 | ||
147 | /* | 148 | /* |
148 | * If this quota has a group hint attached, prepare for releasing it | 149 | * If this quota has a hint attached, prepare for releasing it now. |
149 | * now. | ||
150 | */ | 150 | */ |
151 | gdqp = dqp->q_gdquot; | 151 | gdqp = dqp->q_gdquot; |
152 | if (gdqp) { | 152 | if (gdqp) { |
@@ -154,6 +154,12 @@ xfs_qm_dqpurge( | |||
154 | dqp->q_gdquot = NULL; | 154 | dqp->q_gdquot = NULL; |
155 | } | 155 | } |
156 | 156 | ||
157 | pdqp = dqp->q_pdquot; | ||
158 | if (pdqp) { | ||
159 | xfs_dqlock(pdqp); | ||
160 | dqp->q_pdquot = NULL; | ||
161 | } | ||
162 | |||
157 | dqp->dq_flags |= XFS_DQ_FREEING; | 163 | dqp->dq_flags |= XFS_DQ_FREEING; |
158 | 164 | ||
159 | xfs_dqflock(dqp); | 165 | xfs_dqflock(dqp); |
@@ -189,7 +195,7 @@ xfs_qm_dqpurge( | |||
189 | xfs_dqfunlock(dqp); | 195 | xfs_dqfunlock(dqp); |
190 | xfs_dqunlock(dqp); | 196 | xfs_dqunlock(dqp); |
191 | 197 | ||
192 | radix_tree_delete(XFS_DQUOT_TREE(qi, dqp->q_core.d_flags), | 198 | radix_tree_delete(xfs_dquot_tree(qi, dqp->q_core.d_flags), |
193 | be32_to_cpu(dqp->q_core.d_id)); | 199 | be32_to_cpu(dqp->q_core.d_id)); |
194 | qi->qi_dquots--; | 200 | qi->qi_dquots--; |
195 | 201 | ||
@@ -208,6 +214,8 @@ xfs_qm_dqpurge( | |||
208 | 214 | ||
209 | if (gdqp) | 215 | if (gdqp) |
210 | xfs_qm_dqput(gdqp); | 216 | xfs_qm_dqput(gdqp); |
217 | if (pdqp) | ||
218 | xfs_qm_dqput(pdqp); | ||
211 | return 0; | 219 | return 0; |
212 | } | 220 | } |
213 | 221 | ||
@@ -299,8 +307,10 @@ xfs_qm_mount_quotas( | |||
299 | */ | 307 | */ |
300 | if (!XFS_IS_UQUOTA_ON(mp)) | 308 | if (!XFS_IS_UQUOTA_ON(mp)) |
301 | mp->m_qflags &= ~XFS_UQUOTA_CHKD; | 309 | mp->m_qflags &= ~XFS_UQUOTA_CHKD; |
302 | if (!(XFS_IS_GQUOTA_ON(mp) || XFS_IS_PQUOTA_ON(mp))) | 310 | if (!XFS_IS_GQUOTA_ON(mp)) |
303 | mp->m_qflags &= ~XFS_OQUOTA_CHKD; | 311 | mp->m_qflags &= ~XFS_GQUOTA_CHKD; |
312 | if (!XFS_IS_PQUOTA_ON(mp)) | ||
313 | mp->m_qflags &= ~XFS_PQUOTA_CHKD; | ||
304 | 314 | ||
305 | write_changes: | 315 | write_changes: |
306 | /* | 316 | /* |
@@ -362,6 +372,10 @@ xfs_qm_unmount_quotas( | |||
362 | IRELE(mp->m_quotainfo->qi_gquotaip); | 372 | IRELE(mp->m_quotainfo->qi_gquotaip); |
363 | mp->m_quotainfo->qi_gquotaip = NULL; | 373 | mp->m_quotainfo->qi_gquotaip = NULL; |
364 | } | 374 | } |
375 | if (mp->m_quotainfo->qi_pquotaip) { | ||
376 | IRELE(mp->m_quotainfo->qi_pquotaip); | ||
377 | mp->m_quotainfo->qi_pquotaip = NULL; | ||
378 | } | ||
365 | } | 379 | } |
366 | } | 380 | } |
367 | 381 | ||
@@ -408,7 +422,10 @@ xfs_qm_dqattach_one( | |||
408 | * be reclaimed as long as we have a ref from inode and we | 422 | * be reclaimed as long as we have a ref from inode and we |
409 | * hold the ilock. | 423 | * hold the ilock. |
410 | */ | 424 | */ |
411 | dqp = udqhint->q_gdquot; | 425 | if (type == XFS_DQ_GROUP) |
426 | dqp = udqhint->q_gdquot; | ||
427 | else | ||
428 | dqp = udqhint->q_pdquot; | ||
412 | if (dqp && be32_to_cpu(dqp->q_core.d_id) == id) { | 429 | if (dqp && be32_to_cpu(dqp->q_core.d_id) == id) { |
413 | ASSERT(*IO_idqpp == NULL); | 430 | ASSERT(*IO_idqpp == NULL); |
414 | 431 | ||
@@ -451,28 +468,42 @@ xfs_qm_dqattach_one( | |||
451 | 468 | ||
452 | 469 | ||
453 | /* | 470 | /* |
454 | * Given a udquot and gdquot, attach a ptr to the group dquot in the | 471 | * Given a udquot and group/project type, attach the group/project |
455 | * udquot as a hint for future lookups. | 472 | * dquot pointer to the udquot as a hint for future lookups. |
456 | */ | 473 | */ |
457 | STATIC void | 474 | STATIC void |
458 | xfs_qm_dqattach_grouphint( | 475 | xfs_qm_dqattach_hint( |
459 | xfs_dquot_t *udq, | 476 | struct xfs_inode *ip, |
460 | xfs_dquot_t *gdq) | 477 | int type) |
461 | { | 478 | { |
462 | xfs_dquot_t *tmp; | 479 | struct xfs_dquot **dqhintp; |
480 | struct xfs_dquot *dqp; | ||
481 | struct xfs_dquot *udq = ip->i_udquot; | ||
482 | |||
483 | ASSERT(type == XFS_DQ_GROUP || type == XFS_DQ_PROJ); | ||
463 | 484 | ||
464 | xfs_dqlock(udq); | 485 | xfs_dqlock(udq); |
465 | 486 | ||
466 | tmp = udq->q_gdquot; | 487 | if (type == XFS_DQ_GROUP) { |
467 | if (tmp) { | 488 | dqp = ip->i_gdquot; |
468 | if (tmp == gdq) | 489 | dqhintp = &udq->q_gdquot; |
490 | } else { | ||
491 | dqp = ip->i_pdquot; | ||
492 | dqhintp = &udq->q_pdquot; | ||
493 | } | ||
494 | |||
495 | if (*dqhintp) { | ||
496 | struct xfs_dquot *tmp; | ||
497 | |||
498 | if (*dqhintp == dqp) | ||
469 | goto done; | 499 | goto done; |
470 | 500 | ||
471 | udq->q_gdquot = NULL; | 501 | tmp = *dqhintp; |
502 | *dqhintp = NULL; | ||
472 | xfs_qm_dqrele(tmp); | 503 | xfs_qm_dqrele(tmp); |
473 | } | 504 | } |
474 | 505 | ||
475 | udq->q_gdquot = xfs_qm_dqhold(gdq); | 506 | *dqhintp = xfs_qm_dqhold(dqp); |
476 | done: | 507 | done: |
477 | xfs_dqunlock(udq); | 508 | xfs_dqunlock(udq); |
478 | } | 509 | } |
@@ -489,8 +520,7 @@ xfs_qm_need_dqattach( | |||
489 | return false; | 520 | return false; |
490 | if (!XFS_NOT_DQATTACHED(mp, ip)) | 521 | if (!XFS_NOT_DQATTACHED(mp, ip)) |
491 | return false; | 522 | return false; |
492 | if (ip->i_ino == mp->m_sb.sb_uquotino || | 523 | if (xfs_is_quota_inode(&mp->m_sb, ip->i_ino)) |
493 | ip->i_ino == mp->m_sb.sb_gquotino) | ||
494 | return false; | 524 | return false; |
495 | return true; | 525 | return true; |
496 | } | 526 | } |
@@ -526,12 +556,8 @@ xfs_qm_dqattach_locked( | |||
526 | } | 556 | } |
527 | 557 | ||
528 | ASSERT(xfs_isilocked(ip, XFS_ILOCK_EXCL)); | 558 | ASSERT(xfs_isilocked(ip, XFS_ILOCK_EXCL)); |
529 | if (XFS_IS_OQUOTA_ON(mp)) { | 559 | if (XFS_IS_GQUOTA_ON(mp)) { |
530 | error = XFS_IS_GQUOTA_ON(mp) ? | 560 | error = xfs_qm_dqattach_one(ip, ip->i_d.di_gid, XFS_DQ_GROUP, |
531 | xfs_qm_dqattach_one(ip, ip->i_d.di_gid, XFS_DQ_GROUP, | ||
532 | flags & XFS_QMOPT_DQALLOC, | ||
533 | ip->i_udquot, &ip->i_gdquot) : | ||
534 | xfs_qm_dqattach_one(ip, xfs_get_projid(ip), XFS_DQ_PROJ, | ||
535 | flags & XFS_QMOPT_DQALLOC, | 561 | flags & XFS_QMOPT_DQALLOC, |
536 | ip->i_udquot, &ip->i_gdquot); | 562 | ip->i_udquot, &ip->i_gdquot); |
537 | /* | 563 | /* |
@@ -543,14 +569,28 @@ xfs_qm_dqattach_locked( | |||
543 | nquotas++; | 569 | nquotas++; |
544 | } | 570 | } |
545 | 571 | ||
572 | ASSERT(xfs_isilocked(ip, XFS_ILOCK_EXCL)); | ||
573 | if (XFS_IS_PQUOTA_ON(mp)) { | ||
574 | error = xfs_qm_dqattach_one(ip, xfs_get_projid(ip), XFS_DQ_PROJ, | ||
575 | flags & XFS_QMOPT_DQALLOC, | ||
576 | ip->i_udquot, &ip->i_pdquot); | ||
577 | /* | ||
578 | * Don't worry about the udquot that we may have | ||
579 | * attached above. It'll get detached, if not already. | ||
580 | */ | ||
581 | if (error) | ||
582 | goto done; | ||
583 | nquotas++; | ||
584 | } | ||
585 | |||
546 | /* | 586 | /* |
547 | * Attach this group quota to the user quota as a hint. | 587 | * Attach this group/project quota to the user quota as a hint. |
548 | * This WON'T, in general, result in a thrash. | 588 | * This WON'T, in general, result in a thrash. |
549 | */ | 589 | */ |
550 | if (nquotas == 2) { | 590 | if (nquotas > 1 && ip->i_udquot) { |
551 | ASSERT(xfs_isilocked(ip, XFS_ILOCK_EXCL)); | 591 | ASSERT(xfs_isilocked(ip, XFS_ILOCK_EXCL)); |
552 | ASSERT(ip->i_udquot); | 592 | ASSERT(ip->i_gdquot || !XFS_IS_GQUOTA_ON(mp)); |
553 | ASSERT(ip->i_gdquot); | 593 | ASSERT(ip->i_pdquot || !XFS_IS_PQUOTA_ON(mp)); |
554 | 594 | ||
555 | /* | 595 | /* |
556 | * We do not have i_udquot locked at this point, but this check | 596 | * We do not have i_udquot locked at this point, but this check |
@@ -559,7 +599,10 @@ xfs_qm_dqattach_locked( | |||
559 | * succeed in general. | 599 | * succeed in general. |
560 | */ | 600 | */ |
561 | if (ip->i_udquot->q_gdquot != ip->i_gdquot) | 601 | if (ip->i_udquot->q_gdquot != ip->i_gdquot) |
562 | xfs_qm_dqattach_grouphint(ip->i_udquot, ip->i_gdquot); | 602 | xfs_qm_dqattach_hint(ip, XFS_DQ_GROUP); |
603 | |||
604 | if (ip->i_udquot->q_pdquot != ip->i_pdquot) | ||
605 | xfs_qm_dqattach_hint(ip, XFS_DQ_PROJ); | ||
563 | } | 606 | } |
564 | 607 | ||
565 | done: | 608 | done: |
@@ -567,8 +610,10 @@ xfs_qm_dqattach_locked( | |||
567 | if (!error) { | 610 | if (!error) { |
568 | if (XFS_IS_UQUOTA_ON(mp)) | 611 | if (XFS_IS_UQUOTA_ON(mp)) |
569 | ASSERT(ip->i_udquot); | 612 | ASSERT(ip->i_udquot); |
570 | if (XFS_IS_OQUOTA_ON(mp)) | 613 | if (XFS_IS_GQUOTA_ON(mp)) |
571 | ASSERT(ip->i_gdquot); | 614 | ASSERT(ip->i_gdquot); |
615 | if (XFS_IS_PQUOTA_ON(mp)) | ||
616 | ASSERT(ip->i_pdquot); | ||
572 | } | 617 | } |
573 | ASSERT(xfs_isilocked(ip, XFS_ILOCK_EXCL)); | 618 | ASSERT(xfs_isilocked(ip, XFS_ILOCK_EXCL)); |
574 | #endif | 619 | #endif |
@@ -601,13 +646,12 @@ void | |||
601 | xfs_qm_dqdetach( | 646 | xfs_qm_dqdetach( |
602 | xfs_inode_t *ip) | 647 | xfs_inode_t *ip) |
603 | { | 648 | { |
604 | if (!(ip->i_udquot || ip->i_gdquot)) | 649 | if (!(ip->i_udquot || ip->i_gdquot || ip->i_pdquot)) |
605 | return; | 650 | return; |
606 | 651 | ||
607 | trace_xfs_dquot_dqdetach(ip); | 652 | trace_xfs_dquot_dqdetach(ip); |
608 | 653 | ||
609 | ASSERT(ip->i_ino != ip->i_mount->m_sb.sb_uquotino); | 654 | ASSERT(!xfs_is_quota_inode(&ip->i_mount->m_sb, ip->i_ino)); |
610 | ASSERT(ip->i_ino != ip->i_mount->m_sb.sb_gquotino); | ||
611 | if (ip->i_udquot) { | 655 | if (ip->i_udquot) { |
612 | xfs_qm_dqrele(ip->i_udquot); | 656 | xfs_qm_dqrele(ip->i_udquot); |
613 | ip->i_udquot = NULL; | 657 | ip->i_udquot = NULL; |
@@ -616,6 +660,10 @@ xfs_qm_dqdetach( | |||
616 | xfs_qm_dqrele(ip->i_gdquot); | 660 | xfs_qm_dqrele(ip->i_gdquot); |
617 | ip->i_gdquot = NULL; | 661 | ip->i_gdquot = NULL; |
618 | } | 662 | } |
663 | if (ip->i_pdquot) { | ||
664 | xfs_qm_dqrele(ip->i_pdquot); | ||
665 | ip->i_pdquot = NULL; | ||
666 | } | ||
619 | } | 667 | } |
620 | 668 | ||
621 | int | 669 | int |
@@ -660,6 +708,7 @@ xfs_qm_init_quotainfo( | |||
660 | 708 | ||
661 | INIT_RADIX_TREE(&qinf->qi_uquota_tree, GFP_NOFS); | 709 | INIT_RADIX_TREE(&qinf->qi_uquota_tree, GFP_NOFS); |
662 | INIT_RADIX_TREE(&qinf->qi_gquota_tree, GFP_NOFS); | 710 | INIT_RADIX_TREE(&qinf->qi_gquota_tree, GFP_NOFS); |
711 | INIT_RADIX_TREE(&qinf->qi_pquota_tree, GFP_NOFS); | ||
663 | mutex_init(&qinf->qi_tree_lock); | 712 | mutex_init(&qinf->qi_tree_lock); |
664 | 713 | ||
665 | INIT_LIST_HEAD(&qinf->qi_lru_list); | 714 | INIT_LIST_HEAD(&qinf->qi_lru_list); |
@@ -761,6 +810,10 @@ xfs_qm_destroy_quotainfo( | |||
761 | IRELE(qi->qi_gquotaip); | 810 | IRELE(qi->qi_gquotaip); |
762 | qi->qi_gquotaip = NULL; | 811 | qi->qi_gquotaip = NULL; |
763 | } | 812 | } |
813 | if (qi->qi_pquotaip) { | ||
814 | IRELE(qi->qi_pquotaip); | ||
815 | qi->qi_pquotaip = NULL; | ||
816 | } | ||
764 | mutex_destroy(&qi->qi_quotaofflock); | 817 | mutex_destroy(&qi->qi_quotaofflock); |
765 | kmem_free(qi); | 818 | kmem_free(qi); |
766 | mp->m_quotainfo = NULL; | 819 | mp->m_quotainfo = NULL; |
@@ -1152,7 +1205,7 @@ xfs_qm_dqusage_adjust( | |||
1152 | * rootino must have its resources accounted for, not so with the quota | 1205 | * rootino must have its resources accounted for, not so with the quota |
1153 | * inodes. | 1206 | * inodes. |
1154 | */ | 1207 | */ |
1155 | if (ino == mp->m_sb.sb_uquotino || ino == mp->m_sb.sb_gquotino) { | 1208 | if (xfs_is_quota_inode(&mp->m_sb, ino)) { |
1156 | *res = BULKSTAT_RV_NOTHING; | 1209 | *res = BULKSTAT_RV_NOTHING; |
1157 | return XFS_ERROR(EINVAL); | 1210 | return XFS_ERROR(EINVAL); |
1158 | } | 1211 | } |
@@ -1262,19 +1315,21 @@ int | |||
1262 | xfs_qm_quotacheck( | 1315 | xfs_qm_quotacheck( |
1263 | xfs_mount_t *mp) | 1316 | xfs_mount_t *mp) |
1264 | { | 1317 | { |
1265 | int done, count, error, error2; | 1318 | int done, count, error, error2; |
1266 | xfs_ino_t lastino; | 1319 | xfs_ino_t lastino; |
1267 | size_t structsz; | 1320 | size_t structsz; |
1268 | xfs_inode_t *uip, *gip; | 1321 | uint flags; |
1269 | uint flags; | 1322 | LIST_HEAD (buffer_list); |
1270 | LIST_HEAD (buffer_list); | 1323 | struct xfs_inode *uip = mp->m_quotainfo->qi_uquotaip; |
1324 | struct xfs_inode *gip = mp->m_quotainfo->qi_gquotaip; | ||
1325 | struct xfs_inode *pip = mp->m_quotainfo->qi_pquotaip; | ||
1271 | 1326 | ||
1272 | count = INT_MAX; | 1327 | count = INT_MAX; |
1273 | structsz = 1; | 1328 | structsz = 1; |
1274 | lastino = 0; | 1329 | lastino = 0; |
1275 | flags = 0; | 1330 | flags = 0; |
1276 | 1331 | ||
1277 | ASSERT(mp->m_quotainfo->qi_uquotaip || mp->m_quotainfo->qi_gquotaip); | 1332 | ASSERT(uip || gip || pip); |
1278 | ASSERT(XFS_IS_QUOTA_RUNNING(mp)); | 1333 | ASSERT(XFS_IS_QUOTA_RUNNING(mp)); |
1279 | 1334 | ||
1280 | xfs_notice(mp, "Quotacheck needed: Please wait."); | 1335 | xfs_notice(mp, "Quotacheck needed: Please wait."); |
@@ -1284,7 +1339,6 @@ xfs_qm_quotacheck( | |||
1284 | * their counters to zero. We need a clean slate. | 1339 | * their counters to zero. We need a clean slate. |
1285 | * We don't log our changes till later. | 1340 | * We don't log our changes till later. |
1286 | */ | 1341 | */ |
1287 | uip = mp->m_quotainfo->qi_uquotaip; | ||
1288 | if (uip) { | 1342 | if (uip) { |
1289 | error = xfs_qm_dqiterate(mp, uip, XFS_QMOPT_UQUOTA, | 1343 | error = xfs_qm_dqiterate(mp, uip, XFS_QMOPT_UQUOTA, |
1290 | &buffer_list); | 1344 | &buffer_list); |
@@ -1293,14 +1347,20 @@ xfs_qm_quotacheck( | |||
1293 | flags |= XFS_UQUOTA_CHKD; | 1347 | flags |= XFS_UQUOTA_CHKD; |
1294 | } | 1348 | } |
1295 | 1349 | ||
1296 | gip = mp->m_quotainfo->qi_gquotaip; | ||
1297 | if (gip) { | 1350 | if (gip) { |
1298 | error = xfs_qm_dqiterate(mp, gip, XFS_IS_GQUOTA_ON(mp) ? | 1351 | error = xfs_qm_dqiterate(mp, gip, XFS_QMOPT_GQUOTA, |
1299 | XFS_QMOPT_GQUOTA : XFS_QMOPT_PQUOTA, | ||
1300 | &buffer_list); | 1352 | &buffer_list); |
1301 | if (error) | 1353 | if (error) |
1302 | goto error_return; | 1354 | goto error_return; |
1303 | flags |= XFS_OQUOTA_CHKD; | 1355 | flags |= XFS_GQUOTA_CHKD; |
1356 | } | ||
1357 | |||
1358 | if (pip) { | ||
1359 | error = xfs_qm_dqiterate(mp, pip, XFS_QMOPT_PQUOTA, | ||
1360 | &buffer_list); | ||
1361 | if (error) | ||
1362 | goto error_return; | ||
1363 | flags |= XFS_PQUOTA_CHKD; | ||
1304 | } | 1364 | } |
1305 | 1365 | ||
1306 | do { | 1366 | do { |
@@ -1395,15 +1455,14 @@ STATIC int | |||
1395 | xfs_qm_init_quotainos( | 1455 | xfs_qm_init_quotainos( |
1396 | xfs_mount_t *mp) | 1456 | xfs_mount_t *mp) |
1397 | { | 1457 | { |
1398 | xfs_inode_t *uip, *gip; | 1458 | struct xfs_inode *uip = NULL; |
1399 | int error; | 1459 | struct xfs_inode *gip = NULL; |
1400 | __int64_t sbflags; | 1460 | struct xfs_inode *pip = NULL; |
1401 | uint flags; | 1461 | int error; |
1462 | __int64_t sbflags = 0; | ||
1463 | uint flags = 0; | ||
1402 | 1464 | ||
1403 | ASSERT(mp->m_quotainfo); | 1465 | ASSERT(mp->m_quotainfo); |
1404 | uip = gip = NULL; | ||
1405 | sbflags = 0; | ||
1406 | flags = 0; | ||
1407 | 1466 | ||
1408 | /* | 1467 | /* |
1409 | * Get the uquota and gquota inodes | 1468 | * Get the uquota and gquota inodes |
@@ -1412,19 +1471,27 @@ xfs_qm_init_quotainos( | |||
1412 | if (XFS_IS_UQUOTA_ON(mp) && | 1471 | if (XFS_IS_UQUOTA_ON(mp) && |
1413 | mp->m_sb.sb_uquotino != NULLFSINO) { | 1472 | mp->m_sb.sb_uquotino != NULLFSINO) { |
1414 | ASSERT(mp->m_sb.sb_uquotino > 0); | 1473 | ASSERT(mp->m_sb.sb_uquotino > 0); |
1415 | if ((error = xfs_iget(mp, NULL, mp->m_sb.sb_uquotino, | 1474 | error = xfs_iget(mp, NULL, mp->m_sb.sb_uquotino, |
1416 | 0, 0, &uip))) | 1475 | 0, 0, &uip); |
1476 | if (error) | ||
1417 | return XFS_ERROR(error); | 1477 | return XFS_ERROR(error); |
1418 | } | 1478 | } |
1419 | if (XFS_IS_OQUOTA_ON(mp) && | 1479 | if (XFS_IS_GQUOTA_ON(mp) && |
1420 | mp->m_sb.sb_gquotino != NULLFSINO) { | 1480 | mp->m_sb.sb_gquotino != NULLFSINO) { |
1421 | ASSERT(mp->m_sb.sb_gquotino > 0); | 1481 | ASSERT(mp->m_sb.sb_gquotino > 0); |
1422 | if ((error = xfs_iget(mp, NULL, mp->m_sb.sb_gquotino, | 1482 | error = xfs_iget(mp, NULL, mp->m_sb.sb_gquotino, |
1423 | 0, 0, &gip))) { | 1483 | 0, 0, &gip); |
1424 | if (uip) | 1484 | if (error) |
1425 | IRELE(uip); | 1485 | goto error_rele; |
1426 | return XFS_ERROR(error); | 1486 | } |
1427 | } | 1487 | /* XXX: Use gquotino for now */ |
1488 | if (XFS_IS_PQUOTA_ON(mp) && | ||
1489 | mp->m_sb.sb_gquotino != NULLFSINO) { | ||
1490 | ASSERT(mp->m_sb.sb_gquotino > 0); | ||
1491 | error = xfs_iget(mp, NULL, mp->m_sb.sb_gquotino, | ||
1492 | 0, 0, &pip); | ||
1493 | if (error) | ||
1494 | goto error_rele; | ||
1428 | } | 1495 | } |
1429 | } else { | 1496 | } else { |
1430 | flags |= XFS_QMOPT_SBVERSION; | 1497 | flags |= XFS_QMOPT_SBVERSION; |
@@ -1433,36 +1500,52 @@ xfs_qm_init_quotainos( | |||
1433 | } | 1500 | } |
1434 | 1501 | ||
1435 | /* | 1502 | /* |
1436 | * Create the two inodes, if they don't exist already. The changes | 1503 | * Create the three inodes, if they don't exist already. The changes |
1437 | * made above will get added to a transaction and logged in one of | 1504 | * made above will get added to a transaction and logged in one of |
1438 | * the qino_alloc calls below. If the device is readonly, | 1505 | * the qino_alloc calls below. If the device is readonly, |
1439 | * temporarily switch to read-write to do this. | 1506 | * temporarily switch to read-write to do this. |
1440 | */ | 1507 | */ |
1441 | if (XFS_IS_UQUOTA_ON(mp) && uip == NULL) { | 1508 | if (XFS_IS_UQUOTA_ON(mp) && uip == NULL) { |
1442 | if ((error = xfs_qm_qino_alloc(mp, &uip, | 1509 | error = xfs_qm_qino_alloc(mp, &uip, |
1443 | sbflags | XFS_SB_UQUOTINO, | 1510 | sbflags | XFS_SB_UQUOTINO, |
1444 | flags | XFS_QMOPT_UQUOTA))) | 1511 | flags | XFS_QMOPT_UQUOTA); |
1445 | return XFS_ERROR(error); | 1512 | if (error) |
1513 | goto error_rele; | ||
1446 | 1514 | ||
1447 | flags &= ~XFS_QMOPT_SBVERSION; | 1515 | flags &= ~XFS_QMOPT_SBVERSION; |
1448 | } | 1516 | } |
1449 | if (XFS_IS_OQUOTA_ON(mp) && gip == NULL) { | 1517 | if (XFS_IS_GQUOTA_ON(mp) && gip == NULL) { |
1450 | flags |= (XFS_IS_GQUOTA_ON(mp) ? | ||
1451 | XFS_QMOPT_GQUOTA : XFS_QMOPT_PQUOTA); | ||
1452 | error = xfs_qm_qino_alloc(mp, &gip, | 1518 | error = xfs_qm_qino_alloc(mp, &gip, |
1453 | sbflags | XFS_SB_GQUOTINO, flags); | 1519 | sbflags | XFS_SB_GQUOTINO, |
1454 | if (error) { | 1520 | flags | XFS_QMOPT_GQUOTA); |
1455 | if (uip) | 1521 | if (error) |
1456 | IRELE(uip); | 1522 | goto error_rele; |
1457 | 1523 | ||
1458 | return XFS_ERROR(error); | 1524 | flags &= ~XFS_QMOPT_SBVERSION; |
1459 | } | 1525 | } |
1526 | if (XFS_IS_PQUOTA_ON(mp) && pip == NULL) { | ||
1527 | /* XXX: Use XFS_SB_GQUOTINO for now */ | ||
1528 | error = xfs_qm_qino_alloc(mp, &pip, | ||
1529 | sbflags | XFS_SB_GQUOTINO, | ||
1530 | flags | XFS_QMOPT_PQUOTA); | ||
1531 | if (error) | ||
1532 | goto error_rele; | ||
1460 | } | 1533 | } |
1461 | 1534 | ||
1462 | mp->m_quotainfo->qi_uquotaip = uip; | 1535 | mp->m_quotainfo->qi_uquotaip = uip; |
1463 | mp->m_quotainfo->qi_gquotaip = gip; | 1536 | mp->m_quotainfo->qi_gquotaip = gip; |
1537 | mp->m_quotainfo->qi_pquotaip = pip; | ||
1464 | 1538 | ||
1465 | return 0; | 1539 | return 0; |
1540 | |||
1541 | error_rele: | ||
1542 | if (uip) | ||
1543 | IRELE(uip); | ||
1544 | if (gip) | ||
1545 | IRELE(gip); | ||
1546 | if (pip) | ||
1547 | IRELE(pip); | ||
1548 | return XFS_ERROR(error); | ||
1466 | } | 1549 | } |
1467 | 1550 | ||
1468 | STATIC void | 1551 | STATIC void |
@@ -1473,7 +1556,7 @@ xfs_qm_dqfree_one( | |||
1473 | struct xfs_quotainfo *qi = mp->m_quotainfo; | 1556 | struct xfs_quotainfo *qi = mp->m_quotainfo; |
1474 | 1557 | ||
1475 | mutex_lock(&qi->qi_tree_lock); | 1558 | mutex_lock(&qi->qi_tree_lock); |
1476 | radix_tree_delete(XFS_DQUOT_TREE(qi, dqp->q_core.d_flags), | 1559 | radix_tree_delete(xfs_dquot_tree(qi, dqp->q_core.d_flags), |
1477 | be32_to_cpu(dqp->q_core.d_id)); | 1560 | be32_to_cpu(dqp->q_core.d_id)); |
1478 | 1561 | ||
1479 | qi->qi_dquots--; | 1562 | qi->qi_dquots--; |
@@ -1656,10 +1739,13 @@ xfs_qm_vop_dqalloc( | |||
1656 | prid_t prid, | 1739 | prid_t prid, |
1657 | uint flags, | 1740 | uint flags, |
1658 | struct xfs_dquot **O_udqpp, | 1741 | struct xfs_dquot **O_udqpp, |
1659 | struct xfs_dquot **O_gdqpp) | 1742 | struct xfs_dquot **O_gdqpp, |
1743 | struct xfs_dquot **O_pdqpp) | ||
1660 | { | 1744 | { |
1661 | struct xfs_mount *mp = ip->i_mount; | 1745 | struct xfs_mount *mp = ip->i_mount; |
1662 | struct xfs_dquot *uq, *gq; | 1746 | struct xfs_dquot *uq = NULL; |
1747 | struct xfs_dquot *gq = NULL; | ||
1748 | struct xfs_dquot *pq = NULL; | ||
1663 | int error; | 1749 | int error; |
1664 | uint lockflags; | 1750 | uint lockflags; |
1665 | 1751 | ||
@@ -1684,7 +1770,6 @@ xfs_qm_vop_dqalloc( | |||
1684 | } | 1770 | } |
1685 | } | 1771 | } |
1686 | 1772 | ||
1687 | uq = gq = NULL; | ||
1688 | if ((flags & XFS_QMOPT_UQUOTA) && XFS_IS_UQUOTA_ON(mp)) { | 1773 | if ((flags & XFS_QMOPT_UQUOTA) && XFS_IS_UQUOTA_ON(mp)) { |
1689 | if (ip->i_d.di_uid != uid) { | 1774 | if (ip->i_d.di_uid != uid) { |
1690 | /* | 1775 | /* |
@@ -1697,11 +1782,12 @@ xfs_qm_vop_dqalloc( | |||
1697 | * holding ilock. | 1782 | * holding ilock. |
1698 | */ | 1783 | */ |
1699 | xfs_iunlock(ip, lockflags); | 1784 | xfs_iunlock(ip, lockflags); |
1700 | if ((error = xfs_qm_dqget(mp, NULL, (xfs_dqid_t) uid, | 1785 | error = xfs_qm_dqget(mp, NULL, (xfs_dqid_t) uid, |
1701 | XFS_DQ_USER, | 1786 | XFS_DQ_USER, |
1702 | XFS_QMOPT_DQALLOC | | 1787 | XFS_QMOPT_DQALLOC | |
1703 | XFS_QMOPT_DOWARN, | 1788 | XFS_QMOPT_DOWARN, |
1704 | &uq))) { | 1789 | &uq); |
1790 | if (error) { | ||
1705 | ASSERT(error != ENOENT); | 1791 | ASSERT(error != ENOENT); |
1706 | return error; | 1792 | return error; |
1707 | } | 1793 | } |
@@ -1723,15 +1809,14 @@ xfs_qm_vop_dqalloc( | |||
1723 | if ((flags & XFS_QMOPT_GQUOTA) && XFS_IS_GQUOTA_ON(mp)) { | 1809 | if ((flags & XFS_QMOPT_GQUOTA) && XFS_IS_GQUOTA_ON(mp)) { |
1724 | if (ip->i_d.di_gid != gid) { | 1810 | if (ip->i_d.di_gid != gid) { |
1725 | xfs_iunlock(ip, lockflags); | 1811 | xfs_iunlock(ip, lockflags); |
1726 | if ((error = xfs_qm_dqget(mp, NULL, (xfs_dqid_t)gid, | 1812 | error = xfs_qm_dqget(mp, NULL, (xfs_dqid_t)gid, |
1727 | XFS_DQ_GROUP, | 1813 | XFS_DQ_GROUP, |
1728 | XFS_QMOPT_DQALLOC | | 1814 | XFS_QMOPT_DQALLOC | |
1729 | XFS_QMOPT_DOWARN, | 1815 | XFS_QMOPT_DOWARN, |
1730 | &gq))) { | 1816 | &gq); |
1731 | if (uq) | 1817 | if (error) { |
1732 | xfs_qm_dqrele(uq); | ||
1733 | ASSERT(error != ENOENT); | 1818 | ASSERT(error != ENOENT); |
1734 | return error; | 1819 | goto error_rele; |
1735 | } | 1820 | } |
1736 | xfs_dqunlock(gq); | 1821 | xfs_dqunlock(gq); |
1737 | lockflags = XFS_ILOCK_SHARED; | 1822 | lockflags = XFS_ILOCK_SHARED; |
@@ -1740,25 +1825,25 @@ xfs_qm_vop_dqalloc( | |||
1740 | ASSERT(ip->i_gdquot); | 1825 | ASSERT(ip->i_gdquot); |
1741 | gq = xfs_qm_dqhold(ip->i_gdquot); | 1826 | gq = xfs_qm_dqhold(ip->i_gdquot); |
1742 | } | 1827 | } |
1743 | } else if ((flags & XFS_QMOPT_PQUOTA) && XFS_IS_PQUOTA_ON(mp)) { | 1828 | } |
1829 | if ((flags & XFS_QMOPT_PQUOTA) && XFS_IS_PQUOTA_ON(mp)) { | ||
1744 | if (xfs_get_projid(ip) != prid) { | 1830 | if (xfs_get_projid(ip) != prid) { |
1745 | xfs_iunlock(ip, lockflags); | 1831 | xfs_iunlock(ip, lockflags); |
1746 | if ((error = xfs_qm_dqget(mp, NULL, (xfs_dqid_t)prid, | 1832 | error = xfs_qm_dqget(mp, NULL, (xfs_dqid_t)prid, |
1747 | XFS_DQ_PROJ, | 1833 | XFS_DQ_PROJ, |
1748 | XFS_QMOPT_DQALLOC | | 1834 | XFS_QMOPT_DQALLOC | |
1749 | XFS_QMOPT_DOWARN, | 1835 | XFS_QMOPT_DOWARN, |
1750 | &gq))) { | 1836 | &pq); |
1751 | if (uq) | 1837 | if (error) { |
1752 | xfs_qm_dqrele(uq); | ||
1753 | ASSERT(error != ENOENT); | 1838 | ASSERT(error != ENOENT); |
1754 | return (error); | 1839 | goto error_rele; |
1755 | } | 1840 | } |
1756 | xfs_dqunlock(gq); | 1841 | xfs_dqunlock(pq); |
1757 | lockflags = XFS_ILOCK_SHARED; | 1842 | lockflags = XFS_ILOCK_SHARED; |
1758 | xfs_ilock(ip, lockflags); | 1843 | xfs_ilock(ip, lockflags); |
1759 | } else { | 1844 | } else { |
1760 | ASSERT(ip->i_gdquot); | 1845 | ASSERT(ip->i_pdquot); |
1761 | gq = xfs_qm_dqhold(ip->i_gdquot); | 1846 | pq = xfs_qm_dqhold(ip->i_pdquot); |
1762 | } | 1847 | } |
1763 | } | 1848 | } |
1764 | if (uq) | 1849 | if (uq) |
@@ -1773,7 +1858,18 @@ xfs_qm_vop_dqalloc( | |||
1773 | *O_gdqpp = gq; | 1858 | *O_gdqpp = gq; |
1774 | else if (gq) | 1859 | else if (gq) |
1775 | xfs_qm_dqrele(gq); | 1860 | xfs_qm_dqrele(gq); |
1861 | if (O_pdqpp) | ||
1862 | *O_pdqpp = pq; | ||
1863 | else if (pq) | ||
1864 | xfs_qm_dqrele(pq); | ||
1776 | return 0; | 1865 | return 0; |
1866 | |||
1867 | error_rele: | ||
1868 | if (gq) | ||
1869 | xfs_qm_dqrele(gq); | ||
1870 | if (uq) | ||
1871 | xfs_qm_dqrele(uq); | ||
1872 | return error; | ||
1777 | } | 1873 | } |
1778 | 1874 | ||
1779 | /* | 1875 | /* |
@@ -1821,29 +1917,34 @@ xfs_qm_vop_chown( | |||
1821 | */ | 1917 | */ |
1822 | int | 1918 | int |
1823 | xfs_qm_vop_chown_reserve( | 1919 | xfs_qm_vop_chown_reserve( |
1824 | xfs_trans_t *tp, | 1920 | struct xfs_trans *tp, |
1825 | xfs_inode_t *ip, | 1921 | struct xfs_inode *ip, |
1826 | xfs_dquot_t *udqp, | 1922 | struct xfs_dquot *udqp, |
1827 | xfs_dquot_t *gdqp, | 1923 | struct xfs_dquot *gdqp, |
1828 | uint flags) | 1924 | struct xfs_dquot *pdqp, |
1925 | uint flags) | ||
1829 | { | 1926 | { |
1830 | xfs_mount_t *mp = ip->i_mount; | 1927 | struct xfs_mount *mp = ip->i_mount; |
1831 | uint delblks, blkflags, prjflags = 0; | 1928 | uint delblks, blkflags, prjflags = 0; |
1832 | xfs_dquot_t *unresudq, *unresgdq, *delblksudq, *delblksgdq; | 1929 | struct xfs_dquot *udq_unres = NULL; |
1833 | int error; | 1930 | struct xfs_dquot *gdq_unres = NULL; |
1931 | struct xfs_dquot *pdq_unres = NULL; | ||
1932 | struct xfs_dquot *udq_delblks = NULL; | ||
1933 | struct xfs_dquot *gdq_delblks = NULL; | ||
1934 | struct xfs_dquot *pdq_delblks = NULL; | ||
1935 | int error; | ||
1834 | 1936 | ||
1835 | 1937 | ||
1836 | ASSERT(xfs_isilocked(ip, XFS_ILOCK_EXCL|XFS_ILOCK_SHARED)); | 1938 | ASSERT(xfs_isilocked(ip, XFS_ILOCK_EXCL|XFS_ILOCK_SHARED)); |
1837 | ASSERT(XFS_IS_QUOTA_RUNNING(mp)); | 1939 | ASSERT(XFS_IS_QUOTA_RUNNING(mp)); |
1838 | 1940 | ||
1839 | delblks = ip->i_delayed_blks; | 1941 | delblks = ip->i_delayed_blks; |
1840 | delblksudq = delblksgdq = unresudq = unresgdq = NULL; | ||
1841 | blkflags = XFS_IS_REALTIME_INODE(ip) ? | 1942 | blkflags = XFS_IS_REALTIME_INODE(ip) ? |
1842 | XFS_QMOPT_RES_RTBLKS : XFS_QMOPT_RES_REGBLKS; | 1943 | XFS_QMOPT_RES_RTBLKS : XFS_QMOPT_RES_REGBLKS; |
1843 | 1944 | ||
1844 | if (XFS_IS_UQUOTA_ON(mp) && udqp && | 1945 | if (XFS_IS_UQUOTA_ON(mp) && udqp && |
1845 | ip->i_d.di_uid != (uid_t)be32_to_cpu(udqp->q_core.d_id)) { | 1946 | ip->i_d.di_uid != (uid_t)be32_to_cpu(udqp->q_core.d_id)) { |
1846 | delblksudq = udqp; | 1947 | udq_delblks = udqp; |
1847 | /* | 1948 | /* |
1848 | * If there are delayed allocation blocks, then we have to | 1949 | * If there are delayed allocation blocks, then we have to |
1849 | * unreserve those from the old dquot, and add them to the | 1950 | * unreserve those from the old dquot, and add them to the |
@@ -1851,29 +1952,34 @@ xfs_qm_vop_chown_reserve( | |||
1851 | */ | 1952 | */ |
1852 | if (delblks) { | 1953 | if (delblks) { |
1853 | ASSERT(ip->i_udquot); | 1954 | ASSERT(ip->i_udquot); |
1854 | unresudq = ip->i_udquot; | 1955 | udq_unres = ip->i_udquot; |
1855 | } | 1956 | } |
1856 | } | 1957 | } |
1857 | if (XFS_IS_OQUOTA_ON(ip->i_mount) && gdqp) { | 1958 | if (XFS_IS_GQUOTA_ON(ip->i_mount) && gdqp && |
1858 | if (XFS_IS_PQUOTA_ON(ip->i_mount) && | 1959 | ip->i_d.di_gid != be32_to_cpu(gdqp->q_core.d_id)) { |
1859 | xfs_get_projid(ip) != be32_to_cpu(gdqp->q_core.d_id)) | 1960 | gdq_delblks = gdqp; |
1860 | prjflags = XFS_QMOPT_ENOSPC; | 1961 | if (delblks) { |
1861 | 1962 | ASSERT(ip->i_gdquot); | |
1862 | if (prjflags || | 1963 | gdq_unres = ip->i_gdquot; |
1863 | (XFS_IS_GQUOTA_ON(ip->i_mount) && | ||
1864 | ip->i_d.di_gid != be32_to_cpu(gdqp->q_core.d_id))) { | ||
1865 | delblksgdq = gdqp; | ||
1866 | if (delblks) { | ||
1867 | ASSERT(ip->i_gdquot); | ||
1868 | unresgdq = ip->i_gdquot; | ||
1869 | } | ||
1870 | } | 1964 | } |
1871 | } | 1965 | } |
1872 | 1966 | ||
1873 | if ((error = xfs_trans_reserve_quota_bydquots(tp, ip->i_mount, | 1967 | if (XFS_IS_PQUOTA_ON(ip->i_mount) && pdqp && |
1874 | delblksudq, delblksgdq, ip->i_d.di_nblocks, 1, | 1968 | xfs_get_projid(ip) != be32_to_cpu(pdqp->q_core.d_id)) { |
1875 | flags | blkflags | prjflags))) | 1969 | prjflags = XFS_QMOPT_ENOSPC; |
1876 | return (error); | 1970 | pdq_delblks = pdqp; |
1971 | if (delblks) { | ||
1972 | ASSERT(ip->i_pdquot); | ||
1973 | pdq_unres = ip->i_pdquot; | ||
1974 | } | ||
1975 | } | ||
1976 | |||
1977 | error = xfs_trans_reserve_quota_bydquots(tp, ip->i_mount, | ||
1978 | udq_delblks, gdq_delblks, pdq_delblks, | ||
1979 | ip->i_d.di_nblocks, 1, | ||
1980 | flags | blkflags | prjflags); | ||
1981 | if (error) | ||
1982 | return error; | ||
1877 | 1983 | ||
1878 | /* | 1984 | /* |
1879 | * Do the delayed blks reservations/unreservations now. Since, these | 1985 | * Do the delayed blks reservations/unreservations now. Since, these |
@@ -1885,15 +1991,17 @@ xfs_qm_vop_chown_reserve( | |||
1885 | /* | 1991 | /* |
1886 | * Do the reservations first. Unreservation can't fail. | 1992 | * Do the reservations first. Unreservation can't fail. |
1887 | */ | 1993 | */ |
1888 | ASSERT(delblksudq || delblksgdq); | 1994 | ASSERT(udq_delblks || gdq_delblks || pdq_delblks); |
1889 | ASSERT(unresudq || unresgdq); | 1995 | ASSERT(udq_unres || gdq_unres || pdq_unres); |
1890 | if ((error = xfs_trans_reserve_quota_bydquots(NULL, ip->i_mount, | 1996 | error = xfs_trans_reserve_quota_bydquots(NULL, ip->i_mount, |
1891 | delblksudq, delblksgdq, (xfs_qcnt_t)delblks, 0, | 1997 | udq_delblks, gdq_delblks, pdq_delblks, |
1892 | flags | blkflags | prjflags))) | 1998 | (xfs_qcnt_t)delblks, 0, |
1893 | return (error); | 1999 | flags | blkflags | prjflags); |
2000 | if (error) | ||
2001 | return error; | ||
1894 | xfs_trans_reserve_quota_bydquots(NULL, ip->i_mount, | 2002 | xfs_trans_reserve_quota_bydquots(NULL, ip->i_mount, |
1895 | unresudq, unresgdq, -((xfs_qcnt_t)delblks), 0, | 2003 | udq_unres, gdq_unres, pdq_unres, |
1896 | blkflags); | 2004 | -((xfs_qcnt_t)delblks), 0, blkflags); |
1897 | } | 2005 | } |
1898 | 2006 | ||
1899 | return (0); | 2007 | return (0); |
@@ -1932,7 +2040,8 @@ xfs_qm_vop_create_dqattach( | |||
1932 | struct xfs_trans *tp, | 2040 | struct xfs_trans *tp, |
1933 | struct xfs_inode *ip, | 2041 | struct xfs_inode *ip, |
1934 | struct xfs_dquot *udqp, | 2042 | struct xfs_dquot *udqp, |
1935 | struct xfs_dquot *gdqp) | 2043 | struct xfs_dquot *gdqp, |
2044 | struct xfs_dquot *pdqp) | ||
1936 | { | 2045 | { |
1937 | struct xfs_mount *mp = tp->t_mountp; | 2046 | struct xfs_mount *mp = tp->t_mountp; |
1938 | 2047 | ||
@@ -1952,13 +2061,18 @@ xfs_qm_vop_create_dqattach( | |||
1952 | } | 2061 | } |
1953 | if (gdqp) { | 2062 | if (gdqp) { |
1954 | ASSERT(ip->i_gdquot == NULL); | 2063 | ASSERT(ip->i_gdquot == NULL); |
1955 | ASSERT(XFS_IS_OQUOTA_ON(mp)); | 2064 | ASSERT(XFS_IS_GQUOTA_ON(mp)); |
1956 | ASSERT((XFS_IS_GQUOTA_ON(mp) ? | 2065 | ASSERT(ip->i_d.di_gid == be32_to_cpu(gdqp->q_core.d_id)); |
1957 | ip->i_d.di_gid : xfs_get_projid(ip)) == | ||
1958 | be32_to_cpu(gdqp->q_core.d_id)); | ||
1959 | |||
1960 | ip->i_gdquot = xfs_qm_dqhold(gdqp); | 2066 | ip->i_gdquot = xfs_qm_dqhold(gdqp); |
1961 | xfs_trans_mod_dquot(tp, gdqp, XFS_TRANS_DQ_ICOUNT, 1); | 2067 | xfs_trans_mod_dquot(tp, gdqp, XFS_TRANS_DQ_ICOUNT, 1); |
1962 | } | 2068 | } |
2069 | if (pdqp) { | ||
2070 | ASSERT(ip->i_pdquot == NULL); | ||
2071 | ASSERT(XFS_IS_PQUOTA_ON(mp)); | ||
2072 | ASSERT(xfs_get_projid(ip) == be32_to_cpu(pdqp->q_core.d_id)); | ||
2073 | |||
2074 | ip->i_pdquot = xfs_qm_dqhold(pdqp); | ||
2075 | xfs_trans_mod_dquot(tp, pdqp, XFS_TRANS_DQ_ICOUNT, 1); | ||
2076 | } | ||
1963 | } | 2077 | } |
1964 | 2078 | ||
diff --git a/fs/xfs/xfs_qm.h b/fs/xfs/xfs_qm.h index 5d16a6e6900f..579d6a02a5b6 100644 --- a/fs/xfs/xfs_qm.h +++ b/fs/xfs/xfs_qm.h | |||
@@ -44,9 +44,11 @@ extern struct kmem_zone *xfs_qm_dqtrxzone; | |||
44 | typedef struct xfs_quotainfo { | 44 | typedef struct xfs_quotainfo { |
45 | struct radix_tree_root qi_uquota_tree; | 45 | struct radix_tree_root qi_uquota_tree; |
46 | struct radix_tree_root qi_gquota_tree; | 46 | struct radix_tree_root qi_gquota_tree; |
47 | struct radix_tree_root qi_pquota_tree; | ||
47 | struct mutex qi_tree_lock; | 48 | struct mutex qi_tree_lock; |
48 | xfs_inode_t *qi_uquotaip; /* user quota inode */ | 49 | struct xfs_inode *qi_uquotaip; /* user quota inode */ |
49 | xfs_inode_t *qi_gquotaip; /* group quota inode */ | 50 | struct xfs_inode *qi_gquotaip; /* group quota inode */ |
51 | struct xfs_inode *qi_pquotaip; /* project quota inode */ | ||
50 | struct list_head qi_lru_list; | 52 | struct list_head qi_lru_list; |
51 | struct mutex qi_lru_lock; | 53 | struct mutex qi_lru_lock; |
52 | int qi_lru_count; | 54 | int qi_lru_count; |
@@ -69,30 +71,66 @@ typedef struct xfs_quotainfo { | |||
69 | struct shrinker qi_shrinker; | 71 | struct shrinker qi_shrinker; |
70 | } xfs_quotainfo_t; | 72 | } xfs_quotainfo_t; |
71 | 73 | ||
72 | #define XFS_DQUOT_TREE(qi, type) \ | 74 | static inline struct radix_tree_root * |
73 | ((type & XFS_DQ_USER) ? \ | 75 | xfs_dquot_tree( |
74 | &((qi)->qi_uquota_tree) : \ | 76 | struct xfs_quotainfo *qi, |
75 | &((qi)->qi_gquota_tree)) | 77 | int type) |
78 | { | ||
79 | switch (type) { | ||
80 | case XFS_DQ_USER: | ||
81 | return &qi->qi_uquota_tree; | ||
82 | case XFS_DQ_GROUP: | ||
83 | return &qi->qi_gquota_tree; | ||
84 | case XFS_DQ_PROJ: | ||
85 | return &qi->qi_pquota_tree; | ||
86 | default: | ||
87 | ASSERT(0); | ||
88 | } | ||
89 | return NULL; | ||
90 | } | ||
76 | 91 | ||
92 | static inline struct xfs_inode * | ||
93 | xfs_dq_to_quota_inode(struct xfs_dquot *dqp) | ||
94 | { | ||
95 | switch (dqp->dq_flags & XFS_DQ_ALLTYPES) { | ||
96 | case XFS_DQ_USER: | ||
97 | return dqp->q_mount->m_quotainfo->qi_uquotaip; | ||
98 | case XFS_DQ_GROUP: | ||
99 | return dqp->q_mount->m_quotainfo->qi_gquotaip; | ||
100 | case XFS_DQ_PROJ: | ||
101 | return dqp->q_mount->m_quotainfo->qi_pquotaip; | ||
102 | default: | ||
103 | ASSERT(0); | ||
104 | } | ||
105 | return NULL; | ||
106 | } | ||
77 | 107 | ||
78 | extern int xfs_qm_calc_dquots_per_chunk(struct xfs_mount *mp, | 108 | extern int xfs_qm_calc_dquots_per_chunk(struct xfs_mount *mp, |
79 | unsigned int nbblks); | 109 | unsigned int nbblks); |
80 | extern void xfs_trans_mod_dquot(xfs_trans_t *, xfs_dquot_t *, uint, long); | 110 | extern void xfs_trans_mod_dquot(struct xfs_trans *, |
81 | extern int xfs_trans_reserve_quota_bydquots(xfs_trans_t *, xfs_mount_t *, | 111 | struct xfs_dquot *, uint, long); |
82 | xfs_dquot_t *, xfs_dquot_t *, long, long, uint); | 112 | extern int xfs_trans_reserve_quota_bydquots(struct xfs_trans *, |
83 | extern void xfs_trans_dqjoin(xfs_trans_t *, xfs_dquot_t *); | 113 | struct xfs_mount *, struct xfs_dquot *, |
84 | extern void xfs_trans_log_dquot(xfs_trans_t *, xfs_dquot_t *); | 114 | struct xfs_dquot *, struct xfs_dquot *, |
115 | long, long, uint); | ||
116 | extern void xfs_trans_dqjoin(struct xfs_trans *, struct xfs_dquot *); | ||
117 | extern void xfs_trans_log_dquot(struct xfs_trans *, struct xfs_dquot *); | ||
85 | 118 | ||
86 | /* | 119 | /* |
87 | * We keep the usr and grp dquots separately so that locking will be easier | 120 | * We keep the usr, grp, and prj dquots separately so that locking will be |
88 | * to do at commit time. All transactions that we know of at this point | 121 | * easier to do at commit time. All transactions that we know of at this point |
89 | * affect no more than two dquots of one type. Hence, the TRANS_MAXDQS value. | 122 | * affect no more than two dquots of one type. Hence, the TRANS_MAXDQS value. |
90 | */ | 123 | */ |
124 | enum { | ||
125 | XFS_QM_TRANS_USR = 0, | ||
126 | XFS_QM_TRANS_GRP, | ||
127 | XFS_QM_TRANS_PRJ, | ||
128 | XFS_QM_TRANS_DQTYPES | ||
129 | }; | ||
91 | #define XFS_QM_TRANS_MAXDQS 2 | 130 | #define XFS_QM_TRANS_MAXDQS 2 |
92 | typedef struct xfs_dquot_acct { | 131 | struct xfs_dquot_acct { |
93 | xfs_dqtrx_t dqa_usrdquots[XFS_QM_TRANS_MAXDQS]; | 132 | struct xfs_dqtrx dqs[XFS_QM_TRANS_DQTYPES][XFS_QM_TRANS_MAXDQS]; |
94 | xfs_dqtrx_t dqa_grpdquots[XFS_QM_TRANS_MAXDQS]; | 133 | }; |
95 | } xfs_dquot_acct_t; | ||
96 | 134 | ||
97 | /* | 135 | /* |
98 | * Users are allowed to have a usage exceeding their softlimit for | 136 | * Users are allowed to have a usage exceeding their softlimit for |
@@ -106,22 +144,23 @@ typedef struct xfs_dquot_acct { | |||
106 | #define XFS_QM_IWARNLIMIT 5 | 144 | #define XFS_QM_IWARNLIMIT 5 |
107 | #define XFS_QM_RTBWARNLIMIT 5 | 145 | #define XFS_QM_RTBWARNLIMIT 5 |
108 | 146 | ||
109 | extern void xfs_qm_destroy_quotainfo(xfs_mount_t *); | 147 | extern void xfs_qm_destroy_quotainfo(struct xfs_mount *); |
110 | extern int xfs_qm_quotacheck(xfs_mount_t *); | 148 | extern int xfs_qm_quotacheck(struct xfs_mount *); |
111 | extern int xfs_qm_write_sb_changes(xfs_mount_t *, __int64_t); | 149 | extern int xfs_qm_write_sb_changes(struct xfs_mount *, __int64_t); |
112 | 150 | ||
113 | /* dquot stuff */ | 151 | /* dquot stuff */ |
114 | extern void xfs_qm_dqpurge_all(xfs_mount_t *, uint); | 152 | extern void xfs_qm_dqpurge_all(struct xfs_mount *, uint); |
115 | extern void xfs_qm_dqrele_all_inodes(xfs_mount_t *, uint); | 153 | extern void xfs_qm_dqrele_all_inodes(struct xfs_mount *, uint); |
116 | 154 | ||
117 | /* quota ops */ | 155 | /* quota ops */ |
118 | extern int xfs_qm_scall_trunc_qfiles(xfs_mount_t *, uint); | 156 | extern int xfs_qm_scall_trunc_qfiles(struct xfs_mount *, uint); |
119 | extern int xfs_qm_scall_getquota(xfs_mount_t *, xfs_dqid_t, uint, | 157 | extern int xfs_qm_scall_getquota(struct xfs_mount *, xfs_dqid_t, |
120 | fs_disk_quota_t *); | 158 | uint, struct fs_disk_quota *); |
121 | extern int xfs_qm_scall_setqlim(struct xfs_mount *, xfs_dqid_t, uint, | 159 | extern int xfs_qm_scall_setqlim(struct xfs_mount *, xfs_dqid_t, uint, |
122 | fs_disk_quota_t *); | 160 | struct fs_disk_quota *); |
123 | extern int xfs_qm_scall_getqstat(xfs_mount_t *, fs_quota_stat_t *); | 161 | extern int xfs_qm_scall_getqstat(struct xfs_mount *, |
124 | extern int xfs_qm_scall_quotaon(xfs_mount_t *, uint); | 162 | struct fs_quota_stat *); |
125 | extern int xfs_qm_scall_quotaoff(xfs_mount_t *, uint); | 163 | extern int xfs_qm_scall_quotaon(struct xfs_mount *, uint); |
164 | extern int xfs_qm_scall_quotaoff(struct xfs_mount *, uint); | ||
126 | 165 | ||
127 | #endif /* __XFS_QM_H__ */ | 166 | #endif /* __XFS_QM_H__ */ |
diff --git a/fs/xfs/xfs_qm_bhv.c b/fs/xfs/xfs_qm_bhv.c index 2d02eac1c9a8..437a52d91f6d 100644 --- a/fs/xfs/xfs_qm_bhv.c +++ b/fs/xfs/xfs_qm_bhv.c | |||
@@ -112,16 +112,16 @@ xfs_qm_newmount( | |||
112 | 112 | ||
113 | if (((uquotaondisk && !XFS_IS_UQUOTA_ON(mp)) || | 113 | if (((uquotaondisk && !XFS_IS_UQUOTA_ON(mp)) || |
114 | (!uquotaondisk && XFS_IS_UQUOTA_ON(mp)) || | 114 | (!uquotaondisk && XFS_IS_UQUOTA_ON(mp)) || |
115 | (pquotaondisk && !XFS_IS_PQUOTA_ON(mp)) || | ||
116 | (!pquotaondisk && XFS_IS_PQUOTA_ON(mp)) || | ||
117 | (gquotaondisk && !XFS_IS_GQUOTA_ON(mp)) || | 115 | (gquotaondisk && !XFS_IS_GQUOTA_ON(mp)) || |
118 | (!gquotaondisk && XFS_IS_OQUOTA_ON(mp))) && | 116 | (!gquotaondisk && XFS_IS_GQUOTA_ON(mp)) || |
117 | (pquotaondisk && !XFS_IS_PQUOTA_ON(mp)) || | ||
118 | (!pquotaondisk && XFS_IS_PQUOTA_ON(mp))) && | ||
119 | xfs_dev_is_read_only(mp, "changing quota state")) { | 119 | xfs_dev_is_read_only(mp, "changing quota state")) { |
120 | xfs_warn(mp, "please mount with%s%s%s%s.", | 120 | xfs_warn(mp, "please mount with%s%s%s%s.", |
121 | (!quotaondisk ? "out quota" : ""), | 121 | (!quotaondisk ? "out quota" : ""), |
122 | (uquotaondisk ? " usrquota" : ""), | 122 | (uquotaondisk ? " usrquota" : ""), |
123 | (pquotaondisk ? " prjquota" : ""), | 123 | (gquotaondisk ? " grpquota" : ""), |
124 | (gquotaondisk ? " grpquota" : "")); | 124 | (pquotaondisk ? " prjquota" : "")); |
125 | return XFS_ERROR(EPERM); | 125 | return XFS_ERROR(EPERM); |
126 | } | 126 | } |
127 | 127 | ||
diff --git a/fs/xfs/xfs_qm_syscalls.c b/fs/xfs/xfs_qm_syscalls.c index 6cdf6ffc36a1..e4f8b2d6f38b 100644 --- a/fs/xfs/xfs_qm_syscalls.c +++ b/fs/xfs/xfs_qm_syscalls.c | |||
@@ -117,11 +117,12 @@ xfs_qm_scall_quotaoff( | |||
117 | } | 117 | } |
118 | if (flags & XFS_GQUOTA_ACCT) { | 118 | if (flags & XFS_GQUOTA_ACCT) { |
119 | dqtype |= XFS_QMOPT_GQUOTA; | 119 | dqtype |= XFS_QMOPT_GQUOTA; |
120 | flags |= (XFS_OQUOTA_CHKD | XFS_OQUOTA_ENFD); | 120 | flags |= (XFS_GQUOTA_CHKD | XFS_GQUOTA_ENFD); |
121 | inactivate_flags |= XFS_GQUOTA_ACTIVE; | 121 | inactivate_flags |= XFS_GQUOTA_ACTIVE; |
122 | } else if (flags & XFS_PQUOTA_ACCT) { | 122 | } |
123 | if (flags & XFS_PQUOTA_ACCT) { | ||
123 | dqtype |= XFS_QMOPT_PQUOTA; | 124 | dqtype |= XFS_QMOPT_PQUOTA; |
124 | flags |= (XFS_OQUOTA_CHKD | XFS_OQUOTA_ENFD); | 125 | flags |= (XFS_PQUOTA_CHKD | XFS_PQUOTA_ENFD); |
125 | inactivate_flags |= XFS_PQUOTA_ACTIVE; | 126 | inactivate_flags |= XFS_PQUOTA_ACTIVE; |
126 | } | 127 | } |
127 | 128 | ||
@@ -198,10 +199,9 @@ xfs_qm_scall_quotaoff( | |||
198 | } | 199 | } |
199 | 200 | ||
200 | /* | 201 | /* |
201 | * If quotas is completely disabled, close shop. | 202 | * If all quotas are completely turned off, close shop. |
202 | */ | 203 | */ |
203 | if (((flags & XFS_MOUNT_QUOTA_ALL) == XFS_MOUNT_QUOTA_SET1) || | 204 | if (mp->m_qflags == 0) { |
204 | ((flags & XFS_MOUNT_QUOTA_ALL) == XFS_MOUNT_QUOTA_SET2)) { | ||
205 | mutex_unlock(&q->qi_quotaofflock); | 205 | mutex_unlock(&q->qi_quotaofflock); |
206 | xfs_qm_destroy_quotainfo(mp); | 206 | xfs_qm_destroy_quotainfo(mp); |
207 | return (0); | 207 | return (0); |
@@ -214,10 +214,14 @@ xfs_qm_scall_quotaoff( | |||
214 | IRELE(q->qi_uquotaip); | 214 | IRELE(q->qi_uquotaip); |
215 | q->qi_uquotaip = NULL; | 215 | q->qi_uquotaip = NULL; |
216 | } | 216 | } |
217 | if ((dqtype & (XFS_QMOPT_GQUOTA|XFS_QMOPT_PQUOTA)) && q->qi_gquotaip) { | 217 | if ((dqtype & XFS_QMOPT_GQUOTA) && q->qi_gquotaip) { |
218 | IRELE(q->qi_gquotaip); | 218 | IRELE(q->qi_gquotaip); |
219 | q->qi_gquotaip = NULL; | 219 | q->qi_gquotaip = NULL; |
220 | } | 220 | } |
221 | if ((dqtype & XFS_QMOPT_PQUOTA) && q->qi_pquotaip) { | ||
222 | IRELE(q->qi_pquotaip); | ||
223 | q->qi_pquotaip = NULL; | ||
224 | } | ||
221 | 225 | ||
222 | out_unlock: | 226 | out_unlock: |
223 | mutex_unlock(&q->qi_quotaofflock); | 227 | mutex_unlock(&q->qi_quotaofflock); |
@@ -335,14 +339,14 @@ xfs_qm_scall_quotaon( | |||
335 | * quota acct on ondisk without m_qflags' knowing. | 339 | * quota acct on ondisk without m_qflags' knowing. |
336 | */ | 340 | */ |
337 | if (((flags & XFS_UQUOTA_ACCT) == 0 && | 341 | if (((flags & XFS_UQUOTA_ACCT) == 0 && |
338 | (mp->m_sb.sb_qflags & XFS_UQUOTA_ACCT) == 0 && | 342 | (mp->m_sb.sb_qflags & XFS_UQUOTA_ACCT) == 0 && |
339 | (flags & XFS_UQUOTA_ENFD)) | 343 | (flags & XFS_UQUOTA_ENFD)) || |
340 | || | 344 | ((flags & XFS_GQUOTA_ACCT) == 0 && |
345 | (mp->m_sb.sb_qflags & XFS_GQUOTA_ACCT) == 0 && | ||
346 | (flags & XFS_GQUOTA_ENFD)) || | ||
341 | ((flags & XFS_PQUOTA_ACCT) == 0 && | 347 | ((flags & XFS_PQUOTA_ACCT) == 0 && |
342 | (mp->m_sb.sb_qflags & XFS_PQUOTA_ACCT) == 0 && | 348 | (mp->m_sb.sb_qflags & XFS_PQUOTA_ACCT) == 0 && |
343 | (flags & XFS_GQUOTA_ACCT) == 0 && | 349 | (flags & XFS_PQUOTA_ENFD))) { |
344 | (mp->m_sb.sb_qflags & XFS_GQUOTA_ACCT) == 0 && | ||
345 | (flags & XFS_OQUOTA_ENFD))) { | ||
346 | xfs_debug(mp, | 350 | xfs_debug(mp, |
347 | "%s: Can't enforce without acct, flags=%x sbflags=%x\n", | 351 | "%s: Can't enforce without acct, flags=%x sbflags=%x\n", |
348 | __func__, flags, mp->m_sb.sb_qflags); | 352 | __func__, flags, mp->m_sb.sb_qflags); |
@@ -407,11 +411,11 @@ xfs_qm_scall_getqstat( | |||
407 | struct fs_quota_stat *out) | 411 | struct fs_quota_stat *out) |
408 | { | 412 | { |
409 | struct xfs_quotainfo *q = mp->m_quotainfo; | 413 | struct xfs_quotainfo *q = mp->m_quotainfo; |
410 | struct xfs_inode *uip, *gip; | 414 | struct xfs_inode *uip = NULL; |
411 | bool tempuqip, tempgqip; | 415 | struct xfs_inode *gip = NULL; |
416 | bool tempuqip = false; | ||
417 | bool tempgqip = false; | ||
412 | 418 | ||
413 | uip = gip = NULL; | ||
414 | tempuqip = tempgqip = false; | ||
415 | memset(out, 0, sizeof(fs_quota_stat_t)); | 419 | memset(out, 0, sizeof(fs_quota_stat_t)); |
416 | 420 | ||
417 | out->qs_version = FS_QSTAT_VERSION; | 421 | out->qs_version = FS_QSTAT_VERSION; |
@@ -776,9 +780,12 @@ xfs_qm_scall_getquota( | |||
776 | * gets turned off. No need to confuse the user level code, | 780 | * gets turned off. No need to confuse the user level code, |
777 | * so return zeroes in that case. | 781 | * so return zeroes in that case. |
778 | */ | 782 | */ |
779 | if ((!XFS_IS_UQUOTA_ENFORCED(mp) && dqp->q_core.d_flags == XFS_DQ_USER) || | 783 | if ((!XFS_IS_UQUOTA_ENFORCED(mp) && |
780 | (!XFS_IS_OQUOTA_ENFORCED(mp) && | 784 | dqp->q_core.d_flags == XFS_DQ_USER) || |
781 | (dqp->q_core.d_flags & (XFS_DQ_PROJ | XFS_DQ_GROUP)))) { | 785 | (!XFS_IS_GQUOTA_ENFORCED(mp) && |
786 | dqp->q_core.d_flags == XFS_DQ_GROUP) || | ||
787 | (!XFS_IS_PQUOTA_ENFORCED(mp) && | ||
788 | dqp->q_core.d_flags == XFS_DQ_PROJ)) { | ||
782 | dst->d_btimer = 0; | 789 | dst->d_btimer = 0; |
783 | dst->d_itimer = 0; | 790 | dst->d_itimer = 0; |
784 | dst->d_rtbtimer = 0; | 791 | dst->d_rtbtimer = 0; |
@@ -786,8 +793,8 @@ xfs_qm_scall_getquota( | |||
786 | 793 | ||
787 | #ifdef DEBUG | 794 | #ifdef DEBUG |
788 | if (((XFS_IS_UQUOTA_ENFORCED(mp) && dst->d_flags == FS_USER_QUOTA) || | 795 | if (((XFS_IS_UQUOTA_ENFORCED(mp) && dst->d_flags == FS_USER_QUOTA) || |
789 | (XFS_IS_OQUOTA_ENFORCED(mp) && | 796 | (XFS_IS_GQUOTA_ENFORCED(mp) && dst->d_flags == FS_GROUP_QUOTA) || |
790 | (dst->d_flags & (FS_PROJ_QUOTA | FS_GROUP_QUOTA)))) && | 797 | (XFS_IS_PQUOTA_ENFORCED(mp) && dst->d_flags == FS_PROJ_QUOTA)) && |
791 | dst->d_id != 0) { | 798 | dst->d_id != 0) { |
792 | if ((dst->d_bcount > dst->d_blk_softlimit) && | 799 | if ((dst->d_bcount > dst->d_blk_softlimit) && |
793 | (dst->d_blk_softlimit > 0)) { | 800 | (dst->d_blk_softlimit > 0)) { |
@@ -833,16 +840,16 @@ xfs_qm_export_flags( | |||
833 | uflags = 0; | 840 | uflags = 0; |
834 | if (flags & XFS_UQUOTA_ACCT) | 841 | if (flags & XFS_UQUOTA_ACCT) |
835 | uflags |= FS_QUOTA_UDQ_ACCT; | 842 | uflags |= FS_QUOTA_UDQ_ACCT; |
836 | if (flags & XFS_PQUOTA_ACCT) | ||
837 | uflags |= FS_QUOTA_PDQ_ACCT; | ||
838 | if (flags & XFS_GQUOTA_ACCT) | 843 | if (flags & XFS_GQUOTA_ACCT) |
839 | uflags |= FS_QUOTA_GDQ_ACCT; | 844 | uflags |= FS_QUOTA_GDQ_ACCT; |
845 | if (flags & XFS_PQUOTA_ACCT) | ||
846 | uflags |= FS_QUOTA_PDQ_ACCT; | ||
840 | if (flags & XFS_UQUOTA_ENFD) | 847 | if (flags & XFS_UQUOTA_ENFD) |
841 | uflags |= FS_QUOTA_UDQ_ENFD; | 848 | uflags |= FS_QUOTA_UDQ_ENFD; |
842 | if (flags & (XFS_OQUOTA_ENFD)) { | 849 | if (flags & XFS_GQUOTA_ENFD) |
843 | uflags |= (flags & XFS_GQUOTA_ACCT) ? | 850 | uflags |= FS_QUOTA_GDQ_ENFD; |
844 | FS_QUOTA_GDQ_ENFD : FS_QUOTA_PDQ_ENFD; | 851 | if (flags & XFS_PQUOTA_ENFD) |
845 | } | 852 | uflags |= FS_QUOTA_PDQ_ENFD; |
846 | return (uflags); | 853 | return (uflags); |
847 | } | 854 | } |
848 | 855 | ||
@@ -856,9 +863,11 @@ xfs_dqrele_inode( | |||
856 | { | 863 | { |
857 | /* skip quota inodes */ | 864 | /* skip quota inodes */ |
858 | if (ip == ip->i_mount->m_quotainfo->qi_uquotaip || | 865 | if (ip == ip->i_mount->m_quotainfo->qi_uquotaip || |
859 | ip == ip->i_mount->m_quotainfo->qi_gquotaip) { | 866 | ip == ip->i_mount->m_quotainfo->qi_gquotaip || |
867 | ip == ip->i_mount->m_quotainfo->qi_pquotaip) { | ||
860 | ASSERT(ip->i_udquot == NULL); | 868 | ASSERT(ip->i_udquot == NULL); |
861 | ASSERT(ip->i_gdquot == NULL); | 869 | ASSERT(ip->i_gdquot == NULL); |
870 | ASSERT(ip->i_pdquot == NULL); | ||
862 | return 0; | 871 | return 0; |
863 | } | 872 | } |
864 | 873 | ||
@@ -867,10 +876,14 @@ xfs_dqrele_inode( | |||
867 | xfs_qm_dqrele(ip->i_udquot); | 876 | xfs_qm_dqrele(ip->i_udquot); |
868 | ip->i_udquot = NULL; | 877 | ip->i_udquot = NULL; |
869 | } | 878 | } |
870 | if (flags & (XFS_PQUOTA_ACCT|XFS_GQUOTA_ACCT) && ip->i_gdquot) { | 879 | if ((flags & XFS_GQUOTA_ACCT) && ip->i_gdquot) { |
871 | xfs_qm_dqrele(ip->i_gdquot); | 880 | xfs_qm_dqrele(ip->i_gdquot); |
872 | ip->i_gdquot = NULL; | 881 | ip->i_gdquot = NULL; |
873 | } | 882 | } |
883 | if ((flags & XFS_PQUOTA_ACCT) && ip->i_pdquot) { | ||
884 | xfs_qm_dqrele(ip->i_pdquot); | ||
885 | ip->i_pdquot = NULL; | ||
886 | } | ||
874 | xfs_iunlock(ip, XFS_ILOCK_EXCL); | 887 | xfs_iunlock(ip, XFS_ILOCK_EXCL); |
875 | return 0; | 888 | return 0; |
876 | } | 889 | } |
diff --git a/fs/xfs/xfs_quota.h b/fs/xfs/xfs_quota.h index c38068f26c55..b14f42c714b6 100644 --- a/fs/xfs/xfs_quota.h +++ b/fs/xfs/xfs_quota.h | |||
@@ -108,11 +108,28 @@ typedef struct xfs_dqblk { | |||
108 | { XFS_DQ_FREEING, "FREEING" } | 108 | { XFS_DQ_FREEING, "FREEING" } |
109 | 109 | ||
110 | /* | 110 | /* |
111 | * In the worst case, when both user and group quotas are on, | 111 | * We have the possibility of all three quota types being active at once, and |
112 | * we can have a max of three dquots changing in a single transaction. | 112 | * hence free space modification requires modification of all three current |
113 | * dquots in a single transaction. For this case we need to have a reservation | ||
114 | * of at least 3 dquots. | ||
115 | * | ||
116 | * However, a chmod operation can change both UID and GID in a single | ||
117 | * transaction, resulting in requiring {old, new} x {uid, gid} dquots to be | ||
118 | * modified. Hence for this case we need to reserve space for at least 4 dquots. | ||
119 | * | ||
120 | * And in the worst case, there's a rename operation that can be modifying up to | ||
121 | * 4 inodes with dquots attached to them. In reality, the only inodes that can | ||
122 | * have their dquots modified are the source and destination directory inodes | ||
123 | * due to directory name creation and removal. That can require space allocation | ||
124 | * and/or freeing on both directory inodes, and hence all three dquots on each | ||
125 | * inode can be modified. And if the directories are world writeable, all the | ||
126 | * dquots can be unique and so 6 dquots can be modified.... | ||
127 | * | ||
128 | * And, of course, we also need to take into account the dquot log format item | ||
129 | * used to describe each dquot. | ||
113 | */ | 130 | */ |
114 | #define XFS_DQUOT_LOGRES(mp) (sizeof(xfs_disk_dquot_t) * 3) | 131 | #define XFS_DQUOT_LOGRES(mp) \ |
115 | 132 | ((sizeof(struct xfs_dq_logformat) + sizeof(struct xfs_disk_dquot)) * 6) | |
116 | 133 | ||
117 | /* | 134 | /* |
118 | * These are the structures used to lay out dquots and quotaoff | 135 | * These are the structures used to lay out dquots and quotaoff |
@@ -161,30 +178,42 @@ typedef struct xfs_qoff_logformat { | |||
161 | #define XFS_GQUOTA_ACCT 0x0040 /* group quota accounting ON */ | 178 | #define XFS_GQUOTA_ACCT 0x0040 /* group quota accounting ON */ |
162 | 179 | ||
163 | /* | 180 | /* |
181 | * Conversion to and from the combined OQUOTA flag (if necessary) | ||
182 | * is done only in xfs_sb_qflags_to_disk() and xfs_sb_qflags_from_disk() | ||
183 | */ | ||
184 | #define XFS_GQUOTA_ENFD 0x0080 /* group quota limits enforced */ | ||
185 | #define XFS_GQUOTA_CHKD 0x0100 /* quotacheck run on group quotas */ | ||
186 | #define XFS_PQUOTA_ENFD 0x0200 /* project quota limits enforced */ | ||
187 | #define XFS_PQUOTA_CHKD 0x0400 /* quotacheck run on project quotas */ | ||
188 | |||
189 | /* | ||
164 | * Quota Accounting/Enforcement flags | 190 | * Quota Accounting/Enforcement flags |
165 | */ | 191 | */ |
166 | #define XFS_ALL_QUOTA_ACCT \ | 192 | #define XFS_ALL_QUOTA_ACCT \ |
167 | (XFS_UQUOTA_ACCT | XFS_GQUOTA_ACCT | XFS_PQUOTA_ACCT) | 193 | (XFS_UQUOTA_ACCT | XFS_GQUOTA_ACCT | XFS_PQUOTA_ACCT) |
168 | #define XFS_ALL_QUOTA_ENFD (XFS_UQUOTA_ENFD | XFS_OQUOTA_ENFD) | 194 | #define XFS_ALL_QUOTA_ENFD \ |
169 | #define XFS_ALL_QUOTA_CHKD (XFS_UQUOTA_CHKD | XFS_OQUOTA_CHKD) | 195 | (XFS_UQUOTA_ENFD | XFS_GQUOTA_ENFD | XFS_PQUOTA_ENFD) |
196 | #define XFS_ALL_QUOTA_CHKD \ | ||
197 | (XFS_UQUOTA_CHKD | XFS_GQUOTA_CHKD | XFS_PQUOTA_CHKD) | ||
170 | 198 | ||
171 | #define XFS_IS_QUOTA_RUNNING(mp) ((mp)->m_qflags & XFS_ALL_QUOTA_ACCT) | 199 | #define XFS_IS_QUOTA_RUNNING(mp) ((mp)->m_qflags & XFS_ALL_QUOTA_ACCT) |
172 | #define XFS_IS_UQUOTA_RUNNING(mp) ((mp)->m_qflags & XFS_UQUOTA_ACCT) | 200 | #define XFS_IS_UQUOTA_RUNNING(mp) ((mp)->m_qflags & XFS_UQUOTA_ACCT) |
173 | #define XFS_IS_PQUOTA_RUNNING(mp) ((mp)->m_qflags & XFS_PQUOTA_ACCT) | 201 | #define XFS_IS_PQUOTA_RUNNING(mp) ((mp)->m_qflags & XFS_PQUOTA_ACCT) |
174 | #define XFS_IS_GQUOTA_RUNNING(mp) ((mp)->m_qflags & XFS_GQUOTA_ACCT) | 202 | #define XFS_IS_GQUOTA_RUNNING(mp) ((mp)->m_qflags & XFS_GQUOTA_ACCT) |
175 | #define XFS_IS_UQUOTA_ENFORCED(mp) ((mp)->m_qflags & XFS_UQUOTA_ENFD) | 203 | #define XFS_IS_UQUOTA_ENFORCED(mp) ((mp)->m_qflags & XFS_UQUOTA_ENFD) |
176 | #define XFS_IS_OQUOTA_ENFORCED(mp) ((mp)->m_qflags & XFS_OQUOTA_ENFD) | 204 | #define XFS_IS_GQUOTA_ENFORCED(mp) ((mp)->m_qflags & XFS_GQUOTA_ENFD) |
205 | #define XFS_IS_PQUOTA_ENFORCED(mp) ((mp)->m_qflags & XFS_PQUOTA_ENFD) | ||
177 | 206 | ||
178 | /* | 207 | /* |
179 | * Incore only flags for quotaoff - these bits get cleared when quota(s) | 208 | * Incore only flags for quotaoff - these bits get cleared when quota(s) |
180 | * are in the process of getting turned off. These flags are in m_qflags but | 209 | * are in the process of getting turned off. These flags are in m_qflags but |
181 | * never in sb_qflags. | 210 | * never in sb_qflags. |
182 | */ | 211 | */ |
183 | #define XFS_UQUOTA_ACTIVE 0x0100 /* uquotas are being turned off */ | 212 | #define XFS_UQUOTA_ACTIVE 0x1000 /* uquotas are being turned off */ |
184 | #define XFS_PQUOTA_ACTIVE 0x0200 /* pquotas are being turned off */ | 213 | #define XFS_GQUOTA_ACTIVE 0x2000 /* gquotas are being turned off */ |
185 | #define XFS_GQUOTA_ACTIVE 0x0400 /* gquotas are being turned off */ | 214 | #define XFS_PQUOTA_ACTIVE 0x4000 /* pquotas are being turned off */ |
186 | #define XFS_ALL_QUOTA_ACTIVE \ | 215 | #define XFS_ALL_QUOTA_ACTIVE \ |
187 | (XFS_UQUOTA_ACTIVE | XFS_PQUOTA_ACTIVE | XFS_GQUOTA_ACTIVE) | 216 | (XFS_UQUOTA_ACTIVE | XFS_GQUOTA_ACTIVE | XFS_PQUOTA_ACTIVE) |
188 | 217 | ||
189 | /* | 218 | /* |
190 | * Checking XFS_IS_*QUOTA_ON() while holding any inode lock guarantees | 219 | * Checking XFS_IS_*QUOTA_ON() while holding any inode lock guarantees |
@@ -259,33 +288,24 @@ typedef struct xfs_qoff_logformat { | |||
259 | * we didn't have the inode locked, the appropriate dquot(s) will be | 288 | * we didn't have the inode locked, the appropriate dquot(s) will be |
260 | * attached atomically. | 289 | * attached atomically. |
261 | */ | 290 | */ |
262 | #define XFS_NOT_DQATTACHED(mp, ip) ((XFS_IS_UQUOTA_ON(mp) &&\ | 291 | #define XFS_NOT_DQATTACHED(mp, ip) \ |
263 | (ip)->i_udquot == NULL) || \ | 292 | ((XFS_IS_UQUOTA_ON(mp) && (ip)->i_udquot == NULL) || \ |
264 | (XFS_IS_OQUOTA_ON(mp) && \ | 293 | (XFS_IS_GQUOTA_ON(mp) && (ip)->i_gdquot == NULL) || \ |
265 | (ip)->i_gdquot == NULL)) | 294 | (XFS_IS_PQUOTA_ON(mp) && (ip)->i_pdquot == NULL)) |
266 | 295 | ||
267 | #define XFS_QM_NEED_QUOTACHECK(mp) \ | 296 | #define XFS_QM_NEED_QUOTACHECK(mp) \ |
268 | ((XFS_IS_UQUOTA_ON(mp) && \ | 297 | ((XFS_IS_UQUOTA_ON(mp) && \ |
269 | (mp->m_sb.sb_qflags & XFS_UQUOTA_CHKD) == 0) || \ | 298 | (mp->m_sb.sb_qflags & XFS_UQUOTA_CHKD) == 0) || \ |
270 | (XFS_IS_GQUOTA_ON(mp) && \ | 299 | (XFS_IS_GQUOTA_ON(mp) && \ |
271 | ((mp->m_sb.sb_qflags & XFS_OQUOTA_CHKD) == 0 || \ | 300 | (mp->m_sb.sb_qflags & XFS_GQUOTA_CHKD) == 0) || \ |
272 | (mp->m_sb.sb_qflags & XFS_PQUOTA_ACCT))) || \ | ||
273 | (XFS_IS_PQUOTA_ON(mp) && \ | 301 | (XFS_IS_PQUOTA_ON(mp) && \ |
274 | ((mp->m_sb.sb_qflags & XFS_OQUOTA_CHKD) == 0 || \ | 302 | (mp->m_sb.sb_qflags & XFS_PQUOTA_CHKD) == 0)) |
275 | (mp->m_sb.sb_qflags & XFS_GQUOTA_ACCT)))) | ||
276 | |||
277 | #define XFS_MOUNT_QUOTA_SET1 (XFS_UQUOTA_ACCT|XFS_UQUOTA_ENFD|\ | ||
278 | XFS_UQUOTA_CHKD|XFS_PQUOTA_ACCT|\ | ||
279 | XFS_OQUOTA_ENFD|XFS_OQUOTA_CHKD) | ||
280 | |||
281 | #define XFS_MOUNT_QUOTA_SET2 (XFS_UQUOTA_ACCT|XFS_UQUOTA_ENFD|\ | ||
282 | XFS_UQUOTA_CHKD|XFS_GQUOTA_ACCT|\ | ||
283 | XFS_OQUOTA_ENFD|XFS_OQUOTA_CHKD) | ||
284 | 303 | ||
285 | #define XFS_MOUNT_QUOTA_ALL (XFS_UQUOTA_ACCT|XFS_UQUOTA_ENFD|\ | 304 | #define XFS_MOUNT_QUOTA_ALL (XFS_UQUOTA_ACCT|XFS_UQUOTA_ENFD|\ |
286 | XFS_UQUOTA_CHKD|XFS_PQUOTA_ACCT|\ | 305 | XFS_UQUOTA_CHKD|XFS_GQUOTA_ACCT|\ |
287 | XFS_OQUOTA_ENFD|XFS_OQUOTA_CHKD|\ | 306 | XFS_GQUOTA_ENFD|XFS_GQUOTA_CHKD|\ |
288 | XFS_GQUOTA_ACCT) | 307 | XFS_PQUOTA_ACCT|XFS_PQUOTA_ENFD|\ |
308 | XFS_PQUOTA_CHKD) | ||
289 | 309 | ||
290 | 310 | ||
291 | /* | 311 | /* |
@@ -318,17 +338,18 @@ extern int xfs_trans_reserve_quota_nblks(struct xfs_trans *, | |||
318 | struct xfs_inode *, long, long, uint); | 338 | struct xfs_inode *, long, long, uint); |
319 | extern int xfs_trans_reserve_quota_bydquots(struct xfs_trans *, | 339 | extern int xfs_trans_reserve_quota_bydquots(struct xfs_trans *, |
320 | struct xfs_mount *, struct xfs_dquot *, | 340 | struct xfs_mount *, struct xfs_dquot *, |
321 | struct xfs_dquot *, long, long, uint); | 341 | struct xfs_dquot *, struct xfs_dquot *, long, long, uint); |
322 | 342 | ||
323 | extern int xfs_qm_vop_dqalloc(struct xfs_inode *, uid_t, gid_t, prid_t, uint, | 343 | extern int xfs_qm_vop_dqalloc(struct xfs_inode *, uid_t, gid_t, prid_t, uint, |
324 | struct xfs_dquot **, struct xfs_dquot **); | 344 | struct xfs_dquot **, struct xfs_dquot **, struct xfs_dquot **); |
325 | extern void xfs_qm_vop_create_dqattach(struct xfs_trans *, struct xfs_inode *, | 345 | extern void xfs_qm_vop_create_dqattach(struct xfs_trans *, struct xfs_inode *, |
326 | struct xfs_dquot *, struct xfs_dquot *); | 346 | struct xfs_dquot *, struct xfs_dquot *, struct xfs_dquot *); |
327 | extern int xfs_qm_vop_rename_dqattach(struct xfs_inode **); | 347 | extern int xfs_qm_vop_rename_dqattach(struct xfs_inode **); |
328 | extern struct xfs_dquot *xfs_qm_vop_chown(struct xfs_trans *, | 348 | extern struct xfs_dquot *xfs_qm_vop_chown(struct xfs_trans *, |
329 | struct xfs_inode *, struct xfs_dquot **, struct xfs_dquot *); | 349 | struct xfs_inode *, struct xfs_dquot **, struct xfs_dquot *); |
330 | extern int xfs_qm_vop_chown_reserve(struct xfs_trans *, struct xfs_inode *, | 350 | extern int xfs_qm_vop_chown_reserve(struct xfs_trans *, struct xfs_inode *, |
331 | struct xfs_dquot *, struct xfs_dquot *, uint); | 351 | struct xfs_dquot *, struct xfs_dquot *, |
352 | struct xfs_dquot *, uint); | ||
332 | extern int xfs_qm_dqattach(struct xfs_inode *, uint); | 353 | extern int xfs_qm_dqattach(struct xfs_inode *, uint); |
333 | extern int xfs_qm_dqattach_locked(struct xfs_inode *, uint); | 354 | extern int xfs_qm_dqattach_locked(struct xfs_inode *, uint); |
334 | extern void xfs_qm_dqdetach(struct xfs_inode *); | 355 | extern void xfs_qm_dqdetach(struct xfs_inode *); |
@@ -342,10 +363,12 @@ extern void xfs_qm_unmount_quotas(struct xfs_mount *); | |||
342 | #else | 363 | #else |
343 | static inline int | 364 | static inline int |
344 | xfs_qm_vop_dqalloc(struct xfs_inode *ip, uid_t uid, gid_t gid, prid_t prid, | 365 | xfs_qm_vop_dqalloc(struct xfs_inode *ip, uid_t uid, gid_t gid, prid_t prid, |
345 | uint flags, struct xfs_dquot **udqp, struct xfs_dquot **gdqp) | 366 | uint flags, struct xfs_dquot **udqp, struct xfs_dquot **gdqp, |
367 | struct xfs_dquot **pdqp) | ||
346 | { | 368 | { |
347 | *udqp = NULL; | 369 | *udqp = NULL; |
348 | *gdqp = NULL; | 370 | *gdqp = NULL; |
371 | *pdqp = NULL; | ||
349 | return 0; | 372 | return 0; |
350 | } | 373 | } |
351 | #define xfs_trans_dup_dqinfo(tp, tp2) | 374 | #define xfs_trans_dup_dqinfo(tp, tp2) |
@@ -360,14 +383,15 @@ static inline int xfs_trans_reserve_quota_nblks(struct xfs_trans *tp, | |||
360 | } | 383 | } |
361 | static inline int xfs_trans_reserve_quota_bydquots(struct xfs_trans *tp, | 384 | static inline int xfs_trans_reserve_quota_bydquots(struct xfs_trans *tp, |
362 | struct xfs_mount *mp, struct xfs_dquot *udqp, | 385 | struct xfs_mount *mp, struct xfs_dquot *udqp, |
363 | struct xfs_dquot *gdqp, long nblks, long nions, uint flags) | 386 | struct xfs_dquot *gdqp, struct xfs_dquot *pdqp, |
387 | long nblks, long nions, uint flags) | ||
364 | { | 388 | { |
365 | return 0; | 389 | return 0; |
366 | } | 390 | } |
367 | #define xfs_qm_vop_create_dqattach(tp, ip, u, g) | 391 | #define xfs_qm_vop_create_dqattach(tp, ip, u, g, p) |
368 | #define xfs_qm_vop_rename_dqattach(it) (0) | 392 | #define xfs_qm_vop_rename_dqattach(it) (0) |
369 | #define xfs_qm_vop_chown(tp, ip, old, new) (NULL) | 393 | #define xfs_qm_vop_chown(tp, ip, old, new) (NULL) |
370 | #define xfs_qm_vop_chown_reserve(tp, ip, u, g, fl) (0) | 394 | #define xfs_qm_vop_chown_reserve(tp, ip, u, g, p, fl) (0) |
371 | #define xfs_qm_dqattach(ip, fl) (0) | 395 | #define xfs_qm_dqattach(ip, fl) (0) |
372 | #define xfs_qm_dqattach_locked(ip, fl) (0) | 396 | #define xfs_qm_dqattach_locked(ip, fl) (0) |
373 | #define xfs_qm_dqdetach(ip) | 397 | #define xfs_qm_dqdetach(ip) |
@@ -381,8 +405,8 @@ static inline int xfs_trans_reserve_quota_bydquots(struct xfs_trans *tp, | |||
381 | 405 | ||
382 | #define xfs_trans_unreserve_quota_nblks(tp, ip, nblks, ninos, flags) \ | 406 | #define xfs_trans_unreserve_quota_nblks(tp, ip, nblks, ninos, flags) \ |
383 | xfs_trans_reserve_quota_nblks(tp, ip, -(nblks), -(ninos), flags) | 407 | xfs_trans_reserve_quota_nblks(tp, ip, -(nblks), -(ninos), flags) |
384 | #define xfs_trans_reserve_quota(tp, mp, ud, gd, nb, ni, f) \ | 408 | #define xfs_trans_reserve_quota(tp, mp, ud, gd, pd, nb, ni, f) \ |
385 | xfs_trans_reserve_quota_bydquots(tp, mp, ud, gd, nb, ni, \ | 409 | xfs_trans_reserve_quota_bydquots(tp, mp, ud, gd, pd, nb, ni, \ |
386 | f | XFS_QMOPT_RES_REGBLKS) | 410 | f | XFS_QMOPT_RES_REGBLKS) |
387 | 411 | ||
388 | extern int xfs_qm_dqcheck(struct xfs_mount *, xfs_disk_dquot_t *, | 412 | extern int xfs_qm_dqcheck(struct xfs_mount *, xfs_disk_dquot_t *, |
diff --git a/fs/xfs/xfs_quotaops.c b/fs/xfs/xfs_quotaops.c index 71926d630527..20e30f93b0c7 100644 --- a/fs/xfs/xfs_quotaops.c +++ b/fs/xfs/xfs_quotaops.c | |||
@@ -75,8 +75,10 @@ xfs_fs_set_xstate( | |||
75 | flags |= XFS_GQUOTA_ACCT; | 75 | flags |= XFS_GQUOTA_ACCT; |
76 | if (uflags & FS_QUOTA_UDQ_ENFD) | 76 | if (uflags & FS_QUOTA_UDQ_ENFD) |
77 | flags |= XFS_UQUOTA_ENFD; | 77 | flags |= XFS_UQUOTA_ENFD; |
78 | if (uflags & (FS_QUOTA_PDQ_ENFD|FS_QUOTA_GDQ_ENFD)) | 78 | if (uflags & FS_QUOTA_GDQ_ENFD) |
79 | flags |= XFS_OQUOTA_ENFD; | 79 | flags |= XFS_GQUOTA_ENFD; |
80 | if (uflags & FS_QUOTA_PDQ_ENFD) | ||
81 | flags |= XFS_PQUOTA_ENFD; | ||
80 | 82 | ||
81 | switch (op) { | 83 | switch (op) { |
82 | case Q_XQUOTAON: | 84 | case Q_XQUOTAON: |
diff --git a/fs/xfs/xfs_sb.h b/fs/xfs/xfs_sb.h index 2de58a85833c..78f9e70b80c7 100644 --- a/fs/xfs/xfs_sb.h +++ b/fs/xfs/xfs_sb.h | |||
@@ -618,6 +618,12 @@ xfs_sb_has_incompat_log_feature( | |||
618 | return (sbp->sb_features_log_incompat & feature) != 0; | 618 | return (sbp->sb_features_log_incompat & feature) != 0; |
619 | } | 619 | } |
620 | 620 | ||
621 | static inline bool | ||
622 | xfs_is_quota_inode(struct xfs_sb *sbp, xfs_ino_t ino) | ||
623 | { | ||
624 | return (ino == sbp->sb_uquotino || ino == sbp->sb_gquotino); | ||
625 | } | ||
626 | |||
621 | /* | 627 | /* |
622 | * end of superblock version macros | 628 | * end of superblock version macros |
623 | */ | 629 | */ |
diff --git a/fs/xfs/xfs_super.c b/fs/xfs/xfs_super.c index 3033ba5e9762..1d68ffcdeaa7 100644 --- a/fs/xfs/xfs_super.c +++ b/fs/xfs/xfs_super.c | |||
@@ -51,6 +51,7 @@ | |||
51 | #include "xfs_inode_item.h" | 51 | #include "xfs_inode_item.h" |
52 | #include "xfs_icache.h" | 52 | #include "xfs_icache.h" |
53 | #include "xfs_trace.h" | 53 | #include "xfs_trace.h" |
54 | #include "xfs_icreate_item.h" | ||
54 | 55 | ||
55 | #include <linux/namei.h> | 56 | #include <linux/namei.h> |
56 | #include <linux/init.h> | 57 | #include <linux/init.h> |
@@ -359,17 +360,17 @@ xfs_parseargs( | |||
359 | } else if (!strcmp(this_char, MNTOPT_PQUOTA) || | 360 | } else if (!strcmp(this_char, MNTOPT_PQUOTA) || |
360 | !strcmp(this_char, MNTOPT_PRJQUOTA)) { | 361 | !strcmp(this_char, MNTOPT_PRJQUOTA)) { |
361 | mp->m_qflags |= (XFS_PQUOTA_ACCT | XFS_PQUOTA_ACTIVE | | 362 | mp->m_qflags |= (XFS_PQUOTA_ACCT | XFS_PQUOTA_ACTIVE | |
362 | XFS_OQUOTA_ENFD); | 363 | XFS_PQUOTA_ENFD); |
363 | } else if (!strcmp(this_char, MNTOPT_PQUOTANOENF)) { | 364 | } else if (!strcmp(this_char, MNTOPT_PQUOTANOENF)) { |
364 | mp->m_qflags |= (XFS_PQUOTA_ACCT | XFS_PQUOTA_ACTIVE); | 365 | mp->m_qflags |= (XFS_PQUOTA_ACCT | XFS_PQUOTA_ACTIVE); |
365 | mp->m_qflags &= ~XFS_OQUOTA_ENFD; | 366 | mp->m_qflags &= ~XFS_PQUOTA_ENFD; |
366 | } else if (!strcmp(this_char, MNTOPT_GQUOTA) || | 367 | } else if (!strcmp(this_char, MNTOPT_GQUOTA) || |
367 | !strcmp(this_char, MNTOPT_GRPQUOTA)) { | 368 | !strcmp(this_char, MNTOPT_GRPQUOTA)) { |
368 | mp->m_qflags |= (XFS_GQUOTA_ACCT | XFS_GQUOTA_ACTIVE | | 369 | mp->m_qflags |= (XFS_GQUOTA_ACCT | XFS_GQUOTA_ACTIVE | |
369 | XFS_OQUOTA_ENFD); | 370 | XFS_GQUOTA_ENFD); |
370 | } else if (!strcmp(this_char, MNTOPT_GQUOTANOENF)) { | 371 | } else if (!strcmp(this_char, MNTOPT_GQUOTANOENF)) { |
371 | mp->m_qflags |= (XFS_GQUOTA_ACCT | XFS_GQUOTA_ACTIVE); | 372 | mp->m_qflags |= (XFS_GQUOTA_ACCT | XFS_GQUOTA_ACTIVE); |
372 | mp->m_qflags &= ~XFS_OQUOTA_ENFD; | 373 | mp->m_qflags &= ~XFS_GQUOTA_ENFD; |
373 | } else if (!strcmp(this_char, MNTOPT_DELAYLOG)) { | 374 | } else if (!strcmp(this_char, MNTOPT_DELAYLOG)) { |
374 | xfs_warn(mp, | 375 | xfs_warn(mp, |
375 | "delaylog is the default now, option is deprecated."); | 376 | "delaylog is the default now, option is deprecated."); |
@@ -439,20 +440,15 @@ xfs_parseargs( | |||
439 | } | 440 | } |
440 | 441 | ||
441 | done: | 442 | done: |
442 | if (!(mp->m_flags & XFS_MOUNT_NOALIGN)) { | 443 | if (dsunit && !(mp->m_flags & XFS_MOUNT_NOALIGN)) { |
443 | /* | 444 | /* |
444 | * At this point the superblock has not been read | 445 | * At this point the superblock has not been read |
445 | * in, therefore we do not know the block size. | 446 | * in, therefore we do not know the block size. |
446 | * Before the mount call ends we will convert | 447 | * Before the mount call ends we will convert |
447 | * these to FSBs. | 448 | * these to FSBs. |
448 | */ | 449 | */ |
449 | if (dsunit) { | 450 | mp->m_dalign = dsunit; |
450 | mp->m_dalign = dsunit; | 451 | mp->m_swidth = dswidth; |
451 | mp->m_flags |= XFS_MOUNT_RETERR; | ||
452 | } | ||
453 | |||
454 | if (dswidth) | ||
455 | mp->m_swidth = dswidth; | ||
456 | } | 452 | } |
457 | 453 | ||
458 | if (mp->m_logbufs != -1 && | 454 | if (mp->m_logbufs != -1 && |
@@ -563,12 +559,12 @@ xfs_showargs( | |||
563 | /* Either project or group quotas can be active, not both */ | 559 | /* Either project or group quotas can be active, not both */ |
564 | 560 | ||
565 | if (mp->m_qflags & XFS_PQUOTA_ACCT) { | 561 | if (mp->m_qflags & XFS_PQUOTA_ACCT) { |
566 | if (mp->m_qflags & XFS_OQUOTA_ENFD) | 562 | if (mp->m_qflags & XFS_PQUOTA_ENFD) |
567 | seq_puts(m, "," MNTOPT_PRJQUOTA); | 563 | seq_puts(m, "," MNTOPT_PRJQUOTA); |
568 | else | 564 | else |
569 | seq_puts(m, "," MNTOPT_PQUOTANOENF); | 565 | seq_puts(m, "," MNTOPT_PQUOTANOENF); |
570 | } else if (mp->m_qflags & XFS_GQUOTA_ACCT) { | 566 | } else if (mp->m_qflags & XFS_GQUOTA_ACCT) { |
571 | if (mp->m_qflags & XFS_OQUOTA_ENFD) | 567 | if (mp->m_qflags & XFS_GQUOTA_ENFD) |
572 | seq_puts(m, "," MNTOPT_GRPQUOTA); | 568 | seq_puts(m, "," MNTOPT_GRPQUOTA); |
573 | else | 569 | else |
574 | seq_puts(m, "," MNTOPT_GQUOTANOENF); | 570 | seq_puts(m, "," MNTOPT_GQUOTANOENF); |
@@ -1136,8 +1132,8 @@ xfs_fs_statfs( | |||
1136 | spin_unlock(&mp->m_sb_lock); | 1132 | spin_unlock(&mp->m_sb_lock); |
1137 | 1133 | ||
1138 | if ((ip->i_d.di_flags & XFS_DIFLAG_PROJINHERIT) && | 1134 | if ((ip->i_d.di_flags & XFS_DIFLAG_PROJINHERIT) && |
1139 | ((mp->m_qflags & (XFS_PQUOTA_ACCT|XFS_OQUOTA_ENFD))) == | 1135 | ((mp->m_qflags & (XFS_PQUOTA_ACCT|XFS_PQUOTA_ENFD))) == |
1140 | (XFS_PQUOTA_ACCT|XFS_OQUOTA_ENFD)) | 1136 | (XFS_PQUOTA_ACCT|XFS_PQUOTA_ENFD)) |
1141 | xfs_qm_statvfs(ip, statp); | 1137 | xfs_qm_statvfs(ip, statp); |
1142 | return 0; | 1138 | return 0; |
1143 | } | 1139 | } |
@@ -1481,6 +1477,10 @@ xfs_fs_fill_super( | |||
1481 | sb->s_time_gran = 1; | 1477 | sb->s_time_gran = 1; |
1482 | set_posix_acl_flag(sb); | 1478 | set_posix_acl_flag(sb); |
1483 | 1479 | ||
1480 | /* version 5 superblocks support inode version counters. */ | ||
1481 | if (XFS_SB_VERSION_NUM(&mp->m_sb) == XFS_SB_VERSION_5) | ||
1482 | sb->s_flags |= MS_I_VERSION; | ||
1483 | |||
1484 | error = xfs_mountfs(mp); | 1484 | error = xfs_mountfs(mp); |
1485 | if (error) | 1485 | if (error) |
1486 | goto out_filestream_unmount; | 1486 | goto out_filestream_unmount; |
@@ -1655,9 +1655,15 @@ xfs_init_zones(void) | |||
1655 | KM_ZONE_SPREAD, NULL); | 1655 | KM_ZONE_SPREAD, NULL); |
1656 | if (!xfs_ili_zone) | 1656 | if (!xfs_ili_zone) |
1657 | goto out_destroy_inode_zone; | 1657 | goto out_destroy_inode_zone; |
1658 | xfs_icreate_zone = kmem_zone_init(sizeof(struct xfs_icreate_item), | ||
1659 | "xfs_icr"); | ||
1660 | if (!xfs_icreate_zone) | ||
1661 | goto out_destroy_ili_zone; | ||
1658 | 1662 | ||
1659 | return 0; | 1663 | return 0; |
1660 | 1664 | ||
1665 | out_destroy_ili_zone: | ||
1666 | kmem_zone_destroy(xfs_ili_zone); | ||
1661 | out_destroy_inode_zone: | 1667 | out_destroy_inode_zone: |
1662 | kmem_zone_destroy(xfs_inode_zone); | 1668 | kmem_zone_destroy(xfs_inode_zone); |
1663 | out_destroy_efi_zone: | 1669 | out_destroy_efi_zone: |
@@ -1696,6 +1702,7 @@ xfs_destroy_zones(void) | |||
1696 | * destroy caches. | 1702 | * destroy caches. |
1697 | */ | 1703 | */ |
1698 | rcu_barrier(); | 1704 | rcu_barrier(); |
1705 | kmem_zone_destroy(xfs_icreate_zone); | ||
1699 | kmem_zone_destroy(xfs_ili_zone); | 1706 | kmem_zone_destroy(xfs_ili_zone); |
1700 | kmem_zone_destroy(xfs_inode_zone); | 1707 | kmem_zone_destroy(xfs_inode_zone); |
1701 | kmem_zone_destroy(xfs_efi_zone); | 1708 | kmem_zone_destroy(xfs_efi_zone); |
diff --git a/fs/xfs/xfs_symlink.c b/fs/xfs/xfs_symlink.c index 195a403e1522..f4895b662fcb 100644 --- a/fs/xfs/xfs_symlink.c +++ b/fs/xfs/xfs_symlink.c | |||
@@ -358,7 +358,9 @@ xfs_symlink( | |||
358 | int n; | 358 | int n; |
359 | xfs_buf_t *bp; | 359 | xfs_buf_t *bp; |
360 | prid_t prid; | 360 | prid_t prid; |
361 | struct xfs_dquot *udqp, *gdqp; | 361 | struct xfs_dquot *udqp = NULL; |
362 | struct xfs_dquot *gdqp = NULL; | ||
363 | struct xfs_dquot *pdqp = NULL; | ||
362 | uint resblks; | 364 | uint resblks; |
363 | 365 | ||
364 | *ipp = NULL; | 366 | *ipp = NULL; |
@@ -385,7 +387,7 @@ xfs_symlink( | |||
385 | * Make sure that we have allocated dquot(s) on disk. | 387 | * Make sure that we have allocated dquot(s) on disk. |
386 | */ | 388 | */ |
387 | error = xfs_qm_vop_dqalloc(dp, current_fsuid(), current_fsgid(), prid, | 389 | error = xfs_qm_vop_dqalloc(dp, current_fsuid(), current_fsgid(), prid, |
388 | XFS_QMOPT_QUOTALL | XFS_QMOPT_INHERIT, &udqp, &gdqp); | 390 | XFS_QMOPT_QUOTALL | XFS_QMOPT_INHERIT, &udqp, &gdqp, &pdqp); |
389 | if (error) | 391 | if (error) |
390 | goto std_return; | 392 | goto std_return; |
391 | 393 | ||
@@ -426,7 +428,8 @@ xfs_symlink( | |||
426 | /* | 428 | /* |
427 | * Reserve disk quota : blocks and inode. | 429 | * Reserve disk quota : blocks and inode. |
428 | */ | 430 | */ |
429 | error = xfs_trans_reserve_quota(tp, mp, udqp, gdqp, resblks, 1, 0); | 431 | error = xfs_trans_reserve_quota(tp, mp, udqp, gdqp, |
432 | pdqp, resblks, 1, 0); | ||
430 | if (error) | 433 | if (error) |
431 | goto error_return; | 434 | goto error_return; |
432 | 435 | ||
@@ -464,7 +467,7 @@ xfs_symlink( | |||
464 | /* | 467 | /* |
465 | * Also attach the dquot(s) to it, if applicable. | 468 | * Also attach the dquot(s) to it, if applicable. |
466 | */ | 469 | */ |
467 | xfs_qm_vop_create_dqattach(tp, ip, udqp, gdqp); | 470 | xfs_qm_vop_create_dqattach(tp, ip, udqp, gdqp, pdqp); |
468 | 471 | ||
469 | if (resblks) | 472 | if (resblks) |
470 | resblks -= XFS_IALLOC_SPACE_RES(mp); | 473 | resblks -= XFS_IALLOC_SPACE_RES(mp); |
@@ -562,6 +565,7 @@ xfs_symlink( | |||
562 | error = xfs_trans_commit(tp, XFS_TRANS_RELEASE_LOG_RES); | 565 | error = xfs_trans_commit(tp, XFS_TRANS_RELEASE_LOG_RES); |
563 | xfs_qm_dqrele(udqp); | 566 | xfs_qm_dqrele(udqp); |
564 | xfs_qm_dqrele(gdqp); | 567 | xfs_qm_dqrele(gdqp); |
568 | xfs_qm_dqrele(pdqp); | ||
565 | 569 | ||
566 | *ipp = ip; | 570 | *ipp = ip; |
567 | return 0; | 571 | return 0; |
@@ -575,6 +579,7 @@ xfs_symlink( | |||
575 | xfs_trans_cancel(tp, cancel_flags); | 579 | xfs_trans_cancel(tp, cancel_flags); |
576 | xfs_qm_dqrele(udqp); | 580 | xfs_qm_dqrele(udqp); |
577 | xfs_qm_dqrele(gdqp); | 581 | xfs_qm_dqrele(gdqp); |
582 | xfs_qm_dqrele(pdqp); | ||
578 | 583 | ||
579 | if (unlock_dp_on_error) | 584 | if (unlock_dp_on_error) |
580 | xfs_iunlock(dp, XFS_ILOCK_EXCL); | 585 | xfs_iunlock(dp, XFS_ILOCK_EXCL); |
@@ -585,7 +590,7 @@ xfs_symlink( | |||
585 | /* | 590 | /* |
586 | * Free a symlink that has blocks associated with it. | 591 | * Free a symlink that has blocks associated with it. |
587 | */ | 592 | */ |
588 | int | 593 | STATIC int |
589 | xfs_inactive_symlink_rmt( | 594 | xfs_inactive_symlink_rmt( |
590 | xfs_inode_t *ip, | 595 | xfs_inode_t *ip, |
591 | xfs_trans_t **tpp) | 596 | xfs_trans_t **tpp) |
@@ -606,7 +611,7 @@ xfs_inactive_symlink_rmt( | |||
606 | 611 | ||
607 | tp = *tpp; | 612 | tp = *tpp; |
608 | mp = ip->i_mount; | 613 | mp = ip->i_mount; |
609 | ASSERT(ip->i_d.di_size > XFS_IFORK_DSIZE(ip)); | 614 | ASSERT(ip->i_df.if_flags & XFS_IFEXTENTS); |
610 | /* | 615 | /* |
611 | * We're freeing a symlink that has some | 616 | * We're freeing a symlink that has some |
612 | * blocks allocated to it. Free the | 617 | * blocks allocated to it. Free the |
@@ -720,3 +725,47 @@ xfs_inactive_symlink_rmt( | |||
720 | error0: | 725 | error0: |
721 | return error; | 726 | return error; |
722 | } | 727 | } |
728 | |||
729 | /* | ||
730 | * xfs_inactive_symlink - free a symlink | ||
731 | */ | ||
732 | int | ||
733 | xfs_inactive_symlink( | ||
734 | struct xfs_inode *ip, | ||
735 | struct xfs_trans **tp) | ||
736 | { | ||
737 | struct xfs_mount *mp = ip->i_mount; | ||
738 | int pathlen; | ||
739 | |||
740 | trace_xfs_inactive_symlink(ip); | ||
741 | |||
742 | ASSERT(xfs_isilocked(ip, XFS_ILOCK_EXCL)); | ||
743 | |||
744 | if (XFS_FORCED_SHUTDOWN(mp)) | ||
745 | return XFS_ERROR(EIO); | ||
746 | |||
747 | /* | ||
748 | * Zero length symlinks _can_ exist. | ||
749 | */ | ||
750 | pathlen = (int)ip->i_d.di_size; | ||
751 | if (!pathlen) | ||
752 | return 0; | ||
753 | |||
754 | if (pathlen < 0 || pathlen > MAXPATHLEN) { | ||
755 | xfs_alert(mp, "%s: inode (0x%llx) bad symlink length (%d)", | ||
756 | __func__, (unsigned long long)ip->i_ino, pathlen); | ||
757 | ASSERT(0); | ||
758 | return XFS_ERROR(EFSCORRUPTED); | ||
759 | } | ||
760 | |||
761 | if (ip->i_df.if_flags & XFS_IFINLINE) { | ||
762 | if (ip->i_df.if_bytes > 0) | ||
763 | xfs_idata_realloc(ip, -(ip->i_df.if_bytes), | ||
764 | XFS_DATA_FORK); | ||
765 | ASSERT(ip->i_df.if_bytes == 0); | ||
766 | return 0; | ||
767 | } | ||
768 | |||
769 | /* remove the remote symlink */ | ||
770 | return xfs_inactive_symlink_rmt(ip, tp); | ||
771 | } | ||
diff --git a/fs/xfs/xfs_symlink.h b/fs/xfs/xfs_symlink.h index b39398d2097c..374394880c01 100644 --- a/fs/xfs/xfs_symlink.h +++ b/fs/xfs/xfs_symlink.h | |||
@@ -60,7 +60,7 @@ extern const struct xfs_buf_ops xfs_symlink_buf_ops; | |||
60 | int xfs_symlink(struct xfs_inode *dp, struct xfs_name *link_name, | 60 | int xfs_symlink(struct xfs_inode *dp, struct xfs_name *link_name, |
61 | const char *target_path, umode_t mode, struct xfs_inode **ipp); | 61 | const char *target_path, umode_t mode, struct xfs_inode **ipp); |
62 | int xfs_readlink(struct xfs_inode *ip, char *link); | 62 | int xfs_readlink(struct xfs_inode *ip, char *link); |
63 | int xfs_inactive_symlink_rmt(struct xfs_inode *ip, struct xfs_trans **tpp); | 63 | int xfs_inactive_symlink(struct xfs_inode *ip, struct xfs_trans **tpp); |
64 | 64 | ||
65 | #endif /* __KERNEL__ */ | 65 | #endif /* __KERNEL__ */ |
66 | #endif /* __XFS_SYMLINK_H */ | 66 | #endif /* __XFS_SYMLINK_H */ |
diff --git a/fs/xfs/xfs_sysctl.c b/fs/xfs/xfs_sysctl.c index 2801b5ce6cdb..1743b9f8e23d 100644 --- a/fs/xfs/xfs_sysctl.c +++ b/fs/xfs/xfs_sysctl.c | |||
@@ -25,11 +25,11 @@ static struct ctl_table_header *xfs_table_header; | |||
25 | #ifdef CONFIG_PROC_FS | 25 | #ifdef CONFIG_PROC_FS |
26 | STATIC int | 26 | STATIC int |
27 | xfs_stats_clear_proc_handler( | 27 | xfs_stats_clear_proc_handler( |
28 | ctl_table *ctl, | 28 | struct ctl_table *ctl, |
29 | int write, | 29 | int write, |
30 | void __user *buffer, | 30 | void __user *buffer, |
31 | size_t *lenp, | 31 | size_t *lenp, |
32 | loff_t *ppos) | 32 | loff_t *ppos) |
33 | { | 33 | { |
34 | int c, ret, *valp = ctl->data; | 34 | int c, ret, *valp = ctl->data; |
35 | __uint32_t vn_active; | 35 | __uint32_t vn_active; |
@@ -55,11 +55,11 @@ xfs_stats_clear_proc_handler( | |||
55 | 55 | ||
56 | STATIC int | 56 | STATIC int |
57 | xfs_panic_mask_proc_handler( | 57 | xfs_panic_mask_proc_handler( |
58 | ctl_table *ctl, | 58 | struct ctl_table *ctl, |
59 | int write, | 59 | int write, |
60 | void __user *buffer, | 60 | void __user *buffer, |
61 | size_t *lenp, | 61 | size_t *lenp, |
62 | loff_t *ppos) | 62 | loff_t *ppos) |
63 | { | 63 | { |
64 | int ret, *valp = ctl->data; | 64 | int ret, *valp = ctl->data; |
65 | 65 | ||
@@ -74,7 +74,7 @@ xfs_panic_mask_proc_handler( | |||
74 | } | 74 | } |
75 | #endif /* CONFIG_PROC_FS */ | 75 | #endif /* CONFIG_PROC_FS */ |
76 | 76 | ||
77 | static ctl_table xfs_table[] = { | 77 | static struct ctl_table xfs_table[] = { |
78 | { | 78 | { |
79 | .procname = "irix_sgid_inherit", | 79 | .procname = "irix_sgid_inherit", |
80 | .data = &xfs_params.sgid_inherit.val, | 80 | .data = &xfs_params.sgid_inherit.val, |
@@ -227,7 +227,7 @@ static ctl_table xfs_table[] = { | |||
227 | {} | 227 | {} |
228 | }; | 228 | }; |
229 | 229 | ||
230 | static ctl_table xfs_dir_table[] = { | 230 | static struct ctl_table xfs_dir_table[] = { |
231 | { | 231 | { |
232 | .procname = "xfs", | 232 | .procname = "xfs", |
233 | .mode = 0555, | 233 | .mode = 0555, |
@@ -236,7 +236,7 @@ static ctl_table xfs_dir_table[] = { | |||
236 | {} | 236 | {} |
237 | }; | 237 | }; |
238 | 238 | ||
239 | static ctl_table xfs_root_table[] = { | 239 | static struct ctl_table xfs_root_table[] = { |
240 | { | 240 | { |
241 | .procname = "fs", | 241 | .procname = "fs", |
242 | .mode = 0555, | 242 | .mode = 0555, |
diff --git a/fs/xfs/xfs_trace.h b/fs/xfs/xfs_trace.h index aa4db3307d36..47910e638c18 100644 --- a/fs/xfs/xfs_trace.h +++ b/fs/xfs/xfs_trace.h | |||
@@ -486,9 +486,12 @@ DEFINE_EVENT(xfs_buf_item_class, name, \ | |||
486 | TP_PROTO(struct xfs_buf_log_item *bip), \ | 486 | TP_PROTO(struct xfs_buf_log_item *bip), \ |
487 | TP_ARGS(bip)) | 487 | TP_ARGS(bip)) |
488 | DEFINE_BUF_ITEM_EVENT(xfs_buf_item_size); | 488 | DEFINE_BUF_ITEM_EVENT(xfs_buf_item_size); |
489 | DEFINE_BUF_ITEM_EVENT(xfs_buf_item_size_ordered); | ||
489 | DEFINE_BUF_ITEM_EVENT(xfs_buf_item_size_stale); | 490 | DEFINE_BUF_ITEM_EVENT(xfs_buf_item_size_stale); |
490 | DEFINE_BUF_ITEM_EVENT(xfs_buf_item_format); | 491 | DEFINE_BUF_ITEM_EVENT(xfs_buf_item_format); |
492 | DEFINE_BUF_ITEM_EVENT(xfs_buf_item_format_ordered); | ||
491 | DEFINE_BUF_ITEM_EVENT(xfs_buf_item_format_stale); | 493 | DEFINE_BUF_ITEM_EVENT(xfs_buf_item_format_stale); |
494 | DEFINE_BUF_ITEM_EVENT(xfs_buf_item_ordered); | ||
492 | DEFINE_BUF_ITEM_EVENT(xfs_buf_item_pin); | 495 | DEFINE_BUF_ITEM_EVENT(xfs_buf_item_pin); |
493 | DEFINE_BUF_ITEM_EVENT(xfs_buf_item_unpin); | 496 | DEFINE_BUF_ITEM_EVENT(xfs_buf_item_unpin); |
494 | DEFINE_BUF_ITEM_EVENT(xfs_buf_item_unpin_stale); | 497 | DEFINE_BUF_ITEM_EVENT(xfs_buf_item_unpin_stale); |
@@ -508,6 +511,7 @@ DEFINE_BUF_ITEM_EVENT(xfs_trans_bjoin); | |||
508 | DEFINE_BUF_ITEM_EVENT(xfs_trans_bhold); | 511 | DEFINE_BUF_ITEM_EVENT(xfs_trans_bhold); |
509 | DEFINE_BUF_ITEM_EVENT(xfs_trans_bhold_release); | 512 | DEFINE_BUF_ITEM_EVENT(xfs_trans_bhold_release); |
510 | DEFINE_BUF_ITEM_EVENT(xfs_trans_binval); | 513 | DEFINE_BUF_ITEM_EVENT(xfs_trans_binval); |
514 | DEFINE_BUF_ITEM_EVENT(xfs_trans_buf_ordered); | ||
511 | 515 | ||
512 | DECLARE_EVENT_CLASS(xfs_lock_class, | 516 | DECLARE_EVENT_CLASS(xfs_lock_class, |
513 | TP_PROTO(struct xfs_inode *ip, unsigned lock_flags, | 517 | TP_PROTO(struct xfs_inode *ip, unsigned lock_flags, |
@@ -571,6 +575,7 @@ DEFINE_INODE_EVENT(xfs_iget_miss); | |||
571 | DEFINE_INODE_EVENT(xfs_getattr); | 575 | DEFINE_INODE_EVENT(xfs_getattr); |
572 | DEFINE_INODE_EVENT(xfs_setattr); | 576 | DEFINE_INODE_EVENT(xfs_setattr); |
573 | DEFINE_INODE_EVENT(xfs_readlink); | 577 | DEFINE_INODE_EVENT(xfs_readlink); |
578 | DEFINE_INODE_EVENT(xfs_inactive_symlink); | ||
574 | DEFINE_INODE_EVENT(xfs_alloc_file_space); | 579 | DEFINE_INODE_EVENT(xfs_alloc_file_space); |
575 | DEFINE_INODE_EVENT(xfs_free_file_space); | 580 | DEFINE_INODE_EVENT(xfs_free_file_space); |
576 | DEFINE_INODE_EVENT(xfs_readdir); | 581 | DEFINE_INODE_EVENT(xfs_readdir); |
@@ -974,14 +979,16 @@ DEFINE_RW_EVENT(xfs_file_splice_read); | |||
974 | DEFINE_RW_EVENT(xfs_file_splice_write); | 979 | DEFINE_RW_EVENT(xfs_file_splice_write); |
975 | 980 | ||
976 | DECLARE_EVENT_CLASS(xfs_page_class, | 981 | DECLARE_EVENT_CLASS(xfs_page_class, |
977 | TP_PROTO(struct inode *inode, struct page *page, unsigned long off), | 982 | TP_PROTO(struct inode *inode, struct page *page, unsigned long off, |
978 | TP_ARGS(inode, page, off), | 983 | unsigned int len), |
984 | TP_ARGS(inode, page, off, len), | ||
979 | TP_STRUCT__entry( | 985 | TP_STRUCT__entry( |
980 | __field(dev_t, dev) | 986 | __field(dev_t, dev) |
981 | __field(xfs_ino_t, ino) | 987 | __field(xfs_ino_t, ino) |
982 | __field(pgoff_t, pgoff) | 988 | __field(pgoff_t, pgoff) |
983 | __field(loff_t, size) | 989 | __field(loff_t, size) |
984 | __field(unsigned long, offset) | 990 | __field(unsigned long, offset) |
991 | __field(unsigned int, length) | ||
985 | __field(int, delalloc) | 992 | __field(int, delalloc) |
986 | __field(int, unwritten) | 993 | __field(int, unwritten) |
987 | ), | 994 | ), |
@@ -995,24 +1002,27 @@ DECLARE_EVENT_CLASS(xfs_page_class, | |||
995 | __entry->pgoff = page_offset(page); | 1002 | __entry->pgoff = page_offset(page); |
996 | __entry->size = i_size_read(inode); | 1003 | __entry->size = i_size_read(inode); |
997 | __entry->offset = off; | 1004 | __entry->offset = off; |
1005 | __entry->length = len; | ||
998 | __entry->delalloc = delalloc; | 1006 | __entry->delalloc = delalloc; |
999 | __entry->unwritten = unwritten; | 1007 | __entry->unwritten = unwritten; |
1000 | ), | 1008 | ), |
1001 | TP_printk("dev %d:%d ino 0x%llx pgoff 0x%lx size 0x%llx offset %lx " | 1009 | TP_printk("dev %d:%d ino 0x%llx pgoff 0x%lx size 0x%llx offset %lx " |
1002 | "delalloc %d unwritten %d", | 1010 | "length %x delalloc %d unwritten %d", |
1003 | MAJOR(__entry->dev), MINOR(__entry->dev), | 1011 | MAJOR(__entry->dev), MINOR(__entry->dev), |
1004 | __entry->ino, | 1012 | __entry->ino, |
1005 | __entry->pgoff, | 1013 | __entry->pgoff, |
1006 | __entry->size, | 1014 | __entry->size, |
1007 | __entry->offset, | 1015 | __entry->offset, |
1016 | __entry->length, | ||
1008 | __entry->delalloc, | 1017 | __entry->delalloc, |
1009 | __entry->unwritten) | 1018 | __entry->unwritten) |
1010 | ) | 1019 | ) |
1011 | 1020 | ||
1012 | #define DEFINE_PAGE_EVENT(name) \ | 1021 | #define DEFINE_PAGE_EVENT(name) \ |
1013 | DEFINE_EVENT(xfs_page_class, name, \ | 1022 | DEFINE_EVENT(xfs_page_class, name, \ |
1014 | TP_PROTO(struct inode *inode, struct page *page, unsigned long off), \ | 1023 | TP_PROTO(struct inode *inode, struct page *page, unsigned long off, \ |
1015 | TP_ARGS(inode, page, off)) | 1024 | unsigned int len), \ |
1025 | TP_ARGS(inode, page, off, len)) | ||
1016 | DEFINE_PAGE_EVENT(xfs_writepage); | 1026 | DEFINE_PAGE_EVENT(xfs_writepage); |
1017 | DEFINE_PAGE_EVENT(xfs_releasepage); | 1027 | DEFINE_PAGE_EVENT(xfs_releasepage); |
1018 | DEFINE_PAGE_EVENT(xfs_invalidatepage); | 1028 | DEFINE_PAGE_EVENT(xfs_invalidatepage); |
diff --git a/fs/xfs/xfs_trans.c b/fs/xfs/xfs_trans.c index 2fd7c1ff1d21..35a229981354 100644 --- a/fs/xfs/xfs_trans.c +++ b/fs/xfs/xfs_trans.c | |||
@@ -234,71 +234,93 @@ xfs_calc_remove_reservation( | |||
234 | } | 234 | } |
235 | 235 | ||
236 | /* | 236 | /* |
237 | * For symlink we can modify: | 237 | * For create, break it in to the two cases that the transaction |
238 | * covers. We start with the modify case - allocation done by modification | ||
239 | * of the state of existing inodes - and the allocation case. | ||
240 | */ | ||
241 | |||
242 | /* | ||
243 | * For create we can modify: | ||
238 | * the parent directory inode: inode size | 244 | * the parent directory inode: inode size |
239 | * the new inode: inode size | 245 | * the new inode: inode size |
240 | * the inode btree entry: 1 block | 246 | * the inode btree entry: block size |
247 | * the superblock for the nlink flag: sector size | ||
241 | * the directory btree: (max depth + v2) * dir block size | 248 | * the directory btree: (max depth + v2) * dir block size |
242 | * the directory inode's bmap btree: (max depth + v2) * block size | 249 | * the directory inode's bmap btree: (max depth + v2) * block size |
243 | * the blocks for the symlink: 1 kB | 250 | */ |
244 | * Or in the first xact we allocate some inodes giving: | 251 | STATIC uint |
252 | xfs_calc_create_resv_modify( | ||
253 | struct xfs_mount *mp) | ||
254 | { | ||
255 | return xfs_calc_buf_res(2, mp->m_sb.sb_inodesize) + | ||
256 | xfs_calc_buf_res(1, mp->m_sb.sb_sectsize) + | ||
257 | (uint)XFS_FSB_TO_B(mp, 1) + | ||
258 | xfs_calc_buf_res(XFS_DIROP_LOG_COUNT(mp), XFS_FSB_TO_B(mp, 1)); | ||
259 | } | ||
260 | |||
261 | /* | ||
262 | * For create we can allocate some inodes giving: | ||
245 | * the agi and agf of the ag getting the new inodes: 2 * sectorsize | 263 | * the agi and agf of the ag getting the new inodes: 2 * sectorsize |
264 | * the superblock for the nlink flag: sector size | ||
246 | * the inode blocks allocated: XFS_IALLOC_BLOCKS * blocksize | 265 | * the inode blocks allocated: XFS_IALLOC_BLOCKS * blocksize |
247 | * the inode btree: max depth * blocksize | 266 | * the inode btree: max depth * blocksize |
248 | * the allocation btrees: 2 trees * (2 * max depth - 1) * block size | 267 | * the allocation btrees: 2 trees * (max depth - 1) * block size |
249 | */ | 268 | */ |
250 | STATIC uint | 269 | STATIC uint |
251 | xfs_calc_symlink_reservation( | 270 | xfs_calc_create_resv_alloc( |
271 | struct xfs_mount *mp) | ||
272 | { | ||
273 | return xfs_calc_buf_res(2, mp->m_sb.sb_sectsize) + | ||
274 | mp->m_sb.sb_sectsize + | ||
275 | xfs_calc_buf_res(XFS_IALLOC_BLOCKS(mp), XFS_FSB_TO_B(mp, 1)) + | ||
276 | xfs_calc_buf_res(mp->m_in_maxlevels, XFS_FSB_TO_B(mp, 1)) + | ||
277 | xfs_calc_buf_res(XFS_ALLOCFREE_LOG_COUNT(mp, 1), | ||
278 | XFS_FSB_TO_B(mp, 1)); | ||
279 | } | ||
280 | |||
281 | STATIC uint | ||
282 | __xfs_calc_create_reservation( | ||
252 | struct xfs_mount *mp) | 283 | struct xfs_mount *mp) |
253 | { | 284 | { |
254 | return XFS_DQUOT_LOGRES(mp) + | 285 | return XFS_DQUOT_LOGRES(mp) + |
255 | MAX((xfs_calc_buf_res(2, mp->m_sb.sb_inodesize) + | 286 | MAX(xfs_calc_create_resv_alloc(mp), |
256 | xfs_calc_buf_res(1, XFS_FSB_TO_B(mp, 1)) + | 287 | xfs_calc_create_resv_modify(mp)); |
257 | xfs_calc_buf_res(XFS_DIROP_LOG_COUNT(mp), | ||
258 | XFS_FSB_TO_B(mp, 1)) + | ||
259 | xfs_calc_buf_res(1, 1024)), | ||
260 | (xfs_calc_buf_res(2, mp->m_sb.sb_sectsize) + | ||
261 | xfs_calc_buf_res(XFS_IALLOC_BLOCKS(mp), | ||
262 | XFS_FSB_TO_B(mp, 1)) + | ||
263 | xfs_calc_buf_res(mp->m_in_maxlevels, | ||
264 | XFS_FSB_TO_B(mp, 1)) + | ||
265 | xfs_calc_buf_res(XFS_ALLOCFREE_LOG_COUNT(mp, 1), | ||
266 | XFS_FSB_TO_B(mp, 1)))); | ||
267 | } | 288 | } |
268 | 289 | ||
269 | /* | 290 | /* |
270 | * For create we can modify: | 291 | * For icreate we can allocate some inodes giving: |
271 | * the parent directory inode: inode size | ||
272 | * the new inode: inode size | ||
273 | * the inode btree entry: block size | ||
274 | * the superblock for the nlink flag: sector size | ||
275 | * the directory btree: (max depth + v2) * dir block size | ||
276 | * the directory inode's bmap btree: (max depth + v2) * block size | ||
277 | * Or in the first xact we allocate some inodes giving: | ||
278 | * the agi and agf of the ag getting the new inodes: 2 * sectorsize | 292 | * the agi and agf of the ag getting the new inodes: 2 * sectorsize |
279 | * the superblock for the nlink flag: sector size | 293 | * the superblock for the nlink flag: sector size |
280 | * the inode blocks allocated: XFS_IALLOC_BLOCKS * blocksize | ||
281 | * the inode btree: max depth * blocksize | 294 | * the inode btree: max depth * blocksize |
282 | * the allocation btrees: 2 trees * (max depth - 1) * block size | 295 | * the allocation btrees: 2 trees * (max depth - 1) * block size |
283 | */ | 296 | */ |
284 | STATIC uint | 297 | STATIC uint |
285 | xfs_calc_create_reservation( | 298 | xfs_calc_icreate_resv_alloc( |
286 | struct xfs_mount *mp) | 299 | struct xfs_mount *mp) |
287 | { | 300 | { |
301 | return xfs_calc_buf_res(2, mp->m_sb.sb_sectsize) + | ||
302 | mp->m_sb.sb_sectsize + | ||
303 | xfs_calc_buf_res(mp->m_in_maxlevels, XFS_FSB_TO_B(mp, 1)) + | ||
304 | xfs_calc_buf_res(XFS_ALLOCFREE_LOG_COUNT(mp, 1), | ||
305 | XFS_FSB_TO_B(mp, 1)); | ||
306 | } | ||
307 | |||
308 | STATIC uint | ||
309 | xfs_calc_icreate_reservation(xfs_mount_t *mp) | ||
310 | { | ||
288 | return XFS_DQUOT_LOGRES(mp) + | 311 | return XFS_DQUOT_LOGRES(mp) + |
289 | MAX((xfs_calc_buf_res(2, mp->m_sb.sb_inodesize) + | 312 | MAX(xfs_calc_icreate_resv_alloc(mp), |
290 | xfs_calc_buf_res(1, mp->m_sb.sb_sectsize) + | 313 | xfs_calc_create_resv_modify(mp)); |
291 | (uint)XFS_FSB_TO_B(mp, 1) + | 314 | } |
292 | xfs_calc_buf_res(XFS_DIROP_LOG_COUNT(mp), | 315 | |
293 | XFS_FSB_TO_B(mp, 1))), | 316 | STATIC uint |
294 | (xfs_calc_buf_res(2, mp->m_sb.sb_sectsize) + | 317 | xfs_calc_create_reservation( |
295 | mp->m_sb.sb_sectsize + | 318 | struct xfs_mount *mp) |
296 | xfs_calc_buf_res(XFS_IALLOC_BLOCKS(mp), | 319 | { |
297 | XFS_FSB_TO_B(mp, 1)) + | 320 | if (xfs_sb_version_hascrc(&mp->m_sb)) |
298 | xfs_calc_buf_res(mp->m_in_maxlevels, | 321 | return xfs_calc_icreate_reservation(mp); |
299 | XFS_FSB_TO_B(mp, 1)) + | 322 | return __xfs_calc_create_reservation(mp); |
300 | xfs_calc_buf_res(XFS_ALLOCFREE_LOG_COUNT(mp, 1), | 323 | |
301 | XFS_FSB_TO_B(mp, 1)))); | ||
302 | } | 324 | } |
303 | 325 | ||
304 | /* | 326 | /* |
@@ -311,6 +333,20 @@ xfs_calc_mkdir_reservation( | |||
311 | return xfs_calc_create_reservation(mp); | 333 | return xfs_calc_create_reservation(mp); |
312 | } | 334 | } |
313 | 335 | ||
336 | |||
337 | /* | ||
338 | * Making a new symplink is the same as creating a new file, but | ||
339 | * with the added blocks for remote symlink data which can be up to 1kB in | ||
340 | * length (MAXPATHLEN). | ||
341 | */ | ||
342 | STATIC uint | ||
343 | xfs_calc_symlink_reservation( | ||
344 | struct xfs_mount *mp) | ||
345 | { | ||
346 | return xfs_calc_create_reservation(mp) + | ||
347 | xfs_calc_buf_res(1, MAXPATHLEN); | ||
348 | } | ||
349 | |||
314 | /* | 350 | /* |
315 | * In freeing an inode we can modify: | 351 | * In freeing an inode we can modify: |
316 | * the inode being freed: inode size | 352 | * the inode being freed: inode size |
diff --git a/fs/xfs/xfs_trans.h b/fs/xfs/xfs_trans.h index a44dba5b2cdb..2b4946393e30 100644 --- a/fs/xfs/xfs_trans.h +++ b/fs/xfs/xfs_trans.h | |||
@@ -48,6 +48,7 @@ typedef struct xfs_trans_header { | |||
48 | #define XFS_LI_BUF 0x123c /* v2 bufs, variable sized inode bufs */ | 48 | #define XFS_LI_BUF 0x123c /* v2 bufs, variable sized inode bufs */ |
49 | #define XFS_LI_DQUOT 0x123d | 49 | #define XFS_LI_DQUOT 0x123d |
50 | #define XFS_LI_QUOTAOFF 0x123e | 50 | #define XFS_LI_QUOTAOFF 0x123e |
51 | #define XFS_LI_ICREATE 0x123f | ||
51 | 52 | ||
52 | #define XFS_LI_TYPE_DESC \ | 53 | #define XFS_LI_TYPE_DESC \ |
53 | { XFS_LI_EFI, "XFS_LI_EFI" }, \ | 54 | { XFS_LI_EFI, "XFS_LI_EFI" }, \ |
@@ -107,7 +108,8 @@ typedef struct xfs_trans_header { | |||
107 | #define XFS_TRANS_SWAPEXT 40 | 108 | #define XFS_TRANS_SWAPEXT 40 |
108 | #define XFS_TRANS_SB_COUNT 41 | 109 | #define XFS_TRANS_SB_COUNT 41 |
109 | #define XFS_TRANS_CHECKPOINT 42 | 110 | #define XFS_TRANS_CHECKPOINT 42 |
110 | #define XFS_TRANS_TYPE_MAX 42 | 111 | #define XFS_TRANS_ICREATE 43 |
112 | #define XFS_TRANS_TYPE_MAX 43 | ||
111 | /* new transaction types need to be reflected in xfs_logprint(8) */ | 113 | /* new transaction types need to be reflected in xfs_logprint(8) */ |
112 | 114 | ||
113 | #define XFS_TRANS_TYPES \ | 115 | #define XFS_TRANS_TYPES \ |
@@ -210,23 +212,18 @@ struct xfs_log_item_desc { | |||
210 | /* | 212 | /* |
211 | * Per-extent log reservation for the allocation btree changes | 213 | * Per-extent log reservation for the allocation btree changes |
212 | * involved in freeing or allocating an extent. | 214 | * involved in freeing or allocating an extent. |
213 | * 2 trees * (2 blocks/level * max depth - 1) * block size | 215 | * 2 trees * (2 blocks/level * max depth - 1) |
214 | */ | 216 | */ |
215 | #define XFS_ALLOCFREE_LOG_RES(mp,nx) \ | ||
216 | ((nx) * (2 * XFS_FSB_TO_B((mp), 2 * XFS_AG_MAXLEVELS(mp) - 1))) | ||
217 | #define XFS_ALLOCFREE_LOG_COUNT(mp,nx) \ | 217 | #define XFS_ALLOCFREE_LOG_COUNT(mp,nx) \ |
218 | ((nx) * (2 * (2 * XFS_AG_MAXLEVELS(mp) - 1))) | 218 | ((nx) * (2 * (2 * XFS_AG_MAXLEVELS(mp) - 1))) |
219 | 219 | ||
220 | /* | 220 | /* |
221 | * Per-directory log reservation for any directory change. | 221 | * Per-directory log reservation for any directory change. |
222 | * dir blocks: (1 btree block per level + data block + free block) * dblock size | 222 | * dir blocks: (1 btree block per level + data block + free block) |
223 | * bmap btree: (levels + 2) * max depth * block size | 223 | * bmap btree: (levels + 2) * max depth |
224 | * v2 directory blocks can be fragmented below the dirblksize down to the fsb | 224 | * v2 directory blocks can be fragmented below the dirblksize down to the fsb |
225 | * size, so account for that in the DAENTER macros. | 225 | * size, so account for that in the DAENTER macros. |
226 | */ | 226 | */ |
227 | #define XFS_DIROP_LOG_RES(mp) \ | ||
228 | (XFS_FSB_TO_B(mp, XFS_DAENTER_BLOCKS(mp, XFS_DATA_FORK)) + \ | ||
229 | (XFS_FSB_TO_B(mp, XFS_DAENTER_BMAPS(mp, XFS_DATA_FORK) + 1))) | ||
230 | #define XFS_DIROP_LOG_COUNT(mp) \ | 227 | #define XFS_DIROP_LOG_COUNT(mp) \ |
231 | (XFS_DAENTER_BLOCKS(mp, XFS_DATA_FORK) + \ | 228 | (XFS_DAENTER_BLOCKS(mp, XFS_DATA_FORK) + \ |
232 | XFS_DAENTER_BMAPS(mp, XFS_DATA_FORK) + 1) | 229 | XFS_DAENTER_BMAPS(mp, XFS_DATA_FORK) + 1) |
@@ -503,6 +500,7 @@ void xfs_trans_bhold_release(xfs_trans_t *, struct xfs_buf *); | |||
503 | void xfs_trans_binval(xfs_trans_t *, struct xfs_buf *); | 500 | void xfs_trans_binval(xfs_trans_t *, struct xfs_buf *); |
504 | void xfs_trans_inode_buf(xfs_trans_t *, struct xfs_buf *); | 501 | void xfs_trans_inode_buf(xfs_trans_t *, struct xfs_buf *); |
505 | void xfs_trans_stale_inode_buf(xfs_trans_t *, struct xfs_buf *); | 502 | void xfs_trans_stale_inode_buf(xfs_trans_t *, struct xfs_buf *); |
503 | void xfs_trans_ordered_buf(xfs_trans_t *, struct xfs_buf *); | ||
506 | void xfs_trans_dquot_buf(xfs_trans_t *, struct xfs_buf *, uint); | 504 | void xfs_trans_dquot_buf(xfs_trans_t *, struct xfs_buf *, uint); |
507 | void xfs_trans_inode_alloc_buf(xfs_trans_t *, struct xfs_buf *); | 505 | void xfs_trans_inode_alloc_buf(xfs_trans_t *, struct xfs_buf *); |
508 | void xfs_trans_ichgtime(struct xfs_trans *, struct xfs_inode *, int); | 506 | void xfs_trans_ichgtime(struct xfs_trans *, struct xfs_inode *, int); |
diff --git a/fs/xfs/xfs_trans_buf.c b/fs/xfs/xfs_trans_buf.c index 73a5fa457e16..aa5a04b844d6 100644 --- a/fs/xfs/xfs_trans_buf.c +++ b/fs/xfs/xfs_trans_buf.c | |||
@@ -397,7 +397,6 @@ shutdown_abort: | |||
397 | return XFS_ERROR(EIO); | 397 | return XFS_ERROR(EIO); |
398 | } | 398 | } |
399 | 399 | ||
400 | |||
401 | /* | 400 | /* |
402 | * Release the buffer bp which was previously acquired with one of the | 401 | * Release the buffer bp which was previously acquired with one of the |
403 | * xfs_trans_... buffer allocation routines if the buffer has not | 402 | * xfs_trans_... buffer allocation routines if the buffer has not |
@@ -603,8 +602,14 @@ xfs_trans_log_buf(xfs_trans_t *tp, | |||
603 | 602 | ||
604 | tp->t_flags |= XFS_TRANS_DIRTY; | 603 | tp->t_flags |= XFS_TRANS_DIRTY; |
605 | bip->bli_item.li_desc->lid_flags |= XFS_LID_DIRTY; | 604 | bip->bli_item.li_desc->lid_flags |= XFS_LID_DIRTY; |
606 | bip->bli_flags |= XFS_BLI_LOGGED; | 605 | |
607 | xfs_buf_item_log(bip, first, last); | 606 | /* |
607 | * If we have an ordered buffer we are not logging any dirty range but | ||
608 | * it still needs to be marked dirty and that it has been logged. | ||
609 | */ | ||
610 | bip->bli_flags |= XFS_BLI_DIRTY | XFS_BLI_LOGGED; | ||
611 | if (!(bip->bli_flags & XFS_BLI_ORDERED)) | ||
612 | xfs_buf_item_log(bip, first, last); | ||
608 | } | 613 | } |
609 | 614 | ||
610 | 615 | ||
@@ -757,6 +762,29 @@ xfs_trans_inode_alloc_buf( | |||
757 | } | 762 | } |
758 | 763 | ||
759 | /* | 764 | /* |
765 | * Mark the buffer as ordered for this transaction. This means | ||
766 | * that the contents of the buffer are not recorded in the transaction | ||
767 | * but it is tracked in the AIL as though it was. This allows us | ||
768 | * to record logical changes in transactions rather than the physical | ||
769 | * changes we make to the buffer without changing writeback ordering | ||
770 | * constraints of metadata buffers. | ||
771 | */ | ||
772 | void | ||
773 | xfs_trans_ordered_buf( | ||
774 | struct xfs_trans *tp, | ||
775 | struct xfs_buf *bp) | ||
776 | { | ||
777 | struct xfs_buf_log_item *bip = bp->b_fspriv; | ||
778 | |||
779 | ASSERT(bp->b_transp == tp); | ||
780 | ASSERT(bip != NULL); | ||
781 | ASSERT(atomic_read(&bip->bli_refcount) > 0); | ||
782 | |||
783 | bip->bli_flags |= XFS_BLI_ORDERED; | ||
784 | trace_xfs_buf_item_ordered(bip); | ||
785 | } | ||
786 | |||
787 | /* | ||
760 | * Set the type of the buffer for log recovery so that it can correctly identify | 788 | * Set the type of the buffer for log recovery so that it can correctly identify |
761 | * and hence attach the correct buffer ops to the buffer after replay. | 789 | * and hence attach the correct buffer ops to the buffer after replay. |
762 | */ | 790 | */ |
diff --git a/fs/xfs/xfs_trans_dquot.c b/fs/xfs/xfs_trans_dquot.c index fec75d023703..61407a847b86 100644 --- a/fs/xfs/xfs_trans_dquot.c +++ b/fs/xfs/xfs_trans_dquot.c | |||
@@ -103,8 +103,6 @@ xfs_trans_dup_dqinfo( | |||
103 | return; | 103 | return; |
104 | 104 | ||
105 | xfs_trans_alloc_dqinfo(ntp); | 105 | xfs_trans_alloc_dqinfo(ntp); |
106 | oqa = otp->t_dqinfo->dqa_usrdquots; | ||
107 | nqa = ntp->t_dqinfo->dqa_usrdquots; | ||
108 | 106 | ||
109 | /* | 107 | /* |
110 | * Because the quota blk reservation is carried forward, | 108 | * Because the quota blk reservation is carried forward, |
@@ -113,7 +111,9 @@ xfs_trans_dup_dqinfo( | |||
113 | if(otp->t_flags & XFS_TRANS_DQ_DIRTY) | 111 | if(otp->t_flags & XFS_TRANS_DQ_DIRTY) |
114 | ntp->t_flags |= XFS_TRANS_DQ_DIRTY; | 112 | ntp->t_flags |= XFS_TRANS_DQ_DIRTY; |
115 | 113 | ||
116 | for (j = 0; j < 2; j++) { | 114 | for (j = 0; j < XFS_QM_TRANS_DQTYPES; j++) { |
115 | oqa = otp->t_dqinfo->dqs[j]; | ||
116 | nqa = ntp->t_dqinfo->dqs[j]; | ||
117 | for (i = 0; i < XFS_QM_TRANS_MAXDQS; i++) { | 117 | for (i = 0; i < XFS_QM_TRANS_MAXDQS; i++) { |
118 | if (oqa[i].qt_dquot == NULL) | 118 | if (oqa[i].qt_dquot == NULL) |
119 | break; | 119 | break; |
@@ -138,8 +138,6 @@ xfs_trans_dup_dqinfo( | |||
138 | oq->qt_ino_res = oq->qt_ino_res_used; | 138 | oq->qt_ino_res = oq->qt_ino_res_used; |
139 | 139 | ||
140 | } | 140 | } |
141 | oqa = otp->t_dqinfo->dqa_grpdquots; | ||
142 | nqa = ntp->t_dqinfo->dqa_grpdquots; | ||
143 | } | 141 | } |
144 | } | 142 | } |
145 | 143 | ||
@@ -157,8 +155,7 @@ xfs_trans_mod_dquot_byino( | |||
157 | 155 | ||
158 | if (!XFS_IS_QUOTA_RUNNING(mp) || | 156 | if (!XFS_IS_QUOTA_RUNNING(mp) || |
159 | !XFS_IS_QUOTA_ON(mp) || | 157 | !XFS_IS_QUOTA_ON(mp) || |
160 | ip->i_ino == mp->m_sb.sb_uquotino || | 158 | xfs_is_quota_inode(&mp->m_sb, ip->i_ino)) |
161 | ip->i_ino == mp->m_sb.sb_gquotino) | ||
162 | return; | 159 | return; |
163 | 160 | ||
164 | if (tp->t_dqinfo == NULL) | 161 | if (tp->t_dqinfo == NULL) |
@@ -166,20 +163,28 @@ xfs_trans_mod_dquot_byino( | |||
166 | 163 | ||
167 | if (XFS_IS_UQUOTA_ON(mp) && ip->i_udquot) | 164 | if (XFS_IS_UQUOTA_ON(mp) && ip->i_udquot) |
168 | (void) xfs_trans_mod_dquot(tp, ip->i_udquot, field, delta); | 165 | (void) xfs_trans_mod_dquot(tp, ip->i_udquot, field, delta); |
169 | if (XFS_IS_OQUOTA_ON(mp) && ip->i_gdquot) | 166 | if (XFS_IS_GQUOTA_ON(mp) && ip->i_gdquot) |
170 | (void) xfs_trans_mod_dquot(tp, ip->i_gdquot, field, delta); | 167 | (void) xfs_trans_mod_dquot(tp, ip->i_gdquot, field, delta); |
168 | if (XFS_IS_PQUOTA_ON(mp) && ip->i_pdquot) | ||
169 | (void) xfs_trans_mod_dquot(tp, ip->i_pdquot, field, delta); | ||
171 | } | 170 | } |
172 | 171 | ||
173 | STATIC xfs_dqtrx_t * | 172 | STATIC struct xfs_dqtrx * |
174 | xfs_trans_get_dqtrx( | 173 | xfs_trans_get_dqtrx( |
175 | xfs_trans_t *tp, | 174 | struct xfs_trans *tp, |
176 | xfs_dquot_t *dqp) | 175 | struct xfs_dquot *dqp) |
177 | { | 176 | { |
178 | int i; | 177 | int i; |
179 | xfs_dqtrx_t *qa; | 178 | struct xfs_dqtrx *qa; |
180 | 179 | ||
181 | qa = XFS_QM_ISUDQ(dqp) ? | 180 | if (XFS_QM_ISUDQ(dqp)) |
182 | tp->t_dqinfo->dqa_usrdquots : tp->t_dqinfo->dqa_grpdquots; | 181 | qa = tp->t_dqinfo->dqs[XFS_QM_TRANS_USR]; |
182 | else if (XFS_QM_ISGDQ(dqp)) | ||
183 | qa = tp->t_dqinfo->dqs[XFS_QM_TRANS_GRP]; | ||
184 | else if (XFS_QM_ISPDQ(dqp)) | ||
185 | qa = tp->t_dqinfo->dqs[XFS_QM_TRANS_PRJ]; | ||
186 | else | ||
187 | return NULL; | ||
183 | 188 | ||
184 | for (i = 0; i < XFS_QM_TRANS_MAXDQS; i++) { | 189 | for (i = 0; i < XFS_QM_TRANS_MAXDQS; i++) { |
185 | if (qa[i].qt_dquot == NULL || | 190 | if (qa[i].qt_dquot == NULL || |
@@ -292,11 +297,10 @@ xfs_trans_mod_dquot( | |||
292 | 297 | ||
293 | 298 | ||
294 | /* | 299 | /* |
295 | * Given an array of dqtrx structures, lock all the dquots associated | 300 | * Given an array of dqtrx structures, lock all the dquots associated and join |
296 | * and join them to the transaction, provided they have been modified. | 301 | * them to the transaction, provided they have been modified. We know that the |
297 | * We know that the highest number of dquots (of one type - usr OR grp), | 302 | * highest number of dquots of one type - usr, grp OR prj - involved in a |
298 | * involved in a transaction is 2 and that both usr and grp combined - 3. | 303 | * transaction is 2 so we don't need to make this very generic. |
299 | * So, we don't attempt to make this very generic. | ||
300 | */ | 304 | */ |
301 | STATIC void | 305 | STATIC void |
302 | xfs_trans_dqlockedjoin( | 306 | xfs_trans_dqlockedjoin( |
@@ -339,12 +343,10 @@ xfs_trans_apply_dquot_deltas( | |||
339 | return; | 343 | return; |
340 | 344 | ||
341 | ASSERT(tp->t_dqinfo); | 345 | ASSERT(tp->t_dqinfo); |
342 | qa = tp->t_dqinfo->dqa_usrdquots; | 346 | for (j = 0; j < XFS_QM_TRANS_DQTYPES; j++) { |
343 | for (j = 0; j < 2; j++) { | 347 | qa = tp->t_dqinfo->dqs[j]; |
344 | if (qa[0].qt_dquot == NULL) { | 348 | if (qa[0].qt_dquot == NULL) |
345 | qa = tp->t_dqinfo->dqa_grpdquots; | ||
346 | continue; | 349 | continue; |
347 | } | ||
348 | 350 | ||
349 | /* | 351 | /* |
350 | * Lock all of the dquots and join them to the transaction. | 352 | * Lock all of the dquots and join them to the transaction. |
@@ -495,10 +497,6 @@ xfs_trans_apply_dquot_deltas( | |||
495 | ASSERT(dqp->q_res_rtbcount >= | 497 | ASSERT(dqp->q_res_rtbcount >= |
496 | be64_to_cpu(dqp->q_core.d_rtbcount)); | 498 | be64_to_cpu(dqp->q_core.d_rtbcount)); |
497 | } | 499 | } |
498 | /* | ||
499 | * Do the group quotas next | ||
500 | */ | ||
501 | qa = tp->t_dqinfo->dqa_grpdquots; | ||
502 | } | 500 | } |
503 | } | 501 | } |
504 | 502 | ||
@@ -521,9 +519,9 @@ xfs_trans_unreserve_and_mod_dquots( | |||
521 | if (!tp->t_dqinfo || !(tp->t_flags & XFS_TRANS_DQ_DIRTY)) | 519 | if (!tp->t_dqinfo || !(tp->t_flags & XFS_TRANS_DQ_DIRTY)) |
522 | return; | 520 | return; |
523 | 521 | ||
524 | qa = tp->t_dqinfo->dqa_usrdquots; | 522 | for (j = 0; j < XFS_QM_TRANS_DQTYPES; j++) { |
523 | qa = tp->t_dqinfo->dqs[j]; | ||
525 | 524 | ||
526 | for (j = 0; j < 2; j++) { | ||
527 | for (i = 0; i < XFS_QM_TRANS_MAXDQS; i++) { | 525 | for (i = 0; i < XFS_QM_TRANS_MAXDQS; i++) { |
528 | qtrx = &qa[i]; | 526 | qtrx = &qa[i]; |
529 | /* | 527 | /* |
@@ -565,7 +563,6 @@ xfs_trans_unreserve_and_mod_dquots( | |||
565 | xfs_dqunlock(dqp); | 563 | xfs_dqunlock(dqp); |
566 | 564 | ||
567 | } | 565 | } |
568 | qa = tp->t_dqinfo->dqa_grpdquots; | ||
569 | } | 566 | } |
570 | } | 567 | } |
571 | 568 | ||
@@ -640,8 +637,8 @@ xfs_trans_dqresv( | |||
640 | if ((flags & XFS_QMOPT_FORCE_RES) == 0 && | 637 | if ((flags & XFS_QMOPT_FORCE_RES) == 0 && |
641 | dqp->q_core.d_id && | 638 | dqp->q_core.d_id && |
642 | ((XFS_IS_UQUOTA_ENFORCED(dqp->q_mount) && XFS_QM_ISUDQ(dqp)) || | 639 | ((XFS_IS_UQUOTA_ENFORCED(dqp->q_mount) && XFS_QM_ISUDQ(dqp)) || |
643 | (XFS_IS_OQUOTA_ENFORCED(dqp->q_mount) && | 640 | (XFS_IS_GQUOTA_ENFORCED(dqp->q_mount) && XFS_QM_ISGDQ(dqp)) || |
644 | (XFS_QM_ISPDQ(dqp) || XFS_QM_ISGDQ(dqp))))) { | 641 | (XFS_IS_PQUOTA_ENFORCED(dqp->q_mount) && XFS_QM_ISPDQ(dqp)))) { |
645 | if (nblks > 0) { | 642 | if (nblks > 0) { |
646 | /* | 643 | /* |
647 | * dquot is locked already. See if we'd go over the | 644 | * dquot is locked already. See if we'd go over the |
@@ -736,8 +733,8 @@ error_return: | |||
736 | 733 | ||
737 | /* | 734 | /* |
738 | * Given dquot(s), make disk block and/or inode reservations against them. | 735 | * Given dquot(s), make disk block and/or inode reservations against them. |
739 | * The fact that this does the reservation against both the usr and | 736 | * The fact that this does the reservation against user, group and |
740 | * grp/prj quotas is important, because this follows a both-or-nothing | 737 | * project quotas is important, because this follows a all-or-nothing |
741 | * approach. | 738 | * approach. |
742 | * | 739 | * |
743 | * flags = XFS_QMOPT_FORCE_RES evades limit enforcement. Used by chown. | 740 | * flags = XFS_QMOPT_FORCE_RES evades limit enforcement. Used by chown. |
@@ -748,15 +745,16 @@ error_return: | |||
748 | */ | 745 | */ |
749 | int | 746 | int |
750 | xfs_trans_reserve_quota_bydquots( | 747 | xfs_trans_reserve_quota_bydquots( |
751 | xfs_trans_t *tp, | 748 | struct xfs_trans *tp, |
752 | xfs_mount_t *mp, | 749 | struct xfs_mount *mp, |
753 | xfs_dquot_t *udqp, | 750 | struct xfs_dquot *udqp, |
754 | xfs_dquot_t *gdqp, | 751 | struct xfs_dquot *gdqp, |
755 | long nblks, | 752 | struct xfs_dquot *pdqp, |
756 | long ninos, | 753 | long nblks, |
757 | uint flags) | 754 | long ninos, |
755 | uint flags) | ||
758 | { | 756 | { |
759 | int resvd = 0, error; | 757 | int error; |
760 | 758 | ||
761 | if (!XFS_IS_QUOTA_RUNNING(mp) || !XFS_IS_QUOTA_ON(mp)) | 759 | if (!XFS_IS_QUOTA_RUNNING(mp) || !XFS_IS_QUOTA_ON(mp)) |
762 | return 0; | 760 | return 0; |
@@ -771,28 +769,34 @@ xfs_trans_reserve_quota_bydquots( | |||
771 | (flags & ~XFS_QMOPT_ENOSPC)); | 769 | (flags & ~XFS_QMOPT_ENOSPC)); |
772 | if (error) | 770 | if (error) |
773 | return error; | 771 | return error; |
774 | resvd = 1; | ||
775 | } | 772 | } |
776 | 773 | ||
777 | if (gdqp) { | 774 | if (gdqp) { |
778 | error = xfs_trans_dqresv(tp, mp, gdqp, nblks, ninos, flags); | 775 | error = xfs_trans_dqresv(tp, mp, gdqp, nblks, ninos, flags); |
779 | if (error) { | 776 | if (error) |
780 | /* | 777 | goto unwind_usr; |
781 | * can't do it, so backout previous reservation | 778 | } |
782 | */ | 779 | |
783 | if (resvd) { | 780 | if (pdqp) { |
784 | flags |= XFS_QMOPT_FORCE_RES; | 781 | error = xfs_trans_dqresv(tp, mp, pdqp, nblks, ninos, flags); |
785 | xfs_trans_dqresv(tp, mp, udqp, | 782 | if (error) |
786 | -nblks, -ninos, flags); | 783 | goto unwind_grp; |
787 | } | ||
788 | return error; | ||
789 | } | ||
790 | } | 784 | } |
791 | 785 | ||
792 | /* | 786 | /* |
793 | * Didn't change anything critical, so, no need to log | 787 | * Didn't change anything critical, so, no need to log |
794 | */ | 788 | */ |
795 | return 0; | 789 | return 0; |
790 | |||
791 | unwind_grp: | ||
792 | flags |= XFS_QMOPT_FORCE_RES; | ||
793 | if (gdqp) | ||
794 | xfs_trans_dqresv(tp, mp, gdqp, -nblks, -ninos, flags); | ||
795 | unwind_usr: | ||
796 | flags |= XFS_QMOPT_FORCE_RES; | ||
797 | if (udqp) | ||
798 | xfs_trans_dqresv(tp, mp, udqp, -nblks, -ninos, flags); | ||
799 | return error; | ||
796 | } | 800 | } |
797 | 801 | ||
798 | 802 | ||
@@ -816,8 +820,7 @@ xfs_trans_reserve_quota_nblks( | |||
816 | if (XFS_IS_PQUOTA_ON(mp)) | 820 | if (XFS_IS_PQUOTA_ON(mp)) |
817 | flags |= XFS_QMOPT_ENOSPC; | 821 | flags |= XFS_QMOPT_ENOSPC; |
818 | 822 | ||
819 | ASSERT(ip->i_ino != mp->m_sb.sb_uquotino); | 823 | ASSERT(!xfs_is_quota_inode(&mp->m_sb, ip->i_ino)); |
820 | ASSERT(ip->i_ino != mp->m_sb.sb_gquotino); | ||
821 | 824 | ||
822 | ASSERT(xfs_isilocked(ip, XFS_ILOCK_EXCL)); | 825 | ASSERT(xfs_isilocked(ip, XFS_ILOCK_EXCL)); |
823 | ASSERT((flags & ~(XFS_QMOPT_FORCE_RES | XFS_QMOPT_ENOSPC)) == | 826 | ASSERT((flags & ~(XFS_QMOPT_FORCE_RES | XFS_QMOPT_ENOSPC)) == |
@@ -830,6 +833,7 @@ xfs_trans_reserve_quota_nblks( | |||
830 | */ | 833 | */ |
831 | return xfs_trans_reserve_quota_bydquots(tp, mp, | 834 | return xfs_trans_reserve_quota_bydquots(tp, mp, |
832 | ip->i_udquot, ip->i_gdquot, | 835 | ip->i_udquot, ip->i_gdquot, |
836 | ip->i_pdquot, | ||
833 | nblks, ninos, flags); | 837 | nblks, ninos, flags); |
834 | } | 838 | } |
835 | 839 | ||
diff --git a/fs/xfs/xfs_trans_inode.c b/fs/xfs/xfs_trans_inode.c index ac6d567704db..53dfe46f3680 100644 --- a/fs/xfs/xfs_trans_inode.c +++ b/fs/xfs/xfs_trans_inode.c | |||
@@ -112,6 +112,17 @@ xfs_trans_log_inode( | |||
112 | ASSERT(ip->i_itemp != NULL); | 112 | ASSERT(ip->i_itemp != NULL); |
113 | ASSERT(xfs_isilocked(ip, XFS_ILOCK_EXCL)); | 113 | ASSERT(xfs_isilocked(ip, XFS_ILOCK_EXCL)); |
114 | 114 | ||
115 | /* | ||
116 | * First time we log the inode in a transaction, bump the inode change | ||
117 | * counter if it is configured for this to occur. | ||
118 | */ | ||
119 | if (!(ip->i_itemp->ili_item.li_desc->lid_flags & XFS_LID_DIRTY) && | ||
120 | IS_I_VERSION(VFS_I(ip))) { | ||
121 | inode_inc_iversion(VFS_I(ip)); | ||
122 | ip->i_d.di_changecount = VFS_I(ip)->i_version; | ||
123 | flags |= XFS_ILOG_CORE; | ||
124 | } | ||
125 | |||
115 | tp->t_flags |= XFS_TRANS_DIRTY; | 126 | tp->t_flags |= XFS_TRANS_DIRTY; |
116 | ip->i_itemp->ili_item.li_desc->lid_flags |= XFS_LID_DIRTY; | 127 | ip->i_itemp->ili_item.li_desc->lid_flags |= XFS_LID_DIRTY; |
117 | 128 | ||
diff --git a/fs/xfs/xfs_vnodeops.c b/fs/xfs/xfs_vnodeops.c index 0176bb21f09a..dc730ac272be 100644 --- a/fs/xfs/xfs_vnodeops.c +++ b/fs/xfs/xfs_vnodeops.c | |||
@@ -322,18 +322,9 @@ xfs_inactive( | |||
322 | xfs_trans_ijoin(tp, ip, 0); | 322 | xfs_trans_ijoin(tp, ip, 0); |
323 | 323 | ||
324 | if (S_ISLNK(ip->i_d.di_mode)) { | 324 | if (S_ISLNK(ip->i_d.di_mode)) { |
325 | /* | 325 | error = xfs_inactive_symlink(ip, &tp); |
326 | * Zero length symlinks _can_ exist. | 326 | if (error) |
327 | */ | 327 | goto out_cancel; |
328 | if (ip->i_d.di_size > XFS_IFORK_DSIZE(ip)) { | ||
329 | error = xfs_inactive_symlink_rmt(ip, &tp); | ||
330 | if (error) | ||
331 | goto out_cancel; | ||
332 | } else if (ip->i_df.if_bytes > 0) { | ||
333 | xfs_idata_realloc(ip, -(ip->i_df.if_bytes), | ||
334 | XFS_DATA_FORK); | ||
335 | ASSERT(ip->i_df.if_bytes == 0); | ||
336 | } | ||
337 | } else if (truncate) { | 328 | } else if (truncate) { |
338 | ip->i_d.di_size = 0; | 329 | ip->i_d.di_size = 0; |
339 | xfs_trans_log_inode(tp, ip, XFS_ILOG_CORE); | 330 | xfs_trans_log_inode(tp, ip, XFS_ILOG_CORE); |
@@ -498,6 +489,7 @@ xfs_create( | |||
498 | prid_t prid; | 489 | prid_t prid; |
499 | struct xfs_dquot *udqp = NULL; | 490 | struct xfs_dquot *udqp = NULL; |
500 | struct xfs_dquot *gdqp = NULL; | 491 | struct xfs_dquot *gdqp = NULL; |
492 | struct xfs_dquot *pdqp = NULL; | ||
501 | uint resblks; | 493 | uint resblks; |
502 | uint log_res; | 494 | uint log_res; |
503 | uint log_count; | 495 | uint log_count; |
@@ -516,7 +508,8 @@ xfs_create( | |||
516 | * Make sure that we have allocated dquot(s) on disk. | 508 | * Make sure that we have allocated dquot(s) on disk. |
517 | */ | 509 | */ |
518 | error = xfs_qm_vop_dqalloc(dp, current_fsuid(), current_fsgid(), prid, | 510 | error = xfs_qm_vop_dqalloc(dp, current_fsuid(), current_fsgid(), prid, |
519 | XFS_QMOPT_QUOTALL | XFS_QMOPT_INHERIT, &udqp, &gdqp); | 511 | XFS_QMOPT_QUOTALL | XFS_QMOPT_INHERIT, |
512 | &udqp, &gdqp, &pdqp); | ||
520 | if (error) | 513 | if (error) |
521 | return error; | 514 | return error; |
522 | 515 | ||
@@ -568,7 +561,8 @@ xfs_create( | |||
568 | /* | 561 | /* |
569 | * Reserve disk quota and the inode. | 562 | * Reserve disk quota and the inode. |
570 | */ | 563 | */ |
571 | error = xfs_trans_reserve_quota(tp, mp, udqp, gdqp, resblks, 1, 0); | 564 | error = xfs_trans_reserve_quota(tp, mp, udqp, gdqp, |
565 | pdqp, resblks, 1, 0); | ||
572 | if (error) | 566 | if (error) |
573 | goto out_trans_cancel; | 567 | goto out_trans_cancel; |
574 | 568 | ||
@@ -632,7 +626,7 @@ xfs_create( | |||
632 | * These ids of the inode couldn't have changed since the new | 626 | * These ids of the inode couldn't have changed since the new |
633 | * inode has been locked ever since it was created. | 627 | * inode has been locked ever since it was created. |
634 | */ | 628 | */ |
635 | xfs_qm_vop_create_dqattach(tp, ip, udqp, gdqp); | 629 | xfs_qm_vop_create_dqattach(tp, ip, udqp, gdqp, pdqp); |
636 | 630 | ||
637 | error = xfs_bmap_finish(&tp, &free_list, &committed); | 631 | error = xfs_bmap_finish(&tp, &free_list, &committed); |
638 | if (error) | 632 | if (error) |
@@ -644,6 +638,7 @@ xfs_create( | |||
644 | 638 | ||
645 | xfs_qm_dqrele(udqp); | 639 | xfs_qm_dqrele(udqp); |
646 | xfs_qm_dqrele(gdqp); | 640 | xfs_qm_dqrele(gdqp); |
641 | xfs_qm_dqrele(pdqp); | ||
647 | 642 | ||
648 | *ipp = ip; | 643 | *ipp = ip; |
649 | return 0; | 644 | return 0; |
@@ -665,6 +660,7 @@ xfs_create( | |||
665 | 660 | ||
666 | xfs_qm_dqrele(udqp); | 661 | xfs_qm_dqrele(udqp); |
667 | xfs_qm_dqrele(gdqp); | 662 | xfs_qm_dqrele(gdqp); |
663 | xfs_qm_dqrele(pdqp); | ||
668 | 664 | ||
669 | if (unlock_dp_on_error) | 665 | if (unlock_dp_on_error) |
670 | xfs_iunlock(dp, XFS_ILOCK_EXCL); | 666 | xfs_iunlock(dp, XFS_ILOCK_EXCL); |
@@ -1577,7 +1573,7 @@ xfs_free_file_space( | |||
1577 | } | 1573 | } |
1578 | xfs_ilock(ip, XFS_ILOCK_EXCL); | 1574 | xfs_ilock(ip, XFS_ILOCK_EXCL); |
1579 | error = xfs_trans_reserve_quota(tp, mp, | 1575 | error = xfs_trans_reserve_quota(tp, mp, |
1580 | ip->i_udquot, ip->i_gdquot, | 1576 | ip->i_udquot, ip->i_gdquot, ip->i_pdquot, |
1581 | resblks, 0, XFS_QMOPT_RES_REGBLKS); | 1577 | resblks, 0, XFS_QMOPT_RES_REGBLKS); |
1582 | if (error) | 1578 | if (error) |
1583 | goto error1; | 1579 | goto error1; |
diff --git a/fs/xfs/xfs_vnodeops.h b/fs/xfs/xfs_vnodeops.h index 5163022d9808..38c67c34d73f 100644 --- a/fs/xfs/xfs_vnodeops.h +++ b/fs/xfs/xfs_vnodeops.h | |||
@@ -31,8 +31,7 @@ int xfs_remove(struct xfs_inode *dp, struct xfs_name *name, | |||
31 | struct xfs_inode *ip); | 31 | struct xfs_inode *ip); |
32 | int xfs_link(struct xfs_inode *tdp, struct xfs_inode *sip, | 32 | int xfs_link(struct xfs_inode *tdp, struct xfs_inode *sip, |
33 | struct xfs_name *target_name); | 33 | struct xfs_name *target_name); |
34 | int xfs_readdir(struct xfs_inode *dp, void *dirent, size_t bufsize, | 34 | int xfs_readdir(struct xfs_inode *dp, struct dir_context *ctx, size_t bufsize); |
35 | xfs_off_t *offset, filldir_t filldir); | ||
36 | int xfs_symlink(struct xfs_inode *dp, struct xfs_name *link_name, | 35 | int xfs_symlink(struct xfs_inode *dp, struct xfs_name *link_name, |
37 | const char *target_path, umode_t mode, struct xfs_inode **ipp); | 36 | const char *target_path, umode_t mode, struct xfs_inode **ipp); |
38 | int xfs_set_dmattrs(struct xfs_inode *ip, u_int evmask, u_int16_t state); | 37 | int xfs_set_dmattrs(struct xfs_inode *ip, u_int evmask, u_int16_t state); |