aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAl Viro <viro@zeniv.linux.org.uk>2012-04-06 14:30:07 -0400
committerAl Viro <viro@zeniv.linux.org.uk>2012-05-29 23:28:37 -0400
commitc4c995430a94e7d94526fcb347c4ba4b2ae82500 (patch)
tree00dd49eb6252305e90106a375fc3fa12d25f4d1b
parent4085e155b14a89ee36f7bfc5bd07294b0c34b0e6 (diff)
hpfs: get rid of bitfields in struct fnode
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
-rw-r--r--fs/hpfs/anode.c4
-rw-r--r--fs/hpfs/dir.c2
-rw-r--r--fs/hpfs/dnode.c2
-rw-r--r--fs/hpfs/ea.c24
-rw-r--r--fs/hpfs/hpfs.h32
-rw-r--r--fs/hpfs/inode.c2
-rw-r--r--fs/hpfs/map.c2
-rw-r--r--fs/hpfs/namei.c2
8 files changed, 32 insertions, 38 deletions
diff --git a/fs/hpfs/anode.c b/fs/hpfs/anode.c
index 3cb4d9c3eca4..ec5f8b9e5c2a 100644
--- a/fs/hpfs/anode.c
+++ b/fs/hpfs/anode.c
@@ -479,13 +479,13 @@ void hpfs_remove_fnode(struct super_block *s, fnode_secno fno)
479 struct extended_attribute *ea; 479 struct extended_attribute *ea;
480 struct extended_attribute *ea_end; 480 struct extended_attribute *ea_end;
481 if (!(fnode = hpfs_map_fnode(s, fno, &bh))) return; 481 if (!(fnode = hpfs_map_fnode(s, fno, &bh))) return;
482 if (!fnode->dirflag) hpfs_remove_btree(s, &fnode->btree); 482 if (!fnode_is_dir(fnode)) hpfs_remove_btree(s, &fnode->btree);
483 else hpfs_remove_dtree(s, le32_to_cpu(fnode->u.external[0].disk_secno)); 483 else hpfs_remove_dtree(s, le32_to_cpu(fnode->u.external[0].disk_secno));
484 ea_end = fnode_end_ea(fnode); 484 ea_end = fnode_end_ea(fnode);
485 for (ea = fnode_ea(fnode); ea < ea_end; ea = next_ea(ea)) 485 for (ea = fnode_ea(fnode); ea < ea_end; ea = next_ea(ea))
486 if (ea_indirect(ea)) 486 if (ea_indirect(ea))
487 hpfs_ea_remove(s, ea_sec(ea), ea_in_anode(ea), ea_len(ea)); 487 hpfs_ea_remove(s, ea_sec(ea), ea_in_anode(ea), ea_len(ea));
488 hpfs_ea_ext_remove(s, le32_to_cpu(fnode->ea_secno), fnode->ea_anode, le32_to_cpu(fnode->ea_size_l)); 488 hpfs_ea_ext_remove(s, le32_to_cpu(fnode->ea_secno), fnode_in_anode(fnode), le32_to_cpu(fnode->ea_size_l));
489 brelse(bh); 489 brelse(bh);
490 hpfs_free_sectors(s, fno, 1); 490 hpfs_free_sectors(s, fno, 1);
491} 491}
diff --git a/fs/hpfs/dir.c b/fs/hpfs/dir.c
index 2fa0089a02a8..b8472f803f4e 100644
--- a/fs/hpfs/dir.c
+++ b/fs/hpfs/dir.c
@@ -87,7 +87,7 @@ static int hpfs_readdir(struct file *filp, void *dirent, filldir_t filldir)
87 ret = -EIOERROR; 87 ret = -EIOERROR;
88 goto out; 88 goto out;
89 } 89 }
90 if (!fno->dirflag) { 90 if (!fnode_is_dir(fno)) {
91 e = 1; 91 e = 1;
92 hpfs_error(inode->i_sb, "not a directory, fnode %08lx", 92 hpfs_error(inode->i_sb, "not a directory, fnode %08lx",
93 (unsigned long)inode->i_ino); 93 (unsigned long)inode->i_ino);
diff --git a/fs/hpfs/dnode.c b/fs/hpfs/dnode.c
index 1e0e2ac30fd3..6bf9fdeba6f2 100644
--- a/fs/hpfs/dnode.c
+++ b/fs/hpfs/dnode.c
@@ -1015,7 +1015,7 @@ struct hpfs_dirent *map_fnode_dirent(struct super_block *s, fnode_secno fno,
1015 kfree(name2); 1015 kfree(name2);
1016 return NULL; 1016 return NULL;
1017 } 1017 }
1018 if (!upf->dirflag) { 1018 if (!fnode_is_dir(upf)) {
1019 brelse(bh); 1019 brelse(bh);
1020 hpfs_error(s, "fnode %08x has non-directory parent %08x", fno, le32_to_cpu(f->up)); 1020 hpfs_error(s, "fnode %08x has non-directory parent %08x", fno, le32_to_cpu(f->up));
1021 kfree(name2); 1021 kfree(name2);
diff --git a/fs/hpfs/ea.c b/fs/hpfs/ea.c
index 7cd0092771f4..bcaafcd2666a 100644
--- a/fs/hpfs/ea.c
+++ b/fs/hpfs/ea.c
@@ -91,7 +91,7 @@ int hpfs_read_ea(struct super_block *s, struct fnode *fnode, char *key,
91 } 91 }
92 a = le32_to_cpu(fnode->ea_secno); 92 a = le32_to_cpu(fnode->ea_secno);
93 len = le32_to_cpu(fnode->ea_size_l); 93 len = le32_to_cpu(fnode->ea_size_l);
94 ano = fnode->ea_anode; 94 ano = fnode_in_anode(fnode);
95 pos = 0; 95 pos = 0;
96 while (pos < len) { 96 while (pos < len) {
97 ea = (struct extended_attribute *)ex; 97 ea = (struct extended_attribute *)ex;
@@ -148,7 +148,7 @@ char *hpfs_get_ea(struct super_block *s, struct fnode *fnode, char *key, int *si
148 } 148 }
149 a = le32_to_cpu(fnode->ea_secno); 149 a = le32_to_cpu(fnode->ea_secno);
150 len = le32_to_cpu(fnode->ea_size_l); 150 len = le32_to_cpu(fnode->ea_size_l);
151 ano = fnode->ea_anode; 151 ano = fnode_in_anode(fnode);
152 pos = 0; 152 pos = 0;
153 while (pos < len) { 153 while (pos < len) {
154 char ex[4 + 255 + 1 + 8]; 154 char ex[4 + 255 + 1 + 8];
@@ -209,7 +209,7 @@ void hpfs_set_ea(struct inode *inode, struct fnode *fnode, const char *key,
209 } 209 }
210 a = le32_to_cpu(fnode->ea_secno); 210 a = le32_to_cpu(fnode->ea_secno);
211 len = le32_to_cpu(fnode->ea_size_l); 211 len = le32_to_cpu(fnode->ea_size_l);
212 ano = fnode->ea_anode; 212 ano = fnode_in_anode(fnode);
213 pos = 0; 213 pos = 0;
214 while (pos < len) { 214 while (pos < len) {
215 char ex[4 + 255 + 1 + 8]; 215 char ex[4 + 255 + 1 + 8];
@@ -276,7 +276,7 @@ void hpfs_set_ea(struct inode *inode, struct fnode *fnode, const char *key,
276 fnode->ea_size_l = cpu_to_le32(le16_to_cpu(fnode->ea_size_s)); 276 fnode->ea_size_l = cpu_to_le32(le16_to_cpu(fnode->ea_size_s));
277 fnode->ea_size_s = cpu_to_le16(0); 277 fnode->ea_size_s = cpu_to_le16(0);
278 fnode->ea_secno = cpu_to_le32(n); 278 fnode->ea_secno = cpu_to_le32(n);
279 fnode->ea_anode = cpu_to_le32(0); 279 fnode->flags &= ~FNODE_anode;
280 mark_buffer_dirty(bh); 280 mark_buffer_dirty(bh);
281 brelse(bh); 281 brelse(bh);
282 } 282 }
@@ -288,9 +288,9 @@ void hpfs_set_ea(struct inode *inode, struct fnode *fnode, const char *key,
288 secno q = hpfs_alloc_sector(s, fno, 1, 0); 288 secno q = hpfs_alloc_sector(s, fno, 1, 0);
289 if (!q) goto bail; 289 if (!q) goto bail;
290 fnode->ea_secno = cpu_to_le32(q); 290 fnode->ea_secno = cpu_to_le32(q);
291 fnode->ea_anode = 0; 291 fnode->flags &= ~FNODE_anode;
292 len++; 292 len++;
293 } else if (!fnode->ea_anode) { 293 } else if (!fnode_in_anode(fnode)) {
294 if (hpfs_alloc_if_possible(s, le32_to_cpu(fnode->ea_secno) + len)) { 294 if (hpfs_alloc_if_possible(s, le32_to_cpu(fnode->ea_secno) + len)) {
295 len++; 295 len++;
296 } else { 296 } else {
@@ -310,7 +310,7 @@ void hpfs_set_ea(struct inode *inode, struct fnode *fnode, const char *key,
310 anode->u.external[0].length = cpu_to_le32(len); 310 anode->u.external[0].length = cpu_to_le32(len);
311 mark_buffer_dirty(bh); 311 mark_buffer_dirty(bh);
312 brelse(bh); 312 brelse(bh);
313 fnode->ea_anode = 1; 313 fnode->flags |= FNODE_anode;
314 fnode->ea_secno = cpu_to_le32(a_s);*/ 314 fnode->ea_secno = cpu_to_le32(a_s);*/
315 secno new_sec; 315 secno new_sec;
316 int i; 316 int i;
@@ -338,7 +338,7 @@ void hpfs_set_ea(struct inode *inode, struct fnode *fnode, const char *key,
338 len = (pos + 511) >> 9; 338 len = (pos + 511) >> 9;
339 } 339 }
340 } 340 }
341 if (fnode->ea_anode) { 341 if (fnode_in_anode(fnode)) {
342 if (hpfs_add_sector_to_btree(s, le32_to_cpu(fnode->ea_secno), 342 if (hpfs_add_sector_to_btree(s, le32_to_cpu(fnode->ea_secno),
343 0, len) != -1) { 343 0, len) != -1) {
344 len++; 344 len++;
@@ -351,16 +351,16 @@ void hpfs_set_ea(struct inode *inode, struct fnode *fnode, const char *key,
351 h[1] = strlen(key); 351 h[1] = strlen(key);
352 h[2] = size & 0xff; 352 h[2] = size & 0xff;
353 h[3] = size >> 8; 353 h[3] = size >> 8;
354 if (hpfs_ea_write(s, le32_to_cpu(fnode->ea_secno), fnode->ea_anode, le32_to_cpu(fnode->ea_size_l), 4, h)) goto bail; 354 if (hpfs_ea_write(s, le32_to_cpu(fnode->ea_secno), fnode_in_anode(fnode), le32_to_cpu(fnode->ea_size_l), 4, h)) goto bail;
355 if (hpfs_ea_write(s, le32_to_cpu(fnode->ea_secno), fnode->ea_anode, le32_to_cpu(fnode->ea_size_l) + 4, h[1] + 1, key)) goto bail; 355 if (hpfs_ea_write(s, le32_to_cpu(fnode->ea_secno), fnode_in_anode(fnode), le32_to_cpu(fnode->ea_size_l) + 4, h[1] + 1, key)) goto bail;
356 if (hpfs_ea_write(s, le32_to_cpu(fnode->ea_secno), fnode->ea_anode, le32_to_cpu(fnode->ea_size_l) + 5 + h[1], size, data)) goto bail; 356 if (hpfs_ea_write(s, le32_to_cpu(fnode->ea_secno), fnode_in_anode(fnode), le32_to_cpu(fnode->ea_size_l) + 5 + h[1], size, data)) goto bail;
357 fnode->ea_size_l = cpu_to_le32(pos); 357 fnode->ea_size_l = cpu_to_le32(pos);
358 ret: 358 ret:
359 hpfs_i(inode)->i_ea_size += 5 + strlen(key) + size; 359 hpfs_i(inode)->i_ea_size += 5 + strlen(key) + size;
360 return; 360 return;
361 bail: 361 bail:
362 if (le32_to_cpu(fnode->ea_secno)) 362 if (le32_to_cpu(fnode->ea_secno))
363 if (fnode->ea_anode) hpfs_truncate_btree(s, le32_to_cpu(fnode->ea_secno), 1, (le32_to_cpu(fnode->ea_size_l) + 511) >> 9); 363 if (fnode_in_anode(fnode)) hpfs_truncate_btree(s, le32_to_cpu(fnode->ea_secno), 1, (le32_to_cpu(fnode->ea_size_l) + 511) >> 9);
364 else hpfs_free_sectors(s, le32_to_cpu(fnode->ea_secno) + ((le32_to_cpu(fnode->ea_size_l) + 511) >> 9), len - ((le32_to_cpu(fnode->ea_size_l) + 511) >> 9)); 364 else hpfs_free_sectors(s, le32_to_cpu(fnode->ea_secno) + ((le32_to_cpu(fnode->ea_size_l) + 511) >> 9), len - ((le32_to_cpu(fnode->ea_size_l) + 511) >> 9));
365 else fnode->ea_secno = fnode->ea_size_l = cpu_to_le32(0); 365 else fnode->ea_secno = fnode->ea_size_l = cpu_to_le32(0);
366} 366}
diff --git a/fs/hpfs/hpfs.h b/fs/hpfs/hpfs.h
index ca90bde6564c..37cc4483fbd1 100644
--- a/fs/hpfs/hpfs.h
+++ b/fs/hpfs/hpfs.h
@@ -436,6 +436,7 @@ struct bplus_header
436 436
437#define FNODE_MAGIC 0xf7e40aae 437#define FNODE_MAGIC 0xf7e40aae
438 438
439enum {FNODE_anode = cpu_to_le16(2), FNODE_dir = cpu_to_le16(256)};
439struct fnode 440struct fnode
440{ 441{
441 u32 magic; /* f7e4 0aae */ 442 u32 magic; /* f7e4 0aae */
@@ -451,26 +452,9 @@ struct fnode
451 secno ea_secno; /* first sector of disk-resident ea's*/ 452 secno ea_secno; /* first sector of disk-resident ea's*/
452 u16 ea_size_s; /* length of fnode-resident ea's */ 453 u16 ea_size_s; /* length of fnode-resident ea's */
453 454
454#ifdef __LITTLE_ENDIAN 455 __le16 flags; /* bit 1 set -> ea_secno is an anode */
455 u8 flag0: 1; 456 /* bit 8 set -> directory. first & only extent
456 u8 ea_anode: 1; /* 1 -> ea_secno is an anode */
457 u8 flag234567: 6;
458#else
459 u8 flag234567: 6;
460 u8 ea_anode: 1; /* 1 -> ea_secno is an anode */
461 u8 flag0: 1;
462#endif
463
464#ifdef __LITTLE_ENDIAN
465 u8 dirflag: 1; /* 1 -> directory. first & only extent
466 points to dnode. */
467 u8 flag9012345: 7;
468#else
469 u8 flag9012345: 7;
470 u8 dirflag: 1; /* 1 -> directory. first & only extent
471 points to dnode. */ 457 points to dnode. */
472#endif
473
474 struct bplus_header btree; /* b+ tree, 8 extents or 12 subtrees */ 458 struct bplus_header btree; /* b+ tree, 8 extents or 12 subtrees */
475 union { 459 union {
476 struct bplus_leaf_node external[8]; 460 struct bplus_leaf_node external[8];
@@ -492,6 +476,16 @@ struct fnode
492 via fnode + ea_offs. I think.) */ 476 via fnode + ea_offs. I think.) */
493}; 477};
494 478
479static inline bool fnode_in_anode(struct fnode *p)
480{
481 return (p->flags & FNODE_anode) != 0;
482}
483
484static inline bool fnode_is_dir(struct fnode *p)
485{
486 return (p->flags & FNODE_dir) != 0;
487}
488
495 489
496/* anode: 99.44% pure allocation tree */ 490/* anode: 99.44% pure allocation tree */
497 491
diff --git a/fs/hpfs/inode.c b/fs/hpfs/inode.c
index b43066cbdc6a..ed671e0ea784 100644
--- a/fs/hpfs/inode.c
+++ b/fs/hpfs/inode.c
@@ -110,7 +110,7 @@ void hpfs_read_inode(struct inode *i)
110 } 110 }
111 } 111 }
112 } 112 }
113 if (fnode->dirflag) { 113 if (fnode_is_dir(fnode)) {
114 int n_dnodes, n_subdirs; 114 int n_dnodes, n_subdirs;
115 i->i_mode |= S_IFDIR; 115 i->i_mode |= S_IFDIR;
116 i->i_op = &hpfs_dir_iops; 116 i->i_op = &hpfs_dir_iops;
diff --git a/fs/hpfs/map.c b/fs/hpfs/map.c
index a790821366a7..fffcb330694e 100644
--- a/fs/hpfs/map.c
+++ b/fs/hpfs/map.c
@@ -130,7 +130,7 @@ struct fnode *hpfs_map_fnode(struct super_block *s, ino_t ino, struct buffer_hea
130 (unsigned long)ino); 130 (unsigned long)ino);
131 goto bail; 131 goto bail;
132 } 132 }
133 if (!fnode->dirflag) { 133 if (!fnode_is_dir(fnode)) {
134 if ((unsigned)fnode->btree.n_used_nodes + (unsigned)fnode->btree.n_free_nodes != 134 if ((unsigned)fnode->btree.n_used_nodes + (unsigned)fnode->btree.n_free_nodes !=
135 (fnode->btree.internal ? 12 : 8)) { 135 (fnode->btree.internal ? 12 : 8)) {
136 hpfs_error(s, 136 hpfs_error(s,
diff --git a/fs/hpfs/namei.c b/fs/hpfs/namei.c
index 30dd7b10b507..9083ef8af58c 100644
--- a/fs/hpfs/namei.c
+++ b/fs/hpfs/namei.c
@@ -70,7 +70,7 @@ static int hpfs_mkdir(struct inode *dir, struct dentry *dentry, umode_t mode)
70 fnode->len = len; 70 fnode->len = len;
71 memcpy(fnode->name, name, len > 15 ? 15 : len); 71 memcpy(fnode->name, name, len > 15 ? 15 : len);
72 fnode->up = cpu_to_le32(dir->i_ino); 72 fnode->up = cpu_to_le32(dir->i_ino);
73 fnode->dirflag = 1; 73 fnode->flags |= FNODE_dir;
74 fnode->btree.n_free_nodes = 7; 74 fnode->btree.n_free_nodes = 7;
75 fnode->btree.n_used_nodes = 1; 75 fnode->btree.n_used_nodes = 1;
76 fnode->btree.first_free = cpu_to_le16(0x14); 76 fnode->btree.first_free = cpu_to_le16(0x14);