diff options
Diffstat (limited to 'fs/xfs/linux-2.6/xfs_buf.c')
-rw-r--r-- | fs/xfs/linux-2.6/xfs_buf.c | 67 |
1 files changed, 22 insertions, 45 deletions
diff --git a/fs/xfs/linux-2.6/xfs_buf.c b/fs/xfs/linux-2.6/xfs_buf.c index 649ade8ef598..ea79072f5210 100644 --- a/fs/xfs/linux-2.6/xfs_buf.c +++ b/fs/xfs/linux-2.6/xfs_buf.c | |||
@@ -39,13 +39,12 @@ | |||
39 | #include "xfs_inum.h" | 39 | #include "xfs_inum.h" |
40 | #include "xfs_log.h" | 40 | #include "xfs_log.h" |
41 | #include "xfs_ag.h" | 41 | #include "xfs_ag.h" |
42 | #include "xfs_dmapi.h" | ||
43 | #include "xfs_mount.h" | 42 | #include "xfs_mount.h" |
44 | #include "xfs_trace.h" | 43 | #include "xfs_trace.h" |
45 | 44 | ||
46 | static kmem_zone_t *xfs_buf_zone; | 45 | static kmem_zone_t *xfs_buf_zone; |
47 | STATIC int xfsbufd(void *); | 46 | STATIC int xfsbufd(void *); |
48 | STATIC int xfsbufd_wakeup(int, gfp_t); | 47 | STATIC int xfsbufd_wakeup(struct shrinker *, int, gfp_t); |
49 | STATIC void xfs_buf_delwri_queue(xfs_buf_t *, int); | 48 | STATIC void xfs_buf_delwri_queue(xfs_buf_t *, int); |
50 | static struct shrinker xfs_buf_shake = { | 49 | static struct shrinker xfs_buf_shake = { |
51 | .shrink = xfsbufd_wakeup, | 50 | .shrink = xfsbufd_wakeup, |
@@ -340,7 +339,7 @@ _xfs_buf_lookup_pages( | |||
340 | __func__, gfp_mask); | 339 | __func__, gfp_mask); |
341 | 340 | ||
342 | XFS_STATS_INC(xb_page_retries); | 341 | XFS_STATS_INC(xb_page_retries); |
343 | xfsbufd_wakeup(0, gfp_mask); | 342 | xfsbufd_wakeup(NULL, 0, gfp_mask); |
344 | congestion_wait(BLK_RW_ASYNC, HZ/50); | 343 | congestion_wait(BLK_RW_ASYNC, HZ/50); |
345 | goto retry; | 344 | goto retry; |
346 | } | 345 | } |
@@ -579,9 +578,9 @@ _xfs_buf_read( | |||
579 | XBF_READ_AHEAD | _XBF_RUN_QUEUES); | 578 | XBF_READ_AHEAD | _XBF_RUN_QUEUES); |
580 | 579 | ||
581 | status = xfs_buf_iorequest(bp); | 580 | status = xfs_buf_iorequest(bp); |
582 | if (!status && !(flags & XBF_ASYNC)) | 581 | if (status || XFS_BUF_ISERROR(bp) || (flags & XBF_ASYNC)) |
583 | status = xfs_buf_iowait(bp); | 582 | return status; |
584 | return status; | 583 | return xfs_buf_iowait(bp); |
585 | } | 584 | } |
586 | 585 | ||
587 | xfs_buf_t * | 586 | xfs_buf_t * |
@@ -897,36 +896,6 @@ xfs_buf_unlock( | |||
897 | trace_xfs_buf_unlock(bp, _RET_IP_); | 896 | trace_xfs_buf_unlock(bp, _RET_IP_); |
898 | } | 897 | } |
899 | 898 | ||
900 | |||
901 | /* | ||
902 | * Pinning Buffer Storage in Memory | ||
903 | * Ensure that no attempt to force a buffer to disk will succeed. | ||
904 | */ | ||
905 | void | ||
906 | xfs_buf_pin( | ||
907 | xfs_buf_t *bp) | ||
908 | { | ||
909 | trace_xfs_buf_pin(bp, _RET_IP_); | ||
910 | atomic_inc(&bp->b_pin_count); | ||
911 | } | ||
912 | |||
913 | void | ||
914 | xfs_buf_unpin( | ||
915 | xfs_buf_t *bp) | ||
916 | { | ||
917 | trace_xfs_buf_unpin(bp, _RET_IP_); | ||
918 | |||
919 | if (atomic_dec_and_test(&bp->b_pin_count)) | ||
920 | wake_up_all(&bp->b_waiters); | ||
921 | } | ||
922 | |||
923 | int | ||
924 | xfs_buf_ispin( | ||
925 | xfs_buf_t *bp) | ||
926 | { | ||
927 | return atomic_read(&bp->b_pin_count); | ||
928 | } | ||
929 | |||
930 | STATIC void | 899 | STATIC void |
931 | xfs_buf_wait_unpin( | 900 | xfs_buf_wait_unpin( |
932 | xfs_buf_t *bp) | 901 | xfs_buf_t *bp) |
@@ -1018,13 +987,12 @@ xfs_bwrite( | |||
1018 | { | 987 | { |
1019 | int error; | 988 | int error; |
1020 | 989 | ||
1021 | bp->b_strat = xfs_bdstrat_cb; | ||
1022 | bp->b_mount = mp; | 990 | bp->b_mount = mp; |
1023 | bp->b_flags |= XBF_WRITE; | 991 | bp->b_flags |= XBF_WRITE; |
1024 | bp->b_flags &= ~(XBF_ASYNC | XBF_READ); | 992 | bp->b_flags &= ~(XBF_ASYNC | XBF_READ); |
1025 | 993 | ||
1026 | xfs_buf_delwri_dequeue(bp); | 994 | xfs_buf_delwri_dequeue(bp); |
1027 | xfs_buf_iostrategy(bp); | 995 | xfs_bdstrat_cb(bp); |
1028 | 996 | ||
1029 | error = xfs_buf_iowait(bp); | 997 | error = xfs_buf_iowait(bp); |
1030 | if (error) | 998 | if (error) |
@@ -1040,7 +1008,6 @@ xfs_bdwrite( | |||
1040 | { | 1008 | { |
1041 | trace_xfs_buf_bdwrite(bp, _RET_IP_); | 1009 | trace_xfs_buf_bdwrite(bp, _RET_IP_); |
1042 | 1010 | ||
1043 | bp->b_strat = xfs_bdstrat_cb; | ||
1044 | bp->b_mount = mp; | 1011 | bp->b_mount = mp; |
1045 | 1012 | ||
1046 | bp->b_flags &= ~XBF_READ; | 1013 | bp->b_flags &= ~XBF_READ; |
@@ -1075,7 +1042,6 @@ xfs_bioerror( | |||
1075 | XFS_BUF_UNDONE(bp); | 1042 | XFS_BUF_UNDONE(bp); |
1076 | XFS_BUF_STALE(bp); | 1043 | XFS_BUF_STALE(bp); |
1077 | 1044 | ||
1078 | XFS_BUF_CLR_BDSTRAT_FUNC(bp); | ||
1079 | xfs_biodone(bp); | 1045 | xfs_biodone(bp); |
1080 | 1046 | ||
1081 | return EIO; | 1047 | return EIO; |
@@ -1105,7 +1071,6 @@ xfs_bioerror_relse( | |||
1105 | XFS_BUF_DONE(bp); | 1071 | XFS_BUF_DONE(bp); |
1106 | XFS_BUF_STALE(bp); | 1072 | XFS_BUF_STALE(bp); |
1107 | XFS_BUF_CLR_IODONE_FUNC(bp); | 1073 | XFS_BUF_CLR_IODONE_FUNC(bp); |
1108 | XFS_BUF_CLR_BDSTRAT_FUNC(bp); | ||
1109 | if (!(fl & XBF_ASYNC)) { | 1074 | if (!(fl & XBF_ASYNC)) { |
1110 | /* | 1075 | /* |
1111 | * Mark b_error and B_ERROR _both_. | 1076 | * Mark b_error and B_ERROR _both_. |
@@ -1311,8 +1276,19 @@ submit_io: | |||
1311 | if (size) | 1276 | if (size) |
1312 | goto next_chunk; | 1277 | goto next_chunk; |
1313 | } else { | 1278 | } else { |
1314 | bio_put(bio); | 1279 | /* |
1280 | * if we get here, no pages were added to the bio. However, | ||
1281 | * we can't just error out here - if the pages are locked then | ||
1282 | * we have to unlock them otherwise we can hang on a later | ||
1283 | * access to the page. | ||
1284 | */ | ||
1315 | xfs_buf_ioerror(bp, EIO); | 1285 | xfs_buf_ioerror(bp, EIO); |
1286 | if (bp->b_flags & _XBF_PAGE_LOCKED) { | ||
1287 | int i; | ||
1288 | for (i = 0; i < bp->b_page_count; i++) | ||
1289 | unlock_page(bp->b_pages[i]); | ||
1290 | } | ||
1291 | bio_put(bio); | ||
1316 | } | 1292 | } |
1317 | } | 1293 | } |
1318 | 1294 | ||
@@ -1762,6 +1738,7 @@ xfs_buf_runall_queues( | |||
1762 | 1738 | ||
1763 | STATIC int | 1739 | STATIC int |
1764 | xfsbufd_wakeup( | 1740 | xfsbufd_wakeup( |
1741 | struct shrinker *shrink, | ||
1765 | int priority, | 1742 | int priority, |
1766 | gfp_t mask) | 1743 | gfp_t mask) |
1767 | { | 1744 | { |
@@ -1803,7 +1780,7 @@ xfs_buf_delwri_split( | |||
1803 | trace_xfs_buf_delwri_split(bp, _RET_IP_); | 1780 | trace_xfs_buf_delwri_split(bp, _RET_IP_); |
1804 | ASSERT(bp->b_flags & XBF_DELWRI); | 1781 | ASSERT(bp->b_flags & XBF_DELWRI); |
1805 | 1782 | ||
1806 | if (!xfs_buf_ispin(bp) && !xfs_buf_cond_lock(bp)) { | 1783 | if (!XFS_BUF_ISPINNED(bp) && !xfs_buf_cond_lock(bp)) { |
1807 | if (!force && | 1784 | if (!force && |
1808 | time_before(jiffies, bp->b_queuetime + age)) { | 1785 | time_before(jiffies, bp->b_queuetime + age)) { |
1809 | xfs_buf_unlock(bp); | 1786 | xfs_buf_unlock(bp); |
@@ -1888,7 +1865,7 @@ xfsbufd( | |||
1888 | struct xfs_buf *bp; | 1865 | struct xfs_buf *bp; |
1889 | bp = list_first_entry(&tmp, struct xfs_buf, b_list); | 1866 | bp = list_first_entry(&tmp, struct xfs_buf, b_list); |
1890 | list_del_init(&bp->b_list); | 1867 | list_del_init(&bp->b_list); |
1891 | xfs_buf_iostrategy(bp); | 1868 | xfs_bdstrat_cb(bp); |
1892 | count++; | 1869 | count++; |
1893 | } | 1870 | } |
1894 | if (count) | 1871 | if (count) |
@@ -1935,7 +1912,7 @@ xfs_flush_buftarg( | |||
1935 | bp->b_flags &= ~XBF_ASYNC; | 1912 | bp->b_flags &= ~XBF_ASYNC; |
1936 | list_add(&bp->b_list, &wait_list); | 1913 | list_add(&bp->b_list, &wait_list); |
1937 | } | 1914 | } |
1938 | xfs_buf_iostrategy(bp); | 1915 | xfs_bdstrat_cb(bp); |
1939 | } | 1916 | } |
1940 | 1917 | ||
1941 | if (wait) { | 1918 | if (wait) { |