Skip to content

Commit 5619a69

Browse files
committed
Merge branch 'for-linus' of git://oss.sgi.com/xfs/xfs
* 'for-linus' of git://oss.sgi.com/xfs/xfs: (69 commits) xfs: add AIL pushing tracepoints xfs: put in missed fix for merge problem xfs: do not flush data workqueues in xfs_flush_buftarg xfs: remove XFS_bflush xfs: remove xfs_buf_target_name xfs: use xfs_ioerror_alert in xfs_buf_iodone_callbacks xfs: clean up xfs_ioerror_alert xfs: clean up buffer allocation xfs: remove buffers from the delwri list in xfs_buf_stale xfs: remove XFS_BUF_STALE and XFS_BUF_SUPER_STALE xfs: remove XFS_BUF_SET_VTYPE and XFS_BUF_SET_VTYPE_REF xfs: remove XFS_BUF_FINISH_IOWAIT xfs: remove xfs_get_buftarg_list xfs: fix buffer flushing during unmount xfs: optimize fsync on directories xfs: reduce the number of log forces from tail pushing xfs: Don't allocate new buffers on every call to _xfs_buf_find xfs: simplify xfs_trans_ijoin* again xfs: unlock the inode before log force in xfs_change_file_space xfs: unlock the inode before log force in xfs_fs_nfs_commit_metadata ...
2 parents 37be944 + 9e4c109 commit 5619a69

47 files changed

Lines changed: 2033 additions & 2324 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/xfs_alloc.c‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -452,7 +452,7 @@ xfs_alloc_read_agfl(
452452
if (error)
453453
return error;
454454
ASSERT(!xfs_buf_geterror(bp));
455-
XFS_BUF_SET_VTYPE_REF(bp, B_FS_AGFL, XFS_AGFL_REF);
455+
xfs_buf_set_ref(bp, XFS_AGFL_REF);
456456
*bpp = bp;
457457
return 0;
458458
}
@@ -2139,7 +2139,7 @@ xfs_read_agf(
21392139
xfs_trans_brelse(tp, *bpp);
21402140
return XFS_ERROR(EFSCORRUPTED);
21412141
}
2142-
XFS_BUF_SET_VTYPE_REF(*bpp, B_FS_AGF, XFS_AGF_REF);
2142+
xfs_buf_set_ref(*bpp, XFS_AGF_REF);
21432143
return 0;
21442144
}
21452145

‎fs/xfs/xfs_aops.c‎

Lines changed: 42 additions & 77 deletions
Original file line numberDiff line numberDiff line change
@@ -38,40 +38,6 @@
3838
#include <linux/pagevec.h>
3939
#include <linux/writeback.h>
4040

