]> git.proxmox.com Git - mirror_ubuntu-artful-kernel.git/blobdiff - fs/ocfs2/aops.c
ocfs2: don't open-code inode_lock/inode_unlock
[mirror_ubuntu-artful-kernel.git] / fs / ocfs2 / aops.c
index 1581240a7ca0496d8fe4910bf09641c5661178af..abb0b0bf7c7f5674cafb119d4f9062160881aa89 100644 (file)
@@ -234,7 +234,7 @@ int ocfs2_read_inline_data(struct inode *inode, struct page *page,
 
        size = i_size_read(inode);
 
-       if (size > PAGE_CACHE_SIZE ||
+       if (size > PAGE_SIZE ||
            size > ocfs2_max_inline_data_with_xattr(inode->i_sb, di)) {
                ocfs2_error(inode->i_sb,
                            "Inode %llu has with inline data has bad size: %Lu\n",
@@ -247,7 +247,7 @@ int ocfs2_read_inline_data(struct inode *inode, struct page *page,
        if (size)
                memcpy(kaddr, di->id2.i_data.id_data, size);
        /* Clear the remaining part of the page */
-       memset(kaddr + size, 0, PAGE_CACHE_SIZE - size);
+       memset(kaddr + size, 0, PAGE_SIZE - size);
        flush_dcache_page(page);
        kunmap_atomic(kaddr);
 
@@ -282,7 +282,7 @@ static int ocfs2_readpage(struct file *file, struct page *page)
 {
        struct inode *inode = page->mapping->host;
        struct ocfs2_inode_info *oi = OCFS2_I(inode);
-       loff_t start = (loff_t)page->index << PAGE_CACHE_SHIFT;
+       loff_t start = (loff_t)page->index << PAGE_SHIFT;
        int ret, unlock = 1;
 
        trace_ocfs2_readpage((unsigned long long)oi->ip_blkno,
@@ -385,7 +385,7 @@ static int ocfs2_readpages(struct file *filp, struct address_space *mapping,
         * drop out in that case as it's not worth handling here.
         */
        last = list_entry(pages->prev, struct page, lru);
-       start = (loff_t)last->index << PAGE_CACHE_SHIFT;
+       start = (loff_t)last->index << PAGE_SHIFT;
        if (start >= i_size_read(inode))
                goto out_unlock;
 
@@ -511,12 +511,12 @@ static void ocfs2_figure_cluster_boundaries(struct ocfs2_super *osb,
                                            unsigned int *start,
                                            unsigned int *end)
 {
-       unsigned int cluster_start = 0, cluster_end = PAGE_CACHE_SIZE;
+       unsigned int cluster_start = 0, cluster_end = PAGE_SIZE;
 
-       if (unlikely(PAGE_CACHE_SHIFT > osb->s_clustersize_bits)) {
+       if (unlikely(PAGE_SHIFT > osb->s_clustersize_bits)) {
                unsigned int cpp;
 
-               cpp = 1 << (PAGE_CACHE_SHIFT - osb->s_clustersize_bits);
+               cpp = 1 << (PAGE_SHIFT - osb->s_clustersize_bits);
 
                cluster_start = cpos % cpp;
                cluster_start = cluster_start << osb->s_clustersize_bits;
@@ -684,13 +684,13 @@ next_bh:
        return ret;
 }
 
-#if (PAGE_CACHE_SIZE >= OCFS2_MAX_CLUSTERSIZE)
+#if (PAGE_SIZE >= OCFS2_MAX_CLUSTERSIZE)
 #define OCFS2_MAX_CTXT_PAGES   1
 #else
-#define OCFS2_MAX_CTXT_PAGES   (OCFS2_MAX_CLUSTERSIZE / PAGE_CACHE_SIZE)
+#define OCFS2_MAX_CTXT_PAGES   (OCFS2_MAX_CLUSTERSIZE / PAGE_SIZE)
 #endif
 
-#define OCFS2_MAX_CLUSTERS_PER_PAGE    (PAGE_CACHE_SIZE / OCFS2_MIN_CLUSTERSIZE)
+#define OCFS2_MAX_CLUSTERS_PER_PAGE    (PAGE_SIZE / OCFS2_MIN_CLUSTERSIZE)
 
 struct ocfs2_unwritten_extent {
        struct list_head        ue_node;
@@ -785,7 +785,7 @@ void ocfs2_unlock_and_free_pages(struct page **pages, int num_pages)
                if (pages[i]) {
                        unlock_page(pages[i]);
                        mark_page_accessed(pages[i]);
-                       page_cache_release(pages[i]);
+                       put_page(pages[i]);
                }
        }
 }
@@ -808,7 +808,7 @@ static void ocfs2_unlock_pages(struct ocfs2_write_ctxt *wc)
                        }
                }
                mark_page_accessed(wc->w_target_page);
-               page_cache_release(wc->w_target_page);
+               put_page(wc->w_target_page);
        }
        ocfs2_unlock_and_free_pages(wc->w_pages, wc->w_num_pages);
 }
@@ -857,7 +857,7 @@ static int ocfs2_alloc_write_ctxt(struct ocfs2_write_ctxt **wcp,
        wc->w_di_bh = di_bh;
        wc->w_type = type;
 
-       if (unlikely(PAGE_CACHE_SHIFT > osb->s_clustersize_bits))
+       if (unlikely(PAGE_SHIFT > osb->s_clustersize_bits))
                wc->w_large_pages = 1;
        else
                wc->w_large_pages = 0;
@@ -920,7 +920,7 @@ static void ocfs2_write_failure(struct inode *inode,
                                loff_t user_pos, unsigned user_len)
 {
        int i;
-       unsigned from = user_pos & (PAGE_CACHE_SIZE - 1),
+       unsigned from = user_pos & (PAGE_SIZE - 1),
                to = user_pos + user_len;
        struct page *tmppage;
 
@@ -960,7 +960,7 @@ static int ocfs2_prepare_page_for_write(struct inode *inode, u64 *p_blkno,
                        (page_offset(page) <= user_pos));
 
        if (page == wc->w_target_page) {
-               map_from = user_pos & (PAGE_CACHE_SIZE - 1);
+               map_from = user_pos & (PAGE_SIZE - 1);
                map_to = map_from + user_len;
 
                if (new)
@@ -1034,7 +1034,7 @@ static int ocfs2_grab_pages_for_write(struct address_space *mapping,
        struct inode *inode = mapping->host;
        loff_t last_byte;
 
-       target_index = user_pos >> PAGE_CACHE_SHIFT;
+       target_index = user_pos >> PAGE_SHIFT;
 
        /*
         * Figure out how many pages we'll be manipulating here. For
@@ -1053,14 +1053,14 @@ static int ocfs2_grab_pages_for_write(struct address_space *mapping,
                 */
                last_byte = max(user_pos + user_len, i_size_read(inode));
                BUG_ON(last_byte < 1);
-               end_index = ((last_byte - 1) >> PAGE_CACHE_SHIFT) + 1;
+               end_index = ((last_byte - 1) >> PAGE_SHIFT) + 1;
                if ((start + wc->w_num_pages) > end_index)
                        wc->w_num_pages = end_index - start;
        } else {
                wc->w_num_pages = 1;
                start = target_index;
        }
-       end_index = (user_pos + user_len - 1) >> PAGE_CACHE_SHIFT;
+       end_index = (user_pos + user_len - 1) >> PAGE_SHIFT;
 
        for(i = 0; i < wc->w_num_pages; i++) {
                index = start + i;
@@ -1082,7 +1082,7 @@ static int ocfs2_grab_pages_for_write(struct address_space *mapping,
                                goto out;
                        }
 
-                       page_cache_get(mmap_page);
+                       get_page(mmap_page);
                        wc->w_pages[i] = mmap_page;
                        wc->w_target_locked = true;
                } else if (index >= target_index && index <= end_index &&
@@ -1272,7 +1272,7 @@ static void ocfs2_set_target_boundaries(struct ocfs2_super *osb,
 {
        struct ocfs2_write_cluster_desc *desc;
 
-       wc->w_target_from = pos & (PAGE_CACHE_SIZE - 1);
+       wc->w_target_from = pos & (PAGE_SIZE - 1);
        wc->w_target_to = wc->w_target_from + len;
 
        if (alloc == 0)
@@ -1309,7 +1309,7 @@ static void ocfs2_set_target_boundaries(struct ocfs2_super *osb,
                                                        &wc->w_target_to);
        } else {
                wc->w_target_from = 0;
-               wc->w_target_to = PAGE_CACHE_SIZE;
+               wc->w_target_to = PAGE_SIZE;
        }
 }
 
@@ -1981,7 +1981,7 @@ int ocfs2_write_end_nolock(struct address_space *mapping,
                           struct page *page, void *fsdata)
 {
        int i, ret;
-       unsigned from, to, start = pos & (PAGE_CACHE_SIZE - 1);
+       unsigned from, to, start = pos & (PAGE_SIZE - 1);
        struct inode *inode = mapping->host;
        struct ocfs2_super *osb = OCFS2_SB(inode->i_sb);
        struct ocfs2_write_ctxt *wc = fsdata;
@@ -2027,8 +2027,8 @@ int ocfs2_write_end_nolock(struct address_space *mapping,
                        from = wc->w_target_from;
                        to = wc->w_target_to;
 
-                       BUG_ON(from > PAGE_CACHE_SIZE ||
-                              to > PAGE_CACHE_SIZE ||
+                       BUG_ON(from > PAGE_SIZE ||
+                              to > PAGE_SIZE ||
                               to < from);
                } else {
                        /*
@@ -2037,7 +2037,7 @@ int ocfs2_write_end_nolock(struct address_space *mapping,
                         * to flush their entire range.
                         */
                        from = 0;
-                       to = PAGE_CACHE_SIZE;
+                       to = PAGE_SIZE;
                }
 
                if (page_has_buffers(tmppage)) {
@@ -2311,7 +2311,7 @@ static void ocfs2_dio_end_io_write(struct inode *inode,
        /* ocfs2_file_write_iter will get i_mutex, so we need not lock if we
         * are in that context. */
        if (dwc->dw_writer_pid != task_pid_nr(current)) {
-               mutex_lock(&inode->i_mutex);
+               inode_lock(inode);
                locked = 1;
        }
 
@@ -2390,7 +2390,7 @@ out:
                ocfs2_free_alloc_context(meta_ac);
        ocfs2_run_deallocs(osb, &dealloc);
        if (locked)
-               mutex_unlock(&inode->i_mutex);
+               inode_unlock(inode);
        ocfs2_dio_free_write_ctx(inode, dwc);
 }