Skip to content

Commit da89bd2

Browse files
committed
Merge tag 'for-linus-v3.11-rc1' of git://oss.sgi.com/xfs/xfs
Pull xfs update from Ben Myers: "This includes several bugfixes, part of the work for project quotas and group quotas to be used together, performance improvements for inode creation/deletion, buffer readahead, and bulkstat, implementation of the inode change count, an inode create transaction, and the removal of a bunch of dead code. There are also some duplicate commits that you already have from the 3.10-rc series. - part of the work to allow project quotas and group quotas to be used together - inode change count - inode create transaction - block queue plugging in buffer readahead and bulkstat - ordered log vector support - removal of dead code in and around xfs_sync_inode_grab, xfs_ialloc_get_rec, XFS_MOUNT_RETERR, XFS_ALLOCFREE_LOG_RES, XFS_DIROP_LOG_RES, xfs_chash, ctl_table, and xfs_growfs_data_private - don't keep silent if sunit/swidth can not be changed via mount - fix a leak of remote symlink blocks into the filesystem when xattrs are used on symlinks - fix for fiemap to return FIEMAP_EXTENT_UNKOWN flag on delay extents - part of a fix for xfs_fsr - disable speculative preallocation with small files - performance improvements for inode creates and deletes" * tag 'for-linus-v3.11-rc1' of git://oss.sgi.com/xfs/xfs: (61 commits) xfs: Remove incore use of XFS_OQUOTA_ENFD and XFS_OQUOTA_CHKD xfs: Change xfs_dquot_acct to be a 2-dimensional array xfs: Code cleanup and removal of some typedef usage xfs: Replace macro XFS_DQ_TO_QIP with a function xfs: Replace macro XFS_DQUOT_TREE with a function xfs: Define a new function xfs_is_quota_inode() xfs: implement inode change count xfs: Use inode create transaction xfs: Inode create item recovery xfs: Inode create transaction reservations xfs: Inode create log items xfs: Introduce an ordered buffer item xfs: Introduce ordered log vector support xfs: xfs_ifree doesn't need to modify the inode buffer xfs: don't do IO when creating an new inode xfs: don't use speculative prealloc for small files xfs: plug directory buffer readahead xfs: add pluging for bulkstat readahead xfs: Remove dead function prototype xfs_sync_inode_grab() xfs: Remove the left function variable from xfs_ialloc_get_rec() ...
2 parents be0c5d8 + 83e782e commit da89bd2

43 files changed

Lines changed: 1180 additions & 477 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎fs/xfs/Makefile‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@ xfs-y += xfs_alloc.o \
7171
xfs_dir2_sf.o \
7272
xfs_ialloc.o \
7373
xfs_ialloc_btree.o \
74+
xfs_icreate_item.o \
7475
xfs_inode.o \
7576
xfs_log_recover.o \
7677
xfs_mount.o \

