diff options
Diffstat (limited to 'fs/ocfs2/aops.c')
-rw-r--r-- | fs/ocfs2/aops.c | 31 |
1 files changed, 16 insertions, 15 deletions
diff --git a/fs/ocfs2/aops.c b/fs/ocfs2/aops.c index 8e7cafb5fc6c..a480b09c79b9 100644 --- a/fs/ocfs2/aops.c +++ b/fs/ocfs2/aops.c | |||
@@ -222,7 +222,10 @@ static int ocfs2_readpage(struct file *file, struct page *page) | |||
222 | goto out; | 222 | goto out; |
223 | } | 223 | } |
224 | 224 | ||
225 | down_read(&OCFS2_I(inode)->ip_alloc_sem); | 225 | if (down_read_trylock(&OCFS2_I(inode)->ip_alloc_sem) == 0) { |
226 | ret = AOP_TRUNCATED_PAGE; | ||
227 | goto out_meta_unlock; | ||
228 | } | ||
226 | 229 | ||
227 | /* | 230 | /* |
228 | * i_size might have just been updated as we grabed the meta lock. We | 231 | * i_size might have just been updated as we grabed the meta lock. We |
@@ -235,10 +238,7 @@ static int ocfs2_readpage(struct file *file, struct page *page) | |||
235 | * XXX sys_readahead() seems to get that wrong? | 238 | * XXX sys_readahead() seems to get that wrong? |
236 | */ | 239 | */ |
237 | if (start >= i_size_read(inode)) { | 240 | if (start >= i_size_read(inode)) { |
238 | char *addr = kmap(page); | 241 | zero_user_page(page, 0, PAGE_SIZE, KM_USER0); |
239 | memset(addr, 0, PAGE_SIZE); | ||
240 | flush_dcache_page(page); | ||
241 | kunmap(page); | ||
242 | SetPageUptodate(page); | 242 | SetPageUptodate(page); |
243 | ret = 0; | 243 | ret = 0; |
244 | goto out_alloc; | 244 | goto out_alloc; |
@@ -258,6 +258,7 @@ static int ocfs2_readpage(struct file *file, struct page *page) | |||
258 | ocfs2_data_unlock(inode, 0); | 258 | ocfs2_data_unlock(inode, 0); |
259 | out_alloc: | 259 | out_alloc: |
260 | up_read(&OCFS2_I(inode)->ip_alloc_sem); | 260 | up_read(&OCFS2_I(inode)->ip_alloc_sem); |
261 | out_meta_unlock: | ||
261 | ocfs2_meta_unlock(inode, 0); | 262 | ocfs2_meta_unlock(inode, 0); |
262 | out: | 263 | out: |
263 | if (unlock) | 264 | if (unlock) |
@@ -797,6 +798,11 @@ int ocfs2_map_and_write_splice_data(struct inode *inode, | |||
797 | } | 798 | } |
798 | to = from + bytes; | 799 | to = from + bytes; |
799 | 800 | ||
801 | BUG_ON(from > PAGE_CACHE_SIZE); | ||
802 | BUG_ON(to > PAGE_CACHE_SIZE); | ||
803 | BUG_ON(from < cluster_start); | ||
804 | BUG_ON(to > cluster_end); | ||
805 | |||
800 | if (wc->w_this_page_new) | 806 | if (wc->w_this_page_new) |
801 | ret = ocfs2_map_page_blocks(wc->w_this_page, p_blkno, inode, | 807 | ret = ocfs2_map_page_blocks(wc->w_this_page, p_blkno, inode, |
802 | cluster_start, cluster_end, 1); | 808 | cluster_start, cluster_end, 1); |
@@ -808,11 +814,6 @@ int ocfs2_map_and_write_splice_data(struct inode *inode, | |||
808 | goto out; | 814 | goto out; |
809 | } | 815 | } |
810 | 816 | ||
811 | BUG_ON(from > PAGE_CACHE_SIZE); | ||
812 | BUG_ON(to > PAGE_CACHE_SIZE); | ||
813 | BUG_ON(from > osb->s_clustersize); | ||
814 | BUG_ON(to > osb->s_clustersize); | ||
815 | |||
816 | src = buf->ops->map(sp->s_pipe, buf, 1); | 817 | src = buf->ops->map(sp->s_pipe, buf, 1); |
817 | dst = kmap_atomic(wc->w_this_page, KM_USER1); | 818 | dst = kmap_atomic(wc->w_this_page, KM_USER1); |
818 | memcpy(dst + from, src + src_from, bytes); | 819 | memcpy(dst + from, src + src_from, bytes); |
@@ -889,6 +890,11 @@ int ocfs2_map_and_write_user_data(struct inode *inode, | |||
889 | 890 | ||
890 | to = from + bytes; | 891 | to = from + bytes; |
891 | 892 | ||
893 | BUG_ON(from > PAGE_CACHE_SIZE); | ||
894 | BUG_ON(to > PAGE_CACHE_SIZE); | ||
895 | BUG_ON(from < cluster_start); | ||
896 | BUG_ON(to > cluster_end); | ||
897 | |||
892 | if (wc->w_this_page_new) | 898 | if (wc->w_this_page_new) |
893 | ret = ocfs2_map_page_blocks(wc->w_this_page, p_blkno, inode, | 899 | ret = ocfs2_map_page_blocks(wc->w_this_page, p_blkno, inode, |
894 | cluster_start, cluster_end, 1); | 900 | cluster_start, cluster_end, 1); |
@@ -900,11 +906,6 @@ int ocfs2_map_and_write_user_data(struct inode *inode, | |||
900 | goto out; | 906 | goto out; |
901 | } | 907 | } |
902 | 908 | ||
903 | BUG_ON(from > PAGE_CACHE_SIZE); | ||
904 | BUG_ON(to > PAGE_CACHE_SIZE); | ||
905 | BUG_ON(from > osb->s_clustersize); | ||
906 | BUG_ON(to > osb->s_clustersize); | ||
907 | |||
908 | dst = kmap(wc->w_this_page); | 909 | dst = kmap(wc->w_this_page); |
909 | memcpy(dst + from, bp->b_src_buf + src_from, bytes); | 910 | memcpy(dst + from, bp->b_src_buf + src_from, bytes); |
910 | kunmap(wc->w_this_page); | 911 | kunmap(wc->w_this_page); |