Skip to content

Commit 369c4f5

Browse files
committed
Merge tag 'for-linus-Jun-21-2012' of git://oss.sgi.com/xfs/xfs
Pull XFS fixes from Ben Myers: - Fix stale data exposure with unwritten extents - Fix a warning in xfs_alloc_vextent with ODEBUG - Fix overallocation and alignment of pages for xfs_bufs - Fix a cursor leak - Fix a log hang - Fix a crash related to xfs_sync_worker - Rename xfs log structure from struct log to struct xlog so we can use crash dumps effectively * tag 'for-linus-Jun-21-2012' of git://oss.sgi.com/xfs/xfs: xfs: rename log structure to xlog xfs: shutdown xfs_sync_worker before the log xfs: Fix overallocation in xfs_buf_allocate_memory() xfs: fix allocbt cursor leak in xfs_alloc_ag_vextent_near xfs: check for stale inode before acquiring iflock on push xfs: fix debug_object WARN at xfs_alloc_vextent() xfs: xfs_vm_writepage clear iomap_valid when !buffer_uptodate (REV2)
2 parents a116371 + f7bdf03 commit 369c4f5

File tree

11 files changed

+153
-131
lines changed

11 files changed

+153
-131
lines changed

fs/xfs/xfs_alloc.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1080,6 +1080,7 @@ xfs_alloc_ag_vextent_near(
10801080
goto restart;
10811081
}
10821082

1083+
xfs_btree_del_cursor(cnt_cur, XFS_BTREE_NOERROR);
10831084
trace_xfs_alloc_size_neither(args);
10841085
args->agbno = NULLAGBLOCK;
10851086
return 0;
@@ -2441,7 +2442,7 @@ xfs_alloc_vextent(
24412442
DECLARE_COMPLETION_ONSTACK(done);
24422443

24432444
args->done = &done;
2444-
INIT_WORK(&args->work, xfs_alloc_vextent_worker);
2445+
INIT_WORK_ONSTACK(&args->work, xfs_alloc_vextent_worker);
24452446
queue_work(xfs_alloc_wq, &args->work);
24462447
wait_for_completion(&done);
24472448
return args->result;

fs/xfs/xfs_aops.c

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -981,10 +981,15 @@ xfs_vm_writepage(
981981
imap_valid = 0;
982982
}
983983
} else {
984-
if (PageUptodate(page)) {
984+
if (PageUptodate(page))
985985
ASSERT(buffer_mapped(bh));
986-
imap_valid = 0;
987-
}
986+
/*
987+
* This buffer is not uptodate and will not be
988+
* written to disk. Ensure that we will put any
989+
* subsequent writeable buffers into a new
990+
* ioend.
991+
*/
992+
imap_valid = 0;
988993
continue;
989994
}
990995

fs/xfs/xfs_buf.c

