diff options
author | Christoph Hellwig <hch@lst.de> | 2010-06-04 05:29:56 -0400 |
---|---|---|
committer | Al Viro <viro@zeniv.linux.org.uk> | 2010-08-09 16:47:31 -0400 |
commit | f4e420dc423148fba637af1ab618fa8896dfb2d6 (patch) | |
tree | df0e81f5f4b8448dd6b3929e5537dcc46e7d7dde /fs/nilfs2 | |
parent | 282dc178849882289d30e58b54be6b2799b351aa (diff) |
clean up write_begin usage for directories in pagecache
For filesystem that implement directories in pagecache we call
block_write_begin with an already allocated page for this code, while the
normal regular file write path uses the default block_write_begin behaviour.
Get rid of the __foofs_write_begin helper and opencode the normal write_begin
call in foofs_write_begin, while adding a new foofs_prepare_chunk helper for
the directory code. The added benefit is that foofs_prepare_chunk has
a much saner calling convention.
Note that the interruptible flag passed into block_write_begin is always
ignored if we already pass in a page (see next patch for details), and
we never were doing truncations of exessive blocks for this case either so we
can switch directly to block_write_begin_newtrunc.
Signed-off-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
Diffstat (limited to 'fs/nilfs2')
-rw-r--r-- | fs/nilfs2/dir.c | 26 |
1 files changed, 7 insertions, 19 deletions
diff --git a/fs/nilfs2/dir.c b/fs/nilfs2/dir.c index 85c89dfc71f0..fc2bcfa599a3 100644 --- a/fs/nilfs2/dir.c +++ b/fs/nilfs2/dir.c | |||
@@ -80,23 +80,11 @@ static unsigned nilfs_last_byte(struct inode *inode, unsigned long page_nr) | |||
80 | return last_byte; | 80 | return last_byte; |
81 | } | 81 | } |
82 | 82 | ||
83 | static int nilfs_prepare_chunk_uninterruptible(struct page *page, | 83 | static int nilfs_prepare_chunk(struct page *page, unsigned from, unsigned to) |
84 | struct address_space *mapping, | ||
85 | unsigned from, unsigned to) | ||
86 | { | 84 | { |
87 | loff_t pos = page_offset(page) + from; | 85 | loff_t pos = page_offset(page) + from; |
88 | return block_write_begin(NULL, mapping, pos, to - from, | 86 | return block_write_begin_newtrunc(NULL, page->mapping, pos, to - from, |
89 | AOP_FLAG_UNINTERRUPTIBLE, &page, | 87 | 0, &page, NULL, nilfs_get_block); |
90 | NULL, nilfs_get_block); | ||
91 | } | ||
92 | |||
93 | static int nilfs_prepare_chunk(struct page *page, | ||
94 | struct address_space *mapping, | ||
95 | unsigned from, unsigned to) | ||
96 | { | ||
97 | loff_t pos = page_offset(page) + from; | ||
98 | return block_write_begin(NULL, mapping, pos, to - from, 0, &page, | ||
99 | NULL, nilfs_get_block); | ||
100 | } | 88 | } |
101 | 89 | ||
102 | static void nilfs_commit_chunk(struct page *page, | 90 | static void nilfs_commit_chunk(struct page *page, |
@@ -449,7 +437,7 @@ void nilfs_set_link(struct inode *dir, struct nilfs_dir_entry *de, | |||
449 | int err; | 437 | int err; |
450 | 438 | ||
451 | lock_page(page); | 439 | lock_page(page); |
452 | err = nilfs_prepare_chunk_uninterruptible(page, mapping, from, to); | 440 | err = nilfs_prepare_chunk(page, from, to); |
453 | BUG_ON(err); | 441 | BUG_ON(err); |
454 | de->inode = cpu_to_le64(inode->i_ino); | 442 | de->inode = cpu_to_le64(inode->i_ino); |
455 | nilfs_set_de_type(de, inode); | 443 | nilfs_set_de_type(de, inode); |
@@ -530,7 +518,7 @@ int nilfs_add_link(struct dentry *dentry, struct inode *inode) | |||
530 | got_it: | 518 | got_it: |
531 | from = (char *)de - (char *)page_address(page); | 519 | from = (char *)de - (char *)page_address(page); |
532 | to = from + rec_len; | 520 | to = from + rec_len; |
533 | err = nilfs_prepare_chunk(page, page->mapping, from, to); | 521 | err = nilfs_prepare_chunk(page, from, to); |
534 | if (err) | 522 | if (err) |
535 | goto out_unlock; | 523 | goto out_unlock; |
536 | if (de->inode) { | 524 | if (de->inode) { |
@@ -587,7 +575,7 @@ int nilfs_delete_entry(struct nilfs_dir_entry *dir, struct page *page) | |||
587 | if (pde) | 575 | if (pde) |
588 | from = (char *)pde - (char *)page_address(page); | 576 | from = (char *)pde - (char *)page_address(page); |
589 | lock_page(page); | 577 | lock_page(page); |
590 | err = nilfs_prepare_chunk(page, mapping, from, to); | 578 | err = nilfs_prepare_chunk(page, from, to); |
591 | BUG_ON(err); | 579 | BUG_ON(err); |
592 | if (pde) | 580 | if (pde) |
593 | pde->rec_len = cpu_to_le16(to - from); | 581 | pde->rec_len = cpu_to_le16(to - from); |
@@ -615,7 +603,7 @@ int nilfs_make_empty(struct inode *inode, struct inode *parent) | |||
615 | if (!page) | 603 | if (!page) |
616 | return -ENOMEM; | 604 | return -ENOMEM; |
617 | 605 | ||
618 | err = nilfs_prepare_chunk(page, mapping, 0, chunk_size); | 606 | err = nilfs_prepare_chunk(page, 0, chunk_size); |
619 | if (unlikely(err)) { | 607 | if (unlikely(err)) { |
620 | unlock_page(page); | 608 | unlock_page(page); |
621 | goto fail; | 609 | goto fail; |