aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChristoph Hellwig <hch@lst.de>2016-09-18 21:26:41 -0400
committerDave Chinner <david@fromorbit.com>2016-09-18 21:26:41 -0400
commite372843a407ddff1e4c4acc7cdf3df9987bf48cc (patch)
treeb7b686f81f32ab70af5207d435e982d7bcc61f43
parent66642c5c1dea411dd2842159f9f297ce8e914994 (diff)
xfs: refactor xfs_setfilesize
Rename the current function to __xfs_setfilesize and add a non-static wrapper that also takes care of creating the transaction. This new helper will be used by the new iomap-based DAX path. Signed-off-by: Christoph Hellwig <hch@lst.de> Reviewed-by: Dave Chinner <dchinner@redhat.com> Signed-off-by: Dave Chinner <david@fromorbit.com>
-rw-r--r--fs/xfs/xfs_aops.c31
-rw-r--r--fs/xfs/xfs_aops.h1
2 files changed, 22 insertions, 10 deletions
diff --git a/fs/xfs/xfs_aops.c b/fs/xfs/xfs_aops.c
index 7575cfc3ad15..4a28fa91e3b1 100644
--- a/fs/xfs/xfs_aops.c
+++ b/fs/xfs/xfs_aops.c
@@ -200,7 +200,7 @@ xfs_setfilesize_trans_alloc(
200 * Update on-disk file size now that data has been written to disk. 200 * Update on-disk file size now that data has been written to disk.
201 */ 201 */
202STATIC int 202STATIC int
203xfs_setfilesize( 203__xfs_setfilesize(
204 struct xfs_inode *ip, 204 struct xfs_inode *ip,
205 struct xfs_trans *tp, 205 struct xfs_trans *tp,
206 xfs_off_t offset, 206 xfs_off_t offset,
@@ -225,6 +225,23 @@ xfs_setfilesize(
225 return xfs_trans_commit(tp); 225 return xfs_trans_commit(tp);
226} 226}
227 227
228int
229xfs_setfilesize(
230 struct xfs_inode *ip,
231 xfs_off_t offset,
232 size_t size)
233{
234 struct xfs_mount *mp = ip->i_mount;
235 struct xfs_trans *tp;
236 int error;
237
238 error = xfs_trans_alloc(mp, &M_RES(mp)->tr_fsyncts, 0, 0, 0, &tp);
239 if (error)
240 return error;
241
242 return __xfs_setfilesize(ip, tp, offset, size);
243}
244
228STATIC int 245STATIC int
229xfs_setfilesize_ioend( 246xfs_setfilesize_ioend(
230 struct xfs_ioend *ioend, 247 struct xfs_ioend *ioend,
@@ -247,7 +264,7 @@ xfs_setfilesize_ioend(
247 return error; 264 return error;
248 } 265 }
249 266
250 return xfs_setfilesize(ip, tp, ioend->io_offset, ioend->io_size); 267 return __xfs_setfilesize(ip, tp, ioend->io_offset, ioend->io_size);
251} 268}
252 269
253/* 270/*
@@ -1336,13 +1353,12 @@ xfs_end_io_direct_write(
1336{ 1353{
1337 struct inode *inode = file_inode(iocb->ki_filp); 1354 struct inode *inode = file_inode(iocb->ki_filp);
1338 struct xfs_inode *ip = XFS_I(inode); 1355 struct xfs_inode *ip = XFS_I(inode);
1339 struct xfs_mount *mp = ip->i_mount;
1340 uintptr_t flags = (uintptr_t)private; 1356 uintptr_t flags = (uintptr_t)private;
1341 int error = 0; 1357 int error = 0;
1342 1358
1343 trace_xfs_end_io_direct_write(ip, offset, size); 1359 trace_xfs_end_io_direct_write(ip, offset, size);
1344 1360
1345 if (XFS_FORCED_SHUTDOWN(mp)) 1361 if (XFS_FORCED_SHUTDOWN(ip->i_mount))
1346 return -EIO; 1362 return -EIO;
1347 1363
1348 if (size <= 0) 1364 if (size <= 0)
@@ -1380,14 +1396,9 @@ xfs_end_io_direct_write(
1380 1396
1381 error = xfs_iomap_write_unwritten(ip, offset, size); 1397 error = xfs_iomap_write_unwritten(ip, offset, size);
1382 } else if (flags & XFS_DIO_FLAG_APPEND) { 1398 } else if (flags & XFS_DIO_FLAG_APPEND) {
1383 struct xfs_trans *tp;
1384
1385 trace_xfs_end_io_direct_write_append(ip, offset, size); 1399 trace_xfs_end_io_direct_write_append(ip, offset, size);
1386 1400
1387 error = xfs_trans_alloc(mp, &M_RES(mp)->tr_fsyncts, 0, 0, 0, 1401 error = xfs_setfilesize(ip, offset, size);
1388 &tp);
1389 if (!error)
1390 error = xfs_setfilesize(ip, tp, offset, size);
1391 } 1402 }
1392 1403
1393 return error; 1404 return error;
diff --git a/fs/xfs/xfs_aops.h b/fs/xfs/xfs_aops.h
index bf2d9a141a73..1950e3bca2ac 100644
--- a/fs/xfs/xfs_aops.h
+++ b/fs/xfs/xfs_aops.h
@@ -62,6 +62,7 @@ int xfs_get_blocks_dax_fault(struct inode *inode, sector_t offset,
62 62
63int xfs_end_io_direct_write(struct kiocb *iocb, loff_t offset, 63int xfs_end_io_direct_write(struct kiocb *iocb, loff_t offset,
64 ssize_t size, void *private); 64 ssize_t size, void *private);
65int xfs_setfilesize(struct xfs_inode *ip, xfs_off_t offset, size_t size);
65 66
66extern void xfs_count_page_state(struct page *, int *, int *); 67extern void xfs_count_page_state(struct page *, int *, int *);
67extern struct block_device *xfs_find_bdev_for_inode(struct inode *); 68extern struct block_device *xfs_find_bdev_for_inode(struct inode *);