]> err.no Git - linux-2.6/blobdiff - fs/ocfs2/aops.c
[MIPS] Early check for SMTC kernel on non-MT processor
[linux-2.6] / fs / ocfs2 / aops.c
index 56963e6c46c06acb21a9990887b48d46fd808d9b..a480b09c79b916de88252129919bedbbfb10850a 100644 (file)
@@ -78,7 +78,8 @@ static int ocfs2_symlink_get_block(struct inode *inode, sector_t iblock,
 
        if (!OCFS2_IS_VALID_DINODE(fe)) {
                mlog(ML_ERROR, "Invalid dinode #%llu: signature = %.*s\n",
-                    (unsigned long long)fe->i_blkno, 7, fe->i_signature);
+                    (unsigned long long)le64_to_cpu(fe->i_blkno), 7,
+                    fe->i_signature);
                goto bail;
        }
 
@@ -221,7 +222,10 @@ static int ocfs2_readpage(struct file *file, struct page *page)
                goto out;
        }
 
-       down_read(&OCFS2_I(inode)->ip_alloc_sem);
+       if (down_read_trylock(&OCFS2_I(inode)->ip_alloc_sem) == 0) {
+               ret = AOP_TRUNCATED_PAGE;
+               goto out_meta_unlock;
+       }
 
        /*
         * i_size might have just been updated as we grabed the meta lock.  We
@@ -234,10 +238,7 @@ static int ocfs2_readpage(struct file *file, struct page *page)
         * XXX sys_readahead() seems to get that wrong?
         */
        if (start >= i_size_read(inode)) {
-               char *addr = kmap(page);
-               memset(addr, 0, PAGE_SIZE);
-               flush_dcache_page(page);
-               kunmap(page);
+               zero_user_page(page, 0, PAGE_SIZE, KM_USER0);
                SetPageUptodate(page);
                ret = 0;
                goto out_alloc;
@@ -257,6 +258,7 @@ static int ocfs2_readpage(struct file *file, struct page *page)
        ocfs2_data_unlock(inode, 0);
 out_alloc:
        up_read(&OCFS2_I(inode)->ip_alloc_sem);
+out_meta_unlock:
        ocfs2_meta_unlock(inode, 0);
 out:
        if (unlock)
@@ -796,6 +798,11 @@ int ocfs2_map_and_write_splice_data(struct inode *inode,
        }
        to = from + bytes;
 
+       BUG_ON(from > PAGE_CACHE_SIZE);
+       BUG_ON(to > PAGE_CACHE_SIZE);
+       BUG_ON(from < cluster_start);
+       BUG_ON(to > cluster_end);
+
        if (wc->w_this_page_new)
                ret = ocfs2_map_page_blocks(wc->w_this_page, p_blkno, inode,
                                            cluster_start, cluster_end, 1);
@@ -807,11 +814,6 @@ int ocfs2_map_and_write_splice_data(struct inode *inode,
                goto out;
        }
 
-       BUG_ON(from > PAGE_CACHE_SIZE);
-       BUG_ON(to > PAGE_CACHE_SIZE);
-       BUG_ON(from > osb->s_clustersize);
-       BUG_ON(to > osb->s_clustersize);
-
        src = buf->ops->map(sp->s_pipe, buf, 1);
        dst = kmap_atomic(wc->w_this_page, KM_USER1);
        memcpy(dst + from, src + src_from, bytes);
@@ -888,6 +890,11 @@ int ocfs2_map_and_write_user_data(struct inode *inode,
 
        to = from + bytes;
 
+       BUG_ON(from > PAGE_CACHE_SIZE);
+       BUG_ON(to > PAGE_CACHE_SIZE);
+       BUG_ON(from < cluster_start);
+       BUG_ON(to > cluster_end);
+
        if (wc->w_this_page_new)
                ret = ocfs2_map_page_blocks(wc->w_this_page, p_blkno, inode,
                                            cluster_start, cluster_end, 1);
@@ -899,11 +906,6 @@ int ocfs2_map_and_write_user_data(struct inode *inode,
                goto out;
        }
 
-       BUG_ON(from > PAGE_CACHE_SIZE);
-       BUG_ON(to > PAGE_CACHE_SIZE);
-       BUG_ON(from > osb->s_clustersize);
-       BUG_ON(to > osb->s_clustersize);
-
        dst = kmap(wc->w_this_page);
        memcpy(dst + from, bp->b_src_buf + src_from, bytes);
        kunmap(wc->w_this_page);
@@ -939,9 +941,9 @@ out:
  * Returns a negative error code or the number of bytes copied into
  * the page.
  */
-int ocfs2_write_data_page(struct inode *inode, handle_t *handle,
-                         u64 *p_blkno, struct page *page,
-                         struct ocfs2_write_ctxt *wc, int new)
+static int ocfs2_write_data_page(struct inode *inode, handle_t *handle,
+                                u64 *p_blkno, struct page *page,
+                                struct ocfs2_write_ctxt *wc, int new)
 {
        int ret, copied = 0;
        unsigned int from = 0, to = 0;
@@ -1086,7 +1088,7 @@ static ssize_t ocfs2_write(struct file *file, u32 phys, handle_t *handle,
        for(i = 0; i < numpages; i++) {
                index = start + i;
 
-               cpages[i] = grab_cache_page(mapping, index);
+               cpages[i] = find_or_create_page(mapping, index, GFP_NOFS);
                if (!cpages[i]) {
                        ret = -ENOMEM;
                        mlog_errno(ret);