Lines changed: 2 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -201,14 +201,7 @@ xfs_buf_alloc(
201201
bp->b_length = numblks;
202202
bp->b_io_length = numblks;
203203
bp->b_flags = flags;
204-
205-
/*
206-
* We do not set the block number here in the buffer because we have not
207-
* finished initialising the buffer. We insert the buffer into the cache
208-
* in this state, so this ensures that we are unable to do IO on a
209-
* buffer that hasn't been fully initialised.
210-
*/
211-
bp->b_bn = XFS_BUF_DADDR_NULL;
204+
bp->b_bn = blkno;
212205
atomic_set(&bp->b_pin_count, 0);
213206
init_waitqueue_head(&bp->b_waiters);
214207

@@ -567,11 +560,6 @@ xfs_buf_get(
567560
if (bp != new_bp)
568561
xfs_buf_free(new_bp);
569562

570-
/*
571-
* Now we have a workable buffer, fill in the block number so
572-
* that we can do IO on it.
573-
*/
574-
bp->b_bn = blkno;
575563
bp->b_io_length = bp->b_length;
576564

577565
found:
@@ -772,7 +760,7 @@ xfs_buf_get_uncached(
772760
int error, i;
773761
xfs_buf_t *bp;
774762

775-
bp = xfs_buf_alloc(target, 0, numblks, 0);
763+
bp = xfs_buf_alloc(target, XFS_BUF_DADDR_NULL, numblks, 0);
776764
if (unlikely(bp == NULL))
777765
goto fail;
778766

fs/xfs/xfs_inode_item.c

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -504,6 +504,14 @@ xfs_inode_item_push(
504504
goto out_unlock;
505505
}
506506

507+
/*
508+
* Stale inode items should force out the iclog.
509+
*/
510+
if (ip->i_flags & XFS_ISTALE) {
511+
rval = XFS_ITEM_PINNED;
512+
goto out_unlock;
513+
}
514+
507515
/*
508516
* Someone else is already flushing the inode. Nothing we can do
509517
* here but wait for the flush to finish and remove the item from
@@ -514,15 +522,6 @@ xfs_inode_item_push(
514522
goto out_unlock;
515523
}
516524

517-
/*
518-
* Stale inode items should force out the iclog.
519-
*/
520-
if (ip->i_flags & XFS_ISTALE) {
521-
xfs_ifunlock(ip);
522-
xfs_iunlock(ip, XFS_ILOCK_SHARED);
523-
return XFS_ITEM_PINNED;
524-
}
525-
526525
ASSERT(iip->ili_fields != 0 || XFS_FORCED_SHUTDOWN(ip->i_mount));
527526
ASSERT(iip->ili_logged == 0 || XFS_FORCED_SHUTDOWN(ip->i_mount));
528527

fs/xfs/xfs_log.c

Lines changed: 45 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -38,13 +38,21 @@
3838
kmem_zone_t *xfs_log_ticket_zone;
3939

4040
/* Local miscellaneous function prototypes */
41-
STATIC int xlog_commit_record(struct log *log, struct xlog_ticket *ticket,
42-
xlog_in_core_t **, xfs_lsn_t *);
41+
STATIC int
42+
xlog_commit_record(
43+
struct xlog *log,
44+
struct xlog_ticket *ticket,
45+
struct xlog_in_core **iclog,
46+
xfs_lsn_t *commitlsnp);
47+
4348
STATIC xlog_t * xlog_alloc_log(xfs_mount_t *mp,
4449
xfs_buftarg_t *log_target,
4550
xfs_daddr_t blk_offset,
4651
int num_bblks);
47-
STATIC int xlog_space_left(struct log *log, atomic64_t *head);
52+
STATIC int
53+
xlog_space_left(
54+
struct xlog *log,
55+
atomic64_t *head);
4856
STATIC int xlog_sync(xlog_t *log, xlog_in_core_t *iclog);
4957
STATIC void xlog_dealloc_log(xlog_t *log);
5058

@@ -64,16 +72,20 @@ STATIC void xlog_state_switch_iclogs(xlog_t *log,
6472
int eventual_size);
6573
STATIC void xlog_state_want_sync(xlog_t *log, xlog_in_core_t *iclog);
6674

67-
STATIC void xlog_grant_push_ail(struct log *log,
68-
int need_bytes);
75+
STATIC void
76+
xlog_grant_push_ail(
77+
struct xlog *log,
78+
int need_bytes);
6979
STATIC void xlog_regrant_reserve_log_space(xlog_t *log,
7080
xlog_ticket_t *ticket);
7181
STATIC void xlog_ungrant_log_space(xlog_t *log,
7282
xlog_ticket_t *ticket);
7383

7484
#if defined(DEBUG)
7585
STATIC void xlog_verify_dest_ptr(xlog_t *log, char *ptr);
76-
STATIC void xlog_verify_grant_tail(struct log *log);
86+
STATIC void
87+
xlog_verify_grant_tail(
88+
struct xlog *log);
7789
STATIC void xlog_verify_iclog(xlog_t *log, xlog_in_core_t *iclog,
7890
int count, boolean_t syncing);
7991
STATIC void xlog_verify_tail_lsn(xlog_t *log, xlog_in_core_t *iclog,
@@ -89,9 +101,9 @@ STATIC int xlog_iclogs_empty(xlog_t *log);
89101

90102
static void
91103
xlog_grant_sub_space(
92-
struct log *log,
93-
atomic64_t *head,
94-
int bytes)
104+
struct xlog *log,
105+
atomic64_t *head,
106+
int bytes)
95107
{
96108
int64_t head_val = atomic64_read(head);
97109
int64_t new, old;
@@ -115,9 +127,9 @@ xlog_grant_sub_space(
115127

116128
static void
117129
xlog_grant_add_space(
118-
struct log *log,
119-
atomic64_t *head,
120-
int bytes)
130+
struct xlog *log,
131+
atomic64_t *head,
132+
int bytes)
121133
{
122134
int64_t head_val = atomic64_read(head);
123135
int64_t new, old;
@@ -165,7 +177,7 @@ xlog_grant_head_wake_all(
165177

166178
static inline int
167179
xlog_ticket_reservation(
168-
struct log *log,
180+
struct xlog *log,
169181
struct xlog_grant_head *head,
170182
struct xlog_ticket *tic)
171183
{
@@ -182,7 +194,7 @@ xlog_ticket_reservation(
182194

183195
STATIC bool
184196
xlog_grant_head_wake(
185-
struct log *log,
197+
struct xlog *log,
186198
struct xlog_grant_head *head,
187199
int *free_bytes)
188200
{
@@ -204,7 +216,7 @@ xlog_grant_head_wake(
204216

205217
STATIC int
206218
xlog_grant_head_wait(
207-
struct log *log,
219+
struct xlog *log,
208220
struct xlog_grant_head *head,
209221
struct xlog_ticket *tic,
210222
int need_bytes)
@@ -256,7 +268,7 @@ xlog_grant_head_wait(
256268
*/
257269
STATIC int
258270
xlog_grant_head_check(
259-
struct log *log,
271+
struct xlog *log,
260272
struct xlog_grant_head *head,
261273
struct xlog_ticket *tic,
262274
int *need_bytes)
@@ -323,7 +335,7 @@ xfs_log_regrant(
323335
struct xfs_mount *mp,
324336
struct xlog_ticket *tic)
325337
{
326-
struct log *log = mp->m_log;
338+
struct xlog *log = mp->m_log;
327339
int need_bytes;
328340
int error = 0;
329341

@@ -389,7 +401,7 @@ xfs_log_reserve(
389401
bool permanent,
390402
uint t_type)
391403
{
392-
struct log *log = mp->m_log;
404+
struct xlog *log = mp->m_log;
393405
struct xlog_ticket *tic;
394406
int need_bytes;
395407
int error = 0;
@@ -465,7 +477,7 @@ xfs_log_done(
465477
struct xlog_in_core **iclog,
466478
uint flags)
467479
{
468-
struct log *log = mp->m_log;
480+
struct xlog *log = mp->m_log;
469481
xfs_lsn_t lsn = 0;
470482

471483
if (XLOG_FORCED_SHUTDOWN(log) ||
@@ -810,6 +822,7 @@ xfs_log_unmount_write(xfs_mount_t *mp)
810822
void
811823
xfs_log_unmount(xfs_mount_t *mp)
812824
{
825+
cancel_delayed_work_sync(&mp->m_sync_work);
813826
xfs_trans_ail_destroy(mp);
814827
xlog_dealloc_log(mp->m_log);
815828
}
@@ -838,7 +851,7 @@ void
838851
xfs_log_space_wake(
839852
struct xfs_mount *mp)
840853
{
841-
struct log *log = mp->m_log;
854+
struct xlog *log = mp->m_log;
842855
int free_bytes;
843856

844857
if (XLOG_FORCED_SHUTDOWN(log))
@@ -916,7 +929,7 @@ xfs_lsn_t
916929
xlog_assign_tail_lsn_locked(
917930
struct xfs_mount *mp)
918931
{
919-
struct log *log = mp->m_log;
932+
struct xlog *log = mp->m_log;
920933
struct xfs_log_item *lip;
921934
xfs_lsn_t tail_lsn;
922935

@@ -965,7 +978,7 @@ xlog_assign_tail_lsn(
965978
*/
966979
STATIC int
967980
xlog_space_left(
968-
struct log *log,
981+
struct xlog *log,
969982
atomic64_t *head)
970983
{
971984
int free_bytes;
@@ -1277,7 +1290,7 @@ xlog_alloc_log(xfs_mount_t *mp,
12771290
*/
12781291
STATIC int
12791292
xlog_commit_record(
1280-
struct log *log,
1293+
struct xlog *log,
12811294
struct xlog_ticket *ticket,
12821295
struct xlog_in_core **iclog,
12831296
xfs_lsn_t *commitlsnp)
@@ -1311,7 +1324,7 @@ xlog_commit_record(
13111324
*/
13121325
STATIC void
13131326
xlog_grant_push_ail(
1314-
struct log *log,
1327+
struct xlog *log,
13151328
int need_bytes)
13161329
{
13171330
xfs_lsn_t threshold_lsn = 0;
@@ -1790,7 +1803,7 @@ xlog_write_start_rec(
17901803

17911804
static xlog_op_header_t *
17921805
xlog_write_setup_ophdr(
1793-
struct log *log,
1806+
struct xlog *log,
17941807
struct xlog_op_header *ophdr,
17951808
struct xlog_ticket *ticket,
17961809
uint flags)
@@ -1873,7 +1886,7 @@ xlog_write_setup_copy(
18731886

18741887
static int
18751888
xlog_write_copy_finish(
1876-
struct log *log,
1889+
struct xlog *log,
18771890
struct xlog_in_core *iclog,
18781891
uint flags,
18791892
int *record_cnt,
@@ -1958,7 +1971,7 @@ xlog_write_copy_finish(
19581971
*/
19591972
int
19601973
xlog_write(
1961-
struct log *log,
1974+
struct xlog *log,
19621975
struct xfs_log_vec *log_vector,
19631976
struct xlog_ticket *ticket,
19641977
xfs_lsn_t *start_lsn,
@@ -2821,7 +2834,7 @@ _xfs_log_force(
28212834
uint flags,
28222835
int *log_flushed)
28232836
{
2824-
struct log *log = mp->m_log;
2837+
struct xlog *log = mp->m_log;
28252838
struct xlog_in_core *iclog;
28262839
xfs_lsn_t lsn;
28272840

@@ -2969,7 +2982,7 @@ _xfs_log_force_lsn(
29692982
uint flags,
29702983
int *log_flushed)
29712984
{
2972-
struct log *log = mp->m_log;
2985+
struct xlog *log = mp->m_log;
29732986
struct xlog_in_core *iclog;
29742987
int already_slept = 0;
29752988

@@ -3147,7 +3160,7 @@ xfs_log_ticket_get(
31473160
*/
31483161
xlog_ticket_t *
31493162
xlog_ticket_alloc(
3150-
struct log *log,
3163+
struct xlog *log,
31513164
int unit_bytes,
31523165
int cnt,
31533166
char client,
@@ -3278,7 +3291,7 @@ xlog_ticket_alloc(
32783291
*/
32793292
void
32803293
xlog_verify_dest_ptr(
3281-
struct log *log,
3294+
struct xlog *log,
32823295
char *ptr)
32833296
{
32843297
int i;
@@ -3307,7 +3320,7 @@ xlog_verify_dest_ptr(
33073320
*/
33083321
STATIC void
33093322
xlog_verify_grant_tail(
3310-
struct log *log)
3323+
struct xlog *log)
33113324
{
33123325
int tail_cycle, tail_blocks;
33133326
int cycle, space;

0 commit comments

Comments
 (0)