diff options
author | Steven Whitehouse <swhiteho@redhat.com> | 2007-10-17 03:35:19 -0400 |
---|---|---|
committer | Steven Whitehouse <swhiteho@redhat.com> | 2008-01-25 03:07:21 -0500 |
commit | bf36a713169432643d4fc7eeb4e0ace96d791d26 (patch) | |
tree | 2cb69c9716b9ee8c687ef807bb88d5e635db3462 /fs | |
parent | e7e36f143565d14950055c893cfaf4400ad64d34 (diff) |
[GFS2] Add gfs2_is_writeback()
This adds a function "gfs2_is_writeback()" along the lines of the
existing "gfs2_is_jdata()" in order to clean up the code and make
the various tests for the inode mode more obvious. It also fixes
the PageChecked() logic where we were resetting the flag too early
in the case of an error path.
Signed-off-by: Steven Whitehouse <swhiteho@redhat.com>
Diffstat (limited to 'fs')
-rw-r--r-- | fs/gfs2/bmap.c | 6 | ||||
-rw-r--r-- | fs/gfs2/incore.h | 2 | ||||
-rw-r--r-- | fs/gfs2/inode.h | 6 | ||||
-rw-r--r-- | fs/gfs2/ops_address.c | 10 |
4 files changed, 13 insertions, 11 deletions
diff --git a/fs/gfs2/bmap.c b/fs/gfs2/bmap.c index 93fa427bb5f5..1cfd493e30fb 100644 --- a/fs/gfs2/bmap.c +++ b/fs/gfs2/bmap.c | |||
@@ -59,7 +59,6 @@ struct strip_mine { | |||
59 | static int gfs2_unstuffer_page(struct gfs2_inode *ip, struct buffer_head *dibh, | 59 | static int gfs2_unstuffer_page(struct gfs2_inode *ip, struct buffer_head *dibh, |
60 | u64 block, struct page *page) | 60 | u64 block, struct page *page) |
61 | { | 61 | { |
62 | struct gfs2_sbd *sdp = GFS2_SB(&ip->i_inode); | ||
63 | struct inode *inode = &ip->i_inode; | 62 | struct inode *inode = &ip->i_inode; |
64 | struct buffer_head *bh; | 63 | struct buffer_head *bh; |
65 | int release = 0; | 64 | int release = 0; |
@@ -95,7 +94,7 @@ static int gfs2_unstuffer_page(struct gfs2_inode *ip, struct buffer_head *dibh, | |||
95 | set_buffer_uptodate(bh); | 94 | set_buffer_uptodate(bh); |
96 | if (!gfs2_is_jdata(ip)) | 95 | if (!gfs2_is_jdata(ip)) |
97 | mark_buffer_dirty(bh); | 96 | mark_buffer_dirty(bh); |
98 | if (sdp->sd_args.ar_data == GFS2_DATA_ORDERED || gfs2_is_jdata(ip)) | 97 | if (!gfs2_is_writeback(ip)) |
99 | gfs2_trans_add_bh(ip->i_gl, bh, 0); | 98 | gfs2_trans_add_bh(ip->i_gl, bh, 0); |
100 | 99 | ||
101 | if (release) { | 100 | if (release) { |
@@ -879,7 +878,6 @@ static int gfs2_block_truncate_page(struct address_space *mapping) | |||
879 | { | 878 | { |
880 | struct inode *inode = mapping->host; | 879 | struct inode *inode = mapping->host; |
881 | struct gfs2_inode *ip = GFS2_I(inode); | 880 | struct gfs2_inode *ip = GFS2_I(inode); |
882 | struct gfs2_sbd *sdp = GFS2_SB(inode); | ||
883 | loff_t from = inode->i_size; | 881 | loff_t from = inode->i_size; |
884 | unsigned long index = from >> PAGE_CACHE_SHIFT; | 882 | unsigned long index = from >> PAGE_CACHE_SHIFT; |
885 | unsigned offset = from & (PAGE_CACHE_SIZE-1); | 883 | unsigned offset = from & (PAGE_CACHE_SIZE-1); |
@@ -931,7 +929,7 @@ static int gfs2_block_truncate_page(struct address_space *mapping) | |||
931 | err = 0; | 929 | err = 0; |
932 | } | 930 | } |
933 | 931 | ||
934 | if (sdp->sd_args.ar_data == GFS2_DATA_ORDERED || gfs2_is_jdata(ip)) | 932 | if (!gfs2_is_writeback(ip)) |
935 | gfs2_trans_add_bh(ip->i_gl, bh, 0); | 933 | gfs2_trans_add_bh(ip->i_gl, bh, 0); |
936 | 934 | ||
937 | zero_user_page(page, offset, length, KM_USER0); | 935 | zero_user_page(page, offset, length, KM_USER0); |
diff --git a/fs/gfs2/incore.h b/fs/gfs2/incore.h index e53da7d4cfff..82dfe9bd270b 100644 --- a/fs/gfs2/incore.h +++ b/fs/gfs2/incore.h | |||
@@ -285,7 +285,7 @@ static inline struct gfs2_inode *GFS2_I(struct inode *inode) | |||
285 | return container_of(inode, struct gfs2_inode, i_inode); | 285 | return container_of(inode, struct gfs2_inode, i_inode); |
286 | } | 286 | } |
287 | 287 | ||
288 | static inline struct gfs2_sbd *GFS2_SB(struct inode *inode) | 288 | static inline struct gfs2_sbd *GFS2_SB(const struct inode *inode) |
289 | { | 289 | { |
290 | return inode->i_sb->s_fs_info; | 290 | return inode->i_sb->s_fs_info; |
291 | } | 291 | } |
diff --git a/fs/gfs2/inode.h b/fs/gfs2/inode.h index 351ac87ab384..bed3dc212a18 100644 --- a/fs/gfs2/inode.h +++ b/fs/gfs2/inode.h | |||
@@ -20,6 +20,12 @@ static inline int gfs2_is_jdata(const struct gfs2_inode *ip) | |||
20 | return ip->i_di.di_flags & GFS2_DIF_JDATA; | 20 | return ip->i_di.di_flags & GFS2_DIF_JDATA; |
21 | } | 21 | } |
22 | 22 | ||
23 | static inline int gfs2_is_writeback(const struct gfs2_inode *ip) | ||
24 | { | ||
25 | const struct gfs2_sbd *sdp = GFS2_SB(&ip->i_inode); | ||
26 | return (sdp->sd_args.ar_data == GFS2_DATA_WRITEBACK) && !gfs2_is_jdata(ip); | ||
27 | } | ||
28 | |||
23 | static inline int gfs2_is_dir(const struct gfs2_inode *ip) | 29 | static inline int gfs2_is_dir(const struct gfs2_inode *ip) |
24 | { | 30 | { |
25 | return S_ISDIR(ip->i_inode.i_mode); | 31 | return S_ISDIR(ip->i_inode.i_mode); |
diff --git a/fs/gfs2/ops_address.c b/fs/gfs2/ops_address.c index 4c4ef7f59909..ed154af86171 100644 --- a/fs/gfs2/ops_address.c +++ b/fs/gfs2/ops_address.c | |||
@@ -138,12 +138,11 @@ static int gfs2_writepage(struct page *page, struct writeback_control *wbc) | |||
138 | return 0; /* don't care */ | 138 | return 0; /* don't care */ |
139 | } | 139 | } |
140 | 140 | ||
141 | if ((sdp->sd_args.ar_data == GFS2_DATA_ORDERED || gfs2_is_jdata(ip)) && | 141 | if (PageChecked(page)) { |
142 | PageChecked(page)) { | ||
143 | ClearPageChecked(page); | ||
144 | error = gfs2_trans_begin(sdp, RES_DINODE + 1, 0); | 142 | error = gfs2_trans_begin(sdp, RES_DINODE + 1, 0); |
145 | if (error) | 143 | if (error) |
146 | goto out_ignore; | 144 | goto out_ignore; |
145 | ClearPageChecked(page); | ||
147 | if (!page_has_buffers(page)) { | 146 | if (!page_has_buffers(page)) { |
148 | create_empty_buffers(page, inode->i_sb->s_blocksize, | 147 | create_empty_buffers(page, inode->i_sb->s_blocksize, |
149 | (1 << BH_Dirty)|(1 << BH_Uptodate)); | 148 | (1 << BH_Dirty)|(1 << BH_Uptodate)); |
@@ -180,9 +179,8 @@ static int gfs2_writepages(struct address_space *mapping, | |||
180 | { | 179 | { |
181 | struct inode *inode = mapping->host; | 180 | struct inode *inode = mapping->host; |
182 | struct gfs2_inode *ip = GFS2_I(inode); | 181 | struct gfs2_inode *ip = GFS2_I(inode); |
183 | struct gfs2_sbd *sdp = GFS2_SB(inode); | ||
184 | 182 | ||
185 | if (sdp->sd_args.ar_data == GFS2_DATA_WRITEBACK && !gfs2_is_jdata(ip)) | 183 | if (gfs2_is_writeback(ip)) |
186 | return mpage_writepages(mapping, wbc, gfs2_get_block_noalloc); | 184 | return mpage_writepages(mapping, wbc, gfs2_get_block_noalloc); |
187 | 185 | ||
188 | return generic_writepages(mapping, wbc); | 186 | return generic_writepages(mapping, wbc); |
@@ -606,7 +604,7 @@ static int gfs2_write_end(struct file *file, struct address_space *mapping, | |||
606 | if (gfs2_is_stuffed(ip)) | 604 | if (gfs2_is_stuffed(ip)) |
607 | return gfs2_stuffed_write_end(inode, dibh, pos, len, copied, page); | 605 | return gfs2_stuffed_write_end(inode, dibh, pos, len, copied, page); |
608 | 606 | ||
609 | if (sdp->sd_args.ar_data == GFS2_DATA_ORDERED || gfs2_is_jdata(ip)) | 607 | if (!gfs2_is_writeback(ip)) |
610 | gfs2_page_add_databufs(ip, page, from, to); | 608 | gfs2_page_add_databufs(ip, page, from, to); |
611 | 609 | ||
612 | ret = generic_write_end(file, mapping, pos, len, copied, page, fsdata); | 610 | ret = generic_write_end(file, mapping, pos, len, copied, page, fsdata); |