patch-2.3.26 linux/fs/bfs/inode.c

Next file: linux/fs/buffer.c
Previous file: linux/fs/bfs/file.c
Back to the patch index
Back to the overall index

diff -u --recursive --new-file v2.3.25/linux/fs/bfs/inode.c linux/fs/bfs/inode.c
@@ -196,6 +196,7 @@
 {
 	brelse(s->su_sbh);
 	kfree(s->su_imap);
+	kfree(s->su_bmap);
 	MOD_DEC_USE_COUNT;
 }
 
@@ -243,7 +244,6 @@
 
 	if (!tmpbuf)
 		return;
-	memset(tmpbuf, 0, 400);
 	for (i=s->su_lasti; i>=0; i--) {
 		if (i>PAGE_SIZE-100) break;
 		if (test_bit(i, s->su_imap))
@@ -295,24 +295,33 @@
 	s->su_lasti = (bfs_sb->s_start - BFS_BSIZE)/sizeof(struct bfs_inode) 
 			+ BFS_ROOT_INO - 1;
 
+	s->su_bmap = kmalloc(sizeof(struct bfs_bmap) * s->su_lasti, GFP_KERNEL);
+	if (!s->su_bmap)
+		goto out;
 	imap_len = s->su_lasti/8 + 1;
 	s->su_imap = kmalloc(imap_len, GFP_KERNEL);
-	if (!s->su_imap)
+	if (!s->su_imap) {
+		kfree(s->su_bmap);
 		goto out;
+	}
 	memset(s->su_imap, 0, imap_len);
-	for (i=0; i<BFS_ROOT_INO; i++)
+	for (i=0; i<BFS_ROOT_INO; i++) {
+		s->su_bmap[i].start = s->su_bmap[i].end = 0;
 		set_bit(i, s->su_imap);
+	}
 
 	s->s_op = &bfs_sops;
 	inode = iget(s, BFS_ROOT_INO);
 	if (!inode) {
 		kfree(s->su_imap);
+		kfree(s->su_bmap);
 		goto out;
 	}
 	s->s_root = d_alloc_root(inode);
 	if (!s->s_root) {
 		iput(inode);
 		kfree(s->su_imap);
+		kfree(s->su_bmap);
 		goto out;
 	}
 
@@ -324,9 +333,10 @@
 	s->su_lf_ioff = 0;
 	for (i=BFS_ROOT_INO; i<=s->su_lasti; i++) {
 		inode = iget(s,i);
-		if (inode->iu_dsk_ino == 0)
+		if (inode->iu_dsk_ino == 0) {
 			s->su_freei++;
-		else {
+			s->su_bmap[i].start = s->su_bmap[i].end = 0;
+		} else {
 			set_bit(i, s->su_imap);
 			s->su_freeb -= inode->i_blocks;
 			if (inode->iu_eblock > s->su_lf_eblk) {
@@ -334,6 +344,8 @@
 				s->su_lf_sblk = inode->iu_sblock;
 				s->su_lf_ioff = BFS_INO2OFF(i);
 			}
+			s->su_bmap[i].start = inode->iu_sblock;
+			s->su_bmap[i].end = inode->iu_eblock;
 		}
 		iput(inode);
 	}

FUNET's LINUX-ADM group, linux-adm@nic.funet.fi
TCL-scripts by Sam Shen (who was at: slshen@lbl.gov)