Merge branch 'i2c/for-next' of git://git.kernel.org/pub/scm/linux/kernel/git/wsa...
[platform/adaptation/renesas_rcar/renesas_kernel.git] / fs / nilfs2 / inode.c
index 689fb60..b1a5277 100644 (file)
@@ -54,7 +54,7 @@ void nilfs_inode_add_blocks(struct inode *inode, int n)
 
        inode_add_bytes(inode, (1 << inode->i_blkbits) * n);
        if (root)
-               atomic_add(n, &root->blocks_count);
+               atomic64_add(n, &root->blocks_count);
 }
 
 void nilfs_inode_sub_blocks(struct inode *inode, int n)
@@ -63,7 +63,7 @@ void nilfs_inode_sub_blocks(struct inode *inode, int n)
 
        inode_sub_bytes(inode, (1 << inode->i_blkbits) * n);
        if (root)
-               atomic_sub(n, &root->blocks_count);
+               atomic64_sub(n, &root->blocks_count);
 }
 
 /**
@@ -219,13 +219,32 @@ static int nilfs_writepage(struct page *page, struct writeback_control *wbc)
 
 static int nilfs_set_page_dirty(struct page *page)
 {
-       int ret = __set_page_dirty_buffers(page);
+       int ret = __set_page_dirty_nobuffers(page);
 
-       if (ret) {
+       if (page_has_buffers(page)) {
                struct inode *inode = page->mapping->host;
-               unsigned nr_dirty = 1 << (PAGE_SHIFT - inode->i_blkbits);
+               unsigned nr_dirty = 0;
+               struct buffer_head *bh, *head;
 
-               nilfs_set_file_dirty(inode, nr_dirty);
+               /*
+                * This page is locked by callers, and no other thread
+                * concurrently marks its buffers dirty since they are
+                * only dirtied through routines in fs/buffer.c in
+                * which call sites of mark_buffer_dirty are protected
+                * by page lock.
+                */
+               bh = head = page_buffers(page);
+               do {
+                       /* Do not mark hole blocks dirty */
+                       if (buffer_dirty(bh) || !buffer_mapped(bh))
+                               continue;
+
+                       set_buffer_dirty(bh);
+                       nr_dirty++;
+               } while (bh = bh->b_this_page, bh != head);
+
+               if (nr_dirty)
+                       nilfs_set_file_dirty(inode, nr_dirty);
        }
        return ret;
 }
@@ -350,7 +369,7 @@ struct inode *nilfs_new_inode(struct inode *dir, umode_t mode)
                goto failed_ifile_create_inode;
        /* reference count of i_bh inherits from nilfs_mdt_read_block() */
 
-       atomic_inc(&root->inodes_count);
+       atomic64_inc(&root->inodes_count);
        inode_init_owner(inode, dir, mode);
        inode->i_ino = ino;
        inode->i_mtime = inode->i_atime = inode->i_ctime = CURRENT_TIME;
@@ -782,7 +801,7 @@ void nilfs_evict_inode(struct inode *inode)
 
        ret = nilfs_ifile_delete_inode(ii->i_root->ifile, inode->i_ino);
        if (!ret)
-               atomic_dec(&ii->i_root->inodes_count);
+               atomic64_dec(&ii->i_root->inodes_count);
 
        nilfs_clear_inode(inode);