diff options
Diffstat (limited to 'fs/xfs/linux-2.6')
-rw-r--r-- | fs/xfs/linux-2.6/kmem.c | 9 | ||||
-rw-r--r-- | fs/xfs/linux-2.6/xfs_aops.c | 10 | ||||
-rw-r--r-- | fs/xfs/linux-2.6/xfs_buf.c | 374 | ||||
-rw-r--r-- | fs/xfs/linux-2.6/xfs_buf.h | 40 | ||||
-rw-r--r-- | fs/xfs/linux-2.6/xfs_file.c | 6 | ||||
-rw-r--r-- | fs/xfs/linux-2.6/xfs_ioctl.c | 4 | ||||
-rw-r--r-- | fs/xfs/linux-2.6/xfs_linux.h | 23 | ||||
-rw-r--r-- | fs/xfs/linux-2.6/xfs_message.c | 133 | ||||
-rw-r--r-- | fs/xfs/linux-2.6/xfs_message.h | 38 | ||||
-rw-r--r-- | fs/xfs/linux-2.6/xfs_super.c | 164 | ||||
-rw-r--r-- | fs/xfs/linux-2.6/xfs_sync.c | 35 | ||||
-rw-r--r-- | fs/xfs/linux-2.6/xfs_sysctl.c | 2 |
12 files changed, 427 insertions, 411 deletions
diff --git a/fs/xfs/linux-2.6/kmem.c b/fs/xfs/linux-2.6/kmem.c index 666c9db48eb6..a907de565db3 100644 --- a/fs/xfs/linux-2.6/kmem.c +++ b/fs/xfs/linux-2.6/kmem.c | |||
@@ -23,6 +23,7 @@ | |||
23 | #include <linux/backing-dev.h> | 23 | #include <linux/backing-dev.h> |
24 | #include "time.h" | 24 | #include "time.h" |
25 | #include "kmem.h" | 25 | #include "kmem.h" |
26 | #include "xfs_message.h" | ||
26 | 27 | ||
27 | /* | 28 | /* |
28 | * Greedy allocation. May fail and may return vmalloced memory. | 29 | * Greedy allocation. May fail and may return vmalloced memory. |
@@ -56,8 +57,8 @@ kmem_alloc(size_t size, unsigned int __nocast flags) | |||
56 | if (ptr || (flags & (KM_MAYFAIL|KM_NOSLEEP))) | 57 | if (ptr || (flags & (KM_MAYFAIL|KM_NOSLEEP))) |
57 | return ptr; | 58 | return ptr; |
58 | if (!(++retries % 100)) | 59 | if (!(++retries % 100)) |
59 | printk(KERN_ERR "XFS: possible memory allocation " | 60 | xfs_err(NULL, |
60 | "deadlock in %s (mode:0x%x)\n", | 61 | "possible memory allocation deadlock in %s (mode:0x%x)", |
61 | __func__, lflags); | 62 | __func__, lflags); |
62 | congestion_wait(BLK_RW_ASYNC, HZ/50); | 63 | congestion_wait(BLK_RW_ASYNC, HZ/50); |
63 | } while (1); | 64 | } while (1); |
@@ -112,8 +113,8 @@ kmem_zone_alloc(kmem_zone_t *zone, unsigned int __nocast flags) | |||
112 | if (ptr || (flags & (KM_MAYFAIL|KM_NOSLEEP))) | 113 | if (ptr || (flags & (KM_MAYFAIL|KM_NOSLEEP))) |
113 | return ptr; | 114 | return ptr; |
114 | if (!(++retries % 100)) | 115 | if (!(++retries % 100)) |
115 | printk(KERN_ERR "XFS: possible memory allocation " | 116 | xfs_err(NULL, |
116 | "deadlock in %s (mode:0x%x)\n", | 117 | "possible memory allocation deadlock in %s (mode:0x%x)", |
117 | __func__, lflags); | 118 | __func__, lflags); |
118 | congestion_wait(BLK_RW_ASYNC, HZ/50); | 119 | congestion_wait(BLK_RW_ASYNC, HZ/50); |
119 | } while (1); | 120 | } while (1); |
diff --git a/fs/xfs/linux-2.6/xfs_aops.c b/fs/xfs/linux-2.6/xfs_aops.c index ec7bbb5645b6..52dbd14260ba 100644 --- a/fs/xfs/linux-2.6/xfs_aops.c +++ b/fs/xfs/linux-2.6/xfs_aops.c | |||
@@ -413,8 +413,7 @@ xfs_submit_ioend_bio( | |||
413 | if (xfs_ioend_new_eof(ioend)) | 413 | if (xfs_ioend_new_eof(ioend)) |
414 | xfs_mark_inode_dirty(XFS_I(ioend->io_inode)); | 414 | xfs_mark_inode_dirty(XFS_I(ioend->io_inode)); |
415 | 415 | ||
416 | submit_bio(wbc->sync_mode == WB_SYNC_ALL ? | 416 | submit_bio(wbc->sync_mode == WB_SYNC_ALL ? WRITE_SYNC : WRITE, bio); |
417 | WRITE_SYNC_PLUG : WRITE, bio); | ||
418 | } | 417 | } |
419 | 418 | ||
420 | STATIC struct bio * | 419 | STATIC struct bio * |
@@ -854,7 +853,7 @@ xfs_aops_discard_page( | |||
854 | if (XFS_FORCED_SHUTDOWN(ip->i_mount)) | 853 | if (XFS_FORCED_SHUTDOWN(ip->i_mount)) |
855 | goto out_invalidate; | 854 | goto out_invalidate; |
856 | 855 | ||
857 | xfs_fs_cmn_err(CE_ALERT, ip->i_mount, | 856 | xfs_alert(ip->i_mount, |
858 | "page discard on page %p, inode 0x%llx, offset %llu.", | 857 | "page discard on page %p, inode 0x%llx, offset %llu.", |
859 | page, ip->i_ino, offset); | 858 | page, ip->i_ino, offset); |
860 | 859 | ||
@@ -872,7 +871,7 @@ xfs_aops_discard_page( | |||
872 | if (error) { | 871 | if (error) { |
873 | /* something screwed, just bail */ | 872 | /* something screwed, just bail */ |
874 | if (!XFS_FORCED_SHUTDOWN(ip->i_mount)) { | 873 | if (!XFS_FORCED_SHUTDOWN(ip->i_mount)) { |
875 | xfs_fs_cmn_err(CE_ALERT, ip->i_mount, | 874 | xfs_alert(ip->i_mount, |
876 | "page discard unable to remove delalloc mapping."); | 875 | "page discard unable to remove delalloc mapping."); |
877 | } | 876 | } |
878 | break; | 877 | break; |
@@ -1411,7 +1410,7 @@ xfs_vm_write_failed( | |||
1411 | if (error) { | 1410 | if (error) { |
1412 | /* something screwed, just bail */ | 1411 | /* something screwed, just bail */ |
1413 | if (!XFS_FORCED_SHUTDOWN(ip->i_mount)) { | 1412 | if (!XFS_FORCED_SHUTDOWN(ip->i_mount)) { |
1414 | xfs_fs_cmn_err(CE_ALERT, ip->i_mount, | 1413 | xfs_alert(ip->i_mount, |
1415 | "xfs_vm_write_failed: unable to clean up ino %lld", | 1414 | "xfs_vm_write_failed: unable to clean up ino %lld", |
1416 | ip->i_ino); | 1415 | ip->i_ino); |
1417 | } | 1416 | } |
@@ -1495,7 +1494,6 @@ const struct address_space_operations xfs_address_space_operations = { | |||
1495 | .readpages = xfs_vm_readpages, | 1494 | .readpages = xfs_vm_readpages, |
1496 | .writepage = xfs_vm_writepage, | 1495 | .writepage = xfs_vm_writepage, |
1497 | .writepages = xfs_vm_writepages, | 1496 | .writepages = xfs_vm_writepages, |
1498 | .sync_page = block_sync_page, | ||
1499 | .releasepage = xfs_vm_releasepage, | 1497 | .releasepage = xfs_vm_releasepage, |
1500 | .invalidatepage = xfs_vm_invalidatepage, | 1498 | .invalidatepage = xfs_vm_invalidatepage, |
1501 | .write_begin = xfs_vm_write_begin, | 1499 | .write_begin = xfs_vm_write_begin, |
diff --git a/fs/xfs/linux-2.6/xfs_buf.c b/fs/xfs/linux-2.6/xfs_buf.c index f83a4c830a65..596bb2c9de42 100644 --- a/fs/xfs/linux-2.6/xfs_buf.c +++ b/fs/xfs/linux-2.6/xfs_buf.c | |||
@@ -94,75 +94,6 @@ xfs_buf_vmap_len( | |||
94 | } | 94 | } |
95 | 95 | ||
96 | /* | 96 | /* |
97 | * Page Region interfaces. | ||
98 | * | ||
99 | * For pages in filesystems where the blocksize is smaller than the | ||
100 | * pagesize, we use the page->private field (long) to hold a bitmap | ||
101 | * of uptodate regions within the page. | ||
102 | * | ||
103 | * Each such region is "bytes per page / bits per long" bytes long. | ||
104 | * | ||
105 | * NBPPR == number-of-bytes-per-page-region | ||
106 | * BTOPR == bytes-to-page-region (rounded up) | ||
107 | * BTOPRT == bytes-to-page-region-truncated (rounded down) | ||
108 | */ | ||
109 | #if (BITS_PER_LONG == 32) | ||
110 | #define PRSHIFT (PAGE_CACHE_SHIFT - 5) /* (32 == 1<<5) */ | ||
111 | #elif (BITS_PER_LONG == 64) | ||
112 | #define PRSHIFT (PAGE_CACHE_SHIFT - 6) /* (64 == 1<<6) */ | ||
113 | #else | ||
114 | #error BITS_PER_LONG must be 32 or 64 | ||
115 | #endif | ||
116 | #define NBPPR (PAGE_CACHE_SIZE/BITS_PER_LONG) | ||
117 | #define BTOPR(b) (((unsigned int)(b) + (NBPPR - 1)) >> PRSHIFT) | ||
118 | #define BTOPRT(b) (((unsigned int)(b) >> PRSHIFT)) | ||
119 | |||
120 | STATIC unsigned long | ||
121 | page_region_mask( | ||
122 | size_t offset, | ||
123 | size_t length) | ||
124 | { | ||
125 | unsigned long mask; | ||
126 | int first, final; | ||
127 | |||
128 | first = BTOPR(offset); | ||
129 | final = BTOPRT(offset + length - 1); | ||
130 | first = min(first, final); | ||
131 | |||
132 | mask = ~0UL; | ||
133 | mask <<= BITS_PER_LONG - (final - first); | ||
134 | mask >>= BITS_PER_LONG - (final); | ||
135 | |||
136 | ASSERT(offset + length <= PAGE_CACHE_SIZE); | ||
137 | ASSERT((final - first) < BITS_PER_LONG && (final - first) >= 0); | ||
138 | |||
139 | return mask; | ||
140 | } | ||
141 | |||
142 | STATIC void | ||
143 | set_page_region( | ||
144 | struct page *page, | ||
145 | size_t offset, | ||
146 | size_t length) | ||
147 | { | ||
148 | set_page_private(page, | ||
149 | page_private(page) | page_region_mask(offset, length)); | ||
150 | if (page_private(page) == ~0UL) | ||
151 | SetPageUptodate(page); | ||
152 | } | ||
153 | |||
154 | STATIC int | ||
155 | test_page_region( | ||
156 | struct page *page, | ||
157 | size_t offset, | ||
158 | size_t length) | ||
159 | { | ||
160 | unsigned long mask = page_region_mask(offset, length); | ||
161 | |||
162 | return (mask && (page_private(page) & mask) == mask); | ||
163 | } | ||
164 | |||
165 | /* | ||
166 | * xfs_buf_lru_add - add a buffer to the LRU. | 97 | * xfs_buf_lru_add - add a buffer to the LRU. |
167 | * | 98 | * |
168 | * The LRU takes a new reference to the buffer so that it will only be freed | 99 | * The LRU takes a new reference to the buffer so that it will only be freed |
@@ -332,7 +263,7 @@ xfs_buf_free( | |||
332 | 263 | ||
333 | ASSERT(list_empty(&bp->b_lru)); | 264 | ASSERT(list_empty(&bp->b_lru)); |
334 | 265 | ||
335 | if (bp->b_flags & (_XBF_PAGE_CACHE|_XBF_PAGES)) { | 266 | if (bp->b_flags & _XBF_PAGES) { |
336 | uint i; | 267 | uint i; |
337 | 268 | ||
338 | if (xfs_buf_is_vmapped(bp)) | 269 | if (xfs_buf_is_vmapped(bp)) |
@@ -342,25 +273,22 @@ xfs_buf_free( | |||
342 | for (i = 0; i < bp->b_page_count; i++) { | 273 | for (i = 0; i < bp->b_page_count; i++) { |
343 | struct page *page = bp->b_pages[i]; | 274 | struct page *page = bp->b_pages[i]; |
344 | 275 | ||
345 | if (bp->b_flags & _XBF_PAGE_CACHE) | 276 | __free_page(page); |
346 | ASSERT(!PagePrivate(page)); | ||
347 | page_cache_release(page); | ||
348 | } | 277 | } |
349 | } | 278 | } else if (bp->b_flags & _XBF_KMEM) |
279 | kmem_free(bp->b_addr); | ||
350 | _xfs_buf_free_pages(bp); | 280 | _xfs_buf_free_pages(bp); |
351 | xfs_buf_deallocate(bp); | 281 | xfs_buf_deallocate(bp); |
352 | } | 282 | } |
353 | 283 | ||
354 | /* | 284 | /* |
355 | * Finds all pages for buffer in question and builds it's page list. | 285 | * Allocates all the pages for buffer in question and builds it's page list. |
356 | */ | 286 | */ |
357 | STATIC int | 287 | STATIC int |
358 | _xfs_buf_lookup_pages( | 288 | xfs_buf_allocate_memory( |
359 | xfs_buf_t *bp, | 289 | xfs_buf_t *bp, |
360 | uint flags) | 290 | uint flags) |
361 | { | 291 | { |
362 | struct address_space *mapping = bp->b_target->bt_mapping; | ||
363 | size_t blocksize = bp->b_target->bt_bsize; | ||
364 | size_t size = bp->b_count_desired; | 292 | size_t size = bp->b_count_desired; |
365 | size_t nbytes, offset; | 293 | size_t nbytes, offset; |
366 | gfp_t gfp_mask = xb_to_gfp(flags); | 294 | gfp_t gfp_mask = xb_to_gfp(flags); |
@@ -369,29 +297,55 @@ _xfs_buf_lookup_pages( | |||
369 | xfs_off_t end; | 297 | xfs_off_t end; |
370 | int error; | 298 | int error; |
371 | 299 | ||
300 | /* | ||
301 | * for buffers that are contained within a single page, just allocate | ||
302 | * the memory from the heap - there's no need for the complexity of | ||
303 | * page arrays to keep allocation down to order 0. | ||
304 | */ | ||
305 | if (bp->b_buffer_length < PAGE_SIZE) { | ||
306 | bp->b_addr = kmem_alloc(bp->b_buffer_length, xb_to_km(flags)); | ||
307 | if (!bp->b_addr) { | ||
308 | /* low memory - use alloc_page loop instead */ | ||
309 | goto use_alloc_page; | ||
310 | } | ||
311 | |||
312 | if (((unsigned long)(bp->b_addr + bp->b_buffer_length - 1) & | ||
313 | PAGE_MASK) != | ||
314 | ((unsigned long)bp->b_addr & PAGE_MASK)) { | ||
315 | /* b_addr spans two pages - use alloc_page instead */ | ||
316 | kmem_free(bp->b_addr); | ||
317 | bp->b_addr = NULL; | ||
318 | goto use_alloc_page; | ||
319 | } | ||
320 | bp->b_offset = offset_in_page(bp->b_addr); | ||
321 | bp->b_pages = bp->b_page_array; | ||
322 | bp->b_pages[0] = virt_to_page(bp->b_addr); | ||
323 | bp->b_page_count = 1; | ||
324 | bp->b_flags |= XBF_MAPPED | _XBF_KMEM; | ||
325 | return 0; | ||
326 | } | ||
327 | |||
328 | use_alloc_page: | ||
372 | end = bp->b_file_offset + bp->b_buffer_length; | 329 | end = bp->b_file_offset + bp->b_buffer_length; |
373 | page_count = xfs_buf_btoc(end) - xfs_buf_btoct(bp->b_file_offset); | 330 | page_count = xfs_buf_btoc(end) - xfs_buf_btoct(bp->b_file_offset); |
374 | |||
375 | error = _xfs_buf_get_pages(bp, page_count, flags); | 331 | error = _xfs_buf_get_pages(bp, page_count, flags); |
376 | if (unlikely(error)) | 332 | if (unlikely(error)) |
377 | return error; | 333 | return error; |
378 | bp->b_flags |= _XBF_PAGE_CACHE; | ||
379 | 334 | ||
380 | offset = bp->b_offset; | 335 | offset = bp->b_offset; |
381 | first = bp->b_file_offset >> PAGE_CACHE_SHIFT; | 336 | first = bp->b_file_offset >> PAGE_SHIFT; |
337 | bp->b_flags |= _XBF_PAGES; | ||
382 | 338 | ||
383 | for (i = 0; i < bp->b_page_count; i++) { | 339 | for (i = 0; i < bp->b_page_count; i++) { |
384 | struct page *page; | 340 | struct page *page; |
385 | uint retries = 0; | 341 | uint retries = 0; |
386 | 342 | retry: | |
387 | retry: | 343 | page = alloc_page(gfp_mask); |
388 | page = find_or_create_page(mapping, first + i, gfp_mask); | ||
389 | if (unlikely(page == NULL)) { | 344 | if (unlikely(page == NULL)) { |
390 | if (flags & XBF_READ_AHEAD) { | 345 | if (flags & XBF_READ_AHEAD) { |
391 | bp->b_page_count = i; | 346 | bp->b_page_count = i; |
392 | for (i = 0; i < bp->b_page_count; i++) | 347 | error = ENOMEM; |
393 | unlock_page(bp->b_pages[i]); | 348 | goto out_free_pages; |
394 | return -ENOMEM; | ||
395 | } | 349 | } |
396 | 350 | ||
397 | /* | 351 | /* |
@@ -401,9 +355,8 @@ _xfs_buf_lookup_pages( | |||
401 | * handle buffer allocation failures we can't do much. | 355 | * handle buffer allocation failures we can't do much. |
402 | */ | 356 | */ |
403 | if (!(++retries % 100)) | 357 | if (!(++retries % 100)) |
404 | printk(KERN_ERR | 358 | xfs_err(NULL, |
405 | "XFS: possible memory allocation " | 359 | "possible memory allocation deadlock in %s (mode:0x%x)", |
406 | "deadlock in %s (mode:0x%x)\n", | ||
407 | __func__, gfp_mask); | 360 | __func__, gfp_mask); |
408 | 361 | ||
409 | XFS_STATS_INC(xb_page_retries); | 362 | XFS_STATS_INC(xb_page_retries); |
@@ -413,33 +366,16 @@ _xfs_buf_lookup_pages( | |||
413 | 366 | ||
414 | XFS_STATS_INC(xb_page_found); | 367 | XFS_STATS_INC(xb_page_found); |
415 | 368 | ||
416 | nbytes = min_t(size_t, size, PAGE_CACHE_SIZE - offset); | 369 | nbytes = min_t(size_t, size, PAGE_SIZE - offset); |
417 | size -= nbytes; | 370 | size -= nbytes; |
418 | |||
419 | ASSERT(!PagePrivate(page)); | ||
420 | if (!PageUptodate(page)) { | ||
421 | page_count--; | ||
422 | if (blocksize >= PAGE_CACHE_SIZE) { | ||
423 | if (flags & XBF_READ) | ||
424 | bp->b_flags |= _XBF_PAGE_LOCKED; | ||
425 | } else if (!PagePrivate(page)) { | ||
426 | if (test_page_region(page, offset, nbytes)) | ||
427 | page_count++; | ||
428 | } | ||
429 | } | ||
430 | |||
431 | bp->b_pages[i] = page; | 371 | bp->b_pages[i] = page; |
432 | offset = 0; | 372 | offset = 0; |
433 | } | 373 | } |
374 | return 0; | ||
434 | 375 | ||
435 | if (!(bp->b_flags & _XBF_PAGE_LOCKED)) { | 376 | out_free_pages: |
436 | for (i = 0; i < bp->b_page_count; i++) | 377 | for (i = 0; i < bp->b_page_count; i++) |
437 | unlock_page(bp->b_pages[i]); | 378 | __free_page(bp->b_pages[i]); |
438 | } | ||
439 | |||
440 | if (page_count == bp->b_page_count) | ||
441 | bp->b_flags |= XBF_DONE; | ||
442 | |||
443 | return error; | 379 | return error; |
444 | } | 380 | } |
445 | 381 | ||
@@ -451,14 +387,23 @@ _xfs_buf_map_pages( | |||
451 | xfs_buf_t *bp, | 387 | xfs_buf_t *bp, |
452 | uint flags) | 388 | uint flags) |
453 | { | 389 | { |
454 | /* A single page buffer is always mappable */ | 390 | ASSERT(bp->b_flags & _XBF_PAGES); |
455 | if (bp->b_page_count == 1) { | 391 | if (bp->b_page_count == 1) { |
392 | /* A single page buffer is always mappable */ | ||
456 | bp->b_addr = page_address(bp->b_pages[0]) + bp->b_offset; | 393 | bp->b_addr = page_address(bp->b_pages[0]) + bp->b_offset; |
457 | bp->b_flags |= XBF_MAPPED; | 394 | bp->b_flags |= XBF_MAPPED; |
458 | } else if (flags & XBF_MAPPED) { | 395 | } else if (flags & XBF_MAPPED) { |
459 | bp->b_addr = vm_map_ram(bp->b_pages, bp->b_page_count, | 396 | int retried = 0; |
460 | -1, PAGE_KERNEL); | 397 | |
461 | if (unlikely(bp->b_addr == NULL)) | 398 | do { |
399 | bp->b_addr = vm_map_ram(bp->b_pages, bp->b_page_count, | ||
400 | -1, PAGE_KERNEL); | ||
401 | if (bp->b_addr) | ||
402 | break; | ||
403 | vm_unmap_aliases(); | ||
404 | } while (retried++ <= 1); | ||
405 | |||
406 | if (!bp->b_addr) | ||
462 | return -ENOMEM; | 407 | return -ENOMEM; |
463 | bp->b_addr += bp->b_offset; | 408 | bp->b_addr += bp->b_offset; |
464 | bp->b_flags |= XBF_MAPPED; | 409 | bp->b_flags |= XBF_MAPPED; |
@@ -569,9 +514,14 @@ found: | |||
569 | } | 514 | } |
570 | } | 515 | } |
571 | 516 | ||
517 | /* | ||
518 | * if the buffer is stale, clear all the external state associated with | ||
519 | * it. We need to keep flags such as how we allocated the buffer memory | ||
520 | * intact here. | ||
521 | */ | ||
572 | if (bp->b_flags & XBF_STALE) { | 522 | if (bp->b_flags & XBF_STALE) { |
573 | ASSERT((bp->b_flags & _XBF_DELWRI_Q) == 0); | 523 | ASSERT((bp->b_flags & _XBF_DELWRI_Q) == 0); |
574 | bp->b_flags &= XBF_MAPPED; | 524 | bp->b_flags &= XBF_MAPPED | _XBF_KMEM | _XBF_PAGES; |
575 | } | 525 | } |
576 | 526 | ||
577 | trace_xfs_buf_find(bp, flags, _RET_IP_); | 527 | trace_xfs_buf_find(bp, flags, _RET_IP_); |
@@ -592,7 +542,7 @@ xfs_buf_get( | |||
592 | xfs_buf_flags_t flags) | 542 | xfs_buf_flags_t flags) |
593 | { | 543 | { |
594 | xfs_buf_t *bp, *new_bp; | 544 | xfs_buf_t *bp, *new_bp; |
595 | int error = 0, i; | 545 | int error = 0; |
596 | 546 | ||
597 | new_bp = xfs_buf_allocate(flags); | 547 | new_bp = xfs_buf_allocate(flags); |
598 | if (unlikely(!new_bp)) | 548 | if (unlikely(!new_bp)) |
@@ -600,7 +550,7 @@ xfs_buf_get( | |||
600 | 550 | ||
601 | bp = _xfs_buf_find(target, ioff, isize, flags, new_bp); | 551 | bp = _xfs_buf_find(target, ioff, isize, flags, new_bp); |
602 | if (bp == new_bp) { | 552 | if (bp == new_bp) { |
603 | error = _xfs_buf_lookup_pages(bp, flags); | 553 | error = xfs_buf_allocate_memory(bp, flags); |
604 | if (error) | 554 | if (error) |
605 | goto no_buffer; | 555 | goto no_buffer; |
606 | } else { | 556 | } else { |
@@ -609,14 +559,11 @@ xfs_buf_get( | |||
609 | return NULL; | 559 | return NULL; |
610 | } | 560 | } |
611 | 561 | ||
612 | for (i = 0; i < bp->b_page_count; i++) | ||
613 | mark_page_accessed(bp->b_pages[i]); | ||
614 | |||
615 | if (!(bp->b_flags & XBF_MAPPED)) { | 562 | if (!(bp->b_flags & XBF_MAPPED)) { |
616 | error = _xfs_buf_map_pages(bp, flags); | 563 | error = _xfs_buf_map_pages(bp, flags); |
617 | if (unlikely(error)) { | 564 | if (unlikely(error)) { |
618 | printk(KERN_WARNING "%s: failed to map pages\n", | 565 | xfs_warn(target->bt_mount, |
619 | __func__); | 566 | "%s: failed to map pages\n", __func__); |
620 | goto no_buffer; | 567 | goto no_buffer; |
621 | } | 568 | } |
622 | } | 569 | } |
@@ -712,8 +659,7 @@ xfs_buf_readahead( | |||
712 | { | 659 | { |
713 | struct backing_dev_info *bdi; | 660 | struct backing_dev_info *bdi; |
714 | 661 | ||
715 | bdi = target->bt_mapping->backing_dev_info; | 662 | if (bdi_read_congested(target->bt_bdi)) |
716 | if (bdi_read_congested(bdi)) | ||
717 | return; | 663 | return; |
718 | 664 | ||
719 | xfs_buf_read(target, ioff, isize, | 665 | xfs_buf_read(target, ioff, isize, |
@@ -791,10 +737,10 @@ xfs_buf_associate_memory( | |||
791 | size_t buflen; | 737 | size_t buflen; |
792 | int page_count; | 738 | int page_count; |
793 | 739 | ||
794 | pageaddr = (unsigned long)mem & PAGE_CACHE_MASK; | 740 | pageaddr = (unsigned long)mem & PAGE_MASK; |
795 | offset = (unsigned long)mem - pageaddr; | 741 | offset = (unsigned long)mem - pageaddr; |
796 | buflen = PAGE_CACHE_ALIGN(len + offset); | 742 | buflen = PAGE_ALIGN(len + offset); |
797 | page_count = buflen >> PAGE_CACHE_SHIFT; | 743 | page_count = buflen >> PAGE_SHIFT; |
798 | 744 | ||
799 | /* Free any previous set of page pointers */ | 745 | /* Free any previous set of page pointers */ |
800 | if (bp->b_pages) | 746 | if (bp->b_pages) |
@@ -811,13 +757,12 @@ xfs_buf_associate_memory( | |||
811 | 757 | ||
812 | for (i = 0; i < bp->b_page_count; i++) { | 758 | for (i = 0; i < bp->b_page_count; i++) { |
813 | bp->b_pages[i] = mem_to_page((void *)pageaddr); | 759 | bp->b_pages[i] = mem_to_page((void *)pageaddr); |
814 | pageaddr += PAGE_CACHE_SIZE; | 760 | pageaddr += PAGE_SIZE; |
815 | } | 761 | } |
816 | 762 | ||
817 | bp->b_count_desired = len; | 763 | bp->b_count_desired = len; |
818 | bp->b_buffer_length = buflen; | 764 | bp->b_buffer_length = buflen; |
819 | bp->b_flags |= XBF_MAPPED; | 765 | bp->b_flags |= XBF_MAPPED; |
820 | bp->b_flags &= ~_XBF_PAGE_LOCKED; | ||
821 | 766 | ||
822 | return 0; | 767 | return 0; |
823 | } | 768 | } |
@@ -850,8 +795,8 @@ xfs_buf_get_uncached( | |||
850 | 795 | ||
851 | error = _xfs_buf_map_pages(bp, XBF_MAPPED); | 796 | error = _xfs_buf_map_pages(bp, XBF_MAPPED); |
852 | if (unlikely(error)) { | 797 | if (unlikely(error)) { |
853 | printk(KERN_WARNING "%s: failed to map pages\n", | 798 | xfs_warn(target->bt_mount, |
854 | __func__); | 799 | "%s: failed to map pages\n", __func__); |
855 | goto fail_free_mem; | 800 | goto fail_free_mem; |
856 | } | 801 | } |
857 | 802 | ||
@@ -924,20 +869,7 @@ xfs_buf_rele( | |||
924 | 869 | ||
925 | 870 | ||
926 | /* | 871 | /* |
927 | * Mutual exclusion on buffers. Locking model: | 872 | * Lock a buffer object, if it is not already locked. |
928 | * | ||
929 | * Buffers associated with inodes for which buffer locking | ||
930 | * is not enabled are not protected by semaphores, and are | ||
931 | * assumed to be exclusively owned by the caller. There is a | ||
932 | * spinlock in the buffer, used by the caller when concurrent | ||
933 | * access is possible. | ||
934 | */ | ||
935 | |||
936 | /* | ||
937 | * Locks a buffer object, if it is not already locked. Note that this in | ||
938 | * no way locks the underlying pages, so it is only useful for | ||
939 | * synchronizing concurrent use of buffer objects, not for synchronizing | ||
940 | * independent access to the underlying pages. | ||
941 | * | 873 | * |
942 | * If we come across a stale, pinned, locked buffer, we know that we are | 874 | * If we come across a stale, pinned, locked buffer, we know that we are |
943 | * being asked to lock a buffer that has been reallocated. Because it is | 875 | * being asked to lock a buffer that has been reallocated. Because it is |
@@ -971,10 +903,7 @@ xfs_buf_lock_value( | |||
971 | } | 903 | } |
972 | 904 | ||
973 | /* | 905 | /* |
974 | * Locks a buffer object. | 906 | * Lock a buffer object. |
975 | * Note that this in no way locks the underlying pages, so it is only | ||
976 | * useful for synchronizing concurrent use of buffer objects, not for | ||
977 | * synchronizing independent access to the underlying pages. | ||
978 | * | 907 | * |
979 | * If we come across a stale, pinned, locked buffer, we know that we | 908 | * If we come across a stale, pinned, locked buffer, we know that we |
980 | * are being asked to lock a buffer that has been reallocated. Because | 909 | * are being asked to lock a buffer that has been reallocated. Because |
@@ -991,7 +920,7 @@ xfs_buf_lock( | |||
991 | if (atomic_read(&bp->b_pin_count) && (bp->b_flags & XBF_STALE)) | 920 | if (atomic_read(&bp->b_pin_count) && (bp->b_flags & XBF_STALE)) |
992 | xfs_log_force(bp->b_target->bt_mount, 0); | 921 | xfs_log_force(bp->b_target->bt_mount, 0); |
993 | if (atomic_read(&bp->b_io_remaining)) | 922 | if (atomic_read(&bp->b_io_remaining)) |
994 | blk_run_address_space(bp->b_target->bt_mapping); | 923 | blk_flush_plug(current); |
995 | down(&bp->b_sema); | 924 | down(&bp->b_sema); |
996 | XB_SET_OWNER(bp); | 925 | XB_SET_OWNER(bp); |
997 | 926 | ||
@@ -1035,9 +964,7 @@ xfs_buf_wait_unpin( | |||
1035 | set_current_state(TASK_UNINTERRUPTIBLE); | 964 | set_current_state(TASK_UNINTERRUPTIBLE); |
1036 | if (atomic_read(&bp->b_pin_count) == 0) | 965 | if (atomic_read(&bp->b_pin_count) == 0) |
1037 | break; | 966 | break; |
1038 | if (atomic_read(&bp->b_io_remaining)) | 967 | io_schedule(); |
1039 | blk_run_address_space(bp->b_target->bt_mapping); | ||
1040 | schedule(); | ||
1041 | } | 968 | } |
1042 | remove_wait_queue(&bp->b_waiters, &wait); | 969 | remove_wait_queue(&bp->b_waiters, &wait); |
1043 | set_current_state(TASK_RUNNING); | 970 | set_current_state(TASK_RUNNING); |
@@ -1249,10 +1176,8 @@ _xfs_buf_ioend( | |||
1249 | xfs_buf_t *bp, | 1176 | xfs_buf_t *bp, |
1250 | int schedule) | 1177 | int schedule) |
1251 | { | 1178 | { |
1252 | if (atomic_dec_and_test(&bp->b_io_remaining) == 1) { | 1179 | if (atomic_dec_and_test(&bp->b_io_remaining) == 1) |
1253 | bp->b_flags &= ~_XBF_PAGE_LOCKED; | ||
1254 | xfs_buf_ioend(bp, schedule); | 1180 | xfs_buf_ioend(bp, schedule); |
1255 | } | ||
1256 | } | 1181 | } |
1257 | 1182 | ||
1258 | STATIC void | 1183 | STATIC void |
@@ -1261,35 +1186,12 @@ xfs_buf_bio_end_io( | |||
1261 | int error) | 1186 | int error) |
1262 | { | 1187 | { |
1263 | xfs_buf_t *bp = (xfs_buf_t *)bio->bi_private; | 1188 | xfs_buf_t *bp = (xfs_buf_t *)bio->bi_private; |
1264 | unsigned int blocksize = bp->b_target->bt_bsize; | ||
1265 | struct bio_vec *bvec = bio->bi_io_vec + bio->bi_vcnt - 1; | ||
1266 | 1189 | ||
1267 | xfs_buf_ioerror(bp, -error); | 1190 | xfs_buf_ioerror(bp, -error); |
1268 | 1191 | ||
1269 | if (!error && xfs_buf_is_vmapped(bp) && (bp->b_flags & XBF_READ)) | 1192 | if (!error && xfs_buf_is_vmapped(bp) && (bp->b_flags & XBF_READ)) |
1270 | invalidate_kernel_vmap_range(bp->b_addr, xfs_buf_vmap_len(bp)); | 1193 | invalidate_kernel_vmap_range(bp->b_addr, xfs_buf_vmap_len(bp)); |
1271 | 1194 | ||
1272 | do { | ||
1273 | struct page *page = bvec->bv_page; | ||
1274 | |||
1275 | ASSERT(!PagePrivate(page)); | ||
1276 | if (unlikely(bp->b_error)) { | ||
1277 | if (bp->b_flags & XBF_READ) | ||
1278 | ClearPageUptodate(page); | ||
1279 | } else if (blocksize >= PAGE_CACHE_SIZE) { | ||
1280 | SetPageUptodate(page); | ||
1281 | } else if (!PagePrivate(page) && | ||
1282 | (bp->b_flags & _XBF_PAGE_CACHE)) { | ||
1283 | set_page_region(page, bvec->bv_offset, bvec->bv_len); | ||
1284 | } | ||
1285 | |||
1286 | if (--bvec >= bio->bi_io_vec) | ||
1287 | prefetchw(&bvec->bv_page->flags); | ||
1288 | |||
1289 | if (bp->b_flags & _XBF_PAGE_LOCKED) | ||
1290 | unlock_page(page); | ||
1291 | } while (bvec >= bio->bi_io_vec); | ||
1292 | |||
1293 | _xfs_buf_ioend(bp, 1); | 1195 | _xfs_buf_ioend(bp, 1); |
1294 | bio_put(bio); | 1196 | bio_put(bio); |
1295 | } | 1197 | } |
@@ -1303,7 +1205,6 @@ _xfs_buf_ioapply( | |||
1303 | int offset = bp->b_offset; | 1205 | int offset = bp->b_offset; |
1304 | int size = bp->b_count_desired; | 1206 | int size = bp->b_count_desired; |
1305 | sector_t sector = bp->b_bn; | 1207 | sector_t sector = bp->b_bn; |
1306 | unsigned int blocksize = bp->b_target->bt_bsize; | ||
1307 | 1208 | ||
1308 | total_nr_pages = bp->b_page_count; | 1209 | total_nr_pages = bp->b_page_count; |
1309 | map_i = 0; | 1210 | map_i = 0; |
@@ -1324,29 +1225,6 @@ _xfs_buf_ioapply( | |||
1324 | (bp->b_flags & XBF_READ_AHEAD) ? READA : READ; | 1225 | (bp->b_flags & XBF_READ_AHEAD) ? READA : READ; |
1325 | } | 1226 | } |
1326 | 1227 | ||
1327 | /* Special code path for reading a sub page size buffer in -- | ||
1328 | * we populate up the whole page, and hence the other metadata | ||
1329 | * in the same page. This optimization is only valid when the | ||
1330 | * filesystem block size is not smaller than the page size. | ||
1331 | */ | ||
1332 | if ((bp->b_buffer_length < PAGE_CACHE_SIZE) && | ||
1333 | ((bp->b_flags & (XBF_READ|_XBF_PAGE_LOCKED)) == | ||
1334 | (XBF_READ|_XBF_PAGE_LOCKED)) && | ||
1335 | (blocksize >= PAGE_CACHE_SIZE)) { | ||
1336 | bio = bio_alloc(GFP_NOIO, 1); | ||
1337 | |||
1338 | bio->bi_bdev = bp->b_target->bt_bdev; | ||
1339 | bio->bi_sector = sector - (offset >> BBSHIFT); | ||
1340 | bio->bi_end_io = xfs_buf_bio_end_io; | ||
1341 | bio->bi_private = bp; | ||
1342 | |||
1343 | bio_add_page(bio, bp->b_pages[0], PAGE_CACHE_SIZE, 0); | ||
1344 | size = 0; | ||
1345 | |||
1346 | atomic_inc(&bp->b_io_remaining); | ||
1347 | |||
1348 | goto submit_io; | ||
1349 | } | ||
1350 | 1228 | ||
1351 | next_chunk: | 1229 | next_chunk: |
1352 | atomic_inc(&bp->b_io_remaining); | 1230 | atomic_inc(&bp->b_io_remaining); |
@@ -1360,8 +1238,9 @@ next_chunk: | |||
1360 | bio->bi_end_io = xfs_buf_bio_end_io; | 1238 | bio->bi_end_io = xfs_buf_bio_end_io; |
1361 | bio->bi_private = bp; | 1239 | bio->bi_private = bp; |
1362 | 1240 | ||
1241 | |||
1363 | for (; size && nr_pages; nr_pages--, map_i++) { | 1242 | for (; size && nr_pages; nr_pages--, map_i++) { |
1364 | int rbytes, nbytes = PAGE_CACHE_SIZE - offset; | 1243 | int rbytes, nbytes = PAGE_SIZE - offset; |
1365 | 1244 | ||
1366 | if (nbytes > size) | 1245 | if (nbytes > size) |
1367 | nbytes = size; | 1246 | nbytes = size; |
@@ -1376,7 +1255,6 @@ next_chunk: | |||
1376 | total_nr_pages--; | 1255 | total_nr_pages--; |
1377 | } | 1256 | } |
1378 | 1257 | ||
1379 | submit_io: | ||
1380 | if (likely(bio->bi_size)) { | 1258 | if (likely(bio->bi_size)) { |
1381 | if (xfs_buf_is_vmapped(bp)) { | 1259 | if (xfs_buf_is_vmapped(bp)) { |
1382 | flush_kernel_vmap_range(bp->b_addr, | 1260 | flush_kernel_vmap_range(bp->b_addr, |
@@ -1386,18 +1264,7 @@ submit_io: | |||
1386 | if (size) | 1264 | if (size) |
1387 | goto next_chunk; | 1265 | goto next_chunk; |
1388 | } else { | 1266 | } else { |
1389 | /* | ||
1390 | * if we get here, no pages were added to the bio. However, | ||
1391 | * we can't just error out here - if the pages are locked then | ||
1392 | * we have to unlock them otherwise we can hang on a later | ||
1393 | * access to the page. | ||
1394 | */ | ||
1395 | xfs_buf_ioerror(bp, EIO); | 1267 | xfs_buf_ioerror(bp, EIO); |
1396 | if (bp->b_flags & _XBF_PAGE_LOCKED) { | ||
1397 | int i; | ||
1398 | for (i = 0; i < bp->b_page_count; i++) | ||
1399 | unlock_page(bp->b_pages[i]); | ||
1400 | } | ||
1401 | bio_put(bio); | 1268 | bio_put(bio); |
1402 | } | 1269 | } |
1403 | } | 1270 | } |
@@ -1443,7 +1310,7 @@ xfs_buf_iowait( | |||
1443 | trace_xfs_buf_iowait(bp, _RET_IP_); | 1310 | trace_xfs_buf_iowait(bp, _RET_IP_); |
1444 | 1311 | ||
1445 | if (atomic_read(&bp->b_io_remaining)) | 1312 | if (atomic_read(&bp->b_io_remaining)) |
1446 | blk_run_address_space(bp->b_target->bt_mapping); | 1313 | blk_flush_plug(current); |
1447 | wait_for_completion(&bp->b_iowait); | 1314 | wait_for_completion(&bp->b_iowait); |
1448 | 1315 | ||
1449 | trace_xfs_buf_iowait_done(bp, _RET_IP_); | 1316 | trace_xfs_buf_iowait_done(bp, _RET_IP_); |
@@ -1461,8 +1328,8 @@ xfs_buf_offset( | |||
1461 | return XFS_BUF_PTR(bp) + offset; | 1328 | return XFS_BUF_PTR(bp) + offset; |
1462 | 1329 | ||
1463 | offset += bp->b_offset; | 1330 | offset += bp->b_offset; |
1464 | page = bp->b_pages[offset >> PAGE_CACHE_SHIFT]; | 1331 | page = bp->b_pages[offset >> PAGE_SHIFT]; |
1465 | return (xfs_caddr_t)page_address(page) + (offset & (PAGE_CACHE_SIZE-1)); | 1332 | return (xfs_caddr_t)page_address(page) + (offset & (PAGE_SIZE-1)); |
1466 | } | 1333 | } |
1467 | 1334 | ||
1468 | /* | 1335 | /* |
@@ -1484,9 +1351,9 @@ xfs_buf_iomove( | |||
1484 | page = bp->b_pages[xfs_buf_btoct(boff + bp->b_offset)]; | 1351 | page = bp->b_pages[xfs_buf_btoct(boff + bp->b_offset)]; |
1485 | cpoff = xfs_buf_poff(boff + bp->b_offset); | 1352 | cpoff = xfs_buf_poff(boff + bp->b_offset); |
1486 | csize = min_t(size_t, | 1353 | csize = min_t(size_t, |
1487 | PAGE_CACHE_SIZE-cpoff, bp->b_count_desired-boff); | 1354 | PAGE_SIZE-cpoff, bp->b_count_desired-boff); |
1488 | 1355 | ||
1489 | ASSERT(((csize + cpoff) <= PAGE_CACHE_SIZE)); | 1356 | ASSERT(((csize + cpoff) <= PAGE_SIZE)); |
1490 | 1357 | ||
1491 | switch (mode) { | 1358 | switch (mode) { |
1492 | case XBRW_ZERO: | 1359 | case XBRW_ZERO: |
@@ -1599,7 +1466,6 @@ xfs_free_buftarg( | |||
1599 | xfs_flush_buftarg(btp, 1); | 1466 | xfs_flush_buftarg(btp, 1); |
1600 | if (mp->m_flags & XFS_MOUNT_BARRIER) | 1467 | if (mp->m_flags & XFS_MOUNT_BARRIER) |
1601 | xfs_blkdev_issue_flush(btp); | 1468 | xfs_blkdev_issue_flush(btp); |
1602 | iput(btp->bt_mapping->host); | ||
1603 | 1469 | ||
1604 | kthread_stop(btp->bt_task); | 1470 | kthread_stop(btp->bt_task); |
1605 | kmem_free(btp); | 1471 | kmem_free(btp); |
@@ -1617,21 +1483,12 @@ xfs_setsize_buftarg_flags( | |||
1617 | btp->bt_smask = sectorsize - 1; | 1483 | btp->bt_smask = sectorsize - 1; |
1618 | 1484 | ||
1619 | if (set_blocksize(btp->bt_bdev, sectorsize)) { | 1485 | if (set_blocksize(btp->bt_bdev, sectorsize)) { |
1620 | printk(KERN_WARNING | 1486 | xfs_warn(btp->bt_mount, |
1621 | "XFS: Cannot set_blocksize to %u on device %s\n", | 1487 | "Cannot set_blocksize to %u on device %s\n", |
1622 | sectorsize, XFS_BUFTARG_NAME(btp)); | 1488 | sectorsize, XFS_BUFTARG_NAME(btp)); |
1623 | return EINVAL; | 1489 | return EINVAL; |
1624 | } | 1490 | } |
1625 | 1491 | ||
1626 | if (verbose && | ||
1627 | (PAGE_CACHE_SIZE / BITS_PER_LONG) > sectorsize) { | ||
1628 | printk(KERN_WARNING | ||
1629 | "XFS: %u byte sectors in use on device %s. " | ||
1630 | "This is suboptimal; %u or greater is ideal.\n", | ||
1631 | sectorsize, XFS_BUFTARG_NAME(btp), | ||
1632 | (unsigned int)PAGE_CACHE_SIZE / BITS_PER_LONG); | ||
1633 | } | ||
1634 | |||
1635 | return 0; | 1492 | return 0; |
1636 | } | 1493 | } |
1637 | 1494 | ||
@@ -1646,7 +1503,7 @@ xfs_setsize_buftarg_early( | |||
1646 | struct block_device *bdev) | 1503 | struct block_device *bdev) |
1647 | { | 1504 | { |
1648 | return xfs_setsize_buftarg_flags(btp, | 1505 | return xfs_setsize_buftarg_flags(btp, |
1649 | PAGE_CACHE_SIZE, bdev_logical_block_size(bdev), 0); | 1506 | PAGE_SIZE, bdev_logical_block_size(bdev), 0); |
1650 | } | 1507 | } |
1651 | 1508 | ||
1652 | int | 1509 | int |
@@ -1659,41 +1516,6 @@ xfs_setsize_buftarg( | |||
1659 | } | 1516 | } |
1660 | 1517 | ||
1661 | STATIC int | 1518 | STATIC int |
1662 | xfs_mapping_buftarg( | ||
1663 | xfs_buftarg_t *btp, | ||
1664 | struct block_device *bdev) | ||
1665 | { | ||
1666 | struct backing_dev_info *bdi; | ||
1667 | struct inode *inode; | ||
1668 | struct address_space *mapping; | ||
1669 | static const struct address_space_operations mapping_aops = { | ||
1670 | .sync_page = block_sync_page, | ||
1671 | .migratepage = fail_migrate_page, | ||
1672 | }; | ||
1673 | |||
1674 | inode = new_inode(bdev->bd_inode->i_sb); | ||
1675 | if (!inode) { | ||
1676 | printk(KERN_WARNING | ||
1677 | "XFS: Cannot allocate mapping inode for device %s\n", | ||
1678 | XFS_BUFTARG_NAME(btp)); | ||
1679 | return ENOMEM; | ||
1680 | } | ||
1681 | inode->i_ino = get_next_ino(); | ||
1682 | inode->i_mode = S_IFBLK; | ||
1683 | inode->i_bdev = bdev; | ||
1684 | inode->i_rdev = bdev->bd_dev; | ||
1685 | bdi = blk_get_backing_dev_info(bdev); | ||
1686 | if (!bdi) | ||
1687 | bdi = &default_backing_dev_info; | ||
1688 | mapping = &inode->i_data; | ||
1689 | mapping->a_ops = &mapping_aops; | ||
1690 | mapping->backing_dev_info = bdi; | ||
1691 | mapping_set_gfp_mask(mapping, GFP_NOFS); | ||
1692 | btp->bt_mapping = mapping; | ||
1693 | return 0; | ||
1694 | } | ||
1695 | |||
1696 | STATIC int | ||
1697 | xfs_alloc_delwrite_queue( | 1519 | xfs_alloc_delwrite_queue( |
1698 | xfs_buftarg_t *btp, | 1520 | xfs_buftarg_t *btp, |
1699 | const char *fsname) | 1521 | const char *fsname) |
@@ -1721,12 +1543,14 @@ xfs_alloc_buftarg( | |||
1721 | btp->bt_mount = mp; | 1543 | btp->bt_mount = mp; |
1722 | btp->bt_dev = bdev->bd_dev; | 1544 | btp->bt_dev = bdev->bd_dev; |
1723 | btp->bt_bdev = bdev; | 1545 | btp->bt_bdev = bdev; |
1546 | btp->bt_bdi = blk_get_backing_dev_info(bdev); | ||
1547 | if (!btp->bt_bdi) | ||
1548 | goto error; | ||
1549 | |||
1724 | INIT_LIST_HEAD(&btp->bt_lru); | 1550 | INIT_LIST_HEAD(&btp->bt_lru); |
1725 | spin_lock_init(&btp->bt_lru_lock); | 1551 | spin_lock_init(&btp->bt_lru_lock); |
1726 | if (xfs_setsize_buftarg_early(btp, bdev)) | 1552 | if (xfs_setsize_buftarg_early(btp, bdev)) |
1727 | goto error; | 1553 | goto error; |
1728 | if (xfs_mapping_buftarg(btp, bdev)) | ||
1729 | goto error; | ||
1730 | if (xfs_alloc_delwrite_queue(btp, fsname)) | 1554 | if (xfs_alloc_delwrite_queue(btp, fsname)) |
1731 | goto error; | 1555 | goto error; |
1732 | btp->bt_shrinker.shrink = xfs_buftarg_shrink; | 1556 | btp->bt_shrinker.shrink = xfs_buftarg_shrink; |
@@ -1948,7 +1772,7 @@ xfsbufd( | |||
1948 | count++; | 1772 | count++; |
1949 | } | 1773 | } |
1950 | if (count) | 1774 | if (count) |
1951 | blk_run_address_space(target->bt_mapping); | 1775 | blk_flush_plug(current); |
1952 | 1776 | ||
1953 | } while (!kthread_should_stop()); | 1777 | } while (!kthread_should_stop()); |
1954 | 1778 | ||
@@ -1996,7 +1820,7 @@ xfs_flush_buftarg( | |||
1996 | 1820 | ||
1997 | if (wait) { | 1821 | if (wait) { |
1998 | /* Expedite and wait for IO to complete. */ | 1822 | /* Expedite and wait for IO to complete. */ |
1999 | blk_run_address_space(target->bt_mapping); | 1823 | blk_flush_plug(current); |
2000 | while (!list_empty(&wait_list)) { | 1824 | while (!list_empty(&wait_list)) { |
2001 | bp = list_first_entry(&wait_list, struct xfs_buf, b_list); | 1825 | bp = list_first_entry(&wait_list, struct xfs_buf, b_list); |
2002 | 1826 | ||
diff --git a/fs/xfs/linux-2.6/xfs_buf.h b/fs/xfs/linux-2.6/xfs_buf.h index cbe65950e524..a9a1c4512645 100644 --- a/fs/xfs/linux-2.6/xfs_buf.h +++ b/fs/xfs/linux-2.6/xfs_buf.h | |||
@@ -61,30 +61,11 @@ typedef enum { | |||
61 | #define XBF_DONT_BLOCK (1 << 16)/* do not block in current thread */ | 61 | #define XBF_DONT_BLOCK (1 << 16)/* do not block in current thread */ |
62 | 62 | ||
63 | /* flags used only internally */ | 63 | /* flags used only internally */ |
64 | #define _XBF_PAGE_CACHE (1 << 17)/* backed by pagecache */ | ||
65 | #define _XBF_PAGES (1 << 18)/* backed by refcounted pages */ | 64 | #define _XBF_PAGES (1 << 18)/* backed by refcounted pages */ |
66 | #define _XBF_RUN_QUEUES (1 << 19)/* run block device task queue */ | 65 | #define _XBF_RUN_QUEUES (1 << 19)/* run block device task queue */ |
66 | #define _XBF_KMEM (1 << 20)/* backed by heap memory */ | ||
67 | #define _XBF_DELWRI_Q (1 << 21)/* buffer on delwri queue */ | 67 | #define _XBF_DELWRI_Q (1 << 21)/* buffer on delwri queue */ |
68 | 68 | ||
69 | /* | ||
70 | * Special flag for supporting metadata blocks smaller than a FSB. | ||
71 | * | ||
72 | * In this case we can have multiple xfs_buf_t on a single page and | ||
73 | * need to lock out concurrent xfs_buf_t readers as they only | ||
74 | * serialise access to the buffer. | ||
75 | * | ||
76 | * If the FSB size >= PAGE_CACHE_SIZE case, we have no serialisation | ||
77 | * between reads of the page. Hence we can have one thread read the | ||
78 | * page and modify it, but then race with another thread that thinks | ||
79 | * the page is not up-to-date and hence reads it again. | ||
80 | * | ||
81 | * The result is that the first modifcation to the page is lost. | ||
82 | * This sort of AGF/AGI reading race can happen when unlinking inodes | ||
83 | * that require truncation and results in the AGI unlinked list | ||
84 | * modifications being lost. | ||
85 | */ | ||
86 | #define _XBF_PAGE_LOCKED (1 << 22) | ||
87 | |||
88 | typedef unsigned int xfs_buf_flags_t; | 69 | typedef unsigned int xfs_buf_flags_t; |
89 | 70 | ||
90 | #define XFS_BUF_FLAGS \ | 71 | #define XFS_BUF_FLAGS \ |
@@ -100,12 +81,10 @@ typedef unsigned int xfs_buf_flags_t; | |||
100 | { XBF_LOCK, "LOCK" }, /* should never be set */\ | 81 | { XBF_LOCK, "LOCK" }, /* should never be set */\ |
101 | { XBF_TRYLOCK, "TRYLOCK" }, /* ditto */\ | 82 | { XBF_TRYLOCK, "TRYLOCK" }, /* ditto */\ |
102 | { XBF_DONT_BLOCK, "DONT_BLOCK" }, /* ditto */\ | 83 | { XBF_DONT_BLOCK, "DONT_BLOCK" }, /* ditto */\ |
103 | { _XBF_PAGE_CACHE, "PAGE_CACHE" }, \ | ||
104 | { _XBF_PAGES, "PAGES" }, \ | 84 | { _XBF_PAGES, "PAGES" }, \ |
105 | { _XBF_RUN_QUEUES, "RUN_QUEUES" }, \ | 85 | { _XBF_RUN_QUEUES, "RUN_QUEUES" }, \ |
106 | { _XBF_DELWRI_Q, "DELWRI_Q" }, \ | 86 | { _XBF_KMEM, "KMEM" }, \ |
107 | { _XBF_PAGE_LOCKED, "PAGE_LOCKED" } | 87 | { _XBF_DELWRI_Q, "DELWRI_Q" } |
108 | |||
109 | 88 | ||
110 | typedef enum { | 89 | typedef enum { |
111 | XBT_FORCE_SLEEP = 0, | 90 | XBT_FORCE_SLEEP = 0, |
@@ -120,7 +99,7 @@ typedef struct xfs_bufhash { | |||
120 | typedef struct xfs_buftarg { | 99 | typedef struct xfs_buftarg { |
121 | dev_t bt_dev; | 100 | dev_t bt_dev; |
122 | struct block_device *bt_bdev; | 101 | struct block_device *bt_bdev; |
123 | struct address_space *bt_mapping; | 102 | struct backing_dev_info *bt_bdi; |
124 | struct xfs_mount *bt_mount; | 103 | struct xfs_mount *bt_mount; |
125 | unsigned int bt_bsize; | 104 | unsigned int bt_bsize; |
126 | unsigned int bt_sshift; | 105 | unsigned int bt_sshift; |
@@ -139,17 +118,6 @@ typedef struct xfs_buftarg { | |||
139 | unsigned int bt_lru_nr; | 118 | unsigned int bt_lru_nr; |
140 | } xfs_buftarg_t; | 119 | } xfs_buftarg_t; |
141 | 120 | ||
142 | /* | ||
143 | * xfs_buf_t: Buffer structure for pagecache-based buffers | ||
144 | * | ||
145 | * This buffer structure is used by the pagecache buffer management routines | ||
146 | * to refer to an assembly of pages forming a logical buffer. | ||
147 | * | ||
148 | * The buffer structure is used on a temporary basis only, and discarded when | ||
149 | * released. The real data storage is recorded in the pagecache. Buffers are | ||
150 | * hashed to the block device on which the file system resides. | ||
151 | */ | ||
152 | |||
153 | struct xfs_buf; | 121 | struct xfs_buf; |
154 | typedef void (*xfs_buf_iodone_t)(struct xfs_buf *); | 122 | typedef void (*xfs_buf_iodone_t)(struct xfs_buf *); |
155 | 123 | ||
diff --git a/fs/xfs/linux-2.6/xfs_file.c b/fs/xfs/linux-2.6/xfs_file.c index a55c1b46b219..52aadfbed132 100644 --- a/fs/xfs/linux-2.6/xfs_file.c +++ b/fs/xfs/linux-2.6/xfs_file.c | |||
@@ -896,6 +896,7 @@ xfs_file_fallocate( | |||
896 | xfs_flock64_t bf; | 896 | xfs_flock64_t bf; |
897 | xfs_inode_t *ip = XFS_I(inode); | 897 | xfs_inode_t *ip = XFS_I(inode); |
898 | int cmd = XFS_IOC_RESVSP; | 898 | int cmd = XFS_IOC_RESVSP; |
899 | int attr_flags = XFS_ATTR_NOLOCK; | ||
899 | 900 | ||
900 | if (mode & ~(FALLOC_FL_KEEP_SIZE | FALLOC_FL_PUNCH_HOLE)) | 901 | if (mode & ~(FALLOC_FL_KEEP_SIZE | FALLOC_FL_PUNCH_HOLE)) |
901 | return -EOPNOTSUPP; | 902 | return -EOPNOTSUPP; |
@@ -918,7 +919,10 @@ xfs_file_fallocate( | |||
918 | goto out_unlock; | 919 | goto out_unlock; |
919 | } | 920 | } |
920 | 921 | ||
921 | error = -xfs_change_file_space(ip, cmd, &bf, 0, XFS_ATTR_NOLOCK); | 922 | if (file->f_flags & O_DSYNC) |
923 | attr_flags |= XFS_ATTR_SYNC; | ||
924 | |||
925 | error = -xfs_change_file_space(ip, cmd, &bf, 0, attr_flags); | ||
922 | if (error) | 926 | if (error) |
923 | goto out_unlock; | 927 | goto out_unlock; |
924 | 928 | ||
diff --git a/fs/xfs/linux-2.6/xfs_ioctl.c b/fs/xfs/linux-2.6/xfs_ioctl.c index 0ca0e3c024d7..acca2c5ca3fa 100644 --- a/fs/xfs/linux-2.6/xfs_ioctl.c +++ b/fs/xfs/linux-2.6/xfs_ioctl.c | |||
@@ -624,6 +624,10 @@ xfs_ioc_space( | |||
624 | 624 | ||
625 | if (filp->f_flags & (O_NDELAY|O_NONBLOCK)) | 625 | if (filp->f_flags & (O_NDELAY|O_NONBLOCK)) |
626 | attr_flags |= XFS_ATTR_NONBLOCK; | 626 | attr_flags |= XFS_ATTR_NONBLOCK; |
627 | |||
628 | if (filp->f_flags & O_DSYNC) | ||
629 | attr_flags |= XFS_ATTR_SYNC; | ||
630 | |||
627 | if (ioflags & IO_INVIS) | 631 | if (ioflags & IO_INVIS) |
628 | attr_flags |= XFS_ATTR_DMI; | 632 | attr_flags |= XFS_ATTR_DMI; |
629 | 633 | ||
diff --git a/fs/xfs/linux-2.6/xfs_linux.h b/fs/xfs/linux-2.6/xfs_linux.h index 096494997747..244be9cbfe78 100644 --- a/fs/xfs/linux-2.6/xfs_linux.h +++ b/fs/xfs/linux-2.6/xfs_linux.h | |||
@@ -39,7 +39,6 @@ | |||
39 | #include <mrlock.h> | 39 | #include <mrlock.h> |
40 | #include <time.h> | 40 | #include <time.h> |
41 | 41 | ||
42 | #include <support/debug.h> | ||
43 | #include <support/uuid.h> | 42 | #include <support/uuid.h> |
44 | 43 | ||
45 | #include <linux/semaphore.h> | 44 | #include <linux/semaphore.h> |
@@ -86,6 +85,7 @@ | |||
86 | #include <xfs_aops.h> | 85 | #include <xfs_aops.h> |
87 | #include <xfs_super.h> | 86 | #include <xfs_super.h> |
88 | #include <xfs_buf.h> | 87 | #include <xfs_buf.h> |
88 | #include <xfs_message.h> | ||
89 | 89 | ||
90 | /* | 90 | /* |
91 | * Feature macros (disable/enable) | 91 | * Feature macros (disable/enable) |
@@ -280,4 +280,25 @@ static inline __uint64_t howmany_64(__uint64_t x, __uint32_t y) | |||
280 | #define __arch_pack | 280 | #define __arch_pack |
281 | #endif | 281 | #endif |
282 | 282 | ||
283 | #define ASSERT_ALWAYS(expr) \ | ||
284 | (unlikely(expr) ? (void)0 : assfail(#expr, __FILE__, __LINE__)) | ||
285 | |||
286 | #ifndef DEBUG | ||
287 | #define ASSERT(expr) ((void)0) | ||
288 | |||
289 | #ifndef STATIC | ||
290 | # define STATIC static noinline | ||
291 | #endif | ||
292 | |||
293 | #else /* DEBUG */ | ||
294 | |||
295 | #define ASSERT(expr) \ | ||
296 | (unlikely(expr) ? (void)0 : assfail(#expr, __FILE__, __LINE__)) | ||
297 | |||
298 | #ifndef STATIC | ||
299 | # define STATIC noinline | ||
300 | #endif | ||
301 | |||
302 | #endif /* DEBUG */ | ||
303 | |||
283 | #endif /* __XFS_LINUX__ */ | 304 | #endif /* __XFS_LINUX__ */ |
diff --git a/fs/xfs/linux-2.6/xfs_message.c b/fs/xfs/linux-2.6/xfs_message.c new file mode 100644 index 000000000000..508e06fd7d1e --- /dev/null +++ b/fs/xfs/linux-2.6/xfs_message.c | |||
@@ -0,0 +1,133 @@ | |||
1 | /* | ||
2 | * Copyright (c) 2011 Red Hat, Inc. All Rights Reserved. | ||
3 | * | ||
4 | * This program is free software; you can redistribute it and/or | ||
5 | * modify it under the terms of the GNU General Public License as | ||
6 | * published by the Free Software Foundation. | ||
7 | * | ||
8 | * This program is distributed in the hope that it would be useful, | ||
9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
11 | * GNU General Public License for more details. | ||
12 | * | ||
13 | * You should have received a copy of the GNU General Public License | ||
14 | * along with this program; if not, write the Free Software Foundation, | ||
15 | * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA | ||
16 | */ | ||
17 | |||
18 | #include "xfs.h" | ||
19 | #include "xfs_fs.h" | ||
20 | #include "xfs_types.h" | ||
21 | #include "xfs_log.h" | ||
22 | #include "xfs_inum.h" | ||
23 | #include "xfs_trans.h" | ||
24 | #include "xfs_sb.h" | ||
25 | #include "xfs_ag.h" | ||
26 | #include "xfs_mount.h" | ||
27 | |||
28 | /* | ||
29 | * XFS logging functions | ||
30 | */ | ||
31 | static int | ||
32 | __xfs_printk( | ||
33 | const char *level, | ||
34 | const struct xfs_mount *mp, | ||
35 | struct va_format *vaf) | ||
36 | { | ||
37 | if (mp && mp->m_fsname) | ||
38 | return printk("%sXFS (%s): %pV\n", level, mp->m_fsname, vaf); | ||
39 | return printk("%sXFS: %pV\n", level, vaf); | ||
40 | } | ||
41 | |||
42 | int xfs_printk( | ||
43 | const char *level, | ||
44 | const struct xfs_mount *mp, | ||
45 | const char *fmt, ...) | ||
46 | { | ||
47 | struct va_format vaf; | ||
48 | va_list args; | ||
49 | int r; | ||
50 | |||
51 | va_start(args, fmt); | ||
52 | |||
53 | vaf.fmt = fmt; | ||
54 | vaf.va = &args; | ||
55 | |||
56 | r = __xfs_printk(level, mp, &vaf); | ||
57 | va_end(args); | ||
58 | |||
59 | return r; | ||
60 | } | ||
61 | |||
62 | #define define_xfs_printk_level(func, kern_level) \ | ||
63 | int func(const struct xfs_mount *mp, const char *fmt, ...) \ | ||
64 | { \ | ||
65 | struct va_format vaf; \ | ||
66 | va_list args; \ | ||
67 | int r; \ | ||
68 | \ | ||
69 | va_start(args, fmt); \ | ||
70 | \ | ||
71 | vaf.fmt = fmt; \ | ||
72 | vaf.va = &args; \ | ||
73 | \ | ||
74 | r = __xfs_printk(kern_level, mp, &vaf); \ | ||
75 | va_end(args); \ | ||
76 | \ | ||
77 | return r; \ | ||
78 | } \ | ||
79 | |||
80 | define_xfs_printk_level(xfs_emerg, KERN_EMERG); | ||
81 | define_xfs_printk_level(xfs_alert, KERN_ALERT); | ||
82 | define_xfs_printk_level(xfs_crit, KERN_CRIT); | ||
83 | define_xfs_printk_level(xfs_err, KERN_ERR); | ||
84 | define_xfs_printk_level(xfs_warn, KERN_WARNING); | ||
85 | define_xfs_printk_level(xfs_notice, KERN_NOTICE); | ||
86 | define_xfs_printk_level(xfs_info, KERN_INFO); | ||
87 | #ifdef DEBUG | ||
88 | define_xfs_printk_level(xfs_debug, KERN_DEBUG); | ||
89 | #endif | ||
90 | |||
91 | int | ||
92 | xfs_alert_tag( | ||
93 | const struct xfs_mount *mp, | ||
94 | int panic_tag, | ||
95 | const char *fmt, ...) | ||
96 | { | ||
97 | struct va_format vaf; | ||
98 | va_list args; | ||
99 | int do_panic = 0; | ||
100 | int r; | ||
101 | |||
102 | if (xfs_panic_mask && (xfs_panic_mask & panic_tag)) { | ||
103 | xfs_printk(KERN_ALERT, mp, | ||
104 | "XFS: Transforming an alert into a BUG."); | ||
105 | do_panic = 1; | ||
106 | } | ||
107 | |||
108 | va_start(args, fmt); | ||
109 | |||
110 | vaf.fmt = fmt; | ||
111 | vaf.va = &args; | ||
112 | |||
113 | r = __xfs_printk(KERN_ALERT, mp, &vaf); | ||
114 | va_end(args); | ||
115 | |||
116 | BUG_ON(do_panic); | ||
117 | |||
118 | return r; | ||
119 | } | ||
120 | |||
121 | void | ||
122 | assfail(char *expr, char *file, int line) | ||
123 | { | ||
124 | xfs_emerg(NULL, "Assertion failed: %s, file: %s, line: %d", | ||
125 | expr, file, line); | ||
126 | BUG(); | ||
127 | } | ||
128 | |||
129 | void | ||
130 | xfs_hex_dump(void *p, int length) | ||
131 | { | ||
132 | print_hex_dump(KERN_ALERT, "", DUMP_PREFIX_ADDRESS, 16, 1, p, length, 1); | ||
133 | } | ||
diff --git a/fs/xfs/linux-2.6/xfs_message.h b/fs/xfs/linux-2.6/xfs_message.h new file mode 100644 index 000000000000..e77ffa16745b --- /dev/null +++ b/fs/xfs/linux-2.6/xfs_message.h | |||
@@ -0,0 +1,38 @@ | |||
1 | #ifndef __XFS_MESSAGE_H | ||
2 | #define __XFS_MESSAGE_H 1 | ||
3 | |||
4 | struct xfs_mount; | ||
5 | |||
6 | extern int xfs_printk(const char *level, const struct xfs_mount *mp, | ||
7 | const char *fmt, ...) | ||
8 | __attribute__ ((format (printf, 3, 4))); | ||
9 | extern int xfs_emerg(const struct xfs_mount *mp, const char *fmt, ...) | ||
10 | __attribute__ ((format (printf, 2, 3))); | ||
11 | extern int xfs_alert(const struct xfs_mount *mp, const char *fmt, ...) | ||
12 | __attribute__ ((format (printf, 2, 3))); | ||
13 | extern int xfs_alert_tag(const struct xfs_mount *mp, int tag, | ||
14 | const char *fmt, ...) | ||
15 | __attribute__ ((format (printf, 3, 4))); | ||
16 | extern int xfs_crit(const struct xfs_mount *mp, const char *fmt, ...) | ||
17 | __attribute__ ((format (printf, 2, 3))); | ||
18 | extern int xfs_err(const struct xfs_mount *mp, const char *fmt, ...) | ||
19 | __attribute__ ((format (printf, 2, 3))); | ||
20 | extern int xfs_warn(const struct xfs_mount *mp, const char *fmt, ...) | ||
21 | __attribute__ ((format (printf, 2, 3))); | ||
22 | extern int xfs_notice(const struct xfs_mount *mp, const char *fmt, ...) | ||
23 | __attribute__ ((format (printf, 2, 3))); | ||
24 | extern int xfs_info(const struct xfs_mount *mp, const char *fmt, ...) | ||
25 | __attribute__ ((format (printf, 2, 3))); | ||
26 | |||
27 | #ifdef DEBUG | ||
28 | extern int xfs_debug(const struct xfs_mount *mp, const char *fmt, ...) | ||
29 | __attribute__ ((format (printf, 2, 3))); | ||
30 | #else | ||
31 | #define xfs_debug(mp, fmt, ...) (0) | ||
32 | #endif | ||
33 | |||
34 | extern void assfail(char *expr, char *f, int l); | ||
35 | |||
36 | extern void xfs_hex_dump(void *p, int length); | ||
37 | |||
38 | #endif /* __XFS_MESSAGE_H */ | ||
diff --git a/fs/xfs/linux-2.6/xfs_super.c b/fs/xfs/linux-2.6/xfs_super.c index 9731898083ae..1ba5c451da36 100644 --- a/fs/xfs/linux-2.6/xfs_super.c +++ b/fs/xfs/linux-2.6/xfs_super.c | |||
@@ -173,6 +173,15 @@ xfs_parseargs( | |||
173 | __uint8_t iosizelog = 0; | 173 | __uint8_t iosizelog = 0; |
174 | 174 | ||
175 | /* | 175 | /* |
176 | * set up the mount name first so all the errors will refer to the | ||
177 | * correct device. | ||
178 | */ | ||
179 | mp->m_fsname = kstrndup(sb->s_id, MAXNAMELEN, GFP_KERNEL); | ||
180 | if (!mp->m_fsname) | ||
181 | return ENOMEM; | ||
182 | mp->m_fsname_len = strlen(mp->m_fsname) + 1; | ||
183 | |||
184 | /* | ||
176 | * Copy binary VFS mount flags we are interested in. | 185 | * Copy binary VFS mount flags we are interested in. |
177 | */ | 186 | */ |
178 | if (sb->s_flags & MS_RDONLY) | 187 | if (sb->s_flags & MS_RDONLY) |
@@ -189,6 +198,7 @@ xfs_parseargs( | |||
189 | mp->m_flags |= XFS_MOUNT_BARRIER; | 198 | mp->m_flags |= XFS_MOUNT_BARRIER; |
190 | mp->m_flags |= XFS_MOUNT_COMPAT_IOSIZE; | 199 | mp->m_flags |= XFS_MOUNT_COMPAT_IOSIZE; |
191 | mp->m_flags |= XFS_MOUNT_SMALL_INUMS; | 200 | mp->m_flags |= XFS_MOUNT_SMALL_INUMS; |
201 | mp->m_flags |= XFS_MOUNT_DELAYLOG; | ||
192 | 202 | ||
193 | /* | 203 | /* |
194 | * These can be overridden by the mount option parsing. | 204 | * These can be overridden by the mount option parsing. |
@@ -207,24 +217,21 @@ xfs_parseargs( | |||
207 | 217 | ||
208 | if (!strcmp(this_char, MNTOPT_LOGBUFS)) { | 218 | if (!strcmp(this_char, MNTOPT_LOGBUFS)) { |
209 | if (!value || !*value) { | 219 | if (!value || !*value) { |
210 | cmn_err(CE_WARN, | 220 | xfs_warn(mp, "%s option requires an argument", |
211 | "XFS: %s option requires an argument", | ||
212 | this_char); | 221 | this_char); |
213 | return EINVAL; | 222 | return EINVAL; |
214 | } | 223 | } |
215 | mp->m_logbufs = simple_strtoul(value, &eov, 10); | 224 | mp->m_logbufs = simple_strtoul(value, &eov, 10); |
216 | } else if (!strcmp(this_char, MNTOPT_LOGBSIZE)) { | 225 | } else if (!strcmp(this_char, MNTOPT_LOGBSIZE)) { |
217 | if (!value || !*value) { | 226 | if (!value || !*value) { |
218 | cmn_err(CE_WARN, | 227 | xfs_warn(mp, "%s option requires an argument", |
219 | "XFS: %s option requires an argument", | ||
220 | this_char); | 228 | this_char); |
221 | return EINVAL; | 229 | return EINVAL; |
222 | } | 230 | } |
223 | mp->m_logbsize = suffix_strtoul(value, &eov, 10); | 231 | mp->m_logbsize = suffix_strtoul(value, &eov, 10); |
224 | } else if (!strcmp(this_char, MNTOPT_LOGDEV)) { | 232 | } else if (!strcmp(this_char, MNTOPT_LOGDEV)) { |
225 | if (!value || !*value) { | 233 | if (!value || !*value) { |
226 | cmn_err(CE_WARN, | 234 | xfs_warn(mp, "%s option requires an argument", |
227 | "XFS: %s option requires an argument", | ||
228 | this_char); | 235 | this_char); |
229 | return EINVAL; | 236 | return EINVAL; |
230 | } | 237 | } |
@@ -232,14 +239,12 @@ xfs_parseargs( | |||
232 | if (!mp->m_logname) | 239 | if (!mp->m_logname) |
233 | return ENOMEM; | 240 | return ENOMEM; |
234 | } else if (!strcmp(this_char, MNTOPT_MTPT)) { | 241 | } else if (!strcmp(this_char, MNTOPT_MTPT)) { |
235 | cmn_err(CE_WARN, | 242 | xfs_warn(mp, "%s option not allowed on this system", |
236 | "XFS: %s option not allowed on this system", | ||
237 | this_char); | 243 | this_char); |
238 | return EINVAL; | 244 | return EINVAL; |
239 | } else if (!strcmp(this_char, MNTOPT_RTDEV)) { | 245 | } else if (!strcmp(this_char, MNTOPT_RTDEV)) { |
240 | if (!value || !*value) { | 246 | if (!value || !*value) { |
241 | cmn_err(CE_WARN, | 247 | xfs_warn(mp, "%s option requires an argument", |
242 | "XFS: %s option requires an argument", | ||
243 | this_char); | 248 | this_char); |
244 | return EINVAL; | 249 | return EINVAL; |
245 | } | 250 | } |
@@ -248,8 +253,7 @@ xfs_parseargs( | |||
248 | return ENOMEM; | 253 | return ENOMEM; |
249 | } else if (!strcmp(this_char, MNTOPT_BIOSIZE)) { | 254 | } else if (!strcmp(this_char, MNTOPT_BIOSIZE)) { |
250 | if (!value || !*value) { | 255 | if (!value || !*value) { |
251 | cmn_err(CE_WARN, | 256 | xfs_warn(mp, "%s option requires an argument", |
252 | "XFS: %s option requires an argument", | ||
253 | this_char); | 257 | this_char); |
254 | return EINVAL; | 258 | return EINVAL; |
255 | } | 259 | } |
@@ -257,8 +261,7 @@ xfs_parseargs( | |||
257 | iosizelog = ffs(iosize) - 1; | 261 | iosizelog = ffs(iosize) - 1; |
258 | } else if (!strcmp(this_char, MNTOPT_ALLOCSIZE)) { | 262 | } else if (!strcmp(this_char, MNTOPT_ALLOCSIZE)) { |
259 | if (!value || !*value) { | 263 | if (!value || !*value) { |
260 | cmn_err(CE_WARN, | 264 | xfs_warn(mp, "%s option requires an argument", |
261 | "XFS: %s option requires an argument", | ||
262 | this_char); | 265 | this_char); |
263 | return EINVAL; | 266 | return EINVAL; |
264 | } | 267 | } |
@@ -280,16 +283,14 @@ xfs_parseargs( | |||
280 | mp->m_flags |= XFS_MOUNT_SWALLOC; | 283 | mp->m_flags |= XFS_MOUNT_SWALLOC; |
281 | } else if (!strcmp(this_char, MNTOPT_SUNIT)) { | 284 | } else if (!strcmp(this_char, MNTOPT_SUNIT)) { |
282 | if (!value || !*value) { | 285 | if (!value || !*value) { |
283 | cmn_err(CE_WARN, | 286 | xfs_warn(mp, "%s option requires an argument", |
284 | "XFS: %s option requires an argument", | ||
285 | this_char); | 287 | this_char); |
286 | return EINVAL; | 288 | return EINVAL; |
287 | } | 289 | } |
288 | dsunit = simple_strtoul(value, &eov, 10); | 290 | dsunit = simple_strtoul(value, &eov, 10); |
289 | } else if (!strcmp(this_char, MNTOPT_SWIDTH)) { | 291 | } else if (!strcmp(this_char, MNTOPT_SWIDTH)) { |
290 | if (!value || !*value) { | 292 | if (!value || !*value) { |
291 | cmn_err(CE_WARN, | 293 | xfs_warn(mp, "%s option requires an argument", |
292 | "XFS: %s option requires an argument", | ||
293 | this_char); | 294 | this_char); |
294 | return EINVAL; | 295 | return EINVAL; |
295 | } | 296 | } |
@@ -297,8 +298,7 @@ xfs_parseargs( | |||
297 | } else if (!strcmp(this_char, MNTOPT_64BITINODE)) { | 298 | } else if (!strcmp(this_char, MNTOPT_64BITINODE)) { |
298 | mp->m_flags &= ~XFS_MOUNT_SMALL_INUMS; | 299 | mp->m_flags &= ~XFS_MOUNT_SMALL_INUMS; |
299 | #if !XFS_BIG_INUMS | 300 | #if !XFS_BIG_INUMS |
300 | cmn_err(CE_WARN, | 301 | xfs_warn(mp, "%s option not allowed on this system", |
301 | "XFS: %s option not allowed on this system", | ||
302 | this_char); | 302 | this_char); |
303 | return EINVAL; | 303 | return EINVAL; |
304 | #endif | 304 | #endif |
@@ -356,20 +356,19 @@ xfs_parseargs( | |||
356 | } else if (!strcmp(this_char, MNTOPT_NODELAYLOG)) { | 356 | } else if (!strcmp(this_char, MNTOPT_NODELAYLOG)) { |
357 | mp->m_flags &= ~XFS_MOUNT_DELAYLOG; | 357 | mp->m_flags &= ~XFS_MOUNT_DELAYLOG; |
358 | } else if (!strcmp(this_char, "ihashsize")) { | 358 | } else if (!strcmp(this_char, "ihashsize")) { |
359 | cmn_err(CE_WARN, | 359 | xfs_warn(mp, |
360 | "XFS: ihashsize no longer used, option is deprecated."); | 360 | "ihashsize no longer used, option is deprecated."); |
361 | } else if (!strcmp(this_char, "osyncisdsync")) { | 361 | } else if (!strcmp(this_char, "osyncisdsync")) { |
362 | cmn_err(CE_WARN, | 362 | xfs_warn(mp, |
363 | "XFS: osyncisdsync has no effect, option is deprecated."); | 363 | "osyncisdsync has no effect, option is deprecated."); |
364 | } else if (!strcmp(this_char, "osyncisosync")) { | 364 | } else if (!strcmp(this_char, "osyncisosync")) { |
365 | cmn_err(CE_WARN, | 365 | xfs_warn(mp, |
366 | "XFS: osyncisosync has no effect, option is deprecated."); | 366 | "osyncisosync has no effect, option is deprecated."); |
367 | } else if (!strcmp(this_char, "irixsgid")) { | 367 | } else if (!strcmp(this_char, "irixsgid")) { |
368 | cmn_err(CE_WARN, | 368 | xfs_warn(mp, |
369 | "XFS: irixsgid is now a sysctl(2) variable, option is deprecated."); | 369 | "irixsgid is now a sysctl(2) variable, option is deprecated."); |
370 | } else { | 370 | } else { |
371 | cmn_err(CE_WARN, | 371 | xfs_warn(mp, "unknown mount option [%s].", this_char); |
372 | "XFS: unknown mount option [%s].", this_char); | ||
373 | return EINVAL; | 372 | return EINVAL; |
374 | } | 373 | } |
375 | } | 374 | } |
@@ -379,40 +378,37 @@ xfs_parseargs( | |||
379 | */ | 378 | */ |
380 | if ((mp->m_flags & XFS_MOUNT_NORECOVERY) && | 379 | if ((mp->m_flags & XFS_MOUNT_NORECOVERY) && |
381 | !(mp->m_flags & XFS_MOUNT_RDONLY)) { | 380 | !(mp->m_flags & XFS_MOUNT_RDONLY)) { |
382 | cmn_err(CE_WARN, "XFS: no-recovery mounts must be read-only."); | 381 | xfs_warn(mp, "no-recovery mounts must be read-only."); |
383 | return EINVAL; | 382 | return EINVAL; |
384 | } | 383 | } |
385 | 384 | ||
386 | if ((mp->m_flags & XFS_MOUNT_NOALIGN) && (dsunit || dswidth)) { | 385 | if ((mp->m_flags & XFS_MOUNT_NOALIGN) && (dsunit || dswidth)) { |
387 | cmn_err(CE_WARN, | 386 | xfs_warn(mp, |
388 | "XFS: sunit and swidth options incompatible with the noalign option"); | 387 | "sunit and swidth options incompatible with the noalign option"); |
389 | return EINVAL; | 388 | return EINVAL; |
390 | } | 389 | } |
391 | 390 | ||
392 | #ifndef CONFIG_XFS_QUOTA | 391 | #ifndef CONFIG_XFS_QUOTA |
393 | if (XFS_IS_QUOTA_RUNNING(mp)) { | 392 | if (XFS_IS_QUOTA_RUNNING(mp)) { |
394 | cmn_err(CE_WARN, | 393 | xfs_warn(mp, "quota support not available in this kernel."); |
395 | "XFS: quota support not available in this kernel."); | ||
396 | return EINVAL; | 394 | return EINVAL; |
397 | } | 395 | } |
398 | #endif | 396 | #endif |
399 | 397 | ||
400 | if ((mp->m_qflags & (XFS_GQUOTA_ACCT | XFS_GQUOTA_ACTIVE)) && | 398 | if ((mp->m_qflags & (XFS_GQUOTA_ACCT | XFS_GQUOTA_ACTIVE)) && |
401 | (mp->m_qflags & (XFS_PQUOTA_ACCT | XFS_PQUOTA_ACTIVE))) { | 399 | (mp->m_qflags & (XFS_PQUOTA_ACCT | XFS_PQUOTA_ACTIVE))) { |
402 | cmn_err(CE_WARN, | 400 | xfs_warn(mp, "cannot mount with both project and group quota"); |
403 | "XFS: cannot mount with both project and group quota"); | ||
404 | return EINVAL; | 401 | return EINVAL; |
405 | } | 402 | } |
406 | 403 | ||
407 | if ((dsunit && !dswidth) || (!dsunit && dswidth)) { | 404 | if ((dsunit && !dswidth) || (!dsunit && dswidth)) { |
408 | cmn_err(CE_WARN, | 405 | xfs_warn(mp, "sunit and swidth must be specified together"); |
409 | "XFS: sunit and swidth must be specified together"); | ||
410 | return EINVAL; | 406 | return EINVAL; |
411 | } | 407 | } |
412 | 408 | ||
413 | if (dsunit && (dswidth % dsunit != 0)) { | 409 | if (dsunit && (dswidth % dsunit != 0)) { |
414 | cmn_err(CE_WARN, | 410 | xfs_warn(mp, |
415 | "XFS: stripe width (%d) must be a multiple of the stripe unit (%d)", | 411 | "stripe width (%d) must be a multiple of the stripe unit (%d)", |
416 | dswidth, dsunit); | 412 | dswidth, dsunit); |
417 | return EINVAL; | 413 | return EINVAL; |
418 | } | 414 | } |
@@ -438,8 +434,7 @@ done: | |||
438 | mp->m_logbufs != 0 && | 434 | mp->m_logbufs != 0 && |
439 | (mp->m_logbufs < XLOG_MIN_ICLOGS || | 435 | (mp->m_logbufs < XLOG_MIN_ICLOGS || |
440 | mp->m_logbufs > XLOG_MAX_ICLOGS)) { | 436 | mp->m_logbufs > XLOG_MAX_ICLOGS)) { |
441 | cmn_err(CE_WARN, | 437 | xfs_warn(mp, "invalid logbufs value: %d [not %d-%d]", |
442 | "XFS: invalid logbufs value: %d [not %d-%d]", | ||
443 | mp->m_logbufs, XLOG_MIN_ICLOGS, XLOG_MAX_ICLOGS); | 438 | mp->m_logbufs, XLOG_MIN_ICLOGS, XLOG_MAX_ICLOGS); |
444 | return XFS_ERROR(EINVAL); | 439 | return XFS_ERROR(EINVAL); |
445 | } | 440 | } |
@@ -448,22 +443,16 @@ done: | |||
448 | (mp->m_logbsize < XLOG_MIN_RECORD_BSIZE || | 443 | (mp->m_logbsize < XLOG_MIN_RECORD_BSIZE || |
449 | mp->m_logbsize > XLOG_MAX_RECORD_BSIZE || | 444 | mp->m_logbsize > XLOG_MAX_RECORD_BSIZE || |
450 | !is_power_of_2(mp->m_logbsize))) { | 445 | !is_power_of_2(mp->m_logbsize))) { |
451 | cmn_err(CE_WARN, | 446 | xfs_warn(mp, |
452 | "XFS: invalid logbufsize: %d [not 16k,32k,64k,128k or 256k]", | 447 | "invalid logbufsize: %d [not 16k,32k,64k,128k or 256k]", |
453 | mp->m_logbsize); | 448 | mp->m_logbsize); |
454 | return XFS_ERROR(EINVAL); | 449 | return XFS_ERROR(EINVAL); |
455 | } | 450 | } |
456 | 451 | ||
457 | mp->m_fsname = kstrndup(sb->s_id, MAXNAMELEN, GFP_KERNEL); | ||
458 | if (!mp->m_fsname) | ||
459 | return ENOMEM; | ||
460 | mp->m_fsname_len = strlen(mp->m_fsname) + 1; | ||
461 | |||
462 | if (iosizelog) { | 452 | if (iosizelog) { |
463 | if (iosizelog > XFS_MAX_IO_LOG || | 453 | if (iosizelog > XFS_MAX_IO_LOG || |
464 | iosizelog < XFS_MIN_IO_LOG) { | 454 | iosizelog < XFS_MIN_IO_LOG) { |
465 | cmn_err(CE_WARN, | 455 | xfs_warn(mp, "invalid log iosize: %d [not %d-%d]", |
466 | "XFS: invalid log iosize: %d [not %d-%d]", | ||
467 | iosizelog, XFS_MIN_IO_LOG, | 456 | iosizelog, XFS_MIN_IO_LOG, |
468 | XFS_MAX_IO_LOG); | 457 | XFS_MAX_IO_LOG); |
469 | return XFS_ERROR(EINVAL); | 458 | return XFS_ERROR(EINVAL); |
@@ -610,7 +599,7 @@ xfs_blkdev_get( | |||
610 | mp); | 599 | mp); |
611 | if (IS_ERR(*bdevp)) { | 600 | if (IS_ERR(*bdevp)) { |
612 | error = PTR_ERR(*bdevp); | 601 | error = PTR_ERR(*bdevp); |
613 | printk("XFS: Invalid device [%s], error=%d\n", name, error); | 602 | xfs_warn(mp, "Invalid device [%s], error=%d\n", name, error); |
614 | } | 603 | } |
615 | 604 | ||
616 | return -error; | 605 | return -error; |
@@ -664,23 +653,23 @@ xfs_mountfs_check_barriers(xfs_mount_t *mp) | |||
664 | int error; | 653 | int error; |
665 | 654 | ||
666 | if (mp->m_logdev_targp != mp->m_ddev_targp) { | 655 | if (mp->m_logdev_targp != mp->m_ddev_targp) { |
667 | xfs_fs_cmn_err(CE_NOTE, mp, | 656 | xfs_notice(mp, |
668 | "Disabling barriers, not supported with external log device"); | 657 | "Disabling barriers, not supported with external log device"); |
669 | mp->m_flags &= ~XFS_MOUNT_BARRIER; | 658 | mp->m_flags &= ~XFS_MOUNT_BARRIER; |
670 | return; | 659 | return; |
671 | } | 660 | } |
672 | 661 | ||
673 | if (xfs_readonly_buftarg(mp->m_ddev_targp)) { | 662 | if (xfs_readonly_buftarg(mp->m_ddev_targp)) { |
674 | xfs_fs_cmn_err(CE_NOTE, mp, | 663 | xfs_notice(mp, |
675 | "Disabling barriers, underlying device is readonly"); | 664 | "Disabling barriers, underlying device is readonly"); |
676 | mp->m_flags &= ~XFS_MOUNT_BARRIER; | 665 | mp->m_flags &= ~XFS_MOUNT_BARRIER; |
677 | return; | 666 | return; |
678 | } | 667 | } |
679 | 668 | ||
680 | error = xfs_barrier_test(mp); | 669 | error = xfs_barrier_test(mp); |
681 | if (error) { | 670 | if (error) { |
682 | xfs_fs_cmn_err(CE_NOTE, mp, | 671 | xfs_notice(mp, |
683 | "Disabling barriers, trial barrier write failed"); | 672 | "Disabling barriers, trial barrier write failed"); |
684 | mp->m_flags &= ~XFS_MOUNT_BARRIER; | 673 | mp->m_flags &= ~XFS_MOUNT_BARRIER; |
685 | return; | 674 | return; |
686 | } | 675 | } |
@@ -743,8 +732,8 @@ xfs_open_devices( | |||
743 | goto out_close_logdev; | 732 | goto out_close_logdev; |
744 | 733 | ||
745 | if (rtdev == ddev || rtdev == logdev) { | 734 | if (rtdev == ddev || rtdev == logdev) { |
746 | cmn_err(CE_WARN, | 735 | xfs_warn(mp, |
747 | "XFS: Cannot mount filesystem with identical rtdev and ddev/logdev."); | 736 | "Cannot mount filesystem with identical rtdev and ddev/logdev."); |
748 | error = EINVAL; | 737 | error = EINVAL; |
749 | goto out_close_rtdev; | 738 | goto out_close_rtdev; |
750 | } | 739 | } |
@@ -1089,7 +1078,7 @@ xfs_fs_write_inode( | |||
1089 | error = 0; | 1078 | error = 0; |
1090 | goto out_unlock; | 1079 | goto out_unlock; |
1091 | } | 1080 | } |
1092 | error = xfs_iflush(ip, 0); | 1081 | error = xfs_iflush(ip, SYNC_TRYLOCK); |
1093 | } | 1082 | } |
1094 | 1083 | ||
1095 | out_unlock: | 1084 | out_unlock: |
@@ -1345,8 +1334,8 @@ xfs_fs_remount( | |||
1345 | * options that we can't actually change. | 1334 | * options that we can't actually change. |
1346 | */ | 1335 | */ |
1347 | #if 0 | 1336 | #if 0 |
1348 | printk(KERN_INFO | 1337 | xfs_info(mp, |
1349 | "XFS: mount option \"%s\" not supported for remount\n", p); | 1338 | "mount option \"%s\" not supported for remount\n", p); |
1350 | return -EINVAL; | 1339 | return -EINVAL; |
1351 | #else | 1340 | #else |
1352 | break; | 1341 | break; |
@@ -1367,8 +1356,7 @@ xfs_fs_remount( | |||
1367 | if (mp->m_update_flags) { | 1356 | if (mp->m_update_flags) { |
1368 | error = xfs_mount_log_sb(mp, mp->m_update_flags); | 1357 | error = xfs_mount_log_sb(mp, mp->m_update_flags); |
1369 | if (error) { | 1358 | if (error) { |
1370 | cmn_err(CE_WARN, | 1359 | xfs_warn(mp, "failed to write sb changes"); |
1371 | "XFS: failed to write sb changes"); | ||
1372 | return error; | 1360 | return error; |
1373 | } | 1361 | } |
1374 | mp->m_update_flags = 0; | 1362 | mp->m_update_flags = 0; |
@@ -1452,15 +1440,15 @@ xfs_finish_flags( | |||
1452 | mp->m_logbsize = mp->m_sb.sb_logsunit; | 1440 | mp->m_logbsize = mp->m_sb.sb_logsunit; |
1453 | } else if (mp->m_logbsize > 0 && | 1441 | } else if (mp->m_logbsize > 0 && |
1454 | mp->m_logbsize < mp->m_sb.sb_logsunit) { | 1442 | mp->m_logbsize < mp->m_sb.sb_logsunit) { |
1455 | cmn_err(CE_WARN, | 1443 | xfs_warn(mp, |
1456 | "XFS: logbuf size must be greater than or equal to log stripe size"); | 1444 | "logbuf size must be greater than or equal to log stripe size"); |
1457 | return XFS_ERROR(EINVAL); | 1445 | return XFS_ERROR(EINVAL); |
1458 | } | 1446 | } |
1459 | } else { | 1447 | } else { |
1460 | /* Fail a mount if the logbuf is larger than 32K */ | 1448 | /* Fail a mount if the logbuf is larger than 32K */ |
1461 | if (mp->m_logbsize > XLOG_BIG_RECORD_BSIZE) { | 1449 | if (mp->m_logbsize > XLOG_BIG_RECORD_BSIZE) { |
1462 | cmn_err(CE_WARN, | 1450 | xfs_warn(mp, |
1463 | "XFS: logbuf size for version 1 logs must be 16K or 32K"); | 1451 | "logbuf size for version 1 logs must be 16K or 32K"); |
1464 | return XFS_ERROR(EINVAL); | 1452 | return XFS_ERROR(EINVAL); |
1465 | } | 1453 | } |
1466 | } | 1454 | } |
@@ -1477,8 +1465,8 @@ xfs_finish_flags( | |||
1477 | * prohibit r/w mounts of read-only filesystems | 1465 | * prohibit r/w mounts of read-only filesystems |
1478 | */ | 1466 | */ |
1479 | if ((mp->m_sb.sb_flags & XFS_SBF_READONLY) && !ronly) { | 1467 | if ((mp->m_sb.sb_flags & XFS_SBF_READONLY) && !ronly) { |
1480 | cmn_err(CE_WARN, | 1468 | xfs_warn(mp, |
1481 | "XFS: cannot mount a read-only filesystem as read-write"); | 1469 | "cannot mount a read-only filesystem as read-write"); |
1482 | return XFS_ERROR(EROFS); | 1470 | return XFS_ERROR(EROFS); |
1483 | } | 1471 | } |
1484 | 1472 | ||
@@ -1551,10 +1539,14 @@ xfs_fs_fill_super( | |||
1551 | if (error) | 1539 | if (error) |
1552 | goto out_free_sb; | 1540 | goto out_free_sb; |
1553 | 1541 | ||
1554 | error = xfs_mountfs(mp); | 1542 | /* |
1555 | if (error) | 1543 | * we must configure the block size in the superblock before we run the |
1556 | goto out_filestream_unmount; | 1544 | * full mount process as the mount process can lookup and cache inodes. |
1557 | 1545 | * For the same reason we must also initialise the syncd and register | |
1546 | * the inode cache shrinker so that inodes can be reclaimed during | ||
1547 | * operations like a quotacheck that iterate all inodes in the | ||
1548 | * filesystem. | ||
1549 | */ | ||
1558 | sb->s_magic = XFS_SB_MAGIC; | 1550 | sb->s_magic = XFS_SB_MAGIC; |
1559 | sb->s_blocksize = mp->m_sb.sb_blocksize; | 1551 | sb->s_blocksize = mp->m_sb.sb_blocksize; |
1560 | sb->s_blocksize_bits = ffs(sb->s_blocksize) - 1; | 1552 | sb->s_blocksize_bits = ffs(sb->s_blocksize) - 1; |
@@ -1562,6 +1554,16 @@ xfs_fs_fill_super( | |||
1562 | sb->s_time_gran = 1; | 1554 | sb->s_time_gran = 1; |
1563 | set_posix_acl_flag(sb); | 1555 | set_posix_acl_flag(sb); |
1564 | 1556 | ||
1557 | error = xfs_syncd_init(mp); | ||
1558 | if (error) | ||
1559 | goto out_filestream_unmount; | ||
1560 | |||
1561 | xfs_inode_shrinker_register(mp); | ||
1562 | |||
1563 | error = xfs_mountfs(mp); | ||
1564 | if (error) | ||
1565 | goto out_syncd_stop; | ||
1566 | |||
1565 | root = igrab(VFS_I(mp->m_rootip)); | 1567 | root = igrab(VFS_I(mp->m_rootip)); |
1566 | if (!root) { | 1568 | if (!root) { |
1567 | error = ENOENT; | 1569 | error = ENOENT; |
@@ -1577,14 +1579,11 @@ xfs_fs_fill_super( | |||
1577 | goto fail_vnrele; | 1579 | goto fail_vnrele; |
1578 | } | 1580 | } |
1579 | 1581 | ||
1580 | error = xfs_syncd_init(mp); | ||
1581 | if (error) | ||
1582 | goto fail_vnrele; | ||
1583 | |||
1584 | xfs_inode_shrinker_register(mp); | ||
1585 | |||
1586 | return 0; | 1582 | return 0; |
1587 | 1583 | ||
1584 | out_syncd_stop: | ||
1585 | xfs_inode_shrinker_unregister(mp); | ||
1586 | xfs_syncd_stop(mp); | ||
1588 | out_filestream_unmount: | 1587 | out_filestream_unmount: |
1589 | xfs_filestream_unmount(mp); | 1588 | xfs_filestream_unmount(mp); |
1590 | out_free_sb: | 1589 | out_free_sb: |
@@ -1608,6 +1607,9 @@ xfs_fs_fill_super( | |||
1608 | } | 1607 | } |
1609 | 1608 | ||
1610 | fail_unmount: | 1609 | fail_unmount: |
1610 | xfs_inode_shrinker_unregister(mp); | ||
1611 | xfs_syncd_stop(mp); | ||
1612 | |||
1611 | /* | 1613 | /* |
1612 | * Blow away any referenced inode in the filestreams cache. | 1614 | * Blow away any referenced inode in the filestreams cache. |
1613 | * This can and will cause log traffic as inodes go inactive | 1615 | * This can and will cause log traffic as inodes go inactive |
diff --git a/fs/xfs/linux-2.6/xfs_sync.c b/fs/xfs/linux-2.6/xfs_sync.c index e22f0057d21f..594cd822d84d 100644 --- a/fs/xfs/linux-2.6/xfs_sync.c +++ b/fs/xfs/linux-2.6/xfs_sync.c | |||
@@ -425,8 +425,7 @@ xfs_quiesce_attr( | |||
425 | /* Push the superblock and write an unmount record */ | 425 | /* Push the superblock and write an unmount record */ |
426 | error = xfs_log_sbcount(mp, 1); | 426 | error = xfs_log_sbcount(mp, 1); |
427 | if (error) | 427 | if (error) |
428 | xfs_fs_cmn_err(CE_WARN, mp, | 428 | xfs_warn(mp, "xfs_attr_quiesce: failed to log sb changes. " |
429 | "xfs_attr_quiesce: failed to log sb changes. " | ||
430 | "Frozen image may not be consistent."); | 429 | "Frozen image may not be consistent."); |
431 | xfs_log_unmount_write(mp); | 430 | xfs_log_unmount_write(mp); |
432 | xfs_unmountfs_writesb(mp); | 431 | xfs_unmountfs_writesb(mp); |
@@ -762,8 +761,10 @@ xfs_reclaim_inode( | |||
762 | struct xfs_perag *pag, | 761 | struct xfs_perag *pag, |
763 | int sync_mode) | 762 | int sync_mode) |
764 | { | 763 | { |
765 | int error = 0; | 764 | int error; |
766 | 765 | ||
766 | restart: | ||
767 | error = 0; | ||
767 | xfs_ilock(ip, XFS_ILOCK_EXCL); | 768 | xfs_ilock(ip, XFS_ILOCK_EXCL); |
768 | if (!xfs_iflock_nowait(ip)) { | 769 | if (!xfs_iflock_nowait(ip)) { |
769 | if (!(sync_mode & SYNC_WAIT)) | 770 | if (!(sync_mode & SYNC_WAIT)) |
@@ -789,9 +790,31 @@ xfs_reclaim_inode( | |||
789 | if (xfs_inode_clean(ip)) | 790 | if (xfs_inode_clean(ip)) |
790 | goto reclaim; | 791 | goto reclaim; |
791 | 792 | ||
792 | /* Now we have an inode that needs flushing */ | 793 | /* |
793 | error = xfs_iflush(ip, sync_mode); | 794 | * Now we have an inode that needs flushing. |
795 | * | ||
796 | * We do a nonblocking flush here even if we are doing a SYNC_WAIT | ||
797 | * reclaim as we can deadlock with inode cluster removal. | ||
798 | * xfs_ifree_cluster() can lock the inode buffer before it locks the | ||
799 | * ip->i_lock, and we are doing the exact opposite here. As a result, | ||
800 | * doing a blocking xfs_itobp() to get the cluster buffer will result | ||
801 | * in an ABBA deadlock with xfs_ifree_cluster(). | ||
802 | * | ||
803 | * As xfs_ifree_cluser() must gather all inodes that are active in the | ||
804 | * cache to mark them stale, if we hit this case we don't actually want | ||
805 | * to do IO here - we want the inode marked stale so we can simply | ||
806 | * reclaim it. Hence if we get an EAGAIN error on a SYNC_WAIT flush, | ||
807 | * just unlock the inode, back off and try again. Hopefully the next | ||
808 | * pass through will see the stale flag set on the inode. | ||
809 | */ | ||
810 | error = xfs_iflush(ip, SYNC_TRYLOCK | sync_mode); | ||
794 | if (sync_mode & SYNC_WAIT) { | 811 | if (sync_mode & SYNC_WAIT) { |
812 | if (error == EAGAIN) { | ||
813 | xfs_iunlock(ip, XFS_ILOCK_EXCL); | ||
814 | /* backoff longer than in xfs_ifree_cluster */ | ||
815 | delay(2); | ||
816 | goto restart; | ||
817 | } | ||
795 | xfs_iflock(ip); | 818 | xfs_iflock(ip); |
796 | goto reclaim; | 819 | goto reclaim; |
797 | } | 820 | } |
@@ -806,7 +829,7 @@ xfs_reclaim_inode( | |||
806 | * pass on the error. | 829 | * pass on the error. |
807 | */ | 830 | */ |
808 | if (error && error != EAGAIN && !XFS_FORCED_SHUTDOWN(ip->i_mount)) { | 831 | if (error && error != EAGAIN && !XFS_FORCED_SHUTDOWN(ip->i_mount)) { |
809 | xfs_fs_cmn_err(CE_WARN, ip->i_mount, | 832 | xfs_warn(ip->i_mount, |
810 | "inode 0x%llx background reclaim flush failed with %d", | 833 | "inode 0x%llx background reclaim flush failed with %d", |
811 | (long long)ip->i_ino, error); | 834 | (long long)ip->i_ino, error); |
812 | } | 835 | } |
diff --git a/fs/xfs/linux-2.6/xfs_sysctl.c b/fs/xfs/linux-2.6/xfs_sysctl.c index ee3cee097e7e..ee2d2adaa438 100644 --- a/fs/xfs/linux-2.6/xfs_sysctl.c +++ b/fs/xfs/linux-2.6/xfs_sysctl.c | |||
@@ -37,7 +37,7 @@ xfs_stats_clear_proc_handler( | |||
37 | ret = proc_dointvec_minmax(ctl, write, buffer, lenp, ppos); | 37 | ret = proc_dointvec_minmax(ctl, write, buffer, lenp, ppos); |
38 | 38 | ||
39 | if (!ret && write && *valp) { | 39 | if (!ret && write && *valp) { |
40 | printk("XFS Clearing xfsstats\n"); | 40 | xfs_notice(NULL, "Clearing xfsstats"); |
41 | for_each_possible_cpu(c) { | 41 | for_each_possible_cpu(c) { |
42 | preempt_disable(); | 42 | preempt_disable(); |
43 | /* save vn_active, it's a universal truth! */ | 43 | /* save vn_active, it's a universal truth! */ |