aboutsummaryrefslogtreecommitdiffstats
path: root/fs/gfs2
diff options
context:
space:
mode:
Diffstat (limited to 'fs/gfs2')
-rw-r--r--fs/gfs2/acl.c23
-rw-r--r--fs/gfs2/acl.h2
-rw-r--r--fs/gfs2/aops.c132
-rw-r--r--fs/gfs2/bmap.c115
-rw-r--r--fs/gfs2/bmap.h2
-rw-r--r--fs/gfs2/dir.c23
-rw-r--r--fs/gfs2/file.c13
-rw-r--r--fs/gfs2/glock.c28
-rw-r--r--fs/gfs2/glops.c2
-rw-r--r--fs/gfs2/incore.h37
-rw-r--r--fs/gfs2/inode.c75
-rw-r--r--fs/gfs2/lock_dlm.c10
-rw-r--r--fs/gfs2/log.c102
-rw-r--r--fs/gfs2/lops.c85
-rw-r--r--fs/gfs2/lops.h5
-rw-r--r--fs/gfs2/main.c4
-rw-r--r--fs/gfs2/meta_io.c14
-rw-r--r--fs/gfs2/meta_io.h3
-rw-r--r--fs/gfs2/ops_fstype.c89
-rw-r--r--fs/gfs2/quota.c18
-rw-r--r--fs/gfs2/recovery.c16
-rw-r--r--fs/gfs2/recovery.h6
-rw-r--r--fs/gfs2/rgrp.c32
-rw-r--r--fs/gfs2/super.c37
-rw-r--r--fs/gfs2/sys.c7
-rw-r--r--fs/gfs2/trans.c29
-rw-r--r--fs/gfs2/util.c101
-rw-r--r--fs/gfs2/util.h31
28 files changed, 604 insertions, 437 deletions
diff --git a/fs/gfs2/acl.c b/fs/gfs2/acl.c
index ba9456685f47..3088e2a38e30 100644
--- a/fs/gfs2/acl.c
+++ b/fs/gfs2/acl.c
@@ -64,18 +64,6 @@ struct posix_acl *gfs2_get_acl(struct inode *inode, int type)
64 return acl; 64 return acl;
65} 65}
66 66
67static int gfs2_set_mode(struct inode *inode, umode_t mode)
68{
69 int error = 0;
70
71 if (mode != inode->i_mode) {
72 inode->i_mode = mode;
73 mark_inode_dirty(inode);
74 }
75
76 return error;
77}
78
79int gfs2_set_acl(struct inode *inode, struct posix_acl *acl, int type) 67int gfs2_set_acl(struct inode *inode, struct posix_acl *acl, int type)
80{ 68{
81 int error; 69 int error;
@@ -85,8 +73,8 @@ int gfs2_set_acl(struct inode *inode, struct posix_acl *acl, int type)
85 73
86 BUG_ON(name == NULL); 74 BUG_ON(name == NULL);
87 75
88 if (acl->a_count > GFS2_ACL_MAX_ENTRIES) 76 if (acl->a_count > GFS2_ACL_MAX_ENTRIES(GFS2_SB(inode)))
89 return -EINVAL; 77 return -E2BIG;
90 78
91 if (type == ACL_TYPE_ACCESS) { 79 if (type == ACL_TYPE_ACCESS) {
92 umode_t mode = inode->i_mode; 80 umode_t mode = inode->i_mode;
@@ -98,9 +86,10 @@ int gfs2_set_acl(struct inode *inode, struct posix_acl *acl, int type)
98 if (error == 0) 86 if (error == 0)
99 acl = NULL; 87 acl = NULL;
100 88
101 error = gfs2_set_mode(inode, mode); 89 if (mode != inode->i_mode) {
102 if (error) 90 inode->i_mode = mode;
103 return error; 91 mark_inode_dirty(inode);
92 }
104 } 93 }
105 94
106 if (acl) { 95 if (acl) {
diff --git a/fs/gfs2/acl.h b/fs/gfs2/acl.h
index 301260c999ba..2d65ec4cd4be 100644
--- a/fs/gfs2/acl.h
+++ b/fs/gfs2/acl.h
@@ -14,7 +14,7 @@
14 14
15#define GFS2_POSIX_ACL_ACCESS "posix_acl_access" 15#define GFS2_POSIX_ACL_ACCESS "posix_acl_access"
16#define GFS2_POSIX_ACL_DEFAULT "posix_acl_default" 16#define GFS2_POSIX_ACL_DEFAULT "posix_acl_default"
17#define GFS2_ACL_MAX_ENTRIES 25 17#define GFS2_ACL_MAX_ENTRIES(sdp) ((300 << (sdp)->sd_sb.sb_bsize_shift) >> 12)
18 18
19extern struct posix_acl *gfs2_get_acl(struct inode *inode, int type); 19extern struct posix_acl *gfs2_get_acl(struct inode *inode, int type);
20extern int gfs2_set_acl(struct inode *inode, struct posix_acl *acl, int type); 20extern int gfs2_set_acl(struct inode *inode, struct posix_acl *acl, int type);
diff --git a/fs/gfs2/aops.c b/fs/gfs2/aops.c
index 49436fa7cd4f..ce62dcac90b6 100644
--- a/fs/gfs2/aops.c
+++ b/fs/gfs2/aops.c
@@ -21,6 +21,7 @@
21#include <linux/gfs2_ondisk.h> 21#include <linux/gfs2_ondisk.h>
22#include <linux/backing-dev.h> 22#include <linux/backing-dev.h>
23#include <linux/aio.h> 23#include <linux/aio.h>
24#include <trace/events/writeback.h>
24 25
25#include "gfs2.h" 26#include "gfs2.h"
26#include "incore.h" 27#include "incore.h"
@@ -230,13 +231,11 @@ static int gfs2_writepages(struct address_space *mapping,
230static int gfs2_write_jdata_pagevec(struct address_space *mapping, 231static int gfs2_write_jdata_pagevec(struct address_space *mapping,
231 struct writeback_control *wbc, 232 struct writeback_control *wbc,
232 struct pagevec *pvec, 233 struct pagevec *pvec,
233 int nr_pages, pgoff_t end) 234 int nr_pages, pgoff_t end,
235 pgoff_t *done_index)
234{ 236{
235 struct inode *inode = mapping->host; 237 struct inode *inode = mapping->host;
236 struct gfs2_sbd *sdp = GFS2_SB(inode); 238 struct gfs2_sbd *sdp = GFS2_SB(inode);
237 loff_t i_size = i_size_read(inode);
238 pgoff_t end_index = i_size >> PAGE_CACHE_SHIFT;
239 unsigned offset = i_size & (PAGE_CACHE_SIZE-1);
240 unsigned nrblocks = nr_pages * (PAGE_CACHE_SIZE/inode->i_sb->s_blocksize); 239 unsigned nrblocks = nr_pages * (PAGE_CACHE_SIZE/inode->i_sb->s_blocksize);
241 int i; 240 int i;
242 int ret; 241 int ret;
@@ -248,40 +247,83 @@ static int gfs2_write_jdata_pagevec(struct address_space *mapping,
248 for(i = 0; i < nr_pages; i++) { 247 for(i = 0; i < nr_pages; i++) {
249 struct page *page = pvec->pages[i]; 248 struct page *page = pvec->pages[i];
250 249
250 /*
251 * At this point, the page may be truncated or
252 * invalidated (changing page->mapping to NULL), or
253 * even swizzled back from swapper_space to tmpfs file
254 * mapping. However, page->index will not change
255 * because we have a reference on the page.
256 */
257 if (page->index > end) {
258 /*
259 * can't be range_cyclic (1st pass) because
260 * end == -1 in that case.
261 */
262 ret = 1;
263 break;
264 }
265
266 *done_index = page->index;
267
251 lock_page(page); 268 lock_page(page);
252 269
253 if (unlikely(page->mapping != mapping)) { 270 if (unlikely(page->mapping != mapping)) {
271continue_unlock:
254 unlock_page(page); 272 unlock_page(page);
255 continue; 273 continue;
256 } 274 }
257 275
258 if (!wbc->range_cyclic && page->index > end) { 276 if (!PageDirty(page)) {
259 ret = 1; 277 /* someone wrote it for us */
260 unlock_page(page); 278 goto continue_unlock;
261 continue;
262 } 279 }
263 280
264 if (wbc->sync_mode != WB_SYNC_NONE) 281 if (PageWriteback(page)) {
265 wait_on_page_writeback(page); 282 if (wbc->sync_mode != WB_SYNC_NONE)
266 283 wait_on_page_writeback(page);
267 if (PageWriteback(page) || 284 else
268 !clear_page_dirty_for_io(page)) { 285 goto continue_unlock;
269 unlock_page(page);
270 continue;
271 } 286 }
272 287
273 /* Is the page fully outside i_size? (truncate in progress) */ 288 BUG_ON(PageWriteback(page));
274 if (page->index > end_index || (page->index == end_index && !offset)) { 289 if (!clear_page_dirty_for_io(page))
275 page->mapping->a_ops->invalidatepage(page, 0, 290 goto continue_unlock;
276 PAGE_CACHE_SIZE); 291
277 unlock_page(page); 292 trace_wbc_writepage(wbc, mapping->backing_dev_info);
278 continue;
279 }
280 293
281 ret = __gfs2_jdata_writepage(page, wbc); 294 ret = __gfs2_jdata_writepage(page, wbc);
295 if (unlikely(ret)) {
296 if (ret == AOP_WRITEPAGE_ACTIVATE) {
297 unlock_page(page);
298 ret = 0;
299 } else {
300
301 /*
302 * done_index is set past this page,
303 * so media errors will not choke
304 * background writeout for the entire
305 * file. This has consequences for
306 * range_cyclic semantics (ie. it may
307 * not be suitable for data integrity
308 * writeout).
309 */
310 *done_index = page->index + 1;
311 ret = 1;
312 break;
313 }
314 }
282 315
283 if (ret || (--(wbc->nr_to_write) <= 0)) 316 /*
317 * We stop writing back only if we are not doing
318 * integrity sync. In case of integrity sync we have to
319 * keep going until we have written all the pages
320 * we tagged for writeback prior to entering this loop.
321 */
322 if (--wbc->nr_to_write <= 0 && wbc->sync_mode == WB_SYNC_NONE) {
284 ret = 1; 323 ret = 1;
324 break;
325 }
326
285 } 327 }
286 gfs2_trans_end(sdp); 328 gfs2_trans_end(sdp);
287 return ret; 329 return ret;
@@ -306,51 +348,69 @@ static int gfs2_write_cache_jdata(struct address_space *mapping,
306 int done = 0; 348 int done = 0;
307 struct pagevec pvec; 349 struct pagevec pvec;
308 int nr_pages; 350 int nr_pages;
351 pgoff_t uninitialized_var(writeback_index);
309 pgoff_t index; 352 pgoff_t index;
310 pgoff_t end; 353 pgoff_t end;
311 int scanned = 0; 354 pgoff_t done_index;
355 int cycled;
312 int range_whole = 0; 356 int range_whole = 0;
357 int tag;
313 358
314 pagevec_init(&pvec, 0); 359 pagevec_init(&pvec, 0);
315 if (wbc->range_cyclic) { 360 if (wbc->range_cyclic) {
316 index = mapping->writeback_index; /* Start from prev offset */ 361 writeback_index = mapping->writeback_index; /* prev offset */
362 index = writeback_index;
363 if (index == 0)
364 cycled = 1;
365 else
366 cycled = 0;
317 end = -1; 367 end = -1;
318 } else { 368 } else {
319 index = wbc->range_start >> PAGE_CACHE_SHIFT; 369 index = wbc->range_start >> PAGE_CACHE_SHIFT;
320 end = wbc->range_end >> PAGE_CACHE_SHIFT; 370 end = wbc->range_end >> PAGE_CACHE_SHIFT;
321 if (wbc->range_start == 0 && wbc->range_end == LLONG_MAX) 371 if (wbc->range_start == 0 && wbc->range_end == LLONG_MAX)
322 range_whole = 1; 372 range_whole = 1;
323 scanned = 1; 373 cycled = 1; /* ignore range_cyclic tests */
324 } 374 }
375 if (wbc->sync_mode == WB_SYNC_ALL || wbc->tagged_writepages)
376 tag = PAGECACHE_TAG_TOWRITE;
377 else
378 tag = PAGECACHE_TAG_DIRTY;
325 379
326retry: 380retry:
327 while (!done && (index <= end) && 381 if (wbc->sync_mode == WB_SYNC_ALL || wbc->tagged_writepages)
328 (nr_pages = pagevec_lookup_tag(&pvec, mapping, &index, 382 tag_pages_for_writeback(mapping, index, end);
329 PAGECACHE_TAG_DIRTY, 383 done_index = index;
330 min(end - index, (pgoff_t)PAGEVEC_SIZE-1) + 1))) { 384 while (!done && (index <= end)) {
331 scanned = 1; 385 nr_pages = pagevec_lookup_tag(&pvec, mapping, &index, tag,
332 ret = gfs2_write_jdata_pagevec(mapping, wbc, &pvec, nr_pages, end); 386 min(end - index, (pgoff_t)PAGEVEC_SIZE-1) + 1);
387 if (nr_pages == 0)
388 break;
389
390 ret = gfs2_write_jdata_pagevec(mapping, wbc, &pvec, nr_pages, end, &done_index);
333 if (ret) 391 if (ret)
334 done = 1; 392 done = 1;
335 if (ret > 0) 393 if (ret > 0)
336 ret = 0; 394 ret = 0;
337
338 pagevec_release(&pvec); 395 pagevec_release(&pvec);
339 cond_resched(); 396 cond_resched();
340 } 397 }
341 398
342 if (!scanned && !done) { 399 if (!cycled && !done) {
343 /* 400 /*
401 * range_cyclic:
344 * We hit the last page and there is more work to be done: wrap 402 * We hit the last page and there is more work to be done: wrap
345 * back to the start of the file 403 * back to the start of the file
346 */ 404 */
347 scanned = 1; 405 cycled = 1;
348 index = 0; 406 index = 0;
407 end = writeback_index - 1;
349 goto retry; 408 goto retry;
350 } 409 }
351 410
352 if (wbc->range_cyclic || (range_whole && wbc->nr_to_write > 0)) 411 if (wbc->range_cyclic || (range_whole && wbc->nr_to_write > 0))
353 mapping->writeback_index = index; 412 mapping->writeback_index = done_index;
413
354 return ret; 414 return ret;
355} 415}
356 416
diff --git a/fs/gfs2/bmap.c b/fs/gfs2/bmap.c
index fe0500c0af7a..c62d4b9f51dc 100644
--- a/fs/gfs2/bmap.c
+++ b/fs/gfs2/bmap.c
@@ -1328,6 +1328,121 @@ int gfs2_file_dealloc(struct gfs2_inode *ip)
1328} 1328}
1329 1329
1330/** 1330/**
1331 * gfs2_free_journal_extents - Free cached journal bmap info
1332 * @jd: The journal
1333 *
1334 */
1335
1336void gfs2_free_journal_extents(struct gfs2_jdesc *jd)
1337{
1338 struct gfs2_journal_extent *jext;
1339
1340 while(!list_empty(&jd->extent_list)) {
1341 jext = list_entry(jd->extent_list.next, struct gfs2_journal_extent, list);
1342 list_del(&jext->list);
1343 kfree(jext);
1344 }
1345}
1346
1347/**
1348 * gfs2_add_jextent - Add or merge a new extent to extent cache
1349 * @jd: The journal descriptor
1350 * @lblock: The logical block at start of new extent
1351 * @pblock: The physical block at start of new extent
1352 * @blocks: Size of extent in fs blocks
1353 *
1354 * Returns: 0 on success or -ENOMEM
1355 */
1356
1357static int gfs2_add_jextent(struct gfs2_jdesc *jd, u64 lblock, u64 dblock, u64 blocks)
1358{
1359 struct gfs2_journal_extent *jext;
1360
1361 if (!list_empty(&jd->extent_list)) {
1362 jext = list_entry(jd->extent_list.prev, struct gfs2_journal_extent, list);
1363 if ((jext->dblock + jext->blocks) == dblock) {
1364 jext->blocks += blocks;
1365 return 0;
1366 }
1367 }
1368
1369 jext = kzalloc(sizeof(struct gfs2_journal_extent), GFP_NOFS);
1370 if (jext == NULL)
1371 return -ENOMEM;
1372 jext->dblock = dblock;
1373 jext->lblock = lblock;
1374 jext->blocks = blocks;
1375 list_add_tail(&jext->list, &jd->extent_list);
1376 jd->nr_extents++;
1377 return 0;
1378}
1379
1380/**
1381 * gfs2_map_journal_extents - Cache journal bmap info
1382 * @sdp: The super block
1383 * @jd: The journal to map
1384 *
1385 * Create a reusable "extent" mapping from all logical
1386 * blocks to all physical blocks for the given journal. This will save
1387 * us time when writing journal blocks. Most journals will have only one
1388 * extent that maps all their logical blocks. That's because gfs2.mkfs
1389 * arranges the journal blocks sequentially to maximize performance.
1390 * So the extent would map the first block for the entire file length.
1391 * However, gfs2_jadd can happen while file activity is happening, so
1392 * those journals may not be sequential. Less likely is the case where
1393 * the users created their own journals by mounting the metafs and
1394 * laying it out. But it's still possible. These journals might have
1395 * several extents.
1396 *
1397 * Returns: 0 on success, or error on failure
1398 */
1399
1400int gfs2_map_journal_extents(struct gfs2_sbd *sdp, struct gfs2_jdesc *jd)
1401{
1402 u64 lblock = 0;
1403 u64 lblock_stop;
1404 struct gfs2_inode *ip = GFS2_I(jd->jd_inode);
1405 struct buffer_head bh;
1406 unsigned int shift = sdp->sd_sb.sb_bsize_shift;
1407 u64 size;
1408 int rc;
1409
1410 lblock_stop = i_size_read(jd->jd_inode) >> shift;
1411 size = (lblock_stop - lblock) << shift;
1412 jd->nr_extents = 0;
1413 WARN_ON(!list_empty(&jd->extent_list));
1414
1415 do {
1416 bh.b_state = 0;
1417 bh.b_blocknr = 0;
1418 bh.b_size = size;
1419 rc = gfs2_block_map(jd->jd_inode, lblock, &bh, 0);
1420 if (rc || !buffer_mapped(&bh))
1421 goto fail;
1422 rc = gfs2_add_jextent(jd, lblock, bh.b_blocknr, bh.b_size >> shift);
1423 if (rc)
1424 goto fail;
1425 size -= bh.b_size;
1426 lblock += (bh.b_size >> ip->i_inode.i_blkbits);
1427 } while(size > 0);
1428
1429 fs_info(sdp, "journal %d mapped with %u extents\n", jd->jd_jid,
1430 jd->nr_extents);
1431 return 0;
1432
1433fail:
1434 fs_warn(sdp, "error %d mapping journal %u at offset %llu (extent %u)\n",
1435 rc, jd->jd_jid,
1436 (unsigned long long)(i_size_read(jd->jd_inode) - size),
1437 jd->nr_extents);
1438 fs_warn(sdp, "bmap=%d lblock=%llu block=%llu, state=0x%08lx, size=%llu\n",
1439 rc, (unsigned long long)lblock, (unsigned long long)bh.b_blocknr,
1440 bh.b_state, (unsigned long long)bh.b_size);
1441 gfs2_free_journal_extents(jd);
1442 return rc;
1443}
1444
1445/**
1331 * gfs2_write_alloc_required - figure out if a write will require an allocation 1446 * gfs2_write_alloc_required - figure out if a write will require an allocation
1332 * @ip: the file being written to 1447 * @ip: the file being written to
1333 * @offset: the offset to write to 1448 * @offset: the offset to write to
diff --git a/fs/gfs2/bmap.h b/fs/gfs2/bmap.h
index 42fea03e2bd9..81ded5e2aaa2 100644
--- a/fs/gfs2/bmap.h
+++ b/fs/gfs2/bmap.h
@@ -55,5 +55,7 @@ extern int gfs2_truncatei_resume(struct gfs2_inode *ip);
55extern int gfs2_file_dealloc(struct gfs2_inode *ip); 55extern int gfs2_file_dealloc(struct gfs2_inode *ip);
56extern int gfs2_write_alloc_required(struct gfs2_inode *ip, u64 offset, 56extern int gfs2_write_alloc_required(struct gfs2_inode *ip, u64 offset,
57 unsigned int len); 57 unsigned int len);
58extern int gfs2_map_journal_extents(struct gfs2_sbd *sdp, struct gfs2_jdesc *jd);
59extern void gfs2_free_journal_extents(struct gfs2_jdesc *jd);
58 60
59#endif /* __BMAP_DOT_H__ */ 61#endif /* __BMAP_DOT_H__ */
diff --git a/fs/gfs2/dir.c b/fs/gfs2/dir.c
index fa32655449c8..1a349f9a9685 100644
--- a/fs/gfs2/dir.c
+++ b/fs/gfs2/dir.c
@@ -53,6 +53,8 @@
53 * but never before the maximum hash table size has been reached. 53 * but never before the maximum hash table size has been reached.
54 */ 54 */
55 55
56#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
57
56#include <linux/slab.h> 58#include <linux/slab.h>
57#include <linux/spinlock.h> 59#include <linux/spinlock.h>
58#include <linux/buffer_head.h> 60#include <linux/buffer_head.h>
@@ -507,8 +509,8 @@ static int gfs2_check_dirent(struct gfs2_dirent *dent, unsigned int offset,
507 goto error; 509 goto error;
508 return 0; 510 return 0;
509error: 511error:
510 printk(KERN_WARNING "gfs2_check_dirent: %s (%s)\n", msg, 512 pr_warn("%s: %s (%s)\n",
511 first ? "first in block" : "not first in block"); 513 __func__, msg, first ? "first in block" : "not first in block");
512 return -EIO; 514 return -EIO;
513} 515}
514 516
@@ -531,8 +533,7 @@ static int gfs2_dirent_offset(const void *buf)
531 } 533 }
532 return offset; 534 return offset;
533wrong_type: 535wrong_type:
534 printk(KERN_WARNING "gfs2_scan_dirent: wrong block type %u\n", 536 pr_warn("%s: wrong block type %u\n", __func__, be32_to_cpu(h->mh_type));
535 be32_to_cpu(h->mh_type));
536 return -1; 537 return -1;
537} 538}
538 539
@@ -728,7 +729,7 @@ static int get_leaf(struct gfs2_inode *dip, u64 leaf_no,
728 729
729 error = gfs2_meta_read(dip->i_gl, leaf_no, DIO_WAIT, bhp); 730 error = gfs2_meta_read(dip->i_gl, leaf_no, DIO_WAIT, bhp);
730 if (!error && gfs2_metatype_check(GFS2_SB(&dip->i_inode), *bhp, GFS2_METATYPE_LF)) { 731 if (!error && gfs2_metatype_check(GFS2_SB(&dip->i_inode), *bhp, GFS2_METATYPE_LF)) {
731 /* printk(KERN_INFO "block num=%llu\n", leaf_no); */ 732 /* pr_info("block num=%llu\n", leaf_no); */
732 error = -EIO; 733 error = -EIO;
733 } 734 }
734 735
@@ -1006,7 +1007,8 @@ static int dir_split_leaf(struct inode *inode, const struct qstr *name)
1006 len = 1 << (dip->i_depth - be16_to_cpu(oleaf->lf_depth)); 1007 len = 1 << (dip->i_depth - be16_to_cpu(oleaf->lf_depth));
1007 half_len = len >> 1; 1008 half_len = len >> 1;
1008 if (!half_len) { 1009 if (!half_len) {
1009 printk(KERN_WARNING "i_depth %u lf_depth %u index %u\n", dip->i_depth, be16_to_cpu(oleaf->lf_depth), index); 1010 pr_warn("i_depth %u lf_depth %u index %u\n",
1011 dip->i_depth, be16_to_cpu(oleaf->lf_depth), index);
1010 gfs2_consist_inode(dip); 1012 gfs2_consist_inode(dip);
1011 error = -EIO; 1013 error = -EIO;
1012 goto fail_brelse; 1014 goto fail_brelse;
@@ -1684,6 +1686,14 @@ static int dir_new_leaf(struct inode *inode, const struct qstr *name)
1684 return 0; 1686 return 0;
1685} 1687}
1686 1688
1689static u16 gfs2_inode_ra_len(const struct gfs2_inode *ip)
1690{
1691 u64 where = ip->i_no_addr + 1;
1692 if (ip->i_eattr == where)
1693 return 1;
1694 return 0;
1695}
1696
1687/** 1697/**
1688 * gfs2_dir_add - Add new filename into directory 1698 * gfs2_dir_add - Add new filename into directory
1689 * @inode: The directory inode 1699 * @inode: The directory inode
@@ -1721,6 +1731,7 @@ int gfs2_dir_add(struct inode *inode, const struct qstr *name,
1721 dent = gfs2_init_dirent(inode, dent, name, bh); 1731 dent = gfs2_init_dirent(inode, dent, name, bh);
1722 gfs2_inum_out(nip, dent); 1732 gfs2_inum_out(nip, dent);
1723 dent->de_type = cpu_to_be16(IF2DT(nip->i_inode.i_mode)); 1733 dent->de_type = cpu_to_be16(IF2DT(nip->i_inode.i_mode));
1734 dent->de_rahead = cpu_to_be16(gfs2_inode_ra_len(nip));
1724 tv = CURRENT_TIME; 1735 tv = CURRENT_TIME;
1725 if (ip->i_diskflags & GFS2_DIF_EXHASH) { 1736 if (ip->i_diskflags & GFS2_DIF_EXHASH) {
1726 leaf = (struct gfs2_leaf *)bh->b_data; 1737 leaf = (struct gfs2_leaf *)bh->b_data;
diff --git a/fs/gfs2/file.c b/fs/gfs2/file.c
index efc078f0ee4e..6c794085abac 100644
--- a/fs/gfs2/file.c
+++ b/fs/gfs2/file.c
@@ -811,6 +811,8 @@ static long gfs2_fallocate(struct file *file, int mode, loff_t offset,
811 loff_t bsize_mask = ~((loff_t)sdp->sd_sb.sb_bsize - 1); 811 loff_t bsize_mask = ~((loff_t)sdp->sd_sb.sb_bsize - 1);
812 loff_t next = (offset + len - 1) >> sdp->sd_sb.sb_bsize_shift; 812 loff_t next = (offset + len - 1) >> sdp->sd_sb.sb_bsize_shift;
813 loff_t max_chunk_size = UINT_MAX & bsize_mask; 813 loff_t max_chunk_size = UINT_MAX & bsize_mask;
814 struct gfs2_holder gh;
815
814 next = (next + 1) << sdp->sd_sb.sb_bsize_shift; 816 next = (next + 1) << sdp->sd_sb.sb_bsize_shift;
815 817
816 /* We only support the FALLOC_FL_KEEP_SIZE mode */ 818 /* We only support the FALLOC_FL_KEEP_SIZE mode */
@@ -831,8 +833,10 @@ static long gfs2_fallocate(struct file *file, int mode, loff_t offset,
831 if (error) 833 if (error)
832 return error; 834 return error;
833 835
834 gfs2_holder_init(ip->i_gl, LM_ST_EXCLUSIVE, 0, &ip->i_gh); 836 mutex_lock(&inode->i_mutex);
835 error = gfs2_glock_nq(&ip->i_gh); 837
838 gfs2_holder_init(ip->i_gl, LM_ST_EXCLUSIVE, 0, &gh);
839 error = gfs2_glock_nq(&gh);
836 if (unlikely(error)) 840 if (unlikely(error))
837 goto out_uninit; 841 goto out_uninit;
838 842
@@ -900,9 +904,10 @@ out_trans_fail:
900out_qunlock: 904out_qunlock:
901 gfs2_quota_unlock(ip); 905 gfs2_quota_unlock(ip);
902out_unlock: 906out_unlock:
903 gfs2_glock_dq(&ip->i_gh); 907 gfs2_glock_dq(&gh);
904out_uninit: 908out_uninit:
905 gfs2_holder_uninit(&ip->i_gh); 909 gfs2_holder_uninit(&gh);
910 mutex_unlock(&inode->i_mutex);
906 return error; 911 return error;
907} 912}
908 913
diff --git a/fs/gfs2/glock.c b/fs/gfs2/glock.c
index ca0be6c69a26..aec7f73832f0 100644
--- a/fs/gfs2/glock.c
+++ b/fs/gfs2/glock.c
@@ -7,6 +7,8 @@
7 * of the GNU General Public License version 2. 7 * of the GNU General Public License version 2.
8 */ 8 */
9 9
10#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
11
10#include <linux/sched.h> 12#include <linux/sched.h>
11#include <linux/slab.h> 13#include <linux/slab.h>
12#include <linux/spinlock.h> 14#include <linux/spinlock.h>
@@ -468,7 +470,7 @@ retry:
468 do_xmote(gl, gh, LM_ST_UNLOCKED); 470 do_xmote(gl, gh, LM_ST_UNLOCKED);
469 break; 471 break;
470 default: /* Everything else */ 472 default: /* Everything else */
471 printk(KERN_ERR "GFS2: wanted %u got %u\n", gl->gl_target, state); 473 pr_err("wanted %u got %u\n", gl->gl_target, state);
472 GLOCK_BUG_ON(gl, 1); 474 GLOCK_BUG_ON(gl, 1);
473 } 475 }
474 spin_unlock(&gl->gl_spin); 476 spin_unlock(&gl->gl_spin);
@@ -542,7 +544,7 @@ __acquires(&gl->gl_spin)
542 /* lock_dlm */ 544 /* lock_dlm */
543 ret = sdp->sd_lockstruct.ls_ops->lm_lock(gl, target, lck_flags); 545 ret = sdp->sd_lockstruct.ls_ops->lm_lock(gl, target, lck_flags);
544 if (ret) { 546 if (ret) {
545 printk(KERN_ERR "GFS2: lm_lock ret %d\n", ret); 547 pr_err("lm_lock ret %d\n", ret);
546 GLOCK_BUG_ON(gl, 1); 548 GLOCK_BUG_ON(gl, 1);
547 } 549 }
548 } else { /* lock_nolock */ 550 } else { /* lock_nolock */
@@ -935,7 +937,7 @@ void gfs2_print_dbg(struct seq_file *seq, const char *fmt, ...)
935 vaf.fmt = fmt; 937 vaf.fmt = fmt;
936 vaf.va = &args; 938 vaf.va = &args;
937 939
938 printk(KERN_ERR " %pV", &vaf); 940 pr_err("%pV", &vaf);
939 } 941 }
940 942
941 va_end(args); 943 va_end(args);
@@ -1010,13 +1012,13 @@ do_cancel:
1010 return; 1012 return;
1011 1013
1012trap_recursive: 1014trap_recursive:
1013 printk(KERN_ERR "original: %pSR\n", (void *)gh2->gh_ip); 1015 pr_err("original: %pSR\n", (void *)gh2->gh_ip);
1014 printk(KERN_ERR "pid: %d\n", pid_nr(gh2->gh_owner_pid)); 1016 pr_err("pid: %d\n", pid_nr(gh2->gh_owner_pid));
1015 printk(KERN_ERR "lock type: %d req lock state : %d\n", 1017 pr_err("lock type: %d req lock state : %d\n",
1016 gh2->gh_gl->gl_name.ln_type, gh2->gh_state); 1018 gh2->gh_gl->gl_name.ln_type, gh2->gh_state);
1017 printk(KERN_ERR "new: %pSR\n", (void *)gh->gh_ip); 1019 pr_err("new: %pSR\n", (void *)gh->gh_ip);
1018 printk(KERN_ERR "pid: %d\n", pid_nr(gh->gh_owner_pid)); 1020 pr_err("pid: %d\n", pid_nr(gh->gh_owner_pid));
1019 printk(KERN_ERR "lock type: %d req lock state : %d\n", 1021 pr_err("lock type: %d req lock state : %d\n",
1020 gh->gh_gl->gl_name.ln_type, gh->gh_state); 1022 gh->gh_gl->gl_name.ln_type, gh->gh_state);
1021 gfs2_dump_glock(NULL, gl); 1023 gfs2_dump_glock(NULL, gl);
1022 BUG(); 1024 BUG();
@@ -1045,9 +1047,13 @@ int gfs2_glock_nq(struct gfs2_holder *gh)
1045 1047
1046 spin_lock(&gl->gl_spin); 1048 spin_lock(&gl->gl_spin);
1047 add_to_queue(gh); 1049 add_to_queue(gh);
1048 if ((LM_FLAG_NOEXP & gh->gh_flags) && 1050 if (unlikely((LM_FLAG_NOEXP & gh->gh_flags) &&
1049 test_and_clear_bit(GLF_FROZEN, &gl->gl_flags)) 1051 test_and_clear_bit(GLF_FROZEN, &gl->gl_flags))) {
1050 set_bit(GLF_REPLY_PENDING, &gl->gl_flags); 1052 set_bit(GLF_REPLY_PENDING, &gl->gl_flags);
1053 gl->gl_lockref.count++;
1054 if (queue_delayed_work(glock_workqueue, &gl->gl_work, 0) == 0)
1055 gl->gl_lockref.count--;
1056 }
1051 run_queue(gl, 1); 1057 run_queue(gl, 1);
1052 spin_unlock(&gl->gl_spin); 1058 spin_unlock(&gl->gl_spin);
1053 1059
diff --git a/fs/gfs2/glops.c b/fs/gfs2/glops.c
index 3bf0631b5d56..54b66809e818 100644
--- a/fs/gfs2/glops.c
+++ b/fs/gfs2/glops.c
@@ -82,6 +82,8 @@ static void gfs2_ail_empty_gl(struct gfs2_glock *gl)
82 struct gfs2_trans tr; 82 struct gfs2_trans tr;
83 83
84 memset(&tr, 0, sizeof(tr)); 84 memset(&tr, 0, sizeof(tr));
85 INIT_LIST_HEAD(&tr.tr_buf);
86 INIT_LIST_HEAD(&tr.tr_databuf);
85 tr.tr_revokes = atomic_read(&gl->gl_ail_count); 87 tr.tr_revokes = atomic_read(&gl->gl_ail_count);
86 88
87 if (!tr.tr_revokes) 89 if (!tr.tr_revokes)
diff --git a/fs/gfs2/incore.h b/fs/gfs2/incore.h
index cf0e34400f71..bdf70c18610c 100644
--- a/fs/gfs2/incore.h
+++ b/fs/gfs2/incore.h
@@ -52,7 +52,7 @@ struct gfs2_log_header_host {
52 */ 52 */
53 53
54struct gfs2_log_operations { 54struct gfs2_log_operations {
55 void (*lo_before_commit) (struct gfs2_sbd *sdp); 55 void (*lo_before_commit) (struct gfs2_sbd *sdp, struct gfs2_trans *tr);
56 void (*lo_after_commit) (struct gfs2_sbd *sdp, struct gfs2_trans *tr); 56 void (*lo_after_commit) (struct gfs2_sbd *sdp, struct gfs2_trans *tr);
57 void (*lo_before_scan) (struct gfs2_jdesc *jd, 57 void (*lo_before_scan) (struct gfs2_jdesc *jd,
58 struct gfs2_log_header_host *head, int pass); 58 struct gfs2_log_header_host *head, int pass);
@@ -371,6 +371,7 @@ enum {
371 GIF_ALLOC_FAILED = 2, 371 GIF_ALLOC_FAILED = 2,
372 GIF_SW_PAGED = 3, 372 GIF_SW_PAGED = 3,
373 GIF_ORDERED = 4, 373 GIF_ORDERED = 4,
374 GIF_FREE_VFS_INODE = 5,
374}; 375};
375 376
376struct gfs2_inode { 377struct gfs2_inode {
@@ -462,11 +463,11 @@ struct gfs2_trans {
462 unsigned int tr_blocks; 463 unsigned int tr_blocks;
463 unsigned int tr_revokes; 464 unsigned int tr_revokes;
464 unsigned int tr_reserved; 465 unsigned int tr_reserved;
466 unsigned int tr_touched:1;
467 unsigned int tr_attached:1;
465 468
466 struct gfs2_holder tr_t_gh; 469 struct gfs2_holder tr_t_gh;
467 470
468 int tr_touched;
469 int tr_attached;
470 471
471 unsigned int tr_num_buf_new; 472 unsigned int tr_num_buf_new;
472 unsigned int tr_num_databuf_new; 473 unsigned int tr_num_databuf_new;
@@ -476,6 +477,8 @@ struct gfs2_trans {
476 unsigned int tr_num_revoke_rm; 477 unsigned int tr_num_revoke_rm;
477 478
478 struct list_head tr_list; 479 struct list_head tr_list;
480 struct list_head tr_databuf;
481 struct list_head tr_buf;
479 482
480 unsigned int tr_first; 483 unsigned int tr_first;
481 struct list_head tr_ail1_list; 484 struct list_head tr_ail1_list;
@@ -483,7 +486,7 @@ struct gfs2_trans {
483}; 486};
484 487
485struct gfs2_journal_extent { 488struct gfs2_journal_extent {
486 struct list_head extent_list; 489 struct list_head list;
487 490
488 unsigned int lblock; /* First logical block */ 491 unsigned int lblock; /* First logical block */
489 u64 dblock; /* First disk block */ 492 u64 dblock; /* First disk block */
@@ -493,6 +496,7 @@ struct gfs2_journal_extent {
493struct gfs2_jdesc { 496struct gfs2_jdesc {
494 struct list_head jd_list; 497 struct list_head jd_list;
495 struct list_head extent_list; 498 struct list_head extent_list;
499 unsigned int nr_extents;
496 struct work_struct jd_work; 500 struct work_struct jd_work;
497 struct inode *jd_inode; 501 struct inode *jd_inode;
498 unsigned long jd_flags; 502 unsigned long jd_flags;
@@ -500,6 +504,15 @@ struct gfs2_jdesc {
500 unsigned int jd_jid; 504 unsigned int jd_jid;
501 unsigned int jd_blocks; 505 unsigned int jd_blocks;
502 int jd_recover_error; 506 int jd_recover_error;
507 /* Replay stuff */
508
509 unsigned int jd_found_blocks;
510 unsigned int jd_found_revokes;
511 unsigned int jd_replayed_blocks;
512
513 struct list_head jd_revoke_list;
514 unsigned int jd_replay_tail;
515
503}; 516};
504 517
505struct gfs2_statfs_change_host { 518struct gfs2_statfs_change_host {
@@ -746,19 +759,12 @@ struct gfs2_sbd {
746 759
747 struct gfs2_trans *sd_log_tr; 760 struct gfs2_trans *sd_log_tr;
748 unsigned int sd_log_blks_reserved; 761 unsigned int sd_log_blks_reserved;
749 unsigned int sd_log_commited_buf;
750 unsigned int sd_log_commited_databuf;
751 int sd_log_commited_revoke; 762 int sd_log_commited_revoke;
752 763
753 atomic_t sd_log_pinned; 764 atomic_t sd_log_pinned;
754 unsigned int sd_log_num_buf;
755 unsigned int sd_log_num_revoke; 765 unsigned int sd_log_num_revoke;
756 unsigned int sd_log_num_rg;
757 unsigned int sd_log_num_databuf;
758 766
759 struct list_head sd_log_le_buf;
760 struct list_head sd_log_le_revoke; 767 struct list_head sd_log_le_revoke;
761 struct list_head sd_log_le_databuf;
762 struct list_head sd_log_le_ordered; 768 struct list_head sd_log_le_ordered;
763 spinlock_t sd_ordered_lock; 769 spinlock_t sd_ordered_lock;
764 770
@@ -786,15 +792,6 @@ struct gfs2_sbd {
786 struct list_head sd_ail1_list; 792 struct list_head sd_ail1_list;
787 struct list_head sd_ail2_list; 793 struct list_head sd_ail2_list;
788 794
789 /* Replay stuff */
790
791 struct list_head sd_revoke_list;
792 unsigned int sd_replay_tail;
793
794 unsigned int sd_found_blocks;
795 unsigned int sd_found_revokes;
796 unsigned int sd_replayed_blocks;
797
798 /* For quiescing the filesystem */ 795 /* For quiescing the filesystem */
799 struct gfs2_holder sd_freeze_gh; 796 struct gfs2_holder sd_freeze_gh;
800 797
diff --git a/fs/gfs2/inode.c b/fs/gfs2/inode.c
index 5c524180c98e..28cc7bf6575a 100644
--- a/fs/gfs2/inode.c
+++ b/fs/gfs2/inode.c
@@ -376,12 +376,11 @@ static void munge_mode_uid_gid(const struct gfs2_inode *dip,
376 inode->i_gid = current_fsgid(); 376 inode->i_gid = current_fsgid();
377} 377}
378 378
379static int alloc_dinode(struct gfs2_inode *ip, u32 flags) 379static int alloc_dinode(struct gfs2_inode *ip, u32 flags, unsigned *dblocks)
380{ 380{
381 struct gfs2_sbd *sdp = GFS2_SB(&ip->i_inode); 381 struct gfs2_sbd *sdp = GFS2_SB(&ip->i_inode);
382 struct gfs2_alloc_parms ap = { .target = RES_DINODE, .aflags = flags, }; 382 struct gfs2_alloc_parms ap = { .target = *dblocks, .aflags = flags, };
383 int error; 383 int error;
384 int dblocks = 1;
385 384
386 error = gfs2_quota_lock_check(ip); 385 error = gfs2_quota_lock_check(ip);
387 if (error) 386 if (error)
@@ -391,11 +390,11 @@ static int alloc_dinode(struct gfs2_inode *ip, u32 flags)
391 if (error) 390 if (error)
392 goto out_quota; 391 goto out_quota;
393 392
394 error = gfs2_trans_begin(sdp, RES_RG_BIT + RES_STATFS + RES_QUOTA, 0); 393 error = gfs2_trans_begin(sdp, (*dblocks * RES_RG_BIT) + RES_STATFS + RES_QUOTA, 0);
395 if (error) 394 if (error)
396 goto out_ipreserv; 395 goto out_ipreserv;
397 396
398 error = gfs2_alloc_blocks(ip, &ip->i_no_addr, &dblocks, 1, &ip->i_generation); 397 error = gfs2_alloc_blocks(ip, &ip->i_no_addr, dblocks, 1, &ip->i_generation);
399 ip->i_no_formal_ino = ip->i_generation; 398 ip->i_no_formal_ino = ip->i_generation;
400 ip->i_inode.i_ino = ip->i_no_addr; 399 ip->i_inode.i_ino = ip->i_no_addr;
401 ip->i_goal = ip->i_no_addr; 400 ip->i_goal = ip->i_no_addr;
@@ -428,6 +427,33 @@ static void gfs2_init_dir(struct buffer_head *dibh,
428} 427}
429 428
430/** 429/**
430 * gfs2_init_xattr - Initialise an xattr block for a new inode
431 * @ip: The inode in question
432 *
433 * This sets up an empty xattr block for a new inode, ready to
434 * take any ACLs, LSM xattrs, etc.
435 */
436
437static void gfs2_init_xattr(struct gfs2_inode *ip)
438{
439 struct gfs2_sbd *sdp = GFS2_SB(&ip->i_inode);
440 struct buffer_head *bh;
441 struct gfs2_ea_header *ea;
442
443 bh = gfs2_meta_new(ip->i_gl, ip->i_eattr);
444 gfs2_trans_add_meta(ip->i_gl, bh);
445 gfs2_metatype_set(bh, GFS2_METATYPE_EA, GFS2_FORMAT_EA);
446 gfs2_buffer_clear_tail(bh, sizeof(struct gfs2_meta_header));
447
448 ea = GFS2_EA_BH2FIRST(bh);
449 ea->ea_rec_len = cpu_to_be32(sdp->sd_jbsize);
450 ea->ea_type = GFS2_EATYPE_UNUSED;
451 ea->ea_flags = GFS2_EAFLAG_LAST;
452
453 brelse(bh);
454}
455
456/**
431 * init_dinode - Fill in a new dinode structure 457 * init_dinode - Fill in a new dinode structure
432 * @dip: The directory this inode is being created in 458 * @dip: The directory this inode is being created in
433 * @ip: The inode 459 * @ip: The inode
@@ -545,13 +571,6 @@ static int gfs2_initxattrs(struct inode *inode, const struct xattr *xattr_array,
545 return err; 571 return err;
546} 572}
547 573
548static int gfs2_security_init(struct gfs2_inode *dip, struct gfs2_inode *ip,
549 const struct qstr *qstr)
550{
551 return security_inode_init_security(&ip->i_inode, &dip->i_inode, qstr,
552 &gfs2_initxattrs, NULL);
553}
554
555/** 574/**
556 * gfs2_create_inode - Create a new inode 575 * gfs2_create_inode - Create a new inode
557 * @dir: The parent directory 576 * @dir: The parent directory
@@ -578,8 +597,9 @@ static int gfs2_create_inode(struct inode *dir, struct dentry *dentry,
578 struct gfs2_sbd *sdp = GFS2_SB(&dip->i_inode); 597 struct gfs2_sbd *sdp = GFS2_SB(&dip->i_inode);
579 struct gfs2_glock *io_gl; 598 struct gfs2_glock *io_gl;
580 struct dentry *d; 599 struct dentry *d;
581 int error; 600 int error, free_vfs_inode = 0;
582 u32 aflags = 0; 601 u32 aflags = 0;
602 unsigned blocks = 1;
583 struct gfs2_diradd da = { .bh = NULL, }; 603 struct gfs2_diradd da = { .bh = NULL, };
584 604
585 if (!name->len || name->len > GFS2_FNAMESIZE) 605 if (!name->len || name->len > GFS2_FNAMESIZE)
@@ -676,10 +696,15 @@ static int gfs2_create_inode(struct inode *dir, struct dentry *dentry,
676 (dip->i_diskflags & GFS2_DIF_TOPDIR)) 696 (dip->i_diskflags & GFS2_DIF_TOPDIR))
677 aflags |= GFS2_AF_ORLOV; 697 aflags |= GFS2_AF_ORLOV;
678 698
679 error = alloc_dinode(ip, aflags); 699 if (default_acl || acl)
700 blocks++;
701
702 error = alloc_dinode(ip, aflags, &blocks);
680 if (error) 703 if (error)
681 goto fail_free_inode; 704 goto fail_free_inode;
682 705
706 gfs2_set_inode_blocks(inode, blocks);
707
683 error = gfs2_glock_get(sdp, ip->i_no_addr, &gfs2_inode_glops, CREATE, &ip->i_gl); 708 error = gfs2_glock_get(sdp, ip->i_no_addr, &gfs2_inode_glops, CREATE, &ip->i_gl);
684 if (error) 709 if (error)
685 goto fail_free_inode; 710 goto fail_free_inode;
@@ -689,10 +714,14 @@ static int gfs2_create_inode(struct inode *dir, struct dentry *dentry,
689 if (error) 714 if (error)
690 goto fail_free_inode; 715 goto fail_free_inode;
691 716
692 error = gfs2_trans_begin(sdp, RES_DINODE, 0); 717 error = gfs2_trans_begin(sdp, blocks, 0);
693 if (error) 718 if (error)
694 goto fail_gunlock2; 719 goto fail_gunlock2;
695 720
721 if (blocks > 1) {
722 ip->i_eattr = ip->i_no_addr + 1;
723 gfs2_init_xattr(ip);
724 }
696 init_dinode(dip, ip, symname); 725 init_dinode(dip, ip, symname);
697 gfs2_trans_end(sdp); 726 gfs2_trans_end(sdp);
698 727
@@ -722,7 +751,8 @@ static int gfs2_create_inode(struct inode *dir, struct dentry *dentry,
722 if (error) 751 if (error)
723 goto fail_gunlock3; 752 goto fail_gunlock3;
724 753
725 error = gfs2_security_init(dip, ip, name); 754 error = security_inode_init_security(&ip->i_inode, &dip->i_inode, name,
755 &gfs2_initxattrs, NULL);
726 if (error) 756 if (error)
727 goto fail_gunlock3; 757 goto fail_gunlock3;
728 758
@@ -758,15 +788,16 @@ fail_free_acls:
758 if (acl) 788 if (acl)
759 posix_acl_release(acl); 789 posix_acl_release(acl);
760fail_free_vfs_inode: 790fail_free_vfs_inode:
761 free_inode_nonrcu(inode); 791 free_vfs_inode = 1;
762 inode = NULL;
763fail_gunlock: 792fail_gunlock:
764 gfs2_dir_no_add(&da); 793 gfs2_dir_no_add(&da);
765 gfs2_glock_dq_uninit(ghs); 794 gfs2_glock_dq_uninit(ghs);
766 if (inode && !IS_ERR(inode)) { 795 if (inode && !IS_ERR(inode)) {
767 clear_nlink(inode); 796 clear_nlink(inode);
768 mark_inode_dirty(inode); 797 if (!free_vfs_inode)
769 set_bit(GIF_ALLOC_FAILED, &GFS2_I(inode)->i_flags); 798 mark_inode_dirty(inode);
799 set_bit(free_vfs_inode ? GIF_FREE_VFS_INODE : GIF_ALLOC_FAILED,
800 &GFS2_I(inode)->i_flags);
770 iput(inode); 801 iput(inode);
771 } 802 }
772fail: 803fail:
@@ -1263,6 +1294,10 @@ static int gfs2_ok_to_move(struct gfs2_inode *this, struct gfs2_inode *to)
1263 } 1294 }
1264 1295
1265 tmp = gfs2_lookupi(dir, &gfs2_qdotdot, 1); 1296 tmp = gfs2_lookupi(dir, &gfs2_qdotdot, 1);
1297 if (!tmp) {
1298 error = -ENOENT;
1299 break;
1300 }
1266 if (IS_ERR(tmp)) { 1301 if (IS_ERR(tmp)) {
1267 error = PTR_ERR(tmp); 1302 error = PTR_ERR(tmp);
1268 break; 1303 break;
diff --git a/fs/gfs2/lock_dlm.c b/fs/gfs2/lock_dlm.c
index 2a6ba06bee6f..c1eb555dc588 100644
--- a/fs/gfs2/lock_dlm.c
+++ b/fs/gfs2/lock_dlm.c
@@ -7,6 +7,8 @@
7 * of the GNU General Public License version 2. 7 * of the GNU General Public License version 2.
8 */ 8 */
9 9
10#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
11
10#include <linux/fs.h> 12#include <linux/fs.h>
11#include <linux/dlm.h> 13#include <linux/dlm.h>
12#include <linux/slab.h> 14#include <linux/slab.h>
@@ -176,7 +178,7 @@ static void gdlm_bast(void *arg, int mode)
176 gfs2_glock_cb(gl, LM_ST_SHARED); 178 gfs2_glock_cb(gl, LM_ST_SHARED);
177 break; 179 break;
178 default: 180 default:
179 printk(KERN_ERR "unknown bast mode %d", mode); 181 pr_err("unknown bast mode %d\n", mode);
180 BUG(); 182 BUG();
181 } 183 }
182} 184}
@@ -195,7 +197,7 @@ static int make_mode(const unsigned int lmstate)
195 case LM_ST_SHARED: 197 case LM_ST_SHARED:
196 return DLM_LOCK_PR; 198 return DLM_LOCK_PR;
197 } 199 }
198 printk(KERN_ERR "unknown LM state %d", lmstate); 200 pr_err("unknown LM state %d\n", lmstate);
199 BUG(); 201 BUG();
200 return -1; 202 return -1;
201} 203}
@@ -308,7 +310,7 @@ static void gdlm_put_lock(struct gfs2_glock *gl)
308 error = dlm_unlock(ls->ls_dlm, gl->gl_lksb.sb_lkid, DLM_LKF_VALBLK, 310 error = dlm_unlock(ls->ls_dlm, gl->gl_lksb.sb_lkid, DLM_LKF_VALBLK,
309 NULL, gl); 311 NULL, gl);
310 if (error) { 312 if (error) {
311 printk(KERN_ERR "gdlm_unlock %x,%llx err=%d\n", 313 pr_err("gdlm_unlock %x,%llx err=%d\n",
312 gl->gl_name.ln_type, 314 gl->gl_name.ln_type,
313 (unsigned long long)gl->gl_name.ln_number, error); 315 (unsigned long long)gl->gl_name.ln_number, error);
314 return; 316 return;
@@ -1102,7 +1104,7 @@ static void gdlm_recover_slot(void *arg, struct dlm_slot *slot)
1102 } 1104 }
1103 1105
1104 if (ls->ls_recover_submit[jid]) { 1106 if (ls->ls_recover_submit[jid]) {
1105 fs_info(sdp, "recover_slot jid %d gen %u prev %u", 1107 fs_info(sdp, "recover_slot jid %d gen %u prev %u\n",
1106 jid, ls->ls_recover_block, ls->ls_recover_submit[jid]); 1108 jid, ls->ls_recover_block, ls->ls_recover_submit[jid]);
1107 } 1109 }
1108 ls->ls_recover_submit[jid] = ls->ls_recover_block; 1110 ls->ls_recover_submit[jid] = ls->ls_recover_block;
diff --git a/fs/gfs2/log.c b/fs/gfs2/log.c
index 9dcb9777a5f8..4a14d504ef83 100644
--- a/fs/gfs2/log.c
+++ b/fs/gfs2/log.c
@@ -18,6 +18,7 @@
18#include <linux/kthread.h> 18#include <linux/kthread.h>
19#include <linux/freezer.h> 19#include <linux/freezer.h>
20#include <linux/bio.h> 20#include <linux/bio.h>
21#include <linux/blkdev.h>
21#include <linux/writeback.h> 22#include <linux/writeback.h>
22#include <linux/list_sort.h> 23#include <linux/list_sort.h>
23 24
@@ -145,8 +146,10 @@ void gfs2_ail1_flush(struct gfs2_sbd *sdp, struct writeback_control *wbc)
145{ 146{
146 struct list_head *head = &sdp->sd_ail1_list; 147 struct list_head *head = &sdp->sd_ail1_list;
147 struct gfs2_trans *tr; 148 struct gfs2_trans *tr;
149 struct blk_plug plug;
148 150
149 trace_gfs2_ail_flush(sdp, wbc, 1); 151 trace_gfs2_ail_flush(sdp, wbc, 1);
152 blk_start_plug(&plug);
150 spin_lock(&sdp->sd_ail_lock); 153 spin_lock(&sdp->sd_ail_lock);
151restart: 154restart:
152 list_for_each_entry_reverse(tr, head, tr_list) { 155 list_for_each_entry_reverse(tr, head, tr_list) {
@@ -156,6 +159,7 @@ restart:
156 goto restart; 159 goto restart;
157 } 160 }
158 spin_unlock(&sdp->sd_ail_lock); 161 spin_unlock(&sdp->sd_ail_lock);
162 blk_finish_plug(&plug);
159 trace_gfs2_ail_flush(sdp, wbc, 0); 163 trace_gfs2_ail_flush(sdp, wbc, 0);
160} 164}
161 165
@@ -410,24 +414,22 @@ static inline unsigned int log_distance(struct gfs2_sbd *sdp, unsigned int newer
410static unsigned int calc_reserved(struct gfs2_sbd *sdp) 414static unsigned int calc_reserved(struct gfs2_sbd *sdp)
411{ 415{
412 unsigned int reserved = 0; 416 unsigned int reserved = 0;
413 unsigned int mbuf_limit, metabufhdrs_needed; 417 unsigned int mbuf;
414 unsigned int dbuf_limit, databufhdrs_needed; 418 unsigned int dbuf;
415 unsigned int revokes = 0; 419 struct gfs2_trans *tr = sdp->sd_log_tr;
416 420
417 mbuf_limit = buf_limit(sdp); 421 if (tr) {
418 metabufhdrs_needed = (sdp->sd_log_commited_buf + 422 mbuf = tr->tr_num_buf_new - tr->tr_num_buf_rm;
419 (mbuf_limit - 1)) / mbuf_limit; 423 dbuf = tr->tr_num_databuf_new - tr->tr_num_databuf_rm;
420 dbuf_limit = databuf_limit(sdp); 424 reserved = mbuf + dbuf;
421 databufhdrs_needed = (sdp->sd_log_commited_databuf + 425 /* Account for header blocks */
422 (dbuf_limit - 1)) / dbuf_limit; 426 reserved += DIV_ROUND_UP(mbuf, buf_limit(sdp));
427 reserved += DIV_ROUND_UP(dbuf, databuf_limit(sdp));
428 }
423 429
424 if (sdp->sd_log_commited_revoke > 0) 430 if (sdp->sd_log_commited_revoke > 0)
425 revokes = gfs2_struct2blk(sdp, sdp->sd_log_commited_revoke, 431 reserved += gfs2_struct2blk(sdp, sdp->sd_log_commited_revoke,
426 sizeof(u64)); 432 sizeof(u64));
427
428 reserved = sdp->sd_log_commited_buf + metabufhdrs_needed +
429 sdp->sd_log_commited_databuf + databufhdrs_needed +
430 revokes;
431 /* One for the overall header */ 433 /* One for the overall header */
432 if (reserved) 434 if (reserved)
433 reserved++; 435 reserved++;
@@ -682,36 +684,25 @@ void gfs2_log_flush(struct gfs2_sbd *sdp, struct gfs2_glock *gl)
682 } 684 }
683 trace_gfs2_log_flush(sdp, 1); 685 trace_gfs2_log_flush(sdp, 1);
684 686
687 sdp->sd_log_flush_head = sdp->sd_log_head;
688 sdp->sd_log_flush_wrapped = 0;
685 tr = sdp->sd_log_tr; 689 tr = sdp->sd_log_tr;
686 if (tr) { 690 if (tr) {
687 sdp->sd_log_tr = NULL; 691 sdp->sd_log_tr = NULL;
688 INIT_LIST_HEAD(&tr->tr_ail1_list); 692 INIT_LIST_HEAD(&tr->tr_ail1_list);
689 INIT_LIST_HEAD(&tr->tr_ail2_list); 693 INIT_LIST_HEAD(&tr->tr_ail2_list);
694 tr->tr_first = sdp->sd_log_flush_head;
690 } 695 }
691 696
692 if (sdp->sd_log_num_buf != sdp->sd_log_commited_buf) {
693 printk(KERN_INFO "GFS2: log buf %u %u\n", sdp->sd_log_num_buf,
694 sdp->sd_log_commited_buf);
695 gfs2_assert_withdraw(sdp, 0);
696 }
697 if (sdp->sd_log_num_databuf != sdp->sd_log_commited_databuf) {
698 printk(KERN_INFO "GFS2: log databuf %u %u\n",
699 sdp->sd_log_num_databuf, sdp->sd_log_commited_databuf);
700 gfs2_assert_withdraw(sdp, 0);
701 }
702 gfs2_assert_withdraw(sdp, 697 gfs2_assert_withdraw(sdp,
703 sdp->sd_log_num_revoke == sdp->sd_log_commited_revoke); 698 sdp->sd_log_num_revoke == sdp->sd_log_commited_revoke);
704 699
705 sdp->sd_log_flush_head = sdp->sd_log_head;
706 sdp->sd_log_flush_wrapped = 0;
707 if (tr)
708 tr->tr_first = sdp->sd_log_flush_head;
709
710 gfs2_ordered_write(sdp); 700 gfs2_ordered_write(sdp);
711 lops_before_commit(sdp); 701 lops_before_commit(sdp, tr);
712 gfs2_log_flush_bio(sdp, WRITE); 702 gfs2_log_flush_bio(sdp, WRITE);
713 703
714 if (sdp->sd_log_head != sdp->sd_log_flush_head) { 704 if (sdp->sd_log_head != sdp->sd_log_flush_head) {
705 log_flush_wait(sdp);
715 log_write_header(sdp, 0); 706 log_write_header(sdp, 0);
716 } else if (sdp->sd_log_tail != current_tail(sdp) && !sdp->sd_log_idle){ 707 } else if (sdp->sd_log_tail != current_tail(sdp) && !sdp->sd_log_idle){
717 atomic_dec(&sdp->sd_log_blks_free); /* Adjust for unreserved buffer */ 708 atomic_dec(&sdp->sd_log_blks_free); /* Adjust for unreserved buffer */
@@ -723,8 +714,6 @@ void gfs2_log_flush(struct gfs2_sbd *sdp, struct gfs2_glock *gl)
723 gfs2_log_lock(sdp); 714 gfs2_log_lock(sdp);
724 sdp->sd_log_head = sdp->sd_log_flush_head; 715 sdp->sd_log_head = sdp->sd_log_flush_head;
725 sdp->sd_log_blks_reserved = 0; 716 sdp->sd_log_blks_reserved = 0;
726 sdp->sd_log_commited_buf = 0;
727 sdp->sd_log_commited_databuf = 0;
728 sdp->sd_log_commited_revoke = 0; 717 sdp->sd_log_commited_revoke = 0;
729 718
730 spin_lock(&sdp->sd_ail_lock); 719 spin_lock(&sdp->sd_ail_lock);
@@ -740,34 +729,54 @@ void gfs2_log_flush(struct gfs2_sbd *sdp, struct gfs2_glock *gl)
740 kfree(tr); 729 kfree(tr);
741} 730}
742 731
732/**
733 * gfs2_merge_trans - Merge a new transaction into a cached transaction
734 * @old: Original transaction to be expanded
735 * @new: New transaction to be merged
736 */
737
738static void gfs2_merge_trans(struct gfs2_trans *old, struct gfs2_trans *new)
739{
740 WARN_ON_ONCE(old->tr_attached != 1);
741
742 old->tr_num_buf_new += new->tr_num_buf_new;
743 old->tr_num_databuf_new += new->tr_num_databuf_new;
744 old->tr_num_buf_rm += new->tr_num_buf_rm;
745 old->tr_num_databuf_rm += new->tr_num_databuf_rm;
746 old->tr_num_revoke += new->tr_num_revoke;
747 old->tr_num_revoke_rm += new->tr_num_revoke_rm;
748
749 list_splice_tail_init(&new->tr_databuf, &old->tr_databuf);
750 list_splice_tail_init(&new->tr_buf, &old->tr_buf);
751}
752
743static void log_refund(struct gfs2_sbd *sdp, struct gfs2_trans *tr) 753static void log_refund(struct gfs2_sbd *sdp, struct gfs2_trans *tr)
744{ 754{
745 unsigned int reserved; 755 unsigned int reserved;
746 unsigned int unused; 756 unsigned int unused;
757 unsigned int maxres;
747 758
748 gfs2_log_lock(sdp); 759 gfs2_log_lock(sdp);
749 760
750 sdp->sd_log_commited_buf += tr->tr_num_buf_new - tr->tr_num_buf_rm; 761 if (sdp->sd_log_tr) {
751 sdp->sd_log_commited_databuf += tr->tr_num_databuf_new - 762 gfs2_merge_trans(sdp->sd_log_tr, tr);
752 tr->tr_num_databuf_rm; 763 } else if (tr->tr_num_buf_new || tr->tr_num_databuf_new) {
753 gfs2_assert_withdraw(sdp, (((int)sdp->sd_log_commited_buf) >= 0) || 764 gfs2_assert_withdraw(sdp, tr->tr_t_gh.gh_gl);
754 (((int)sdp->sd_log_commited_databuf) >= 0)); 765 sdp->sd_log_tr = tr;
766 tr->tr_attached = 1;
767 }
768
755 sdp->sd_log_commited_revoke += tr->tr_num_revoke - tr->tr_num_revoke_rm; 769 sdp->sd_log_commited_revoke += tr->tr_num_revoke - tr->tr_num_revoke_rm;
756 reserved = calc_reserved(sdp); 770 reserved = calc_reserved(sdp);
757 gfs2_assert_withdraw(sdp, sdp->sd_log_blks_reserved + tr->tr_reserved >= reserved); 771 maxres = sdp->sd_log_blks_reserved + tr->tr_reserved;
758 unused = sdp->sd_log_blks_reserved - reserved + tr->tr_reserved; 772 gfs2_assert_withdraw(sdp, maxres >= reserved);
773 unused = maxres - reserved;
759 atomic_add(unused, &sdp->sd_log_blks_free); 774 atomic_add(unused, &sdp->sd_log_blks_free);
760 trace_gfs2_log_blocks(sdp, unused); 775 trace_gfs2_log_blocks(sdp, unused);
761 gfs2_assert_withdraw(sdp, atomic_read(&sdp->sd_log_blks_free) <= 776 gfs2_assert_withdraw(sdp, atomic_read(&sdp->sd_log_blks_free) <=
762 sdp->sd_jdesc->jd_blocks); 777 sdp->sd_jdesc->jd_blocks);
763 sdp->sd_log_blks_reserved = reserved; 778 sdp->sd_log_blks_reserved = reserved;
764 779
765 if (sdp->sd_log_tr == NULL &&
766 (tr->tr_num_buf_new || tr->tr_num_databuf_new)) {
767 gfs2_assert_withdraw(sdp, tr->tr_t_gh.gh_gl);
768 sdp->sd_log_tr = tr;
769 tr->tr_attached = 1;
770 }
771 gfs2_log_unlock(sdp); 780 gfs2_log_unlock(sdp);
772} 781}
773 782
@@ -807,10 +816,7 @@ void gfs2_log_shutdown(struct gfs2_sbd *sdp)
807 down_write(&sdp->sd_log_flush_lock); 816 down_write(&sdp->sd_log_flush_lock);
808 817
809 gfs2_assert_withdraw(sdp, !sdp->sd_log_blks_reserved); 818 gfs2_assert_withdraw(sdp, !sdp->sd_log_blks_reserved);
810 gfs2_assert_withdraw(sdp, !sdp->sd_log_num_buf);
811 gfs2_assert_withdraw(sdp, !sdp->sd_log_num_revoke); 819 gfs2_assert_withdraw(sdp, !sdp->sd_log_num_revoke);
812 gfs2_assert_withdraw(sdp, !sdp->sd_log_num_rg);
813 gfs2_assert_withdraw(sdp, !sdp->sd_log_num_databuf);
814 gfs2_assert_withdraw(sdp, list_empty(&sdp->sd_ail1_list)); 820 gfs2_assert_withdraw(sdp, list_empty(&sdp->sd_ail1_list));
815 821
816 sdp->sd_log_flush_head = sdp->sd_log_head; 822 sdp->sd_log_flush_head = sdp->sd_log_head;
diff --git a/fs/gfs2/lops.c b/fs/gfs2/lops.c
index 76693793cedd..a294d8d8bcd4 100644
--- a/fs/gfs2/lops.c
+++ b/fs/gfs2/lops.c
@@ -146,8 +146,8 @@ static u64 gfs2_log_bmap(struct gfs2_sbd *sdp)
146 struct gfs2_journal_extent *je; 146 struct gfs2_journal_extent *je;
147 u64 block; 147 u64 block;
148 148
149 list_for_each_entry(je, &sdp->sd_jdesc->extent_list, extent_list) { 149 list_for_each_entry(je, &sdp->sd_jdesc->extent_list, list) {
150 if (lbn >= je->lblock && lbn < je->lblock + je->blocks) { 150 if ((lbn >= je->lblock) && (lbn < (je->lblock + je->blocks))) {
151 block = je->dblock + lbn - je->lblock; 151 block = je->dblock + lbn - je->lblock;
152 gfs2_log_incr_head(sdp); 152 gfs2_log_incr_head(sdp);
153 return block; 153 return block;
@@ -491,44 +491,40 @@ static void gfs2_before_commit(struct gfs2_sbd *sdp, unsigned int limit,
491 gfs2_log_unlock(sdp); 491 gfs2_log_unlock(sdp);
492} 492}
493 493
494static void buf_lo_before_commit(struct gfs2_sbd *sdp) 494static void buf_lo_before_commit(struct gfs2_sbd *sdp, struct gfs2_trans *tr)
495{ 495{
496 unsigned int limit = buf_limit(sdp); /* 503 for 4k blocks */ 496 unsigned int limit = buf_limit(sdp); /* 503 for 4k blocks */
497 497 unsigned int nbuf;
498 gfs2_before_commit(sdp, limit, sdp->sd_log_num_buf, 498 if (tr == NULL)
499 &sdp->sd_log_le_buf, 0); 499 return;
500 nbuf = tr->tr_num_buf_new - tr->tr_num_buf_rm;
501 gfs2_before_commit(sdp, limit, nbuf, &tr->tr_buf, 0);
500} 502}
501 503
502static void buf_lo_after_commit(struct gfs2_sbd *sdp, struct gfs2_trans *tr) 504static void buf_lo_after_commit(struct gfs2_sbd *sdp, struct gfs2_trans *tr)
503{ 505{
504 struct list_head *head = &sdp->sd_log_le_buf; 506 struct list_head *head;
505 struct gfs2_bufdata *bd; 507 struct gfs2_bufdata *bd;
506 508
507 if (tr == NULL) { 509 if (tr == NULL)
508 gfs2_assert(sdp, list_empty(head));
509 return; 510 return;
510 }
511 511
512 head = &tr->tr_buf;
512 while (!list_empty(head)) { 513 while (!list_empty(head)) {
513 bd = list_entry(head->next, struct gfs2_bufdata, bd_list); 514 bd = list_entry(head->next, struct gfs2_bufdata, bd_list);
514 list_del_init(&bd->bd_list); 515 list_del_init(&bd->bd_list);
515 sdp->sd_log_num_buf--;
516
517 gfs2_unpin(sdp, bd->bd_bh, tr); 516 gfs2_unpin(sdp, bd->bd_bh, tr);
518 } 517 }
519 gfs2_assert_warn(sdp, !sdp->sd_log_num_buf);
520} 518}
521 519
522static void buf_lo_before_scan(struct gfs2_jdesc *jd, 520static void buf_lo_before_scan(struct gfs2_jdesc *jd,
523 struct gfs2_log_header_host *head, int pass) 521 struct gfs2_log_header_host *head, int pass)
524{ 522{
525 struct gfs2_sbd *sdp = GFS2_SB(jd->jd_inode);
526
527 if (pass != 0) 523 if (pass != 0)
528 return; 524 return;
529 525
530 sdp->sd_found_blocks = 0; 526 jd->jd_found_blocks = 0;
531 sdp->sd_replayed_blocks = 0; 527 jd->jd_replayed_blocks = 0;
532} 528}
533 529
534static int buf_lo_scan_elements(struct gfs2_jdesc *jd, unsigned int start, 530static int buf_lo_scan_elements(struct gfs2_jdesc *jd, unsigned int start,
@@ -551,9 +547,9 @@ static int buf_lo_scan_elements(struct gfs2_jdesc *jd, unsigned int start,
551 for (; blks; gfs2_replay_incr_blk(sdp, &start), blks--) { 547 for (; blks; gfs2_replay_incr_blk(sdp, &start), blks--) {
552 blkno = be64_to_cpu(*ptr++); 548 blkno = be64_to_cpu(*ptr++);
553 549
554 sdp->sd_found_blocks++; 550 jd->jd_found_blocks++;
555 551
556 if (gfs2_revoke_check(sdp, blkno, start)) 552 if (gfs2_revoke_check(jd, blkno, start))
557 continue; 553 continue;
558 554
559 error = gfs2_replay_read_block(jd, start, &bh_log); 555 error = gfs2_replay_read_block(jd, start, &bh_log);
@@ -574,7 +570,7 @@ static int buf_lo_scan_elements(struct gfs2_jdesc *jd, unsigned int start,
574 if (error) 570 if (error)
575 break; 571 break;
576 572
577 sdp->sd_replayed_blocks++; 573 jd->jd_replayed_blocks++;
578 } 574 }
579 575
580 return error; 576 return error;
@@ -617,10 +613,10 @@ static void buf_lo_after_scan(struct gfs2_jdesc *jd, int error, int pass)
617 gfs2_meta_sync(ip->i_gl); 613 gfs2_meta_sync(ip->i_gl);
618 614
619 fs_info(sdp, "jid=%u: Replayed %u of %u blocks\n", 615 fs_info(sdp, "jid=%u: Replayed %u of %u blocks\n",
620 jd->jd_jid, sdp->sd_replayed_blocks, sdp->sd_found_blocks); 616 jd->jd_jid, jd->jd_replayed_blocks, jd->jd_found_blocks);
621} 617}
622 618
623static void revoke_lo_before_commit(struct gfs2_sbd *sdp) 619static void revoke_lo_before_commit(struct gfs2_sbd *sdp, struct gfs2_trans *tr)
624{ 620{
625 struct gfs2_meta_header *mh; 621 struct gfs2_meta_header *mh;
626 unsigned int offset; 622 unsigned int offset;
@@ -679,13 +675,11 @@ static void revoke_lo_after_commit(struct gfs2_sbd *sdp, struct gfs2_trans *tr)
679static void revoke_lo_before_scan(struct gfs2_jdesc *jd, 675static void revoke_lo_before_scan(struct gfs2_jdesc *jd,
680 struct gfs2_log_header_host *head, int pass) 676 struct gfs2_log_header_host *head, int pass)
681{ 677{
682 struct gfs2_sbd *sdp = GFS2_SB(jd->jd_inode);
683
684 if (pass != 0) 678 if (pass != 0)
685 return; 679 return;
686 680
687 sdp->sd_found_revokes = 0; 681 jd->jd_found_revokes = 0;
688 sdp->sd_replay_tail = head->lh_tail; 682 jd->jd_replay_tail = head->lh_tail;
689} 683}
690 684
691static int revoke_lo_scan_elements(struct gfs2_jdesc *jd, unsigned int start, 685static int revoke_lo_scan_elements(struct gfs2_jdesc *jd, unsigned int start,
@@ -717,13 +711,13 @@ static int revoke_lo_scan_elements(struct gfs2_jdesc *jd, unsigned int start,
717 while (offset + sizeof(u64) <= sdp->sd_sb.sb_bsize) { 711 while (offset + sizeof(u64) <= sdp->sd_sb.sb_bsize) {
718 blkno = be64_to_cpu(*(__be64 *)(bh->b_data + offset)); 712 blkno = be64_to_cpu(*(__be64 *)(bh->b_data + offset));
719 713
720 error = gfs2_revoke_add(sdp, blkno, start); 714 error = gfs2_revoke_add(jd, blkno, start);
721 if (error < 0) { 715 if (error < 0) {
722 brelse(bh); 716 brelse(bh);
723 return error; 717 return error;
724 } 718 }
725 else if (error) 719 else if (error)
726 sdp->sd_found_revokes++; 720 jd->jd_found_revokes++;
727 721
728 if (!--revokes) 722 if (!--revokes)
729 break; 723 break;
@@ -743,16 +737,16 @@ static void revoke_lo_after_scan(struct gfs2_jdesc *jd, int error, int pass)
743 struct gfs2_sbd *sdp = GFS2_SB(jd->jd_inode); 737 struct gfs2_sbd *sdp = GFS2_SB(jd->jd_inode);
744 738
745 if (error) { 739 if (error) {
746 gfs2_revoke_clean(sdp); 740 gfs2_revoke_clean(jd);
747 return; 741 return;
748 } 742 }
749 if (pass != 1) 743 if (pass != 1)
750 return; 744 return;
751 745
752 fs_info(sdp, "jid=%u: Found %u revoke tags\n", 746 fs_info(sdp, "jid=%u: Found %u revoke tags\n",
753 jd->jd_jid, sdp->sd_found_revokes); 747 jd->jd_jid, jd->jd_found_revokes);
754 748
755 gfs2_revoke_clean(sdp); 749 gfs2_revoke_clean(jd);
756} 750}
757 751
758/** 752/**
@@ -760,12 +754,14 @@ static void revoke_lo_after_scan(struct gfs2_jdesc *jd, int error, int pass)
760 * 754 *
761 */ 755 */
762 756
763static void databuf_lo_before_commit(struct gfs2_sbd *sdp) 757static void databuf_lo_before_commit(struct gfs2_sbd *sdp, struct gfs2_trans *tr)
764{ 758{
765 unsigned int limit = buf_limit(sdp) / 2; 759 unsigned int limit = databuf_limit(sdp);
766 760 unsigned int nbuf;
767 gfs2_before_commit(sdp, limit, sdp->sd_log_num_databuf, 761 if (tr == NULL)
768 &sdp->sd_log_le_databuf, 1); 762 return;
763 nbuf = tr->tr_num_databuf_new - tr->tr_num_databuf_rm;
764 gfs2_before_commit(sdp, limit, nbuf, &tr->tr_databuf, 1);
769} 765}
770 766
771static int databuf_lo_scan_elements(struct gfs2_jdesc *jd, unsigned int start, 767static int databuf_lo_scan_elements(struct gfs2_jdesc *jd, unsigned int start,
@@ -789,9 +785,9 @@ static int databuf_lo_scan_elements(struct gfs2_jdesc *jd, unsigned int start,
789 blkno = be64_to_cpu(*ptr++); 785 blkno = be64_to_cpu(*ptr++);
790 esc = be64_to_cpu(*ptr++); 786 esc = be64_to_cpu(*ptr++);
791 787
792 sdp->sd_found_blocks++; 788 jd->jd_found_blocks++;
793 789
794 if (gfs2_revoke_check(sdp, blkno, start)) 790 if (gfs2_revoke_check(jd, blkno, start))
795 continue; 791 continue;
796 792
797 error = gfs2_replay_read_block(jd, start, &bh_log); 793 error = gfs2_replay_read_block(jd, start, &bh_log);
@@ -811,7 +807,7 @@ static int databuf_lo_scan_elements(struct gfs2_jdesc *jd, unsigned int start,
811 brelse(bh_log); 807 brelse(bh_log);
812 brelse(bh_ip); 808 brelse(bh_ip);
813 809
814 sdp->sd_replayed_blocks++; 810 jd->jd_replayed_blocks++;
815 } 811 }
816 812
817 return error; 813 return error;
@@ -835,26 +831,23 @@ static void databuf_lo_after_scan(struct gfs2_jdesc *jd, int error, int pass)
835 gfs2_meta_sync(ip->i_gl); 831 gfs2_meta_sync(ip->i_gl);
836 832
837 fs_info(sdp, "jid=%u: Replayed %u of %u data blocks\n", 833 fs_info(sdp, "jid=%u: Replayed %u of %u data blocks\n",
838 jd->jd_jid, sdp->sd_replayed_blocks, sdp->sd_found_blocks); 834 jd->jd_jid, jd->jd_replayed_blocks, jd->jd_found_blocks);
839} 835}
840 836
841static void databuf_lo_after_commit(struct gfs2_sbd *sdp, struct gfs2_trans *tr) 837static void databuf_lo_after_commit(struct gfs2_sbd *sdp, struct gfs2_trans *tr)
842{ 838{
843 struct list_head *head = &sdp->sd_log_le_databuf; 839 struct list_head *head;
844 struct gfs2_bufdata *bd; 840 struct gfs2_bufdata *bd;
845 841
846 if (tr == NULL) { 842 if (tr == NULL)
847 gfs2_assert(sdp, list_empty(head));
848 return; 843 return;
849 }
850 844
845 head = &tr->tr_databuf;
851 while (!list_empty(head)) { 846 while (!list_empty(head)) {
852 bd = list_entry(head->next, struct gfs2_bufdata, bd_list); 847 bd = list_entry(head->next, struct gfs2_bufdata, bd_list);
853 list_del_init(&bd->bd_list); 848 list_del_init(&bd->bd_list);
854 sdp->sd_log_num_databuf--;
855 gfs2_unpin(sdp, bd->bd_bh, tr); 849 gfs2_unpin(sdp, bd->bd_bh, tr);
856 } 850 }
857 gfs2_assert_warn(sdp, !sdp->sd_log_num_databuf);
858} 851}
859 852
860 853
diff --git a/fs/gfs2/lops.h b/fs/gfs2/lops.h
index 9ca2e6438419..a65a7ba32ffd 100644
--- a/fs/gfs2/lops.h
+++ b/fs/gfs2/lops.h
@@ -46,12 +46,13 @@ static inline unsigned int databuf_limit(struct gfs2_sbd *sdp)
46 return limit; 46 return limit;
47} 47}
48 48
49static inline void lops_before_commit(struct gfs2_sbd *sdp) 49static inline void lops_before_commit(struct gfs2_sbd *sdp,
50 struct gfs2_trans *tr)
50{ 51{
51 int x; 52 int x;
52 for (x = 0; gfs2_log_ops[x]; x++) 53 for (x = 0; gfs2_log_ops[x]; x++)
53 if (gfs2_log_ops[x]->lo_before_commit) 54 if (gfs2_log_ops[x]->lo_before_commit)
54 gfs2_log_ops[x]->lo_before_commit(sdp); 55 gfs2_log_ops[x]->lo_before_commit(sdp, tr);
55} 56}
56 57
57static inline void lops_after_commit(struct gfs2_sbd *sdp, 58static inline void lops_after_commit(struct gfs2_sbd *sdp,
diff --git a/fs/gfs2/main.c b/fs/gfs2/main.c
index c272e73063de..82b6ac829656 100644
--- a/fs/gfs2/main.c
+++ b/fs/gfs2/main.c
@@ -7,6 +7,8 @@
7 * of the GNU General Public License version 2. 7 * of the GNU General Public License version 2.
8 */ 8 */
9 9
10#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
11
10#include <linux/slab.h> 12#include <linux/slab.h>
11#include <linux/spinlock.h> 13#include <linux/spinlock.h>
12#include <linux/completion.h> 14#include <linux/completion.h>
@@ -165,7 +167,7 @@ static int __init init_gfs2_fs(void)
165 167
166 gfs2_register_debugfs(); 168 gfs2_register_debugfs();
167 169
168 printk("GFS2 installed\n"); 170 pr_info("GFS2 installed\n");
169 171
170 return 0; 172 return 0;
171 173
diff --git a/fs/gfs2/meta_io.c b/fs/gfs2/meta_io.c
index c7f24690ed05..2cf09b63a6b4 100644
--- a/fs/gfs2/meta_io.c
+++ b/fs/gfs2/meta_io.c
@@ -97,6 +97,11 @@ const struct address_space_operations gfs2_meta_aops = {
97 .releasepage = gfs2_releasepage, 97 .releasepage = gfs2_releasepage,
98}; 98};
99 99
100const struct address_space_operations gfs2_rgrp_aops = {
101 .writepage = gfs2_aspace_writepage,
102 .releasepage = gfs2_releasepage,
103};
104
100/** 105/**
101 * gfs2_getbuf - Get a buffer with a given address space 106 * gfs2_getbuf - Get a buffer with a given address space
102 * @gl: the glock 107 * @gl: the glock
@@ -267,15 +272,10 @@ void gfs2_remove_from_journal(struct buffer_head *bh, struct gfs2_trans *tr, int
267 trace_gfs2_pin(bd, 0); 272 trace_gfs2_pin(bd, 0);
268 atomic_dec(&sdp->sd_log_pinned); 273 atomic_dec(&sdp->sd_log_pinned);
269 list_del_init(&bd->bd_list); 274 list_del_init(&bd->bd_list);
270 if (meta) { 275 if (meta)
271 gfs2_assert_warn(sdp, sdp->sd_log_num_buf);
272 sdp->sd_log_num_buf--;
273 tr->tr_num_buf_rm++; 276 tr->tr_num_buf_rm++;
274 } else { 277 else
275 gfs2_assert_warn(sdp, sdp->sd_log_num_databuf);
276 sdp->sd_log_num_databuf--;
277 tr->tr_num_databuf_rm++; 278 tr->tr_num_databuf_rm++;
278 }
279 tr->tr_touched = 1; 279 tr->tr_touched = 1;
280 was_pinned = 1; 280 was_pinned = 1;
281 brelse(bh); 281 brelse(bh);
diff --git a/fs/gfs2/meta_io.h b/fs/gfs2/meta_io.h
index 4823b934208a..ac5d8027d335 100644
--- a/fs/gfs2/meta_io.h
+++ b/fs/gfs2/meta_io.h
@@ -38,12 +38,15 @@ static inline void gfs2_buffer_copy_tail(struct buffer_head *to_bh,
38} 38}
39 39
40extern const struct address_space_operations gfs2_meta_aops; 40extern const struct address_space_operations gfs2_meta_aops;
41extern const struct address_space_operations gfs2_rgrp_aops;
41 42
42static inline struct gfs2_sbd *gfs2_mapping2sbd(struct address_space *mapping) 43static inline struct gfs2_sbd *gfs2_mapping2sbd(struct address_space *mapping)
43{ 44{
44 struct inode *inode = mapping->host; 45 struct inode *inode = mapping->host;
45 if (mapping->a_ops == &gfs2_meta_aops) 46 if (mapping->a_ops == &gfs2_meta_aops)
46 return (((struct gfs2_glock *)mapping) - 1)->gl_sbd; 47 return (((struct gfs2_glock *)mapping) - 1)->gl_sbd;
48 else if (mapping->a_ops == &gfs2_rgrp_aops)
49 return container_of(mapping, struct gfs2_sbd, sd_aspace);
47 else 50 else
48 return inode->i_sb->s_fs_info; 51 return inode->i_sb->s_fs_info;
49} 52}
diff --git a/fs/gfs2/ops_fstype.c b/fs/gfs2/ops_fstype.c
index c6872d09561a..22f954051bb8 100644
--- a/fs/gfs2/ops_fstype.c
+++ b/fs/gfs2/ops_fstype.c
@@ -7,6 +7,8 @@
7 * of the GNU General Public License version 2. 7 * of the GNU General Public License version 2.
8 */ 8 */
9 9
10#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
11
10#include <linux/sched.h> 12#include <linux/sched.h>
11#include <linux/slab.h> 13#include <linux/slab.h>
12#include <linux/spinlock.h> 14#include <linux/spinlock.h>
@@ -104,7 +106,7 @@ static struct gfs2_sbd *init_sbd(struct super_block *sb)
104 mapping = &sdp->sd_aspace; 106 mapping = &sdp->sd_aspace;
105 107
106 address_space_init_once(mapping); 108 address_space_init_once(mapping);
107 mapping->a_ops = &gfs2_meta_aops; 109 mapping->a_ops = &gfs2_rgrp_aops;
108 mapping->host = sb->s_bdev->bd_inode; 110 mapping->host = sb->s_bdev->bd_inode;
109 mapping->flags = 0; 111 mapping->flags = 0;
110 mapping_set_gfp_mask(mapping, GFP_NOFS); 112 mapping_set_gfp_mask(mapping, GFP_NOFS);
@@ -114,9 +116,7 @@ static struct gfs2_sbd *init_sbd(struct super_block *sb)
114 116
115 spin_lock_init(&sdp->sd_log_lock); 117 spin_lock_init(&sdp->sd_log_lock);
116 atomic_set(&sdp->sd_log_pinned, 0); 118 atomic_set(&sdp->sd_log_pinned, 0);
117 INIT_LIST_HEAD(&sdp->sd_log_le_buf);
118 INIT_LIST_HEAD(&sdp->sd_log_le_revoke); 119 INIT_LIST_HEAD(&sdp->sd_log_le_revoke);
119 INIT_LIST_HEAD(&sdp->sd_log_le_databuf);
120 INIT_LIST_HEAD(&sdp->sd_log_le_ordered); 120 INIT_LIST_HEAD(&sdp->sd_log_le_ordered);
121 spin_lock_init(&sdp->sd_ordered_lock); 121 spin_lock_init(&sdp->sd_ordered_lock);
122 122
@@ -130,8 +130,6 @@ static struct gfs2_sbd *init_sbd(struct super_block *sb)
130 atomic_set(&sdp->sd_log_in_flight, 0); 130 atomic_set(&sdp->sd_log_in_flight, 0);
131 init_waitqueue_head(&sdp->sd_log_flush_wait); 131 init_waitqueue_head(&sdp->sd_log_flush_wait);
132 132
133 INIT_LIST_HEAD(&sdp->sd_revoke_list);
134
135 return sdp; 133 return sdp;
136} 134}
137 135
@@ -154,7 +152,7 @@ static int gfs2_check_sb(struct gfs2_sbd *sdp, int silent)
154 if (sb->sb_magic != GFS2_MAGIC || 152 if (sb->sb_magic != GFS2_MAGIC ||
155 sb->sb_type != GFS2_METATYPE_SB) { 153 sb->sb_type != GFS2_METATYPE_SB) {
156 if (!silent) 154 if (!silent)
157 printk(KERN_WARNING "GFS2: not a GFS2 filesystem\n"); 155 pr_warn("not a GFS2 filesystem\n");
158 return -EINVAL; 156 return -EINVAL;
159 } 157 }
160 158
@@ -176,7 +174,7 @@ static void end_bio_io_page(struct bio *bio, int error)
176 if (!error) 174 if (!error)
177 SetPageUptodate(page); 175 SetPageUptodate(page);
178 else 176 else
179 printk(KERN_WARNING "gfs2: error %d reading superblock\n", error); 177 pr_warn("error %d reading superblock\n", error);
180 unlock_page(page); 178 unlock_page(page);
181} 179}
182 180
@@ -519,67 +517,6 @@ out:
519 return ret; 517 return ret;
520} 518}
521 519
522/**
523 * map_journal_extents - create a reusable "extent" mapping from all logical
524 * blocks to all physical blocks for the given journal. This will save
525 * us time when writing journal blocks. Most journals will have only one
526 * extent that maps all their logical blocks. That's because gfs2.mkfs
527 * arranges the journal blocks sequentially to maximize performance.
528 * So the extent would map the first block for the entire file length.
529 * However, gfs2_jadd can happen while file activity is happening, so
530 * those journals may not be sequential. Less likely is the case where
531 * the users created their own journals by mounting the metafs and
532 * laying it out. But it's still possible. These journals might have
533 * several extents.
534 *
535 * TODO: This should be done in bigger chunks rather than one block at a time,
536 * but since it's only done at mount time, I'm not worried about the
537 * time it takes.
538 */
539static int map_journal_extents(struct gfs2_sbd *sdp)
540{
541 struct gfs2_jdesc *jd = sdp->sd_jdesc;
542 unsigned int lb;
543 u64 db, prev_db; /* logical block, disk block, prev disk block */
544 struct gfs2_inode *ip = GFS2_I(jd->jd_inode);
545 struct gfs2_journal_extent *jext = NULL;
546 struct buffer_head bh;
547 int rc = 0;
548
549 prev_db = 0;
550
551 for (lb = 0; lb < i_size_read(jd->jd_inode) >> sdp->sd_sb.sb_bsize_shift; lb++) {
552 bh.b_state = 0;
553 bh.b_blocknr = 0;
554 bh.b_size = 1 << ip->i_inode.i_blkbits;
555 rc = gfs2_block_map(jd->jd_inode, lb, &bh, 0);
556 db = bh.b_blocknr;
557 if (rc || !db) {
558 printk(KERN_INFO "GFS2 journal mapping error %d: lb="
559 "%u db=%llu\n", rc, lb, (unsigned long long)db);
560 break;
561 }
562 if (!prev_db || db != prev_db + 1) {
563 jext = kzalloc(sizeof(struct gfs2_journal_extent),
564 GFP_KERNEL);
565 if (!jext) {
566 printk(KERN_INFO "GFS2 error: out of memory "
567 "mapping journal extents.\n");
568 rc = -ENOMEM;
569 break;
570 }
571 jext->dblock = db;
572 jext->lblock = lb;
573 jext->blocks = 1;
574 list_add_tail(&jext->extent_list, &jd->extent_list);
575 } else {
576 jext->blocks++;
577 }
578 prev_db = db;
579 }
580 return rc;
581}
582
583static void gfs2_others_may_mount(struct gfs2_sbd *sdp) 520static void gfs2_others_may_mount(struct gfs2_sbd *sdp)
584{ 521{
585 char *message = "FIRSTMOUNT=Done"; 522 char *message = "FIRSTMOUNT=Done";
@@ -638,6 +575,8 @@ static int gfs2_jindex_hold(struct gfs2_sbd *sdp, struct gfs2_holder *ji_gh)
638 break; 575 break;
639 576
640 INIT_LIST_HEAD(&jd->extent_list); 577 INIT_LIST_HEAD(&jd->extent_list);
578 INIT_LIST_HEAD(&jd->jd_revoke_list);
579
641 INIT_WORK(&jd->jd_work, gfs2_recover_func); 580 INIT_WORK(&jd->jd_work, gfs2_recover_func);
642 jd->jd_inode = gfs2_lookupi(sdp->sd_jindex, &name, 1); 581 jd->jd_inode = gfs2_lookupi(sdp->sd_jindex, &name, 1);
643 if (!jd->jd_inode || IS_ERR(jd->jd_inode)) { 582 if (!jd->jd_inode || IS_ERR(jd->jd_inode)) {
@@ -781,7 +720,7 @@ static int init_journal(struct gfs2_sbd *sdp, int undo)
781 atomic_set(&sdp->sd_log_thresh2, 4*sdp->sd_jdesc->jd_blocks/5); 720 atomic_set(&sdp->sd_log_thresh2, 4*sdp->sd_jdesc->jd_blocks/5);
782 721
783 /* Map the extents for this journal's blocks */ 722 /* Map the extents for this journal's blocks */
784 map_journal_extents(sdp); 723 gfs2_map_journal_extents(sdp, sdp->sd_jdesc);
785 } 724 }
786 trace_gfs2_log_blocks(sdp, atomic_read(&sdp->sd_log_blks_free)); 725 trace_gfs2_log_blocks(sdp, atomic_read(&sdp->sd_log_blks_free));
787 726
@@ -1008,7 +947,7 @@ static int gfs2_lm_mount(struct gfs2_sbd *sdp, int silent)
1008 lm = &gfs2_dlm_ops; 947 lm = &gfs2_dlm_ops;
1009#endif 948#endif
1010 } else { 949 } else {
1011 printk(KERN_INFO "GFS2: can't find protocol %s\n", proto); 950 pr_info("can't find protocol %s\n", proto);
1012 return -ENOENT; 951 return -ENOENT;
1013 } 952 }
1014 953
@@ -1115,7 +1054,7 @@ static int fill_super(struct super_block *sb, struct gfs2_args *args, int silent
1115 1054
1116 sdp = init_sbd(sb); 1055 sdp = init_sbd(sb);
1117 if (!sdp) { 1056 if (!sdp) {
1118 printk(KERN_WARNING "GFS2: can't alloc struct gfs2_sbd\n"); 1057 pr_warn("can't alloc struct gfs2_sbd\n");
1119 return -ENOMEM; 1058 return -ENOMEM;
1120 } 1059 }
1121 sdp->sd_args = *args; 1060 sdp->sd_args = *args;
@@ -1363,7 +1302,7 @@ static struct dentry *gfs2_mount(struct file_system_type *fs_type, int flags,
1363 1302
1364 error = gfs2_mount_args(&args, data); 1303 error = gfs2_mount_args(&args, data);
1365 if (error) { 1304 if (error) {
1366 printk(KERN_WARNING "GFS2: can't parse mount arguments\n"); 1305 pr_warn("can't parse mount arguments\n");
1367 goto error_super; 1306 goto error_super;
1368 } 1307 }
1369 1308
@@ -1413,15 +1352,15 @@ static struct dentry *gfs2_mount_meta(struct file_system_type *fs_type,
1413 1352
1414 error = kern_path(dev_name, LOOKUP_FOLLOW, &path); 1353 error = kern_path(dev_name, LOOKUP_FOLLOW, &path);
1415 if (error) { 1354 if (error) {
1416 printk(KERN_WARNING "GFS2: path_lookup on %s returned error %d\n", 1355 pr_warn("path_lookup on %s returned error %d\n",
1417 dev_name, error); 1356 dev_name, error);
1418 return ERR_PTR(error); 1357 return ERR_PTR(error);
1419 } 1358 }
1420 s = sget(&gfs2_fs_type, test_gfs2_super, set_meta_super, flags, 1359 s = sget(&gfs2_fs_type, test_gfs2_super, set_meta_super, flags,
1421 path.dentry->d_inode->i_sb->s_bdev); 1360 path.dentry->d_inode->i_sb->s_bdev);
1422 path_put(&path); 1361 path_put(&path);
1423 if (IS_ERR(s)) { 1362 if (IS_ERR(s)) {
1424 printk(KERN_WARNING "GFS2: gfs2 mount does not exist\n"); 1363 pr_warn("gfs2 mount does not exist\n");
1425 return ERR_CAST(s); 1364 return ERR_CAST(s);
1426 } 1365 }
1427 if ((flags ^ s->s_flags) & MS_RDONLY) { 1366 if ((flags ^ s->s_flags) & MS_RDONLY) {
diff --git a/fs/gfs2/quota.c b/fs/gfs2/quota.c
index 8bec0e3192dd..c4effff7cf55 100644
--- a/fs/gfs2/quota.c
+++ b/fs/gfs2/quota.c
@@ -36,6 +36,8 @@
36 * the quota file, so it is not being constantly read. 36 * the quota file, so it is not being constantly read.
37 */ 37 */
38 38
39#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
40
39#include <linux/sched.h> 41#include <linux/sched.h>
40#include <linux/slab.h> 42#include <linux/slab.h>
41#include <linux/mm.h> 43#include <linux/mm.h>
@@ -330,6 +332,7 @@ static int slot_get(struct gfs2_quota_data *qd)
330 if (bit < sdp->sd_quota_slots) { 332 if (bit < sdp->sd_quota_slots) {
331 set_bit(bit, sdp->sd_quota_bitmap); 333 set_bit(bit, sdp->sd_quota_bitmap);
332 qd->qd_slot = bit; 334 qd->qd_slot = bit;
335 error = 0;
333out: 336out:
334 qd->qd_slot_count++; 337 qd->qd_slot_count++;
335 } 338 }
@@ -1081,10 +1084,10 @@ static int print_message(struct gfs2_quota_data *qd, char *type)
1081{ 1084{
1082 struct gfs2_sbd *sdp = qd->qd_gl->gl_sbd; 1085 struct gfs2_sbd *sdp = qd->qd_gl->gl_sbd;
1083 1086
1084 printk(KERN_INFO "GFS2: fsid=%s: quota %s for %s %u\n", 1087 fs_info(sdp, "quota %s for %s %u\n",
1085 sdp->sd_fsname, type, 1088 type,
1086 (qd->qd_id.type == USRQUOTA) ? "user" : "group", 1089 (qd->qd_id.type == USRQUOTA) ? "user" : "group",
1087 from_kqid(&init_user_ns, qd->qd_id)); 1090 from_kqid(&init_user_ns, qd->qd_id));
1088 1091
1089 return 0; 1092 return 0;
1090} 1093}
@@ -1242,14 +1245,13 @@ int gfs2_quota_init(struct gfs2_sbd *sdp)
1242 bm_size = DIV_ROUND_UP(sdp->sd_quota_slots, 8 * sizeof(unsigned long)); 1245 bm_size = DIV_ROUND_UP(sdp->sd_quota_slots, 8 * sizeof(unsigned long));
1243 bm_size *= sizeof(unsigned long); 1246 bm_size *= sizeof(unsigned long);
1244 error = -ENOMEM; 1247 error = -ENOMEM;
1245 sdp->sd_quota_bitmap = kmalloc(bm_size, GFP_NOFS|__GFP_NOWARN); 1248 sdp->sd_quota_bitmap = kzalloc(bm_size, GFP_NOFS | __GFP_NOWARN);
1246 if (sdp->sd_quota_bitmap == NULL) 1249 if (sdp->sd_quota_bitmap == NULL)
1247 sdp->sd_quota_bitmap = __vmalloc(bm_size, GFP_NOFS, PAGE_KERNEL); 1250 sdp->sd_quota_bitmap = __vmalloc(bm_size, GFP_NOFS |
1251 __GFP_ZERO, PAGE_KERNEL);
1248 if (!sdp->sd_quota_bitmap) 1252 if (!sdp->sd_quota_bitmap)
1249 return error; 1253 return error;
1250 1254
1251 memset(sdp->sd_quota_bitmap, 0, bm_size);
1252
1253 for (x = 0; x < blocks; x++) { 1255 for (x = 0; x < blocks; x++) {
1254 struct buffer_head *bh; 1256 struct buffer_head *bh;
1255 const struct gfs2_quota_change *qc; 1257 const struct gfs2_quota_change *qc;
diff --git a/fs/gfs2/recovery.c b/fs/gfs2/recovery.c
index 963b2d75200c..7ad4094d68c0 100644
--- a/fs/gfs2/recovery.c
+++ b/fs/gfs2/recovery.c
@@ -52,9 +52,9 @@ int gfs2_replay_read_block(struct gfs2_jdesc *jd, unsigned int blk,
52 return error; 52 return error;
53} 53}
54 54
55int gfs2_revoke_add(struct gfs2_sbd *sdp, u64 blkno, unsigned int where) 55int gfs2_revoke_add(struct gfs2_jdesc *jd, u64 blkno, unsigned int where)
56{ 56{
57 struct list_head *head = &sdp->sd_revoke_list; 57 struct list_head *head = &jd->jd_revoke_list;
58 struct gfs2_revoke_replay *rr; 58 struct gfs2_revoke_replay *rr;
59 int found = 0; 59 int found = 0;
60 60
@@ -81,13 +81,13 @@ int gfs2_revoke_add(struct gfs2_sbd *sdp, u64 blkno, unsigned int where)
81 return 1; 81 return 1;
82} 82}
83 83
84int gfs2_revoke_check(struct gfs2_sbd *sdp, u64 blkno, unsigned int where) 84int gfs2_revoke_check(struct gfs2_jdesc *jd, u64 blkno, unsigned int where)
85{ 85{
86 struct gfs2_revoke_replay *rr; 86 struct gfs2_revoke_replay *rr;
87 int wrap, a, b, revoke; 87 int wrap, a, b, revoke;
88 int found = 0; 88 int found = 0;
89 89
90 list_for_each_entry(rr, &sdp->sd_revoke_list, rr_list) { 90 list_for_each_entry(rr, &jd->jd_revoke_list, rr_list) {
91 if (rr->rr_blkno == blkno) { 91 if (rr->rr_blkno == blkno) {
92 found = 1; 92 found = 1;
93 break; 93 break;
@@ -97,17 +97,17 @@ int gfs2_revoke_check(struct gfs2_sbd *sdp, u64 blkno, unsigned int where)
97 if (!found) 97 if (!found)
98 return 0; 98 return 0;
99 99
100 wrap = (rr->rr_where < sdp->sd_replay_tail); 100 wrap = (rr->rr_where < jd->jd_replay_tail);
101 a = (sdp->sd_replay_tail < where); 101 a = (jd->jd_replay_tail < where);
102 b = (where < rr->rr_where); 102 b = (where < rr->rr_where);
103 revoke = (wrap) ? (a || b) : (a && b); 103 revoke = (wrap) ? (a || b) : (a && b);
104 104
105 return revoke; 105 return revoke;
106} 106}
107 107
108void gfs2_revoke_clean(struct gfs2_sbd *sdp) 108void gfs2_revoke_clean(struct gfs2_jdesc *jd)
109{ 109{
110 struct list_head *head = &sdp->sd_revoke_list; 110 struct list_head *head = &jd->jd_revoke_list;
111 struct gfs2_revoke_replay *rr; 111 struct gfs2_revoke_replay *rr;
112 112
113 while (!list_empty(head)) { 113 while (!list_empty(head)) {
diff --git a/fs/gfs2/recovery.h b/fs/gfs2/recovery.h
index 2226136c7647..6142836cce96 100644
--- a/fs/gfs2/recovery.h
+++ b/fs/gfs2/recovery.h
@@ -23,9 +23,9 @@ static inline void gfs2_replay_incr_blk(struct gfs2_sbd *sdp, unsigned int *blk)
23extern int gfs2_replay_read_block(struct gfs2_jdesc *jd, unsigned int blk, 23extern int gfs2_replay_read_block(struct gfs2_jdesc *jd, unsigned int blk,
24 struct buffer_head **bh); 24 struct buffer_head **bh);
25 25
26extern int gfs2_revoke_add(struct gfs2_sbd *sdp, u64 blkno, unsigned int where); 26extern int gfs2_revoke_add(struct gfs2_jdesc *jd, u64 blkno, unsigned int where);
27extern int gfs2_revoke_check(struct gfs2_sbd *sdp, u64 blkno, unsigned int where); 27extern int gfs2_revoke_check(struct gfs2_jdesc *jd, u64 blkno, unsigned int where);
28extern void gfs2_revoke_clean(struct gfs2_sbd *sdp); 28extern void gfs2_revoke_clean(struct gfs2_jdesc *jd);
29 29
30extern int gfs2_find_jhead(struct gfs2_jdesc *jd, 30extern int gfs2_find_jhead(struct gfs2_jdesc *jd,
31 struct gfs2_log_header_host *head); 31 struct gfs2_log_header_host *head);
diff --git a/fs/gfs2/rgrp.c b/fs/gfs2/rgrp.c
index a1da21349235..281a7716e3f3 100644
--- a/fs/gfs2/rgrp.c
+++ b/fs/gfs2/rgrp.c
@@ -7,6 +7,8 @@
7 * of the GNU General Public License version 2. 7 * of the GNU General Public License version 2.
8 */ 8 */
9 9
10#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
11
10#include <linux/slab.h> 12#include <linux/slab.h>
11#include <linux/spinlock.h> 13#include <linux/spinlock.h>
12#include <linux/completion.h> 14#include <linux/completion.h>
@@ -99,12 +101,12 @@ static inline void gfs2_setbit(const struct gfs2_rbm *rbm, bool do_clone,
99 cur_state = (*byte1 >> bit) & GFS2_BIT_MASK; 101 cur_state = (*byte1 >> bit) & GFS2_BIT_MASK;
100 102
101 if (unlikely(!valid_change[new_state * 4 + cur_state])) { 103 if (unlikely(!valid_change[new_state * 4 + cur_state])) {
102 printk(KERN_WARNING "GFS2: buf_blk = 0x%x old_state=%d, " 104 pr_warn("buf_blk = 0x%x old_state=%d, new_state=%d\n",
103 "new_state=%d\n", rbm->offset, cur_state, new_state); 105 rbm->offset, cur_state, new_state);
104 printk(KERN_WARNING "GFS2: rgrp=0x%llx bi_start=0x%x\n", 106 pr_warn("rgrp=0x%llx bi_start=0x%x\n",
105 (unsigned long long)rbm->rgd->rd_addr, bi->bi_start); 107 (unsigned long long)rbm->rgd->rd_addr, bi->bi_start);
106 printk(KERN_WARNING "GFS2: bi_offset=0x%x bi_len=0x%x\n", 108 pr_warn("bi_offset=0x%x bi_len=0x%x\n",
107 bi->bi_offset, bi->bi_len); 109 bi->bi_offset, bi->bi_len);
108 dump_stack(); 110 dump_stack();
109 gfs2_consist_rgrpd(rbm->rgd); 111 gfs2_consist_rgrpd(rbm->rgd);
110 return; 112 return;
@@ -736,11 +738,11 @@ void gfs2_clear_rgrpd(struct gfs2_sbd *sdp)
736 738
737static void gfs2_rindex_print(const struct gfs2_rgrpd *rgd) 739static void gfs2_rindex_print(const struct gfs2_rgrpd *rgd)
738{ 740{
739 printk(KERN_INFO " ri_addr = %llu\n", (unsigned long long)rgd->rd_addr); 741 pr_info("ri_addr = %llu\n", (unsigned long long)rgd->rd_addr);
740 printk(KERN_INFO " ri_length = %u\n", rgd->rd_length); 742 pr_info("ri_length = %u\n", rgd->rd_length);
741 printk(KERN_INFO " ri_data0 = %llu\n", (unsigned long long)rgd->rd_data0); 743 pr_info("ri_data0 = %llu\n", (unsigned long long)rgd->rd_data0);
742 printk(KERN_INFO " ri_data = %u\n", rgd->rd_data); 744 pr_info("ri_data = %u\n", rgd->rd_data);
743 printk(KERN_INFO " ri_bitbytes = %u\n", rgd->rd_bitbytes); 745 pr_info("ri_bitbytes = %u\n", rgd->rd_bitbytes);
744} 746}
745 747
746/** 748/**
@@ -1102,7 +1104,7 @@ static u32 count_unlinked(struct gfs2_rgrpd *rgd)
1102 * Returns: errno 1104 * Returns: errno
1103 */ 1105 */
1104 1106
1105int gfs2_rgrp_bh_get(struct gfs2_rgrpd *rgd) 1107static int gfs2_rgrp_bh_get(struct gfs2_rgrpd *rgd)
1106{ 1108{
1107 struct gfs2_sbd *sdp = rgd->rd_sbd; 1109 struct gfs2_sbd *sdp = rgd->rd_sbd;
1108 struct gfs2_glock *gl = rgd->rd_gl; 1110 struct gfs2_glock *gl = rgd->rd_gl;
@@ -1169,7 +1171,7 @@ fail:
1169 return error; 1171 return error;
1170} 1172}
1171 1173
1172int update_rgrp_lvb(struct gfs2_rgrpd *rgd) 1174static int update_rgrp_lvb(struct gfs2_rgrpd *rgd)
1173{ 1175{
1174 u32 rl_flags; 1176 u32 rl_flags;
1175 1177
@@ -2278,7 +2280,7 @@ int gfs2_alloc_blocks(struct gfs2_inode *ip, u64 *bn, unsigned int *nblocks,
2278 } 2280 }
2279 } 2281 }
2280 if (rbm.rgd->rd_free < *nblocks) { 2282 if (rbm.rgd->rd_free < *nblocks) {
2281 printk(KERN_WARNING "nblocks=%u\n", *nblocks); 2283 pr_warn("nblocks=%u\n", *nblocks);
2282 goto rgrp_error; 2284 goto rgrp_error;
2283 } 2285 }
2284 2286
@@ -2296,7 +2298,7 @@ int gfs2_alloc_blocks(struct gfs2_inode *ip, u64 *bn, unsigned int *nblocks,
2296 2298
2297 gfs2_statfs_change(sdp, 0, -(s64)*nblocks, dinode ? 1 : 0); 2299 gfs2_statfs_change(sdp, 0, -(s64)*nblocks, dinode ? 1 : 0);
2298 if (dinode) 2300 if (dinode)
2299 gfs2_trans_add_unrevoke(sdp, block, 1); 2301 gfs2_trans_add_unrevoke(sdp, block, *nblocks);
2300 2302
2301 gfs2_quota_change(ip, *nblocks, ip->i_inode.i_uid, ip->i_inode.i_gid); 2303 gfs2_quota_change(ip, *nblocks, ip->i_inode.i_uid, ip->i_inode.i_gid);
2302 2304
diff --git a/fs/gfs2/super.c b/fs/gfs2/super.c
index 24410cd9a82a..033ee975a895 100644
--- a/fs/gfs2/super.c
+++ b/fs/gfs2/super.c
@@ -7,6 +7,8 @@
7 * of the GNU General Public License version 2. 7 * of the GNU General Public License version 2.
8 */ 8 */
9 9
10#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
11
10#include <linux/bio.h> 12#include <linux/bio.h>
11#include <linux/sched.h> 13#include <linux/sched.h>
12#include <linux/slab.h> 14#include <linux/slab.h>
@@ -175,8 +177,7 @@ int gfs2_mount_args(struct gfs2_args *args, char *options)
175 break; 177 break;
176 case Opt_debug: 178 case Opt_debug:
177 if (args->ar_errors == GFS2_ERRORS_PANIC) { 179 if (args->ar_errors == GFS2_ERRORS_PANIC) {
178 printk(KERN_WARNING "GFS2: -o debug and -o errors=panic " 180 pr_warn("-o debug and -o errors=panic are mutually exclusive\n");
179 "are mutually exclusive.\n");
180 return -EINVAL; 181 return -EINVAL;
181 } 182 }
182 args->ar_debug = 1; 183 args->ar_debug = 1;
@@ -228,21 +229,21 @@ int gfs2_mount_args(struct gfs2_args *args, char *options)
228 case Opt_commit: 229 case Opt_commit:
229 rv = match_int(&tmp[0], &args->ar_commit); 230 rv = match_int(&tmp[0], &args->ar_commit);
230 if (rv || args->ar_commit <= 0) { 231 if (rv || args->ar_commit <= 0) {
231 printk(KERN_WARNING "GFS2: commit mount option requires a positive numeric argument\n"); 232 pr_warn("commit mount option requires a positive numeric argument\n");
232 return rv ? rv : -EINVAL; 233 return rv ? rv : -EINVAL;
233 } 234 }
234 break; 235 break;
235 case Opt_statfs_quantum: 236 case Opt_statfs_quantum:
236 rv = match_int(&tmp[0], &args->ar_statfs_quantum); 237 rv = match_int(&tmp[0], &args->ar_statfs_quantum);
237 if (rv || args->ar_statfs_quantum < 0) { 238 if (rv || args->ar_statfs_quantum < 0) {
238 printk(KERN_WARNING "GFS2: statfs_quantum mount option requires a non-negative numeric argument\n"); 239 pr_warn("statfs_quantum mount option requires a non-negative numeric argument\n");
239 return rv ? rv : -EINVAL; 240 return rv ? rv : -EINVAL;
240 } 241 }
241 break; 242 break;
242 case Opt_quota_quantum: 243 case Opt_quota_quantum:
243 rv = match_int(&tmp[0], &args->ar_quota_quantum); 244 rv = match_int(&tmp[0], &args->ar_quota_quantum);
244 if (rv || args->ar_quota_quantum <= 0) { 245 if (rv || args->ar_quota_quantum <= 0) {
245 printk(KERN_WARNING "GFS2: quota_quantum mount option requires a positive numeric argument\n"); 246 pr_warn("quota_quantum mount option requires a positive numeric argument\n");
246 return rv ? rv : -EINVAL; 247 return rv ? rv : -EINVAL;
247 } 248 }
248 break; 249 break;
@@ -250,7 +251,7 @@ int gfs2_mount_args(struct gfs2_args *args, char *options)
250 rv = match_int(&tmp[0], &args->ar_statfs_percent); 251 rv = match_int(&tmp[0], &args->ar_statfs_percent);
251 if (rv || args->ar_statfs_percent < 0 || 252 if (rv || args->ar_statfs_percent < 0 ||
252 args->ar_statfs_percent > 100) { 253 args->ar_statfs_percent > 100) {
253 printk(KERN_WARNING "statfs_percent mount option requires a numeric argument between 0 and 100\n"); 254 pr_warn("statfs_percent mount option requires a numeric argument between 0 and 100\n");
254 return rv ? rv : -EINVAL; 255 return rv ? rv : -EINVAL;
255 } 256 }
256 break; 257 break;
@@ -259,8 +260,7 @@ int gfs2_mount_args(struct gfs2_args *args, char *options)
259 break; 260 break;
260 case Opt_err_panic: 261 case Opt_err_panic:
261 if (args->ar_debug) { 262 if (args->ar_debug) {
262 printk(KERN_WARNING "GFS2: -o debug and -o errors=panic " 263 pr_warn("-o debug and -o errors=panic are mutually exclusive\n");
263 "are mutually exclusive.\n");
264 return -EINVAL; 264 return -EINVAL;
265 } 265 }
266 args->ar_errors = GFS2_ERRORS_PANIC; 266 args->ar_errors = GFS2_ERRORS_PANIC;
@@ -279,7 +279,7 @@ int gfs2_mount_args(struct gfs2_args *args, char *options)
279 break; 279 break;
280 case Opt_error: 280 case Opt_error:
281 default: 281 default:
282 printk(KERN_WARNING "GFS2: invalid mount option: %s\n", o); 282 pr_warn("invalid mount option: %s\n", o);
283 return -EINVAL; 283 return -EINVAL;
284 } 284 }
285 } 285 }
@@ -295,9 +295,8 @@ int gfs2_mount_args(struct gfs2_args *args, char *options)
295 295
296void gfs2_jindex_free(struct gfs2_sbd *sdp) 296void gfs2_jindex_free(struct gfs2_sbd *sdp)
297{ 297{
298 struct list_head list, *head; 298 struct list_head list;
299 struct gfs2_jdesc *jd; 299 struct gfs2_jdesc *jd;
300 struct gfs2_journal_extent *jext;
301 300
302 spin_lock(&sdp->sd_jindex_spin); 301 spin_lock(&sdp->sd_jindex_spin);
303 list_add(&list, &sdp->sd_jindex_list); 302 list_add(&list, &sdp->sd_jindex_list);
@@ -307,14 +306,7 @@ void gfs2_jindex_free(struct gfs2_sbd *sdp)
307 306
308 while (!list_empty(&list)) { 307 while (!list_empty(&list)) {
309 jd = list_entry(list.next, struct gfs2_jdesc, jd_list); 308 jd = list_entry(list.next, struct gfs2_jdesc, jd_list);
310 head = &jd->extent_list; 309 gfs2_free_journal_extents(jd);
311 while (!list_empty(head)) {
312 jext = list_entry(head->next,
313 struct gfs2_journal_extent,
314 extent_list);
315 list_del(&jext->extent_list);
316 kfree(jext);
317 }
318 list_del(&jd->jd_list); 310 list_del(&jd->jd_list);
319 iput(jd->jd_inode); 311 iput(jd->jd_inode);
320 kfree(jd); 312 kfree(jd);
@@ -1256,7 +1248,7 @@ static int gfs2_drop_inode(struct inode *inode)
1256{ 1248{
1257 struct gfs2_inode *ip = GFS2_I(inode); 1249 struct gfs2_inode *ip = GFS2_I(inode);
1258 1250
1259 if (inode->i_nlink) { 1251 if (!test_bit(GIF_FREE_VFS_INODE, &ip->i_flags) && inode->i_nlink) {
1260 struct gfs2_glock *gl = ip->i_iopen_gh.gh_gl; 1252 struct gfs2_glock *gl = ip->i_iopen_gh.gh_gl;
1261 if (gl && test_bit(GLF_DEMOTE, &gl->gl_flags)) 1253 if (gl && test_bit(GLF_DEMOTE, &gl->gl_flags))
1262 clear_nlink(inode); 1254 clear_nlink(inode);
@@ -1471,6 +1463,11 @@ static void gfs2_evict_inode(struct inode *inode)
1471 struct gfs2_holder gh; 1463 struct gfs2_holder gh;
1472 int error; 1464 int error;
1473 1465
1466 if (test_bit(GIF_FREE_VFS_INODE, &ip->i_flags)) {
1467 clear_inode(inode);
1468 return;
1469 }
1470
1474 if (inode->i_nlink || (sb->s_flags & MS_RDONLY)) 1471 if (inode->i_nlink || (sb->s_flags & MS_RDONLY))
1475 goto out; 1472 goto out;
1476 1473
diff --git a/fs/gfs2/sys.c b/fs/gfs2/sys.c
index d09f6edda0ff..de25d5577e5d 100644
--- a/fs/gfs2/sys.c
+++ b/fs/gfs2/sys.c
@@ -7,6 +7,8 @@
7 * of the GNU General Public License version 2. 7 * of the GNU General Public License version 2.
8 */ 8 */
9 9
10#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
11
10#include <linux/sched.h> 12#include <linux/sched.h>
11#include <linux/spinlock.h> 13#include <linux/spinlock.h>
12#include <linux/completion.h> 14#include <linux/completion.h>
@@ -138,9 +140,8 @@ static ssize_t withdraw_store(struct gfs2_sbd *sdp, const char *buf, size_t len)
138 if (simple_strtol(buf, NULL, 0) != 1) 140 if (simple_strtol(buf, NULL, 0) != 1)
139 return -EINVAL; 141 return -EINVAL;
140 142
141 gfs2_lm_withdraw(sdp, 143 gfs2_lm_withdraw(sdp, "withdrawing from cluster at user's request\n");
142 "GFS2: fsid=%s: withdrawing from cluster at user's request\n", 144
143 sdp->sd_fsname);
144 return len; 145 return len;
145} 146}
146 147
diff --git a/fs/gfs2/trans.c b/fs/gfs2/trans.c
index 2b20d7046bf3..bead90d27bad 100644
--- a/fs/gfs2/trans.c
+++ b/fs/gfs2/trans.c
@@ -7,6 +7,8 @@
7 * of the GNU General Public License version 2. 7 * of the GNU General Public License version 2.
8 */ 8 */
9 9
10#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
11
10#include <linux/sched.h> 12#include <linux/sched.h>
11#include <linux/slab.h> 13#include <linux/slab.h>
12#include <linux/spinlock.h> 14#include <linux/spinlock.h>
@@ -51,6 +53,9 @@ int gfs2_trans_begin(struct gfs2_sbd *sdp, unsigned int blocks,
51 if (revokes) 53 if (revokes)
52 tr->tr_reserved += gfs2_struct2blk(sdp, revokes, 54 tr->tr_reserved += gfs2_struct2blk(sdp, revokes,
53 sizeof(u64)); 55 sizeof(u64));
56 INIT_LIST_HEAD(&tr->tr_databuf);
57 INIT_LIST_HEAD(&tr->tr_buf);
58
54 sb_start_intwrite(sdp->sd_vfs); 59 sb_start_intwrite(sdp->sd_vfs);
55 gfs2_holder_init(sdp->sd_trans_gl, LM_ST_SHARED, 0, &tr->tr_t_gh); 60 gfs2_holder_init(sdp->sd_trans_gl, LM_ST_SHARED, 0, &tr->tr_t_gh);
56 61
@@ -96,14 +101,13 @@ static void gfs2_log_release(struct gfs2_sbd *sdp, unsigned int blks)
96 101
97static void gfs2_print_trans(const struct gfs2_trans *tr) 102static void gfs2_print_trans(const struct gfs2_trans *tr)
98{ 103{
99 printk(KERN_WARNING "GFS2: Transaction created at: %pSR\n", 104 pr_warn("Transaction created at: %pSR\n", (void *)tr->tr_ip);
100 (void *)tr->tr_ip); 105 pr_warn("blocks=%u revokes=%u reserved=%u touched=%u\n",
101 printk(KERN_WARNING "GFS2: blocks=%u revokes=%u reserved=%u touched=%d\n", 106 tr->tr_blocks, tr->tr_revokes, tr->tr_reserved, tr->tr_touched);
102 tr->tr_blocks, tr->tr_revokes, tr->tr_reserved, tr->tr_touched); 107 pr_warn("Buf %u/%u Databuf %u/%u Revoke %u/%u\n",
103 printk(KERN_WARNING "GFS2: Buf %u/%u Databuf %u/%u Revoke %u/%u\n", 108 tr->tr_num_buf_new, tr->tr_num_buf_rm,
104 tr->tr_num_buf_new, tr->tr_num_buf_rm, 109 tr->tr_num_databuf_new, tr->tr_num_databuf_rm,
105 tr->tr_num_databuf_new, tr->tr_num_databuf_rm, 110 tr->tr_num_revoke, tr->tr_num_revoke_rm);
106 tr->tr_num_revoke, tr->tr_num_revoke_rm);
107} 111}
108 112
109void gfs2_trans_end(struct gfs2_sbd *sdp) 113void gfs2_trans_end(struct gfs2_sbd *sdp)
@@ -210,8 +214,7 @@ void gfs2_trans_add_data(struct gfs2_glock *gl, struct buffer_head *bh)
210 set_bit(GLF_DIRTY, &bd->bd_gl->gl_flags); 214 set_bit(GLF_DIRTY, &bd->bd_gl->gl_flags);
211 gfs2_pin(sdp, bd->bd_bh); 215 gfs2_pin(sdp, bd->bd_bh);
212 tr->tr_num_databuf_new++; 216 tr->tr_num_databuf_new++;
213 sdp->sd_log_num_databuf++; 217 list_add_tail(&bd->bd_list, &tr->tr_databuf);
214 list_add_tail(&bd->bd_list, &sdp->sd_log_le_databuf);
215 } 218 }
216 gfs2_log_unlock(sdp); 219 gfs2_log_unlock(sdp);
217 unlock_buffer(bh); 220 unlock_buffer(bh);
@@ -230,16 +233,14 @@ static void meta_lo_add(struct gfs2_sbd *sdp, struct gfs2_bufdata *bd)
230 set_bit(GLF_DIRTY, &bd->bd_gl->gl_flags); 233 set_bit(GLF_DIRTY, &bd->bd_gl->gl_flags);
231 mh = (struct gfs2_meta_header *)bd->bd_bh->b_data; 234 mh = (struct gfs2_meta_header *)bd->bd_bh->b_data;
232 if (unlikely(mh->mh_magic != cpu_to_be32(GFS2_MAGIC))) { 235 if (unlikely(mh->mh_magic != cpu_to_be32(GFS2_MAGIC))) {
233 printk(KERN_ERR 236 pr_err("Attempting to add uninitialised block to journal (inplace block=%lld)\n",
234 "Attempting to add uninitialised block to journal (inplace block=%lld)\n",
235 (unsigned long long)bd->bd_bh->b_blocknr); 237 (unsigned long long)bd->bd_bh->b_blocknr);
236 BUG(); 238 BUG();
237 } 239 }
238 gfs2_pin(sdp, bd->bd_bh); 240 gfs2_pin(sdp, bd->bd_bh);
239 mh->__pad0 = cpu_to_be64(0); 241 mh->__pad0 = cpu_to_be64(0);
240 mh->mh_jid = cpu_to_be32(sdp->sd_jdesc->jd_jid); 242 mh->mh_jid = cpu_to_be32(sdp->sd_jdesc->jd_jid);
241 sdp->sd_log_num_buf++; 243 list_add(&bd->bd_list, &tr->tr_buf);
242 list_add(&bd->bd_list, &sdp->sd_log_le_buf);
243 tr->tr_num_buf_new++; 244 tr->tr_num_buf_new++;
244} 245}
245 246
diff --git a/fs/gfs2/util.c b/fs/gfs2/util.c
index f7109f689e61..86d2035ac669 100644
--- a/fs/gfs2/util.c
+++ b/fs/gfs2/util.c
@@ -7,6 +7,8 @@
7 * of the GNU General Public License version 2. 7 * of the GNU General Public License version 2.
8 */ 8 */
9 9
10#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
11
10#include <linux/spinlock.h> 12#include <linux/spinlock.h>
11#include <linux/completion.h> 13#include <linux/completion.h>
12#include <linux/buffer_head.h> 14#include <linux/buffer_head.h>
@@ -30,22 +32,27 @@ mempool_t *gfs2_page_pool __read_mostly;
30 32
31void gfs2_assert_i(struct gfs2_sbd *sdp) 33void gfs2_assert_i(struct gfs2_sbd *sdp)
32{ 34{
33 printk(KERN_EMERG "GFS2: fsid=%s: fatal assertion failed\n", 35 fs_emerg(sdp, "fatal assertion failed\n");
34 sdp->sd_fsname);
35} 36}
36 37
37int gfs2_lm_withdraw(struct gfs2_sbd *sdp, char *fmt, ...) 38int gfs2_lm_withdraw(struct gfs2_sbd *sdp, const char *fmt, ...)
38{ 39{
39 struct lm_lockstruct *ls = &sdp->sd_lockstruct; 40 struct lm_lockstruct *ls = &sdp->sd_lockstruct;
40 const struct lm_lockops *lm = ls->ls_ops; 41 const struct lm_lockops *lm = ls->ls_ops;
41 va_list args; 42 va_list args;
43 struct va_format vaf;
42 44
43 if (sdp->sd_args.ar_errors == GFS2_ERRORS_WITHDRAW && 45 if (sdp->sd_args.ar_errors == GFS2_ERRORS_WITHDRAW &&
44 test_and_set_bit(SDF_SHUTDOWN, &sdp->sd_flags)) 46 test_and_set_bit(SDF_SHUTDOWN, &sdp->sd_flags))
45 return 0; 47 return 0;
46 48
47 va_start(args, fmt); 49 va_start(args, fmt);
48 vprintk(fmt, args); 50
51 vaf.fmt = fmt;
52 vaf.va = &args;
53
54 fs_err(sdp, "%pV", &vaf);
55
49 va_end(args); 56 va_end(args);
50 57
51 if (sdp->sd_args.ar_errors == GFS2_ERRORS_WITHDRAW) { 58 if (sdp->sd_args.ar_errors == GFS2_ERRORS_WITHDRAW) {
@@ -66,7 +73,7 @@ int gfs2_lm_withdraw(struct gfs2_sbd *sdp, char *fmt, ...)
66 } 73 }
67 74
68 if (sdp->sd_args.ar_errors == GFS2_ERRORS_PANIC) 75 if (sdp->sd_args.ar_errors == GFS2_ERRORS_PANIC)
69 panic("GFS2: fsid=%s: panic requested.\n", sdp->sd_fsname); 76 panic("GFS2: fsid=%s: panic requested\n", sdp->sd_fsname);
70 77
71 return -1; 78 return -1;
72} 79}
@@ -82,10 +89,9 @@ int gfs2_assert_withdraw_i(struct gfs2_sbd *sdp, char *assertion,
82{ 89{
83 int me; 90 int me;
84 me = gfs2_lm_withdraw(sdp, 91 me = gfs2_lm_withdraw(sdp,
85 "GFS2: fsid=%s: fatal: assertion \"%s\" failed\n" 92 "fatal: assertion \"%s\" failed\n"
86 "GFS2: fsid=%s: function = %s, file = %s, line = %u\n", 93 " function = %s, file = %s, line = %u\n",
87 sdp->sd_fsname, assertion, 94 assertion, function, file, line);
88 sdp->sd_fsname, function, file, line);
89 dump_stack(); 95 dump_stack();
90 return (me) ? -1 : -2; 96 return (me) ? -1 : -2;
91} 97}
@@ -105,11 +111,8 @@ int gfs2_assert_warn_i(struct gfs2_sbd *sdp, char *assertion,
105 return -2; 111 return -2;
106 112
107 if (sdp->sd_args.ar_errors == GFS2_ERRORS_WITHDRAW) 113 if (sdp->sd_args.ar_errors == GFS2_ERRORS_WITHDRAW)
108 printk(KERN_WARNING 114 fs_warn(sdp, "warning: assertion \"%s\" failed at function = %s, file = %s, line = %u\n",
109 "GFS2: fsid=%s: warning: assertion \"%s\" failed\n" 115 assertion, function, file, line);
110 "GFS2: fsid=%s: function = %s, file = %s, line = %u\n",
111 sdp->sd_fsname, assertion,
112 sdp->sd_fsname, function, file, line);
113 116
114 if (sdp->sd_args.ar_debug) 117 if (sdp->sd_args.ar_debug)
115 BUG(); 118 BUG();
@@ -138,10 +141,8 @@ int gfs2_consist_i(struct gfs2_sbd *sdp, int cluster_wide, const char *function,
138{ 141{
139 int rv; 142 int rv;
140 rv = gfs2_lm_withdraw(sdp, 143 rv = gfs2_lm_withdraw(sdp,
141 "GFS2: fsid=%s: fatal: filesystem consistency error\n" 144 "fatal: filesystem consistency error - function = %s, file = %s, line = %u\n",
142 "GFS2: fsid=%s: function = %s, file = %s, line = %u\n", 145 function, file, line);
143 sdp->sd_fsname,
144 sdp->sd_fsname, function, file, line);
145 return rv; 146 return rv;
146} 147}
147 148
@@ -157,13 +158,12 @@ int gfs2_consist_inode_i(struct gfs2_inode *ip, int cluster_wide,
157 struct gfs2_sbd *sdp = GFS2_SB(&ip->i_inode); 158 struct gfs2_sbd *sdp = GFS2_SB(&ip->i_inode);
158 int rv; 159 int rv;
159 rv = gfs2_lm_withdraw(sdp, 160 rv = gfs2_lm_withdraw(sdp,
160 "GFS2: fsid=%s: fatal: filesystem consistency error\n" 161 "fatal: filesystem consistency error\n"
161 "GFS2: fsid=%s: inode = %llu %llu\n" 162 " inode = %llu %llu\n"
162 "GFS2: fsid=%s: function = %s, file = %s, line = %u\n", 163 " function = %s, file = %s, line = %u\n",
163 sdp->sd_fsname, 164 (unsigned long long)ip->i_no_formal_ino,
164 sdp->sd_fsname, (unsigned long long)ip->i_no_formal_ino, 165 (unsigned long long)ip->i_no_addr,
165 (unsigned long long)ip->i_no_addr, 166 function, file, line);
166 sdp->sd_fsname, function, file, line);
167 return rv; 167 return rv;
168} 168}
169 169
@@ -179,12 +179,11 @@ int gfs2_consist_rgrpd_i(struct gfs2_rgrpd *rgd, int cluster_wide,
179 struct gfs2_sbd *sdp = rgd->rd_sbd; 179 struct gfs2_sbd *sdp = rgd->rd_sbd;
180 int rv; 180 int rv;
181 rv = gfs2_lm_withdraw(sdp, 181 rv = gfs2_lm_withdraw(sdp,
182 "GFS2: fsid=%s: fatal: filesystem consistency error\n" 182 "fatal: filesystem consistency error\n"
183 "GFS2: fsid=%s: RG = %llu\n" 183 " RG = %llu\n"
184 "GFS2: fsid=%s: function = %s, file = %s, line = %u\n", 184 " function = %s, file = %s, line = %u\n",
185 sdp->sd_fsname, 185 (unsigned long long)rgd->rd_addr,
186 sdp->sd_fsname, (unsigned long long)rgd->rd_addr, 186 function, file, line);
187 sdp->sd_fsname, function, file, line);
188 return rv; 187 return rv;
189} 188}
190 189
@@ -200,12 +199,11 @@ int gfs2_meta_check_ii(struct gfs2_sbd *sdp, struct buffer_head *bh,
200{ 199{
201 int me; 200 int me;
202 me = gfs2_lm_withdraw(sdp, 201 me = gfs2_lm_withdraw(sdp,
203 "GFS2: fsid=%s: fatal: invalid metadata block\n" 202 "fatal: invalid metadata block\n"
204 "GFS2: fsid=%s: bh = %llu (%s)\n" 203 " bh = %llu (%s)\n"
205 "GFS2: fsid=%s: function = %s, file = %s, line = %u\n", 204 " function = %s, file = %s, line = %u\n",
206 sdp->sd_fsname, 205 (unsigned long long)bh->b_blocknr, type,
207 sdp->sd_fsname, (unsigned long long)bh->b_blocknr, type, 206 function, file, line);
208 sdp->sd_fsname, function, file, line);
209 return (me) ? -1 : -2; 207 return (me) ? -1 : -2;
210} 208}
211 209
@@ -221,12 +219,11 @@ int gfs2_metatype_check_ii(struct gfs2_sbd *sdp, struct buffer_head *bh,
221{ 219{
222 int me; 220 int me;
223 me = gfs2_lm_withdraw(sdp, 221 me = gfs2_lm_withdraw(sdp,
224 "GFS2: fsid=%s: fatal: invalid metadata block\n" 222 "fatal: invalid metadata block\n"
225 "GFS2: fsid=%s: bh = %llu (type: exp=%u, found=%u)\n" 223 " bh = %llu (type: exp=%u, found=%u)\n"
226 "GFS2: fsid=%s: function = %s, file = %s, line = %u\n", 224 " function = %s, file = %s, line = %u\n",
227 sdp->sd_fsname, 225 (unsigned long long)bh->b_blocknr, type, t,
228 sdp->sd_fsname, (unsigned long long)bh->b_blocknr, type, t, 226 function, file, line);
229 sdp->sd_fsname, function, file, line);
230 return (me) ? -1 : -2; 227 return (me) ? -1 : -2;
231} 228}
232 229
@@ -241,10 +238,9 @@ int gfs2_io_error_i(struct gfs2_sbd *sdp, const char *function, char *file,
241{ 238{
242 int rv; 239 int rv;
243 rv = gfs2_lm_withdraw(sdp, 240 rv = gfs2_lm_withdraw(sdp,
244 "GFS2: fsid=%s: fatal: I/O error\n" 241 "fatal: I/O error\n"
245 "GFS2: fsid=%s: function = %s, file = %s, line = %u\n", 242 " function = %s, file = %s, line = %u\n",
246 sdp->sd_fsname, 243 function, file, line);
247 sdp->sd_fsname, function, file, line);
248 return rv; 244 return rv;
249} 245}
250 246
@@ -259,12 +255,11 @@ int gfs2_io_error_bh_i(struct gfs2_sbd *sdp, struct buffer_head *bh,
259{ 255{
260 int rv; 256 int rv;
261 rv = gfs2_lm_withdraw(sdp, 257 rv = gfs2_lm_withdraw(sdp,
262 "GFS2: fsid=%s: fatal: I/O error\n" 258 "fatal: I/O error\n"
263 "GFS2: fsid=%s: block = %llu\n" 259 " block = %llu\n"
264 "GFS2: fsid=%s: function = %s, file = %s, line = %u\n", 260 " function = %s, file = %s, line = %u\n",
265 sdp->sd_fsname, 261 (unsigned long long)bh->b_blocknr,
266 sdp->sd_fsname, (unsigned long long)bh->b_blocknr, 262 function, file, line);
267 sdp->sd_fsname, function, file, line);
268 return rv; 263 return rv;
269} 264}
270 265
diff --git a/fs/gfs2/util.h b/fs/gfs2/util.h
index b7ffb09b99ea..cbdcbdf39614 100644
--- a/fs/gfs2/util.h
+++ b/fs/gfs2/util.h
@@ -10,22 +10,23 @@
10#ifndef __UTIL_DOT_H__ 10#ifndef __UTIL_DOT_H__
11#define __UTIL_DOT_H__ 11#define __UTIL_DOT_H__
12 12
13#ifdef pr_fmt
14#undef pr_fmt
15#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
16#endif
17
13#include <linux/mempool.h> 18#include <linux/mempool.h>
14 19
15#include "incore.h" 20#include "incore.h"
16 21
17#define fs_printk(level, fs, fmt, arg...) \ 22#define fs_emerg(fs, fmt, ...) \
18 printk(level "GFS2: fsid=%s: " fmt , (fs)->sd_fsname , ## arg) 23 pr_emerg("fsid=%s: " fmt, (fs)->sd_fsname, ##__VA_ARGS__)
19 24#define fs_warn(fs, fmt, ...) \
20#define fs_info(fs, fmt, arg...) \ 25 pr_warn("fsid=%s: " fmt, (fs)->sd_fsname, ##__VA_ARGS__)
21 fs_printk(KERN_INFO , fs , fmt , ## arg) 26#define fs_err(fs, fmt, ...) \
22 27 pr_err("fsid=%s: " fmt, (fs)->sd_fsname, ##__VA_ARGS__)
23#define fs_warn(fs, fmt, arg...) \ 28#define fs_info(fs, fmt, ...) \
24 fs_printk(KERN_WARNING , fs , fmt , ## arg) 29 pr_info("fsid=%s: " fmt, (fs)->sd_fsname, ##__VA_ARGS__)
25
26#define fs_err(fs, fmt, arg...) \
27 fs_printk(KERN_ERR, fs , fmt , ## arg)
28
29 30
30void gfs2_assert_i(struct gfs2_sbd *sdp); 31void gfs2_assert_i(struct gfs2_sbd *sdp);
31 32
@@ -85,7 +86,7 @@ static inline int gfs2_meta_check(struct gfs2_sbd *sdp,
85 struct gfs2_meta_header *mh = (struct gfs2_meta_header *)bh->b_data; 86 struct gfs2_meta_header *mh = (struct gfs2_meta_header *)bh->b_data;
86 u32 magic = be32_to_cpu(mh->mh_magic); 87 u32 magic = be32_to_cpu(mh->mh_magic);
87 if (unlikely(magic != GFS2_MAGIC)) { 88 if (unlikely(magic != GFS2_MAGIC)) {
88 printk(KERN_ERR "GFS2: Magic number missing at %llu\n", 89 pr_err("Magic number missing at %llu\n",
89 (unsigned long long)bh->b_blocknr); 90 (unsigned long long)bh->b_blocknr);
90 return -EIO; 91 return -EIO;
91 } 92 }
@@ -164,7 +165,7 @@ static inline unsigned int gfs2_tune_get_i(struct gfs2_tune *gt,
164#define gfs2_tune_get(sdp, field) \ 165#define gfs2_tune_get(sdp, field) \
165gfs2_tune_get_i(&(sdp)->sd_tune, &(sdp)->sd_tune.field) 166gfs2_tune_get_i(&(sdp)->sd_tune, &(sdp)->sd_tune.field)
166 167
167int gfs2_lm_withdraw(struct gfs2_sbd *sdp, char *fmt, ...); 168__printf(2, 3)
169int gfs2_lm_withdraw(struct gfs2_sbd *sdp, const char *fmt, ...);
168 170
169#endif /* __UTIL_DOT_H__ */ 171#endif /* __UTIL_DOT_H__ */
170