‎fs/xfs/xfs_alloc.c‎

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -175,6 +175,7 @@ xfs_alloc_compute_diff(
175175
xfs_agblock_t wantbno, /* target starting block */
176176
xfs_extlen_t wantlen, /* target length */
177177
xfs_extlen_t alignment, /* target alignment */
178+
char userdata, /* are we allocating data? */
178179
xfs_agblock_t freebno, /* freespace's starting block */
179180
xfs_extlen_t freelen, /* freespace's length */
180181
xfs_agblock_t *newbnop) /* result: best start block from free */
@@ -189,7 +190,14 @@ xfs_alloc_compute_diff(
189190
ASSERT(freelen >= wantlen);
190191
freeend = freebno + freelen;
191192
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)) {
193201
if ((newbno1 = roundup(freebno, alignment)) >= freeend)
194202
newbno1 = NULLAGBLOCK;
195203
} else if (freeend >= wantend && alignment > 1) {
@@ -805,7 +813,8 @@ xfs_alloc_find_best_extent(
805813
xfs_alloc_fix_len(args);
806814

807815
sdiff = xfs_alloc_compute_diff(args->agbno, args->len,
808-
args->alignment, *sbnoa,
816+
args->alignment,
817+
args->userdata, *sbnoa,
809818
*slena, &new);
810819

811820
/*
@@ -976,7 +985,8 @@ xfs_alloc_ag_vextent_near(
976985
if (args->len < blen)
977986
continue;
978987
ltdiff = xfs_alloc_compute_diff(args->agbno, args->len,
979-
args->alignment, ltbnoa, ltlena, &ltnew);
988+
args->alignment, args->userdata, ltbnoa,
989+
ltlena, &ltnew);
980990
if (ltnew != NULLAGBLOCK &&
981991
(args->len > blen || ltdiff < bdiff)) {
982992
bdiff = ltdiff;
@@ -1128,7 +1138,8 @@ xfs_alloc_ag_vextent_near(
11281138
args->len = XFS_EXTLEN_MIN(ltlena, args->maxlen);
11291139
xfs_alloc_fix_len(args);
11301140
ltdiff = xfs_alloc_compute_diff(args->agbno, args->len,
1131-
args->alignment, ltbnoa, ltlena, &ltnew);
1141+
args->alignment, args->userdata, ltbnoa,
1142+
ltlena, &ltnew);
11321143

11331144
error = xfs_alloc_find_best_extent(args,
11341145
&bno_cur_lt, &bno_cur_gt,
@@ -1144,7 +1155,8 @@ xfs_alloc_ag_vextent_near(
11441155
args->len = XFS_EXTLEN_MIN(gtlena, args->maxlen);
11451156
xfs_alloc_fix_len(args);
11461157
gtdiff = xfs_alloc_compute_diff(args->agbno, args->len,
1147-
args->alignment, gtbnoa, gtlena, &gtnew);
1158+
args->alignment, args->userdata, gtbnoa,
1159+
gtlena, &gtnew);
11481160

11491161
error = xfs_alloc_find_best_extent(args,
11501162
&bno_cur_gt, &bno_cur_lt,
@@ -1203,7 +1215,7 @@ xfs_alloc_ag_vextent_near(
12031215
}
12041216
rlen = args->len;
12051217
(void)xfs_alloc_compute_diff(args->agbno, rlen, args->alignment,
1206-
ltbnoa, ltlena, &ltnew);
1218+
args->userdata, ltbnoa, ltlena, &ltnew);
12071219
ASSERT(ltnew >= ltbno);
12081220
ASSERT(ltnew + rlen <= ltbnoa + ltlena);
12091221
ASSERT(ltnew + rlen <= be32_to_cpu(XFS_BUF_TO_AGF(args->agbp)->agf_length));

‎fs/xfs/xfs_bmap_btree.h‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -196,6 +196,8 @@ typedef __be64 xfs_bmbt_ptr_t, xfs_bmdr_ptr_t;
196196
#define XFS_BMDR_SPACE_CALC(nrecs) \
197197
(int)(sizeof(xfs_bmdr_block_t) + \
198198
((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)))
199201

200202
/*
201203
* Maximum number of bmap btree levels.

‎fs/xfs/xfs_buf_item.c‎

Lines changed: 58 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,16 @@ xfs_buf_item_size(
140140

141141
ASSERT(bip->bli_flags & XFS_BLI_LOGGED);
142142

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+
143153
/*
144154
* the vector count is based on the number of buffer vectors we have
145155
* dirty bits in. This will only be greater than one when we have a
@@ -212,6 +222,7 @@ xfs_buf_item_format_segment(
212222
goto out;
213223
}
214224

225+
215226
/*
216227
* Fill in an iovec for each set of contiguous chunks.
217228
*/
@@ -299,18 +310,36 @@ xfs_buf_item_format(
299310

300311
/*
301312
* 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
303316
* this state if the inode buffer allocation has not yet been committed
304317
* to the log as setting the XFS_BLI_INODE_BUF flag will prevent
305318
* 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.
306324
*/
307325
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) &&
309328
xfs_log_item_in_current_chkpt(lip)))
310329
bip->__bli_format.blf_flags |= XFS_BLF_INODE_BUF;
311330
bip->bli_flags &= ~XFS_BLI_INODE_BUF;
312331
}
313332

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+
314343
for (i = 0; i < bip->bli_format_count; i++) {
315344
vecp = xfs_buf_item_format_segment(bip, vecp, offset,
316345
&bip->bli_formats[i]);
@@ -340,6 +369,7 @@ xfs_buf_item_pin(
340369

341370
ASSERT(atomic_read(&bip->bli_refcount) > 0);
342371
ASSERT((bip->bli_flags & XFS_BLI_LOGGED) ||
372+
(bip->bli_flags & XFS_BLI_ORDERED) ||
343373
(bip->bli_flags & XFS_BLI_STALE));
344374

345375
trace_xfs_buf_item_pin(bip);
@@ -512,8 +542,9 @@ xfs_buf_item_unlock(
512542
{
513543
struct xfs_buf_log_item *bip = BUF_ITEM(lip);
514544
struct xfs_buf *bp = bip->bli_buf;
515-
int aborted, clean, i;
516-
uint hold;
545+
bool clean;
546+
bool aborted;
547+
int flags;
517548

518549
/* Clear the buffer's association with this transaction. */
519550
bp->b_transp = NULL;
@@ -524,23 +555,21 @@ xfs_buf_item_unlock(
524555
* (cancelled) buffers at unpin time, but we'll never go through the
525556
* pin/unpin cycle if we abort inside commit.
526557
*/
527-
aborted = (lip->li_flags & XFS_LI_ABORTED) != 0;
528-
558+
aborted = (lip->li_flags & XFS_LI_ABORTED) ? true : false;
529559
/*
530-
* Before possibly freeing the buf item, determine if we should
531-
* release the buffer at the end of this routine.
560+
* Before possibly freeing the buf item, copy the per-transaction state
561+
* so we can reference it safely later after clearing it from the
562+
* buffer log item.
532563
*/
533-
hold = bip->bli_flags & XFS_BLI_HOLD;
534-
535-
/* Clear the per transaction state. */
536-
bip->bli_flags &= ~(XFS_BLI_LOGGED | XFS_BLI_HOLD);
564+
flags = bip->bli_flags;
565+
bip->bli_flags &= ~(XFS_BLI_LOGGED | XFS_BLI_HOLD | XFS_BLI_ORDERED);
537566

538567
/*
539568
* If the buf item is marked stale, then don't do anything. We'll
540569
* unlock the buffer and free the buf item when the buffer is unpinned
541570
* for the last time.
542571
*/
543-
if (bip->bli_flags & XFS_BLI_STALE) {
572+
if (flags & XFS_BLI_STALE) {
544573
trace_xfs_buf_item_unlock_stale(bip);
545574
ASSERT(bip->__bli_format.blf_flags & XFS_BLF_CANCEL);
546575
if (!aborted) {
@@ -557,13 +586,19 @@ xfs_buf_item_unlock(
557586
* be the only reference to the buf item, so we free it anyway
558587
* regardless of whether it is dirty or not. A dirty abort implies a
559588
* shutdown, anyway.
589+
*
590+
* Ordered buffers are dirty but may have no recorded changes, so ensure
591+
* we only release clean items here.
560592
*/
561-
clean = 1;
562-
for (i = 0; i < bip->bli_format_count; i++) {
563-
if (!xfs_bitmap_empty(bip->bli_formats[i].blf_data_map,
564-
bip->bli_formats[i].blf_map_size)) {
565-
clean = 0;
566-
break;
593+
clean = (flags & XFS_BLI_DIRTY) ? false : true;
594+
if (clean) {
595+
int i;
596+
for (i = 0; i < bip->bli_format_count; i++) {
597+
if (!xfs_bitmap_empty(bip->bli_formats[i].blf_data_map,
598+
bip->bli_formats[i].blf_map_size)) {
599+
clean = false;
600+
break;
601+
}
567602
}
568603
}
569604
if (clean)
@@ -576,7 +611,7 @@ xfs_buf_item_unlock(
576611
} else
577612
atomic_dec(&bip->bli_refcount);
578613

579-
if (!hold)
614+
if (!(flags & XFS_BLI_HOLD))
580615
xfs_buf_relse(bp);
581616
}
582617

@@ -841,12 +876,6 @@ xfs_buf_item_log(
841876
uint end;
842877
struct xfs_buf *bp = bip->bli_buf;
843878

844-
/*
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-
850879
/*
851880
* walk each buffer segment and mark them dirty appropriately.
852881
*/
@@ -873,7 +902,7 @@ xfs_buf_item_log(
873902

874903

875904
/*
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
877906
* point, not just the current transaction) and 0 if not.
878907
*/
879908
uint
@@ -907,11 +936,11 @@ void
907936
xfs_buf_item_relse(
908937
xfs_buf_t *bp)
909938
{
910-
xfs_buf_log_item_t *bip;
939+
xfs_buf_log_item_t *bip = bp->b_fspriv;
911940

912941
trace_xfs_buf_item_relse(bp, _RET_IP_);
942+
ASSERT(!(bip->bli_item.li_flags & XFS_LI_IN_AIL));
913943

914-
bip = bp->b_fspriv;
915944
bp->b_fspriv = bip->bli_item.li_bio_list;
916945
if (bp->b_fspriv == NULL)
917946
bp->b_iodone = NULL;

‎fs/xfs/xfs_buf_item.h‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,7 @@ xfs_blft_from_flags(struct xfs_buf_log_format *blf)
120120
#define XFS_BLI_INODE_ALLOC_BUF 0x10
121121
#define XFS_BLI_STALE_INODE 0x20
122122
#define XFS_BLI_INODE_BUF 0x40
123+
#define XFS_BLI_ORDERED 0x80
123124

124125
#define XFS_BLI_FLAGS \
125126
{ XFS_BLI_HOLD, "HOLD" }, \
@@ -128,7 +129,8 @@ xfs_blft_from_flags(struct xfs_buf_log_format *blf)
128129
{ XFS_BLI_LOGGED, "LOGGED" }, \
129130
{ XFS_BLI_INODE_ALLOC_BUF, "INODE_ALLOC" }, \
130131
{ 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" }
132134

133135

134136
#ifdef __KERNEL__

‎fs/xfs/xfs_dfrag.c‎

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,9 @@
2424
#include "xfs_ag.h"
2525
#include "xfs_mount.h"
2626
#include "xfs_bmap_btree.h"
27+
#include "xfs_alloc_btree.h"
28+
#include "xfs_ialloc_btree.h"
29+
#include "xfs_btree.h"
2730
#include "xfs_dinode.h"
2831
#include "xfs_inode.h"
2932
#include "xfs_inode_item.h"
@@ -182,7 +185,7 @@ xfs_swap_extents_check_format(
182185
*/
183186
if (tip->i_d.di_format == XFS_DINODE_FMT_BTREE) {
184187
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))
186189
return EINVAL;
187190
if (XFS_IFORK_NEXTENTS(tip, XFS_DATA_FORK) <=
188191
XFS_IFORK_MAXEXT(ip, XFS_DATA_FORK))
@@ -192,9 +195,8 @@ xfs_swap_extents_check_format(
192195
/* Reciprocal target->temp btree format checks */
193196
if (ip->i_d.di_format == XFS_DINODE_FMT_BTREE) {
194197
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))
196199
return EINVAL;
197-
198200
if (XFS_IFORK_NEXTENTS(ip, XFS_DATA_FORK) <=
199201
XFS_IFORK_MAXEXT(tip, XFS_DATA_FORK))
200202
return EINVAL;

‎fs/xfs/xfs_dir2_leaf.c‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1108,6 +1108,7 @@ xfs_dir2_leaf_readbuf(
11081108
struct xfs_mount *mp = dp->i_mount;
11091109
struct xfs_buf *bp = *bpp;
11101110
struct xfs_bmbt_irec *map = mip->map;
1111+
struct blk_plug plug;
11111112
int error = 0;
11121113
int length;
11131114
int i;
@@ -1236,6 +1237,7 @@ xfs_dir2_leaf_readbuf(
12361237
/*
12371238
* Do we need more readahead?
12381239
*/
1240+
blk_start_plug(&plug);
12391241
for (mip->ra_index = mip->ra_offset = i = 0;
12401242
mip->ra_want > mip->ra_current && i < mip->map_blocks;
12411243
i += mp->m_dirblkfsbs) {
@@ -1287,6 +1289,7 @@ xfs_dir2_leaf_readbuf(
12871289
}
12881290
}
12891291
}
1292+
blk_finish_plug(&plug);
12901293

12911294
out:
12921295
*bpp = bp;

‎fs/xfs/xfs_dquot.c‎

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -570,13 +570,13 @@ xfs_qm_dqtobp(
570570
xfs_buf_t **O_bpp,
571571
uint flags)
572572
{
573-
xfs_bmbt_irec_t map;
574-
int nmaps = 1, error;
575-
xfs_buf_t *bp;
576-
xfs_inode_t *quotip = XFS_DQ_TO_QIP(dqp);
577-
xfs_mount_t *mp = dqp->q_mount;
578-
xfs_dqid_t id = be32_to_cpu(dqp->q_core.d_id);
579-
xfs_trans_t *tp = (tpp ? *tpp : NULL);
573+
struct xfs_bmbt_irec map;
574+
int nmaps = 1, error;
575+
struct xfs_buf *bp;
576+
struct xfs_inode *quotip = xfs_dq_to_quota_inode(dqp);
577+
struct xfs_mount *mp = dqp->q_mount;
578+
xfs_dqid_t id = be32_to_cpu(dqp->q_core.d_id);
579+
struct xfs_trans *tp = (tpp ? *tpp : NULL);
580580

581581
dqp->q_fileoffset = (xfs_fileoff_t)id / mp->m_quotainfo->qi_dqperchunk;
582582

@@ -804,7 +804,7 @@ xfs_qm_dqget(
804804
xfs_dquot_t **O_dqpp) /* OUT : locked incore dquot */
805805
{
806806
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);
808808
struct xfs_dquot *dqp;
809809
int error;
810810

‎fs/xfs/xfs_dquot.h‎

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -143,10 +143,6 @@ static inline xfs_dquot_t *xfs_inode_dquot(struct xfs_inode *ip, int type)
143143
#define XFS_QM_ISUDQ(dqp) ((dqp)->dq_flags & XFS_DQ_USER)
144144
#define XFS_QM_ISPDQ(dqp) ((dqp)->dq_flags & XFS_DQ_PROJ)
145145
#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)
150146

151147
extern int xfs_qm_dqread(struct xfs_mount *, xfs_dqid_t, uint,
152148
uint, struct xfs_dquot **);

‎fs/xfs/xfs_fsops.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,7 @@ xfs_growfs_data_private(
176176
if (!bp)
177177
return EIO;
178178
if (bp->b_error) {
179-
int error = bp->b_error;
179+
error = bp->b_error;
180180
xfs_buf_relse(bp);
181181
return error;
182182
}

0 commit comments

Comments
 (0)