41-
42-
/*
43-
* Prime number of hash buckets since address is used as the key.
44-
*/
45-
#define NVSYNC 37
46-
#define to_ioend_wq(v) (&xfs_ioend_wq[((unsigned long)v) % NVSYNC])
47-
static wait_queue_head_t xfs_ioend_wq[NVSYNC];
48-
49-
void __init
50-
xfs_ioend_init(void)
51-
{
52-
int i;
53-
54-
for (i = 0; i < NVSYNC; i++)
55-
init_waitqueue_head(&xfs_ioend_wq[i]);
56-
}
57-
58-
void
59-
xfs_ioend_wait(
60-
xfs_inode_t *ip)
61-
{
62-
wait_queue_head_t *wq = to_ioend_wq(ip);
63-
64-
wait_event(*wq, (atomic_read(&ip->i_iocount) == 0));
65-
}
66-
67-
STATIC void
68-
xfs_ioend_wake(
69-
xfs_inode_t *ip)
70-
{
71-
if (atomic_dec_and_test(&ip->i_iocount))
72-
wake_up(to_ioend_wq(ip));
73-
}
74-
7541
void
7642
xfs_count_page_state(
7743
struct page *page,
@@ -115,25 +81,20 @@ xfs_destroy_ioend(
11581
xfs_ioend_t *ioend)
11682
{
11783
struct buffer_head *bh, *next;
118-
struct xfs_inode *ip = XFS_I(ioend->io_inode);
11984

12085
for (bh = ioend->io_buffer_head; bh; bh = next) {
12186
next = bh->b_private;
12287
bh->b_end_io(bh, !ioend->io_error);
12388
}
12489

125-
/*
126-
* Volume managers supporting multiple paths can send back ENODEV
127-
* when the final path disappears. In this case continuing to fill
128-
* the page cache with dirty data which cannot be written out is
129-
* evil, so prevent that.
130-
*/
131-
if (unlikely(ioend->io_error == -ENODEV)) {
132-
xfs_do_force_shutdown(ip->i_mount, SHUTDOWN_DEVICE_REQ,
133-
__FILE__, __LINE__);
90+
if (ioend->io_iocb) {
91+
if (ioend->io_isasync) {
92+
aio_complete(ioend->io_iocb, ioend->io_error ?
93+
ioend->io_error : ioend->io_result, 0);
94+
}
95+
inode_dio_done(ioend->io_inode);
13496
}
13597

136-
xfs_ioend_wake(ip);
13798
mempool_free(ioend, xfs_ioend_pool);
13899
}
139100

@@ -155,6 +116,15 @@ xfs_ioend_new_eof(
155116
return isize > ip->i_d.di_size ? isize : 0;
156117
}
157118

119+
/*
120+
* Fast and loose check if this write could update the on-disk inode size.
121+
*/
122+
static inline bool xfs_ioend_is_append(struct xfs_ioend *ioend)
123+
{
124+
return ioend->io_offset + ioend->io_size >
125+
XFS_I(ioend->io_inode)->i_d.di_size;
126+
}
127+
158128
/*
159129
* Update on-disk file size now that data has been written to disk. The
160130
* current in-memory file size is i_size. If a write is beyond eof i_new_size
@@ -173,9 +143,6 @@ xfs_setfilesize(
173143
xfs_inode_t *ip = XFS_I(ioend->io_inode);
174144
xfs_fsize_t isize;
175145

176-
if (unlikely(ioend->io_error))
177-
return 0;
178-
179146
if (!xfs_ilock_nowait(ip, XFS_ILOCK_EXCL))
180147
return EAGAIN;
181148

@@ -192,6 +159,9 @@ xfs_setfilesize(
192159

193160
/*
194161
* Schedule IO completion handling on the final put of an ioend.
162+
*
163+
* If there is no work to do we might as well call it a day and free the
164+
* ioend right now.
195165
*/
196166
STATIC void
197167
xfs_finish_ioend(
@@ -200,8 +170,10 @@ xfs_finish_ioend(
200170
if (atomic_dec_and_test(&ioend->io_remaining)) {
201171
if (ioend->io_type == IO_UNWRITTEN)
202172
queue_work(xfsconvertd_workqueue, &ioend->io_work);
203-
else
173+
else if (xfs_ioend_is_append(ioend))
204174
queue_work(xfsdatad_workqueue, &ioend->io_work);
175+
else
176+
xfs_destroy_ioend(ioend);
205177
}
206178
}
207179

@@ -216,17 +188,24 @@ xfs_end_io(
216188
struct xfs_inode *ip = XFS_I(ioend->io_inode);
217189
int error = 0;
218190

191+
if (XFS_FORCED_SHUTDOWN(ip->i_mount)) {
192+
error = -EIO;
193+
goto done;
194+
}
195+
if (ioend->io_error)
196+
goto done;
197+
219198
/*
220199
* For unwritten extents we need to issue transactions to convert a
221200
* range to normal written extens after the data I/O has finished.
222201
*/
223-
if (ioend->io_type == IO_UNWRITTEN &&
224-
likely(!ioend->io_error && !XFS_FORCED_SHUTDOWN(ip->i_mount))) {
225-
202+
if (ioend->io_type == IO_UNWRITTEN) {
226203
error = xfs_iomap_write_unwritten(ip, ioend->io_offset,
227204
ioend->io_size);
228-
if (error)
229-
ioend->io_error = error;
205+
if (error) {
206+
ioend->io_error = -error;
207+
goto done;
208+
}
230209
}
231210

232211
/*
@@ -236,6 +215,7 @@ xfs_end_io(
236215
error = xfs_setfilesize(ioend);
237216
ASSERT(!error || error == EAGAIN);
238217

218+
done:
239219
/*
240220
* If we didn't complete processing of the ioend, requeue it to the
241221
* tail of the workqueue for another attempt later. Otherwise destroy
@@ -247,8 +227,6 @@ xfs_end_io(
247227
/* ensure we don't spin on blocked ioends */
248228
delay(1);
249229
} else {
250-
if (ioend->io_iocb)
251-
aio_complete(ioend->io_iocb, ioend->io_result, 0);
252230
xfs_destroy_ioend(ioend);
253231
}
254232
}
@@ -285,13 +263,13 @@ xfs_alloc_ioend(
285263
* all the I/O from calling the completion routine too early.
286264
*/
287265
atomic_set(&ioend->io_remaining, 1);
266+
ioend->io_isasync = 0;
288267
ioend->io_error = 0;
289268
ioend->io_list = NULL;
290269
ioend->io_type = type;
291270
ioend->io_inode = inode;
292271
ioend->io_buffer_head = NULL;
293272
ioend->io_buffer_tail = NULL;
294-
atomic_inc(&XFS_I(ioend->io_inode)->i_iocount);
295273
ioend->io_offset = 0;
296274
ioend->io_size = 0;
297275
ioend->io_iocb = NULL;
@@ -337,8 +315,8 @@ xfs_map_blocks(
337315
count = mp->m_maxioffset - offset;
338316
end_fsb = XFS_B_TO_FSB(mp, (xfs_ufsize_t)offset + count);
339317
offset_fsb = XFS_B_TO_FSBT(mp, offset);
340-
error = xfs_bmapi(NULL, ip, offset_fsb, end_fsb - offset_fsb,
341-
bmapi_flags, NULL, 0, imap, &nimaps, NULL);
318+
error = xfs_bmapi_read(ip, offset_fsb, end_fsb - offset_fsb,
319+
imap, &nimaps, bmapi_flags);
342320
xfs_iunlock(ip, XFS_ILOCK_SHARED);
343321

344322
if (error)
@@ -551,7 +529,6 @@ xfs_cancel_ioend(
551529
unlock_buffer(bh);
552530
} while ((bh = next_bh) != NULL);
553531

554-
xfs_ioend_wake(XFS_I(ioend->io_inode));
555532
mempool_free(ioend, xfs_ioend_pool);
556533
} while ((ioend = next) != NULL);
557534
}
@@ -1161,8 +1138,8 @@ __xfs_get_blocks(
11611138
end_fsb = XFS_B_TO_FSB(mp, (xfs_ufsize_t)offset + size);
11621139
offset_fsb = XFS_B_TO_FSBT(mp, offset);
11631140

1164-
error = xfs_bmapi(NULL, ip, offset_fsb, end_fsb - offset_fsb,
1165-
XFS_BMAPI_ENTIRE, NULL, 0, &imap, &nimaps, NULL);
1141+
error = xfs_bmapi_read(ip, offset_fsb, end_fsb - offset_fsb,
1142+
&imap, &nimaps, XFS_BMAPI_ENTIRE);
11661143
if (error)
11671144
goto out_unlock;
11681145

@@ -1300,7 +1277,6 @@ xfs_end_io_direct_write(
13001277
bool is_async)
13011278
{
13021279
struct xfs_ioend *ioend = iocb->private;
1303-
struct inode *inode = ioend->io_inode;
13041280

13051281
/*
13061282
* blockdev_direct_IO can return an error even after the I/O
@@ -1311,28 +1287,17 @@ xfs_end_io_direct_write(
13111287

13121288
ioend->io_offset = offset;
13131289
ioend->io_size = size;
1290+
ioend->io_iocb = iocb;
1291+
ioend->io_result = ret;
13141292
if (private && size > 0)
13151293
ioend->io_type = IO_UNWRITTEN;
13161294

13171295
if (is_async) {
1318-
/*
1319-
* If we are converting an unwritten extent we need to delay
1320-
* the AIO completion until after the unwrittent extent
1321-
* conversion has completed, otherwise do it ASAP.
1322-
*/
1323-
if (ioend->io_type == IO_UNWRITTEN) {
1324-
ioend->io_iocb = iocb;
1325-
ioend->io_result = ret;
1326-
} else {
1327-
aio_complete(iocb, ret, 0);
1328-
}
1296+
ioend->io_isasync = 1;
13291297
xfs_finish_ioend(ioend);
13301298
} else {
13311299
xfs_finish_ioend_sync(ioend);
13321300
}
1333-
1334-
/* XXX: probably should move into the real I/O completion handler */
1335-
inode_dio_done(inode);
13361301
}
13371302

13381303
STATIC ssize_t

‎fs/xfs/xfs_aops.h‎

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ typedef struct xfs_ioend {
4747
unsigned int io_type; /* delalloc / unwritten */
4848
int io_error; /* I/O error code */
4949
atomic_t io_remaining; /* hold count */
50+
unsigned int io_isasync : 1; /* needs aio_complete */
5051
struct inode *io_inode; /* file being written to */
5152
struct buffer_head *io_buffer_head;/* buffer linked list head */
5253
struct buffer_head *io_buffer_tail;/* buffer linked list tail */
@@ -60,9 +61,6 @@ typedef struct xfs_ioend {
6061
extern const struct address_space_operations xfs_address_space_operations;
6162
extern int xfs_get_blocks(struct inode *, sector_t, struct buffer_head *, int);
6263

63-
extern void xfs_ioend_init(void);
64-
extern void xfs_ioend_wait(struct xfs_inode *);
65-
6664
extern void xfs_count_page_state(struct page *, int *, int *);
6765

6866
#endif /* __XFS_AOPS_H__ */

0 commit comments

Comments
 (0)