diff options
Diffstat (limited to 'fs/xfs/linux-2.6')
-rw-r--r-- | fs/xfs/linux-2.6/xfs_buf.c | 24 | ||||
-rw-r--r-- | fs/xfs/linux-2.6/xfs_buf.h | 19 | ||||
-rw-r--r-- | fs/xfs/linux-2.6/xfs_file.c | 17 | ||||
-rw-r--r-- | fs/xfs/linux-2.6/xfs_vnode.h | 8 |
4 files changed, 50 insertions, 18 deletions
diff --git a/fs/xfs/linux-2.6/xfs_buf.c b/fs/xfs/linux-2.6/xfs_buf.c index 5105015a75ad..98e0e86093b4 100644 --- a/fs/xfs/linux-2.6/xfs_buf.c +++ b/fs/xfs/linux-2.6/xfs_buf.c | |||
@@ -387,6 +387,8 @@ _xfs_buf_lookup_pages( | |||
387 | if (unlikely(page == NULL)) { | 387 | if (unlikely(page == NULL)) { |
388 | if (flags & XBF_READ_AHEAD) { | 388 | if (flags & XBF_READ_AHEAD) { |
389 | bp->b_page_count = i; | 389 | bp->b_page_count = i; |
390 | for (i = 0; i < bp->b_page_count; i++) | ||
391 | unlock_page(bp->b_pages[i]); | ||
390 | return -ENOMEM; | 392 | return -ENOMEM; |
391 | } | 393 | } |
392 | 394 | ||
@@ -416,17 +418,24 @@ _xfs_buf_lookup_pages( | |||
416 | ASSERT(!PagePrivate(page)); | 418 | ASSERT(!PagePrivate(page)); |
417 | if (!PageUptodate(page)) { | 419 | if (!PageUptodate(page)) { |
418 | page_count--; | 420 | page_count--; |
419 | if (blocksize < PAGE_CACHE_SIZE && !PagePrivate(page)) { | 421 | if (blocksize >= PAGE_CACHE_SIZE) { |
422 | if (flags & XBF_READ) | ||
423 | bp->b_flags |= _XBF_PAGE_LOCKED; | ||
424 | } else if (!PagePrivate(page)) { | ||
420 | if (test_page_region(page, offset, nbytes)) | 425 | if (test_page_region(page, offset, nbytes)) |
421 | page_count++; | 426 | page_count++; |
422 | } | 427 | } |
423 | } | 428 | } |
424 | 429 | ||
425 | unlock_page(page); | ||
426 | bp->b_pages[i] = page; | 430 | bp->b_pages[i] = page; |
427 | offset = 0; | 431 | offset = 0; |
428 | } | 432 | } |
429 | 433 | ||
434 | if (!(bp->b_flags & _XBF_PAGE_LOCKED)) { | ||
435 | for (i = 0; i < bp->b_page_count; i++) | ||
436 | unlock_page(bp->b_pages[i]); | ||
437 | } | ||
438 | |||
430 | if (page_count == bp->b_page_count) | 439 | if (page_count == bp->b_page_count) |
431 | bp->b_flags |= XBF_DONE; | 440 | bp->b_flags |= XBF_DONE; |
432 | 441 | ||
@@ -746,6 +755,7 @@ xfs_buf_associate_memory( | |||
746 | bp->b_count_desired = len; | 755 | bp->b_count_desired = len; |
747 | bp->b_buffer_length = buflen; | 756 | bp->b_buffer_length = buflen; |
748 | bp->b_flags |= XBF_MAPPED; | 757 | bp->b_flags |= XBF_MAPPED; |
758 | bp->b_flags &= ~_XBF_PAGE_LOCKED; | ||
749 | 759 | ||
750 | return 0; | 760 | return 0; |
751 | } | 761 | } |
@@ -1093,8 +1103,10 @@ _xfs_buf_ioend( | |||
1093 | xfs_buf_t *bp, | 1103 | xfs_buf_t *bp, |
1094 | int schedule) | 1104 | int schedule) |
1095 | { | 1105 | { |
1096 | if (atomic_dec_and_test(&bp->b_io_remaining) == 1) | 1106 | if (atomic_dec_and_test(&bp->b_io_remaining) == 1) { |
1107 | bp->b_flags &= ~_XBF_PAGE_LOCKED; | ||
1097 | xfs_buf_ioend(bp, schedule); | 1108 | xfs_buf_ioend(bp, schedule); |
1109 | } | ||
1098 | } | 1110 | } |
1099 | 1111 | ||
1100 | STATIC void | 1112 | STATIC void |
@@ -1125,6 +1137,9 @@ xfs_buf_bio_end_io( | |||
1125 | 1137 | ||
1126 | if (--bvec >= bio->bi_io_vec) | 1138 | if (--bvec >= bio->bi_io_vec) |
1127 | prefetchw(&bvec->bv_page->flags); | 1139 | prefetchw(&bvec->bv_page->flags); |
1140 | |||
1141 | if (bp->b_flags & _XBF_PAGE_LOCKED) | ||
1142 | unlock_page(page); | ||
1128 | } while (bvec >= bio->bi_io_vec); | 1143 | } while (bvec >= bio->bi_io_vec); |
1129 | 1144 | ||
1130 | _xfs_buf_ioend(bp, 1); | 1145 | _xfs_buf_ioend(bp, 1); |
@@ -1163,7 +1178,8 @@ _xfs_buf_ioapply( | |||
1163 | * filesystem block size is not smaller than the page size. | 1178 | * filesystem block size is not smaller than the page size. |
1164 | */ | 1179 | */ |
1165 | if ((bp->b_buffer_length < PAGE_CACHE_SIZE) && | 1180 | if ((bp->b_buffer_length < PAGE_CACHE_SIZE) && |
1166 | (bp->b_flags & XBF_READ) && | 1181 | ((bp->b_flags & (XBF_READ|_XBF_PAGE_LOCKED)) == |
1182 | (XBF_READ|_XBF_PAGE_LOCKED)) && | ||
1167 | (blocksize >= PAGE_CACHE_SIZE)) { | 1183 | (blocksize >= PAGE_CACHE_SIZE)) { |
1168 | bio = bio_alloc(GFP_NOIO, 1); | 1184 | bio = bio_alloc(GFP_NOIO, 1); |
1169 | 1185 | ||
diff --git a/fs/xfs/linux-2.6/xfs_buf.h b/fs/xfs/linux-2.6/xfs_buf.h index 841d7883528d..f948ec7ba9a4 100644 --- a/fs/xfs/linux-2.6/xfs_buf.h +++ b/fs/xfs/linux-2.6/xfs_buf.h | |||
@@ -66,6 +66,25 @@ typedef enum { | |||
66 | _XBF_PAGES = (1 << 18), /* backed by refcounted pages */ | 66 | _XBF_PAGES = (1 << 18), /* backed by refcounted pages */ |
67 | _XBF_RUN_QUEUES = (1 << 19),/* run block device task queue */ | 67 | _XBF_RUN_QUEUES = (1 << 19),/* run block device task queue */ |
68 | _XBF_DELWRI_Q = (1 << 21), /* buffer on delwri queue */ | 68 | _XBF_DELWRI_Q = (1 << 21), /* buffer on delwri queue */ |
69 | |||
70 | /* | ||
71 | * Special flag for supporting metadata blocks smaller than a FSB. | ||
72 | * | ||
73 | * In this case we can have multiple xfs_buf_t on a single page and | ||
74 | * need to lock out concurrent xfs_buf_t readers as they only | ||
75 | * serialise access to the buffer. | ||
76 | * | ||
77 | * If the FSB size >= PAGE_CACHE_SIZE case, we have no serialisation | ||
78 | * between reads of the page. Hence we can have one thread read the | ||
79 | * page and modify it, but then race with another thread that thinks | ||
80 | * the page is not up-to-date and hence reads it again. | ||
81 | * | ||
82 | * The result is that the first modifcation to the page is lost. | ||
83 | * This sort of AGF/AGI reading race can happen when unlinking inodes | ||
84 | * that require truncation and results in the AGI unlinked list | ||
85 | * modifications being lost. | ||
86 | */ | ||
87 | _XBF_PAGE_LOCKED = (1 << 22), | ||
69 | } xfs_buf_flags_t; | 88 | } xfs_buf_flags_t; |
70 | 89 | ||
71 | typedef enum { | 90 | typedef enum { |
diff --git a/fs/xfs/linux-2.6/xfs_file.c b/fs/xfs/linux-2.6/xfs_file.c index 65e78c13d4ae..5f60363b9343 100644 --- a/fs/xfs/linux-2.6/xfs_file.c +++ b/fs/xfs/linux-2.6/xfs_file.c | |||
@@ -184,19 +184,24 @@ xfs_file_release( | |||
184 | return -xfs_release(XFS_I(inode)); | 184 | return -xfs_release(XFS_I(inode)); |
185 | } | 185 | } |
186 | 186 | ||
187 | /* | ||
188 | * We ignore the datasync flag here because a datasync is effectively | ||
189 | * identical to an fsync. That is, datasync implies that we need to write | ||
190 | * only the metadata needed to be able to access the data that is written | ||
191 | * if we crash after the call completes. Hence if we are writing beyond | ||
192 | * EOF we have to log the inode size change as well, which makes it a | ||
193 | * full fsync. If we don't write beyond EOF, the inode core will be | ||
194 | * clean in memory and so we don't need to log the inode, just like | ||
195 | * fsync. | ||
196 | */ | ||
187 | STATIC int | 197 | STATIC int |
188 | xfs_file_fsync( | 198 | xfs_file_fsync( |
189 | struct file *filp, | 199 | struct file *filp, |
190 | struct dentry *dentry, | 200 | struct dentry *dentry, |
191 | int datasync) | 201 | int datasync) |
192 | { | 202 | { |
193 | int flags = FSYNC_WAIT; | ||
194 | |||
195 | if (datasync) | ||
196 | flags |= FSYNC_DATA; | ||
197 | xfs_iflags_clear(XFS_I(dentry->d_inode), XFS_ITRUNCATED); | 203 | xfs_iflags_clear(XFS_I(dentry->d_inode), XFS_ITRUNCATED); |
198 | return -xfs_fsync(XFS_I(dentry->d_inode), flags, | 204 | return -xfs_fsync(XFS_I(dentry->d_inode)); |
199 | (xfs_off_t)0, (xfs_off_t)-1); | ||
200 | } | 205 | } |
201 | 206 | ||
202 | /* | 207 | /* |
diff --git a/fs/xfs/linux-2.6/xfs_vnode.h b/fs/xfs/linux-2.6/xfs_vnode.h index 9d73cb5c0fc7..25eb2a9e8d9b 100644 --- a/fs/xfs/linux-2.6/xfs_vnode.h +++ b/fs/xfs/linux-2.6/xfs_vnode.h | |||
@@ -230,14 +230,6 @@ static inline void vn_atime_to_time_t(bhv_vnode_t *vp, time_t *tt) | |||
230 | #define ATTR_NOSIZETOK 0x400 /* Don't get the SIZE token */ | 230 | #define ATTR_NOSIZETOK 0x400 /* Don't get the SIZE token */ |
231 | 231 | ||
232 | /* | 232 | /* |
233 | * Flags to vop_fsync/reclaim. | ||
234 | */ | ||
235 | #define FSYNC_NOWAIT 0 /* asynchronous flush */ | ||
236 | #define FSYNC_WAIT 0x1 /* synchronous fsync or forced reclaim */ | ||
237 | #define FSYNC_INVAL 0x2 /* flush and invalidate cached data */ | ||
238 | #define FSYNC_DATA 0x4 /* synchronous fsync of data only */ | ||
239 | |||
240 | /* | ||
241 | * Tracking vnode activity. | 233 | * Tracking vnode activity. |
242 | */ | 234 | */ |
243 | #if defined(XFS_INODE_TRACE) | 235 | #if defined(XFS_INODE_TRACE) |