diff options
Diffstat (limited to 'fs/logfs/readwrite.c')
-rw-r--r-- | fs/logfs/readwrite.c | 51 |
1 files changed, 34 insertions, 17 deletions
diff --git a/fs/logfs/readwrite.c b/fs/logfs/readwrite.c index 2ac4217b7901..4153e65b0148 100644 --- a/fs/logfs/readwrite.c +++ b/fs/logfs/readwrite.c | |||
@@ -244,8 +244,7 @@ static void preunlock_page(struct super_block *sb, struct page *page, int lock) | |||
244 | * is waiting for s_write_mutex. We annotate this fact by setting PG_pre_locked | 244 | * is waiting for s_write_mutex. We annotate this fact by setting PG_pre_locked |
245 | * in addition to PG_locked. | 245 | * in addition to PG_locked. |
246 | */ | 246 | */ |
247 | static void logfs_get_wblocks(struct super_block *sb, struct page *page, | 247 | void logfs_get_wblocks(struct super_block *sb, struct page *page, int lock) |
248 | int lock) | ||
249 | { | 248 | { |
250 | struct logfs_super *super = logfs_super(sb); | 249 | struct logfs_super *super = logfs_super(sb); |
251 | 250 | ||
@@ -260,8 +259,7 @@ static void logfs_get_wblocks(struct super_block *sb, struct page *page, | |||
260 | } | 259 | } |
261 | } | 260 | } |
262 | 261 | ||
263 | static void logfs_put_wblocks(struct super_block *sb, struct page *page, | 262 | void logfs_put_wblocks(struct super_block *sb, struct page *page, int lock) |
264 | int lock) | ||
265 | { | 263 | { |
266 | struct logfs_super *super = logfs_super(sb); | 264 | struct logfs_super *super = logfs_super(sb); |
267 | 265 | ||
@@ -424,7 +422,7 @@ static void inode_write_block(struct logfs_block *block) | |||
424 | if (inode->i_ino == LOGFS_INO_MASTER) | 422 | if (inode->i_ino == LOGFS_INO_MASTER) |
425 | logfs_write_anchor(inode->i_sb); | 423 | logfs_write_anchor(inode->i_sb); |
426 | else { | 424 | else { |
427 | ret = __logfs_write_inode(inode, 0); | 425 | ret = __logfs_write_inode(inode, NULL, 0); |
428 | /* see indirect_write_block comment */ | 426 | /* see indirect_write_block comment */ |
429 | BUG_ON(ret); | 427 | BUG_ON(ret); |
430 | } | 428 | } |
@@ -560,8 +558,13 @@ static void inode_free_block(struct super_block *sb, struct logfs_block *block) | |||
560 | static void indirect_free_block(struct super_block *sb, | 558 | static void indirect_free_block(struct super_block *sb, |
561 | struct logfs_block *block) | 559 | struct logfs_block *block) |
562 | { | 560 | { |
563 | ClearPagePrivate(block->page); | 561 | struct page *page = block->page; |
564 | block->page->private = 0; | 562 | |
563 | if (PagePrivate(page)) { | ||
564 | ClearPagePrivate(page); | ||
565 | page_cache_release(page); | ||
566 | set_page_private(page, 0); | ||
567 | } | ||
565 | __free_block(sb, block); | 568 | __free_block(sb, block); |
566 | } | 569 | } |
567 | 570 | ||
@@ -650,8 +653,11 @@ static void alloc_data_block(struct inode *inode, struct page *page) | |||
650 | logfs_unpack_index(page->index, &bix, &level); | 653 | logfs_unpack_index(page->index, &bix, &level); |
651 | block = __alloc_block(inode->i_sb, inode->i_ino, bix, level); | 654 | block = __alloc_block(inode->i_sb, inode->i_ino, bix, level); |
652 | block->page = page; | 655 | block->page = page; |
656 | |||
653 | SetPagePrivate(page); | 657 | SetPagePrivate(page); |
654 | page->private = (unsigned long)block; | 658 | page_cache_get(page); |
659 | set_page_private(page, (unsigned long) block); | ||
660 | |||
655 | block->ops = &indirect_block_ops; | 661 | block->ops = &indirect_block_ops; |
656 | } | 662 | } |
657 | 663 | ||
@@ -1570,11 +1576,15 @@ int logfs_write_buf(struct inode *inode, struct page *page, long flags) | |||
1570 | static int __logfs_delete(struct inode *inode, struct page *page) | 1576 | static int __logfs_delete(struct inode *inode, struct page *page) |
1571 | { | 1577 | { |
1572 | long flags = WF_DELETE; | 1578 | long flags = WF_DELETE; |
1579 | int err; | ||
1573 | 1580 | ||
1574 | inode->i_ctime = inode->i_mtime = CURRENT_TIME; | 1581 | inode->i_ctime = inode->i_mtime = CURRENT_TIME; |
1575 | 1582 | ||
1576 | if (page->index < I0_BLOCKS) | 1583 | if (page->index < I0_BLOCKS) |
1577 | return logfs_write_direct(inode, page, flags); | 1584 | return logfs_write_direct(inode, page, flags); |
1585 | err = grow_inode(inode, page->index, 0); | ||
1586 | if (err) | ||
1587 | return err; | ||
1578 | return logfs_write_rec(inode, page, page->index, 0, flags); | 1588 | return logfs_write_rec(inode, page, page->index, 0, flags); |
1579 | } | 1589 | } |
1580 | 1590 | ||
@@ -1623,7 +1633,7 @@ int logfs_rewrite_block(struct inode *inode, u64 bix, u64 ofs, | |||
1623 | if (inode->i_ino == LOGFS_INO_MASTER) | 1633 | if (inode->i_ino == LOGFS_INO_MASTER) |
1624 | logfs_write_anchor(inode->i_sb); | 1634 | logfs_write_anchor(inode->i_sb); |
1625 | else { | 1635 | else { |
1626 | err = __logfs_write_inode(inode, flags); | 1636 | err = __logfs_write_inode(inode, page, flags); |
1627 | } | 1637 | } |
1628 | } | 1638 | } |
1629 | } | 1639 | } |
@@ -1873,7 +1883,7 @@ int logfs_truncate(struct inode *inode, u64 target) | |||
1873 | logfs_get_wblocks(sb, NULL, 1); | 1883 | logfs_get_wblocks(sb, NULL, 1); |
1874 | err = __logfs_truncate(inode, size); | 1884 | err = __logfs_truncate(inode, size); |
1875 | if (!err) | 1885 | if (!err) |
1876 | err = __logfs_write_inode(inode, 0); | 1886 | err = __logfs_write_inode(inode, NULL, 0); |
1877 | logfs_put_wblocks(sb, NULL, 1); | 1887 | logfs_put_wblocks(sb, NULL, 1); |
1878 | } | 1888 | } |
1879 | 1889 | ||
@@ -1901,8 +1911,11 @@ static void move_page_to_inode(struct inode *inode, struct page *page) | |||
1901 | li->li_block = block; | 1911 | li->li_block = block; |
1902 | 1912 | ||
1903 | block->page = NULL; | 1913 | block->page = NULL; |
1904 | page->private = 0; | 1914 | if (PagePrivate(page)) { |
1905 | ClearPagePrivate(page); | 1915 | ClearPagePrivate(page); |
1916 | page_cache_release(page); | ||
1917 | set_page_private(page, 0); | ||
1918 | } | ||
1906 | } | 1919 | } |
1907 | 1920 | ||
1908 | static void move_inode_to_page(struct page *page, struct inode *inode) | 1921 | static void move_inode_to_page(struct page *page, struct inode *inode) |
@@ -1918,8 +1931,12 @@ static void move_inode_to_page(struct page *page, struct inode *inode) | |||
1918 | BUG_ON(PagePrivate(page)); | 1931 | BUG_ON(PagePrivate(page)); |
1919 | block->ops = &indirect_block_ops; | 1932 | block->ops = &indirect_block_ops; |
1920 | block->page = page; | 1933 | block->page = page; |
1921 | page->private = (unsigned long)block; | 1934 | |
1922 | SetPagePrivate(page); | 1935 | if (!PagePrivate(page)) { |
1936 | SetPagePrivate(page); | ||
1937 | page_cache_get(page); | ||
1938 | set_page_private(page, (unsigned long) block); | ||
1939 | } | ||
1923 | 1940 | ||
1924 | block->inode = NULL; | 1941 | block->inode = NULL; |
1925 | li->li_block = NULL; | 1942 | li->li_block = NULL; |
@@ -2106,14 +2123,14 @@ void logfs_set_segment_unreserved(struct super_block *sb, u32 segno, u32 ec) | |||
2106 | ec_level); | 2123 | ec_level); |
2107 | } | 2124 | } |
2108 | 2125 | ||
2109 | int __logfs_write_inode(struct inode *inode, long flags) | 2126 | int __logfs_write_inode(struct inode *inode, struct page *page, long flags) |
2110 | { | 2127 | { |
2111 | struct super_block *sb = inode->i_sb; | 2128 | struct super_block *sb = inode->i_sb; |
2112 | int ret; | 2129 | int ret; |
2113 | 2130 | ||
2114 | logfs_get_wblocks(sb, NULL, flags & WF_LOCK); | 2131 | logfs_get_wblocks(sb, page, flags & WF_LOCK); |
2115 | ret = do_write_inode(inode); | 2132 | ret = do_write_inode(inode); |
2116 | logfs_put_wblocks(sb, NULL, flags & WF_LOCK); | 2133 | logfs_put_wblocks(sb, page, flags & WF_LOCK); |
2117 | return ret; | 2134 | return ret; |
2118 | } | 2135 | } |
2119 | 2136 | ||