aboutsummaryrefslogtreecommitdiffstats
path: root/fs/gfs2/bmap.c
diff options
context:
space:
mode:
authorSteven Whitehouse <swhiteho@redhat.com>2006-02-08 06:50:51 -0500
committerSteven Whitehouse <swhiteho@redhat.com>2006-02-08 06:50:51 -0500
commit18ec7d5c3f434aed9661ed10a9e1f48cdeb4981d (patch)
treea7161a4c4b3592052e6772e1c23849de16cac649 /fs/gfs2/bmap.c
parent257f9b4e97e9a6cceeb247cead92119a4396d37b (diff)
[GFS2] Make journaled data files identical to normal files on disk
This is a very large patch, with a few still to be resolved issues so you might want to check out the previous head of the tree since this is known to be unstable. Fixes for the various bugs will be forthcoming shortly. This patch removes the special data format which has been used up till now for journaled data files. Directories still retain the old format so that they will remain on disk compatible with earlier releases. As a result you can now do the following with journaled data files: 1) mmap them 2) export them over NFS 3) convert to/from normal files whenever you want to (the zero length restriction is gone) In addition the level at which GFS' locking is done has changed for all files (since they all now use the page cache) such that the locking is done at the page cache level rather than the level of the fs operations. This should mean that things like loopback mounts and other things which touch the page cache directly should now work. Current known issues: 1. There is a lock mode inversion problem related to the resource group hold function which needs to be resolved. 2. Any significant amount of I/O causes an oops with an offset of hex 320 (NULL pointer dereference) which appears to be related to a journaled data buffer appearing on a list where it shouldn't be. 3. Direct I/O writes are disabled for the time being (will reappear later) 4. There is probably a deadlock between the page lock and GFS' locks under certain combinations of mmap and fs operation I/O. 5. Issue relating to ref counting on internally used inodes causes a hang on umount (discovered before this patch, and not fixed by it) 6. One part of the directory metadata is different from GFS1 and will need to be resolved before next release. Signed-off-by: Steven Whitehouse <swhiteho@redhat.com>
Diffstat (limited to 'fs/gfs2/bmap.c')
-rw-r--r--fs/gfs2/bmap.c59
1 files changed, 12 insertions, 47 deletions
diff --git a/fs/gfs2/bmap.c b/fs/gfs2/bmap.c
index bd194f645c52..4efcd8a39e98 100644
--- a/fs/gfs2/bmap.c
+++ b/fs/gfs2/bmap.c
@@ -18,12 +18,12 @@
18#include "bmap.h" 18#include "bmap.h"
19#include "glock.h" 19#include "glock.h"
20#include "inode.h" 20#include "inode.h"
21#include "jdata.h"
22#include "meta_io.h" 21#include "meta_io.h"
23#include "page.h" 22#include "page.h"
24#include "quota.h" 23#include "quota.h"
25#include "rgrp.h" 24#include "rgrp.h"
26#include "trans.h" 25#include "trans.h"
26#include "dir.h"
27 27
28/* This doesn't need to be that large as max 64 bit pointers in a 4k 28/* This doesn't need to be that large as max 64 bit pointers in a 4k
29 * block is 512, so __u16 is fine for that. It saves stack space to 29 * block is 512, so __u16 is fine for that. It saves stack space to
@@ -90,7 +90,7 @@ int gfs2_unstuff_dinode(struct gfs2_inode *ip, gfs2_unstuffer_t unstuffer,
90{ 90{
91 struct buffer_head *bh, *dibh; 91 struct buffer_head *bh, *dibh;
92 uint64_t block = 0; 92 uint64_t block = 0;
93 int journaled = gfs2_is_jdata(ip); 93 int isdir = gfs2_is_dir(ip);
94 int error; 94 int error;
95 95
96 down_write(&ip->i_rw_mutex); 96 down_write(&ip->i_rw_mutex);
@@ -103,10 +103,10 @@ int gfs2_unstuff_dinode(struct gfs2_inode *ip, gfs2_unstuffer_t unstuffer,
103 /* Get a free block, fill it with the stuffed data, 103 /* Get a free block, fill it with the stuffed data,
104 and write it out to disk */ 104 and write it out to disk */
105 105
106 if (journaled) { 106 if (isdir) {
107 block = gfs2_alloc_meta(ip); 107 block = gfs2_alloc_meta(ip);
108 108
109 error = gfs2_jdata_get_buffer(ip, block, 1, &bh); 109 error = gfs2_dir_get_buffer(ip, block, 1, &bh);
110 if (error) 110 if (error)
111 goto out_brelse; 111 goto out_brelse;
112 gfs2_buffer_copy_tail(bh, 112 gfs2_buffer_copy_tail(bh,
@@ -168,7 +168,7 @@ static unsigned int calc_tree_height(struct gfs2_inode *ip, uint64_t size)
168 if (ip->i_di.di_size > size) 168 if (ip->i_di.di_size > size)
169 size = ip->i_di.di_size; 169 size = ip->i_di.di_size;
170 170
171 if (gfs2_is_jdata(ip)) { 171 if (gfs2_is_dir(ip)) {
172 arr = sdp->sd_jheightsize; 172 arr = sdp->sd_jheightsize;
173 max = sdp->sd_max_jheight; 173 max = sdp->sd_max_jheight;
174 } else { 174 } else {
@@ -377,7 +377,7 @@ static void lookup_block(struct gfs2_inode *ip, struct buffer_head *bh,
377 return; 377 return;
378 378
379 if (height == ip->i_di.di_height - 1 && 379 if (height == ip->i_di.di_height - 1 &&
380 !gfs2_is_jdata(ip)) 380 !gfs2_is_dir(ip))
381 *block = gfs2_alloc_data(ip); 381 *block = gfs2_alloc_data(ip);
382 else 382 else
383 *block = gfs2_alloc_meta(ip); 383 *block = gfs2_alloc_meta(ip);
@@ -430,7 +430,7 @@ int gfs2_block_map(struct gfs2_inode *ip, uint64_t lblock, int *new,
430 if (gfs2_assert_warn(sdp, !gfs2_is_stuffed(ip))) 430 if (gfs2_assert_warn(sdp, !gfs2_is_stuffed(ip)))
431 goto out; 431 goto out;
432 432
433 bsize = (gfs2_is_jdata(ip)) ? sdp->sd_jbsize : sdp->sd_sb.sb_bsize; 433 bsize = (gfs2_is_dir(ip)) ? sdp->sd_jbsize : sdp->sd_sb.sb_bsize;
434 434
435 height = calc_tree_height(ip, (lblock + 1) * bsize); 435 height = calc_tree_height(ip, (lblock + 1) * bsize);
436 if (ip->i_di.di_height < height) { 436 if (ip->i_di.di_height < height) {
@@ -618,7 +618,7 @@ static int do_strip(struct gfs2_inode *ip, struct buffer_head *dibh,
618 sm->sm_first = 0; 618 sm->sm_first = 0;
619 } 619 }
620 620
621 metadata = (height != ip->i_di.di_height - 1) || gfs2_is_jdata(ip); 621 metadata = (height != ip->i_di.di_height - 1);
622 if (metadata) 622 if (metadata)
623 revokes = (height) ? sdp->sd_inptrs : sdp->sd_diptrs; 623 revokes = (height) ? sdp->sd_inptrs : sdp->sd_diptrs;
624 624
@@ -814,33 +814,6 @@ static int do_grow(struct gfs2_inode *ip, uint64_t size)
814 return error; 814 return error;
815} 815}
816 816
817static int truncator_journaled(struct gfs2_inode *ip, uint64_t size)
818{
819 uint64_t lbn, dbn;
820 uint32_t off;
821 struct buffer_head *bh;
822 int new = 0;
823 int error;
824
825 lbn = size;
826 off = do_div(lbn, ip->i_sbd->sd_jbsize);
827
828 error = gfs2_block_map(ip, lbn, &new, &dbn, NULL);
829 if (error || !dbn)
830 return error;
831
832 error = gfs2_jdata_get_buffer(ip, dbn, 0, &bh);
833 if (error)
834 return error;
835
836 gfs2_trans_add_bh(ip->i_gl, bh, 1);
837 gfs2_buffer_clear_tail(bh, sizeof(struct gfs2_meta_header) + off);
838
839 brelse(bh);
840
841 return 0;
842}
843
844static int trunc_start(struct gfs2_inode *ip, uint64_t size) 817static int trunc_start(struct gfs2_inode *ip, uint64_t size)
845{ 818{
846 struct gfs2_sbd *sdp = ip->i_sbd; 819 struct gfs2_sbd *sdp = ip->i_sbd;
@@ -866,12 +839,7 @@ static int trunc_start(struct gfs2_inode *ip, uint64_t size)
866 error = 1; 839 error = 1;
867 840
868 } else { 841 } else {
869 if (journaled) { 842 if (size & (uint64_t)(sdp->sd_sb.sb_bsize - 1))
870 uint64_t junk = size;
871 /* we're just interested in the modulus */
872 if (do_div(junk, sdp->sd_jbsize))
873 error = truncator_journaled(ip, size);
874 } else if (size & (uint64_t)(sdp->sd_sb.sb_bsize - 1))
875 error = gfs2_block_truncate_page(ip->i_vnode->i_mapping); 843 error = gfs2_block_truncate_page(ip->i_vnode->i_mapping);
876 844
877 if (!error) { 845 if (!error) {
@@ -900,10 +868,7 @@ static int trunc_dealloc(struct gfs2_inode *ip, uint64_t size)
900 868
901 if (!size) 869 if (!size)
902 lblock = 0; 870 lblock = 0;
903 else if (gfs2_is_jdata(ip)) { 871 else
904 lblock = size - 1;
905 do_div(lblock, ip->i_sbd->sd_jbsize);
906 } else
907 lblock = (size - 1) >> ip->i_sbd->sd_sb.sb_bsize_shift; 872 lblock = (size - 1) >> ip->i_sbd->sd_sb.sb_bsize_shift;
908 873
909 find_metapath(ip, lblock, &mp); 874 find_metapath(ip, lblock, &mp);
@@ -1051,7 +1016,7 @@ void gfs2_write_calc_reserv(struct gfs2_inode *ip, unsigned int len,
1051 struct gfs2_sbd *sdp = ip->i_sbd; 1016 struct gfs2_sbd *sdp = ip->i_sbd;
1052 unsigned int tmp; 1017 unsigned int tmp;
1053 1018
1054 if (gfs2_is_jdata(ip)) { 1019 if (gfs2_is_dir(ip)) {
1055 *data_blocks = DIV_RU(len, sdp->sd_jbsize) + 2; 1020 *data_blocks = DIV_RU(len, sdp->sd_jbsize) + 2;
1056 *ind_blocks = 3 * (sdp->sd_max_jheight - 1); 1021 *ind_blocks = 3 * (sdp->sd_max_jheight - 1);
1057 } else { 1022 } else {
@@ -1096,7 +1061,7 @@ int gfs2_write_alloc_required(struct gfs2_inode *ip, uint64_t offset,
1096 return 0; 1061 return 0;
1097 } 1062 }
1098 1063
1099 if (gfs2_is_jdata(ip)) { 1064 if (gfs2_is_dir(ip)) {
1100 unsigned int bsize = sdp->sd_jbsize; 1065 unsigned int bsize = sdp->sd_jbsize;
1101 lblock = offset; 1066 lblock = offset;
1102 do_div(lblock, bsize); 1067 do_div(lblock, bsize);