__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.
Unified · Split
| @@ -1834,9 +1834,11 @@ void page_zero_new_buffers(struct page *page, unsigned from, unsigned to) · 1833 unmodified lines | ||
| 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; |
| @@ -1916,7 +1918,7 @@ int block_prepare_write(struct page *page, unsigned from, unsigned to, · 73 unmodified lines | ||
| 1916 | 1918 | } |
| 1917 | 1919 | return err; |
| 1918 | 1920 | } |
| 1919 | −EXPORT_SYMBOL(block_prepare_write); | |
| 1921 | +EXPORT_SYMBOL(__block_write_begin); | |
| 1920 | 1922 | |
| 1921 | 1923 | static int __block_commit_write(struct inode *inode, struct page *page, |
| 1922 | 1924 | unsigned from, unsigned to) |
| @@ -1953,15 +1955,6 @@ static int __block_commit_write(struct inode *inode, struct page *page, · 30 unmodified lines | ||
| 1953 | 1955 | return 0; |
| 1954 | 1956 | } |
| 1955 | 1957 | |
| 1956 | −int __block_write_begin(struct page *page, loff_t pos, unsigned len, | |
| 1957 | − get_block_t *get_block) | |
| 1958 | −{ | |
| 1959 | − unsigned start = pos & (PAGE_CACHE_SIZE - 1); | |
| 1960 | − | |
| 1961 | − return block_prepare_write(page, start, start + len, get_block); | |
| 1962 | −} | |
| 1963 | −EXPORT_SYMBOL(__block_write_begin); | |
| 1964 | − | |
| 1965 | 1958 | /* |
| 1966 | 1959 | * block_write_begin takes care of the basic task of block allocation and |
| 1967 | 1960 | * bringing partial write blocks uptodate first. |
| @@ -2379,7 +2372,7 @@ block_page_mkwrite(struct vm_area_struct *vma, struct vm_fault *vmf, · 411 unmodified lines | ||
| 2379 | 2372 | else |
| 2380 | 2373 | end = PAGE_CACHE_SIZE; |
| 2381 | 2374 | |
| 2382 | − ret = block_prepare_write(page, 0, end, get_block); | |
| 2375 | + ret = __block_write_begin(page, 0, end, get_block); | |
| 2383 | 2376 | if (!ret) |
| 2384 | 2377 | ret = block_commit_write(page, 0, end); |
| 2385 | 2378 | |
| @@ -1696,8 +1696,8 @@ static int ext3_journalled_writepage(struct page *page, · 1695 unmodified lines | ||
| 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; |
| @@ -1538,10 +1538,10 @@ static int do_journal_get_write_access(handle_t *handle, · 1537 unmodified lines | ||
| 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,8 +2550,7 @@ static int ext4_da_get_block_prep(struct inode *inode, sector_t iblock, · 1002 unmodified lines | ||
| 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) |
| @@ -2583,7 +2582,7 @@ static int ext4_da_get_block_prep(struct inode *inode, sector_t iblock, · 25 unmodified lines | ||
| 2583 | 2582 | /* |
| 2584 | 2583 | * This function is used as a standard get_block_t calback function |
| 2585 | 2584 | * when there is no desire to allocate any blocks. It is used as a |
| 2586 | − * callback function for block_prepare_write() and block_write_full_page(). | |
| 2585 | + * callback function for block_write_begin() and block_write_full_page(). | |
| 2587 | 2586 | * These functions should only try to map a single block at a time. |
| 2588 | 2587 | * |
| 2589 | 2588 | * Since this function doesn't do block allocations even if the caller |
| @@ -2743,7 +2742,7 @@ static int ext4_writepage(struct page *page, · 153 unmodified lines | ||
| 2743 | 2742 | * all are mapped and non delay. We don't want to |
| 2744 | 2743 | * do block allocation here. |
| 2745 | 2744 | */ |
| 2746 | − ret = block_prepare_write(page, 0, len, | |
| 2745 | + ret = __block_write_begin(page, 0, len, | |
| 2747 | 2746 | noalloc_get_block_write); |
| 2748 | 2747 | if (!ret) { |
| 2749 | 2748 | page_bufs = page_buffers(page); |
| @@ -618,7 +618,6 @@ static int gfs2_write_begin(struct file *file, struct address_space *mapping, · 617 unmodified lines | ||
| 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); |
| @@ -691,7 +690,7 @@ static int gfs2_write_begin(struct file *file, struct address_space *mapping, · 66 unmodified lines | ||
| 691 | 690 | } |
| 692 | 691 | |
| 693 | 692 | prepare_write: |
| 694 | − error = block_prepare_write(page, from, to, gfs2_block_map); | |
| 693 | + error = __block_write_begin(page, from, len, gfs2_block_map); | |
| 695 | 694 | out: |
| 696 | 695 | if (error == 0) |
| 697 | 696 | return 0; |
| @@ -1294,7 +1294,7 @@ static int write_empty_blocks(struct page *page, unsigned from, unsigned to) · 1293 unmodified lines | ||
| 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,7 +1313,7 @@ static int write_empty_blocks(struct page *page, unsigned from, unsigned to) · 12 unmodified lines | ||
| 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,7 +1328,7 @@ static int write_empty_blocks(struct page *page, unsigned from, unsigned to) · 8 unmodified lines | ||
| 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); |
| @@ -165,7 +165,7 @@ int ocfs2_get_block(struct inode *inode, sector_t iblock, · 164 unmodified lines | ||
| 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 |
| @@ -407,21 +407,6 @@ static int ocfs2_writepage(struct page *page, struct writeback_control *wbc) · 235 unmodified lines | ||
| 407 | 407 | return ret; |
| 408 | 408 | } |
| 409 | 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 | − | |
| 422 | − return ret; | |
| 423 | −} | |
| 424 | − | |
| 425 | 410 | /* Taken from ext3. We don't necessarily need the full blown |
| 426 | 411 | * functionality yet, but IMHO it's better to cut and paste the whole |
| 427 | 412 | * thing so we can avoid introducing our own bugs (and easily pick up |
| @@ -732,7 +717,7 @@ static int ocfs2_should_read_blk(struct inode *inode, struct page *page, · 304 unmodified lines | ||
| 732 | 717 | } |
| 733 | 718 | |
| 734 | 719 | /* |
| 735 | − * Some of this taken from block_prepare_write(). We already have our | |
| 720 | + * Some of this taken from __block_write_begin(). We already have our | |
| 736 | 721 | * mapping by now though, and the entire write will be allocating or |
| 737 | 722 | * it won't, so not much need to use BH_New. |
| 738 | 723 | * |
| @@ -22,9 +22,6 @@ · 21 unmodified lines | ||
| 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, |
| @@ -796,13 +796,12 @@ static int ocfs2_write_zero_page(struct inode *inode, u64 abs_from, · 795 unmodified lines | ||
| 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; |
| @@ -22,8 +22,6 @@ · 21 unmodified lines | ||
| 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 | { |
| @@ -165,7 +163,7 @@ inline void make_le_item_head(struct item_head *ih, const struct cpu_key *key, · 135 unmodified lines | ||
| 165 | 163 | ** but tail is still sitting in a direct item, and we can't write to |
| 166 | 164 | ** it. So, look through this page, and check all the mapped buffers |
| 167 | 165 | ** to make sure they have valid block numbers. Any that don't need |
| 168 | −** to be unmapped, so that block_prepare_write will correctly call | |
| 166 | +** to be unmapped, so that __block_write_begin will correctly call | |
| 169 | 167 | ** reiserfs_get_block to convert the tail into an unformatted node |
| 170 | 168 | */ |
| 171 | 169 | static inline void fix_tail_page_for_writing(struct page *page) |
| @@ -439,13 +437,13 @@ static int reiserfs_bmap(struct inode *inode, sector_t block, · 267 unmodified lines | ||
| 439 | 437 | } |
| 440 | 438 | |
| 441 | 439 | /* special version of get_block that is only used by grab_tail_page right |
| 442 | −** now. It is sent to block_prepare_write, and when you try to get a | |
| 440 | +** now. It is sent to __block_write_begin, and when you try to get a | |
| 443 | 441 | ** block past the end of the file (or a block from a hole) it returns |
| 444 | −** -ENOENT instead of a valid buffer. block_prepare_write expects to | |
| 442 | +** -ENOENT instead of a valid buffer. __block_write_begin expects to | |
| 445 | 443 | ** be able to do i/o on the buffers returned, unless an error value |
| 446 | 444 | ** is also returned. |
| 447 | 445 | ** |
| 448 | −** So, this allows block_prepare_write to be used for reading a single block | |
| 446 | +** So, this allows __block_write_begin to be used for reading a single block | |
| 449 | 447 | ** in a page. Where it does not produce a valid page for holes, or past the |
| 450 | 448 | ** end of the file. This turns out to be exactly what we need for reading |
| 451 | 449 | ** tails for conversion. |
| @@ -558,11 +556,12 @@ static int convert_tail_for_hole(struct inode *inode, · 106 unmodified lines | ||
| 558 | 556 | ** |
| 559 | 557 | ** We must fix the tail page for writing because it might have buffers |
| 560 | 558 | ** that are mapped, but have a block number of 0. This indicates tail |
| 561 | − ** data that has been read directly into the page, and block_prepare_write | |
| 562 | − ** won't trigger a get_block in this case. | |
| 559 | + ** data that has been read directly into the page, and | |
| 560 | + ** __block_write_begin won't trigger a get_block in this case. | |
| 563 | 561 | */ |
| 564 | 562 | fix_tail_page_for_writing(tail_page); |
| 565 | − retval = reiserfs_prepare_write(NULL, tail_page, tail_start, tail_end); | |
| 563 | + retval = __reiserfs_write_begin(tail_page, tail_start, | |
| 564 | + tail_end - tail_start); | |
| 566 | 565 | if (retval) |
| 567 | 566 | goto unlock; |
| 568 | 567 | |
| @@ -2033,7 +2032,7 @@ static int grab_tail_page(struct inode *inode, · 1464 unmodified lines | ||
| 2033 | 2032 | /* start within the page of the last block in the file */ |
| 2034 | 2033 | start = (offset / blocksize) * blocksize; |
| 2035 | 2034 | |
| 2036 | − error = block_prepare_write(page, start, offset, | |
| 2035 | + error = __block_write_begin(page, start, offset - start, | |
| 2037 | 2036 | reiserfs_get_block_create_0); |
| 2038 | 2037 | if (error) |
| 2039 | 2038 | goto unlock; |
| @@ -2628,8 +2627,7 @@ static int reiserfs_write_begin(struct file *file, · 588 unmodified lines | ||
| 2628 | 2627 | return ret; |
| 2629 | 2628 | } |
| 2630 | 2629 | |
| 2631 | −int reiserfs_prepare_write(struct file *f, struct page *page, | |
| 2632 | − unsigned from, unsigned to) | |
| 2630 | +int __reiserfs_write_begin(struct page *page, unsigned from, unsigned len) | |
| 2633 | 2631 | { |
| 2634 | 2632 | struct inode *inode = page->mapping->host; |
| 2635 | 2633 | int ret; |
| @@ -2650,7 +2648,7 @@ int reiserfs_prepare_write(struct file *f, struct page *page, · 14 unmodified lines | ||
| 2650 | 2648 | th->t_refcount++; |
| 2651 | 2649 | } |
| 2652 | 2650 | |
| 2653 | − ret = block_prepare_write(page, from, to, reiserfs_get_block); | |
| 2651 | + ret = __block_write_begin(page, from, len, reiserfs_get_block); | |
| 2654 | 2652 | if (ret && reiserfs_transaction_running(inode->i_sb)) { |
| 2655 | 2653 | struct reiserfs_transaction_handle *th = current->journal_info; |
| 2656 | 2654 | /* this gets a little ugly. If reiserfs_get_block returned an |
| @@ -160,8 +160,6 @@ long reiserfs_compat_ioctl(struct file *file, unsigned int cmd, · 159 unmodified lines | ||
| 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. |
| @@ -200,7 +198,7 @@ int reiserfs_unpack(struct inode *inode, struct file *filp) · 32 unmodified lines | ||
| 200 | 198 | } |
| 201 | 199 | |
| 202 | 200 | /* we unpack by finding the page with the tail, and calling |
| 203 | − ** reiserfs_prepare_write on that page. This will force a | |
| 201 | + ** __reiserfs_write_begin on that page. This will force a | |
| 204 | 202 | ** reiserfs_get_block to unpack the tail for us. |
| 205 | 203 | */ |
| 206 | 204 | index = inode->i_size >> PAGE_CACHE_SHIFT; |
| @@ -210,7 +208,7 @@ int reiserfs_unpack(struct inode *inode, struct file *filp) · 3 unmodified lines | ||
| 210 | 208 | if (!page) { |
| 211 | 209 | goto out; |
| 212 | 210 | } |
| 213 | − retval = reiserfs_prepare_write(NULL, page, write_from, write_from); | |
| 211 | + retval = __reiserfs_write_begin(page, write_from, 0); | |
| 214 | 212 | if (retval) |
| 215 | 213 | goto out_unlock; |
| 216 | 214 | |
| @@ -418,8 +418,6 @@ static inline __u32 xattr_hash(const char *msg, int len) · 417 unmodified lines | ||
| 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 | { |
| @@ -532,8 +530,7 @@ reiserfs_xattr_set_handle(struct reiserfs_transaction_handle *th, · 106 unmodified lines | ||
| 532 | 530 | rxh->h_hash = cpu_to_le32(xahash); |
| 533 | 531 | } |
| 534 | 532 | |
| 535 | − err = reiserfs_prepare_write(NULL, page, page_offset, | |
| 536 | − page_offset + chunk + skip); | |
| 533 | + err = __reiserfs_write_begin(page, page_offset, chunk + skip); | |
| 537 | 534 | if (!err) { |
| 538 | 535 | if (buffer) |
| 539 | 536 | memcpy(data + skip, buffer + buffer_pos, chunk); |
| @@ -576,7 +576,7 @@ xfs_max_file_offset( · 575 unmodified lines | ||
| 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 |
| @@ -212,7 +212,6 @@ int generic_write_end(struct file *, struct address_space *, · 211 unmodified lines | ||
| 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 *); |
| @@ -2072,6 +2072,8 @@ void sd_attrs_to_i_attrs(__u16 sd_attrs, struct inode *inode); · 2071 unmodified lines | ||
| 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, |