ocfs2: use i_size_read() to access i_size
authorJunxiao Bi <junxiao.bi@oracle.com>
Wed, 11 Sep 2013 21:19:45 +0000 (14:19 -0700)
committerLinus Torvalds <torvalds@linux-foundation.org>
Wed, 11 Sep 2013 22:56:30 +0000 (15:56 -0700)
Though ocfs2 uses inode->i_mutex to protect i_size, there are both
i_size_read/write() and direct accesses.  Clean up all direct access to
eliminate confusion.

Signed-off-by: Junxiao Bi <junxiao.bi@oracle.com>
Cc: Jie Liu <jeff.liu@oracle.com>
Cc: Mark Fasheh <mfasheh@suse.com>
Cc: Joel Becker <jlbec@evilplan.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
fs/ocfs2/aops.c
fs/ocfs2/extent_map.c
fs/ocfs2/ioctl.c
fs/ocfs2/journal.c
fs/ocfs2/move_extents.c
fs/ocfs2/quota_global.c
fs/ocfs2/quota_local.c

index 94417a85ce6eecce9ce3367365fb2d40581c5a7e..f37d3c0e20535eacce542c7184f48d8b509884a2 100644 (file)
@@ -2044,7 +2044,7 @@ int ocfs2_write_end_nolock(struct address_space *mapping,
 
 out_write_size:
        pos += copied;
-       if (pos > inode->i_size) {
+       if (pos > i_size_read(inode)) {
                i_size_write(inode, pos);
                mark_inode_dirty(inode);
        }
index 2487116d0d3312981834aa3667fd708dc7aa05ab..4bf2b763467fd78bb0dbc316b49b6f341f3125e7 100644 (file)
@@ -852,20 +852,20 @@ int ocfs2_seek_data_hole_offset(struct file *file, loff_t *offset, int whence)
 
        down_read(&OCFS2_I(inode)->ip_alloc_sem);
 
-       if (*offset >= inode->i_size) {
+       if (*offset >= i_size_read(inode)) {
                ret = -ENXIO;
                goto out_unlock;
        }
 
        if (OCFS2_I(inode)->ip_dyn_features & OCFS2_INLINE_DATA_FL) {
                if (whence == SEEK_HOLE)
-                       *offset = inode->i_size;
+                       *offset = i_size_read(inode);
                goto out_unlock;
        }
 
        clen = 0;
        cpos = *offset >> cs_bits;
-       cend = ocfs2_clusters_for_bytes(inode->i_sb, inode->i_size);
+       cend = ocfs2_clusters_for_bytes(inode->i_sb, i_size_read(inode));
 
        while (cpos < cend && !is_last) {
                ret = ocfs2_get_clusters_nocache(inode, di_bh, cpos, &hole_size,
@@ -904,8 +904,8 @@ int ocfs2_seek_data_hole_offset(struct file *file, loff_t *offset, int whence)
                extlen = clen;
                extlen <<=  cs_bits;
 
-               if ((extoff + extlen) > inode->i_size)
-                       extlen = inode->i_size - extoff;
+               if ((extoff + extlen) > i_size_read(inode))
+                       extlen = i_size_read(inode) - extoff;
                extoff += extlen;
                if (extoff > *offset)
                        *offset = extoff;
index 0c60ef2d8056ea4412e1338a3580f03acc72210a..fa32ce9b455df9ad7ff06e812ad79eb8f42a4e4b 100644 (file)
@@ -303,7 +303,7 @@ int ocfs2_info_handle_journal_size(struct inode *inode,
        if (o2info_from_user(oij, req))
                goto bail;
 
-       oij.ij_journal_size = osb->journal->j_inode->i_size;
+       oij.ij_journal_size = i_size_read(osb->journal->j_inode);
 
        o2info_set_request_filled(&oij.ij_req);
 
index a126cb37ca4d690a8445bdcadc26bb6c8bda362e..44fc3e530c3d82c5a0d42d838461365cc53d72f3 100644 (file)
@@ -836,14 +836,14 @@ int ocfs2_journal_init(struct ocfs2_journal *journal, int *dirty)
        inode_lock = 1;
        di = (struct ocfs2_dinode *)bh->b_data;
 
-       if (inode->i_size <  OCFS2_MIN_JOURNAL_SIZE) {
+       if (i_size_read(inode) <  OCFS2_MIN_JOURNAL_SIZE) {
                mlog(ML_ERROR, "Journal file size (%lld) is too small!\n",
-                    inode->i_size);
+                    i_size_read(inode));
                status = -EINVAL;
                goto done;
        }
 
-       trace_ocfs2_journal_init(inode->i_size,
+       trace_ocfs2_journal_init(i_size_read(inode),
                                 (unsigned long long)inode->i_blocks,
                                 OCFS2_I(inode)->ip_clusters);
 
@@ -1131,7 +1131,7 @@ static int ocfs2_force_read_journal(struct inode *inode)
 
        memset(bhs, 0, sizeof(struct buffer_head *) * CONCURRENT_JOURNAL_FILL);
 
-       num_blocks = ocfs2_blocks_for_bytes(inode->i_sb, inode->i_size);
+       num_blocks = ocfs2_blocks_for_bytes(inode->i_sb, i_size_read(inode));
        v_blkno = 0;
        while (v_blkno < num_blocks) {
                status = ocfs2_extent_map_get_blocks(inode, v_blkno,
index 452068b45749a7545002543f0b0b450b52612dec..415928536c5e91185cbe2833ecc4757097fc05b5 100644 (file)
@@ -845,7 +845,7 @@ static int __ocfs2_move_extents_range(struct buffer_head *di_bh,
        struct ocfs2_move_extents *range = context->range;
        struct ocfs2_super *osb = OCFS2_SB(inode->i_sb);
 
-       if ((inode->i_size == 0) || (range->me_len == 0))
+       if ((i_size_read(inode) == 0) || (range->me_len == 0))
                return 0;
 
        if (OCFS2_I(inode)->ip_dyn_features & OCFS2_INLINE_DATA_FL)
index 332a281f217ed021dee419722bd4dd5ca83de9a9..aaa50611ec66c27f2b6cd9a67a039a05e0253787 100644 (file)
@@ -234,7 +234,7 @@ ssize_t ocfs2_quota_write(struct super_block *sb, int type,
                len = sb->s_blocksize - OCFS2_QBLK_RESERVED_SPACE - offset;
        }
 
-       if (gqinode->i_size < off + len) {
+       if (i_size_read(gqinode) < off + len) {
                loff_t rounded_end =
                                ocfs2_align_bytes_to_blocks(sb, off + len);
 
@@ -778,8 +778,8 @@ static int ocfs2_acquire_dquot(struct dquot *dquot)
                 */
                WARN_ON(journal_current_handle());
                status = ocfs2_extend_no_holes(gqinode, NULL,
-                       gqinode->i_size + (need_alloc << sb->s_blocksize_bits),
-                       gqinode->i_size);
+                       i_size_read(gqinode) + (need_alloc << sb->s_blocksize_bits),
+                       i_size_read(gqinode));
                if (status < 0)
                        goto out_dq;
        }
index 27fe7ee4874cbac39381b90694e0ce7c0c11ce66..2e4344be3b962b40a6cd4e5743a87f088b7abe63 100644 (file)
@@ -982,14 +982,14 @@ static struct ocfs2_quota_chunk *ocfs2_local_quota_add_chunk(
 
        /* We are protected by dqio_sem so no locking needed */
        status = ocfs2_extend_no_holes(lqinode, NULL,
-                                      lqinode->i_size + 2 * sb->s_blocksize,
-                                      lqinode->i_size);
+                                      i_size_read(lqinode) + 2 * sb->s_blocksize,
+                                      i_size_read(lqinode));
        if (status < 0) {
                mlog_errno(status);
                goto out;
        }
        status = ocfs2_simple_size_update(lqinode, oinfo->dqi_lqi_bh,
-                                         lqinode->i_size + 2 * sb->s_blocksize);
+                                         i_size_read(lqinode) + 2 * sb->s_blocksize);
        if (status < 0) {
                mlog_errno(status);
                goto out;
@@ -1125,14 +1125,14 @@ static struct ocfs2_quota_chunk *ocfs2_extend_local_quota_file(
 
        /* We are protected by dqio_sem so no locking needed */
        status = ocfs2_extend_no_holes(lqinode, NULL,
-                                      lqinode->i_size + sb->s_blocksize,
-                                      lqinode->i_size);
+                                      i_size_read(lqinode) + sb->s_blocksize,
+                                      i_size_read(lqinode));
        if (status < 0) {
                mlog_errno(status);
                goto out;
        }
        status = ocfs2_simple_size_update(lqinode, oinfo->dqi_lqi_bh,
-                                         lqinode->i_size + sb->s_blocksize);
+                                         i_size_read(lqinode) + sb->s_blocksize);
        if (status < 0) {
                mlog_errno(status);
                goto out;