diff options
author | Lachlan McIlroy <lachlan@sgi.com> | 2007-05-07 23:49:27 -0400 |
---|---|---|
committer | Tim Shimmin <tes@sgi.com> | 2007-05-07 23:49:27 -0400 |
commit | d3cf209476b72c83907a412b6708c5e498410aa7 (patch) | |
tree | 5e7a85751ae03b9eb3110e1cfc147b3492ae0fa5 | |
parent | 424ea91ba61c1cdc2dac68576c97030cbf47d84f (diff) |
[XFS] propogate return codes from flush routines
This patch handles error return values in fs_flush_pages and
fs_flushinval_pages. It changes the prototype of fs_flushinval_pages so we
can propogate the errors and handle them at higher layers. I also modified
xfs_itruncate_start so that it could propogate the error further.
SGI-PV: 961990
SGI-Modid: xfs-linux-melb:xfs-kern:28231a
Signed-off-by: Lachlan McIlroy <lachlan@sgi.com>
Signed-off-by: Stewart Smith <stewart@flamingspork.com>
Signed-off-by: Tim Shimmin <tes@sgi.com>
-rw-r--r-- | fs/xfs/linux-2.6/xfs_fs_subr.c | 21 | ||||
-rw-r--r-- | fs/xfs/linux-2.6/xfs_fs_subr.h | 2 | ||||
-rw-r--r-- | fs/xfs/linux-2.6/xfs_lrw.c | 12 | ||||
-rw-r--r-- | fs/xfs/linux-2.6/xfs_vnode.h | 2 | ||||
-rw-r--r-- | fs/xfs/xfs_dfrag.c | 4 | ||||
-rw-r--r-- | fs/xfs/xfs_inode.c | 8 | ||||
-rw-r--r-- | fs/xfs/xfs_inode.h | 2 | ||||
-rw-r--r-- | fs/xfs/xfs_utils.c | 6 | ||||
-rw-r--r-- | fs/xfs/xfs_vfsops.c | 2 | ||||
-rw-r--r-- | fs/xfs/xfs_vnodeops.c | 16 |
10 files changed, 53 insertions, 22 deletions
diff --git a/fs/xfs/linux-2.6/xfs_fs_subr.c b/fs/xfs/linux-2.6/xfs_fs_subr.c index dc0562828e76..2eb87cd082af 100644 --- a/fs/xfs/linux-2.6/xfs_fs_subr.c +++ b/fs/xfs/linux-2.6/xfs_fs_subr.c | |||
@@ -35,7 +35,7 @@ fs_tosspages( | |||
35 | truncate_inode_pages(ip->i_mapping, first); | 35 | truncate_inode_pages(ip->i_mapping, first); |
36 | } | 36 | } |
37 | 37 | ||
38 | void | 38 | int |
39 | fs_flushinval_pages( | 39 | fs_flushinval_pages( |
40 | bhv_desc_t *bdp, | 40 | bhv_desc_t *bdp, |
41 | xfs_off_t first, | 41 | xfs_off_t first, |
@@ -44,13 +44,16 @@ fs_flushinval_pages( | |||
44 | { | 44 | { |
45 | bhv_vnode_t *vp = BHV_TO_VNODE(bdp); | 45 | bhv_vnode_t *vp = BHV_TO_VNODE(bdp); |
46 | struct inode *ip = vn_to_inode(vp); | 46 | struct inode *ip = vn_to_inode(vp); |
47 | int ret = 0; | ||
47 | 48 | ||
48 | if (VN_CACHED(vp)) { | 49 | if (VN_CACHED(vp)) { |
49 | if (VN_TRUNC(vp)) | 50 | if (VN_TRUNC(vp)) |
50 | VUNTRUNCATE(vp); | 51 | VUNTRUNCATE(vp); |
51 | filemap_write_and_wait(ip->i_mapping); | 52 | ret = filemap_write_and_wait(ip->i_mapping); |
52 | truncate_inode_pages(ip->i_mapping, first); | 53 | if (!ret) |
54 | truncate_inode_pages(ip->i_mapping, first); | ||
53 | } | 55 | } |
56 | return ret; | ||
54 | } | 57 | } |
55 | 58 | ||
56 | int | 59 | int |
@@ -63,14 +66,18 @@ fs_flush_pages( | |||
63 | { | 66 | { |
64 | bhv_vnode_t *vp = BHV_TO_VNODE(bdp); | 67 | bhv_vnode_t *vp = BHV_TO_VNODE(bdp); |
65 | struct inode *ip = vn_to_inode(vp); | 68 | struct inode *ip = vn_to_inode(vp); |
69 | int ret = 0; | ||
70 | int ret2; | ||
66 | 71 | ||
67 | if (VN_DIRTY(vp)) { | 72 | if (VN_DIRTY(vp)) { |
68 | if (VN_TRUNC(vp)) | 73 | if (VN_TRUNC(vp)) |
69 | VUNTRUNCATE(vp); | 74 | VUNTRUNCATE(vp); |
70 | filemap_fdatawrite(ip->i_mapping); | 75 | ret = filemap_fdatawrite(ip->i_mapping); |
71 | if (flags & XFS_B_ASYNC) | 76 | if (flags & XFS_B_ASYNC) |
72 | return 0; | 77 | return ret; |
73 | filemap_fdatawait(ip->i_mapping); | 78 | ret2 = filemap_fdatawait(ip->i_mapping); |
79 | if (!ret) | ||
80 | ret = ret2; | ||
74 | } | 81 | } |
75 | return 0; | 82 | return ret; |
76 | } | 83 | } |
diff --git a/fs/xfs/linux-2.6/xfs_fs_subr.h b/fs/xfs/linux-2.6/xfs_fs_subr.h index aee9ccdd18f7..c1b53118a303 100644 --- a/fs/xfs/linux-2.6/xfs_fs_subr.h +++ b/fs/xfs/linux-2.6/xfs_fs_subr.h | |||
@@ -23,7 +23,7 @@ extern int fs_noerr(void); | |||
23 | extern int fs_nosys(void); | 23 | extern int fs_nosys(void); |
24 | extern void fs_noval(void); | 24 | extern void fs_noval(void); |
25 | extern void fs_tosspages(bhv_desc_t *, xfs_off_t, xfs_off_t, int); | 25 | extern void fs_tosspages(bhv_desc_t *, xfs_off_t, xfs_off_t, int); |
26 | extern void fs_flushinval_pages(bhv_desc_t *, xfs_off_t, xfs_off_t, int); | 26 | extern int fs_flushinval_pages(bhv_desc_t *, xfs_off_t, xfs_off_t, int); |
27 | extern int fs_flush_pages(bhv_desc_t *, xfs_off_t, xfs_off_t, uint64_t, int); | 27 | extern int fs_flush_pages(bhv_desc_t *, xfs_off_t, xfs_off_t, uint64_t, int); |
28 | 28 | ||
29 | #endif /* __XFS_FS_SUBR_H__ */ | 29 | #endif /* __XFS_FS_SUBR_H__ */ |
diff --git a/fs/xfs/linux-2.6/xfs_lrw.c b/fs/xfs/linux-2.6/xfs_lrw.c index ff8d64eba9f8..8e46c9798fbf 100644 --- a/fs/xfs/linux-2.6/xfs_lrw.c +++ b/fs/xfs/linux-2.6/xfs_lrw.c | |||
@@ -191,7 +191,7 @@ xfs_read( | |||
191 | struct file *file = iocb->ki_filp; | 191 | struct file *file = iocb->ki_filp; |
192 | struct inode *inode = file->f_mapping->host; | 192 | struct inode *inode = file->f_mapping->host; |
193 | size_t size = 0; | 193 | size_t size = 0; |
194 | ssize_t ret; | 194 | ssize_t ret = 0; |
195 | xfs_fsize_t n; | 195 | xfs_fsize_t n; |
196 | xfs_inode_t *ip; | 196 | xfs_inode_t *ip; |
197 | xfs_mount_t *mp; | 197 | xfs_mount_t *mp; |
@@ -263,9 +263,13 @@ xfs_read( | |||
263 | 263 | ||
264 | if (unlikely(ioflags & IO_ISDIRECT)) { | 264 | if (unlikely(ioflags & IO_ISDIRECT)) { |
265 | if (VN_CACHED(vp)) | 265 | if (VN_CACHED(vp)) |
266 | bhv_vop_flushinval_pages(vp, ctooff(offtoct(*offset)), | 266 | ret = bhv_vop_flushinval_pages(vp, ctooff(offtoct(*offset)), |
267 | -1, FI_REMAPF_LOCKED); | 267 | -1, FI_REMAPF_LOCKED); |
268 | mutex_unlock(&inode->i_mutex); | 268 | mutex_unlock(&inode->i_mutex); |
269 | if (ret) { | ||
270 | xfs_iunlock(ip, XFS_IOLOCK_SHARED); | ||
271 | return ret; | ||
272 | } | ||
269 | } | 273 | } |
270 | 274 | ||
271 | xfs_rw_enter_trace(XFS_READ_ENTER, &ip->i_iocore, | 275 | xfs_rw_enter_trace(XFS_READ_ENTER, &ip->i_iocore, |
@@ -814,8 +818,10 @@ retry: | |||
814 | if (need_flush) { | 818 | if (need_flush) { |
815 | xfs_inval_cached_trace(io, pos, -1, | 819 | xfs_inval_cached_trace(io, pos, -1, |
816 | ctooff(offtoct(pos)), -1); | 820 | ctooff(offtoct(pos)), -1); |
817 | bhv_vop_flushinval_pages(vp, ctooff(offtoct(pos)), | 821 | error = bhv_vop_flushinval_pages(vp, ctooff(offtoct(pos)), |
818 | -1, FI_REMAPF_LOCKED); | 822 | -1, FI_REMAPF_LOCKED); |
823 | if (error) | ||
824 | goto out_unlock_internal; | ||
819 | } | 825 | } |
820 | 826 | ||
821 | if (need_i_mutex) { | 827 | if (need_i_mutex) { |
diff --git a/fs/xfs/linux-2.6/xfs_vnode.h b/fs/xfs/linux-2.6/xfs_vnode.h index b76118cf4897..d1b2d01843d1 100644 --- a/fs/xfs/linux-2.6/xfs_vnode.h +++ b/fs/xfs/linux-2.6/xfs_vnode.h | |||
@@ -194,7 +194,7 @@ typedef int (*vop_attr_list_t)(bhv_desc_t *, char *, int, int, | |||
194 | typedef void (*vop_link_removed_t)(bhv_desc_t *, bhv_vnode_t *, int); | 194 | typedef void (*vop_link_removed_t)(bhv_desc_t *, bhv_vnode_t *, int); |
195 | typedef void (*vop_vnode_change_t)(bhv_desc_t *, bhv_vchange_t, __psint_t); | 195 | typedef void (*vop_vnode_change_t)(bhv_desc_t *, bhv_vchange_t, __psint_t); |
196 | typedef void (*vop_ptossvp_t)(bhv_desc_t *, xfs_off_t, xfs_off_t, int); | 196 | typedef void (*vop_ptossvp_t)(bhv_desc_t *, xfs_off_t, xfs_off_t, int); |
197 | typedef void (*vop_pflushinvalvp_t)(bhv_desc_t *, xfs_off_t, xfs_off_t, int); | 197 | typedef int (*vop_pflushinvalvp_t)(bhv_desc_t *, xfs_off_t, xfs_off_t, int); |
198 | typedef int (*vop_pflushvp_t)(bhv_desc_t *, xfs_off_t, xfs_off_t, | 198 | typedef int (*vop_pflushvp_t)(bhv_desc_t *, xfs_off_t, xfs_off_t, |
199 | uint64_t, int); | 199 | uint64_t, int); |
200 | typedef int (*vop_iflush_t)(bhv_desc_t *, int); | 200 | typedef int (*vop_iflush_t)(bhv_desc_t *, int); |
diff --git a/fs/xfs/xfs_dfrag.c b/fs/xfs/xfs_dfrag.c index fb6f22c511e2..de35d18cc002 100644 --- a/fs/xfs/xfs_dfrag.c +++ b/fs/xfs/xfs_dfrag.c | |||
@@ -199,7 +199,9 @@ xfs_swap_extents( | |||
199 | 199 | ||
200 | if (VN_CACHED(tvp) != 0) { | 200 | if (VN_CACHED(tvp) != 0) { |
201 | xfs_inval_cached_trace(&tip->i_iocore, 0, -1, 0, -1); | 201 | xfs_inval_cached_trace(&tip->i_iocore, 0, -1, 0, -1); |
202 | bhv_vop_flushinval_pages(tvp, 0, -1, FI_REMAPF_LOCKED); | 202 | error = bhv_vop_flushinval_pages(tvp, 0, -1, FI_REMAPF_LOCKED); |
203 | if (error) | ||
204 | goto error0; | ||
203 | } | 205 | } |
204 | 206 | ||
205 | /* Verify O_DIRECT for ftmp */ | 207 | /* Verify O_DIRECT for ftmp */ |
diff --git a/fs/xfs/xfs_inode.c b/fs/xfs/xfs_inode.c index 3541d19859e1..7d1ab3967b8e 100644 --- a/fs/xfs/xfs_inode.c +++ b/fs/xfs/xfs_inode.c | |||
@@ -1421,7 +1421,7 @@ xfs_itrunc_trace( | |||
1421 | * must be called again with all the same restrictions as the initial | 1421 | * must be called again with all the same restrictions as the initial |
1422 | * call. | 1422 | * call. |
1423 | */ | 1423 | */ |
1424 | void | 1424 | int |
1425 | xfs_itruncate_start( | 1425 | xfs_itruncate_start( |
1426 | xfs_inode_t *ip, | 1426 | xfs_inode_t *ip, |
1427 | uint flags, | 1427 | uint flags, |
@@ -1431,6 +1431,7 @@ xfs_itruncate_start( | |||
1431 | xfs_off_t toss_start; | 1431 | xfs_off_t toss_start; |
1432 | xfs_mount_t *mp; | 1432 | xfs_mount_t *mp; |
1433 | bhv_vnode_t *vp; | 1433 | bhv_vnode_t *vp; |
1434 | int error = 0; | ||
1434 | 1435 | ||
1435 | ASSERT(ismrlocked(&ip->i_iolock, MR_UPDATE) != 0); | 1436 | ASSERT(ismrlocked(&ip->i_iolock, MR_UPDATE) != 0); |
1436 | ASSERT((new_size == 0) || (new_size <= ip->i_d.di_size)); | 1437 | ASSERT((new_size == 0) || (new_size <= ip->i_d.di_size)); |
@@ -1468,7 +1469,7 @@ xfs_itruncate_start( | |||
1468 | * file size, so there is no way that the data extended | 1469 | * file size, so there is no way that the data extended |
1469 | * out there. | 1470 | * out there. |
1470 | */ | 1471 | */ |
1471 | return; | 1472 | return 0; |
1472 | } | 1473 | } |
1473 | last_byte = xfs_file_last_byte(ip); | 1474 | last_byte = xfs_file_last_byte(ip); |
1474 | xfs_itrunc_trace(XFS_ITRUNC_START, ip, flags, new_size, toss_start, | 1475 | xfs_itrunc_trace(XFS_ITRUNC_START, ip, flags, new_size, toss_start, |
@@ -1477,7 +1478,7 @@ xfs_itruncate_start( | |||
1477 | if (flags & XFS_ITRUNC_DEFINITE) { | 1478 | if (flags & XFS_ITRUNC_DEFINITE) { |
1478 | bhv_vop_toss_pages(vp, toss_start, -1, FI_REMAPF_LOCKED); | 1479 | bhv_vop_toss_pages(vp, toss_start, -1, FI_REMAPF_LOCKED); |
1479 | } else { | 1480 | } else { |
1480 | bhv_vop_flushinval_pages(vp, toss_start, -1, FI_REMAPF_LOCKED); | 1481 | error = bhv_vop_flushinval_pages(vp, toss_start, -1, FI_REMAPF_LOCKED); |
1481 | } | 1482 | } |
1482 | } | 1483 | } |
1483 | 1484 | ||
@@ -1486,6 +1487,7 @@ xfs_itruncate_start( | |||
1486 | ASSERT(VN_CACHED(vp) == 0); | 1487 | ASSERT(VN_CACHED(vp) == 0); |
1487 | } | 1488 | } |
1488 | #endif | 1489 | #endif |
1490 | return error; | ||
1489 | } | 1491 | } |
1490 | 1492 | ||
1491 | /* | 1493 | /* |
diff --git a/fs/xfs/xfs_inode.h b/fs/xfs/xfs_inode.h index bc823720d88f..699960f3459f 100644 --- a/fs/xfs/xfs_inode.h +++ b/fs/xfs/xfs_inode.h | |||
@@ -481,7 +481,7 @@ uint xfs_ip2xflags(struct xfs_inode *); | |||
481 | uint xfs_dic2xflags(struct xfs_dinode_core *); | 481 | uint xfs_dic2xflags(struct xfs_dinode_core *); |
482 | int xfs_ifree(struct xfs_trans *, xfs_inode_t *, | 482 | int xfs_ifree(struct xfs_trans *, xfs_inode_t *, |
483 | struct xfs_bmap_free *); | 483 | struct xfs_bmap_free *); |
484 | void xfs_itruncate_start(xfs_inode_t *, uint, xfs_fsize_t); | 484 | int xfs_itruncate_start(xfs_inode_t *, uint, xfs_fsize_t); |
485 | int xfs_itruncate_finish(struct xfs_trans **, xfs_inode_t *, | 485 | int xfs_itruncate_finish(struct xfs_trans **, xfs_inode_t *, |
486 | xfs_fsize_t, int, int); | 486 | xfs_fsize_t, int, int); |
487 | int xfs_iunlink(struct xfs_trans *, xfs_inode_t *); | 487 | int xfs_iunlink(struct xfs_trans *, xfs_inode_t *); |
diff --git a/fs/xfs/xfs_utils.c b/fs/xfs/xfs_utils.c index 948b0c892e96..20ffec308e1e 100644 --- a/fs/xfs/xfs_utils.c +++ b/fs/xfs/xfs_utils.c | |||
@@ -420,7 +420,11 @@ xfs_truncate_file( | |||
420 | * in a transaction. | 420 | * in a transaction. |
421 | */ | 421 | */ |
422 | xfs_ilock(ip, XFS_IOLOCK_EXCL); | 422 | xfs_ilock(ip, XFS_IOLOCK_EXCL); |
423 | xfs_itruncate_start(ip, XFS_ITRUNC_DEFINITE, (xfs_fsize_t)0); | 423 | error = xfs_itruncate_start(ip, XFS_ITRUNC_DEFINITE, (xfs_fsize_t)0); |
424 | if (error) { | ||
425 | xfs_iunlock(ip, XFS_IOLOCK_EXCL); | ||
426 | return error; | ||
427 | } | ||
424 | 428 | ||
425 | tp = xfs_trans_alloc(mp, XFS_TRANS_TRUNCATE_FILE); | 429 | tp = xfs_trans_alloc(mp, XFS_TRANS_TRUNCATE_FILE); |
426 | if ((error = xfs_trans_reserve(tp, 0, XFS_ITRUNCATE_LOG_RES(mp), 0, | 430 | if ((error = xfs_trans_reserve(tp, 0, XFS_ITRUNCATE_LOG_RES(mp), 0, |
diff --git a/fs/xfs/xfs_vfsops.c b/fs/xfs/xfs_vfsops.c index 22a09273748f..2e830e7f52e0 100644 --- a/fs/xfs/xfs_vfsops.c +++ b/fs/xfs/xfs_vfsops.c | |||
@@ -1147,7 +1147,7 @@ xfs_sync_inodes( | |||
1147 | if (XFS_FORCED_SHUTDOWN(mp)) { | 1147 | if (XFS_FORCED_SHUTDOWN(mp)) { |
1148 | bhv_vop_toss_pages(vp, 0, -1, FI_REMAPF); | 1148 | bhv_vop_toss_pages(vp, 0, -1, FI_REMAPF); |
1149 | } else { | 1149 | } else { |
1150 | bhv_vop_flushinval_pages(vp, 0, -1, FI_REMAPF); | 1150 | error = bhv_vop_flushinval_pages(vp, 0, -1, FI_REMAPF); |
1151 | } | 1151 | } |
1152 | 1152 | ||
1153 | xfs_ilock(ip, XFS_ILOCK_SHARED); | 1153 | xfs_ilock(ip, XFS_ILOCK_SHARED); |
diff --git a/fs/xfs/xfs_vnodeops.c b/fs/xfs/xfs_vnodeops.c index 5ed349eccb00..6e49bd362460 100644 --- a/fs/xfs/xfs_vnodeops.c +++ b/fs/xfs/xfs_vnodeops.c | |||
@@ -1257,8 +1257,12 @@ xfs_inactive_free_eofblocks( | |||
1257 | * do that within a transaction. | 1257 | * do that within a transaction. |
1258 | */ | 1258 | */ |
1259 | xfs_ilock(ip, XFS_IOLOCK_EXCL); | 1259 | xfs_ilock(ip, XFS_IOLOCK_EXCL); |
1260 | xfs_itruncate_start(ip, XFS_ITRUNC_DEFINITE, | 1260 | error = xfs_itruncate_start(ip, XFS_ITRUNC_DEFINITE, |
1261 | ip->i_d.di_size); | 1261 | ip->i_d.di_size); |
1262 | if (error) { | ||
1263 | xfs_iunlock(ip, XFS_IOLOCK_EXCL); | ||
1264 | return error; | ||
1265 | } | ||
1262 | 1266 | ||
1263 | error = xfs_trans_reserve(tp, 0, | 1267 | error = xfs_trans_reserve(tp, 0, |
1264 | XFS_ITRUNCATE_LOG_RES(mp), | 1268 | XFS_ITRUNCATE_LOG_RES(mp), |
@@ -1674,7 +1678,11 @@ xfs_inactive( | |||
1674 | */ | 1678 | */ |
1675 | xfs_ilock(ip, XFS_IOLOCK_EXCL); | 1679 | xfs_ilock(ip, XFS_IOLOCK_EXCL); |
1676 | 1680 | ||
1677 | xfs_itruncate_start(ip, XFS_ITRUNC_DEFINITE, 0); | 1681 | error = xfs_itruncate_start(ip, XFS_ITRUNC_DEFINITE, 0); |
1682 | if (error) { | ||
1683 | xfs_iunlock(ip, XFS_IOLOCK_EXCL); | ||
1684 | return VN_INACTIVE_CACHE; | ||
1685 | } | ||
1678 | 1686 | ||
1679 | error = xfs_trans_reserve(tp, 0, | 1687 | error = xfs_trans_reserve(tp, 0, |
1680 | XFS_ITRUNCATE_LOG_RES(mp), | 1688 | XFS_ITRUNCATE_LOG_RES(mp), |
@@ -4338,8 +4346,10 @@ xfs_free_file_space( | |||
4338 | if (VN_CACHED(vp) != 0) { | 4346 | if (VN_CACHED(vp) != 0) { |
4339 | xfs_inval_cached_trace(&ip->i_iocore, ioffset, -1, | 4347 | xfs_inval_cached_trace(&ip->i_iocore, ioffset, -1, |
4340 | ctooff(offtoct(ioffset)), -1); | 4348 | ctooff(offtoct(ioffset)), -1); |
4341 | bhv_vop_flushinval_pages(vp, ctooff(offtoct(ioffset)), | 4349 | error = bhv_vop_flushinval_pages(vp, ctooff(offtoct(ioffset)), |
4342 | -1, FI_REMAPF_LOCKED); | 4350 | -1, FI_REMAPF_LOCKED); |
4351 | if (error) | ||
4352 | goto out_unlock_iolock; | ||
4343 | } | 4353 | } |
4344 | 4354 | ||
4345 | /* | 4355 | /* |