Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

fs: kill block_prepare_write

__block_write_begin and block_prepare_write are identical except for slightly
different calling conventions. Convert all callers to the __block_write_begin
calling conventions and drop block_prepare_write.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>

authored by

Christoph Hellwig and committed by
Al Viro
ebdec241 56b0dacf

+39 -73
+5 -12
fs/buffer.c
··· 1834 1834 } 1835 1835 EXPORT_SYMBOL(page_zero_new_buffers); 1836 1836 1837 - int block_prepare_write(struct page *page, unsigned from, unsigned to, 1837 + int __block_write_begin(struct page *page, loff_t pos, unsigned len, 1838 1838 get_block_t *get_block) 1839 1839 { 1840 + unsigned from = pos & (PAGE_CACHE_SIZE - 1); 1841 + unsigned to = from + len; 1840 1842 struct inode *inode = page->mapping->host; 1841 1843 unsigned block_start, block_end; 1842 1844 sector_t block; ··· 1918 1916 } 1919 1917 return err; 1920 1918 } 1921 - EXPORT_SYMBOL(block_prepare_write); 1919 + EXPORT_SYMBOL(__block_write_begin); 1922 1920 1923 1921 static int __block_commit_write(struct inode *inode, struct page *page, 1924 1922 unsigned from, unsigned to) ··· 1954 1952 SetPageUptodate(page); 1955 1953 return 0; 1956 1954 } 1957 - 1958 - int __block_write_begin(struct page *page, loff_t pos, unsigned len, 1959 - get_block_t *get_block) 1960 - { 1961 - unsigned start = pos & (PAGE_CACHE_SIZE - 1); 1962 - 1963 - return block_prepare_write(page, start, start + len, get_block); 1964 - } 1965 - EXPORT_SYMBOL(__block_write_begin); 1966 1955 1967 1956 /* 1968 1957 * block_write_begin takes care of the basic task of block allocation and ··· 2372 2379 else 2373 2380 end = PAGE_CACHE_SIZE; 2374 2381 2375 - ret = block_prepare_write(page, 0, end, get_block); 2382 + ret = __block_write_begin(page, 0, end, get_block); 2376 2383 if (!ret) 2377 2384 ret = block_commit_write(page, 0, end); 2378 2385
+2 -2
fs/ext3/inode.c
··· 1696 1696 * doesn't seem much point in redirtying the page here. 1697 1697 */ 1698 1698 ClearPageChecked(page); 1699 - ret = block_prepare_write(page, 0, PAGE_CACHE_SIZE, 1700 - ext3_get_block); 1699 + ret = __block_write_begin(page, 0, PAGE_CACHE_SIZE, 1700 + ext3_get_block); 1701 1701 if (ret != 0) { 1702 1702 ext3_journal_stop(handle); 1703 1703 goto out_unlock;
+5 -6
fs/ext4/inode.c
··· 1538 1538 if (!buffer_mapped(bh) || buffer_freed(bh)) 1539 1539 return 0; 1540 1540 /* 1541 - * __block_prepare_write() could have dirtied some buffers. Clean 1541 + * __block_write_begin() could have dirtied some buffers. Clean 1542 1542 * the dirty bit as jbd2_journal_get_write_access() could complain 1543 1543 * otherwise about fs integrity issues. Setting of the dirty bit 1544 - * by __block_prepare_write() isn't a real problem here as we clear 1544 + * by __block_write_begin() isn't a real problem here as we clear 1545 1545 * the bit before releasing a page lock and thus writeback cannot 1546 1546 * ever write the buffer. 1547 1547 */ ··· 2550 2550 if (buffer_delay(bh)) 2551 2551 return 0; /* Not sure this could or should happen */ 2552 2552 /* 2553 - * XXX: __block_prepare_write() unmaps passed block, 2554 - * is it OK? 2553 + * XXX: __block_write_begin() unmaps passed block, is it OK? 2555 2554 */ 2556 2555 ret = ext4_da_reserve_space(inode, iblock); 2557 2556 if (ret) ··· 2582 2583 /* 2583 2584 * This function is used as a standard get_block_t calback function 2584 2585 * when there is no desire to allocate any blocks. It is used as a 2585 - * callback function for block_prepare_write() and block_write_full_page(). 2586 + * callback function for block_write_begin() and block_write_full_page(). 2586 2587 * These functions should only try to map a single block at a time. 2587 2588 * 2588 2589 * Since this function doesn't do block allocations even if the caller ··· 2742 2743 * all are mapped and non delay. We don't want to 2743 2744 * do block allocation here. 2744 2745 */ 2745 - ret = block_prepare_write(page, 0, len, 2746 + ret = __block_write_begin(page, 0, len, 2746 2747 noalloc_get_block_write); 2747 2748 if (!ret) { 2748 2749 page_bufs = page_buffers(page);
+1 -2
fs/gfs2/aops.c
··· 618 618 struct gfs2_alloc *al = NULL; 619 619 pgoff_t index = pos >> PAGE_CACHE_SHIFT; 620 620 unsigned from = pos & (PAGE_CACHE_SIZE - 1); 621 - unsigned to = from + len; 622 621 struct page *page; 623 622 624 623 gfs2_holder_init(ip->i_gl, LM_ST_EXCLUSIVE, 0, &ip->i_gh); ··· 690 691 } 691 692 692 693 prepare_write: 693 - error = block_prepare_write(page, from, to, gfs2_block_map); 694 + error = __block_write_begin(page, from, len, gfs2_block_map); 694 695 out: 695 696 if (error == 0) 696 697 return 0;
+3 -3
fs/gfs2/ops_inode.c
··· 1294 1294 int error; 1295 1295 1296 1296 if (!page_has_buffers(page)) { 1297 - error = block_prepare_write(page, from, to, gfs2_block_map); 1297 + error = __block_write_begin(page, from, to - from, gfs2_block_map); 1298 1298 if (unlikely(error)) 1299 1299 return error; 1300 1300 ··· 1313 1313 next += bh->b_size; 1314 1314 if (buffer_mapped(bh)) { 1315 1315 if (end) { 1316 - error = block_prepare_write(page, start, end, 1316 + error = __block_write_begin(page, start, end - start, 1317 1317 gfs2_block_map); 1318 1318 if (unlikely(error)) 1319 1319 return error; ··· 1328 1328 } while (next < to); 1329 1329 1330 1330 if (end) { 1331 - error = block_prepare_write(page, start, end, gfs2_block_map); 1331 + error = __block_write_begin(page, start, end - start, gfs2_block_map); 1332 1332 if (unlikely(error)) 1333 1333 return error; 1334 1334 empty_write_end(page, start, end);
+2 -17
fs/ocfs2/aops.c
··· 165 165 * ocfs2 never allocates in this function - the only time we 166 166 * need to use BH_New is when we're extending i_size on a file 167 167 * system which doesn't support holes, in which case BH_New 168 - * allows block_prepare_write() to zero. 168 + * allows __block_write_begin() to zero. 169 169 * 170 170 * If we see this on a sparse file system, then a truncate has 171 171 * raced us and removed the cluster. In this case, we clear ··· 403 403 ret = block_write_full_page(page, ocfs2_get_block, wbc); 404 404 405 405 mlog_exit(ret); 406 - 407 - return ret; 408 - } 409 - 410 - /* 411 - * This is called from ocfs2_write_zero_page() which has handled it's 412 - * own cluster locking and has ensured allocation exists for those 413 - * blocks to be written. 414 - */ 415 - int ocfs2_prepare_write_nolock(struct inode *inode, struct page *page, 416 - unsigned from, unsigned to) 417 - { 418 - int ret; 419 - 420 - ret = block_prepare_write(page, from, to, ocfs2_get_block); 421 406 422 407 return ret; 423 408 } ··· 717 732 } 718 733 719 734 /* 720 - * Some of this taken from block_prepare_write(). We already have our 735 + * Some of this taken from __block_write_begin(). We already have our 721 736 * mapping by now though, and the entire write will be allocating or 722 737 * it won't, so not much need to use BH_New. 723 738 *
-3
fs/ocfs2/aops.h
··· 22 22 #ifndef OCFS2_AOPS_H 23 23 #define OCFS2_AOPS_H 24 24 25 - int ocfs2_prepare_write_nolock(struct inode *inode, struct page *page, 26 - unsigned from, unsigned to); 27 - 28 25 handle_t *ocfs2_start_walk_page_trans(struct inode *inode, 29 26 struct page *page, 30 27 unsigned from,
+4 -5
fs/ocfs2/file.c
··· 796 796 block_end = block_start + (1 << inode->i_blkbits); 797 797 798 798 /* 799 - * block_start is block-aligned. Bump it by one to 800 - * force ocfs2_{prepare,commit}_write() to zero the 799 + * block_start is block-aligned. Bump it by one to force 800 + * __block_write_begin and block_commit_write to zero the 801 801 * whole block. 802 802 */ 803 - ret = ocfs2_prepare_write_nolock(inode, page, 804 - block_start + 1, 805 - block_start + 1); 803 + ret = __block_write_begin(page, block_start + 1, 0, 804 + ocfs2_get_block); 806 805 if (ret < 0) { 807 806 mlog_errno(ret); 808 807 goto out_unlock;
+11 -13
fs/reiserfs/inode.c
··· 22 22 23 23 int reiserfs_commit_write(struct file *f, struct page *page, 24 24 unsigned from, unsigned to); 25 - int reiserfs_prepare_write(struct file *f, struct page *page, 26 - unsigned from, unsigned to); 27 25 28 26 void reiserfs_evict_inode(struct inode *inode) 29 27 { ··· 163 165 ** but tail is still sitting in a direct item, and we can't write to 164 166 ** it. So, look through this page, and check all the mapped buffers 165 167 ** to make sure they have valid block numbers. Any that don't need 166 - ** to be unmapped, so that block_prepare_write will correctly call 168 + ** to be unmapped, so that __block_write_begin will correctly call 167 169 ** reiserfs_get_block to convert the tail into an unformatted node 168 170 */ 169 171 static inline void fix_tail_page_for_writing(struct page *page) ··· 437 439 } 438 440 439 441 /* special version of get_block that is only used by grab_tail_page right 440 - ** now. It is sent to block_prepare_write, and when you try to get a 442 + ** now. It is sent to __block_write_begin, and when you try to get a 441 443 ** block past the end of the file (or a block from a hole) it returns 442 - ** -ENOENT instead of a valid buffer. block_prepare_write expects to 444 + ** -ENOENT instead of a valid buffer. __block_write_begin expects to 443 445 ** be able to do i/o on the buffers returned, unless an error value 444 446 ** is also returned. 445 447 ** 446 - ** So, this allows block_prepare_write to be used for reading a single block 448 + ** So, this allows __block_write_begin to be used for reading a single block 447 449 ** in a page. Where it does not produce a valid page for holes, or past the 448 450 ** end of the file. This turns out to be exactly what we need for reading 449 451 ** tails for conversion. ··· 556 558 ** 557 559 ** We must fix the tail page for writing because it might have buffers 558 560 ** that are mapped, but have a block number of 0. This indicates tail 559 - ** data that has been read directly into the page, and block_prepare_write 560 - ** won't trigger a get_block in this case. 561 + ** data that has been read directly into the page, and 562 + ** __block_write_begin won't trigger a get_block in this case. 561 563 */ 562 564 fix_tail_page_for_writing(tail_page); 563 - retval = reiserfs_prepare_write(NULL, tail_page, tail_start, tail_end); 565 + retval = __reiserfs_write_begin(tail_page, tail_start, 566 + tail_end - tail_start); 564 567 if (retval) 565 568 goto unlock; 566 569 ··· 2032 2033 /* start within the page of the last block in the file */ 2033 2034 start = (offset / blocksize) * blocksize; 2034 2035 2035 - error = block_prepare_write(page, start, offset, 2036 + error = __block_write_begin(page, start, offset - start, 2036 2037 reiserfs_get_block_create_0); 2037 2038 if (error) 2038 2039 goto unlock; ··· 2627 2628 return ret; 2628 2629 } 2629 2630 2630 - int reiserfs_prepare_write(struct file *f, struct page *page, 2631 - unsigned from, unsigned to) 2631 + int __reiserfs_write_begin(struct page *page, unsigned from, unsigned len) 2632 2632 { 2633 2633 struct inode *inode = page->mapping->host; 2634 2634 int ret; ··· 2648 2650 th->t_refcount++; 2649 2651 } 2650 2652 2651 - ret = block_prepare_write(page, from, to, reiserfs_get_block); 2653 + ret = __block_write_begin(page, from, len, reiserfs_get_block); 2652 2654 if (ret && reiserfs_transaction_running(inode->i_sb)) { 2653 2655 struct reiserfs_transaction_handle *th = current->journal_info; 2654 2656 /* this gets a little ugly. If reiserfs_get_block returned an
+2 -4
fs/reiserfs/ioctl.c
··· 160 160 161 161 int reiserfs_commit_write(struct file *f, struct page *page, 162 162 unsigned from, unsigned to); 163 - int reiserfs_prepare_write(struct file *f, struct page *page, 164 - unsigned from, unsigned to); 165 163 /* 166 164 ** reiserfs_unpack 167 165 ** Function try to convert tail from direct item into indirect. ··· 198 200 } 199 201 200 202 /* we unpack by finding the page with the tail, and calling 201 - ** reiserfs_prepare_write on that page. This will force a 203 + ** __reiserfs_write_begin on that page. This will force a 202 204 ** reiserfs_get_block to unpack the tail for us. 203 205 */ 204 206 index = inode->i_size >> PAGE_CACHE_SHIFT; ··· 208 210 if (!page) { 209 211 goto out; 210 212 } 211 - retval = reiserfs_prepare_write(NULL, page, write_from, write_from); 213 + retval = __reiserfs_write_begin(page, write_from, 0); 212 214 if (retval) 213 215 goto out_unlock; 214 216
+1 -4
fs/reiserfs/xattr.c
··· 418 418 419 419 int reiserfs_commit_write(struct file *f, struct page *page, 420 420 unsigned from, unsigned to); 421 - int reiserfs_prepare_write(struct file *f, struct page *page, 422 - unsigned from, unsigned to); 423 421 424 422 static void update_ctime(struct inode *inode) 425 423 { ··· 530 532 rxh->h_hash = cpu_to_le32(xahash); 531 533 } 532 534 533 - err = reiserfs_prepare_write(NULL, page, page_offset, 534 - page_offset + chunk + skip); 535 + err = __reiserfs_write_begin(page, page_offset, chunk + skip); 535 536 if (!err) { 536 537 if (buffer) 537 538 memcpy(data + skip, buffer + buffer_pos, chunk);
+1 -1
fs/xfs/linux-2.6/xfs_super.c
··· 576 576 577 577 /* Figure out maximum filesize, on Linux this can depend on 578 578 * the filesystem blocksize (on 32 bit platforms). 579 - * __block_prepare_write does this in an [unsigned] long... 579 + * __block_write_begin does this in an [unsigned] long... 580 580 * page->index << (PAGE_CACHE_SHIFT - bbits) 581 581 * So, for page sized blocks (4K on 32 bit platforms), 582 582 * this wraps at around 8Tb (hence MAX_LFS_FILESIZE which is
-1
include/linux/buffer_head.h
··· 212 212 loff_t, unsigned, unsigned, 213 213 struct page *, void *); 214 214 void page_zero_new_buffers(struct page *page, unsigned from, unsigned to); 215 - int block_prepare_write(struct page*, unsigned, unsigned, get_block_t*); 216 215 int cont_write_begin(struct file *, struct address_space *, loff_t, 217 216 unsigned, unsigned, struct page **, void **, 218 217 get_block_t *, loff_t *);
+2
include/linux/reiserfs_fs.h
··· 2072 2072 void i_attrs_to_sd_attrs(struct inode *inode, __u16 * sd_attrs); 2073 2073 int reiserfs_setattr(struct dentry *dentry, struct iattr *attr); 2074 2074 2075 + int __reiserfs_write_begin(struct page *page, unsigned from, unsigned len); 2076 + 2075 2077 /* namei.c */ 2076 2078 void set_de_name_and_namelen(struct reiserfs_dir_entry *de); 2077 2079 int search_by_entry_key(struct super_block *sb, const struct cpu_key *key,