diff options
author | Steve French <sfrench@us.ibm.com> | 2005-11-09 17:33:22 -0500 |
---|---|---|
committer | Steve French <sfrench@us.ibm.com> | 2005-11-09 17:33:22 -0500 |
commit | e82b3aec8d508d2a925a4c766e97f16b7c4dfb1b (patch) | |
tree | 69d5685ef0c194f651a03e30bff14628b4d45400 /fs | |
parent | ec58ef03284f0bfa50a04982b74c8c2325a0758e (diff) | |
parent | ad8f76be48d817b48222411ae16a7dfe257bdb24 (diff) |
Merge with /pub/scm/linux/kernel/git/torvalds/linux-2.6.git
Diffstat (limited to 'fs')
322 files changed, 12084 insertions, 15560 deletions
diff --git a/fs/9p/error.c b/fs/9p/error.c index fee5d19179c5..834cb179e388 100644 --- a/fs/9p/error.c +++ b/fs/9p/error.c | |||
@@ -33,6 +33,7 @@ | |||
33 | 33 | ||
34 | #include <linux/list.h> | 34 | #include <linux/list.h> |
35 | #include <linux/jhash.h> | 35 | #include <linux/jhash.h> |
36 | #include <linux/string.h> | ||
36 | 37 | ||
37 | #include "debug.h" | 38 | #include "debug.h" |
38 | #include "error.h" | 39 | #include "error.h" |
diff --git a/fs/9p/trans_sock.c b/fs/9p/trans_sock.c index 01e26f0013ac..a93c2bf94c33 100644 --- a/fs/9p/trans_sock.c +++ b/fs/9p/trans_sock.c | |||
@@ -269,8 +269,7 @@ static void v9fs_sock_close(struct v9fs_transport *trans) | |||
269 | dprintk(DEBUG_TRANS, "socket closed\n"); | 269 | dprintk(DEBUG_TRANS, "socket closed\n"); |
270 | } | 270 | } |
271 | 271 | ||
272 | if (ts) | 272 | kfree(ts); |
273 | kfree(ts); | ||
274 | 273 | ||
275 | trans->priv = NULL; | 274 | trans->priv = NULL; |
276 | } | 275 | } |
diff --git a/fs/9p/v9fs.c b/fs/9p/v9fs.c index 82303f3bf76f..418c3743fdee 100644 --- a/fs/9p/v9fs.c +++ b/fs/9p/v9fs.c | |||
@@ -266,7 +266,7 @@ v9fs_session_init(struct v9fs_session_info *v9ses, | |||
266 | 266 | ||
267 | v9ses->remotename = __getname(); | 267 | v9ses->remotename = __getname(); |
268 | if (!v9ses->remotename) { | 268 | if (!v9ses->remotename) { |
269 | putname(v9ses->name); | 269 | __putname(v9ses->name); |
270 | return -ENOMEM; | 270 | return -ENOMEM; |
271 | } | 271 | } |
272 | 272 | ||
@@ -411,8 +411,8 @@ void v9fs_session_close(struct v9fs_session_info *v9ses) | |||
411 | if (v9ses->transport) | 411 | if (v9ses->transport) |
412 | v9ses->transport->close(v9ses->transport); | 412 | v9ses->transport->close(v9ses->transport); |
413 | 413 | ||
414 | putname(v9ses->name); | 414 | __putname(v9ses->name); |
415 | putname(v9ses->remotename); | 415 | __putname(v9ses->remotename); |
416 | } | 416 | } |
417 | 417 | ||
418 | /** | 418 | /** |
diff --git a/fs/9p/vfs_file.c b/fs/9p/vfs_file.c index bbc3cc63854f..89c849da8504 100644 --- a/fs/9p/vfs_file.c +++ b/fs/9p/vfs_file.c | |||
@@ -32,7 +32,6 @@ | |||
32 | #include <linux/string.h> | 32 | #include <linux/string.h> |
33 | #include <linux/smp_lock.h> | 33 | #include <linux/smp_lock.h> |
34 | #include <linux/inet.h> | 34 | #include <linux/inet.h> |
35 | #include <linux/version.h> | ||
36 | #include <linux/list.h> | 35 | #include <linux/list.h> |
37 | #include <asm/uaccess.h> | 36 | #include <asm/uaccess.h> |
38 | #include <linux/idr.h> | 37 | #include <linux/idr.h> |
diff --git a/fs/9p/vfs_inode.c b/fs/9p/vfs_inode.c index 2b696ae6655a..be7288184fa9 100644 --- a/fs/9p/vfs_inode.c +++ b/fs/9p/vfs_inode.c | |||
@@ -1105,7 +1105,7 @@ static int v9fs_vfs_readlink(struct dentry *dentry, char __user * buffer, | |||
1105 | } | 1105 | } |
1106 | } | 1106 | } |
1107 | 1107 | ||
1108 | putname(link); | 1108 | __putname(link); |
1109 | return retval; | 1109 | return retval; |
1110 | } | 1110 | } |
1111 | 1111 | ||
@@ -1129,7 +1129,7 @@ static void *v9fs_vfs_follow_link(struct dentry *dentry, struct nameidata *nd) | |||
1129 | len = v9fs_readlink(dentry, link, strlen(link)); | 1129 | len = v9fs_readlink(dentry, link, strlen(link)); |
1130 | 1130 | ||
1131 | if (len < 0) { | 1131 | if (len < 0) { |
1132 | putname(link); | 1132 | __putname(link); |
1133 | link = ERR_PTR(len); | 1133 | link = ERR_PTR(len); |
1134 | } else | 1134 | } else |
1135 | link[len] = 0; | 1135 | link[len] = 0; |
@@ -1152,7 +1152,7 @@ static void v9fs_vfs_put_link(struct dentry *dentry, struct nameidata *nd, void | |||
1152 | 1152 | ||
1153 | dprintk(DEBUG_VFS, " %s %s\n", dentry->d_name.name, s); | 1153 | dprintk(DEBUG_VFS, " %s %s\n", dentry->d_name.name, s); |
1154 | if (!IS_ERR(s)) | 1154 | if (!IS_ERR(s)) |
1155 | putname(s); | 1155 | __putname(s); |
1156 | } | 1156 | } |
1157 | 1157 | ||
1158 | /** | 1158 | /** |
@@ -1228,7 +1228,7 @@ v9fs_vfs_link(struct dentry *old_dentry, struct inode *dir, | |||
1228 | FreeMem: | 1228 | FreeMem: |
1229 | kfree(mistat); | 1229 | kfree(mistat); |
1230 | kfree(fcall); | 1230 | kfree(fcall); |
1231 | putname(symname); | 1231 | __putname(symname); |
1232 | return retval; | 1232 | return retval; |
1233 | } | 1233 | } |
1234 | 1234 | ||
@@ -1319,7 +1319,7 @@ v9fs_vfs_mknod(struct inode *dir, struct dentry *dentry, int mode, dev_t rdev) | |||
1319 | FreeMem: | 1319 | FreeMem: |
1320 | kfree(mistat); | 1320 | kfree(mistat); |
1321 | kfree(fcall); | 1321 | kfree(fcall); |
1322 | putname(symname); | 1322 | __putname(symname); |
1323 | 1323 | ||
1324 | return retval; | 1324 | return retval; |
1325 | } | 1325 | } |
diff --git a/fs/Kconfig b/fs/Kconfig index 8855fd41cfa8..4419855d779b 100644 --- a/fs/Kconfig +++ b/fs/Kconfig | |||
@@ -898,6 +898,7 @@ config AFFS_FS | |||
898 | config HFS_FS | 898 | config HFS_FS |
899 | tristate "Apple Macintosh file system support (EXPERIMENTAL)" | 899 | tristate "Apple Macintosh file system support (EXPERIMENTAL)" |
900 | depends on EXPERIMENTAL | 900 | depends on EXPERIMENTAL |
901 | select NLS | ||
901 | help | 902 | help |
902 | If you say Y here, you will be able to mount Macintosh-formatted | 903 | If you say Y here, you will be able to mount Macintosh-formatted |
903 | floppy disks and hard drive partitions with full read-write access. | 904 | floppy disks and hard drive partitions with full read-write access. |
@@ -1050,6 +1051,19 @@ config JFFS2_FS_WRITEBUFFER | |||
1050 | - NOR flash with transparent ECC | 1051 | - NOR flash with transparent ECC |
1051 | - DataFlash | 1052 | - DataFlash |
1052 | 1053 | ||
1054 | config JFFS2_SUMMARY | ||
1055 | bool "JFFS2 summary support (EXPERIMENTAL)" | ||
1056 | depends on JFFS2_FS && EXPERIMENTAL | ||
1057 | default n | ||
1058 | help | ||
1059 | This feature makes it possible to use summary information | ||
1060 | for faster filesystem mount. | ||
1061 | |||
1062 | The summary information can be inserted into a filesystem image | ||
1063 | by the utility 'sumtool'. | ||
1064 | |||
1065 | If unsure, say 'N'. | ||
1066 | |||
1053 | config JFFS2_COMPRESSION_OPTIONS | 1067 | config JFFS2_COMPRESSION_OPTIONS |
1054 | bool "Advanced compression options for JFFS2" | 1068 | bool "Advanced compression options for JFFS2" |
1055 | depends on JFFS2_FS | 1069 | depends on JFFS2_FS |
@@ -1071,10 +1085,10 @@ config JFFS2_ZLIB | |||
1071 | default y | 1085 | default y |
1072 | help | 1086 | help |
1073 | Zlib is designed to be a free, general-purpose, legally unencumbered, | 1087 | Zlib is designed to be a free, general-purpose, legally unencumbered, |
1074 | lossless data-compression library for use on virtually any computer | 1088 | lossless data-compression library for use on virtually any computer |
1075 | hardware and operating system. See <http://www.gzip.org/zlib/> for | 1089 | hardware and operating system. See <http://www.gzip.org/zlib/> for |
1076 | further information. | 1090 | further information. |
1077 | 1091 | ||
1078 | Say 'Y' if unsure. | 1092 | Say 'Y' if unsure. |
1079 | 1093 | ||
1080 | config JFFS2_RTIME | 1094 | config JFFS2_RTIME |
@@ -1096,7 +1110,7 @@ choice | |||
1096 | default JFFS2_CMODE_PRIORITY | 1110 | default JFFS2_CMODE_PRIORITY |
1097 | depends on JFFS2_FS | 1111 | depends on JFFS2_FS |
1098 | help | 1112 | help |
1099 | You can set here the default compression mode of JFFS2 from | 1113 | You can set here the default compression mode of JFFS2 from |
1100 | the available compression modes. Don't touch if unsure. | 1114 | the available compression modes. Don't touch if unsure. |
1101 | 1115 | ||
1102 | config JFFS2_CMODE_NONE | 1116 | config JFFS2_CMODE_NONE |
@@ -1107,13 +1121,13 @@ config JFFS2_CMODE_NONE | |||
1107 | config JFFS2_CMODE_PRIORITY | 1121 | config JFFS2_CMODE_PRIORITY |
1108 | bool "priority" | 1122 | bool "priority" |
1109 | help | 1123 | help |
1110 | Tries the compressors in a predefinied order and chooses the first | 1124 | Tries the compressors in a predefinied order and chooses the first |
1111 | successful one. | 1125 | successful one. |
1112 | 1126 | ||
1113 | config JFFS2_CMODE_SIZE | 1127 | config JFFS2_CMODE_SIZE |
1114 | bool "size (EXPERIMENTAL)" | 1128 | bool "size (EXPERIMENTAL)" |
1115 | help | 1129 | help |
1116 | Tries all compressors and chooses the one which has the smallest | 1130 | Tries all compressors and chooses the one which has the smallest |
1117 | result. | 1131 | result. |
1118 | 1132 | ||
1119 | endchoice | 1133 | endchoice |
diff --git a/fs/Makefile b/fs/Makefile index 1972da186272..4c2655759078 100644 --- a/fs/Makefile +++ b/fs/Makefile | |||
@@ -10,7 +10,7 @@ obj-y := open.o read_write.o file_table.o buffer.o bio.o super.o \ | |||
10 | ioctl.o readdir.o select.o fifo.o locks.o dcache.o inode.o \ | 10 | ioctl.o readdir.o select.o fifo.o locks.o dcache.o inode.o \ |
11 | attr.o bad_inode.o file.o filesystems.o namespace.o aio.o \ | 11 | attr.o bad_inode.o file.o filesystems.o namespace.o aio.o \ |
12 | seq_file.o xattr.o libfs.o fs-writeback.o mpage.o direct-io.o \ | 12 | seq_file.o xattr.o libfs.o fs-writeback.o mpage.o direct-io.o \ |
13 | ioprio.o | 13 | ioprio.o pnode.o |
14 | 14 | ||
15 | obj-$(CONFIG_INOTIFY) += inotify.o | 15 | obj-$(CONFIG_INOTIFY) += inotify.o |
16 | obj-$(CONFIG_EPOLL) += eventpoll.o | 16 | obj-$(CONFIG_EPOLL) += eventpoll.o |
diff --git a/fs/adfs/adfs.h b/fs/adfs/adfs.h index fd528433de43..f6cd01352cc8 100644 --- a/fs/adfs/adfs.h +++ b/fs/adfs/adfs.h | |||
@@ -12,7 +12,6 @@ | |||
12 | #define ADFS_NDA_PUBLIC_READ (1 << 5) | 12 | #define ADFS_NDA_PUBLIC_READ (1 << 5) |
13 | #define ADFS_NDA_PUBLIC_WRITE (1 << 6) | 13 | #define ADFS_NDA_PUBLIC_WRITE (1 << 6) |
14 | 14 | ||
15 | #include <linux/version.h> | ||
16 | #include "dir_f.h" | 15 | #include "dir_f.h" |
17 | 16 | ||
18 | struct buffer_head; | 17 | struct buffer_head; |
diff --git a/fs/affs/file.c b/fs/affs/file.c index 6744924b6905..f72fb776ecdf 100644 --- a/fs/affs/file.c +++ b/fs/affs/file.c | |||
@@ -22,14 +22,13 @@ static int affs_grow_extcache(struct inode *inode, u32 lc_idx); | |||
22 | static struct buffer_head *affs_alloc_extblock(struct inode *inode, struct buffer_head *bh, u32 ext); | 22 | static struct buffer_head *affs_alloc_extblock(struct inode *inode, struct buffer_head *bh, u32 ext); |
23 | static inline struct buffer_head *affs_get_extblock(struct inode *inode, u32 ext); | 23 | static inline struct buffer_head *affs_get_extblock(struct inode *inode, u32 ext); |
24 | static struct buffer_head *affs_get_extblock_slow(struct inode *inode, u32 ext); | 24 | static struct buffer_head *affs_get_extblock_slow(struct inode *inode, u32 ext); |
25 | static ssize_t affs_file_write(struct file *filp, const char __user *buf, size_t count, loff_t *ppos); | ||
26 | static int affs_file_open(struct inode *inode, struct file *filp); | 25 | static int affs_file_open(struct inode *inode, struct file *filp); |
27 | static int affs_file_release(struct inode *inode, struct file *filp); | 26 | static int affs_file_release(struct inode *inode, struct file *filp); |
28 | 27 | ||
29 | struct file_operations affs_file_operations = { | 28 | struct file_operations affs_file_operations = { |
30 | .llseek = generic_file_llseek, | 29 | .llseek = generic_file_llseek, |
31 | .read = generic_file_read, | 30 | .read = generic_file_read, |
32 | .write = affs_file_write, | 31 | .write = generic_file_write, |
33 | .mmap = generic_file_mmap, | 32 | .mmap = generic_file_mmap, |
34 | .open = affs_file_open, | 33 | .open = affs_file_open, |
35 | .release = affs_file_release, | 34 | .release = affs_file_release, |
@@ -473,21 +472,6 @@ affs_getemptyblk_ino(struct inode *inode, int block) | |||
473 | return ERR_PTR(err); | 472 | return ERR_PTR(err); |
474 | } | 473 | } |
475 | 474 | ||
476 | static ssize_t | ||
477 | affs_file_write(struct file *file, const char __user *buf, | ||
478 | size_t count, loff_t *ppos) | ||
479 | { | ||
480 | ssize_t retval; | ||
481 | |||
482 | retval = generic_file_write (file, buf, count, ppos); | ||
483 | if (retval >0) { | ||
484 | struct inode *inode = file->f_dentry->d_inode; | ||
485 | inode->i_ctime = inode->i_mtime = CURRENT_TIME_SEC; | ||
486 | mark_inode_dirty(inode); | ||
487 | } | ||
488 | return retval; | ||
489 | } | ||
490 | |||
491 | static int | 475 | static int |
492 | affs_do_readpage_ofs(struct file *file, struct page *page, unsigned from, unsigned to) | 476 | affs_do_readpage_ofs(struct file *file, struct page *page, unsigned from, unsigned to) |
493 | { | 477 | { |
diff --git a/fs/affs/super.c b/fs/affs/super.c index 9c3080716c92..aaec015a16e4 100644 --- a/fs/affs/super.c +++ b/fs/affs/super.c | |||
@@ -35,8 +35,7 @@ affs_put_super(struct super_block *sb) | |||
35 | mark_buffer_dirty(sbi->s_root_bh); | 35 | mark_buffer_dirty(sbi->s_root_bh); |
36 | } | 36 | } |
37 | 37 | ||
38 | if (sbi->s_prefix) | 38 | kfree(sbi->s_prefix); |
39 | kfree(sbi->s_prefix); | ||
40 | affs_free_bitmap(sb); | 39 | affs_free_bitmap(sb); |
41 | affs_brelse(sbi->s_root_bh); | 40 | affs_brelse(sbi->s_root_bh); |
42 | kfree(sbi); | 41 | kfree(sbi); |
@@ -198,10 +197,9 @@ parse_options(char *options, uid_t *uid, gid_t *gid, int *mode, int *reserved, s | |||
198 | *mount_opts |= SF_MUFS; | 197 | *mount_opts |= SF_MUFS; |
199 | break; | 198 | break; |
200 | case Opt_prefix: | 199 | case Opt_prefix: |
201 | if (*prefix) { /* Free any previous prefix */ | 200 | /* Free any previous prefix */ |
202 | kfree(*prefix); | 201 | kfree(*prefix); |
203 | *prefix = NULL; | 202 | *prefix = NULL; |
204 | } | ||
205 | *prefix = match_strdup(&args[0]); | 203 | *prefix = match_strdup(&args[0]); |
206 | if (!*prefix) | 204 | if (!*prefix) |
207 | return 0; | 205 | return 0; |
@@ -462,11 +460,9 @@ got_root: | |||
462 | out_error: | 460 | out_error: |
463 | if (root_inode) | 461 | if (root_inode) |
464 | iput(root_inode); | 462 | iput(root_inode); |
465 | if (sbi->s_bitmap) | 463 | kfree(sbi->s_bitmap); |
466 | kfree(sbi->s_bitmap); | ||
467 | affs_brelse(root_bh); | 464 | affs_brelse(root_bh); |
468 | if (sbi->s_prefix) | 465 | kfree(sbi->s_prefix); |
469 | kfree(sbi->s_prefix); | ||
470 | kfree(sbi); | 466 | kfree(sbi); |
471 | sb->s_fs_info = NULL; | 467 | sb->s_fs_info = NULL; |
472 | return -EINVAL; | 468 | return -EINVAL; |
diff --git a/fs/afs/file.c b/fs/afs/file.c index 4975c9c193dd..150b19227922 100644 --- a/fs/afs/file.c +++ b/fs/afs/file.c | |||
@@ -31,24 +31,10 @@ static int afs_file_readpage(struct file *file, struct page *page); | |||
31 | static int afs_file_invalidatepage(struct page *page, unsigned long offset); | 31 | static int afs_file_invalidatepage(struct page *page, unsigned long offset); |
32 | static int afs_file_releasepage(struct page *page, gfp_t gfp_flags); | 32 | static int afs_file_releasepage(struct page *page, gfp_t gfp_flags); |
33 | 33 | ||
34 | static ssize_t afs_file_write(struct file *file, const char __user *buf, | ||
35 | size_t size, loff_t *off); | ||
36 | |||
37 | struct inode_operations afs_file_inode_operations = { | 34 | struct inode_operations afs_file_inode_operations = { |
38 | .getattr = afs_inode_getattr, | 35 | .getattr = afs_inode_getattr, |
39 | }; | 36 | }; |
40 | 37 | ||
41 | struct file_operations afs_file_file_operations = { | ||
42 | .read = generic_file_read, | ||
43 | .write = afs_file_write, | ||
44 | .mmap = generic_file_mmap, | ||
45 | #if 0 | ||
46 | .open = afs_file_open, | ||
47 | .release = afs_file_release, | ||
48 | .fsync = afs_file_fsync, | ||
49 | #endif | ||
50 | }; | ||
51 | |||
52 | struct address_space_operations afs_fs_aops = { | 38 | struct address_space_operations afs_fs_aops = { |
53 | .readpage = afs_file_readpage, | 39 | .readpage = afs_file_readpage, |
54 | .sync_page = block_sync_page, | 40 | .sync_page = block_sync_page, |
@@ -59,22 +45,6 @@ struct address_space_operations afs_fs_aops = { | |||
59 | 45 | ||
60 | /*****************************************************************************/ | 46 | /*****************************************************************************/ |
61 | /* | 47 | /* |
62 | * AFS file write | ||
63 | */ | ||
64 | static ssize_t afs_file_write(struct file *file, const char __user *buf, | ||
65 | size_t size, loff_t *off) | ||
66 | { | ||
67 | struct afs_vnode *vnode; | ||
68 | |||
69 | vnode = AFS_FS_I(file->f_dentry->d_inode); | ||
70 | if (vnode->flags & AFS_VNODE_DELETED) | ||
71 | return -ESTALE; | ||
72 | |||
73 | return -EIO; | ||
74 | } /* end afs_file_write() */ | ||
75 | |||
76 | /*****************************************************************************/ | ||
77 | /* | ||
78 | * deal with notification that a page was read from the cache | 48 | * deal with notification that a page was read from the cache |
79 | */ | 49 | */ |
80 | #ifdef AFS_CACHING_SUPPORT | 50 | #ifdef AFS_CACHING_SUPPORT |
@@ -295,8 +265,7 @@ static int afs_file_releasepage(struct page *page, gfp_t gfp_flags) | |||
295 | set_page_private(page, 0); | 265 | set_page_private(page, 0); |
296 | ClearPagePrivate(page); | 266 | ClearPagePrivate(page); |
297 | 267 | ||
298 | if (pageio) | 268 | kfree(pageio); |
299 | kfree(pageio); | ||
300 | } | 269 | } |
301 | 270 | ||
302 | _leave(" = 0"); | 271 | _leave(" = 0"); |
diff --git a/fs/afs/inode.c b/fs/afs/inode.c index c476fde33fbc..4ebb30a50ed5 100644 --- a/fs/afs/inode.c +++ b/fs/afs/inode.c | |||
@@ -49,7 +49,7 @@ static int afs_inode_map_status(struct afs_vnode *vnode) | |||
49 | case AFS_FTYPE_FILE: | 49 | case AFS_FTYPE_FILE: |
50 | inode->i_mode = S_IFREG | vnode->status.mode; | 50 | inode->i_mode = S_IFREG | vnode->status.mode; |
51 | inode->i_op = &afs_file_inode_operations; | 51 | inode->i_op = &afs_file_inode_operations; |
52 | inode->i_fop = &afs_file_file_operations; | 52 | inode->i_fop = &generic_ro_fops; |
53 | break; | 53 | break; |
54 | case AFS_FTYPE_DIR: | 54 | case AFS_FTYPE_DIR: |
55 | inode->i_mode = S_IFDIR | vnode->status.mode; | 55 | inode->i_mode = S_IFDIR | vnode->status.mode; |
diff --git a/fs/afs/internal.h b/fs/afs/internal.h index f09860b45c1a..ab8f87c66319 100644 --- a/fs/afs/internal.h +++ b/fs/afs/internal.h | |||
@@ -71,7 +71,6 @@ extern struct file_operations afs_dir_file_operations; | |||
71 | */ | 71 | */ |
72 | extern struct address_space_operations afs_fs_aops; | 72 | extern struct address_space_operations afs_fs_aops; |
73 | extern struct inode_operations afs_file_inode_operations; | 73 | extern struct inode_operations afs_file_inode_operations; |
74 | extern struct file_operations afs_file_file_operations; | ||
75 | 74 | ||
76 | #ifdef AFS_CACHING_SUPPORT | 75 | #ifdef AFS_CACHING_SUPPORT |
77 | extern int afs_cache_get_page_cookie(struct page *page, | 76 | extern int afs_cache_get_page_cookie(struct page *page, |
@@ -42,8 +42,9 @@ | |||
42 | #endif | 42 | #endif |
43 | 43 | ||
44 | /*------ sysctl variables----*/ | 44 | /*------ sysctl variables----*/ |
45 | atomic_t aio_nr = ATOMIC_INIT(0); /* current system wide number of aio requests */ | 45 | static DEFINE_SPINLOCK(aio_nr_lock); |
46 | unsigned aio_max_nr = 0x10000; /* system wide maximum number of aio requests */ | 46 | unsigned long aio_nr; /* current system wide number of aio requests */ |
47 | unsigned long aio_max_nr = 0x10000; /* system wide maximum number of aio requests */ | ||
47 | /*----end sysctl variables---*/ | 48 | /*----end sysctl variables---*/ |
48 | 49 | ||
49 | static kmem_cache_t *kiocb_cachep; | 50 | static kmem_cache_t *kiocb_cachep; |
@@ -208,7 +209,7 @@ static struct kioctx *ioctx_alloc(unsigned nr_events) | |||
208 | return ERR_PTR(-EINVAL); | 209 | return ERR_PTR(-EINVAL); |
209 | } | 210 | } |
210 | 211 | ||
211 | if (nr_events > aio_max_nr) | 212 | if ((unsigned long)nr_events > aio_max_nr) |
212 | return ERR_PTR(-EAGAIN); | 213 | return ERR_PTR(-EAGAIN); |
213 | 214 | ||
214 | ctx = kmem_cache_alloc(kioctx_cachep, GFP_KERNEL); | 215 | ctx = kmem_cache_alloc(kioctx_cachep, GFP_KERNEL); |
@@ -233,8 +234,14 @@ static struct kioctx *ioctx_alloc(unsigned nr_events) | |||
233 | goto out_freectx; | 234 | goto out_freectx; |
234 | 235 | ||
235 | /* limit the number of system wide aios */ | 236 | /* limit the number of system wide aios */ |
236 | atomic_add(ctx->max_reqs, &aio_nr); /* undone by __put_ioctx */ | 237 | spin_lock(&aio_nr_lock); |
237 | if (unlikely(atomic_read(&aio_nr) > aio_max_nr)) | 238 | if (aio_nr + ctx->max_reqs > aio_max_nr || |
239 | aio_nr + ctx->max_reqs < aio_nr) | ||
240 | ctx->max_reqs = 0; | ||
241 | else | ||
242 | aio_nr += ctx->max_reqs; | ||
243 | spin_unlock(&aio_nr_lock); | ||
244 | if (ctx->max_reqs == 0) | ||
238 | goto out_cleanup; | 245 | goto out_cleanup; |
239 | 246 | ||
240 | /* now link into global list. kludge. FIXME */ | 247 | /* now link into global list. kludge. FIXME */ |
@@ -248,8 +255,6 @@ static struct kioctx *ioctx_alloc(unsigned nr_events) | |||
248 | return ctx; | 255 | return ctx; |
249 | 256 | ||
250 | out_cleanup: | 257 | out_cleanup: |
251 | atomic_sub(ctx->max_reqs, &aio_nr); | ||
252 | ctx->max_reqs = 0; /* prevent __put_ioctx from sub'ing aio_nr */ | ||
253 | __put_ioctx(ctx); | 258 | __put_ioctx(ctx); |
254 | return ERR_PTR(-EAGAIN); | 259 | return ERR_PTR(-EAGAIN); |
255 | 260 | ||
@@ -374,7 +379,12 @@ void fastcall __put_ioctx(struct kioctx *ctx) | |||
374 | pr_debug("__put_ioctx: freeing %p\n", ctx); | 379 | pr_debug("__put_ioctx: freeing %p\n", ctx); |
375 | kmem_cache_free(kioctx_cachep, ctx); | 380 | kmem_cache_free(kioctx_cachep, ctx); |
376 | 381 | ||
377 | atomic_sub(nr_events, &aio_nr); | 382 | if (nr_events) { |
383 | spin_lock(&aio_nr_lock); | ||
384 | BUG_ON(aio_nr - nr_events > aio_nr); | ||
385 | aio_nr -= nr_events; | ||
386 | spin_unlock(&aio_nr_lock); | ||
387 | } | ||
378 | } | 388 | } |
379 | 389 | ||
380 | /* aio_get_req | 390 | /* aio_get_req |
@@ -1258,8 +1268,9 @@ asmlinkage long sys_io_setup(unsigned nr_events, aio_context_t __user *ctxp) | |||
1258 | goto out; | 1268 | goto out; |
1259 | 1269 | ||
1260 | ret = -EINVAL; | 1270 | ret = -EINVAL; |
1261 | if (unlikely(ctx || (int)nr_events <= 0)) { | 1271 | if (unlikely(ctx || nr_events == 0)) { |
1262 | pr_debug("EINVAL: io_setup: ctx or nr_events > max\n"); | 1272 | pr_debug("EINVAL: io_setup: ctx %lu nr_events %u\n", |
1273 | ctx, nr_events); | ||
1263 | goto out; | 1274 | goto out; |
1264 | } | 1275 | } |
1265 | 1276 | ||
diff --git a/fs/autofs/waitq.c b/fs/autofs/waitq.c index 1fcaa1568541..633f628005b4 100644 --- a/fs/autofs/waitq.c +++ b/fs/autofs/waitq.c | |||
@@ -150,10 +150,8 @@ int autofs_wait(struct autofs_sb_info *sbi, struct qstr *name) | |||
150 | if ( sbi->catatonic ) { | 150 | if ( sbi->catatonic ) { |
151 | /* We might have slept, so check again for catatonic mode */ | 151 | /* We might have slept, so check again for catatonic mode */ |
152 | wq->status = -ENOENT; | 152 | wq->status = -ENOENT; |
153 | if ( wq->name ) { | 153 | kfree(wq->name); |
154 | kfree(wq->name); | 154 | wq->name = NULL; |
155 | wq->name = NULL; | ||
156 | } | ||
157 | } | 155 | } |
158 | 156 | ||
159 | if ( wq->name ) { | 157 | if ( wq->name ) { |
diff --git a/fs/autofs4/inode.c b/fs/autofs4/inode.c index 0a3c05d10167..818b37be5153 100644 --- a/fs/autofs4/inode.c +++ b/fs/autofs4/inode.c | |||
@@ -22,10 +22,8 @@ | |||
22 | 22 | ||
23 | static void ino_lnkfree(struct autofs_info *ino) | 23 | static void ino_lnkfree(struct autofs_info *ino) |
24 | { | 24 | { |
25 | if (ino->u.symlink) { | 25 | kfree(ino->u.symlink); |
26 | kfree(ino->u.symlink); | 26 | ino->u.symlink = NULL; |
27 | ino->u.symlink = NULL; | ||
28 | } | ||
29 | } | 27 | } |
30 | 28 | ||
31 | struct autofs_info *autofs4_init_ino(struct autofs_info *ino, | 29 | struct autofs_info *autofs4_init_ino(struct autofs_info *ino, |
diff --git a/fs/autofs4/waitq.c b/fs/autofs4/waitq.c index 3df86285a1c7..394ff36ef8f1 100644 --- a/fs/autofs4/waitq.c +++ b/fs/autofs4/waitq.c | |||
@@ -243,10 +243,8 @@ int autofs4_wait(struct autofs_sb_info *sbi, struct dentry *dentry, | |||
243 | if ( sbi->catatonic ) { | 243 | if ( sbi->catatonic ) { |
244 | /* We might have slept, so check again for catatonic mode */ | 244 | /* We might have slept, so check again for catatonic mode */ |
245 | wq->status = -ENOENT; | 245 | wq->status = -ENOENT; |
246 | if ( wq->name ) { | 246 | kfree(wq->name); |
247 | kfree(wq->name); | 247 | wq->name = NULL; |
248 | wq->name = NULL; | ||
249 | } | ||
250 | } | 248 | } |
251 | 249 | ||
252 | if ( wq->name ) { | 250 | if ( wq->name ) { |
diff --git a/fs/befs/linuxvfs.c b/fs/befs/linuxvfs.c index e0a6025f1d06..2d365cb8eec6 100644 --- a/fs/befs/linuxvfs.c +++ b/fs/befs/linuxvfs.c | |||
@@ -73,12 +73,6 @@ static struct inode_operations befs_dir_inode_operations = { | |||
73 | .lookup = befs_lookup, | 73 | .lookup = befs_lookup, |
74 | }; | 74 | }; |
75 | 75 | ||
76 | static struct file_operations befs_file_operations = { | ||
77 | .llseek = default_llseek, | ||
78 | .read = generic_file_read, | ||
79 | .mmap = generic_file_readonly_mmap, | ||
80 | }; | ||
81 | |||
82 | static struct address_space_operations befs_aops = { | 76 | static struct address_space_operations befs_aops = { |
83 | .readpage = befs_readpage, | 77 | .readpage = befs_readpage, |
84 | .sync_page = block_sync_page, | 78 | .sync_page = block_sync_page, |
@@ -398,7 +392,7 @@ befs_read_inode(struct inode *inode) | |||
398 | inode->i_mapping->a_ops = &befs_aops; | 392 | inode->i_mapping->a_ops = &befs_aops; |
399 | 393 | ||
400 | if (S_ISREG(inode->i_mode)) { | 394 | if (S_ISREG(inode->i_mode)) { |
401 | inode->i_fop = &befs_file_operations; | 395 | inode->i_fop = &generic_ro_fops; |
402 | } else if (S_ISDIR(inode->i_mode)) { | 396 | } else if (S_ISDIR(inode->i_mode)) { |
403 | inode->i_op = &befs_dir_inode_operations; | 397 | inode->i_op = &befs_dir_inode_operations; |
404 | inode->i_fop = &befs_dir_operations; | 398 | inode->i_fop = &befs_dir_operations; |
@@ -731,20 +725,16 @@ parse_options(char *options, befs_mount_options * opts) | |||
731 | static void | 725 | static void |
732 | befs_put_super(struct super_block *sb) | 726 | befs_put_super(struct super_block *sb) |
733 | { | 727 | { |
734 | if (BEFS_SB(sb)->mount_opts.iocharset) { | 728 | kfree(BEFS_SB(sb)->mount_opts.iocharset); |
735 | kfree(BEFS_SB(sb)->mount_opts.iocharset); | 729 | BEFS_SB(sb)->mount_opts.iocharset = NULL; |
736 | BEFS_SB(sb)->mount_opts.iocharset = NULL; | ||
737 | } | ||
738 | 730 | ||
739 | if (BEFS_SB(sb)->nls) { | 731 | if (BEFS_SB(sb)->nls) { |
740 | unload_nls(BEFS_SB(sb)->nls); | 732 | unload_nls(BEFS_SB(sb)->nls); |
741 | BEFS_SB(sb)->nls = NULL; | 733 | BEFS_SB(sb)->nls = NULL; |
742 | } | 734 | } |
743 | 735 | ||
744 | if (sb->s_fs_info) { | 736 | kfree(sb->s_fs_info); |
745 | kfree(sb->s_fs_info); | 737 | sb->s_fs_info = NULL; |
746 | sb->s_fs_info = NULL; | ||
747 | } | ||
748 | return; | 738 | return; |
749 | } | 739 | } |
750 | 740 | ||
diff --git a/fs/binfmt_elf.c b/fs/binfmt_elf.c index 6fa6adc40972..f36f2210204f 100644 --- a/fs/binfmt_elf.c +++ b/fs/binfmt_elf.c | |||
@@ -1006,8 +1006,7 @@ out_free_dentry: | |||
1006 | if (interpreter) | 1006 | if (interpreter) |
1007 | fput(interpreter); | 1007 | fput(interpreter); |
1008 | out_free_interp: | 1008 | out_free_interp: |
1009 | if (elf_interpreter) | 1009 | kfree(elf_interpreter); |
1010 | kfree(elf_interpreter); | ||
1011 | out_free_file: | 1010 | out_free_file: |
1012 | sys_close(elf_exec_fileno); | 1011 | sys_close(elf_exec_fileno); |
1013 | out_free_fh: | 1012 | out_free_fh: |
diff --git a/fs/binfmt_elf_fdpic.c b/fs/binfmt_elf_fdpic.c index dda87c4c82a3..e0344f69c79d 100644 --- a/fs/binfmt_elf_fdpic.c +++ b/fs/binfmt_elf_fdpic.c | |||
@@ -411,16 +411,11 @@ error: | |||
411 | allow_write_access(interpreter); | 411 | allow_write_access(interpreter); |
412 | fput(interpreter); | 412 | fput(interpreter); |
413 | } | 413 | } |
414 | if (interpreter_name) | 414 | kfree(interpreter_name); |
415 | kfree(interpreter_name); | 415 | kfree(exec_params.phdrs); |
416 | if (exec_params.phdrs) | 416 | kfree(exec_params.loadmap); |
417 | kfree(exec_params.phdrs); | 417 | kfree(interp_params.phdrs); |
418 | if (exec_params.loadmap) | 418 | kfree(interp_params.loadmap); |
419 | kfree(exec_params.loadmap); | ||
420 | if (interp_params.phdrs) | ||
421 | kfree(interp_params.phdrs); | ||
422 | if (interp_params.loadmap) | ||
423 | kfree(interp_params.loadmap); | ||
424 | return retval; | 419 | return retval; |
425 | 420 | ||
426 | /* unrecoverable error - kill the process */ | 421 | /* unrecoverable error - kill the process */ |
diff --git a/fs/binfmt_misc.c b/fs/binfmt_misc.c index 8ae0db6cd69c..2568eb41cb3a 100644 --- a/fs/binfmt_misc.c +++ b/fs/binfmt_misc.c | |||
@@ -150,7 +150,7 @@ static int load_misc_binary(struct linux_binprm *bprm, struct pt_regs *regs) | |||
150 | 150 | ||
151 | /* if the binary is not readable than enforce mm->dumpable=0 | 151 | /* if the binary is not readable than enforce mm->dumpable=0 |
152 | regardless of the interpreter's permissions */ | 152 | regardless of the interpreter's permissions */ |
153 | if (permission(bprm->file->f_dentry->d_inode, MAY_READ, NULL)) | 153 | if (file_permission(bprm->file, MAY_READ)) |
154 | bprm->interp_flags |= BINPRM_FLAGS_ENFORCE_NONDUMP; | 154 | bprm->interp_flags |= BINPRM_FLAGS_ENFORCE_NONDUMP; |
155 | 155 | ||
156 | allow_write_access(bprm->file); | 156 | allow_write_access(bprm->file); |
diff --git a/fs/buffer.c b/fs/buffer.c index 35fa34977e81..5287be18633b 100644 --- a/fs/buffer.c +++ b/fs/buffer.c | |||
@@ -396,7 +396,7 @@ asmlinkage long sys_fdatasync(unsigned int fd) | |||
396 | * private_lock is contended then so is mapping->tree_lock). | 396 | * private_lock is contended then so is mapping->tree_lock). |
397 | */ | 397 | */ |
398 | static struct buffer_head * | 398 | static struct buffer_head * |
399 | __find_get_block_slow(struct block_device *bdev, sector_t block, int unused) | 399 | __find_get_block_slow(struct block_device *bdev, sector_t block) |
400 | { | 400 | { |
401 | struct inode *bd_inode = bdev->bd_inode; | 401 | struct inode *bd_inode = bdev->bd_inode; |
402 | struct address_space *bd_mapping = bd_inode->i_mapping; | 402 | struct address_space *bd_mapping = bd_inode->i_mapping; |
@@ -1438,7 +1438,7 @@ __find_get_block(struct block_device *bdev, sector_t block, int size) | |||
1438 | struct buffer_head *bh = lookup_bh_lru(bdev, block, size); | 1438 | struct buffer_head *bh = lookup_bh_lru(bdev, block, size); |
1439 | 1439 | ||
1440 | if (bh == NULL) { | 1440 | if (bh == NULL) { |
1441 | bh = __find_get_block_slow(bdev, block, size); | 1441 | bh = __find_get_block_slow(bdev, block); |
1442 | if (bh) | 1442 | if (bh) |
1443 | bh_lru_install(bh); | 1443 | bh_lru_install(bh); |
1444 | } | 1444 | } |
@@ -1705,7 +1705,7 @@ void unmap_underlying_metadata(struct block_device *bdev, sector_t block) | |||
1705 | 1705 | ||
1706 | might_sleep(); | 1706 | might_sleep(); |
1707 | 1707 | ||
1708 | old_bh = __find_get_block_slow(bdev, block, 0); | 1708 | old_bh = __find_get_block_slow(bdev, block); |
1709 | if (old_bh) { | 1709 | if (old_bh) { |
1710 | clear_buffer_dirty(old_bh); | 1710 | clear_buffer_dirty(old_bh); |
1711 | wait_on_buffer(old_bh); | 1711 | wait_on_buffer(old_bh); |
diff --git a/fs/cifs/asn1.c b/fs/cifs/asn1.c index 98539e2afe81..086ae8f4a207 100644 --- a/fs/cifs/asn1.c +++ b/fs/cifs/asn1.c | |||
@@ -553,8 +553,7 @@ decode_negTokenInit(unsigned char *security_blob, int length, | |||
553 | *(oid + 3))); | 553 | *(oid + 3))); |
554 | rc = compare_oid(oid, oidlen, NTLMSSP_OID, | 554 | rc = compare_oid(oid, oidlen, NTLMSSP_OID, |
555 | NTLMSSP_OID_LEN); | 555 | NTLMSSP_OID_LEN); |
556 | if(oid) | 556 | kfree(oid); |
557 | kfree(oid); | ||
558 | if (rc) | 557 | if (rc) |
559 | use_ntlmssp = TRUE; | 558 | use_ntlmssp = TRUE; |
560 | } | 559 | } |
diff --git a/fs/cifs/connect.c b/fs/cifs/connect.c index d74367a08d51..450ab75d6546 100644 --- a/fs/cifs/connect.c +++ b/fs/cifs/connect.c | |||
@@ -1265,8 +1265,7 @@ connect_to_dfs_path(int xid, struct cifsSesInfo *pSesInfo, | |||
1265 | the helper that resolves tcp names, mount to it, try to | 1265 | the helper that resolves tcp names, mount to it, try to |
1266 | tcon to it unmount it if fail */ | 1266 | tcon to it unmount it if fail */ |
1267 | 1267 | ||
1268 | if(referrals) | 1268 | kfree(referrals); |
1269 | kfree(referrals); | ||
1270 | 1269 | ||
1271 | return rc; | 1270 | return rc; |
1272 | } | 1271 | } |
@@ -1535,10 +1534,8 @@ cifs_mount(struct super_block *sb, struct cifs_sb_info *cifs_sb, | |||
1535 | 1534 | ||
1536 | memset(&volume_info,0,sizeof(struct smb_vol)); | 1535 | memset(&volume_info,0,sizeof(struct smb_vol)); |
1537 | if (cifs_parse_mount_options(mount_data, devname, &volume_info)) { | 1536 | if (cifs_parse_mount_options(mount_data, devname, &volume_info)) { |
1538 | if(volume_info.UNC) | 1537 | kfree(volume_info.UNC); |
1539 | kfree(volume_info.UNC); | 1538 | kfree(volume_info.password); |
1540 | if(volume_info.password) | ||
1541 | kfree(volume_info.password); | ||
1542 | FreeXid(xid); | 1539 | FreeXid(xid); |
1543 | return -EINVAL; | 1540 | return -EINVAL; |
1544 | } | 1541 | } |
@@ -1551,10 +1548,8 @@ cifs_mount(struct super_block *sb, struct cifs_sb_info *cifs_sb, | |||
1551 | cifserror("No username specified "); | 1548 | cifserror("No username specified "); |
1552 | /* In userspace mount helper we can get user name from alternate | 1549 | /* In userspace mount helper we can get user name from alternate |
1553 | locations such as env variables and files on disk */ | 1550 | locations such as env variables and files on disk */ |
1554 | if(volume_info.UNC) | 1551 | kfree(volume_info.UNC); |
1555 | kfree(volume_info.UNC); | 1552 | kfree(volume_info.password); |
1556 | if(volume_info.password) | ||
1557 | kfree(volume_info.password); | ||
1558 | FreeXid(xid); | 1553 | FreeXid(xid); |
1559 | return -EINVAL; | 1554 | return -EINVAL; |
1560 | } | 1555 | } |
@@ -1573,10 +1568,8 @@ cifs_mount(struct super_block *sb, struct cifs_sb_info *cifs_sb, | |||
1573 | 1568 | ||
1574 | if(rc <= 0) { | 1569 | if(rc <= 0) { |
1575 | /* we failed translating address */ | 1570 | /* we failed translating address */ |
1576 | if(volume_info.UNC) | 1571 | kfree(volume_info.UNC); |
1577 | kfree(volume_info.UNC); | 1572 | kfree(volume_info.password); |
1578 | if(volume_info.password) | ||
1579 | kfree(volume_info.password); | ||
1580 | FreeXid(xid); | 1573 | FreeXid(xid); |
1581 | return -EINVAL; | 1574 | return -EINVAL; |
1582 | } | 1575 | } |
@@ -1587,19 +1580,15 @@ cifs_mount(struct super_block *sb, struct cifs_sb_info *cifs_sb, | |||
1587 | } else if (volume_info.UNCip){ | 1580 | } else if (volume_info.UNCip){ |
1588 | /* BB using ip addr as server name connect to the DFS root below */ | 1581 | /* BB using ip addr as server name connect to the DFS root below */ |
1589 | cERROR(1,("Connecting to DFS root not implemented yet")); | 1582 | cERROR(1,("Connecting to DFS root not implemented yet")); |
1590 | if(volume_info.UNC) | 1583 | kfree(volume_info.UNC); |
1591 | kfree(volume_info.UNC); | 1584 | kfree(volume_info.password); |
1592 | if(volume_info.password) | ||
1593 | kfree(volume_info.password); | ||
1594 | FreeXid(xid); | 1585 | FreeXid(xid); |
1595 | return -EINVAL; | 1586 | return -EINVAL; |
1596 | } else /* which servers DFS root would we conect to */ { | 1587 | } else /* which servers DFS root would we conect to */ { |
1597 | cERROR(1, | 1588 | cERROR(1, |
1598 | ("CIFS mount error: No UNC path (e.g. -o unc=//192.168.1.100/public) specified ")); | 1589 | ("CIFS mount error: No UNC path (e.g. -o unc=//192.168.1.100/public) specified ")); |
1599 | if(volume_info.UNC) | 1590 | kfree(volume_info.UNC); |
1600 | kfree(volume_info.UNC); | 1591 | kfree(volume_info.password); |
1601 | if(volume_info.password) | ||
1602 | kfree(volume_info.password); | ||
1603 | FreeXid(xid); | 1592 | FreeXid(xid); |
1604 | return -EINVAL; | 1593 | return -EINVAL; |
1605 | } | 1594 | } |
@@ -1612,10 +1601,8 @@ cifs_mount(struct super_block *sb, struct cifs_sb_info *cifs_sb, | |||
1612 | cifs_sb->local_nls = load_nls(volume_info.iocharset); | 1601 | cifs_sb->local_nls = load_nls(volume_info.iocharset); |
1613 | if(cifs_sb->local_nls == NULL) { | 1602 | if(cifs_sb->local_nls == NULL) { |
1614 | cERROR(1,("CIFS mount error: iocharset %s not found",volume_info.iocharset)); | 1603 | cERROR(1,("CIFS mount error: iocharset %s not found",volume_info.iocharset)); |
1615 | if(volume_info.UNC) | 1604 | kfree(volume_info.UNC); |
1616 | kfree(volume_info.UNC); | 1605 | kfree(volume_info.password); |
1617 | if(volume_info.password) | ||
1618 | kfree(volume_info.password); | ||
1619 | FreeXid(xid); | 1606 | FreeXid(xid); |
1620 | return -ELIBACC; | 1607 | return -ELIBACC; |
1621 | } | 1608 | } |
@@ -1630,10 +1617,8 @@ cifs_mount(struct super_block *sb, struct cifs_sb_info *cifs_sb, | |||
1630 | &sin_server6.sin6_addr, | 1617 | &sin_server6.sin6_addr, |
1631 | volume_info.username, &srvTcp); | 1618 | volume_info.username, &srvTcp); |
1632 | else { | 1619 | else { |
1633 | if(volume_info.UNC) | 1620 | kfree(volume_info.UNC); |
1634 | kfree(volume_info.UNC); | 1621 | kfree(volume_info.password); |
1635 | if(volume_info.password) | ||
1636 | kfree(volume_info.password); | ||
1637 | FreeXid(xid); | 1622 | FreeXid(xid); |
1638 | return -EINVAL; | 1623 | return -EINVAL; |
1639 | } | 1624 | } |
@@ -1654,10 +1639,8 @@ cifs_mount(struct super_block *sb, struct cifs_sb_info *cifs_sb, | |||
1654 | ("Error connecting to IPv4 socket. Aborting operation")); | 1639 | ("Error connecting to IPv4 socket. Aborting operation")); |
1655 | if(csocket != NULL) | 1640 | if(csocket != NULL) |
1656 | sock_release(csocket); | 1641 | sock_release(csocket); |
1657 | if(volume_info.UNC) | 1642 | kfree(volume_info.UNC); |
1658 | kfree(volume_info.UNC); | 1643 | kfree(volume_info.password); |
1659 | if(volume_info.password) | ||
1660 | kfree(volume_info.password); | ||
1661 | FreeXid(xid); | 1644 | FreeXid(xid); |
1662 | return rc; | 1645 | return rc; |
1663 | } | 1646 | } |
@@ -1666,10 +1649,8 @@ cifs_mount(struct super_block *sb, struct cifs_sb_info *cifs_sb, | |||
1666 | if (srvTcp == NULL) { | 1649 | if (srvTcp == NULL) { |
1667 | rc = -ENOMEM; | 1650 | rc = -ENOMEM; |
1668 | sock_release(csocket); | 1651 | sock_release(csocket); |
1669 | if(volume_info.UNC) | 1652 | kfree(volume_info.UNC); |
1670 | kfree(volume_info.UNC); | 1653 | kfree(volume_info.password); |
1671 | if(volume_info.password) | ||
1672 | kfree(volume_info.password); | ||
1673 | FreeXid(xid); | 1654 | FreeXid(xid); |
1674 | return rc; | 1655 | return rc; |
1675 | } else { | 1656 | } else { |
@@ -1692,10 +1673,8 @@ cifs_mount(struct super_block *sb, struct cifs_sb_info *cifs_sb, | |||
1692 | if(rc < 0) { | 1673 | if(rc < 0) { |
1693 | rc = -ENOMEM; | 1674 | rc = -ENOMEM; |
1694 | sock_release(csocket); | 1675 | sock_release(csocket); |
1695 | if(volume_info.UNC) | 1676 | kfree(volume_info.UNC); |
1696 | kfree(volume_info.UNC); | 1677 | kfree(volume_info.password); |
1697 | if(volume_info.password) | ||
1698 | kfree(volume_info.password); | ||
1699 | FreeXid(xid); | 1678 | FreeXid(xid); |
1700 | return rc; | 1679 | return rc; |
1701 | } | 1680 | } |
@@ -1710,8 +1689,7 @@ cifs_mount(struct super_block *sb, struct cifs_sb_info *cifs_sb, | |||
1710 | if (existingCifsSes) { | 1689 | if (existingCifsSes) { |
1711 | pSesInfo = existingCifsSes; | 1690 | pSesInfo = existingCifsSes; |
1712 | cFYI(1, ("Existing smb sess found ")); | 1691 | cFYI(1, ("Existing smb sess found ")); |
1713 | if(volume_info.password) | 1692 | kfree(volume_info.password); |
1714 | kfree(volume_info.password); | ||
1715 | /* volume_info.UNC freed at end of function */ | 1693 | /* volume_info.UNC freed at end of function */ |
1716 | } else if (!rc) { | 1694 | } else if (!rc) { |
1717 | cFYI(1, ("Existing smb sess not found ")); | 1695 | cFYI(1, ("Existing smb sess not found ")); |
@@ -1741,8 +1719,7 @@ cifs_mount(struct super_block *sb, struct cifs_sb_info *cifs_sb, | |||
1741 | if(!rc) | 1719 | if(!rc) |
1742 | atomic_inc(&srvTcp->socketUseCount); | 1720 | atomic_inc(&srvTcp->socketUseCount); |
1743 | } else | 1721 | } else |
1744 | if(volume_info.password) | 1722 | kfree(volume_info.password); |
1745 | kfree(volume_info.password); | ||
1746 | } | 1723 | } |
1747 | 1724 | ||
1748 | /* search for existing tcon to this server share */ | 1725 | /* search for existing tcon to this server share */ |
@@ -1821,8 +1798,7 @@ cifs_mount(struct super_block *sb, struct cifs_sb_info *cifs_sb, | |||
1821 | "", cifs_sb->local_nls, | 1798 | "", cifs_sb->local_nls, |
1822 | cifs_sb->mnt_cifs_flags & | 1799 | cifs_sb->mnt_cifs_flags & |
1823 | CIFS_MOUNT_MAP_SPECIAL_CHR); | 1800 | CIFS_MOUNT_MAP_SPECIAL_CHR); |
1824 | if(volume_info.UNC) | 1801 | kfree(volume_info.UNC); |
1825 | kfree(volume_info.UNC); | ||
1826 | FreeXid(xid); | 1802 | FreeXid(xid); |
1827 | return -ENODEV; | 1803 | return -ENODEV; |
1828 | } else { | 1804 | } else { |
@@ -1925,8 +1901,7 @@ cifs_mount(struct super_block *sb, struct cifs_sb_info *cifs_sb, | |||
1925 | (in which case it is not needed anymore) but when new sesion is created | 1901 | (in which case it is not needed anymore) but when new sesion is created |
1926 | the password ptr is put in the new session structure (in which case the | 1902 | the password ptr is put in the new session structure (in which case the |
1927 | password will be freed at unmount time) */ | 1903 | password will be freed at unmount time) */ |
1928 | if(volume_info.UNC) | 1904 | kfree(volume_info.UNC); |
1929 | kfree(volume_info.UNC); | ||
1930 | FreeXid(xid); | 1905 | FreeXid(xid); |
1931 | return rc; | 1906 | return rc; |
1932 | } | 1907 | } |
@@ -3283,8 +3258,7 @@ CIFSTCon(unsigned int xid, struct cifsSesInfo *ses, | |||
3283 | if ((bcc_ptr + (2 * length)) - | 3258 | if ((bcc_ptr + (2 * length)) - |
3284 | pByteArea(smb_buffer_response) <= | 3259 | pByteArea(smb_buffer_response) <= |
3285 | BCC(smb_buffer_response)) { | 3260 | BCC(smb_buffer_response)) { |
3286 | if(tcon->nativeFileSystem) | 3261 | kfree(tcon->nativeFileSystem); |
3287 | kfree(tcon->nativeFileSystem); | ||
3288 | tcon->nativeFileSystem = | 3262 | tcon->nativeFileSystem = |
3289 | kzalloc(length + 2, GFP_KERNEL); | 3263 | kzalloc(length + 2, GFP_KERNEL); |
3290 | cifs_strfromUCS_le(tcon->nativeFileSystem, | 3264 | cifs_strfromUCS_le(tcon->nativeFileSystem, |
@@ -3301,8 +3275,7 @@ CIFSTCon(unsigned int xid, struct cifsSesInfo *ses, | |||
3301 | if ((bcc_ptr + length) - | 3275 | if ((bcc_ptr + length) - |
3302 | pByteArea(smb_buffer_response) <= | 3276 | pByteArea(smb_buffer_response) <= |
3303 | BCC(smb_buffer_response)) { | 3277 | BCC(smb_buffer_response)) { |
3304 | if(tcon->nativeFileSystem) | 3278 | kfree(tcon->nativeFileSystem); |
3305 | kfree(tcon->nativeFileSystem); | ||
3306 | tcon->nativeFileSystem = | 3279 | tcon->nativeFileSystem = |
3307 | kzalloc(length + 1, GFP_KERNEL); | 3280 | kzalloc(length + 1, GFP_KERNEL); |
3308 | strncpy(tcon->nativeFileSystem, bcc_ptr, | 3281 | strncpy(tcon->nativeFileSystem, bcc_ptr, |
diff --git a/fs/cifs/link.c b/fs/cifs/link.c index b43e071fe110..0f99aae33162 100644 --- a/fs/cifs/link.c +++ b/fs/cifs/link.c | |||
@@ -84,10 +84,8 @@ cifs_hardlink(struct dentry *old_file, struct inode *inode, | |||
84 | cifsInode->time = 0; /* will force revalidate to go get info when needed */ | 84 | cifsInode->time = 0; /* will force revalidate to go get info when needed */ |
85 | 85 | ||
86 | cifs_hl_exit: | 86 | cifs_hl_exit: |
87 | if (fromName) | 87 | kfree(fromName); |
88 | kfree(fromName); | 88 | kfree(toName); |
89 | if (toName) | ||
90 | kfree(toName); | ||
91 | FreeXid(xid); | 89 | FreeXid(xid); |
92 | return rc; | 90 | return rc; |
93 | } | 91 | } |
@@ -206,8 +204,7 @@ cifs_symlink(struct inode *inode, struct dentry *direntry, const char *symname) | |||
206 | } | 204 | } |
207 | } | 205 | } |
208 | 206 | ||
209 | if (full_path) | 207 | kfree(full_path); |
210 | kfree(full_path); | ||
211 | FreeXid(xid); | 208 | FreeXid(xid); |
212 | return rc; | 209 | return rc; |
213 | } | 210 | } |
@@ -253,8 +250,7 @@ cifs_readlink(struct dentry *direntry, char __user *pBuffer, int buflen) | |||
253 | len = buflen; | 250 | len = buflen; |
254 | tmpbuffer = kmalloc(len,GFP_KERNEL); | 251 | tmpbuffer = kmalloc(len,GFP_KERNEL); |
255 | if(tmpbuffer == NULL) { | 252 | if(tmpbuffer == NULL) { |
256 | if (full_path) | 253 | kfree(full_path); |
257 | kfree(full_path); | ||
258 | FreeXid(xid); | 254 | FreeXid(xid); |
259 | return -ENOMEM; | 255 | return -ENOMEM; |
260 | } | 256 | } |
@@ -303,8 +299,7 @@ cifs_readlink(struct dentry *direntry, char __user *pBuffer, int buflen) | |||
303 | strncpy(tmpbuffer, referrals, len-1); | 299 | strncpy(tmpbuffer, referrals, len-1); |
304 | } | 300 | } |
305 | } | 301 | } |
306 | if(referrals) | 302 | kfree(referrals); |
307 | kfree(referrals); | ||
308 | kfree(tmp_path); | 303 | kfree(tmp_path); |
309 | } | 304 | } |
310 | /* BB add code like else decode referrals then memcpy to | 305 | /* BB add code like else decode referrals then memcpy to |
@@ -323,12 +318,8 @@ cifs_readlink(struct dentry *direntry, char __user *pBuffer, int buflen) | |||
323 | rc)); | 318 | rc)); |
324 | } | 319 | } |
325 | 320 | ||
326 | if (tmpbuffer) { | 321 | kfree(tmpbuffer); |
327 | kfree(tmpbuffer); | 322 | kfree(full_path); |
328 | } | ||
329 | if (full_path) { | ||
330 | kfree(full_path); | ||
331 | } | ||
332 | FreeXid(xid); | 323 | FreeXid(xid); |
333 | return rc; | 324 | return rc; |
334 | } | 325 | } |
diff --git a/fs/cifs/misc.c b/fs/cifs/misc.c index eba1de917f2a..34a06692e4fa 100644 --- a/fs/cifs/misc.c +++ b/fs/cifs/misc.c | |||
@@ -98,14 +98,10 @@ sesInfoFree(struct cifsSesInfo *buf_to_free) | |||
98 | atomic_dec(&sesInfoAllocCount); | 98 | atomic_dec(&sesInfoAllocCount); |
99 | list_del(&buf_to_free->cifsSessionList); | 99 | list_del(&buf_to_free->cifsSessionList); |
100 | write_unlock(&GlobalSMBSeslock); | 100 | write_unlock(&GlobalSMBSeslock); |
101 | if (buf_to_free->serverOS) | 101 | kfree(buf_to_free->serverOS); |
102 | kfree(buf_to_free->serverOS); | 102 | kfree(buf_to_free->serverDomain); |
103 | if (buf_to_free->serverDomain) | 103 | kfree(buf_to_free->serverNOS); |
104 | kfree(buf_to_free->serverDomain); | 104 | kfree(buf_to_free->password); |
105 | if (buf_to_free->serverNOS) | ||
106 | kfree(buf_to_free->serverNOS); | ||
107 | if (buf_to_free->password) | ||
108 | kfree(buf_to_free->password); | ||
109 | kfree(buf_to_free); | 105 | kfree(buf_to_free); |
110 | } | 106 | } |
111 | 107 | ||
@@ -144,8 +140,7 @@ tconInfoFree(struct cifsTconInfo *buf_to_free) | |||
144 | atomic_dec(&tconInfoAllocCount); | 140 | atomic_dec(&tconInfoAllocCount); |
145 | list_del(&buf_to_free->cifsConnectionList); | 141 | list_del(&buf_to_free->cifsConnectionList); |
146 | write_unlock(&GlobalSMBSeslock); | 142 | write_unlock(&GlobalSMBSeslock); |
147 | if (buf_to_free->nativeFileSystem) | 143 | kfree(buf_to_free->nativeFileSystem); |
148 | kfree(buf_to_free->nativeFileSystem); | ||
149 | kfree(buf_to_free); | 144 | kfree(buf_to_free); |
150 | } | 145 | } |
151 | 146 | ||
diff --git a/fs/cifs/xattr.c b/fs/cifs/xattr.c index c1e02eff1d25..f375f87c7dbd 100644 --- a/fs/cifs/xattr.c +++ b/fs/cifs/xattr.c | |||
@@ -87,8 +87,7 @@ int cifs_removexattr(struct dentry * direntry, const char * ea_name) | |||
87 | cifs_sb->mnt_cifs_flags & CIFS_MOUNT_MAP_SPECIAL_CHR); | 87 | cifs_sb->mnt_cifs_flags & CIFS_MOUNT_MAP_SPECIAL_CHR); |
88 | } | 88 | } |
89 | remove_ea_exit: | 89 | remove_ea_exit: |
90 | if (full_path) | 90 | kfree(full_path); |
91 | kfree(full_path); | ||
92 | FreeXid(xid); | 91 | FreeXid(xid); |
93 | #endif | 92 | #endif |
94 | return rc; | 93 | return rc; |
@@ -132,8 +131,7 @@ int cifs_setxattr(struct dentry * direntry, const char * ea_name, | |||
132 | returns as xattrs */ | 131 | returns as xattrs */ |
133 | if(value_size > MAX_EA_VALUE_SIZE) { | 132 | if(value_size > MAX_EA_VALUE_SIZE) { |
134 | cFYI(1,("size of EA value too large")); | 133 | cFYI(1,("size of EA value too large")); |
135 | if(full_path) | 134 | kfree(full_path); |
136 | kfree(full_path); | ||
137 | FreeXid(xid); | 135 | FreeXid(xid); |
138 | return -EOPNOTSUPP; | 136 | return -EOPNOTSUPP; |
139 | } | 137 | } |
@@ -195,8 +193,7 @@ int cifs_setxattr(struct dentry * direntry, const char * ea_name, | |||
195 | } | 193 | } |
196 | 194 | ||
197 | set_ea_exit: | 195 | set_ea_exit: |
198 | if (full_path) | 196 | kfree(full_path); |
199 | kfree(full_path); | ||
200 | FreeXid(xid); | 197 | FreeXid(xid); |
201 | #endif | 198 | #endif |
202 | return rc; | 199 | return rc; |
@@ -298,8 +295,7 @@ ssize_t cifs_getxattr(struct dentry * direntry, const char * ea_name, | |||
298 | rc = -EOPNOTSUPP; | 295 | rc = -EOPNOTSUPP; |
299 | 296 | ||
300 | get_ea_exit: | 297 | get_ea_exit: |
301 | if (full_path) | 298 | kfree(full_path); |
302 | kfree(full_path); | ||
303 | FreeXid(xid); | 299 | FreeXid(xid); |
304 | #endif | 300 | #endif |
305 | return rc; | 301 | return rc; |
@@ -345,8 +341,7 @@ ssize_t cifs_listxattr(struct dentry * direntry, char * data, size_t buf_size) | |||
345 | cifs_sb->mnt_cifs_flags & | 341 | cifs_sb->mnt_cifs_flags & |
346 | CIFS_MOUNT_MAP_SPECIAL_CHR); | 342 | CIFS_MOUNT_MAP_SPECIAL_CHR); |
347 | 343 | ||
348 | if (full_path) | 344 | kfree(full_path); |
349 | kfree(full_path); | ||
350 | FreeXid(xid); | 345 | FreeXid(xid); |
351 | #endif | 346 | #endif |
352 | return rc; | 347 | return rc; |
diff --git a/fs/compat_ioctl.c b/fs/compat_ioctl.c index 43dbcb0b21eb..26300fccb4fc 100644 --- a/fs/compat_ioctl.c +++ b/fs/compat_ioctl.c | |||
@@ -840,146 +840,6 @@ static int hdio_getgeo(unsigned int fd, unsigned int cmd, unsigned long arg) | |||
840 | return err ? -EFAULT : 0; | 840 | return err ? -EFAULT : 0; |
841 | } | 841 | } |
842 | 842 | ||
843 | struct fb_fix_screeninfo32 { | ||
844 | char id[16]; | ||
845 | compat_caddr_t smem_start; | ||
846 | u32 smem_len; | ||
847 | u32 type; | ||
848 | u32 type_aux; | ||
849 | u32 visual; | ||
850 | u16 xpanstep; | ||
851 | u16 ypanstep; | ||
852 | u16 ywrapstep; | ||
853 | u32 line_length; | ||
854 | compat_caddr_t mmio_start; | ||
855 | u32 mmio_len; | ||
856 | u32 accel; | ||
857 | u16 reserved[3]; | ||
858 | }; | ||
859 | |||
860 | struct fb_cmap32 { | ||
861 | u32 start; | ||
862 | u32 len; | ||
863 | compat_caddr_t red; | ||
864 | compat_caddr_t green; | ||
865 | compat_caddr_t blue; | ||
866 | compat_caddr_t transp; | ||
867 | }; | ||
868 | |||
869 | static int fb_getput_cmap(unsigned int fd, unsigned int cmd, unsigned long arg) | ||
870 | { | ||
871 | struct fb_cmap_user __user *cmap; | ||
872 | struct fb_cmap32 __user *cmap32; | ||
873 | __u32 data; | ||
874 | int err; | ||
875 | |||
876 | cmap = compat_alloc_user_space(sizeof(*cmap)); | ||
877 | cmap32 = compat_ptr(arg); | ||
878 | |||
879 | if (copy_in_user(&cmap->start, &cmap32->start, 2 * sizeof(__u32))) | ||
880 | return -EFAULT; | ||
881 | |||
882 | if (get_user(data, &cmap32->red) || | ||
883 | put_user(compat_ptr(data), &cmap->red) || | ||
884 | get_user(data, &cmap32->green) || | ||
885 | put_user(compat_ptr(data), &cmap->green) || | ||
886 | get_user(data, &cmap32->blue) || | ||
887 | put_user(compat_ptr(data), &cmap->blue) || | ||
888 | get_user(data, &cmap32->transp) || | ||
889 | put_user(compat_ptr(data), &cmap->transp)) | ||
890 | return -EFAULT; | ||
891 | |||
892 | err = sys_ioctl(fd, cmd, (unsigned long) cmap); | ||
893 | |||
894 | if (!err) { | ||
895 | if (copy_in_user(&cmap32->start, | ||
896 | &cmap->start, | ||
897 | 2 * sizeof(__u32))) | ||
898 | err = -EFAULT; | ||
899 | } | ||
900 | return err; | ||
901 | } | ||
902 | |||
903 | static int do_fscreeninfo_to_user(struct fb_fix_screeninfo *fix, | ||
904 | struct fb_fix_screeninfo32 __user *fix32) | ||
905 | { | ||
906 | __u32 data; | ||
907 | int err; | ||
908 | |||
909 | err = copy_to_user(&fix32->id, &fix->id, sizeof(fix32->id)); | ||
910 | |||
911 | data = (__u32) (unsigned long) fix->smem_start; | ||
912 | err |= put_user(data, &fix32->smem_start); | ||
913 | |||
914 | err |= put_user(fix->smem_len, &fix32->smem_len); | ||
915 | err |= put_user(fix->type, &fix32->type); | ||
916 | err |= put_user(fix->type_aux, &fix32->type_aux); | ||
917 | err |= put_user(fix->visual, &fix32->visual); | ||
918 | err |= put_user(fix->xpanstep, &fix32->xpanstep); | ||
919 | err |= put_user(fix->ypanstep, &fix32->ypanstep); | ||
920 | err |= put_user(fix->ywrapstep, &fix32->ywrapstep); | ||
921 | err |= put_user(fix->line_length, &fix32->line_length); | ||
922 | |||
923 | data = (__u32) (unsigned long) fix->mmio_start; | ||
924 | err |= put_user(data, &fix32->mmio_start); | ||
925 | |||
926 | err |= put_user(fix->mmio_len, &fix32->mmio_len); | ||
927 | err |= put_user(fix->accel, &fix32->accel); | ||
928 | err |= copy_to_user(fix32->reserved, fix->reserved, | ||
929 | sizeof(fix->reserved)); | ||
930 | |||
931 | return err; | ||
932 | } | ||
933 | |||
934 | static int fb_get_fscreeninfo(unsigned int fd, unsigned int cmd, unsigned long arg) | ||
935 | { | ||
936 | mm_segment_t old_fs; | ||
937 | struct fb_fix_screeninfo fix; | ||
938 | struct fb_fix_screeninfo32 __user *fix32; | ||
939 | int err; | ||
940 | |||
941 | fix32 = compat_ptr(arg); | ||
942 | |||
943 | old_fs = get_fs(); | ||
944 | set_fs(KERNEL_DS); | ||
945 | err = sys_ioctl(fd, cmd, (unsigned long) &fix); | ||
946 | set_fs(old_fs); | ||
947 | |||
948 | if (!err) | ||
949 | err = do_fscreeninfo_to_user(&fix, fix32); | ||
950 | |||
951 | return err; | ||
952 | } | ||
953 | |||
954 | static int fb_ioctl_trans(unsigned int fd, unsigned int cmd, unsigned long arg) | ||
955 | { | ||
956 | int err; | ||
957 | |||
958 | switch (cmd) { | ||
959 | case FBIOGET_FSCREENINFO: | ||
960 | err = fb_get_fscreeninfo(fd,cmd, arg); | ||
961 | break; | ||
962 | |||
963 | case FBIOGETCMAP: | ||
964 | case FBIOPUTCMAP: | ||
965 | err = fb_getput_cmap(fd, cmd, arg); | ||
966 | break; | ||
967 | |||
968 | default: | ||
969 | do { | ||
970 | static int count; | ||
971 | if (++count <= 20) | ||
972 | printk("%s: Unknown fb ioctl cmd fd(%d) " | ||
973 | "cmd(%08x) arg(%08lx)\n", | ||
974 | __FUNCTION__, fd, cmd, arg); | ||
975 | } while(0); | ||
976 | err = -ENOSYS; | ||
977 | break; | ||
978 | }; | ||
979 | |||
980 | return err; | ||
981 | } | ||
982 | |||
983 | static int hdio_ioctl_trans(unsigned int fd, unsigned int cmd, unsigned long arg) | 843 | static int hdio_ioctl_trans(unsigned int fd, unsigned int cmd, unsigned long arg) |
984 | { | 844 | { |
985 | mm_segment_t old_fs = get_fs(); | 845 | mm_segment_t old_fs = get_fs(); |
@@ -2235,7 +2095,8 @@ static int fd_ioctl_trans(unsigned int fd, unsigned int cmd, unsigned long arg) | |||
2235 | if (err) | 2095 | if (err) |
2236 | err = -EFAULT; | 2096 | err = -EFAULT; |
2237 | 2097 | ||
2238 | out: if (karg) kfree(karg); | 2098 | out: |
2099 | kfree(karg); | ||
2239 | return err; | 2100 | return err; |
2240 | } | 2101 | } |
2241 | 2102 | ||
@@ -2952,10 +2813,7 @@ HANDLE_IOCTL(BLKGETSIZE, w_long) | |||
2952 | HANDLE_IOCTL(0x1260, broken_blkgetsize) | 2813 | HANDLE_IOCTL(0x1260, broken_blkgetsize) |
2953 | HANDLE_IOCTL(BLKFRAGET, w_long) | 2814 | HANDLE_IOCTL(BLKFRAGET, w_long) |
2954 | HANDLE_IOCTL(BLKSECTGET, w_long) | 2815 | HANDLE_IOCTL(BLKSECTGET, w_long) |
2955 | HANDLE_IOCTL(FBIOGET_FSCREENINFO, fb_ioctl_trans) | ||
2956 | HANDLE_IOCTL(BLKPG, blkpg_ioctl_trans) | 2816 | HANDLE_IOCTL(BLKPG, blkpg_ioctl_trans) |
2957 | HANDLE_IOCTL(FBIOGETCMAP, fb_ioctl_trans) | ||
2958 | HANDLE_IOCTL(FBIOPUTCMAP, fb_ioctl_trans) | ||
2959 | HANDLE_IOCTL(HDIO_GET_KEEPSETTINGS, hdio_ioctl_trans) | 2817 | HANDLE_IOCTL(HDIO_GET_KEEPSETTINGS, hdio_ioctl_trans) |
2960 | HANDLE_IOCTL(HDIO_GET_UNMASKINTR, hdio_ioctl_trans) | 2818 | HANDLE_IOCTL(HDIO_GET_UNMASKINTR, hdio_ioctl_trans) |
2961 | HANDLE_IOCTL(HDIO_GET_DMA, hdio_ioctl_trans) | 2819 | HANDLE_IOCTL(HDIO_GET_DMA, hdio_ioctl_trans) |
@@ -3050,6 +2908,16 @@ HANDLE_IOCTL(TIOCSSERIAL, serial_struct_ioctl) | |||
3050 | COMPATIBLE_IOCTL(TIOCGLTC) | 2908 | COMPATIBLE_IOCTL(TIOCGLTC) |
3051 | COMPATIBLE_IOCTL(TIOCSLTC) | 2909 | COMPATIBLE_IOCTL(TIOCSLTC) |
3052 | #endif | 2910 | #endif |
2911 | #ifdef TIOCSTART | ||
2912 | /* | ||
2913 | * For these two we have defintions in ioctls.h and/or termios.h on | ||
2914 | * some architectures but no actual implemention. Some applications | ||
2915 | * like bash call them if they are defined in the headers, so we provide | ||
2916 | * entries here to avoid syslog message spew. | ||
2917 | */ | ||
2918 | COMPATIBLE_IOCTL(TIOCSTART) | ||
2919 | COMPATIBLE_IOCTL(TIOCSTOP) | ||
2920 | #endif | ||
3053 | /* Usbdevfs */ | 2921 | /* Usbdevfs */ |
3054 | HANDLE_IOCTL(USBDEVFS_CONTROL32, do_usbdevfs_control) | 2922 | HANDLE_IOCTL(USBDEVFS_CONTROL32, do_usbdevfs_control) |
3055 | HANDLE_IOCTL(USBDEVFS_BULK32, do_usbdevfs_bulk) | 2923 | HANDLE_IOCTL(USBDEVFS_BULK32, do_usbdevfs_bulk) |
diff --git a/fs/dcache.c b/fs/dcache.c index e90512ed35a4..17e439138681 100644 --- a/fs/dcache.c +++ b/fs/dcache.c | |||
@@ -644,7 +644,7 @@ void shrink_dcache_parent(struct dentry * parent) | |||
644 | * | 644 | * |
645 | * Prune the dentries that are anonymous | 645 | * Prune the dentries that are anonymous |
646 | * | 646 | * |
647 | * parsing d_hash list does not hlist_for_each_rcu() as it | 647 | * parsing d_hash list does not hlist_for_each_entry_rcu() as it |
648 | * done under dcache_lock. | 648 | * done under dcache_lock. |
649 | * | 649 | * |
650 | */ | 650 | */ |
@@ -1043,15 +1043,13 @@ struct dentry * __d_lookup(struct dentry * parent, struct qstr * name) | |||
1043 | struct hlist_head *head = d_hash(parent,hash); | 1043 | struct hlist_head *head = d_hash(parent,hash); |
1044 | struct dentry *found = NULL; | 1044 | struct dentry *found = NULL; |
1045 | struct hlist_node *node; | 1045 | struct hlist_node *node; |
1046 | struct dentry *dentry; | ||
1046 | 1047 | ||
1047 | rcu_read_lock(); | 1048 | rcu_read_lock(); |
1048 | 1049 | ||
1049 | hlist_for_each_rcu(node, head) { | 1050 | hlist_for_each_entry_rcu(dentry, node, head, d_hash) { |
1050 | struct dentry *dentry; | ||
1051 | struct qstr *qstr; | 1051 | struct qstr *qstr; |
1052 | 1052 | ||
1053 | dentry = hlist_entry(node, struct dentry, d_hash); | ||
1054 | |||
1055 | if (dentry->d_name.hash != hash) | 1053 | if (dentry->d_name.hash != hash) |
1056 | continue; | 1054 | continue; |
1057 | if (dentry->d_parent != parent) | 1055 | if (dentry->d_parent != parent) |
@@ -1123,7 +1121,7 @@ int d_validate(struct dentry *dentry, struct dentry *dparent) | |||
1123 | spin_lock(&dcache_lock); | 1121 | spin_lock(&dcache_lock); |
1124 | base = d_hash(dparent, dentry->d_name.hash); | 1122 | base = d_hash(dparent, dentry->d_name.hash); |
1125 | hlist_for_each(lhp,base) { | 1123 | hlist_for_each(lhp,base) { |
1126 | /* hlist_for_each_rcu() not required for d_hash list | 1124 | /* hlist_for_each_entry_rcu() not required for d_hash list |
1127 | * as it is parsed under dcache_lock | 1125 | * as it is parsed under dcache_lock |
1128 | */ | 1126 | */ |
1129 | if (dentry == hlist_entry(lhp, struct dentry, d_hash)) { | 1127 | if (dentry == hlist_entry(lhp, struct dentry, d_hash)) { |
diff --git a/fs/devfs/base.c b/fs/devfs/base.c index 8b679b67e5e0..1274422a5384 100644 --- a/fs/devfs/base.c +++ b/fs/devfs/base.c | |||
@@ -2738,10 +2738,8 @@ static int devfsd_close(struct inode *inode, struct file *file) | |||
2738 | entry = fs_info->devfsd_first_event; | 2738 | entry = fs_info->devfsd_first_event; |
2739 | fs_info->devfsd_first_event = NULL; | 2739 | fs_info->devfsd_first_event = NULL; |
2740 | fs_info->devfsd_last_event = NULL; | 2740 | fs_info->devfsd_last_event = NULL; |
2741 | if (fs_info->devfsd_info) { | 2741 | kfree(fs_info->devfsd_info); |
2742 | kfree(fs_info->devfsd_info); | 2742 | fs_info->devfsd_info = NULL; |
2743 | fs_info->devfsd_info = NULL; | ||
2744 | } | ||
2745 | spin_unlock(&fs_info->devfsd_buffer_lock); | 2743 | spin_unlock(&fs_info->devfsd_buffer_lock); |
2746 | fs_info->devfsd_pgrp = 0; | 2744 | fs_info->devfsd_pgrp = 0; |
2747 | fs_info->devfsd_task = NULL; | 2745 | fs_info->devfsd_task = NULL; |
diff --git a/fs/dquot.c b/fs/dquot.c index ea7644227a65..05b60283c9c2 100644 --- a/fs/dquot.c +++ b/fs/dquot.c | |||
@@ -77,6 +77,7 @@ | |||
77 | #include <linux/kmod.h> | 77 | #include <linux/kmod.h> |
78 | #include <linux/namei.h> | 78 | #include <linux/namei.h> |
79 | #include <linux/buffer_head.h> | 79 | #include <linux/buffer_head.h> |
80 | #include <linux/quotaops.h> | ||
80 | 81 | ||
81 | #include <asm/uaccess.h> | 82 | #include <asm/uaccess.h> |
82 | 83 | ||
@@ -1320,13 +1321,11 @@ int vfs_quota_off(struct super_block *sb, int type) | |||
1320 | int cnt; | 1321 | int cnt; |
1321 | struct quota_info *dqopt = sb_dqopt(sb); | 1322 | struct quota_info *dqopt = sb_dqopt(sb); |
1322 | struct inode *toputinode[MAXQUOTAS]; | 1323 | struct inode *toputinode[MAXQUOTAS]; |
1323 | struct vfsmount *toputmnt[MAXQUOTAS]; | ||
1324 | 1324 | ||
1325 | /* We need to serialize quota_off() for device */ | 1325 | /* We need to serialize quota_off() for device */ |
1326 | down(&dqopt->dqonoff_sem); | 1326 | down(&dqopt->dqonoff_sem); |
1327 | for (cnt = 0; cnt < MAXQUOTAS; cnt++) { | 1327 | for (cnt = 0; cnt < MAXQUOTAS; cnt++) { |
1328 | toputinode[cnt] = NULL; | 1328 | toputinode[cnt] = NULL; |
1329 | toputmnt[cnt] = NULL; | ||
1330 | if (type != -1 && cnt != type) | 1329 | if (type != -1 && cnt != type) |
1331 | continue; | 1330 | continue; |
1332 | if (!sb_has_quota_enabled(sb, cnt)) | 1331 | if (!sb_has_quota_enabled(sb, cnt)) |
@@ -1347,9 +1346,7 @@ int vfs_quota_off(struct super_block *sb, int type) | |||
1347 | put_quota_format(dqopt->info[cnt].dqi_format); | 1346 | put_quota_format(dqopt->info[cnt].dqi_format); |
1348 | 1347 | ||
1349 | toputinode[cnt] = dqopt->files[cnt]; | 1348 | toputinode[cnt] = dqopt->files[cnt]; |
1350 | toputmnt[cnt] = dqopt->mnt[cnt]; | ||
1351 | dqopt->files[cnt] = NULL; | 1349 | dqopt->files[cnt] = NULL; |
1352 | dqopt->mnt[cnt] = NULL; | ||
1353 | dqopt->info[cnt].dqi_flags = 0; | 1350 | dqopt->info[cnt].dqi_flags = 0; |
1354 | dqopt->info[cnt].dqi_igrace = 0; | 1351 | dqopt->info[cnt].dqi_igrace = 0; |
1355 | dqopt->info[cnt].dqi_bgrace = 0; | 1352 | dqopt->info[cnt].dqi_bgrace = 0; |
@@ -1357,10 +1354,7 @@ int vfs_quota_off(struct super_block *sb, int type) | |||
1357 | } | 1354 | } |
1358 | up(&dqopt->dqonoff_sem); | 1355 | up(&dqopt->dqonoff_sem); |
1359 | /* Sync the superblock so that buffers with quota data are written to | 1356 | /* Sync the superblock so that buffers with quota data are written to |
1360 | * disk (and so userspace sees correct data afterwards). | 1357 | * disk (and so userspace sees correct data afterwards). */ |
1361 | * The reference to vfsmnt we are still holding protects us from | ||
1362 | * umount (we don't have it only when quotas are turned on/off for | ||
1363 | * journal replay but in that case we are guarded by the fs anyway). */ | ||
1364 | if (sb->s_op->sync_fs) | 1358 | if (sb->s_op->sync_fs) |
1365 | sb->s_op->sync_fs(sb, 1); | 1359 | sb->s_op->sync_fs(sb, 1); |
1366 | sync_blockdev(sb->s_bdev); | 1360 | sync_blockdev(sb->s_bdev); |
@@ -1384,10 +1378,6 @@ int vfs_quota_off(struct super_block *sb, int type) | |||
1384 | iput(toputinode[cnt]); | 1378 | iput(toputinode[cnt]); |
1385 | } | 1379 | } |
1386 | up(&dqopt->dqonoff_sem); | 1380 | up(&dqopt->dqonoff_sem); |
1387 | /* We don't hold the reference when we turned on quotas | ||
1388 | * just for the journal replay... */ | ||
1389 | if (toputmnt[cnt]) | ||
1390 | mntput(toputmnt[cnt]); | ||
1391 | } | 1381 | } |
1392 | if (sb->s_bdev) | 1382 | if (sb->s_bdev) |
1393 | invalidate_bdev(sb->s_bdev, 0); | 1383 | invalidate_bdev(sb->s_bdev, 0); |
@@ -1502,11 +1492,8 @@ int vfs_quota_on(struct super_block *sb, int type, int format_id, char *path) | |||
1502 | /* Quota file not on the same filesystem? */ | 1492 | /* Quota file not on the same filesystem? */ |
1503 | if (nd.mnt->mnt_sb != sb) | 1493 | if (nd.mnt->mnt_sb != sb) |
1504 | error = -EXDEV; | 1494 | error = -EXDEV; |
1505 | else { | 1495 | else |
1506 | error = vfs_quota_on_inode(nd.dentry->d_inode, type, format_id); | 1496 | error = vfs_quota_on_inode(nd.dentry->d_inode, type, format_id); |
1507 | if (!error) | ||
1508 | sb_dqopt(sb)->mnt[type] = mntget(nd.mnt); | ||
1509 | } | ||
1510 | out_path: | 1497 | out_path: |
1511 | path_release(&nd); | 1498 | path_release(&nd); |
1512 | return error; | 1499 | return error; |
@@ -48,6 +48,7 @@ | |||
48 | #include <linux/syscalls.h> | 48 | #include <linux/syscalls.h> |
49 | #include <linux/rmap.h> | 49 | #include <linux/rmap.h> |
50 | #include <linux/acct.h> | 50 | #include <linux/acct.h> |
51 | #include <linux/cn_proc.h> | ||
51 | 52 | ||
52 | #include <asm/uaccess.h> | 53 | #include <asm/uaccess.h> |
53 | #include <asm/mmu_context.h> | 54 | #include <asm/mmu_context.h> |
@@ -134,7 +135,7 @@ asmlinkage long sys_uselib(const char __user * library) | |||
134 | if (!S_ISREG(nd.dentry->d_inode->i_mode)) | 135 | if (!S_ISREG(nd.dentry->d_inode->i_mode)) |
135 | goto exit; | 136 | goto exit; |
136 | 137 | ||
137 | error = permission(nd.dentry->d_inode, MAY_READ | MAY_EXEC, &nd); | 138 | error = vfs_permission(&nd, MAY_READ | MAY_EXEC); |
138 | if (error) | 139 | if (error) |
139 | goto exit; | 140 | goto exit; |
140 | 141 | ||
@@ -494,7 +495,7 @@ struct file *open_exec(const char *name) | |||
494 | file = ERR_PTR(-EACCES); | 495 | file = ERR_PTR(-EACCES); |
495 | if (!(nd.mnt->mnt_flags & MNT_NOEXEC) && | 496 | if (!(nd.mnt->mnt_flags & MNT_NOEXEC) && |
496 | S_ISREG(inode->i_mode)) { | 497 | S_ISREG(inode->i_mode)) { |
497 | int err = permission(inode, MAY_EXEC, &nd); | 498 | int err = vfs_permission(&nd, MAY_EXEC); |
498 | if (!err && !(inode->i_mode & 0111)) | 499 | if (!err && !(inode->i_mode & 0111)) |
499 | err = -EACCES; | 500 | err = -EACCES; |
500 | file = ERR_PTR(err); | 501 | file = ERR_PTR(err); |
@@ -589,6 +590,7 @@ static inline int de_thread(struct task_struct *tsk) | |||
589 | struct signal_struct *sig = tsk->signal; | 590 | struct signal_struct *sig = tsk->signal; |
590 | struct sighand_struct *newsighand, *oldsighand = tsk->sighand; | 591 | struct sighand_struct *newsighand, *oldsighand = tsk->sighand; |
591 | spinlock_t *lock = &oldsighand->siglock; | 592 | spinlock_t *lock = &oldsighand->siglock; |
593 | struct task_struct *leader = NULL; | ||
592 | int count; | 594 | int count; |
593 | 595 | ||
594 | /* | 596 | /* |
@@ -664,7 +666,7 @@ static inline int de_thread(struct task_struct *tsk) | |||
664 | * and to assume its PID: | 666 | * and to assume its PID: |
665 | */ | 667 | */ |
666 | if (!thread_group_leader(current)) { | 668 | if (!thread_group_leader(current)) { |
667 | struct task_struct *leader = current->group_leader, *parent; | 669 | struct task_struct *parent; |
668 | struct dentry *proc_dentry1, *proc_dentry2; | 670 | struct dentry *proc_dentry1, *proc_dentry2; |
669 | unsigned long exit_state, ptrace; | 671 | unsigned long exit_state, ptrace; |
670 | 672 | ||
@@ -673,6 +675,7 @@ static inline int de_thread(struct task_struct *tsk) | |||
673 | * It should already be zombie at this point, most | 675 | * It should already be zombie at this point, most |
674 | * of the time. | 676 | * of the time. |
675 | */ | 677 | */ |
678 | leader = current->group_leader; | ||
676 | while (leader->exit_state != EXIT_ZOMBIE) | 679 | while (leader->exit_state != EXIT_ZOMBIE) |
677 | yield(); | 680 | yield(); |
678 | 681 | ||
@@ -732,7 +735,6 @@ static inline int de_thread(struct task_struct *tsk) | |||
732 | proc_pid_flush(proc_dentry2); | 735 | proc_pid_flush(proc_dentry2); |
733 | 736 | ||
734 | BUG_ON(exit_state != EXIT_ZOMBIE); | 737 | BUG_ON(exit_state != EXIT_ZOMBIE); |
735 | release_task(leader); | ||
736 | } | 738 | } |
737 | 739 | ||
738 | /* | 740 | /* |
@@ -742,8 +744,11 @@ static inline int de_thread(struct task_struct *tsk) | |||
742 | sig->flags = 0; | 744 | sig->flags = 0; |
743 | 745 | ||
744 | no_thread_group: | 746 | no_thread_group: |
745 | BUG_ON(atomic_read(&sig->count) != 1); | ||
746 | exit_itimers(sig); | 747 | exit_itimers(sig); |
748 | if (leader) | ||
749 | release_task(leader); | ||
750 | |||
751 | BUG_ON(atomic_read(&sig->count) != 1); | ||
747 | 752 | ||
748 | if (atomic_read(&oldsighand->count) == 1) { | 753 | if (atomic_read(&oldsighand->count) == 1) { |
749 | /* | 754 | /* |
@@ -891,7 +896,7 @@ int flush_old_exec(struct linux_binprm * bprm) | |||
891 | flush_thread(); | 896 | flush_thread(); |
892 | 897 | ||
893 | if (bprm->e_uid != current->euid || bprm->e_gid != current->egid || | 898 | if (bprm->e_uid != current->euid || bprm->e_gid != current->egid || |
894 | permission(bprm->file->f_dentry->d_inode,MAY_READ, NULL) || | 899 | file_permission(bprm->file, MAY_READ) || |
895 | (bprm->interp_flags & BINPRM_FLAGS_ENFORCE_NONDUMP)) { | 900 | (bprm->interp_flags & BINPRM_FLAGS_ENFORCE_NONDUMP)) { |
896 | suid_keys(current); | 901 | suid_keys(current); |
897 | current->mm->dumpable = suid_dumpable; | 902 | current->mm->dumpable = suid_dumpable; |
@@ -1096,6 +1101,7 @@ int search_binary_handler(struct linux_binprm *bprm,struct pt_regs *regs) | |||
1096 | fput(bprm->file); | 1101 | fput(bprm->file); |
1097 | bprm->file = NULL; | 1102 | bprm->file = NULL; |
1098 | current->did_exec = 1; | 1103 | current->did_exec = 1; |
1104 | proc_exec_connector(current); | ||
1099 | return retval; | 1105 | return retval; |
1100 | } | 1106 | } |
1101 | read_lock(&binfmt_lock); | 1107 | read_lock(&binfmt_lock); |
@@ -1509,7 +1515,7 @@ int do_coredump(long signr, int exit_code, struct pt_regs * regs) | |||
1509 | goto close_fail; | 1515 | goto close_fail; |
1510 | if (!file->f_op->write) | 1516 | if (!file->f_op->write) |
1511 | goto close_fail; | 1517 | goto close_fail; |
1512 | if (do_truncate(file->f_dentry, 0) != 0) | 1518 | if (do_truncate(file->f_dentry, 0, file) != 0) |
1513 | goto close_fail; | 1519 | goto close_fail; |
1514 | 1520 | ||
1515 | retval = binfmt->core_dump(signr, regs, file); | 1521 | retval = binfmt->core_dump(signr, regs, file); |
diff --git a/fs/ext2/CHANGES b/fs/ext2/CHANGES deleted file mode 100644 index aa5aaf0e5911..000000000000 --- a/fs/ext2/CHANGES +++ /dev/null | |||
@@ -1,157 +0,0 @@ | |||
1 | Changes from version 0.5a to version 0.5b | ||
2 | ========================================= | ||
3 | - Now that we have sysctl(), the immutable flag cannot be changed when | ||
4 | the system is running at security level > 0. | ||
5 | - Some cleanups in the code. | ||
6 | - More consistency checks on directories. | ||
7 | - The ext2.diff patch from Tom May <ftom@netcom.com> has been | ||
8 | integrated. This patch replaces expensive "/" and "%" with | ||
9 | cheap ">>" and "&" where possible. | ||
10 | |||
11 | Changes from version 0.5 to version 0.5a | ||
12 | ======================================== | ||
13 | - Zero the partial block following the end of the file when a file | ||
14 | is truncated. | ||
15 | - Dates updated in the copyright. | ||
16 | - More checks when the filesystem is mounted: the count of blocks, | ||
17 | fragments, and inodes per group is checked against the block size. | ||
18 | - The buffers used by the error routines are now static variables, to | ||
19 | avoid using space on the kernel stack, as requested by Linus. | ||
20 | - Some cleanups in the error messages (some versions of syslog contain | ||
21 | a bug which truncates an error message if it contains '\n'). | ||
22 | - Check that no data can be written to a file past the 2GB limit. | ||
23 | - The famous readdir() bug has been fixed by Stephen Tweedie. | ||
24 | - Added a revision level in the superblock. | ||
25 | - Full support for O_SYNC flag of the open system call. | ||
26 | - New mount options: `resuid=#uid' and `resgid=#gid'. `resuid' causes | ||
27 | ext2fs to consider user #uid like root for the reserved blocks. | ||
28 | `resgid' acts the same way with group #gid. New fields in the | ||
29 | superblock contain default values for resuid and resgid and can | ||
30 | be modified by tune2fs. | ||
31 | Idea comes from Rene Cougnenc <cougnenc@renux.frmug.fr.net>. | ||
32 | - New mount options: `bsddf' and `minixdf'. `bsddf' causes ext2fs | ||
33 | to remove the blocks used for FS structures from the total block | ||
34 | count in statfs. With `minixdf', ext2fs mimics Minix behavior | ||
35 | in statfs (i.e. it returns the total number of blocks on the | ||
36 | partition). This is intended to make bde happy :-) | ||
37 | - New file attributes: | ||
38 | - Immutable files cannot be modified. Data cannot be written to | ||
39 | these files. They cannot be removed, renamed and new links cannot | ||
40 | be created. Even root cannot modify the files. He has to remove | ||
41 | the immutable attribute first. | ||
42 | - Append-only files: can only be written in append-mode when writing. | ||
43 | They cannot be removed, renamed and new links cannot be created. | ||
44 | Note: files may only be added to an append-only directory. | ||
45 | - No-dump files: the attribute is not used by the kernel. My port | ||
46 | of dump uses it to avoid backing up files which are not important. | ||
47 | - New check in ext2_check_dir_entry: the inode number is checked. | ||
48 | - Support for big file systems: the copy of the FS descriptor is now | ||
49 | dynamically allocated (previous versions used a fixed size array). | ||
50 | This allows to mount 2GB+ FS. | ||
51 | - Reorganization of the ext2_inode structure to allow other operating | ||
52 | systems to create specific fields if they use ext2fs as their native | ||
53 | file system. Currently, ext2fs is only implemented in Linux but | ||
54 | will soon be part of Gnu Hurd and of Masix. | ||
55 | |||
56 | Changes from version 0.4b to version 0.5 | ||
57 | ======================================== | ||
58 | - New superblock fields: s_lastcheck and s_checkinterval added | ||
59 | by Uwe Ohse <uwe@tirka.gun.de> to implement timedependent checks | ||
60 | of the file system | ||
61 | - Real random numbers for secure rm added by Pierre del Perugia | ||
62 | <delperug@gla.ecoledoc.ibp.fr> | ||
63 | - The mount warnings related to the state of a fs are not printed | ||
64 | if the fs is mounted read-only, idea by Nick Holloway | ||
65 | <alfie@dcs.warwick.ac.uk> | ||
66 | |||
67 | Changes from version 0.4a to version 0.4b | ||
68 | ========================================= | ||
69 | - Copyrights changed to include the name of my laboratory. | ||
70 | - Clean up of balloc.c and ialloc.c. | ||
71 | - More consistency checks. | ||
72 | - Block preallocation added by Stephen Tweedie. | ||
73 | - Direct reads of directories disallowed. | ||
74 | - Readahead implemented in readdir by Stephen Tweedie. | ||
75 | - Bugs in block and inodes allocation fixed. | ||
76 | - Readahead implemented in ext2_find_entry by Chip Salzenberg. | ||
77 | - New mount options: | ||
78 | `check=none|normal|strict' | ||
79 | `debug' | ||
80 | `errors=continue|remount-ro|panic' | ||
81 | `grpid', `bsdgroups' | ||
82 | `nocheck' | ||
83 | `nogrpid', `sysvgroups' | ||
84 | - truncate() now tries to deallocate contiguous blocks in a single call | ||
85 | to ext2_free_blocks(). | ||
86 | - lots of cosmetic changes. | ||
87 | |||
88 | Changes from version 0.4 to version 0.4a | ||
89 | ======================================== | ||
90 | - the `sync' option support is now complete. Version 0.4 was not | ||
91 | supporting it when truncating a file. I have tested the synchronous | ||
92 | writes and they work but they make the system very slow :-( I have | ||
93 | to work again on this to make it faster. | ||
94 | - when detecting an error on a mounted filesystem, version 0.4 used | ||
95 | to try to write a flag in the super block even if the filesystem had | ||
96 | been mounted read-only. This is fixed. | ||
97 | - the `sb=#' option now causes the kernel code to use the filesystem | ||
98 | descriptors located at block #+1. Version 0.4 used the superblock | ||
99 | backup located at block # but used the main copy of the descriptors. | ||
100 | - a new file attribute `S' is supported. This attribute causes | ||
101 | synchronous writes but is applied to a file not to the entire file | ||
102 | system (thanks to Michael Kraehe <kraehe@bakunin.north.de> for | ||
103 | suggesting it). | ||
104 | - the directory cache is inhibited by default. The cache management | ||
105 | code seems to be buggy and I have to look at it carefully before | ||
106 | using it again. | ||
107 | - deleting a file with the `s' attribute (secure deletion) causes its | ||
108 | blocks to be overwritten with random values not with zeros (thanks to | ||
109 | Michael A. Griffith <grif@cs.ucr.edu> for suggesting it). | ||
110 | - lots of cosmetic changes have been made. | ||
111 | |||
112 | Changes from version 0.3 to version 0.4 | ||
113 | ======================================= | ||
114 | - Three new mount options are supported: `check', `sync' and `sb=#'. | ||
115 | `check' tells the kernel code to make more consistency checks | ||
116 | when the file system is mounted. Currently, the kernel code checks | ||
117 | that the blocks and inodes bitmaps are consistent with the free | ||
118 | blocks and inodes counts. More checks will be added in future | ||
119 | releases. | ||
120 | `sync' tells the kernel code to use synchronous writes when updating | ||
121 | an inode, a bitmap, a directory entry or an indirect block. This | ||
122 | can make the file system much slower but can be a big win for files | ||
123 | recovery in case of a crash (and we can now say to the BSD folks | ||
124 | that Linux also supports synchronous updates :-). | ||
125 | `sb=#' tells the kernel code to use an alternate super block instead | ||
126 | of its master copy. `#' is the number of the block (counted in | ||
127 | 1024 bytes blocks) which contains the alternate super block. | ||
128 | An ext2 file system typically contains backups of the super block | ||
129 | at blocks 8193, 16385, and so on. | ||
130 | - I have change the meaning of the valid flag used by e2fsck. it | ||
131 | now contains the state of the file system. If the kernel code | ||
132 | detects an inconsistency while the file system is mounted, it flags | ||
133 | it as erroneous and e2fsck will detect that on next run. | ||
134 | - The super block now contains a mount counter. This counter is | ||
135 | incremented each time the file system is mounted read/write. When | ||
136 | this counter becomes bigger than a maximal mount counts (also stored | ||
137 | in the super block), e2fsck checks the file system, even if it had | ||
138 | been unmounted cleanly, and resets this counter to 0. | ||
139 | - File attributes are now supported. One can associate a set of | ||
140 | attributes to a file. Three attributes are defined: | ||
141 | `c': the file is marked for automatic compression, | ||
142 | `s': the file is marked for secure deletion: when the file is | ||
143 | deleted, its blocks are zeroed and written back to the disk, | ||
144 | `u': the file is marked for undeletion: when the file is deleted, | ||
145 | its contents are saved to allow a future undeletion. | ||
146 | Currently, only the `s' attribute is implemented in the kernel | ||
147 | code. Support for the other attributes will be added in a future | ||
148 | release. | ||
149 | - a few bugs related to times updates have been fixed by Bruce | ||
150 | Evans and me. | ||
151 | - a bug related to the links count of deleted inodes has been fixed. | ||
152 | Previous versions used to keep the links count set to 1 when a file | ||
153 | was deleted. The new version now sets links_count to 0 when deleting | ||
154 | the last link. | ||
155 | - a race condition when deallocating an inode has been fixed by | ||
156 | Stephen Tweedie. | ||
157 | |||
diff --git a/fs/ext2/acl.c b/fs/ext2/acl.c index 213148c36ebe..6af2f4130290 100644 --- a/fs/ext2/acl.c +++ b/fs/ext2/acl.c | |||
@@ -194,8 +194,7 @@ ext2_get_acl(struct inode *inode, int type) | |||
194 | acl = NULL; | 194 | acl = NULL; |
195 | else | 195 | else |
196 | acl = ERR_PTR(retval); | 196 | acl = ERR_PTR(retval); |
197 | if (value) | 197 | kfree(value); |
198 | kfree(value); | ||
199 | 198 | ||
200 | if (!IS_ERR(acl)) { | 199 | if (!IS_ERR(acl)) { |
201 | switch(type) { | 200 | switch(type) { |
@@ -262,8 +261,7 @@ ext2_set_acl(struct inode *inode, int type, struct posix_acl *acl) | |||
262 | 261 | ||
263 | error = ext2_xattr_set(inode, name_index, "", value, size, 0); | 262 | error = ext2_xattr_set(inode, name_index, "", value, size, 0); |
264 | 263 | ||
265 | if (value) | 264 | kfree(value); |
266 | kfree(value); | ||
267 | if (!error) { | 265 | if (!error) { |
268 | switch(type) { | 266 | switch(type) { |
269 | case ACL_TYPE_ACCESS: | 267 | case ACL_TYPE_ACCESS: |
diff --git a/fs/ext2/balloc.c b/fs/ext2/balloc.c index 6591abef64d0..bb6908066494 100644 --- a/fs/ext2/balloc.c +++ b/fs/ext2/balloc.c | |||
@@ -624,76 +624,3 @@ unsigned long ext2_bg_num_gdb(struct super_block *sb, int group) | |||
624 | return EXT2_SB(sb)->s_gdb_count; | 624 | return EXT2_SB(sb)->s_gdb_count; |
625 | } | 625 | } |
626 | 626 | ||
627 | #ifdef CONFIG_EXT2_CHECK | ||
628 | /* Called at mount-time, super-block is locked */ | ||
629 | void ext2_check_blocks_bitmap (struct super_block * sb) | ||
630 | { | ||
631 | struct buffer_head *bitmap_bh = NULL; | ||
632 | struct ext2_super_block * es; | ||
633 | unsigned long desc_count, bitmap_count, x, j; | ||
634 | unsigned long desc_blocks; | ||
635 | struct ext2_group_desc * desc; | ||
636 | int i; | ||
637 | |||
638 | es = EXT2_SB(sb)->s_es; | ||
639 | desc_count = 0; | ||
640 | bitmap_count = 0; | ||
641 | desc = NULL; | ||
642 | for (i = 0; i < EXT2_SB(sb)->s_groups_count; i++) { | ||
643 | desc = ext2_get_group_desc (sb, i, NULL); | ||
644 | if (!desc) | ||
645 | continue; | ||
646 | desc_count += le16_to_cpu(desc->bg_free_blocks_count); | ||
647 | brelse(bitmap_bh); | ||
648 | bitmap_bh = read_block_bitmap(sb, i); | ||
649 | if (!bitmap_bh) | ||
650 | continue; | ||
651 | |||
652 | if (ext2_bg_has_super(sb, i) && | ||
653 | !ext2_test_bit(0, bitmap_bh->b_data)) | ||
654 | ext2_error(sb, __FUNCTION__, | ||
655 | "Superblock in group %d is marked free", i); | ||
656 | |||
657 | desc_blocks = ext2_bg_num_gdb(sb, i); | ||
658 | for (j = 0; j < desc_blocks; j++) | ||
659 | if (!ext2_test_bit(j + 1, bitmap_bh->b_data)) | ||
660 | ext2_error(sb, __FUNCTION__, | ||
661 | "Descriptor block #%ld in group " | ||
662 | "%d is marked free", j, i); | ||
663 | |||
664 | if (!block_in_use(le32_to_cpu(desc->bg_block_bitmap), | ||
665 | sb, bitmap_bh->b_data)) | ||
666 | ext2_error(sb, "ext2_check_blocks_bitmap", | ||
667 | "Block bitmap for group %d is marked free", | ||
668 | i); | ||
669 | |||
670 | if (!block_in_use(le32_to_cpu(desc->bg_inode_bitmap), | ||
671 | sb, bitmap_bh->b_data)) | ||
672 | ext2_error(sb, "ext2_check_blocks_bitmap", | ||
673 | "Inode bitmap for group %d is marked free", | ||
674 | i); | ||
675 | |||
676 | for (j = 0; j < EXT2_SB(sb)->s_itb_per_group; j++) | ||
677 | if (!block_in_use(le32_to_cpu(desc->bg_inode_table) + j, | ||
678 | sb, bitmap_bh->b_data)) | ||
679 | ext2_error (sb, "ext2_check_blocks_bitmap", | ||
680 | "Block #%ld of the inode table in " | ||
681 | "group %d is marked free", j, i); | ||
682 | |||
683 | x = ext2_count_free(bitmap_bh, sb->s_blocksize); | ||
684 | if (le16_to_cpu(desc->bg_free_blocks_count) != x) | ||
685 | ext2_error (sb, "ext2_check_blocks_bitmap", | ||
686 | "Wrong free blocks count for group %d, " | ||
687 | "stored = %d, counted = %lu", i, | ||
688 | le16_to_cpu(desc->bg_free_blocks_count), x); | ||
689 | bitmap_count += x; | ||
690 | } | ||
691 | if (le32_to_cpu(es->s_free_blocks_count) != bitmap_count) | ||
692 | ext2_error (sb, "ext2_check_blocks_bitmap", | ||
693 | "Wrong free blocks count in super block, " | ||
694 | "stored = %lu, counted = %lu", | ||
695 | (unsigned long)le32_to_cpu(es->s_free_blocks_count), | ||
696 | bitmap_count); | ||
697 | brelse(bitmap_bh); | ||
698 | } | ||
699 | #endif | ||
diff --git a/fs/ext2/ialloc.c b/fs/ext2/ialloc.c index e2d6208633a7..74714af4ae69 100644 --- a/fs/ext2/ialloc.c +++ b/fs/ext2/ialloc.c | |||
@@ -700,43 +700,3 @@ unsigned long ext2_count_dirs (struct super_block * sb) | |||
700 | return count; | 700 | return count; |
701 | } | 701 | } |
702 | 702 | ||
703 | #ifdef CONFIG_EXT2_CHECK | ||
704 | /* Called at mount-time, super-block is locked */ | ||
705 | void ext2_check_inodes_bitmap (struct super_block * sb) | ||
706 | { | ||
707 | struct ext2_super_block * es = EXT2_SB(sb)->s_es; | ||
708 | unsigned long desc_count = 0, bitmap_count = 0; | ||
709 | struct buffer_head *bitmap_bh = NULL; | ||
710 | int i; | ||
711 | |||
712 | for (i = 0; i < EXT2_SB(sb)->s_groups_count; i++) { | ||
713 | struct ext2_group_desc *desc; | ||
714 | unsigned x; | ||
715 | |||
716 | desc = ext2_get_group_desc(sb, i, NULL); | ||
717 | if (!desc) | ||
718 | continue; | ||
719 | desc_count += le16_to_cpu(desc->bg_free_inodes_count); | ||
720 | brelse(bitmap_bh); | ||
721 | bitmap_bh = read_inode_bitmap(sb, i); | ||
722 | if (!bitmap_bh) | ||
723 | continue; | ||
724 | |||
725 | x = ext2_count_free(bitmap_bh, EXT2_INODES_PER_GROUP(sb) / 8); | ||
726 | if (le16_to_cpu(desc->bg_free_inodes_count) != x) | ||
727 | ext2_error (sb, "ext2_check_inodes_bitmap", | ||
728 | "Wrong free inodes count in group %d, " | ||
729 | "stored = %d, counted = %lu", i, | ||
730 | le16_to_cpu(desc->bg_free_inodes_count), x); | ||
731 | bitmap_count += x; | ||
732 | } | ||
733 | brelse(bitmap_bh); | ||
734 | if (percpu_counter_read(&EXT2_SB(sb)->s_freeinodes_counter) != | ||
735 | bitmap_count) | ||
736 | ext2_error(sb, "ext2_check_inodes_bitmap", | ||
737 | "Wrong free inodes count in super block, " | ||
738 | "stored = %lu, counted = %lu", | ||
739 | (unsigned long)le32_to_cpu(es->s_free_inodes_count), | ||
740 | bitmap_count); | ||
741 | } | ||
742 | #endif | ||
diff --git a/fs/ext2/super.c b/fs/ext2/super.c index 3c0c7c6a5b44..e4ed4b31a433 100644 --- a/fs/ext2/super.c +++ b/fs/ext2/super.c | |||
@@ -281,7 +281,7 @@ static unsigned long get_sb_block(void **data) | |||
281 | enum { | 281 | enum { |
282 | Opt_bsd_df, Opt_minix_df, Opt_grpid, Opt_nogrpid, | 282 | Opt_bsd_df, Opt_minix_df, Opt_grpid, Opt_nogrpid, |
283 | Opt_resgid, Opt_resuid, Opt_sb, Opt_err_cont, Opt_err_panic, | 283 | Opt_resgid, Opt_resuid, Opt_sb, Opt_err_cont, Opt_err_panic, |
284 | Opt_err_ro, Opt_nouid32, Opt_check, Opt_nocheck, Opt_debug, | 284 | Opt_err_ro, Opt_nouid32, Opt_nocheck, Opt_debug, |
285 | Opt_oldalloc, Opt_orlov, Opt_nobh, Opt_user_xattr, Opt_nouser_xattr, | 285 | Opt_oldalloc, Opt_orlov, Opt_nobh, Opt_user_xattr, Opt_nouser_xattr, |
286 | Opt_acl, Opt_noacl, Opt_xip, Opt_ignore, Opt_err, Opt_quota, | 286 | Opt_acl, Opt_noacl, Opt_xip, Opt_ignore, Opt_err, Opt_quota, |
287 | Opt_usrquota, Opt_grpquota | 287 | Opt_usrquota, Opt_grpquota |
@@ -303,7 +303,6 @@ static match_table_t tokens = { | |||
303 | {Opt_nouid32, "nouid32"}, | 303 | {Opt_nouid32, "nouid32"}, |
304 | {Opt_nocheck, "check=none"}, | 304 | {Opt_nocheck, "check=none"}, |
305 | {Opt_nocheck, "nocheck"}, | 305 | {Opt_nocheck, "nocheck"}, |
306 | {Opt_check, "check"}, | ||
307 | {Opt_debug, "debug"}, | 306 | {Opt_debug, "debug"}, |
308 | {Opt_oldalloc, "oldalloc"}, | 307 | {Opt_oldalloc, "oldalloc"}, |
309 | {Opt_orlov, "orlov"}, | 308 | {Opt_orlov, "orlov"}, |
@@ -376,13 +375,6 @@ static int parse_options (char * options, | |||
376 | case Opt_nouid32: | 375 | case Opt_nouid32: |
377 | set_opt (sbi->s_mount_opt, NO_UID32); | 376 | set_opt (sbi->s_mount_opt, NO_UID32); |
378 | break; | 377 | break; |
379 | case Opt_check: | ||
380 | #ifdef CONFIG_EXT2_CHECK | ||
381 | set_opt (sbi->s_mount_opt, CHECK); | ||
382 | #else | ||
383 | printk("EXT2 Check option not supported\n"); | ||
384 | #endif | ||
385 | break; | ||
386 | case Opt_nocheck: | 378 | case Opt_nocheck: |
387 | clear_opt (sbi->s_mount_opt, CHECK); | 379 | clear_opt (sbi->s_mount_opt, CHECK); |
388 | break; | 380 | break; |
@@ -503,12 +495,6 @@ static int ext2_setup_super (struct super_block * sb, | |||
503 | EXT2_BLOCKS_PER_GROUP(sb), | 495 | EXT2_BLOCKS_PER_GROUP(sb), |
504 | EXT2_INODES_PER_GROUP(sb), | 496 | EXT2_INODES_PER_GROUP(sb), |
505 | sbi->s_mount_opt); | 497 | sbi->s_mount_opt); |
506 | #ifdef CONFIG_EXT2_CHECK | ||
507 | if (test_opt (sb, CHECK)) { | ||
508 | ext2_check_blocks_bitmap (sb); | ||
509 | ext2_check_inodes_bitmap (sb); | ||
510 | } | ||
511 | #endif | ||
512 | return res; | 498 | return res; |
513 | } | 499 | } |
514 | 500 | ||
diff --git a/fs/ext3/balloc.c b/fs/ext3/balloc.c index 7992d21e0e09..ae1148c24c53 100644 --- a/fs/ext3/balloc.c +++ b/fs/ext3/balloc.c | |||
@@ -1517,76 +1517,3 @@ unsigned long ext3_bg_num_gdb(struct super_block *sb, int group) | |||
1517 | return EXT3_SB(sb)->s_gdb_count; | 1517 | return EXT3_SB(sb)->s_gdb_count; |
1518 | } | 1518 | } |
1519 | 1519 | ||
1520 | #ifdef CONFIG_EXT3_CHECK | ||
1521 | /* Called at mount-time, super-block is locked */ | ||
1522 | void ext3_check_blocks_bitmap (struct super_block * sb) | ||
1523 | { | ||
1524 | struct ext3_super_block *es; | ||
1525 | unsigned long desc_count, bitmap_count, x, j; | ||
1526 | unsigned long desc_blocks; | ||
1527 | struct buffer_head *bitmap_bh = NULL; | ||
1528 | struct ext3_group_desc *gdp; | ||
1529 | int i; | ||
1530 | |||
1531 | es = EXT3_SB(sb)->s_es; | ||
1532 | desc_count = 0; | ||
1533 | bitmap_count = 0; | ||
1534 | gdp = NULL; | ||
1535 | for (i = 0; i < EXT3_SB(sb)->s_groups_count; i++) { | ||
1536 | gdp = ext3_get_group_desc (sb, i, NULL); | ||
1537 | if (!gdp) | ||
1538 | continue; | ||
1539 | desc_count += le16_to_cpu(gdp->bg_free_blocks_count); | ||
1540 | brelse(bitmap_bh); | ||
1541 | bitmap_bh = read_block_bitmap(sb, i); | ||
1542 | if (bitmap_bh == NULL) | ||
1543 | continue; | ||
1544 | |||
1545 | if (ext3_bg_has_super(sb, i) && | ||
1546 | !ext3_test_bit(0, bitmap_bh->b_data)) | ||
1547 | ext3_error(sb, __FUNCTION__, | ||
1548 | "Superblock in group %d is marked free", i); | ||
1549 | |||
1550 | desc_blocks = ext3_bg_num_gdb(sb, i); | ||
1551 | for (j = 0; j < desc_blocks; j++) | ||
1552 | if (!ext3_test_bit(j + 1, bitmap_bh->b_data)) | ||
1553 | ext3_error(sb, __FUNCTION__, | ||
1554 | "Descriptor block #%ld in group " | ||
1555 | "%d is marked free", j, i); | ||
1556 | |||
1557 | if (!block_in_use (le32_to_cpu(gdp->bg_block_bitmap), | ||
1558 | sb, bitmap_bh->b_data)) | ||
1559 | ext3_error (sb, "ext3_check_blocks_bitmap", | ||
1560 | "Block bitmap for group %d is marked free", | ||
1561 | i); | ||
1562 | |||
1563 | if (!block_in_use (le32_to_cpu(gdp->bg_inode_bitmap), | ||
1564 | sb, bitmap_bh->b_data)) | ||
1565 | ext3_error (sb, "ext3_check_blocks_bitmap", | ||
1566 | "Inode bitmap for group %d is marked free", | ||
1567 | i); | ||
1568 | |||
1569 | for (j = 0; j < EXT3_SB(sb)->s_itb_per_group; j++) | ||
1570 | if (!block_in_use (le32_to_cpu(gdp->bg_inode_table) + j, | ||
1571 | sb, bitmap_bh->b_data)) | ||
1572 | ext3_error (sb, "ext3_check_blocks_bitmap", | ||
1573 | "Block #%d of the inode table in " | ||
1574 | "group %d is marked free", j, i); | ||
1575 | |||
1576 | x = ext3_count_free(bitmap_bh, sb->s_blocksize); | ||
1577 | if (le16_to_cpu(gdp->bg_free_blocks_count) != x) | ||
1578 | ext3_error (sb, "ext3_check_blocks_bitmap", | ||
1579 | "Wrong free blocks count for group %d, " | ||
1580 | "stored = %d, counted = %lu", i, | ||
1581 | le16_to_cpu(gdp->bg_free_blocks_count), x); | ||
1582 | bitmap_count += x; | ||
1583 | } | ||
1584 | brelse(bitmap_bh); | ||
1585 | if (le32_to_cpu(es->s_free_blocks_count) != bitmap_count) | ||
1586 | ext3_error (sb, "ext3_check_blocks_bitmap", | ||
1587 | "Wrong free blocks count in super block, " | ||
1588 | "stored = %lu, counted = %lu", | ||
1589 | (unsigned long)le32_to_cpu(es->s_free_blocks_count), | ||
1590 | bitmap_count); | ||
1591 | } | ||
1592 | #endif | ||
diff --git a/fs/ext3/ialloc.c b/fs/ext3/ialloc.c index df3f517c54ac..9e4a24376210 100644 --- a/fs/ext3/ialloc.c +++ b/fs/ext3/ialloc.c | |||
@@ -756,44 +756,3 @@ unsigned long ext3_count_dirs (struct super_block * sb) | |||
756 | return count; | 756 | return count; |
757 | } | 757 | } |
758 | 758 | ||
759 | #ifdef CONFIG_EXT3_CHECK | ||
760 | /* Called at mount-time, super-block is locked */ | ||
761 | void ext3_check_inodes_bitmap (struct super_block * sb) | ||
762 | { | ||
763 | struct ext3_super_block * es; | ||
764 | unsigned long desc_count, bitmap_count, x; | ||
765 | struct buffer_head *bitmap_bh = NULL; | ||
766 | struct ext3_group_desc * gdp; | ||
767 | int i; | ||
768 | |||
769 | es = EXT3_SB(sb)->s_es; | ||
770 | desc_count = 0; | ||
771 | bitmap_count = 0; | ||
772 | gdp = NULL; | ||
773 | for (i = 0; i < EXT3_SB(sb)->s_groups_count; i++) { | ||
774 | gdp = ext3_get_group_desc (sb, i, NULL); | ||
775 | if (!gdp) | ||
776 | continue; | ||
777 | desc_count += le16_to_cpu(gdp->bg_free_inodes_count); | ||
778 | brelse(bitmap_bh); | ||
779 | bitmap_bh = read_inode_bitmap(sb, i); | ||
780 | if (!bitmap_bh) | ||
781 | continue; | ||
782 | |||
783 | x = ext3_count_free(bitmap_bh, EXT3_INODES_PER_GROUP(sb) / 8); | ||
784 | if (le16_to_cpu(gdp->bg_free_inodes_count) != x) | ||
785 | ext3_error (sb, "ext3_check_inodes_bitmap", | ||
786 | "Wrong free inodes count in group %d, " | ||
787 | "stored = %d, counted = %lu", i, | ||
788 | le16_to_cpu(gdp->bg_free_inodes_count), x); | ||
789 | bitmap_count += x; | ||
790 | } | ||
791 | brelse(bitmap_bh); | ||
792 | if (le32_to_cpu(es->s_free_inodes_count) != bitmap_count) | ||
793 | ext3_error (sb, "ext3_check_inodes_bitmap", | ||
794 | "Wrong free inodes count in super block, " | ||
795 | "stored = %lu, counted = %lu", | ||
796 | (unsigned long)le32_to_cpu(es->s_free_inodes_count), | ||
797 | bitmap_count); | ||
798 | } | ||
799 | #endif | ||
diff --git a/fs/ext3/super.c b/fs/ext3/super.c index f594989ccb7a..4e6730622d90 100644 --- a/fs/ext3/super.c +++ b/fs/ext3/super.c | |||
@@ -625,7 +625,7 @@ static struct export_operations ext3_export_ops = { | |||
625 | enum { | 625 | enum { |
626 | Opt_bsd_df, Opt_minix_df, Opt_grpid, Opt_nogrpid, | 626 | Opt_bsd_df, Opt_minix_df, Opt_grpid, Opt_nogrpid, |
627 | Opt_resgid, Opt_resuid, Opt_sb, Opt_err_cont, Opt_err_panic, Opt_err_ro, | 627 | Opt_resgid, Opt_resuid, Opt_sb, Opt_err_cont, Opt_err_panic, Opt_err_ro, |
628 | Opt_nouid32, Opt_check, Opt_nocheck, Opt_debug, Opt_oldalloc, Opt_orlov, | 628 | Opt_nouid32, Opt_nocheck, Opt_debug, Opt_oldalloc, Opt_orlov, |
629 | Opt_user_xattr, Opt_nouser_xattr, Opt_acl, Opt_noacl, | 629 | Opt_user_xattr, Opt_nouser_xattr, Opt_acl, Opt_noacl, |
630 | Opt_reservation, Opt_noreservation, Opt_noload, Opt_nobh, | 630 | Opt_reservation, Opt_noreservation, Opt_noload, Opt_nobh, |
631 | Opt_commit, Opt_journal_update, Opt_journal_inum, | 631 | Opt_commit, Opt_journal_update, Opt_journal_inum, |
@@ -652,7 +652,6 @@ static match_table_t tokens = { | |||
652 | {Opt_nouid32, "nouid32"}, | 652 | {Opt_nouid32, "nouid32"}, |
653 | {Opt_nocheck, "nocheck"}, | 653 | {Opt_nocheck, "nocheck"}, |
654 | {Opt_nocheck, "check=none"}, | 654 | {Opt_nocheck, "check=none"}, |
655 | {Opt_check, "check"}, | ||
656 | {Opt_debug, "debug"}, | 655 | {Opt_debug, "debug"}, |
657 | {Opt_oldalloc, "oldalloc"}, | 656 | {Opt_oldalloc, "oldalloc"}, |
658 | {Opt_orlov, "orlov"}, | 657 | {Opt_orlov, "orlov"}, |
@@ -773,14 +772,6 @@ static int parse_options (char * options, struct super_block *sb, | |||
773 | case Opt_nouid32: | 772 | case Opt_nouid32: |
774 | set_opt (sbi->s_mount_opt, NO_UID32); | 773 | set_opt (sbi->s_mount_opt, NO_UID32); |
775 | break; | 774 | break; |
776 | case Opt_check: | ||
777 | #ifdef CONFIG_EXT3_CHECK | ||
778 | set_opt (sbi->s_mount_opt, CHECK); | ||
779 | #else | ||
780 | printk(KERN_ERR | ||
781 | "EXT3 Check option not supported\n"); | ||
782 | #endif | ||
783 | break; | ||
784 | case Opt_nocheck: | 775 | case Opt_nocheck: |
785 | clear_opt (sbi->s_mount_opt, CHECK); | 776 | clear_opt (sbi->s_mount_opt, CHECK); |
786 | break; | 777 | break; |
@@ -1115,12 +1106,6 @@ static int ext3_setup_super(struct super_block *sb, struct ext3_super_block *es, | |||
1115 | } else { | 1106 | } else { |
1116 | printk("internal journal\n"); | 1107 | printk("internal journal\n"); |
1117 | } | 1108 | } |
1118 | #ifdef CONFIG_EXT3_CHECK | ||
1119 | if (test_opt (sb, CHECK)) { | ||
1120 | ext3_check_blocks_bitmap (sb); | ||
1121 | ext3_check_inodes_bitmap (sb); | ||
1122 | } | ||
1123 | #endif | ||
1124 | return res; | 1109 | return res; |
1125 | } | 1110 | } |
1126 | 1111 | ||
diff --git a/fs/fat/inode.c b/fs/fat/inode.c index e2effe2dc9b2..a0f9b9fe1307 100644 --- a/fs/fat/inode.c +++ b/fs/fat/inode.c | |||
@@ -846,7 +846,7 @@ static match_table_t vfat_tokens = { | |||
846 | {Opt_err, NULL} | 846 | {Opt_err, NULL} |
847 | }; | 847 | }; |
848 | 848 | ||
849 | static int parse_options(char *options, int is_vfat, int *debug, | 849 | static int parse_options(char *options, int is_vfat, int silent, int *debug, |
850 | struct fat_mount_options *opts) | 850 | struct fat_mount_options *opts) |
851 | { | 851 | { |
852 | char *p; | 852 | char *p; |
@@ -1008,8 +1008,11 @@ static int parse_options(char *options, int is_vfat, int *debug, | |||
1008 | break; | 1008 | break; |
1009 | /* unknown option */ | 1009 | /* unknown option */ |
1010 | default: | 1010 | default: |
1011 | printk(KERN_ERR "FAT: Unrecognized mount option \"%s\" " | 1011 | if (!silent) { |
1012 | "or missing value\n", p); | 1012 | printk(KERN_ERR |
1013 | "FAT: Unrecognized mount option \"%s\" " | ||
1014 | "or missing value\n", p); | ||
1015 | } | ||
1013 | return -EINVAL; | 1016 | return -EINVAL; |
1014 | } | 1017 | } |
1015 | } | 1018 | } |
@@ -1091,7 +1094,7 @@ int fat_fill_super(struct super_block *sb, void *data, int silent, | |||
1091 | sb->s_export_op = &fat_export_ops; | 1094 | sb->s_export_op = &fat_export_ops; |
1092 | sbi->dir_ops = fs_dir_inode_ops; | 1095 | sbi->dir_ops = fs_dir_inode_ops; |
1093 | 1096 | ||
1094 | error = parse_options(data, isvfat, &debug, &sbi->options); | 1097 | error = parse_options(data, isvfat, silent, &debug, &sbi->options); |
1095 | if (error) | 1098 | if (error) |
1096 | goto out_fail; | 1099 | goto out_fail; |
1097 | 1100 | ||
diff --git a/fs/file_table.c b/fs/file_table.c index 4dc205546547..c3a5e2fd663b 100644 --- a/fs/file_table.c +++ b/fs/file_table.c | |||
@@ -35,7 +35,7 @@ static DEFINE_SPINLOCK(filp_count_lock); | |||
35 | * context and must be fully threaded - use a local spinlock | 35 | * context and must be fully threaded - use a local spinlock |
36 | * to protect files_stat.nr_files | 36 | * to protect files_stat.nr_files |
37 | */ | 37 | */ |
38 | void filp_ctor(void * objp, struct kmem_cache_s *cachep, unsigned long cflags) | 38 | void filp_ctor(void *objp, struct kmem_cache *cachep, unsigned long cflags) |
39 | { | 39 | { |
40 | if ((cflags & (SLAB_CTOR_VERIFY|SLAB_CTOR_CONSTRUCTOR)) == | 40 | if ((cflags & (SLAB_CTOR_VERIFY|SLAB_CTOR_CONSTRUCTOR)) == |
41 | SLAB_CTOR_CONSTRUCTOR) { | 41 | SLAB_CTOR_CONSTRUCTOR) { |
@@ -46,7 +46,7 @@ void filp_ctor(void * objp, struct kmem_cache_s *cachep, unsigned long cflags) | |||
46 | } | 46 | } |
47 | } | 47 | } |
48 | 48 | ||
49 | void filp_dtor(void * objp, struct kmem_cache_s *cachep, unsigned long dflags) | 49 | void filp_dtor(void *objp, struct kmem_cache *cachep, unsigned long dflags) |
50 | { | 50 | { |
51 | unsigned long flags; | 51 | unsigned long flags; |
52 | spin_lock_irqsave(&filp_count_lock, flags); | 52 | spin_lock_irqsave(&filp_count_lock, flags); |
diff --git a/fs/freevxfs/vxfs_extern.h b/fs/freevxfs/vxfs_extern.h index d8be917f9797..927acf70c591 100644 --- a/fs/freevxfs/vxfs_extern.h +++ b/fs/freevxfs/vxfs_extern.h | |||
@@ -38,7 +38,7 @@ | |||
38 | */ | 38 | */ |
39 | 39 | ||
40 | 40 | ||
41 | struct kmem_cache_s; | 41 | struct kmem_cache; |
42 | struct super_block; | 42 | struct super_block; |
43 | struct vxfs_inode_info; | 43 | struct vxfs_inode_info; |
44 | struct inode; | 44 | struct inode; |
@@ -51,7 +51,7 @@ extern daddr_t vxfs_bmap1(struct inode *, long); | |||
51 | extern int vxfs_read_fshead(struct super_block *); | 51 | extern int vxfs_read_fshead(struct super_block *); |
52 | 52 | ||
53 | /* vxfs_inode.c */ | 53 | /* vxfs_inode.c */ |
54 | extern struct kmem_cache_s *vxfs_inode_cachep; | 54 | extern struct kmem_cache *vxfs_inode_cachep; |
55 | extern void vxfs_dumpi(struct vxfs_inode_info *, ino_t); | 55 | extern void vxfs_dumpi(struct vxfs_inode_info *, ino_t); |
56 | extern struct inode * vxfs_get_fake_inode(struct super_block *, | 56 | extern struct inode * vxfs_get_fake_inode(struct super_block *, |
57 | struct vxfs_inode_info *); | 57 | struct vxfs_inode_info *); |
diff --git a/fs/freevxfs/vxfs_inode.c b/fs/freevxfs/vxfs_inode.c index 9672d2facffe..f544aae9169f 100644 --- a/fs/freevxfs/vxfs_inode.c +++ b/fs/freevxfs/vxfs_inode.c | |||
@@ -46,15 +46,6 @@ extern struct address_space_operations vxfs_immed_aops; | |||
46 | 46 | ||
47 | extern struct inode_operations vxfs_immed_symlink_iops; | 47 | extern struct inode_operations vxfs_immed_symlink_iops; |
48 | 48 | ||
49 | static struct file_operations vxfs_file_operations = { | ||
50 | .open = generic_file_open, | ||
51 | .llseek = generic_file_llseek, | ||
52 | .read = generic_file_read, | ||
53 | .mmap = generic_file_mmap, | ||
54 | .sendfile = generic_file_sendfile, | ||
55 | }; | ||
56 | |||
57 | |||
58 | kmem_cache_t *vxfs_inode_cachep; | 49 | kmem_cache_t *vxfs_inode_cachep; |
59 | 50 | ||
60 | 51 | ||
@@ -318,7 +309,7 @@ vxfs_read_inode(struct inode *ip) | |||
318 | aops = &vxfs_aops; | 309 | aops = &vxfs_aops; |
319 | 310 | ||
320 | if (S_ISREG(ip->i_mode)) { | 311 | if (S_ISREG(ip->i_mode)) { |
321 | ip->i_fop = &vxfs_file_operations; | 312 | ip->i_fop = &generic_ro_fops; |
322 | ip->i_mapping->a_ops = aops; | 313 | ip->i_mapping->a_ops = aops; |
323 | } else if (S_ISDIR(ip->i_mode)) { | 314 | } else if (S_ISDIR(ip->i_mode)) { |
324 | ip->i_op = &vxfs_dir_inode_ops; | 315 | ip->i_op = &vxfs_dir_inode_ops; |
diff --git a/fs/fs-writeback.c b/fs/fs-writeback.c index c27f8d4098be..785c7213a54f 100644 --- a/fs/fs-writeback.c +++ b/fs/fs-writeback.c | |||
@@ -562,7 +562,7 @@ int write_inode_now(struct inode *inode, int sync) | |||
562 | }; | 562 | }; |
563 | 563 | ||
564 | if (!mapping_cap_writeback_dirty(inode->i_mapping)) | 564 | if (!mapping_cap_writeback_dirty(inode->i_mapping)) |
565 | return 0; | 565 | wbc.nr_to_write = 0; |
566 | 566 | ||
567 | might_sleep(); | 567 | might_sleep(); |
568 | spin_lock(&inode_lock); | 568 | spin_lock(&inode_lock); |
@@ -606,7 +606,7 @@ EXPORT_SYMBOL(sync_inode); | |||
606 | * O_SYNC flag set, to flush dirty writes to disk. | 606 | * O_SYNC flag set, to flush dirty writes to disk. |
607 | * | 607 | * |
608 | * @what is a bitmask, specifying which part of the inode's data should be | 608 | * @what is a bitmask, specifying which part of the inode's data should be |
609 | * written and waited upon: | 609 | * written and waited upon. |
610 | * | 610 | * |
611 | * OSYNC_DATA: i_mapping's dirty data | 611 | * OSYNC_DATA: i_mapping's dirty data |
612 | * OSYNC_METADATA: the buffers at i_mapping->private_list | 612 | * OSYNC_METADATA: the buffers at i_mapping->private_list |
@@ -672,8 +672,9 @@ int writeback_acquire(struct backing_dev_info *bdi) | |||
672 | 672 | ||
673 | /** | 673 | /** |
674 | * writeback_in_progress: determine whether there is writeback in progress | 674 | * writeback_in_progress: determine whether there is writeback in progress |
675 | * against a backing device. | ||
676 | * @bdi: the device's backing_dev_info structure. | 675 | * @bdi: the device's backing_dev_info structure. |
676 | * | ||
677 | * Determine whether there is writeback in progress against a backing device. | ||
677 | */ | 678 | */ |
678 | int writeback_in_progress(struct backing_dev_info *bdi) | 679 | int writeback_in_progress(struct backing_dev_info *bdi) |
679 | { | 680 | { |
diff --git a/fs/fuse/dev.c b/fs/fuse/dev.c index a6f90a6c754a..8f873e621f41 100644 --- a/fs/fuse/dev.c +++ b/fs/fuse/dev.c | |||
@@ -184,6 +184,13 @@ static void request_end(struct fuse_conn *fc, struct fuse_req *req) | |||
184 | fuse_putback_request() */ | 184 | fuse_putback_request() */ |
185 | for (i = 1; i < FUSE_MAX_OUTSTANDING; i++) | 185 | for (i = 1; i < FUSE_MAX_OUTSTANDING; i++) |
186 | up(&fc->outstanding_sem); | 186 | up(&fc->outstanding_sem); |
187 | } else if (req->in.h.opcode == FUSE_RELEASE && req->inode == NULL) { | ||
188 | /* Special case for failed iget in CREATE */ | ||
189 | u64 nodeid = req->in.h.nodeid; | ||
190 | __fuse_get_request(req); | ||
191 | fuse_reset_request(req); | ||
192 | fuse_send_forget(fc, req, nodeid, 1); | ||
193 | putback = 0; | ||
187 | } | 194 | } |
188 | if (putback) | 195 | if (putback) |
189 | fuse_putback_request(fc, req); | 196 | fuse_putback_request(fc, req); |
diff --git a/fs/fuse/dir.c b/fs/fuse/dir.c index 70dba721acab..c045cc70c749 100644 --- a/fs/fuse/dir.c +++ b/fs/fuse/dir.c | |||
@@ -13,6 +13,7 @@ | |||
13 | #include <linux/gfp.h> | 13 | #include <linux/gfp.h> |
14 | #include <linux/sched.h> | 14 | #include <linux/sched.h> |
15 | #include <linux/namei.h> | 15 | #include <linux/namei.h> |
16 | #include <linux/mount.h> | ||
16 | 17 | ||
17 | static inline unsigned long time_to_jiffies(unsigned long sec, | 18 | static inline unsigned long time_to_jiffies(unsigned long sec, |
18 | unsigned long nsec) | 19 | unsigned long nsec) |
@@ -134,6 +135,101 @@ static void fuse_invalidate_entry(struct dentry *entry) | |||
134 | entry->d_time = jiffies - 1; | 135 | entry->d_time = jiffies - 1; |
135 | } | 136 | } |
136 | 137 | ||
138 | static int fuse_create_open(struct inode *dir, struct dentry *entry, int mode, | ||
139 | struct nameidata *nd) | ||
140 | { | ||
141 | int err; | ||
142 | struct inode *inode; | ||
143 | struct fuse_conn *fc = get_fuse_conn(dir); | ||
144 | struct fuse_req *req; | ||
145 | struct fuse_open_in inarg; | ||
146 | struct fuse_open_out outopen; | ||
147 | struct fuse_entry_out outentry; | ||
148 | struct fuse_inode *fi; | ||
149 | struct fuse_file *ff; | ||
150 | struct file *file; | ||
151 | int flags = nd->intent.open.flags - 1; | ||
152 | |||
153 | err = -ENOSYS; | ||
154 | if (fc->no_create) | ||
155 | goto out; | ||
156 | |||
157 | err = -ENAMETOOLONG; | ||
158 | if (entry->d_name.len > FUSE_NAME_MAX) | ||
159 | goto out; | ||
160 | |||
161 | err = -EINTR; | ||
162 | req = fuse_get_request(fc); | ||
163 | if (!req) | ||
164 | goto out; | ||
165 | |||
166 | ff = fuse_file_alloc(); | ||
167 | if (!ff) | ||
168 | goto out_put_request; | ||
169 | |||
170 | flags &= ~O_NOCTTY; | ||
171 | memset(&inarg, 0, sizeof(inarg)); | ||
172 | inarg.flags = flags; | ||
173 | inarg.mode = mode; | ||
174 | req->in.h.opcode = FUSE_CREATE; | ||
175 | req->in.h.nodeid = get_node_id(dir); | ||
176 | req->inode = dir; | ||
177 | req->in.numargs = 2; | ||
178 | req->in.args[0].size = sizeof(inarg); | ||
179 | req->in.args[0].value = &inarg; | ||
180 | req->in.args[1].size = entry->d_name.len + 1; | ||
181 | req->in.args[1].value = entry->d_name.name; | ||
182 | req->out.numargs = 2; | ||
183 | req->out.args[0].size = sizeof(outentry); | ||
184 | req->out.args[0].value = &outentry; | ||
185 | req->out.args[1].size = sizeof(outopen); | ||
186 | req->out.args[1].value = &outopen; | ||
187 | request_send(fc, req); | ||
188 | err = req->out.h.error; | ||
189 | if (err) { | ||
190 | if (err == -ENOSYS) | ||
191 | fc->no_create = 1; | ||
192 | goto out_free_ff; | ||
193 | } | ||
194 | |||
195 | err = -EIO; | ||
196 | if (!S_ISREG(outentry.attr.mode)) | ||
197 | goto out_free_ff; | ||
198 | |||
199 | inode = fuse_iget(dir->i_sb, outentry.nodeid, outentry.generation, | ||
200 | &outentry.attr); | ||
201 | err = -ENOMEM; | ||
202 | if (!inode) { | ||
203 | flags &= ~(O_CREAT | O_EXCL | O_TRUNC); | ||
204 | ff->fh = outopen.fh; | ||
205 | fuse_send_release(fc, ff, outentry.nodeid, NULL, flags, 0); | ||
206 | goto out_put_request; | ||
207 | } | ||
208 | fuse_put_request(fc, req); | ||
209 | entry->d_time = time_to_jiffies(outentry.entry_valid, | ||
210 | outentry.entry_valid_nsec); | ||
211 | fi = get_fuse_inode(inode); | ||
212 | fi->i_time = time_to_jiffies(outentry.attr_valid, | ||
213 | outentry.attr_valid_nsec); | ||
214 | |||
215 | d_instantiate(entry, inode); | ||
216 | file = lookup_instantiate_filp(nd, entry, generic_file_open); | ||
217 | if (IS_ERR(file)) { | ||
218 | ff->fh = outopen.fh; | ||
219 | fuse_send_release(fc, ff, outentry.nodeid, inode, flags, 0); | ||
220 | return PTR_ERR(file); | ||
221 | } | ||
222 | fuse_finish_open(inode, file, ff, &outopen); | ||
223 | return 0; | ||
224 | |||
225 | out_free_ff: | ||
226 | fuse_file_free(ff); | ||
227 | out_put_request: | ||
228 | fuse_put_request(fc, req); | ||
229 | out: | ||
230 | return err; | ||
231 | } | ||
232 | |||
137 | static int create_new_entry(struct fuse_conn *fc, struct fuse_req *req, | 233 | static int create_new_entry(struct fuse_conn *fc, struct fuse_req *req, |
138 | struct inode *dir, struct dentry *entry, | 234 | struct inode *dir, struct dentry *entry, |
139 | int mode) | 235 | int mode) |
@@ -208,6 +304,12 @@ static int fuse_mknod(struct inode *dir, struct dentry *entry, int mode, | |||
208 | static int fuse_create(struct inode *dir, struct dentry *entry, int mode, | 304 | static int fuse_create(struct inode *dir, struct dentry *entry, int mode, |
209 | struct nameidata *nd) | 305 | struct nameidata *nd) |
210 | { | 306 | { |
307 | if (nd && (nd->flags & LOOKUP_CREATE)) { | ||
308 | int err = fuse_create_open(dir, entry, mode, nd); | ||
309 | if (err != -ENOSYS) | ||
310 | return err; | ||
311 | /* Fall back on mknod */ | ||
312 | } | ||
211 | return fuse_mknod(dir, entry, mode, 0); | 313 | return fuse_mknod(dir, entry, mode, 0); |
212 | } | 314 | } |
213 | 315 | ||
@@ -461,6 +563,38 @@ static int fuse_revalidate(struct dentry *entry) | |||
461 | return fuse_do_getattr(inode); | 563 | return fuse_do_getattr(inode); |
462 | } | 564 | } |
463 | 565 | ||
566 | static int fuse_access(struct inode *inode, int mask) | ||
567 | { | ||
568 | struct fuse_conn *fc = get_fuse_conn(inode); | ||
569 | struct fuse_req *req; | ||
570 | struct fuse_access_in inarg; | ||
571 | int err; | ||
572 | |||
573 | if (fc->no_access) | ||
574 | return 0; | ||
575 | |||
576 | req = fuse_get_request(fc); | ||
577 | if (!req) | ||
578 | return -EINTR; | ||
579 | |||
580 | memset(&inarg, 0, sizeof(inarg)); | ||
581 | inarg.mask = mask; | ||
582 | req->in.h.opcode = FUSE_ACCESS; | ||
583 | req->in.h.nodeid = get_node_id(inode); | ||
584 | req->inode = inode; | ||
585 | req->in.numargs = 1; | ||
586 | req->in.args[0].size = sizeof(inarg); | ||
587 | req->in.args[0].value = &inarg; | ||
588 | request_send(fc, req); | ||
589 | err = req->out.h.error; | ||
590 | fuse_put_request(fc, req); | ||
591 | if (err == -ENOSYS) { | ||
592 | fc->no_access = 1; | ||
593 | err = 0; | ||
594 | } | ||
595 | return err; | ||
596 | } | ||
597 | |||
464 | static int fuse_permission(struct inode *inode, int mask, struct nameidata *nd) | 598 | static int fuse_permission(struct inode *inode, int mask, struct nameidata *nd) |
465 | { | 599 | { |
466 | struct fuse_conn *fc = get_fuse_conn(inode); | 600 | struct fuse_conn *fc = get_fuse_conn(inode); |
@@ -491,11 +625,11 @@ static int fuse_permission(struct inode *inode, int mask, struct nameidata *nd) | |||
491 | return err; | 625 | return err; |
492 | } else { | 626 | } else { |
493 | int mode = inode->i_mode; | 627 | int mode = inode->i_mode; |
494 | if ((mask & MAY_WRITE) && IS_RDONLY(inode) && | ||
495 | (S_ISREG(mode) || S_ISDIR(mode) || S_ISLNK(mode))) | ||
496 | return -EROFS; | ||
497 | if ((mask & MAY_EXEC) && !S_ISDIR(mode) && !(mode & S_IXUGO)) | 628 | if ((mask & MAY_EXEC) && !S_ISDIR(mode) && !(mode & S_IXUGO)) |
498 | return -EACCES; | 629 | return -EACCES; |
630 | |||
631 | if (nd && (nd->flags & LOOKUP_ACCESS)) | ||
632 | return fuse_access(inode, mask); | ||
499 | return 0; | 633 | return 0; |
500 | } | 634 | } |
501 | } | 635 | } |
@@ -629,29 +763,29 @@ static int fuse_dir_fsync(struct file *file, struct dentry *de, int datasync) | |||
629 | return file ? fuse_fsync_common(file, de, datasync, 1) : 0; | 763 | return file ? fuse_fsync_common(file, de, datasync, 1) : 0; |
630 | } | 764 | } |
631 | 765 | ||
632 | static unsigned iattr_to_fattr(struct iattr *iattr, struct fuse_attr *fattr) | 766 | static void iattr_to_fattr(struct iattr *iattr, struct fuse_setattr_in *arg) |
633 | { | 767 | { |
634 | unsigned ivalid = iattr->ia_valid; | 768 | unsigned ivalid = iattr->ia_valid; |
635 | unsigned fvalid = 0; | ||
636 | |||
637 | memset(fattr, 0, sizeof(*fattr)); | ||
638 | 769 | ||
639 | if (ivalid & ATTR_MODE) | 770 | if (ivalid & ATTR_MODE) |
640 | fvalid |= FATTR_MODE, fattr->mode = iattr->ia_mode; | 771 | arg->valid |= FATTR_MODE, arg->mode = iattr->ia_mode; |
641 | if (ivalid & ATTR_UID) | 772 | if (ivalid & ATTR_UID) |
642 | fvalid |= FATTR_UID, fattr->uid = iattr->ia_uid; | 773 | arg->valid |= FATTR_UID, arg->uid = iattr->ia_uid; |
643 | if (ivalid & ATTR_GID) | 774 | if (ivalid & ATTR_GID) |
644 | fvalid |= FATTR_GID, fattr->gid = iattr->ia_gid; | 775 | arg->valid |= FATTR_GID, arg->gid = iattr->ia_gid; |
645 | if (ivalid & ATTR_SIZE) | 776 | if (ivalid & ATTR_SIZE) |
646 | fvalid |= FATTR_SIZE, fattr->size = iattr->ia_size; | 777 | arg->valid |= FATTR_SIZE, arg->size = iattr->ia_size; |
647 | /* You can only _set_ these together (they may change by themselves) */ | 778 | /* You can only _set_ these together (they may change by themselves) */ |
648 | if ((ivalid & (ATTR_ATIME | ATTR_MTIME)) == (ATTR_ATIME | ATTR_MTIME)) { | 779 | if ((ivalid & (ATTR_ATIME | ATTR_MTIME)) == (ATTR_ATIME | ATTR_MTIME)) { |
649 | fvalid |= FATTR_ATIME | FATTR_MTIME; | 780 | arg->valid |= FATTR_ATIME | FATTR_MTIME; |
650 | fattr->atime = iattr->ia_atime.tv_sec; | 781 | arg->atime = iattr->ia_atime.tv_sec; |
651 | fattr->mtime = iattr->ia_mtime.tv_sec; | 782 | arg->mtime = iattr->ia_mtime.tv_sec; |
783 | } | ||
784 | if (ivalid & ATTR_FILE) { | ||
785 | struct fuse_file *ff = iattr->ia_file->private_data; | ||
786 | arg->valid |= FATTR_FH; | ||
787 | arg->fh = ff->fh; | ||
652 | } | 788 | } |
653 | |||
654 | return fvalid; | ||
655 | } | 789 | } |
656 | 790 | ||
657 | static int fuse_setattr(struct dentry *entry, struct iattr *attr) | 791 | static int fuse_setattr(struct dentry *entry, struct iattr *attr) |
@@ -686,7 +820,7 @@ static int fuse_setattr(struct dentry *entry, struct iattr *attr) | |||
686 | return -EINTR; | 820 | return -EINTR; |
687 | 821 | ||
688 | memset(&inarg, 0, sizeof(inarg)); | 822 | memset(&inarg, 0, sizeof(inarg)); |
689 | inarg.valid = iattr_to_fattr(attr, &inarg.attr); | 823 | iattr_to_fattr(attr, &inarg); |
690 | req->in.h.opcode = FUSE_SETATTR; | 824 | req->in.h.opcode = FUSE_SETATTR; |
691 | req->in.h.nodeid = get_node_id(inode); | 825 | req->in.h.nodeid = get_node_id(inode); |
692 | req->inode = inode; | 826 | req->inode = inode; |
@@ -735,7 +869,9 @@ static struct dentry *fuse_lookup(struct inode *dir, struct dentry *entry, | |||
735 | struct nameidata *nd) | 869 | struct nameidata *nd) |
736 | { | 870 | { |
737 | struct inode *inode; | 871 | struct inode *inode; |
738 | int err = fuse_lookup_iget(dir, entry, &inode); | 872 | int err; |
873 | |||
874 | err = fuse_lookup_iget(dir, entry, &inode); | ||
739 | if (err) | 875 | if (err) |
740 | return ERR_PTR(err); | 876 | return ERR_PTR(err); |
741 | if (inode && S_ISDIR(inode->i_mode)) { | 877 | if (inode && S_ISDIR(inode->i_mode)) { |
diff --git a/fs/fuse/file.c b/fs/fuse/file.c index 657ab11c173b..2ca86141d13a 100644 --- a/fs/fuse/file.c +++ b/fs/fuse/file.c | |||
@@ -14,11 +14,69 @@ | |||
14 | 14 | ||
15 | static struct file_operations fuse_direct_io_file_operations; | 15 | static struct file_operations fuse_direct_io_file_operations; |
16 | 16 | ||
17 | int fuse_open_common(struct inode *inode, struct file *file, int isdir) | 17 | static int fuse_send_open(struct inode *inode, struct file *file, int isdir, |
18 | struct fuse_open_out *outargp) | ||
18 | { | 19 | { |
19 | struct fuse_conn *fc = get_fuse_conn(inode); | 20 | struct fuse_conn *fc = get_fuse_conn(inode); |
20 | struct fuse_req *req; | ||
21 | struct fuse_open_in inarg; | 21 | struct fuse_open_in inarg; |
22 | struct fuse_req *req; | ||
23 | int err; | ||
24 | |||
25 | req = fuse_get_request(fc); | ||
26 | if (!req) | ||
27 | return -EINTR; | ||
28 | |||
29 | memset(&inarg, 0, sizeof(inarg)); | ||
30 | inarg.flags = file->f_flags & ~(O_CREAT | O_EXCL | O_NOCTTY | O_TRUNC); | ||
31 | req->in.h.opcode = isdir ? FUSE_OPENDIR : FUSE_OPEN; | ||
32 | req->in.h.nodeid = get_node_id(inode); | ||
33 | req->inode = inode; | ||
34 | req->in.numargs = 1; | ||
35 | req->in.args[0].size = sizeof(inarg); | ||
36 | req->in.args[0].value = &inarg; | ||
37 | req->out.numargs = 1; | ||
38 | req->out.args[0].size = sizeof(*outargp); | ||
39 | req->out.args[0].value = outargp; | ||
40 | request_send(fc, req); | ||
41 | err = req->out.h.error; | ||
42 | fuse_put_request(fc, req); | ||
43 | |||
44 | return err; | ||
45 | } | ||
46 | |||
47 | struct fuse_file *fuse_file_alloc(void) | ||
48 | { | ||
49 | struct fuse_file *ff; | ||
50 | ff = kmalloc(sizeof(struct fuse_file), GFP_KERNEL); | ||
51 | if (ff) { | ||
52 | ff->release_req = fuse_request_alloc(); | ||
53 | if (!ff->release_req) { | ||
54 | kfree(ff); | ||
55 | ff = NULL; | ||
56 | } | ||
57 | } | ||
58 | return ff; | ||
59 | } | ||
60 | |||
61 | void fuse_file_free(struct fuse_file *ff) | ||
62 | { | ||
63 | fuse_request_free(ff->release_req); | ||
64 | kfree(ff); | ||
65 | } | ||
66 | |||
67 | void fuse_finish_open(struct inode *inode, struct file *file, | ||
68 | struct fuse_file *ff, struct fuse_open_out *outarg) | ||
69 | { | ||
70 | if (outarg->open_flags & FOPEN_DIRECT_IO) | ||
71 | file->f_op = &fuse_direct_io_file_operations; | ||
72 | if (!(outarg->open_flags & FOPEN_KEEP_CACHE)) | ||
73 | invalidate_inode_pages(inode->i_mapping); | ||
74 | ff->fh = outarg->fh; | ||
75 | file->private_data = ff; | ||
76 | } | ||
77 | |||
78 | int fuse_open_common(struct inode *inode, struct file *file, int isdir) | ||
79 | { | ||
22 | struct fuse_open_out outarg; | 80 | struct fuse_open_out outarg; |
23 | struct fuse_file *ff; | 81 | struct fuse_file *ff; |
24 | int err; | 82 | int err; |
@@ -34,73 +92,53 @@ int fuse_open_common(struct inode *inode, struct file *file, int isdir) | |||
34 | /* If opening the root node, no lookup has been performed on | 92 | /* If opening the root node, no lookup has been performed on |
35 | it, so the attributes must be refreshed */ | 93 | it, so the attributes must be refreshed */ |
36 | if (get_node_id(inode) == FUSE_ROOT_ID) { | 94 | if (get_node_id(inode) == FUSE_ROOT_ID) { |
37 | int err = fuse_do_getattr(inode); | 95 | err = fuse_do_getattr(inode); |
38 | if (err) | 96 | if (err) |
39 | return err; | 97 | return err; |
40 | } | 98 | } |
41 | 99 | ||
42 | req = fuse_get_request(fc); | 100 | ff = fuse_file_alloc(); |
43 | if (!req) | ||
44 | return -EINTR; | ||
45 | |||
46 | err = -ENOMEM; | ||
47 | ff = kmalloc(sizeof(struct fuse_file), GFP_KERNEL); | ||
48 | if (!ff) | 101 | if (!ff) |
49 | goto out_put_request; | 102 | return -ENOMEM; |
50 | 103 | ||
51 | ff->release_req = fuse_request_alloc(); | 104 | err = fuse_send_open(inode, file, isdir, &outarg); |
52 | if (!ff->release_req) { | 105 | if (err) |
53 | kfree(ff); | 106 | fuse_file_free(ff); |
54 | goto out_put_request; | 107 | else { |
55 | } | 108 | if (isdir) |
56 | 109 | outarg.open_flags &= ~FOPEN_DIRECT_IO; | |
57 | memset(&inarg, 0, sizeof(inarg)); | 110 | fuse_finish_open(inode, file, ff, &outarg); |
58 | inarg.flags = file->f_flags & ~(O_CREAT | O_EXCL | O_NOCTTY | O_TRUNC); | ||
59 | req->in.h.opcode = isdir ? FUSE_OPENDIR : FUSE_OPEN; | ||
60 | req->in.h.nodeid = get_node_id(inode); | ||
61 | req->inode = inode; | ||
62 | req->in.numargs = 1; | ||
63 | req->in.args[0].size = sizeof(inarg); | ||
64 | req->in.args[0].value = &inarg; | ||
65 | req->out.numargs = 1; | ||
66 | req->out.args[0].size = sizeof(outarg); | ||
67 | req->out.args[0].value = &outarg; | ||
68 | request_send(fc, req); | ||
69 | err = req->out.h.error; | ||
70 | if (err) { | ||
71 | fuse_request_free(ff->release_req); | ||
72 | kfree(ff); | ||
73 | } else { | ||
74 | if (!isdir && (outarg.open_flags & FOPEN_DIRECT_IO)) | ||
75 | file->f_op = &fuse_direct_io_file_operations; | ||
76 | if (!(outarg.open_flags & FOPEN_KEEP_CACHE)) | ||
77 | invalidate_inode_pages(inode->i_mapping); | ||
78 | ff->fh = outarg.fh; | ||
79 | file->private_data = ff; | ||
80 | } | 111 | } |
81 | 112 | ||
82 | out_put_request: | ||
83 | fuse_put_request(fc, req); | ||
84 | return err; | 113 | return err; |
85 | } | 114 | } |
86 | 115 | ||
87 | int fuse_release_common(struct inode *inode, struct file *file, int isdir) | 116 | void fuse_send_release(struct fuse_conn *fc, struct fuse_file *ff, |
117 | u64 nodeid, struct inode *inode, int flags, int isdir) | ||
88 | { | 118 | { |
89 | struct fuse_conn *fc = get_fuse_conn(inode); | 119 | struct fuse_req * req = ff->release_req; |
90 | struct fuse_file *ff = file->private_data; | ||
91 | struct fuse_req *req = ff->release_req; | ||
92 | struct fuse_release_in *inarg = &req->misc.release_in; | 120 | struct fuse_release_in *inarg = &req->misc.release_in; |
93 | 121 | ||
94 | inarg->fh = ff->fh; | 122 | inarg->fh = ff->fh; |
95 | inarg->flags = file->f_flags & ~O_EXCL; | 123 | inarg->flags = flags; |
96 | req->in.h.opcode = isdir ? FUSE_RELEASEDIR : FUSE_RELEASE; | 124 | req->in.h.opcode = isdir ? FUSE_RELEASEDIR : FUSE_RELEASE; |
97 | req->in.h.nodeid = get_node_id(inode); | 125 | req->in.h.nodeid = nodeid; |
98 | req->inode = inode; | 126 | req->inode = inode; |
99 | req->in.numargs = 1; | 127 | req->in.numargs = 1; |
100 | req->in.args[0].size = sizeof(struct fuse_release_in); | 128 | req->in.args[0].size = sizeof(struct fuse_release_in); |
101 | req->in.args[0].value = inarg; | 129 | req->in.args[0].value = inarg; |
102 | request_send_background(fc, req); | 130 | request_send_background(fc, req); |
103 | kfree(ff); | 131 | kfree(ff); |
132 | } | ||
133 | |||
134 | int fuse_release_common(struct inode *inode, struct file *file, int isdir) | ||
135 | { | ||
136 | struct fuse_file *ff = file->private_data; | ||
137 | if (ff) { | ||
138 | struct fuse_conn *fc = get_fuse_conn(inode); | ||
139 | u64 nodeid = get_node_id(inode); | ||
140 | fuse_send_release(fc, ff, nodeid, inode, file->f_flags, isdir); | ||
141 | } | ||
104 | 142 | ||
105 | /* Return value is ignored by VFS */ | 143 | /* Return value is ignored by VFS */ |
106 | return 0; | 144 | return 0; |
diff --git a/fs/fuse/fuse_i.h b/fs/fuse/fuse_i.h index 5cb456f572c1..0ea5301f86be 100644 --- a/fs/fuse/fuse_i.h +++ b/fs/fuse/fuse_i.h | |||
@@ -266,6 +266,12 @@ struct fuse_conn { | |||
266 | /** Is removexattr not implemented by fs? */ | 266 | /** Is removexattr not implemented by fs? */ |
267 | unsigned no_removexattr : 1; | 267 | unsigned no_removexattr : 1; |
268 | 268 | ||
269 | /** Is access not implemented by fs? */ | ||
270 | unsigned no_access : 1; | ||
271 | |||
272 | /** Is create not implemented by fs? */ | ||
273 | unsigned no_create : 1; | ||
274 | |||
269 | /** Backing dev info */ | 275 | /** Backing dev info */ |
270 | struct backing_dev_info bdi; | 276 | struct backing_dev_info bdi; |
271 | }; | 277 | }; |
@@ -337,6 +343,17 @@ size_t fuse_send_read_common(struct fuse_req *req, struct file *file, | |||
337 | */ | 343 | */ |
338 | int fuse_open_common(struct inode *inode, struct file *file, int isdir); | 344 | int fuse_open_common(struct inode *inode, struct file *file, int isdir); |
339 | 345 | ||
346 | struct fuse_file *fuse_file_alloc(void); | ||
347 | void fuse_file_free(struct fuse_file *ff); | ||
348 | void fuse_finish_open(struct inode *inode, struct file *file, | ||
349 | struct fuse_file *ff, struct fuse_open_out *outarg); | ||
350 | |||
351 | /** | ||
352 | * Send a RELEASE request | ||
353 | */ | ||
354 | void fuse_send_release(struct fuse_conn *fc, struct fuse_file *ff, | ||
355 | u64 nodeid, struct inode *inode, int flags, int isdir); | ||
356 | |||
340 | /** | 357 | /** |
341 | * Send RELEASE or RELEASEDIR request | 358 | * Send RELEASE or RELEASEDIR request |
342 | */ | 359 | */ |
diff --git a/fs/hfs/hfs_fs.h b/fs/hfs/hfs_fs.h index aae019aadf88..cc5dcd52e23d 100644 --- a/fs/hfs/hfs_fs.h +++ b/fs/hfs/hfs_fs.h | |||
@@ -9,7 +9,6 @@ | |||
9 | #ifndef _LINUX_HFS_FS_H | 9 | #ifndef _LINUX_HFS_FS_H |
10 | #define _LINUX_HFS_FS_H | 10 | #define _LINUX_HFS_FS_H |
11 | 11 | ||
12 | #include <linux/version.h> | ||
13 | #include <linux/slab.h> | 12 | #include <linux/slab.h> |
14 | #include <linux/types.h> | 13 | #include <linux/types.h> |
15 | #include <linux/buffer_head.h> | 14 | #include <linux/buffer_head.h> |
diff --git a/fs/hfs/inode.c b/fs/hfs/inode.c index 3f680c5675bf..d499393a8ae7 100644 --- a/fs/hfs/inode.c +++ b/fs/hfs/inode.c | |||
@@ -12,7 +12,6 @@ | |||
12 | */ | 12 | */ |
13 | 13 | ||
14 | #include <linux/pagemap.h> | 14 | #include <linux/pagemap.h> |
15 | #include <linux/version.h> | ||
16 | #include <linux/mpage.h> | 15 | #include <linux/mpage.h> |
17 | 16 | ||
18 | #include "hfs_fs.h" | 17 | #include "hfs_fs.h" |
diff --git a/fs/hfsplus/bnode.c b/fs/hfsplus/bnode.c index b85abc6e6f83..930cd9212de8 100644 --- a/fs/hfsplus/bnode.c +++ b/fs/hfsplus/bnode.c | |||
@@ -13,7 +13,6 @@ | |||
13 | #include <linux/pagemap.h> | 13 | #include <linux/pagemap.h> |
14 | #include <linux/fs.h> | 14 | #include <linux/fs.h> |
15 | #include <linux/swap.h> | 15 | #include <linux/swap.h> |
16 | #include <linux/version.h> | ||
17 | 16 | ||
18 | #include "hfsplus_fs.h" | 17 | #include "hfsplus_fs.h" |
19 | #include "hfsplus_raw.h" | 18 | #include "hfsplus_raw.h" |
diff --git a/fs/hfsplus/dir.c b/fs/hfsplus/dir.c index 7bda76667a4a..50c8f44b6c66 100644 --- a/fs/hfsplus/dir.c +++ b/fs/hfsplus/dir.c | |||
@@ -13,7 +13,6 @@ | |||
13 | #include <linux/sched.h> | 13 | #include <linux/sched.h> |
14 | #include <linux/slab.h> | 14 | #include <linux/slab.h> |
15 | #include <linux/random.h> | 15 | #include <linux/random.h> |
16 | #include <linux/version.h> | ||
17 | 16 | ||
18 | #include "hfsplus_fs.h" | 17 | #include "hfsplus_fs.h" |
19 | #include "hfsplus_raw.h" | 18 | #include "hfsplus_raw.h" |
diff --git a/fs/hfsplus/extents.c b/fs/hfsplus/extents.c index e7235ca79a95..e3ff56a03011 100644 --- a/fs/hfsplus/extents.c +++ b/fs/hfsplus/extents.c | |||
@@ -11,7 +11,6 @@ | |||
11 | #include <linux/errno.h> | 11 | #include <linux/errno.h> |
12 | #include <linux/fs.h> | 12 | #include <linux/fs.h> |
13 | #include <linux/pagemap.h> | 13 | #include <linux/pagemap.h> |
14 | #include <linux/version.h> | ||
15 | 14 | ||
16 | #include "hfsplus_fs.h" | 15 | #include "hfsplus_fs.h" |
17 | #include "hfsplus_raw.h" | 16 | #include "hfsplus_raw.h" |
diff --git a/fs/hfsplus/hfsplus_fs.h b/fs/hfsplus/hfsplus_fs.h index 2bc0cdd30e56..c60e5635498d 100644 --- a/fs/hfsplus/hfsplus_fs.h +++ b/fs/hfsplus/hfsplus_fs.h | |||
@@ -11,7 +11,6 @@ | |||
11 | #define _LINUX_HFSPLUS_FS_H | 11 | #define _LINUX_HFSPLUS_FS_H |
12 | 12 | ||
13 | #include <linux/fs.h> | 13 | #include <linux/fs.h> |
14 | #include <linux/version.h> | ||
15 | #include <linux/buffer_head.h> | 14 | #include <linux/buffer_head.h> |
16 | #include "hfsplus_raw.h" | 15 | #include "hfsplus_raw.h" |
17 | 16 | ||
diff --git a/fs/hfsplus/inode.c b/fs/hfsplus/inode.c index f205773ddfbe..fc98583cf045 100644 --- a/fs/hfsplus/inode.c +++ b/fs/hfsplus/inode.c | |||
@@ -11,7 +11,6 @@ | |||
11 | #include <linux/mm.h> | 11 | #include <linux/mm.h> |
12 | #include <linux/fs.h> | 12 | #include <linux/fs.h> |
13 | #include <linux/pagemap.h> | 13 | #include <linux/pagemap.h> |
14 | #include <linux/version.h> | ||
15 | #include <linux/mpage.h> | 14 | #include <linux/mpage.h> |
16 | 15 | ||
17 | #include "hfsplus_fs.h" | 16 | #include "hfsplus_fs.h" |
diff --git a/fs/hfsplus/super.c b/fs/hfsplus/super.c index 452fc1fdbd32..0ce1c455ae55 100644 --- a/fs/hfsplus/super.c +++ b/fs/hfsplus/super.c | |||
@@ -14,7 +14,6 @@ | |||
14 | #include <linux/fs.h> | 14 | #include <linux/fs.h> |
15 | #include <linux/sched.h> | 15 | #include <linux/sched.h> |
16 | #include <linux/slab.h> | 16 | #include <linux/slab.h> |
17 | #include <linux/version.h> | ||
18 | #include <linux/vfs.h> | 17 | #include <linux/vfs.h> |
19 | #include <linux/nls.h> | 18 | #include <linux/nls.h> |
20 | 19 | ||
diff --git a/fs/hfsplus/wrapper.c b/fs/hfsplus/wrapper.c index 0c51d6338b0b..95455e839231 100644 --- a/fs/hfsplus/wrapper.c +++ b/fs/hfsplus/wrapper.c | |||
@@ -12,7 +12,6 @@ | |||
12 | #include <linux/blkdev.h> | 12 | #include <linux/blkdev.h> |
13 | #include <linux/cdrom.h> | 13 | #include <linux/cdrom.h> |
14 | #include <linux/genhd.h> | 14 | #include <linux/genhd.h> |
15 | #include <linux/version.h> | ||
16 | #include <asm/unaligned.h> | 15 | #include <asm/unaligned.h> |
17 | 16 | ||
18 | #include "hfsplus_fs.h" | 17 | #include "hfsplus_fs.h" |
diff --git a/fs/hostfs/hostfs_kern.c b/fs/hostfs/hostfs_kern.c index dd7113106269..4684eb7d48c6 100644 --- a/fs/hostfs/hostfs_kern.c +++ b/fs/hostfs/hostfs_kern.c | |||
@@ -8,7 +8,6 @@ | |||
8 | 8 | ||
9 | #include <linux/stddef.h> | 9 | #include <linux/stddef.h> |
10 | #include <linux/fs.h> | 10 | #include <linux/fs.h> |
11 | #include <linux/version.h> | ||
12 | #include <linux/module.h> | 11 | #include <linux/module.h> |
13 | #include <linux/init.h> | 12 | #include <linux/init.h> |
14 | #include <linux/slab.h> | 13 | #include <linux/slab.h> |
@@ -294,8 +293,7 @@ static void hostfs_delete_inode(struct inode *inode) | |||
294 | 293 | ||
295 | static void hostfs_destroy_inode(struct inode *inode) | 294 | static void hostfs_destroy_inode(struct inode *inode) |
296 | { | 295 | { |
297 | if(HOSTFS_I(inode)->host_filename) | 296 | kfree(HOSTFS_I(inode)->host_filename); |
298 | kfree(HOSTFS_I(inode)->host_filename); | ||
299 | 297 | ||
300 | /*XXX: This should not happen, probably. The check is here for | 298 | /*XXX: This should not happen, probably. The check is here for |
301 | * additional safety.*/ | 299 | * additional safety.*/ |
diff --git a/fs/hpfs/dnode.c b/fs/hpfs/dnode.c index 1d21307730a8..229ff2fb1809 100644 --- a/fs/hpfs/dnode.c +++ b/fs/hpfs/dnode.c | |||
@@ -244,12 +244,12 @@ static int hpfs_add_to_dnode(struct inode *i, dnode_secno dno, | |||
244 | go_up: | 244 | go_up: |
245 | if (namelen >= 256) { | 245 | if (namelen >= 256) { |
246 | hpfs_error(i->i_sb, "hpfs_add_to_dnode: namelen == %d", namelen); | 246 | hpfs_error(i->i_sb, "hpfs_add_to_dnode: namelen == %d", namelen); |
247 | if (nd) kfree(nd); | 247 | kfree(nd); |
248 | kfree(nname); | 248 | kfree(nname); |
249 | return 1; | 249 | return 1; |
250 | } | 250 | } |
251 | if (!(d = hpfs_map_dnode(i->i_sb, dno, &qbh))) { | 251 | if (!(d = hpfs_map_dnode(i->i_sb, dno, &qbh))) { |
252 | if (nd) kfree(nd); | 252 | kfree(nd); |
253 | kfree(nname); | 253 | kfree(nname); |
254 | return 1; | 254 | return 1; |
255 | } | 255 | } |
@@ -257,7 +257,7 @@ static int hpfs_add_to_dnode(struct inode *i, dnode_secno dno, | |||
257 | if (hpfs_sb(i->i_sb)->sb_chk) | 257 | if (hpfs_sb(i->i_sb)->sb_chk) |
258 | if (hpfs_stop_cycles(i->i_sb, dno, &c1, &c2, "hpfs_add_to_dnode")) { | 258 | if (hpfs_stop_cycles(i->i_sb, dno, &c1, &c2, "hpfs_add_to_dnode")) { |
259 | hpfs_brelse4(&qbh); | 259 | hpfs_brelse4(&qbh); |
260 | if (nd) kfree(nd); | 260 | kfree(nd); |
261 | kfree(nname); | 261 | kfree(nname); |
262 | return 1; | 262 | return 1; |
263 | } | 263 | } |
@@ -270,7 +270,7 @@ static int hpfs_add_to_dnode(struct inode *i, dnode_secno dno, | |||
270 | for_all_poss(i, hpfs_pos_subst, 5, t + 1); | 270 | for_all_poss(i, hpfs_pos_subst, 5, t + 1); |
271 | hpfs_mark_4buffers_dirty(&qbh); | 271 | hpfs_mark_4buffers_dirty(&qbh); |
272 | hpfs_brelse4(&qbh); | 272 | hpfs_brelse4(&qbh); |
273 | if (nd) kfree(nd); | 273 | kfree(nd); |
274 | kfree(nname); | 274 | kfree(nname); |
275 | return 0; | 275 | return 0; |
276 | } | 276 | } |
diff --git a/fs/hpfs/file.c b/fs/hpfs/file.c index ab144dabd870..7c995ac4081b 100644 --- a/fs/hpfs/file.c +++ b/fs/hpfs/file.c | |||
@@ -114,11 +114,8 @@ static ssize_t hpfs_file_write(struct file *file, const char __user *buf, | |||
114 | ssize_t retval; | 114 | ssize_t retval; |
115 | 115 | ||
116 | retval = generic_file_write(file, buf, count, ppos); | 116 | retval = generic_file_write(file, buf, count, ppos); |
117 | if (retval > 0) { | 117 | if (retval > 0) |
118 | struct inode *inode = file->f_dentry->d_inode; | 118 | hpfs_i(file->f_dentry->d_inode)->i_dirty = 1; |
119 | inode->i_mtime = CURRENT_TIME_SEC; | ||
120 | hpfs_i(inode)->i_dirty = 1; | ||
121 | } | ||
122 | return retval; | 119 | return retval; |
123 | } | 120 | } |
124 | 121 | ||
diff --git a/fs/hpfs/super.c b/fs/hpfs/super.c index 8eefa6366db7..63e88d7e2c3b 100644 --- a/fs/hpfs/super.c +++ b/fs/hpfs/super.c | |||
@@ -75,7 +75,7 @@ void hpfs_error(struct super_block *s, char *m,...) | |||
75 | } else if (s->s_flags & MS_RDONLY) printk("; going on - but anything won't be destroyed because it's read-only\n"); | 75 | } else if (s->s_flags & MS_RDONLY) printk("; going on - but anything won't be destroyed because it's read-only\n"); |
76 | else printk("; corrupted filesystem mounted read/write - your computer will explode within 20 seconds ... but you wanted it so!\n"); | 76 | else printk("; corrupted filesystem mounted read/write - your computer will explode within 20 seconds ... but you wanted it so!\n"); |
77 | } else printk("\n"); | 77 | } else printk("\n"); |
78 | if (buf) kfree(buf); | 78 | kfree(buf); |
79 | hpfs_sb(s)->sb_was_error = 1; | 79 | hpfs_sb(s)->sb_was_error = 1; |
80 | } | 80 | } |
81 | 81 | ||
@@ -102,8 +102,8 @@ int hpfs_stop_cycles(struct super_block *s, int key, int *c1, int *c2, | |||
102 | static void hpfs_put_super(struct super_block *s) | 102 | static void hpfs_put_super(struct super_block *s) |
103 | { | 103 | { |
104 | struct hpfs_sb_info *sbi = hpfs_sb(s); | 104 | struct hpfs_sb_info *sbi = hpfs_sb(s); |
105 | if (sbi->sb_cp_table) kfree(sbi->sb_cp_table); | 105 | kfree(sbi->sb_cp_table); |
106 | if (sbi->sb_bmp_dir) kfree(sbi->sb_bmp_dir); | 106 | kfree(sbi->sb_bmp_dir); |
107 | unmark_dirty(s); | 107 | unmark_dirty(s); |
108 | s->s_fs_info = NULL; | 108 | s->s_fs_info = NULL; |
109 | kfree(sbi); | 109 | kfree(sbi); |
@@ -654,8 +654,8 @@ bail3: brelse(bh1); | |||
654 | bail2: brelse(bh0); | 654 | bail2: brelse(bh0); |
655 | bail1: | 655 | bail1: |
656 | bail0: | 656 | bail0: |
657 | if (sbi->sb_bmp_dir) kfree(sbi->sb_bmp_dir); | 657 | kfree(sbi->sb_bmp_dir); |
658 | if (sbi->sb_cp_table) kfree(sbi->sb_cp_table); | 658 | kfree(sbi->sb_cp_table); |
659 | s->s_fs_info = NULL; | 659 | s->s_fs_info = NULL; |
660 | kfree(sbi); | 660 | kfree(sbi); |
661 | return -EINVAL; | 661 | return -EINVAL; |
diff --git a/fs/hugetlbfs/inode.c b/fs/hugetlbfs/inode.c index e026c807e6b3..64983ab55586 100644 --- a/fs/hugetlbfs/inode.c +++ b/fs/hugetlbfs/inode.c | |||
@@ -63,7 +63,7 @@ static void huge_pagevec_release(struct pagevec *pvec) | |||
63 | * | 63 | * |
64 | * Result is in bytes to be compatible with is_hugepage_mem_enough() | 64 | * Result is in bytes to be compatible with is_hugepage_mem_enough() |
65 | */ | 65 | */ |
66 | unsigned long | 66 | static unsigned long |
67 | huge_pages_needed(struct address_space *mapping, struct vm_area_struct *vma) | 67 | huge_pages_needed(struct address_space *mapping, struct vm_area_struct *vma) |
68 | { | 68 | { |
69 | int i; | 69 | int i; |
diff --git a/fs/inotify.c b/fs/inotify.c index 9fbaebfdf40b..bf7ce1d2412b 100644 --- a/fs/inotify.c +++ b/fs/inotify.c | |||
@@ -372,7 +372,7 @@ static int find_inode(const char __user *dirname, struct nameidata *nd) | |||
372 | if (error) | 372 | if (error) |
373 | return error; | 373 | return error; |
374 | /* you can only watch an inode if you have read permissions on it */ | 374 | /* you can only watch an inode if you have read permissions on it */ |
375 | error = permission(nd->dentry->d_inode, MAY_READ, NULL); | 375 | error = vfs_permission(nd, MAY_READ); |
376 | if (error) | 376 | if (error) |
377 | path_release(nd); | 377 | path_release(nd); |
378 | return error; | 378 | return error; |
diff --git a/fs/isofs/inode.c b/fs/isofs/inode.c index 1652de1b6cb9..298f08be22d4 100644 --- a/fs/isofs/inode.c +++ b/fs/isofs/inode.c | |||
@@ -855,8 +855,7 @@ root_found: | |||
855 | if (opt.check == 'r') table++; | 855 | if (opt.check == 'r') table++; |
856 | s->s_root->d_op = &isofs_dentry_ops[table]; | 856 | s->s_root->d_op = &isofs_dentry_ops[table]; |
857 | 857 | ||
858 | if (opt.iocharset) | 858 | kfree(opt.iocharset); |
859 | kfree(opt.iocharset); | ||
860 | 859 | ||
861 | return 0; | 860 | return 0; |
862 | 861 | ||
@@ -895,8 +894,7 @@ out_unknown_format: | |||
895 | out_freebh: | 894 | out_freebh: |
896 | brelse(bh); | 895 | brelse(bh); |
897 | out_freesbi: | 896 | out_freesbi: |
898 | if (opt.iocharset) | 897 | kfree(opt.iocharset); |
899 | kfree(opt.iocharset); | ||
900 | kfree(sbi); | 898 | kfree(sbi); |
901 | s->s_fs_info = NULL; | 899 | s->s_fs_info = NULL; |
902 | return -EINVAL; | 900 | return -EINVAL; |
@@ -1164,8 +1162,7 @@ out_nomem: | |||
1164 | 1162 | ||
1165 | out_noread: | 1163 | out_noread: |
1166 | printk(KERN_INFO "ISOFS: unable to read i-node block %lu\n", block); | 1164 | printk(KERN_INFO "ISOFS: unable to read i-node block %lu\n", block); |
1167 | if (tmpde) | 1165 | kfree(tmpde); |
1168 | kfree(tmpde); | ||
1169 | return -EIO; | 1166 | return -EIO; |
1170 | 1167 | ||
1171 | out_toomany: | 1168 | out_toomany: |
@@ -1334,8 +1331,7 @@ static void isofs_read_inode(struct inode *inode) | |||
1334 | init_special_inode(inode, inode->i_mode, inode->i_rdev); | 1331 | init_special_inode(inode, inode->i_mode, inode->i_rdev); |
1335 | 1332 | ||
1336 | out: | 1333 | out: |
1337 | if (tmpde) | 1334 | kfree(tmpde); |
1338 | kfree(tmpde); | ||
1339 | if (bh) | 1335 | if (bh) |
1340 | brelse(bh); | 1336 | brelse(bh); |
1341 | return; | 1337 | return; |
diff --git a/fs/jbd/commit.c b/fs/jbd/commit.c index 2a3e310f79ef..002ad2bbc769 100644 --- a/fs/jbd/commit.c +++ b/fs/jbd/commit.c | |||
@@ -261,10 +261,8 @@ void journal_commit_transaction(journal_t *journal) | |||
261 | struct buffer_head *bh = jh2bh(jh); | 261 | struct buffer_head *bh = jh2bh(jh); |
262 | 262 | ||
263 | jbd_lock_bh_state(bh); | 263 | jbd_lock_bh_state(bh); |
264 | if (jh->b_committed_data) { | 264 | kfree(jh->b_committed_data); |
265 | kfree(jh->b_committed_data); | 265 | jh->b_committed_data = NULL; |
266 | jh->b_committed_data = NULL; | ||
267 | } | ||
268 | jbd_unlock_bh_state(bh); | 266 | jbd_unlock_bh_state(bh); |
269 | } | 267 | } |
270 | journal_refile_buffer(journal, jh); | 268 | journal_refile_buffer(journal, jh); |
diff --git a/fs/jbd/recovery.c b/fs/jbd/recovery.c index 103c34e4fb28..80d7f53fd0a7 100644 --- a/fs/jbd/recovery.c +++ b/fs/jbd/recovery.c | |||
@@ -210,7 +210,7 @@ do { \ | |||
210 | } while (0) | 210 | } while (0) |
211 | 211 | ||
212 | /** | 212 | /** |
213 | * int journal_recover(journal_t *journal) - recovers a on-disk journal | 213 | * journal_recover - recovers a on-disk journal |
214 | * @journal: the journal to recover | 214 | * @journal: the journal to recover |
215 | * | 215 | * |
216 | * The primary function for recovering the log contents when mounting a | 216 | * The primary function for recovering the log contents when mounting a |
@@ -266,7 +266,7 @@ int journal_recover(journal_t *journal) | |||
266 | } | 266 | } |
267 | 267 | ||
268 | /** | 268 | /** |
269 | * int journal_skip_recovery() - Start journal and wipe exiting records | 269 | * journal_skip_recovery - Start journal and wipe exiting records |
270 | * @journal: journal to startup | 270 | * @journal: journal to startup |
271 | * | 271 | * |
272 | * Locate any valid recovery information from the journal and set up the | 272 | * Locate any valid recovery information from the journal and set up the |
diff --git a/fs/jbd/transaction.c b/fs/jbd/transaction.c index 13cb05bf6048..429f4b263cf1 100644 --- a/fs/jbd/transaction.c +++ b/fs/jbd/transaction.c | |||
@@ -227,8 +227,7 @@ repeat_locked: | |||
227 | spin_unlock(&transaction->t_handle_lock); | 227 | spin_unlock(&transaction->t_handle_lock); |
228 | spin_unlock(&journal->j_state_lock); | 228 | spin_unlock(&journal->j_state_lock); |
229 | out: | 229 | out: |
230 | if (new_transaction) | 230 | kfree(new_transaction); |
231 | kfree(new_transaction); | ||
232 | return ret; | 231 | return ret; |
233 | } | 232 | } |
234 | 233 | ||
@@ -725,8 +724,7 @@ done: | |||
725 | journal_cancel_revoke(handle, jh); | 724 | journal_cancel_revoke(handle, jh); |
726 | 725 | ||
727 | out: | 726 | out: |
728 | if (frozen_buffer) | 727 | kfree(frozen_buffer); |
729 | kfree(frozen_buffer); | ||
730 | 728 | ||
731 | JBUFFER_TRACE(jh, "exit"); | 729 | JBUFFER_TRACE(jh, "exit"); |
732 | return error; | 730 | return error; |
@@ -905,8 +903,7 @@ repeat: | |||
905 | jbd_unlock_bh_state(bh); | 903 | jbd_unlock_bh_state(bh); |
906 | out: | 904 | out: |
907 | journal_put_journal_head(jh); | 905 | journal_put_journal_head(jh); |
908 | if (committed_data) | 906 | kfree(committed_data); |
909 | kfree(committed_data); | ||
910 | return err; | 907 | return err; |
911 | } | 908 | } |
912 | 909 | ||
diff --git a/fs/jffs/intrep.c b/fs/jffs/intrep.c index 27f199e94cfc..b2e95421d932 100644 --- a/fs/jffs/intrep.c +++ b/fs/jffs/intrep.c | |||
@@ -462,7 +462,7 @@ jffs_checksum_flash(struct mtd_info *mtd, loff_t start, int size, __u32 *result) | |||
462 | } | 462 | } |
463 | 463 | ||
464 | /* Free read buffer */ | 464 | /* Free read buffer */ |
465 | kfree (read_buf); | 465 | kfree(read_buf); |
466 | 466 | ||
467 | /* Return result */ | 467 | /* Return result */ |
468 | D3(printk("checksum result: 0x%08x\n", sum)); | 468 | D3(printk("checksum result: 0x%08x\n", sum)); |
@@ -1011,12 +1011,12 @@ jffs_scan_flash(struct jffs_control *c) | |||
1011 | offset , fmc->sector_size); | 1011 | offset , fmc->sector_size); |
1012 | 1012 | ||
1013 | flash_safe_release(fmc->mtd); | 1013 | flash_safe_release(fmc->mtd); |
1014 | kfree (read_buf); | 1014 | kfree(read_buf); |
1015 | return -1; /* bad, bad, bad! */ | 1015 | return -1; /* bad, bad, bad! */ |
1016 | 1016 | ||
1017 | } | 1017 | } |
1018 | flash_safe_release(fmc->mtd); | 1018 | flash_safe_release(fmc->mtd); |
1019 | kfree (read_buf); | 1019 | kfree(read_buf); |
1020 | 1020 | ||
1021 | return -EAGAIN; /* erased offending sector. Try mount one more time please. */ | 1021 | return -EAGAIN; /* erased offending sector. Try mount one more time please. */ |
1022 | } | 1022 | } |
@@ -1112,7 +1112,7 @@ jffs_scan_flash(struct jffs_control *c) | |||
1112 | if (!node) { | 1112 | if (!node) { |
1113 | if (!(node = jffs_alloc_node())) { | 1113 | if (!(node = jffs_alloc_node())) { |
1114 | /* Free read buffer */ | 1114 | /* Free read buffer */ |
1115 | kfree (read_buf); | 1115 | kfree(read_buf); |
1116 | 1116 | ||
1117 | /* Release the flash device */ | 1117 | /* Release the flash device */ |
1118 | flash_safe_release(fmc->mtd); | 1118 | flash_safe_release(fmc->mtd); |
@@ -1269,7 +1269,7 @@ jffs_scan_flash(struct jffs_control *c) | |||
1269 | DJM(no_jffs_node--); | 1269 | DJM(no_jffs_node--); |
1270 | 1270 | ||
1271 | /* Free read buffer */ | 1271 | /* Free read buffer */ |
1272 | kfree (read_buf); | 1272 | kfree(read_buf); |
1273 | 1273 | ||
1274 | /* Release the flash device */ | 1274 | /* Release the flash device */ |
1275 | flash_safe_release(fmc->mtd); | 1275 | flash_safe_release(fmc->mtd); |
@@ -1296,7 +1296,7 @@ jffs_scan_flash(struct jffs_control *c) | |||
1296 | flash_safe_release(fmc->flash_part); | 1296 | flash_safe_release(fmc->flash_part); |
1297 | 1297 | ||
1298 | /* Free read buffer */ | 1298 | /* Free read buffer */ |
1299 | kfree (read_buf); | 1299 | kfree(read_buf); |
1300 | 1300 | ||
1301 | return -ENOMEM; | 1301 | return -ENOMEM; |
1302 | } | 1302 | } |
@@ -1324,7 +1324,7 @@ jffs_scan_flash(struct jffs_control *c) | |||
1324 | jffs_build_end(fmc); | 1324 | jffs_build_end(fmc); |
1325 | 1325 | ||
1326 | /* Free read buffer */ | 1326 | /* Free read buffer */ |
1327 | kfree (read_buf); | 1327 | kfree(read_buf); |
1328 | 1328 | ||
1329 | if(!num_free_space){ | 1329 | if(!num_free_space){ |
1330 | printk(KERN_WARNING "jffs_scan_flash(): Did not find even a single " | 1330 | printk(KERN_WARNING "jffs_scan_flash(): Did not find even a single " |
@@ -1747,9 +1747,7 @@ jffs_find_child(struct jffs_file *dir, const char *name, int len) | |||
1747 | } | 1747 | } |
1748 | printk("jffs_find_child(): Didn't find the file \"%s\".\n", | 1748 | printk("jffs_find_child(): Didn't find the file \"%s\".\n", |
1749 | (copy ? copy : "")); | 1749 | (copy ? copy : "")); |
1750 | if (copy) { | 1750 | kfree(copy); |
1751 | kfree(copy); | ||
1752 | } | ||
1753 | }); | 1751 | }); |
1754 | 1752 | ||
1755 | return f; | 1753 | return f; |
diff --git a/fs/jffs2/Makefile b/fs/jffs2/Makefile index f1afe681ecd6..77dc5561a04e 100644 --- a/fs/jffs2/Makefile +++ b/fs/jffs2/Makefile | |||
@@ -1,7 +1,7 @@ | |||
1 | # | 1 | # |
2 | # Makefile for the Linux Journalling Flash File System v2 (JFFS2) | 2 | # Makefile for the Linux Journalling Flash File System v2 (JFFS2) |
3 | # | 3 | # |
4 | # $Id: Makefile.common,v 1.9 2005/02/09 09:23:53 pavlov Exp $ | 4 | # $Id: Makefile.common,v 1.11 2005/09/07 08:34:53 havasi Exp $ |
5 | # | 5 | # |
6 | 6 | ||
7 | obj-$(CONFIG_JFFS2_FS) += jffs2.o | 7 | obj-$(CONFIG_JFFS2_FS) += jffs2.o |
@@ -9,9 +9,10 @@ obj-$(CONFIG_JFFS2_FS) += jffs2.o | |||
9 | jffs2-y := compr.o dir.o file.o ioctl.o nodelist.o malloc.o | 9 | jffs2-y := compr.o dir.o file.o ioctl.o nodelist.o malloc.o |
10 | jffs2-y += read.o nodemgmt.o readinode.o write.o scan.o gc.o | 10 | jffs2-y += read.o nodemgmt.o readinode.o write.o scan.o gc.o |
11 | jffs2-y += symlink.o build.o erase.o background.o fs.o writev.o | 11 | jffs2-y += symlink.o build.o erase.o background.o fs.o writev.o |
12 | jffs2-y += super.o | 12 | jffs2-y += super.o debug.o |
13 | 13 | ||
14 | jffs2-$(CONFIG_JFFS2_FS_WRITEBUFFER) += wbuf.o | 14 | jffs2-$(CONFIG_JFFS2_FS_WRITEBUFFER) += wbuf.o |
15 | jffs2-$(CONFIG_JFFS2_RUBIN) += compr_rubin.o | 15 | jffs2-$(CONFIG_JFFS2_RUBIN) += compr_rubin.o |
16 | jffs2-$(CONFIG_JFFS2_RTIME) += compr_rtime.o | 16 | jffs2-$(CONFIG_JFFS2_RTIME) += compr_rtime.o |
17 | jffs2-$(CONFIG_JFFS2_ZLIB) += compr_zlib.o | 17 | jffs2-$(CONFIG_JFFS2_ZLIB) += compr_zlib.o |
18 | jffs2-$(CONFIG_JFFS2_SUMMARY) += summary.o | ||
diff --git a/fs/jffs2/TODO b/fs/jffs2/TODO index 2bff82fd221f..d0e23b26fa50 100644 --- a/fs/jffs2/TODO +++ b/fs/jffs2/TODO | |||
@@ -1,5 +1,11 @@ | |||
1 | $Id: TODO,v 1.10 2002/09/09 16:31:21 dwmw2 Exp $ | 1 | $Id: TODO,v 1.18 2005/09/22 11:24:56 dedekind Exp $ |
2 | 2 | ||
3 | - support asynchronous operation -- add a per-fs 'reserved_space' count, | ||
4 | let each outstanding write reserve the _maximum_ amount of physical | ||
5 | space it could take. Let GC flush the outstanding writes because the | ||
6 | reservations will necessarily be pessimistic. With this we could even | ||
7 | do shared writable mmap, if we can have a fs hook for do_wp_page() to | ||
8 | make the reservation. | ||
3 | - disable compression in commit_write()? | 9 | - disable compression in commit_write()? |
4 | - fine-tune the allocation / GC thresholds | 10 | - fine-tune the allocation / GC thresholds |
5 | - chattr support - turning on/off and tuning compression per-inode | 11 | - chattr support - turning on/off and tuning compression per-inode |
@@ -11,26 +17,15 @@ $Id: TODO,v 1.10 2002/09/09 16:31:21 dwmw2 Exp $ | |||
11 | - test, test, test | 17 | - test, test, test |
12 | 18 | ||
13 | - NAND flash support: | 19 | - NAND flash support: |
14 | - flush_wbuf using GC to fill it, don't just pad. | 20 | - almost done :) |
15 | - Deal with write errors. Data don't get lost - we just have to write | 21 | - use bad block check instead of the hardwired byte check |
16 | the affected node(s) out again somewhere else. | ||
17 | - make fsync flush only if actually required | ||
18 | - make sys_sync() work. | ||
19 | - reboot notifier | ||
20 | - timed flush of old wbuf | ||
21 | - fix magical second arg of jffs2_flush_wbuf(). Split into two or more functions instead. | ||
22 | |||
23 | 22 | ||
24 | - Optimisations: | 23 | - Optimisations: |
25 | - Stop GC from decompressing and immediately recompressing nodes which could | 24 | - Split writes so they go to two separate blocks rather than just c->nextblock. |
26 | just be copied intact. (We now keep track of REF_PRISTINE flag. Easy now.) | 25 | By writing _new_ nodes to one block, and garbage-collected REF_PRISTINE |
27 | - Furthermore, in the case where it could be copied intact we don't even need | 26 | nodes to a different one, we can separate clean nodes from those which |
28 | to call iget() for it -- if we use (raw_node_raw->flash_offset & 2) as a flag | 27 | are likely to become dirty, and end up with blocks which are each far |
29 | to show a node can be copied intact and it's _not_ in icache, we could just do | 28 | closer to 100% or 0% clean, hence speeding up later GC progress dramatically. |
30 | it, fix up the next_in_ino list and move on. We would need a way to find out | ||
31 | _whether_ it's in icache though -- if it's in icache we also need to do the | ||
32 | fragment lists, etc. P'raps a flag or pointer in the jffs2_inode_cache could | ||
33 | help. (We have half of this now.) | ||
34 | - Stop keeping name in-core with struct jffs2_full_dirent. If we keep the hash in | 29 | - Stop keeping name in-core with struct jffs2_full_dirent. If we keep the hash in |
35 | the full dirent, we only need to go to the flash in lookup() when we think we've | 30 | the full dirent, we only need to go to the flash in lookup() when we think we've |
36 | got a match, and in readdir(). | 31 | got a match, and in readdir(). |
@@ -38,3 +33,8 @@ $Id: TODO,v 1.10 2002/09/09 16:31:21 dwmw2 Exp $ | |||
38 | - Remove totlen from jffs2_raw_node_ref? Need to have totlen passed into | 33 | - Remove totlen from jffs2_raw_node_ref? Need to have totlen passed into |
39 | jffs2_mark_node_obsolete(). Can all callers work it out? | 34 | jffs2_mark_node_obsolete(). Can all callers work it out? |
40 | - Remove size from jffs2_raw_node_frag. | 35 | - Remove size from jffs2_raw_node_frag. |
36 | |||
37 | dedekind: | ||
38 | 1. __jffs2_flush_wbuf() has a strange 'pad' parameter. Eliminate. | ||
39 | 2. get_sb()->build_fs()->scan() path... Why get_sb() removes scan()'s crap in | ||
40 | case of failure? scan() does not clean everything. Fix. | ||
diff --git a/fs/jffs2/background.c b/fs/jffs2/background.c index 8210ac16a368..7b77a9541125 100644 --- a/fs/jffs2/background.c +++ b/fs/jffs2/background.c | |||
@@ -51,7 +51,7 @@ int jffs2_start_garbage_collect_thread(struct jffs2_sb_info *c) | |||
51 | D1(printk(KERN_DEBUG "JFFS2: Garbage collect thread is pid %d\n", pid)); | 51 | D1(printk(KERN_DEBUG "JFFS2: Garbage collect thread is pid %d\n", pid)); |
52 | wait_for_completion(&c->gc_thread_start); | 52 | wait_for_completion(&c->gc_thread_start); |
53 | } | 53 | } |
54 | 54 | ||
55 | return ret; | 55 | return ret; |
56 | } | 56 | } |
57 | 57 | ||
@@ -101,7 +101,7 @@ static int jffs2_garbage_collect_thread(void *_c) | |||
101 | 101 | ||
102 | cond_resched(); | 102 | cond_resched(); |
103 | 103 | ||
104 | /* Put_super will send a SIGKILL and then wait on the sem. | 104 | /* Put_super will send a SIGKILL and then wait on the sem. |
105 | */ | 105 | */ |
106 | while (signal_pending(current)) { | 106 | while (signal_pending(current)) { |
107 | siginfo_t info; | 107 | siginfo_t info; |
diff --git a/fs/jffs2/build.c b/fs/jffs2/build.c index 97dc39796e2c..fff108bb118b 100644 --- a/fs/jffs2/build.c +++ b/fs/jffs2/build.c | |||
@@ -7,7 +7,7 @@ | |||
7 | * | 7 | * |
8 | * For licensing information, see the file 'LICENCE' in this directory. | 8 | * For licensing information, see the file 'LICENCE' in this directory. |
9 | * | 9 | * |
10 | * $Id: build.c,v 1.71 2005/07/12 16:37:08 dedekind Exp $ | 10 | * $Id: build.c,v 1.85 2005/11/07 11:14:38 gleixner Exp $ |
11 | * | 11 | * |
12 | */ | 12 | */ |
13 | 13 | ||
@@ -18,7 +18,8 @@ | |||
18 | #include <linux/mtd/mtd.h> | 18 | #include <linux/mtd/mtd.h> |
19 | #include "nodelist.h" | 19 | #include "nodelist.h" |
20 | 20 | ||
21 | static void jffs2_build_remove_unlinked_inode(struct jffs2_sb_info *, struct jffs2_inode_cache *, struct jffs2_full_dirent **); | 21 | static void jffs2_build_remove_unlinked_inode(struct jffs2_sb_info *, |
22 | struct jffs2_inode_cache *, struct jffs2_full_dirent **); | ||
22 | 23 | ||
23 | static inline struct jffs2_inode_cache * | 24 | static inline struct jffs2_inode_cache * |
24 | first_inode_chain(int *i, struct jffs2_sb_info *c) | 25 | first_inode_chain(int *i, struct jffs2_sb_info *c) |
@@ -46,11 +47,12 @@ next_inode(int *i, struct jffs2_inode_cache *ic, struct jffs2_sb_info *c) | |||
46 | ic = next_inode(&i, ic, (c))) | 47 | ic = next_inode(&i, ic, (c))) |
47 | 48 | ||
48 | 49 | ||
49 | static inline void jffs2_build_inode_pass1(struct jffs2_sb_info *c, struct jffs2_inode_cache *ic) | 50 | static inline void jffs2_build_inode_pass1(struct jffs2_sb_info *c, |
51 | struct jffs2_inode_cache *ic) | ||
50 | { | 52 | { |
51 | struct jffs2_full_dirent *fd; | 53 | struct jffs2_full_dirent *fd; |
52 | 54 | ||
53 | D1(printk(KERN_DEBUG "jffs2_build_inode building directory inode #%u\n", ic->ino)); | 55 | dbg_fsbuild("building directory inode #%u\n", ic->ino); |
54 | 56 | ||
55 | /* For each child, increase nlink */ | 57 | /* For each child, increase nlink */ |
56 | for(fd = ic->scan_dents; fd; fd = fd->next) { | 58 | for(fd = ic->scan_dents; fd; fd = fd->next) { |
@@ -58,26 +60,23 @@ static inline void jffs2_build_inode_pass1(struct jffs2_sb_info *c, struct jffs2 | |||
58 | if (!fd->ino) | 60 | if (!fd->ino) |
59 | continue; | 61 | continue; |
60 | 62 | ||
61 | /* XXX: Can get high latency here with huge directories */ | 63 | /* we can get high latency here with huge directories */ |
62 | 64 | ||
63 | child_ic = jffs2_get_ino_cache(c, fd->ino); | 65 | child_ic = jffs2_get_ino_cache(c, fd->ino); |
64 | if (!child_ic) { | 66 | if (!child_ic) { |
65 | printk(KERN_NOTICE "Eep. Child \"%s\" (ino #%u) of dir ino #%u doesn't exist!\n", | 67 | dbg_fsbuild("child \"%s\" (ino #%u) of dir ino #%u doesn't exist!\n", |
66 | fd->name, fd->ino, ic->ino); | 68 | fd->name, fd->ino, ic->ino); |
67 | jffs2_mark_node_obsolete(c, fd->raw); | 69 | jffs2_mark_node_obsolete(c, fd->raw); |
68 | continue; | 70 | continue; |
69 | } | 71 | } |
70 | 72 | ||
71 | if (child_ic->nlink++ && fd->type == DT_DIR) { | 73 | if (child_ic->nlink++ && fd->type == DT_DIR) { |
72 | printk(KERN_NOTICE "Child dir \"%s\" (ino #%u) of dir ino #%u appears to be a hard link\n", fd->name, fd->ino, ic->ino); | 74 | JFFS2_ERROR("child dir \"%s\" (ino #%u) of dir ino #%u appears to be a hard link\n", |
73 | if (fd->ino == 1 && ic->ino == 1) { | 75 | fd->name, fd->ino, ic->ino); |
74 | printk(KERN_NOTICE "This is mostly harmless, and probably caused by creating a JFFS2 image\n"); | 76 | /* TODO: What do we do about it? */ |
75 | printk(KERN_NOTICE "using a buggy version of mkfs.jffs2. Use at least v1.17.\n"); | ||
76 | } | ||
77 | /* What do we do about it? */ | ||
78 | } | 77 | } |
79 | D1(printk(KERN_DEBUG "Increased nlink for child \"%s\" (ino #%u)\n", fd->name, fd->ino)); | 78 | dbg_fsbuild("increased nlink for child \"%s\" (ino #%u)\n", fd->name, fd->ino); |
80 | /* Can't free them. We might need them in pass 2 */ | 79 | /* Can't free scan_dents so far. We might need them in pass 2 */ |
81 | } | 80 | } |
82 | } | 81 | } |
83 | 82 | ||
@@ -94,6 +93,8 @@ static int jffs2_build_filesystem(struct jffs2_sb_info *c) | |||
94 | struct jffs2_full_dirent *fd; | 93 | struct jffs2_full_dirent *fd; |
95 | struct jffs2_full_dirent *dead_fds = NULL; | 94 | struct jffs2_full_dirent *dead_fds = NULL; |
96 | 95 | ||
96 | dbg_fsbuild("build FS data structures\n"); | ||
97 | |||
97 | /* First, scan the medium and build all the inode caches with | 98 | /* First, scan the medium and build all the inode caches with |
98 | lists of physical nodes */ | 99 | lists of physical nodes */ |
99 | 100 | ||
@@ -103,60 +104,54 @@ static int jffs2_build_filesystem(struct jffs2_sb_info *c) | |||
103 | if (ret) | 104 | if (ret) |
104 | goto exit; | 105 | goto exit; |
105 | 106 | ||
106 | D1(printk(KERN_DEBUG "Scanned flash completely\n")); | 107 | dbg_fsbuild("scanned flash completely\n"); |
107 | D2(jffs2_dump_block_lists(c)); | 108 | jffs2_dbg_dump_block_lists_nolock(c); |
108 | 109 | ||
110 | dbg_fsbuild("pass 1 starting\n"); | ||
109 | c->flags |= JFFS2_SB_FLAG_BUILDING; | 111 | c->flags |= JFFS2_SB_FLAG_BUILDING; |
110 | /* Now scan the directory tree, increasing nlink according to every dirent found. */ | 112 | /* Now scan the directory tree, increasing nlink according to every dirent found. */ |
111 | for_each_inode(i, c, ic) { | 113 | for_each_inode(i, c, ic) { |
112 | D1(printk(KERN_DEBUG "Pass 1: ino #%u\n", ic->ino)); | ||
113 | |||
114 | D1(BUG_ON(ic->ino > c->highest_ino)); | ||
115 | |||
116 | if (ic->scan_dents) { | 114 | if (ic->scan_dents) { |
117 | jffs2_build_inode_pass1(c, ic); | 115 | jffs2_build_inode_pass1(c, ic); |
118 | cond_resched(); | 116 | cond_resched(); |
119 | } | 117 | } |
120 | } | 118 | } |
121 | 119 | ||
122 | D1(printk(KERN_DEBUG "Pass 1 complete\n")); | 120 | dbg_fsbuild("pass 1 complete\n"); |
123 | 121 | ||
124 | /* Next, scan for inodes with nlink == 0 and remove them. If | 122 | /* Next, scan for inodes with nlink == 0 and remove them. If |
125 | they were directories, then decrement the nlink of their | 123 | they were directories, then decrement the nlink of their |
126 | children too, and repeat the scan. As that's going to be | 124 | children too, and repeat the scan. As that's going to be |
127 | a fairly uncommon occurrence, it's not so evil to do it this | 125 | a fairly uncommon occurrence, it's not so evil to do it this |
128 | way. Recursion bad. */ | 126 | way. Recursion bad. */ |
129 | D1(printk(KERN_DEBUG "Pass 2 starting\n")); | 127 | dbg_fsbuild("pass 2 starting\n"); |
130 | 128 | ||
131 | for_each_inode(i, c, ic) { | 129 | for_each_inode(i, c, ic) { |
132 | D1(printk(KERN_DEBUG "Pass 2: ino #%u, nlink %d, ic %p, nodes %p\n", ic->ino, ic->nlink, ic, ic->nodes)); | ||
133 | if (ic->nlink) | 130 | if (ic->nlink) |
134 | continue; | 131 | continue; |
135 | 132 | ||
136 | jffs2_build_remove_unlinked_inode(c, ic, &dead_fds); | 133 | jffs2_build_remove_unlinked_inode(c, ic, &dead_fds); |
137 | cond_resched(); | 134 | cond_resched(); |
138 | } | 135 | } |
139 | 136 | ||
140 | D1(printk(KERN_DEBUG "Pass 2a starting\n")); | 137 | dbg_fsbuild("pass 2a starting\n"); |
141 | 138 | ||
142 | while (dead_fds) { | 139 | while (dead_fds) { |
143 | fd = dead_fds; | 140 | fd = dead_fds; |
144 | dead_fds = fd->next; | 141 | dead_fds = fd->next; |
145 | 142 | ||
146 | ic = jffs2_get_ino_cache(c, fd->ino); | 143 | ic = jffs2_get_ino_cache(c, fd->ino); |
147 | D1(printk(KERN_DEBUG "Removing dead_fd ino #%u (\"%s\"), ic at %p\n", fd->ino, fd->name, ic)); | ||
148 | 144 | ||
149 | if (ic) | 145 | if (ic) |
150 | jffs2_build_remove_unlinked_inode(c, ic, &dead_fds); | 146 | jffs2_build_remove_unlinked_inode(c, ic, &dead_fds); |
151 | jffs2_free_full_dirent(fd); | 147 | jffs2_free_full_dirent(fd); |
152 | } | 148 | } |
153 | 149 | ||
154 | D1(printk(KERN_DEBUG "Pass 2 complete\n")); | 150 | dbg_fsbuild("pass 2a complete\n"); |
155 | 151 | dbg_fsbuild("freeing temporary data structures\n"); | |
152 | |||
156 | /* Finally, we can scan again and free the dirent structs */ | 153 | /* Finally, we can scan again and free the dirent structs */ |
157 | for_each_inode(i, c, ic) { | 154 | for_each_inode(i, c, ic) { |
158 | D1(printk(KERN_DEBUG "Pass 3: ino #%u, ic %p, nodes %p\n", ic->ino, ic, ic->nodes)); | ||
159 | |||
160 | while(ic->scan_dents) { | 155 | while(ic->scan_dents) { |
161 | fd = ic->scan_dents; | 156 | fd = ic->scan_dents; |
162 | ic->scan_dents = fd->next; | 157 | ic->scan_dents = fd->next; |
@@ -166,9 +161,8 @@ static int jffs2_build_filesystem(struct jffs2_sb_info *c) | |||
166 | cond_resched(); | 161 | cond_resched(); |
167 | } | 162 | } |
168 | c->flags &= ~JFFS2_SB_FLAG_BUILDING; | 163 | c->flags &= ~JFFS2_SB_FLAG_BUILDING; |
169 | 164 | ||
170 | D1(printk(KERN_DEBUG "Pass 3 complete\n")); | 165 | dbg_fsbuild("FS build complete\n"); |
171 | D2(jffs2_dump_block_lists(c)); | ||
172 | 166 | ||
173 | /* Rotate the lists by some number to ensure wear levelling */ | 167 | /* Rotate the lists by some number to ensure wear levelling */ |
174 | jffs2_rotate_lists(c); | 168 | jffs2_rotate_lists(c); |
@@ -189,24 +183,26 @@ exit: | |||
189 | return ret; | 183 | return ret; |
190 | } | 184 | } |
191 | 185 | ||
192 | static void jffs2_build_remove_unlinked_inode(struct jffs2_sb_info *c, struct jffs2_inode_cache *ic, struct jffs2_full_dirent **dead_fds) | 186 | static void jffs2_build_remove_unlinked_inode(struct jffs2_sb_info *c, |
187 | struct jffs2_inode_cache *ic, | ||
188 | struct jffs2_full_dirent **dead_fds) | ||
193 | { | 189 | { |
194 | struct jffs2_raw_node_ref *raw; | 190 | struct jffs2_raw_node_ref *raw; |
195 | struct jffs2_full_dirent *fd; | 191 | struct jffs2_full_dirent *fd; |
196 | 192 | ||
197 | D1(printk(KERN_DEBUG "JFFS2: Removing ino #%u with nlink == zero.\n", ic->ino)); | 193 | dbg_fsbuild("removing ino #%u with nlink == zero.\n", ic->ino); |
198 | 194 | ||
199 | raw = ic->nodes; | 195 | raw = ic->nodes; |
200 | while (raw != (void *)ic) { | 196 | while (raw != (void *)ic) { |
201 | struct jffs2_raw_node_ref *next = raw->next_in_ino; | 197 | struct jffs2_raw_node_ref *next = raw->next_in_ino; |
202 | D1(printk(KERN_DEBUG "obsoleting node at 0x%08x\n", ref_offset(raw))); | 198 | dbg_fsbuild("obsoleting node at 0x%08x\n", ref_offset(raw)); |
203 | jffs2_mark_node_obsolete(c, raw); | 199 | jffs2_mark_node_obsolete(c, raw); |
204 | raw = next; | 200 | raw = next; |
205 | } | 201 | } |
206 | 202 | ||
207 | if (ic->scan_dents) { | 203 | if (ic->scan_dents) { |
208 | int whinged = 0; | 204 | int whinged = 0; |
209 | D1(printk(KERN_DEBUG "Inode #%u was a directory which may have children...\n", ic->ino)); | 205 | dbg_fsbuild("inode #%u was a directory which may have children...\n", ic->ino); |
210 | 206 | ||
211 | while(ic->scan_dents) { | 207 | while(ic->scan_dents) { |
212 | struct jffs2_inode_cache *child_ic; | 208 | struct jffs2_inode_cache *child_ic; |
@@ -216,45 +212,43 @@ static void jffs2_build_remove_unlinked_inode(struct jffs2_sb_info *c, struct jf | |||
216 | 212 | ||
217 | if (!fd->ino) { | 213 | if (!fd->ino) { |
218 | /* It's a deletion dirent. Ignore it */ | 214 | /* It's a deletion dirent. Ignore it */ |
219 | D1(printk(KERN_DEBUG "Child \"%s\" is a deletion dirent, skipping...\n", fd->name)); | 215 | dbg_fsbuild("child \"%s\" is a deletion dirent, skipping...\n", fd->name); |
220 | jffs2_free_full_dirent(fd); | 216 | jffs2_free_full_dirent(fd); |
221 | continue; | 217 | continue; |
222 | } | 218 | } |
223 | if (!whinged) { | 219 | if (!whinged) |
224 | whinged = 1; | 220 | whinged = 1; |
225 | printk(KERN_NOTICE "Inode #%u was a directory with children - removing those too...\n", ic->ino); | ||
226 | } | ||
227 | 221 | ||
228 | D1(printk(KERN_DEBUG "Removing child \"%s\", ino #%u\n", | 222 | dbg_fsbuild("removing child \"%s\", ino #%u\n", fd->name, fd->ino); |
229 | fd->name, fd->ino)); | 223 | |
230 | |||
231 | child_ic = jffs2_get_ino_cache(c, fd->ino); | 224 | child_ic = jffs2_get_ino_cache(c, fd->ino); |
232 | if (!child_ic) { | 225 | if (!child_ic) { |
233 | printk(KERN_NOTICE "Cannot remove child \"%s\", ino #%u, because it doesn't exist\n", fd->name, fd->ino); | 226 | dbg_fsbuild("cannot remove child \"%s\", ino #%u, because it doesn't exist\n", |
227 | fd->name, fd->ino); | ||
234 | jffs2_free_full_dirent(fd); | 228 | jffs2_free_full_dirent(fd); |
235 | continue; | 229 | continue; |
236 | } | 230 | } |
237 | 231 | ||
238 | /* Reduce nlink of the child. If it's now zero, stick it on the | 232 | /* Reduce nlink of the child. If it's now zero, stick it on the |
239 | dead_fds list to be cleaned up later. Else just free the fd */ | 233 | dead_fds list to be cleaned up later. Else just free the fd */ |
240 | 234 | ||
241 | child_ic->nlink--; | 235 | child_ic->nlink--; |
242 | 236 | ||
243 | if (!child_ic->nlink) { | 237 | if (!child_ic->nlink) { |
244 | D1(printk(KERN_DEBUG "Inode #%u (\"%s\") has now got zero nlink. Adding to dead_fds list.\n", | 238 | dbg_fsbuild("inode #%u (\"%s\") has now got zero nlink, adding to dead_fds list.\n", |
245 | fd->ino, fd->name)); | 239 | fd->ino, fd->name); |
246 | fd->next = *dead_fds; | 240 | fd->next = *dead_fds; |
247 | *dead_fds = fd; | 241 | *dead_fds = fd; |
248 | } else { | 242 | } else { |
249 | D1(printk(KERN_DEBUG "Inode #%u (\"%s\") has now got nlink %d. Ignoring.\n", | 243 | dbg_fsbuild("inode #%u (\"%s\") has now got nlink %d. Ignoring.\n", |
250 | fd->ino, fd->name, child_ic->nlink)); | 244 | fd->ino, fd->name, child_ic->nlink); |
251 | jffs2_free_full_dirent(fd); | 245 | jffs2_free_full_dirent(fd); |
252 | } | 246 | } |
253 | } | 247 | } |
254 | } | 248 | } |
255 | 249 | ||
256 | /* | 250 | /* |
257 | We don't delete the inocache from the hash list and free it yet. | 251 | We don't delete the inocache from the hash list and free it yet. |
258 | The erase code will do that, when all the nodes are completely gone. | 252 | The erase code will do that, when all the nodes are completely gone. |
259 | */ | 253 | */ |
260 | } | 254 | } |
@@ -268,7 +262,7 @@ static void jffs2_calc_trigger_levels(struct jffs2_sb_info *c) | |||
268 | because there's not enough free space... */ | 262 | because there's not enough free space... */ |
269 | c->resv_blocks_deletion = 2; | 263 | c->resv_blocks_deletion = 2; |
270 | 264 | ||
271 | /* Be conservative about how much space we need before we allow writes. | 265 | /* Be conservative about how much space we need before we allow writes. |
272 | On top of that which is required for deletia, require an extra 2% | 266 | On top of that which is required for deletia, require an extra 2% |
273 | of the medium to be available, for overhead caused by nodes being | 267 | of the medium to be available, for overhead caused by nodes being |
274 | split across blocks, etc. */ | 268 | split across blocks, etc. */ |
@@ -283,7 +277,7 @@ static void jffs2_calc_trigger_levels(struct jffs2_sb_info *c) | |||
283 | 277 | ||
284 | c->resv_blocks_gctrigger = c->resv_blocks_write + 1; | 278 | c->resv_blocks_gctrigger = c->resv_blocks_write + 1; |
285 | 279 | ||
286 | /* When do we allow garbage collection to merge nodes to make | 280 | /* When do we allow garbage collection to merge nodes to make |
287 | long-term progress at the expense of short-term space exhaustion? */ | 281 | long-term progress at the expense of short-term space exhaustion? */ |
288 | c->resv_blocks_gcmerge = c->resv_blocks_deletion + 1; | 282 | c->resv_blocks_gcmerge = c->resv_blocks_deletion + 1; |
289 | 283 | ||
@@ -295,45 +289,45 @@ static void jffs2_calc_trigger_levels(struct jffs2_sb_info *c) | |||
295 | trying to GC to make more space. It'll be a fruitless task */ | 289 | trying to GC to make more space. It'll be a fruitless task */ |
296 | c->nospc_dirty_size = c->sector_size + (c->flash_size / 100); | 290 | c->nospc_dirty_size = c->sector_size + (c->flash_size / 100); |
297 | 291 | ||
298 | D1(printk(KERN_DEBUG "JFFS2 trigger levels (size %d KiB, block size %d KiB, %d blocks)\n", | 292 | dbg_fsbuild("JFFS2 trigger levels (size %d KiB, block size %d KiB, %d blocks)\n", |
299 | c->flash_size / 1024, c->sector_size / 1024, c->nr_blocks)); | 293 | c->flash_size / 1024, c->sector_size / 1024, c->nr_blocks); |
300 | D1(printk(KERN_DEBUG "Blocks required to allow deletion: %d (%d KiB)\n", | 294 | dbg_fsbuild("Blocks required to allow deletion: %d (%d KiB)\n", |
301 | c->resv_blocks_deletion, c->resv_blocks_deletion*c->sector_size/1024)); | 295 | c->resv_blocks_deletion, c->resv_blocks_deletion*c->sector_size/1024); |
302 | D1(printk(KERN_DEBUG "Blocks required to allow writes: %d (%d KiB)\n", | 296 | dbg_fsbuild("Blocks required to allow writes: %d (%d KiB)\n", |
303 | c->resv_blocks_write, c->resv_blocks_write*c->sector_size/1024)); | 297 | c->resv_blocks_write, c->resv_blocks_write*c->sector_size/1024); |
304 | D1(printk(KERN_DEBUG "Blocks required to quiesce GC thread: %d (%d KiB)\n", | 298 | dbg_fsbuild("Blocks required to quiesce GC thread: %d (%d KiB)\n", |
305 | c->resv_blocks_gctrigger, c->resv_blocks_gctrigger*c->sector_size/1024)); | 299 | c->resv_blocks_gctrigger, c->resv_blocks_gctrigger*c->sector_size/1024); |
306 | D1(printk(KERN_DEBUG "Blocks required to allow GC merges: %d (%d KiB)\n", | 300 | dbg_fsbuild("Blocks required to allow GC merges: %d (%d KiB)\n", |
307 | c->resv_blocks_gcmerge, c->resv_blocks_gcmerge*c->sector_size/1024)); | 301 | c->resv_blocks_gcmerge, c->resv_blocks_gcmerge*c->sector_size/1024); |
308 | D1(printk(KERN_DEBUG "Blocks required to GC bad blocks: %d (%d KiB)\n", | 302 | dbg_fsbuild("Blocks required to GC bad blocks: %d (%d KiB)\n", |
309 | c->resv_blocks_gcbad, c->resv_blocks_gcbad*c->sector_size/1024)); | 303 | c->resv_blocks_gcbad, c->resv_blocks_gcbad*c->sector_size/1024); |
310 | D1(printk(KERN_DEBUG "Amount of dirty space required to GC: %d bytes\n", | 304 | dbg_fsbuild("Amount of dirty space required to GC: %d bytes\n", |
311 | c->nospc_dirty_size)); | 305 | c->nospc_dirty_size); |
312 | } | 306 | } |
313 | 307 | ||
314 | int jffs2_do_mount_fs(struct jffs2_sb_info *c) | 308 | int jffs2_do_mount_fs(struct jffs2_sb_info *c) |
315 | { | 309 | { |
310 | int ret; | ||
316 | int i; | 311 | int i; |
312 | int size; | ||
317 | 313 | ||
318 | c->free_size = c->flash_size; | 314 | c->free_size = c->flash_size; |
319 | c->nr_blocks = c->flash_size / c->sector_size; | 315 | c->nr_blocks = c->flash_size / c->sector_size; |
320 | if (c->mtd->flags & MTD_NO_VIRTBLOCKS) | 316 | size = sizeof(struct jffs2_eraseblock) * c->nr_blocks; |
321 | c->blocks = vmalloc(sizeof(struct jffs2_eraseblock) * c->nr_blocks); | 317 | #ifndef __ECOS |
318 | if (jffs2_blocks_use_vmalloc(c)) | ||
319 | c->blocks = vmalloc(size); | ||
322 | else | 320 | else |
323 | c->blocks = kmalloc(sizeof(struct jffs2_eraseblock) * c->nr_blocks, GFP_KERNEL); | 321 | #endif |
322 | c->blocks = kmalloc(size, GFP_KERNEL); | ||
324 | if (!c->blocks) | 323 | if (!c->blocks) |
325 | return -ENOMEM; | 324 | return -ENOMEM; |
325 | |||
326 | memset(c->blocks, 0, size); | ||
326 | for (i=0; i<c->nr_blocks; i++) { | 327 | for (i=0; i<c->nr_blocks; i++) { |
327 | INIT_LIST_HEAD(&c->blocks[i].list); | 328 | INIT_LIST_HEAD(&c->blocks[i].list); |
328 | c->blocks[i].offset = i * c->sector_size; | 329 | c->blocks[i].offset = i * c->sector_size; |
329 | c->blocks[i].free_size = c->sector_size; | 330 | c->blocks[i].free_size = c->sector_size; |
330 | c->blocks[i].dirty_size = 0; | ||
331 | c->blocks[i].wasted_size = 0; | ||
332 | c->blocks[i].unchecked_size = 0; | ||
333 | c->blocks[i].used_size = 0; | ||
334 | c->blocks[i].first_node = NULL; | ||
335 | c->blocks[i].last_node = NULL; | ||
336 | c->blocks[i].bad_count = 0; | ||
337 | } | 331 | } |
338 | 332 | ||
339 | INIT_LIST_HEAD(&c->clean_list); | 333 | INIT_LIST_HEAD(&c->clean_list); |
@@ -348,16 +342,23 @@ int jffs2_do_mount_fs(struct jffs2_sb_info *c) | |||
348 | INIT_LIST_HEAD(&c->bad_list); | 342 | INIT_LIST_HEAD(&c->bad_list); |
349 | INIT_LIST_HEAD(&c->bad_used_list); | 343 | INIT_LIST_HEAD(&c->bad_used_list); |
350 | c->highest_ino = 1; | 344 | c->highest_ino = 1; |
345 | c->summary = NULL; | ||
346 | |||
347 | ret = jffs2_sum_init(c); | ||
348 | if (ret) | ||
349 | return ret; | ||
351 | 350 | ||
352 | if (jffs2_build_filesystem(c)) { | 351 | if (jffs2_build_filesystem(c)) { |
353 | D1(printk(KERN_DEBUG "build_fs failed\n")); | 352 | dbg_fsbuild("build_fs failed\n"); |
354 | jffs2_free_ino_caches(c); | 353 | jffs2_free_ino_caches(c); |
355 | jffs2_free_raw_node_refs(c); | 354 | jffs2_free_raw_node_refs(c); |
356 | if (c->mtd->flags & MTD_NO_VIRTBLOCKS) { | 355 | #ifndef __ECOS |
356 | if (jffs2_blocks_use_vmalloc(c)) | ||
357 | vfree(c->blocks); | 357 | vfree(c->blocks); |
358 | } else { | 358 | else |
359 | #endif | ||
359 | kfree(c->blocks); | 360 | kfree(c->blocks); |
360 | } | 361 | |
361 | return -EIO; | 362 | return -EIO; |
362 | } | 363 | } |
363 | 364 | ||
diff --git a/fs/jffs2/compr.c b/fs/jffs2/compr.c index af922a9618ac..e7944e665b9f 100644 --- a/fs/jffs2/compr.c +++ b/fs/jffs2/compr.c | |||
@@ -9,7 +9,7 @@ | |||
9 | * | 9 | * |
10 | * For licensing information, see the file 'LICENCE' in this directory. | 10 | * For licensing information, see the file 'LICENCE' in this directory. |
11 | * | 11 | * |
12 | * $Id: compr.c,v 1.42 2004/08/07 21:56:08 dwmw2 Exp $ | 12 | * $Id: compr.c,v 1.46 2005/11/07 11:14:38 gleixner Exp $ |
13 | * | 13 | * |
14 | */ | 14 | */ |
15 | 15 | ||
@@ -36,16 +36,16 @@ static uint32_t none_stat_compr_blocks=0,none_stat_decompr_blocks=0,none_stat_co | |||
36 | * data. | 36 | * data. |
37 | * | 37 | * |
38 | * Returns: Lower byte to be stored with data indicating compression type used. | 38 | * Returns: Lower byte to be stored with data indicating compression type used. |
39 | * Zero is used to show that the data could not be compressed - the | 39 | * Zero is used to show that the data could not be compressed - the |
40 | * compressed version was actually larger than the original. | 40 | * compressed version was actually larger than the original. |
41 | * Upper byte will be used later. (soon) | 41 | * Upper byte will be used later. (soon) |
42 | * | 42 | * |
43 | * If the cdata buffer isn't large enough to hold all the uncompressed data, | 43 | * If the cdata buffer isn't large enough to hold all the uncompressed data, |
44 | * jffs2_compress should compress as much as will fit, and should set | 44 | * jffs2_compress should compress as much as will fit, and should set |
45 | * *datalen accordingly to show the amount of data which were compressed. | 45 | * *datalen accordingly to show the amount of data which were compressed. |
46 | */ | 46 | */ |
47 | uint16_t jffs2_compress(struct jffs2_sb_info *c, struct jffs2_inode_info *f, | 47 | uint16_t jffs2_compress(struct jffs2_sb_info *c, struct jffs2_inode_info *f, |
48 | unsigned char *data_in, unsigned char **cpage_out, | 48 | unsigned char *data_in, unsigned char **cpage_out, |
49 | uint32_t *datalen, uint32_t *cdatalen) | 49 | uint32_t *datalen, uint32_t *cdatalen) |
50 | { | 50 | { |
51 | int ret = JFFS2_COMPR_NONE; | 51 | int ret = JFFS2_COMPR_NONE; |
@@ -164,7 +164,7 @@ uint16_t jffs2_compress(struct jffs2_sb_info *c, struct jffs2_inode_info *f, | |||
164 | } | 164 | } |
165 | 165 | ||
166 | int jffs2_decompress(struct jffs2_sb_info *c, struct jffs2_inode_info *f, | 166 | int jffs2_decompress(struct jffs2_sb_info *c, struct jffs2_inode_info *f, |
167 | uint16_t comprtype, unsigned char *cdata_in, | 167 | uint16_t comprtype, unsigned char *cdata_in, |
168 | unsigned char *data_out, uint32_t cdatalen, uint32_t datalen) | 168 | unsigned char *data_out, uint32_t cdatalen, uint32_t datalen) |
169 | { | 169 | { |
170 | struct jffs2_compressor *this; | 170 | struct jffs2_compressor *this; |
@@ -298,7 +298,7 @@ char *jffs2_stats(void) | |||
298 | 298 | ||
299 | act_buf += sprintf(act_buf,"JFFS2 compressor statistics:\n"); | 299 | act_buf += sprintf(act_buf,"JFFS2 compressor statistics:\n"); |
300 | act_buf += sprintf(act_buf,"%10s ","none"); | 300 | act_buf += sprintf(act_buf,"%10s ","none"); |
301 | act_buf += sprintf(act_buf,"compr: %d blocks (%d) decompr: %d blocks\n", none_stat_compr_blocks, | 301 | act_buf += sprintf(act_buf,"compr: %d blocks (%d) decompr: %d blocks\n", none_stat_compr_blocks, |
302 | none_stat_compr_size, none_stat_decompr_blocks); | 302 | none_stat_compr_size, none_stat_decompr_blocks); |
303 | spin_lock(&jffs2_compressor_list_lock); | 303 | spin_lock(&jffs2_compressor_list_lock); |
304 | list_for_each_entry(this, &jffs2_compressor_list, list) { | 304 | list_for_each_entry(this, &jffs2_compressor_list, list) { |
@@ -307,8 +307,8 @@ char *jffs2_stats(void) | |||
307 | act_buf += sprintf(act_buf,"- "); | 307 | act_buf += sprintf(act_buf,"- "); |
308 | else | 308 | else |
309 | act_buf += sprintf(act_buf,"+ "); | 309 | act_buf += sprintf(act_buf,"+ "); |
310 | act_buf += sprintf(act_buf,"compr: %d blocks (%d/%d) decompr: %d blocks ", this->stat_compr_blocks, | 310 | act_buf += sprintf(act_buf,"compr: %d blocks (%d/%d) decompr: %d blocks ", this->stat_compr_blocks, |
311 | this->stat_compr_new_size, this->stat_compr_orig_size, | 311 | this->stat_compr_new_size, this->stat_compr_orig_size, |
312 | this->stat_decompr_blocks); | 312 | this->stat_decompr_blocks); |
313 | act_buf += sprintf(act_buf,"\n"); | 313 | act_buf += sprintf(act_buf,"\n"); |
314 | } | 314 | } |
@@ -317,7 +317,7 @@ char *jffs2_stats(void) | |||
317 | return buf; | 317 | return buf; |
318 | } | 318 | } |
319 | 319 | ||
320 | char *jffs2_get_compression_mode_name(void) | 320 | char *jffs2_get_compression_mode_name(void) |
321 | { | 321 | { |
322 | switch (jffs2_compression_mode) { | 322 | switch (jffs2_compression_mode) { |
323 | case JFFS2_COMPR_MODE_NONE: | 323 | case JFFS2_COMPR_MODE_NONE: |
@@ -330,7 +330,7 @@ char *jffs2_get_compression_mode_name(void) | |||
330 | return "unkown"; | 330 | return "unkown"; |
331 | } | 331 | } |
332 | 332 | ||
333 | int jffs2_set_compression_mode_name(const char *name) | 333 | int jffs2_set_compression_mode_name(const char *name) |
334 | { | 334 | { |
335 | if (!strcmp("none",name)) { | 335 | if (!strcmp("none",name)) { |
336 | jffs2_compression_mode = JFFS2_COMPR_MODE_NONE; | 336 | jffs2_compression_mode = JFFS2_COMPR_MODE_NONE; |
@@ -355,7 +355,7 @@ static int jffs2_compressor_Xable(const char *name, int disabled) | |||
355 | if (!strcmp(this->name, name)) { | 355 | if (!strcmp(this->name, name)) { |
356 | this->disabled = disabled; | 356 | this->disabled = disabled; |
357 | spin_unlock(&jffs2_compressor_list_lock); | 357 | spin_unlock(&jffs2_compressor_list_lock); |
358 | return 0; | 358 | return 0; |
359 | } | 359 | } |
360 | } | 360 | } |
361 | spin_unlock(&jffs2_compressor_list_lock); | 361 | spin_unlock(&jffs2_compressor_list_lock); |
@@ -385,7 +385,7 @@ int jffs2_set_compressor_priority(const char *name, int priority) | |||
385 | } | 385 | } |
386 | } | 386 | } |
387 | spin_unlock(&jffs2_compressor_list_lock); | 387 | spin_unlock(&jffs2_compressor_list_lock); |
388 | printk(KERN_WARNING "JFFS2: compressor %s not found.\n",name); | 388 | printk(KERN_WARNING "JFFS2: compressor %s not found.\n",name); |
389 | return 1; | 389 | return 1; |
390 | reinsert: | 390 | reinsert: |
391 | /* list is sorted in the order of priority, so if | 391 | /* list is sorted in the order of priority, so if |
@@ -412,7 +412,7 @@ void jffs2_free_comprbuf(unsigned char *comprbuf, unsigned char *orig) | |||
412 | kfree(comprbuf); | 412 | kfree(comprbuf); |
413 | } | 413 | } |
414 | 414 | ||
415 | int jffs2_compressors_init(void) | 415 | int jffs2_compressors_init(void) |
416 | { | 416 | { |
417 | /* Registering compressors */ | 417 | /* Registering compressors */ |
418 | #ifdef CONFIG_JFFS2_ZLIB | 418 | #ifdef CONFIG_JFFS2_ZLIB |
@@ -425,12 +425,6 @@ int jffs2_compressors_init(void) | |||
425 | jffs2_rubinmips_init(); | 425 | jffs2_rubinmips_init(); |
426 | jffs2_dynrubin_init(); | 426 | jffs2_dynrubin_init(); |
427 | #endif | 427 | #endif |
428 | #ifdef CONFIG_JFFS2_LZARI | ||
429 | jffs2_lzari_init(); | ||
430 | #endif | ||
431 | #ifdef CONFIG_JFFS2_LZO | ||
432 | jffs2_lzo_init(); | ||
433 | #endif | ||
434 | /* Setting default compression mode */ | 428 | /* Setting default compression mode */ |
435 | #ifdef CONFIG_JFFS2_CMODE_NONE | 429 | #ifdef CONFIG_JFFS2_CMODE_NONE |
436 | jffs2_compression_mode = JFFS2_COMPR_MODE_NONE; | 430 | jffs2_compression_mode = JFFS2_COMPR_MODE_NONE; |
@@ -446,15 +440,9 @@ int jffs2_compressors_init(void) | |||
446 | return 0; | 440 | return 0; |
447 | } | 441 | } |
448 | 442 | ||
449 | int jffs2_compressors_exit(void) | 443 | int jffs2_compressors_exit(void) |
450 | { | 444 | { |
451 | /* Unregistering compressors */ | 445 | /* Unregistering compressors */ |
452 | #ifdef CONFIG_JFFS2_LZO | ||
453 | jffs2_lzo_exit(); | ||
454 | #endif | ||
455 | #ifdef CONFIG_JFFS2_LZARI | ||
456 | jffs2_lzari_exit(); | ||
457 | #endif | ||
458 | #ifdef CONFIG_JFFS2_RUBIN | 446 | #ifdef CONFIG_JFFS2_RUBIN |
459 | jffs2_dynrubin_exit(); | 447 | jffs2_dynrubin_exit(); |
460 | jffs2_rubinmips_exit(); | 448 | jffs2_rubinmips_exit(); |
diff --git a/fs/jffs2/compr.h b/fs/jffs2/compr.h index 89ceeed201eb..a77e830d85c5 100644 --- a/fs/jffs2/compr.h +++ b/fs/jffs2/compr.h | |||
@@ -4,10 +4,10 @@ | |||
4 | * Copyright (C) 2004 Ferenc Havasi <havasi@inf.u-szeged.hu>, | 4 | * Copyright (C) 2004 Ferenc Havasi <havasi@inf.u-szeged.hu>, |
5 | * University of Szeged, Hungary | 5 | * University of Szeged, Hungary |
6 | * | 6 | * |
7 | * For licensing information, see the file 'LICENCE' in the | 7 | * For licensing information, see the file 'LICENCE' in the |
8 | * jffs2 directory. | 8 | * jffs2 directory. |
9 | * | 9 | * |
10 | * $Id: compr.h,v 1.6 2004/07/16 15:17:57 dwmw2 Exp $ | 10 | * $Id: compr.h,v 1.9 2005/11/07 11:14:38 gleixner Exp $ |
11 | * | 11 | * |
12 | */ | 12 | */ |
13 | 13 | ||
@@ -103,13 +103,5 @@ void jffs2_rtime_exit(void); | |||
103 | int jffs2_zlib_init(void); | 103 | int jffs2_zlib_init(void); |
104 | void jffs2_zlib_exit(void); | 104 | void jffs2_zlib_exit(void); |
105 | #endif | 105 | #endif |
106 | #ifdef CONFIG_JFFS2_LZARI | ||
107 | int jffs2_lzari_init(void); | ||
108 | void jffs2_lzari_exit(void); | ||
109 | #endif | ||
110 | #ifdef CONFIG_JFFS2_LZO | ||
111 | int jffs2_lzo_init(void); | ||
112 | void jffs2_lzo_exit(void); | ||
113 | #endif | ||
114 | 106 | ||
115 | #endif /* __JFFS2_COMPR_H__ */ | 107 | #endif /* __JFFS2_COMPR_H__ */ |
diff --git a/fs/jffs2/compr_rtime.c b/fs/jffs2/compr_rtime.c index 393129418666..2eb1b7428d16 100644 --- a/fs/jffs2/compr_rtime.c +++ b/fs/jffs2/compr_rtime.c | |||
@@ -24,8 +24,8 @@ | |||
24 | #include <linux/kernel.h> | 24 | #include <linux/kernel.h> |
25 | #include <linux/types.h> | 25 | #include <linux/types.h> |
26 | #include <linux/errno.h> | 26 | #include <linux/errno.h> |
27 | #include <linux/string.h> | 27 | #include <linux/string.h> |
28 | #include <linux/jffs2.h> | 28 | #include <linux/jffs2.h> |
29 | #include "compr.h" | 29 | #include "compr.h" |
30 | 30 | ||
31 | /* _compress returns the compressed size, -1 if bigger */ | 31 | /* _compress returns the compressed size, -1 if bigger */ |
@@ -38,19 +38,19 @@ static int jffs2_rtime_compress(unsigned char *data_in, | |||
38 | int outpos = 0; | 38 | int outpos = 0; |
39 | int pos=0; | 39 | int pos=0; |
40 | 40 | ||
41 | memset(positions,0,sizeof(positions)); | 41 | memset(positions,0,sizeof(positions)); |
42 | 42 | ||
43 | while (pos < (*sourcelen) && outpos <= (*dstlen)-2) { | 43 | while (pos < (*sourcelen) && outpos <= (*dstlen)-2) { |
44 | int backpos, runlen=0; | 44 | int backpos, runlen=0; |
45 | unsigned char value; | 45 | unsigned char value; |
46 | 46 | ||
47 | value = data_in[pos]; | 47 | value = data_in[pos]; |
48 | 48 | ||
49 | cpage_out[outpos++] = data_in[pos++]; | 49 | cpage_out[outpos++] = data_in[pos++]; |
50 | 50 | ||
51 | backpos = positions[value]; | 51 | backpos = positions[value]; |
52 | positions[value]=pos; | 52 | positions[value]=pos; |
53 | 53 | ||
54 | while ((backpos < pos) && (pos < (*sourcelen)) && | 54 | while ((backpos < pos) && (pos < (*sourcelen)) && |
55 | (data_in[pos]==data_in[backpos++]) && (runlen<255)) { | 55 | (data_in[pos]==data_in[backpos++]) && (runlen<255)) { |
56 | pos++; | 56 | pos++; |
@@ -63,12 +63,12 @@ static int jffs2_rtime_compress(unsigned char *data_in, | |||
63 | /* We failed */ | 63 | /* We failed */ |
64 | return -1; | 64 | return -1; |
65 | } | 65 | } |
66 | 66 | ||
67 | /* Tell the caller how much we managed to compress, and how much space it took */ | 67 | /* Tell the caller how much we managed to compress, and how much space it took */ |
68 | *sourcelen = pos; | 68 | *sourcelen = pos; |
69 | *dstlen = outpos; | 69 | *dstlen = outpos; |
70 | return 0; | 70 | return 0; |
71 | } | 71 | } |
72 | 72 | ||
73 | 73 | ||
74 | static int jffs2_rtime_decompress(unsigned char *data_in, | 74 | static int jffs2_rtime_decompress(unsigned char *data_in, |
@@ -79,19 +79,19 @@ static int jffs2_rtime_decompress(unsigned char *data_in, | |||
79 | short positions[256]; | 79 | short positions[256]; |
80 | int outpos = 0; | 80 | int outpos = 0; |
81 | int pos=0; | 81 | int pos=0; |
82 | 82 | ||
83 | memset(positions,0,sizeof(positions)); | 83 | memset(positions,0,sizeof(positions)); |
84 | 84 | ||
85 | while (outpos<destlen) { | 85 | while (outpos<destlen) { |
86 | unsigned char value; | 86 | unsigned char value; |
87 | int backoffs; | 87 | int backoffs; |
88 | int repeat; | 88 | int repeat; |
89 | 89 | ||
90 | value = data_in[pos++]; | 90 | value = data_in[pos++]; |
91 | cpage_out[outpos++] = value; /* first the verbatim copied byte */ | 91 | cpage_out[outpos++] = value; /* first the verbatim copied byte */ |
92 | repeat = data_in[pos++]; | 92 | repeat = data_in[pos++]; |
93 | backoffs = positions[value]; | 93 | backoffs = positions[value]; |
94 | 94 | ||
95 | positions[value]=outpos; | 95 | positions[value]=outpos; |
96 | if (repeat) { | 96 | if (repeat) { |
97 | if (backoffs + repeat >= outpos) { | 97 | if (backoffs + repeat >= outpos) { |
@@ -101,12 +101,12 @@ static int jffs2_rtime_decompress(unsigned char *data_in, | |||
101 | } | 101 | } |
102 | } else { | 102 | } else { |
103 | memcpy(&cpage_out[outpos],&cpage_out[backoffs],repeat); | 103 | memcpy(&cpage_out[outpos],&cpage_out[backoffs],repeat); |
104 | outpos+=repeat; | 104 | outpos+=repeat; |
105 | } | 105 | } |
106 | } | 106 | } |
107 | } | 107 | } |
108 | return 0; | 108 | return 0; |
109 | } | 109 | } |
110 | 110 | ||
111 | static struct jffs2_compressor jffs2_rtime_comp = { | 111 | static struct jffs2_compressor jffs2_rtime_comp = { |
112 | .priority = JFFS2_RTIME_PRIORITY, | 112 | .priority = JFFS2_RTIME_PRIORITY, |
diff --git a/fs/jffs2/compr_rubin.c b/fs/jffs2/compr_rubin.c index 09422388fb96..e792e675d624 100644 --- a/fs/jffs2/compr_rubin.c +++ b/fs/jffs2/compr_rubin.c | |||
@@ -11,7 +11,6 @@ | |||
11 | * | 11 | * |
12 | */ | 12 | */ |
13 | 13 | ||
14 | |||
15 | #include <linux/string.h> | 14 | #include <linux/string.h> |
16 | #include <linux/types.h> | 15 | #include <linux/types.h> |
17 | #include <linux/jffs2.h> | 16 | #include <linux/jffs2.h> |
@@ -20,7 +19,7 @@ | |||
20 | #include "compr.h" | 19 | #include "compr.h" |
21 | 20 | ||
22 | static void init_rubin(struct rubin_state *rs, int div, int *bits) | 21 | static void init_rubin(struct rubin_state *rs, int div, int *bits) |
23 | { | 22 | { |
24 | int c; | 23 | int c; |
25 | 24 | ||
26 | rs->q = 0; | 25 | rs->q = 0; |
@@ -40,7 +39,7 @@ static int encode(struct rubin_state *rs, long A, long B, int symbol) | |||
40 | 39 | ||
41 | while ((rs->q >= UPPER_BIT_RUBIN) || ((rs->p + rs->q) <= UPPER_BIT_RUBIN)) { | 40 | while ((rs->q >= UPPER_BIT_RUBIN) || ((rs->p + rs->q) <= UPPER_BIT_RUBIN)) { |
42 | rs->bit_number++; | 41 | rs->bit_number++; |
43 | 42 | ||
44 | ret = pushbit(&rs->pp, (rs->q & UPPER_BIT_RUBIN) ? 1 : 0, 0); | 43 | ret = pushbit(&rs->pp, (rs->q & UPPER_BIT_RUBIN) ? 1 : 0, 0); |
45 | if (ret) | 44 | if (ret) |
46 | return ret; | 45 | return ret; |
@@ -68,7 +67,7 @@ static int encode(struct rubin_state *rs, long A, long B, int symbol) | |||
68 | 67 | ||
69 | 68 | ||
70 | static void end_rubin(struct rubin_state *rs) | 69 | static void end_rubin(struct rubin_state *rs) |
71 | { | 70 | { |
72 | 71 | ||
73 | int i; | 72 | int i; |
74 | 73 | ||
@@ -82,7 +81,7 @@ static void end_rubin(struct rubin_state *rs) | |||
82 | 81 | ||
83 | static void init_decode(struct rubin_state *rs, int div, int *bits) | 82 | static void init_decode(struct rubin_state *rs, int div, int *bits) |
84 | { | 83 | { |
85 | init_rubin(rs, div, bits); | 84 | init_rubin(rs, div, bits); |
86 | 85 | ||
87 | /* behalve lower */ | 86 | /* behalve lower */ |
88 | rs->rec_q = 0; | 87 | rs->rec_q = 0; |
@@ -188,7 +187,7 @@ static int in_byte(struct rubin_state *rs) | |||
188 | 187 | ||
189 | 188 | ||
190 | 189 | ||
191 | static int rubin_do_compress(int bit_divider, int *bits, unsigned char *data_in, | 190 | static int rubin_do_compress(int bit_divider, int *bits, unsigned char *data_in, |
192 | unsigned char *cpage_out, uint32_t *sourcelen, uint32_t *dstlen) | 191 | unsigned char *cpage_out, uint32_t *sourcelen, uint32_t *dstlen) |
193 | { | 192 | { |
194 | int outpos = 0; | 193 | int outpos = 0; |
@@ -198,31 +197,31 @@ static int rubin_do_compress(int bit_divider, int *bits, unsigned char *data_in, | |||
198 | init_pushpull(&rs.pp, cpage_out, *dstlen * 8, 0, 32); | 197 | init_pushpull(&rs.pp, cpage_out, *dstlen * 8, 0, 32); |
199 | 198 | ||
200 | init_rubin(&rs, bit_divider, bits); | 199 | init_rubin(&rs, bit_divider, bits); |
201 | 200 | ||
202 | while (pos < (*sourcelen) && !out_byte(&rs, data_in[pos])) | 201 | while (pos < (*sourcelen) && !out_byte(&rs, data_in[pos])) |
203 | pos++; | 202 | pos++; |
204 | 203 | ||
205 | end_rubin(&rs); | 204 | end_rubin(&rs); |
206 | 205 | ||
207 | if (outpos > pos) { | 206 | if (outpos > pos) { |
208 | /* We failed */ | 207 | /* We failed */ |
209 | return -1; | 208 | return -1; |
210 | } | 209 | } |
211 | 210 | ||
212 | /* Tell the caller how much we managed to compress, | 211 | /* Tell the caller how much we managed to compress, |
213 | * and how much space it took */ | 212 | * and how much space it took */ |
214 | 213 | ||
215 | outpos = (pushedbits(&rs.pp)+7)/8; | 214 | outpos = (pushedbits(&rs.pp)+7)/8; |
216 | 215 | ||
217 | if (outpos >= pos) | 216 | if (outpos >= pos) |
218 | return -1; /* We didn't actually compress */ | 217 | return -1; /* We didn't actually compress */ |
219 | *sourcelen = pos; | 218 | *sourcelen = pos; |
220 | *dstlen = outpos; | 219 | *dstlen = outpos; |
221 | return 0; | 220 | return 0; |
222 | } | 221 | } |
223 | #if 0 | 222 | #if 0 |
224 | /* _compress returns the compressed size, -1 if bigger */ | 223 | /* _compress returns the compressed size, -1 if bigger */ |
225 | int jffs2_rubinmips_compress(unsigned char *data_in, unsigned char *cpage_out, | 224 | int jffs2_rubinmips_compress(unsigned char *data_in, unsigned char *cpage_out, |
226 | uint32_t *sourcelen, uint32_t *dstlen, void *model) | 225 | uint32_t *sourcelen, uint32_t *dstlen, void *model) |
227 | { | 226 | { |
228 | return rubin_do_compress(BIT_DIVIDER_MIPS, bits_mips, data_in, cpage_out, sourcelen, dstlen); | 227 | return rubin_do_compress(BIT_DIVIDER_MIPS, bits_mips, data_in, cpage_out, sourcelen, dstlen); |
@@ -277,7 +276,7 @@ static int jffs2_dynrubin_compress(unsigned char *data_in, | |||
277 | } | 276 | } |
278 | 277 | ||
279 | ret = rubin_do_compress(256, bits, data_in, cpage_out+8, &mysrclen, &mydstlen); | 278 | ret = rubin_do_compress(256, bits, data_in, cpage_out+8, &mysrclen, &mydstlen); |
280 | if (ret) | 279 | if (ret) |
281 | return ret; | 280 | return ret; |
282 | 281 | ||
283 | /* Add back the 8 bytes we took for the probabilities */ | 282 | /* Add back the 8 bytes we took for the probabilities */ |
@@ -293,19 +292,19 @@ static int jffs2_dynrubin_compress(unsigned char *data_in, | |||
293 | return 0; | 292 | return 0; |
294 | } | 293 | } |
295 | 294 | ||
296 | static void rubin_do_decompress(int bit_divider, int *bits, unsigned char *cdata_in, | 295 | static void rubin_do_decompress(int bit_divider, int *bits, unsigned char *cdata_in, |
297 | unsigned char *page_out, uint32_t srclen, uint32_t destlen) | 296 | unsigned char *page_out, uint32_t srclen, uint32_t destlen) |
298 | { | 297 | { |
299 | int outpos = 0; | 298 | int outpos = 0; |
300 | struct rubin_state rs; | 299 | struct rubin_state rs; |
301 | 300 | ||
302 | init_pushpull(&rs.pp, cdata_in, srclen, 0, 0); | 301 | init_pushpull(&rs.pp, cdata_in, srclen, 0, 0); |
303 | init_decode(&rs, bit_divider, bits); | 302 | init_decode(&rs, bit_divider, bits); |
304 | 303 | ||
305 | while (outpos < destlen) { | 304 | while (outpos < destlen) { |
306 | page_out[outpos++] = in_byte(&rs); | 305 | page_out[outpos++] = in_byte(&rs); |
307 | } | 306 | } |
308 | } | 307 | } |
309 | 308 | ||
310 | 309 | ||
311 | static int jffs2_rubinmips_decompress(unsigned char *data_in, | 310 | static int jffs2_rubinmips_decompress(unsigned char *data_in, |
diff --git a/fs/jffs2/compr_rubin.h b/fs/jffs2/compr_rubin.h index cf51e34f6574..bf1a93451621 100644 --- a/fs/jffs2/compr_rubin.h +++ b/fs/jffs2/compr_rubin.h | |||
@@ -1,7 +1,7 @@ | |||
1 | /* Rubin encoder/decoder header */ | 1 | /* Rubin encoder/decoder header */ |
2 | /* work started at : aug 3, 1994 */ | 2 | /* work started at : aug 3, 1994 */ |
3 | /* last modification : aug 15, 1994 */ | 3 | /* last modification : aug 15, 1994 */ |
4 | /* $Id: compr_rubin.h,v 1.6 2002/01/25 01:49:26 dwmw2 Exp $ */ | 4 | /* $Id: compr_rubin.h,v 1.7 2005/11/07 11:14:38 gleixner Exp $ */ |
5 | 5 | ||
6 | #include "pushpull.h" | 6 | #include "pushpull.h" |
7 | 7 | ||
@@ -11,8 +11,8 @@ | |||
11 | 11 | ||
12 | 12 | ||
13 | struct rubin_state { | 13 | struct rubin_state { |
14 | unsigned long p; | 14 | unsigned long p; |
15 | unsigned long q; | 15 | unsigned long q; |
16 | unsigned long rec_q; | 16 | unsigned long rec_q; |
17 | long bit_number; | 17 | long bit_number; |
18 | struct pushpull pp; | 18 | struct pushpull pp; |
diff --git a/fs/jffs2/compr_zlib.c b/fs/jffs2/compr_zlib.c index 83f7e0788fd0..4db8be8e90cc 100644 --- a/fs/jffs2/compr_zlib.c +++ b/fs/jffs2/compr_zlib.c | |||
@@ -7,7 +7,7 @@ | |||
7 | * | 7 | * |
8 | * For licensing information, see the file 'LICENCE' in this directory. | 8 | * For licensing information, see the file 'LICENCE' in this directory. |
9 | * | 9 | * |
10 | * $Id: compr_zlib.c,v 1.31 2005/05/20 19:30:06 gleixner Exp $ | 10 | * $Id: compr_zlib.c,v 1.32 2005/11/07 11:14:38 gleixner Exp $ |
11 | * | 11 | * |
12 | */ | 12 | */ |
13 | 13 | ||
@@ -24,11 +24,11 @@ | |||
24 | #include "nodelist.h" | 24 | #include "nodelist.h" |
25 | #include "compr.h" | 25 | #include "compr.h" |
26 | 26 | ||
27 | /* Plan: call deflate() with avail_in == *sourcelen, | 27 | /* Plan: call deflate() with avail_in == *sourcelen, |
28 | avail_out = *dstlen - 12 and flush == Z_FINISH. | 28 | avail_out = *dstlen - 12 and flush == Z_FINISH. |
29 | If it doesn't manage to finish, call it again with | 29 | If it doesn't manage to finish, call it again with |
30 | avail_in == 0 and avail_out set to the remaining 12 | 30 | avail_in == 0 and avail_out set to the remaining 12 |
31 | bytes for it to clean up. | 31 | bytes for it to clean up. |
32 | Q: Is 12 bytes sufficient? | 32 | Q: Is 12 bytes sufficient? |
33 | */ | 33 | */ |
34 | #define STREAM_END_SPACE 12 | 34 | #define STREAM_END_SPACE 12 |
@@ -89,7 +89,7 @@ static int jffs2_zlib_compress(unsigned char *data_in, | |||
89 | 89 | ||
90 | def_strm.next_in = data_in; | 90 | def_strm.next_in = data_in; |
91 | def_strm.total_in = 0; | 91 | def_strm.total_in = 0; |
92 | 92 | ||
93 | def_strm.next_out = cpage_out; | 93 | def_strm.next_out = cpage_out; |
94 | def_strm.total_out = 0; | 94 | def_strm.total_out = 0; |
95 | 95 | ||
@@ -99,7 +99,7 @@ static int jffs2_zlib_compress(unsigned char *data_in, | |||
99 | D1(printk(KERN_DEBUG "calling deflate with avail_in %d, avail_out %d\n", | 99 | D1(printk(KERN_DEBUG "calling deflate with avail_in %d, avail_out %d\n", |
100 | def_strm.avail_in, def_strm.avail_out)); | 100 | def_strm.avail_in, def_strm.avail_out)); |
101 | ret = zlib_deflate(&def_strm, Z_PARTIAL_FLUSH); | 101 | ret = zlib_deflate(&def_strm, Z_PARTIAL_FLUSH); |
102 | D1(printk(KERN_DEBUG "deflate returned with avail_in %d, avail_out %d, total_in %ld, total_out %ld\n", | 102 | D1(printk(KERN_DEBUG "deflate returned with avail_in %d, avail_out %d, total_in %ld, total_out %ld\n", |
103 | def_strm.avail_in, def_strm.avail_out, def_strm.total_in, def_strm.total_out)); | 103 | def_strm.avail_in, def_strm.avail_out, def_strm.total_in, def_strm.total_out)); |
104 | if (ret != Z_OK) { | 104 | if (ret != Z_OK) { |
105 | D1(printk(KERN_DEBUG "deflate in loop returned %d\n", ret)); | 105 | D1(printk(KERN_DEBUG "deflate in loop returned %d\n", ret)); |
@@ -150,7 +150,7 @@ static int jffs2_zlib_decompress(unsigned char *data_in, | |||
150 | inf_strm.next_in = data_in; | 150 | inf_strm.next_in = data_in; |
151 | inf_strm.avail_in = srclen; | 151 | inf_strm.avail_in = srclen; |
152 | inf_strm.total_in = 0; | 152 | inf_strm.total_in = 0; |
153 | 153 | ||
154 | inf_strm.next_out = cpage_out; | 154 | inf_strm.next_out = cpage_out; |
155 | inf_strm.avail_out = destlen; | 155 | inf_strm.avail_out = destlen; |
156 | inf_strm.total_out = 0; | 156 | inf_strm.total_out = 0; |
diff --git a/fs/jffs2/comprtest.c b/fs/jffs2/comprtest.c index cf51f091d0e7..f0fb8be7740c 100644 --- a/fs/jffs2/comprtest.c +++ b/fs/jffs2/comprtest.c | |||
@@ -1,4 +1,4 @@ | |||
1 | /* $Id: comprtest.c,v 1.5 2002/01/03 15:20:44 dwmw2 Exp $ */ | 1 | /* $Id: comprtest.c,v 1.6 2005/11/07 11:14:38 gleixner Exp $ */ |
2 | 2 | ||
3 | #include <linux/kernel.h> | 3 | #include <linux/kernel.h> |
4 | #include <linux/string.h> | 4 | #include <linux/string.h> |
@@ -265,9 +265,9 @@ static unsigned char testdata[TESTDATA_LEN] = { | |||
265 | static unsigned char comprbuf[TESTDATA_LEN]; | 265 | static unsigned char comprbuf[TESTDATA_LEN]; |
266 | static unsigned char decomprbuf[TESTDATA_LEN]; | 266 | static unsigned char decomprbuf[TESTDATA_LEN]; |
267 | 267 | ||
268 | int jffs2_decompress(unsigned char comprtype, unsigned char *cdata_in, | 268 | int jffs2_decompress(unsigned char comprtype, unsigned char *cdata_in, |
269 | unsigned char *data_out, uint32_t cdatalen, uint32_t datalen); | 269 | unsigned char *data_out, uint32_t cdatalen, uint32_t datalen); |
270 | unsigned char jffs2_compress(unsigned char *data_in, unsigned char *cpage_out, | 270 | unsigned char jffs2_compress(unsigned char *data_in, unsigned char *cpage_out, |
271 | uint32_t *datalen, uint32_t *cdatalen); | 271 | uint32_t *datalen, uint32_t *cdatalen); |
272 | 272 | ||
273 | int init_module(void ) { | 273 | int init_module(void ) { |
@@ -276,10 +276,10 @@ int init_module(void ) { | |||
276 | int ret; | 276 | int ret; |
277 | 277 | ||
278 | printk("Original data: %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x\n", | 278 | printk("Original data: %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x\n", |
279 | testdata[0],testdata[1],testdata[2],testdata[3], | 279 | testdata[0],testdata[1],testdata[2],testdata[3], |
280 | testdata[4],testdata[5],testdata[6],testdata[7], | 280 | testdata[4],testdata[5],testdata[6],testdata[7], |
281 | testdata[8],testdata[9],testdata[10],testdata[11], | 281 | testdata[8],testdata[9],testdata[10],testdata[11], |
282 | testdata[12],testdata[13],testdata[14],testdata[15]); | 282 | testdata[12],testdata[13],testdata[14],testdata[15]); |
283 | d = TESTDATA_LEN; | 283 | d = TESTDATA_LEN; |
284 | c = TESTDATA_LEN; | 284 | c = TESTDATA_LEN; |
285 | comprtype = jffs2_compress(testdata, comprbuf, &d, &c); | 285 | comprtype = jffs2_compress(testdata, comprbuf, &d, &c); |
@@ -287,18 +287,18 @@ int init_module(void ) { | |||
287 | printk("jffs2_compress used compression type %d. Compressed size %d, uncompressed size %d\n", | 287 | printk("jffs2_compress used compression type %d. Compressed size %d, uncompressed size %d\n", |
288 | comprtype, c, d); | 288 | comprtype, c, d); |
289 | printk("Compressed data: %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x\n", | 289 | printk("Compressed data: %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x\n", |
290 | comprbuf[0],comprbuf[1],comprbuf[2],comprbuf[3], | 290 | comprbuf[0],comprbuf[1],comprbuf[2],comprbuf[3], |
291 | comprbuf[4],comprbuf[5],comprbuf[6],comprbuf[7], | 291 | comprbuf[4],comprbuf[5],comprbuf[6],comprbuf[7], |
292 | comprbuf[8],comprbuf[9],comprbuf[10],comprbuf[11], | 292 | comprbuf[8],comprbuf[9],comprbuf[10],comprbuf[11], |
293 | comprbuf[12],comprbuf[13],comprbuf[14],comprbuf[15]); | 293 | comprbuf[12],comprbuf[13],comprbuf[14],comprbuf[15]); |
294 | 294 | ||
295 | ret = jffs2_decompress(comprtype, comprbuf, decomprbuf, c, d); | 295 | ret = jffs2_decompress(comprtype, comprbuf, decomprbuf, c, d); |
296 | printk("jffs2_decompress returned %d\n", ret); | 296 | printk("jffs2_decompress returned %d\n", ret); |
297 | printk("Decompressed data: %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x\n", | 297 | printk("Decompressed data: %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x\n", |
298 | decomprbuf[0],decomprbuf[1],decomprbuf[2],decomprbuf[3], | 298 | decomprbuf[0],decomprbuf[1],decomprbuf[2],decomprbuf[3], |
299 | decomprbuf[4],decomprbuf[5],decomprbuf[6],decomprbuf[7], | 299 | decomprbuf[4],decomprbuf[5],decomprbuf[6],decomprbuf[7], |
300 | decomprbuf[8],decomprbuf[9],decomprbuf[10],decomprbuf[11], | 300 | decomprbuf[8],decomprbuf[9],decomprbuf[10],decomprbuf[11], |
301 | decomprbuf[12],decomprbuf[13],decomprbuf[14],decomprbuf[15]); | 301 | decomprbuf[12],decomprbuf[13],decomprbuf[14],decomprbuf[15]); |
302 | if (memcmp(decomprbuf, testdata, d)) | 302 | if (memcmp(decomprbuf, testdata, d)) |
303 | printk("Compression and decompression corrupted data\n"); | 303 | printk("Compression and decompression corrupted data\n"); |
304 | else | 304 | else |
diff --git a/fs/jffs2/debug.c b/fs/jffs2/debug.c new file mode 100644 index 000000000000..1fe17de713e8 --- /dev/null +++ b/fs/jffs2/debug.c | |||
@@ -0,0 +1,705 @@ | |||
1 | /* | ||
2 | * JFFS2 -- Journalling Flash File System, Version 2. | ||
3 | * | ||
4 | * Copyright (C) 2001-2003 Red Hat, Inc. | ||
5 | * | ||
6 | * Created by David Woodhouse <dwmw2@infradead.org> | ||
7 | * | ||
8 | * For licensing information, see the file 'LICENCE' in this directory. | ||
9 | * | ||
10 | * $Id: debug.c,v 1.12 2005/11/07 11:14:39 gleixner Exp $ | ||
11 | * | ||
12 | */ | ||
13 | #include <linux/kernel.h> | ||
14 | #include <linux/types.h> | ||
15 | #include <linux/pagemap.h> | ||
16 | #include <linux/crc32.h> | ||
17 | #include <linux/jffs2.h> | ||
18 | #include <linux/mtd/mtd.h> | ||
19 | #include "nodelist.h" | ||
20 | #include "debug.h" | ||
21 | |||
22 | #ifdef JFFS2_DBG_SANITY_CHECKS | ||
23 | |||
24 | void | ||
25 | __jffs2_dbg_acct_sanity_check_nolock(struct jffs2_sb_info *c, | ||
26 | struct jffs2_eraseblock *jeb) | ||
27 | { | ||
28 | if (unlikely(jeb && jeb->used_size + jeb->dirty_size + | ||
29 | jeb->free_size + jeb->wasted_size + | ||
30 | jeb->unchecked_size != c->sector_size)) { | ||
31 | JFFS2_ERROR("eeep, space accounting for block at 0x%08x is screwed.\n", jeb->offset); | ||
32 | JFFS2_ERROR("free %#08x + dirty %#08x + used %#08x + wasted %#08x + unchecked %#08x != total %#08x.\n", | ||
33 | jeb->free_size, jeb->dirty_size, jeb->used_size, | ||
34 | jeb->wasted_size, jeb->unchecked_size, c->sector_size); | ||
35 | BUG(); | ||
36 | } | ||
37 | |||
38 | if (unlikely(c->used_size + c->dirty_size + c->free_size + c->erasing_size + c->bad_size | ||
39 | + c->wasted_size + c->unchecked_size != c->flash_size)) { | ||
40 | JFFS2_ERROR("eeep, space accounting superblock info is screwed.\n"); | ||
41 | JFFS2_ERROR("free %#08x + dirty %#08x + used %#08x + erasing %#08x + bad %#08x + wasted %#08x + unchecked %#08x != total %#08x.\n", | ||
42 | c->free_size, c->dirty_size, c->used_size, c->erasing_size, c->bad_size, | ||
43 | c->wasted_size, c->unchecked_size, c->flash_size); | ||
44 | BUG(); | ||
45 | } | ||
46 | } | ||
47 | |||
48 | void | ||
49 | __jffs2_dbg_acct_sanity_check(struct jffs2_sb_info *c, | ||
50 | struct jffs2_eraseblock *jeb) | ||
51 | { | ||
52 | spin_lock(&c->erase_completion_lock); | ||
53 | jffs2_dbg_acct_sanity_check_nolock(c, jeb); | ||
54 | spin_unlock(&c->erase_completion_lock); | ||
55 | } | ||
56 | |||
57 | #endif /* JFFS2_DBG_SANITY_CHECKS */ | ||
58 | |||
59 | #ifdef JFFS2_DBG_PARANOIA_CHECKS | ||
60 | /* | ||
61 | * Check the fragtree. | ||
62 | */ | ||
63 | void | ||
64 | __jffs2_dbg_fragtree_paranoia_check(struct jffs2_inode_info *f) | ||
65 | { | ||
66 | down(&f->sem); | ||
67 | __jffs2_dbg_fragtree_paranoia_check_nolock(f); | ||
68 | up(&f->sem); | ||
69 | } | ||
70 | |||
71 | void | ||
72 | __jffs2_dbg_fragtree_paranoia_check_nolock(struct jffs2_inode_info *f) | ||
73 | { | ||
74 | struct jffs2_node_frag *frag; | ||
75 | int bitched = 0; | ||
76 | |||
77 | for (frag = frag_first(&f->fragtree); frag; frag = frag_next(frag)) { | ||
78 | struct jffs2_full_dnode *fn = frag->node; | ||
79 | |||
80 | if (!fn || !fn->raw) | ||
81 | continue; | ||
82 | |||
83 | if (ref_flags(fn->raw) == REF_PRISTINE) { | ||
84 | if (fn->frags > 1) { | ||
85 | JFFS2_ERROR("REF_PRISTINE node at 0x%08x had %d frags. Tell dwmw2.\n", | ||
86 | ref_offset(fn->raw), fn->frags); | ||
87 | bitched = 1; | ||
88 | } | ||
89 | |||
90 | /* A hole node which isn't multi-page should be garbage-collected | ||
91 | and merged anyway, so we just check for the frag size here, | ||
92 | rather than mucking around with actually reading the node | ||
93 | and checking the compression type, which is the real way | ||
94 | to tell a hole node. */ | ||
95 | if (frag->ofs & (PAGE_CACHE_SIZE-1) && frag_prev(frag) | ||
96 | && frag_prev(frag)->size < PAGE_CACHE_SIZE && frag_prev(frag)->node) { | ||
97 | JFFS2_ERROR("REF_PRISTINE node at 0x%08x had a previous non-hole frag in the same page. Tell dwmw2.\n", | ||
98 | ref_offset(fn->raw)); | ||
99 | bitched = 1; | ||
100 | } | ||
101 | |||
102 | if ((frag->ofs+frag->size) & (PAGE_CACHE_SIZE-1) && frag_next(frag) | ||
103 | && frag_next(frag)->size < PAGE_CACHE_SIZE && frag_next(frag)->node) { | ||
104 | JFFS2_ERROR("REF_PRISTINE node at 0x%08x (%08x-%08x) had a following non-hole frag in the same page. Tell dwmw2.\n", | ||
105 | ref_offset(fn->raw), frag->ofs, frag->ofs+frag->size); | ||
106 | bitched = 1; | ||
107 | } | ||
108 | } | ||
109 | } | ||
110 | |||
111 | if (bitched) { | ||
112 | JFFS2_ERROR("fragtree is corrupted.\n"); | ||
113 | __jffs2_dbg_dump_fragtree_nolock(f); | ||
114 | BUG(); | ||
115 | } | ||
116 | } | ||
117 | |||
118 | /* | ||
119 | * Check if the flash contains all 0xFF before we start writing. | ||
120 | */ | ||
121 | void | ||
122 | __jffs2_dbg_prewrite_paranoia_check(struct jffs2_sb_info *c, | ||
123 | uint32_t ofs, int len) | ||
124 | { | ||
125 | size_t retlen; | ||
126 | int ret, i; | ||
127 | unsigned char *buf; | ||
128 | |||
129 | buf = kmalloc(len, GFP_KERNEL); | ||
130 | if (!buf) | ||
131 | return; | ||
132 | |||
133 | ret = jffs2_flash_read(c, ofs, len, &retlen, buf); | ||
134 | if (ret || (retlen != len)) { | ||
135 | JFFS2_WARNING("read %d bytes failed or short. ret %d, retlen %zd.\n", | ||
136 | len, ret, retlen); | ||
137 | kfree(buf); | ||
138 | return; | ||
139 | } | ||
140 | |||
141 | ret = 0; | ||
142 | for (i = 0; i < len; i++) | ||
143 | if (buf[i] != 0xff) | ||
144 | ret = 1; | ||
145 | |||
146 | if (ret) { | ||
147 | JFFS2_ERROR("argh, about to write node to %#08x on flash, but there are data already there. The first corrupted byte is at %#08x offset.\n", | ||
148 | ofs, ofs + i); | ||
149 | __jffs2_dbg_dump_buffer(buf, len, ofs); | ||
150 | kfree(buf); | ||
151 | BUG(); | ||
152 | } | ||
153 | |||
154 | kfree(buf); | ||
155 | } | ||
156 | |||
157 | /* | ||
158 | * Check the space accounting and node_ref list correctness for the JFFS2 erasable block 'jeb'. | ||
159 | */ | ||
160 | void | ||
161 | __jffs2_dbg_acct_paranoia_check(struct jffs2_sb_info *c, | ||
162 | struct jffs2_eraseblock *jeb) | ||
163 | { | ||
164 | spin_lock(&c->erase_completion_lock); | ||
165 | __jffs2_dbg_acct_paranoia_check_nolock(c, jeb); | ||
166 | spin_unlock(&c->erase_completion_lock); | ||
167 | } | ||
168 | |||
169 | void | ||
170 | __jffs2_dbg_acct_paranoia_check_nolock(struct jffs2_sb_info *c, | ||
171 | struct jffs2_eraseblock *jeb) | ||
172 | { | ||
173 | uint32_t my_used_size = 0; | ||
174 | uint32_t my_unchecked_size = 0; | ||
175 | uint32_t my_dirty_size = 0; | ||
176 | struct jffs2_raw_node_ref *ref2 = jeb->first_node; | ||
177 | |||
178 | while (ref2) { | ||
179 | uint32_t totlen = ref_totlen(c, jeb, ref2); | ||
180 | |||
181 | if (ref2->flash_offset < jeb->offset || | ||
182 | ref2->flash_offset > jeb->offset + c->sector_size) { | ||
183 | JFFS2_ERROR("node_ref %#08x shouldn't be in block at %#08x.\n", | ||
184 | ref_offset(ref2), jeb->offset); | ||
185 | goto error; | ||
186 | |||
187 | } | ||
188 | if (ref_flags(ref2) == REF_UNCHECKED) | ||
189 | my_unchecked_size += totlen; | ||
190 | else if (!ref_obsolete(ref2)) | ||
191 | my_used_size += totlen; | ||
192 | else | ||
193 | my_dirty_size += totlen; | ||
194 | |||
195 | if ((!ref2->next_phys) != (ref2 == jeb->last_node)) { | ||
196 | JFFS2_ERROR("node_ref for node at %#08x (mem %p) has next_phys at %#08x (mem %p), last_node is at %#08x (mem %p).\n", | ||
197 | ref_offset(ref2), ref2, ref_offset(ref2->next_phys), ref2->next_phys, | ||
198 | ref_offset(jeb->last_node), jeb->last_node); | ||
199 | goto error; | ||
200 | } | ||
201 | ref2 = ref2->next_phys; | ||
202 | } | ||
203 | |||
204 | if (my_used_size != jeb->used_size) { | ||
205 | JFFS2_ERROR("Calculated used size %#08x != stored used size %#08x.\n", | ||
206 | my_used_size, jeb->used_size); | ||
207 | goto error; | ||
208 | } | ||
209 | |||
210 | if (my_unchecked_size != jeb->unchecked_size) { | ||
211 | JFFS2_ERROR("Calculated unchecked size %#08x != stored unchecked size %#08x.\n", | ||
212 | my_unchecked_size, jeb->unchecked_size); | ||
213 | goto error; | ||
214 | } | ||
215 | |||
216 | #if 0 | ||
217 | /* This should work when we implement ref->__totlen elemination */ | ||
218 | if (my_dirty_size != jeb->dirty_size + jeb->wasted_size) { | ||
219 | JFFS2_ERROR("Calculated dirty+wasted size %#08x != stored dirty + wasted size %#08x\n", | ||
220 | my_dirty_size, jeb->dirty_size + jeb->wasted_size); | ||
221 | goto error; | ||
222 | } | ||
223 | |||
224 | if (jeb->free_size == 0 | ||
225 | && my_used_size + my_unchecked_size + my_dirty_size != c->sector_size) { | ||
226 | JFFS2_ERROR("The sum of all nodes in block (%#x) != size of block (%#x)\n", | ||
227 | my_used_size + my_unchecked_size + my_dirty_size, | ||
228 | c->sector_size); | ||
229 | goto error; | ||
230 | } | ||
231 | #endif | ||
232 | |||
233 | return; | ||
234 | |||
235 | error: | ||
236 | __jffs2_dbg_dump_node_refs_nolock(c, jeb); | ||
237 | __jffs2_dbg_dump_jeb_nolock(jeb); | ||
238 | __jffs2_dbg_dump_block_lists_nolock(c); | ||
239 | BUG(); | ||
240 | |||
241 | } | ||
242 | #endif /* JFFS2_DBG_PARANOIA_CHECKS */ | ||
243 | |||
244 | #if defined(JFFS2_DBG_DUMPS) || defined(JFFS2_DBG_PARANOIA_CHECKS) | ||
245 | /* | ||
246 | * Dump the node_refs of the 'jeb' JFFS2 eraseblock. | ||
247 | */ | ||
248 | void | ||
249 | __jffs2_dbg_dump_node_refs(struct jffs2_sb_info *c, | ||
250 | struct jffs2_eraseblock *jeb) | ||
251 | { | ||
252 | spin_lock(&c->erase_completion_lock); | ||
253 | __jffs2_dbg_dump_node_refs_nolock(c, jeb); | ||
254 | spin_unlock(&c->erase_completion_lock); | ||
255 | } | ||
256 | |||
257 | void | ||
258 | __jffs2_dbg_dump_node_refs_nolock(struct jffs2_sb_info *c, | ||
259 | struct jffs2_eraseblock *jeb) | ||
260 | { | ||
261 | struct jffs2_raw_node_ref *ref; | ||
262 | int i = 0; | ||
263 | |||
264 | printk(JFFS2_DBG_MSG_PREFIX " Dump node_refs of the eraseblock %#08x\n", jeb->offset); | ||
265 | if (!jeb->first_node) { | ||
266 | printk(JFFS2_DBG_MSG_PREFIX " no nodes in the eraseblock %#08x\n", jeb->offset); | ||
267 | return; | ||
268 | } | ||
269 | |||
270 | printk(JFFS2_DBG); | ||
271 | for (ref = jeb->first_node; ; ref = ref->next_phys) { | ||
272 | printk("%#08x(%#x)", ref_offset(ref), ref->__totlen); | ||
273 | if (ref->next_phys) | ||
274 | printk("->"); | ||
275 | else | ||
276 | break; | ||
277 | if (++i == 4) { | ||
278 | i = 0; | ||
279 | printk("\n" JFFS2_DBG); | ||
280 | } | ||
281 | } | ||
282 | printk("\n"); | ||
283 | } | ||
284 | |||
285 | /* | ||
286 | * Dump an eraseblock's space accounting. | ||
287 | */ | ||
288 | void | ||
289 | __jffs2_dbg_dump_jeb(struct jffs2_sb_info *c, struct jffs2_eraseblock *jeb) | ||
290 | { | ||
291 | spin_lock(&c->erase_completion_lock); | ||
292 | __jffs2_dbg_dump_jeb_nolock(jeb); | ||
293 | spin_unlock(&c->erase_completion_lock); | ||
294 | } | ||
295 | |||
296 | void | ||
297 | __jffs2_dbg_dump_jeb_nolock(struct jffs2_eraseblock *jeb) | ||
298 | { | ||
299 | if (!jeb) | ||
300 | return; | ||
301 | |||
302 | printk(JFFS2_DBG_MSG_PREFIX " dump space accounting for the eraseblock at %#08x:\n", | ||
303 | jeb->offset); | ||
304 | |||
305 | printk(JFFS2_DBG "used_size: %#08x\n", jeb->used_size); | ||
306 | printk(JFFS2_DBG "dirty_size: %#08x\n", jeb->dirty_size); | ||
307 | printk(JFFS2_DBG "wasted_size: %#08x\n", jeb->wasted_size); | ||
308 | printk(JFFS2_DBG "unchecked_size: %#08x\n", jeb->unchecked_size); | ||
309 | printk(JFFS2_DBG "free_size: %#08x\n", jeb->free_size); | ||
310 | } | ||
311 | |||
312 | void | ||
313 | __jffs2_dbg_dump_block_lists(struct jffs2_sb_info *c) | ||
314 | { | ||
315 | spin_lock(&c->erase_completion_lock); | ||
316 | __jffs2_dbg_dump_block_lists_nolock(c); | ||
317 | spin_unlock(&c->erase_completion_lock); | ||
318 | } | ||
319 | |||
320 | void | ||
321 | __jffs2_dbg_dump_block_lists_nolock(struct jffs2_sb_info *c) | ||
322 | { | ||
323 | printk(JFFS2_DBG_MSG_PREFIX " dump JFFS2 blocks lists:\n"); | ||
324 | |||
325 | printk(JFFS2_DBG "flash_size: %#08x\n", c->flash_size); | ||
326 | printk(JFFS2_DBG "used_size: %#08x\n", c->used_size); | ||
327 | printk(JFFS2_DBG "dirty_size: %#08x\n", c->dirty_size); | ||
328 | printk(JFFS2_DBG "wasted_size: %#08x\n", c->wasted_size); | ||
329 | printk(JFFS2_DBG "unchecked_size: %#08x\n", c->unchecked_size); | ||
330 | printk(JFFS2_DBG "free_size: %#08x\n", c->free_size); | ||
331 | printk(JFFS2_DBG "erasing_size: %#08x\n", c->erasing_size); | ||
332 | printk(JFFS2_DBG "bad_size: %#08x\n", c->bad_size); | ||
333 | printk(JFFS2_DBG "sector_size: %#08x\n", c->sector_size); | ||
334 | printk(JFFS2_DBG "jffs2_reserved_blocks size: %#08x\n", | ||
335 | c->sector_size * c->resv_blocks_write); | ||
336 | |||
337 | if (c->nextblock) | ||
338 | printk(JFFS2_DBG "nextblock: %#08x (used %#08x, dirty %#08x, wasted %#08x, unchecked %#08x, free %#08x)\n", | ||
339 | c->nextblock->offset, c->nextblock->used_size, | ||
340 | c->nextblock->dirty_size, c->nextblock->wasted_size, | ||
341 | c->nextblock->unchecked_size, c->nextblock->free_size); | ||
342 | else | ||
343 | printk(JFFS2_DBG "nextblock: NULL\n"); | ||
344 | |||
345 | if (c->gcblock) | ||
346 | printk(JFFS2_DBG "gcblock: %#08x (used %#08x, dirty %#08x, wasted %#08x, unchecked %#08x, free %#08x)\n", | ||
347 | c->gcblock->offset, c->gcblock->used_size, c->gcblock->dirty_size, | ||
348 | c->gcblock->wasted_size, c->gcblock->unchecked_size, c->gcblock->free_size); | ||
349 | else | ||
350 | printk(JFFS2_DBG "gcblock: NULL\n"); | ||
351 | |||
352 | if (list_empty(&c->clean_list)) { | ||
353 | printk(JFFS2_DBG "clean_list: empty\n"); | ||
354 | } else { | ||
355 | struct list_head *this; | ||
356 | int numblocks = 0; | ||
357 | uint32_t dirty = 0; | ||
358 | |||
359 | list_for_each(this, &c->clean_list) { | ||
360 | struct jffs2_eraseblock *jeb = list_entry(this, struct jffs2_eraseblock, list); | ||
361 | numblocks ++; | ||
362 | dirty += jeb->wasted_size; | ||
363 | if (!(jeb->used_size == 0 && jeb->dirty_size == 0 && jeb->wasted_size == 0)) { | ||
364 | printk(JFFS2_DBG "clean_list: %#08x (used %#08x, dirty %#08x, wasted %#08x, unchecked %#08x, free %#08x)\n", | ||
365 | jeb->offset, jeb->used_size, jeb->dirty_size, jeb->wasted_size, | ||
366 | jeb->unchecked_size, jeb->free_size); | ||
367 | } | ||
368 | } | ||
369 | |||
370 | printk (JFFS2_DBG "Contains %d blocks with total wasted size %u, average wasted size: %u\n", | ||
371 | numblocks, dirty, dirty / numblocks); | ||
372 | } | ||
373 | |||
374 | if (list_empty(&c->very_dirty_list)) { | ||
375 | printk(JFFS2_DBG "very_dirty_list: empty\n"); | ||
376 | } else { | ||
377 | struct list_head *this; | ||
378 | int numblocks = 0; | ||
379 | uint32_t dirty = 0; | ||
380 | |||
381 | list_for_each(this, &c->very_dirty_list) { | ||
382 | struct jffs2_eraseblock *jeb = list_entry(this, struct jffs2_eraseblock, list); | ||
383 | |||
384 | numblocks ++; | ||
385 | dirty += jeb->dirty_size; | ||
386 | if (!(jeb->used_size == 0 && jeb->dirty_size == 0 && jeb->wasted_size == 0)) { | ||
387 | printk(JFFS2_DBG "very_dirty_list: %#08x (used %#08x, dirty %#08x, wasted %#08x, unchecked %#08x, free %#08x)\n", | ||
388 | jeb->offset, jeb->used_size, jeb->dirty_size, jeb->wasted_size, | ||
389 | jeb->unchecked_size, jeb->free_size); | ||
390 | } | ||
391 | } | ||
392 | |||
393 | printk (JFFS2_DBG "Contains %d blocks with total dirty size %u, average dirty size: %u\n", | ||
394 | numblocks, dirty, dirty / numblocks); | ||
395 | } | ||
396 | |||
397 | if (list_empty(&c->dirty_list)) { | ||
398 | printk(JFFS2_DBG "dirty_list: empty\n"); | ||
399 | } else { | ||
400 | struct list_head *this; | ||
401 | int numblocks = 0; | ||
402 | uint32_t dirty = 0; | ||
403 | |||
404 | list_for_each(this, &c->dirty_list) { | ||
405 | struct jffs2_eraseblock *jeb = list_entry(this, struct jffs2_eraseblock, list); | ||
406 | |||
407 | numblocks ++; | ||
408 | dirty += jeb->dirty_size; | ||
409 | if (!(jeb->used_size == 0 && jeb->dirty_size == 0 && jeb->wasted_size == 0)) { | ||
410 | printk(JFFS2_DBG "dirty_list: %#08x (used %#08x, dirty %#08x, wasted %#08x, unchecked %#08x, free %#08x)\n", | ||
411 | jeb->offset, jeb->used_size, jeb->dirty_size, jeb->wasted_size, | ||
412 | jeb->unchecked_size, jeb->free_size); | ||
413 | } | ||
414 | } | ||
415 | |||
416 | printk (JFFS2_DBG "contains %d blocks with total dirty size %u, average dirty size: %u\n", | ||
417 | numblocks, dirty, dirty / numblocks); | ||
418 | } | ||
419 | |||
420 | if (list_empty(&c->erasable_list)) { | ||
421 | printk(JFFS2_DBG "erasable_list: empty\n"); | ||
422 | } else { | ||
423 | struct list_head *this; | ||
424 | |||
425 | list_for_each(this, &c->erasable_list) { | ||
426 | struct jffs2_eraseblock *jeb = list_entry(this, struct jffs2_eraseblock, list); | ||
427 | |||
428 | if (!(jeb->used_size == 0 && jeb->dirty_size == 0 && jeb->wasted_size == 0)) { | ||
429 | printk(JFFS2_DBG "erasable_list: %#08x (used %#08x, dirty %#08x, wasted %#08x, unchecked %#08x, free %#08x)\n", | ||
430 | jeb->offset, jeb->used_size, jeb->dirty_size, jeb->wasted_size, | ||
431 | jeb->unchecked_size, jeb->free_size); | ||
432 | } | ||
433 | } | ||
434 | } | ||
435 | |||
436 | if (list_empty(&c->erasing_list)) { | ||
437 | printk(JFFS2_DBG "erasing_list: empty\n"); | ||
438 | } else { | ||
439 | struct list_head *this; | ||
440 | |||
441 | list_for_each(this, &c->erasing_list) { | ||
442 | struct jffs2_eraseblock *jeb = list_entry(this, struct jffs2_eraseblock, list); | ||
443 | |||
444 | if (!(jeb->used_size == 0 && jeb->dirty_size == 0 && jeb->wasted_size == 0)) { | ||
445 | printk(JFFS2_DBG "erasing_list: %#08x (used %#08x, dirty %#08x, wasted %#08x, unchecked %#08x, free %#08x)\n", | ||
446 | jeb->offset, jeb->used_size, jeb->dirty_size, jeb->wasted_size, | ||
447 | jeb->unchecked_size, jeb->free_size); | ||
448 | } | ||
449 | } | ||
450 | } | ||
451 | |||
452 | if (list_empty(&c->erase_pending_list)) { | ||
453 | printk(JFFS2_DBG "erase_pending_list: empty\n"); | ||
454 | } else { | ||
455 | struct list_head *this; | ||
456 | |||
457 | list_for_each(this, &c->erase_pending_list) { | ||
458 | struct jffs2_eraseblock *jeb = list_entry(this, struct jffs2_eraseblock, list); | ||
459 | |||
460 | if (!(jeb->used_size == 0 && jeb->dirty_size == 0 && jeb->wasted_size == 0)) { | ||
461 | printk(JFFS2_DBG "erase_pending_list: %#08x (used %#08x, dirty %#08x, wasted %#08x, unchecked %#08x, free %#08x)\n", | ||
462 | jeb->offset, jeb->used_size, jeb->dirty_size, jeb->wasted_size, | ||
463 | jeb->unchecked_size, jeb->free_size); | ||
464 | } | ||
465 | } | ||
466 | } | ||
467 | |||
468 | if (list_empty(&c->erasable_pending_wbuf_list)) { | ||
469 | printk(JFFS2_DBG "erasable_pending_wbuf_list: empty\n"); | ||
470 | } else { | ||
471 | struct list_head *this; | ||
472 | |||
473 | list_for_each(this, &c->erasable_pending_wbuf_list) { | ||
474 | struct jffs2_eraseblock *jeb = list_entry(this, struct jffs2_eraseblock, list); | ||
475 | |||
476 | if (!(jeb->used_size == 0 && jeb->dirty_size == 0 && jeb->wasted_size == 0)) { | ||
477 | printk(JFFS2_DBG "erasable_pending_wbuf_list: %#08x (used %#08x, dirty %#08x, wasted %#08x, unchecked %#08x, free %#08x)\n", | ||
478 | jeb->offset, jeb->used_size, jeb->dirty_size, jeb->wasted_size, | ||
479 | jeb->unchecked_size, jeb->free_size); | ||
480 | } | ||
481 | } | ||
482 | } | ||
483 | |||
484 | if (list_empty(&c->free_list)) { | ||
485 | printk(JFFS2_DBG "free_list: empty\n"); | ||
486 | } else { | ||
487 | struct list_head *this; | ||
488 | |||
489 | list_for_each(this, &c->free_list) { | ||
490 | struct jffs2_eraseblock *jeb = list_entry(this, struct jffs2_eraseblock, list); | ||
491 | |||
492 | if (!(jeb->used_size == 0 && jeb->dirty_size == 0 && jeb->wasted_size == 0)) { | ||
493 | printk(JFFS2_DBG "free_list: %#08x (used %#08x, dirty %#08x, wasted %#08x, unchecked %#08x, free %#08x)\n", | ||
494 | jeb->offset, jeb->used_size, jeb->dirty_size, jeb->wasted_size, | ||
495 | jeb->unchecked_size, jeb->free_size); | ||
496 | } | ||
497 | } | ||
498 | } | ||
499 | |||
500 | if (list_empty(&c->bad_list)) { | ||
501 | printk(JFFS2_DBG "bad_list: empty\n"); | ||
502 | } else { | ||
503 | struct list_head *this; | ||
504 | |||
505 | list_for_each(this, &c->bad_list) { | ||
506 | struct jffs2_eraseblock *jeb = list_entry(this, struct jffs2_eraseblock, list); | ||
507 | |||
508 | if (!(jeb->used_size == 0 && jeb->dirty_size == 0 && jeb->wasted_size == 0)) { | ||
509 | printk(JFFS2_DBG "bad_list: %#08x (used %#08x, dirty %#08x, wasted %#08x, unchecked %#08x, free %#08x)\n", | ||
510 | jeb->offset, jeb->used_size, jeb->dirty_size, jeb->wasted_size, | ||
511 | jeb->unchecked_size, jeb->free_size); | ||
512 | } | ||
513 | } | ||
514 | } | ||
515 | |||
516 | if (list_empty(&c->bad_used_list)) { | ||
517 | printk(JFFS2_DBG "bad_used_list: empty\n"); | ||
518 | } else { | ||
519 | struct list_head *this; | ||
520 | |||
521 | list_for_each(this, &c->bad_used_list) { | ||
522 | struct jffs2_eraseblock *jeb = list_entry(this, struct jffs2_eraseblock, list); | ||
523 | |||
524 | if (!(jeb->used_size == 0 && jeb->dirty_size == 0 && jeb->wasted_size == 0)) { | ||
525 | printk(JFFS2_DBG "bad_used_list: %#08x (used %#08x, dirty %#08x, wasted %#08x, unchecked %#08x, free %#08x)\n", | ||
526 | jeb->offset, jeb->used_size, jeb->dirty_size, jeb->wasted_size, | ||
527 | jeb->unchecked_size, jeb->free_size); | ||
528 | } | ||
529 | } | ||
530 | } | ||
531 | } | ||
532 | |||
533 | void | ||
534 | __jffs2_dbg_dump_fragtree(struct jffs2_inode_info *f) | ||
535 | { | ||
536 | down(&f->sem); | ||
537 | jffs2_dbg_dump_fragtree_nolock(f); | ||
538 | up(&f->sem); | ||
539 | } | ||
540 | |||
541 | void | ||
542 | __jffs2_dbg_dump_fragtree_nolock(struct jffs2_inode_info *f) | ||
543 | { | ||
544 | struct jffs2_node_frag *this = frag_first(&f->fragtree); | ||
545 | uint32_t lastofs = 0; | ||
546 | int buggy = 0; | ||
547 | |||
548 | printk(JFFS2_DBG_MSG_PREFIX " dump fragtree of ino #%u\n", f->inocache->ino); | ||
549 | while(this) { | ||
550 | if (this->node) | ||
551 | printk(JFFS2_DBG "frag %#04x-%#04x: %#08x(%d) on flash (*%p), left (%p), right (%p), parent (%p)\n", | ||
552 | this->ofs, this->ofs+this->size, ref_offset(this->node->raw), | ||
553 | ref_flags(this->node->raw), this, frag_left(this), frag_right(this), | ||
554 | frag_parent(this)); | ||
555 | else | ||
556 | printk(JFFS2_DBG "frag %#04x-%#04x: hole (*%p). left (%p), right (%p), parent (%p)\n", | ||
557 | this->ofs, this->ofs+this->size, this, frag_left(this), | ||
558 | frag_right(this), frag_parent(this)); | ||
559 | if (this->ofs != lastofs) | ||
560 | buggy = 1; | ||
561 | lastofs = this->ofs + this->size; | ||
562 | this = frag_next(this); | ||
563 | } | ||
564 | |||
565 | if (f->metadata) | ||
566 | printk(JFFS2_DBG "metadata at 0x%08x\n", ref_offset(f->metadata->raw)); | ||
567 | |||
568 | if (buggy) { | ||
569 | JFFS2_ERROR("frag tree got a hole in it.\n"); | ||
570 | BUG(); | ||
571 | } | ||
572 | } | ||
573 | |||
574 | #define JFFS2_BUFDUMP_BYTES_PER_LINE 32 | ||
575 | void | ||
576 | __jffs2_dbg_dump_buffer(unsigned char *buf, int len, uint32_t offs) | ||
577 | { | ||
578 | int skip; | ||
579 | int i; | ||
580 | |||
581 | printk(JFFS2_DBG_MSG_PREFIX " dump from offset %#08x to offset %#08x (%x bytes).\n", | ||
582 | offs, offs + len, len); | ||
583 | i = skip = offs % JFFS2_BUFDUMP_BYTES_PER_LINE; | ||
584 | offs = offs & ~(JFFS2_BUFDUMP_BYTES_PER_LINE - 1); | ||
585 | |||
586 | if (skip != 0) | ||
587 | printk(JFFS2_DBG "%#08x: ", offs); | ||
588 | |||
589 | while (skip--) | ||
590 | printk(" "); | ||
591 | |||
592 | while (i < len) { | ||
593 | if ((i % JFFS2_BUFDUMP_BYTES_PER_LINE) == 0 && i != len -1) { | ||
594 | if (i != 0) | ||
595 | printk("\n"); | ||
596 | offs += JFFS2_BUFDUMP_BYTES_PER_LINE; | ||
597 | printk(JFFS2_DBG "%0#8x: ", offs); | ||
598 | } | ||
599 | |||
600 | printk("%02x ", buf[i]); | ||
601 | |||
602 | i += 1; | ||
603 | } | ||
604 | |||
605 | printk("\n"); | ||
606 | } | ||
607 | |||
608 | /* | ||
609 | * Dump a JFFS2 node. | ||
610 | */ | ||
611 | void | ||
612 | __jffs2_dbg_dump_node(struct jffs2_sb_info *c, uint32_t ofs) | ||
613 | { | ||
614 | union jffs2_node_union node; | ||
615 | int len = sizeof(union jffs2_node_union); | ||
616 | size_t retlen; | ||
617 | uint32_t crc; | ||
618 | int ret; | ||
619 | |||
620 | printk(JFFS2_DBG_MSG_PREFIX " dump node at offset %#08x.\n", ofs); | ||
621 | |||
622 | ret = jffs2_flash_read(c, ofs, len, &retlen, (unsigned char *)&node); | ||
623 | if (ret || (retlen != len)) { | ||
624 | JFFS2_ERROR("read %d bytes failed or short. ret %d, retlen %zd.\n", | ||
625 | len, ret, retlen); | ||
626 | return; | ||
627 | } | ||
628 | |||
629 | printk(JFFS2_DBG "magic:\t%#04x\n", je16_to_cpu(node.u.magic)); | ||
630 | printk(JFFS2_DBG "nodetype:\t%#04x\n", je16_to_cpu(node.u.nodetype)); | ||
631 | printk(JFFS2_DBG "totlen:\t%#08x\n", je32_to_cpu(node.u.totlen)); | ||
632 | printk(JFFS2_DBG "hdr_crc:\t%#08x\n", je32_to_cpu(node.u.hdr_crc)); | ||
633 | |||
634 | crc = crc32(0, &node.u, sizeof(node.u) - 4); | ||
635 | if (crc != je32_to_cpu(node.u.hdr_crc)) { | ||
636 | JFFS2_ERROR("wrong common header CRC.\n"); | ||
637 | return; | ||
638 | } | ||
639 | |||
640 | if (je16_to_cpu(node.u.magic) != JFFS2_MAGIC_BITMASK && | ||
641 | je16_to_cpu(node.u.magic) != JFFS2_OLD_MAGIC_BITMASK) | ||
642 | { | ||
643 | JFFS2_ERROR("wrong node magic: %#04x instead of %#04x.\n", | ||
644 | je16_to_cpu(node.u.magic), JFFS2_MAGIC_BITMASK); | ||
645 | return; | ||
646 | } | ||
647 | |||
648 | switch(je16_to_cpu(node.u.nodetype)) { | ||
649 | |||
650 | case JFFS2_NODETYPE_INODE: | ||
651 | |||
652 | printk(JFFS2_DBG "the node is inode node\n"); | ||
653 | printk(JFFS2_DBG "ino:\t%#08x\n", je32_to_cpu(node.i.ino)); | ||
654 | printk(JFFS2_DBG "version:\t%#08x\n", je32_to_cpu(node.i.version)); | ||
655 | printk(JFFS2_DBG "mode:\t%#08x\n", node.i.mode.m); | ||
656 | printk(JFFS2_DBG "uid:\t%#04x\n", je16_to_cpu(node.i.uid)); | ||
657 | printk(JFFS2_DBG "gid:\t%#04x\n", je16_to_cpu(node.i.gid)); | ||
658 | printk(JFFS2_DBG "isize:\t%#08x\n", je32_to_cpu(node.i.isize)); | ||
659 | printk(JFFS2_DBG "atime:\t%#08x\n", je32_to_cpu(node.i.atime)); | ||
660 | printk(JFFS2_DBG "mtime:\t%#08x\n", je32_to_cpu(node.i.mtime)); | ||
661 | printk(JFFS2_DBG "ctime:\t%#08x\n", je32_to_cpu(node.i.ctime)); | ||
662 | printk(JFFS2_DBG "offset:\t%#08x\n", je32_to_cpu(node.i.offset)); | ||
663 | printk(JFFS2_DBG "csize:\t%#08x\n", je32_to_cpu(node.i.csize)); | ||
664 | printk(JFFS2_DBG "dsize:\t%#08x\n", je32_to_cpu(node.i.dsize)); | ||
665 | printk(JFFS2_DBG "compr:\t%#02x\n", node.i.compr); | ||
666 | printk(JFFS2_DBG "usercompr:\t%#02x\n", node.i.usercompr); | ||
667 | printk(JFFS2_DBG "flags:\t%#04x\n", je16_to_cpu(node.i.flags)); | ||
668 | printk(JFFS2_DBG "data_crc:\t%#08x\n", je32_to_cpu(node.i.data_crc)); | ||
669 | printk(JFFS2_DBG "node_crc:\t%#08x\n", je32_to_cpu(node.i.node_crc)); | ||
670 | |||
671 | crc = crc32(0, &node.i, sizeof(node.i) - 8); | ||
672 | if (crc != je32_to_cpu(node.i.node_crc)) { | ||
673 | JFFS2_ERROR("wrong node header CRC.\n"); | ||
674 | return; | ||
675 | } | ||
676 | break; | ||
677 | |||
678 | case JFFS2_NODETYPE_DIRENT: | ||
679 | |||
680 | printk(JFFS2_DBG "the node is dirent node\n"); | ||
681 | printk(JFFS2_DBG "pino:\t%#08x\n", je32_to_cpu(node.d.pino)); | ||
682 | printk(JFFS2_DBG "version:\t%#08x\n", je32_to_cpu(node.d.version)); | ||
683 | printk(JFFS2_DBG "ino:\t%#08x\n", je32_to_cpu(node.d.ino)); | ||
684 | printk(JFFS2_DBG "mctime:\t%#08x\n", je32_to_cpu(node.d.mctime)); | ||
685 | printk(JFFS2_DBG "nsize:\t%#02x\n", node.d.nsize); | ||
686 | printk(JFFS2_DBG "type:\t%#02x\n", node.d.type); | ||
687 | printk(JFFS2_DBG "node_crc:\t%#08x\n", je32_to_cpu(node.d.node_crc)); | ||
688 | printk(JFFS2_DBG "name_crc:\t%#08x\n", je32_to_cpu(node.d.name_crc)); | ||
689 | |||
690 | node.d.name[node.d.nsize] = '\0'; | ||
691 | printk(JFFS2_DBG "name:\t\"%s\"\n", node.d.name); | ||
692 | |||
693 | crc = crc32(0, &node.d, sizeof(node.d) - 8); | ||
694 | if (crc != je32_to_cpu(node.d.node_crc)) { | ||
695 | JFFS2_ERROR("wrong node header CRC.\n"); | ||
696 | return; | ||
697 | } | ||
698 | break; | ||
699 | |||
700 | default: | ||
701 | printk(JFFS2_DBG "node type is unknown\n"); | ||
702 | break; | ||
703 | } | ||
704 | } | ||
705 | #endif /* JFFS2_DBG_DUMPS || JFFS2_DBG_PARANOIA_CHECKS */ | ||
diff --git a/fs/jffs2/debug.h b/fs/jffs2/debug.h new file mode 100644 index 000000000000..f193d43a8a59 --- /dev/null +++ b/fs/jffs2/debug.h | |||
@@ -0,0 +1,279 @@ | |||
1 | /* | ||
2 | * JFFS2 -- Journalling Flash File System, Version 2. | ||
3 | * | ||
4 | * Copyright (C) 2001-2003 Red Hat, Inc. | ||
5 | * | ||
6 | * Created by David Woodhouse <dwmw2@infradead.org> | ||
7 | * | ||
8 | * For licensing information, see the file 'LICENCE' in this directory. | ||
9 | * | ||
10 | * $Id: debug.h,v 1.21 2005/11/07 11:14:39 gleixner Exp $ | ||
11 | * | ||
12 | */ | ||
13 | #ifndef _JFFS2_DEBUG_H_ | ||
14 | #define _JFFS2_DEBUG_H_ | ||
15 | |||
16 | #include <linux/config.h> | ||
17 | |||
18 | #ifndef CONFIG_JFFS2_FS_DEBUG | ||
19 | #define CONFIG_JFFS2_FS_DEBUG 0 | ||
20 | #endif | ||
21 | |||
22 | #if CONFIG_JFFS2_FS_DEBUG > 0 | ||
23 | /* Enable "paranoia" checks and dumps */ | ||
24 | #define JFFS2_DBG_PARANOIA_CHECKS | ||
25 | #define JFFS2_DBG_DUMPS | ||
26 | |||
27 | /* | ||
28 | * By defining/undefining the below macros one may select debugging messages | ||
29 | * fro specific JFFS2 subsystems. | ||
30 | */ | ||
31 | #define JFFS2_DBG_READINODE_MESSAGES | ||
32 | #define JFFS2_DBG_FRAGTREE_MESSAGES | ||
33 | #define JFFS2_DBG_DENTLIST_MESSAGES | ||
34 | #define JFFS2_DBG_NODEREF_MESSAGES | ||
35 | #define JFFS2_DBG_INOCACHE_MESSAGES | ||
36 | #define JFFS2_DBG_SUMMARY_MESSAGES | ||
37 | #define JFFS2_DBG_FSBUILD_MESSAGES | ||
38 | #endif | ||
39 | |||
40 | #if CONFIG_JFFS2_FS_DEBUG > 1 | ||
41 | #define JFFS2_DBG_FRAGTREE2_MESSAGES | ||
42 | #define JFFS2_DBG_MEMALLOC_MESSAGES | ||
43 | #endif | ||
44 | |||
45 | /* Sanity checks are supposed to be light-weight and enabled by default */ | ||
46 | #define JFFS2_DBG_SANITY_CHECKS | ||
47 | |||
48 | /* | ||
49 | * Dx() are mainly used for debugging messages, they must go away and be | ||
50 | * superseded by nicer dbg_xxx() macros... | ||
51 | */ | ||
52 | #if CONFIG_JFFS2_FS_DEBUG > 0 | ||
53 | #define D1(x) x | ||
54 | #else | ||
55 | #define D1(x) | ||
56 | #endif | ||
57 | |||
58 | #if CONFIG_JFFS2_FS_DEBUG > 1 | ||
59 | #define D2(x) x | ||
60 | #else | ||
61 | #define D2(x) | ||
62 | #endif | ||
63 | |||
64 | /* The prefixes of JFFS2 messages */ | ||
65 | #define JFFS2_DBG_PREFIX "[JFFS2 DBG]" | ||
66 | #define JFFS2_ERR_PREFIX "JFFS2 error:" | ||
67 | #define JFFS2_WARN_PREFIX "JFFS2 warning:" | ||
68 | #define JFFS2_NOTICE_PREFIX "JFFS2 notice:" | ||
69 | |||
70 | #define JFFS2_ERR KERN_ERR | ||
71 | #define JFFS2_WARN KERN_WARNING | ||
72 | #define JFFS2_NOT KERN_NOTICE | ||
73 | #define JFFS2_DBG KERN_DEBUG | ||
74 | |||
75 | #define JFFS2_DBG_MSG_PREFIX JFFS2_DBG JFFS2_DBG_PREFIX | ||
76 | #define JFFS2_ERR_MSG_PREFIX JFFS2_ERR JFFS2_ERR_PREFIX | ||
77 | #define JFFS2_WARN_MSG_PREFIX JFFS2_WARN JFFS2_WARN_PREFIX | ||
78 | #define JFFS2_NOTICE_MSG_PREFIX JFFS2_NOT JFFS2_NOTICE_PREFIX | ||
79 | |||
80 | /* JFFS2 message macros */ | ||
81 | #define JFFS2_ERROR(fmt, ...) \ | ||
82 | do { \ | ||
83 | printk(JFFS2_ERR_MSG_PREFIX \ | ||
84 | " (%d) %s: " fmt, current->pid, \ | ||
85 | __FUNCTION__, ##__VA_ARGS__); \ | ||
86 | } while(0) | ||
87 | |||
88 | #define JFFS2_WARNING(fmt, ...) \ | ||
89 | do { \ | ||
90 | printk(JFFS2_WARN_MSG_PREFIX \ | ||
91 | " (%d) %s: " fmt, current->pid, \ | ||
92 | __FUNCTION__, ##__VA_ARGS__); \ | ||
93 | } while(0) | ||
94 | |||
95 | #define JFFS2_NOTICE(fmt, ...) \ | ||
96 | do { \ | ||
97 | printk(JFFS2_NOTICE_MSG_PREFIX \ | ||
98 | " (%d) %s: " fmt, current->pid, \ | ||
99 | __FUNCTION__, ##__VA_ARGS__); \ | ||
100 | } while(0) | ||
101 | |||
102 | #define JFFS2_DEBUG(fmt, ...) \ | ||
103 | do { \ | ||
104 | printk(JFFS2_DBG_MSG_PREFIX \ | ||
105 | " (%d) %s: " fmt, current->pid, \ | ||
106 | __FUNCTION__, ##__VA_ARGS__); \ | ||
107 | } while(0) | ||
108 | |||
109 | /* | ||
110 | * We split our debugging messages on several parts, depending on the JFFS2 | ||
111 | * subsystem the message belongs to. | ||
112 | */ | ||
113 | /* Read inode debugging messages */ | ||
114 | #ifdef JFFS2_DBG_READINODE_MESSAGES | ||
115 | #define dbg_readinode(fmt, ...) JFFS2_DEBUG(fmt, ##__VA_ARGS__) | ||
116 | #else | ||
117 | #define dbg_readinode(fmt, ...) | ||
118 | #endif | ||
119 | |||
120 | /* Fragtree build debugging messages */ | ||
121 | #ifdef JFFS2_DBG_FRAGTREE_MESSAGES | ||
122 | #define dbg_fragtree(fmt, ...) JFFS2_DEBUG(fmt, ##__VA_ARGS__) | ||
123 | #else | ||
124 | #define dbg_fragtree(fmt, ...) | ||
125 | #endif | ||
126 | #ifdef JFFS2_DBG_FRAGTREE2_MESSAGES | ||
127 | #define dbg_fragtree2(fmt, ...) JFFS2_DEBUG(fmt, ##__VA_ARGS__) | ||
128 | #else | ||
129 | #define dbg_fragtree2(fmt, ...) | ||
130 | #endif | ||
131 | |||
132 | /* Directory entry list manilulation debugging messages */ | ||
133 | #ifdef JFFS2_DBG_DENTLIST_MESSAGES | ||
134 | #define dbg_dentlist(fmt, ...) JFFS2_DEBUG(fmt, ##__VA_ARGS__) | ||
135 | #else | ||
136 | #define dbg_dentlist(fmt, ...) | ||
137 | #endif | ||
138 | |||
139 | /* Print the messages about manipulating node_refs */ | ||
140 | #ifdef JFFS2_DBG_NODEREF_MESSAGES | ||
141 | #define dbg_noderef(fmt, ...) JFFS2_DEBUG(fmt, ##__VA_ARGS__) | ||
142 | #else | ||
143 | #define dbg_noderef(fmt, ...) | ||
144 | #endif | ||
145 | |||
146 | /* Manipulations with the list of inodes (JFFS2 inocache) */ | ||
147 | #ifdef JFFS2_DBG_INOCACHE_MESSAGES | ||
148 | #define dbg_inocache(fmt, ...) JFFS2_DEBUG(fmt, ##__VA_ARGS__) | ||
149 | #else | ||
150 | #define dbg_inocache(fmt, ...) | ||
151 | #endif | ||
152 | |||
153 | /* Summary debugging messages */ | ||
154 | #ifdef JFFS2_DBG_SUMMARY_MESSAGES | ||
155 | #define dbg_summary(fmt, ...) JFFS2_DEBUG(fmt, ##__VA_ARGS__) | ||
156 | #else | ||
157 | #define dbg_summary(fmt, ...) | ||
158 | #endif | ||
159 | |||
160 | /* File system build messages */ | ||
161 | #ifdef JFFS2_DBG_FSBUILD_MESSAGES | ||
162 | #define dbg_fsbuild(fmt, ...) JFFS2_DEBUG(fmt, ##__VA_ARGS__) | ||
163 | #else | ||
164 | #define dbg_fsbuild(fmt, ...) | ||
165 | #endif | ||
166 | |||
167 | /* Watch the object allocations */ | ||
168 | #ifdef JFFS2_DBG_MEMALLOC_MESSAGES | ||
169 | #define dbg_memalloc(fmt, ...) JFFS2_DEBUG(fmt, ##__VA_ARGS__) | ||
170 | #else | ||
171 | #define dbg_memalloc(fmt, ...) | ||
172 | #endif | ||
173 | |||
174 | |||
175 | /* "Sanity" checks */ | ||
176 | void | ||
177 | __jffs2_dbg_acct_sanity_check_nolock(struct jffs2_sb_info *c, | ||
178 | struct jffs2_eraseblock *jeb); | ||
179 | void | ||
180 | __jffs2_dbg_acct_sanity_check(struct jffs2_sb_info *c, | ||
181 | struct jffs2_eraseblock *jeb); | ||
182 | |||
183 | /* "Paranoia" checks */ | ||
184 | void | ||
185 | __jffs2_dbg_fragtree_paranoia_check(struct jffs2_inode_info *f); | ||
186 | void | ||
187 | __jffs2_dbg_fragtree_paranoia_check_nolock(struct jffs2_inode_info *f); | ||
188 | void | ||
189 | __jffs2_dbg_acct_paranoia_check(struct jffs2_sb_info *c, | ||
190 | struct jffs2_eraseblock *jeb); | ||
191 | void | ||
192 | __jffs2_dbg_acct_paranoia_check_nolock(struct jffs2_sb_info *c, | ||
193 | struct jffs2_eraseblock *jeb); | ||
194 | void | ||
195 | __jffs2_dbg_prewrite_paranoia_check(struct jffs2_sb_info *c, | ||
196 | uint32_t ofs, int len); | ||
197 | |||
198 | /* "Dump" functions */ | ||
199 | void | ||
200 | __jffs2_dbg_dump_jeb(struct jffs2_sb_info *c, struct jffs2_eraseblock *jeb); | ||
201 | void | ||
202 | __jffs2_dbg_dump_jeb_nolock(struct jffs2_eraseblock *jeb); | ||
203 | void | ||
204 | __jffs2_dbg_dump_block_lists(struct jffs2_sb_info *c); | ||
205 | void | ||
206 | __jffs2_dbg_dump_block_lists_nolock(struct jffs2_sb_info *c); | ||
207 | void | ||
208 | __jffs2_dbg_dump_node_refs(struct jffs2_sb_info *c, | ||
209 | struct jffs2_eraseblock *jeb); | ||
210 | void | ||
211 | __jffs2_dbg_dump_node_refs_nolock(struct jffs2_sb_info *c, | ||
212 | struct jffs2_eraseblock *jeb); | ||
213 | void | ||
214 | __jffs2_dbg_dump_fragtree(struct jffs2_inode_info *f); | ||
215 | void | ||
216 | __jffs2_dbg_dump_fragtree_nolock(struct jffs2_inode_info *f); | ||
217 | void | ||
218 | __jffs2_dbg_dump_buffer(unsigned char *buf, int len, uint32_t offs); | ||
219 | void | ||
220 | __jffs2_dbg_dump_node(struct jffs2_sb_info *c, uint32_t ofs); | ||
221 | |||
222 | #ifdef JFFS2_DBG_PARANOIA_CHECKS | ||
223 | #define jffs2_dbg_fragtree_paranoia_check(f) \ | ||
224 | __jffs2_dbg_fragtree_paranoia_check(f) | ||
225 | #define jffs2_dbg_fragtree_paranoia_check_nolock(f) \ | ||
226 | __jffs2_dbg_fragtree_paranoia_check_nolock(f) | ||
227 | #define jffs2_dbg_acct_paranoia_check(c, jeb) \ | ||
228 | __jffs2_dbg_acct_paranoia_check(c,jeb) | ||
229 | #define jffs2_dbg_acct_paranoia_check_nolock(c, jeb) \ | ||
230 | __jffs2_dbg_acct_paranoia_check_nolock(c,jeb) | ||
231 | #define jffs2_dbg_prewrite_paranoia_check(c, ofs, len) \ | ||
232 | __jffs2_dbg_prewrite_paranoia_check(c, ofs, len) | ||
233 | #else | ||
234 | #define jffs2_dbg_fragtree_paranoia_check(f) | ||
235 | #define jffs2_dbg_fragtree_paranoia_check_nolock(f) | ||
236 | #define jffs2_dbg_acct_paranoia_check(c, jeb) | ||
237 | #define jffs2_dbg_acct_paranoia_check_nolock(c, jeb) | ||
238 | #define jffs2_dbg_prewrite_paranoia_check(c, ofs, len) | ||
239 | #endif /* !JFFS2_PARANOIA_CHECKS */ | ||
240 | |||
241 | #ifdef JFFS2_DBG_DUMPS | ||
242 | #define jffs2_dbg_dump_jeb(c, jeb) \ | ||
243 | __jffs2_dbg_dump_jeb(c, jeb); | ||
244 | #define jffs2_dbg_dump_jeb_nolock(jeb) \ | ||
245 | __jffs2_dbg_dump_jeb_nolock(jeb); | ||
246 | #define jffs2_dbg_dump_block_lists(c) \ | ||
247 | __jffs2_dbg_dump_block_lists(c) | ||
248 | #define jffs2_dbg_dump_block_lists_nolock(c) \ | ||
249 | __jffs2_dbg_dump_block_lists_nolock(c) | ||
250 | #define jffs2_dbg_dump_fragtree(f) \ | ||
251 | __jffs2_dbg_dump_fragtree(f); | ||
252 | #define jffs2_dbg_dump_fragtree_nolock(f) \ | ||
253 | __jffs2_dbg_dump_fragtree_nolock(f); | ||
254 | #define jffs2_dbg_dump_buffer(buf, len, offs) \ | ||
255 | __jffs2_dbg_dump_buffer(*buf, len, offs); | ||
256 | #define jffs2_dbg_dump_node(c, ofs) \ | ||
257 | __jffs2_dbg_dump_node(c, ofs); | ||
258 | #else | ||
259 | #define jffs2_dbg_dump_jeb(c, jeb) | ||
260 | #define jffs2_dbg_dump_jeb_nolock(jeb) | ||
261 | #define jffs2_dbg_dump_block_lists(c) | ||
262 | #define jffs2_dbg_dump_block_lists_nolock(c) | ||
263 | #define jffs2_dbg_dump_fragtree(f) | ||
264 | #define jffs2_dbg_dump_fragtree_nolock(f) | ||
265 | #define jffs2_dbg_dump_buffer(buf, len, offs) | ||
266 | #define jffs2_dbg_dump_node(c, ofs) | ||
267 | #endif /* !JFFS2_DBG_DUMPS */ | ||
268 | |||
269 | #ifdef JFFS2_DBG_SANITY_CHECKS | ||
270 | #define jffs2_dbg_acct_sanity_check(c, jeb) \ | ||
271 | __jffs2_dbg_acct_sanity_check(c, jeb) | ||
272 | #define jffs2_dbg_acct_sanity_check_nolock(c, jeb) \ | ||
273 | __jffs2_dbg_acct_sanity_check_nolock(c, jeb) | ||
274 | #else | ||
275 | #define jffs2_dbg_acct_sanity_check(c, jeb) | ||
276 | #define jffs2_dbg_acct_sanity_check_nolock(c, jeb) | ||
277 | #endif /* !JFFS2_DBG_SANITY_CHECKS */ | ||
278 | |||
279 | #endif /* _JFFS2_DEBUG_H_ */ | ||
diff --git a/fs/jffs2/dir.c b/fs/jffs2/dir.c index 3ca0d25eef1d..a7bf9cb2567f 100644 --- a/fs/jffs2/dir.c +++ b/fs/jffs2/dir.c | |||
@@ -7,7 +7,7 @@ | |||
7 | * | 7 | * |
8 | * For licensing information, see the file 'LICENCE' in this directory. | 8 | * For licensing information, see the file 'LICENCE' in this directory. |
9 | * | 9 | * |
10 | * $Id: dir.c,v 1.86 2005/07/06 12:13:09 dwmw2 Exp $ | 10 | * $Id: dir.c,v 1.90 2005/11/07 11:14:39 gleixner Exp $ |
11 | * | 11 | * |
12 | */ | 12 | */ |
13 | 13 | ||
@@ -64,7 +64,7 @@ struct inode_operations jffs2_dir_inode_operations = | |||
64 | 64 | ||
65 | 65 | ||
66 | /* We keep the dirent list sorted in increasing order of name hash, | 66 | /* We keep the dirent list sorted in increasing order of name hash, |
67 | and we use the same hash function as the dentries. Makes this | 67 | and we use the same hash function as the dentries. Makes this |
68 | nice and simple | 68 | nice and simple |
69 | */ | 69 | */ |
70 | static struct dentry *jffs2_lookup(struct inode *dir_i, struct dentry *target, | 70 | static struct dentry *jffs2_lookup(struct inode *dir_i, struct dentry *target, |
@@ -85,7 +85,7 @@ static struct dentry *jffs2_lookup(struct inode *dir_i, struct dentry *target, | |||
85 | 85 | ||
86 | /* NB: The 2.2 backport will need to explicitly check for '.' and '..' here */ | 86 | /* NB: The 2.2 backport will need to explicitly check for '.' and '..' here */ |
87 | for (fd_list = dir_f->dents; fd_list && fd_list->nhash <= target->d_name.hash; fd_list = fd_list->next) { | 87 | for (fd_list = dir_f->dents; fd_list && fd_list->nhash <= target->d_name.hash; fd_list = fd_list->next) { |
88 | if (fd_list->nhash == target->d_name.hash && | 88 | if (fd_list->nhash == target->d_name.hash && |
89 | (!fd || fd_list->version > fd->version) && | 89 | (!fd || fd_list->version > fd->version) && |
90 | strlen(fd_list->name) == target->d_name.len && | 90 | strlen(fd_list->name) == target->d_name.len && |
91 | !strncmp(fd_list->name, target->d_name.name, target->d_name.len)) { | 91 | !strncmp(fd_list->name, target->d_name.name, target->d_name.len)) { |
@@ -147,7 +147,7 @@ static int jffs2_readdir(struct file *filp, void *dirent, filldir_t filldir) | |||
147 | curofs++; | 147 | curofs++; |
148 | /* First loop: curofs = 2; offset = 2 */ | 148 | /* First loop: curofs = 2; offset = 2 */ |
149 | if (curofs < offset) { | 149 | if (curofs < offset) { |
150 | D2(printk(KERN_DEBUG "Skipping dirent: \"%s\", ino #%u, type %d, because curofs %ld < offset %ld\n", | 150 | D2(printk(KERN_DEBUG "Skipping dirent: \"%s\", ino #%u, type %d, because curofs %ld < offset %ld\n", |
151 | fd->name, fd->ino, fd->type, curofs, offset)); | 151 | fd->name, fd->ino, fd->type, curofs, offset)); |
152 | continue; | 152 | continue; |
153 | } | 153 | } |
@@ -182,7 +182,7 @@ static int jffs2_create(struct inode *dir_i, struct dentry *dentry, int mode, | |||
182 | ri = jffs2_alloc_raw_inode(); | 182 | ri = jffs2_alloc_raw_inode(); |
183 | if (!ri) | 183 | if (!ri) |
184 | return -ENOMEM; | 184 | return -ENOMEM; |
185 | 185 | ||
186 | c = JFFS2_SB_INFO(dir_i->i_sb); | 186 | c = JFFS2_SB_INFO(dir_i->i_sb); |
187 | 187 | ||
188 | D1(printk(KERN_DEBUG "jffs2_create()\n")); | 188 | D1(printk(KERN_DEBUG "jffs2_create()\n")); |
@@ -203,7 +203,7 @@ static int jffs2_create(struct inode *dir_i, struct dentry *dentry, int mode, | |||
203 | f = JFFS2_INODE_INFO(inode); | 203 | f = JFFS2_INODE_INFO(inode); |
204 | dir_f = JFFS2_INODE_INFO(dir_i); | 204 | dir_f = JFFS2_INODE_INFO(dir_i); |
205 | 205 | ||
206 | ret = jffs2_do_create(c, dir_f, f, ri, | 206 | ret = jffs2_do_create(c, dir_f, f, ri, |
207 | dentry->d_name.name, dentry->d_name.len); | 207 | dentry->d_name.name, dentry->d_name.len); |
208 | 208 | ||
209 | if (ret) { | 209 | if (ret) { |
@@ -232,11 +232,14 @@ static int jffs2_unlink(struct inode *dir_i, struct dentry *dentry) | |||
232 | struct jffs2_inode_info *dir_f = JFFS2_INODE_INFO(dir_i); | 232 | struct jffs2_inode_info *dir_f = JFFS2_INODE_INFO(dir_i); |
233 | struct jffs2_inode_info *dead_f = JFFS2_INODE_INFO(dentry->d_inode); | 233 | struct jffs2_inode_info *dead_f = JFFS2_INODE_INFO(dentry->d_inode); |
234 | int ret; | 234 | int ret; |
235 | uint32_t now = get_seconds(); | ||
235 | 236 | ||
236 | ret = jffs2_do_unlink(c, dir_f, dentry->d_name.name, | 237 | ret = jffs2_do_unlink(c, dir_f, dentry->d_name.name, |
237 | dentry->d_name.len, dead_f); | 238 | dentry->d_name.len, dead_f, now); |
238 | if (dead_f->inocache) | 239 | if (dead_f->inocache) |
239 | dentry->d_inode->i_nlink = dead_f->inocache->nlink; | 240 | dentry->d_inode->i_nlink = dead_f->inocache->nlink; |
241 | if (!ret) | ||
242 | dir_i->i_mtime = dir_i->i_ctime = ITIME(now); | ||
240 | return ret; | 243 | return ret; |
241 | } | 244 | } |
242 | /***********************************************************************/ | 245 | /***********************************************************************/ |
@@ -249,6 +252,7 @@ static int jffs2_link (struct dentry *old_dentry, struct inode *dir_i, struct de | |||
249 | struct jffs2_inode_info *dir_f = JFFS2_INODE_INFO(dir_i); | 252 | struct jffs2_inode_info *dir_f = JFFS2_INODE_INFO(dir_i); |
250 | int ret; | 253 | int ret; |
251 | uint8_t type; | 254 | uint8_t type; |
255 | uint32_t now; | ||
252 | 256 | ||
253 | /* Don't let people make hard links to bad inodes. */ | 257 | /* Don't let people make hard links to bad inodes. */ |
254 | if (!f->inocache) | 258 | if (!f->inocache) |
@@ -261,13 +265,15 @@ static int jffs2_link (struct dentry *old_dentry, struct inode *dir_i, struct de | |||
261 | type = (old_dentry->d_inode->i_mode & S_IFMT) >> 12; | 265 | type = (old_dentry->d_inode->i_mode & S_IFMT) >> 12; |
262 | if (!type) type = DT_REG; | 266 | if (!type) type = DT_REG; |
263 | 267 | ||
264 | ret = jffs2_do_link(c, dir_f, f->inocache->ino, type, dentry->d_name.name, dentry->d_name.len); | 268 | now = get_seconds(); |
269 | ret = jffs2_do_link(c, dir_f, f->inocache->ino, type, dentry->d_name.name, dentry->d_name.len, now); | ||
265 | 270 | ||
266 | if (!ret) { | 271 | if (!ret) { |
267 | down(&f->sem); | 272 | down(&f->sem); |
268 | old_dentry->d_inode->i_nlink = ++f->inocache->nlink; | 273 | old_dentry->d_inode->i_nlink = ++f->inocache->nlink; |
269 | up(&f->sem); | 274 | up(&f->sem); |
270 | d_instantiate(dentry, old_dentry->d_inode); | 275 | d_instantiate(dentry, old_dentry->d_inode); |
276 | dir_i->i_mtime = dir_i->i_ctime = ITIME(now); | ||
271 | atomic_inc(&old_dentry->d_inode->i_count); | 277 | atomic_inc(&old_dentry->d_inode->i_count); |
272 | } | 278 | } |
273 | return ret; | 279 | return ret; |
@@ -297,14 +303,15 @@ static int jffs2_symlink (struct inode *dir_i, struct dentry *dentry, const char | |||
297 | 303 | ||
298 | if (!ri) | 304 | if (!ri) |
299 | return -ENOMEM; | 305 | return -ENOMEM; |
300 | 306 | ||
301 | c = JFFS2_SB_INFO(dir_i->i_sb); | 307 | c = JFFS2_SB_INFO(dir_i->i_sb); |
302 | 308 | ||
303 | /* Try to reserve enough space for both node and dirent. | 309 | /* Try to reserve enough space for both node and dirent. |
304 | * Just the node will do for now, though | 310 | * Just the node will do for now, though |
305 | */ | 311 | */ |
306 | namelen = dentry->d_name.len; | 312 | namelen = dentry->d_name.len; |
307 | ret = jffs2_reserve_space(c, sizeof(*ri) + targetlen, &phys_ofs, &alloclen, ALLOC_NORMAL); | 313 | ret = jffs2_reserve_space(c, sizeof(*ri) + targetlen, &phys_ofs, &alloclen, |
314 | ALLOC_NORMAL, JFFS2_SUMMARY_INODE_SIZE); | ||
308 | 315 | ||
309 | if (ret) { | 316 | if (ret) { |
310 | jffs2_free_raw_inode(ri); | 317 | jffs2_free_raw_inode(ri); |
@@ -331,7 +338,7 @@ static int jffs2_symlink (struct inode *dir_i, struct dentry *dentry, const char | |||
331 | ri->compr = JFFS2_COMPR_NONE; | 338 | ri->compr = JFFS2_COMPR_NONE; |
332 | ri->data_crc = cpu_to_je32(crc32(0, target, targetlen)); | 339 | ri->data_crc = cpu_to_je32(crc32(0, target, targetlen)); |
333 | ri->node_crc = cpu_to_je32(crc32(0, ri, sizeof(*ri)-8)); | 340 | ri->node_crc = cpu_to_je32(crc32(0, ri, sizeof(*ri)-8)); |
334 | 341 | ||
335 | fn = jffs2_write_dnode(c, f, ri, target, targetlen, phys_ofs, ALLOC_NORMAL); | 342 | fn = jffs2_write_dnode(c, f, ri, target, targetlen, phys_ofs, ALLOC_NORMAL); |
336 | 343 | ||
337 | jffs2_free_raw_inode(ri); | 344 | jffs2_free_raw_inode(ri); |
@@ -344,9 +351,9 @@ static int jffs2_symlink (struct inode *dir_i, struct dentry *dentry, const char | |||
344 | return PTR_ERR(fn); | 351 | return PTR_ERR(fn); |
345 | } | 352 | } |
346 | 353 | ||
347 | /* We use f->dents field to store the target path. */ | 354 | /* We use f->target field to store the target path. */ |
348 | f->dents = kmalloc(targetlen + 1, GFP_KERNEL); | 355 | f->target = kmalloc(targetlen + 1, GFP_KERNEL); |
349 | if (!f->dents) { | 356 | if (!f->target) { |
350 | printk(KERN_WARNING "Can't allocate %d bytes of memory\n", targetlen + 1); | 357 | printk(KERN_WARNING "Can't allocate %d bytes of memory\n", targetlen + 1); |
351 | up(&f->sem); | 358 | up(&f->sem); |
352 | jffs2_complete_reservation(c); | 359 | jffs2_complete_reservation(c); |
@@ -354,17 +361,18 @@ static int jffs2_symlink (struct inode *dir_i, struct dentry *dentry, const char | |||
354 | return -ENOMEM; | 361 | return -ENOMEM; |
355 | } | 362 | } |
356 | 363 | ||
357 | memcpy(f->dents, target, targetlen + 1); | 364 | memcpy(f->target, target, targetlen + 1); |
358 | D1(printk(KERN_DEBUG "jffs2_symlink: symlink's target '%s' cached\n", (char *)f->dents)); | 365 | D1(printk(KERN_DEBUG "jffs2_symlink: symlink's target '%s' cached\n", (char *)f->target)); |
359 | 366 | ||
360 | /* No data here. Only a metadata node, which will be | 367 | /* No data here. Only a metadata node, which will be |
361 | obsoleted by the first data write | 368 | obsoleted by the first data write |
362 | */ | 369 | */ |
363 | f->metadata = fn; | 370 | f->metadata = fn; |
364 | up(&f->sem); | 371 | up(&f->sem); |
365 | 372 | ||
366 | jffs2_complete_reservation(c); | 373 | jffs2_complete_reservation(c); |
367 | ret = jffs2_reserve_space(c, sizeof(*rd)+namelen, &phys_ofs, &alloclen, ALLOC_NORMAL); | 374 | ret = jffs2_reserve_space(c, sizeof(*rd)+namelen, &phys_ofs, &alloclen, |
375 | ALLOC_NORMAL, JFFS2_SUMMARY_DIRENT_SIZE(namelen)); | ||
368 | if (ret) { | 376 | if (ret) { |
369 | /* Eep. */ | 377 | /* Eep. */ |
370 | jffs2_clear_inode(inode); | 378 | jffs2_clear_inode(inode); |
@@ -399,7 +407,7 @@ static int jffs2_symlink (struct inode *dir_i, struct dentry *dentry, const char | |||
399 | fd = jffs2_write_dirent(c, dir_f, rd, dentry->d_name.name, namelen, phys_ofs, ALLOC_NORMAL); | 407 | fd = jffs2_write_dirent(c, dir_f, rd, dentry->d_name.name, namelen, phys_ofs, ALLOC_NORMAL); |
400 | 408 | ||
401 | if (IS_ERR(fd)) { | 409 | if (IS_ERR(fd)) { |
402 | /* dirent failed to write. Delete the inode normally | 410 | /* dirent failed to write. Delete the inode normally |
403 | as if it were the final unlink() */ | 411 | as if it were the final unlink() */ |
404 | jffs2_complete_reservation(c); | 412 | jffs2_complete_reservation(c); |
405 | jffs2_free_raw_dirent(rd); | 413 | jffs2_free_raw_dirent(rd); |
@@ -442,14 +450,15 @@ static int jffs2_mkdir (struct inode *dir_i, struct dentry *dentry, int mode) | |||
442 | ri = jffs2_alloc_raw_inode(); | 450 | ri = jffs2_alloc_raw_inode(); |
443 | if (!ri) | 451 | if (!ri) |
444 | return -ENOMEM; | 452 | return -ENOMEM; |
445 | 453 | ||
446 | c = JFFS2_SB_INFO(dir_i->i_sb); | 454 | c = JFFS2_SB_INFO(dir_i->i_sb); |
447 | 455 | ||
448 | /* Try to reserve enough space for both node and dirent. | 456 | /* Try to reserve enough space for both node and dirent. |
449 | * Just the node will do for now, though | 457 | * Just the node will do for now, though |
450 | */ | 458 | */ |
451 | namelen = dentry->d_name.len; | 459 | namelen = dentry->d_name.len; |
452 | ret = jffs2_reserve_space(c, sizeof(*ri), &phys_ofs, &alloclen, ALLOC_NORMAL); | 460 | ret = jffs2_reserve_space(c, sizeof(*ri), &phys_ofs, &alloclen, ALLOC_NORMAL, |
461 | JFFS2_SUMMARY_INODE_SIZE); | ||
453 | 462 | ||
454 | if (ret) { | 463 | if (ret) { |
455 | jffs2_free_raw_inode(ri); | 464 | jffs2_free_raw_inode(ri); |
@@ -473,7 +482,7 @@ static int jffs2_mkdir (struct inode *dir_i, struct dentry *dentry, int mode) | |||
473 | 482 | ||
474 | ri->data_crc = cpu_to_je32(0); | 483 | ri->data_crc = cpu_to_je32(0); |
475 | ri->node_crc = cpu_to_je32(crc32(0, ri, sizeof(*ri)-8)); | 484 | ri->node_crc = cpu_to_je32(crc32(0, ri, sizeof(*ri)-8)); |
476 | 485 | ||
477 | fn = jffs2_write_dnode(c, f, ri, NULL, 0, phys_ofs, ALLOC_NORMAL); | 486 | fn = jffs2_write_dnode(c, f, ri, NULL, 0, phys_ofs, ALLOC_NORMAL); |
478 | 487 | ||
479 | jffs2_free_raw_inode(ri); | 488 | jffs2_free_raw_inode(ri); |
@@ -485,20 +494,21 @@ static int jffs2_mkdir (struct inode *dir_i, struct dentry *dentry, int mode) | |||
485 | jffs2_clear_inode(inode); | 494 | jffs2_clear_inode(inode); |
486 | return PTR_ERR(fn); | 495 | return PTR_ERR(fn); |
487 | } | 496 | } |
488 | /* No data here. Only a metadata node, which will be | 497 | /* No data here. Only a metadata node, which will be |
489 | obsoleted by the first data write | 498 | obsoleted by the first data write |
490 | */ | 499 | */ |
491 | f->metadata = fn; | 500 | f->metadata = fn; |
492 | up(&f->sem); | 501 | up(&f->sem); |
493 | 502 | ||
494 | jffs2_complete_reservation(c); | 503 | jffs2_complete_reservation(c); |
495 | ret = jffs2_reserve_space(c, sizeof(*rd)+namelen, &phys_ofs, &alloclen, ALLOC_NORMAL); | 504 | ret = jffs2_reserve_space(c, sizeof(*rd)+namelen, &phys_ofs, &alloclen, |
505 | ALLOC_NORMAL, JFFS2_SUMMARY_DIRENT_SIZE(namelen)); | ||
496 | if (ret) { | 506 | if (ret) { |
497 | /* Eep. */ | 507 | /* Eep. */ |
498 | jffs2_clear_inode(inode); | 508 | jffs2_clear_inode(inode); |
499 | return ret; | 509 | return ret; |
500 | } | 510 | } |
501 | 511 | ||
502 | rd = jffs2_alloc_raw_dirent(); | 512 | rd = jffs2_alloc_raw_dirent(); |
503 | if (!rd) { | 513 | if (!rd) { |
504 | /* Argh. Now we treat it like a normal delete */ | 514 | /* Argh. Now we treat it like a normal delete */ |
@@ -525,9 +535,9 @@ static int jffs2_mkdir (struct inode *dir_i, struct dentry *dentry, int mode) | |||
525 | rd->name_crc = cpu_to_je32(crc32(0, dentry->d_name.name, namelen)); | 535 | rd->name_crc = cpu_to_je32(crc32(0, dentry->d_name.name, namelen)); |
526 | 536 | ||
527 | fd = jffs2_write_dirent(c, dir_f, rd, dentry->d_name.name, namelen, phys_ofs, ALLOC_NORMAL); | 537 | fd = jffs2_write_dirent(c, dir_f, rd, dentry->d_name.name, namelen, phys_ofs, ALLOC_NORMAL); |
528 | 538 | ||
529 | if (IS_ERR(fd)) { | 539 | if (IS_ERR(fd)) { |
530 | /* dirent failed to write. Delete the inode normally | 540 | /* dirent failed to write. Delete the inode normally |
531 | as if it were the final unlink() */ | 541 | as if it were the final unlink() */ |
532 | jffs2_complete_reservation(c); | 542 | jffs2_complete_reservation(c); |
533 | jffs2_free_raw_dirent(rd); | 543 | jffs2_free_raw_dirent(rd); |
@@ -589,19 +599,20 @@ static int jffs2_mknod (struct inode *dir_i, struct dentry *dentry, int mode, de | |||
589 | ri = jffs2_alloc_raw_inode(); | 599 | ri = jffs2_alloc_raw_inode(); |
590 | if (!ri) | 600 | if (!ri) |
591 | return -ENOMEM; | 601 | return -ENOMEM; |
592 | 602 | ||
593 | c = JFFS2_SB_INFO(dir_i->i_sb); | 603 | c = JFFS2_SB_INFO(dir_i->i_sb); |
594 | 604 | ||
595 | if (S_ISBLK(mode) || S_ISCHR(mode)) { | 605 | if (S_ISBLK(mode) || S_ISCHR(mode)) { |
596 | dev = cpu_to_je16(old_encode_dev(rdev)); | 606 | dev = cpu_to_je16(old_encode_dev(rdev)); |
597 | devlen = sizeof(dev); | 607 | devlen = sizeof(dev); |
598 | } | 608 | } |
599 | 609 | ||
600 | /* Try to reserve enough space for both node and dirent. | 610 | /* Try to reserve enough space for both node and dirent. |
601 | * Just the node will do for now, though | 611 | * Just the node will do for now, though |
602 | */ | 612 | */ |
603 | namelen = dentry->d_name.len; | 613 | namelen = dentry->d_name.len; |
604 | ret = jffs2_reserve_space(c, sizeof(*ri) + devlen, &phys_ofs, &alloclen, ALLOC_NORMAL); | 614 | ret = jffs2_reserve_space(c, sizeof(*ri) + devlen, &phys_ofs, &alloclen, |
615 | ALLOC_NORMAL, JFFS2_SUMMARY_INODE_SIZE); | ||
605 | 616 | ||
606 | if (ret) { | 617 | if (ret) { |
607 | jffs2_free_raw_inode(ri); | 618 | jffs2_free_raw_inode(ri); |
@@ -627,7 +638,7 @@ static int jffs2_mknod (struct inode *dir_i, struct dentry *dentry, int mode, de | |||
627 | ri->compr = JFFS2_COMPR_NONE; | 638 | ri->compr = JFFS2_COMPR_NONE; |
628 | ri->data_crc = cpu_to_je32(crc32(0, &dev, devlen)); | 639 | ri->data_crc = cpu_to_je32(crc32(0, &dev, devlen)); |
629 | ri->node_crc = cpu_to_je32(crc32(0, ri, sizeof(*ri)-8)); | 640 | ri->node_crc = cpu_to_je32(crc32(0, ri, sizeof(*ri)-8)); |
630 | 641 | ||
631 | fn = jffs2_write_dnode(c, f, ri, (char *)&dev, devlen, phys_ofs, ALLOC_NORMAL); | 642 | fn = jffs2_write_dnode(c, f, ri, (char *)&dev, devlen, phys_ofs, ALLOC_NORMAL); |
632 | 643 | ||
633 | jffs2_free_raw_inode(ri); | 644 | jffs2_free_raw_inode(ri); |
@@ -639,14 +650,15 @@ static int jffs2_mknod (struct inode *dir_i, struct dentry *dentry, int mode, de | |||
639 | jffs2_clear_inode(inode); | 650 | jffs2_clear_inode(inode); |
640 | return PTR_ERR(fn); | 651 | return PTR_ERR(fn); |
641 | } | 652 | } |
642 | /* No data here. Only a metadata node, which will be | 653 | /* No data here. Only a metadata node, which will be |
643 | obsoleted by the first data write | 654 | obsoleted by the first data write |
644 | */ | 655 | */ |
645 | f->metadata = fn; | 656 | f->metadata = fn; |
646 | up(&f->sem); | 657 | up(&f->sem); |
647 | 658 | ||
648 | jffs2_complete_reservation(c); | 659 | jffs2_complete_reservation(c); |
649 | ret = jffs2_reserve_space(c, sizeof(*rd)+namelen, &phys_ofs, &alloclen, ALLOC_NORMAL); | 660 | ret = jffs2_reserve_space(c, sizeof(*rd)+namelen, &phys_ofs, &alloclen, |
661 | ALLOC_NORMAL, JFFS2_SUMMARY_DIRENT_SIZE(namelen)); | ||
650 | if (ret) { | 662 | if (ret) { |
651 | /* Eep. */ | 663 | /* Eep. */ |
652 | jffs2_clear_inode(inode); | 664 | jffs2_clear_inode(inode); |
@@ -682,9 +694,9 @@ static int jffs2_mknod (struct inode *dir_i, struct dentry *dentry, int mode, de | |||
682 | rd->name_crc = cpu_to_je32(crc32(0, dentry->d_name.name, namelen)); | 694 | rd->name_crc = cpu_to_je32(crc32(0, dentry->d_name.name, namelen)); |
683 | 695 | ||
684 | fd = jffs2_write_dirent(c, dir_f, rd, dentry->d_name.name, namelen, phys_ofs, ALLOC_NORMAL); | 696 | fd = jffs2_write_dirent(c, dir_f, rd, dentry->d_name.name, namelen, phys_ofs, ALLOC_NORMAL); |
685 | 697 | ||
686 | if (IS_ERR(fd)) { | 698 | if (IS_ERR(fd)) { |
687 | /* dirent failed to write. Delete the inode normally | 699 | /* dirent failed to write. Delete the inode normally |
688 | as if it were the final unlink() */ | 700 | as if it were the final unlink() */ |
689 | jffs2_complete_reservation(c); | 701 | jffs2_complete_reservation(c); |
690 | jffs2_free_raw_dirent(rd); | 702 | jffs2_free_raw_dirent(rd); |
@@ -716,8 +728,9 @@ static int jffs2_rename (struct inode *old_dir_i, struct dentry *old_dentry, | |||
716 | struct jffs2_sb_info *c = JFFS2_SB_INFO(old_dir_i->i_sb); | 728 | struct jffs2_sb_info *c = JFFS2_SB_INFO(old_dir_i->i_sb); |
717 | struct jffs2_inode_info *victim_f = NULL; | 729 | struct jffs2_inode_info *victim_f = NULL; |
718 | uint8_t type; | 730 | uint8_t type; |
731 | uint32_t now; | ||
719 | 732 | ||
720 | /* The VFS will check for us and prevent trying to rename a | 733 | /* The VFS will check for us and prevent trying to rename a |
721 | * file over a directory and vice versa, but if it's a directory, | 734 | * file over a directory and vice versa, but if it's a directory, |
722 | * the VFS can't check whether the victim is empty. The filesystem | 735 | * the VFS can't check whether the victim is empty. The filesystem |
723 | * needs to do that for itself. | 736 | * needs to do that for itself. |
@@ -739,19 +752,20 @@ static int jffs2_rename (struct inode *old_dir_i, struct dentry *old_dentry, | |||
739 | } | 752 | } |
740 | 753 | ||
741 | /* XXX: We probably ought to alloc enough space for | 754 | /* XXX: We probably ought to alloc enough space for |
742 | both nodes at the same time. Writing the new link, | 755 | both nodes at the same time. Writing the new link, |
743 | then getting -ENOSPC, is quite bad :) | 756 | then getting -ENOSPC, is quite bad :) |
744 | */ | 757 | */ |
745 | 758 | ||
746 | /* Make a hard link */ | 759 | /* Make a hard link */ |
747 | 760 | ||
748 | /* XXX: This is ugly */ | 761 | /* XXX: This is ugly */ |
749 | type = (old_dentry->d_inode->i_mode & S_IFMT) >> 12; | 762 | type = (old_dentry->d_inode->i_mode & S_IFMT) >> 12; |
750 | if (!type) type = DT_REG; | 763 | if (!type) type = DT_REG; |
751 | 764 | ||
752 | ret = jffs2_do_link(c, JFFS2_INODE_INFO(new_dir_i), | 765 | now = get_seconds(); |
766 | ret = jffs2_do_link(c, JFFS2_INODE_INFO(new_dir_i), | ||
753 | old_dentry->d_inode->i_ino, type, | 767 | old_dentry->d_inode->i_ino, type, |
754 | new_dentry->d_name.name, new_dentry->d_name.len); | 768 | new_dentry->d_name.name, new_dentry->d_name.len, now); |
755 | 769 | ||
756 | if (ret) | 770 | if (ret) |
757 | return ret; | 771 | return ret; |
@@ -768,14 +782,14 @@ static int jffs2_rename (struct inode *old_dir_i, struct dentry *old_dentry, | |||
768 | } | 782 | } |
769 | } | 783 | } |
770 | 784 | ||
771 | /* If it was a directory we moved, and there was no victim, | 785 | /* If it was a directory we moved, and there was no victim, |
772 | increase i_nlink on its new parent */ | 786 | increase i_nlink on its new parent */ |
773 | if (S_ISDIR(old_dentry->d_inode->i_mode) && !victim_f) | 787 | if (S_ISDIR(old_dentry->d_inode->i_mode) && !victim_f) |
774 | new_dir_i->i_nlink++; | 788 | new_dir_i->i_nlink++; |
775 | 789 | ||
776 | /* Unlink the original */ | 790 | /* Unlink the original */ |
777 | ret = jffs2_do_unlink(c, JFFS2_INODE_INFO(old_dir_i), | 791 | ret = jffs2_do_unlink(c, JFFS2_INODE_INFO(old_dir_i), |
778 | old_dentry->d_name.name, old_dentry->d_name.len, NULL); | 792 | old_dentry->d_name.name, old_dentry->d_name.len, NULL, now); |
779 | 793 | ||
780 | /* We don't touch inode->i_nlink */ | 794 | /* We don't touch inode->i_nlink */ |
781 | 795 | ||
@@ -792,12 +806,15 @@ static int jffs2_rename (struct inode *old_dir_i, struct dentry *old_dentry, | |||
792 | /* Might as well let the VFS know */ | 806 | /* Might as well let the VFS know */ |
793 | d_instantiate(new_dentry, old_dentry->d_inode); | 807 | d_instantiate(new_dentry, old_dentry->d_inode); |
794 | atomic_inc(&old_dentry->d_inode->i_count); | 808 | atomic_inc(&old_dentry->d_inode->i_count); |
809 | new_dir_i->i_mtime = new_dir_i->i_ctime = ITIME(now); | ||
795 | return ret; | 810 | return ret; |
796 | } | 811 | } |
797 | 812 | ||
798 | if (S_ISDIR(old_dentry->d_inode->i_mode)) | 813 | if (S_ISDIR(old_dentry->d_inode->i_mode)) |
799 | old_dir_i->i_nlink--; | 814 | old_dir_i->i_nlink--; |
800 | 815 | ||
816 | new_dir_i->i_mtime = new_dir_i->i_ctime = old_dir_i->i_mtime = old_dir_i->i_ctime = ITIME(now); | ||
817 | |||
801 | return 0; | 818 | return 0; |
802 | } | 819 | } |
803 | 820 | ||
diff --git a/fs/jffs2/erase.c b/fs/jffs2/erase.c index 787d84ac2bcd..dad68fdffe9e 100644 --- a/fs/jffs2/erase.c +++ b/fs/jffs2/erase.c | |||
@@ -7,7 +7,7 @@ | |||
7 | * | 7 | * |
8 | * For licensing information, see the file 'LICENCE' in this directory. | 8 | * For licensing information, see the file 'LICENCE' in this directory. |
9 | * | 9 | * |
10 | * $Id: erase.c,v 1.80 2005/07/14 19:46:24 joern Exp $ | 10 | * $Id: erase.c,v 1.85 2005/09/20 14:53:15 dedekind Exp $ |
11 | * | 11 | * |
12 | */ | 12 | */ |
13 | 13 | ||
@@ -24,7 +24,7 @@ struct erase_priv_struct { | |||
24 | struct jffs2_eraseblock *jeb; | 24 | struct jffs2_eraseblock *jeb; |
25 | struct jffs2_sb_info *c; | 25 | struct jffs2_sb_info *c; |
26 | }; | 26 | }; |
27 | 27 | ||
28 | #ifndef __ECOS | 28 | #ifndef __ECOS |
29 | static void jffs2_erase_callback(struct erase_info *); | 29 | static void jffs2_erase_callback(struct erase_info *); |
30 | #endif | 30 | #endif |
@@ -48,7 +48,8 @@ static void jffs2_erase_block(struct jffs2_sb_info *c, | |||
48 | #else /* Linux */ | 48 | #else /* Linux */ |
49 | struct erase_info *instr; | 49 | struct erase_info *instr; |
50 | 50 | ||
51 | D1(printk(KERN_DEBUG "jffs2_erase_block(): erase block %#x (range %#x-%#x)\n", jeb->offset, jeb->offset, jeb->offset + c->sector_size)); | 51 | D1(printk(KERN_DEBUG "jffs2_erase_block(): erase block %#08x (range %#08x-%#08x)\n", |
52 | jeb->offset, jeb->offset, jeb->offset + c->sector_size)); | ||
52 | instr = kmalloc(sizeof(struct erase_info) + sizeof(struct erase_priv_struct), GFP_KERNEL); | 53 | instr = kmalloc(sizeof(struct erase_info) + sizeof(struct erase_priv_struct), GFP_KERNEL); |
53 | if (!instr) { | 54 | if (!instr) { |
54 | printk(KERN_WARNING "kmalloc for struct erase_info in jffs2_erase_block failed. Refiling block for later\n"); | 55 | printk(KERN_WARNING "kmalloc for struct erase_info in jffs2_erase_block failed. Refiling block for later\n"); |
@@ -70,7 +71,7 @@ static void jffs2_erase_block(struct jffs2_sb_info *c, | |||
70 | instr->callback = jffs2_erase_callback; | 71 | instr->callback = jffs2_erase_callback; |
71 | instr->priv = (unsigned long)(&instr[1]); | 72 | instr->priv = (unsigned long)(&instr[1]); |
72 | instr->fail_addr = 0xffffffff; | 73 | instr->fail_addr = 0xffffffff; |
73 | 74 | ||
74 | ((struct erase_priv_struct *)instr->priv)->jeb = jeb; | 75 | ((struct erase_priv_struct *)instr->priv)->jeb = jeb; |
75 | ((struct erase_priv_struct *)instr->priv)->c = c; | 76 | ((struct erase_priv_struct *)instr->priv)->c = c; |
76 | 77 | ||
@@ -95,7 +96,7 @@ static void jffs2_erase_block(struct jffs2_sb_info *c, | |||
95 | return; | 96 | return; |
96 | } | 97 | } |
97 | 98 | ||
98 | if (ret == -EROFS) | 99 | if (ret == -EROFS) |
99 | printk(KERN_WARNING "Erase at 0x%08x failed immediately: -EROFS. Is the sector locked?\n", jeb->offset); | 100 | printk(KERN_WARNING "Erase at 0x%08x failed immediately: -EROFS. Is the sector locked?\n", jeb->offset); |
100 | else | 101 | else |
101 | printk(KERN_WARNING "Erase at 0x%08x failed immediately: errno %d\n", jeb->offset, ret); | 102 | printk(KERN_WARNING "Erase at 0x%08x failed immediately: errno %d\n", jeb->offset, ret); |
@@ -196,7 +197,7 @@ static void jffs2_erase_failed(struct jffs2_sb_info *c, struct jffs2_eraseblock | |||
196 | c->nr_erasing_blocks--; | 197 | c->nr_erasing_blocks--; |
197 | spin_unlock(&c->erase_completion_lock); | 198 | spin_unlock(&c->erase_completion_lock); |
198 | wake_up(&c->erase_wait); | 199 | wake_up(&c->erase_wait); |
199 | } | 200 | } |
200 | 201 | ||
201 | #ifndef __ECOS | 202 | #ifndef __ECOS |
202 | static void jffs2_erase_callback(struct erase_info *instr) | 203 | static void jffs2_erase_callback(struct erase_info *instr) |
@@ -208,7 +209,7 @@ static void jffs2_erase_callback(struct erase_info *instr) | |||
208 | jffs2_erase_failed(priv->c, priv->jeb, instr->fail_addr); | 209 | jffs2_erase_failed(priv->c, priv->jeb, instr->fail_addr); |
209 | } else { | 210 | } else { |
210 | jffs2_erase_succeeded(priv->c, priv->jeb); | 211 | jffs2_erase_succeeded(priv->c, priv->jeb); |
211 | } | 212 | } |
212 | kfree(instr); | 213 | kfree(instr); |
213 | } | 214 | } |
214 | #endif /* !__ECOS */ | 215 | #endif /* !__ECOS */ |
@@ -226,13 +227,13 @@ static inline void jffs2_remove_node_refs_from_ino_list(struct jffs2_sb_info *c, | |||
226 | /* Walk the inode's list once, removing any nodes from this eraseblock */ | 227 | /* Walk the inode's list once, removing any nodes from this eraseblock */ |
227 | while (1) { | 228 | while (1) { |
228 | if (!(*prev)->next_in_ino) { | 229 | if (!(*prev)->next_in_ino) { |
229 | /* We're looking at the jffs2_inode_cache, which is | 230 | /* We're looking at the jffs2_inode_cache, which is |
230 | at the end of the linked list. Stash it and continue | 231 | at the end of the linked list. Stash it and continue |
231 | from the beginning of the list */ | 232 | from the beginning of the list */ |
232 | ic = (struct jffs2_inode_cache *)(*prev); | 233 | ic = (struct jffs2_inode_cache *)(*prev); |
233 | prev = &ic->nodes; | 234 | prev = &ic->nodes; |
234 | continue; | 235 | continue; |
235 | } | 236 | } |
236 | 237 | ||
237 | if (SECTOR_ADDR((*prev)->flash_offset) == jeb->offset) { | 238 | if (SECTOR_ADDR((*prev)->flash_offset) == jeb->offset) { |
238 | /* It's in the block we're erasing */ | 239 | /* It's in the block we're erasing */ |
@@ -266,7 +267,7 @@ static inline void jffs2_remove_node_refs_from_ino_list(struct jffs2_sb_info *c, | |||
266 | printk(KERN_DEBUG "After remove_node_refs_from_ino_list: \n" KERN_DEBUG); | 267 | printk(KERN_DEBUG "After remove_node_refs_from_ino_list: \n" KERN_DEBUG); |
267 | 268 | ||
268 | this = ic->nodes; | 269 | this = ic->nodes; |
269 | 270 | ||
270 | while(this) { | 271 | while(this) { |
271 | printk( "0x%08x(%d)->", ref_offset(this), ref_flags(this)); | 272 | printk( "0x%08x(%d)->", ref_offset(this), ref_flags(this)); |
272 | if (++i == 5) { | 273 | if (++i == 5) { |
@@ -289,7 +290,7 @@ static void jffs2_free_all_node_refs(struct jffs2_sb_info *c, struct jffs2_erase | |||
289 | while(jeb->first_node) { | 290 | while(jeb->first_node) { |
290 | ref = jeb->first_node; | 291 | ref = jeb->first_node; |
291 | jeb->first_node = ref->next_phys; | 292 | jeb->first_node = ref->next_phys; |
292 | 293 | ||
293 | /* Remove from the inode-list */ | 294 | /* Remove from the inode-list */ |
294 | if (ref->next_in_ino) | 295 | if (ref->next_in_ino) |
295 | jffs2_remove_node_refs_from_ino_list(c, ref, jeb); | 296 | jffs2_remove_node_refs_from_ino_list(c, ref, jeb); |
@@ -306,7 +307,7 @@ static int jffs2_block_check_erase(struct jffs2_sb_info *c, struct jffs2_erasebl | |||
306 | uint32_t ofs; | 307 | uint32_t ofs; |
307 | size_t retlen; | 308 | size_t retlen; |
308 | int ret = -EIO; | 309 | int ret = -EIO; |
309 | 310 | ||
310 | ebuf = kmalloc(PAGE_SIZE, GFP_KERNEL); | 311 | ebuf = kmalloc(PAGE_SIZE, GFP_KERNEL); |
311 | if (!ebuf) { | 312 | if (!ebuf) { |
312 | printk(KERN_WARNING "Failed to allocate page buffer for verifying erase at 0x%08x. Refiling\n", jeb->offset); | 313 | printk(KERN_WARNING "Failed to allocate page buffer for verifying erase at 0x%08x. Refiling\n", jeb->offset); |
@@ -360,7 +361,7 @@ static void jffs2_mark_erased_block(struct jffs2_sb_info *c, struct jffs2_eraseb | |||
360 | case -EIO: goto filebad; | 361 | case -EIO: goto filebad; |
361 | } | 362 | } |
362 | 363 | ||
363 | /* Write the erase complete marker */ | 364 | /* Write the erase complete marker */ |
364 | D1(printk(KERN_DEBUG "Writing erased marker to block at 0x%08x\n", jeb->offset)); | 365 | D1(printk(KERN_DEBUG "Writing erased marker to block at 0x%08x\n", jeb->offset)); |
365 | bad_offset = jeb->offset; | 366 | bad_offset = jeb->offset; |
366 | 367 | ||
@@ -398,7 +399,7 @@ static void jffs2_mark_erased_block(struct jffs2_sb_info *c, struct jffs2_eraseb | |||
398 | vecs[0].iov_base = (unsigned char *) ▮ | 399 | vecs[0].iov_base = (unsigned char *) ▮ |
399 | vecs[0].iov_len = sizeof(marker); | 400 | vecs[0].iov_len = sizeof(marker); |
400 | ret = jffs2_flash_direct_writev(c, vecs, 1, jeb->offset, &retlen); | 401 | ret = jffs2_flash_direct_writev(c, vecs, 1, jeb->offset, &retlen); |
401 | 402 | ||
402 | if (ret || retlen != sizeof(marker)) { | 403 | if (ret || retlen != sizeof(marker)) { |
403 | if (ret) | 404 | if (ret) |
404 | printk(KERN_WARNING "Write clean marker to block at 0x%08x failed: %d\n", | 405 | printk(KERN_WARNING "Write clean marker to block at 0x%08x failed: %d\n", |
@@ -415,9 +416,9 @@ static void jffs2_mark_erased_block(struct jffs2_sb_info *c, struct jffs2_eraseb | |||
415 | marker_ref->next_phys = NULL; | 416 | marker_ref->next_phys = NULL; |
416 | marker_ref->flash_offset = jeb->offset | REF_NORMAL; | 417 | marker_ref->flash_offset = jeb->offset | REF_NORMAL; |
417 | marker_ref->__totlen = c->cleanmarker_size; | 418 | marker_ref->__totlen = c->cleanmarker_size; |
418 | 419 | ||
419 | jeb->first_node = jeb->last_node = marker_ref; | 420 | jeb->first_node = jeb->last_node = marker_ref; |
420 | 421 | ||
421 | jeb->free_size = c->sector_size - c->cleanmarker_size; | 422 | jeb->free_size = c->sector_size - c->cleanmarker_size; |
422 | jeb->used_size = c->cleanmarker_size; | 423 | jeb->used_size = c->cleanmarker_size; |
423 | jeb->dirty_size = 0; | 424 | jeb->dirty_size = 0; |
@@ -429,8 +430,8 @@ static void jffs2_mark_erased_block(struct jffs2_sb_info *c, struct jffs2_eraseb | |||
429 | c->free_size += jeb->free_size; | 430 | c->free_size += jeb->free_size; |
430 | c->used_size += jeb->used_size; | 431 | c->used_size += jeb->used_size; |
431 | 432 | ||
432 | ACCT_SANITY_CHECK(c,jeb); | 433 | jffs2_dbg_acct_sanity_check_nolock(c,jeb); |
433 | D1(ACCT_PARANOIA_CHECK(jeb)); | 434 | jffs2_dbg_acct_paranoia_check_nolock(c, jeb); |
434 | 435 | ||
435 | list_add_tail(&jeb->list, &c->free_list); | 436 | list_add_tail(&jeb->list, &c->free_list); |
436 | c->nr_erasing_blocks--; | 437 | c->nr_erasing_blocks--; |
diff --git a/fs/jffs2/file.c b/fs/jffs2/file.c index 8279bf0133ff..935f273dc57b 100644 --- a/fs/jffs2/file.c +++ b/fs/jffs2/file.c | |||
@@ -7,7 +7,7 @@ | |||
7 | * | 7 | * |
8 | * For licensing information, see the file 'LICENCE' in this directory. | 8 | * For licensing information, see the file 'LICENCE' in this directory. |
9 | * | 9 | * |
10 | * $Id: file.c,v 1.102 2005/07/06 12:13:09 dwmw2 Exp $ | 10 | * $Id: file.c,v 1.104 2005/10/18 23:29:35 tpoynor Exp $ |
11 | * | 11 | * |
12 | */ | 12 | */ |
13 | 13 | ||
@@ -34,8 +34,8 @@ int jffs2_fsync(struct file *filp, struct dentry *dentry, int datasync) | |||
34 | 34 | ||
35 | /* Trigger GC to flush any pending writes for this inode */ | 35 | /* Trigger GC to flush any pending writes for this inode */ |
36 | jffs2_flush_wbuf_gc(c, inode->i_ino); | 36 | jffs2_flush_wbuf_gc(c, inode->i_ino); |
37 | 37 | ||
38 | return 0; | 38 | return 0; |
39 | } | 39 | } |
40 | 40 | ||
41 | struct file_operations jffs2_file_operations = | 41 | struct file_operations jffs2_file_operations = |
@@ -107,7 +107,7 @@ static int jffs2_readpage (struct file *filp, struct page *pg) | |||
107 | { | 107 | { |
108 | struct jffs2_inode_info *f = JFFS2_INODE_INFO(pg->mapping->host); | 108 | struct jffs2_inode_info *f = JFFS2_INODE_INFO(pg->mapping->host); |
109 | int ret; | 109 | int ret; |
110 | 110 | ||
111 | down(&f->sem); | 111 | down(&f->sem); |
112 | ret = jffs2_do_readpage_unlock(pg->mapping->host, pg); | 112 | ret = jffs2_do_readpage_unlock(pg->mapping->host, pg); |
113 | up(&f->sem); | 113 | up(&f->sem); |
@@ -130,11 +130,12 @@ static int jffs2_prepare_write (struct file *filp, struct page *pg, | |||
130 | struct jffs2_raw_inode ri; | 130 | struct jffs2_raw_inode ri; |
131 | struct jffs2_full_dnode *fn; | 131 | struct jffs2_full_dnode *fn; |
132 | uint32_t phys_ofs, alloc_len; | 132 | uint32_t phys_ofs, alloc_len; |
133 | 133 | ||
134 | D1(printk(KERN_DEBUG "Writing new hole frag 0x%x-0x%x between current EOF and new page\n", | 134 | D1(printk(KERN_DEBUG "Writing new hole frag 0x%x-0x%x between current EOF and new page\n", |
135 | (unsigned int)inode->i_size, pageofs)); | 135 | (unsigned int)inode->i_size, pageofs)); |
136 | 136 | ||
137 | ret = jffs2_reserve_space(c, sizeof(ri), &phys_ofs, &alloc_len, ALLOC_NORMAL); | 137 | ret = jffs2_reserve_space(c, sizeof(ri), &phys_ofs, &alloc_len, |
138 | ALLOC_NORMAL, JFFS2_SUMMARY_INODE_SIZE); | ||
138 | if (ret) | 139 | if (ret) |
139 | return ret; | 140 | return ret; |
140 | 141 | ||
@@ -159,7 +160,7 @@ static int jffs2_prepare_write (struct file *filp, struct page *pg, | |||
159 | ri.compr = JFFS2_COMPR_ZERO; | 160 | ri.compr = JFFS2_COMPR_ZERO; |
160 | ri.node_crc = cpu_to_je32(crc32(0, &ri, sizeof(ri)-8)); | 161 | ri.node_crc = cpu_to_je32(crc32(0, &ri, sizeof(ri)-8)); |
161 | ri.data_crc = cpu_to_je32(0); | 162 | ri.data_crc = cpu_to_je32(0); |
162 | 163 | ||
163 | fn = jffs2_write_dnode(c, f, &ri, NULL, 0, phys_ofs, ALLOC_NORMAL); | 164 | fn = jffs2_write_dnode(c, f, &ri, NULL, 0, phys_ofs, ALLOC_NORMAL); |
164 | 165 | ||
165 | if (IS_ERR(fn)) { | 166 | if (IS_ERR(fn)) { |
@@ -186,7 +187,7 @@ static int jffs2_prepare_write (struct file *filp, struct page *pg, | |||
186 | inode->i_size = pageofs; | 187 | inode->i_size = pageofs; |
187 | up(&f->sem); | 188 | up(&f->sem); |
188 | } | 189 | } |
189 | 190 | ||
190 | /* Read in the page if it wasn't already present, unless it's a whole page */ | 191 | /* Read in the page if it wasn't already present, unless it's a whole page */ |
191 | if (!PageUptodate(pg) && (start || end < PAGE_CACHE_SIZE)) { | 192 | if (!PageUptodate(pg) && (start || end < PAGE_CACHE_SIZE)) { |
192 | down(&f->sem); | 193 | down(&f->sem); |
@@ -217,7 +218,7 @@ static int jffs2_commit_write (struct file *filp, struct page *pg, | |||
217 | if (!start && end == PAGE_CACHE_SIZE) { | 218 | if (!start && end == PAGE_CACHE_SIZE) { |
218 | /* We need to avoid deadlock with page_cache_read() in | 219 | /* We need to avoid deadlock with page_cache_read() in |
219 | jffs2_garbage_collect_pass(). So we have to mark the | 220 | jffs2_garbage_collect_pass(). So we have to mark the |
220 | page up to date, to prevent page_cache_read() from | 221 | page up to date, to prevent page_cache_read() from |
221 | trying to re-lock it. */ | 222 | trying to re-lock it. */ |
222 | SetPageUptodate(pg); | 223 | SetPageUptodate(pg); |
223 | } | 224 | } |
@@ -251,7 +252,7 @@ static int jffs2_commit_write (struct file *filp, struct page *pg, | |||
251 | /* There was an error writing. */ | 252 | /* There was an error writing. */ |
252 | SetPageError(pg); | 253 | SetPageError(pg); |
253 | } | 254 | } |
254 | 255 | ||
255 | /* Adjust writtenlen for the padding we did, so we don't confuse our caller */ | 256 | /* Adjust writtenlen for the padding we did, so we don't confuse our caller */ |
256 | if (writtenlen < (start&3)) | 257 | if (writtenlen < (start&3)) |
257 | writtenlen = 0; | 258 | writtenlen = 0; |
@@ -262,7 +263,7 @@ static int jffs2_commit_write (struct file *filp, struct page *pg, | |||
262 | if (inode->i_size < (pg->index << PAGE_CACHE_SHIFT) + start + writtenlen) { | 263 | if (inode->i_size < (pg->index << PAGE_CACHE_SHIFT) + start + writtenlen) { |
263 | inode->i_size = (pg->index << PAGE_CACHE_SHIFT) + start + writtenlen; | 264 | inode->i_size = (pg->index << PAGE_CACHE_SHIFT) + start + writtenlen; |
264 | inode->i_blocks = (inode->i_size + 511) >> 9; | 265 | inode->i_blocks = (inode->i_size + 511) >> 9; |
265 | 266 | ||
266 | inode->i_ctime = inode->i_mtime = ITIME(je32_to_cpu(ri->ctime)); | 267 | inode->i_ctime = inode->i_mtime = ITIME(je32_to_cpu(ri->ctime)); |
267 | } | 268 | } |
268 | } | 269 | } |
@@ -271,13 +272,13 @@ static int jffs2_commit_write (struct file *filp, struct page *pg, | |||
271 | 272 | ||
272 | if (start+writtenlen < end) { | 273 | if (start+writtenlen < end) { |
273 | /* generic_file_write has written more to the page cache than we've | 274 | /* generic_file_write has written more to the page cache than we've |
274 | actually written to the medium. Mark the page !Uptodate so that | 275 | actually written to the medium. Mark the page !Uptodate so that |
275 | it gets reread */ | 276 | it gets reread */ |
276 | D1(printk(KERN_DEBUG "jffs2_commit_write(): Not all bytes written. Marking page !uptodate\n")); | 277 | D1(printk(KERN_DEBUG "jffs2_commit_write(): Not all bytes written. Marking page !uptodate\n")); |
277 | SetPageError(pg); | 278 | SetPageError(pg); |
278 | ClearPageUptodate(pg); | 279 | ClearPageUptodate(pg); |
279 | } | 280 | } |
280 | 281 | ||
281 | D1(printk(KERN_DEBUG "jffs2_commit_write() returning %d\n",writtenlen?writtenlen:ret)); | 282 | D1(printk(KERN_DEBUG "jffs2_commit_write() returning %d\n",start+writtenlen==end?0:ret)); |
282 | return writtenlen?writtenlen:ret; | 283 | return start+writtenlen==end?0:ret; |
283 | } | 284 | } |
diff --git a/fs/jffs2/fs.c b/fs/jffs2/fs.c index 5687c3f42002..543420665c5b 100644 --- a/fs/jffs2/fs.c +++ b/fs/jffs2/fs.c | |||
@@ -7,7 +7,7 @@ | |||
7 | * | 7 | * |
8 | * For licensing information, see the file 'LICENCE' in this directory. | 8 | * For licensing information, see the file 'LICENCE' in this directory. |
9 | * | 9 | * |
10 | * $Id: fs.c,v 1.56 2005/07/06 12:13:09 dwmw2 Exp $ | 10 | * $Id: fs.c,v 1.66 2005/09/27 13:17:29 dedekind Exp $ |
11 | * | 11 | * |
12 | */ | 12 | */ |
13 | 13 | ||
@@ -40,7 +40,7 @@ static int jffs2_do_setattr (struct inode *inode, struct iattr *iattr) | |||
40 | int ret; | 40 | int ret; |
41 | D1(printk(KERN_DEBUG "jffs2_setattr(): ino #%lu\n", inode->i_ino)); | 41 | D1(printk(KERN_DEBUG "jffs2_setattr(): ino #%lu\n", inode->i_ino)); |
42 | ret = inode_change_ok(inode, iattr); | 42 | ret = inode_change_ok(inode, iattr); |
43 | if (ret) | 43 | if (ret) |
44 | return ret; | 44 | return ret; |
45 | 45 | ||
46 | /* Special cases - we don't want more than one data node | 46 | /* Special cases - we don't want more than one data node |
@@ -73,8 +73,9 @@ static int jffs2_do_setattr (struct inode *inode, struct iattr *iattr) | |||
73 | kfree(mdata); | 73 | kfree(mdata); |
74 | return -ENOMEM; | 74 | return -ENOMEM; |
75 | } | 75 | } |
76 | 76 | ||
77 | ret = jffs2_reserve_space(c, sizeof(*ri) + mdatalen, &phys_ofs, &alloclen, ALLOC_NORMAL); | 77 | ret = jffs2_reserve_space(c, sizeof(*ri) + mdatalen, &phys_ofs, &alloclen, |
78 | ALLOC_NORMAL, JFFS2_SUMMARY_INODE_SIZE); | ||
78 | if (ret) { | 79 | if (ret) { |
79 | jffs2_free_raw_inode(ri); | 80 | jffs2_free_raw_inode(ri); |
80 | if (S_ISLNK(inode->i_mode & S_IFMT)) | 81 | if (S_ISLNK(inode->i_mode & S_IFMT)) |
@@ -83,7 +84,7 @@ static int jffs2_do_setattr (struct inode *inode, struct iattr *iattr) | |||
83 | } | 84 | } |
84 | down(&f->sem); | 85 | down(&f->sem); |
85 | ivalid = iattr->ia_valid; | 86 | ivalid = iattr->ia_valid; |
86 | 87 | ||
87 | ri->magic = cpu_to_je16(JFFS2_MAGIC_BITMASK); | 88 | ri->magic = cpu_to_je16(JFFS2_MAGIC_BITMASK); |
88 | ri->nodetype = cpu_to_je16(JFFS2_NODETYPE_INODE); | 89 | ri->nodetype = cpu_to_je16(JFFS2_NODETYPE_INODE); |
89 | ri->totlen = cpu_to_je32(sizeof(*ri) + mdatalen); | 90 | ri->totlen = cpu_to_je32(sizeof(*ri) + mdatalen); |
@@ -99,7 +100,7 @@ static int jffs2_do_setattr (struct inode *inode, struct iattr *iattr) | |||
99 | if (iattr->ia_mode & S_ISGID && | 100 | if (iattr->ia_mode & S_ISGID && |
100 | !in_group_p(je16_to_cpu(ri->gid)) && !capable(CAP_FSETID)) | 101 | !in_group_p(je16_to_cpu(ri->gid)) && !capable(CAP_FSETID)) |
101 | ri->mode = cpu_to_jemode(iattr->ia_mode & ~S_ISGID); | 102 | ri->mode = cpu_to_jemode(iattr->ia_mode & ~S_ISGID); |
102 | else | 103 | else |
103 | ri->mode = cpu_to_jemode(iattr->ia_mode); | 104 | ri->mode = cpu_to_jemode(iattr->ia_mode); |
104 | else | 105 | else |
105 | ri->mode = cpu_to_jemode(inode->i_mode); | 106 | ri->mode = cpu_to_jemode(inode->i_mode); |
@@ -128,7 +129,7 @@ static int jffs2_do_setattr (struct inode *inode, struct iattr *iattr) | |||
128 | new_metadata = jffs2_write_dnode(c, f, ri, mdata, mdatalen, phys_ofs, ALLOC_NORMAL); | 129 | new_metadata = jffs2_write_dnode(c, f, ri, mdata, mdatalen, phys_ofs, ALLOC_NORMAL); |
129 | if (S_ISLNK(inode->i_mode)) | 130 | if (S_ISLNK(inode->i_mode)) |
130 | kfree(mdata); | 131 | kfree(mdata); |
131 | 132 | ||
132 | if (IS_ERR(new_metadata)) { | 133 | if (IS_ERR(new_metadata)) { |
133 | jffs2_complete_reservation(c); | 134 | jffs2_complete_reservation(c); |
134 | jffs2_free_raw_inode(ri); | 135 | jffs2_free_raw_inode(ri); |
@@ -147,7 +148,7 @@ static int jffs2_do_setattr (struct inode *inode, struct iattr *iattr) | |||
147 | old_metadata = f->metadata; | 148 | old_metadata = f->metadata; |
148 | 149 | ||
149 | if (ivalid & ATTR_SIZE && inode->i_size > iattr->ia_size) | 150 | if (ivalid & ATTR_SIZE && inode->i_size > iattr->ia_size) |
150 | jffs2_truncate_fraglist (c, &f->fragtree, iattr->ia_size); | 151 | jffs2_truncate_fragtree (c, &f->fragtree, iattr->ia_size); |
151 | 152 | ||
152 | if (ivalid & ATTR_SIZE && inode->i_size < iattr->ia_size) { | 153 | if (ivalid & ATTR_SIZE && inode->i_size < iattr->ia_size) { |
153 | jffs2_add_full_dnode_to_inode(c, f, new_metadata); | 154 | jffs2_add_full_dnode_to_inode(c, f, new_metadata); |
@@ -166,7 +167,7 @@ static int jffs2_do_setattr (struct inode *inode, struct iattr *iattr) | |||
166 | jffs2_complete_reservation(c); | 167 | jffs2_complete_reservation(c); |
167 | 168 | ||
168 | /* We have to do the vmtruncate() without f->sem held, since | 169 | /* We have to do the vmtruncate() without f->sem held, since |
169 | some pages may be locked and waiting for it in readpage(). | 170 | some pages may be locked and waiting for it in readpage(). |
170 | We are protected from a simultaneous write() extending i_size | 171 | We are protected from a simultaneous write() extending i_size |
171 | back past iattr->ia_size, because do_truncate() holds the | 172 | back past iattr->ia_size, because do_truncate() holds the |
172 | generic inode semaphore. */ | 173 | generic inode semaphore. */ |
@@ -194,31 +195,27 @@ int jffs2_statfs(struct super_block *sb, struct kstatfs *buf) | |||
194 | buf->f_namelen = JFFS2_MAX_NAME_LEN; | 195 | buf->f_namelen = JFFS2_MAX_NAME_LEN; |
195 | 196 | ||
196 | spin_lock(&c->erase_completion_lock); | 197 | spin_lock(&c->erase_completion_lock); |
197 | |||
198 | avail = c->dirty_size + c->free_size; | 198 | avail = c->dirty_size + c->free_size; |
199 | if (avail > c->sector_size * c->resv_blocks_write) | 199 | if (avail > c->sector_size * c->resv_blocks_write) |
200 | avail -= c->sector_size * c->resv_blocks_write; | 200 | avail -= c->sector_size * c->resv_blocks_write; |
201 | else | 201 | else |
202 | avail = 0; | 202 | avail = 0; |
203 | spin_unlock(&c->erase_completion_lock); | ||
203 | 204 | ||
204 | buf->f_bavail = buf->f_bfree = avail >> PAGE_SHIFT; | 205 | buf->f_bavail = buf->f_bfree = avail >> PAGE_SHIFT; |
205 | 206 | ||
206 | D2(jffs2_dump_block_lists(c)); | ||
207 | |||
208 | spin_unlock(&c->erase_completion_lock); | ||
209 | |||
210 | return 0; | 207 | return 0; |
211 | } | 208 | } |
212 | 209 | ||
213 | 210 | ||
214 | void jffs2_clear_inode (struct inode *inode) | 211 | void jffs2_clear_inode (struct inode *inode) |
215 | { | 212 | { |
216 | /* We can forget about this inode for now - drop all | 213 | /* We can forget about this inode for now - drop all |
217 | * the nodelists associated with it, etc. | 214 | * the nodelists associated with it, etc. |
218 | */ | 215 | */ |
219 | struct jffs2_sb_info *c = JFFS2_SB_INFO(inode->i_sb); | 216 | struct jffs2_sb_info *c = JFFS2_SB_INFO(inode->i_sb); |
220 | struct jffs2_inode_info *f = JFFS2_INODE_INFO(inode); | 217 | struct jffs2_inode_info *f = JFFS2_INODE_INFO(inode); |
221 | 218 | ||
222 | D1(printk(KERN_DEBUG "jffs2_clear_inode(): ino #%lu mode %o\n", inode->i_ino, inode->i_mode)); | 219 | D1(printk(KERN_DEBUG "jffs2_clear_inode(): ino #%lu mode %o\n", inode->i_ino, inode->i_mode)); |
223 | 220 | ||
224 | jffs2_do_clear_inode(c, f); | 221 | jffs2_do_clear_inode(c, f); |
@@ -237,7 +234,7 @@ void jffs2_read_inode (struct inode *inode) | |||
237 | c = JFFS2_SB_INFO(inode->i_sb); | 234 | c = JFFS2_SB_INFO(inode->i_sb); |
238 | 235 | ||
239 | jffs2_init_inode_info(f); | 236 | jffs2_init_inode_info(f); |
240 | 237 | ||
241 | ret = jffs2_do_read_inode(c, f, inode->i_ino, &latest_node); | 238 | ret = jffs2_do_read_inode(c, f, inode->i_ino, &latest_node); |
242 | 239 | ||
243 | if (ret) { | 240 | if (ret) { |
@@ -257,14 +254,14 @@ void jffs2_read_inode (struct inode *inode) | |||
257 | 254 | ||
258 | inode->i_blksize = PAGE_SIZE; | 255 | inode->i_blksize = PAGE_SIZE; |
259 | inode->i_blocks = (inode->i_size + 511) >> 9; | 256 | inode->i_blocks = (inode->i_size + 511) >> 9; |
260 | 257 | ||
261 | switch (inode->i_mode & S_IFMT) { | 258 | switch (inode->i_mode & S_IFMT) { |
262 | jint16_t rdev; | 259 | jint16_t rdev; |
263 | 260 | ||
264 | case S_IFLNK: | 261 | case S_IFLNK: |
265 | inode->i_op = &jffs2_symlink_inode_operations; | 262 | inode->i_op = &jffs2_symlink_inode_operations; |
266 | break; | 263 | break; |
267 | 264 | ||
268 | case S_IFDIR: | 265 | case S_IFDIR: |
269 | { | 266 | { |
270 | struct jffs2_full_dirent *fd; | 267 | struct jffs2_full_dirent *fd; |
@@ -301,7 +298,7 @@ void jffs2_read_inode (struct inode *inode) | |||
301 | jffs2_do_clear_inode(c, f); | 298 | jffs2_do_clear_inode(c, f); |
302 | make_bad_inode(inode); | 299 | make_bad_inode(inode); |
303 | return; | 300 | return; |
304 | } | 301 | } |
305 | 302 | ||
306 | case S_IFSOCK: | 303 | case S_IFSOCK: |
307 | case S_IFIFO: | 304 | case S_IFIFO: |
@@ -357,11 +354,11 @@ int jffs2_remount_fs (struct super_block *sb, int *flags, char *data) | |||
357 | down(&c->alloc_sem); | 354 | down(&c->alloc_sem); |
358 | jffs2_flush_wbuf_pad(c); | 355 | jffs2_flush_wbuf_pad(c); |
359 | up(&c->alloc_sem); | 356 | up(&c->alloc_sem); |
360 | } | 357 | } |
361 | 358 | ||
362 | if (!(*flags & MS_RDONLY)) | 359 | if (!(*flags & MS_RDONLY)) |
363 | jffs2_start_garbage_collect_thread(c); | 360 | jffs2_start_garbage_collect_thread(c); |
364 | 361 | ||
365 | *flags |= MS_NOATIME; | 362 | *flags |= MS_NOATIME; |
366 | 363 | ||
367 | return 0; | 364 | return 0; |
@@ -395,9 +392,9 @@ struct inode *jffs2_new_inode (struct inode *dir_i, int mode, struct jffs2_raw_i | |||
395 | D1(printk(KERN_DEBUG "jffs2_new_inode(): dir_i %ld, mode 0x%x\n", dir_i->i_ino, mode)); | 392 | D1(printk(KERN_DEBUG "jffs2_new_inode(): dir_i %ld, mode 0x%x\n", dir_i->i_ino, mode)); |
396 | 393 | ||
397 | c = JFFS2_SB_INFO(sb); | 394 | c = JFFS2_SB_INFO(sb); |
398 | 395 | ||
399 | inode = new_inode(sb); | 396 | inode = new_inode(sb); |
400 | 397 | ||
401 | if (!inode) | 398 | if (!inode) |
402 | return ERR_PTR(-ENOMEM); | 399 | return ERR_PTR(-ENOMEM); |
403 | 400 | ||
@@ -461,40 +458,24 @@ int jffs2_do_fill_super(struct super_block *sb, void *data, int silent) | |||
461 | #endif | 458 | #endif |
462 | 459 | ||
463 | c->flash_size = c->mtd->size; | 460 | c->flash_size = c->mtd->size; |
464 | 461 | c->sector_size = c->mtd->erasesize; | |
465 | /* | ||
466 | * Check, if we have to concatenate physical blocks to larger virtual blocks | ||
467 | * to reduce the memorysize for c->blocks. (kmalloc allows max. 128K allocation) | ||
468 | */ | ||
469 | c->sector_size = c->mtd->erasesize; | ||
470 | blocks = c->flash_size / c->sector_size; | 462 | blocks = c->flash_size / c->sector_size; |
471 | if (!(c->mtd->flags & MTD_NO_VIRTBLOCKS)) { | ||
472 | while ((blocks * sizeof (struct jffs2_eraseblock)) > (128 * 1024)) { | ||
473 | blocks >>= 1; | ||
474 | c->sector_size <<= 1; | ||
475 | } | ||
476 | } | ||
477 | 463 | ||
478 | /* | 464 | /* |
479 | * Size alignment check | 465 | * Size alignment check |
480 | */ | 466 | */ |
481 | if ((c->sector_size * blocks) != c->flash_size) { | 467 | if ((c->sector_size * blocks) != c->flash_size) { |
482 | c->flash_size = c->sector_size * blocks; | 468 | c->flash_size = c->sector_size * blocks; |
483 | printk(KERN_INFO "jffs2: Flash size not aligned to erasesize, reducing to %dKiB\n", | 469 | printk(KERN_INFO "jffs2: Flash size not aligned to erasesize, reducing to %dKiB\n", |
484 | c->flash_size / 1024); | 470 | c->flash_size / 1024); |
485 | } | 471 | } |
486 | 472 | ||
487 | if (c->sector_size != c->mtd->erasesize) | ||
488 | printk(KERN_INFO "jffs2: Erase block size too small (%dKiB). Using virtual blocks size (%dKiB) instead\n", | ||
489 | c->mtd->erasesize / 1024, c->sector_size / 1024); | ||
490 | |||
491 | if (c->flash_size < 5*c->sector_size) { | 473 | if (c->flash_size < 5*c->sector_size) { |
492 | printk(KERN_ERR "jffs2: Too few erase blocks (%d)\n", c->flash_size / c->sector_size); | 474 | printk(KERN_ERR "jffs2: Too few erase blocks (%d)\n", c->flash_size / c->sector_size); |
493 | return -EINVAL; | 475 | return -EINVAL; |
494 | } | 476 | } |
495 | 477 | ||
496 | c->cleanmarker_size = sizeof(struct jffs2_unknown_node); | 478 | c->cleanmarker_size = sizeof(struct jffs2_unknown_node); |
497 | /* Joern -- stick alignment for weird 8-byte-page flash here */ | ||
498 | 479 | ||
499 | /* NAND (or other bizarre) flash... do setup accordingly */ | 480 | /* NAND (or other bizarre) flash... do setup accordingly */ |
500 | ret = jffs2_flash_setup(c); | 481 | ret = jffs2_flash_setup(c); |
@@ -517,7 +498,7 @@ int jffs2_do_fill_super(struct super_block *sb, void *data, int silent) | |||
517 | root_i = iget(sb, 1); | 498 | root_i = iget(sb, 1); |
518 | if (is_bad_inode(root_i)) { | 499 | if (is_bad_inode(root_i)) { |
519 | D1(printk(KERN_WARNING "get root inode failed\n")); | 500 | D1(printk(KERN_WARNING "get root inode failed\n")); |
520 | goto out_nodes; | 501 | goto out_root_i; |
521 | } | 502 | } |
522 | 503 | ||
523 | D1(printk(KERN_DEBUG "jffs2_do_fill_super(): d_alloc_root()\n")); | 504 | D1(printk(KERN_DEBUG "jffs2_do_fill_super(): d_alloc_root()\n")); |
@@ -535,10 +516,9 @@ int jffs2_do_fill_super(struct super_block *sb, void *data, int silent) | |||
535 | 516 | ||
536 | out_root_i: | 517 | out_root_i: |
537 | iput(root_i); | 518 | iput(root_i); |
538 | out_nodes: | ||
539 | jffs2_free_ino_caches(c); | 519 | jffs2_free_ino_caches(c); |
540 | jffs2_free_raw_node_refs(c); | 520 | jffs2_free_raw_node_refs(c); |
541 | if (c->mtd->flags & MTD_NO_VIRTBLOCKS) | 521 | if (jffs2_blocks_use_vmalloc(c)) |
542 | vfree(c->blocks); | 522 | vfree(c->blocks); |
543 | else | 523 | else |
544 | kfree(c->blocks); | 524 | kfree(c->blocks); |
@@ -563,16 +543,16 @@ struct jffs2_inode_info *jffs2_gc_fetch_inode(struct jffs2_sb_info *c, | |||
563 | struct jffs2_inode_cache *ic; | 543 | struct jffs2_inode_cache *ic; |
564 | if (!nlink) { | 544 | if (!nlink) { |
565 | /* The inode has zero nlink but its nodes weren't yet marked | 545 | /* The inode has zero nlink but its nodes weren't yet marked |
566 | obsolete. This has to be because we're still waiting for | 546 | obsolete. This has to be because we're still waiting for |
567 | the final (close() and) iput() to happen. | 547 | the final (close() and) iput() to happen. |
568 | 548 | ||
569 | There's a possibility that the final iput() could have | 549 | There's a possibility that the final iput() could have |
570 | happened while we were contemplating. In order to ensure | 550 | happened while we were contemplating. In order to ensure |
571 | that we don't cause a new read_inode() (which would fail) | 551 | that we don't cause a new read_inode() (which would fail) |
572 | for the inode in question, we use ilookup() in this case | 552 | for the inode in question, we use ilookup() in this case |
573 | instead of iget(). | 553 | instead of iget(). |
574 | 554 | ||
575 | The nlink can't _become_ zero at this point because we're | 555 | The nlink can't _become_ zero at this point because we're |
576 | holding the alloc_sem, and jffs2_do_unlink() would also | 556 | holding the alloc_sem, and jffs2_do_unlink() would also |
577 | need that while decrementing nlink on any inode. | 557 | need that while decrementing nlink on any inode. |
578 | */ | 558 | */ |
@@ -619,19 +599,19 @@ struct jffs2_inode_info *jffs2_gc_fetch_inode(struct jffs2_sb_info *c, | |||
619 | return JFFS2_INODE_INFO(inode); | 599 | return JFFS2_INODE_INFO(inode); |
620 | } | 600 | } |
621 | 601 | ||
622 | unsigned char *jffs2_gc_fetch_page(struct jffs2_sb_info *c, | 602 | unsigned char *jffs2_gc_fetch_page(struct jffs2_sb_info *c, |
623 | struct jffs2_inode_info *f, | 603 | struct jffs2_inode_info *f, |
624 | unsigned long offset, | 604 | unsigned long offset, |
625 | unsigned long *priv) | 605 | unsigned long *priv) |
626 | { | 606 | { |
627 | struct inode *inode = OFNI_EDONI_2SFFJ(f); | 607 | struct inode *inode = OFNI_EDONI_2SFFJ(f); |
628 | struct page *pg; | 608 | struct page *pg; |
629 | 609 | ||
630 | pg = read_cache_page(inode->i_mapping, offset >> PAGE_CACHE_SHIFT, | 610 | pg = read_cache_page(inode->i_mapping, offset >> PAGE_CACHE_SHIFT, |
631 | (void *)jffs2_do_readpage_unlock, inode); | 611 | (void *)jffs2_do_readpage_unlock, inode); |
632 | if (IS_ERR(pg)) | 612 | if (IS_ERR(pg)) |
633 | return (void *)pg; | 613 | return (void *)pg; |
634 | 614 | ||
635 | *priv = (unsigned long)pg; | 615 | *priv = (unsigned long)pg; |
636 | return kmap(pg); | 616 | return kmap(pg); |
637 | } | 617 | } |
@@ -648,7 +628,7 @@ void jffs2_gc_release_page(struct jffs2_sb_info *c, | |||
648 | 628 | ||
649 | static int jffs2_flash_setup(struct jffs2_sb_info *c) { | 629 | static int jffs2_flash_setup(struct jffs2_sb_info *c) { |
650 | int ret = 0; | 630 | int ret = 0; |
651 | 631 | ||
652 | if (jffs2_cleanmarker_oob(c)) { | 632 | if (jffs2_cleanmarker_oob(c)) { |
653 | /* NAND flash... do setup accordingly */ | 633 | /* NAND flash... do setup accordingly */ |
654 | ret = jffs2_nand_flash_setup(c); | 634 | ret = jffs2_nand_flash_setup(c); |
@@ -662,14 +642,21 @@ static int jffs2_flash_setup(struct jffs2_sb_info *c) { | |||
662 | if (ret) | 642 | if (ret) |
663 | return ret; | 643 | return ret; |
664 | } | 644 | } |
665 | 645 | ||
666 | /* and Dataflash */ | 646 | /* and Dataflash */ |
667 | if (jffs2_dataflash(c)) { | 647 | if (jffs2_dataflash(c)) { |
668 | ret = jffs2_dataflash_setup(c); | 648 | ret = jffs2_dataflash_setup(c); |
669 | if (ret) | 649 | if (ret) |
670 | return ret; | 650 | return ret; |
671 | } | 651 | } |
672 | 652 | ||
653 | /* and Intel "Sibley" flash */ | ||
654 | if (jffs2_nor_wbuf_flash(c)) { | ||
655 | ret = jffs2_nor_wbuf_flash_setup(c); | ||
656 | if (ret) | ||
657 | return ret; | ||
658 | } | ||
659 | |||
673 | return ret; | 660 | return ret; |
674 | } | 661 | } |
675 | 662 | ||
@@ -683,9 +670,14 @@ void jffs2_flash_cleanup(struct jffs2_sb_info *c) { | |||
683 | if (jffs2_nor_ecc(c)) { | 670 | if (jffs2_nor_ecc(c)) { |
684 | jffs2_nor_ecc_flash_cleanup(c); | 671 | jffs2_nor_ecc_flash_cleanup(c); |
685 | } | 672 | } |
686 | 673 | ||
687 | /* and DataFlash */ | 674 | /* and DataFlash */ |
688 | if (jffs2_dataflash(c)) { | 675 | if (jffs2_dataflash(c)) { |
689 | jffs2_dataflash_cleanup(c); | 676 | jffs2_dataflash_cleanup(c); |
690 | } | 677 | } |
678 | |||
679 | /* and Intel "Sibley" flash */ | ||
680 | if (jffs2_nor_wbuf_flash(c)) { | ||
681 | jffs2_nor_wbuf_flash_cleanup(c); | ||
682 | } | ||
691 | } | 683 | } |
diff --git a/fs/jffs2/gc.c b/fs/jffs2/gc.c index 7086cd634503..f9ffece453a3 100644 --- a/fs/jffs2/gc.c +++ b/fs/jffs2/gc.c | |||
@@ -7,7 +7,7 @@ | |||
7 | * | 7 | * |
8 | * For licensing information, see the file 'LICENCE' in this directory. | 8 | * For licensing information, see the file 'LICENCE' in this directory. |
9 | * | 9 | * |
10 | * $Id: gc.c,v 1.148 2005/04/09 10:47:00 dedekind Exp $ | 10 | * $Id: gc.c,v 1.155 2005/11/07 11:14:39 gleixner Exp $ |
11 | * | 11 | * |
12 | */ | 12 | */ |
13 | 13 | ||
@@ -21,14 +21,14 @@ | |||
21 | #include "nodelist.h" | 21 | #include "nodelist.h" |
22 | #include "compr.h" | 22 | #include "compr.h" |
23 | 23 | ||
24 | static int jffs2_garbage_collect_pristine(struct jffs2_sb_info *c, | 24 | static int jffs2_garbage_collect_pristine(struct jffs2_sb_info *c, |
25 | struct jffs2_inode_cache *ic, | 25 | struct jffs2_inode_cache *ic, |
26 | struct jffs2_raw_node_ref *raw); | 26 | struct jffs2_raw_node_ref *raw); |
27 | static int jffs2_garbage_collect_metadata(struct jffs2_sb_info *c, struct jffs2_eraseblock *jeb, | 27 | static int jffs2_garbage_collect_metadata(struct jffs2_sb_info *c, struct jffs2_eraseblock *jeb, |
28 | struct jffs2_inode_info *f, struct jffs2_full_dnode *fd); | 28 | struct jffs2_inode_info *f, struct jffs2_full_dnode *fd); |
29 | static int jffs2_garbage_collect_dirent(struct jffs2_sb_info *c, struct jffs2_eraseblock *jeb, | 29 | static int jffs2_garbage_collect_dirent(struct jffs2_sb_info *c, struct jffs2_eraseblock *jeb, |
30 | struct jffs2_inode_info *f, struct jffs2_full_dirent *fd); | 30 | struct jffs2_inode_info *f, struct jffs2_full_dirent *fd); |
31 | static int jffs2_garbage_collect_deletion_dirent(struct jffs2_sb_info *c, struct jffs2_eraseblock *jeb, | 31 | static int jffs2_garbage_collect_deletion_dirent(struct jffs2_sb_info *c, struct jffs2_eraseblock *jeb, |
32 | struct jffs2_inode_info *f, struct jffs2_full_dirent *fd); | 32 | struct jffs2_inode_info *f, struct jffs2_full_dirent *fd); |
33 | static int jffs2_garbage_collect_hole(struct jffs2_sb_info *c, struct jffs2_eraseblock *jeb, | 33 | static int jffs2_garbage_collect_hole(struct jffs2_sb_info *c, struct jffs2_eraseblock *jeb, |
34 | struct jffs2_inode_info *f, struct jffs2_full_dnode *fn, | 34 | struct jffs2_inode_info *f, struct jffs2_full_dnode *fn, |
@@ -55,7 +55,7 @@ again: | |||
55 | D1(printk(KERN_DEBUG "Picking block from bad_used_list to GC next\n")); | 55 | D1(printk(KERN_DEBUG "Picking block from bad_used_list to GC next\n")); |
56 | nextlist = &c->bad_used_list; | 56 | nextlist = &c->bad_used_list; |
57 | } else if (n < 50 && !list_empty(&c->erasable_list)) { | 57 | } else if (n < 50 && !list_empty(&c->erasable_list)) { |
58 | /* Note that most of them will have gone directly to be erased. | 58 | /* Note that most of them will have gone directly to be erased. |
59 | So don't favour the erasable_list _too_ much. */ | 59 | So don't favour the erasable_list _too_ much. */ |
60 | D1(printk(KERN_DEBUG "Picking block from erasable_list to GC next\n")); | 60 | D1(printk(KERN_DEBUG "Picking block from erasable_list to GC next\n")); |
61 | nextlist = &c->erasable_list; | 61 | nextlist = &c->erasable_list; |
@@ -101,7 +101,7 @@ again: | |||
101 | printk(KERN_WARNING "Eep. ret->gc_node for block at 0x%08x is NULL\n", ret->offset); | 101 | printk(KERN_WARNING "Eep. ret->gc_node for block at 0x%08x is NULL\n", ret->offset); |
102 | BUG(); | 102 | BUG(); |
103 | } | 103 | } |
104 | 104 | ||
105 | /* Have we accidentally picked a clean block with wasted space ? */ | 105 | /* Have we accidentally picked a clean block with wasted space ? */ |
106 | if (ret->wasted_size) { | 106 | if (ret->wasted_size) { |
107 | D1(printk(KERN_DEBUG "Converting wasted_size %08x to dirty_size\n", ret->wasted_size)); | 107 | D1(printk(KERN_DEBUG "Converting wasted_size %08x to dirty_size\n", ret->wasted_size)); |
@@ -111,7 +111,6 @@ again: | |||
111 | ret->wasted_size = 0; | 111 | ret->wasted_size = 0; |
112 | } | 112 | } |
113 | 113 | ||
114 | D2(jffs2_dump_block_lists(c)); | ||
115 | return ret; | 114 | return ret; |
116 | } | 115 | } |
117 | 116 | ||
@@ -137,12 +136,12 @@ int jffs2_garbage_collect_pass(struct jffs2_sb_info *c) | |||
137 | 136 | ||
138 | /* We can't start doing GC yet. We haven't finished checking | 137 | /* We can't start doing GC yet. We haven't finished checking |
139 | the node CRCs etc. Do it now. */ | 138 | the node CRCs etc. Do it now. */ |
140 | 139 | ||
141 | /* checked_ino is protected by the alloc_sem */ | 140 | /* checked_ino is protected by the alloc_sem */ |
142 | if (c->checked_ino > c->highest_ino) { | 141 | if (c->checked_ino > c->highest_ino) { |
143 | printk(KERN_CRIT "Checked all inodes but still 0x%x bytes of unchecked space?\n", | 142 | printk(KERN_CRIT "Checked all inodes but still 0x%x bytes of unchecked space?\n", |
144 | c->unchecked_size); | 143 | c->unchecked_size); |
145 | D2(jffs2_dump_block_lists(c)); | 144 | jffs2_dbg_dump_block_lists_nolock(c); |
146 | spin_unlock(&c->erase_completion_lock); | 145 | spin_unlock(&c->erase_completion_lock); |
147 | BUG(); | 146 | BUG(); |
148 | } | 147 | } |
@@ -179,7 +178,7 @@ int jffs2_garbage_collect_pass(struct jffs2_sb_info *c) | |||
179 | 178 | ||
180 | case INO_STATE_READING: | 179 | case INO_STATE_READING: |
181 | /* We need to wait for it to finish, lest we move on | 180 | /* We need to wait for it to finish, lest we move on |
182 | and trigger the BUG() above while we haven't yet | 181 | and trigger the BUG() above while we haven't yet |
183 | finished checking all its nodes */ | 182 | finished checking all its nodes */ |
184 | D1(printk(KERN_DEBUG "Waiting for ino #%u to finish reading\n", ic->ino)); | 183 | D1(printk(KERN_DEBUG "Waiting for ino #%u to finish reading\n", ic->ino)); |
185 | up(&c->alloc_sem); | 184 | up(&c->alloc_sem); |
@@ -229,13 +228,13 @@ int jffs2_garbage_collect_pass(struct jffs2_sb_info *c) | |||
229 | } | 228 | } |
230 | 229 | ||
231 | raw = jeb->gc_node; | 230 | raw = jeb->gc_node; |
232 | 231 | ||
233 | while(ref_obsolete(raw)) { | 232 | while(ref_obsolete(raw)) { |
234 | D1(printk(KERN_DEBUG "Node at 0x%08x is obsolete... skipping\n", ref_offset(raw))); | 233 | D1(printk(KERN_DEBUG "Node at 0x%08x is obsolete... skipping\n", ref_offset(raw))); |
235 | raw = raw->next_phys; | 234 | raw = raw->next_phys; |
236 | if (unlikely(!raw)) { | 235 | if (unlikely(!raw)) { |
237 | printk(KERN_WARNING "eep. End of raw list while still supposedly nodes to GC\n"); | 236 | printk(KERN_WARNING "eep. End of raw list while still supposedly nodes to GC\n"); |
238 | printk(KERN_WARNING "erase block at 0x%08x. free_size 0x%08x, dirty_size 0x%08x, used_size 0x%08x\n", | 237 | printk(KERN_WARNING "erase block at 0x%08x. free_size 0x%08x, dirty_size 0x%08x, used_size 0x%08x\n", |
239 | jeb->offset, jeb->free_size, jeb->dirty_size, jeb->used_size); | 238 | jeb->offset, jeb->free_size, jeb->dirty_size, jeb->used_size); |
240 | jeb->gc_node = raw; | 239 | jeb->gc_node = raw; |
241 | spin_unlock(&c->erase_completion_lock); | 240 | spin_unlock(&c->erase_completion_lock); |
@@ -260,7 +259,7 @@ int jffs2_garbage_collect_pass(struct jffs2_sb_info *c) | |||
260 | ic = jffs2_raw_ref_to_ic(raw); | 259 | ic = jffs2_raw_ref_to_ic(raw); |
261 | 260 | ||
262 | /* We need to hold the inocache. Either the erase_completion_lock or | 261 | /* We need to hold the inocache. Either the erase_completion_lock or |
263 | the inocache_lock are sufficient; we trade down since the inocache_lock | 262 | the inocache_lock are sufficient; we trade down since the inocache_lock |
264 | causes less contention. */ | 263 | causes less contention. */ |
265 | spin_lock(&c->inocache_lock); | 264 | spin_lock(&c->inocache_lock); |
266 | 265 | ||
@@ -279,14 +278,14 @@ int jffs2_garbage_collect_pass(struct jffs2_sb_info *c) | |||
279 | 278 | ||
280 | switch(ic->state) { | 279 | switch(ic->state) { |
281 | case INO_STATE_CHECKEDABSENT: | 280 | case INO_STATE_CHECKEDABSENT: |
282 | /* It's been checked, but it's not currently in-core. | 281 | /* It's been checked, but it's not currently in-core. |
283 | We can just copy any pristine nodes, but have | 282 | We can just copy any pristine nodes, but have |
284 | to prevent anyone else from doing read_inode() while | 283 | to prevent anyone else from doing read_inode() while |
285 | we're at it, so we set the state accordingly */ | 284 | we're at it, so we set the state accordingly */ |
286 | if (ref_flags(raw) == REF_PRISTINE) | 285 | if (ref_flags(raw) == REF_PRISTINE) |
287 | ic->state = INO_STATE_GC; | 286 | ic->state = INO_STATE_GC; |
288 | else { | 287 | else { |
289 | D1(printk(KERN_DEBUG "Ino #%u is absent but node not REF_PRISTINE. Reading.\n", | 288 | D1(printk(KERN_DEBUG "Ino #%u is absent but node not REF_PRISTINE. Reading.\n", |
290 | ic->ino)); | 289 | ic->ino)); |
291 | } | 290 | } |
292 | break; | 291 | break; |
@@ -299,8 +298,8 @@ int jffs2_garbage_collect_pass(struct jffs2_sb_info *c) | |||
299 | case INO_STATE_CHECKING: | 298 | case INO_STATE_CHECKING: |
300 | case INO_STATE_GC: | 299 | case INO_STATE_GC: |
301 | /* Should never happen. We should have finished checking | 300 | /* Should never happen. We should have finished checking |
302 | by the time we actually start doing any GC, and since | 301 | by the time we actually start doing any GC, and since |
303 | we're holding the alloc_sem, no other garbage collection | 302 | we're holding the alloc_sem, no other garbage collection |
304 | can happen. | 303 | can happen. |
305 | */ | 304 | */ |
306 | printk(KERN_CRIT "Inode #%u already in state %d in jffs2_garbage_collect_pass()!\n", | 305 | printk(KERN_CRIT "Inode #%u already in state %d in jffs2_garbage_collect_pass()!\n", |
@@ -320,21 +319,21 @@ int jffs2_garbage_collect_pass(struct jffs2_sb_info *c) | |||
320 | D1(printk(KERN_DEBUG "jffs2_garbage_collect_pass() waiting for ino #%u in state %d\n", | 319 | D1(printk(KERN_DEBUG "jffs2_garbage_collect_pass() waiting for ino #%u in state %d\n", |
321 | ic->ino, ic->state)); | 320 | ic->ino, ic->state)); |
322 | sleep_on_spinunlock(&c->inocache_wq, &c->inocache_lock); | 321 | sleep_on_spinunlock(&c->inocache_wq, &c->inocache_lock); |
323 | /* And because we dropped the alloc_sem we must start again from the | 322 | /* And because we dropped the alloc_sem we must start again from the |
324 | beginning. Ponder chance of livelock here -- we're returning success | 323 | beginning. Ponder chance of livelock here -- we're returning success |
325 | without actually making any progress. | 324 | without actually making any progress. |
326 | 325 | ||
327 | Q: What are the chances that the inode is back in INO_STATE_READING | 326 | Q: What are the chances that the inode is back in INO_STATE_READING |
328 | again by the time we next enter this function? And that this happens | 327 | again by the time we next enter this function? And that this happens |
329 | enough times to cause a real delay? | 328 | enough times to cause a real delay? |
330 | 329 | ||
331 | A: Small enough that I don't care :) | 330 | A: Small enough that I don't care :) |
332 | */ | 331 | */ |
333 | return 0; | 332 | return 0; |
334 | } | 333 | } |
335 | 334 | ||
336 | /* OK. Now if the inode is in state INO_STATE_GC, we are going to copy the | 335 | /* OK. Now if the inode is in state INO_STATE_GC, we are going to copy the |
337 | node intact, and we don't have to muck about with the fragtree etc. | 336 | node intact, and we don't have to muck about with the fragtree etc. |
338 | because we know it's not in-core. If it _was_ in-core, we go through | 337 | because we know it's not in-core. If it _was_ in-core, we go through |
339 | all the iget() crap anyway */ | 338 | all the iget() crap anyway */ |
340 | 339 | ||
@@ -454,7 +453,7 @@ static int jffs2_garbage_collect_live(struct jffs2_sb_info *c, struct jffs2_era | |||
454 | if (!ret) { | 453 | if (!ret) { |
455 | /* Urgh. Return it sensibly. */ | 454 | /* Urgh. Return it sensibly. */ |
456 | frag->node->raw = f->inocache->nodes; | 455 | frag->node->raw = f->inocache->nodes; |
457 | } | 456 | } |
458 | if (ret != -EBADFD) | 457 | if (ret != -EBADFD) |
459 | goto upnout; | 458 | goto upnout; |
460 | } | 459 | } |
@@ -468,7 +467,7 @@ static int jffs2_garbage_collect_live(struct jffs2_sb_info *c, struct jffs2_era | |||
468 | } | 467 | } |
469 | goto upnout; | 468 | goto upnout; |
470 | } | 469 | } |
471 | 470 | ||
472 | /* Wasn't a dnode. Try dirent */ | 471 | /* Wasn't a dnode. Try dirent */ |
473 | for (fd = f->dents; fd; fd=fd->next) { | 472 | for (fd = f->dents; fd; fd=fd->next) { |
474 | if (fd->raw == raw) | 473 | if (fd->raw == raw) |
@@ -485,7 +484,8 @@ static int jffs2_garbage_collect_live(struct jffs2_sb_info *c, struct jffs2_era | |||
485 | if (ref_obsolete(raw)) { | 484 | if (ref_obsolete(raw)) { |
486 | printk(KERN_WARNING "But it's obsolete so we don't mind too much\n"); | 485 | printk(KERN_WARNING "But it's obsolete so we don't mind too much\n"); |
487 | } else { | 486 | } else { |
488 | ret = -EIO; | 487 | jffs2_dbg_dump_node(c, ref_offset(raw)); |
488 | BUG(); | ||
489 | } | 489 | } |
490 | } | 490 | } |
491 | upnout: | 491 | upnout: |
@@ -494,7 +494,7 @@ static int jffs2_garbage_collect_live(struct jffs2_sb_info *c, struct jffs2_era | |||
494 | return ret; | 494 | return ret; |
495 | } | 495 | } |
496 | 496 | ||
497 | static int jffs2_garbage_collect_pristine(struct jffs2_sb_info *c, | 497 | static int jffs2_garbage_collect_pristine(struct jffs2_sb_info *c, |
498 | struct jffs2_inode_cache *ic, | 498 | struct jffs2_inode_cache *ic, |
499 | struct jffs2_raw_node_ref *raw) | 499 | struct jffs2_raw_node_ref *raw) |
500 | { | 500 | { |
@@ -513,8 +513,11 @@ static int jffs2_garbage_collect_pristine(struct jffs2_sb_info *c, | |||
513 | /* Ask for a small amount of space (or the totlen if smaller) because we | 513 | /* Ask for a small amount of space (or the totlen if smaller) because we |
514 | don't want to force wastage of the end of a block if splitting would | 514 | don't want to force wastage of the end of a block if splitting would |
515 | work. */ | 515 | work. */ |
516 | ret = jffs2_reserve_space_gc(c, min_t(uint32_t, sizeof(struct jffs2_raw_inode) + JFFS2_MIN_DATA_LEN, | 516 | ret = jffs2_reserve_space_gc(c, min_t(uint32_t, sizeof(struct jffs2_raw_inode) + |
517 | rawlen), &phys_ofs, &alloclen); | 517 | JFFS2_MIN_DATA_LEN, rawlen), &phys_ofs, &alloclen, rawlen); |
518 | /* this is not the exact summary size of it, | ||
519 | it is only an upper estimation */ | ||
520 | |||
518 | if (ret) | 521 | if (ret) |
519 | return ret; | 522 | return ret; |
520 | 523 | ||
@@ -577,7 +580,7 @@ static int jffs2_garbage_collect_pristine(struct jffs2_sb_info *c, | |||
577 | } | 580 | } |
578 | break; | 581 | break; |
579 | default: | 582 | default: |
580 | printk(KERN_WARNING "Unknown node type for REF_PRISTINE node at 0x%08x: 0x%04x\n", | 583 | printk(KERN_WARNING "Unknown node type for REF_PRISTINE node at 0x%08x: 0x%04x\n", |
581 | ref_offset(raw), je16_to_cpu(node->u.nodetype)); | 584 | ref_offset(raw), je16_to_cpu(node->u.nodetype)); |
582 | goto bail; | 585 | goto bail; |
583 | } | 586 | } |
@@ -618,17 +621,19 @@ static int jffs2_garbage_collect_pristine(struct jffs2_sb_info *c, | |||
618 | retried = 1; | 621 | retried = 1; |
619 | 622 | ||
620 | D1(printk(KERN_DEBUG "Retrying failed write of REF_PRISTINE node.\n")); | 623 | D1(printk(KERN_DEBUG "Retrying failed write of REF_PRISTINE node.\n")); |
621 | |||
622 | ACCT_SANITY_CHECK(c,jeb); | ||
623 | D1(ACCT_PARANOIA_CHECK(jeb)); | ||
624 | 624 | ||
625 | ret = jffs2_reserve_space_gc(c, rawlen, &phys_ofs, &dummy); | 625 | jffs2_dbg_acct_sanity_check(c,jeb); |
626 | jffs2_dbg_acct_paranoia_check(c, jeb); | ||
627 | |||
628 | ret = jffs2_reserve_space_gc(c, rawlen, &phys_ofs, &dummy, rawlen); | ||
629 | /* this is not the exact summary size of it, | ||
630 | it is only an upper estimation */ | ||
626 | 631 | ||
627 | if (!ret) { | 632 | if (!ret) { |
628 | D1(printk(KERN_DEBUG "Allocated space at 0x%08x to retry failed write.\n", phys_ofs)); | 633 | D1(printk(KERN_DEBUG "Allocated space at 0x%08x to retry failed write.\n", phys_ofs)); |
629 | 634 | ||
630 | ACCT_SANITY_CHECK(c,jeb); | 635 | jffs2_dbg_acct_sanity_check(c,jeb); |
631 | D1(ACCT_PARANOIA_CHECK(jeb)); | 636 | jffs2_dbg_acct_paranoia_check(c, jeb); |
632 | 637 | ||
633 | goto retry; | 638 | goto retry; |
634 | } | 639 | } |
@@ -664,7 +669,7 @@ static int jffs2_garbage_collect_pristine(struct jffs2_sb_info *c, | |||
664 | goto out_node; | 669 | goto out_node; |
665 | } | 670 | } |
666 | 671 | ||
667 | static int jffs2_garbage_collect_metadata(struct jffs2_sb_info *c, struct jffs2_eraseblock *jeb, | 672 | static int jffs2_garbage_collect_metadata(struct jffs2_sb_info *c, struct jffs2_eraseblock *jeb, |
668 | struct jffs2_inode_info *f, struct jffs2_full_dnode *fn) | 673 | struct jffs2_inode_info *f, struct jffs2_full_dnode *fn) |
669 | { | 674 | { |
670 | struct jffs2_full_dnode *new_fn; | 675 | struct jffs2_full_dnode *new_fn; |
@@ -679,7 +684,7 @@ static int jffs2_garbage_collect_metadata(struct jffs2_sb_info *c, struct jffs2_ | |||
679 | S_ISCHR(JFFS2_F_I_MODE(f)) ) { | 684 | S_ISCHR(JFFS2_F_I_MODE(f)) ) { |
680 | /* For these, we don't actually need to read the old node */ | 685 | /* For these, we don't actually need to read the old node */ |
681 | /* FIXME: for minor or major > 255. */ | 686 | /* FIXME: for minor or major > 255. */ |
682 | dev = cpu_to_je16(((JFFS2_F_I_RDEV_MAJ(f) << 8) | | 687 | dev = cpu_to_je16(((JFFS2_F_I_RDEV_MAJ(f) << 8) | |
683 | JFFS2_F_I_RDEV_MIN(f))); | 688 | JFFS2_F_I_RDEV_MIN(f))); |
684 | mdata = (char *)&dev; | 689 | mdata = (char *)&dev; |
685 | mdatalen = sizeof(dev); | 690 | mdatalen = sizeof(dev); |
@@ -700,14 +705,15 @@ static int jffs2_garbage_collect_metadata(struct jffs2_sb_info *c, struct jffs2_ | |||
700 | D1(printk(KERN_DEBUG "jffs2_garbage_collect_metadata(): Writing %d bites of symlink target\n", mdatalen)); | 705 | D1(printk(KERN_DEBUG "jffs2_garbage_collect_metadata(): Writing %d bites of symlink target\n", mdatalen)); |
701 | 706 | ||
702 | } | 707 | } |
703 | 708 | ||
704 | ret = jffs2_reserve_space_gc(c, sizeof(ri) + mdatalen, &phys_ofs, &alloclen); | 709 | ret = jffs2_reserve_space_gc(c, sizeof(ri) + mdatalen, &phys_ofs, &alloclen, |
710 | JFFS2_SUMMARY_INODE_SIZE); | ||
705 | if (ret) { | 711 | if (ret) { |
706 | printk(KERN_WARNING "jffs2_reserve_space_gc of %zd bytes for garbage_collect_metadata failed: %d\n", | 712 | printk(KERN_WARNING "jffs2_reserve_space_gc of %zd bytes for garbage_collect_metadata failed: %d\n", |
707 | sizeof(ri)+ mdatalen, ret); | 713 | sizeof(ri)+ mdatalen, ret); |
708 | goto out; | 714 | goto out; |
709 | } | 715 | } |
710 | 716 | ||
711 | last_frag = frag_last(&f->fragtree); | 717 | last_frag = frag_last(&f->fragtree); |
712 | if (last_frag) | 718 | if (last_frag) |
713 | /* Fetch the inode length from the fragtree rather then | 719 | /* Fetch the inode length from the fragtree rather then |
@@ -715,7 +721,7 @@ static int jffs2_garbage_collect_metadata(struct jffs2_sb_info *c, struct jffs2_ | |||
715 | ilen = last_frag->ofs + last_frag->size; | 721 | ilen = last_frag->ofs + last_frag->size; |
716 | else | 722 | else |
717 | ilen = JFFS2_F_I_SIZE(f); | 723 | ilen = JFFS2_F_I_SIZE(f); |
718 | 724 | ||
719 | memset(&ri, 0, sizeof(ri)); | 725 | memset(&ri, 0, sizeof(ri)); |
720 | ri.magic = cpu_to_je16(JFFS2_MAGIC_BITMASK); | 726 | ri.magic = cpu_to_je16(JFFS2_MAGIC_BITMASK); |
721 | ri.nodetype = cpu_to_je16(JFFS2_NODETYPE_INODE); | 727 | ri.nodetype = cpu_to_je16(JFFS2_NODETYPE_INODE); |
@@ -754,7 +760,7 @@ static int jffs2_garbage_collect_metadata(struct jffs2_sb_info *c, struct jffs2_ | |||
754 | return ret; | 760 | return ret; |
755 | } | 761 | } |
756 | 762 | ||
757 | static int jffs2_garbage_collect_dirent(struct jffs2_sb_info *c, struct jffs2_eraseblock *jeb, | 763 | static int jffs2_garbage_collect_dirent(struct jffs2_sb_info *c, struct jffs2_eraseblock *jeb, |
758 | struct jffs2_inode_info *f, struct jffs2_full_dirent *fd) | 764 | struct jffs2_inode_info *f, struct jffs2_full_dirent *fd) |
759 | { | 765 | { |
760 | struct jffs2_full_dirent *new_fd; | 766 | struct jffs2_full_dirent *new_fd; |
@@ -771,12 +777,18 @@ static int jffs2_garbage_collect_dirent(struct jffs2_sb_info *c, struct jffs2_er | |||
771 | rd.pino = cpu_to_je32(f->inocache->ino); | 777 | rd.pino = cpu_to_je32(f->inocache->ino); |
772 | rd.version = cpu_to_je32(++f->highest_version); | 778 | rd.version = cpu_to_je32(++f->highest_version); |
773 | rd.ino = cpu_to_je32(fd->ino); | 779 | rd.ino = cpu_to_je32(fd->ino); |
774 | rd.mctime = cpu_to_je32(max(JFFS2_F_I_MTIME(f), JFFS2_F_I_CTIME(f))); | 780 | /* If the times on this inode were set by explicit utime() they can be different, |
781 | so refrain from splatting them. */ | ||
782 | if (JFFS2_F_I_MTIME(f) == JFFS2_F_I_CTIME(f)) | ||
783 | rd.mctime = cpu_to_je32(JFFS2_F_I_MTIME(f)); | ||
784 | else | ||
785 | rd.mctime = cpu_to_je32(0); | ||
775 | rd.type = fd->type; | 786 | rd.type = fd->type; |
776 | rd.node_crc = cpu_to_je32(crc32(0, &rd, sizeof(rd)-8)); | 787 | rd.node_crc = cpu_to_je32(crc32(0, &rd, sizeof(rd)-8)); |
777 | rd.name_crc = cpu_to_je32(crc32(0, fd->name, rd.nsize)); | 788 | rd.name_crc = cpu_to_je32(crc32(0, fd->name, rd.nsize)); |
778 | 789 | ||
779 | ret = jffs2_reserve_space_gc(c, sizeof(rd)+rd.nsize, &phys_ofs, &alloclen); | 790 | ret = jffs2_reserve_space_gc(c, sizeof(rd)+rd.nsize, &phys_ofs, &alloclen, |
791 | JFFS2_SUMMARY_DIRENT_SIZE(rd.nsize)); | ||
780 | if (ret) { | 792 | if (ret) { |
781 | printk(KERN_WARNING "jffs2_reserve_space_gc of %zd bytes for garbage_collect_dirent failed: %d\n", | 793 | printk(KERN_WARNING "jffs2_reserve_space_gc of %zd bytes for garbage_collect_dirent failed: %d\n", |
782 | sizeof(rd)+rd.nsize, ret); | 794 | sizeof(rd)+rd.nsize, ret); |
@@ -792,7 +804,7 @@ static int jffs2_garbage_collect_dirent(struct jffs2_sb_info *c, struct jffs2_er | |||
792 | return 0; | 804 | return 0; |
793 | } | 805 | } |
794 | 806 | ||
795 | static int jffs2_garbage_collect_deletion_dirent(struct jffs2_sb_info *c, struct jffs2_eraseblock *jeb, | 807 | static int jffs2_garbage_collect_deletion_dirent(struct jffs2_sb_info *c, struct jffs2_eraseblock *jeb, |
796 | struct jffs2_inode_info *f, struct jffs2_full_dirent *fd) | 808 | struct jffs2_inode_info *f, struct jffs2_full_dirent *fd) |
797 | { | 809 | { |
798 | struct jffs2_full_dirent **fdp = &f->dents; | 810 | struct jffs2_full_dirent **fdp = &f->dents; |
@@ -831,7 +843,7 @@ static int jffs2_garbage_collect_deletion_dirent(struct jffs2_sb_info *c, struct | |||
831 | if (ref_totlen(c, NULL, raw) != rawlen) | 843 | if (ref_totlen(c, NULL, raw) != rawlen) |
832 | continue; | 844 | continue; |
833 | 845 | ||
834 | /* Doesn't matter if there's one in the same erase block. We're going to | 846 | /* Doesn't matter if there's one in the same erase block. We're going to |
835 | delete it too at the same time. */ | 847 | delete it too at the same time. */ |
836 | if (SECTOR_ADDR(raw->flash_offset) == SECTOR_ADDR(fd->raw->flash_offset)) | 848 | if (SECTOR_ADDR(raw->flash_offset) == SECTOR_ADDR(fd->raw->flash_offset)) |
837 | continue; | 849 | continue; |
@@ -883,6 +895,9 @@ static int jffs2_garbage_collect_deletion_dirent(struct jffs2_sb_info *c, struct | |||
883 | kfree(rd); | 895 | kfree(rd); |
884 | } | 896 | } |
885 | 897 | ||
898 | /* FIXME: If we're deleting a dirent which contains the current mtime and ctime, | ||
899 | we should update the metadata node with those times accordingly */ | ||
900 | |||
886 | /* No need for it any more. Just mark it obsolete and remove it from the list */ | 901 | /* No need for it any more. Just mark it obsolete and remove it from the list */ |
887 | while (*fdp) { | 902 | while (*fdp) { |
888 | if ((*fdp) == fd) { | 903 | if ((*fdp) == fd) { |
@@ -912,13 +927,13 @@ static int jffs2_garbage_collect_hole(struct jffs2_sb_info *c, struct jffs2_eras | |||
912 | 927 | ||
913 | D1(printk(KERN_DEBUG "Writing replacement hole node for ino #%u from offset 0x%x to 0x%x\n", | 928 | D1(printk(KERN_DEBUG "Writing replacement hole node for ino #%u from offset 0x%x to 0x%x\n", |
914 | f->inocache->ino, start, end)); | 929 | f->inocache->ino, start, end)); |
915 | 930 | ||
916 | memset(&ri, 0, sizeof(ri)); | 931 | memset(&ri, 0, sizeof(ri)); |
917 | 932 | ||
918 | if(fn->frags > 1) { | 933 | if(fn->frags > 1) { |
919 | size_t readlen; | 934 | size_t readlen; |
920 | uint32_t crc; | 935 | uint32_t crc; |
921 | /* It's partially obsoleted by a later write. So we have to | 936 | /* It's partially obsoleted by a later write. So we have to |
922 | write it out again with the _same_ version as before */ | 937 | write it out again with the _same_ version as before */ |
923 | ret = jffs2_flash_read(c, ref_offset(fn->raw), sizeof(ri), &readlen, (char *)&ri); | 938 | ret = jffs2_flash_read(c, ref_offset(fn->raw), sizeof(ri), &readlen, (char *)&ri); |
924 | if (readlen != sizeof(ri) || ret) { | 939 | if (readlen != sizeof(ri) || ret) { |
@@ -940,16 +955,16 @@ static int jffs2_garbage_collect_hole(struct jffs2_sb_info *c, struct jffs2_eras | |||
940 | crc = crc32(0, &ri, sizeof(ri)-8); | 955 | crc = crc32(0, &ri, sizeof(ri)-8); |
941 | if (crc != je32_to_cpu(ri.node_crc)) { | 956 | if (crc != je32_to_cpu(ri.node_crc)) { |
942 | printk(KERN_WARNING "jffs2_garbage_collect_hole: Node at 0x%08x had CRC 0x%08x which doesn't match calculated CRC 0x%08x\n", | 957 | printk(KERN_WARNING "jffs2_garbage_collect_hole: Node at 0x%08x had CRC 0x%08x which doesn't match calculated CRC 0x%08x\n", |
943 | ref_offset(fn->raw), | 958 | ref_offset(fn->raw), |
944 | je32_to_cpu(ri.node_crc), crc); | 959 | je32_to_cpu(ri.node_crc), crc); |
945 | /* FIXME: We could possibly deal with this by writing new holes for each frag */ | 960 | /* FIXME: We could possibly deal with this by writing new holes for each frag */ |
946 | printk(KERN_WARNING "Data in the range 0x%08x to 0x%08x of inode #%u will be lost\n", | 961 | printk(KERN_WARNING "Data in the range 0x%08x to 0x%08x of inode #%u will be lost\n", |
947 | start, end, f->inocache->ino); | 962 | start, end, f->inocache->ino); |
948 | goto fill; | 963 | goto fill; |
949 | } | 964 | } |
950 | if (ri.compr != JFFS2_COMPR_ZERO) { | 965 | if (ri.compr != JFFS2_COMPR_ZERO) { |
951 | printk(KERN_WARNING "jffs2_garbage_collect_hole: Node 0x%08x wasn't a hole node!\n", ref_offset(fn->raw)); | 966 | printk(KERN_WARNING "jffs2_garbage_collect_hole: Node 0x%08x wasn't a hole node!\n", ref_offset(fn->raw)); |
952 | printk(KERN_WARNING "Data in the range 0x%08x to 0x%08x of inode #%u will be lost\n", | 967 | printk(KERN_WARNING "Data in the range 0x%08x to 0x%08x of inode #%u will be lost\n", |
953 | start, end, f->inocache->ino); | 968 | start, end, f->inocache->ino); |
954 | goto fill; | 969 | goto fill; |
955 | } | 970 | } |
@@ -967,7 +982,7 @@ static int jffs2_garbage_collect_hole(struct jffs2_sb_info *c, struct jffs2_eras | |||
967 | ri.csize = cpu_to_je32(0); | 982 | ri.csize = cpu_to_je32(0); |
968 | ri.compr = JFFS2_COMPR_ZERO; | 983 | ri.compr = JFFS2_COMPR_ZERO; |
969 | } | 984 | } |
970 | 985 | ||
971 | frag = frag_last(&f->fragtree); | 986 | frag = frag_last(&f->fragtree); |
972 | if (frag) | 987 | if (frag) |
973 | /* Fetch the inode length from the fragtree rather then | 988 | /* Fetch the inode length from the fragtree rather then |
@@ -986,7 +1001,8 @@ static int jffs2_garbage_collect_hole(struct jffs2_sb_info *c, struct jffs2_eras | |||
986 | ri.data_crc = cpu_to_je32(0); | 1001 | ri.data_crc = cpu_to_je32(0); |
987 | ri.node_crc = cpu_to_je32(crc32(0, &ri, sizeof(ri)-8)); | 1002 | ri.node_crc = cpu_to_je32(crc32(0, &ri, sizeof(ri)-8)); |
988 | 1003 | ||
989 | ret = jffs2_reserve_space_gc(c, sizeof(ri), &phys_ofs, &alloclen); | 1004 | ret = jffs2_reserve_space_gc(c, sizeof(ri), &phys_ofs, &alloclen, |
1005 | JFFS2_SUMMARY_INODE_SIZE); | ||
990 | if (ret) { | 1006 | if (ret) { |
991 | printk(KERN_WARNING "jffs2_reserve_space_gc of %zd bytes for garbage_collect_hole failed: %d\n", | 1007 | printk(KERN_WARNING "jffs2_reserve_space_gc of %zd bytes for garbage_collect_hole failed: %d\n", |
992 | sizeof(ri), ret); | 1008 | sizeof(ri), ret); |
@@ -1008,10 +1024,10 @@ static int jffs2_garbage_collect_hole(struct jffs2_sb_info *c, struct jffs2_eras | |||
1008 | return 0; | 1024 | return 0; |
1009 | } | 1025 | } |
1010 | 1026 | ||
1011 | /* | 1027 | /* |
1012 | * We should only get here in the case where the node we are | 1028 | * We should only get here in the case where the node we are |
1013 | * replacing had more than one frag, so we kept the same version | 1029 | * replacing had more than one frag, so we kept the same version |
1014 | * number as before. (Except in case of error -- see 'goto fill;' | 1030 | * number as before. (Except in case of error -- see 'goto fill;' |
1015 | * above.) | 1031 | * above.) |
1016 | */ | 1032 | */ |
1017 | D1(if(unlikely(fn->frags <= 1)) { | 1033 | D1(if(unlikely(fn->frags <= 1)) { |
@@ -1023,7 +1039,7 @@ static int jffs2_garbage_collect_hole(struct jffs2_sb_info *c, struct jffs2_eras | |||
1023 | /* This is a partially-overlapped hole node. Mark it REF_NORMAL not REF_PRISTINE */ | 1039 | /* This is a partially-overlapped hole node. Mark it REF_NORMAL not REF_PRISTINE */ |
1024 | mark_ref_normal(new_fn->raw); | 1040 | mark_ref_normal(new_fn->raw); |
1025 | 1041 | ||
1026 | for (frag = jffs2_lookup_node_frag(&f->fragtree, fn->ofs); | 1042 | for (frag = jffs2_lookup_node_frag(&f->fragtree, fn->ofs); |
1027 | frag; frag = frag_next(frag)) { | 1043 | frag; frag = frag_next(frag)) { |
1028 | if (frag->ofs > fn->size + fn->ofs) | 1044 | if (frag->ofs > fn->size + fn->ofs) |
1029 | break; | 1045 | break; |
@@ -1041,10 +1057,10 @@ static int jffs2_garbage_collect_hole(struct jffs2_sb_info *c, struct jffs2_eras | |||
1041 | printk(KERN_WARNING "jffs2_garbage_collect_hole: New node has no frags!\n"); | 1057 | printk(KERN_WARNING "jffs2_garbage_collect_hole: New node has no frags!\n"); |
1042 | BUG(); | 1058 | BUG(); |
1043 | } | 1059 | } |
1044 | 1060 | ||
1045 | jffs2_mark_node_obsolete(c, fn->raw); | 1061 | jffs2_mark_node_obsolete(c, fn->raw); |
1046 | jffs2_free_full_dnode(fn); | 1062 | jffs2_free_full_dnode(fn); |
1047 | 1063 | ||
1048 | return 0; | 1064 | return 0; |
1049 | } | 1065 | } |
1050 | 1066 | ||
@@ -1054,12 +1070,12 @@ static int jffs2_garbage_collect_dnode(struct jffs2_sb_info *c, struct jffs2_era | |||
1054 | { | 1070 | { |
1055 | struct jffs2_full_dnode *new_fn; | 1071 | struct jffs2_full_dnode *new_fn; |
1056 | struct jffs2_raw_inode ri; | 1072 | struct jffs2_raw_inode ri; |
1057 | uint32_t alloclen, phys_ofs, offset, orig_end, orig_start; | 1073 | uint32_t alloclen, phys_ofs, offset, orig_end, orig_start; |
1058 | int ret = 0; | 1074 | int ret = 0; |
1059 | unsigned char *comprbuf = NULL, *writebuf; | 1075 | unsigned char *comprbuf = NULL, *writebuf; |
1060 | unsigned long pg; | 1076 | unsigned long pg; |
1061 | unsigned char *pg_ptr; | 1077 | unsigned char *pg_ptr; |
1062 | 1078 | ||
1063 | memset(&ri, 0, sizeof(ri)); | 1079 | memset(&ri, 0, sizeof(ri)); |
1064 | 1080 | ||
1065 | D1(printk(KERN_DEBUG "Writing replacement dnode for ino #%u from offset 0x%x to 0x%x\n", | 1081 | D1(printk(KERN_DEBUG "Writing replacement dnode for ino #%u from offset 0x%x to 0x%x\n", |
@@ -1071,8 +1087,8 @@ static int jffs2_garbage_collect_dnode(struct jffs2_sb_info *c, struct jffs2_era | |||
1071 | if (c->nr_free_blocks + c->nr_erasing_blocks > c->resv_blocks_gcmerge) { | 1087 | if (c->nr_free_blocks + c->nr_erasing_blocks > c->resv_blocks_gcmerge) { |
1072 | /* Attempt to do some merging. But only expand to cover logically | 1088 | /* Attempt to do some merging. But only expand to cover logically |
1073 | adjacent frags if the block containing them is already considered | 1089 | adjacent frags if the block containing them is already considered |
1074 | to be dirty. Otherwise we end up with GC just going round in | 1090 | to be dirty. Otherwise we end up with GC just going round in |
1075 | circles dirtying the nodes it already wrote out, especially | 1091 | circles dirtying the nodes it already wrote out, especially |
1076 | on NAND where we have small eraseblocks and hence a much higher | 1092 | on NAND where we have small eraseblocks and hence a much higher |
1077 | chance of nodes having to be split to cross boundaries. */ | 1093 | chance of nodes having to be split to cross boundaries. */ |
1078 | 1094 | ||
@@ -1106,7 +1122,7 @@ static int jffs2_garbage_collect_dnode(struct jffs2_sb_info *c, struct jffs2_era | |||
1106 | break; | 1122 | break; |
1107 | } else { | 1123 | } else { |
1108 | 1124 | ||
1109 | /* OK, it's a frag which extends to the beginning of the page. Does it live | 1125 | /* OK, it's a frag which extends to the beginning of the page. Does it live |
1110 | in a block which is still considered clean? If so, don't obsolete it. | 1126 | in a block which is still considered clean? If so, don't obsolete it. |
1111 | If not, cover it anyway. */ | 1127 | If not, cover it anyway. */ |
1112 | 1128 | ||
@@ -1156,7 +1172,7 @@ static int jffs2_garbage_collect_dnode(struct jffs2_sb_info *c, struct jffs2_era | |||
1156 | break; | 1172 | break; |
1157 | } else { | 1173 | } else { |
1158 | 1174 | ||
1159 | /* OK, it's a frag which extends to the beginning of the page. Does it live | 1175 | /* OK, it's a frag which extends to the beginning of the page. Does it live |
1160 | in a block which is still considered clean? If so, don't obsolete it. | 1176 | in a block which is still considered clean? If so, don't obsolete it. |
1161 | If not, cover it anyway. */ | 1177 | If not, cover it anyway. */ |
1162 | 1178 | ||
@@ -1183,14 +1199,14 @@ static int jffs2_garbage_collect_dnode(struct jffs2_sb_info *c, struct jffs2_era | |||
1183 | break; | 1199 | break; |
1184 | } | 1200 | } |
1185 | } | 1201 | } |
1186 | D1(printk(KERN_DEBUG "Expanded dnode to write from (0x%x-0x%x) to (0x%x-0x%x)\n", | 1202 | D1(printk(KERN_DEBUG "Expanded dnode to write from (0x%x-0x%x) to (0x%x-0x%x)\n", |
1187 | orig_start, orig_end, start, end)); | 1203 | orig_start, orig_end, start, end)); |
1188 | 1204 | ||
1189 | D1(BUG_ON(end > frag_last(&f->fragtree)->ofs + frag_last(&f->fragtree)->size)); | 1205 | D1(BUG_ON(end > frag_last(&f->fragtree)->ofs + frag_last(&f->fragtree)->size)); |
1190 | BUG_ON(end < orig_end); | 1206 | BUG_ON(end < orig_end); |
1191 | BUG_ON(start > orig_start); | 1207 | BUG_ON(start > orig_start); |
1192 | } | 1208 | } |
1193 | 1209 | ||
1194 | /* First, use readpage() to read the appropriate page into the page cache */ | 1210 | /* First, use readpage() to read the appropriate page into the page cache */ |
1195 | /* Q: What happens if we actually try to GC the _same_ page for which commit_write() | 1211 | /* Q: What happens if we actually try to GC the _same_ page for which commit_write() |
1196 | * triggered garbage collection in the first place? | 1212 | * triggered garbage collection in the first place? |
@@ -1211,7 +1227,8 @@ static int jffs2_garbage_collect_dnode(struct jffs2_sb_info *c, struct jffs2_era | |||
1211 | uint32_t cdatalen; | 1227 | uint32_t cdatalen; |
1212 | uint16_t comprtype = JFFS2_COMPR_NONE; | 1228 | uint16_t comprtype = JFFS2_COMPR_NONE; |
1213 | 1229 | ||
1214 | ret = jffs2_reserve_space_gc(c, sizeof(ri) + JFFS2_MIN_DATA_LEN, &phys_ofs, &alloclen); | 1230 | ret = jffs2_reserve_space_gc(c, sizeof(ri) + JFFS2_MIN_DATA_LEN, &phys_ofs, |
1231 | &alloclen, JFFS2_SUMMARY_INODE_SIZE); | ||
1215 | 1232 | ||
1216 | if (ret) { | 1233 | if (ret) { |
1217 | printk(KERN_WARNING "jffs2_reserve_space_gc of %zd bytes for garbage_collect_dnode failed: %d\n", | 1234 | printk(KERN_WARNING "jffs2_reserve_space_gc of %zd bytes for garbage_collect_dnode failed: %d\n", |
@@ -1246,7 +1263,7 @@ static int jffs2_garbage_collect_dnode(struct jffs2_sb_info *c, struct jffs2_era | |||
1246 | ri.usercompr = (comprtype >> 8) & 0xff; | 1263 | ri.usercompr = (comprtype >> 8) & 0xff; |
1247 | ri.node_crc = cpu_to_je32(crc32(0, &ri, sizeof(ri)-8)); | 1264 | ri.node_crc = cpu_to_je32(crc32(0, &ri, sizeof(ri)-8)); |
1248 | ri.data_crc = cpu_to_je32(crc32(0, comprbuf, cdatalen)); | 1265 | ri.data_crc = cpu_to_je32(crc32(0, comprbuf, cdatalen)); |
1249 | 1266 | ||
1250 | new_fn = jffs2_write_dnode(c, f, &ri, comprbuf, cdatalen, phys_ofs, ALLOC_GC); | 1267 | new_fn = jffs2_write_dnode(c, f, &ri, comprbuf, cdatalen, phys_ofs, ALLOC_GC); |
1251 | 1268 | ||
1252 | jffs2_free_comprbuf(comprbuf, writebuf); | 1269 | jffs2_free_comprbuf(comprbuf, writebuf); |
@@ -1268,4 +1285,3 @@ static int jffs2_garbage_collect_dnode(struct jffs2_sb_info *c, struct jffs2_era | |||
1268 | jffs2_gc_release_page(c, pg_ptr, &pg); | 1285 | jffs2_gc_release_page(c, pg_ptr, &pg); |
1269 | return ret; | 1286 | return ret; |
1270 | } | 1287 | } |
1271 | |||
diff --git a/fs/jffs2/histo.h b/fs/jffs2/histo.h index 84f184f0836f..22a93a08210c 100644 --- a/fs/jffs2/histo.h +++ b/fs/jffs2/histo.h | |||
@@ -1,3 +1,3 @@ | |||
1 | /* This file provides the bit-probabilities for the input file */ | 1 | /* This file provides the bit-probabilities for the input file */ |
2 | #define BIT_DIVIDER 629 | 2 | #define BIT_DIVIDER 629 |
3 | static int bits[9] = { 179,167,183,165,159,198,178,119,}; /* ia32 .so files */ | 3 | static int bits[9] = { 179,167,183,165,159,198,178,119,}; /* ia32 .so files */ |
diff --git a/fs/jffs2/histo_mips.h b/fs/jffs2/histo_mips.h index 9a443268d885..fa3dac19a109 100644 --- a/fs/jffs2/histo_mips.h +++ b/fs/jffs2/histo_mips.h | |||
@@ -1,2 +1,2 @@ | |||
1 | #define BIT_DIVIDER_MIPS 1043 | 1 | #define BIT_DIVIDER_MIPS 1043 |
2 | static int bits_mips[8] = { 277,249,290,267,229,341,212,241}; /* mips32 */ | 2 | static int bits_mips[8] = { 277,249,290,267,229,341,212,241}; /* mips32 */ |
diff --git a/fs/jffs2/ioctl.c b/fs/jffs2/ioctl.c index 238c7992064c..69099835de1c 100644 --- a/fs/jffs2/ioctl.c +++ b/fs/jffs2/ioctl.c | |||
@@ -7,17 +7,17 @@ | |||
7 | * | 7 | * |
8 | * For licensing information, see the file 'LICENCE' in this directory. | 8 | * For licensing information, see the file 'LICENCE' in this directory. |
9 | * | 9 | * |
10 | * $Id: ioctl.c,v 1.9 2004/11/16 20:36:11 dwmw2 Exp $ | 10 | * $Id: ioctl.c,v 1.10 2005/11/07 11:14:40 gleixner Exp $ |
11 | * | 11 | * |
12 | */ | 12 | */ |
13 | 13 | ||
14 | #include <linux/fs.h> | 14 | #include <linux/fs.h> |
15 | 15 | ||
16 | int jffs2_ioctl(struct inode *inode, struct file *filp, unsigned int cmd, | 16 | int jffs2_ioctl(struct inode *inode, struct file *filp, unsigned int cmd, |
17 | unsigned long arg) | 17 | unsigned long arg) |
18 | { | 18 | { |
19 | /* Later, this will provide for lsattr.jffs2 and chattr.jffs2, which | 19 | /* Later, this will provide for lsattr.jffs2 and chattr.jffs2, which |
20 | will include compression support etc. */ | 20 | will include compression support etc. */ |
21 | return -ENOTTY; | 21 | return -ENOTTY; |
22 | } | 22 | } |
23 | 23 | ||
diff --git a/fs/jffs2/malloc.c b/fs/jffs2/malloc.c index 5abb431c2a00..036cbd11c004 100644 --- a/fs/jffs2/malloc.c +++ b/fs/jffs2/malloc.c | |||
@@ -7,7 +7,7 @@ | |||
7 | * | 7 | * |
8 | * For licensing information, see the file 'LICENCE' in this directory. | 8 | * For licensing information, see the file 'LICENCE' in this directory. |
9 | * | 9 | * |
10 | * $Id: malloc.c,v 1.28 2004/11/16 20:36:11 dwmw2 Exp $ | 10 | * $Id: malloc.c,v 1.31 2005/11/07 11:14:40 gleixner Exp $ |
11 | * | 11 | * |
12 | */ | 12 | */ |
13 | 13 | ||
@@ -17,15 +17,6 @@ | |||
17 | #include <linux/jffs2.h> | 17 | #include <linux/jffs2.h> |
18 | #include "nodelist.h" | 18 | #include "nodelist.h" |
19 | 19 | ||
20 | #if 0 | ||
21 | #define JFFS2_SLAB_POISON SLAB_POISON | ||
22 | #else | ||
23 | #define JFFS2_SLAB_POISON 0 | ||
24 | #endif | ||
25 | |||
26 | // replace this by #define D3 (x) x for cache debugging | ||
27 | #define D3(x) | ||
28 | |||
29 | /* These are initialised to NULL in the kernel startup code. | 20 | /* These are initialised to NULL in the kernel startup code. |
30 | If you're porting to other operating systems, beware */ | 21 | If you're porting to other operating systems, beware */ |
31 | static kmem_cache_t *full_dnode_slab; | 22 | static kmem_cache_t *full_dnode_slab; |
@@ -38,45 +29,45 @@ static kmem_cache_t *inode_cache_slab; | |||
38 | 29 | ||
39 | int __init jffs2_create_slab_caches(void) | 30 | int __init jffs2_create_slab_caches(void) |
40 | { | 31 | { |
41 | full_dnode_slab = kmem_cache_create("jffs2_full_dnode", | 32 | full_dnode_slab = kmem_cache_create("jffs2_full_dnode", |
42 | sizeof(struct jffs2_full_dnode), | 33 | sizeof(struct jffs2_full_dnode), |
43 | 0, JFFS2_SLAB_POISON, NULL, NULL); | 34 | 0, 0, NULL, NULL); |
44 | if (!full_dnode_slab) | 35 | if (!full_dnode_slab) |
45 | goto err; | 36 | goto err; |
46 | 37 | ||
47 | raw_dirent_slab = kmem_cache_create("jffs2_raw_dirent", | 38 | raw_dirent_slab = kmem_cache_create("jffs2_raw_dirent", |
48 | sizeof(struct jffs2_raw_dirent), | 39 | sizeof(struct jffs2_raw_dirent), |
49 | 0, JFFS2_SLAB_POISON, NULL, NULL); | 40 | 0, 0, NULL, NULL); |
50 | if (!raw_dirent_slab) | 41 | if (!raw_dirent_slab) |
51 | goto err; | 42 | goto err; |
52 | 43 | ||
53 | raw_inode_slab = kmem_cache_create("jffs2_raw_inode", | 44 | raw_inode_slab = kmem_cache_create("jffs2_raw_inode", |
54 | sizeof(struct jffs2_raw_inode), | 45 | sizeof(struct jffs2_raw_inode), |
55 | 0, JFFS2_SLAB_POISON, NULL, NULL); | 46 | 0, 0, NULL, NULL); |
56 | if (!raw_inode_slab) | 47 | if (!raw_inode_slab) |
57 | goto err; | 48 | goto err; |
58 | 49 | ||
59 | tmp_dnode_info_slab = kmem_cache_create("jffs2_tmp_dnode", | 50 | tmp_dnode_info_slab = kmem_cache_create("jffs2_tmp_dnode", |
60 | sizeof(struct jffs2_tmp_dnode_info), | 51 | sizeof(struct jffs2_tmp_dnode_info), |
61 | 0, JFFS2_SLAB_POISON, NULL, NULL); | 52 | 0, 0, NULL, NULL); |
62 | if (!tmp_dnode_info_slab) | 53 | if (!tmp_dnode_info_slab) |
63 | goto err; | 54 | goto err; |
64 | 55 | ||
65 | raw_node_ref_slab = kmem_cache_create("jffs2_raw_node_ref", | 56 | raw_node_ref_slab = kmem_cache_create("jffs2_raw_node_ref", |
66 | sizeof(struct jffs2_raw_node_ref), | 57 | sizeof(struct jffs2_raw_node_ref), |
67 | 0, JFFS2_SLAB_POISON, NULL, NULL); | 58 | 0, 0, NULL, NULL); |
68 | if (!raw_node_ref_slab) | 59 | if (!raw_node_ref_slab) |
69 | goto err; | 60 | goto err; |
70 | 61 | ||
71 | node_frag_slab = kmem_cache_create("jffs2_node_frag", | 62 | node_frag_slab = kmem_cache_create("jffs2_node_frag", |
72 | sizeof(struct jffs2_node_frag), | 63 | sizeof(struct jffs2_node_frag), |
73 | 0, JFFS2_SLAB_POISON, NULL, NULL); | 64 | 0, 0, NULL, NULL); |
74 | if (!node_frag_slab) | 65 | if (!node_frag_slab) |
75 | goto err; | 66 | goto err; |
76 | 67 | ||
77 | inode_cache_slab = kmem_cache_create("jffs2_inode_cache", | 68 | inode_cache_slab = kmem_cache_create("jffs2_inode_cache", |
78 | sizeof(struct jffs2_inode_cache), | 69 | sizeof(struct jffs2_inode_cache), |
79 | 0, JFFS2_SLAB_POISON, NULL, NULL); | 70 | 0, 0, NULL, NULL); |
80 | if (inode_cache_slab) | 71 | if (inode_cache_slab) |
81 | return 0; | 72 | return 0; |
82 | err: | 73 | err: |
@@ -104,102 +95,113 @@ void jffs2_destroy_slab_caches(void) | |||
104 | 95 | ||
105 | struct jffs2_full_dirent *jffs2_alloc_full_dirent(int namesize) | 96 | struct jffs2_full_dirent *jffs2_alloc_full_dirent(int namesize) |
106 | { | 97 | { |
107 | return kmalloc(sizeof(struct jffs2_full_dirent) + namesize, GFP_KERNEL); | 98 | struct jffs2_full_dirent *ret; |
99 | ret = kmalloc(sizeof(struct jffs2_full_dirent) + namesize, GFP_KERNEL); | ||
100 | dbg_memalloc("%p\n", ret); | ||
101 | return ret; | ||
108 | } | 102 | } |
109 | 103 | ||
110 | void jffs2_free_full_dirent(struct jffs2_full_dirent *x) | 104 | void jffs2_free_full_dirent(struct jffs2_full_dirent *x) |
111 | { | 105 | { |
106 | dbg_memalloc("%p\n", x); | ||
112 | kfree(x); | 107 | kfree(x); |
113 | } | 108 | } |
114 | 109 | ||
115 | struct jffs2_full_dnode *jffs2_alloc_full_dnode(void) | 110 | struct jffs2_full_dnode *jffs2_alloc_full_dnode(void) |
116 | { | 111 | { |
117 | struct jffs2_full_dnode *ret = kmem_cache_alloc(full_dnode_slab, GFP_KERNEL); | 112 | struct jffs2_full_dnode *ret; |
118 | D3 (printk (KERN_DEBUG "alloc_full_dnode at %p\n", ret)); | 113 | ret = kmem_cache_alloc(full_dnode_slab, GFP_KERNEL); |
114 | dbg_memalloc("%p\n", ret); | ||
119 | return ret; | 115 | return ret; |
120 | } | 116 | } |
121 | 117 | ||
122 | void jffs2_free_full_dnode(struct jffs2_full_dnode *x) | 118 | void jffs2_free_full_dnode(struct jffs2_full_dnode *x) |
123 | { | 119 | { |
124 | D3 (printk (KERN_DEBUG "free full_dnode at %p\n", x)); | 120 | dbg_memalloc("%p\n", x); |
125 | kmem_cache_free(full_dnode_slab, x); | 121 | kmem_cache_free(full_dnode_slab, x); |
126 | } | 122 | } |
127 | 123 | ||
128 | struct jffs2_raw_dirent *jffs2_alloc_raw_dirent(void) | 124 | struct jffs2_raw_dirent *jffs2_alloc_raw_dirent(void) |
129 | { | 125 | { |
130 | struct jffs2_raw_dirent *ret = kmem_cache_alloc(raw_dirent_slab, GFP_KERNEL); | 126 | struct jffs2_raw_dirent *ret; |
131 | D3 (printk (KERN_DEBUG "alloc_raw_dirent\n", ret)); | 127 | ret = kmem_cache_alloc(raw_dirent_slab, GFP_KERNEL); |
128 | dbg_memalloc("%p\n", ret); | ||
132 | return ret; | 129 | return ret; |
133 | } | 130 | } |
134 | 131 | ||
135 | void jffs2_free_raw_dirent(struct jffs2_raw_dirent *x) | 132 | void jffs2_free_raw_dirent(struct jffs2_raw_dirent *x) |
136 | { | 133 | { |
137 | D3 (printk (KERN_DEBUG "free_raw_dirent at %p\n", x)); | 134 | dbg_memalloc("%p\n", x); |
138 | kmem_cache_free(raw_dirent_slab, x); | 135 | kmem_cache_free(raw_dirent_slab, x); |
139 | } | 136 | } |
140 | 137 | ||
141 | struct jffs2_raw_inode *jffs2_alloc_raw_inode(void) | 138 | struct jffs2_raw_inode *jffs2_alloc_raw_inode(void) |
142 | { | 139 | { |
143 | struct jffs2_raw_inode *ret = kmem_cache_alloc(raw_inode_slab, GFP_KERNEL); | 140 | struct jffs2_raw_inode *ret; |
144 | D3 (printk (KERN_DEBUG "alloc_raw_inode at %p\n", ret)); | 141 | ret = kmem_cache_alloc(raw_inode_slab, GFP_KERNEL); |
142 | dbg_memalloc("%p\n", ret); | ||
145 | return ret; | 143 | return ret; |
146 | } | 144 | } |
147 | 145 | ||
148 | void jffs2_free_raw_inode(struct jffs2_raw_inode *x) | 146 | void jffs2_free_raw_inode(struct jffs2_raw_inode *x) |
149 | { | 147 | { |
150 | D3 (printk (KERN_DEBUG "free_raw_inode at %p\n", x)); | 148 | dbg_memalloc("%p\n", x); |
151 | kmem_cache_free(raw_inode_slab, x); | 149 | kmem_cache_free(raw_inode_slab, x); |
152 | } | 150 | } |
153 | 151 | ||
154 | struct jffs2_tmp_dnode_info *jffs2_alloc_tmp_dnode_info(void) | 152 | struct jffs2_tmp_dnode_info *jffs2_alloc_tmp_dnode_info(void) |
155 | { | 153 | { |
156 | struct jffs2_tmp_dnode_info *ret = kmem_cache_alloc(tmp_dnode_info_slab, GFP_KERNEL); | 154 | struct jffs2_tmp_dnode_info *ret; |
157 | D3 (printk (KERN_DEBUG "alloc_tmp_dnode_info at %p\n", ret)); | 155 | ret = kmem_cache_alloc(tmp_dnode_info_slab, GFP_KERNEL); |
156 | dbg_memalloc("%p\n", | ||
157 | ret); | ||
158 | return ret; | 158 | return ret; |
159 | } | 159 | } |
160 | 160 | ||
161 | void jffs2_free_tmp_dnode_info(struct jffs2_tmp_dnode_info *x) | 161 | void jffs2_free_tmp_dnode_info(struct jffs2_tmp_dnode_info *x) |
162 | { | 162 | { |
163 | D3 (printk (KERN_DEBUG "free_tmp_dnode_info at %p\n", x)); | 163 | dbg_memalloc("%p\n", x); |
164 | kmem_cache_free(tmp_dnode_info_slab, x); | 164 | kmem_cache_free(tmp_dnode_info_slab, x); |
165 | } | 165 | } |
166 | 166 | ||
167 | struct jffs2_raw_node_ref *jffs2_alloc_raw_node_ref(void) | 167 | struct jffs2_raw_node_ref *jffs2_alloc_raw_node_ref(void) |
168 | { | 168 | { |
169 | struct jffs2_raw_node_ref *ret = kmem_cache_alloc(raw_node_ref_slab, GFP_KERNEL); | 169 | struct jffs2_raw_node_ref *ret; |
170 | D3 (printk (KERN_DEBUG "alloc_raw_node_ref at %p\n", ret)); | 170 | ret = kmem_cache_alloc(raw_node_ref_slab, GFP_KERNEL); |
171 | dbg_memalloc("%p\n", ret); | ||
171 | return ret; | 172 | return ret; |
172 | } | 173 | } |
173 | 174 | ||
174 | void jffs2_free_raw_node_ref(struct jffs2_raw_node_ref *x) | 175 | void jffs2_free_raw_node_ref(struct jffs2_raw_node_ref *x) |
175 | { | 176 | { |
176 | D3 (printk (KERN_DEBUG "free_raw_node_ref at %p\n", x)); | 177 | dbg_memalloc("%p\n", x); |
177 | kmem_cache_free(raw_node_ref_slab, x); | 178 | kmem_cache_free(raw_node_ref_slab, x); |
178 | } | 179 | } |
179 | 180 | ||
180 | struct jffs2_node_frag *jffs2_alloc_node_frag(void) | 181 | struct jffs2_node_frag *jffs2_alloc_node_frag(void) |
181 | { | 182 | { |
182 | struct jffs2_node_frag *ret = kmem_cache_alloc(node_frag_slab, GFP_KERNEL); | 183 | struct jffs2_node_frag *ret; |
183 | D3 (printk (KERN_DEBUG "alloc_node_frag at %p\n", ret)); | 184 | ret = kmem_cache_alloc(node_frag_slab, GFP_KERNEL); |
185 | dbg_memalloc("%p\n", ret); | ||
184 | return ret; | 186 | return ret; |
185 | } | 187 | } |
186 | 188 | ||
187 | void jffs2_free_node_frag(struct jffs2_node_frag *x) | 189 | void jffs2_free_node_frag(struct jffs2_node_frag *x) |
188 | { | 190 | { |
189 | D3 (printk (KERN_DEBUG "free_node_frag at %p\n", x)); | 191 | dbg_memalloc("%p\n", x); |
190 | kmem_cache_free(node_frag_slab, x); | 192 | kmem_cache_free(node_frag_slab, x); |
191 | } | 193 | } |
192 | 194 | ||
193 | struct jffs2_inode_cache *jffs2_alloc_inode_cache(void) | 195 | struct jffs2_inode_cache *jffs2_alloc_inode_cache(void) |
194 | { | 196 | { |
195 | struct jffs2_inode_cache *ret = kmem_cache_alloc(inode_cache_slab, GFP_KERNEL); | 197 | struct jffs2_inode_cache *ret; |
196 | D3 (printk(KERN_DEBUG "Allocated inocache at %p\n", ret)); | 198 | ret = kmem_cache_alloc(inode_cache_slab, GFP_KERNEL); |
199 | dbg_memalloc("%p\n", ret); | ||
197 | return ret; | 200 | return ret; |
198 | } | 201 | } |
199 | 202 | ||
200 | void jffs2_free_inode_cache(struct jffs2_inode_cache *x) | 203 | void jffs2_free_inode_cache(struct jffs2_inode_cache *x) |
201 | { | 204 | { |
202 | D3 (printk(KERN_DEBUG "Freeing inocache at %p\n", x)); | 205 | dbg_memalloc("%p\n", x); |
203 | kmem_cache_free(inode_cache_slab, x); | 206 | kmem_cache_free(inode_cache_slab, x); |
204 | } | 207 | } |
205 | |||
diff --git a/fs/jffs2/nodelist.c b/fs/jffs2/nodelist.c index 4991c348f6ec..c79eebb8ab32 100644 --- a/fs/jffs2/nodelist.c +++ b/fs/jffs2/nodelist.c | |||
@@ -7,7 +7,7 @@ | |||
7 | * | 7 | * |
8 | * For licensing information, see the file 'LICENCE' in this directory. | 8 | * For licensing information, see the file 'LICENCE' in this directory. |
9 | * | 9 | * |
10 | * $Id: nodelist.c,v 1.98 2005/07/10 15:15:32 dedekind Exp $ | 10 | * $Id: nodelist.c,v 1.115 2005/11/07 11:14:40 gleixner Exp $ |
11 | * | 11 | * |
12 | */ | 12 | */ |
13 | 13 | ||
@@ -24,469 +24,832 @@ | |||
24 | void jffs2_add_fd_to_list(struct jffs2_sb_info *c, struct jffs2_full_dirent *new, struct jffs2_full_dirent **list) | 24 | void jffs2_add_fd_to_list(struct jffs2_sb_info *c, struct jffs2_full_dirent *new, struct jffs2_full_dirent **list) |
25 | { | 25 | { |
26 | struct jffs2_full_dirent **prev = list; | 26 | struct jffs2_full_dirent **prev = list; |
27 | D1(printk(KERN_DEBUG "jffs2_add_fd_to_list( %p, %p (->%p))\n", new, list, *list)); | 27 | |
28 | dbg_dentlist("add dirent \"%s\", ino #%u\n", new->name, new->ino); | ||
28 | 29 | ||
29 | while ((*prev) && (*prev)->nhash <= new->nhash) { | 30 | while ((*prev) && (*prev)->nhash <= new->nhash) { |
30 | if ((*prev)->nhash == new->nhash && !strcmp((*prev)->name, new->name)) { | 31 | if ((*prev)->nhash == new->nhash && !strcmp((*prev)->name, new->name)) { |
31 | /* Duplicate. Free one */ | 32 | /* Duplicate. Free one */ |
32 | if (new->version < (*prev)->version) { | 33 | if (new->version < (*prev)->version) { |
33 | D1(printk(KERN_DEBUG "Eep! Marking new dirent node obsolete\n")); | 34 | dbg_dentlist("Eep! Marking new dirent node is obsolete, old is \"%s\", ino #%u\n", |
34 | D1(printk(KERN_DEBUG "New dirent is \"%s\"->ino #%u. Old is \"%s\"->ino #%u\n", new->name, new->ino, (*prev)->name, (*prev)->ino)); | 35 | (*prev)->name, (*prev)->ino); |
35 | jffs2_mark_node_obsolete(c, new->raw); | 36 | jffs2_mark_node_obsolete(c, new->raw); |
36 | jffs2_free_full_dirent(new); | 37 | jffs2_free_full_dirent(new); |
37 | } else { | 38 | } else { |
38 | D1(printk(KERN_DEBUG "Marking old dirent node (ino #%u) obsolete\n", (*prev)->ino)); | 39 | dbg_dentlist("marking old dirent \"%s\", ino #%u bsolete\n", |
40 | (*prev)->name, (*prev)->ino); | ||
39 | new->next = (*prev)->next; | 41 | new->next = (*prev)->next; |
40 | jffs2_mark_node_obsolete(c, ((*prev)->raw)); | 42 | jffs2_mark_node_obsolete(c, ((*prev)->raw)); |
41 | jffs2_free_full_dirent(*prev); | 43 | jffs2_free_full_dirent(*prev); |
42 | *prev = new; | 44 | *prev = new; |
43 | } | 45 | } |
44 | goto out; | 46 | return; |
45 | } | 47 | } |
46 | prev = &((*prev)->next); | 48 | prev = &((*prev)->next); |
47 | } | 49 | } |
48 | new->next = *prev; | 50 | new->next = *prev; |
49 | *prev = new; | 51 | *prev = new; |
52 | } | ||
53 | |||
54 | void jffs2_truncate_fragtree(struct jffs2_sb_info *c, struct rb_root *list, uint32_t size) | ||
55 | { | ||
56 | struct jffs2_node_frag *frag = jffs2_lookup_node_frag(list, size); | ||
57 | |||
58 | dbg_fragtree("truncating fragtree to 0x%08x bytes\n", size); | ||
59 | |||
60 | /* We know frag->ofs <= size. That's what lookup does for us */ | ||
61 | if (frag && frag->ofs != size) { | ||
62 | if (frag->ofs+frag->size > size) { | ||
63 | frag->size = size - frag->ofs; | ||
64 | } | ||
65 | frag = frag_next(frag); | ||
66 | } | ||
67 | while (frag && frag->ofs >= size) { | ||
68 | struct jffs2_node_frag *next = frag_next(frag); | ||
69 | |||
70 | frag_erase(frag, list); | ||
71 | jffs2_obsolete_node_frag(c, frag); | ||
72 | frag = next; | ||
73 | } | ||
50 | 74 | ||
51 | out: | 75 | if (size == 0) |
52 | D2(while(*list) { | 76 | return; |
53 | printk(KERN_DEBUG "Dirent \"%s\" (hash 0x%08x, ino #%u\n", (*list)->name, (*list)->nhash, (*list)->ino); | 77 | |
54 | list = &(*list)->next; | 78 | /* |
55 | }); | 79 | * If the last fragment starts at the RAM page boundary, it is |
80 | * REF_PRISTINE irrespective of its size. | ||
81 | */ | ||
82 | frag = frag_last(list); | ||
83 | if (frag->node && (frag->ofs & (PAGE_CACHE_SIZE - 1)) == 0) { | ||
84 | dbg_fragtree2("marking the last fragment 0x%08x-0x%08x REF_PRISTINE.\n", | ||
85 | frag->ofs, frag->ofs + frag->size); | ||
86 | frag->node->raw->flash_offset = ref_offset(frag->node->raw) | REF_PRISTINE; | ||
87 | } | ||
56 | } | 88 | } |
57 | 89 | ||
58 | /* | 90 | void jffs2_obsolete_node_frag(struct jffs2_sb_info *c, struct jffs2_node_frag *this) |
59 | * Put a new tmp_dnode_info into the temporaty RB-tree, keeping the list in | ||
60 | * order of increasing version. | ||
61 | */ | ||
62 | static void jffs2_add_tn_to_tree(struct jffs2_tmp_dnode_info *tn, struct rb_root *list) | ||
63 | { | 91 | { |
64 | struct rb_node **p = &list->rb_node; | 92 | if (this->node) { |
65 | struct rb_node * parent = NULL; | 93 | this->node->frags--; |
66 | struct jffs2_tmp_dnode_info *this; | 94 | if (!this->node->frags) { |
67 | 95 | /* The node has no valid frags left. It's totally obsoleted */ | |
68 | while (*p) { | 96 | dbg_fragtree2("marking old node @0x%08x (0x%04x-0x%04x) obsolete\n", |
69 | parent = *p; | 97 | ref_offset(this->node->raw), this->node->ofs, this->node->ofs+this->node->size); |
70 | this = rb_entry(parent, struct jffs2_tmp_dnode_info, rb); | 98 | jffs2_mark_node_obsolete(c, this->node->raw); |
71 | 99 | jffs2_free_full_dnode(this->node); | |
72 | /* There may actually be a collision here, but it doesn't | 100 | } else { |
73 | actually matter. As long as the two nodes with the same | 101 | dbg_fragtree2("marking old node @0x%08x (0x%04x-0x%04x) REF_NORMAL. frags is %d\n", |
74 | version are together, it's all fine. */ | 102 | ref_offset(this->node->raw), this->node->ofs, this->node->ofs+this->node->size, this->node->frags); |
75 | if (tn->version < this->version) | 103 | mark_ref_normal(this->node->raw); |
76 | p = &(*p)->rb_left; | 104 | } |
77 | else | ||
78 | p = &(*p)->rb_right; | ||
79 | } | ||
80 | 105 | ||
81 | rb_link_node(&tn->rb, parent, p); | 106 | } |
82 | rb_insert_color(&tn->rb, list); | 107 | jffs2_free_node_frag(this); |
83 | } | 108 | } |
84 | 109 | ||
85 | static void jffs2_free_tmp_dnode_info_list(struct rb_root *list) | 110 | static void jffs2_fragtree_insert(struct jffs2_node_frag *newfrag, struct jffs2_node_frag *base) |
86 | { | 111 | { |
87 | struct rb_node *this; | 112 | struct rb_node *parent = &base->rb; |
88 | struct jffs2_tmp_dnode_info *tn; | 113 | struct rb_node **link = &parent; |
89 | 114 | ||
90 | this = list->rb_node; | 115 | dbg_fragtree2("insert frag (0x%04x-0x%04x)\n", newfrag->ofs, newfrag->ofs + newfrag->size); |
91 | 116 | ||
92 | /* Now at bottom of tree */ | 117 | while (*link) { |
93 | while (this) { | 118 | parent = *link; |
94 | if (this->rb_left) | 119 | base = rb_entry(parent, struct jffs2_node_frag, rb); |
95 | this = this->rb_left; | 120 | |
96 | else if (this->rb_right) | 121 | if (newfrag->ofs > base->ofs) |
97 | this = this->rb_right; | 122 | link = &base->rb.rb_right; |
123 | else if (newfrag->ofs < base->ofs) | ||
124 | link = &base->rb.rb_left; | ||
98 | else { | 125 | else { |
99 | tn = rb_entry(this, struct jffs2_tmp_dnode_info, rb); | 126 | JFFS2_ERROR("duplicate frag at %08x (%p,%p)\n", newfrag->ofs, newfrag, base); |
100 | jffs2_free_full_dnode(tn->fn); | 127 | BUG(); |
101 | jffs2_free_tmp_dnode_info(tn); | ||
102 | |||
103 | this = this->rb_parent; | ||
104 | if (!this) | ||
105 | break; | ||
106 | |||
107 | if (this->rb_left == &tn->rb) | ||
108 | this->rb_left = NULL; | ||
109 | else if (this->rb_right == &tn->rb) | ||
110 | this->rb_right = NULL; | ||
111 | else BUG(); | ||
112 | } | 128 | } |
113 | } | 129 | } |
114 | list->rb_node = NULL; | 130 | |
131 | rb_link_node(&newfrag->rb, &base->rb, link); | ||
115 | } | 132 | } |
116 | 133 | ||
117 | static void jffs2_free_full_dirent_list(struct jffs2_full_dirent *fd) | 134 | /* |
135 | * Allocate and initializes a new fragment. | ||
136 | */ | ||
137 | static inline struct jffs2_node_frag * new_fragment(struct jffs2_full_dnode *fn, uint32_t ofs, uint32_t size) | ||
118 | { | 138 | { |
119 | struct jffs2_full_dirent *next; | 139 | struct jffs2_node_frag *newfrag; |
120 | 140 | ||
121 | while (fd) { | 141 | newfrag = jffs2_alloc_node_frag(); |
122 | next = fd->next; | 142 | if (likely(newfrag)) { |
123 | jffs2_free_full_dirent(fd); | 143 | newfrag->ofs = ofs; |
124 | fd = next; | 144 | newfrag->size = size; |
145 | newfrag->node = fn; | ||
146 | } else { | ||
147 | JFFS2_ERROR("cannot allocate a jffs2_node_frag object\n"); | ||
125 | } | 148 | } |
149 | |||
150 | return newfrag; | ||
126 | } | 151 | } |
127 | 152 | ||
128 | /* Returns first valid node after 'ref'. May return 'ref' */ | 153 | /* |
129 | static struct jffs2_raw_node_ref *jffs2_first_valid_node(struct jffs2_raw_node_ref *ref) | 154 | * Called when there is no overlapping fragment exist. Inserts a hole before the new |
155 | * fragment and inserts the new fragment to the fragtree. | ||
156 | */ | ||
157 | static int no_overlapping_node(struct jffs2_sb_info *c, struct rb_root *root, | ||
158 | struct jffs2_node_frag *newfrag, | ||
159 | struct jffs2_node_frag *this, uint32_t lastend) | ||
130 | { | 160 | { |
131 | while (ref && ref->next_in_ino) { | 161 | if (lastend < newfrag->node->ofs) { |
132 | if (!ref_obsolete(ref)) | 162 | /* put a hole in before the new fragment */ |
133 | return ref; | 163 | struct jffs2_node_frag *holefrag; |
134 | D1(printk(KERN_DEBUG "node at 0x%08x is obsoleted. Ignoring.\n", ref_offset(ref))); | 164 | |
135 | ref = ref->next_in_ino; | 165 | holefrag= new_fragment(NULL, lastend, newfrag->node->ofs - lastend); |
166 | if (unlikely(!holefrag)) { | ||
167 | jffs2_free_node_frag(newfrag); | ||
168 | return -ENOMEM; | ||
169 | } | ||
170 | |||
171 | if (this) { | ||
172 | /* By definition, the 'this' node has no right-hand child, | ||
173 | because there are no frags with offset greater than it. | ||
174 | So that's where we want to put the hole */ | ||
175 | dbg_fragtree2("add hole frag %#04x-%#04x on the right of the new frag.\n", | ||
176 | holefrag->ofs, holefrag->ofs + holefrag->size); | ||
177 | rb_link_node(&holefrag->rb, &this->rb, &this->rb.rb_right); | ||
178 | } else { | ||
179 | dbg_fragtree2("Add hole frag %#04x-%#04x to the root of the tree.\n", | ||
180 | holefrag->ofs, holefrag->ofs + holefrag->size); | ||
181 | rb_link_node(&holefrag->rb, NULL, &root->rb_node); | ||
182 | } | ||
183 | rb_insert_color(&holefrag->rb, root); | ||
184 | this = holefrag; | ||
185 | } | ||
186 | |||
187 | if (this) { | ||
188 | /* By definition, the 'this' node has no right-hand child, | ||
189 | because there are no frags with offset greater than it. | ||
190 | So that's where we want to put new fragment */ | ||
191 | dbg_fragtree2("add the new node at the right\n"); | ||
192 | rb_link_node(&newfrag->rb, &this->rb, &this->rb.rb_right); | ||
193 | } else { | ||
194 | dbg_fragtree2("insert the new node at the root of the tree\n"); | ||
195 | rb_link_node(&newfrag->rb, NULL, &root->rb_node); | ||
136 | } | 196 | } |
137 | return NULL; | 197 | rb_insert_color(&newfrag->rb, root); |
198 | |||
199 | return 0; | ||
138 | } | 200 | } |
139 | 201 | ||
140 | /* Get tmp_dnode_info and full_dirent for all non-obsolete nodes associated | 202 | /* Doesn't set inode->i_size */ |
141 | with this ino, returning the former in order of version */ | 203 | static int jffs2_add_frag_to_fragtree(struct jffs2_sb_info *c, struct rb_root *root, struct jffs2_node_frag *newfrag) |
204 | { | ||
205 | struct jffs2_node_frag *this; | ||
206 | uint32_t lastend; | ||
207 | |||
208 | /* Skip all the nodes which are completed before this one starts */ | ||
209 | this = jffs2_lookup_node_frag(root, newfrag->node->ofs); | ||
210 | |||
211 | if (this) { | ||
212 | dbg_fragtree2("lookup gave frag 0x%04x-0x%04x; phys 0x%08x (*%p)\n", | ||
213 | this->ofs, this->ofs+this->size, this->node?(ref_offset(this->node->raw)):0xffffffff, this); | ||
214 | lastend = this->ofs + this->size; | ||
215 | } else { | ||
216 | dbg_fragtree2("lookup gave no frag\n"); | ||
217 | lastend = 0; | ||
218 | } | ||
219 | |||
220 | /* See if we ran off the end of the fragtree */ | ||
221 | if (lastend <= newfrag->ofs) { | ||
222 | /* We did */ | ||
223 | |||
224 | /* Check if 'this' node was on the same page as the new node. | ||
225 | If so, both 'this' and the new node get marked REF_NORMAL so | ||
226 | the GC can take a look. | ||
227 | */ | ||
228 | if (lastend && (lastend-1) >> PAGE_CACHE_SHIFT == newfrag->ofs >> PAGE_CACHE_SHIFT) { | ||
229 | if (this->node) | ||
230 | mark_ref_normal(this->node->raw); | ||
231 | mark_ref_normal(newfrag->node->raw); | ||
232 | } | ||
233 | |||
234 | return no_overlapping_node(c, root, newfrag, this, lastend); | ||
235 | } | ||
142 | 236 | ||
143 | int jffs2_get_inode_nodes(struct jffs2_sb_info *c, struct jffs2_inode_info *f, | 237 | if (this->node) |
144 | struct rb_root *tnp, struct jffs2_full_dirent **fdp, | 238 | dbg_fragtree2("dealing with frag %u-%u, phys %#08x(%d).\n", |
145 | uint32_t *highest_version, uint32_t *latest_mctime, | 239 | this->ofs, this->ofs + this->size, |
146 | uint32_t *mctime_ver) | 240 | ref_offset(this->node->raw), ref_flags(this->node->raw)); |
241 | else | ||
242 | dbg_fragtree2("dealing with hole frag %u-%u.\n", | ||
243 | this->ofs, this->ofs + this->size); | ||
244 | |||
245 | /* OK. 'this' is pointing at the first frag that newfrag->ofs at least partially obsoletes, | ||
246 | * - i.e. newfrag->ofs < this->ofs+this->size && newfrag->ofs >= this->ofs | ||
247 | */ | ||
248 | if (newfrag->ofs > this->ofs) { | ||
249 | /* This node isn't completely obsoleted. The start of it remains valid */ | ||
250 | |||
251 | /* Mark the new node and the partially covered node REF_NORMAL -- let | ||
252 | the GC take a look at them */ | ||
253 | mark_ref_normal(newfrag->node->raw); | ||
254 | if (this->node) | ||
255 | mark_ref_normal(this->node->raw); | ||
256 | |||
257 | if (this->ofs + this->size > newfrag->ofs + newfrag->size) { | ||
258 | /* The new node splits 'this' frag into two */ | ||
259 | struct jffs2_node_frag *newfrag2; | ||
260 | |||
261 | if (this->node) | ||
262 | dbg_fragtree2("split old frag 0x%04x-0x%04x, phys 0x%08x\n", | ||
263 | this->ofs, this->ofs+this->size, ref_offset(this->node->raw)); | ||
264 | else | ||
265 | dbg_fragtree2("split old hole frag 0x%04x-0x%04x\n", | ||
266 | this->ofs, this->ofs+this->size); | ||
267 | |||
268 | /* New second frag pointing to this's node */ | ||
269 | newfrag2 = new_fragment(this->node, newfrag->ofs + newfrag->size, | ||
270 | this->ofs + this->size - newfrag->ofs - newfrag->size); | ||
271 | if (unlikely(!newfrag2)) | ||
272 | return -ENOMEM; | ||
273 | if (this->node) | ||
274 | this->node->frags++; | ||
275 | |||
276 | /* Adjust size of original 'this' */ | ||
277 | this->size = newfrag->ofs - this->ofs; | ||
278 | |||
279 | /* Now, we know there's no node with offset | ||
280 | greater than this->ofs but smaller than | ||
281 | newfrag2->ofs or newfrag->ofs, for obvious | ||
282 | reasons. So we can do a tree insert from | ||
283 | 'this' to insert newfrag, and a tree insert | ||
284 | from newfrag to insert newfrag2. */ | ||
285 | jffs2_fragtree_insert(newfrag, this); | ||
286 | rb_insert_color(&newfrag->rb, root); | ||
287 | |||
288 | jffs2_fragtree_insert(newfrag2, newfrag); | ||
289 | rb_insert_color(&newfrag2->rb, root); | ||
290 | |||
291 | return 0; | ||
292 | } | ||
293 | /* New node just reduces 'this' frag in size, doesn't split it */ | ||
294 | this->size = newfrag->ofs - this->ofs; | ||
295 | |||
296 | /* Again, we know it lives down here in the tree */ | ||
297 | jffs2_fragtree_insert(newfrag, this); | ||
298 | rb_insert_color(&newfrag->rb, root); | ||
299 | } else { | ||
300 | /* New frag starts at the same point as 'this' used to. Replace | ||
301 | it in the tree without doing a delete and insertion */ | ||
302 | dbg_fragtree2("inserting newfrag (*%p),%d-%d in before 'this' (*%p),%d-%d\n", | ||
303 | newfrag, newfrag->ofs, newfrag->ofs+newfrag->size, this, this->ofs, this->ofs+this->size); | ||
304 | |||
305 | rb_replace_node(&this->rb, &newfrag->rb, root); | ||
306 | |||
307 | if (newfrag->ofs + newfrag->size >= this->ofs+this->size) { | ||
308 | dbg_fragtree2("obsoleting node frag %p (%x-%x)\n", this, this->ofs, this->ofs+this->size); | ||
309 | jffs2_obsolete_node_frag(c, this); | ||
310 | } else { | ||
311 | this->ofs += newfrag->size; | ||
312 | this->size -= newfrag->size; | ||
313 | |||
314 | jffs2_fragtree_insert(this, newfrag); | ||
315 | rb_insert_color(&this->rb, root); | ||
316 | return 0; | ||
317 | } | ||
318 | } | ||
319 | /* OK, now we have newfrag added in the correct place in the tree, but | ||
320 | frag_next(newfrag) may be a fragment which is overlapped by it | ||
321 | */ | ||
322 | while ((this = frag_next(newfrag)) && newfrag->ofs + newfrag->size >= this->ofs + this->size) { | ||
323 | /* 'this' frag is obsoleted completely. */ | ||
324 | dbg_fragtree2("obsoleting node frag %p (%x-%x) and removing from tree\n", | ||
325 | this, this->ofs, this->ofs+this->size); | ||
326 | rb_erase(&this->rb, root); | ||
327 | jffs2_obsolete_node_frag(c, this); | ||
328 | } | ||
329 | /* Now we're pointing at the first frag which isn't totally obsoleted by | ||
330 | the new frag */ | ||
331 | |||
332 | if (!this || newfrag->ofs + newfrag->size == this->ofs) | ||
333 | return 0; | ||
334 | |||
335 | /* Still some overlap but we don't need to move it in the tree */ | ||
336 | this->size = (this->ofs + this->size) - (newfrag->ofs + newfrag->size); | ||
337 | this->ofs = newfrag->ofs + newfrag->size; | ||
338 | |||
339 | /* And mark them REF_NORMAL so the GC takes a look at them */ | ||
340 | if (this->node) | ||
341 | mark_ref_normal(this->node->raw); | ||
342 | mark_ref_normal(newfrag->node->raw); | ||
343 | |||
344 | return 0; | ||
345 | } | ||
346 | |||
347 | /* | ||
348 | * Given an inode, probably with existing tree of fragments, add the new node | ||
349 | * to the fragment tree. | ||
350 | */ | ||
351 | int jffs2_add_full_dnode_to_inode(struct jffs2_sb_info *c, struct jffs2_inode_info *f, struct jffs2_full_dnode *fn) | ||
147 | { | 352 | { |
148 | struct jffs2_raw_node_ref *ref, *valid_ref; | 353 | int ret; |
149 | struct jffs2_tmp_dnode_info *tn; | 354 | struct jffs2_node_frag *newfrag; |
150 | struct rb_root ret_tn = RB_ROOT; | ||
151 | struct jffs2_full_dirent *fd, *ret_fd = NULL; | ||
152 | union jffs2_node_union node; | ||
153 | size_t retlen; | ||
154 | int err; | ||
155 | |||
156 | *mctime_ver = 0; | ||
157 | |||
158 | D1(printk(KERN_DEBUG "jffs2_get_inode_nodes(): ino #%u\n", f->inocache->ino)); | ||
159 | 355 | ||
160 | spin_lock(&c->erase_completion_lock); | 356 | if (unlikely(!fn->size)) |
357 | return 0; | ||
161 | 358 | ||
162 | valid_ref = jffs2_first_valid_node(f->inocache->nodes); | 359 | newfrag = new_fragment(fn, fn->ofs, fn->size); |
360 | if (unlikely(!newfrag)) | ||
361 | return -ENOMEM; | ||
362 | newfrag->node->frags = 1; | ||
163 | 363 | ||
164 | if (!valid_ref && (f->inocache->ino != 1)) | 364 | dbg_fragtree("adding node %#04x-%#04x @0x%08x on flash, newfrag *%p\n", |
165 | printk(KERN_WARNING "Eep. No valid nodes for ino #%u\n", f->inocache->ino); | 365 | fn->ofs, fn->ofs+fn->size, ref_offset(fn->raw), newfrag); |
166 | 366 | ||
167 | while (valid_ref) { | 367 | ret = jffs2_add_frag_to_fragtree(c, &f->fragtree, newfrag); |
168 | /* We can hold a pointer to a non-obsolete node without the spinlock, | 368 | if (unlikely(ret)) |
169 | but _obsolete_ nodes may disappear at any time, if the block | 369 | return ret; |
170 | they're in gets erased. So if we mark 'ref' obsolete while we're | ||
171 | not holding the lock, it can go away immediately. For that reason, | ||
172 | we find the next valid node first, before processing 'ref'. | ||
173 | */ | ||
174 | ref = valid_ref; | ||
175 | valid_ref = jffs2_first_valid_node(ref->next_in_ino); | ||
176 | spin_unlock(&c->erase_completion_lock); | ||
177 | 370 | ||
178 | cond_resched(); | 371 | /* If we now share a page with other nodes, mark either previous |
372 | or next node REF_NORMAL, as appropriate. */ | ||
373 | if (newfrag->ofs & (PAGE_CACHE_SIZE-1)) { | ||
374 | struct jffs2_node_frag *prev = frag_prev(newfrag); | ||
375 | |||
376 | mark_ref_normal(fn->raw); | ||
377 | /* If we don't start at zero there's _always_ a previous */ | ||
378 | if (prev->node) | ||
379 | mark_ref_normal(prev->node->raw); | ||
380 | } | ||
381 | |||
382 | if ((newfrag->ofs+newfrag->size) & (PAGE_CACHE_SIZE-1)) { | ||
383 | struct jffs2_node_frag *next = frag_next(newfrag); | ||
384 | |||
385 | if (next) { | ||
386 | mark_ref_normal(fn->raw); | ||
387 | if (next->node) | ||
388 | mark_ref_normal(next->node->raw); | ||
389 | } | ||
390 | } | ||
391 | jffs2_dbg_fragtree_paranoia_check_nolock(f); | ||
392 | |||
393 | return 0; | ||
394 | } | ||
395 | |||
396 | /* | ||
397 | * Check the data CRC of the node. | ||
398 | * | ||
399 | * Returns: 0 if the data CRC is correct; | ||
400 | * 1 - if incorrect; | ||
401 | * error code if an error occured. | ||
402 | */ | ||
403 | static int check_node_data(struct jffs2_sb_info *c, struct jffs2_tmp_dnode_info *tn) | ||
404 | { | ||
405 | struct jffs2_raw_node_ref *ref = tn->fn->raw; | ||
406 | int err = 0, pointed = 0; | ||
407 | struct jffs2_eraseblock *jeb; | ||
408 | unsigned char *buffer; | ||
409 | uint32_t crc, ofs, retlen, len; | ||
410 | |||
411 | BUG_ON(tn->csize == 0); | ||
412 | |||
413 | if (!jffs2_is_writebuffered(c)) | ||
414 | goto adj_acc; | ||
415 | |||
416 | /* Calculate how many bytes were already checked */ | ||
417 | ofs = ref_offset(ref) + sizeof(struct jffs2_raw_inode); | ||
418 | len = ofs % c->wbuf_pagesize; | ||
419 | if (likely(len)) | ||
420 | len = c->wbuf_pagesize - len; | ||
421 | |||
422 | if (len >= tn->csize) { | ||
423 | dbg_readinode("no need to check node at %#08x, data length %u, data starts at %#08x - it has already been checked.\n", | ||
424 | ref_offset(ref), tn->csize, ofs); | ||
425 | goto adj_acc; | ||
426 | } | ||
427 | |||
428 | ofs += len; | ||
429 | len = tn->csize - len; | ||
430 | |||
431 | dbg_readinode("check node at %#08x, data length %u, partial CRC %#08x, correct CRC %#08x, data starts at %#08x, start checking from %#08x - %u bytes.\n", | ||
432 | ref_offset(ref), tn->csize, tn->partial_crc, tn->data_crc, ofs - len, ofs, len); | ||
433 | |||
434 | #ifndef __ECOS | ||
435 | /* TODO: instead, incapsulate point() stuff to jffs2_flash_read(), | ||
436 | * adding and jffs2_flash_read_end() interface. */ | ||
437 | if (c->mtd->point) { | ||
438 | err = c->mtd->point(c->mtd, ofs, len, &retlen, &buffer); | ||
439 | if (!err && retlen < tn->csize) { | ||
440 | JFFS2_WARNING("MTD point returned len too short: %u instead of %u.\n", retlen, tn->csize); | ||
441 | c->mtd->unpoint(c->mtd, buffer, ofs, len); | ||
442 | } else if (err) | ||
443 | JFFS2_WARNING("MTD point failed: error code %d.\n", err); | ||
444 | else | ||
445 | pointed = 1; /* succefully pointed to device */ | ||
446 | } | ||
447 | #endif | ||
448 | |||
449 | if (!pointed) { | ||
450 | buffer = kmalloc(len, GFP_KERNEL); | ||
451 | if (unlikely(!buffer)) | ||
452 | return -ENOMEM; | ||
179 | 453 | ||
180 | /* FIXME: point() */ | 454 | /* TODO: this is very frequent pattern, make it a separate |
181 | err = jffs2_flash_read(c, (ref_offset(ref)), | 455 | * routine */ |
182 | min_t(uint32_t, ref_totlen(c, NULL, ref), sizeof(node)), | 456 | err = jffs2_flash_read(c, ofs, len, &retlen, buffer); |
183 | &retlen, (void *)&node); | ||
184 | if (err) { | 457 | if (err) { |
185 | printk(KERN_WARNING "error %d reading node at 0x%08x in get_inode_nodes()\n", err, ref_offset(ref)); | 458 | JFFS2_ERROR("can not read %d bytes from 0x%08x, error code: %d.\n", len, ofs, err); |
186 | goto free_out; | 459 | goto free_out; |
187 | } | 460 | } |
188 | |||
189 | 461 | ||
190 | /* Check we've managed to read at least the common node header */ | 462 | if (retlen != len) { |
191 | if (retlen < min_t(uint32_t, ref_totlen(c, NULL, ref), sizeof(node.u))) { | 463 | JFFS2_ERROR("short read at %#08x: %d instead of %d.\n", ofs, retlen, len); |
192 | printk(KERN_WARNING "short read in get_inode_nodes()\n"); | ||
193 | err = -EIO; | 464 | err = -EIO; |
194 | goto free_out; | 465 | goto free_out; |
195 | } | 466 | } |
196 | 467 | } | |
197 | switch (je16_to_cpu(node.u.nodetype)) { | ||
198 | case JFFS2_NODETYPE_DIRENT: | ||
199 | D1(printk(KERN_DEBUG "Node at %08x (%d) is a dirent node\n", ref_offset(ref), ref_flags(ref))); | ||
200 | if (ref_flags(ref) == REF_UNCHECKED) { | ||
201 | printk(KERN_WARNING "BUG: Dirent node at 0x%08x never got checked? How?\n", ref_offset(ref)); | ||
202 | BUG(); | ||
203 | } | ||
204 | if (retlen < sizeof(node.d)) { | ||
205 | printk(KERN_WARNING "short read in get_inode_nodes()\n"); | ||
206 | err = -EIO; | ||
207 | goto free_out; | ||
208 | } | ||
209 | /* sanity check */ | ||
210 | if (PAD((node.d.nsize + sizeof (node.d))) != PAD(je32_to_cpu (node.d.totlen))) { | ||
211 | printk(KERN_NOTICE "jffs2_get_inode_nodes(): Illegal nsize in node at 0x%08x: nsize 0x%02x, totlen %04x\n", | ||
212 | ref_offset(ref), node.d.nsize, je32_to_cpu(node.d.totlen)); | ||
213 | jffs2_mark_node_obsolete(c, ref); | ||
214 | spin_lock(&c->erase_completion_lock); | ||
215 | continue; | ||
216 | } | ||
217 | if (je32_to_cpu(node.d.version) > *highest_version) | ||
218 | *highest_version = je32_to_cpu(node.d.version); | ||
219 | if (ref_obsolete(ref)) { | ||
220 | /* Obsoleted. This cannot happen, surely? dwmw2 20020308 */ | ||
221 | printk(KERN_ERR "Dirent node at 0x%08x became obsolete while we weren't looking\n", | ||
222 | ref_offset(ref)); | ||
223 | BUG(); | ||
224 | } | ||
225 | |||
226 | fd = jffs2_alloc_full_dirent(node.d.nsize+1); | ||
227 | if (!fd) { | ||
228 | err = -ENOMEM; | ||
229 | goto free_out; | ||
230 | } | ||
231 | fd->raw = ref; | ||
232 | fd->version = je32_to_cpu(node.d.version); | ||
233 | fd->ino = je32_to_cpu(node.d.ino); | ||
234 | fd->type = node.d.type; | ||
235 | |||
236 | /* Pick out the mctime of the latest dirent */ | ||
237 | if(fd->version > *mctime_ver) { | ||
238 | *mctime_ver = fd->version; | ||
239 | *latest_mctime = je32_to_cpu(node.d.mctime); | ||
240 | } | ||
241 | 468 | ||
242 | /* memcpy as much of the name as possible from the raw | 469 | /* Continue calculating CRC */ |
243 | dirent we've already read from the flash | 470 | crc = crc32(tn->partial_crc, buffer, len); |
244 | */ | 471 | if(!pointed) |
245 | if (retlen > sizeof(struct jffs2_raw_dirent)) | 472 | kfree(buffer); |
246 | memcpy(&fd->name[0], &node.d.name[0], min_t(uint32_t, node.d.nsize, (retlen-sizeof(struct jffs2_raw_dirent)))); | 473 | #ifndef __ECOS |
247 | 474 | else | |
248 | /* Do we need to copy any more of the name directly | 475 | c->mtd->unpoint(c->mtd, buffer, ofs, len); |
249 | from the flash? | 476 | #endif |
250 | */ | ||
251 | if (node.d.nsize + sizeof(struct jffs2_raw_dirent) > retlen) { | ||
252 | /* FIXME: point() */ | ||
253 | int already = retlen - sizeof(struct jffs2_raw_dirent); | ||
254 | |||
255 | err = jffs2_flash_read(c, (ref_offset(ref)) + retlen, | ||
256 | node.d.nsize - already, &retlen, &fd->name[already]); | ||
257 | if (!err && retlen != node.d.nsize - already) | ||
258 | err = -EIO; | ||
259 | |||
260 | if (err) { | ||
261 | printk(KERN_WARNING "Read remainder of name in jffs2_get_inode_nodes(): error %d\n", err); | ||
262 | jffs2_free_full_dirent(fd); | ||
263 | goto free_out; | ||
264 | } | ||
265 | } | ||
266 | fd->nhash = full_name_hash(fd->name, node.d.nsize); | ||
267 | fd->next = NULL; | ||
268 | fd->name[node.d.nsize] = '\0'; | ||
269 | /* Wheee. We now have a complete jffs2_full_dirent structure, with | ||
270 | the name in it and everything. Link it into the list | ||
271 | */ | ||
272 | D1(printk(KERN_DEBUG "Adding fd \"%s\", ino #%u\n", fd->name, fd->ino)); | ||
273 | jffs2_add_fd_to_list(c, fd, &ret_fd); | ||
274 | break; | ||
275 | |||
276 | case JFFS2_NODETYPE_INODE: | ||
277 | D1(printk(KERN_DEBUG "Node at %08x (%d) is a data node\n", ref_offset(ref), ref_flags(ref))); | ||
278 | if (retlen < sizeof(node.i)) { | ||
279 | printk(KERN_WARNING "read too short for dnode\n"); | ||
280 | err = -EIO; | ||
281 | goto free_out; | ||
282 | } | ||
283 | if (je32_to_cpu(node.i.version) > *highest_version) | ||
284 | *highest_version = je32_to_cpu(node.i.version); | ||
285 | D1(printk(KERN_DEBUG "version %d, highest_version now %d\n", je32_to_cpu(node.i.version), *highest_version)); | ||
286 | |||
287 | if (ref_obsolete(ref)) { | ||
288 | /* Obsoleted. This cannot happen, surely? dwmw2 20020308 */ | ||
289 | printk(KERN_ERR "Inode node at 0x%08x became obsolete while we weren't looking\n", | ||
290 | ref_offset(ref)); | ||
291 | BUG(); | ||
292 | } | ||
293 | 477 | ||
294 | /* If we've never checked the CRCs on this node, check them now. */ | 478 | if (crc != tn->data_crc) { |
295 | if (ref_flags(ref) == REF_UNCHECKED) { | 479 | JFFS2_NOTICE("wrong data CRC in data node at 0x%08x: read %#08x, calculated %#08x.\n", |
296 | uint32_t crc, len; | 480 | ofs, tn->data_crc, crc); |
297 | struct jffs2_eraseblock *jeb; | 481 | return 1; |
298 | 482 | } | |
299 | crc = crc32(0, &node, sizeof(node.i)-8); | ||
300 | if (crc != je32_to_cpu(node.i.node_crc)) { | ||
301 | printk(KERN_NOTICE "jffs2_get_inode_nodes(): CRC failed on node at 0x%08x: Read 0x%08x, calculated 0x%08x\n", | ||
302 | ref_offset(ref), je32_to_cpu(node.i.node_crc), crc); | ||
303 | jffs2_mark_node_obsolete(c, ref); | ||
304 | spin_lock(&c->erase_completion_lock); | ||
305 | continue; | ||
306 | } | ||
307 | |||
308 | /* sanity checks */ | ||
309 | if ( je32_to_cpu(node.i.offset) > je32_to_cpu(node.i.isize) || | ||
310 | PAD(je32_to_cpu(node.i.csize) + sizeof (node.i)) != PAD(je32_to_cpu(node.i.totlen))) { | ||
311 | printk(KERN_NOTICE "jffs2_get_inode_nodes(): Inode corrupted at 0x%08x, totlen %d, #ino %d, version %d, isize %d, csize %d, dsize %d \n", | ||
312 | ref_offset(ref), je32_to_cpu(node.i.totlen), je32_to_cpu(node.i.ino), | ||
313 | je32_to_cpu(node.i.version), je32_to_cpu(node.i.isize), | ||
314 | je32_to_cpu(node.i.csize), je32_to_cpu(node.i.dsize)); | ||
315 | jffs2_mark_node_obsolete(c, ref); | ||
316 | spin_lock(&c->erase_completion_lock); | ||
317 | continue; | ||
318 | } | ||
319 | 483 | ||
320 | if (node.i.compr != JFFS2_COMPR_ZERO && je32_to_cpu(node.i.csize)) { | 484 | adj_acc: |
321 | unsigned char *buf=NULL; | 485 | jeb = &c->blocks[ref->flash_offset / c->sector_size]; |
322 | uint32_t pointed = 0; | 486 | len = ref_totlen(c, jeb, ref); |
323 | #ifndef __ECOS | 487 | |
324 | if (c->mtd->point) { | 488 | /* |
325 | err = c->mtd->point (c->mtd, ref_offset(ref) + sizeof(node.i), je32_to_cpu(node.i.csize), | 489 | * Mark the node as having been checked and fix the |
326 | &retlen, &buf); | 490 | * accounting accordingly. |
327 | if (!err && retlen < je32_to_cpu(node.i.csize)) { | 491 | */ |
328 | D1(printk(KERN_DEBUG "MTD point returned len too short: 0x%zx\n", retlen)); | 492 | spin_lock(&c->erase_completion_lock); |
329 | c->mtd->unpoint(c->mtd, buf, ref_offset(ref) + sizeof(node.i), je32_to_cpu(node.i.csize)); | 493 | jeb->used_size += len; |
330 | } else if (err){ | 494 | jeb->unchecked_size -= len; |
331 | D1(printk(KERN_DEBUG "MTD point failed %d\n", err)); | 495 | c->used_size += len; |
332 | } else | 496 | c->unchecked_size -= len; |
333 | pointed = 1; /* succefully pointed to device */ | 497 | spin_unlock(&c->erase_completion_lock); |
334 | } | 498 | |
335 | #endif | 499 | return 0; |
336 | if(!pointed){ | 500 | |
337 | buf = kmalloc(je32_to_cpu(node.i.csize), GFP_KERNEL); | 501 | free_out: |
338 | if (!buf) | 502 | if(!pointed) |
339 | return -ENOMEM; | 503 | kfree(buffer); |
340 | |||
341 | err = jffs2_flash_read(c, ref_offset(ref) + sizeof(node.i), je32_to_cpu(node.i.csize), | ||
342 | &retlen, buf); | ||
343 | if (!err && retlen != je32_to_cpu(node.i.csize)) | ||
344 | err = -EIO; | ||
345 | if (err) { | ||
346 | kfree(buf); | ||
347 | return err; | ||
348 | } | ||
349 | } | ||
350 | crc = crc32(0, buf, je32_to_cpu(node.i.csize)); | ||
351 | if(!pointed) | ||
352 | kfree(buf); | ||
353 | #ifndef __ECOS | 504 | #ifndef __ECOS |
354 | else | 505 | else |
355 | c->mtd->unpoint(c->mtd, buf, ref_offset(ref) + sizeof(node.i), je32_to_cpu(node.i.csize)); | 506 | c->mtd->unpoint(c->mtd, buffer, ofs, len); |
356 | #endif | 507 | #endif |
508 | return err; | ||
509 | } | ||
357 | 510 | ||
358 | if (crc != je32_to_cpu(node.i.data_crc)) { | 511 | /* |
359 | printk(KERN_NOTICE "jffs2_get_inode_nodes(): Data CRC failed on node at 0x%08x: Read 0x%08x, calculated 0x%08x\n", | 512 | * Helper function for jffs2_add_older_frag_to_fragtree(). |
360 | ref_offset(ref), je32_to_cpu(node.i.data_crc), crc); | 513 | * |
361 | jffs2_mark_node_obsolete(c, ref); | 514 | * Checks the node if we are in the checking stage. |
362 | spin_lock(&c->erase_completion_lock); | 515 | */ |
363 | continue; | 516 | static inline int check_node(struct jffs2_sb_info *c, struct jffs2_inode_info *f, struct jffs2_tmp_dnode_info *tn) |
364 | } | 517 | { |
365 | 518 | int ret; | |
366 | } | ||
367 | 519 | ||
368 | /* Mark the node as having been checked and fix the accounting accordingly */ | 520 | BUG_ON(ref_obsolete(tn->fn->raw)); |
369 | spin_lock(&c->erase_completion_lock); | 521 | |
370 | jeb = &c->blocks[ref->flash_offset / c->sector_size]; | 522 | /* We only check the data CRC of unchecked nodes */ |
371 | len = ref_totlen(c, jeb, ref); | 523 | if (ref_flags(tn->fn->raw) != REF_UNCHECKED) |
372 | 524 | return 0; | |
373 | jeb->used_size += len; | 525 | |
374 | jeb->unchecked_size -= len; | 526 | dbg_fragtree2("check node %#04x-%#04x, phys offs %#08x.\n", |
375 | c->used_size += len; | 527 | tn->fn->ofs, tn->fn->ofs + tn->fn->size, ref_offset(tn->fn->raw)); |
376 | c->unchecked_size -= len; | 528 | |
377 | 529 | ret = check_node_data(c, tn); | |
378 | /* If node covers at least a whole page, or if it starts at the | 530 | if (unlikely(ret < 0)) { |
379 | beginning of a page and runs to the end of the file, or if | 531 | JFFS2_ERROR("check_node_data() returned error: %d.\n", |
380 | it's a hole node, mark it REF_PRISTINE, else REF_NORMAL. | 532 | ret); |
381 | 533 | } else if (unlikely(ret > 0)) { | |
382 | If it's actually overlapped, it'll get made NORMAL (or OBSOLETE) | 534 | dbg_fragtree2("CRC error, mark it obsolete.\n"); |
383 | when the overlapping node(s) get added to the tree anyway. | 535 | jffs2_mark_node_obsolete(c, tn->fn->raw); |
384 | */ | 536 | } |
385 | if ((je32_to_cpu(node.i.dsize) >= PAGE_CACHE_SIZE) || | 537 | |
386 | ( ((je32_to_cpu(node.i.offset)&(PAGE_CACHE_SIZE-1))==0) && | 538 | return ret; |
387 | (je32_to_cpu(node.i.dsize)+je32_to_cpu(node.i.offset) == je32_to_cpu(node.i.isize)))) { | 539 | } |
388 | D1(printk(KERN_DEBUG "Marking node at 0x%08x REF_PRISTINE\n", ref_offset(ref))); | 540 | |
389 | ref->flash_offset = ref_offset(ref) | REF_PRISTINE; | 541 | /* |
390 | } else { | 542 | * Helper function for jffs2_add_older_frag_to_fragtree(). |
391 | D1(printk(KERN_DEBUG "Marking node at 0x%08x REF_NORMAL\n", ref_offset(ref))); | 543 | * |
392 | ref->flash_offset = ref_offset(ref) | REF_NORMAL; | 544 | * Called when the new fragment that is being inserted |
393 | } | 545 | * splits a hole fragment. |
394 | spin_unlock(&c->erase_completion_lock); | 546 | */ |
547 | static int split_hole(struct jffs2_sb_info *c, struct rb_root *root, | ||
548 | struct jffs2_node_frag *newfrag, struct jffs2_node_frag *hole) | ||
549 | { | ||
550 | dbg_fragtree2("fragment %#04x-%#04x splits the hole %#04x-%#04x\n", | ||
551 | newfrag->ofs, newfrag->ofs + newfrag->size, hole->ofs, hole->ofs + hole->size); | ||
552 | |||
553 | if (hole->ofs == newfrag->ofs) { | ||
554 | /* | ||
555 | * Well, the new fragment actually starts at the same offset as | ||
556 | * the hole. | ||
557 | */ | ||
558 | if (hole->ofs + hole->size > newfrag->ofs + newfrag->size) { | ||
559 | /* | ||
560 | * We replace the overlapped left part of the hole by | ||
561 | * the new node. | ||
562 | */ | ||
563 | |||
564 | dbg_fragtree2("insert fragment %#04x-%#04x and cut the left part of the hole\n", | ||
565 | newfrag->ofs, newfrag->ofs + newfrag->size); | ||
566 | rb_replace_node(&hole->rb, &newfrag->rb, root); | ||
567 | |||
568 | hole->ofs += newfrag->size; | ||
569 | hole->size -= newfrag->size; | ||
570 | |||
571 | /* | ||
572 | * We know that 'hole' should be the right hand | ||
573 | * fragment. | ||
574 | */ | ||
575 | jffs2_fragtree_insert(hole, newfrag); | ||
576 | rb_insert_color(&hole->rb, root); | ||
577 | } else { | ||
578 | /* | ||
579 | * Ah, the new fragment is of the same size as the hole. | ||
580 | * Relace the hole by it. | ||
581 | */ | ||
582 | dbg_fragtree2("insert fragment %#04x-%#04x and overwrite hole\n", | ||
583 | newfrag->ofs, newfrag->ofs + newfrag->size); | ||
584 | rb_replace_node(&hole->rb, &newfrag->rb, root); | ||
585 | jffs2_free_node_frag(hole); | ||
586 | } | ||
587 | } else { | ||
588 | /* The new fragment lefts some hole space at the left */ | ||
589 | |||
590 | struct jffs2_node_frag * newfrag2 = NULL; | ||
591 | |||
592 | if (hole->ofs + hole->size > newfrag->ofs + newfrag->size) { | ||
593 | /* The new frag also lefts some space at the right */ | ||
594 | newfrag2 = new_fragment(NULL, newfrag->ofs + | ||
595 | newfrag->size, hole->ofs + hole->size | ||
596 | - newfrag->ofs - newfrag->size); | ||
597 | if (unlikely(!newfrag2)) { | ||
598 | jffs2_free_node_frag(newfrag); | ||
599 | return -ENOMEM; | ||
395 | } | 600 | } |
601 | } | ||
602 | |||
603 | hole->size = newfrag->ofs - hole->ofs; | ||
604 | dbg_fragtree2("left the hole %#04x-%#04x at the left and inserd fragment %#04x-%#04x\n", | ||
605 | hole->ofs, hole->ofs + hole->size, newfrag->ofs, newfrag->ofs + newfrag->size); | ||
606 | |||
607 | jffs2_fragtree_insert(newfrag, hole); | ||
608 | rb_insert_color(&newfrag->rb, root); | ||
609 | |||
610 | if (newfrag2) { | ||
611 | dbg_fragtree2("left the hole %#04x-%#04x at the right\n", | ||
612 | newfrag2->ofs, newfrag2->ofs + newfrag2->size); | ||
613 | jffs2_fragtree_insert(newfrag2, newfrag); | ||
614 | rb_insert_color(&newfrag2->rb, root); | ||
615 | } | ||
616 | } | ||
617 | |||
618 | return 0; | ||
619 | } | ||
620 | |||
621 | /* | ||
622 | * This function is used when we build inode. It expects the nodes are passed | ||
623 | * in the decreasing version order. The whole point of this is to improve the | ||
624 | * inodes checking on NAND: we check the nodes' data CRC only when they are not | ||
625 | * obsoleted. Previously, add_frag_to_fragtree() function was used and | ||
626 | * nodes were passed to it in the increasing version ordes and CRCs of all | ||
627 | * nodes were checked. | ||
628 | * | ||
629 | * Note: tn->fn->size shouldn't be zero. | ||
630 | * | ||
631 | * Returns 0 if the node was inserted | ||
632 | * 1 if it wasn't inserted (since it is obsolete) | ||
633 | * < 0 an if error occured | ||
634 | */ | ||
635 | int jffs2_add_older_frag_to_fragtree(struct jffs2_sb_info *c, struct jffs2_inode_info *f, | ||
636 | struct jffs2_tmp_dnode_info *tn) | ||
637 | { | ||
638 | struct jffs2_node_frag *this, *newfrag; | ||
639 | uint32_t lastend; | ||
640 | struct jffs2_full_dnode *fn = tn->fn; | ||
641 | struct rb_root *root = &f->fragtree; | ||
642 | uint32_t fn_size = fn->size, fn_ofs = fn->ofs; | ||
643 | int err, checked = 0; | ||
644 | int ref_flag; | ||
645 | |||
646 | dbg_fragtree("insert fragment %#04x-%#04x, ver %u\n", fn_ofs, fn_ofs + fn_size, tn->version); | ||
647 | |||
648 | /* Skip all the nodes which are completed before this one starts */ | ||
649 | this = jffs2_lookup_node_frag(root, fn_ofs); | ||
650 | if (this) | ||
651 | dbg_fragtree2("'this' found %#04x-%#04x (%s)\n", this->ofs, this->ofs + this->size, this->node ? "data" : "hole"); | ||
652 | |||
653 | if (this) | ||
654 | lastend = this->ofs + this->size; | ||
655 | else | ||
656 | lastend = 0; | ||
657 | |||
658 | /* Detect the preliminary type of node */ | ||
659 | if (fn->size >= PAGE_CACHE_SIZE) | ||
660 | ref_flag = REF_PRISTINE; | ||
661 | else | ||
662 | ref_flag = REF_NORMAL; | ||
663 | |||
664 | /* See if we ran off the end of the root */ | ||
665 | if (lastend <= fn_ofs) { | ||
666 | /* We did */ | ||
667 | |||
668 | /* | ||
669 | * We are going to insert the new node into the | ||
670 | * fragment tree, so check it. | ||
671 | */ | ||
672 | err = check_node(c, f, tn); | ||
673 | if (err != 0) | ||
674 | return err; | ||
675 | |||
676 | fn->frags = 1; | ||
677 | |||
678 | newfrag = new_fragment(fn, fn_ofs, fn_size); | ||
679 | if (unlikely(!newfrag)) | ||
680 | return -ENOMEM; | ||
681 | |||
682 | err = no_overlapping_node(c, root, newfrag, this, lastend); | ||
683 | if (unlikely(err != 0)) { | ||
684 | jffs2_free_node_frag(newfrag); | ||
685 | return err; | ||
686 | } | ||
687 | |||
688 | goto out_ok; | ||
689 | } | ||
396 | 690 | ||
397 | tn = jffs2_alloc_tmp_dnode_info(); | 691 | fn->frags = 0; |
398 | if (!tn) { | 692 | |
399 | D1(printk(KERN_DEBUG "alloc tn failed\n")); | 693 | while (1) { |
400 | err = -ENOMEM; | 694 | /* |
401 | goto free_out; | 695 | * Here we have: |
696 | * fn_ofs < this->ofs + this->size && fn_ofs >= this->ofs. | ||
697 | * | ||
698 | * Remember, 'this' has higher version, any non-hole node | ||
699 | * which is already in the fragtree is newer then the newly | ||
700 | * inserted. | ||
701 | */ | ||
702 | if (!this->node) { | ||
703 | /* | ||
704 | * 'this' is the hole fragment, so at least the | ||
705 | * beginning of the new fragment is valid. | ||
706 | */ | ||
707 | |||
708 | /* | ||
709 | * We are going to insert the new node into the | ||
710 | * fragment tree, so check it. | ||
711 | */ | ||
712 | if (!checked) { | ||
713 | err = check_node(c, f, tn); | ||
714 | if (unlikely(err != 0)) | ||
715 | return err; | ||
716 | checked = 1; | ||
402 | } | 717 | } |
403 | 718 | ||
404 | tn->fn = jffs2_alloc_full_dnode(); | 719 | if (this->ofs + this->size >= fn_ofs + fn_size) { |
405 | if (!tn->fn) { | 720 | /* We split the hole on two parts */ |
406 | D1(printk(KERN_DEBUG "alloc fn failed\n")); | 721 | |
407 | err = -ENOMEM; | 722 | fn->frags += 1; |
408 | jffs2_free_tmp_dnode_info(tn); | 723 | newfrag = new_fragment(fn, fn_ofs, fn_size); |
409 | goto free_out; | 724 | if (unlikely(!newfrag)) |
725 | return -ENOMEM; | ||
726 | |||
727 | err = split_hole(c, root, newfrag, this); | ||
728 | if (unlikely(err)) | ||
729 | return err; | ||
730 | goto out_ok; | ||
410 | } | 731 | } |
411 | tn->version = je32_to_cpu(node.i.version); | 732 | |
412 | tn->fn->ofs = je32_to_cpu(node.i.offset); | 733 | /* |
413 | /* There was a bug where we wrote hole nodes out with | 734 | * The beginning of the new fragment is valid since it |
414 | csize/dsize swapped. Deal with it */ | 735 | * overlaps the hole node. |
415 | if (node.i.compr == JFFS2_COMPR_ZERO && !je32_to_cpu(node.i.dsize) && je32_to_cpu(node.i.csize)) | 736 | */ |
416 | tn->fn->size = je32_to_cpu(node.i.csize); | 737 | |
417 | else // normal case... | 738 | ref_flag = REF_NORMAL; |
418 | tn->fn->size = je32_to_cpu(node.i.dsize); | 739 | |
419 | tn->fn->raw = ref; | 740 | fn->frags += 1; |
420 | D1(printk(KERN_DEBUG "dnode @%08x: ver %u, offset %04x, dsize %04x\n", | 741 | newfrag = new_fragment(fn, fn_ofs, |
421 | ref_offset(ref), je32_to_cpu(node.i.version), | 742 | this->ofs + this->size - fn_ofs); |
422 | je32_to_cpu(node.i.offset), je32_to_cpu(node.i.dsize))); | 743 | if (unlikely(!newfrag)) |
423 | jffs2_add_tn_to_tree(tn, &ret_tn); | 744 | return -ENOMEM; |
424 | break; | 745 | |
425 | 746 | if (fn_ofs == this->ofs) { | |
426 | default: | 747 | /* |
427 | if (ref_flags(ref) == REF_UNCHECKED) { | 748 | * The new node starts at the same offset as |
428 | struct jffs2_eraseblock *jeb; | 749 | * the hole and supersieds the hole. |
429 | uint32_t len; | 750 | */ |
430 | 751 | dbg_fragtree2("add the new fragment instead of hole %#04x-%#04x, refcnt %d\n", | |
431 | printk(KERN_ERR "Eep. Unknown node type %04x at %08x was marked REF_UNCHECKED\n", | 752 | fn_ofs, fn_ofs + this->ofs + this->size - fn_ofs, fn->frags); |
432 | je16_to_cpu(node.u.nodetype), ref_offset(ref)); | 753 | |
433 | 754 | rb_replace_node(&this->rb, &newfrag->rb, root); | |
434 | /* Mark the node as having been checked and fix the accounting accordingly */ | 755 | jffs2_free_node_frag(this); |
435 | spin_lock(&c->erase_completion_lock); | 756 | } else { |
436 | jeb = &c->blocks[ref->flash_offset / c->sector_size]; | 757 | /* |
437 | len = ref_totlen(c, jeb, ref); | 758 | * The hole becomes shorter as its right part |
438 | 759 | * is supersieded by the new fragment. | |
439 | jeb->used_size += len; | 760 | */ |
440 | jeb->unchecked_size -= len; | 761 | dbg_fragtree2("reduce size of hole %#04x-%#04x to %#04x-%#04x\n", |
441 | c->used_size += len; | 762 | this->ofs, this->ofs + this->size, this->ofs, this->ofs + this->size - newfrag->size); |
442 | c->unchecked_size -= len; | 763 | |
443 | 764 | dbg_fragtree2("add new fragment %#04x-%#04x, refcnt %d\n", fn_ofs, | |
444 | mark_ref_normal(ref); | 765 | fn_ofs + this->ofs + this->size - fn_ofs, fn->frags); |
445 | spin_unlock(&c->erase_completion_lock); | 766 | |
767 | this->size -= newfrag->size; | ||
768 | jffs2_fragtree_insert(newfrag, this); | ||
769 | rb_insert_color(&newfrag->rb, root); | ||
446 | } | 770 | } |
447 | node.u.nodetype = cpu_to_je16(JFFS2_NODE_ACCURATE | je16_to_cpu(node.u.nodetype)); | 771 | |
448 | if (crc32(0, &node, sizeof(struct jffs2_unknown_node)-4) != je32_to_cpu(node.u.hdr_crc)) { | 772 | fn_ofs += newfrag->size; |
449 | /* Hmmm. This should have been caught at scan time. */ | 773 | fn_size -= newfrag->size; |
450 | printk(KERN_ERR "Node header CRC failed at %08x. But it must have been OK earlier.\n", | 774 | this = rb_entry(rb_next(&newfrag->rb), |
451 | ref_offset(ref)); | 775 | struct jffs2_node_frag, rb); |
452 | printk(KERN_ERR "Node was: { %04x, %04x, %08x, %08x }\n", | 776 | |
453 | je16_to_cpu(node.u.magic), je16_to_cpu(node.u.nodetype), je32_to_cpu(node.u.totlen), | 777 | dbg_fragtree2("switch to the next 'this' fragment: %#04x-%#04x %s\n", |
454 | je32_to_cpu(node.u.hdr_crc)); | 778 | this->ofs, this->ofs + this->size, this->node ? "(data)" : "(hole)"); |
455 | jffs2_mark_node_obsolete(c, ref); | 779 | } |
456 | } else switch(je16_to_cpu(node.u.nodetype) & JFFS2_COMPAT_MASK) { | 780 | |
457 | case JFFS2_FEATURE_INCOMPAT: | 781 | /* |
458 | printk(KERN_NOTICE "Unknown INCOMPAT nodetype %04X at %08x\n", je16_to_cpu(node.u.nodetype), ref_offset(ref)); | 782 | * 'This' node is not the hole so it obsoletes the new fragment |
459 | /* EEP */ | 783 | * either fully or partially. |
460 | BUG(); | 784 | */ |
461 | break; | 785 | if (this->ofs + this->size >= fn_ofs + fn_size) { |
462 | case JFFS2_FEATURE_ROCOMPAT: | 786 | /* The new node is obsolete, drop it */ |
463 | printk(KERN_NOTICE "Unknown ROCOMPAT nodetype %04X at %08x\n", je16_to_cpu(node.u.nodetype), ref_offset(ref)); | 787 | if (fn->frags == 0) { |
464 | if (!(c->flags & JFFS2_SB_FLAG_RO)) | 788 | dbg_fragtree2("%#04x-%#04x is obsolete, mark it obsolete\n", fn_ofs, fn_ofs + fn_size); |
465 | BUG(); | 789 | ref_flag = REF_OBSOLETE; |
466 | break; | ||
467 | case JFFS2_FEATURE_RWCOMPAT_COPY: | ||
468 | printk(KERN_NOTICE "Unknown RWCOMPAT_COPY nodetype %04X at %08x\n", je16_to_cpu(node.u.nodetype), ref_offset(ref)); | ||
469 | break; | ||
470 | case JFFS2_FEATURE_RWCOMPAT_DELETE: | ||
471 | printk(KERN_NOTICE "Unknown RWCOMPAT_DELETE nodetype %04X at %08x\n", je16_to_cpu(node.u.nodetype), ref_offset(ref)); | ||
472 | jffs2_mark_node_obsolete(c, ref); | ||
473 | break; | ||
474 | } | 790 | } |
791 | goto out_ok; | ||
792 | } else { | ||
793 | struct jffs2_node_frag *new_this; | ||
794 | |||
795 | /* 'This' node obsoletes the beginning of the new node */ | ||
796 | dbg_fragtree2("the beginning %#04x-%#04x is obsolete\n", fn_ofs, this->ofs + this->size); | ||
797 | |||
798 | ref_flag = REF_NORMAL; | ||
799 | |||
800 | fn_size -= this->ofs + this->size - fn_ofs; | ||
801 | fn_ofs = this->ofs + this->size; | ||
802 | dbg_fragtree2("now considering %#04x-%#04x\n", fn_ofs, fn_ofs + fn_size); | ||
803 | |||
804 | new_this = rb_entry(rb_next(&this->rb), struct jffs2_node_frag, rb); | ||
805 | if (!new_this) { | ||
806 | /* | ||
807 | * There is no next fragment. Add the rest of | ||
808 | * the new node as the right-hand child. | ||
809 | */ | ||
810 | if (!checked) { | ||
811 | err = check_node(c, f, tn); | ||
812 | if (unlikely(err != 0)) | ||
813 | return err; | ||
814 | checked = 1; | ||
815 | } | ||
475 | 816 | ||
817 | fn->frags += 1; | ||
818 | newfrag = new_fragment(fn, fn_ofs, fn_size); | ||
819 | if (unlikely(!newfrag)) | ||
820 | return -ENOMEM; | ||
821 | |||
822 | dbg_fragtree2("there are no more fragments, insert %#04x-%#04x\n", | ||
823 | newfrag->ofs, newfrag->ofs + newfrag->size); | ||
824 | rb_link_node(&newfrag->rb, &this->rb, &this->rb.rb_right); | ||
825 | rb_insert_color(&newfrag->rb, root); | ||
826 | goto out_ok; | ||
827 | } else { | ||
828 | this = new_this; | ||
829 | dbg_fragtree2("switch to the next 'this' fragment: %#04x-%#04x %s\n", | ||
830 | this->ofs, this->ofs + this->size, this->node ? "(data)" : "(hole)"); | ||
831 | } | ||
476 | } | 832 | } |
477 | spin_lock(&c->erase_completion_lock); | 833 | } |
834 | |||
835 | out_ok: | ||
836 | BUG_ON(fn->size < PAGE_CACHE_SIZE && ref_flag == REF_PRISTINE); | ||
478 | 837 | ||
838 | if (ref_flag == REF_OBSOLETE) { | ||
839 | dbg_fragtree2("the node is obsolete now\n"); | ||
840 | /* jffs2_mark_node_obsolete() will adjust space accounting */ | ||
841 | jffs2_mark_node_obsolete(c, fn->raw); | ||
842 | return 1; | ||
479 | } | 843 | } |
844 | |||
845 | dbg_fragtree2("the node is \"%s\" now\n", ref_flag == REF_NORMAL ? "REF_NORMAL" : "REF_PRISTINE"); | ||
846 | |||
847 | /* Space accounting was adjusted at check_node_data() */ | ||
848 | spin_lock(&c->erase_completion_lock); | ||
849 | fn->raw->flash_offset = ref_offset(fn->raw) | ref_flag; | ||
480 | spin_unlock(&c->erase_completion_lock); | 850 | spin_unlock(&c->erase_completion_lock); |
481 | *tnp = ret_tn; | ||
482 | *fdp = ret_fd; | ||
483 | 851 | ||
484 | return 0; | 852 | return 0; |
485 | |||
486 | free_out: | ||
487 | jffs2_free_tmp_dnode_info_list(&ret_tn); | ||
488 | jffs2_free_full_dirent_list(ret_fd); | ||
489 | return err; | ||
490 | } | 853 | } |
491 | 854 | ||
492 | void jffs2_set_inocache_state(struct jffs2_sb_info *c, struct jffs2_inode_cache *ic, int state) | 855 | void jffs2_set_inocache_state(struct jffs2_sb_info *c, struct jffs2_inode_cache *ic, int state) |
@@ -499,24 +862,21 @@ void jffs2_set_inocache_state(struct jffs2_sb_info *c, struct jffs2_inode_cache | |||
499 | 862 | ||
500 | /* During mount, this needs no locking. During normal operation, its | 863 | /* During mount, this needs no locking. During normal operation, its |
501 | callers want to do other stuff while still holding the inocache_lock. | 864 | callers want to do other stuff while still holding the inocache_lock. |
502 | Rather than introducing special case get_ino_cache functions or | 865 | Rather than introducing special case get_ino_cache functions or |
503 | callbacks, we just let the caller do the locking itself. */ | 866 | callbacks, we just let the caller do the locking itself. */ |
504 | 867 | ||
505 | struct jffs2_inode_cache *jffs2_get_ino_cache(struct jffs2_sb_info *c, uint32_t ino) | 868 | struct jffs2_inode_cache *jffs2_get_ino_cache(struct jffs2_sb_info *c, uint32_t ino) |
506 | { | 869 | { |
507 | struct jffs2_inode_cache *ret; | 870 | struct jffs2_inode_cache *ret; |
508 | 871 | ||
509 | D2(printk(KERN_DEBUG "jffs2_get_ino_cache(): ino %u\n", ino)); | ||
510 | |||
511 | ret = c->inocache_list[ino % INOCACHE_HASHSIZE]; | 872 | ret = c->inocache_list[ino % INOCACHE_HASHSIZE]; |
512 | while (ret && ret->ino < ino) { | 873 | while (ret && ret->ino < ino) { |
513 | ret = ret->next; | 874 | ret = ret->next; |
514 | } | 875 | } |
515 | 876 | ||
516 | if (ret && ret->ino != ino) | 877 | if (ret && ret->ino != ino) |
517 | ret = NULL; | 878 | ret = NULL; |
518 | 879 | ||
519 | D2(printk(KERN_DEBUG "jffs2_get_ino_cache found %p for ino %u\n", ret, ino)); | ||
520 | return ret; | 880 | return ret; |
521 | } | 881 | } |
522 | 882 | ||
@@ -528,7 +888,7 @@ void jffs2_add_ino_cache (struct jffs2_sb_info *c, struct jffs2_inode_cache *new | |||
528 | if (!new->ino) | 888 | if (!new->ino) |
529 | new->ino = ++c->highest_ino; | 889 | new->ino = ++c->highest_ino; |
530 | 890 | ||
531 | D2(printk(KERN_DEBUG "jffs2_add_ino_cache: Add %p (ino #%u)\n", new, new->ino)); | 891 | dbg_inocache("add %p (ino #%u)\n", new, new->ino); |
532 | 892 | ||
533 | prev = &c->inocache_list[new->ino % INOCACHE_HASHSIZE]; | 893 | prev = &c->inocache_list[new->ino % INOCACHE_HASHSIZE]; |
534 | 894 | ||
@@ -544,11 +904,12 @@ void jffs2_add_ino_cache (struct jffs2_sb_info *c, struct jffs2_inode_cache *new | |||
544 | void jffs2_del_ino_cache(struct jffs2_sb_info *c, struct jffs2_inode_cache *old) | 904 | void jffs2_del_ino_cache(struct jffs2_sb_info *c, struct jffs2_inode_cache *old) |
545 | { | 905 | { |
546 | struct jffs2_inode_cache **prev; | 906 | struct jffs2_inode_cache **prev; |
547 | D1(printk(KERN_DEBUG "jffs2_del_ino_cache: Del %p (ino #%u)\n", old, old->ino)); | 907 | |
908 | dbg_inocache("del %p (ino #%u)\n", old, old->ino); | ||
548 | spin_lock(&c->inocache_lock); | 909 | spin_lock(&c->inocache_lock); |
549 | 910 | ||
550 | prev = &c->inocache_list[old->ino % INOCACHE_HASHSIZE]; | 911 | prev = &c->inocache_list[old->ino % INOCACHE_HASHSIZE]; |
551 | 912 | ||
552 | while ((*prev) && (*prev)->ino < old->ino) { | 913 | while ((*prev) && (*prev)->ino < old->ino) { |
553 | prev = &(*prev)->next; | 914 | prev = &(*prev)->next; |
554 | } | 915 | } |
@@ -558,7 +919,7 @@ void jffs2_del_ino_cache(struct jffs2_sb_info *c, struct jffs2_inode_cache *old) | |||
558 | 919 | ||
559 | /* Free it now unless it's in READING or CLEARING state, which | 920 | /* Free it now unless it's in READING or CLEARING state, which |
560 | are the transitions upon read_inode() and clear_inode(). The | 921 | are the transitions upon read_inode() and clear_inode(). The |
561 | rest of the time we know nobody else is looking at it, and | 922 | rest of the time we know nobody else is looking at it, and |
562 | if it's held by read_inode() or clear_inode() they'll free it | 923 | if it's held by read_inode() or clear_inode() they'll free it |
563 | for themselves. */ | 924 | for themselves. */ |
564 | if (old->state != INO_STATE_READING && old->state != INO_STATE_CLEARING) | 925 | if (old->state != INO_STATE_READING && old->state != INO_STATE_CLEARING) |
@@ -571,7 +932,7 @@ void jffs2_free_ino_caches(struct jffs2_sb_info *c) | |||
571 | { | 932 | { |
572 | int i; | 933 | int i; |
573 | struct jffs2_inode_cache *this, *next; | 934 | struct jffs2_inode_cache *this, *next; |
574 | 935 | ||
575 | for (i=0; i<INOCACHE_HASHSIZE; i++) { | 936 | for (i=0; i<INOCACHE_HASHSIZE; i++) { |
576 | this = c->inocache_list[i]; | 937 | this = c->inocache_list[i]; |
577 | while (this) { | 938 | while (this) { |
@@ -598,38 +959,30 @@ void jffs2_free_raw_node_refs(struct jffs2_sb_info *c) | |||
598 | c->blocks[i].first_node = c->blocks[i].last_node = NULL; | 959 | c->blocks[i].first_node = c->blocks[i].last_node = NULL; |
599 | } | 960 | } |
600 | } | 961 | } |
601 | 962 | ||
602 | struct jffs2_node_frag *jffs2_lookup_node_frag(struct rb_root *fragtree, uint32_t offset) | 963 | struct jffs2_node_frag *jffs2_lookup_node_frag(struct rb_root *fragtree, uint32_t offset) |
603 | { | 964 | { |
604 | /* The common case in lookup is that there will be a node | 965 | /* The common case in lookup is that there will be a node |
605 | which precisely matches. So we go looking for that first */ | 966 | which precisely matches. So we go looking for that first */ |
606 | struct rb_node *next; | 967 | struct rb_node *next; |
607 | struct jffs2_node_frag *prev = NULL; | 968 | struct jffs2_node_frag *prev = NULL; |
608 | struct jffs2_node_frag *frag = NULL; | 969 | struct jffs2_node_frag *frag = NULL; |
609 | 970 | ||
610 | D2(printk(KERN_DEBUG "jffs2_lookup_node_frag(%p, %d)\n", fragtree, offset)); | 971 | dbg_fragtree2("root %p, offset %d\n", fragtree, offset); |
611 | 972 | ||
612 | next = fragtree->rb_node; | 973 | next = fragtree->rb_node; |
613 | 974 | ||
614 | while(next) { | 975 | while(next) { |
615 | frag = rb_entry(next, struct jffs2_node_frag, rb); | 976 | frag = rb_entry(next, struct jffs2_node_frag, rb); |
616 | 977 | ||
617 | D2(printk(KERN_DEBUG "Considering frag %d-%d (%p). left %p, right %p\n", | ||
618 | frag->ofs, frag->ofs+frag->size, frag, frag->rb.rb_left, frag->rb.rb_right)); | ||
619 | if (frag->ofs + frag->size <= offset) { | 978 | if (frag->ofs + frag->size <= offset) { |
620 | D2(printk(KERN_DEBUG "Going right from frag %d-%d, before the region we care about\n", | ||
621 | frag->ofs, frag->ofs+frag->size)); | ||
622 | /* Remember the closest smaller match on the way down */ | 979 | /* Remember the closest smaller match on the way down */ |
623 | if (!prev || frag->ofs > prev->ofs) | 980 | if (!prev || frag->ofs > prev->ofs) |
624 | prev = frag; | 981 | prev = frag; |
625 | next = frag->rb.rb_right; | 982 | next = frag->rb.rb_right; |
626 | } else if (frag->ofs > offset) { | 983 | } else if (frag->ofs > offset) { |
627 | D2(printk(KERN_DEBUG "Going left from frag %d-%d, after the region we care about\n", | ||
628 | frag->ofs, frag->ofs+frag->size)); | ||
629 | next = frag->rb.rb_left; | 984 | next = frag->rb.rb_left; |
630 | } else { | 985 | } else { |
631 | D2(printk(KERN_DEBUG "Returning frag %d,%d, matched\n", | ||
632 | frag->ofs, frag->ofs+frag->size)); | ||
633 | return frag; | 986 | return frag; |
634 | } | 987 | } |
635 | } | 988 | } |
@@ -638,11 +991,11 @@ struct jffs2_node_frag *jffs2_lookup_node_frag(struct rb_root *fragtree, uint32_ | |||
638 | and return the closest smaller one */ | 991 | and return the closest smaller one */ |
639 | 992 | ||
640 | if (prev) | 993 | if (prev) |
641 | D2(printk(KERN_DEBUG "No match. Returning frag %d,%d, closest previous\n", | 994 | dbg_fragtree2("no match. Returning frag %#04x-%#04x, closest previous\n", |
642 | prev->ofs, prev->ofs+prev->size)); | 995 | prev->ofs, prev->ofs+prev->size); |
643 | else | 996 | else |
644 | D2(printk(KERN_DEBUG "Returning NULL, empty fragtree\n")); | 997 | dbg_fragtree2("returning NULL, empty fragtree\n"); |
645 | 998 | ||
646 | return prev; | 999 | return prev; |
647 | } | 1000 | } |
648 | 1001 | ||
@@ -656,39 +1009,32 @@ void jffs2_kill_fragtree(struct rb_root *root, struct jffs2_sb_info *c) | |||
656 | if (!root->rb_node) | 1009 | if (!root->rb_node) |
657 | return; | 1010 | return; |
658 | 1011 | ||
659 | frag = (rb_entry(root->rb_node, struct jffs2_node_frag, rb)); | 1012 | dbg_fragtree("killing\n"); |
660 | 1013 | ||
1014 | frag = (rb_entry(root->rb_node, struct jffs2_node_frag, rb)); | ||
661 | while(frag) { | 1015 | while(frag) { |
662 | if (frag->rb.rb_left) { | 1016 | if (frag->rb.rb_left) { |
663 | D2(printk(KERN_DEBUG "Going left from frag (%p) %d-%d\n", | ||
664 | frag, frag->ofs, frag->ofs+frag->size)); | ||
665 | frag = frag_left(frag); | 1017 | frag = frag_left(frag); |
666 | continue; | 1018 | continue; |
667 | } | 1019 | } |
668 | if (frag->rb.rb_right) { | 1020 | if (frag->rb.rb_right) { |
669 | D2(printk(KERN_DEBUG "Going right from frag (%p) %d-%d\n", | ||
670 | frag, frag->ofs, frag->ofs+frag->size)); | ||
671 | frag = frag_right(frag); | 1021 | frag = frag_right(frag); |
672 | continue; | 1022 | continue; |
673 | } | 1023 | } |
674 | 1024 | ||
675 | D2(printk(KERN_DEBUG "jffs2_kill_fragtree: frag at 0x%x-0x%x: node %p, frags %d--\n", | ||
676 | frag->ofs, frag->ofs+frag->size, frag->node, | ||
677 | frag->node?frag->node->frags:0)); | ||
678 | |||
679 | if (frag->node && !(--frag->node->frags)) { | 1025 | if (frag->node && !(--frag->node->frags)) { |
680 | /* Not a hole, and it's the final remaining frag | 1026 | /* Not a hole, and it's the final remaining frag |
681 | of this node. Free the node */ | 1027 | of this node. Free the node */ |
682 | if (c) | 1028 | if (c) |
683 | jffs2_mark_node_obsolete(c, frag->node->raw); | 1029 | jffs2_mark_node_obsolete(c, frag->node->raw); |
684 | 1030 | ||
685 | jffs2_free_full_dnode(frag->node); | 1031 | jffs2_free_full_dnode(frag->node); |
686 | } | 1032 | } |
687 | parent = frag_parent(frag); | 1033 | parent = frag_parent(frag); |
688 | if (parent) { | 1034 | if (parent) { |
689 | if (frag_left(parent) == frag) | 1035 | if (frag_left(parent) == frag) |
690 | parent->rb.rb_left = NULL; | 1036 | parent->rb.rb_left = NULL; |
691 | else | 1037 | else |
692 | parent->rb.rb_right = NULL; | 1038 | parent->rb.rb_right = NULL; |
693 | } | 1039 | } |
694 | 1040 | ||
@@ -698,29 +1044,3 @@ void jffs2_kill_fragtree(struct rb_root *root, struct jffs2_sb_info *c) | |||
698 | cond_resched(); | 1044 | cond_resched(); |
699 | } | 1045 | } |
700 | } | 1046 | } |
701 | |||
702 | void jffs2_fragtree_insert(struct jffs2_node_frag *newfrag, struct jffs2_node_frag *base) | ||
703 | { | ||
704 | struct rb_node *parent = &base->rb; | ||
705 | struct rb_node **link = &parent; | ||
706 | |||
707 | D2(printk(KERN_DEBUG "jffs2_fragtree_insert(%p; %d-%d, %p)\n", newfrag, | ||
708 | newfrag->ofs, newfrag->ofs+newfrag->size, base)); | ||
709 | |||
710 | while (*link) { | ||
711 | parent = *link; | ||
712 | base = rb_entry(parent, struct jffs2_node_frag, rb); | ||
713 | |||
714 | D2(printk(KERN_DEBUG "fragtree_insert considering frag at 0x%x\n", base->ofs)); | ||
715 | if (newfrag->ofs > base->ofs) | ||
716 | link = &base->rb.rb_right; | ||
717 | else if (newfrag->ofs < base->ofs) | ||
718 | link = &base->rb.rb_left; | ||
719 | else { | ||
720 | printk(KERN_CRIT "Duplicate frag at %08x (%p,%p)\n", newfrag->ofs, newfrag, base); | ||
721 | BUG(); | ||
722 | } | ||
723 | } | ||
724 | |||
725 | rb_link_node(&newfrag->rb, &base->rb, link); | ||
726 | } | ||
diff --git a/fs/jffs2/nodelist.h b/fs/jffs2/nodelist.h index b34c397909ef..23a67bb3052f 100644 --- a/fs/jffs2/nodelist.h +++ b/fs/jffs2/nodelist.h | |||
@@ -7,7 +7,7 @@ | |||
7 | * | 7 | * |
8 | * For licensing information, see the file 'LICENCE' in this directory. | 8 | * For licensing information, see the file 'LICENCE' in this directory. |
9 | * | 9 | * |
10 | * $Id: nodelist.h,v 1.131 2005/07/05 21:03:07 dwmw2 Exp $ | 10 | * $Id: nodelist.h,v 1.140 2005/09/07 08:34:54 havasi Exp $ |
11 | * | 11 | * |
12 | */ | 12 | */ |
13 | 13 | ||
@@ -20,30 +20,15 @@ | |||
20 | #include <linux/jffs2.h> | 20 | #include <linux/jffs2.h> |
21 | #include <linux/jffs2_fs_sb.h> | 21 | #include <linux/jffs2_fs_sb.h> |
22 | #include <linux/jffs2_fs_i.h> | 22 | #include <linux/jffs2_fs_i.h> |
23 | #include "summary.h" | ||
23 | 24 | ||
24 | #ifdef __ECOS | 25 | #ifdef __ECOS |
25 | #include "os-ecos.h" | 26 | #include "os-ecos.h" |
26 | #else | 27 | #else |
27 | #include <linux/mtd/compatmac.h> /* For min/max in older kernels */ | 28 | #include <linux/mtd/compatmac.h> /* For compatibility with older kernels */ |
28 | #include "os-linux.h" | 29 | #include "os-linux.h" |
29 | #endif | 30 | #endif |
30 | 31 | ||
31 | #ifndef CONFIG_JFFS2_FS_DEBUG | ||
32 | #define CONFIG_JFFS2_FS_DEBUG 1 | ||
33 | #endif | ||
34 | |||
35 | #if CONFIG_JFFS2_FS_DEBUG > 0 | ||
36 | #define D1(x) x | ||
37 | #else | ||
38 | #define D1(x) | ||
39 | #endif | ||
40 | |||
41 | #if CONFIG_JFFS2_FS_DEBUG > 1 | ||
42 | #define D2(x) x | ||
43 | #else | ||
44 | #define D2(x) | ||
45 | #endif | ||
46 | |||
47 | #define JFFS2_NATIVE_ENDIAN | 32 | #define JFFS2_NATIVE_ENDIAN |
48 | 33 | ||
49 | /* Note we handle mode bits conversion from JFFS2 (i.e. Linux) to/from | 34 | /* Note we handle mode bits conversion from JFFS2 (i.e. Linux) to/from |
@@ -73,14 +58,17 @@ | |||
73 | #define je16_to_cpu(x) (le16_to_cpu(x.v16)) | 58 | #define je16_to_cpu(x) (le16_to_cpu(x.v16)) |
74 | #define je32_to_cpu(x) (le32_to_cpu(x.v32)) | 59 | #define je32_to_cpu(x) (le32_to_cpu(x.v32)) |
75 | #define jemode_to_cpu(x) (le32_to_cpu(jffs2_to_os_mode((x).m))) | 60 | #define jemode_to_cpu(x) (le32_to_cpu(jffs2_to_os_mode((x).m))) |
76 | #else | 61 | #else |
77 | #error wibble | 62 | #error wibble |
78 | #endif | 63 | #endif |
79 | 64 | ||
65 | /* The minimal node header size */ | ||
66 | #define JFFS2_MIN_NODE_HEADER sizeof(struct jffs2_raw_dirent) | ||
67 | |||
80 | /* | 68 | /* |
81 | This is all we need to keep in-core for each raw node during normal | 69 | This is all we need to keep in-core for each raw node during normal |
82 | operation. As and when we do read_inode on a particular inode, we can | 70 | operation. As and when we do read_inode on a particular inode, we can |
83 | scan the nodes which are listed for it and build up a proper map of | 71 | scan the nodes which are listed for it and build up a proper map of |
84 | which nodes are currently valid. JFFSv1 always used to keep that whole | 72 | which nodes are currently valid. JFFSv1 always used to keep that whole |
85 | map in core for each inode. | 73 | map in core for each inode. |
86 | */ | 74 | */ |
@@ -97,7 +85,7 @@ struct jffs2_raw_node_ref | |||
97 | 85 | ||
98 | /* flash_offset & 3 always has to be zero, because nodes are | 86 | /* flash_offset & 3 always has to be zero, because nodes are |
99 | always aligned at 4 bytes. So we have a couple of extra bits | 87 | always aligned at 4 bytes. So we have a couple of extra bits |
100 | to play with, which indicate the node's status; see below: */ | 88 | to play with, which indicate the node's status; see below: */ |
101 | #define REF_UNCHECKED 0 /* We haven't yet checked the CRC or built its inode */ | 89 | #define REF_UNCHECKED 0 /* We haven't yet checked the CRC or built its inode */ |
102 | #define REF_OBSOLETE 1 /* Obsolete, can be completely ignored */ | 90 | #define REF_OBSOLETE 1 /* Obsolete, can be completely ignored */ |
103 | #define REF_PRISTINE 2 /* Completely clean. GC without looking */ | 91 | #define REF_PRISTINE 2 /* Completely clean. GC without looking */ |
@@ -110,7 +98,7 @@ struct jffs2_raw_node_ref | |||
110 | /* For each inode in the filesystem, we need to keep a record of | 98 | /* For each inode in the filesystem, we need to keep a record of |
111 | nlink, because it would be a PITA to scan the whole directory tree | 99 | nlink, because it would be a PITA to scan the whole directory tree |
112 | at read_inode() time to calculate it, and to keep sufficient information | 100 | at read_inode() time to calculate it, and to keep sufficient information |
113 | in the raw_node_ref (basically both parent and child inode number for | 101 | in the raw_node_ref (basically both parent and child inode number for |
114 | dirent nodes) would take more space than this does. We also keep | 102 | dirent nodes) would take more space than this does. We also keep |
115 | a pointer to the first physical node which is part of this inode, too. | 103 | a pointer to the first physical node which is part of this inode, too. |
116 | */ | 104 | */ |
@@ -140,7 +128,7 @@ struct jffs2_inode_cache { | |||
140 | #define INOCACHE_HASHSIZE 128 | 128 | #define INOCACHE_HASHSIZE 128 |
141 | 129 | ||
142 | /* | 130 | /* |
143 | Larger representation of a raw node, kept in-core only when the | 131 | Larger representation of a raw node, kept in-core only when the |
144 | struct inode for this particular ino is instantiated. | 132 | struct inode for this particular ino is instantiated. |
145 | */ | 133 | */ |
146 | 134 | ||
@@ -150,11 +138,11 @@ struct jffs2_full_dnode | |||
150 | uint32_t ofs; /* The offset to which the data of this node belongs */ | 138 | uint32_t ofs; /* The offset to which the data of this node belongs */ |
151 | uint32_t size; | 139 | uint32_t size; |
152 | uint32_t frags; /* Number of fragments which currently refer | 140 | uint32_t frags; /* Number of fragments which currently refer |
153 | to this node. When this reaches zero, | 141 | to this node. When this reaches zero, |
154 | the node is obsolete. */ | 142 | the node is obsolete. */ |
155 | }; | 143 | }; |
156 | 144 | ||
157 | /* | 145 | /* |
158 | Even larger representation of a raw node, kept in-core only while | 146 | Even larger representation of a raw node, kept in-core only while |
159 | we're actually building up the original map of which nodes go where, | 147 | we're actually building up the original map of which nodes go where, |
160 | in read_inode() | 148 | in read_inode() |
@@ -164,7 +152,10 @@ struct jffs2_tmp_dnode_info | |||
164 | struct rb_node rb; | 152 | struct rb_node rb; |
165 | struct jffs2_full_dnode *fn; | 153 | struct jffs2_full_dnode *fn; |
166 | uint32_t version; | 154 | uint32_t version; |
167 | }; | 155 | uint32_t data_crc; |
156 | uint32_t partial_crc; | ||
157 | uint32_t csize; | ||
158 | }; | ||
168 | 159 | ||
169 | struct jffs2_full_dirent | 160 | struct jffs2_full_dirent |
170 | { | 161 | { |
@@ -178,7 +169,7 @@ struct jffs2_full_dirent | |||
178 | }; | 169 | }; |
179 | 170 | ||
180 | /* | 171 | /* |
181 | Fragments - used to build a map of which raw node to obtain | 172 | Fragments - used to build a map of which raw node to obtain |
182 | data from for each part of the ino | 173 | data from for each part of the ino |
183 | */ | 174 | */ |
184 | struct jffs2_node_frag | 175 | struct jffs2_node_frag |
@@ -207,86 +198,18 @@ struct jffs2_eraseblock | |||
207 | struct jffs2_raw_node_ref *gc_node; /* Next node to be garbage collected */ | 198 | struct jffs2_raw_node_ref *gc_node; /* Next node to be garbage collected */ |
208 | }; | 199 | }; |
209 | 200 | ||
210 | #define ACCT_SANITY_CHECK(c, jeb) do { \ | 201 | static inline int jffs2_blocks_use_vmalloc(struct jffs2_sb_info *c) |
211 | struct jffs2_eraseblock *___j = jeb; \ | ||
212 | if ((___j) && ___j->used_size + ___j->dirty_size + ___j->free_size + ___j->wasted_size + ___j->unchecked_size != c->sector_size) { \ | ||
213 | printk(KERN_NOTICE "Eeep. Space accounting for block at 0x%08x is screwed\n", ___j->offset); \ | ||
214 | printk(KERN_NOTICE "free 0x%08x + dirty 0x%08x + used %08x + wasted %08x + unchecked %08x != total %08x\n", \ | ||
215 | ___j->free_size, ___j->dirty_size, ___j->used_size, ___j->wasted_size, ___j->unchecked_size, c->sector_size); \ | ||
216 | BUG(); \ | ||
217 | } \ | ||
218 | if (c->used_size + c->dirty_size + c->free_size + c->erasing_size + c->bad_size + c->wasted_size + c->unchecked_size != c->flash_size) { \ | ||
219 | printk(KERN_NOTICE "Eeep. Space accounting superblock info is screwed\n"); \ | ||
220 | printk(KERN_NOTICE "free 0x%08x + dirty 0x%08x + used %08x + erasing %08x + bad %08x + wasted %08x + unchecked %08x != total %08x\n", \ | ||
221 | c->free_size, c->dirty_size, c->used_size, c->erasing_size, c->bad_size, c->wasted_size, c->unchecked_size, c->flash_size); \ | ||
222 | BUG(); \ | ||
223 | } \ | ||
224 | } while(0) | ||
225 | |||
226 | static inline void paranoia_failed_dump(struct jffs2_eraseblock *jeb) | ||
227 | { | 202 | { |
228 | struct jffs2_raw_node_ref *ref; | 203 | return ((c->flash_size / c->sector_size) * sizeof (struct jffs2_eraseblock)) > (128 * 1024); |
229 | int i=0; | ||
230 | |||
231 | printk(KERN_NOTICE); | ||
232 | for (ref = jeb->first_node; ref; ref = ref->next_phys) { | ||
233 | printk("%08x->", ref_offset(ref)); | ||
234 | if (++i == 8) { | ||
235 | i = 0; | ||
236 | printk("\n" KERN_NOTICE); | ||
237 | } | ||
238 | } | ||
239 | printk("\n"); | ||
240 | } | 204 | } |
241 | 205 | ||
242 | |||
243 | #define ACCT_PARANOIA_CHECK(jeb) do { \ | ||
244 | uint32_t my_used_size = 0; \ | ||
245 | uint32_t my_unchecked_size = 0; \ | ||
246 | struct jffs2_raw_node_ref *ref2 = jeb->first_node; \ | ||
247 | while (ref2) { \ | ||
248 | if (unlikely(ref2->flash_offset < jeb->offset || \ | ||
249 | ref2->flash_offset > jeb->offset + c->sector_size)) { \ | ||
250 | printk(KERN_NOTICE "Node %08x shouldn't be in block at %08x!\n", \ | ||
251 | ref_offset(ref2), jeb->offset); \ | ||
252 | paranoia_failed_dump(jeb); \ | ||
253 | BUG(); \ | ||
254 | } \ | ||
255 | if (ref_flags(ref2) == REF_UNCHECKED) \ | ||
256 | my_unchecked_size += ref_totlen(c, jeb, ref2); \ | ||
257 | else if (!ref_obsolete(ref2)) \ | ||
258 | my_used_size += ref_totlen(c, jeb, ref2); \ | ||
259 | if (unlikely((!ref2->next_phys) != (ref2 == jeb->last_node))) { \ | ||
260 | if (!ref2->next_phys) \ | ||
261 | printk("ref for node at %p (phys %08x) has next_phys->%p (----), last_node->%p (phys %08x)\n", \ | ||
262 | ref2, ref_offset(ref2), ref2->next_phys, \ | ||
263 | jeb->last_node, ref_offset(jeb->last_node)); \ | ||
264 | else \ | ||
265 | printk("ref for node at %p (phys %08x) has next_phys->%p (%08x), last_node->%p (phys %08x)\n", \ | ||
266 | ref2, ref_offset(ref2), ref2->next_phys, ref_offset(ref2->next_phys), \ | ||
267 | jeb->last_node, ref_offset(jeb->last_node)); \ | ||
268 | paranoia_failed_dump(jeb); \ | ||
269 | BUG(); \ | ||
270 | } \ | ||
271 | ref2 = ref2->next_phys; \ | ||
272 | } \ | ||
273 | if (my_used_size != jeb->used_size) { \ | ||
274 | printk(KERN_NOTICE "Calculated used size %08x != stored used size %08x\n", my_used_size, jeb->used_size); \ | ||
275 | BUG(); \ | ||
276 | } \ | ||
277 | if (my_unchecked_size != jeb->unchecked_size) { \ | ||
278 | printk(KERN_NOTICE "Calculated unchecked size %08x != stored unchecked size %08x\n", my_unchecked_size, jeb->unchecked_size); \ | ||
279 | BUG(); \ | ||
280 | } \ | ||
281 | } while(0) | ||
282 | |||
283 | /* Calculate totlen from surrounding nodes or eraseblock */ | 206 | /* Calculate totlen from surrounding nodes or eraseblock */ |
284 | static inline uint32_t __ref_totlen(struct jffs2_sb_info *c, | 207 | static inline uint32_t __ref_totlen(struct jffs2_sb_info *c, |
285 | struct jffs2_eraseblock *jeb, | 208 | struct jffs2_eraseblock *jeb, |
286 | struct jffs2_raw_node_ref *ref) | 209 | struct jffs2_raw_node_ref *ref) |
287 | { | 210 | { |
288 | uint32_t ref_end; | 211 | uint32_t ref_end; |
289 | 212 | ||
290 | if (ref->next_phys) | 213 | if (ref->next_phys) |
291 | ref_end = ref_offset(ref->next_phys); | 214 | ref_end = ref_offset(ref->next_phys); |
292 | else { | 215 | else { |
@@ -306,11 +229,13 @@ static inline uint32_t ref_totlen(struct jffs2_sb_info *c, | |||
306 | { | 229 | { |
307 | uint32_t ret; | 230 | uint32_t ret; |
308 | 231 | ||
309 | D1(if (jeb && jeb != &c->blocks[ref->flash_offset / c->sector_size]) { | 232 | #if CONFIG_JFFS2_FS_DEBUG > 0 |
233 | if (jeb && jeb != &c->blocks[ref->flash_offset / c->sector_size]) { | ||
310 | printk(KERN_CRIT "ref_totlen called with wrong block -- at 0x%08x instead of 0x%08x; ref 0x%08x\n", | 234 | printk(KERN_CRIT "ref_totlen called with wrong block -- at 0x%08x instead of 0x%08x; ref 0x%08x\n", |
311 | jeb->offset, c->blocks[ref->flash_offset / c->sector_size].offset, ref_offset(ref)); | 235 | jeb->offset, c->blocks[ref->flash_offset / c->sector_size].offset, ref_offset(ref)); |
312 | BUG(); | 236 | BUG(); |
313 | }) | 237 | } |
238 | #endif | ||
314 | 239 | ||
315 | #if 1 | 240 | #if 1 |
316 | ret = ref->__totlen; | 241 | ret = ref->__totlen; |
@@ -323,14 +248,13 @@ static inline uint32_t ref_totlen(struct jffs2_sb_info *c, | |||
323 | ret, ref->__totlen); | 248 | ret, ref->__totlen); |
324 | if (!jeb) | 249 | if (!jeb) |
325 | jeb = &c->blocks[ref->flash_offset / c->sector_size]; | 250 | jeb = &c->blocks[ref->flash_offset / c->sector_size]; |
326 | paranoia_failed_dump(jeb); | 251 | jffs2_dbg_dump_node_refs_nolock(c, jeb); |
327 | BUG(); | 252 | BUG(); |
328 | } | 253 | } |
329 | #endif | 254 | #endif |
330 | return ret; | 255 | return ret; |
331 | } | 256 | } |
332 | 257 | ||
333 | |||
334 | #define ALLOC_NORMAL 0 /* Normal allocation */ | 258 | #define ALLOC_NORMAL 0 /* Normal allocation */ |
335 | #define ALLOC_DELETION 1 /* Deletion node. Best to allow it */ | 259 | #define ALLOC_DELETION 1 /* Deletion node. Best to allow it */ |
336 | #define ALLOC_GC 2 /* Space requested for GC. Give it or die */ | 260 | #define ALLOC_GC 2 /* Space requested for GC. Give it or die */ |
@@ -340,7 +264,7 @@ static inline uint32_t ref_totlen(struct jffs2_sb_info *c, | |||
340 | #define VERYDIRTY(c, size) ((size) >= ((c)->sector_size / 2)) | 264 | #define VERYDIRTY(c, size) ((size) >= ((c)->sector_size / 2)) |
341 | 265 | ||
342 | /* check if dirty space is more than 255 Byte */ | 266 | /* check if dirty space is more than 255 Byte */ |
343 | #define ISDIRTY(size) ((size) > sizeof (struct jffs2_raw_inode) + JFFS2_MIN_DATA_LEN) | 267 | #define ISDIRTY(size) ((size) > sizeof (struct jffs2_raw_inode) + JFFS2_MIN_DATA_LEN) |
344 | 268 | ||
345 | #define PAD(x) (((x)+3)&~3) | 269 | #define PAD(x) (((x)+3)&~3) |
346 | 270 | ||
@@ -384,12 +308,7 @@ static inline struct jffs2_node_frag *frag_last(struct rb_root *root) | |||
384 | #define frag_erase(frag, list) rb_erase(&frag->rb, list); | 308 | #define frag_erase(frag, list) rb_erase(&frag->rb, list); |
385 | 309 | ||
386 | /* nodelist.c */ | 310 | /* nodelist.c */ |
387 | D2(void jffs2_print_frag_list(struct jffs2_inode_info *f)); | ||
388 | void jffs2_add_fd_to_list(struct jffs2_sb_info *c, struct jffs2_full_dirent *new, struct jffs2_full_dirent **list); | 311 | void jffs2_add_fd_to_list(struct jffs2_sb_info *c, struct jffs2_full_dirent *new, struct jffs2_full_dirent **list); |
389 | int jffs2_get_inode_nodes(struct jffs2_sb_info *c, struct jffs2_inode_info *f, | ||
390 | struct rb_root *tnp, struct jffs2_full_dirent **fdp, | ||
391 | uint32_t *highest_version, uint32_t *latest_mctime, | ||
392 | uint32_t *mctime_ver); | ||
393 | void jffs2_set_inocache_state(struct jffs2_sb_info *c, struct jffs2_inode_cache *ic, int state); | 312 | void jffs2_set_inocache_state(struct jffs2_sb_info *c, struct jffs2_inode_cache *ic, int state); |
394 | struct jffs2_inode_cache *jffs2_get_ino_cache(struct jffs2_sb_info *c, uint32_t ino); | 313 | struct jffs2_inode_cache *jffs2_get_ino_cache(struct jffs2_sb_info *c, uint32_t ino); |
395 | void jffs2_add_ino_cache (struct jffs2_sb_info *c, struct jffs2_inode_cache *new); | 314 | void jffs2_add_ino_cache (struct jffs2_sb_info *c, struct jffs2_inode_cache *new); |
@@ -398,19 +317,23 @@ void jffs2_free_ino_caches(struct jffs2_sb_info *c); | |||
398 | void jffs2_free_raw_node_refs(struct jffs2_sb_info *c); | 317 | void jffs2_free_raw_node_refs(struct jffs2_sb_info *c); |
399 | struct jffs2_node_frag *jffs2_lookup_node_frag(struct rb_root *fragtree, uint32_t offset); | 318 | struct jffs2_node_frag *jffs2_lookup_node_frag(struct rb_root *fragtree, uint32_t offset); |
400 | void jffs2_kill_fragtree(struct rb_root *root, struct jffs2_sb_info *c_delete); | 319 | void jffs2_kill_fragtree(struct rb_root *root, struct jffs2_sb_info *c_delete); |
401 | void jffs2_fragtree_insert(struct jffs2_node_frag *newfrag, struct jffs2_node_frag *base); | ||
402 | struct rb_node *rb_next(struct rb_node *); | 320 | struct rb_node *rb_next(struct rb_node *); |
403 | struct rb_node *rb_prev(struct rb_node *); | 321 | struct rb_node *rb_prev(struct rb_node *); |
404 | void rb_replace_node(struct rb_node *victim, struct rb_node *new, struct rb_root *root); | 322 | void rb_replace_node(struct rb_node *victim, struct rb_node *new, struct rb_root *root); |
323 | void jffs2_obsolete_node_frag(struct jffs2_sb_info *c, struct jffs2_node_frag *this); | ||
324 | int jffs2_add_full_dnode_to_inode(struct jffs2_sb_info *c, struct jffs2_inode_info *f, struct jffs2_full_dnode *fn); | ||
325 | void jffs2_truncate_fragtree (struct jffs2_sb_info *c, struct rb_root *list, uint32_t size); | ||
326 | int jffs2_add_older_frag_to_fragtree(struct jffs2_sb_info *c, struct jffs2_inode_info *f, struct jffs2_tmp_dnode_info *tn); | ||
405 | 327 | ||
406 | /* nodemgmt.c */ | 328 | /* nodemgmt.c */ |
407 | int jffs2_thread_should_wake(struct jffs2_sb_info *c); | 329 | int jffs2_thread_should_wake(struct jffs2_sb_info *c); |
408 | int jffs2_reserve_space(struct jffs2_sb_info *c, uint32_t minsize, uint32_t *ofs, uint32_t *len, int prio); | 330 | int jffs2_reserve_space(struct jffs2_sb_info *c, uint32_t minsize, uint32_t *ofs, |
409 | int jffs2_reserve_space_gc(struct jffs2_sb_info *c, uint32_t minsize, uint32_t *ofs, uint32_t *len); | 331 | uint32_t *len, int prio, uint32_t sumsize); |
332 | int jffs2_reserve_space_gc(struct jffs2_sb_info *c, uint32_t minsize, uint32_t *ofs, | ||
333 | uint32_t *len, uint32_t sumsize); | ||
410 | int jffs2_add_physical_node_ref(struct jffs2_sb_info *c, struct jffs2_raw_node_ref *new); | 334 | int jffs2_add_physical_node_ref(struct jffs2_sb_info *c, struct jffs2_raw_node_ref *new); |
411 | void jffs2_complete_reservation(struct jffs2_sb_info *c); | 335 | void jffs2_complete_reservation(struct jffs2_sb_info *c); |
412 | void jffs2_mark_node_obsolete(struct jffs2_sb_info *c, struct jffs2_raw_node_ref *raw); | 336 | void jffs2_mark_node_obsolete(struct jffs2_sb_info *c, struct jffs2_raw_node_ref *raw); |
413 | void jffs2_dump_block_lists(struct jffs2_sb_info *c); | ||
414 | 337 | ||
415 | /* write.c */ | 338 | /* write.c */ |
416 | int jffs2_do_new_inode(struct jffs2_sb_info *c, struct jffs2_inode_info *f, uint32_t mode, struct jffs2_raw_inode *ri); | 339 | int jffs2_do_new_inode(struct jffs2_sb_info *c, struct jffs2_inode_info *f, uint32_t mode, struct jffs2_raw_inode *ri); |
@@ -418,17 +341,15 @@ int jffs2_do_new_inode(struct jffs2_sb_info *c, struct jffs2_inode_info *f, uint | |||
418 | struct jffs2_full_dnode *jffs2_write_dnode(struct jffs2_sb_info *c, struct jffs2_inode_info *f, struct jffs2_raw_inode *ri, const unsigned char *data, uint32_t datalen, uint32_t flash_ofs, int alloc_mode); | 341 | struct jffs2_full_dnode *jffs2_write_dnode(struct jffs2_sb_info *c, struct jffs2_inode_info *f, struct jffs2_raw_inode *ri, const unsigned char *data, uint32_t datalen, uint32_t flash_ofs, int alloc_mode); |
419 | struct jffs2_full_dirent *jffs2_write_dirent(struct jffs2_sb_info *c, struct jffs2_inode_info *f, struct jffs2_raw_dirent *rd, const unsigned char *name, uint32_t namelen, uint32_t flash_ofs, int alloc_mode); | 342 | struct jffs2_full_dirent *jffs2_write_dirent(struct jffs2_sb_info *c, struct jffs2_inode_info *f, struct jffs2_raw_dirent *rd, const unsigned char *name, uint32_t namelen, uint32_t flash_ofs, int alloc_mode); |
420 | int jffs2_write_inode_range(struct jffs2_sb_info *c, struct jffs2_inode_info *f, | 343 | int jffs2_write_inode_range(struct jffs2_sb_info *c, struct jffs2_inode_info *f, |
421 | struct jffs2_raw_inode *ri, unsigned char *buf, | 344 | struct jffs2_raw_inode *ri, unsigned char *buf, |
422 | uint32_t offset, uint32_t writelen, uint32_t *retlen); | 345 | uint32_t offset, uint32_t writelen, uint32_t *retlen); |
423 | int jffs2_do_create(struct jffs2_sb_info *c, struct jffs2_inode_info *dir_f, struct jffs2_inode_info *f, struct jffs2_raw_inode *ri, const char *name, int namelen); | 346 | int jffs2_do_create(struct jffs2_sb_info *c, struct jffs2_inode_info *dir_f, struct jffs2_inode_info *f, struct jffs2_raw_inode *ri, const char *name, int namelen); |
424 | int jffs2_do_unlink(struct jffs2_sb_info *c, struct jffs2_inode_info *dir_f, const char *name, int namelen, struct jffs2_inode_info *dead_f); | 347 | int jffs2_do_unlink(struct jffs2_sb_info *c, struct jffs2_inode_info *dir_f, const char *name, int namelen, struct jffs2_inode_info *dead_f, uint32_t time); |
425 | int jffs2_do_link (struct jffs2_sb_info *c, struct jffs2_inode_info *dir_f, uint32_t ino, uint8_t type, const char *name, int namelen); | 348 | int jffs2_do_link (struct jffs2_sb_info *c, struct jffs2_inode_info *dir_f, uint32_t ino, uint8_t type, const char *name, int namelen, uint32_t time); |
426 | 349 | ||
427 | 350 | ||
428 | /* readinode.c */ | 351 | /* readinode.c */ |
429 | void jffs2_truncate_fraglist (struct jffs2_sb_info *c, struct rb_root *list, uint32_t size); | 352 | int jffs2_do_read_inode(struct jffs2_sb_info *c, struct jffs2_inode_info *f, |
430 | int jffs2_add_full_dnode_to_inode(struct jffs2_sb_info *c, struct jffs2_inode_info *f, struct jffs2_full_dnode *fn); | ||
431 | int jffs2_do_read_inode(struct jffs2_sb_info *c, struct jffs2_inode_info *f, | ||
432 | uint32_t ino, struct jffs2_raw_inode *latest_node); | 353 | uint32_t ino, struct jffs2_raw_inode *latest_node); |
433 | int jffs2_do_crccheck_inode(struct jffs2_sb_info *c, struct jffs2_inode_cache *ic); | 354 | int jffs2_do_crccheck_inode(struct jffs2_sb_info *c, struct jffs2_inode_cache *ic); |
434 | void jffs2_do_clear_inode(struct jffs2_sb_info *c, struct jffs2_inode_info *f); | 355 | void jffs2_do_clear_inode(struct jffs2_sb_info *c, struct jffs2_inode_info *f); |
@@ -468,6 +389,10 @@ char *jffs2_getlink(struct jffs2_sb_info *c, struct jffs2_inode_info *f); | |||
468 | /* scan.c */ | 389 | /* scan.c */ |
469 | int jffs2_scan_medium(struct jffs2_sb_info *c); | 390 | int jffs2_scan_medium(struct jffs2_sb_info *c); |
470 | void jffs2_rotate_lists(struct jffs2_sb_info *c); | 391 | void jffs2_rotate_lists(struct jffs2_sb_info *c); |
392 | int jffs2_fill_scan_buf(struct jffs2_sb_info *c, void *buf, | ||
393 | uint32_t ofs, uint32_t len); | ||
394 | struct jffs2_inode_cache *jffs2_scan_make_ino_cache(struct jffs2_sb_info *c, uint32_t ino); | ||
395 | int jffs2_scan_classify_jeb(struct jffs2_sb_info *c, struct jffs2_eraseblock *jeb); | ||
471 | 396 | ||
472 | /* build.c */ | 397 | /* build.c */ |
473 | int jffs2_do_mount_fs(struct jffs2_sb_info *c); | 398 | int jffs2_do_mount_fs(struct jffs2_sb_info *c); |
@@ -483,4 +408,6 @@ int jffs2_check_nand_cleanmarker(struct jffs2_sb_info *c, struct jffs2_erasebloc | |||
483 | int jffs2_write_nand_cleanmarker(struct jffs2_sb_info *c, struct jffs2_eraseblock *jeb); | 408 | int jffs2_write_nand_cleanmarker(struct jffs2_sb_info *c, struct jffs2_eraseblock *jeb); |
484 | #endif | 409 | #endif |
485 | 410 | ||
411 | #include "debug.h" | ||
412 | |||
486 | #endif /* __JFFS2_NODELIST_H__ */ | 413 | #endif /* __JFFS2_NODELIST_H__ */ |
diff --git a/fs/jffs2/nodemgmt.c b/fs/jffs2/nodemgmt.c index c1d8b5ed9ab9..49127a1f0458 100644 --- a/fs/jffs2/nodemgmt.c +++ b/fs/jffs2/nodemgmt.c | |||
@@ -7,7 +7,7 @@ | |||
7 | * | 7 | * |
8 | * For licensing information, see the file 'LICENCE' in this directory. | 8 | * For licensing information, see the file 'LICENCE' in this directory. |
9 | * | 9 | * |
10 | * $Id: nodemgmt.c,v 1.122 2005/05/06 09:30:27 dedekind Exp $ | 10 | * $Id: nodemgmt.c,v 1.127 2005/09/20 15:49:12 dedekind Exp $ |
11 | * | 11 | * |
12 | */ | 12 | */ |
13 | 13 | ||
@@ -17,6 +17,7 @@ | |||
17 | #include <linux/compiler.h> | 17 | #include <linux/compiler.h> |
18 | #include <linux/sched.h> /* For cond_resched() */ | 18 | #include <linux/sched.h> /* For cond_resched() */ |
19 | #include "nodelist.h" | 19 | #include "nodelist.h" |
20 | #include "debug.h" | ||
20 | 21 | ||
21 | /** | 22 | /** |
22 | * jffs2_reserve_space - request physical space to write nodes to flash | 23 | * jffs2_reserve_space - request physical space to write nodes to flash |
@@ -38,9 +39,11 @@ | |||
38 | * for the requested allocation. | 39 | * for the requested allocation. |
39 | */ | 40 | */ |
40 | 41 | ||
41 | static int jffs2_do_reserve_space(struct jffs2_sb_info *c, uint32_t minsize, uint32_t *ofs, uint32_t *len); | 42 | static int jffs2_do_reserve_space(struct jffs2_sb_info *c, uint32_t minsize, |
43 | uint32_t *ofs, uint32_t *len, uint32_t sumsize); | ||
42 | 44 | ||
43 | int jffs2_reserve_space(struct jffs2_sb_info *c, uint32_t minsize, uint32_t *ofs, uint32_t *len, int prio) | 45 | int jffs2_reserve_space(struct jffs2_sb_info *c, uint32_t minsize, uint32_t *ofs, |
46 | uint32_t *len, int prio, uint32_t sumsize) | ||
44 | { | 47 | { |
45 | int ret = -EAGAIN; | 48 | int ret = -EAGAIN; |
46 | int blocksneeded = c->resv_blocks_write; | 49 | int blocksneeded = c->resv_blocks_write; |
@@ -85,12 +88,12 @@ int jffs2_reserve_space(struct jffs2_sb_info *c, uint32_t minsize, uint32_t *ofs | |||
85 | up(&c->alloc_sem); | 88 | up(&c->alloc_sem); |
86 | return -ENOSPC; | 89 | return -ENOSPC; |
87 | } | 90 | } |
88 | 91 | ||
89 | /* Calc possibly available space. Possibly available means that we | 92 | /* Calc possibly available space. Possibly available means that we |
90 | * don't know, if unchecked size contains obsoleted nodes, which could give us some | 93 | * don't know, if unchecked size contains obsoleted nodes, which could give us some |
91 | * more usable space. This will affect the sum only once, as gc first finishes checking | 94 | * more usable space. This will affect the sum only once, as gc first finishes checking |
92 | * of nodes. | 95 | * of nodes. |
93 | + Return -ENOSPC, if the maximum possibly available space is less or equal than | 96 | + Return -ENOSPC, if the maximum possibly available space is less or equal than |
94 | * blocksneeded * sector_size. | 97 | * blocksneeded * sector_size. |
95 | * This blocks endless gc looping on a filesystem, which is nearly full, even if | 98 | * This blocks endless gc looping on a filesystem, which is nearly full, even if |
96 | * the check above passes. | 99 | * the check above passes. |
@@ -115,7 +118,7 @@ int jffs2_reserve_space(struct jffs2_sb_info *c, uint32_t minsize, uint32_t *ofs | |||
115 | c->nr_free_blocks, c->nr_erasing_blocks, c->free_size, c->dirty_size, c->wasted_size, c->used_size, c->erasing_size, c->bad_size, | 118 | c->nr_free_blocks, c->nr_erasing_blocks, c->free_size, c->dirty_size, c->wasted_size, c->used_size, c->erasing_size, c->bad_size, |
116 | c->free_size + c->dirty_size + c->wasted_size + c->used_size + c->erasing_size + c->bad_size, c->flash_size)); | 119 | c->free_size + c->dirty_size + c->wasted_size + c->used_size + c->erasing_size + c->bad_size, c->flash_size)); |
117 | spin_unlock(&c->erase_completion_lock); | 120 | spin_unlock(&c->erase_completion_lock); |
118 | 121 | ||
119 | ret = jffs2_garbage_collect_pass(c); | 122 | ret = jffs2_garbage_collect_pass(c); |
120 | if (ret) | 123 | if (ret) |
121 | return ret; | 124 | return ret; |
@@ -129,7 +132,7 @@ int jffs2_reserve_space(struct jffs2_sb_info *c, uint32_t minsize, uint32_t *ofs | |||
129 | spin_lock(&c->erase_completion_lock); | 132 | spin_lock(&c->erase_completion_lock); |
130 | } | 133 | } |
131 | 134 | ||
132 | ret = jffs2_do_reserve_space(c, minsize, ofs, len); | 135 | ret = jffs2_do_reserve_space(c, minsize, ofs, len, sumsize); |
133 | if (ret) { | 136 | if (ret) { |
134 | D1(printk(KERN_DEBUG "jffs2_reserve_space: ret is %d\n", ret)); | 137 | D1(printk(KERN_DEBUG "jffs2_reserve_space: ret is %d\n", ret)); |
135 | } | 138 | } |
@@ -140,7 +143,8 @@ int jffs2_reserve_space(struct jffs2_sb_info *c, uint32_t minsize, uint32_t *ofs | |||
140 | return ret; | 143 | return ret; |
141 | } | 144 | } |
142 | 145 | ||
143 | int jffs2_reserve_space_gc(struct jffs2_sb_info *c, uint32_t minsize, uint32_t *ofs, uint32_t *len) | 146 | int jffs2_reserve_space_gc(struct jffs2_sb_info *c, uint32_t minsize, uint32_t *ofs, |
147 | uint32_t *len, uint32_t sumsize) | ||
144 | { | 148 | { |
145 | int ret = -EAGAIN; | 149 | int ret = -EAGAIN; |
146 | minsize = PAD(minsize); | 150 | minsize = PAD(minsize); |
@@ -149,7 +153,7 @@ int jffs2_reserve_space_gc(struct jffs2_sb_info *c, uint32_t minsize, uint32_t * | |||
149 | 153 | ||
150 | spin_lock(&c->erase_completion_lock); | 154 | spin_lock(&c->erase_completion_lock); |
151 | while(ret == -EAGAIN) { | 155 | while(ret == -EAGAIN) { |
152 | ret = jffs2_do_reserve_space(c, minsize, ofs, len); | 156 | ret = jffs2_do_reserve_space(c, minsize, ofs, len, sumsize); |
153 | if (ret) { | 157 | if (ret) { |
154 | D1(printk(KERN_DEBUG "jffs2_reserve_space_gc: looping, ret is %d\n", ret)); | 158 | D1(printk(KERN_DEBUG "jffs2_reserve_space_gc: looping, ret is %d\n", ret)); |
155 | } | 159 | } |
@@ -158,105 +162,185 @@ int jffs2_reserve_space_gc(struct jffs2_sb_info *c, uint32_t minsize, uint32_t * | |||
158 | return ret; | 162 | return ret; |
159 | } | 163 | } |
160 | 164 | ||
161 | /* Called with alloc sem _and_ erase_completion_lock */ | 165 | |
162 | static int jffs2_do_reserve_space(struct jffs2_sb_info *c, uint32_t minsize, uint32_t *ofs, uint32_t *len) | 166 | /* Classify nextblock (clean, dirty of verydirty) and force to select an other one */ |
167 | |||
168 | static void jffs2_close_nextblock(struct jffs2_sb_info *c, struct jffs2_eraseblock *jeb) | ||
163 | { | 169 | { |
164 | struct jffs2_eraseblock *jeb = c->nextblock; | 170 | |
165 | 171 | /* Check, if we have a dirty block now, or if it was dirty already */ | |
166 | restart: | 172 | if (ISDIRTY (jeb->wasted_size + jeb->dirty_size)) { |
167 | if (jeb && minsize > jeb->free_size) { | 173 | c->dirty_size += jeb->wasted_size; |
168 | /* Skip the end of this block and file it as having some dirty space */ | 174 | c->wasted_size -= jeb->wasted_size; |
169 | /* If there's a pending write to it, flush now */ | 175 | jeb->dirty_size += jeb->wasted_size; |
170 | if (jffs2_wbuf_dirty(c)) { | 176 | jeb->wasted_size = 0; |
177 | if (VERYDIRTY(c, jeb->dirty_size)) { | ||
178 | D1(printk(KERN_DEBUG "Adding full erase block at 0x%08x to very_dirty_list (free 0x%08x, dirty 0x%08x, used 0x%08x\n", | ||
179 | jeb->offset, jeb->free_size, jeb->dirty_size, jeb->used_size)); | ||
180 | list_add_tail(&jeb->list, &c->very_dirty_list); | ||
181 | } else { | ||
182 | D1(printk(KERN_DEBUG "Adding full erase block at 0x%08x to dirty_list (free 0x%08x, dirty 0x%08x, used 0x%08x\n", | ||
183 | jeb->offset, jeb->free_size, jeb->dirty_size, jeb->used_size)); | ||
184 | list_add_tail(&jeb->list, &c->dirty_list); | ||
185 | } | ||
186 | } else { | ||
187 | D1(printk(KERN_DEBUG "Adding full erase block at 0x%08x to clean_list (free 0x%08x, dirty 0x%08x, used 0x%08x\n", | ||
188 | jeb->offset, jeb->free_size, jeb->dirty_size, jeb->used_size)); | ||
189 | list_add_tail(&jeb->list, &c->clean_list); | ||
190 | } | ||
191 | c->nextblock = NULL; | ||
192 | |||
193 | } | ||
194 | |||
195 | /* Select a new jeb for nextblock */ | ||
196 | |||
197 | static int jffs2_find_nextblock(struct jffs2_sb_info *c) | ||
198 | { | ||
199 | struct list_head *next; | ||
200 | |||
201 | /* Take the next block off the 'free' list */ | ||
202 | |||
203 | if (list_empty(&c->free_list)) { | ||
204 | |||
205 | if (!c->nr_erasing_blocks && | ||
206 | !list_empty(&c->erasable_list)) { | ||
207 | struct jffs2_eraseblock *ejeb; | ||
208 | |||
209 | ejeb = list_entry(c->erasable_list.next, struct jffs2_eraseblock, list); | ||
210 | list_del(&ejeb->list); | ||
211 | list_add_tail(&ejeb->list, &c->erase_pending_list); | ||
212 | c->nr_erasing_blocks++; | ||
213 | jffs2_erase_pending_trigger(c); | ||
214 | D1(printk(KERN_DEBUG "jffs2_find_nextblock: Triggering erase of erasable block at 0x%08x\n", | ||
215 | ejeb->offset)); | ||
216 | } | ||
217 | |||
218 | if (!c->nr_erasing_blocks && | ||
219 | !list_empty(&c->erasable_pending_wbuf_list)) { | ||
220 | D1(printk(KERN_DEBUG "jffs2_find_nextblock: Flushing write buffer\n")); | ||
221 | /* c->nextblock is NULL, no update to c->nextblock allowed */ | ||
171 | spin_unlock(&c->erase_completion_lock); | 222 | spin_unlock(&c->erase_completion_lock); |
172 | D1(printk(KERN_DEBUG "jffs2_do_reserve_space: Flushing write buffer\n")); | ||
173 | jffs2_flush_wbuf_pad(c); | 223 | jffs2_flush_wbuf_pad(c); |
174 | spin_lock(&c->erase_completion_lock); | 224 | spin_lock(&c->erase_completion_lock); |
175 | jeb = c->nextblock; | 225 | /* Have another go. It'll be on the erasable_list now */ |
176 | goto restart; | 226 | return -EAGAIN; |
177 | } | 227 | } |
178 | c->wasted_size += jeb->free_size; | 228 | |
179 | c->free_size -= jeb->free_size; | 229 | if (!c->nr_erasing_blocks) { |
180 | jeb->wasted_size += jeb->free_size; | 230 | /* Ouch. We're in GC, or we wouldn't have got here. |
181 | jeb->free_size = 0; | 231 | And there's no space left. At all. */ |
182 | 232 | printk(KERN_CRIT "Argh. No free space left for GC. nr_erasing_blocks is %d. nr_free_blocks is %d. (erasableempty: %s, erasingempty: %s, erasependingempty: %s)\n", | |
183 | /* Check, if we have a dirty block now, or if it was dirty already */ | 233 | c->nr_erasing_blocks, c->nr_free_blocks, list_empty(&c->erasable_list)?"yes":"no", |
184 | if (ISDIRTY (jeb->wasted_size + jeb->dirty_size)) { | 234 | list_empty(&c->erasing_list)?"yes":"no", list_empty(&c->erase_pending_list)?"yes":"no"); |
185 | c->dirty_size += jeb->wasted_size; | 235 | return -ENOSPC; |
186 | c->wasted_size -= jeb->wasted_size; | ||
187 | jeb->dirty_size += jeb->wasted_size; | ||
188 | jeb->wasted_size = 0; | ||
189 | if (VERYDIRTY(c, jeb->dirty_size)) { | ||
190 | D1(printk(KERN_DEBUG "Adding full erase block at 0x%08x to very_dirty_list (free 0x%08x, dirty 0x%08x, used 0x%08x\n", | ||
191 | jeb->offset, jeb->free_size, jeb->dirty_size, jeb->used_size)); | ||
192 | list_add_tail(&jeb->list, &c->very_dirty_list); | ||
193 | } else { | ||
194 | D1(printk(KERN_DEBUG "Adding full erase block at 0x%08x to dirty_list (free 0x%08x, dirty 0x%08x, used 0x%08x\n", | ||
195 | jeb->offset, jeb->free_size, jeb->dirty_size, jeb->used_size)); | ||
196 | list_add_tail(&jeb->list, &c->dirty_list); | ||
197 | } | ||
198 | } else { | ||
199 | D1(printk(KERN_DEBUG "Adding full erase block at 0x%08x to clean_list (free 0x%08x, dirty 0x%08x, used 0x%08x\n", | ||
200 | jeb->offset, jeb->free_size, jeb->dirty_size, jeb->used_size)); | ||
201 | list_add_tail(&jeb->list, &c->clean_list); | ||
202 | } | 236 | } |
203 | c->nextblock = jeb = NULL; | 237 | |
238 | spin_unlock(&c->erase_completion_lock); | ||
239 | /* Don't wait for it; just erase one right now */ | ||
240 | jffs2_erase_pending_blocks(c, 1); | ||
241 | spin_lock(&c->erase_completion_lock); | ||
242 | |||
243 | /* An erase may have failed, decreasing the | ||
244 | amount of free space available. So we must | ||
245 | restart from the beginning */ | ||
246 | return -EAGAIN; | ||
204 | } | 247 | } |
205 | |||
206 | if (!jeb) { | ||
207 | struct list_head *next; | ||
208 | /* Take the next block off the 'free' list */ | ||
209 | 248 | ||
210 | if (list_empty(&c->free_list)) { | 249 | next = c->free_list.next; |
250 | list_del(next); | ||
251 | c->nextblock = list_entry(next, struct jffs2_eraseblock, list); | ||
252 | c->nr_free_blocks--; | ||
211 | 253 | ||
212 | if (!c->nr_erasing_blocks && | 254 | jffs2_sum_reset_collected(c->summary); /* reset collected summary */ |
213 | !list_empty(&c->erasable_list)) { | ||
214 | struct jffs2_eraseblock *ejeb; | ||
215 | 255 | ||
216 | ejeb = list_entry(c->erasable_list.next, struct jffs2_eraseblock, list); | 256 | D1(printk(KERN_DEBUG "jffs2_find_nextblock(): new nextblock = 0x%08x\n", c->nextblock->offset)); |
217 | list_del(&ejeb->list); | 257 | |
218 | list_add_tail(&ejeb->list, &c->erase_pending_list); | 258 | return 0; |
219 | c->nr_erasing_blocks++; | 259 | } |
220 | jffs2_erase_pending_trigger(c); | 260 | |
221 | D1(printk(KERN_DEBUG "jffs2_do_reserve_space: Triggering erase of erasable block at 0x%08x\n", | 261 | /* Called with alloc sem _and_ erase_completion_lock */ |
222 | ejeb->offset)); | 262 | static int jffs2_do_reserve_space(struct jffs2_sb_info *c, uint32_t minsize, uint32_t *ofs, uint32_t *len, uint32_t sumsize) |
263 | { | ||
264 | struct jffs2_eraseblock *jeb = c->nextblock; | ||
265 | uint32_t reserved_size; /* for summary information at the end of the jeb */ | ||
266 | int ret; | ||
267 | |||
268 | restart: | ||
269 | reserved_size = 0; | ||
270 | |||
271 | if (jffs2_sum_active() && (sumsize != JFFS2_SUMMARY_NOSUM_SIZE)) { | ||
272 | /* NOSUM_SIZE means not to generate summary */ | ||
273 | |||
274 | if (jeb) { | ||
275 | reserved_size = PAD(sumsize + c->summary->sum_size + JFFS2_SUMMARY_FRAME_SIZE); | ||
276 | dbg_summary("minsize=%d , jeb->free=%d ," | ||
277 | "summary->size=%d , sumsize=%d\n", | ||
278 | minsize, jeb->free_size, | ||
279 | c->summary->sum_size, sumsize); | ||
280 | } | ||
281 | |||
282 | /* Is there enough space for writing out the current node, or we have to | ||
283 | write out summary information now, close this jeb and select new nextblock? */ | ||
284 | if (jeb && (PAD(minsize) + PAD(c->summary->sum_size + sumsize + | ||
285 | JFFS2_SUMMARY_FRAME_SIZE) > jeb->free_size)) { | ||
286 | |||
287 | /* Has summary been disabled for this jeb? */ | ||
288 | if (jffs2_sum_is_disabled(c->summary)) { | ||
289 | sumsize = JFFS2_SUMMARY_NOSUM_SIZE; | ||
290 | goto restart; | ||
223 | } | 291 | } |
224 | 292 | ||
225 | if (!c->nr_erasing_blocks && | 293 | /* Writing out the collected summary information */ |
226 | !list_empty(&c->erasable_pending_wbuf_list)) { | 294 | dbg_summary("generating summary for 0x%08x.\n", jeb->offset); |
227 | D1(printk(KERN_DEBUG "jffs2_do_reserve_space: Flushing write buffer\n")); | 295 | ret = jffs2_sum_write_sumnode(c); |
228 | /* c->nextblock is NULL, no update to c->nextblock allowed */ | 296 | |
297 | if (ret) | ||
298 | return ret; | ||
299 | |||
300 | if (jffs2_sum_is_disabled(c->summary)) { | ||
301 | /* jffs2_write_sumnode() couldn't write out the summary information | ||
302 | diabling summary for this jeb and free the collected information | ||
303 | */ | ||
304 | sumsize = JFFS2_SUMMARY_NOSUM_SIZE; | ||
305 | goto restart; | ||
306 | } | ||
307 | |||
308 | jffs2_close_nextblock(c, jeb); | ||
309 | jeb = NULL; | ||
310 | /* keep always valid value in reserved_size */ | ||
311 | reserved_size = PAD(sumsize + c->summary->sum_size + JFFS2_SUMMARY_FRAME_SIZE); | ||
312 | } | ||
313 | } else { | ||
314 | if (jeb && minsize > jeb->free_size) { | ||
315 | /* Skip the end of this block and file it as having some dirty space */ | ||
316 | /* If there's a pending write to it, flush now */ | ||
317 | |||
318 | if (jffs2_wbuf_dirty(c)) { | ||
229 | spin_unlock(&c->erase_completion_lock); | 319 | spin_unlock(&c->erase_completion_lock); |
320 | D1(printk(KERN_DEBUG "jffs2_do_reserve_space: Flushing write buffer\n")); | ||
230 | jffs2_flush_wbuf_pad(c); | 321 | jffs2_flush_wbuf_pad(c); |
231 | spin_lock(&c->erase_completion_lock); | 322 | spin_lock(&c->erase_completion_lock); |
232 | /* Have another go. It'll be on the erasable_list now */ | 323 | jeb = c->nextblock; |
233 | return -EAGAIN; | 324 | goto restart; |
234 | } | 325 | } |
235 | 326 | ||
236 | if (!c->nr_erasing_blocks) { | 327 | c->wasted_size += jeb->free_size; |
237 | /* Ouch. We're in GC, or we wouldn't have got here. | 328 | c->free_size -= jeb->free_size; |
238 | And there's no space left. At all. */ | 329 | jeb->wasted_size += jeb->free_size; |
239 | printk(KERN_CRIT "Argh. No free space left for GC. nr_erasing_blocks is %d. nr_free_blocks is %d. (erasableempty: %s, erasingempty: %s, erasependingempty: %s)\n", | 330 | jeb->free_size = 0; |
240 | c->nr_erasing_blocks, c->nr_free_blocks, list_empty(&c->erasable_list)?"yes":"no", | ||
241 | list_empty(&c->erasing_list)?"yes":"no", list_empty(&c->erase_pending_list)?"yes":"no"); | ||
242 | return -ENOSPC; | ||
243 | } | ||
244 | |||
245 | spin_unlock(&c->erase_completion_lock); | ||
246 | /* Don't wait for it; just erase one right now */ | ||
247 | jffs2_erase_pending_blocks(c, 1); | ||
248 | spin_lock(&c->erase_completion_lock); | ||
249 | 331 | ||
250 | /* An erase may have failed, decreasing the | 332 | jffs2_close_nextblock(c, jeb); |
251 | amount of free space available. So we must | 333 | jeb = NULL; |
252 | restart from the beginning */ | ||
253 | return -EAGAIN; | ||
254 | } | 334 | } |
335 | } | ||
336 | |||
337 | if (!jeb) { | ||
255 | 338 | ||
256 | next = c->free_list.next; | 339 | ret = jffs2_find_nextblock(c); |
257 | list_del(next); | 340 | if (ret) |
258 | c->nextblock = jeb = list_entry(next, struct jffs2_eraseblock, list); | 341 | return ret; |
259 | c->nr_free_blocks--; | 342 | |
343 | jeb = c->nextblock; | ||
260 | 344 | ||
261 | if (jeb->free_size != c->sector_size - c->cleanmarker_size) { | 345 | if (jeb->free_size != c->sector_size - c->cleanmarker_size) { |
262 | printk(KERN_WARNING "Eep. Block 0x%08x taken from free_list had free_size of 0x%08x!!\n", jeb->offset, jeb->free_size); | 346 | printk(KERN_WARNING "Eep. Block 0x%08x taken from free_list had free_size of 0x%08x!!\n", jeb->offset, jeb->free_size); |
@@ -266,13 +350,13 @@ static int jffs2_do_reserve_space(struct jffs2_sb_info *c, uint32_t minsize, ui | |||
266 | /* OK, jeb (==c->nextblock) is now pointing at a block which definitely has | 350 | /* OK, jeb (==c->nextblock) is now pointing at a block which definitely has |
267 | enough space */ | 351 | enough space */ |
268 | *ofs = jeb->offset + (c->sector_size - jeb->free_size); | 352 | *ofs = jeb->offset + (c->sector_size - jeb->free_size); |
269 | *len = jeb->free_size; | 353 | *len = jeb->free_size - reserved_size; |
270 | 354 | ||
271 | if (c->cleanmarker_size && jeb->used_size == c->cleanmarker_size && | 355 | if (c->cleanmarker_size && jeb->used_size == c->cleanmarker_size && |
272 | !jeb->first_node->next_in_ino) { | 356 | !jeb->first_node->next_in_ino) { |
273 | /* Only node in it beforehand was a CLEANMARKER node (we think). | 357 | /* Only node in it beforehand was a CLEANMARKER node (we think). |
274 | So mark it obsolete now that there's going to be another node | 358 | So mark it obsolete now that there's going to be another node |
275 | in the block. This will reduce used_size to zero but We've | 359 | in the block. This will reduce used_size to zero but We've |
276 | already set c->nextblock so that jffs2_mark_node_obsolete() | 360 | already set c->nextblock so that jffs2_mark_node_obsolete() |
277 | won't try to refile it to the dirty_list. | 361 | won't try to refile it to the dirty_list. |
278 | */ | 362 | */ |
@@ -292,12 +376,12 @@ static int jffs2_do_reserve_space(struct jffs2_sb_info *c, uint32_t minsize, ui | |||
292 | * @len: length of this physical node | 376 | * @len: length of this physical node |
293 | * @dirty: dirty flag for new node | 377 | * @dirty: dirty flag for new node |
294 | * | 378 | * |
295 | * Should only be used to report nodes for which space has been allocated | 379 | * Should only be used to report nodes for which space has been allocated |
296 | * by jffs2_reserve_space. | 380 | * by jffs2_reserve_space. |
297 | * | 381 | * |
298 | * Must be called with the alloc_sem held. | 382 | * Must be called with the alloc_sem held. |
299 | */ | 383 | */ |
300 | 384 | ||
301 | int jffs2_add_physical_node_ref(struct jffs2_sb_info *c, struct jffs2_raw_node_ref *new) | 385 | int jffs2_add_physical_node_ref(struct jffs2_sb_info *c, struct jffs2_raw_node_ref *new) |
302 | { | 386 | { |
303 | struct jffs2_eraseblock *jeb; | 387 | struct jffs2_eraseblock *jeb; |
@@ -349,8 +433,8 @@ int jffs2_add_physical_node_ref(struct jffs2_sb_info *c, struct jffs2_raw_node_r | |||
349 | list_add_tail(&jeb->list, &c->clean_list); | 433 | list_add_tail(&jeb->list, &c->clean_list); |
350 | c->nextblock = NULL; | 434 | c->nextblock = NULL; |
351 | } | 435 | } |
352 | ACCT_SANITY_CHECK(c,jeb); | 436 | jffs2_dbg_acct_sanity_check_nolock(c,jeb); |
353 | D1(ACCT_PARANOIA_CHECK(jeb)); | 437 | jffs2_dbg_acct_paranoia_check_nolock(c, jeb); |
354 | 438 | ||
355 | spin_unlock(&c->erase_completion_lock); | 439 | spin_unlock(&c->erase_completion_lock); |
356 | 440 | ||
@@ -404,8 +488,8 @@ void jffs2_mark_node_obsolete(struct jffs2_sb_info *c, struct jffs2_raw_node_ref | |||
404 | 488 | ||
405 | if (jffs2_can_mark_obsolete(c) && !jffs2_is_readonly(c) && | 489 | if (jffs2_can_mark_obsolete(c) && !jffs2_is_readonly(c) && |
406 | !(c->flags & (JFFS2_SB_FLAG_SCANNING | JFFS2_SB_FLAG_BUILDING))) { | 490 | !(c->flags & (JFFS2_SB_FLAG_SCANNING | JFFS2_SB_FLAG_BUILDING))) { |
407 | /* Hm. This may confuse static lock analysis. If any of the above | 491 | /* Hm. This may confuse static lock analysis. If any of the above |
408 | three conditions is false, we're going to return from this | 492 | three conditions is false, we're going to return from this |
409 | function without actually obliterating any nodes or freeing | 493 | function without actually obliterating any nodes or freeing |
410 | any jffs2_raw_node_refs. So we don't need to stop erases from | 494 | any jffs2_raw_node_refs. So we don't need to stop erases from |
411 | happening, or protect against people holding an obsolete | 495 | happening, or protect against people holding an obsolete |
@@ -430,7 +514,7 @@ void jffs2_mark_node_obsolete(struct jffs2_sb_info *c, struct jffs2_raw_node_ref | |||
430 | ref_totlen(c, jeb, ref), blocknr, ref->flash_offset, jeb->used_size); | 514 | ref_totlen(c, jeb, ref), blocknr, ref->flash_offset, jeb->used_size); |
431 | BUG(); | 515 | BUG(); |
432 | }) | 516 | }) |
433 | D1(printk(KERN_DEBUG "Obsoleting node at 0x%08x of len %x: ", ref_offset(ref), ref_totlen(c, jeb, ref))); | 517 | D1(printk(KERN_DEBUG "Obsoleting node at 0x%08x of len %#x: ", ref_offset(ref), ref_totlen(c, jeb, ref))); |
434 | jeb->used_size -= ref_totlen(c, jeb, ref); | 518 | jeb->used_size -= ref_totlen(c, jeb, ref); |
435 | c->used_size -= ref_totlen(c, jeb, ref); | 519 | c->used_size -= ref_totlen(c, jeb, ref); |
436 | } | 520 | } |
@@ -462,18 +546,17 @@ void jffs2_mark_node_obsolete(struct jffs2_sb_info *c, struct jffs2_raw_node_ref | |||
462 | D1(printk(KERN_DEBUG "Wasting\n")); | 546 | D1(printk(KERN_DEBUG "Wasting\n")); |
463 | addedsize = 0; | 547 | addedsize = 0; |
464 | jeb->wasted_size += ref_totlen(c, jeb, ref); | 548 | jeb->wasted_size += ref_totlen(c, jeb, ref); |
465 | c->wasted_size += ref_totlen(c, jeb, ref); | 549 | c->wasted_size += ref_totlen(c, jeb, ref); |
466 | } | 550 | } |
467 | ref->flash_offset = ref_offset(ref) | REF_OBSOLETE; | 551 | ref->flash_offset = ref_offset(ref) | REF_OBSOLETE; |
468 | |||
469 | ACCT_SANITY_CHECK(c, jeb); | ||
470 | 552 | ||
471 | D1(ACCT_PARANOIA_CHECK(jeb)); | 553 | jffs2_dbg_acct_sanity_check_nolock(c, jeb); |
554 | jffs2_dbg_acct_paranoia_check_nolock(c, jeb); | ||
472 | 555 | ||
473 | if (c->flags & JFFS2_SB_FLAG_SCANNING) { | 556 | if (c->flags & JFFS2_SB_FLAG_SCANNING) { |
474 | /* Flash scanning is in progress. Don't muck about with the block | 557 | /* Flash scanning is in progress. Don't muck about with the block |
475 | lists because they're not ready yet, and don't actually | 558 | lists because they're not ready yet, and don't actually |
476 | obliterate nodes that look obsolete. If they weren't | 559 | obliterate nodes that look obsolete. If they weren't |
477 | marked obsolete on the flash at the time they _became_ | 560 | marked obsolete on the flash at the time they _became_ |
478 | obsolete, there was probably a reason for that. */ | 561 | obsolete, there was probably a reason for that. */ |
479 | spin_unlock(&c->erase_completion_lock); | 562 | spin_unlock(&c->erase_completion_lock); |
@@ -507,7 +590,7 @@ void jffs2_mark_node_obsolete(struct jffs2_sb_info *c, struct jffs2_raw_node_ref | |||
507 | immediately reused, and we spread the load a bit. */ | 590 | immediately reused, and we spread the load a bit. */ |
508 | D1(printk(KERN_DEBUG "...and adding to erasable_list\n")); | 591 | D1(printk(KERN_DEBUG "...and adding to erasable_list\n")); |
509 | list_add_tail(&jeb->list, &c->erasable_list); | 592 | list_add_tail(&jeb->list, &c->erasable_list); |
510 | } | 593 | } |
511 | } | 594 | } |
512 | D1(printk(KERN_DEBUG "Done OK\n")); | 595 | D1(printk(KERN_DEBUG "Done OK\n")); |
513 | } else if (jeb == c->gcblock) { | 596 | } else if (jeb == c->gcblock) { |
@@ -525,8 +608,8 @@ void jffs2_mark_node_obsolete(struct jffs2_sb_info *c, struct jffs2_raw_node_ref | |||
525 | list_add_tail(&jeb->list, &c->very_dirty_list); | 608 | list_add_tail(&jeb->list, &c->very_dirty_list); |
526 | } else { | 609 | } else { |
527 | D1(printk(KERN_DEBUG "Eraseblock at 0x%08x not moved anywhere. (free 0x%08x, dirty 0x%08x, used 0x%08x)\n", | 610 | D1(printk(KERN_DEBUG "Eraseblock at 0x%08x not moved anywhere. (free 0x%08x, dirty 0x%08x, used 0x%08x)\n", |
528 | jeb->offset, jeb->free_size, jeb->dirty_size, jeb->used_size)); | 611 | jeb->offset, jeb->free_size, jeb->dirty_size, jeb->used_size)); |
529 | } | 612 | } |
530 | 613 | ||
531 | spin_unlock(&c->erase_completion_lock); | 614 | spin_unlock(&c->erase_completion_lock); |
532 | 615 | ||
@@ -573,11 +656,11 @@ void jffs2_mark_node_obsolete(struct jffs2_sb_info *c, struct jffs2_raw_node_ref | |||
573 | 656 | ||
574 | /* Nodes which have been marked obsolete no longer need to be | 657 | /* Nodes which have been marked obsolete no longer need to be |
575 | associated with any inode. Remove them from the per-inode list. | 658 | associated with any inode. Remove them from the per-inode list. |
576 | 659 | ||
577 | Note we can't do this for NAND at the moment because we need | 660 | Note we can't do this for NAND at the moment because we need |
578 | obsolete dirent nodes to stay on the lists, because of the | 661 | obsolete dirent nodes to stay on the lists, because of the |
579 | horridness in jffs2_garbage_collect_deletion_dirent(). Also | 662 | horridness in jffs2_garbage_collect_deletion_dirent(). Also |
580 | because we delete the inocache, and on NAND we need that to | 663 | because we delete the inocache, and on NAND we need that to |
581 | stay around until all the nodes are actually erased, in order | 664 | stay around until all the nodes are actually erased, in order |
582 | to stop us from giving the same inode number to another newly | 665 | to stop us from giving the same inode number to another newly |
583 | created inode. */ | 666 | created inode. */ |
@@ -606,7 +689,7 @@ void jffs2_mark_node_obsolete(struct jffs2_sb_info *c, struct jffs2_raw_node_ref | |||
606 | if (ref->next_phys && ref_obsolete(ref->next_phys) && | 689 | if (ref->next_phys && ref_obsolete(ref->next_phys) && |
607 | !ref->next_phys->next_in_ino) { | 690 | !ref->next_phys->next_in_ino) { |
608 | struct jffs2_raw_node_ref *n = ref->next_phys; | 691 | struct jffs2_raw_node_ref *n = ref->next_phys; |
609 | 692 | ||
610 | spin_lock(&c->erase_completion_lock); | 693 | spin_lock(&c->erase_completion_lock); |
611 | 694 | ||
612 | ref->__totlen += n->__totlen; | 695 | ref->__totlen += n->__totlen; |
@@ -620,7 +703,7 @@ void jffs2_mark_node_obsolete(struct jffs2_sb_info *c, struct jffs2_raw_node_ref | |||
620 | 703 | ||
621 | jffs2_free_raw_node_ref(n); | 704 | jffs2_free_raw_node_ref(n); |
622 | } | 705 | } |
623 | 706 | ||
624 | /* Also merge with the previous node in the list, if there is one | 707 | /* Also merge with the previous node in the list, if there is one |
625 | and that one is obsolete */ | 708 | and that one is obsolete */ |
626 | if (ref != jeb->first_node ) { | 709 | if (ref != jeb->first_node ) { |
@@ -630,7 +713,7 @@ void jffs2_mark_node_obsolete(struct jffs2_sb_info *c, struct jffs2_raw_node_ref | |||
630 | 713 | ||
631 | while (p->next_phys != ref) | 714 | while (p->next_phys != ref) |
632 | p = p->next_phys; | 715 | p = p->next_phys; |
633 | 716 | ||
634 | if (ref_obsolete(p) && !ref->next_in_ino) { | 717 | if (ref_obsolete(p) && !ref->next_in_ino) { |
635 | p->__totlen += ref->__totlen; | 718 | p->__totlen += ref->__totlen; |
636 | if (jeb->last_node == ref) { | 719 | if (jeb->last_node == ref) { |
@@ -649,164 +732,6 @@ void jffs2_mark_node_obsolete(struct jffs2_sb_info *c, struct jffs2_raw_node_ref | |||
649 | up(&c->erase_free_sem); | 732 | up(&c->erase_free_sem); |
650 | } | 733 | } |
651 | 734 | ||
652 | #if CONFIG_JFFS2_FS_DEBUG >= 2 | ||
653 | void jffs2_dump_block_lists(struct jffs2_sb_info *c) | ||
654 | { | ||
655 | |||
656 | |||
657 | printk(KERN_DEBUG "jffs2_dump_block_lists:\n"); | ||
658 | printk(KERN_DEBUG "flash_size: %08x\n", c->flash_size); | ||
659 | printk(KERN_DEBUG "used_size: %08x\n", c->used_size); | ||
660 | printk(KERN_DEBUG "dirty_size: %08x\n", c->dirty_size); | ||
661 | printk(KERN_DEBUG "wasted_size: %08x\n", c->wasted_size); | ||
662 | printk(KERN_DEBUG "unchecked_size: %08x\n", c->unchecked_size); | ||
663 | printk(KERN_DEBUG "free_size: %08x\n", c->free_size); | ||
664 | printk(KERN_DEBUG "erasing_size: %08x\n", c->erasing_size); | ||
665 | printk(KERN_DEBUG "bad_size: %08x\n", c->bad_size); | ||
666 | printk(KERN_DEBUG "sector_size: %08x\n", c->sector_size); | ||
667 | printk(KERN_DEBUG "jffs2_reserved_blocks size: %08x\n",c->sector_size * c->resv_blocks_write); | ||
668 | |||
669 | if (c->nextblock) { | ||
670 | printk(KERN_DEBUG "nextblock: %08x (used %08x, dirty %08x, wasted %08x, unchecked %08x, free %08x)\n", | ||
671 | c->nextblock->offset, c->nextblock->used_size, c->nextblock->dirty_size, c->nextblock->wasted_size, c->nextblock->unchecked_size, c->nextblock->free_size); | ||
672 | } else { | ||
673 | printk(KERN_DEBUG "nextblock: NULL\n"); | ||
674 | } | ||
675 | if (c->gcblock) { | ||
676 | printk(KERN_DEBUG "gcblock: %08x (used %08x, dirty %08x, wasted %08x, unchecked %08x, free %08x)\n", | ||
677 | c->gcblock->offset, c->gcblock->used_size, c->gcblock->dirty_size, c->gcblock->wasted_size, c->gcblock->unchecked_size, c->gcblock->free_size); | ||
678 | } else { | ||
679 | printk(KERN_DEBUG "gcblock: NULL\n"); | ||
680 | } | ||
681 | if (list_empty(&c->clean_list)) { | ||
682 | printk(KERN_DEBUG "clean_list: empty\n"); | ||
683 | } else { | ||
684 | struct list_head *this; | ||
685 | int numblocks = 0; | ||
686 | uint32_t dirty = 0; | ||
687 | |||
688 | list_for_each(this, &c->clean_list) { | ||
689 | struct jffs2_eraseblock *jeb = list_entry(this, struct jffs2_eraseblock, list); | ||
690 | numblocks ++; | ||
691 | dirty += jeb->wasted_size; | ||
692 | printk(KERN_DEBUG "clean_list: %08x (used %08x, dirty %08x, wasted %08x, unchecked %08x, free %08x)\n", jeb->offset, jeb->used_size, jeb->dirty_size, jeb->wasted_size, jeb->unchecked_size, jeb->free_size); | ||
693 | } | ||
694 | printk (KERN_DEBUG "Contains %d blocks with total wasted size %u, average wasted size: %u\n", numblocks, dirty, dirty / numblocks); | ||
695 | } | ||
696 | if (list_empty(&c->very_dirty_list)) { | ||
697 | printk(KERN_DEBUG "very_dirty_list: empty\n"); | ||
698 | } else { | ||
699 | struct list_head *this; | ||
700 | int numblocks = 0; | ||
701 | uint32_t dirty = 0; | ||
702 | |||
703 | list_for_each(this, &c->very_dirty_list) { | ||
704 | struct jffs2_eraseblock *jeb = list_entry(this, struct jffs2_eraseblock, list); | ||
705 | numblocks ++; | ||
706 | dirty += jeb->dirty_size; | ||
707 | printk(KERN_DEBUG "very_dirty_list: %08x (used %08x, dirty %08x, wasted %08x, unchecked %08x, free %08x)\n", | ||
708 | jeb->offset, jeb->used_size, jeb->dirty_size, jeb->wasted_size, jeb->unchecked_size, jeb->free_size); | ||
709 | } | ||
710 | printk (KERN_DEBUG "Contains %d blocks with total dirty size %u, average dirty size: %u\n", | ||
711 | numblocks, dirty, dirty / numblocks); | ||
712 | } | ||
713 | if (list_empty(&c->dirty_list)) { | ||
714 | printk(KERN_DEBUG "dirty_list: empty\n"); | ||
715 | } else { | ||
716 | struct list_head *this; | ||
717 | int numblocks = 0; | ||
718 | uint32_t dirty = 0; | ||
719 | |||
720 | list_for_each(this, &c->dirty_list) { | ||
721 | struct jffs2_eraseblock *jeb = list_entry(this, struct jffs2_eraseblock, list); | ||
722 | numblocks ++; | ||
723 | dirty += jeb->dirty_size; | ||
724 | printk(KERN_DEBUG "dirty_list: %08x (used %08x, dirty %08x, wasted %08x, unchecked %08x, free %08x)\n", | ||
725 | jeb->offset, jeb->used_size, jeb->dirty_size, jeb->wasted_size, jeb->unchecked_size, jeb->free_size); | ||
726 | } | ||
727 | printk (KERN_DEBUG "Contains %d blocks with total dirty size %u, average dirty size: %u\n", | ||
728 | numblocks, dirty, dirty / numblocks); | ||
729 | } | ||
730 | if (list_empty(&c->erasable_list)) { | ||
731 | printk(KERN_DEBUG "erasable_list: empty\n"); | ||
732 | } else { | ||
733 | struct list_head *this; | ||
734 | |||
735 | list_for_each(this, &c->erasable_list) { | ||
736 | struct jffs2_eraseblock *jeb = list_entry(this, struct jffs2_eraseblock, list); | ||
737 | printk(KERN_DEBUG "erasable_list: %08x (used %08x, dirty %08x, wasted %08x, unchecked %08x, free %08x)\n", | ||
738 | jeb->offset, jeb->used_size, jeb->dirty_size, jeb->wasted_size, jeb->unchecked_size, jeb->free_size); | ||
739 | } | ||
740 | } | ||
741 | if (list_empty(&c->erasing_list)) { | ||
742 | printk(KERN_DEBUG "erasing_list: empty\n"); | ||
743 | } else { | ||
744 | struct list_head *this; | ||
745 | |||
746 | list_for_each(this, &c->erasing_list) { | ||
747 | struct jffs2_eraseblock *jeb = list_entry(this, struct jffs2_eraseblock, list); | ||
748 | printk(KERN_DEBUG "erasing_list: %08x (used %08x, dirty %08x, wasted %08x, unchecked %08x, free %08x)\n", | ||
749 | jeb->offset, jeb->used_size, jeb->dirty_size, jeb->wasted_size, jeb->unchecked_size, jeb->free_size); | ||
750 | } | ||
751 | } | ||
752 | if (list_empty(&c->erase_pending_list)) { | ||
753 | printk(KERN_DEBUG "erase_pending_list: empty\n"); | ||
754 | } else { | ||
755 | struct list_head *this; | ||
756 | |||
757 | list_for_each(this, &c->erase_pending_list) { | ||
758 | struct jffs2_eraseblock *jeb = list_entry(this, struct jffs2_eraseblock, list); | ||
759 | printk(KERN_DEBUG "erase_pending_list: %08x (used %08x, dirty %08x, wasted %08x, unchecked %08x, free %08x)\n", | ||
760 | jeb->offset, jeb->used_size, jeb->dirty_size, jeb->wasted_size, jeb->unchecked_size, jeb->free_size); | ||
761 | } | ||
762 | } | ||
763 | if (list_empty(&c->erasable_pending_wbuf_list)) { | ||
764 | printk(KERN_DEBUG "erasable_pending_wbuf_list: empty\n"); | ||
765 | } else { | ||
766 | struct list_head *this; | ||
767 | |||
768 | list_for_each(this, &c->erasable_pending_wbuf_list) { | ||
769 | struct jffs2_eraseblock *jeb = list_entry(this, struct jffs2_eraseblock, list); | ||
770 | printk(KERN_DEBUG "erasable_pending_wbuf_list: %08x (used %08x, dirty %08x, wasted %08x, unchecked %08x, free %08x)\n", | ||
771 | jeb->offset, jeb->used_size, jeb->dirty_size, jeb->wasted_size, jeb->unchecked_size, jeb->free_size); | ||
772 | } | ||
773 | } | ||
774 | if (list_empty(&c->free_list)) { | ||
775 | printk(KERN_DEBUG "free_list: empty\n"); | ||
776 | } else { | ||
777 | struct list_head *this; | ||
778 | |||
779 | list_for_each(this, &c->free_list) { | ||
780 | struct jffs2_eraseblock *jeb = list_entry(this, struct jffs2_eraseblock, list); | ||
781 | printk(KERN_DEBUG "free_list: %08x (used %08x, dirty %08x, wasted %08x, unchecked %08x, free %08x)\n", | ||
782 | jeb->offset, jeb->used_size, jeb->dirty_size, jeb->wasted_size, jeb->unchecked_size, jeb->free_size); | ||
783 | } | ||
784 | } | ||
785 | if (list_empty(&c->bad_list)) { | ||
786 | printk(KERN_DEBUG "bad_list: empty\n"); | ||
787 | } else { | ||
788 | struct list_head *this; | ||
789 | |||
790 | list_for_each(this, &c->bad_list) { | ||
791 | struct jffs2_eraseblock *jeb = list_entry(this, struct jffs2_eraseblock, list); | ||
792 | printk(KERN_DEBUG "bad_list: %08x (used %08x, dirty %08x, wasted %08x, unchecked %08x, free %08x)\n", | ||
793 | jeb->offset, jeb->used_size, jeb->dirty_size, jeb->wasted_size, jeb->unchecked_size, jeb->free_size); | ||
794 | } | ||
795 | } | ||
796 | if (list_empty(&c->bad_used_list)) { | ||
797 | printk(KERN_DEBUG "bad_used_list: empty\n"); | ||
798 | } else { | ||
799 | struct list_head *this; | ||
800 | |||
801 | list_for_each(this, &c->bad_used_list) { | ||
802 | struct jffs2_eraseblock *jeb = list_entry(this, struct jffs2_eraseblock, list); | ||
803 | printk(KERN_DEBUG "bad_used_list: %08x (used %08x, dirty %08x, wasted %08x, unchecked %08x, free %08x)\n", | ||
804 | jeb->offset, jeb->used_size, jeb->dirty_size, jeb->wasted_size, jeb->unchecked_size, jeb->free_size); | ||
805 | } | ||
806 | } | ||
807 | } | ||
808 | #endif /* CONFIG_JFFS2_FS_DEBUG */ | ||
809 | |||
810 | int jffs2_thread_should_wake(struct jffs2_sb_info *c) | 735 | int jffs2_thread_should_wake(struct jffs2_sb_info *c) |
811 | { | 736 | { |
812 | int ret = 0; | 737 | int ret = 0; |
@@ -828,11 +753,11 @@ int jffs2_thread_should_wake(struct jffs2_sb_info *c) | |||
828 | */ | 753 | */ |
829 | dirty = c->dirty_size + c->erasing_size - c->nr_erasing_blocks * c->sector_size; | 754 | dirty = c->dirty_size + c->erasing_size - c->nr_erasing_blocks * c->sector_size; |
830 | 755 | ||
831 | if (c->nr_free_blocks + c->nr_erasing_blocks < c->resv_blocks_gctrigger && | 756 | if (c->nr_free_blocks + c->nr_erasing_blocks < c->resv_blocks_gctrigger && |
832 | (dirty > c->nospc_dirty_size)) | 757 | (dirty > c->nospc_dirty_size)) |
833 | ret = 1; | 758 | ret = 1; |
834 | 759 | ||
835 | D1(printk(KERN_DEBUG "jffs2_thread_should_wake(): nr_free_blocks %d, nr_erasing_blocks %d, dirty_size 0x%x: %s\n", | 760 | D1(printk(KERN_DEBUG "jffs2_thread_should_wake(): nr_free_blocks %d, nr_erasing_blocks %d, dirty_size 0x%x: %s\n", |
836 | c->nr_free_blocks, c->nr_erasing_blocks, c->dirty_size, ret?"yes":"no")); | 761 | c->nr_free_blocks, c->nr_erasing_blocks, c->dirty_size, ret?"yes":"no")); |
837 | 762 | ||
838 | return ret; | 763 | return ret; |
diff --git a/fs/jffs2/os-linux.h b/fs/jffs2/os-linux.h index d900c8929b09..59e7a393200c 100644 --- a/fs/jffs2/os-linux.h +++ b/fs/jffs2/os-linux.h | |||
@@ -7,7 +7,7 @@ | |||
7 | * | 7 | * |
8 | * For licensing information, see the file 'LICENCE' in this directory. | 8 | * For licensing information, see the file 'LICENCE' in this directory. |
9 | * | 9 | * |
10 | * $Id: os-linux.h,v 1.58 2005/07/12 02:34:35 tpoynor Exp $ | 10 | * $Id: os-linux.h,v 1.64 2005/09/30 13:59:13 dedekind Exp $ |
11 | * | 11 | * |
12 | */ | 12 | */ |
13 | 13 | ||
@@ -57,6 +57,7 @@ static inline void jffs2_init_inode_info(struct jffs2_inode_info *f) | |||
57 | f->fragtree = RB_ROOT; | 57 | f->fragtree = RB_ROOT; |
58 | f->metadata = NULL; | 58 | f->metadata = NULL; |
59 | f->dents = NULL; | 59 | f->dents = NULL; |
60 | f->target = NULL; | ||
60 | f->flags = 0; | 61 | f->flags = 0; |
61 | f->usercompr = 0; | 62 | f->usercompr = 0; |
62 | } | 63 | } |
@@ -64,17 +65,24 @@ static inline void jffs2_init_inode_info(struct jffs2_inode_info *f) | |||
64 | 65 | ||
65 | #define jffs2_is_readonly(c) (OFNI_BS_2SFFJ(c)->s_flags & MS_RDONLY) | 66 | #define jffs2_is_readonly(c) (OFNI_BS_2SFFJ(c)->s_flags & MS_RDONLY) |
66 | 67 | ||
68 | #define SECTOR_ADDR(x) ( (((unsigned long)(x) / c->sector_size) * c->sector_size) ) | ||
67 | #ifndef CONFIG_JFFS2_FS_WRITEBUFFER | 69 | #ifndef CONFIG_JFFS2_FS_WRITEBUFFER |
68 | #define SECTOR_ADDR(x) ( ((unsigned long)(x) & ~(c->sector_size-1)) ) | 70 | |
71 | |||
72 | #ifdef CONFIG_JFFS2_SUMMARY | ||
73 | #define jffs2_can_mark_obsolete(c) (0) | ||
74 | #else | ||
69 | #define jffs2_can_mark_obsolete(c) (1) | 75 | #define jffs2_can_mark_obsolete(c) (1) |
76 | #endif | ||
77 | |||
70 | #define jffs2_is_writebuffered(c) (0) | 78 | #define jffs2_is_writebuffered(c) (0) |
71 | #define jffs2_cleanmarker_oob(c) (0) | 79 | #define jffs2_cleanmarker_oob(c) (0) |
72 | #define jffs2_write_nand_cleanmarker(c,jeb) (-EIO) | 80 | #define jffs2_write_nand_cleanmarker(c,jeb) (-EIO) |
73 | 81 | ||
74 | #define jffs2_flash_write(c, ofs, len, retlen, buf) ((c)->mtd->write((c)->mtd, ofs, len, retlen, buf)) | 82 | #define jffs2_flash_write(c, ofs, len, retlen, buf) jffs2_flash_direct_write(c, ofs, len, retlen, buf) |
75 | #define jffs2_flash_read(c, ofs, len, retlen, buf) ((c)->mtd->read((c)->mtd, ofs, len, retlen, buf)) | 83 | #define jffs2_flash_read(c, ofs, len, retlen, buf) ((c)->mtd->read((c)->mtd, ofs, len, retlen, buf)) |
76 | #define jffs2_flush_wbuf_pad(c) ({ (void)(c), 0; }) | 84 | #define jffs2_flush_wbuf_pad(c) ({ do{} while(0); (void)(c), 0; }) |
77 | #define jffs2_flush_wbuf_gc(c, i) ({ (void)(c), (void) i, 0; }) | 85 | #define jffs2_flush_wbuf_gc(c, i) ({ do{} while(0); (void)(c), (void) i, 0; }) |
78 | #define jffs2_write_nand_badblock(c,jeb,bad_offset) (1) | 86 | #define jffs2_write_nand_badblock(c,jeb,bad_offset) (1) |
79 | #define jffs2_nand_flash_setup(c) (0) | 87 | #define jffs2_nand_flash_setup(c) (0) |
80 | #define jffs2_nand_flash_cleanup(c) do {} while(0) | 88 | #define jffs2_nand_flash_cleanup(c) do {} while(0) |
@@ -84,16 +92,26 @@ static inline void jffs2_init_inode_info(struct jffs2_inode_info *f) | |||
84 | #define jffs2_wbuf_process NULL | 92 | #define jffs2_wbuf_process NULL |
85 | #define jffs2_nor_ecc(c) (0) | 93 | #define jffs2_nor_ecc(c) (0) |
86 | #define jffs2_dataflash(c) (0) | 94 | #define jffs2_dataflash(c) (0) |
95 | #define jffs2_nor_wbuf_flash(c) (0) | ||
87 | #define jffs2_nor_ecc_flash_setup(c) (0) | 96 | #define jffs2_nor_ecc_flash_setup(c) (0) |
88 | #define jffs2_nor_ecc_flash_cleanup(c) do {} while (0) | 97 | #define jffs2_nor_ecc_flash_cleanup(c) do {} while (0) |
89 | #define jffs2_dataflash_setup(c) (0) | 98 | #define jffs2_dataflash_setup(c) (0) |
90 | #define jffs2_dataflash_cleanup(c) do {} while (0) | 99 | #define jffs2_dataflash_cleanup(c) do {} while (0) |
100 | #define jffs2_nor_wbuf_flash_setup(c) (0) | ||
101 | #define jffs2_nor_wbuf_flash_cleanup(c) do {} while (0) | ||
91 | 102 | ||
92 | #else /* NAND and/or ECC'd NOR support present */ | 103 | #else /* NAND and/or ECC'd NOR support present */ |
93 | 104 | ||
94 | #define jffs2_is_writebuffered(c) (c->wbuf != NULL) | 105 | #define jffs2_is_writebuffered(c) (c->wbuf != NULL) |
95 | #define SECTOR_ADDR(x) ( ((unsigned long)(x) / (unsigned long)(c->sector_size)) * c->sector_size ) | 106 | |
96 | #define jffs2_can_mark_obsolete(c) ((c->mtd->type == MTD_NORFLASH && !(c->mtd->flags & MTD_ECC)) || c->mtd->type == MTD_RAM) | 107 | #ifdef CONFIG_JFFS2_SUMMARY |
108 | #define jffs2_can_mark_obsolete(c) (0) | ||
109 | #else | ||
110 | #define jffs2_can_mark_obsolete(c) \ | ||
111 | ((c->mtd->type == MTD_NORFLASH && !(c->mtd->flags & (MTD_ECC|MTD_PROGRAM_REGIONS))) || \ | ||
112 | c->mtd->type == MTD_RAM) | ||
113 | #endif | ||
114 | |||
97 | #define jffs2_cleanmarker_oob(c) (c->mtd->type == MTD_NANDFLASH) | 115 | #define jffs2_cleanmarker_oob(c) (c->mtd->type == MTD_NANDFLASH) |
98 | 116 | ||
99 | #define jffs2_flash_write_oob(c, ofs, len, retlen, buf) ((c)->mtd->write_oob((c)->mtd, ofs, len, retlen, buf)) | 117 | #define jffs2_flash_write_oob(c, ofs, len, retlen, buf) ((c)->mtd->write_oob((c)->mtd, ofs, len, retlen, buf)) |
@@ -123,6 +141,10 @@ void jffs2_nor_ecc_flash_cleanup(struct jffs2_sb_info *c); | |||
123 | int jffs2_dataflash_setup(struct jffs2_sb_info *c); | 141 | int jffs2_dataflash_setup(struct jffs2_sb_info *c); |
124 | void jffs2_dataflash_cleanup(struct jffs2_sb_info *c); | 142 | void jffs2_dataflash_cleanup(struct jffs2_sb_info *c); |
125 | 143 | ||
144 | #define jffs2_nor_wbuf_flash(c) (c->mtd->type == MTD_NORFLASH && (c->mtd->flags & MTD_PROGRAM_REGIONS)) | ||
145 | int jffs2_nor_wbuf_flash_setup(struct jffs2_sb_info *c); | ||
146 | void jffs2_nor_wbuf_flash_cleanup(struct jffs2_sb_info *c); | ||
147 | |||
126 | #endif /* WRITEBUFFER */ | 148 | #endif /* WRITEBUFFER */ |
127 | 149 | ||
128 | /* erase.c */ | 150 | /* erase.c */ |
@@ -169,20 +191,21 @@ void jffs2_gc_release_inode(struct jffs2_sb_info *c, | |||
169 | struct jffs2_inode_info *jffs2_gc_fetch_inode(struct jffs2_sb_info *c, | 191 | struct jffs2_inode_info *jffs2_gc_fetch_inode(struct jffs2_sb_info *c, |
170 | int inum, int nlink); | 192 | int inum, int nlink); |
171 | 193 | ||
172 | unsigned char *jffs2_gc_fetch_page(struct jffs2_sb_info *c, | 194 | unsigned char *jffs2_gc_fetch_page(struct jffs2_sb_info *c, |
173 | struct jffs2_inode_info *f, | 195 | struct jffs2_inode_info *f, |
174 | unsigned long offset, | 196 | unsigned long offset, |
175 | unsigned long *priv); | 197 | unsigned long *priv); |
176 | void jffs2_gc_release_page(struct jffs2_sb_info *c, | 198 | void jffs2_gc_release_page(struct jffs2_sb_info *c, |
177 | unsigned char *pg, | 199 | unsigned char *pg, |
178 | unsigned long *priv); | 200 | unsigned long *priv); |
179 | void jffs2_flash_cleanup(struct jffs2_sb_info *c); | 201 | void jffs2_flash_cleanup(struct jffs2_sb_info *c); |
180 | 202 | ||
181 | 203 | ||
182 | /* writev.c */ | 204 | /* writev.c */ |
183 | int jffs2_flash_direct_writev(struct jffs2_sb_info *c, const struct kvec *vecs, | 205 | int jffs2_flash_direct_writev(struct jffs2_sb_info *c, const struct kvec *vecs, |
184 | unsigned long count, loff_t to, size_t *retlen); | 206 | unsigned long count, loff_t to, size_t *retlen); |
185 | 207 | int jffs2_flash_direct_write(struct jffs2_sb_info *c, loff_t ofs, size_t len, | |
208 | size_t *retlen, const u_char *buf); | ||
186 | 209 | ||
187 | #endif /* __JFFS2_OS_LINUX_H__ */ | 210 | #endif /* __JFFS2_OS_LINUX_H__ */ |
188 | 211 | ||
diff --git a/fs/jffs2/read.c b/fs/jffs2/read.c index c7f9068907cf..f3b86da833ba 100644 --- a/fs/jffs2/read.c +++ b/fs/jffs2/read.c | |||
@@ -7,7 +7,7 @@ | |||
7 | * | 7 | * |
8 | * For licensing information, see the file 'LICENCE' in this directory. | 8 | * For licensing information, see the file 'LICENCE' in this directory. |
9 | * | 9 | * |
10 | * $Id: read.c,v 1.39 2005/03/01 10:34:03 dedekind Exp $ | 10 | * $Id: read.c,v 1.42 2005/11/07 11:14:41 gleixner Exp $ |
11 | * | 11 | * |
12 | */ | 12 | */ |
13 | 13 | ||
@@ -43,7 +43,7 @@ int jffs2_read_dnode(struct jffs2_sb_info *c, struct jffs2_inode_info *f, | |||
43 | } | 43 | } |
44 | if (readlen != sizeof(*ri)) { | 44 | if (readlen != sizeof(*ri)) { |
45 | jffs2_free_raw_inode(ri); | 45 | jffs2_free_raw_inode(ri); |
46 | printk(KERN_WARNING "Short read from 0x%08x: wanted 0x%zx bytes, got 0x%zx\n", | 46 | printk(KERN_WARNING "Short read from 0x%08x: wanted 0x%zx bytes, got 0x%zx\n", |
47 | ref_offset(fd->raw), sizeof(*ri), readlen); | 47 | ref_offset(fd->raw), sizeof(*ri), readlen); |
48 | return -EIO; | 48 | return -EIO; |
49 | } | 49 | } |
@@ -61,7 +61,7 @@ int jffs2_read_dnode(struct jffs2_sb_info *c, struct jffs2_inode_info *f, | |||
61 | } | 61 | } |
62 | /* There was a bug where we wrote hole nodes out with csize/dsize | 62 | /* There was a bug where we wrote hole nodes out with csize/dsize |
63 | swapped. Deal with it */ | 63 | swapped. Deal with it */ |
64 | if (ri->compr == JFFS2_COMPR_ZERO && !je32_to_cpu(ri->dsize) && | 64 | if (ri->compr == JFFS2_COMPR_ZERO && !je32_to_cpu(ri->dsize) && |
65 | je32_to_cpu(ri->csize)) { | 65 | je32_to_cpu(ri->csize)) { |
66 | ri->dsize = ri->csize; | 66 | ri->dsize = ri->csize; |
67 | ri->csize = cpu_to_je32(0); | 67 | ri->csize = cpu_to_je32(0); |
@@ -74,7 +74,7 @@ int jffs2_read_dnode(struct jffs2_sb_info *c, struct jffs2_inode_info *f, | |||
74 | goto out_ri; | 74 | goto out_ri; |
75 | }); | 75 | }); |
76 | 76 | ||
77 | 77 | ||
78 | if (ri->compr == JFFS2_COMPR_ZERO) { | 78 | if (ri->compr == JFFS2_COMPR_ZERO) { |
79 | memset(buf, 0, len); | 79 | memset(buf, 0, len); |
80 | goto out_ri; | 80 | goto out_ri; |
@@ -82,8 +82,8 @@ int jffs2_read_dnode(struct jffs2_sb_info *c, struct jffs2_inode_info *f, | |||
82 | 82 | ||
83 | /* Cases: | 83 | /* Cases: |
84 | Reading whole node and it's uncompressed - read directly to buffer provided, check CRC. | 84 | Reading whole node and it's uncompressed - read directly to buffer provided, check CRC. |
85 | Reading whole node and it's compressed - read into comprbuf, check CRC and decompress to buffer provided | 85 | Reading whole node and it's compressed - read into comprbuf, check CRC and decompress to buffer provided |
86 | Reading partial node and it's uncompressed - read into readbuf, check CRC, and copy | 86 | Reading partial node and it's uncompressed - read into readbuf, check CRC, and copy |
87 | Reading partial node and it's compressed - read into readbuf, check checksum, decompress to decomprbuf and copy | 87 | Reading partial node and it's compressed - read into readbuf, check checksum, decompress to decomprbuf and copy |
88 | */ | 88 | */ |
89 | if (ri->compr == JFFS2_COMPR_NONE && len == je32_to_cpu(ri->dsize)) { | 89 | if (ri->compr == JFFS2_COMPR_NONE && len == je32_to_cpu(ri->dsize)) { |
@@ -129,7 +129,7 @@ int jffs2_read_dnode(struct jffs2_sb_info *c, struct jffs2_inode_info *f, | |||
129 | D2(printk(KERN_DEBUG "Data CRC matches calculated CRC %08x\n", crc)); | 129 | D2(printk(KERN_DEBUG "Data CRC matches calculated CRC %08x\n", crc)); |
130 | if (ri->compr != JFFS2_COMPR_NONE) { | 130 | if (ri->compr != JFFS2_COMPR_NONE) { |
131 | D2(printk(KERN_DEBUG "Decompress %d bytes from %p to %d bytes at %p\n", | 131 | D2(printk(KERN_DEBUG "Decompress %d bytes from %p to %d bytes at %p\n", |
132 | je32_to_cpu(ri->csize), readbuf, je32_to_cpu(ri->dsize), decomprbuf)); | 132 | je32_to_cpu(ri->csize), readbuf, je32_to_cpu(ri->dsize), decomprbuf)); |
133 | ret = jffs2_decompress(c, f, ri->compr | (ri->usercompr << 8), readbuf, decomprbuf, je32_to_cpu(ri->csize), je32_to_cpu(ri->dsize)); | 133 | ret = jffs2_decompress(c, f, ri->compr | (ri->usercompr << 8), readbuf, decomprbuf, je32_to_cpu(ri->csize), je32_to_cpu(ri->dsize)); |
134 | if (ret) { | 134 | if (ret) { |
135 | printk(KERN_WARNING "Error: jffs2_decompress returned %d\n", ret); | 135 | printk(KERN_WARNING "Error: jffs2_decompress returned %d\n", ret); |
@@ -174,7 +174,6 @@ int jffs2_read_inode_range(struct jffs2_sb_info *c, struct jffs2_inode_info *f, | |||
174 | if (frag) { | 174 | if (frag) { |
175 | D1(printk(KERN_NOTICE "Eep. Hole in ino #%u fraglist. frag->ofs = 0x%08x, offset = 0x%08x\n", f->inocache->ino, frag->ofs, offset)); | 175 | D1(printk(KERN_NOTICE "Eep. Hole in ino #%u fraglist. frag->ofs = 0x%08x, offset = 0x%08x\n", f->inocache->ino, frag->ofs, offset)); |
176 | holesize = min(holesize, frag->ofs - offset); | 176 | holesize = min(holesize, frag->ofs - offset); |
177 | D2(jffs2_print_frag_list(f)); | ||
178 | } | 177 | } |
179 | D1(printk(KERN_DEBUG "Filling non-frag hole from %d-%d\n", offset, offset+holesize)); | 178 | D1(printk(KERN_DEBUG "Filling non-frag hole from %d-%d\n", offset, offset+holesize)); |
180 | memset(buf, 0, holesize); | 179 | memset(buf, 0, holesize); |
@@ -192,7 +191,7 @@ int jffs2_read_inode_range(struct jffs2_sb_info *c, struct jffs2_inode_info *f, | |||
192 | } else { | 191 | } else { |
193 | uint32_t readlen; | 192 | uint32_t readlen; |
194 | uint32_t fragofs; /* offset within the frag to start reading */ | 193 | uint32_t fragofs; /* offset within the frag to start reading */ |
195 | 194 | ||
196 | fragofs = offset - frag->ofs; | 195 | fragofs = offset - frag->ofs; |
197 | readlen = min(frag->size - fragofs, end - offset); | 196 | readlen = min(frag->size - fragofs, end - offset); |
198 | D1(printk(KERN_DEBUG "Reading %d-%d from node at 0x%08x (%d)\n", | 197 | D1(printk(KERN_DEBUG "Reading %d-%d from node at 0x%08x (%d)\n", |
diff --git a/fs/jffs2/readinode.c b/fs/jffs2/readinode.c index 5b2a83599d73..5f0652df5d47 100644 --- a/fs/jffs2/readinode.c +++ b/fs/jffs2/readinode.c | |||
@@ -7,11 +7,12 @@ | |||
7 | * | 7 | * |
8 | * For licensing information, see the file 'LICENCE' in this directory. | 8 | * For licensing information, see the file 'LICENCE' in this directory. |
9 | * | 9 | * |
10 | * $Id: readinode.c,v 1.125 2005/07/10 13:13:55 dedekind Exp $ | 10 | * $Id: readinode.c,v 1.143 2005/11/07 11:14:41 gleixner Exp $ |
11 | * | 11 | * |
12 | */ | 12 | */ |
13 | 13 | ||
14 | #include <linux/kernel.h> | 14 | #include <linux/kernel.h> |
15 | #include <linux/sched.h> | ||
15 | #include <linux/slab.h> | 16 | #include <linux/slab.h> |
16 | #include <linux/fs.h> | 17 | #include <linux/fs.h> |
17 | #include <linux/crc32.h> | 18 | #include <linux/crc32.h> |
@@ -20,502 +21,631 @@ | |||
20 | #include <linux/compiler.h> | 21 | #include <linux/compiler.h> |
21 | #include "nodelist.h" | 22 | #include "nodelist.h" |
22 | 23 | ||
23 | static int jffs2_add_frag_to_fragtree(struct jffs2_sb_info *c, struct rb_root *list, struct jffs2_node_frag *newfrag); | 24 | /* |
24 | 25 | * Put a new tmp_dnode_info into the temporaty RB-tree, keeping the list in | |
25 | #if CONFIG_JFFS2_FS_DEBUG >= 2 | 26 | * order of increasing version. |
26 | static void jffs2_print_fragtree(struct rb_root *list, int permitbug) | 27 | */ |
28 | static void jffs2_add_tn_to_tree(struct jffs2_tmp_dnode_info *tn, struct rb_root *list) | ||
27 | { | 29 | { |
28 | struct jffs2_node_frag *this = frag_first(list); | 30 | struct rb_node **p = &list->rb_node; |
29 | uint32_t lastofs = 0; | 31 | struct rb_node * parent = NULL; |
30 | int buggy = 0; | 32 | struct jffs2_tmp_dnode_info *this; |
31 | 33 | ||
32 | while(this) { | 34 | while (*p) { |
33 | if (this->node) | 35 | parent = *p; |
34 | printk(KERN_DEBUG "frag %04x-%04x: 0x%08x(%d) on flash (*%p). left (%p), right (%p), parent (%p)\n", | 36 | this = rb_entry(parent, struct jffs2_tmp_dnode_info, rb); |
35 | this->ofs, this->ofs+this->size, ref_offset(this->node->raw), ref_flags(this->node->raw), | 37 | |
36 | this, frag_left(this), frag_right(this), frag_parent(this)); | 38 | /* There may actually be a collision here, but it doesn't |
37 | else | 39 | actually matter. As long as the two nodes with the same |
38 | printk(KERN_DEBUG "frag %04x-%04x: hole (*%p). left (%p} right (%p), parent (%p)\n", this->ofs, | 40 | version are together, it's all fine. */ |
39 | this->ofs+this->size, this, frag_left(this), frag_right(this), frag_parent(this)); | 41 | if (tn->version > this->version) |
40 | if (this->ofs != lastofs) | 42 | p = &(*p)->rb_left; |
41 | buggy = 1; | 43 | else |
42 | lastofs = this->ofs+this->size; | 44 | p = &(*p)->rb_right; |
43 | this = frag_next(this); | ||
44 | } | 45 | } |
45 | if (buggy && !permitbug) { | 46 | |
46 | printk(KERN_CRIT "Frag tree got a hole in it\n"); | 47 | rb_link_node(&tn->rb, parent, p); |
47 | BUG(); | 48 | rb_insert_color(&tn->rb, list); |
49 | } | ||
50 | |||
51 | static void jffs2_free_tmp_dnode_info_list(struct rb_root *list) | ||
52 | { | ||
53 | struct rb_node *this; | ||
54 | struct jffs2_tmp_dnode_info *tn; | ||
55 | |||
56 | this = list->rb_node; | ||
57 | |||
58 | /* Now at bottom of tree */ | ||
59 | while (this) { | ||
60 | if (this->rb_left) | ||
61 | this = this->rb_left; | ||
62 | else if (this->rb_right) | ||
63 | this = this->rb_right; | ||
64 | else { | ||
65 | tn = rb_entry(this, struct jffs2_tmp_dnode_info, rb); | ||
66 | jffs2_free_full_dnode(tn->fn); | ||
67 | jffs2_free_tmp_dnode_info(tn); | ||
68 | |||
69 | this = this->rb_parent; | ||
70 | if (!this) | ||
71 | break; | ||
72 | |||
73 | if (this->rb_left == &tn->rb) | ||
74 | this->rb_left = NULL; | ||
75 | else if (this->rb_right == &tn->rb) | ||
76 | this->rb_right = NULL; | ||
77 | else BUG(); | ||
78 | } | ||
48 | } | 79 | } |
80 | list->rb_node = NULL; | ||
49 | } | 81 | } |
50 | 82 | ||
51 | void jffs2_print_frag_list(struct jffs2_inode_info *f) | 83 | static void jffs2_free_full_dirent_list(struct jffs2_full_dirent *fd) |
52 | { | 84 | { |
53 | jffs2_print_fragtree(&f->fragtree, 0); | 85 | struct jffs2_full_dirent *next; |
54 | 86 | ||
55 | if (f->metadata) { | 87 | while (fd) { |
56 | printk(KERN_DEBUG "metadata at 0x%08x\n", ref_offset(f->metadata->raw)); | 88 | next = fd->next; |
89 | jffs2_free_full_dirent(fd); | ||
90 | fd = next; | ||
57 | } | 91 | } |
58 | } | 92 | } |
59 | #endif | ||
60 | 93 | ||
61 | #if CONFIG_JFFS2_FS_DEBUG >= 1 | 94 | /* Returns first valid node after 'ref'. May return 'ref' */ |
62 | static int jffs2_sanitycheck_fragtree(struct jffs2_inode_info *f) | 95 | static struct jffs2_raw_node_ref *jffs2_first_valid_node(struct jffs2_raw_node_ref *ref) |
63 | { | 96 | { |
64 | struct jffs2_node_frag *frag; | 97 | while (ref && ref->next_in_ino) { |
65 | int bitched = 0; | 98 | if (!ref_obsolete(ref)) |
66 | 99 | return ref; | |
67 | for (frag = frag_first(&f->fragtree); frag; frag = frag_next(frag)) { | 100 | dbg_noderef("node at 0x%08x is obsoleted. Ignoring.\n", ref_offset(ref)); |
101 | ref = ref->next_in_ino; | ||
102 | } | ||
103 | return NULL; | ||
104 | } | ||
68 | 105 | ||
69 | struct jffs2_full_dnode *fn = frag->node; | 106 | /* |
70 | if (!fn || !fn->raw) | 107 | * Helper function for jffs2_get_inode_nodes(). |
71 | continue; | 108 | * It is called every time an directory entry node is found. |
109 | * | ||
110 | * Returns: 0 on succes; | ||
111 | * 1 if the node should be marked obsolete; | ||
112 | * negative error code on failure. | ||
113 | */ | ||
114 | static inline int read_direntry(struct jffs2_sb_info *c, struct jffs2_raw_node_ref *ref, | ||
115 | struct jffs2_raw_dirent *rd, uint32_t read, struct jffs2_full_dirent **fdp, | ||
116 | uint32_t *latest_mctime, uint32_t *mctime_ver) | ||
117 | { | ||
118 | struct jffs2_full_dirent *fd; | ||
119 | |||
120 | /* The direntry nodes are checked during the flash scanning */ | ||
121 | BUG_ON(ref_flags(ref) == REF_UNCHECKED); | ||
122 | /* Obsoleted. This cannot happen, surely? dwmw2 20020308 */ | ||
123 | BUG_ON(ref_obsolete(ref)); | ||
124 | |||
125 | /* Sanity check */ | ||
126 | if (unlikely(PAD((rd->nsize + sizeof(*rd))) != PAD(je32_to_cpu(rd->totlen)))) { | ||
127 | JFFS2_ERROR("illegal nsize in node at %#08x: nsize %#02x, totlen %#04x\n", | ||
128 | ref_offset(ref), rd->nsize, je32_to_cpu(rd->totlen)); | ||
129 | return 1; | ||
130 | } | ||
72 | 131 | ||
73 | if (ref_flags(fn->raw) == REF_PRISTINE) { | 132 | fd = jffs2_alloc_full_dirent(rd->nsize + 1); |
133 | if (unlikely(!fd)) | ||
134 | return -ENOMEM; | ||
74 | 135 | ||
75 | if (fn->frags > 1) { | 136 | fd->raw = ref; |
76 | printk(KERN_WARNING "REF_PRISTINE node at 0x%08x had %d frags. Tell dwmw2\n", ref_offset(fn->raw), fn->frags); | 137 | fd->version = je32_to_cpu(rd->version); |
77 | bitched = 1; | 138 | fd->ino = je32_to_cpu(rd->ino); |
78 | } | 139 | fd->type = rd->type; |
79 | /* A hole node which isn't multi-page should be garbage-collected | ||
80 | and merged anyway, so we just check for the frag size here, | ||
81 | rather than mucking around with actually reading the node | ||
82 | and checking the compression type, which is the real way | ||
83 | to tell a hole node. */ | ||
84 | if (frag->ofs & (PAGE_CACHE_SIZE-1) && frag_prev(frag) && frag_prev(frag)->size < PAGE_CACHE_SIZE && frag_prev(frag)->node) { | ||
85 | printk(KERN_WARNING "REF_PRISTINE node at 0x%08x had a previous non-hole frag in the same page. Tell dwmw2\n", | ||
86 | ref_offset(fn->raw)); | ||
87 | bitched = 1; | ||
88 | } | ||
89 | 140 | ||
90 | if ((frag->ofs+frag->size) & (PAGE_CACHE_SIZE-1) && frag_next(frag) && frag_next(frag)->size < PAGE_CACHE_SIZE && frag_next(frag)->node) { | 141 | /* Pick out the mctime of the latest dirent */ |
91 | printk(KERN_WARNING "REF_PRISTINE node at 0x%08x (%08x-%08x) had a following non-hole frag in the same page. Tell dwmw2\n", | 142 | if(fd->version > *mctime_ver && je32_to_cpu(rd->mctime)) { |
92 | ref_offset(fn->raw), frag->ofs, frag->ofs+frag->size); | 143 | *mctime_ver = fd->version; |
93 | bitched = 1; | 144 | *latest_mctime = je32_to_cpu(rd->mctime); |
94 | } | ||
95 | } | ||
96 | } | 145 | } |
97 | |||
98 | if (bitched) { | ||
99 | struct jffs2_node_frag *thisfrag; | ||
100 | |||
101 | printk(KERN_WARNING "Inode is #%u\n", f->inocache->ino); | ||
102 | thisfrag = frag_first(&f->fragtree); | ||
103 | while (thisfrag) { | ||
104 | if (!thisfrag->node) { | ||
105 | printk("Frag @0x%x-0x%x; node-less hole\n", | ||
106 | thisfrag->ofs, thisfrag->size + thisfrag->ofs); | ||
107 | } else if (!thisfrag->node->raw) { | ||
108 | printk("Frag @0x%x-0x%x; raw-less hole\n", | ||
109 | thisfrag->ofs, thisfrag->size + thisfrag->ofs); | ||
110 | } else { | ||
111 | printk("Frag @0x%x-0x%x; raw at 0x%08x(%d) (0x%x-0x%x)\n", | ||
112 | thisfrag->ofs, thisfrag->size + thisfrag->ofs, | ||
113 | ref_offset(thisfrag->node->raw), ref_flags(thisfrag->node->raw), | ||
114 | thisfrag->node->ofs, thisfrag->node->ofs+thisfrag->node->size); | ||
115 | } | ||
116 | thisfrag = frag_next(thisfrag); | ||
117 | } | ||
118 | } | ||
119 | return bitched; | ||
120 | } | ||
121 | #endif /* D1 */ | ||
122 | 146 | ||
123 | static void jffs2_obsolete_node_frag(struct jffs2_sb_info *c, struct jffs2_node_frag *this) | 147 | /* |
124 | { | 148 | * Copy as much of the name as possible from the raw |
125 | if (this->node) { | 149 | * dirent we've already read from the flash. |
126 | this->node->frags--; | 150 | */ |
127 | if (!this->node->frags) { | 151 | if (read > sizeof(*rd)) |
128 | /* The node has no valid frags left. It's totally obsoleted */ | 152 | memcpy(&fd->name[0], &rd->name[0], |
129 | D2(printk(KERN_DEBUG "Marking old node @0x%08x (0x%04x-0x%04x) obsolete\n", | 153 | min_t(uint32_t, rd->nsize, (read - sizeof(*rd)) )); |
130 | ref_offset(this->node->raw), this->node->ofs, this->node->ofs+this->node->size)); | 154 | |
131 | jffs2_mark_node_obsolete(c, this->node->raw); | 155 | /* Do we need to copy any more of the name directly from the flash? */ |
132 | jffs2_free_full_dnode(this->node); | 156 | if (rd->nsize + sizeof(*rd) > read) { |
133 | } else { | 157 | /* FIXME: point() */ |
134 | D2(printk(KERN_DEBUG "Marking old node @0x%08x (0x%04x-0x%04x) REF_NORMAL. frags is %d\n", | 158 | int err; |
135 | ref_offset(this->node->raw), this->node->ofs, this->node->ofs+this->node->size, | 159 | int already = read - sizeof(*rd); |
136 | this->node->frags)); | 160 | |
137 | mark_ref_normal(this->node->raw); | 161 | err = jffs2_flash_read(c, (ref_offset(ref)) + read, |
162 | rd->nsize - already, &read, &fd->name[already]); | ||
163 | if (unlikely(read != rd->nsize - already) && likely(!err)) | ||
164 | return -EIO; | ||
165 | |||
166 | if (unlikely(err)) { | ||
167 | JFFS2_ERROR("read remainder of name: error %d\n", err); | ||
168 | jffs2_free_full_dirent(fd); | ||
169 | return -EIO; | ||
138 | } | 170 | } |
139 | |||
140 | } | 171 | } |
141 | jffs2_free_node_frag(this); | 172 | |
173 | fd->nhash = full_name_hash(fd->name, rd->nsize); | ||
174 | fd->next = NULL; | ||
175 | fd->name[rd->nsize] = '\0'; | ||
176 | |||
177 | /* | ||
178 | * Wheee. We now have a complete jffs2_full_dirent structure, with | ||
179 | * the name in it and everything. Link it into the list | ||
180 | */ | ||
181 | jffs2_add_fd_to_list(c, fd, fdp); | ||
182 | |||
183 | return 0; | ||
142 | } | 184 | } |
143 | 185 | ||
144 | /* Given an inode, probably with existing list of fragments, add the new node | 186 | /* |
145 | * to the fragment list. | 187 | * Helper function for jffs2_get_inode_nodes(). |
188 | * It is called every time an inode node is found. | ||
189 | * | ||
190 | * Returns: 0 on succes; | ||
191 | * 1 if the node should be marked obsolete; | ||
192 | * negative error code on failure. | ||
146 | */ | 193 | */ |
147 | int jffs2_add_full_dnode_to_inode(struct jffs2_sb_info *c, struct jffs2_inode_info *f, struct jffs2_full_dnode *fn) | 194 | static inline int read_dnode(struct jffs2_sb_info *c, struct jffs2_raw_node_ref *ref, |
195 | struct jffs2_raw_inode *rd, struct rb_root *tnp, int rdlen, | ||
196 | uint32_t *latest_mctime, uint32_t *mctime_ver) | ||
148 | { | 197 | { |
149 | int ret; | 198 | struct jffs2_tmp_dnode_info *tn; |
150 | struct jffs2_node_frag *newfrag; | 199 | uint32_t len, csize; |
151 | 200 | int ret = 1; | |
152 | D1(printk(KERN_DEBUG "jffs2_add_full_dnode_to_inode(ino #%u, f %p, fn %p)\n", f->inocache->ino, f, fn)); | ||
153 | 201 | ||
154 | if (unlikely(!fn->size)) | 202 | /* Obsoleted. This cannot happen, surely? dwmw2 20020308 */ |
155 | return 0; | 203 | BUG_ON(ref_obsolete(ref)); |
156 | 204 | ||
157 | newfrag = jffs2_alloc_node_frag(); | 205 | tn = jffs2_alloc_tmp_dnode_info(); |
158 | if (unlikely(!newfrag)) | 206 | if (!tn) { |
207 | JFFS2_ERROR("failed to allocate tn (%d bytes).\n", sizeof(*tn)); | ||
159 | return -ENOMEM; | 208 | return -ENOMEM; |
209 | } | ||
160 | 210 | ||
161 | D2(printk(KERN_DEBUG "adding node %04x-%04x @0x%08x on flash, newfrag *%p\n", | 211 | tn->partial_crc = 0; |
162 | fn->ofs, fn->ofs+fn->size, ref_offset(fn->raw), newfrag)); | 212 | csize = je32_to_cpu(rd->csize); |
163 | |||
164 | newfrag->ofs = fn->ofs; | ||
165 | newfrag->size = fn->size; | ||
166 | newfrag->node = fn; | ||
167 | newfrag->node->frags = 1; | ||
168 | 213 | ||
169 | ret = jffs2_add_frag_to_fragtree(c, &f->fragtree, newfrag); | 214 | /* If we've never checked the CRCs on this node, check them now */ |
170 | if (ret) | 215 | if (ref_flags(ref) == REF_UNCHECKED) { |
171 | return ret; | 216 | uint32_t crc; |
172 | 217 | ||
173 | /* If we now share a page with other nodes, mark either previous | 218 | crc = crc32(0, rd, sizeof(*rd) - 8); |
174 | or next node REF_NORMAL, as appropriate. */ | 219 | if (unlikely(crc != je32_to_cpu(rd->node_crc))) { |
175 | if (newfrag->ofs & (PAGE_CACHE_SIZE-1)) { | 220 | JFFS2_NOTICE("header CRC failed on node at %#08x: read %#08x, calculated %#08x\n", |
176 | struct jffs2_node_frag *prev = frag_prev(newfrag); | 221 | ref_offset(ref), je32_to_cpu(rd->node_crc), crc); |
222 | goto free_out; | ||
223 | } | ||
177 | 224 | ||
178 | mark_ref_normal(fn->raw); | 225 | /* Sanity checks */ |
179 | /* If we don't start at zero there's _always_ a previous */ | 226 | if (unlikely(je32_to_cpu(rd->offset) > je32_to_cpu(rd->isize)) || |
180 | if (prev->node) | 227 | unlikely(PAD(je32_to_cpu(rd->csize) + sizeof(*rd)) != PAD(je32_to_cpu(rd->totlen)))) { |
181 | mark_ref_normal(prev->node->raw); | 228 | JFFS2_WARNING("inode node header CRC is corrupted at %#08x\n", ref_offset(ref)); |
182 | } | 229 | jffs2_dbg_dump_node(c, ref_offset(ref)); |
230 | goto free_out; | ||
231 | } | ||
183 | 232 | ||
184 | if ((newfrag->ofs+newfrag->size) & (PAGE_CACHE_SIZE-1)) { | 233 | if (jffs2_is_writebuffered(c) && csize != 0) { |
185 | struct jffs2_node_frag *next = frag_next(newfrag); | 234 | /* At this point we are supposed to check the data CRC |
186 | 235 | * of our unchecked node. But thus far, we do not | |
187 | if (next) { | 236 | * know whether the node is valid or obsolete. To |
188 | mark_ref_normal(fn->raw); | 237 | * figure this out, we need to walk all the nodes of |
189 | if (next->node) | 238 | * the inode and build the inode fragtree. We don't |
190 | mark_ref_normal(next->node->raw); | 239 | * want to spend time checking data of nodes which may |
240 | * later be found to be obsolete. So we put off the full | ||
241 | * data CRC checking until we have read all the inode | ||
242 | * nodes and have started building the fragtree. | ||
243 | * | ||
244 | * The fragtree is being built starting with nodes | ||
245 | * having the highest version number, so we'll be able | ||
246 | * to detect whether a node is valid (i.e., it is not | ||
247 | * overlapped by a node with higher version) or not. | ||
248 | * And we'll be able to check only those nodes, which | ||
249 | * are not obsolete. | ||
250 | * | ||
251 | * Of course, this optimization only makes sense in case | ||
252 | * of NAND flashes (or other flashes whith | ||
253 | * !jffs2_can_mark_obsolete()), since on NOR flashes | ||
254 | * nodes are marked obsolete physically. | ||
255 | * | ||
256 | * Since NAND flashes (or other flashes with | ||
257 | * jffs2_is_writebuffered(c)) are anyway read by | ||
258 | * fractions of c->wbuf_pagesize, and we have just read | ||
259 | * the node header, it is likely that the starting part | ||
260 | * of the node data is also read when we read the | ||
261 | * header. So we don't mind to check the CRC of the | ||
262 | * starting part of the data of the node now, and check | ||
263 | * the second part later (in jffs2_check_node_data()). | ||
264 | * Of course, we will not need to re-read and re-check | ||
265 | * the NAND page which we have just read. This is why we | ||
266 | * read the whole NAND page at jffs2_get_inode_nodes(), | ||
267 | * while we needed only the node header. | ||
268 | */ | ||
269 | unsigned char *buf; | ||
270 | |||
271 | /* 'buf' will point to the start of data */ | ||
272 | buf = (unsigned char *)rd + sizeof(*rd); | ||
273 | /* len will be the read data length */ | ||
274 | len = min_t(uint32_t, rdlen - sizeof(*rd), csize); | ||
275 | tn->partial_crc = crc32(0, buf, len); | ||
276 | |||
277 | dbg_readinode("Calculates CRC (%#08x) for %d bytes, csize %d\n", tn->partial_crc, len, csize); | ||
278 | |||
279 | /* If we actually calculated the whole data CRC | ||
280 | * and it is wrong, drop the node. */ | ||
281 | if (len >= csize && unlikely(tn->partial_crc != je32_to_cpu(rd->data_crc))) { | ||
282 | JFFS2_NOTICE("wrong data CRC in data node at 0x%08x: read %#08x, calculated %#08x.\n", | ||
283 | ref_offset(ref), tn->partial_crc, je32_to_cpu(rd->data_crc)); | ||
284 | goto free_out; | ||
285 | } | ||
286 | |||
287 | } else if (csize == 0) { | ||
288 | /* | ||
289 | * We checked the header CRC. If the node has no data, adjust | ||
290 | * the space accounting now. For other nodes this will be done | ||
291 | * later either when the node is marked obsolete or when its | ||
292 | * data is checked. | ||
293 | */ | ||
294 | struct jffs2_eraseblock *jeb; | ||
295 | |||
296 | dbg_readinode("the node has no data.\n"); | ||
297 | jeb = &c->blocks[ref->flash_offset / c->sector_size]; | ||
298 | len = ref_totlen(c, jeb, ref); | ||
299 | |||
300 | spin_lock(&c->erase_completion_lock); | ||
301 | jeb->used_size += len; | ||
302 | jeb->unchecked_size -= len; | ||
303 | c->used_size += len; | ||
304 | c->unchecked_size -= len; | ||
305 | ref->flash_offset = ref_offset(ref) | REF_NORMAL; | ||
306 | spin_unlock(&c->erase_completion_lock); | ||
191 | } | 307 | } |
192 | } | 308 | } |
193 | D2(if (jffs2_sanitycheck_fragtree(f)) { | 309 | |
194 | printk(KERN_WARNING "Just added node %04x-%04x @0x%08x on flash, newfrag *%p\n", | 310 | tn->fn = jffs2_alloc_full_dnode(); |
195 | fn->ofs, fn->ofs+fn->size, ref_offset(fn->raw), newfrag); | 311 | if (!tn->fn) { |
196 | return 0; | 312 | JFFS2_ERROR("alloc fn failed\n"); |
197 | }) | 313 | ret = -ENOMEM; |
198 | D2(jffs2_print_frag_list(f)); | 314 | goto free_out; |
315 | } | ||
316 | |||
317 | tn->version = je32_to_cpu(rd->version); | ||
318 | tn->fn->ofs = je32_to_cpu(rd->offset); | ||
319 | tn->data_crc = je32_to_cpu(rd->data_crc); | ||
320 | tn->csize = csize; | ||
321 | tn->fn->raw = ref; | ||
322 | |||
323 | /* There was a bug where we wrote hole nodes out with | ||
324 | csize/dsize swapped. Deal with it */ | ||
325 | if (rd->compr == JFFS2_COMPR_ZERO && !je32_to_cpu(rd->dsize) && csize) | ||
326 | tn->fn->size = csize; | ||
327 | else // normal case... | ||
328 | tn->fn->size = je32_to_cpu(rd->dsize); | ||
329 | |||
330 | dbg_readinode("dnode @%08x: ver %u, offset %#04x, dsize %#04x, csize %#04x\n", | ||
331 | ref_offset(ref), je32_to_cpu(rd->version), je32_to_cpu(rd->offset), je32_to_cpu(rd->dsize), csize); | ||
332 | |||
333 | jffs2_add_tn_to_tree(tn, tnp); | ||
334 | |||
199 | return 0; | 335 | return 0; |
336 | |||
337 | free_out: | ||
338 | jffs2_free_tmp_dnode_info(tn); | ||
339 | return ret; | ||
200 | } | 340 | } |
201 | 341 | ||
202 | /* Doesn't set inode->i_size */ | 342 | /* |
203 | static int jffs2_add_frag_to_fragtree(struct jffs2_sb_info *c, struct rb_root *list, struct jffs2_node_frag *newfrag) | 343 | * Helper function for jffs2_get_inode_nodes(). |
344 | * It is called every time an unknown node is found. | ||
345 | * | ||
346 | * Returns: 0 on succes; | ||
347 | * 1 if the node should be marked obsolete; | ||
348 | * negative error code on failure. | ||
349 | */ | ||
350 | static inline int read_unknown(struct jffs2_sb_info *c, struct jffs2_raw_node_ref *ref, struct jffs2_unknown_node *un) | ||
204 | { | 351 | { |
205 | struct jffs2_node_frag *this; | 352 | /* We don't mark unknown nodes as REF_UNCHECKED */ |
206 | uint32_t lastend; | 353 | BUG_ON(ref_flags(ref) == REF_UNCHECKED); |
207 | 354 | ||
208 | /* Skip all the nodes which are completed before this one starts */ | 355 | un->nodetype = cpu_to_je16(JFFS2_NODE_ACCURATE | je16_to_cpu(un->nodetype)); |
209 | this = jffs2_lookup_node_frag(list, newfrag->node->ofs); | ||
210 | 356 | ||
211 | if (this) { | 357 | if (crc32(0, un, sizeof(struct jffs2_unknown_node) - 4) != je32_to_cpu(un->hdr_crc)) { |
212 | D2(printk(KERN_DEBUG "j_a_f_d_t_f: Lookup gave frag 0x%04x-0x%04x; phys 0x%08x (*%p)\n", | 358 | /* Hmmm. This should have been caught at scan time. */ |
213 | this->ofs, this->ofs+this->size, this->node?(ref_offset(this->node->raw)):0xffffffff, this)); | 359 | JFFS2_NOTICE("node header CRC failed at %#08x. But it must have been OK earlier.\n", ref_offset(ref)); |
214 | lastend = this->ofs + this->size; | 360 | jffs2_dbg_dump_node(c, ref_offset(ref)); |
361 | return 1; | ||
215 | } else { | 362 | } else { |
216 | D2(printk(KERN_DEBUG "j_a_f_d_t_f: Lookup gave no frag\n")); | 363 | switch(je16_to_cpu(un->nodetype) & JFFS2_COMPAT_MASK) { |
217 | lastend = 0; | ||
218 | } | ||
219 | |||
220 | /* See if we ran off the end of the list */ | ||
221 | if (lastend <= newfrag->ofs) { | ||
222 | /* We did */ | ||
223 | |||
224 | /* Check if 'this' node was on the same page as the new node. | ||
225 | If so, both 'this' and the new node get marked REF_NORMAL so | ||
226 | the GC can take a look. | ||
227 | */ | ||
228 | if (lastend && (lastend-1) >> PAGE_CACHE_SHIFT == newfrag->ofs >> PAGE_CACHE_SHIFT) { | ||
229 | if (this->node) | ||
230 | mark_ref_normal(this->node->raw); | ||
231 | mark_ref_normal(newfrag->node->raw); | ||
232 | } | ||
233 | 364 | ||
234 | if (lastend < newfrag->node->ofs) { | 365 | case JFFS2_FEATURE_INCOMPAT: |
235 | /* ... and we need to put a hole in before the new node */ | 366 | JFFS2_ERROR("unknown INCOMPAT nodetype %#04X at %#08x\n", |
236 | struct jffs2_node_frag *holefrag = jffs2_alloc_node_frag(); | 367 | je16_to_cpu(un->nodetype), ref_offset(ref)); |
237 | if (!holefrag) { | 368 | /* EEP */ |
238 | jffs2_free_node_frag(newfrag); | 369 | BUG(); |
239 | return -ENOMEM; | 370 | break; |
240 | } | 371 | |
241 | holefrag->ofs = lastend; | 372 | case JFFS2_FEATURE_ROCOMPAT: |
242 | holefrag->size = newfrag->node->ofs - lastend; | 373 | JFFS2_ERROR("unknown ROCOMPAT nodetype %#04X at %#08x\n", |
243 | holefrag->node = NULL; | 374 | je16_to_cpu(un->nodetype), ref_offset(ref)); |
244 | if (this) { | 375 | BUG_ON(!(c->flags & JFFS2_SB_FLAG_RO)); |
245 | /* By definition, the 'this' node has no right-hand child, | 376 | break; |
246 | because there are no frags with offset greater than it. | 377 | |
247 | So that's where we want to put the hole */ | 378 | case JFFS2_FEATURE_RWCOMPAT_COPY: |
248 | D2(printk(KERN_DEBUG "Adding hole frag (%p) on right of node at (%p)\n", holefrag, this)); | 379 | JFFS2_NOTICE("unknown RWCOMPAT_COPY nodetype %#04X at %#08x\n", |
249 | rb_link_node(&holefrag->rb, &this->rb, &this->rb.rb_right); | 380 | je16_to_cpu(un->nodetype), ref_offset(ref)); |
250 | } else { | 381 | break; |
251 | D2(printk(KERN_DEBUG "Adding hole frag (%p) at root of tree\n", holefrag)); | 382 | |
252 | rb_link_node(&holefrag->rb, NULL, &list->rb_node); | 383 | case JFFS2_FEATURE_RWCOMPAT_DELETE: |
253 | } | 384 | JFFS2_NOTICE("unknown RWCOMPAT_DELETE nodetype %#04X at %#08x\n", |
254 | rb_insert_color(&holefrag->rb, list); | 385 | je16_to_cpu(un->nodetype), ref_offset(ref)); |
255 | this = holefrag; | 386 | return 1; |
256 | } | ||
257 | if (this) { | ||
258 | /* By definition, the 'this' node has no right-hand child, | ||
259 | because there are no frags with offset greater than it. | ||
260 | So that's where we want to put the hole */ | ||
261 | D2(printk(KERN_DEBUG "Adding new frag (%p) on right of node at (%p)\n", newfrag, this)); | ||
262 | rb_link_node(&newfrag->rb, &this->rb, &this->rb.rb_right); | ||
263 | } else { | ||
264 | D2(printk(KERN_DEBUG "Adding new frag (%p) at root of tree\n", newfrag)); | ||
265 | rb_link_node(&newfrag->rb, NULL, &list->rb_node); | ||
266 | } | 387 | } |
267 | rb_insert_color(&newfrag->rb, list); | ||
268 | return 0; | ||
269 | } | 388 | } |
270 | 389 | ||
271 | D2(printk(KERN_DEBUG "j_a_f_d_t_f: dealing with frag 0x%04x-0x%04x; phys 0x%08x (*%p)\n", | 390 | return 0; |
272 | this->ofs, this->ofs+this->size, this->node?(ref_offset(this->node->raw)):0xffffffff, this)); | 391 | } |
273 | 392 | ||
274 | /* OK. 'this' is pointing at the first frag that newfrag->ofs at least partially obsoletes, | 393 | /* |
275 | * - i.e. newfrag->ofs < this->ofs+this->size && newfrag->ofs >= this->ofs | 394 | * Helper function for jffs2_get_inode_nodes(). |
276 | */ | 395 | * The function detects whether more data should be read and reads it if yes. |
277 | if (newfrag->ofs > this->ofs) { | 396 | * |
278 | /* This node isn't completely obsoleted. The start of it remains valid */ | 397 | * Returns: 0 on succes; |
279 | 398 | * negative error code on failure. | |
280 | /* Mark the new node and the partially covered node REF_NORMAL -- let | 399 | */ |
281 | the GC take a look at them */ | 400 | static int read_more(struct jffs2_sb_info *c, struct jffs2_raw_node_ref *ref, |
282 | mark_ref_normal(newfrag->node->raw); | 401 | int right_size, int *rdlen, unsigned char *buf, unsigned char *bufstart) |
283 | if (this->node) | 402 | { |
284 | mark_ref_normal(this->node->raw); | 403 | int right_len, err, len; |
285 | 404 | size_t retlen; | |
286 | if (this->ofs + this->size > newfrag->ofs + newfrag->size) { | 405 | uint32_t offs; |
287 | /* The new node splits 'this' frag into two */ | ||
288 | struct jffs2_node_frag *newfrag2 = jffs2_alloc_node_frag(); | ||
289 | if (!newfrag2) { | ||
290 | jffs2_free_node_frag(newfrag); | ||
291 | return -ENOMEM; | ||
292 | } | ||
293 | D2(printk(KERN_DEBUG "split old frag 0x%04x-0x%04x -->", this->ofs, this->ofs+this->size); | ||
294 | if (this->node) | ||
295 | printk("phys 0x%08x\n", ref_offset(this->node->raw)); | ||
296 | else | ||
297 | printk("hole\n"); | ||
298 | ) | ||
299 | |||
300 | /* New second frag pointing to this's node */ | ||
301 | newfrag2->ofs = newfrag->ofs + newfrag->size; | ||
302 | newfrag2->size = (this->ofs+this->size) - newfrag2->ofs; | ||
303 | newfrag2->node = this->node; | ||
304 | if (this->node) | ||
305 | this->node->frags++; | ||
306 | |||
307 | /* Adjust size of original 'this' */ | ||
308 | this->size = newfrag->ofs - this->ofs; | ||
309 | |||
310 | /* Now, we know there's no node with offset | ||
311 | greater than this->ofs but smaller than | ||
312 | newfrag2->ofs or newfrag->ofs, for obvious | ||
313 | reasons. So we can do a tree insert from | ||
314 | 'this' to insert newfrag, and a tree insert | ||
315 | from newfrag to insert newfrag2. */ | ||
316 | jffs2_fragtree_insert(newfrag, this); | ||
317 | rb_insert_color(&newfrag->rb, list); | ||
318 | |||
319 | jffs2_fragtree_insert(newfrag2, newfrag); | ||
320 | rb_insert_color(&newfrag2->rb, list); | ||
321 | |||
322 | return 0; | ||
323 | } | ||
324 | /* New node just reduces 'this' frag in size, doesn't split it */ | ||
325 | this->size = newfrag->ofs - this->ofs; | ||
326 | 406 | ||
327 | /* Again, we know it lives down here in the tree */ | 407 | if (jffs2_is_writebuffered(c)) { |
328 | jffs2_fragtree_insert(newfrag, this); | 408 | right_len = c->wbuf_pagesize - (bufstart - buf); |
329 | rb_insert_color(&newfrag->rb, list); | 409 | if (right_size + (int)(bufstart - buf) > c->wbuf_pagesize) |
330 | } else { | 410 | right_len += c->wbuf_pagesize; |
331 | /* New frag starts at the same point as 'this' used to. Replace | 411 | } else |
332 | it in the tree without doing a delete and insertion */ | 412 | right_len = right_size; |
333 | D2(printk(KERN_DEBUG "Inserting newfrag (*%p),%d-%d in before 'this' (*%p),%d-%d\n", | ||
334 | newfrag, newfrag->ofs, newfrag->ofs+newfrag->size, | ||
335 | this, this->ofs, this->ofs+this->size)); | ||
336 | |||
337 | rb_replace_node(&this->rb, &newfrag->rb, list); | ||
338 | |||
339 | if (newfrag->ofs + newfrag->size >= this->ofs+this->size) { | ||
340 | D2(printk(KERN_DEBUG "Obsoleting node frag %p (%x-%x)\n", this, this->ofs, this->ofs+this->size)); | ||
341 | jffs2_obsolete_node_frag(c, this); | ||
342 | } else { | ||
343 | this->ofs += newfrag->size; | ||
344 | this->size -= newfrag->size; | ||
345 | 413 | ||
346 | jffs2_fragtree_insert(this, newfrag); | 414 | if (*rdlen == right_len) |
347 | rb_insert_color(&this->rb, list); | 415 | return 0; |
348 | return 0; | 416 | |
349 | } | 417 | /* We need to read more data */ |
418 | offs = ref_offset(ref) + *rdlen; | ||
419 | if (jffs2_is_writebuffered(c)) { | ||
420 | bufstart = buf + c->wbuf_pagesize; | ||
421 | len = c->wbuf_pagesize; | ||
422 | } else { | ||
423 | bufstart = buf + *rdlen; | ||
424 | len = right_size - *rdlen; | ||
350 | } | 425 | } |
351 | /* OK, now we have newfrag added in the correct place in the tree, but | 426 | |
352 | frag_next(newfrag) may be a fragment which is overlapped by it | 427 | dbg_readinode("read more %d bytes\n", len); |
353 | */ | 428 | |
354 | while ((this = frag_next(newfrag)) && newfrag->ofs + newfrag->size >= this->ofs + this->size) { | 429 | err = jffs2_flash_read(c, offs, len, &retlen, bufstart); |
355 | /* 'this' frag is obsoleted completely. */ | 430 | if (err) { |
356 | D2(printk(KERN_DEBUG "Obsoleting node frag %p (%x-%x) and removing from tree\n", this, this->ofs, this->ofs+this->size)); | 431 | JFFS2_ERROR("can not read %d bytes from 0x%08x, " |
357 | rb_erase(&this->rb, list); | 432 | "error code: %d.\n", len, offs, err); |
358 | jffs2_obsolete_node_frag(c, this); | 433 | return err; |
359 | } | 434 | } |
360 | /* Now we're pointing at the first frag which isn't totally obsoleted by | ||
361 | the new frag */ | ||
362 | 435 | ||
363 | if (!this || newfrag->ofs + newfrag->size == this->ofs) { | 436 | if (retlen < len) { |
364 | return 0; | 437 | JFFS2_ERROR("short read at %#08x: %d instead of %d.\n", |
438 | offs, retlen, len); | ||
439 | return -EIO; | ||
365 | } | 440 | } |
366 | /* Still some overlap but we don't need to move it in the tree */ | ||
367 | this->size = (this->ofs + this->size) - (newfrag->ofs + newfrag->size); | ||
368 | this->ofs = newfrag->ofs + newfrag->size; | ||
369 | 441 | ||
370 | /* And mark them REF_NORMAL so the GC takes a look at them */ | 442 | *rdlen = right_len; |
371 | if (this->node) | ||
372 | mark_ref_normal(this->node->raw); | ||
373 | mark_ref_normal(newfrag->node->raw); | ||
374 | 443 | ||
375 | return 0; | 444 | return 0; |
376 | } | 445 | } |
377 | 446 | ||
378 | void jffs2_truncate_fraglist (struct jffs2_sb_info *c, struct rb_root *list, uint32_t size) | 447 | /* Get tmp_dnode_info and full_dirent for all non-obsolete nodes associated |
448 | with this ino, returning the former in order of version */ | ||
449 | static int jffs2_get_inode_nodes(struct jffs2_sb_info *c, struct jffs2_inode_info *f, | ||
450 | struct rb_root *tnp, struct jffs2_full_dirent **fdp, | ||
451 | uint32_t *highest_version, uint32_t *latest_mctime, | ||
452 | uint32_t *mctime_ver) | ||
379 | { | 453 | { |
380 | struct jffs2_node_frag *frag = jffs2_lookup_node_frag(list, size); | 454 | struct jffs2_raw_node_ref *ref, *valid_ref; |
455 | struct rb_root ret_tn = RB_ROOT; | ||
456 | struct jffs2_full_dirent *ret_fd = NULL; | ||
457 | unsigned char *buf = NULL; | ||
458 | union jffs2_node_union *node; | ||
459 | size_t retlen; | ||
460 | int len, err; | ||
461 | |||
462 | *mctime_ver = 0; | ||
463 | |||
464 | dbg_readinode("ino #%u\n", f->inocache->ino); | ||
465 | |||
466 | if (jffs2_is_writebuffered(c)) { | ||
467 | /* | ||
468 | * If we have the write buffer, we assume the minimal I/O unit | ||
469 | * is c->wbuf_pagesize. We implement some optimizations which in | ||
470 | * this case and we need a temporary buffer of size = | ||
471 | * 2*c->wbuf_pagesize bytes (see comments in read_dnode()). | ||
472 | * Basically, we want to read not only the node header, but the | ||
473 | * whole wbuf (NAND page in case of NAND) or 2, if the node | ||
474 | * header overlaps the border between the 2 wbufs. | ||
475 | */ | ||
476 | len = 2*c->wbuf_pagesize; | ||
477 | } else { | ||
478 | /* | ||
479 | * When there is no write buffer, the size of the temporary | ||
480 | * buffer is the size of the larges node header. | ||
481 | */ | ||
482 | len = sizeof(union jffs2_node_union); | ||
483 | } | ||
381 | 484 | ||
382 | D1(printk(KERN_DEBUG "Truncating fraglist to 0x%08x bytes\n", size)); | 485 | /* FIXME: in case of NOR and available ->point() this |
486 | * needs to be fixed. */ | ||
487 | buf = kmalloc(len, GFP_KERNEL); | ||
488 | if (!buf) | ||
489 | return -ENOMEM; | ||
383 | 490 | ||
384 | /* We know frag->ofs <= size. That's what lookup does for us */ | 491 | spin_lock(&c->erase_completion_lock); |
385 | if (frag && frag->ofs != size) { | 492 | valid_ref = jffs2_first_valid_node(f->inocache->nodes); |
386 | if (frag->ofs+frag->size >= size) { | 493 | if (!valid_ref && f->inocache->ino != 1) |
387 | D1(printk(KERN_DEBUG "Truncating frag 0x%08x-0x%08x\n", frag->ofs, frag->ofs+frag->size)); | 494 | JFFS2_WARNING("Eep. No valid nodes for ino #%u.\n", f->inocache->ino); |
388 | frag->size = size - frag->ofs; | 495 | while (valid_ref) { |
496 | unsigned char *bufstart; | ||
497 | |||
498 | /* We can hold a pointer to a non-obsolete node without the spinlock, | ||
499 | but _obsolete_ nodes may disappear at any time, if the block | ||
500 | they're in gets erased. So if we mark 'ref' obsolete while we're | ||
501 | not holding the lock, it can go away immediately. For that reason, | ||
502 | we find the next valid node first, before processing 'ref'. | ||
503 | */ | ||
504 | ref = valid_ref; | ||
505 | valid_ref = jffs2_first_valid_node(ref->next_in_ino); | ||
506 | spin_unlock(&c->erase_completion_lock); | ||
507 | |||
508 | cond_resched(); | ||
509 | |||
510 | /* | ||
511 | * At this point we don't know the type of the node we're going | ||
512 | * to read, so we do not know the size of its header. In order | ||
513 | * to minimize the amount of flash IO we assume the node has | ||
514 | * size = JFFS2_MIN_NODE_HEADER. | ||
515 | */ | ||
516 | if (jffs2_is_writebuffered(c)) { | ||
517 | /* | ||
518 | * We treat 'buf' as 2 adjacent wbufs. We want to | ||
519 | * adjust bufstart such as it points to the | ||
520 | * beginning of the node within this wbuf. | ||
521 | */ | ||
522 | bufstart = buf + (ref_offset(ref) % c->wbuf_pagesize); | ||
523 | /* We will read either one wbuf or 2 wbufs. */ | ||
524 | len = c->wbuf_pagesize - (bufstart - buf); | ||
525 | if (JFFS2_MIN_NODE_HEADER + (int)(bufstart - buf) > c->wbuf_pagesize) { | ||
526 | /* The header spans the border of the first wbuf */ | ||
527 | len += c->wbuf_pagesize; | ||
528 | } | ||
529 | } else { | ||
530 | bufstart = buf; | ||
531 | len = JFFS2_MIN_NODE_HEADER; | ||
389 | } | 532 | } |
390 | frag = frag_next(frag); | ||
391 | } | ||
392 | while (frag && frag->ofs >= size) { | ||
393 | struct jffs2_node_frag *next = frag_next(frag); | ||
394 | 533 | ||
395 | D1(printk(KERN_DEBUG "Removing frag 0x%08x-0x%08x\n", frag->ofs, frag->ofs+frag->size)); | 534 | dbg_readinode("read %d bytes at %#08x(%d).\n", len, ref_offset(ref), ref_flags(ref)); |
396 | frag_erase(frag, list); | ||
397 | jffs2_obsolete_node_frag(c, frag); | ||
398 | frag = next; | ||
399 | } | ||
400 | } | ||
401 | 535 | ||
402 | /* Scan the list of all nodes present for this ino, build map of versions, etc. */ | 536 | /* FIXME: point() */ |
537 | err = jffs2_flash_read(c, ref_offset(ref), len, | ||
538 | &retlen, bufstart); | ||
539 | if (err) { | ||
540 | JFFS2_ERROR("can not read %d bytes from 0x%08x, " "error code: %d.\n", len, ref_offset(ref), err); | ||
541 | goto free_out; | ||
542 | } | ||
403 | 543 | ||
404 | static int jffs2_do_read_inode_internal(struct jffs2_sb_info *c, | 544 | if (retlen < len) { |
405 | struct jffs2_inode_info *f, | 545 | JFFS2_ERROR("short read at %#08x: %d instead of %d.\n", ref_offset(ref), retlen, len); |
406 | struct jffs2_raw_inode *latest_node); | 546 | err = -EIO; |
547 | goto free_out; | ||
548 | } | ||
407 | 549 | ||
408 | int jffs2_do_read_inode(struct jffs2_sb_info *c, struct jffs2_inode_info *f, | 550 | node = (union jffs2_node_union *)bufstart; |
409 | uint32_t ino, struct jffs2_raw_inode *latest_node) | ||
410 | { | ||
411 | D2(printk(KERN_DEBUG "jffs2_do_read_inode(): getting inocache\n")); | ||
412 | 551 | ||
413 | retry_inocache: | 552 | switch (je16_to_cpu(node->u.nodetype)) { |
414 | spin_lock(&c->inocache_lock); | ||
415 | f->inocache = jffs2_get_ino_cache(c, ino); | ||
416 | 553 | ||
417 | D2(printk(KERN_DEBUG "jffs2_do_read_inode(): Got inocache at %p\n", f->inocache)); | 554 | case JFFS2_NODETYPE_DIRENT: |
555 | |||
556 | if (JFFS2_MIN_NODE_HEADER < sizeof(struct jffs2_raw_dirent)) { | ||
557 | err = read_more(c, ref, sizeof(struct jffs2_raw_dirent), &len, buf, bufstart); | ||
558 | if (unlikely(err)) | ||
559 | goto free_out; | ||
560 | } | ||
561 | |||
562 | err = read_direntry(c, ref, &node->d, retlen, &ret_fd, latest_mctime, mctime_ver); | ||
563 | if (err == 1) { | ||
564 | jffs2_mark_node_obsolete(c, ref); | ||
565 | break; | ||
566 | } else if (unlikely(err)) | ||
567 | goto free_out; | ||
568 | |||
569 | if (je32_to_cpu(node->d.version) > *highest_version) | ||
570 | *highest_version = je32_to_cpu(node->d.version); | ||
418 | 571 | ||
419 | if (f->inocache) { | ||
420 | /* Check its state. We may need to wait before we can use it */ | ||
421 | switch(f->inocache->state) { | ||
422 | case INO_STATE_UNCHECKED: | ||
423 | case INO_STATE_CHECKEDABSENT: | ||
424 | f->inocache->state = INO_STATE_READING; | ||
425 | break; | 572 | break; |
426 | |||
427 | case INO_STATE_CHECKING: | ||
428 | case INO_STATE_GC: | ||
429 | /* If it's in either of these states, we need | ||
430 | to wait for whoever's got it to finish and | ||
431 | put it back. */ | ||
432 | D1(printk(KERN_DEBUG "jffs2_get_ino_cache_read waiting for ino #%u in state %d\n", | ||
433 | ino, f->inocache->state)); | ||
434 | sleep_on_spinunlock(&c->inocache_wq, &c->inocache_lock); | ||
435 | goto retry_inocache; | ||
436 | 573 | ||
437 | case INO_STATE_READING: | 574 | case JFFS2_NODETYPE_INODE: |
438 | case INO_STATE_PRESENT: | 575 | |
439 | /* Eep. This should never happen. It can | 576 | if (JFFS2_MIN_NODE_HEADER < sizeof(struct jffs2_raw_inode)) { |
440 | happen if Linux calls read_inode() again | 577 | err = read_more(c, ref, sizeof(struct jffs2_raw_inode), &len, buf, bufstart); |
441 | before clear_inode() has finished though. */ | 578 | if (unlikely(err)) |
442 | printk(KERN_WARNING "Eep. Trying to read_inode #%u when it's already in state %d!\n", ino, f->inocache->state); | 579 | goto free_out; |
443 | /* Fail. That's probably better than allowing it to succeed */ | 580 | } |
444 | f->inocache = NULL; | 581 | |
582 | err = read_dnode(c, ref, &node->i, &ret_tn, len, latest_mctime, mctime_ver); | ||
583 | if (err == 1) { | ||
584 | jffs2_mark_node_obsolete(c, ref); | ||
585 | break; | ||
586 | } else if (unlikely(err)) | ||
587 | goto free_out; | ||
588 | |||
589 | if (je32_to_cpu(node->i.version) > *highest_version) | ||
590 | *highest_version = je32_to_cpu(node->i.version); | ||
591 | |||
445 | break; | 592 | break; |
446 | 593 | ||
447 | default: | 594 | default: |
448 | BUG(); | 595 | if (JFFS2_MIN_NODE_HEADER < sizeof(struct jffs2_unknown_node)) { |
449 | } | 596 | err = read_more(c, ref, sizeof(struct jffs2_unknown_node), &len, buf, bufstart); |
450 | } | 597 | if (unlikely(err)) |
451 | spin_unlock(&c->inocache_lock); | 598 | goto free_out; |
599 | } | ||
600 | |||
601 | err = read_unknown(c, ref, &node->u); | ||
602 | if (err == 1) { | ||
603 | jffs2_mark_node_obsolete(c, ref); | ||
604 | break; | ||
605 | } else if (unlikely(err)) | ||
606 | goto free_out; | ||
452 | 607 | ||
453 | if (!f->inocache && ino == 1) { | ||
454 | /* Special case - no root inode on medium */ | ||
455 | f->inocache = jffs2_alloc_inode_cache(); | ||
456 | if (!f->inocache) { | ||
457 | printk(KERN_CRIT "jffs2_do_read_inode(): Cannot allocate inocache for root inode\n"); | ||
458 | return -ENOMEM; | ||
459 | } | 608 | } |
460 | D1(printk(KERN_DEBUG "jffs2_do_read_inode(): Creating inocache for root inode\n")); | 609 | spin_lock(&c->erase_completion_lock); |
461 | memset(f->inocache, 0, sizeof(struct jffs2_inode_cache)); | ||
462 | f->inocache->ino = f->inocache->nlink = 1; | ||
463 | f->inocache->nodes = (struct jffs2_raw_node_ref *)f->inocache; | ||
464 | f->inocache->state = INO_STATE_READING; | ||
465 | jffs2_add_ino_cache(c, f->inocache); | ||
466 | } | ||
467 | if (!f->inocache) { | ||
468 | printk(KERN_WARNING "jffs2_do_read_inode() on nonexistent ino %u\n", ino); | ||
469 | return -ENOENT; | ||
470 | } | 610 | } |
471 | 611 | ||
472 | return jffs2_do_read_inode_internal(c, f, latest_node); | 612 | spin_unlock(&c->erase_completion_lock); |
473 | } | 613 | *tnp = ret_tn; |
474 | 614 | *fdp = ret_fd; | |
475 | int jffs2_do_crccheck_inode(struct jffs2_sb_info *c, struct jffs2_inode_cache *ic) | 615 | kfree(buf); |
476 | { | ||
477 | struct jffs2_raw_inode n; | ||
478 | struct jffs2_inode_info *f = kmalloc(sizeof(*f), GFP_KERNEL); | ||
479 | int ret; | ||
480 | |||
481 | if (!f) | ||
482 | return -ENOMEM; | ||
483 | 616 | ||
484 | memset(f, 0, sizeof(*f)); | 617 | dbg_readinode("nodes of inode #%u were read, the highest version is %u, latest_mctime %u, mctime_ver %u.\n", |
485 | init_MUTEX_LOCKED(&f->sem); | 618 | f->inocache->ino, *highest_version, *latest_mctime, *mctime_ver); |
486 | f->inocache = ic; | 619 | return 0; |
487 | 620 | ||
488 | ret = jffs2_do_read_inode_internal(c, f, &n); | 621 | free_out: |
489 | if (!ret) { | 622 | jffs2_free_tmp_dnode_info_list(&ret_tn); |
490 | up(&f->sem); | 623 | jffs2_free_full_dirent_list(ret_fd); |
491 | jffs2_do_clear_inode(c, f); | 624 | kfree(buf); |
492 | } | 625 | return err; |
493 | kfree (f); | ||
494 | return ret; | ||
495 | } | 626 | } |
496 | 627 | ||
497 | static int jffs2_do_read_inode_internal(struct jffs2_sb_info *c, | 628 | static int jffs2_do_read_inode_internal(struct jffs2_sb_info *c, |
498 | struct jffs2_inode_info *f, | 629 | struct jffs2_inode_info *f, |
499 | struct jffs2_raw_inode *latest_node) | 630 | struct jffs2_raw_inode *latest_node) |
500 | { | 631 | { |
501 | struct jffs2_tmp_dnode_info *tn = NULL; | 632 | struct jffs2_tmp_dnode_info *tn; |
502 | struct rb_root tn_list; | 633 | struct rb_root tn_list; |
503 | struct rb_node *rb, *repl_rb; | 634 | struct rb_node *rb, *repl_rb; |
504 | struct jffs2_full_dirent *fd_list; | 635 | struct jffs2_full_dirent *fd_list; |
505 | struct jffs2_full_dnode *fn = NULL; | 636 | struct jffs2_full_dnode *fn, *first_fn = NULL; |
506 | uint32_t crc; | 637 | uint32_t crc; |
507 | uint32_t latest_mctime, mctime_ver; | 638 | uint32_t latest_mctime, mctime_ver; |
508 | uint32_t mdata_ver = 0; | ||
509 | size_t retlen; | 639 | size_t retlen; |
510 | int ret; | 640 | int ret; |
511 | 641 | ||
512 | D1(printk(KERN_DEBUG "jffs2_do_read_inode_internal(): ino #%u nlink is %d\n", f->inocache->ino, f->inocache->nlink)); | 642 | dbg_readinode("ino #%u nlink is %d\n", f->inocache->ino, f->inocache->nlink); |
513 | 643 | ||
514 | /* Grab all nodes relevant to this ino */ | 644 | /* Grab all nodes relevant to this ino */ |
515 | ret = jffs2_get_inode_nodes(c, f, &tn_list, &fd_list, &f->highest_version, &latest_mctime, &mctime_ver); | 645 | ret = jffs2_get_inode_nodes(c, f, &tn_list, &fd_list, &f->highest_version, &latest_mctime, &mctime_ver); |
516 | 646 | ||
517 | if (ret) { | 647 | if (ret) { |
518 | printk(KERN_CRIT "jffs2_get_inode_nodes() for ino %u returned %d\n", f->inocache->ino, ret); | 648 | JFFS2_ERROR("cannot read nodes for ino %u, returned error is %d\n", f->inocache->ino, ret); |
519 | if (f->inocache->state == INO_STATE_READING) | 649 | if (f->inocache->state == INO_STATE_READING) |
520 | jffs2_set_inocache_state(c, f->inocache, INO_STATE_CHECKEDABSENT); | 650 | jffs2_set_inocache_state(c, f->inocache, INO_STATE_CHECKEDABSENT); |
521 | return ret; | 651 | return ret; |
@@ -525,42 +655,33 @@ static int jffs2_do_read_inode_internal(struct jffs2_sb_info *c, | |||
525 | rb = rb_first(&tn_list); | 655 | rb = rb_first(&tn_list); |
526 | 656 | ||
527 | while (rb) { | 657 | while (rb) { |
658 | cond_resched(); | ||
528 | tn = rb_entry(rb, struct jffs2_tmp_dnode_info, rb); | 659 | tn = rb_entry(rb, struct jffs2_tmp_dnode_info, rb); |
529 | fn = tn->fn; | 660 | fn = tn->fn; |
530 | 661 | ret = 1; | |
531 | if (f->metadata) { | 662 | dbg_readinode("consider node ver %u, phys offset " |
532 | if (likely(tn->version >= mdata_ver)) { | 663 | "%#08x(%d), range %u-%u.\n", tn->version, |
533 | D1(printk(KERN_DEBUG "Obsoleting old metadata at 0x%08x\n", ref_offset(f->metadata->raw))); | 664 | ref_offset(fn->raw), ref_flags(fn->raw), |
534 | jffs2_mark_node_obsolete(c, f->metadata->raw); | 665 | fn->ofs, fn->ofs + fn->size); |
535 | jffs2_free_full_dnode(f->metadata); | ||
536 | f->metadata = NULL; | ||
537 | |||
538 | mdata_ver = 0; | ||
539 | } else { | ||
540 | /* This should never happen. */ | ||
541 | printk(KERN_WARNING "Er. New metadata at 0x%08x with ver %d is actually older than previous ver %d at 0x%08x\n", | ||
542 | ref_offset(fn->raw), tn->version, mdata_ver, ref_offset(f->metadata->raw)); | ||
543 | jffs2_mark_node_obsolete(c, fn->raw); | ||
544 | jffs2_free_full_dnode(fn); | ||
545 | /* Fill in latest_node from the metadata, not this one we're about to free... */ | ||
546 | fn = f->metadata; | ||
547 | goto next_tn; | ||
548 | } | ||
549 | } | ||
550 | 666 | ||
551 | if (fn->size) { | 667 | if (fn->size) { |
552 | jffs2_add_full_dnode_to_inode(c, f, fn); | 668 | ret = jffs2_add_older_frag_to_fragtree(c, f, tn); |
553 | } else { | 669 | /* TODO: the error code isn't checked, check it */ |
554 | /* Zero-sized node at end of version list. Just a metadata update */ | 670 | jffs2_dbg_fragtree_paranoia_check_nolock(f); |
555 | D1(printk(KERN_DEBUG "metadata @%08x: ver %d\n", ref_offset(fn->raw), tn->version)); | 671 | BUG_ON(ret < 0); |
672 | if (!first_fn && ret == 0) | ||
673 | first_fn = fn; | ||
674 | } else if (!first_fn) { | ||
675 | first_fn = fn; | ||
556 | f->metadata = fn; | 676 | f->metadata = fn; |
557 | mdata_ver = tn->version; | 677 | ret = 0; /* Prevent freeing the metadata update node */ |
558 | } | 678 | } else |
559 | next_tn: | 679 | jffs2_mark_node_obsolete(c, fn->raw); |
680 | |||
560 | BUG_ON(rb->rb_left); | 681 | BUG_ON(rb->rb_left); |
561 | if (rb->rb_parent && rb->rb_parent->rb_left == rb) { | 682 | if (rb->rb_parent && rb->rb_parent->rb_left == rb) { |
562 | /* We were then left-hand child of our parent. We need | 683 | /* We were then left-hand child of our parent. We need |
563 | to move our own right-hand child into our place. */ | 684 | * to move our own right-hand child into our place. */ |
564 | repl_rb = rb->rb_right; | 685 | repl_rb = rb->rb_right; |
565 | if (repl_rb) | 686 | if (repl_rb) |
566 | repl_rb->rb_parent = rb->rb_parent; | 687 | repl_rb->rb_parent = rb->rb_parent; |
@@ -570,7 +691,7 @@ static int jffs2_do_read_inode_internal(struct jffs2_sb_info *c, | |||
570 | rb = rb_next(rb); | 691 | rb = rb_next(rb); |
571 | 692 | ||
572 | /* Remove the spent tn from the tree; don't bother rebalancing | 693 | /* Remove the spent tn from the tree; don't bother rebalancing |
573 | but put our right-hand child in our own place. */ | 694 | * but put our right-hand child in our own place. */ |
574 | if (tn->rb.rb_parent) { | 695 | if (tn->rb.rb_parent) { |
575 | if (tn->rb.rb_parent->rb_left == &tn->rb) | 696 | if (tn->rb.rb_parent->rb_left == &tn->rb) |
576 | tn->rb.rb_parent->rb_left = repl_rb; | 697 | tn->rb.rb_parent->rb_left = repl_rb; |
@@ -581,19 +702,27 @@ static int jffs2_do_read_inode_internal(struct jffs2_sb_info *c, | |||
581 | tn->rb.rb_right->rb_parent = NULL; | 702 | tn->rb.rb_right->rb_parent = NULL; |
582 | 703 | ||
583 | jffs2_free_tmp_dnode_info(tn); | 704 | jffs2_free_tmp_dnode_info(tn); |
705 | if (ret) { | ||
706 | dbg_readinode("delete dnode %u-%u.\n", | ||
707 | fn->ofs, fn->ofs + fn->size); | ||
708 | jffs2_free_full_dnode(fn); | ||
709 | } | ||
584 | } | 710 | } |
585 | D1(jffs2_sanitycheck_fragtree(f)); | 711 | jffs2_dbg_fragtree_paranoia_check_nolock(f); |
586 | 712 | ||
587 | if (!fn) { | 713 | BUG_ON(first_fn && ref_obsolete(first_fn->raw)); |
714 | |||
715 | fn = first_fn; | ||
716 | if (unlikely(!first_fn)) { | ||
588 | /* No data nodes for this inode. */ | 717 | /* No data nodes for this inode. */ |
589 | if (f->inocache->ino != 1) { | 718 | if (f->inocache->ino != 1) { |
590 | printk(KERN_WARNING "jffs2_do_read_inode(): No data nodes found for ino #%u\n", f->inocache->ino); | 719 | JFFS2_WARNING("no data nodes found for ino #%u\n", f->inocache->ino); |
591 | if (!fd_list) { | 720 | if (!fd_list) { |
592 | if (f->inocache->state == INO_STATE_READING) | 721 | if (f->inocache->state == INO_STATE_READING) |
593 | jffs2_set_inocache_state(c, f->inocache, INO_STATE_CHECKEDABSENT); | 722 | jffs2_set_inocache_state(c, f->inocache, INO_STATE_CHECKEDABSENT); |
594 | return -EIO; | 723 | return -EIO; |
595 | } | 724 | } |
596 | printk(KERN_WARNING "jffs2_do_read_inode(): But it has children so we fake some modes for it\n"); | 725 | JFFS2_NOTICE("but it has children so we fake some modes for it\n"); |
597 | } | 726 | } |
598 | latest_node->mode = cpu_to_jemode(S_IFDIR|S_IRUGO|S_IWUSR|S_IXUGO); | 727 | latest_node->mode = cpu_to_jemode(S_IFDIR|S_IRUGO|S_IWUSR|S_IXUGO); |
599 | latest_node->version = cpu_to_je32(0); | 728 | latest_node->version = cpu_to_je32(0); |
@@ -608,8 +737,8 @@ static int jffs2_do_read_inode_internal(struct jffs2_sb_info *c, | |||
608 | 737 | ||
609 | ret = jffs2_flash_read(c, ref_offset(fn->raw), sizeof(*latest_node), &retlen, (void *)latest_node); | 738 | ret = jffs2_flash_read(c, ref_offset(fn->raw), sizeof(*latest_node), &retlen, (void *)latest_node); |
610 | if (ret || retlen != sizeof(*latest_node)) { | 739 | if (ret || retlen != sizeof(*latest_node)) { |
611 | printk(KERN_NOTICE "MTD read in jffs2_do_read_inode() failed: Returned %d, %zd of %zd bytes read\n", | 740 | JFFS2_ERROR("failed to read from flash: error %d, %zd of %zd bytes read\n", |
612 | ret, retlen, sizeof(*latest_node)); | 741 | ret, retlen, sizeof(*latest_node)); |
613 | /* FIXME: If this fails, there seems to be a memory leak. Find it. */ | 742 | /* FIXME: If this fails, there seems to be a memory leak. Find it. */ |
614 | up(&f->sem); | 743 | up(&f->sem); |
615 | jffs2_do_clear_inode(c, f); | 744 | jffs2_do_clear_inode(c, f); |
@@ -618,7 +747,8 @@ static int jffs2_do_read_inode_internal(struct jffs2_sb_info *c, | |||
618 | 747 | ||
619 | crc = crc32(0, latest_node, sizeof(*latest_node)-8); | 748 | crc = crc32(0, latest_node, sizeof(*latest_node)-8); |
620 | if (crc != je32_to_cpu(latest_node->node_crc)) { | 749 | if (crc != je32_to_cpu(latest_node->node_crc)) { |
621 | printk(KERN_NOTICE "CRC failed for read_inode of inode %u at physical location 0x%x\n", f->inocache->ino, ref_offset(fn->raw)); | 750 | JFFS2_ERROR("CRC failed for read_inode of inode %u at physical location 0x%x\n", |
751 | f->inocache->ino, ref_offset(fn->raw)); | ||
622 | up(&f->sem); | 752 | up(&f->sem); |
623 | jffs2_do_clear_inode(c, f); | 753 | jffs2_do_clear_inode(c, f); |
624 | return -EIO; | 754 | return -EIO; |
@@ -633,10 +763,10 @@ static int jffs2_do_read_inode_internal(struct jffs2_sb_info *c, | |||
633 | } | 763 | } |
634 | break; | 764 | break; |
635 | 765 | ||
636 | 766 | ||
637 | case S_IFREG: | 767 | case S_IFREG: |
638 | /* If it was a regular file, truncate it to the latest node's isize */ | 768 | /* If it was a regular file, truncate it to the latest node's isize */ |
639 | jffs2_truncate_fraglist(c, &f->fragtree, je32_to_cpu(latest_node->isize)); | 769 | jffs2_truncate_fragtree(c, &f->fragtree, je32_to_cpu(latest_node->isize)); |
640 | break; | 770 | break; |
641 | 771 | ||
642 | case S_IFLNK: | 772 | case S_IFLNK: |
@@ -649,37 +779,33 @@ static int jffs2_do_read_inode_internal(struct jffs2_sb_info *c, | |||
649 | 779 | ||
650 | if (f->inocache->state != INO_STATE_CHECKING) { | 780 | if (f->inocache->state != INO_STATE_CHECKING) { |
651 | /* Symlink's inode data is the target path. Read it and | 781 | /* Symlink's inode data is the target path. Read it and |
652 | * keep in RAM to facilitate quick follow symlink operation. | 782 | * keep in RAM to facilitate quick follow symlink |
653 | * We use f->dents field to store the target path, which | 783 | * operation. */ |
654 | * is somewhat ugly. */ | 784 | f->target = kmalloc(je32_to_cpu(latest_node->csize) + 1, GFP_KERNEL); |
655 | f->dents = kmalloc(je32_to_cpu(latest_node->csize) + 1, GFP_KERNEL); | 785 | if (!f->target) { |
656 | if (!f->dents) { | 786 | JFFS2_ERROR("can't allocate %d bytes of memory for the symlink target path cache\n", je32_to_cpu(latest_node->csize)); |
657 | printk(KERN_WARNING "Can't allocate %d bytes of memory " | ||
658 | "for the symlink target path cache\n", | ||
659 | je32_to_cpu(latest_node->csize)); | ||
660 | up(&f->sem); | 787 | up(&f->sem); |
661 | jffs2_do_clear_inode(c, f); | 788 | jffs2_do_clear_inode(c, f); |
662 | return -ENOMEM; | 789 | return -ENOMEM; |
663 | } | 790 | } |
664 | 791 | ||
665 | ret = jffs2_flash_read(c, ref_offset(fn->raw) + sizeof(*latest_node), | 792 | ret = jffs2_flash_read(c, ref_offset(fn->raw) + sizeof(*latest_node), |
666 | je32_to_cpu(latest_node->csize), &retlen, (char *)f->dents); | 793 | je32_to_cpu(latest_node->csize), &retlen, (char *)f->target); |
667 | 794 | ||
668 | if (ret || retlen != je32_to_cpu(latest_node->csize)) { | 795 | if (ret || retlen != je32_to_cpu(latest_node->csize)) { |
669 | if (retlen != je32_to_cpu(latest_node->csize)) | 796 | if (retlen != je32_to_cpu(latest_node->csize)) |
670 | ret = -EIO; | 797 | ret = -EIO; |
671 | kfree(f->dents); | 798 | kfree(f->target); |
672 | f->dents = NULL; | 799 | f->target = NULL; |
673 | up(&f->sem); | 800 | up(&f->sem); |
674 | jffs2_do_clear_inode(c, f); | 801 | jffs2_do_clear_inode(c, f); |
675 | return -ret; | 802 | return -ret; |
676 | } | 803 | } |
677 | 804 | ||
678 | ((char *)f->dents)[je32_to_cpu(latest_node->csize)] = '\0'; | 805 | f->target[je32_to_cpu(latest_node->csize)] = '\0'; |
679 | D1(printk(KERN_DEBUG "jffs2_do_read_inode(): symlink's target '%s' cached\n", | 806 | dbg_readinode("symlink's target '%s' cached\n", f->target); |
680 | (char *)f->dents)); | ||
681 | } | 807 | } |
682 | 808 | ||
683 | /* fall through... */ | 809 | /* fall through... */ |
684 | 810 | ||
685 | case S_IFBLK: | 811 | case S_IFBLK: |
@@ -687,14 +813,14 @@ static int jffs2_do_read_inode_internal(struct jffs2_sb_info *c, | |||
687 | /* Certain inode types should have only one data node, and it's | 813 | /* Certain inode types should have only one data node, and it's |
688 | kept as the metadata node */ | 814 | kept as the metadata node */ |
689 | if (f->metadata) { | 815 | if (f->metadata) { |
690 | printk(KERN_WARNING "Argh. Special inode #%u with mode 0%o had metadata node\n", | 816 | JFFS2_ERROR("Argh. Special inode #%u with mode 0%o had metadata node\n", |
691 | f->inocache->ino, jemode_to_cpu(latest_node->mode)); | 817 | f->inocache->ino, jemode_to_cpu(latest_node->mode)); |
692 | up(&f->sem); | 818 | up(&f->sem); |
693 | jffs2_do_clear_inode(c, f); | 819 | jffs2_do_clear_inode(c, f); |
694 | return -EIO; | 820 | return -EIO; |
695 | } | 821 | } |
696 | if (!frag_first(&f->fragtree)) { | 822 | if (!frag_first(&f->fragtree)) { |
697 | printk(KERN_WARNING "Argh. Special inode #%u with mode 0%o has no fragments\n", | 823 | JFFS2_ERROR("Argh. Special inode #%u with mode 0%o has no fragments\n", |
698 | f->inocache->ino, jemode_to_cpu(latest_node->mode)); | 824 | f->inocache->ino, jemode_to_cpu(latest_node->mode)); |
699 | up(&f->sem); | 825 | up(&f->sem); |
700 | jffs2_do_clear_inode(c, f); | 826 | jffs2_do_clear_inode(c, f); |
@@ -702,7 +828,7 @@ static int jffs2_do_read_inode_internal(struct jffs2_sb_info *c, | |||
702 | } | 828 | } |
703 | /* ASSERT: f->fraglist != NULL */ | 829 | /* ASSERT: f->fraglist != NULL */ |
704 | if (frag_next(frag_first(&f->fragtree))) { | 830 | if (frag_next(frag_first(&f->fragtree))) { |
705 | printk(KERN_WARNING "Argh. Special inode #%u with mode 0x%x had more than one node\n", | 831 | JFFS2_ERROR("Argh. Special inode #%u with mode 0x%x had more than one node\n", |
706 | f->inocache->ino, jemode_to_cpu(latest_node->mode)); | 832 | f->inocache->ino, jemode_to_cpu(latest_node->mode)); |
707 | /* FIXME: Deal with it - check crc32, check for duplicate node, check times and discard the older one */ | 833 | /* FIXME: Deal with it - check crc32, check for duplicate node, check times and discard the older one */ |
708 | up(&f->sem); | 834 | up(&f->sem); |
@@ -721,6 +847,93 @@ static int jffs2_do_read_inode_internal(struct jffs2_sb_info *c, | |||
721 | return 0; | 847 | return 0; |
722 | } | 848 | } |
723 | 849 | ||
850 | /* Scan the list of all nodes present for this ino, build map of versions, etc. */ | ||
851 | int jffs2_do_read_inode(struct jffs2_sb_info *c, struct jffs2_inode_info *f, | ||
852 | uint32_t ino, struct jffs2_raw_inode *latest_node) | ||
853 | { | ||
854 | dbg_readinode("read inode #%u\n", ino); | ||
855 | |||
856 | retry_inocache: | ||
857 | spin_lock(&c->inocache_lock); | ||
858 | f->inocache = jffs2_get_ino_cache(c, ino); | ||
859 | |||
860 | if (f->inocache) { | ||
861 | /* Check its state. We may need to wait before we can use it */ | ||
862 | switch(f->inocache->state) { | ||
863 | case INO_STATE_UNCHECKED: | ||
864 | case INO_STATE_CHECKEDABSENT: | ||
865 | f->inocache->state = INO_STATE_READING; | ||
866 | break; | ||
867 | |||
868 | case INO_STATE_CHECKING: | ||
869 | case INO_STATE_GC: | ||
870 | /* If it's in either of these states, we need | ||
871 | to wait for whoever's got it to finish and | ||
872 | put it back. */ | ||
873 | dbg_readinode("waiting for ino #%u in state %d\n", ino, f->inocache->state); | ||
874 | sleep_on_spinunlock(&c->inocache_wq, &c->inocache_lock); | ||
875 | goto retry_inocache; | ||
876 | |||
877 | case INO_STATE_READING: | ||
878 | case INO_STATE_PRESENT: | ||
879 | /* Eep. This should never happen. It can | ||
880 | happen if Linux calls read_inode() again | ||
881 | before clear_inode() has finished though. */ | ||
882 | JFFS2_ERROR("Eep. Trying to read_inode #%u when it's already in state %d!\n", ino, f->inocache->state); | ||
883 | /* Fail. That's probably better than allowing it to succeed */ | ||
884 | f->inocache = NULL; | ||
885 | break; | ||
886 | |||
887 | default: | ||
888 | BUG(); | ||
889 | } | ||
890 | } | ||
891 | spin_unlock(&c->inocache_lock); | ||
892 | |||
893 | if (!f->inocache && ino == 1) { | ||
894 | /* Special case - no root inode on medium */ | ||
895 | f->inocache = jffs2_alloc_inode_cache(); | ||
896 | if (!f->inocache) { | ||
897 | JFFS2_ERROR("cannot allocate inocache for root inode\n"); | ||
898 | return -ENOMEM; | ||
899 | } | ||
900 | dbg_readinode("creating inocache for root inode\n"); | ||
901 | memset(f->inocache, 0, sizeof(struct jffs2_inode_cache)); | ||
902 | f->inocache->ino = f->inocache->nlink = 1; | ||
903 | f->inocache->nodes = (struct jffs2_raw_node_ref *)f->inocache; | ||
904 | f->inocache->state = INO_STATE_READING; | ||
905 | jffs2_add_ino_cache(c, f->inocache); | ||
906 | } | ||
907 | if (!f->inocache) { | ||
908 | JFFS2_ERROR("requestied to read an nonexistent ino %u\n", ino); | ||
909 | return -ENOENT; | ||
910 | } | ||
911 | |||
912 | return jffs2_do_read_inode_internal(c, f, latest_node); | ||
913 | } | ||
914 | |||
915 | int jffs2_do_crccheck_inode(struct jffs2_sb_info *c, struct jffs2_inode_cache *ic) | ||
916 | { | ||
917 | struct jffs2_raw_inode n; | ||
918 | struct jffs2_inode_info *f = kmalloc(sizeof(*f), GFP_KERNEL); | ||
919 | int ret; | ||
920 | |||
921 | if (!f) | ||
922 | return -ENOMEM; | ||
923 | |||
924 | memset(f, 0, sizeof(*f)); | ||
925 | init_MUTEX_LOCKED(&f->sem); | ||
926 | f->inocache = ic; | ||
927 | |||
928 | ret = jffs2_do_read_inode_internal(c, f, &n); | ||
929 | if (!ret) { | ||
930 | up(&f->sem); | ||
931 | jffs2_do_clear_inode(c, f); | ||
932 | } | ||
933 | kfree (f); | ||
934 | return ret; | ||
935 | } | ||
936 | |||
724 | void jffs2_do_clear_inode(struct jffs2_sb_info *c, struct jffs2_inode_info *f) | 937 | void jffs2_do_clear_inode(struct jffs2_sb_info *c, struct jffs2_inode_info *f) |
725 | { | 938 | { |
726 | struct jffs2_full_dirent *fd, *fds; | 939 | struct jffs2_full_dirent *fd, *fds; |
@@ -740,20 +953,16 @@ void jffs2_do_clear_inode(struct jffs2_sb_info *c, struct jffs2_inode_info *f) | |||
740 | 953 | ||
741 | jffs2_kill_fragtree(&f->fragtree, deleted?c:NULL); | 954 | jffs2_kill_fragtree(&f->fragtree, deleted?c:NULL); |
742 | 955 | ||
743 | /* For symlink inodes we us f->dents to store the target path name */ | 956 | if (f->target) { |
744 | if (S_ISLNK(OFNI_EDONI_2SFFJ(f)->i_mode)) { | 957 | kfree(f->target); |
745 | if (f->dents) { | 958 | f->target = NULL; |
746 | kfree(f->dents); | 959 | } |
747 | f->dents = NULL; | ||
748 | } | ||
749 | } else { | ||
750 | fds = f->dents; | ||
751 | 960 | ||
752 | while(fds) { | 961 | fds = f->dents; |
753 | fd = fds; | 962 | while(fds) { |
754 | fds = fd->next; | 963 | fd = fds; |
755 | jffs2_free_full_dirent(fd); | 964 | fds = fd->next; |
756 | } | 965 | jffs2_free_full_dirent(fd); |
757 | } | 966 | } |
758 | 967 | ||
759 | if (f->inocache && f->inocache->state != INO_STATE_CHECKING) { | 968 | if (f->inocache && f->inocache->state != INO_STATE_CHECKING) { |
diff --git a/fs/jffs2/scan.c b/fs/jffs2/scan.c index b63160f83bab..0e7456ec99fd 100644 --- a/fs/jffs2/scan.c +++ b/fs/jffs2/scan.c | |||
@@ -7,7 +7,7 @@ | |||
7 | * | 7 | * |
8 | * For licensing information, see the file 'LICENCE' in this directory. | 8 | * For licensing information, see the file 'LICENCE' in this directory. |
9 | * | 9 | * |
10 | * $Id: scan.c,v 1.119 2005/02/17 17:51:13 dedekind Exp $ | 10 | * $Id: scan.c,v 1.125 2005/09/30 13:59:13 dedekind Exp $ |
11 | * | 11 | * |
12 | */ | 12 | */ |
13 | #include <linux/kernel.h> | 13 | #include <linux/kernel.h> |
@@ -18,22 +18,11 @@ | |||
18 | #include <linux/crc32.h> | 18 | #include <linux/crc32.h> |
19 | #include <linux/compiler.h> | 19 | #include <linux/compiler.h> |
20 | #include "nodelist.h" | 20 | #include "nodelist.h" |
21 | #include "summary.h" | ||
22 | #include "debug.h" | ||
21 | 23 | ||
22 | #define DEFAULT_EMPTY_SCAN_SIZE 1024 | 24 | #define DEFAULT_EMPTY_SCAN_SIZE 1024 |
23 | 25 | ||
24 | #define DIRTY_SPACE(x) do { typeof(x) _x = (x); \ | ||
25 | c->free_size -= _x; c->dirty_size += _x; \ | ||
26 | jeb->free_size -= _x ; jeb->dirty_size += _x; \ | ||
27 | }while(0) | ||
28 | #define USED_SPACE(x) do { typeof(x) _x = (x); \ | ||
29 | c->free_size -= _x; c->used_size += _x; \ | ||
30 | jeb->free_size -= _x ; jeb->used_size += _x; \ | ||
31 | }while(0) | ||
32 | #define UNCHECKED_SPACE(x) do { typeof(x) _x = (x); \ | ||
33 | c->free_size -= _x; c->unchecked_size += _x; \ | ||
34 | jeb->free_size -= _x ; jeb->unchecked_size += _x; \ | ||
35 | }while(0) | ||
36 | |||
37 | #define noisy_printk(noise, args...) do { \ | 26 | #define noisy_printk(noise, args...) do { \ |
38 | if (*(noise)) { \ | 27 | if (*(noise)) { \ |
39 | printk(KERN_NOTICE args); \ | 28 | printk(KERN_NOTICE args); \ |
@@ -47,23 +36,16 @@ | |||
47 | static uint32_t pseudo_random; | 36 | static uint32_t pseudo_random; |
48 | 37 | ||
49 | static int jffs2_scan_eraseblock (struct jffs2_sb_info *c, struct jffs2_eraseblock *jeb, | 38 | static int jffs2_scan_eraseblock (struct jffs2_sb_info *c, struct jffs2_eraseblock *jeb, |
50 | unsigned char *buf, uint32_t buf_size); | 39 | unsigned char *buf, uint32_t buf_size, struct jffs2_summary *s); |
51 | 40 | ||
52 | /* These helper functions _must_ increase ofs and also do the dirty/used space accounting. | 41 | /* These helper functions _must_ increase ofs and also do the dirty/used space accounting. |
53 | * Returning an error will abort the mount - bad checksums etc. should just mark the space | 42 | * Returning an error will abort the mount - bad checksums etc. should just mark the space |
54 | * as dirty. | 43 | * as dirty. |
55 | */ | 44 | */ |
56 | static int jffs2_scan_inode_node(struct jffs2_sb_info *c, struct jffs2_eraseblock *jeb, | 45 | static int jffs2_scan_inode_node(struct jffs2_sb_info *c, struct jffs2_eraseblock *jeb, |
57 | struct jffs2_raw_inode *ri, uint32_t ofs); | 46 | struct jffs2_raw_inode *ri, uint32_t ofs, struct jffs2_summary *s); |
58 | static int jffs2_scan_dirent_node(struct jffs2_sb_info *c, struct jffs2_eraseblock *jeb, | 47 | static int jffs2_scan_dirent_node(struct jffs2_sb_info *c, struct jffs2_eraseblock *jeb, |
59 | struct jffs2_raw_dirent *rd, uint32_t ofs); | 48 | struct jffs2_raw_dirent *rd, uint32_t ofs, struct jffs2_summary *s); |
60 | |||
61 | #define BLK_STATE_ALLFF 0 | ||
62 | #define BLK_STATE_CLEAN 1 | ||
63 | #define BLK_STATE_PARTDIRTY 2 | ||
64 | #define BLK_STATE_CLEANMARKER 3 | ||
65 | #define BLK_STATE_ALLDIRTY 4 | ||
66 | #define BLK_STATE_BADBLOCK 5 | ||
67 | 49 | ||
68 | static inline int min_free(struct jffs2_sb_info *c) | 50 | static inline int min_free(struct jffs2_sb_info *c) |
69 | { | 51 | { |
@@ -89,6 +71,7 @@ int jffs2_scan_medium(struct jffs2_sb_info *c) | |||
89 | uint32_t empty_blocks = 0, bad_blocks = 0; | 71 | uint32_t empty_blocks = 0, bad_blocks = 0; |
90 | unsigned char *flashbuf = NULL; | 72 | unsigned char *flashbuf = NULL; |
91 | uint32_t buf_size = 0; | 73 | uint32_t buf_size = 0; |
74 | struct jffs2_summary *s = NULL; /* summary info collected by the scan process */ | ||
92 | #ifndef __ECOS | 75 | #ifndef __ECOS |
93 | size_t pointlen; | 76 | size_t pointlen; |
94 | 77 | ||
@@ -122,21 +105,34 @@ int jffs2_scan_medium(struct jffs2_sb_info *c) | |||
122 | return -ENOMEM; | 105 | return -ENOMEM; |
123 | } | 106 | } |
124 | 107 | ||
108 | if (jffs2_sum_active()) { | ||
109 | s = kmalloc(sizeof(struct jffs2_summary), GFP_KERNEL); | ||
110 | if (!s) { | ||
111 | JFFS2_WARNING("Can't allocate memory for summary\n"); | ||
112 | return -ENOMEM; | ||
113 | } | ||
114 | memset(s, 0, sizeof(struct jffs2_summary)); | ||
115 | } | ||
116 | |||
125 | for (i=0; i<c->nr_blocks; i++) { | 117 | for (i=0; i<c->nr_blocks; i++) { |
126 | struct jffs2_eraseblock *jeb = &c->blocks[i]; | 118 | struct jffs2_eraseblock *jeb = &c->blocks[i]; |
127 | 119 | ||
128 | ret = jffs2_scan_eraseblock(c, jeb, buf_size?flashbuf:(flashbuf+jeb->offset), buf_size); | 120 | /* reset summary info for next eraseblock scan */ |
121 | jffs2_sum_reset_collected(s); | ||
122 | |||
123 | ret = jffs2_scan_eraseblock(c, jeb, buf_size?flashbuf:(flashbuf+jeb->offset), | ||
124 | buf_size, s); | ||
129 | 125 | ||
130 | if (ret < 0) | 126 | if (ret < 0) |
131 | goto out; | 127 | goto out; |
132 | 128 | ||
133 | ACCT_PARANOIA_CHECK(jeb); | 129 | jffs2_dbg_acct_paranoia_check_nolock(c, jeb); |
134 | 130 | ||
135 | /* Now decide which list to put it on */ | 131 | /* Now decide which list to put it on */ |
136 | switch(ret) { | 132 | switch(ret) { |
137 | case BLK_STATE_ALLFF: | 133 | case BLK_STATE_ALLFF: |
138 | /* | 134 | /* |
139 | * Empty block. Since we can't be sure it | 135 | * Empty block. Since we can't be sure it |
140 | * was entirely erased, we just queue it for erase | 136 | * was entirely erased, we just queue it for erase |
141 | * again. It will be marked as such when the erase | 137 | * again. It will be marked as such when the erase |
142 | * is complete. Meanwhile we still count it as empty | 138 | * is complete. Meanwhile we still count it as empty |
@@ -162,18 +158,18 @@ int jffs2_scan_medium(struct jffs2_sb_info *c) | |||
162 | break; | 158 | break; |
163 | 159 | ||
164 | case BLK_STATE_CLEAN: | 160 | case BLK_STATE_CLEAN: |
165 | /* Full (or almost full) of clean data. Clean list */ | 161 | /* Full (or almost full) of clean data. Clean list */ |
166 | list_add(&jeb->list, &c->clean_list); | 162 | list_add(&jeb->list, &c->clean_list); |
167 | break; | 163 | break; |
168 | 164 | ||
169 | case BLK_STATE_PARTDIRTY: | 165 | case BLK_STATE_PARTDIRTY: |
170 | /* Some data, but not full. Dirty list. */ | 166 | /* Some data, but not full. Dirty list. */ |
171 | /* We want to remember the block with most free space | 167 | /* We want to remember the block with most free space |
172 | and stick it in the 'nextblock' position to start writing to it. */ | 168 | and stick it in the 'nextblock' position to start writing to it. */ |
173 | if (jeb->free_size > min_free(c) && | 169 | if (jeb->free_size > min_free(c) && |
174 | (!c->nextblock || c->nextblock->free_size < jeb->free_size)) { | 170 | (!c->nextblock || c->nextblock->free_size < jeb->free_size)) { |
175 | /* Better candidate for the next writes to go to */ | 171 | /* Better candidate for the next writes to go to */ |
176 | if (c->nextblock) { | 172 | if (c->nextblock) { |
177 | c->nextblock->dirty_size += c->nextblock->free_size + c->nextblock->wasted_size; | 173 | c->nextblock->dirty_size += c->nextblock->free_size + c->nextblock->wasted_size; |
178 | c->dirty_size += c->nextblock->free_size + c->nextblock->wasted_size; | 174 | c->dirty_size += c->nextblock->free_size + c->nextblock->wasted_size; |
179 | c->free_size -= c->nextblock->free_size; | 175 | c->free_size -= c->nextblock->free_size; |
@@ -184,9 +180,14 @@ int jffs2_scan_medium(struct jffs2_sb_info *c) | |||
184 | } else { | 180 | } else { |
185 | list_add(&c->nextblock->list, &c->dirty_list); | 181 | list_add(&c->nextblock->list, &c->dirty_list); |
186 | } | 182 | } |
183 | /* deleting summary information of the old nextblock */ | ||
184 | jffs2_sum_reset_collected(c->summary); | ||
187 | } | 185 | } |
188 | c->nextblock = jeb; | 186 | /* update collected summary infromation for the current nextblock */ |
189 | } else { | 187 | jffs2_sum_move_collected(c, s); |
188 | D1(printk(KERN_DEBUG "jffs2_scan_medium(): new nextblock = 0x%08x\n", jeb->offset)); | ||
189 | c->nextblock = jeb; | ||
190 | } else { | ||
190 | jeb->dirty_size += jeb->free_size + jeb->wasted_size; | 191 | jeb->dirty_size += jeb->free_size + jeb->wasted_size; |
191 | c->dirty_size += jeb->free_size + jeb->wasted_size; | 192 | c->dirty_size += jeb->free_size + jeb->wasted_size; |
192 | c->free_size -= jeb->free_size; | 193 | c->free_size -= jeb->free_size; |
@@ -197,30 +198,33 @@ int jffs2_scan_medium(struct jffs2_sb_info *c) | |||
197 | } else { | 198 | } else { |
198 | list_add(&jeb->list, &c->dirty_list); | 199 | list_add(&jeb->list, &c->dirty_list); |
199 | } | 200 | } |
200 | } | 201 | } |
201 | break; | 202 | break; |
202 | 203 | ||
203 | case BLK_STATE_ALLDIRTY: | 204 | case BLK_STATE_ALLDIRTY: |
204 | /* Nothing valid - not even a clean marker. Needs erasing. */ | 205 | /* Nothing valid - not even a clean marker. Needs erasing. */ |
205 | /* For now we just put it on the erasing list. We'll start the erases later */ | 206 | /* For now we just put it on the erasing list. We'll start the erases later */ |
206 | D1(printk(KERN_NOTICE "JFFS2: Erase block at 0x%08x is not formatted. It will be erased\n", jeb->offset)); | 207 | D1(printk(KERN_NOTICE "JFFS2: Erase block at 0x%08x is not formatted. It will be erased\n", jeb->offset)); |
207 | list_add(&jeb->list, &c->erase_pending_list); | 208 | list_add(&jeb->list, &c->erase_pending_list); |
208 | c->nr_erasing_blocks++; | 209 | c->nr_erasing_blocks++; |
209 | break; | 210 | break; |
210 | 211 | ||
211 | case BLK_STATE_BADBLOCK: | 212 | case BLK_STATE_BADBLOCK: |
212 | D1(printk(KERN_NOTICE "JFFS2: Block at 0x%08x is bad\n", jeb->offset)); | 213 | D1(printk(KERN_NOTICE "JFFS2: Block at 0x%08x is bad\n", jeb->offset)); |
213 | list_add(&jeb->list, &c->bad_list); | 214 | list_add(&jeb->list, &c->bad_list); |
214 | c->bad_size += c->sector_size; | 215 | c->bad_size += c->sector_size; |
215 | c->free_size -= c->sector_size; | 216 | c->free_size -= c->sector_size; |
216 | bad_blocks++; | 217 | bad_blocks++; |
217 | break; | 218 | break; |
218 | default: | 219 | default: |
219 | printk(KERN_WARNING "jffs2_scan_medium(): unknown block state\n"); | 220 | printk(KERN_WARNING "jffs2_scan_medium(): unknown block state\n"); |
220 | BUG(); | 221 | BUG(); |
221 | } | 222 | } |
222 | } | 223 | } |
223 | 224 | ||
225 | if (jffs2_sum_active() && s) | ||
226 | kfree(s); | ||
227 | |||
224 | /* Nextblock dirty is always seen as wasted, because we cannot recycle it now */ | 228 | /* Nextblock dirty is always seen as wasted, because we cannot recycle it now */ |
225 | if (c->nextblock && (c->nextblock->dirty_size)) { | 229 | if (c->nextblock && (c->nextblock->dirty_size)) { |
226 | c->nextblock->wasted_size += c->nextblock->dirty_size; | 230 | c->nextblock->wasted_size += c->nextblock->dirty_size; |
@@ -229,12 +233,12 @@ int jffs2_scan_medium(struct jffs2_sb_info *c) | |||
229 | c->nextblock->dirty_size = 0; | 233 | c->nextblock->dirty_size = 0; |
230 | } | 234 | } |
231 | #ifdef CONFIG_JFFS2_FS_WRITEBUFFER | 235 | #ifdef CONFIG_JFFS2_FS_WRITEBUFFER |
232 | if (!jffs2_can_mark_obsolete(c) && c->nextblock && (c->nextblock->free_size & (c->wbuf_pagesize-1))) { | 236 | if (!jffs2_can_mark_obsolete(c) && c->nextblock && (c->nextblock->free_size % c->wbuf_pagesize)) { |
233 | /* If we're going to start writing into a block which already | 237 | /* If we're going to start writing into a block which already |
234 | contains data, and the end of the data isn't page-aligned, | 238 | contains data, and the end of the data isn't page-aligned, |
235 | skip a little and align it. */ | 239 | skip a little and align it. */ |
236 | 240 | ||
237 | uint32_t skip = c->nextblock->free_size & (c->wbuf_pagesize-1); | 241 | uint32_t skip = c->nextblock->free_size % c->wbuf_pagesize; |
238 | 242 | ||
239 | D1(printk(KERN_DEBUG "jffs2_scan_medium(): Skipping %d bytes in nextblock to ensure page alignment\n", | 243 | D1(printk(KERN_DEBUG "jffs2_scan_medium(): Skipping %d bytes in nextblock to ensure page alignment\n", |
240 | skip)); | 244 | skip)); |
@@ -246,7 +250,7 @@ int jffs2_scan_medium(struct jffs2_sb_info *c) | |||
246 | } | 250 | } |
247 | #endif | 251 | #endif |
248 | if (c->nr_erasing_blocks) { | 252 | if (c->nr_erasing_blocks) { |
249 | if ( !c->used_size && ((c->nr_free_blocks+empty_blocks+bad_blocks)!= c->nr_blocks || bad_blocks == c->nr_blocks) ) { | 253 | if ( !c->used_size && ((c->nr_free_blocks+empty_blocks+bad_blocks)!= c->nr_blocks || bad_blocks == c->nr_blocks) ) { |
250 | printk(KERN_NOTICE "Cowardly refusing to erase blocks on filesystem with no valid JFFS2 nodes\n"); | 254 | printk(KERN_NOTICE "Cowardly refusing to erase blocks on filesystem with no valid JFFS2 nodes\n"); |
251 | printk(KERN_NOTICE "empty_blocks %d, bad_blocks %d, c->nr_blocks %d\n",empty_blocks,bad_blocks,c->nr_blocks); | 255 | printk(KERN_NOTICE "empty_blocks %d, bad_blocks %d, c->nr_blocks %d\n",empty_blocks,bad_blocks,c->nr_blocks); |
252 | ret = -EIO; | 256 | ret = -EIO; |
@@ -259,13 +263,13 @@ int jffs2_scan_medium(struct jffs2_sb_info *c) | |||
259 | if (buf_size) | 263 | if (buf_size) |
260 | kfree(flashbuf); | 264 | kfree(flashbuf); |
261 | #ifndef __ECOS | 265 | #ifndef __ECOS |
262 | else | 266 | else |
263 | c->mtd->unpoint(c->mtd, flashbuf, 0, c->mtd->size); | 267 | c->mtd->unpoint(c->mtd, flashbuf, 0, c->mtd->size); |
264 | #endif | 268 | #endif |
265 | return ret; | 269 | return ret; |
266 | } | 270 | } |
267 | 271 | ||
268 | static int jffs2_fill_scan_buf (struct jffs2_sb_info *c, unsigned char *buf, | 272 | int jffs2_fill_scan_buf (struct jffs2_sb_info *c, void *buf, |
269 | uint32_t ofs, uint32_t len) | 273 | uint32_t ofs, uint32_t len) |
270 | { | 274 | { |
271 | int ret; | 275 | int ret; |
@@ -286,14 +290,36 @@ static int jffs2_fill_scan_buf (struct jffs2_sb_info *c, unsigned char *buf, | |||
286 | return 0; | 290 | return 0; |
287 | } | 291 | } |
288 | 292 | ||
293 | int jffs2_scan_classify_jeb(struct jffs2_sb_info *c, struct jffs2_eraseblock *jeb) | ||
294 | { | ||
295 | if ((jeb->used_size + jeb->unchecked_size) == PAD(c->cleanmarker_size) && !jeb->dirty_size | ||
296 | && (!jeb->first_node || !jeb->first_node->next_phys) ) | ||
297 | return BLK_STATE_CLEANMARKER; | ||
298 | |||
299 | /* move blocks with max 4 byte dirty space to cleanlist */ | ||
300 | else if (!ISDIRTY(c->sector_size - (jeb->used_size + jeb->unchecked_size))) { | ||
301 | c->dirty_size -= jeb->dirty_size; | ||
302 | c->wasted_size += jeb->dirty_size; | ||
303 | jeb->wasted_size += jeb->dirty_size; | ||
304 | jeb->dirty_size = 0; | ||
305 | return BLK_STATE_CLEAN; | ||
306 | } else if (jeb->used_size || jeb->unchecked_size) | ||
307 | return BLK_STATE_PARTDIRTY; | ||
308 | else | ||
309 | return BLK_STATE_ALLDIRTY; | ||
310 | } | ||
311 | |||
289 | static int jffs2_scan_eraseblock (struct jffs2_sb_info *c, struct jffs2_eraseblock *jeb, | 312 | static int jffs2_scan_eraseblock (struct jffs2_sb_info *c, struct jffs2_eraseblock *jeb, |
290 | unsigned char *buf, uint32_t buf_size) { | 313 | unsigned char *buf, uint32_t buf_size, struct jffs2_summary *s) { |
291 | struct jffs2_unknown_node *node; | 314 | struct jffs2_unknown_node *node; |
292 | struct jffs2_unknown_node crcnode; | 315 | struct jffs2_unknown_node crcnode; |
316 | struct jffs2_sum_marker *sm; | ||
293 | uint32_t ofs, prevofs; | 317 | uint32_t ofs, prevofs; |
294 | uint32_t hdr_crc, buf_ofs, buf_len; | 318 | uint32_t hdr_crc, buf_ofs, buf_len; |
295 | int err; | 319 | int err; |
296 | int noise = 0; | 320 | int noise = 0; |
321 | |||
322 | |||
297 | #ifdef CONFIG_JFFS2_FS_WRITEBUFFER | 323 | #ifdef CONFIG_JFFS2_FS_WRITEBUFFER |
298 | int cleanmarkerfound = 0; | 324 | int cleanmarkerfound = 0; |
299 | #endif | 325 | #endif |
@@ -319,17 +345,53 @@ static int jffs2_scan_eraseblock (struct jffs2_sb_info *c, struct jffs2_eraseblo | |||
319 | } | 345 | } |
320 | } | 346 | } |
321 | #endif | 347 | #endif |
348 | |||
349 | if (jffs2_sum_active()) { | ||
350 | sm = kmalloc(sizeof(struct jffs2_sum_marker), GFP_KERNEL); | ||
351 | if (!sm) { | ||
352 | return -ENOMEM; | ||
353 | } | ||
354 | |||
355 | err = jffs2_fill_scan_buf(c, (unsigned char *) sm, jeb->offset + c->sector_size - | ||
356 | sizeof(struct jffs2_sum_marker), sizeof(struct jffs2_sum_marker)); | ||
357 | if (err) { | ||
358 | kfree(sm); | ||
359 | return err; | ||
360 | } | ||
361 | |||
362 | if (je32_to_cpu(sm->magic) == JFFS2_SUM_MAGIC ) { | ||
363 | err = jffs2_sum_scan_sumnode(c, jeb, je32_to_cpu(sm->offset), &pseudo_random); | ||
364 | if (err) { | ||
365 | kfree(sm); | ||
366 | return err; | ||
367 | } | ||
368 | } | ||
369 | |||
370 | kfree(sm); | ||
371 | |||
372 | ofs = jeb->offset; | ||
373 | prevofs = jeb->offset - 1; | ||
374 | } | ||
375 | |||
322 | buf_ofs = jeb->offset; | 376 | buf_ofs = jeb->offset; |
323 | 377 | ||
324 | if (!buf_size) { | 378 | if (!buf_size) { |
325 | buf_len = c->sector_size; | 379 | buf_len = c->sector_size; |
380 | |||
381 | if (jffs2_sum_active()) { | ||
382 | /* must reread because of summary test */ | ||
383 | err = jffs2_fill_scan_buf(c, buf, buf_ofs, buf_len); | ||
384 | if (err) | ||
385 | return err; | ||
386 | } | ||
387 | |||
326 | } else { | 388 | } else { |
327 | buf_len = EMPTY_SCAN_SIZE(c->sector_size); | 389 | buf_len = EMPTY_SCAN_SIZE(c->sector_size); |
328 | err = jffs2_fill_scan_buf(c, buf, buf_ofs, buf_len); | 390 | err = jffs2_fill_scan_buf(c, buf, buf_ofs, buf_len); |
329 | if (err) | 391 | if (err) |
330 | return err; | 392 | return err; |
331 | } | 393 | } |
332 | 394 | ||
333 | /* We temporarily use 'ofs' as a pointer into the buffer/jeb */ | 395 | /* We temporarily use 'ofs' as a pointer into the buffer/jeb */ |
334 | ofs = 0; | 396 | ofs = 0; |
335 | 397 | ||
@@ -367,10 +429,12 @@ static int jffs2_scan_eraseblock (struct jffs2_sb_info *c, struct jffs2_eraseblo | |||
367 | 429 | ||
368 | noise = 10; | 430 | noise = 10; |
369 | 431 | ||
370 | scan_more: | 432 | dbg_summary("no summary found in jeb 0x%08x. Apply original scan.\n",jeb->offset); |
433 | |||
434 | scan_more: | ||
371 | while(ofs < jeb->offset + c->sector_size) { | 435 | while(ofs < jeb->offset + c->sector_size) { |
372 | 436 | ||
373 | D1(ACCT_PARANOIA_CHECK(jeb)); | 437 | jffs2_dbg_acct_paranoia_check_nolock(c, jeb); |
374 | 438 | ||
375 | cond_resched(); | 439 | cond_resched(); |
376 | 440 | ||
@@ -432,7 +496,7 @@ scan_more: | |||
432 | 496 | ||
433 | /* If we're only checking the beginning of a block with a cleanmarker, | 497 | /* If we're only checking the beginning of a block with a cleanmarker, |
434 | bail now */ | 498 | bail now */ |
435 | if (buf_ofs == jeb->offset && jeb->used_size == PAD(c->cleanmarker_size) && | 499 | if (buf_ofs == jeb->offset && jeb->used_size == PAD(c->cleanmarker_size) && |
436 | c->cleanmarker_size && !jeb->dirty_size && !jeb->first_node->next_phys) { | 500 | c->cleanmarker_size && !jeb->dirty_size && !jeb->first_node->next_phys) { |
437 | D1(printk(KERN_DEBUG "%d bytes at start of block seems clean... assuming all clean\n", EMPTY_SCAN_SIZE(c->sector_size))); | 501 | D1(printk(KERN_DEBUG "%d bytes at start of block seems clean... assuming all clean\n", EMPTY_SCAN_SIZE(c->sector_size))); |
438 | return BLK_STATE_CLEANMARKER; | 502 | return BLK_STATE_CLEANMARKER; |
@@ -441,7 +505,7 @@ scan_more: | |||
441 | /* See how much more there is to read in this eraseblock... */ | 505 | /* See how much more there is to read in this eraseblock... */ |
442 | buf_len = min_t(uint32_t, buf_size, jeb->offset + c->sector_size - ofs); | 506 | buf_len = min_t(uint32_t, buf_size, jeb->offset + c->sector_size - ofs); |
443 | if (!buf_len) { | 507 | if (!buf_len) { |
444 | /* No more to read. Break out of main loop without marking | 508 | /* No more to read. Break out of main loop without marking |
445 | this range of empty space as dirty (because it's not) */ | 509 | this range of empty space as dirty (because it's not) */ |
446 | D1(printk(KERN_DEBUG "Empty flash at %08x runs to end of block. Treating as free_space\n", | 510 | D1(printk(KERN_DEBUG "Empty flash at %08x runs to end of block. Treating as free_space\n", |
447 | empty_start)); | 511 | empty_start)); |
@@ -476,8 +540,8 @@ scan_more: | |||
476 | } | 540 | } |
477 | if (je16_to_cpu(node->magic) != JFFS2_MAGIC_BITMASK) { | 541 | if (je16_to_cpu(node->magic) != JFFS2_MAGIC_BITMASK) { |
478 | /* OK. We're out of possibilities. Whinge and move on */ | 542 | /* OK. We're out of possibilities. Whinge and move on */ |
479 | noisy_printk(&noise, "jffs2_scan_eraseblock(): Magic bitmask 0x%04x not found at 0x%08x: 0x%04x instead\n", | 543 | noisy_printk(&noise, "jffs2_scan_eraseblock(): Magic bitmask 0x%04x not found at 0x%08x: 0x%04x instead\n", |
480 | JFFS2_MAGIC_BITMASK, ofs, | 544 | JFFS2_MAGIC_BITMASK, ofs, |
481 | je16_to_cpu(node->magic)); | 545 | je16_to_cpu(node->magic)); |
482 | DIRTY_SPACE(4); | 546 | DIRTY_SPACE(4); |
483 | ofs += 4; | 547 | ofs += 4; |
@@ -492,7 +556,7 @@ scan_more: | |||
492 | if (hdr_crc != je32_to_cpu(node->hdr_crc)) { | 556 | if (hdr_crc != je32_to_cpu(node->hdr_crc)) { |
493 | noisy_printk(&noise, "jffs2_scan_eraseblock(): Node at 0x%08x {0x%04x, 0x%04x, 0x%08x) has invalid CRC 0x%08x (calculated 0x%08x)\n", | 557 | noisy_printk(&noise, "jffs2_scan_eraseblock(): Node at 0x%08x {0x%04x, 0x%04x, 0x%08x) has invalid CRC 0x%08x (calculated 0x%08x)\n", |
494 | ofs, je16_to_cpu(node->magic), | 558 | ofs, je16_to_cpu(node->magic), |
495 | je16_to_cpu(node->nodetype), | 559 | je16_to_cpu(node->nodetype), |
496 | je32_to_cpu(node->totlen), | 560 | je32_to_cpu(node->totlen), |
497 | je32_to_cpu(node->hdr_crc), | 561 | je32_to_cpu(node->hdr_crc), |
498 | hdr_crc); | 562 | hdr_crc); |
@@ -501,7 +565,7 @@ scan_more: | |||
501 | continue; | 565 | continue; |
502 | } | 566 | } |
503 | 567 | ||
504 | if (ofs + je32_to_cpu(node->totlen) > | 568 | if (ofs + je32_to_cpu(node->totlen) > |
505 | jeb->offset + c->sector_size) { | 569 | jeb->offset + c->sector_size) { |
506 | /* Eep. Node goes over the end of the erase block. */ | 570 | /* Eep. Node goes over the end of the erase block. */ |
507 | printk(KERN_WARNING "Node at 0x%08x with length 0x%08x would run over the end of the erase block\n", | 571 | printk(KERN_WARNING "Node at 0x%08x with length 0x%08x would run over the end of the erase block\n", |
@@ -532,11 +596,11 @@ scan_more: | |||
532 | buf_ofs = ofs; | 596 | buf_ofs = ofs; |
533 | node = (void *)buf; | 597 | node = (void *)buf; |
534 | } | 598 | } |
535 | err = jffs2_scan_inode_node(c, jeb, (void *)node, ofs); | 599 | err = jffs2_scan_inode_node(c, jeb, (void *)node, ofs, s); |
536 | if (err) return err; | 600 | if (err) return err; |
537 | ofs += PAD(je32_to_cpu(node->totlen)); | 601 | ofs += PAD(je32_to_cpu(node->totlen)); |
538 | break; | 602 | break; |
539 | 603 | ||
540 | case JFFS2_NODETYPE_DIRENT: | 604 | case JFFS2_NODETYPE_DIRENT: |
541 | if (buf_ofs + buf_len < ofs + je32_to_cpu(node->totlen)) { | 605 | if (buf_ofs + buf_len < ofs + je32_to_cpu(node->totlen)) { |
542 | buf_len = min_t(uint32_t, buf_size, jeb->offset + c->sector_size - ofs); | 606 | buf_len = min_t(uint32_t, buf_size, jeb->offset + c->sector_size - ofs); |
@@ -548,7 +612,7 @@ scan_more: | |||
548 | buf_ofs = ofs; | 612 | buf_ofs = ofs; |
549 | node = (void *)buf; | 613 | node = (void *)buf; |
550 | } | 614 | } |
551 | err = jffs2_scan_dirent_node(c, jeb, (void *)node, ofs); | 615 | err = jffs2_scan_dirent_node(c, jeb, (void *)node, ofs, s); |
552 | if (err) return err; | 616 | if (err) return err; |
553 | ofs += PAD(je32_to_cpu(node->totlen)); | 617 | ofs += PAD(je32_to_cpu(node->totlen)); |
554 | break; | 618 | break; |
@@ -556,7 +620,7 @@ scan_more: | |||
556 | case JFFS2_NODETYPE_CLEANMARKER: | 620 | case JFFS2_NODETYPE_CLEANMARKER: |
557 | D1(printk(KERN_DEBUG "CLEANMARKER node found at 0x%08x\n", ofs)); | 621 | D1(printk(KERN_DEBUG "CLEANMARKER node found at 0x%08x\n", ofs)); |
558 | if (je32_to_cpu(node->totlen) != c->cleanmarker_size) { | 622 | if (je32_to_cpu(node->totlen) != c->cleanmarker_size) { |
559 | printk(KERN_NOTICE "CLEANMARKER node found at 0x%08x has totlen 0x%x != normal 0x%x\n", | 623 | printk(KERN_NOTICE "CLEANMARKER node found at 0x%08x has totlen 0x%x != normal 0x%x\n", |
560 | ofs, je32_to_cpu(node->totlen), c->cleanmarker_size); | 624 | ofs, je32_to_cpu(node->totlen), c->cleanmarker_size); |
561 | DIRTY_SPACE(PAD(sizeof(struct jffs2_unknown_node))); | 625 | DIRTY_SPACE(PAD(sizeof(struct jffs2_unknown_node))); |
562 | ofs += PAD(sizeof(struct jffs2_unknown_node)); | 626 | ofs += PAD(sizeof(struct jffs2_unknown_node)); |
@@ -575,13 +639,15 @@ scan_more: | |||
575 | marker_ref->flash_offset = ofs | REF_NORMAL; | 639 | marker_ref->flash_offset = ofs | REF_NORMAL; |
576 | marker_ref->__totlen = c->cleanmarker_size; | 640 | marker_ref->__totlen = c->cleanmarker_size; |
577 | jeb->first_node = jeb->last_node = marker_ref; | 641 | jeb->first_node = jeb->last_node = marker_ref; |
578 | 642 | ||
579 | USED_SPACE(PAD(c->cleanmarker_size)); | 643 | USED_SPACE(PAD(c->cleanmarker_size)); |
580 | ofs += PAD(c->cleanmarker_size); | 644 | ofs += PAD(c->cleanmarker_size); |
581 | } | 645 | } |
582 | break; | 646 | break; |
583 | 647 | ||
584 | case JFFS2_NODETYPE_PADDING: | 648 | case JFFS2_NODETYPE_PADDING: |
649 | if (jffs2_sum_active()) | ||
650 | jffs2_sum_add_padding_mem(s, je32_to_cpu(node->totlen)); | ||
585 | DIRTY_SPACE(PAD(je32_to_cpu(node->totlen))); | 651 | DIRTY_SPACE(PAD(je32_to_cpu(node->totlen))); |
586 | ofs += PAD(je32_to_cpu(node->totlen)); | 652 | ofs += PAD(je32_to_cpu(node->totlen)); |
587 | break; | 653 | break; |
@@ -616,8 +682,15 @@ scan_more: | |||
616 | } | 682 | } |
617 | } | 683 | } |
618 | 684 | ||
685 | if (jffs2_sum_active()) { | ||
686 | if (PAD(s->sum_size + JFFS2_SUMMARY_FRAME_SIZE) > jeb->free_size) { | ||
687 | dbg_summary("There is not enough space for " | ||
688 | "summary information, disabling for this jeb!\n"); | ||
689 | jffs2_sum_disable_collecting(s); | ||
690 | } | ||
691 | } | ||
619 | 692 | ||
620 | D1(printk(KERN_DEBUG "Block at 0x%08x: free 0x%08x, dirty 0x%08x, unchecked 0x%08x, used 0x%08x\n", jeb->offset, | 693 | D1(printk(KERN_DEBUG "Block at 0x%08x: free 0x%08x, dirty 0x%08x, unchecked 0x%08x, used 0x%08x\n", jeb->offset, |
621 | jeb->free_size, jeb->dirty_size, jeb->unchecked_size, jeb->used_size)); | 694 | jeb->free_size, jeb->dirty_size, jeb->unchecked_size, jeb->used_size)); |
622 | 695 | ||
623 | /* mark_node_obsolete can add to wasted !! */ | 696 | /* mark_node_obsolete can add to wasted !! */ |
@@ -628,24 +701,10 @@ scan_more: | |||
628 | jeb->wasted_size = 0; | 701 | jeb->wasted_size = 0; |
629 | } | 702 | } |
630 | 703 | ||
631 | if ((jeb->used_size + jeb->unchecked_size) == PAD(c->cleanmarker_size) && !jeb->dirty_size | 704 | return jffs2_scan_classify_jeb(c, jeb); |
632 | && (!jeb->first_node || !jeb->first_node->next_phys) ) | ||
633 | return BLK_STATE_CLEANMARKER; | ||
634 | |||
635 | /* move blocks with max 4 byte dirty space to cleanlist */ | ||
636 | else if (!ISDIRTY(c->sector_size - (jeb->used_size + jeb->unchecked_size))) { | ||
637 | c->dirty_size -= jeb->dirty_size; | ||
638 | c->wasted_size += jeb->dirty_size; | ||
639 | jeb->wasted_size += jeb->dirty_size; | ||
640 | jeb->dirty_size = 0; | ||
641 | return BLK_STATE_CLEAN; | ||
642 | } else if (jeb->used_size || jeb->unchecked_size) | ||
643 | return BLK_STATE_PARTDIRTY; | ||
644 | else | ||
645 | return BLK_STATE_ALLDIRTY; | ||
646 | } | 705 | } |
647 | 706 | ||
648 | static struct jffs2_inode_cache *jffs2_scan_make_ino_cache(struct jffs2_sb_info *c, uint32_t ino) | 707 | struct jffs2_inode_cache *jffs2_scan_make_ino_cache(struct jffs2_sb_info *c, uint32_t ino) |
649 | { | 708 | { |
650 | struct jffs2_inode_cache *ic; | 709 | struct jffs2_inode_cache *ic; |
651 | 710 | ||
@@ -671,8 +730,8 @@ static struct jffs2_inode_cache *jffs2_scan_make_ino_cache(struct jffs2_sb_info | |||
671 | return ic; | 730 | return ic; |
672 | } | 731 | } |
673 | 732 | ||
674 | static int jffs2_scan_inode_node(struct jffs2_sb_info *c, struct jffs2_eraseblock *jeb, | 733 | static int jffs2_scan_inode_node(struct jffs2_sb_info *c, struct jffs2_eraseblock *jeb, |
675 | struct jffs2_raw_inode *ri, uint32_t ofs) | 734 | struct jffs2_raw_inode *ri, uint32_t ofs, struct jffs2_summary *s) |
676 | { | 735 | { |
677 | struct jffs2_raw_node_ref *raw; | 736 | struct jffs2_raw_node_ref *raw; |
678 | struct jffs2_inode_cache *ic; | 737 | struct jffs2_inode_cache *ic; |
@@ -681,11 +740,11 @@ static int jffs2_scan_inode_node(struct jffs2_sb_info *c, struct jffs2_erasebloc | |||
681 | D1(printk(KERN_DEBUG "jffs2_scan_inode_node(): Node at 0x%08x\n", ofs)); | 740 | D1(printk(KERN_DEBUG "jffs2_scan_inode_node(): Node at 0x%08x\n", ofs)); |
682 | 741 | ||
683 | /* We do very little here now. Just check the ino# to which we should attribute | 742 | /* We do very little here now. Just check the ino# to which we should attribute |
684 | this node; we can do all the CRC checking etc. later. There's a tradeoff here -- | 743 | this node; we can do all the CRC checking etc. later. There's a tradeoff here -- |
685 | we used to scan the flash once only, reading everything we want from it into | 744 | we used to scan the flash once only, reading everything we want from it into |
686 | memory, then building all our in-core data structures and freeing the extra | 745 | memory, then building all our in-core data structures and freeing the extra |
687 | information. Now we allow the first part of the mount to complete a lot quicker, | 746 | information. Now we allow the first part of the mount to complete a lot quicker, |
688 | but we have to go _back_ to the flash in order to finish the CRC checking, etc. | 747 | but we have to go _back_ to the flash in order to finish the CRC checking, etc. |
689 | Which means that the _full_ amount of time to get to proper write mode with GC | 748 | Which means that the _full_ amount of time to get to proper write mode with GC |
690 | operational may actually be _longer_ than before. Sucks to be me. */ | 749 | operational may actually be _longer_ than before. Sucks to be me. */ |
691 | 750 | ||
@@ -731,7 +790,7 @@ static int jffs2_scan_inode_node(struct jffs2_sb_info *c, struct jffs2_erasebloc | |||
731 | jeb->last_node->next_phys = raw; | 790 | jeb->last_node->next_phys = raw; |
732 | jeb->last_node = raw; | 791 | jeb->last_node = raw; |
733 | 792 | ||
734 | D1(printk(KERN_DEBUG "Node is ino #%u, version %d. Range 0x%x-0x%x\n", | 793 | D1(printk(KERN_DEBUG "Node is ino #%u, version %d. Range 0x%x-0x%x\n", |
735 | je32_to_cpu(ri->ino), je32_to_cpu(ri->version), | 794 | je32_to_cpu(ri->ino), je32_to_cpu(ri->version), |
736 | je32_to_cpu(ri->offset), | 795 | je32_to_cpu(ri->offset), |
737 | je32_to_cpu(ri->offset)+je32_to_cpu(ri->dsize))); | 796 | je32_to_cpu(ri->offset)+je32_to_cpu(ri->dsize))); |
@@ -739,11 +798,16 @@ static int jffs2_scan_inode_node(struct jffs2_sb_info *c, struct jffs2_erasebloc | |||
739 | pseudo_random += je32_to_cpu(ri->version); | 798 | pseudo_random += je32_to_cpu(ri->version); |
740 | 799 | ||
741 | UNCHECKED_SPACE(PAD(je32_to_cpu(ri->totlen))); | 800 | UNCHECKED_SPACE(PAD(je32_to_cpu(ri->totlen))); |
801 | |||
802 | if (jffs2_sum_active()) { | ||
803 | jffs2_sum_add_inode_mem(s, ri, ofs - jeb->offset); | ||
804 | } | ||
805 | |||
742 | return 0; | 806 | return 0; |
743 | } | 807 | } |
744 | 808 | ||
745 | static int jffs2_scan_dirent_node(struct jffs2_sb_info *c, struct jffs2_eraseblock *jeb, | 809 | static int jffs2_scan_dirent_node(struct jffs2_sb_info *c, struct jffs2_eraseblock *jeb, |
746 | struct jffs2_raw_dirent *rd, uint32_t ofs) | 810 | struct jffs2_raw_dirent *rd, uint32_t ofs, struct jffs2_summary *s) |
747 | { | 811 | { |
748 | struct jffs2_raw_node_ref *raw; | 812 | struct jffs2_raw_node_ref *raw; |
749 | struct jffs2_full_dirent *fd; | 813 | struct jffs2_full_dirent *fd; |
@@ -776,7 +840,7 @@ static int jffs2_scan_dirent_node(struct jffs2_sb_info *c, struct jffs2_eraseblo | |||
776 | crc = crc32(0, fd->name, rd->nsize); | 840 | crc = crc32(0, fd->name, rd->nsize); |
777 | if (crc != je32_to_cpu(rd->name_crc)) { | 841 | if (crc != je32_to_cpu(rd->name_crc)) { |
778 | printk(KERN_NOTICE "jffs2_scan_dirent_node(): Name CRC failed on node at 0x%08x: Read 0x%08x, calculated 0x%08x\n", | 842 | printk(KERN_NOTICE "jffs2_scan_dirent_node(): Name CRC failed on node at 0x%08x: Read 0x%08x, calculated 0x%08x\n", |
779 | ofs, je32_to_cpu(rd->name_crc), crc); | 843 | ofs, je32_to_cpu(rd->name_crc), crc); |
780 | D1(printk(KERN_NOTICE "Name for which CRC failed is (now) '%s', ino #%d\n", fd->name, je32_to_cpu(rd->ino))); | 844 | D1(printk(KERN_NOTICE "Name for which CRC failed is (now) '%s', ino #%d\n", fd->name, je32_to_cpu(rd->ino))); |
781 | jffs2_free_full_dirent(fd); | 845 | jffs2_free_full_dirent(fd); |
782 | /* FIXME: Why do we believe totlen? */ | 846 | /* FIXME: Why do we believe totlen? */ |
@@ -796,7 +860,7 @@ static int jffs2_scan_dirent_node(struct jffs2_sb_info *c, struct jffs2_eraseblo | |||
796 | jffs2_free_raw_node_ref(raw); | 860 | jffs2_free_raw_node_ref(raw); |
797 | return -ENOMEM; | 861 | return -ENOMEM; |
798 | } | 862 | } |
799 | 863 | ||
800 | raw->__totlen = PAD(je32_to_cpu(rd->totlen)); | 864 | raw->__totlen = PAD(je32_to_cpu(rd->totlen)); |
801 | raw->flash_offset = ofs | REF_PRISTINE; | 865 | raw->flash_offset = ofs | REF_PRISTINE; |
802 | raw->next_phys = NULL; | 866 | raw->next_phys = NULL; |
@@ -817,6 +881,10 @@ static int jffs2_scan_dirent_node(struct jffs2_sb_info *c, struct jffs2_eraseblo | |||
817 | USED_SPACE(PAD(je32_to_cpu(rd->totlen))); | 881 | USED_SPACE(PAD(je32_to_cpu(rd->totlen))); |
818 | jffs2_add_fd_to_list(c, fd, &ic->scan_dents); | 882 | jffs2_add_fd_to_list(c, fd, &ic->scan_dents); |
819 | 883 | ||
884 | if (jffs2_sum_active()) { | ||
885 | jffs2_sum_add_dirent_mem(s, rd, ofs - jeb->offset); | ||
886 | } | ||
887 | |||
820 | return 0; | 888 | return 0; |
821 | } | 889 | } |
822 | 890 | ||
@@ -852,76 +920,34 @@ void jffs2_rotate_lists(struct jffs2_sb_info *c) | |||
852 | x = count_list(&c->clean_list); | 920 | x = count_list(&c->clean_list); |
853 | if (x) { | 921 | if (x) { |
854 | rotateby = pseudo_random % x; | 922 | rotateby = pseudo_random % x; |
855 | D1(printk(KERN_DEBUG "Rotating clean_list by %d\n", rotateby)); | ||
856 | |||
857 | rotate_list((&c->clean_list), rotateby); | 923 | rotate_list((&c->clean_list), rotateby); |
858 | |||
859 | D1(printk(KERN_DEBUG "Erase block at front of clean_list is at %08x\n", | ||
860 | list_entry(c->clean_list.next, struct jffs2_eraseblock, list)->offset)); | ||
861 | } else { | ||
862 | D1(printk(KERN_DEBUG "Not rotating empty clean_list\n")); | ||
863 | } | 924 | } |
864 | 925 | ||
865 | x = count_list(&c->very_dirty_list); | 926 | x = count_list(&c->very_dirty_list); |
866 | if (x) { | 927 | if (x) { |
867 | rotateby = pseudo_random % x; | 928 | rotateby = pseudo_random % x; |
868 | D1(printk(KERN_DEBUG "Rotating very_dirty_list by %d\n", rotateby)); | ||
869 | |||
870 | rotate_list((&c->very_dirty_list), rotateby); | 929 | rotate_list((&c->very_dirty_list), rotateby); |
871 | |||
872 | D1(printk(KERN_DEBUG "Erase block at front of very_dirty_list is at %08x\n", | ||
873 | list_entry(c->very_dirty_list.next, struct jffs2_eraseblock, list)->offset)); | ||
874 | } else { | ||
875 | D1(printk(KERN_DEBUG "Not rotating empty very_dirty_list\n")); | ||
876 | } | 930 | } |
877 | 931 | ||
878 | x = count_list(&c->dirty_list); | 932 | x = count_list(&c->dirty_list); |
879 | if (x) { | 933 | if (x) { |
880 | rotateby = pseudo_random % x; | 934 | rotateby = pseudo_random % x; |
881 | D1(printk(KERN_DEBUG "Rotating dirty_list by %d\n", rotateby)); | ||
882 | |||
883 | rotate_list((&c->dirty_list), rotateby); | 935 | rotate_list((&c->dirty_list), rotateby); |
884 | |||
885 | D1(printk(KERN_DEBUG "Erase block at front of dirty_list is at %08x\n", | ||
886 | list_entry(c->dirty_list.next, struct jffs2_eraseblock, list)->offset)); | ||
887 | } else { | ||
888 | D1(printk(KERN_DEBUG "Not rotating empty dirty_list\n")); | ||
889 | } | 936 | } |
890 | 937 | ||
891 | x = count_list(&c->erasable_list); | 938 | x = count_list(&c->erasable_list); |
892 | if (x) { | 939 | if (x) { |
893 | rotateby = pseudo_random % x; | 940 | rotateby = pseudo_random % x; |
894 | D1(printk(KERN_DEBUG "Rotating erasable_list by %d\n", rotateby)); | ||
895 | |||
896 | rotate_list((&c->erasable_list), rotateby); | 941 | rotate_list((&c->erasable_list), rotateby); |
897 | |||
898 | D1(printk(KERN_DEBUG "Erase block at front of erasable_list is at %08x\n", | ||
899 | list_entry(c->erasable_list.next, struct jffs2_eraseblock, list)->offset)); | ||
900 | } else { | ||
901 | D1(printk(KERN_DEBUG "Not rotating empty erasable_list\n")); | ||
902 | } | 942 | } |
903 | 943 | ||
904 | if (c->nr_erasing_blocks) { | 944 | if (c->nr_erasing_blocks) { |
905 | rotateby = pseudo_random % c->nr_erasing_blocks; | 945 | rotateby = pseudo_random % c->nr_erasing_blocks; |
906 | D1(printk(KERN_DEBUG "Rotating erase_pending_list by %d\n", rotateby)); | ||
907 | |||
908 | rotate_list((&c->erase_pending_list), rotateby); | 946 | rotate_list((&c->erase_pending_list), rotateby); |
909 | |||
910 | D1(printk(KERN_DEBUG "Erase block at front of erase_pending_list is at %08x\n", | ||
911 | list_entry(c->erase_pending_list.next, struct jffs2_eraseblock, list)->offset)); | ||
912 | } else { | ||
913 | D1(printk(KERN_DEBUG "Not rotating empty erase_pending_list\n")); | ||
914 | } | 947 | } |
915 | 948 | ||
916 | if (c->nr_free_blocks) { | 949 | if (c->nr_free_blocks) { |
917 | rotateby = pseudo_random % c->nr_free_blocks; | 950 | rotateby = pseudo_random % c->nr_free_blocks; |
918 | D1(printk(KERN_DEBUG "Rotating free_list by %d\n", rotateby)); | ||
919 | |||
920 | rotate_list((&c->free_list), rotateby); | 951 | rotate_list((&c->free_list), rotateby); |
921 | |||
922 | D1(printk(KERN_DEBUG "Erase block at front of free_list is at %08x\n", | ||
923 | list_entry(c->free_list.next, struct jffs2_eraseblock, list)->offset)); | ||
924 | } else { | ||
925 | D1(printk(KERN_DEBUG "Not rotating empty free_list\n")); | ||
926 | } | 952 | } |
927 | } | 953 | } |
diff --git a/fs/jffs2/summary.c b/fs/jffs2/summary.c new file mode 100644 index 000000000000..fb9cec61fcf2 --- /dev/null +++ b/fs/jffs2/summary.c | |||
@@ -0,0 +1,730 @@ | |||
1 | /* | ||
2 | * JFFS2 -- Journalling Flash File System, Version 2. | ||
3 | * | ||
4 | * Copyright (C) 2004 Ferenc Havasi <havasi@inf.u-szeged.hu>, | ||
5 | * Zoltan Sogor <weth@inf.u-szeged.hu>, | ||
6 | * Patrik Kluba <pajko@halom.u-szeged.hu>, | ||
7 | * University of Szeged, Hungary | ||
8 | * | ||
9 | * For licensing information, see the file 'LICENCE' in this directory. | ||
10 | * | ||
11 | * $Id: summary.c,v 1.4 2005/09/26 11:37:21 havasi Exp $ | ||
12 | * | ||
13 | */ | ||
14 | |||
15 | #include <linux/kernel.h> | ||
16 | #include <linux/sched.h> | ||
17 | #include <linux/slab.h> | ||
18 | #include <linux/mtd/mtd.h> | ||
19 | #include <linux/pagemap.h> | ||
20 | #include <linux/crc32.h> | ||
21 | #include <linux/compiler.h> | ||
22 | #include <linux/vmalloc.h> | ||
23 | #include "nodelist.h" | ||
24 | #include "debug.h" | ||
25 | |||
26 | int jffs2_sum_init(struct jffs2_sb_info *c) | ||
27 | { | ||
28 | c->summary = kmalloc(sizeof(struct jffs2_summary), GFP_KERNEL); | ||
29 | |||
30 | if (!c->summary) { | ||
31 | JFFS2_WARNING("Can't allocate memory for summary information!\n"); | ||
32 | return -ENOMEM; | ||
33 | } | ||
34 | |||
35 | memset(c->summary, 0, sizeof(struct jffs2_summary)); | ||
36 | |||
37 | c->summary->sum_buf = vmalloc(c->sector_size); | ||
38 | |||
39 | if (!c->summary->sum_buf) { | ||
40 | JFFS2_WARNING("Can't allocate buffer for writing out summary information!\n"); | ||
41 | kfree(c->summary); | ||
42 | return -ENOMEM; | ||
43 | } | ||
44 | |||
45 | dbg_summary("returned succesfully\n"); | ||
46 | |||
47 | return 0; | ||
48 | } | ||
49 | |||
50 | void jffs2_sum_exit(struct jffs2_sb_info *c) | ||
51 | { | ||
52 | dbg_summary("called\n"); | ||
53 | |||
54 | jffs2_sum_disable_collecting(c->summary); | ||
55 | |||
56 | vfree(c->summary->sum_buf); | ||
57 | c->summary->sum_buf = NULL; | ||
58 | |||
59 | kfree(c->summary); | ||
60 | c->summary = NULL; | ||
61 | } | ||
62 | |||
63 | static int jffs2_sum_add_mem(struct jffs2_summary *s, union jffs2_sum_mem *item) | ||
64 | { | ||
65 | if (!s->sum_list_head) | ||
66 | s->sum_list_head = (union jffs2_sum_mem *) item; | ||
67 | if (s->sum_list_tail) | ||
68 | s->sum_list_tail->u.next = (union jffs2_sum_mem *) item; | ||
69 | s->sum_list_tail = (union jffs2_sum_mem *) item; | ||
70 | |||
71 | switch (je16_to_cpu(item->u.nodetype)) { | ||
72 | case JFFS2_NODETYPE_INODE: | ||
73 | s->sum_size += JFFS2_SUMMARY_INODE_SIZE; | ||
74 | s->sum_num++; | ||
75 | dbg_summary("inode (%u) added to summary\n", | ||
76 | je32_to_cpu(item->i.inode)); | ||
77 | break; | ||
78 | case JFFS2_NODETYPE_DIRENT: | ||
79 | s->sum_size += JFFS2_SUMMARY_DIRENT_SIZE(item->d.nsize); | ||
80 | s->sum_num++; | ||
81 | dbg_summary("dirent (%u) added to summary\n", | ||
82 | je32_to_cpu(item->d.ino)); | ||
83 | break; | ||
84 | default: | ||
85 | JFFS2_WARNING("UNKNOWN node type %u\n", | ||
86 | je16_to_cpu(item->u.nodetype)); | ||
87 | return 1; | ||
88 | } | ||
89 | return 0; | ||
90 | } | ||
91 | |||
92 | |||
93 | /* The following 3 functions are called from scan.c to collect summary info for not closed jeb */ | ||
94 | |||
95 | int jffs2_sum_add_padding_mem(struct jffs2_summary *s, uint32_t size) | ||
96 | { | ||
97 | dbg_summary("called with %u\n", size); | ||
98 | s->sum_padded += size; | ||
99 | return 0; | ||
100 | } | ||
101 | |||
102 | int jffs2_sum_add_inode_mem(struct jffs2_summary *s, struct jffs2_raw_inode *ri, | ||
103 | uint32_t ofs) | ||
104 | { | ||
105 | struct jffs2_sum_inode_mem *temp = kmalloc(sizeof(struct jffs2_sum_inode_mem), GFP_KERNEL); | ||
106 | |||
107 | if (!temp) | ||
108 | return -ENOMEM; | ||
109 | |||
110 | temp->nodetype = ri->nodetype; | ||
111 | temp->inode = ri->ino; | ||
112 | temp->version = ri->version; | ||
113 | temp->offset = cpu_to_je32(ofs); /* relative offset from the begining of the jeb */ | ||
114 | temp->totlen = ri->totlen; | ||
115 | temp->next = NULL; | ||
116 | |||
117 | return jffs2_sum_add_mem(s, (union jffs2_sum_mem *)temp); | ||
118 | } | ||
119 | |||
120 | int jffs2_sum_add_dirent_mem(struct jffs2_summary *s, struct jffs2_raw_dirent *rd, | ||
121 | uint32_t ofs) | ||
122 | { | ||
123 | struct jffs2_sum_dirent_mem *temp = | ||
124 | kmalloc(sizeof(struct jffs2_sum_dirent_mem) + rd->nsize, GFP_KERNEL); | ||
125 | |||
126 | if (!temp) | ||
127 | return -ENOMEM; | ||
128 | |||
129 | temp->nodetype = rd->nodetype; | ||
130 | temp->totlen = rd->totlen; | ||
131 | temp->offset = cpu_to_je32(ofs); /* relative from the begining of the jeb */ | ||
132 | temp->pino = rd->pino; | ||
133 | temp->version = rd->version; | ||
134 | temp->ino = rd->ino; | ||
135 | temp->nsize = rd->nsize; | ||
136 | temp->type = rd->type; | ||
137 | temp->next = NULL; | ||
138 | |||
139 | memcpy(temp->name, rd->name, rd->nsize); | ||
140 | |||
141 | return jffs2_sum_add_mem(s, (union jffs2_sum_mem *)temp); | ||
142 | } | ||
143 | |||
144 | /* Cleanup every collected summary information */ | ||
145 | |||
146 | static void jffs2_sum_clean_collected(struct jffs2_summary *s) | ||
147 | { | ||
148 | union jffs2_sum_mem *temp; | ||
149 | |||
150 | if (!s->sum_list_head) { | ||
151 | dbg_summary("already empty\n"); | ||
152 | } | ||
153 | while (s->sum_list_head) { | ||
154 | temp = s->sum_list_head; | ||
155 | s->sum_list_head = s->sum_list_head->u.next; | ||
156 | kfree(temp); | ||
157 | } | ||
158 | s->sum_list_tail = NULL; | ||
159 | s->sum_padded = 0; | ||
160 | s->sum_num = 0; | ||
161 | } | ||
162 | |||
163 | void jffs2_sum_reset_collected(struct jffs2_summary *s) | ||
164 | { | ||
165 | dbg_summary("called\n"); | ||
166 | jffs2_sum_clean_collected(s); | ||
167 | s->sum_size = 0; | ||
168 | } | ||
169 | |||
170 | void jffs2_sum_disable_collecting(struct jffs2_summary *s) | ||
171 | { | ||
172 | dbg_summary("called\n"); | ||
173 | jffs2_sum_clean_collected(s); | ||
174 | s->sum_size = JFFS2_SUMMARY_NOSUM_SIZE; | ||
175 | } | ||
176 | |||
177 | int jffs2_sum_is_disabled(struct jffs2_summary *s) | ||
178 | { | ||
179 | return (s->sum_size == JFFS2_SUMMARY_NOSUM_SIZE); | ||
180 | } | ||
181 | |||
182 | /* Move the collected summary information into sb (called from scan.c) */ | ||
183 | |||
184 | void jffs2_sum_move_collected(struct jffs2_sb_info *c, struct jffs2_summary *s) | ||
185 | { | ||
186 | dbg_summary("oldsize=0x%x oldnum=%u => newsize=0x%x newnum=%u\n", | ||
187 | c->summary->sum_size, c->summary->sum_num, | ||
188 | s->sum_size, s->sum_num); | ||
189 | |||
190 | c->summary->sum_size = s->sum_size; | ||
191 | c->summary->sum_num = s->sum_num; | ||
192 | c->summary->sum_padded = s->sum_padded; | ||
193 | c->summary->sum_list_head = s->sum_list_head; | ||
194 | c->summary->sum_list_tail = s->sum_list_tail; | ||
195 | |||
196 | s->sum_list_head = s->sum_list_tail = NULL; | ||
197 | } | ||
198 | |||
199 | /* Called from wbuf.c to collect writed node info */ | ||
200 | |||
201 | int jffs2_sum_add_kvec(struct jffs2_sb_info *c, const struct kvec *invecs, | ||
202 | unsigned long count, uint32_t ofs) | ||
203 | { | ||
204 | union jffs2_node_union *node; | ||
205 | struct jffs2_eraseblock *jeb; | ||
206 | |||
207 | node = invecs[0].iov_base; | ||
208 | jeb = &c->blocks[ofs / c->sector_size]; | ||
209 | ofs -= jeb->offset; | ||
210 | |||
211 | switch (je16_to_cpu(node->u.nodetype)) { | ||
212 | case JFFS2_NODETYPE_INODE: { | ||
213 | struct jffs2_sum_inode_mem *temp = | ||
214 | kmalloc(sizeof(struct jffs2_sum_inode_mem), GFP_KERNEL); | ||
215 | |||
216 | if (!temp) | ||
217 | goto no_mem; | ||
218 | |||
219 | temp->nodetype = node->i.nodetype; | ||
220 | temp->inode = node->i.ino; | ||
221 | temp->version = node->i.version; | ||
222 | temp->offset = cpu_to_je32(ofs); | ||
223 | temp->totlen = node->i.totlen; | ||
224 | temp->next = NULL; | ||
225 | |||
226 | return jffs2_sum_add_mem(c->summary, (union jffs2_sum_mem *)temp); | ||
227 | } | ||
228 | |||
229 | case JFFS2_NODETYPE_DIRENT: { | ||
230 | struct jffs2_sum_dirent_mem *temp = | ||
231 | kmalloc(sizeof(struct jffs2_sum_dirent_mem) + node->d.nsize, GFP_KERNEL); | ||
232 | |||
233 | if (!temp) | ||
234 | goto no_mem; | ||
235 | |||
236 | temp->nodetype = node->d.nodetype; | ||
237 | temp->totlen = node->d.totlen; | ||
238 | temp->offset = cpu_to_je32(ofs); | ||
239 | temp->pino = node->d.pino; | ||
240 | temp->version = node->d.version; | ||
241 | temp->ino = node->d.ino; | ||
242 | temp->nsize = node->d.nsize; | ||
243 | temp->type = node->d.type; | ||
244 | temp->next = NULL; | ||
245 | |||
246 | switch (count) { | ||
247 | case 1: | ||
248 | memcpy(temp->name,node->d.name,node->d.nsize); | ||
249 | break; | ||
250 | |||
251 | case 2: | ||
252 | memcpy(temp->name,invecs[1].iov_base,node->d.nsize); | ||
253 | break; | ||
254 | |||
255 | default: | ||
256 | BUG(); /* impossible count value */ | ||
257 | break; | ||
258 | } | ||
259 | |||
260 | return jffs2_sum_add_mem(c->summary, (union jffs2_sum_mem *)temp); | ||
261 | } | ||
262 | |||
263 | case JFFS2_NODETYPE_PADDING: | ||
264 | dbg_summary("node PADDING\n"); | ||
265 | c->summary->sum_padded += je32_to_cpu(node->u.totlen); | ||
266 | break; | ||
267 | |||
268 | case JFFS2_NODETYPE_CLEANMARKER: | ||
269 | dbg_summary("node CLEANMARKER\n"); | ||
270 | break; | ||
271 | |||
272 | case JFFS2_NODETYPE_SUMMARY: | ||
273 | dbg_summary("node SUMMARY\n"); | ||
274 | break; | ||
275 | |||
276 | default: | ||
277 | /* If you implement a new node type you should also implement | ||
278 | summary support for it or disable summary. | ||
279 | */ | ||
280 | BUG(); | ||
281 | break; | ||
282 | } | ||
283 | |||
284 | return 0; | ||
285 | |||
286 | no_mem: | ||
287 | JFFS2_WARNING("MEMORY ALLOCATION ERROR!"); | ||
288 | return -ENOMEM; | ||
289 | } | ||
290 | |||
291 | |||
292 | /* Process the stored summary information - helper function for jffs2_sum_scan_sumnode() */ | ||
293 | |||
294 | static int jffs2_sum_process_sum_data(struct jffs2_sb_info *c, struct jffs2_eraseblock *jeb, | ||
295 | struct jffs2_raw_summary *summary, uint32_t *pseudo_random) | ||
296 | { | ||
297 | struct jffs2_raw_node_ref *raw; | ||
298 | struct jffs2_inode_cache *ic; | ||
299 | struct jffs2_full_dirent *fd; | ||
300 | void *sp; | ||
301 | int i, ino; | ||
302 | |||
303 | sp = summary->sum; | ||
304 | |||
305 | for (i=0; i<je32_to_cpu(summary->sum_num); i++) { | ||
306 | dbg_summary("processing summary index %d\n", i); | ||
307 | |||
308 | switch (je16_to_cpu(((struct jffs2_sum_unknown_flash *)sp)->nodetype)) { | ||
309 | case JFFS2_NODETYPE_INODE: { | ||
310 | struct jffs2_sum_inode_flash *spi; | ||
311 | spi = sp; | ||
312 | |||
313 | ino = je32_to_cpu(spi->inode); | ||
314 | |||
315 | dbg_summary("Inode at 0x%08x\n", | ||
316 | jeb->offset + je32_to_cpu(spi->offset)); | ||
317 | |||
318 | raw = jffs2_alloc_raw_node_ref(); | ||
319 | if (!raw) { | ||
320 | JFFS2_NOTICE("allocation of node reference failed\n"); | ||
321 | kfree(summary); | ||
322 | return -ENOMEM; | ||
323 | } | ||
324 | |||
325 | ic = jffs2_scan_make_ino_cache(c, ino); | ||
326 | if (!ic) { | ||
327 | JFFS2_NOTICE("scan_make_ino_cache failed\n"); | ||
328 | jffs2_free_raw_node_ref(raw); | ||
329 | kfree(summary); | ||
330 | return -ENOMEM; | ||
331 | } | ||
332 | |||
333 | raw->flash_offset = (jeb->offset + je32_to_cpu(spi->offset)) | REF_UNCHECKED; | ||
334 | raw->__totlen = PAD(je32_to_cpu(spi->totlen)); | ||
335 | raw->next_phys = NULL; | ||
336 | raw->next_in_ino = ic->nodes; | ||
337 | |||
338 | ic->nodes = raw; | ||
339 | if (!jeb->first_node) | ||
340 | jeb->first_node = raw; | ||
341 | if (jeb->last_node) | ||
342 | jeb->last_node->next_phys = raw; | ||
343 | jeb->last_node = raw; | ||
344 | *pseudo_random += je32_to_cpu(spi->version); | ||
345 | |||
346 | UNCHECKED_SPACE(PAD(je32_to_cpu(spi->totlen))); | ||
347 | |||
348 | sp += JFFS2_SUMMARY_INODE_SIZE; | ||
349 | |||
350 | break; | ||
351 | } | ||
352 | |||
353 | case JFFS2_NODETYPE_DIRENT: { | ||
354 | struct jffs2_sum_dirent_flash *spd; | ||
355 | spd = sp; | ||
356 | |||
357 | dbg_summary("Dirent at 0x%08x\n", | ||
358 | jeb->offset + je32_to_cpu(spd->offset)); | ||
359 | |||
360 | fd = jffs2_alloc_full_dirent(spd->nsize+1); | ||
361 | if (!fd) { | ||
362 | kfree(summary); | ||
363 | return -ENOMEM; | ||
364 | } | ||
365 | |||
366 | memcpy(&fd->name, spd->name, spd->nsize); | ||
367 | fd->name[spd->nsize] = 0; | ||
368 | |||
369 | raw = jffs2_alloc_raw_node_ref(); | ||
370 | if (!raw) { | ||
371 | jffs2_free_full_dirent(fd); | ||
372 | JFFS2_NOTICE("allocation of node reference failed\n"); | ||
373 | kfree(summary); | ||
374 | return -ENOMEM; | ||
375 | } | ||
376 | |||
377 | ic = jffs2_scan_make_ino_cache(c, je32_to_cpu(spd->pino)); | ||
378 | if (!ic) { | ||
379 | jffs2_free_full_dirent(fd); | ||
380 | jffs2_free_raw_node_ref(raw); | ||
381 | kfree(summary); | ||
382 | return -ENOMEM; | ||
383 | } | ||
384 | |||
385 | raw->__totlen = PAD(je32_to_cpu(spd->totlen)); | ||
386 | raw->flash_offset = (jeb->offset + je32_to_cpu(spd->offset)) | REF_PRISTINE; | ||
387 | raw->next_phys = NULL; | ||
388 | raw->next_in_ino = ic->nodes; | ||
389 | ic->nodes = raw; | ||
390 | if (!jeb->first_node) | ||
391 | jeb->first_node = raw; | ||
392 | if (jeb->last_node) | ||
393 | jeb->last_node->next_phys = raw; | ||
394 | jeb->last_node = raw; | ||
395 | |||
396 | fd->raw = raw; | ||
397 | fd->next = NULL; | ||
398 | fd->version = je32_to_cpu(spd->version); | ||
399 | fd->ino = je32_to_cpu(spd->ino); | ||
400 | fd->nhash = full_name_hash(fd->name, spd->nsize); | ||
401 | fd->type = spd->type; | ||
402 | USED_SPACE(PAD(je32_to_cpu(spd->totlen))); | ||
403 | jffs2_add_fd_to_list(c, fd, &ic->scan_dents); | ||
404 | |||
405 | *pseudo_random += je32_to_cpu(spd->version); | ||
406 | |||
407 | sp += JFFS2_SUMMARY_DIRENT_SIZE(spd->nsize); | ||
408 | |||
409 | break; | ||
410 | } | ||
411 | |||
412 | default : { | ||
413 | JFFS2_WARNING("Unsupported node type found in summary! Exiting..."); | ||
414 | kfree(summary); | ||
415 | return -EIO; | ||
416 | } | ||
417 | } | ||
418 | } | ||
419 | |||
420 | kfree(summary); | ||
421 | return 0; | ||
422 | } | ||
423 | |||
424 | /* Process the summary node - called from jffs2_scan_eraseblock() */ | ||
425 | |||
426 | int jffs2_sum_scan_sumnode(struct jffs2_sb_info *c, struct jffs2_eraseblock *jeb, | ||
427 | uint32_t ofs, uint32_t *pseudo_random) | ||
428 | { | ||
429 | struct jffs2_unknown_node crcnode; | ||
430 | struct jffs2_raw_node_ref *cache_ref; | ||
431 | struct jffs2_raw_summary *summary; | ||
432 | int ret, sumsize; | ||
433 | uint32_t crc; | ||
434 | |||
435 | sumsize = c->sector_size - ofs; | ||
436 | ofs += jeb->offset; | ||
437 | |||
438 | dbg_summary("summary found for 0x%08x at 0x%08x (0x%x bytes)\n", | ||
439 | jeb->offset, ofs, sumsize); | ||
440 | |||
441 | summary = kmalloc(sumsize, GFP_KERNEL); | ||
442 | |||
443 | if (!summary) { | ||
444 | return -ENOMEM; | ||
445 | } | ||
446 | |||
447 | ret = jffs2_fill_scan_buf(c, (unsigned char *)summary, ofs, sumsize); | ||
448 | |||
449 | if (ret) { | ||
450 | kfree(summary); | ||
451 | return ret; | ||
452 | } | ||
453 | |||
454 | /* OK, now check for node validity and CRC */ | ||
455 | crcnode.magic = cpu_to_je16(JFFS2_MAGIC_BITMASK); | ||
456 | crcnode.nodetype = cpu_to_je16(JFFS2_NODETYPE_SUMMARY); | ||
457 | crcnode.totlen = summary->totlen; | ||
458 | crc = crc32(0, &crcnode, sizeof(crcnode)-4); | ||
459 | |||
460 | if (je32_to_cpu(summary->hdr_crc) != crc) { | ||
461 | dbg_summary("Summary node header is corrupt (bad CRC or " | ||
462 | "no summary at all)\n"); | ||
463 | goto crc_err; | ||
464 | } | ||
465 | |||
466 | if (je32_to_cpu(summary->totlen) != sumsize) { | ||
467 | dbg_summary("Summary node is corrupt (wrong erasesize?)\n"); | ||
468 | goto crc_err; | ||
469 | } | ||
470 | |||
471 | crc = crc32(0, summary, sizeof(struct jffs2_raw_summary)-8); | ||
472 | |||
473 | if (je32_to_cpu(summary->node_crc) != crc) { | ||
474 | dbg_summary("Summary node is corrupt (bad CRC)\n"); | ||
475 | goto crc_err; | ||
476 | } | ||
477 | |||
478 | crc = crc32(0, summary->sum, sumsize - sizeof(struct jffs2_raw_summary)); | ||
479 | |||
480 | if (je32_to_cpu(summary->sum_crc) != crc) { | ||
481 | dbg_summary("Summary node data is corrupt (bad CRC)\n"); | ||
482 | goto crc_err; | ||
483 | } | ||
484 | |||
485 | if ( je32_to_cpu(summary->cln_mkr) ) { | ||
486 | |||
487 | dbg_summary("Summary : CLEANMARKER node \n"); | ||
488 | |||
489 | if (je32_to_cpu(summary->cln_mkr) != c->cleanmarker_size) { | ||
490 | dbg_summary("CLEANMARKER node has totlen 0x%x != normal 0x%x\n", | ||
491 | je32_to_cpu(summary->cln_mkr), c->cleanmarker_size); | ||
492 | UNCHECKED_SPACE(PAD(je32_to_cpu(summary->cln_mkr))); | ||
493 | } else if (jeb->first_node) { | ||
494 | dbg_summary("CLEANMARKER node not first node in block " | ||
495 | "(0x%08x)\n", jeb->offset); | ||
496 | UNCHECKED_SPACE(PAD(je32_to_cpu(summary->cln_mkr))); | ||
497 | } else { | ||
498 | struct jffs2_raw_node_ref *marker_ref = jffs2_alloc_raw_node_ref(); | ||
499 | |||
500 | if (!marker_ref) { | ||
501 | JFFS2_NOTICE("Failed to allocate node ref for clean marker\n"); | ||
502 | kfree(summary); | ||
503 | return -ENOMEM; | ||
504 | } | ||
505 | |||
506 | marker_ref->next_in_ino = NULL; | ||
507 | marker_ref->next_phys = NULL; | ||
508 | marker_ref->flash_offset = jeb->offset | REF_NORMAL; | ||
509 | marker_ref->__totlen = je32_to_cpu(summary->cln_mkr); | ||
510 | jeb->first_node = jeb->last_node = marker_ref; | ||
511 | |||
512 | USED_SPACE( PAD(je32_to_cpu(summary->cln_mkr)) ); | ||
513 | } | ||
514 | } | ||
515 | |||
516 | if (je32_to_cpu(summary->padded)) { | ||
517 | DIRTY_SPACE(je32_to_cpu(summary->padded)); | ||
518 | } | ||
519 | |||
520 | ret = jffs2_sum_process_sum_data(c, jeb, summary, pseudo_random); | ||
521 | if (ret) | ||
522 | return ret; | ||
523 | |||
524 | /* for PARANOIA_CHECK */ | ||
525 | cache_ref = jffs2_alloc_raw_node_ref(); | ||
526 | |||
527 | if (!cache_ref) { | ||
528 | JFFS2_NOTICE("Failed to allocate node ref for cache\n"); | ||
529 | return -ENOMEM; | ||
530 | } | ||
531 | |||
532 | cache_ref->next_in_ino = NULL; | ||
533 | cache_ref->next_phys = NULL; | ||
534 | cache_ref->flash_offset = ofs | REF_NORMAL; | ||
535 | cache_ref->__totlen = sumsize; | ||
536 | |||
537 | if (!jeb->first_node) | ||
538 | jeb->first_node = cache_ref; | ||
539 | if (jeb->last_node) | ||
540 | jeb->last_node->next_phys = cache_ref; | ||
541 | jeb->last_node = cache_ref; | ||
542 | |||
543 | USED_SPACE(sumsize); | ||
544 | |||
545 | jeb->wasted_size += jeb->free_size; | ||
546 | c->wasted_size += jeb->free_size; | ||
547 | c->free_size -= jeb->free_size; | ||
548 | jeb->free_size = 0; | ||
549 | |||
550 | return jffs2_scan_classify_jeb(c, jeb); | ||
551 | |||
552 | crc_err: | ||
553 | JFFS2_WARNING("Summary node crc error, skipping summary information.\n"); | ||
554 | |||
555 | return 0; | ||
556 | } | ||
557 | |||
558 | /* Write summary data to flash - helper function for jffs2_sum_write_sumnode() */ | ||
559 | |||
560 | static int jffs2_sum_write_data(struct jffs2_sb_info *c, struct jffs2_eraseblock *jeb, | ||
561 | uint32_t infosize, uint32_t datasize, int padsize) | ||
562 | { | ||
563 | struct jffs2_raw_summary isum; | ||
564 | union jffs2_sum_mem *temp; | ||
565 | struct jffs2_sum_marker *sm; | ||
566 | struct kvec vecs[2]; | ||
567 | void *wpage; | ||
568 | int ret; | ||
569 | size_t retlen; | ||
570 | |||
571 | memset(c->summary->sum_buf, 0xff, datasize); | ||
572 | memset(&isum, 0, sizeof(isum)); | ||
573 | |||
574 | isum.magic = cpu_to_je16(JFFS2_MAGIC_BITMASK); | ||
575 | isum.nodetype = cpu_to_je16(JFFS2_NODETYPE_SUMMARY); | ||
576 | isum.totlen = cpu_to_je32(infosize); | ||
577 | isum.hdr_crc = cpu_to_je32(crc32(0, &isum, sizeof(struct jffs2_unknown_node) - 4)); | ||
578 | isum.padded = cpu_to_je32(c->summary->sum_padded); | ||
579 | isum.cln_mkr = cpu_to_je32(c->cleanmarker_size); | ||
580 | isum.sum_num = cpu_to_je32(c->summary->sum_num); | ||
581 | wpage = c->summary->sum_buf; | ||
582 | |||
583 | while (c->summary->sum_num) { | ||
584 | |||
585 | switch (je16_to_cpu(c->summary->sum_list_head->u.nodetype)) { | ||
586 | case JFFS2_NODETYPE_INODE: { | ||
587 | struct jffs2_sum_inode_flash *sino_ptr = wpage; | ||
588 | |||
589 | sino_ptr->nodetype = c->summary->sum_list_head->i.nodetype; | ||
590 | sino_ptr->inode = c->summary->sum_list_head->i.inode; | ||
591 | sino_ptr->version = c->summary->sum_list_head->i.version; | ||
592 | sino_ptr->offset = c->summary->sum_list_head->i.offset; | ||
593 | sino_ptr->totlen = c->summary->sum_list_head->i.totlen; | ||
594 | |||
595 | wpage += JFFS2_SUMMARY_INODE_SIZE; | ||
596 | |||
597 | break; | ||
598 | } | ||
599 | |||
600 | case JFFS2_NODETYPE_DIRENT: { | ||
601 | struct jffs2_sum_dirent_flash *sdrnt_ptr = wpage; | ||
602 | |||
603 | sdrnt_ptr->nodetype = c->summary->sum_list_head->d.nodetype; | ||
604 | sdrnt_ptr->totlen = c->summary->sum_list_head->d.totlen; | ||
605 | sdrnt_ptr->offset = c->summary->sum_list_head->d.offset; | ||
606 | sdrnt_ptr->pino = c->summary->sum_list_head->d.pino; | ||
607 | sdrnt_ptr->version = c->summary->sum_list_head->d.version; | ||
608 | sdrnt_ptr->ino = c->summary->sum_list_head->d.ino; | ||
609 | sdrnt_ptr->nsize = c->summary->sum_list_head->d.nsize; | ||
610 | sdrnt_ptr->type = c->summary->sum_list_head->d.type; | ||
611 | |||
612 | memcpy(sdrnt_ptr->name, c->summary->sum_list_head->d.name, | ||
613 | c->summary->sum_list_head->d.nsize); | ||
614 | |||
615 | wpage += JFFS2_SUMMARY_DIRENT_SIZE(c->summary->sum_list_head->d.nsize); | ||
616 | |||
617 | break; | ||
618 | } | ||
619 | |||
620 | default : { | ||
621 | BUG(); /* unknown node in summary information */ | ||
622 | } | ||
623 | } | ||
624 | |||
625 | temp = c->summary->sum_list_head; | ||
626 | c->summary->sum_list_head = c->summary->sum_list_head->u.next; | ||
627 | kfree(temp); | ||
628 | |||
629 | c->summary->sum_num--; | ||
630 | } | ||
631 | |||
632 | jffs2_sum_reset_collected(c->summary); | ||
633 | |||
634 | wpage += padsize; | ||
635 | |||
636 | sm = wpage; | ||
637 | sm->offset = cpu_to_je32(c->sector_size - jeb->free_size); | ||
638 | sm->magic = cpu_to_je32(JFFS2_SUM_MAGIC); | ||
639 | |||
640 | isum.sum_crc = cpu_to_je32(crc32(0, c->summary->sum_buf, datasize)); | ||
641 | isum.node_crc = cpu_to_je32(crc32(0, &isum, sizeof(isum) - 8)); | ||
642 | |||
643 | vecs[0].iov_base = &isum; | ||
644 | vecs[0].iov_len = sizeof(isum); | ||
645 | vecs[1].iov_base = c->summary->sum_buf; | ||
646 | vecs[1].iov_len = datasize; | ||
647 | |||
648 | dbg_summary("JFFS2: writing out data to flash to pos : 0x%08x\n", | ||
649 | jeb->offset + c->sector_size - jeb->free_size); | ||
650 | |||
651 | spin_unlock(&c->erase_completion_lock); | ||
652 | ret = jffs2_flash_writev(c, vecs, 2, jeb->offset + c->sector_size - | ||
653 | jeb->free_size, &retlen, 0); | ||
654 | spin_lock(&c->erase_completion_lock); | ||
655 | |||
656 | |||
657 | if (ret || (retlen != infosize)) { | ||
658 | JFFS2_WARNING("Write of %zd bytes at 0x%08x failed. returned %d, retlen %zd\n", | ||
659 | infosize, jeb->offset + c->sector_size - jeb->free_size, ret, retlen); | ||
660 | |||
661 | c->summary->sum_size = JFFS2_SUMMARY_NOSUM_SIZE; | ||
662 | WASTED_SPACE(infosize); | ||
663 | |||
664 | return 1; | ||
665 | } | ||
666 | |||
667 | return 0; | ||
668 | } | ||
669 | |||
670 | /* Write out summary information - called from jffs2_do_reserve_space */ | ||
671 | |||
672 | int jffs2_sum_write_sumnode(struct jffs2_sb_info *c) | ||
673 | { | ||
674 | struct jffs2_raw_node_ref *summary_ref; | ||
675 | int datasize, infosize, padsize, ret; | ||
676 | struct jffs2_eraseblock *jeb; | ||
677 | |||
678 | dbg_summary("called\n"); | ||
679 | |||
680 | jeb = c->nextblock; | ||
681 | |||
682 | if (!c->summary->sum_num || !c->summary->sum_list_head) { | ||
683 | JFFS2_WARNING("Empty summary info!!!\n"); | ||
684 | BUG(); | ||
685 | } | ||
686 | |||
687 | datasize = c->summary->sum_size + sizeof(struct jffs2_sum_marker); | ||
688 | infosize = sizeof(struct jffs2_raw_summary) + datasize; | ||
689 | padsize = jeb->free_size - infosize; | ||
690 | infosize += padsize; | ||
691 | datasize += padsize; | ||
692 | |||
693 | /* Is there enough space for summary? */ | ||
694 | if (padsize < 0) { | ||
695 | /* don't try to write out summary for this jeb */ | ||
696 | jffs2_sum_disable_collecting(c->summary); | ||
697 | |||
698 | JFFS2_WARNING("Not enough space for summary, padsize = %d\n", padsize); | ||
699 | return 0; | ||
700 | } | ||
701 | |||
702 | ret = jffs2_sum_write_data(c, jeb, infosize, datasize, padsize); | ||
703 | if (ret) | ||
704 | return 0; /* can't write out summary, block is marked as NOSUM_SIZE */ | ||
705 | |||
706 | /* for ACCT_PARANOIA_CHECK */ | ||
707 | spin_unlock(&c->erase_completion_lock); | ||
708 | summary_ref = jffs2_alloc_raw_node_ref(); | ||
709 | spin_lock(&c->erase_completion_lock); | ||
710 | |||
711 | if (!summary_ref) { | ||
712 | JFFS2_NOTICE("Failed to allocate node ref for summary\n"); | ||
713 | return -ENOMEM; | ||
714 | } | ||
715 | |||
716 | summary_ref->next_in_ino = NULL; | ||
717 | summary_ref->next_phys = NULL; | ||
718 | summary_ref->flash_offset = (jeb->offset + c->sector_size - jeb->free_size) | REF_NORMAL; | ||
719 | summary_ref->__totlen = infosize; | ||
720 | |||
721 | if (!jeb->first_node) | ||
722 | jeb->first_node = summary_ref; | ||
723 | if (jeb->last_node) | ||
724 | jeb->last_node->next_phys = summary_ref; | ||
725 | jeb->last_node = summary_ref; | ||
726 | |||
727 | USED_SPACE(infosize); | ||
728 | |||
729 | return 0; | ||
730 | } | ||
diff --git a/fs/jffs2/summary.h b/fs/jffs2/summary.h new file mode 100644 index 000000000000..b7a678be1709 --- /dev/null +++ b/fs/jffs2/summary.h | |||
@@ -0,0 +1,183 @@ | |||
1 | /* | ||
2 | * JFFS2 -- Journalling Flash File System, Version 2. | ||
3 | * | ||
4 | * Copyright (C) 2004 Ferenc Havasi <havasi@inf.u-szeged.hu>, | ||
5 | * Zoltan Sogor <weth@inf.u-szeged.hu>, | ||
6 | * Patrik Kluba <pajko@halom.u-szeged.hu>, | ||
7 | * University of Szeged, Hungary | ||
8 | * | ||
9 | * For licensing information, see the file 'LICENCE' in this directory. | ||
10 | * | ||
11 | * $Id: summary.h,v 1.2 2005/09/26 11:37:21 havasi Exp $ | ||
12 | * | ||
13 | */ | ||
14 | |||
15 | #ifndef JFFS2_SUMMARY_H | ||
16 | #define JFFS2_SUMMARY_H | ||
17 | |||
18 | #include <linux/uio.h> | ||
19 | #include <linux/jffs2.h> | ||
20 | |||
21 | #define DIRTY_SPACE(x) do { typeof(x) _x = (x); \ | ||
22 | c->free_size -= _x; c->dirty_size += _x; \ | ||
23 | jeb->free_size -= _x ; jeb->dirty_size += _x; \ | ||
24 | }while(0) | ||
25 | #define USED_SPACE(x) do { typeof(x) _x = (x); \ | ||
26 | c->free_size -= _x; c->used_size += _x; \ | ||
27 | jeb->free_size -= _x ; jeb->used_size += _x; \ | ||
28 | }while(0) | ||
29 | #define WASTED_SPACE(x) do { typeof(x) _x = (x); \ | ||
30 | c->free_size -= _x; c->wasted_size += _x; \ | ||
31 | jeb->free_size -= _x ; jeb->wasted_size += _x; \ | ||
32 | }while(0) | ||
33 | #define UNCHECKED_SPACE(x) do { typeof(x) _x = (x); \ | ||
34 | c->free_size -= _x; c->unchecked_size += _x; \ | ||
35 | jeb->free_size -= _x ; jeb->unchecked_size += _x; \ | ||
36 | }while(0) | ||
37 | |||
38 | #define BLK_STATE_ALLFF 0 | ||
39 | #define BLK_STATE_CLEAN 1 | ||
40 | #define BLK_STATE_PARTDIRTY 2 | ||
41 | #define BLK_STATE_CLEANMARKER 3 | ||
42 | #define BLK_STATE_ALLDIRTY 4 | ||
43 | #define BLK_STATE_BADBLOCK 5 | ||
44 | |||
45 | #define JFFS2_SUMMARY_NOSUM_SIZE 0xffffffff | ||
46 | #define JFFS2_SUMMARY_INODE_SIZE (sizeof(struct jffs2_sum_inode_flash)) | ||
47 | #define JFFS2_SUMMARY_DIRENT_SIZE(x) (sizeof(struct jffs2_sum_dirent_flash) + (x)) | ||
48 | |||
49 | /* Summary structures used on flash */ | ||
50 | |||
51 | struct jffs2_sum_unknown_flash | ||
52 | { | ||
53 | jint16_t nodetype; /* node type */ | ||
54 | }; | ||
55 | |||
56 | struct jffs2_sum_inode_flash | ||
57 | { | ||
58 | jint16_t nodetype; /* node type */ | ||
59 | jint32_t inode; /* inode number */ | ||
60 | jint32_t version; /* inode version */ | ||
61 | jint32_t offset; /* offset on jeb */ | ||
62 | jint32_t totlen; /* record length */ | ||
63 | } __attribute__((packed)); | ||
64 | |||
65 | struct jffs2_sum_dirent_flash | ||
66 | { | ||
67 | jint16_t nodetype; /* == JFFS_NODETYPE_DIRENT */ | ||
68 | jint32_t totlen; /* record length */ | ||
69 | jint32_t offset; /* offset on jeb */ | ||
70 | jint32_t pino; /* parent inode */ | ||
71 | jint32_t version; /* dirent version */ | ||
72 | jint32_t ino; /* == zero for unlink */ | ||
73 | uint8_t nsize; /* dirent name size */ | ||
74 | uint8_t type; /* dirent type */ | ||
75 | uint8_t name[0]; /* dirent name */ | ||
76 | } __attribute__((packed)); | ||
77 | |||
78 | union jffs2_sum_flash | ||
79 | { | ||
80 | struct jffs2_sum_unknown_flash u; | ||
81 | struct jffs2_sum_inode_flash i; | ||
82 | struct jffs2_sum_dirent_flash d; | ||
83 | }; | ||
84 | |||
85 | /* Summary structures used in the memory */ | ||
86 | |||
87 | struct jffs2_sum_unknown_mem | ||
88 | { | ||
89 | union jffs2_sum_mem *next; | ||
90 | jint16_t nodetype; /* node type */ | ||
91 | }; | ||
92 | |||
93 | struct jffs2_sum_inode_mem | ||
94 | { | ||
95 | union jffs2_sum_mem *next; | ||
96 | jint16_t nodetype; /* node type */ | ||
97 | jint32_t inode; /* inode number */ | ||
98 | jint32_t version; /* inode version */ | ||
99 | jint32_t offset; /* offset on jeb */ | ||
100 | jint32_t totlen; /* record length */ | ||
101 | } __attribute__((packed)); | ||
102 | |||
103 | struct jffs2_sum_dirent_mem | ||
104 | { | ||
105 | union jffs2_sum_mem *next; | ||
106 | jint16_t nodetype; /* == JFFS_NODETYPE_DIRENT */ | ||
107 | jint32_t totlen; /* record length */ | ||
108 | jint32_t offset; /* ofset on jeb */ | ||
109 | jint32_t pino; /* parent inode */ | ||
110 | jint32_t version; /* dirent version */ | ||
111 | jint32_t ino; /* == zero for unlink */ | ||
112 | uint8_t nsize; /* dirent name size */ | ||
113 | uint8_t type; /* dirent type */ | ||
114 | uint8_t name[0]; /* dirent name */ | ||
115 | } __attribute__((packed)); | ||
116 | |||
117 | union jffs2_sum_mem | ||
118 | { | ||
119 | struct jffs2_sum_unknown_mem u; | ||
120 | struct jffs2_sum_inode_mem i; | ||
121 | struct jffs2_sum_dirent_mem d; | ||
122 | }; | ||
123 | |||
124 | /* Summary related information stored in superblock */ | ||
125 | |||
126 | struct jffs2_summary | ||
127 | { | ||
128 | uint32_t sum_size; /* collected summary information for nextblock */ | ||
129 | uint32_t sum_num; | ||
130 | uint32_t sum_padded; | ||
131 | union jffs2_sum_mem *sum_list_head; | ||
132 | union jffs2_sum_mem *sum_list_tail; | ||
133 | |||
134 | jint32_t *sum_buf; /* buffer for writing out summary */ | ||
135 | }; | ||
136 | |||
137 | /* Summary marker is stored at the end of every sumarized erase block */ | ||
138 | |||
139 | struct jffs2_sum_marker | ||
140 | { | ||
141 | jint32_t offset; /* offset of the summary node in the jeb */ | ||
142 | jint32_t magic; /* == JFFS2_SUM_MAGIC */ | ||
143 | }; | ||
144 | |||
145 | #define JFFS2_SUMMARY_FRAME_SIZE (sizeof(struct jffs2_raw_summary) + sizeof(struct jffs2_sum_marker)) | ||
146 | |||
147 | #ifdef CONFIG_JFFS2_SUMMARY /* SUMMARY SUPPORT ENABLED */ | ||
148 | |||
149 | #define jffs2_sum_active() (1) | ||
150 | int jffs2_sum_init(struct jffs2_sb_info *c); | ||
151 | void jffs2_sum_exit(struct jffs2_sb_info *c); | ||
152 | void jffs2_sum_disable_collecting(struct jffs2_summary *s); | ||
153 | int jffs2_sum_is_disabled(struct jffs2_summary *s); | ||
154 | void jffs2_sum_reset_collected(struct jffs2_summary *s); | ||
155 | void jffs2_sum_move_collected(struct jffs2_sb_info *c, struct jffs2_summary *s); | ||
156 | int jffs2_sum_add_kvec(struct jffs2_sb_info *c, const struct kvec *invecs, | ||
157 | unsigned long count, uint32_t to); | ||
158 | int jffs2_sum_write_sumnode(struct jffs2_sb_info *c); | ||
159 | int jffs2_sum_add_padding_mem(struct jffs2_summary *s, uint32_t size); | ||
160 | int jffs2_sum_add_inode_mem(struct jffs2_summary *s, struct jffs2_raw_inode *ri, uint32_t ofs); | ||
161 | int jffs2_sum_add_dirent_mem(struct jffs2_summary *s, struct jffs2_raw_dirent *rd, uint32_t ofs); | ||
162 | int jffs2_sum_scan_sumnode(struct jffs2_sb_info *c, struct jffs2_eraseblock *jeb, | ||
163 | uint32_t ofs, uint32_t *pseudo_random); | ||
164 | |||
165 | #else /* SUMMARY DISABLED */ | ||
166 | |||
167 | #define jffs2_sum_active() (0) | ||
168 | #define jffs2_sum_init(a) (0) | ||
169 | #define jffs2_sum_exit(a) | ||
170 | #define jffs2_sum_disable_collecting(a) | ||
171 | #define jffs2_sum_is_disabled(a) (0) | ||
172 | #define jffs2_sum_reset_collected(a) | ||
173 | #define jffs2_sum_add_kvec(a,b,c,d) (0) | ||
174 | #define jffs2_sum_move_collected(a,b) | ||
175 | #define jffs2_sum_write_sumnode(a) (0) | ||
176 | #define jffs2_sum_add_padding_mem(a,b) | ||
177 | #define jffs2_sum_add_inode_mem(a,b,c) | ||
178 | #define jffs2_sum_add_dirent_mem(a,b,c) | ||
179 | #define jffs2_sum_scan_sumnode(a,b,c,d) (0) | ||
180 | |||
181 | #endif /* CONFIG_JFFS2_SUMMARY */ | ||
182 | |||
183 | #endif /* JFFS2_SUMMARY_H */ | ||
diff --git a/fs/jffs2/super.c b/fs/jffs2/super.c index aaf9475cfb6a..9e0b5458d9c0 100644 --- a/fs/jffs2/super.c +++ b/fs/jffs2/super.c | |||
@@ -7,7 +7,7 @@ | |||
7 | * | 7 | * |
8 | * For licensing information, see the file 'LICENCE' in this directory. | 8 | * For licensing information, see the file 'LICENCE' in this directory. |
9 | * | 9 | * |
10 | * $Id: super.c,v 1.107 2005/07/12 16:37:08 dedekind Exp $ | 10 | * $Id: super.c,v 1.110 2005/11/07 11:14:42 gleixner Exp $ |
11 | * | 11 | * |
12 | */ | 12 | */ |
13 | 13 | ||
@@ -62,7 +62,7 @@ static int jffs2_sync_fs(struct super_block *sb, int wait) | |||
62 | 62 | ||
63 | down(&c->alloc_sem); | 63 | down(&c->alloc_sem); |
64 | jffs2_flush_wbuf_pad(c); | 64 | jffs2_flush_wbuf_pad(c); |
65 | up(&c->alloc_sem); | 65 | up(&c->alloc_sem); |
66 | return 0; | 66 | return 0; |
67 | } | 67 | } |
68 | 68 | ||
@@ -112,7 +112,7 @@ static int jffs2_sb_set(struct super_block *sb, void *data) | |||
112 | } | 112 | } |
113 | 113 | ||
114 | static struct super_block *jffs2_get_sb_mtd(struct file_system_type *fs_type, | 114 | static struct super_block *jffs2_get_sb_mtd(struct file_system_type *fs_type, |
115 | int flags, const char *dev_name, | 115 | int flags, const char *dev_name, |
116 | void *data, struct mtd_info *mtd) | 116 | void *data, struct mtd_info *mtd) |
117 | { | 117 | { |
118 | struct super_block *sb; | 118 | struct super_block *sb; |
@@ -172,7 +172,7 @@ static struct super_block *jffs2_get_sb_mtd(struct file_system_type *fs_type, | |||
172 | } | 172 | } |
173 | 173 | ||
174 | static struct super_block *jffs2_get_sb_mtdnr(struct file_system_type *fs_type, | 174 | static struct super_block *jffs2_get_sb_mtdnr(struct file_system_type *fs_type, |
175 | int flags, const char *dev_name, | 175 | int flags, const char *dev_name, |
176 | void *data, int mtdnr) | 176 | void *data, int mtdnr) |
177 | { | 177 | { |
178 | struct mtd_info *mtd; | 178 | struct mtd_info *mtd; |
@@ -201,7 +201,7 @@ static struct super_block *jffs2_get_sb(struct file_system_type *fs_type, | |||
201 | 201 | ||
202 | /* The preferred way of mounting in future; especially when | 202 | /* The preferred way of mounting in future; especially when |
203 | CONFIG_BLK_DEV is implemented - we specify the underlying | 203 | CONFIG_BLK_DEV is implemented - we specify the underlying |
204 | MTD device by number or by name, so that we don't require | 204 | MTD device by number or by name, so that we don't require |
205 | block device support to be present in the kernel. */ | 205 | block device support to be present in the kernel. */ |
206 | 206 | ||
207 | /* FIXME: How to do the root fs this way? */ | 207 | /* FIXME: How to do the root fs this way? */ |
@@ -225,7 +225,7 @@ static struct super_block *jffs2_get_sb(struct file_system_type *fs_type, | |||
225 | } else if (isdigit(dev_name[3])) { | 225 | } else if (isdigit(dev_name[3])) { |
226 | /* Mount by MTD device number name */ | 226 | /* Mount by MTD device number name */ |
227 | char *endptr; | 227 | char *endptr; |
228 | 228 | ||
229 | mtdnr = simple_strtoul(dev_name+3, &endptr, 0); | 229 | mtdnr = simple_strtoul(dev_name+3, &endptr, 0); |
230 | if (!*endptr) { | 230 | if (!*endptr) { |
231 | /* It was a valid number */ | 231 | /* It was a valid number */ |
@@ -235,7 +235,7 @@ static struct super_block *jffs2_get_sb(struct file_system_type *fs_type, | |||
235 | } | 235 | } |
236 | } | 236 | } |
237 | 237 | ||
238 | /* Try the old way - the hack where we allowed users to mount | 238 | /* Try the old way - the hack where we allowed users to mount |
239 | /dev/mtdblock$(n) but didn't actually _use_ the blkdev */ | 239 | /dev/mtdblock$(n) but didn't actually _use_ the blkdev */ |
240 | 240 | ||
241 | err = path_lookup(dev_name, LOOKUP_FOLLOW, &nd); | 241 | err = path_lookup(dev_name, LOOKUP_FOLLOW, &nd); |
@@ -282,9 +282,12 @@ static void jffs2_put_super (struct super_block *sb) | |||
282 | down(&c->alloc_sem); | 282 | down(&c->alloc_sem); |
283 | jffs2_flush_wbuf_pad(c); | 283 | jffs2_flush_wbuf_pad(c); |
284 | up(&c->alloc_sem); | 284 | up(&c->alloc_sem); |
285 | |||
286 | jffs2_sum_exit(c); | ||
287 | |||
285 | jffs2_free_ino_caches(c); | 288 | jffs2_free_ino_caches(c); |
286 | jffs2_free_raw_node_refs(c); | 289 | jffs2_free_raw_node_refs(c); |
287 | if (c->mtd->flags & MTD_NO_VIRTBLOCKS) | 290 | if (jffs2_blocks_use_vmalloc(c)) |
288 | vfree(c->blocks); | 291 | vfree(c->blocks); |
289 | else | 292 | else |
290 | kfree(c->blocks); | 293 | kfree(c->blocks); |
@@ -321,6 +324,9 @@ static int __init init_jffs2_fs(void) | |||
321 | #ifdef CONFIG_JFFS2_FS_WRITEBUFFER | 324 | #ifdef CONFIG_JFFS2_FS_WRITEBUFFER |
322 | " (NAND)" | 325 | " (NAND)" |
323 | #endif | 326 | #endif |
327 | #ifdef CONFIG_JFFS2_SUMMARY | ||
328 | " (SUMMARY) " | ||
329 | #endif | ||
324 | " (C) 2001-2003 Red Hat, Inc.\n"); | 330 | " (C) 2001-2003 Red Hat, Inc.\n"); |
325 | 331 | ||
326 | jffs2_inode_cachep = kmem_cache_create("jffs2_i", | 332 | jffs2_inode_cachep = kmem_cache_create("jffs2_i", |
@@ -370,5 +376,5 @@ module_exit(exit_jffs2_fs); | |||
370 | 376 | ||
371 | MODULE_DESCRIPTION("The Journalling Flash File System, v2"); | 377 | MODULE_DESCRIPTION("The Journalling Flash File System, v2"); |
372 | MODULE_AUTHOR("Red Hat, Inc."); | 378 | MODULE_AUTHOR("Red Hat, Inc."); |
373 | MODULE_LICENSE("GPL"); // Actually dual-licensed, but it doesn't matter for | 379 | MODULE_LICENSE("GPL"); // Actually dual-licensed, but it doesn't matter for |
374 | // the sake of this tag. It's Free Software. | 380 | // the sake of this tag. It's Free Software. |
diff --git a/fs/jffs2/symlink.c b/fs/jffs2/symlink.c index 82ef484f5e12..d55754fe8925 100644 --- a/fs/jffs2/symlink.c +++ b/fs/jffs2/symlink.c | |||
@@ -7,7 +7,7 @@ | |||
7 | * | 7 | * |
8 | * For licensing information, see the file 'LICENCE' in this directory. | 8 | * For licensing information, see the file 'LICENCE' in this directory. |
9 | * | 9 | * |
10 | * $Id: symlink.c,v 1.16 2005/03/01 10:50:48 dedekind Exp $ | 10 | * $Id: symlink.c,v 1.19 2005/11/07 11:14:42 gleixner Exp $ |
11 | * | 11 | * |
12 | */ | 12 | */ |
13 | 13 | ||
@@ -21,7 +21,7 @@ | |||
21 | static void *jffs2_follow_link(struct dentry *dentry, struct nameidata *nd); | 21 | static void *jffs2_follow_link(struct dentry *dentry, struct nameidata *nd); |
22 | 22 | ||
23 | struct inode_operations jffs2_symlink_inode_operations = | 23 | struct inode_operations jffs2_symlink_inode_operations = |
24 | { | 24 | { |
25 | .readlink = generic_readlink, | 25 | .readlink = generic_readlink, |
26 | .follow_link = jffs2_follow_link, | 26 | .follow_link = jffs2_follow_link, |
27 | .setattr = jffs2_setattr | 27 | .setattr = jffs2_setattr |
@@ -30,35 +30,33 @@ struct inode_operations jffs2_symlink_inode_operations = | |||
30 | static void *jffs2_follow_link(struct dentry *dentry, struct nameidata *nd) | 30 | static void *jffs2_follow_link(struct dentry *dentry, struct nameidata *nd) |
31 | { | 31 | { |
32 | struct jffs2_inode_info *f = JFFS2_INODE_INFO(dentry->d_inode); | 32 | struct jffs2_inode_info *f = JFFS2_INODE_INFO(dentry->d_inode); |
33 | char *p = (char *)f->dents; | 33 | char *p = (char *)f->target; |
34 | 34 | ||
35 | /* | 35 | /* |
36 | * We don't acquire the f->sem mutex here since the only data we | 36 | * We don't acquire the f->sem mutex here since the only data we |
37 | * use is f->dents which in case of the symlink inode points to the | 37 | * use is f->target. |
38 | * symlink's target path. | ||
39 | * | 38 | * |
40 | * 1. If we are here the inode has already built and f->dents has | 39 | * 1. If we are here the inode has already built and f->target has |
41 | * to point to the target path. | 40 | * to point to the target path. |
42 | * 2. Nobody uses f->dents (if the inode is symlink's inode). The | 41 | * 2. Nobody uses f->target (if the inode is symlink's inode). The |
43 | * exception is inode freeing function which frees f->dents. But | 42 | * exception is inode freeing function which frees f->target. But |
44 | * it can't be called while we are here and before VFS has | 43 | * it can't be called while we are here and before VFS has |
45 | * stopped using our f->dents string which we provide by means of | 44 | * stopped using our f->target string which we provide by means of |
46 | * nd_set_link() call. | 45 | * nd_set_link() call. |
47 | */ | 46 | */ |
48 | 47 | ||
49 | if (!p) { | 48 | if (!p) { |
50 | printk(KERN_ERR "jffs2_follow_link(): can't find symlink taerget\n"); | 49 | printk(KERN_ERR "jffs2_follow_link(): can't find symlink taerget\n"); |
51 | p = ERR_PTR(-EIO); | 50 | p = ERR_PTR(-EIO); |
52 | } else { | ||
53 | D1(printk(KERN_DEBUG "jffs2_follow_link(): target path is '%s'\n", (char *) f->dents)); | ||
54 | } | 51 | } |
52 | D1(printk(KERN_DEBUG "jffs2_follow_link(): target path is '%s'\n", (char *) f->target)); | ||
55 | 53 | ||
56 | nd_set_link(nd, p); | 54 | nd_set_link(nd, p); |
57 | 55 | ||
58 | /* | 56 | /* |
59 | * We unlock the f->sem mutex but VFS will use the f->dents string. This is safe | 57 | * We will unlock the f->sem mutex but VFS will use the f->target string. This is safe |
60 | * since the only way that may cause f->dents to be changed is iput() operation. | 58 | * since the only way that may cause f->target to be changed is iput() operation. |
61 | * But VFS will not use f->dents after iput() has been called. | 59 | * But VFS will not use f->target after iput() has been called. |
62 | */ | 60 | */ |
63 | return NULL; | 61 | return NULL; |
64 | } | 62 | } |
diff --git a/fs/jffs2/wbuf.c b/fs/jffs2/wbuf.c index 316133c626b7..4cebf0e57c46 100644 --- a/fs/jffs2/wbuf.c +++ b/fs/jffs2/wbuf.c | |||
@@ -9,7 +9,7 @@ | |||
9 | * | 9 | * |
10 | * For licensing information, see the file 'LICENCE' in this directory. | 10 | * For licensing information, see the file 'LICENCE' in this directory. |
11 | * | 11 | * |
12 | * $Id: wbuf.c,v 1.92 2005/04/05 12:51:54 dedekind Exp $ | 12 | * $Id: wbuf.c,v 1.100 2005/09/30 13:59:13 dedekind Exp $ |
13 | * | 13 | * |
14 | */ | 14 | */ |
15 | 15 | ||
@@ -30,12 +30,12 @@ | |||
30 | static unsigned char *brokenbuf; | 30 | static unsigned char *brokenbuf; |
31 | #endif | 31 | #endif |
32 | 32 | ||
33 | #define PAGE_DIV(x) ( ((unsigned long)(x) / (unsigned long)(c->wbuf_pagesize)) * (unsigned long)(c->wbuf_pagesize) ) | ||
34 | #define PAGE_MOD(x) ( (unsigned long)(x) % (unsigned long)(c->wbuf_pagesize) ) | ||
35 | |||
33 | /* max. erase failures before we mark a block bad */ | 36 | /* max. erase failures before we mark a block bad */ |
34 | #define MAX_ERASE_FAILURES 2 | 37 | #define MAX_ERASE_FAILURES 2 |
35 | 38 | ||
36 | /* two seconds timeout for timed wbuf-flushing */ | ||
37 | #define WBUF_FLUSH_TIMEOUT 2 * HZ | ||
38 | |||
39 | struct jffs2_inodirty { | 39 | struct jffs2_inodirty { |
40 | uint32_t ino; | 40 | uint32_t ino; |
41 | struct jffs2_inodirty *next; | 41 | struct jffs2_inodirty *next; |
@@ -139,7 +139,6 @@ static void jffs2_block_refile(struct jffs2_sb_info *c, struct jffs2_eraseblock | |||
139 | { | 139 | { |
140 | D1(printk("About to refile bad block at %08x\n", jeb->offset)); | 140 | D1(printk("About to refile bad block at %08x\n", jeb->offset)); |
141 | 141 | ||
142 | D2(jffs2_dump_block_lists(c)); | ||
143 | /* File the existing block on the bad_used_list.... */ | 142 | /* File the existing block on the bad_used_list.... */ |
144 | if (c->nextblock == jeb) | 143 | if (c->nextblock == jeb) |
145 | c->nextblock = NULL; | 144 | c->nextblock = NULL; |
@@ -156,7 +155,6 @@ static void jffs2_block_refile(struct jffs2_sb_info *c, struct jffs2_eraseblock | |||
156 | c->nr_erasing_blocks++; | 155 | c->nr_erasing_blocks++; |
157 | jffs2_erase_pending_trigger(c); | 156 | jffs2_erase_pending_trigger(c); |
158 | } | 157 | } |
159 | D2(jffs2_dump_block_lists(c)); | ||
160 | 158 | ||
161 | /* Adjust its size counts accordingly */ | 159 | /* Adjust its size counts accordingly */ |
162 | c->wasted_size += jeb->free_size; | 160 | c->wasted_size += jeb->free_size; |
@@ -164,8 +162,9 @@ static void jffs2_block_refile(struct jffs2_sb_info *c, struct jffs2_eraseblock | |||
164 | jeb->wasted_size += jeb->free_size; | 162 | jeb->wasted_size += jeb->free_size; |
165 | jeb->free_size = 0; | 163 | jeb->free_size = 0; |
166 | 164 | ||
167 | ACCT_SANITY_CHECK(c,jeb); | 165 | jffs2_dbg_dump_block_lists_nolock(c); |
168 | D1(ACCT_PARANOIA_CHECK(jeb)); | 166 | jffs2_dbg_acct_sanity_check_nolock(c,jeb); |
167 | jffs2_dbg_acct_paranoia_check_nolock(c, jeb); | ||
169 | } | 168 | } |
170 | 169 | ||
171 | /* Recover from failure to write wbuf. Recover the nodes up to the | 170 | /* Recover from failure to write wbuf. Recover the nodes up to the |
@@ -189,7 +188,7 @@ static void jffs2_wbuf_recover(struct jffs2_sb_info *c) | |||
189 | /* Find the first node to be recovered, by skipping over every | 188 | /* Find the first node to be recovered, by skipping over every |
190 | node which ends before the wbuf starts, or which is obsolete. */ | 189 | node which ends before the wbuf starts, or which is obsolete. */ |
191 | first_raw = &jeb->first_node; | 190 | first_raw = &jeb->first_node; |
192 | while (*first_raw && | 191 | while (*first_raw && |
193 | (ref_obsolete(*first_raw) || | 192 | (ref_obsolete(*first_raw) || |
194 | (ref_offset(*first_raw)+ref_totlen(c, jeb, *first_raw)) < c->wbuf_ofs)) { | 193 | (ref_offset(*first_raw)+ref_totlen(c, jeb, *first_raw)) < c->wbuf_ofs)) { |
195 | D1(printk(KERN_DEBUG "Skipping node at 0x%08x(%d)-0x%08x which is either before 0x%08x or obsolete\n", | 194 | D1(printk(KERN_DEBUG "Skipping node at 0x%08x(%d)-0x%08x which is either before 0x%08x or obsolete\n", |
@@ -238,7 +237,7 @@ static void jffs2_wbuf_recover(struct jffs2_sb_info *c) | |||
238 | ret = c->mtd->read_ecc(c->mtd, start, c->wbuf_ofs - start, &retlen, buf, NULL, c->oobinfo); | 237 | ret = c->mtd->read_ecc(c->mtd, start, c->wbuf_ofs - start, &retlen, buf, NULL, c->oobinfo); |
239 | else | 238 | else |
240 | ret = c->mtd->read(c->mtd, start, c->wbuf_ofs - start, &retlen, buf); | 239 | ret = c->mtd->read(c->mtd, start, c->wbuf_ofs - start, &retlen, buf); |
241 | 240 | ||
242 | if (ret == -EBADMSG && retlen == c->wbuf_ofs - start) { | 241 | if (ret == -EBADMSG && retlen == c->wbuf_ofs - start) { |
243 | /* ECC recovered */ | 242 | /* ECC recovered */ |
244 | ret = 0; | 243 | ret = 0; |
@@ -266,7 +265,7 @@ static void jffs2_wbuf_recover(struct jffs2_sb_info *c) | |||
266 | 265 | ||
267 | 266 | ||
268 | /* ... and get an allocation of space from a shiny new block instead */ | 267 | /* ... and get an allocation of space from a shiny new block instead */ |
269 | ret = jffs2_reserve_space_gc(c, end-start, &ofs, &len); | 268 | ret = jffs2_reserve_space_gc(c, end-start, &ofs, &len, JFFS2_SUMMARY_NOSUM_SIZE); |
270 | if (ret) { | 269 | if (ret) { |
271 | printk(KERN_WARNING "Failed to allocate space for wbuf recovery. Data loss ensues.\n"); | 270 | printk(KERN_WARNING "Failed to allocate space for wbuf recovery. Data loss ensues.\n"); |
272 | kfree(buf); | 271 | kfree(buf); |
@@ -275,15 +274,15 @@ static void jffs2_wbuf_recover(struct jffs2_sb_info *c) | |||
275 | if (end-start >= c->wbuf_pagesize) { | 274 | if (end-start >= c->wbuf_pagesize) { |
276 | /* Need to do another write immediately, but it's possible | 275 | /* Need to do another write immediately, but it's possible |
277 | that this is just because the wbuf itself is completely | 276 | that this is just because the wbuf itself is completely |
278 | full, and there's nothing earlier read back from the | 277 | full, and there's nothing earlier read back from the |
279 | flash. Hence 'buf' isn't necessarily what we're writing | 278 | flash. Hence 'buf' isn't necessarily what we're writing |
280 | from. */ | 279 | from. */ |
281 | unsigned char *rewrite_buf = buf?:c->wbuf; | 280 | unsigned char *rewrite_buf = buf?:c->wbuf; |
282 | uint32_t towrite = (end-start) - ((end-start)%c->wbuf_pagesize); | 281 | uint32_t towrite = (end-start) - ((end-start)%c->wbuf_pagesize); |
283 | 282 | ||
284 | D1(printk(KERN_DEBUG "Write 0x%x bytes at 0x%08x in wbuf recover\n", | 283 | D1(printk(KERN_DEBUG "Write 0x%x bytes at 0x%08x in wbuf recover\n", |
285 | towrite, ofs)); | 284 | towrite, ofs)); |
286 | 285 | ||
287 | #ifdef BREAKMEHEADER | 286 | #ifdef BREAKMEHEADER |
288 | static int breakme; | 287 | static int breakme; |
289 | if (breakme++ == 20) { | 288 | if (breakme++ == 20) { |
@@ -327,8 +326,7 @@ static void jffs2_wbuf_recover(struct jffs2_sb_info *c) | |||
327 | c->wbuf_ofs = ofs + towrite; | 326 | c->wbuf_ofs = ofs + towrite; |
328 | memmove(c->wbuf, rewrite_buf + towrite, c->wbuf_len); | 327 | memmove(c->wbuf, rewrite_buf + towrite, c->wbuf_len); |
329 | /* Don't muck about with c->wbuf_inodes. False positives are harmless. */ | 328 | /* Don't muck about with c->wbuf_inodes. False positives are harmless. */ |
330 | if (buf) | 329 | kfree(buf); |
331 | kfree(buf); | ||
332 | } else { | 330 | } else { |
333 | /* OK, now we're left with the dregs in whichever buffer we're using */ | 331 | /* OK, now we're left with the dregs in whichever buffer we're using */ |
334 | if (buf) { | 332 | if (buf) { |
@@ -392,11 +390,11 @@ static void jffs2_wbuf_recover(struct jffs2_sb_info *c) | |||
392 | else | 390 | else |
393 | jeb->last_node = container_of(first_raw, struct jffs2_raw_node_ref, next_phys); | 391 | jeb->last_node = container_of(first_raw, struct jffs2_raw_node_ref, next_phys); |
394 | 392 | ||
395 | ACCT_SANITY_CHECK(c,jeb); | 393 | jffs2_dbg_acct_sanity_check_nolock(c, jeb); |
396 | D1(ACCT_PARANOIA_CHECK(jeb)); | 394 | jffs2_dbg_acct_paranoia_check_nolock(c, jeb); |
397 | 395 | ||
398 | ACCT_SANITY_CHECK(c,new_jeb); | 396 | jffs2_dbg_acct_sanity_check_nolock(c, new_jeb); |
399 | D1(ACCT_PARANOIA_CHECK(new_jeb)); | 397 | jffs2_dbg_acct_paranoia_check_nolock(c, new_jeb); |
400 | 398 | ||
401 | spin_unlock(&c->erase_completion_lock); | 399 | spin_unlock(&c->erase_completion_lock); |
402 | 400 | ||
@@ -435,15 +433,15 @@ static int __jffs2_flush_wbuf(struct jffs2_sb_info *c, int pad) | |||
435 | this happens, if we have a change to a new block, | 433 | this happens, if we have a change to a new block, |
436 | or if fsync forces us to flush the writebuffer. | 434 | or if fsync forces us to flush the writebuffer. |
437 | if we have a switch to next page, we will not have | 435 | if we have a switch to next page, we will not have |
438 | enough remaining space for this. | 436 | enough remaining space for this. |
439 | */ | 437 | */ |
440 | if (pad && !jffs2_dataflash(c)) { | 438 | if (pad ) { |
441 | c->wbuf_len = PAD(c->wbuf_len); | 439 | c->wbuf_len = PAD(c->wbuf_len); |
442 | 440 | ||
443 | /* Pad with JFFS2_DIRTY_BITMASK initially. this helps out ECC'd NOR | 441 | /* Pad with JFFS2_DIRTY_BITMASK initially. this helps out ECC'd NOR |
444 | with 8 byte page size */ | 442 | with 8 byte page size */ |
445 | memset(c->wbuf + c->wbuf_len, 0, c->wbuf_pagesize - c->wbuf_len); | 443 | memset(c->wbuf + c->wbuf_len, 0, c->wbuf_pagesize - c->wbuf_len); |
446 | 444 | ||
447 | if ( c->wbuf_len + sizeof(struct jffs2_unknown_node) < c->wbuf_pagesize) { | 445 | if ( c->wbuf_len + sizeof(struct jffs2_unknown_node) < c->wbuf_pagesize) { |
448 | struct jffs2_unknown_node *padnode = (void *)(c->wbuf + c->wbuf_len); | 446 | struct jffs2_unknown_node *padnode = (void *)(c->wbuf + c->wbuf_len); |
449 | padnode->magic = cpu_to_je16(JFFS2_MAGIC_BITMASK); | 447 | padnode->magic = cpu_to_je16(JFFS2_MAGIC_BITMASK); |
@@ -454,7 +452,7 @@ static int __jffs2_flush_wbuf(struct jffs2_sb_info *c, int pad) | |||
454 | } | 452 | } |
455 | /* else jffs2_flash_writev has actually filled in the rest of the | 453 | /* else jffs2_flash_writev has actually filled in the rest of the |
456 | buffer for us, and will deal with the node refs etc. later. */ | 454 | buffer for us, and will deal with the node refs etc. later. */ |
457 | 455 | ||
458 | #ifdef BREAKME | 456 | #ifdef BREAKME |
459 | static int breakme; | 457 | static int breakme; |
460 | if (breakme++ == 20) { | 458 | if (breakme++ == 20) { |
@@ -463,9 +461,9 @@ static int __jffs2_flush_wbuf(struct jffs2_sb_info *c, int pad) | |||
463 | c->mtd->write_ecc(c->mtd, c->wbuf_ofs, c->wbuf_pagesize, | 461 | c->mtd->write_ecc(c->mtd, c->wbuf_ofs, c->wbuf_pagesize, |
464 | &retlen, brokenbuf, NULL, c->oobinfo); | 462 | &retlen, brokenbuf, NULL, c->oobinfo); |
465 | ret = -EIO; | 463 | ret = -EIO; |
466 | } else | 464 | } else |
467 | #endif | 465 | #endif |
468 | 466 | ||
469 | if (jffs2_cleanmarker_oob(c)) | 467 | if (jffs2_cleanmarker_oob(c)) |
470 | ret = c->mtd->write_ecc(c->mtd, c->wbuf_ofs, c->wbuf_pagesize, &retlen, c->wbuf, NULL, c->oobinfo); | 468 | ret = c->mtd->write_ecc(c->mtd, c->wbuf_ofs, c->wbuf_pagesize, &retlen, c->wbuf, NULL, c->oobinfo); |
471 | else | 469 | else |
@@ -488,7 +486,7 @@ static int __jffs2_flush_wbuf(struct jffs2_sb_info *c, int pad) | |||
488 | spin_lock(&c->erase_completion_lock); | 486 | spin_lock(&c->erase_completion_lock); |
489 | 487 | ||
490 | /* Adjust free size of the block if we padded. */ | 488 | /* Adjust free size of the block if we padded. */ |
491 | if (pad && !jffs2_dataflash(c)) { | 489 | if (pad) { |
492 | struct jffs2_eraseblock *jeb; | 490 | struct jffs2_eraseblock *jeb; |
493 | 491 | ||
494 | jeb = &c->blocks[c->wbuf_ofs / c->sector_size]; | 492 | jeb = &c->blocks[c->wbuf_ofs / c->sector_size]; |
@@ -496,7 +494,7 @@ static int __jffs2_flush_wbuf(struct jffs2_sb_info *c, int pad) | |||
496 | D1(printk(KERN_DEBUG "jffs2_flush_wbuf() adjusting free_size of %sblock at %08x\n", | 494 | D1(printk(KERN_DEBUG "jffs2_flush_wbuf() adjusting free_size of %sblock at %08x\n", |
497 | (jeb==c->nextblock)?"next":"", jeb->offset)); | 495 | (jeb==c->nextblock)?"next":"", jeb->offset)); |
498 | 496 | ||
499 | /* wbuf_pagesize - wbuf_len is the amount of space that's to be | 497 | /* wbuf_pagesize - wbuf_len is the amount of space that's to be |
500 | padded. If there is less free space in the block than that, | 498 | padded. If there is less free space in the block than that, |
501 | something screwed up */ | 499 | something screwed up */ |
502 | if (jeb->free_size < (c->wbuf_pagesize - c->wbuf_len)) { | 500 | if (jeb->free_size < (c->wbuf_pagesize - c->wbuf_len)) { |
@@ -524,9 +522,9 @@ static int __jffs2_flush_wbuf(struct jffs2_sb_info *c, int pad) | |||
524 | return 0; | 522 | return 0; |
525 | } | 523 | } |
526 | 524 | ||
527 | /* Trigger garbage collection to flush the write-buffer. | 525 | /* Trigger garbage collection to flush the write-buffer. |
528 | If ino arg is zero, do it if _any_ real (i.e. not GC) writes are | 526 | If ino arg is zero, do it if _any_ real (i.e. not GC) writes are |
529 | outstanding. If ino arg non-zero, do it only if a write for the | 527 | outstanding. If ino arg non-zero, do it only if a write for the |
530 | given inode is outstanding. */ | 528 | given inode is outstanding. */ |
531 | int jffs2_flush_wbuf_gc(struct jffs2_sb_info *c, uint32_t ino) | 529 | int jffs2_flush_wbuf_gc(struct jffs2_sb_info *c, uint32_t ino) |
532 | { | 530 | { |
@@ -605,15 +603,6 @@ int jffs2_flush_wbuf_pad(struct jffs2_sb_info *c) | |||
605 | 603 | ||
606 | return ret; | 604 | return ret; |
607 | } | 605 | } |
608 | |||
609 | #ifdef CONFIG_JFFS2_FS_WRITEBUFFER | ||
610 | #define PAGE_DIV(x) ( ((unsigned long)(x) / (unsigned long)(c->wbuf_pagesize)) * (unsigned long)(c->wbuf_pagesize) ) | ||
611 | #define PAGE_MOD(x) ( (unsigned long)(x) % (unsigned long)(c->wbuf_pagesize) ) | ||
612 | #else | ||
613 | #define PAGE_DIV(x) ( (x) & (~(c->wbuf_pagesize - 1)) ) | ||
614 | #define PAGE_MOD(x) ( (x) & (c->wbuf_pagesize - 1) ) | ||
615 | #endif | ||
616 | |||
617 | int jffs2_flash_writev(struct jffs2_sb_info *c, const struct kvec *invecs, unsigned long count, loff_t to, size_t *retlen, uint32_t ino) | 606 | int jffs2_flash_writev(struct jffs2_sb_info *c, const struct kvec *invecs, unsigned long count, loff_t to, size_t *retlen, uint32_t ino) |
618 | { | 607 | { |
619 | struct kvec outvecs[3]; | 608 | struct kvec outvecs[3]; |
@@ -630,13 +619,13 @@ int jffs2_flash_writev(struct jffs2_sb_info *c, const struct kvec *invecs, unsig | |||
630 | /* If not NAND flash, don't bother */ | 619 | /* If not NAND flash, don't bother */ |
631 | if (!jffs2_is_writebuffered(c)) | 620 | if (!jffs2_is_writebuffered(c)) |
632 | return jffs2_flash_direct_writev(c, invecs, count, to, retlen); | 621 | return jffs2_flash_direct_writev(c, invecs, count, to, retlen); |
633 | 622 | ||
634 | down_write(&c->wbuf_sem); | 623 | down_write(&c->wbuf_sem); |
635 | 624 | ||
636 | /* If wbuf_ofs is not initialized, set it to target address */ | 625 | /* If wbuf_ofs is not initialized, set it to target address */ |
637 | if (c->wbuf_ofs == 0xFFFFFFFF) { | 626 | if (c->wbuf_ofs == 0xFFFFFFFF) { |
638 | c->wbuf_ofs = PAGE_DIV(to); | 627 | c->wbuf_ofs = PAGE_DIV(to); |
639 | c->wbuf_len = PAGE_MOD(to); | 628 | c->wbuf_len = PAGE_MOD(to); |
640 | memset(c->wbuf,0xff,c->wbuf_pagesize); | 629 | memset(c->wbuf,0xff,c->wbuf_pagesize); |
641 | } | 630 | } |
642 | 631 | ||
@@ -650,10 +639,10 @@ int jffs2_flash_writev(struct jffs2_sb_info *c, const struct kvec *invecs, unsig | |||
650 | memset(c->wbuf,0xff,c->wbuf_pagesize); | 639 | memset(c->wbuf,0xff,c->wbuf_pagesize); |
651 | } | 640 | } |
652 | } | 641 | } |
653 | 642 | ||
654 | /* Sanity checks on target address. | 643 | /* Sanity checks on target address. |
655 | It's permitted to write at PAD(c->wbuf_len+c->wbuf_ofs), | 644 | It's permitted to write at PAD(c->wbuf_len+c->wbuf_ofs), |
656 | and it's permitted to write at the beginning of a new | 645 | and it's permitted to write at the beginning of a new |
657 | erase block. Anything else, and you die. | 646 | erase block. Anything else, and you die. |
658 | New block starts at xxx000c (0-b = block header) | 647 | New block starts at xxx000c (0-b = block header) |
659 | */ | 648 | */ |
@@ -671,8 +660,8 @@ int jffs2_flash_writev(struct jffs2_sb_info *c, const struct kvec *invecs, unsig | |||
671 | } | 660 | } |
672 | /* set pointer to new block */ | 661 | /* set pointer to new block */ |
673 | c->wbuf_ofs = PAGE_DIV(to); | 662 | c->wbuf_ofs = PAGE_DIV(to); |
674 | c->wbuf_len = PAGE_MOD(to); | 663 | c->wbuf_len = PAGE_MOD(to); |
675 | } | 664 | } |
676 | 665 | ||
677 | if (to != PAD(c->wbuf_ofs + c->wbuf_len)) { | 666 | if (to != PAD(c->wbuf_ofs + c->wbuf_len)) { |
678 | /* We're not writing immediately after the writebuffer. Bad. */ | 667 | /* We're not writing immediately after the writebuffer. Bad. */ |
@@ -692,21 +681,21 @@ int jffs2_flash_writev(struct jffs2_sb_info *c, const struct kvec *invecs, unsig | |||
692 | invec = 0; | 681 | invec = 0; |
693 | outvec = 0; | 682 | outvec = 0; |
694 | 683 | ||
695 | /* Fill writebuffer first, if already in use */ | 684 | /* Fill writebuffer first, if already in use */ |
696 | if (c->wbuf_len) { | 685 | if (c->wbuf_len) { |
697 | uint32_t invec_ofs = 0; | 686 | uint32_t invec_ofs = 0; |
698 | 687 | ||
699 | /* adjust alignment offset */ | 688 | /* adjust alignment offset */ |
700 | if (c->wbuf_len != PAGE_MOD(to)) { | 689 | if (c->wbuf_len != PAGE_MOD(to)) { |
701 | c->wbuf_len = PAGE_MOD(to); | 690 | c->wbuf_len = PAGE_MOD(to); |
702 | /* take care of alignment to next page */ | 691 | /* take care of alignment to next page */ |
703 | if (!c->wbuf_len) | 692 | if (!c->wbuf_len) |
704 | c->wbuf_len = c->wbuf_pagesize; | 693 | c->wbuf_len = c->wbuf_pagesize; |
705 | } | 694 | } |
706 | 695 | ||
707 | while(c->wbuf_len < c->wbuf_pagesize) { | 696 | while(c->wbuf_len < c->wbuf_pagesize) { |
708 | uint32_t thislen; | 697 | uint32_t thislen; |
709 | 698 | ||
710 | if (invec == count) | 699 | if (invec == count) |
711 | goto alldone; | 700 | goto alldone; |
712 | 701 | ||
@@ -714,17 +703,17 @@ int jffs2_flash_writev(struct jffs2_sb_info *c, const struct kvec *invecs, unsig | |||
714 | 703 | ||
715 | if (thislen >= invecs[invec].iov_len) | 704 | if (thislen >= invecs[invec].iov_len) |
716 | thislen = invecs[invec].iov_len; | 705 | thislen = invecs[invec].iov_len; |
717 | 706 | ||
718 | invec_ofs = thislen; | 707 | invec_ofs = thislen; |
719 | 708 | ||
720 | memcpy(c->wbuf + c->wbuf_len, invecs[invec].iov_base, thislen); | 709 | memcpy(c->wbuf + c->wbuf_len, invecs[invec].iov_base, thislen); |
721 | c->wbuf_len += thislen; | 710 | c->wbuf_len += thislen; |
722 | donelen += thislen; | 711 | donelen += thislen; |
723 | /* Get next invec, if actual did not fill the buffer */ | 712 | /* Get next invec, if actual did not fill the buffer */ |
724 | if (c->wbuf_len < c->wbuf_pagesize) | 713 | if (c->wbuf_len < c->wbuf_pagesize) |
725 | invec++; | 714 | invec++; |
726 | } | 715 | } |
727 | 716 | ||
728 | /* write buffer is full, flush buffer */ | 717 | /* write buffer is full, flush buffer */ |
729 | ret = __jffs2_flush_wbuf(c, NOPAD); | 718 | ret = __jffs2_flush_wbuf(c, NOPAD); |
730 | if (ret) { | 719 | if (ret) { |
@@ -783,10 +772,10 @@ int jffs2_flash_writev(struct jffs2_sb_info *c, const struct kvec *invecs, unsig | |||
783 | 772 | ||
784 | /* We did cross a page boundary, so we write some now */ | 773 | /* We did cross a page boundary, so we write some now */ |
785 | if (jffs2_cleanmarker_oob(c)) | 774 | if (jffs2_cleanmarker_oob(c)) |
786 | ret = c->mtd->writev_ecc(c->mtd, outvecs, splitvec+1, outvec_to, &wbuf_retlen, NULL, c->oobinfo); | 775 | ret = c->mtd->writev_ecc(c->mtd, outvecs, splitvec+1, outvec_to, &wbuf_retlen, NULL, c->oobinfo); |
787 | else | 776 | else |
788 | ret = jffs2_flash_direct_writev(c, outvecs, splitvec+1, outvec_to, &wbuf_retlen); | 777 | ret = jffs2_flash_direct_writev(c, outvecs, splitvec+1, outvec_to, &wbuf_retlen); |
789 | 778 | ||
790 | if (ret < 0 || wbuf_retlen != PAGE_DIV(totlen)) { | 779 | if (ret < 0 || wbuf_retlen != PAGE_DIV(totlen)) { |
791 | /* At this point we have no problem, | 780 | /* At this point we have no problem, |
792 | c->wbuf is empty. However refile nextblock to avoid | 781 | c->wbuf is empty. However refile nextblock to avoid |
@@ -803,7 +792,7 @@ int jffs2_flash_writev(struct jffs2_sb_info *c, const struct kvec *invecs, unsig | |||
803 | spin_unlock(&c->erase_completion_lock); | 792 | spin_unlock(&c->erase_completion_lock); |
804 | goto exit; | 793 | goto exit; |
805 | } | 794 | } |
806 | 795 | ||
807 | donelen += wbuf_retlen; | 796 | donelen += wbuf_retlen; |
808 | c->wbuf_ofs = PAGE_DIV(outvec_to) + PAGE_DIV(totlen); | 797 | c->wbuf_ofs = PAGE_DIV(outvec_to) + PAGE_DIV(totlen); |
809 | 798 | ||
@@ -837,11 +826,17 @@ int jffs2_flash_writev(struct jffs2_sb_info *c, const struct kvec *invecs, unsig | |||
837 | alldone: | 826 | alldone: |
838 | *retlen = donelen; | 827 | *retlen = donelen; |
839 | 828 | ||
829 | if (jffs2_sum_active()) { | ||
830 | int res = jffs2_sum_add_kvec(c, invecs, count, (uint32_t) to); | ||
831 | if (res) | ||
832 | return res; | ||
833 | } | ||
834 | |||
840 | if (c->wbuf_len && ino) | 835 | if (c->wbuf_len && ino) |
841 | jffs2_wbuf_dirties_inode(c, ino); | 836 | jffs2_wbuf_dirties_inode(c, ino); |
842 | 837 | ||
843 | ret = 0; | 838 | ret = 0; |
844 | 839 | ||
845 | exit: | 840 | exit: |
846 | up_write(&c->wbuf_sem); | 841 | up_write(&c->wbuf_sem); |
847 | return ret; | 842 | return ret; |
@@ -856,7 +851,7 @@ int jffs2_flash_write(struct jffs2_sb_info *c, loff_t ofs, size_t len, size_t *r | |||
856 | struct kvec vecs[1]; | 851 | struct kvec vecs[1]; |
857 | 852 | ||
858 | if (!jffs2_is_writebuffered(c)) | 853 | if (!jffs2_is_writebuffered(c)) |
859 | return c->mtd->write(c->mtd, ofs, len, retlen, buf); | 854 | return jffs2_flash_direct_write(c, ofs, len, retlen, buf); |
860 | 855 | ||
861 | vecs[0].iov_base = (unsigned char *) buf; | 856 | vecs[0].iov_base = (unsigned char *) buf; |
862 | vecs[0].iov_len = len; | 857 | vecs[0].iov_len = len; |
@@ -884,18 +879,18 @@ int jffs2_flash_read(struct jffs2_sb_info *c, loff_t ofs, size_t len, size_t *re | |||
884 | if ( (ret == -EBADMSG) && (*retlen == len) ) { | 879 | if ( (ret == -EBADMSG) && (*retlen == len) ) { |
885 | printk(KERN_WARNING "mtd->read(0x%zx bytes from 0x%llx) returned ECC error\n", | 880 | printk(KERN_WARNING "mtd->read(0x%zx bytes from 0x%llx) returned ECC error\n", |
886 | len, ofs); | 881 | len, ofs); |
887 | /* | 882 | /* |
888 | * We have the raw data without ECC correction in the buffer, maybe | 883 | * We have the raw data without ECC correction in the buffer, maybe |
889 | * we are lucky and all data or parts are correct. We check the node. | 884 | * we are lucky and all data or parts are correct. We check the node. |
890 | * If data are corrupted node check will sort it out. | 885 | * If data are corrupted node check will sort it out. |
891 | * We keep this block, it will fail on write or erase and the we | 886 | * We keep this block, it will fail on write or erase and the we |
892 | * mark it bad. Or should we do that now? But we should give him a chance. | 887 | * mark it bad. Or should we do that now? But we should give him a chance. |
893 | * Maybe we had a system crash or power loss before the ecc write or | 888 | * Maybe we had a system crash or power loss before the ecc write or |
894 | * a erase was completed. | 889 | * a erase was completed. |
895 | * So we return success. :) | 890 | * So we return success. :) |
896 | */ | 891 | */ |
897 | ret = 0; | 892 | ret = 0; |
898 | } | 893 | } |
899 | 894 | ||
900 | /* if no writebuffer available or write buffer empty, return */ | 895 | /* if no writebuffer available or write buffer empty, return */ |
901 | if (!c->wbuf_pagesize || !c->wbuf_len) | 896 | if (!c->wbuf_pagesize || !c->wbuf_len) |
@@ -910,16 +905,16 @@ int jffs2_flash_read(struct jffs2_sb_info *c, loff_t ofs, size_t len, size_t *re | |||
910 | if (owbf > c->wbuf_len) /* is read beyond write buffer ? */ | 905 | if (owbf > c->wbuf_len) /* is read beyond write buffer ? */ |
911 | goto exit; | 906 | goto exit; |
912 | lwbf = c->wbuf_len - owbf; /* number of bytes to copy */ | 907 | lwbf = c->wbuf_len - owbf; /* number of bytes to copy */ |
913 | if (lwbf > len) | 908 | if (lwbf > len) |
914 | lwbf = len; | 909 | lwbf = len; |
915 | } else { | 910 | } else { |
916 | orbf = (c->wbuf_ofs - ofs); /* offset in read buffer */ | 911 | orbf = (c->wbuf_ofs - ofs); /* offset in read buffer */ |
917 | if (orbf > len) /* is write beyond write buffer ? */ | 912 | if (orbf > len) /* is write beyond write buffer ? */ |
918 | goto exit; | 913 | goto exit; |
919 | lwbf = len - orbf; /* number of bytes to copy */ | 914 | lwbf = len - orbf; /* number of bytes to copy */ |
920 | if (lwbf > c->wbuf_len) | 915 | if (lwbf > c->wbuf_len) |
921 | lwbf = c->wbuf_len; | 916 | lwbf = c->wbuf_len; |
922 | } | 917 | } |
923 | if (lwbf > 0) | 918 | if (lwbf > 0) |
924 | memcpy(buf+orbf,c->wbuf+owbf,lwbf); | 919 | memcpy(buf+orbf,c->wbuf+owbf,lwbf); |
925 | 920 | ||
@@ -947,7 +942,7 @@ int jffs2_check_oob_empty( struct jffs2_sb_info *c, struct jffs2_eraseblock *jeb | |||
947 | printk(KERN_NOTICE "jffs2_check_oob_empty(): allocation of temporary data buffer for oob check failed\n"); | 942 | printk(KERN_NOTICE "jffs2_check_oob_empty(): allocation of temporary data buffer for oob check failed\n"); |
948 | return -ENOMEM; | 943 | return -ENOMEM; |
949 | } | 944 | } |
950 | /* | 945 | /* |
951 | * if mode = 0, we scan for a total empty oob area, else we have | 946 | * if mode = 0, we scan for a total empty oob area, else we have |
952 | * to take care of the cleanmarker in the first page of the block | 947 | * to take care of the cleanmarker in the first page of the block |
953 | */ | 948 | */ |
@@ -956,41 +951,41 @@ int jffs2_check_oob_empty( struct jffs2_sb_info *c, struct jffs2_eraseblock *jeb | |||
956 | D1(printk(KERN_WARNING "jffs2_check_oob_empty(): Read OOB failed %d for block at %08x\n", ret, jeb->offset)); | 951 | D1(printk(KERN_WARNING "jffs2_check_oob_empty(): Read OOB failed %d for block at %08x\n", ret, jeb->offset)); |
957 | goto out; | 952 | goto out; |
958 | } | 953 | } |
959 | 954 | ||
960 | if (retlen < len) { | 955 | if (retlen < len) { |
961 | D1(printk(KERN_WARNING "jffs2_check_oob_empty(): Read OOB return short read " | 956 | D1(printk(KERN_WARNING "jffs2_check_oob_empty(): Read OOB return short read " |
962 | "(%zd bytes not %d) for block at %08x\n", retlen, len, jeb->offset)); | 957 | "(%zd bytes not %d) for block at %08x\n", retlen, len, jeb->offset)); |
963 | ret = -EIO; | 958 | ret = -EIO; |
964 | goto out; | 959 | goto out; |
965 | } | 960 | } |
966 | 961 | ||
967 | /* Special check for first page */ | 962 | /* Special check for first page */ |
968 | for(i = 0; i < oob_size ; i++) { | 963 | for(i = 0; i < oob_size ; i++) { |
969 | /* Yeah, we know about the cleanmarker. */ | 964 | /* Yeah, we know about the cleanmarker. */ |
970 | if (mode && i >= c->fsdata_pos && | 965 | if (mode && i >= c->fsdata_pos && |
971 | i < c->fsdata_pos + c->fsdata_len) | 966 | i < c->fsdata_pos + c->fsdata_len) |
972 | continue; | 967 | continue; |
973 | 968 | ||
974 | if (buf[i] != 0xFF) { | 969 | if (buf[i] != 0xFF) { |
975 | D2(printk(KERN_DEBUG "Found %02x at %x in OOB for %08x\n", | 970 | D2(printk(KERN_DEBUG "Found %02x at %x in OOB for %08x\n", |
976 | buf[page+i], page+i, jeb->offset)); | 971 | buf[i], i, jeb->offset)); |
977 | ret = 1; | 972 | ret = 1; |
978 | goto out; | 973 | goto out; |
979 | } | 974 | } |
980 | } | 975 | } |
981 | 976 | ||
982 | /* we know, we are aligned :) */ | 977 | /* we know, we are aligned :) */ |
983 | for (page = oob_size; page < len; page += sizeof(long)) { | 978 | for (page = oob_size; page < len; page += sizeof(long)) { |
984 | unsigned long dat = *(unsigned long *)(&buf[page]); | 979 | unsigned long dat = *(unsigned long *)(&buf[page]); |
985 | if(dat != -1) { | 980 | if(dat != -1) { |
986 | ret = 1; | 981 | ret = 1; |
987 | goto out; | 982 | goto out; |
988 | } | 983 | } |
989 | } | 984 | } |
990 | 985 | ||
991 | out: | 986 | out: |
992 | kfree(buf); | 987 | kfree(buf); |
993 | 988 | ||
994 | return ret; | 989 | return ret; |
995 | } | 990 | } |
996 | 991 | ||
@@ -1072,7 +1067,7 @@ int jffs2_write_nand_cleanmarker(struct jffs2_sb_info *c, struct jffs2_erasebloc | |||
1072 | n.totlen = cpu_to_je32(8); | 1067 | n.totlen = cpu_to_je32(8); |
1073 | 1068 | ||
1074 | ret = jffs2_flash_write_oob(c, jeb->offset + c->fsdata_pos, c->fsdata_len, &retlen, (unsigned char *)&n); | 1069 | ret = jffs2_flash_write_oob(c, jeb->offset + c->fsdata_pos, c->fsdata_len, &retlen, (unsigned char *)&n); |
1075 | 1070 | ||
1076 | if (ret) { | 1071 | if (ret) { |
1077 | D1(printk(KERN_WARNING "jffs2_write_nand_cleanmarker(): Write failed for block at %08x: error %d\n", jeb->offset, ret)); | 1072 | D1(printk(KERN_WARNING "jffs2_write_nand_cleanmarker(): Write failed for block at %08x: error %d\n", jeb->offset, ret)); |
1078 | return ret; | 1073 | return ret; |
@@ -1084,7 +1079,7 @@ int jffs2_write_nand_cleanmarker(struct jffs2_sb_info *c, struct jffs2_erasebloc | |||
1084 | return 0; | 1079 | return 0; |
1085 | } | 1080 | } |
1086 | 1081 | ||
1087 | /* | 1082 | /* |
1088 | * On NAND we try to mark this block bad. If the block was erased more | 1083 | * On NAND we try to mark this block bad. If the block was erased more |
1089 | * than MAX_ERASE_FAILURES we mark it finaly bad. | 1084 | * than MAX_ERASE_FAILURES we mark it finaly bad. |
1090 | * Don't care about failures. This block remains on the erase-pending | 1085 | * Don't care about failures. This block remains on the erase-pending |
@@ -1105,7 +1100,7 @@ int jffs2_write_nand_badblock(struct jffs2_sb_info *c, struct jffs2_eraseblock * | |||
1105 | 1100 | ||
1106 | D1(printk(KERN_WARNING "jffs2_write_nand_badblock(): Marking bad block at %08x\n", bad_offset)); | 1101 | D1(printk(KERN_WARNING "jffs2_write_nand_badblock(): Marking bad block at %08x\n", bad_offset)); |
1107 | ret = c->mtd->block_markbad(c->mtd, bad_offset); | 1102 | ret = c->mtd->block_markbad(c->mtd, bad_offset); |
1108 | 1103 | ||
1109 | if (ret) { | 1104 | if (ret) { |
1110 | D1(printk(KERN_WARNING "jffs2_write_nand_badblock(): Write failed for block at %08x: error %d\n", jeb->offset, ret)); | 1105 | D1(printk(KERN_WARNING "jffs2_write_nand_badblock(): Write failed for block at %08x: error %d\n", jeb->offset, ret)); |
1111 | return ret; | 1106 | return ret; |
@@ -1129,7 +1124,7 @@ static int jffs2_nand_set_oobinfo(struct jffs2_sb_info *c) | |||
1129 | /* Do this only, if we have an oob buffer */ | 1124 | /* Do this only, if we have an oob buffer */ |
1130 | if (!c->mtd->oobsize) | 1125 | if (!c->mtd->oobsize) |
1131 | return 0; | 1126 | return 0; |
1132 | 1127 | ||
1133 | /* Cleanmarker is out-of-band, so inline size zero */ | 1128 | /* Cleanmarker is out-of-band, so inline size zero */ |
1134 | c->cleanmarker_size = 0; | 1129 | c->cleanmarker_size = 0; |
1135 | 1130 | ||
@@ -1155,7 +1150,7 @@ static int jffs2_nand_set_oobinfo(struct jffs2_sb_info *c) | |||
1155 | c->fsdata_len = NAND_JFFS2_OOB16_FSDALEN; | 1150 | c->fsdata_len = NAND_JFFS2_OOB16_FSDALEN; |
1156 | c->badblock_pos = 15; | 1151 | c->badblock_pos = 15; |
1157 | break; | 1152 | break; |
1158 | 1153 | ||
1159 | default: | 1154 | default: |
1160 | D1(printk(KERN_DEBUG "JFFS2 on NAND. No autoplacment info found\n")); | 1155 | D1(printk(KERN_DEBUG "JFFS2 on NAND. No autoplacment info found\n")); |
1161 | return -EINVAL; | 1156 | return -EINVAL; |
@@ -1172,7 +1167,7 @@ int jffs2_nand_flash_setup(struct jffs2_sb_info *c) | |||
1172 | init_rwsem(&c->wbuf_sem); | 1167 | init_rwsem(&c->wbuf_sem); |
1173 | c->wbuf_pagesize = c->mtd->oobblock; | 1168 | c->wbuf_pagesize = c->mtd->oobblock; |
1174 | c->wbuf_ofs = 0xFFFFFFFF; | 1169 | c->wbuf_ofs = 0xFFFFFFFF; |
1175 | 1170 | ||
1176 | c->wbuf = kmalloc(c->wbuf_pagesize, GFP_KERNEL); | 1171 | c->wbuf = kmalloc(c->wbuf_pagesize, GFP_KERNEL); |
1177 | if (!c->wbuf) | 1172 | if (!c->wbuf) |
1178 | return -ENOMEM; | 1173 | return -ENOMEM; |
@@ -1198,17 +1193,41 @@ void jffs2_nand_flash_cleanup(struct jffs2_sb_info *c) | |||
1198 | 1193 | ||
1199 | int jffs2_dataflash_setup(struct jffs2_sb_info *c) { | 1194 | int jffs2_dataflash_setup(struct jffs2_sb_info *c) { |
1200 | c->cleanmarker_size = 0; /* No cleanmarkers needed */ | 1195 | c->cleanmarker_size = 0; /* No cleanmarkers needed */ |
1201 | 1196 | ||
1202 | /* Initialize write buffer */ | 1197 | /* Initialize write buffer */ |
1203 | init_rwsem(&c->wbuf_sem); | 1198 | init_rwsem(&c->wbuf_sem); |
1204 | c->wbuf_pagesize = c->sector_size; | ||
1205 | c->wbuf_ofs = 0xFFFFFFFF; | ||
1206 | 1199 | ||
1200 | |||
1201 | c->wbuf_pagesize = c->mtd->erasesize; | ||
1202 | |||
1203 | /* Find a suitable c->sector_size | ||
1204 | * - Not too much sectors | ||
1205 | * - Sectors have to be at least 4 K + some bytes | ||
1206 | * - All known dataflashes have erase sizes of 528 or 1056 | ||
1207 | * - we take at least 8 eraseblocks and want to have at least 8K size | ||
1208 | * - The concatenation should be a power of 2 | ||
1209 | */ | ||
1210 | |||
1211 | c->sector_size = 8 * c->mtd->erasesize; | ||
1212 | |||
1213 | while (c->sector_size < 8192) { | ||
1214 | c->sector_size *= 2; | ||
1215 | } | ||
1216 | |||
1217 | /* It may be necessary to adjust the flash size */ | ||
1218 | c->flash_size = c->mtd->size; | ||
1219 | |||
1220 | if ((c->flash_size % c->sector_size) != 0) { | ||
1221 | c->flash_size = (c->flash_size / c->sector_size) * c->sector_size; | ||
1222 | printk(KERN_WARNING "JFFS2 flash size adjusted to %dKiB\n", c->flash_size); | ||
1223 | }; | ||
1224 | |||
1225 | c->wbuf_ofs = 0xFFFFFFFF; | ||
1207 | c->wbuf = kmalloc(c->wbuf_pagesize, GFP_KERNEL); | 1226 | c->wbuf = kmalloc(c->wbuf_pagesize, GFP_KERNEL); |
1208 | if (!c->wbuf) | 1227 | if (!c->wbuf) |
1209 | return -ENOMEM; | 1228 | return -ENOMEM; |
1210 | 1229 | ||
1211 | printk(KERN_INFO "JFFS2 write-buffering enabled (%i)\n", c->wbuf_pagesize); | 1230 | printk(KERN_INFO "JFFS2 write-buffering enabled buffer (%d) erasesize (%d)\n", c->wbuf_pagesize, c->sector_size); |
1212 | 1231 | ||
1213 | return 0; | 1232 | return 0; |
1214 | } | 1233 | } |
@@ -1236,3 +1255,23 @@ int jffs2_nor_ecc_flash_setup(struct jffs2_sb_info *c) { | |||
1236 | void jffs2_nor_ecc_flash_cleanup(struct jffs2_sb_info *c) { | 1255 | void jffs2_nor_ecc_flash_cleanup(struct jffs2_sb_info *c) { |
1237 | kfree(c->wbuf); | 1256 | kfree(c->wbuf); |
1238 | } | 1257 | } |
1258 | |||
1259 | int jffs2_nor_wbuf_flash_setup(struct jffs2_sb_info *c) { | ||
1260 | /* Cleanmarker currently occupies a whole programming region */ | ||
1261 | c->cleanmarker_size = MTD_PROGREGION_SIZE(c->mtd); | ||
1262 | |||
1263 | /* Initialize write buffer */ | ||
1264 | init_rwsem(&c->wbuf_sem); | ||
1265 | c->wbuf_pagesize = MTD_PROGREGION_SIZE(c->mtd); | ||
1266 | c->wbuf_ofs = 0xFFFFFFFF; | ||
1267 | |||
1268 | c->wbuf = kmalloc(c->wbuf_pagesize, GFP_KERNEL); | ||
1269 | if (!c->wbuf) | ||
1270 | return -ENOMEM; | ||
1271 | |||
1272 | return 0; | ||
1273 | } | ||
1274 | |||
1275 | void jffs2_nor_wbuf_flash_cleanup(struct jffs2_sb_info *c) { | ||
1276 | kfree(c->wbuf); | ||
1277 | } | ||
diff --git a/fs/jffs2/write.c b/fs/jffs2/write.c index 69100615d9ae..1342f0158e9b 100644 --- a/fs/jffs2/write.c +++ b/fs/jffs2/write.c | |||
@@ -7,7 +7,7 @@ | |||
7 | * | 7 | * |
8 | * For licensing information, see the file 'LICENCE' in this directory. | 8 | * For licensing information, see the file 'LICENCE' in this directory. |
9 | * | 9 | * |
10 | * $Id: write.c,v 1.92 2005/04/13 13:22:35 dwmw2 Exp $ | 10 | * $Id: write.c,v 1.97 2005/11/07 11:14:42 gleixner Exp $ |
11 | * | 11 | * |
12 | */ | 12 | */ |
13 | 13 | ||
@@ -54,35 +54,7 @@ int jffs2_do_new_inode(struct jffs2_sb_info *c, struct jffs2_inode_info *f, uint | |||
54 | return 0; | 54 | return 0; |
55 | } | 55 | } |
56 | 56 | ||
57 | #if CONFIG_JFFS2_FS_DEBUG > 0 | 57 | /* jffs2_write_dnode - given a raw_inode, allocate a full_dnode for it, |
58 | static void writecheck(struct jffs2_sb_info *c, uint32_t ofs) | ||
59 | { | ||
60 | unsigned char buf[16]; | ||
61 | size_t retlen; | ||
62 | int ret, i; | ||
63 | |||
64 | ret = jffs2_flash_read(c, ofs, 16, &retlen, buf); | ||
65 | if (ret || (retlen != 16)) { | ||
66 | D1(printk(KERN_DEBUG "read failed or short in writecheck(). ret %d, retlen %zd\n", ret, retlen)); | ||
67 | return; | ||
68 | } | ||
69 | ret = 0; | ||
70 | for (i=0; i<16; i++) { | ||
71 | if (buf[i] != 0xff) | ||
72 | ret = 1; | ||
73 | } | ||
74 | if (ret) { | ||
75 | printk(KERN_WARNING "ARGH. About to write node to 0x%08x on flash, but there are data already there:\n", ofs); | ||
76 | printk(KERN_WARNING "0x%08x: %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x\n", | ||
77 | ofs, | ||
78 | buf[0], buf[1], buf[2], buf[3], buf[4], buf[5], buf[6], buf[7], | ||
79 | buf[8], buf[9], buf[10], buf[11], buf[12], buf[13], buf[14], buf[15]); | ||
80 | } | ||
81 | } | ||
82 | #endif | ||
83 | |||
84 | |||
85 | /* jffs2_write_dnode - given a raw_inode, allocate a full_dnode for it, | ||
86 | write it to the flash, link it into the existing inode/fragment list */ | 58 | write it to the flash, link it into the existing inode/fragment list */ |
87 | 59 | ||
88 | struct jffs2_full_dnode *jffs2_write_dnode(struct jffs2_sb_info *c, struct jffs2_inode_info *f, struct jffs2_raw_inode *ri, const unsigned char *data, uint32_t datalen, uint32_t flash_ofs, int alloc_mode) | 60 | struct jffs2_full_dnode *jffs2_write_dnode(struct jffs2_sb_info *c, struct jffs2_inode_info *f, struct jffs2_raw_inode *ri, const unsigned char *data, uint32_t datalen, uint32_t flash_ofs, int alloc_mode) |
@@ -106,7 +78,7 @@ struct jffs2_full_dnode *jffs2_write_dnode(struct jffs2_sb_info *c, struct jffs2 | |||
106 | vecs[1].iov_base = (unsigned char *)data; | 78 | vecs[1].iov_base = (unsigned char *)data; |
107 | vecs[1].iov_len = datalen; | 79 | vecs[1].iov_len = datalen; |
108 | 80 | ||
109 | D1(writecheck(c, flash_ofs)); | 81 | jffs2_dbg_prewrite_paranoia_check(c, flash_ofs, vecs[0].iov_len + vecs[1].iov_len); |
110 | 82 | ||
111 | if (je32_to_cpu(ri->totlen) != sizeof(*ri) + datalen) { | 83 | if (je32_to_cpu(ri->totlen) != sizeof(*ri) + datalen) { |
112 | printk(KERN_WARNING "jffs2_write_dnode: ri->totlen (0x%08x) != sizeof(*ri) (0x%08zx) + datalen (0x%08x)\n", je32_to_cpu(ri->totlen), sizeof(*ri), datalen); | 84 | printk(KERN_WARNING "jffs2_write_dnode: ri->totlen (0x%08x) != sizeof(*ri) (0x%08zx) + datalen (0x%08x)\n", je32_to_cpu(ri->totlen), sizeof(*ri), datalen); |
@@ -114,7 +86,7 @@ struct jffs2_full_dnode *jffs2_write_dnode(struct jffs2_sb_info *c, struct jffs2 | |||
114 | raw = jffs2_alloc_raw_node_ref(); | 86 | raw = jffs2_alloc_raw_node_ref(); |
115 | if (!raw) | 87 | if (!raw) |
116 | return ERR_PTR(-ENOMEM); | 88 | return ERR_PTR(-ENOMEM); |
117 | 89 | ||
118 | fn = jffs2_alloc_full_dnode(); | 90 | fn = jffs2_alloc_full_dnode(); |
119 | if (!fn) { | 91 | if (!fn) { |
120 | jffs2_free_raw_node_ref(raw); | 92 | jffs2_free_raw_node_ref(raw); |
@@ -138,7 +110,7 @@ struct jffs2_full_dnode *jffs2_write_dnode(struct jffs2_sb_info *c, struct jffs2 | |||
138 | if ((alloc_mode!=ALLOC_GC) && (je32_to_cpu(ri->version) < f->highest_version)) { | 110 | if ((alloc_mode!=ALLOC_GC) && (je32_to_cpu(ri->version) < f->highest_version)) { |
139 | BUG_ON(!retried); | 111 | BUG_ON(!retried); |
140 | D1(printk(KERN_DEBUG "jffs2_write_dnode : dnode_version %d, " | 112 | D1(printk(KERN_DEBUG "jffs2_write_dnode : dnode_version %d, " |
141 | "highest version %d -> updating dnode\n", | 113 | "highest version %d -> updating dnode\n", |
142 | je32_to_cpu(ri->version), f->highest_version)); | 114 | je32_to_cpu(ri->version), f->highest_version)); |
143 | ri->version = cpu_to_je32(++f->highest_version); | 115 | ri->version = cpu_to_je32(++f->highest_version); |
144 | ri->node_crc = cpu_to_je32(crc32(0, ri, sizeof(*ri)-8)); | 116 | ri->node_crc = cpu_to_je32(crc32(0, ri, sizeof(*ri)-8)); |
@@ -148,7 +120,7 @@ struct jffs2_full_dnode *jffs2_write_dnode(struct jffs2_sb_info *c, struct jffs2 | |||
148 | (alloc_mode==ALLOC_GC)?0:f->inocache->ino); | 120 | (alloc_mode==ALLOC_GC)?0:f->inocache->ino); |
149 | 121 | ||
150 | if (ret || (retlen != sizeof(*ri) + datalen)) { | 122 | if (ret || (retlen != sizeof(*ri) + datalen)) { |
151 | printk(KERN_NOTICE "Write of %zd bytes at 0x%08x failed. returned %d, retlen %zd\n", | 123 | printk(KERN_NOTICE "Write of %zd bytes at 0x%08x failed. returned %d, retlen %zd\n", |
152 | sizeof(*ri)+datalen, flash_ofs, ret, retlen); | 124 | sizeof(*ri)+datalen, flash_ofs, ret, retlen); |
153 | 125 | ||
154 | /* Mark the space as dirtied */ | 126 | /* Mark the space as dirtied */ |
@@ -156,10 +128,10 @@ struct jffs2_full_dnode *jffs2_write_dnode(struct jffs2_sb_info *c, struct jffs2 | |||
156 | /* Doesn't belong to any inode */ | 128 | /* Doesn't belong to any inode */ |
157 | raw->next_in_ino = NULL; | 129 | raw->next_in_ino = NULL; |
158 | 130 | ||
159 | /* Don't change raw->size to match retlen. We may have | 131 | /* Don't change raw->size to match retlen. We may have |
160 | written the node header already, and only the data will | 132 | written the node header already, and only the data will |
161 | seem corrupted, in which case the scan would skip over | 133 | seem corrupted, in which case the scan would skip over |
162 | any node we write before the original intended end of | 134 | any node we write before the original intended end of |
163 | this node */ | 135 | this node */ |
164 | raw->flash_offset |= REF_OBSOLETE; | 136 | raw->flash_offset |= REF_OBSOLETE; |
165 | jffs2_add_physical_node_ref(c, raw); | 137 | jffs2_add_physical_node_ref(c, raw); |
@@ -176,26 +148,28 @@ struct jffs2_full_dnode *jffs2_write_dnode(struct jffs2_sb_info *c, struct jffs2 | |||
176 | retried = 1; | 148 | retried = 1; |
177 | 149 | ||
178 | D1(printk(KERN_DEBUG "Retrying failed write.\n")); | 150 | D1(printk(KERN_DEBUG "Retrying failed write.\n")); |
179 | 151 | ||
180 | ACCT_SANITY_CHECK(c,jeb); | 152 | jffs2_dbg_acct_sanity_check(c,jeb); |
181 | D1(ACCT_PARANOIA_CHECK(jeb)); | 153 | jffs2_dbg_acct_paranoia_check(c, jeb); |
182 | 154 | ||
183 | if (alloc_mode == ALLOC_GC) { | 155 | if (alloc_mode == ALLOC_GC) { |
184 | ret = jffs2_reserve_space_gc(c, sizeof(*ri) + datalen, &flash_ofs, &dummy); | 156 | ret = jffs2_reserve_space_gc(c, sizeof(*ri) + datalen, &flash_ofs, |
157 | &dummy, JFFS2_SUMMARY_INODE_SIZE); | ||
185 | } else { | 158 | } else { |
186 | /* Locking pain */ | 159 | /* Locking pain */ |
187 | up(&f->sem); | 160 | up(&f->sem); |
188 | jffs2_complete_reservation(c); | 161 | jffs2_complete_reservation(c); |
189 | 162 | ||
190 | ret = jffs2_reserve_space(c, sizeof(*ri) + datalen, &flash_ofs, &dummy, alloc_mode); | 163 | ret = jffs2_reserve_space(c, sizeof(*ri) + datalen, &flash_ofs, |
164 | &dummy, alloc_mode, JFFS2_SUMMARY_INODE_SIZE); | ||
191 | down(&f->sem); | 165 | down(&f->sem); |
192 | } | 166 | } |
193 | 167 | ||
194 | if (!ret) { | 168 | if (!ret) { |
195 | D1(printk(KERN_DEBUG "Allocated space at 0x%08x to retry failed write.\n", flash_ofs)); | 169 | D1(printk(KERN_DEBUG "Allocated space at 0x%08x to retry failed write.\n", flash_ofs)); |
196 | 170 | ||
197 | ACCT_SANITY_CHECK(c,jeb); | 171 | jffs2_dbg_acct_sanity_check(c,jeb); |
198 | D1(ACCT_PARANOIA_CHECK(jeb)); | 172 | jffs2_dbg_acct_paranoia_check(c, jeb); |
199 | 173 | ||
200 | goto retry; | 174 | goto retry; |
201 | } | 175 | } |
@@ -207,9 +181,9 @@ struct jffs2_full_dnode *jffs2_write_dnode(struct jffs2_sb_info *c, struct jffs2 | |||
207 | return ERR_PTR(ret?ret:-EIO); | 181 | return ERR_PTR(ret?ret:-EIO); |
208 | } | 182 | } |
209 | /* Mark the space used */ | 183 | /* Mark the space used */ |
210 | /* If node covers at least a whole page, or if it starts at the | 184 | /* If node covers at least a whole page, or if it starts at the |
211 | beginning of a page and runs to the end of the file, or if | 185 | beginning of a page and runs to the end of the file, or if |
212 | it's a hole node, mark it REF_PRISTINE, else REF_NORMAL. | 186 | it's a hole node, mark it REF_PRISTINE, else REF_NORMAL. |
213 | */ | 187 | */ |
214 | if ((je32_to_cpu(ri->dsize) >= PAGE_CACHE_SIZE) || | 188 | if ((je32_to_cpu(ri->dsize) >= PAGE_CACHE_SIZE) || |
215 | ( ((je32_to_cpu(ri->offset)&(PAGE_CACHE_SIZE-1))==0) && | 189 | ( ((je32_to_cpu(ri->offset)&(PAGE_CACHE_SIZE-1))==0) && |
@@ -227,12 +201,12 @@ struct jffs2_full_dnode *jffs2_write_dnode(struct jffs2_sb_info *c, struct jffs2 | |||
227 | spin_unlock(&c->erase_completion_lock); | 201 | spin_unlock(&c->erase_completion_lock); |
228 | 202 | ||
229 | D1(printk(KERN_DEBUG "jffs2_write_dnode wrote node at 0x%08x(%d) with dsize 0x%x, csize 0x%x, node_crc 0x%08x, data_crc 0x%08x, totlen 0x%08x\n", | 203 | D1(printk(KERN_DEBUG "jffs2_write_dnode wrote node at 0x%08x(%d) with dsize 0x%x, csize 0x%x, node_crc 0x%08x, data_crc 0x%08x, totlen 0x%08x\n", |
230 | flash_ofs, ref_flags(raw), je32_to_cpu(ri->dsize), | 204 | flash_ofs, ref_flags(raw), je32_to_cpu(ri->dsize), |
231 | je32_to_cpu(ri->csize), je32_to_cpu(ri->node_crc), | 205 | je32_to_cpu(ri->csize), je32_to_cpu(ri->node_crc), |
232 | je32_to_cpu(ri->data_crc), je32_to_cpu(ri->totlen))); | 206 | je32_to_cpu(ri->data_crc), je32_to_cpu(ri->totlen))); |
233 | 207 | ||
234 | if (retried) { | 208 | if (retried) { |
235 | ACCT_SANITY_CHECK(c,NULL); | 209 | jffs2_dbg_acct_sanity_check(c,NULL); |
236 | } | 210 | } |
237 | 211 | ||
238 | return fn; | 212 | return fn; |
@@ -247,10 +221,9 @@ struct jffs2_full_dirent *jffs2_write_dirent(struct jffs2_sb_info *c, struct jff | |||
247 | int retried = 0; | 221 | int retried = 0; |
248 | int ret; | 222 | int ret; |
249 | 223 | ||
250 | D1(printk(KERN_DEBUG "jffs2_write_dirent(ino #%u, name at *0x%p \"%s\"->ino #%u, name_crc 0x%08x)\n", | 224 | D1(printk(KERN_DEBUG "jffs2_write_dirent(ino #%u, name at *0x%p \"%s\"->ino #%u, name_crc 0x%08x)\n", |
251 | je32_to_cpu(rd->pino), name, name, je32_to_cpu(rd->ino), | 225 | je32_to_cpu(rd->pino), name, name, je32_to_cpu(rd->ino), |
252 | je32_to_cpu(rd->name_crc))); | 226 | je32_to_cpu(rd->name_crc))); |
253 | D1(writecheck(c, flash_ofs)); | ||
254 | 227 | ||
255 | D1(if(je32_to_cpu(rd->hdr_crc) != crc32(0, rd, sizeof(struct jffs2_unknown_node)-4)) { | 228 | D1(if(je32_to_cpu(rd->hdr_crc) != crc32(0, rd, sizeof(struct jffs2_unknown_node)-4)) { |
256 | printk(KERN_CRIT "Eep. CRC not correct in jffs2_write_dirent()\n"); | 229 | printk(KERN_CRIT "Eep. CRC not correct in jffs2_write_dirent()\n"); |
@@ -262,7 +235,9 @@ struct jffs2_full_dirent *jffs2_write_dirent(struct jffs2_sb_info *c, struct jff | |||
262 | vecs[0].iov_len = sizeof(*rd); | 235 | vecs[0].iov_len = sizeof(*rd); |
263 | vecs[1].iov_base = (unsigned char *)name; | 236 | vecs[1].iov_base = (unsigned char *)name; |
264 | vecs[1].iov_len = namelen; | 237 | vecs[1].iov_len = namelen; |
265 | 238 | ||
239 | jffs2_dbg_prewrite_paranoia_check(c, flash_ofs, vecs[0].iov_len + vecs[1].iov_len); | ||
240 | |||
266 | raw = jffs2_alloc_raw_node_ref(); | 241 | raw = jffs2_alloc_raw_node_ref(); |
267 | 242 | ||
268 | if (!raw) | 243 | if (!raw) |
@@ -301,7 +276,7 @@ struct jffs2_full_dirent *jffs2_write_dirent(struct jffs2_sb_info *c, struct jff | |||
301 | ret = jffs2_flash_writev(c, vecs, 2, flash_ofs, &retlen, | 276 | ret = jffs2_flash_writev(c, vecs, 2, flash_ofs, &retlen, |
302 | (alloc_mode==ALLOC_GC)?0:je32_to_cpu(rd->pino)); | 277 | (alloc_mode==ALLOC_GC)?0:je32_to_cpu(rd->pino)); |
303 | if (ret || (retlen != sizeof(*rd) + namelen)) { | 278 | if (ret || (retlen != sizeof(*rd) + namelen)) { |
304 | printk(KERN_NOTICE "Write of %zd bytes at 0x%08x failed. returned %d, retlen %zd\n", | 279 | printk(KERN_NOTICE "Write of %zd bytes at 0x%08x failed. returned %d, retlen %zd\n", |
305 | sizeof(*rd)+namelen, flash_ofs, ret, retlen); | 280 | sizeof(*rd)+namelen, flash_ofs, ret, retlen); |
306 | /* Mark the space as dirtied */ | 281 | /* Mark the space as dirtied */ |
307 | if (retlen) { | 282 | if (retlen) { |
@@ -322,24 +297,26 @@ struct jffs2_full_dirent *jffs2_write_dirent(struct jffs2_sb_info *c, struct jff | |||
322 | 297 | ||
323 | D1(printk(KERN_DEBUG "Retrying failed write.\n")); | 298 | D1(printk(KERN_DEBUG "Retrying failed write.\n")); |
324 | 299 | ||
325 | ACCT_SANITY_CHECK(c,jeb); | 300 | jffs2_dbg_acct_sanity_check(c,jeb); |
326 | D1(ACCT_PARANOIA_CHECK(jeb)); | 301 | jffs2_dbg_acct_paranoia_check(c, jeb); |
327 | 302 | ||
328 | if (alloc_mode == ALLOC_GC) { | 303 | if (alloc_mode == ALLOC_GC) { |
329 | ret = jffs2_reserve_space_gc(c, sizeof(*rd) + namelen, &flash_ofs, &dummy); | 304 | ret = jffs2_reserve_space_gc(c, sizeof(*rd) + namelen, &flash_ofs, |
305 | &dummy, JFFS2_SUMMARY_DIRENT_SIZE(namelen)); | ||
330 | } else { | 306 | } else { |
331 | /* Locking pain */ | 307 | /* Locking pain */ |
332 | up(&f->sem); | 308 | up(&f->sem); |
333 | jffs2_complete_reservation(c); | 309 | jffs2_complete_reservation(c); |
334 | 310 | ||
335 | ret = jffs2_reserve_space(c, sizeof(*rd) + namelen, &flash_ofs, &dummy, alloc_mode); | 311 | ret = jffs2_reserve_space(c, sizeof(*rd) + namelen, &flash_ofs, |
312 | &dummy, alloc_mode, JFFS2_SUMMARY_DIRENT_SIZE(namelen)); | ||
336 | down(&f->sem); | 313 | down(&f->sem); |
337 | } | 314 | } |
338 | 315 | ||
339 | if (!ret) { | 316 | if (!ret) { |
340 | D1(printk(KERN_DEBUG "Allocated space at 0x%08x to retry failed write.\n", flash_ofs)); | 317 | D1(printk(KERN_DEBUG "Allocated space at 0x%08x to retry failed write.\n", flash_ofs)); |
341 | ACCT_SANITY_CHECK(c,jeb); | 318 | jffs2_dbg_acct_sanity_check(c,jeb); |
342 | D1(ACCT_PARANOIA_CHECK(jeb)); | 319 | jffs2_dbg_acct_paranoia_check(c, jeb); |
343 | goto retry; | 320 | goto retry; |
344 | } | 321 | } |
345 | D1(printk(KERN_DEBUG "Failed to allocate space to retry failed write: %d!\n", ret)); | 322 | D1(printk(KERN_DEBUG "Failed to allocate space to retry failed write: %d!\n", ret)); |
@@ -359,7 +336,7 @@ struct jffs2_full_dirent *jffs2_write_dirent(struct jffs2_sb_info *c, struct jff | |||
359 | spin_unlock(&c->erase_completion_lock); | 336 | spin_unlock(&c->erase_completion_lock); |
360 | 337 | ||
361 | if (retried) { | 338 | if (retried) { |
362 | ACCT_SANITY_CHECK(c,NULL); | 339 | jffs2_dbg_acct_sanity_check(c,NULL); |
363 | } | 340 | } |
364 | 341 | ||
365 | return fd; | 342 | return fd; |
@@ -369,7 +346,7 @@ struct jffs2_full_dirent *jffs2_write_dirent(struct jffs2_sb_info *c, struct jff | |||
369 | we don't have to go digging in struct inode or its equivalent. It should set: | 346 | we don't have to go digging in struct inode or its equivalent. It should set: |
370 | mode, uid, gid, (starting)isize, atime, ctime, mtime */ | 347 | mode, uid, gid, (starting)isize, atime, ctime, mtime */ |
371 | int jffs2_write_inode_range(struct jffs2_sb_info *c, struct jffs2_inode_info *f, | 348 | int jffs2_write_inode_range(struct jffs2_sb_info *c, struct jffs2_inode_info *f, |
372 | struct jffs2_raw_inode *ri, unsigned char *buf, | 349 | struct jffs2_raw_inode *ri, unsigned char *buf, |
373 | uint32_t offset, uint32_t writelen, uint32_t *retlen) | 350 | uint32_t offset, uint32_t writelen, uint32_t *retlen) |
374 | { | 351 | { |
375 | int ret = 0; | 352 | int ret = 0; |
@@ -377,7 +354,7 @@ int jffs2_write_inode_range(struct jffs2_sb_info *c, struct jffs2_inode_info *f, | |||
377 | 354 | ||
378 | D1(printk(KERN_DEBUG "jffs2_write_inode_range(): Ino #%u, ofs 0x%x, len 0x%x\n", | 355 | D1(printk(KERN_DEBUG "jffs2_write_inode_range(): Ino #%u, ofs 0x%x, len 0x%x\n", |
379 | f->inocache->ino, offset, writelen)); | 356 | f->inocache->ino, offset, writelen)); |
380 | 357 | ||
381 | while(writelen) { | 358 | while(writelen) { |
382 | struct jffs2_full_dnode *fn; | 359 | struct jffs2_full_dnode *fn; |
383 | unsigned char *comprbuf = NULL; | 360 | unsigned char *comprbuf = NULL; |
@@ -389,7 +366,8 @@ int jffs2_write_inode_range(struct jffs2_sb_info *c, struct jffs2_inode_info *f, | |||
389 | retry: | 366 | retry: |
390 | D2(printk(KERN_DEBUG "jffs2_commit_write() loop: 0x%x to write to 0x%x\n", writelen, offset)); | 367 | D2(printk(KERN_DEBUG "jffs2_commit_write() loop: 0x%x to write to 0x%x\n", writelen, offset)); |
391 | 368 | ||
392 | ret = jffs2_reserve_space(c, sizeof(*ri) + JFFS2_MIN_DATA_LEN, &phys_ofs, &alloclen, ALLOC_NORMAL); | 369 | ret = jffs2_reserve_space(c, sizeof(*ri) + JFFS2_MIN_DATA_LEN, &phys_ofs, |
370 | &alloclen, ALLOC_NORMAL, JFFS2_SUMMARY_INODE_SIZE); | ||
393 | if (ret) { | 371 | if (ret) { |
394 | D1(printk(KERN_DEBUG "jffs2_reserve_space returned %d\n", ret)); | 372 | D1(printk(KERN_DEBUG "jffs2_reserve_space returned %d\n", ret)); |
395 | break; | 373 | break; |
@@ -473,10 +451,11 @@ int jffs2_do_create(struct jffs2_sb_info *c, struct jffs2_inode_info *dir_f, str | |||
473 | uint32_t alloclen, phys_ofs; | 451 | uint32_t alloclen, phys_ofs; |
474 | int ret; | 452 | int ret; |
475 | 453 | ||
476 | /* Try to reserve enough space for both node and dirent. | 454 | /* Try to reserve enough space for both node and dirent. |
477 | * Just the node will do for now, though | 455 | * Just the node will do for now, though |
478 | */ | 456 | */ |
479 | ret = jffs2_reserve_space(c, sizeof(*ri), &phys_ofs, &alloclen, ALLOC_NORMAL); | 457 | ret = jffs2_reserve_space(c, sizeof(*ri), &phys_ofs, &alloclen, ALLOC_NORMAL, |
458 | JFFS2_SUMMARY_INODE_SIZE); | ||
480 | D1(printk(KERN_DEBUG "jffs2_do_create(): reserved 0x%x bytes\n", alloclen)); | 459 | D1(printk(KERN_DEBUG "jffs2_do_create(): reserved 0x%x bytes\n", alloclen)); |
481 | if (ret) { | 460 | if (ret) { |
482 | up(&f->sem); | 461 | up(&f->sem); |
@@ -498,15 +477,16 @@ int jffs2_do_create(struct jffs2_sb_info *c, struct jffs2_inode_info *dir_f, str | |||
498 | jffs2_complete_reservation(c); | 477 | jffs2_complete_reservation(c); |
499 | return PTR_ERR(fn); | 478 | return PTR_ERR(fn); |
500 | } | 479 | } |
501 | /* No data here. Only a metadata node, which will be | 480 | /* No data here. Only a metadata node, which will be |
502 | obsoleted by the first data write | 481 | obsoleted by the first data write |
503 | */ | 482 | */ |
504 | f->metadata = fn; | 483 | f->metadata = fn; |
505 | 484 | ||
506 | up(&f->sem); | 485 | up(&f->sem); |
507 | jffs2_complete_reservation(c); | 486 | jffs2_complete_reservation(c); |
508 | ret = jffs2_reserve_space(c, sizeof(*rd)+namelen, &phys_ofs, &alloclen, ALLOC_NORMAL); | 487 | ret = jffs2_reserve_space(c, sizeof(*rd)+namelen, &phys_ofs, &alloclen, |
509 | 488 | ALLOC_NORMAL, JFFS2_SUMMARY_DIRENT_SIZE(namelen)); | |
489 | |||
510 | if (ret) { | 490 | if (ret) { |
511 | /* Eep. */ | 491 | /* Eep. */ |
512 | D1(printk(KERN_DEBUG "jffs2_reserve_space() for dirent failed\n")); | 492 | D1(printk(KERN_DEBUG "jffs2_reserve_space() for dirent failed\n")); |
@@ -539,9 +519,9 @@ int jffs2_do_create(struct jffs2_sb_info *c, struct jffs2_inode_info *dir_f, str | |||
539 | fd = jffs2_write_dirent(c, dir_f, rd, name, namelen, phys_ofs, ALLOC_NORMAL); | 519 | fd = jffs2_write_dirent(c, dir_f, rd, name, namelen, phys_ofs, ALLOC_NORMAL); |
540 | 520 | ||
541 | jffs2_free_raw_dirent(rd); | 521 | jffs2_free_raw_dirent(rd); |
542 | 522 | ||
543 | if (IS_ERR(fd)) { | 523 | if (IS_ERR(fd)) { |
544 | /* dirent failed to write. Delete the inode normally | 524 | /* dirent failed to write. Delete the inode normally |
545 | as if it were the final unlink() */ | 525 | as if it were the final unlink() */ |
546 | jffs2_complete_reservation(c); | 526 | jffs2_complete_reservation(c); |
547 | up(&dir_f->sem); | 527 | up(&dir_f->sem); |
@@ -560,14 +540,15 @@ int jffs2_do_create(struct jffs2_sb_info *c, struct jffs2_inode_info *dir_f, str | |||
560 | 540 | ||
561 | 541 | ||
562 | int jffs2_do_unlink(struct jffs2_sb_info *c, struct jffs2_inode_info *dir_f, | 542 | int jffs2_do_unlink(struct jffs2_sb_info *c, struct jffs2_inode_info *dir_f, |
563 | const char *name, int namelen, struct jffs2_inode_info *dead_f) | 543 | const char *name, int namelen, struct jffs2_inode_info *dead_f, |
544 | uint32_t time) | ||
564 | { | 545 | { |
565 | struct jffs2_raw_dirent *rd; | 546 | struct jffs2_raw_dirent *rd; |
566 | struct jffs2_full_dirent *fd; | 547 | struct jffs2_full_dirent *fd; |
567 | uint32_t alloclen, phys_ofs; | 548 | uint32_t alloclen, phys_ofs; |
568 | int ret; | 549 | int ret; |
569 | 550 | ||
570 | if (1 /* alternative branch needs testing */ || | 551 | if (1 /* alternative branch needs testing */ || |
571 | !jffs2_can_mark_obsolete(c)) { | 552 | !jffs2_can_mark_obsolete(c)) { |
572 | /* We can't mark stuff obsolete on the medium. We need to write a deletion dirent */ | 553 | /* We can't mark stuff obsolete on the medium. We need to write a deletion dirent */ |
573 | 554 | ||
@@ -575,7 +556,8 @@ int jffs2_do_unlink(struct jffs2_sb_info *c, struct jffs2_inode_info *dir_f, | |||
575 | if (!rd) | 556 | if (!rd) |
576 | return -ENOMEM; | 557 | return -ENOMEM; |
577 | 558 | ||
578 | ret = jffs2_reserve_space(c, sizeof(*rd)+namelen, &phys_ofs, &alloclen, ALLOC_DELETION); | 559 | ret = jffs2_reserve_space(c, sizeof(*rd)+namelen, &phys_ofs, &alloclen, |
560 | ALLOC_DELETION, JFFS2_SUMMARY_DIRENT_SIZE(namelen)); | ||
579 | if (ret) { | 561 | if (ret) { |
580 | jffs2_free_raw_dirent(rd); | 562 | jffs2_free_raw_dirent(rd); |
581 | return ret; | 563 | return ret; |
@@ -588,18 +570,18 @@ int jffs2_do_unlink(struct jffs2_sb_info *c, struct jffs2_inode_info *dir_f, | |||
588 | rd->nodetype = cpu_to_je16(JFFS2_NODETYPE_DIRENT); | 570 | rd->nodetype = cpu_to_je16(JFFS2_NODETYPE_DIRENT); |
589 | rd->totlen = cpu_to_je32(sizeof(*rd) + namelen); | 571 | rd->totlen = cpu_to_je32(sizeof(*rd) + namelen); |
590 | rd->hdr_crc = cpu_to_je32(crc32(0, rd, sizeof(struct jffs2_unknown_node)-4)); | 572 | rd->hdr_crc = cpu_to_je32(crc32(0, rd, sizeof(struct jffs2_unknown_node)-4)); |
591 | 573 | ||
592 | rd->pino = cpu_to_je32(dir_f->inocache->ino); | 574 | rd->pino = cpu_to_je32(dir_f->inocache->ino); |
593 | rd->version = cpu_to_je32(++dir_f->highest_version); | 575 | rd->version = cpu_to_je32(++dir_f->highest_version); |
594 | rd->ino = cpu_to_je32(0); | 576 | rd->ino = cpu_to_je32(0); |
595 | rd->mctime = cpu_to_je32(get_seconds()); | 577 | rd->mctime = cpu_to_je32(time); |
596 | rd->nsize = namelen; | 578 | rd->nsize = namelen; |
597 | rd->type = DT_UNKNOWN; | 579 | rd->type = DT_UNKNOWN; |
598 | rd->node_crc = cpu_to_je32(crc32(0, rd, sizeof(*rd)-8)); | 580 | rd->node_crc = cpu_to_je32(crc32(0, rd, sizeof(*rd)-8)); |
599 | rd->name_crc = cpu_to_je32(crc32(0, name, namelen)); | 581 | rd->name_crc = cpu_to_je32(crc32(0, name, namelen)); |
600 | 582 | ||
601 | fd = jffs2_write_dirent(c, dir_f, rd, name, namelen, phys_ofs, ALLOC_DELETION); | 583 | fd = jffs2_write_dirent(c, dir_f, rd, name, namelen, phys_ofs, ALLOC_DELETION); |
602 | 584 | ||
603 | jffs2_free_raw_dirent(rd); | 585 | jffs2_free_raw_dirent(rd); |
604 | 586 | ||
605 | if (IS_ERR(fd)) { | 587 | if (IS_ERR(fd)) { |
@@ -618,7 +600,7 @@ int jffs2_do_unlink(struct jffs2_sb_info *c, struct jffs2_inode_info *dir_f, | |||
618 | down(&dir_f->sem); | 600 | down(&dir_f->sem); |
619 | 601 | ||
620 | while ((*prev) && (*prev)->nhash <= nhash) { | 602 | while ((*prev) && (*prev)->nhash <= nhash) { |
621 | if ((*prev)->nhash == nhash && | 603 | if ((*prev)->nhash == nhash && |
622 | !memcmp((*prev)->name, name, namelen) && | 604 | !memcmp((*prev)->name, name, namelen) && |
623 | !(*prev)->name[namelen]) { | 605 | !(*prev)->name[namelen]) { |
624 | struct jffs2_full_dirent *this = *prev; | 606 | struct jffs2_full_dirent *this = *prev; |
@@ -639,7 +621,7 @@ int jffs2_do_unlink(struct jffs2_sb_info *c, struct jffs2_inode_info *dir_f, | |||
639 | /* dead_f is NULL if this was a rename not a real unlink */ | 621 | /* dead_f is NULL if this was a rename not a real unlink */ |
640 | /* Also catch the !f->inocache case, where there was a dirent | 622 | /* Also catch the !f->inocache case, where there was a dirent |
641 | pointing to an inode which didn't exist. */ | 623 | pointing to an inode which didn't exist. */ |
642 | if (dead_f && dead_f->inocache) { | 624 | if (dead_f && dead_f->inocache) { |
643 | 625 | ||
644 | down(&dead_f->sem); | 626 | down(&dead_f->sem); |
645 | 627 | ||
@@ -647,9 +629,9 @@ int jffs2_do_unlink(struct jffs2_sb_info *c, struct jffs2_inode_info *dir_f, | |||
647 | while (dead_f->dents) { | 629 | while (dead_f->dents) { |
648 | /* There can be only deleted ones */ | 630 | /* There can be only deleted ones */ |
649 | fd = dead_f->dents; | 631 | fd = dead_f->dents; |
650 | 632 | ||
651 | dead_f->dents = fd->next; | 633 | dead_f->dents = fd->next; |
652 | 634 | ||
653 | if (fd->ino) { | 635 | if (fd->ino) { |
654 | printk(KERN_WARNING "Deleting inode #%u with active dentry \"%s\"->ino #%u\n", | 636 | printk(KERN_WARNING "Deleting inode #%u with active dentry \"%s\"->ino #%u\n", |
655 | dead_f->inocache->ino, fd->name, fd->ino); | 637 | dead_f->inocache->ino, fd->name, fd->ino); |
@@ -673,7 +655,7 @@ int jffs2_do_unlink(struct jffs2_sb_info *c, struct jffs2_inode_info *dir_f, | |||
673 | } | 655 | } |
674 | 656 | ||
675 | 657 | ||
676 | int jffs2_do_link (struct jffs2_sb_info *c, struct jffs2_inode_info *dir_f, uint32_t ino, uint8_t type, const char *name, int namelen) | 658 | int jffs2_do_link (struct jffs2_sb_info *c, struct jffs2_inode_info *dir_f, uint32_t ino, uint8_t type, const char *name, int namelen, uint32_t time) |
677 | { | 659 | { |
678 | struct jffs2_raw_dirent *rd; | 660 | struct jffs2_raw_dirent *rd; |
679 | struct jffs2_full_dirent *fd; | 661 | struct jffs2_full_dirent *fd; |
@@ -684,12 +666,13 @@ int jffs2_do_link (struct jffs2_sb_info *c, struct jffs2_inode_info *dir_f, uint | |||
684 | if (!rd) | 666 | if (!rd) |
685 | return -ENOMEM; | 667 | return -ENOMEM; |
686 | 668 | ||
687 | ret = jffs2_reserve_space(c, sizeof(*rd)+namelen, &phys_ofs, &alloclen, ALLOC_NORMAL); | 669 | ret = jffs2_reserve_space(c, sizeof(*rd)+namelen, &phys_ofs, &alloclen, |
670 | ALLOC_NORMAL, JFFS2_SUMMARY_DIRENT_SIZE(namelen)); | ||
688 | if (ret) { | 671 | if (ret) { |
689 | jffs2_free_raw_dirent(rd); | 672 | jffs2_free_raw_dirent(rd); |
690 | return ret; | 673 | return ret; |
691 | } | 674 | } |
692 | 675 | ||
693 | down(&dir_f->sem); | 676 | down(&dir_f->sem); |
694 | 677 | ||
695 | /* Build a deletion node */ | 678 | /* Build a deletion node */ |
@@ -701,7 +684,7 @@ int jffs2_do_link (struct jffs2_sb_info *c, struct jffs2_inode_info *dir_f, uint | |||
701 | rd->pino = cpu_to_je32(dir_f->inocache->ino); | 684 | rd->pino = cpu_to_je32(dir_f->inocache->ino); |
702 | rd->version = cpu_to_je32(++dir_f->highest_version); | 685 | rd->version = cpu_to_je32(++dir_f->highest_version); |
703 | rd->ino = cpu_to_je32(ino); | 686 | rd->ino = cpu_to_je32(ino); |
704 | rd->mctime = cpu_to_je32(get_seconds()); | 687 | rd->mctime = cpu_to_je32(time); |
705 | rd->nsize = namelen; | 688 | rd->nsize = namelen; |
706 | 689 | ||
707 | rd->type = type; | 690 | rd->type = type; |
@@ -710,7 +693,7 @@ int jffs2_do_link (struct jffs2_sb_info *c, struct jffs2_inode_info *dir_f, uint | |||
710 | rd->name_crc = cpu_to_je32(crc32(0, name, namelen)); | 693 | rd->name_crc = cpu_to_je32(crc32(0, name, namelen)); |
711 | 694 | ||
712 | fd = jffs2_write_dirent(c, dir_f, rd, name, namelen, phys_ofs, ALLOC_NORMAL); | 695 | fd = jffs2_write_dirent(c, dir_f, rd, name, namelen, phys_ofs, ALLOC_NORMAL); |
713 | 696 | ||
714 | jffs2_free_raw_dirent(rd); | 697 | jffs2_free_raw_dirent(rd); |
715 | 698 | ||
716 | if (IS_ERR(fd)) { | 699 | if (IS_ERR(fd)) { |
diff --git a/fs/jffs2/writev.c b/fs/jffs2/writev.c index f079f8388566..c638ae1008de 100644 --- a/fs/jffs2/writev.c +++ b/fs/jffs2/writev.c | |||
@@ -7,7 +7,7 @@ | |||
7 | * | 7 | * |
8 | * For licensing information, see the file 'LICENCE' in this directory. | 8 | * For licensing information, see the file 'LICENCE' in this directory. |
9 | * | 9 | * |
10 | * $Id: writev.c,v 1.6 2004/11/16 20:36:12 dwmw2 Exp $ | 10 | * $Id: writev.c,v 1.8 2005/09/09 15:11:58 havasi Exp $ |
11 | * | 11 | * |
12 | */ | 12 | */ |
13 | 13 | ||
@@ -42,9 +42,40 @@ static inline int mtd_fake_writev(struct mtd_info *mtd, const struct kvec *vecs, | |||
42 | int jffs2_flash_direct_writev(struct jffs2_sb_info *c, const struct kvec *vecs, | 42 | int jffs2_flash_direct_writev(struct jffs2_sb_info *c, const struct kvec *vecs, |
43 | unsigned long count, loff_t to, size_t *retlen) | 43 | unsigned long count, loff_t to, size_t *retlen) |
44 | { | 44 | { |
45 | if (!jffs2_is_writebuffered(c)) { | ||
46 | if (jffs2_sum_active()) { | ||
47 | int res; | ||
48 | res = jffs2_sum_add_kvec(c, vecs, count, (uint32_t) to); | ||
49 | if (res) { | ||
50 | return res; | ||
51 | } | ||
52 | } | ||
53 | } | ||
54 | |||
45 | if (c->mtd->writev) | 55 | if (c->mtd->writev) |
46 | return c->mtd->writev(c->mtd, vecs, count, to, retlen); | 56 | return c->mtd->writev(c->mtd, vecs, count, to, retlen); |
47 | else | 57 | else { |
48 | return mtd_fake_writev(c->mtd, vecs, count, to, retlen); | 58 | return mtd_fake_writev(c->mtd, vecs, count, to, retlen); |
59 | } | ||
49 | } | 60 | } |
50 | 61 | ||
62 | int jffs2_flash_direct_write(struct jffs2_sb_info *c, loff_t ofs, size_t len, | ||
63 | size_t *retlen, const u_char *buf) | ||
64 | { | ||
65 | int ret; | ||
66 | ret = c->mtd->write(c->mtd, ofs, len, retlen, buf); | ||
67 | |||
68 | if (jffs2_sum_active()) { | ||
69 | struct kvec vecs[1]; | ||
70 | int res; | ||
71 | |||
72 | vecs[0].iov_base = (unsigned char *) buf; | ||
73 | vecs[0].iov_len = len; | ||
74 | |||
75 | res = jffs2_sum_add_kvec(c, vecs, 1, (uint32_t) ofs); | ||
76 | if (res) { | ||
77 | return res; | ||
78 | } | ||
79 | } | ||
80 | return ret; | ||
81 | } | ||
diff --git a/fs/jfs/namei.c b/fs/jfs/namei.c index 1abe7343f920..4abbe8604302 100644 --- a/fs/jfs/namei.c +++ b/fs/jfs/namei.c | |||
@@ -827,6 +827,7 @@ static int jfs_link(struct dentry *old_dentry, | |||
827 | /* update object inode */ | 827 | /* update object inode */ |
828 | ip->i_nlink++; /* for new link */ | 828 | ip->i_nlink++; /* for new link */ |
829 | ip->i_ctime = CURRENT_TIME; | 829 | ip->i_ctime = CURRENT_TIME; |
830 | dir->i_ctime = dir->i_mtime = CURRENT_TIME; | ||
830 | mark_inode_dirty(dir); | 831 | mark_inode_dirty(dir); |
831 | atomic_inc(&ip->i_count); | 832 | atomic_inc(&ip->i_count); |
832 | 833 | ||
@@ -1024,6 +1025,8 @@ static int jfs_symlink(struct inode *dip, struct dentry *dentry, | |||
1024 | insert_inode_hash(ip); | 1025 | insert_inode_hash(ip); |
1025 | mark_inode_dirty(ip); | 1026 | mark_inode_dirty(ip); |
1026 | 1027 | ||
1028 | dip->i_ctime = dip->i_mtime = CURRENT_TIME; | ||
1029 | mark_inode_dirty(dip); | ||
1027 | /* | 1030 | /* |
1028 | * commit update of parent directory and link object | 1031 | * commit update of parent directory and link object |
1029 | */ | 1032 | */ |
diff --git a/fs/lockd/clntproc.c b/fs/lockd/clntproc.c index 87332f30141b..c5a33648e9fd 100644 --- a/fs/lockd/clntproc.c +++ b/fs/lockd/clntproc.c | |||
@@ -112,8 +112,7 @@ static struct nlm_lockowner *nlm_find_lockowner(struct nlm_host *host, fl_owner_ | |||
112 | } | 112 | } |
113 | } | 113 | } |
114 | spin_unlock(&host->h_lock); | 114 | spin_unlock(&host->h_lock); |
115 | if (new != NULL) | 115 | kfree(new); |
116 | kfree(new); | ||
117 | return res; | 116 | return res; |
118 | } | 117 | } |
119 | 118 | ||
diff --git a/fs/lockd/svcsubs.c b/fs/lockd/svcsubs.c index de7536358c7c..62f4a385177f 100644 --- a/fs/lockd/svcsubs.c +++ b/fs/lockd/svcsubs.c | |||
@@ -30,6 +30,36 @@ | |||
30 | static struct nlm_file * nlm_files[FILE_NRHASH]; | 30 | static struct nlm_file * nlm_files[FILE_NRHASH]; |
31 | static DECLARE_MUTEX(nlm_file_sema); | 31 | static DECLARE_MUTEX(nlm_file_sema); |
32 | 32 | ||
33 | #ifdef NFSD_DEBUG | ||
34 | static inline void nlm_debug_print_fh(char *msg, struct nfs_fh *f) | ||
35 | { | ||
36 | u32 *fhp = (u32*)f->data; | ||
37 | |||
38 | /* print the first 32 bytes of the fh */ | ||
39 | dprintk("lockd: %s (%08x %08x %08x %08x %08x %08x %08x %08x)\n", | ||
40 | msg, fhp[0], fhp[1], fhp[2], fhp[3], | ||
41 | fhp[4], fhp[5], fhp[6], fhp[7]); | ||
42 | } | ||
43 | |||
44 | static inline void nlm_debug_print_file(char *msg, struct nlm_file *file) | ||
45 | { | ||
46 | struct inode *inode = file->f_file->f_dentry->d_inode; | ||
47 | |||
48 | dprintk("lockd: %s %s/%ld\n", | ||
49 | msg, inode->i_sb->s_id, inode->i_ino); | ||
50 | } | ||
51 | #else | ||
52 | static inline void nlm_debug_print_fh(char *msg, struct nfs_fh *f) | ||
53 | { | ||
54 | return; | ||
55 | } | ||
56 | |||
57 | static inline void nlm_debug_print_file(char *msg, struct nlm_file *file) | ||
58 | { | ||
59 | return; | ||
60 | } | ||
61 | #endif | ||
62 | |||
33 | static inline unsigned int file_hash(struct nfs_fh *f) | 63 | static inline unsigned int file_hash(struct nfs_fh *f) |
34 | { | 64 | { |
35 | unsigned int tmp=0; | 65 | unsigned int tmp=0; |
@@ -55,11 +85,8 @@ nlm_lookup_file(struct svc_rqst *rqstp, struct nlm_file **result, | |||
55 | struct nlm_file *file; | 85 | struct nlm_file *file; |
56 | unsigned int hash; | 86 | unsigned int hash; |
57 | u32 nfserr; | 87 | u32 nfserr; |
58 | u32 *fhp = (u32*)f->data; | ||
59 | |||
60 | dprintk("lockd: nlm_file_lookup(%08x %08x %08x %08x %08x %08x)\n", | ||
61 | fhp[0], fhp[1], fhp[2], fhp[3], fhp[4], fhp[5]); | ||
62 | 88 | ||
89 | nlm_debug_print_fh("nlm_file_lookup", f); | ||
63 | 90 | ||
64 | hash = file_hash(f); | 91 | hash = file_hash(f); |
65 | 92 | ||
@@ -70,8 +97,7 @@ nlm_lookup_file(struct svc_rqst *rqstp, struct nlm_file **result, | |||
70 | if (!nfs_compare_fh(&file->f_handle, f)) | 97 | if (!nfs_compare_fh(&file->f_handle, f)) |
71 | goto found; | 98 | goto found; |
72 | 99 | ||
73 | dprintk("lockd: creating file for (%08x %08x %08x %08x %08x %08x)\n", | 100 | nlm_debug_print_fh("creating file for", f); |
74 | fhp[0], fhp[1], fhp[2], fhp[3], fhp[4], fhp[5]); | ||
75 | 101 | ||
76 | nfserr = nlm_lck_denied_nolocks; | 102 | nfserr = nlm_lck_denied_nolocks; |
77 | file = (struct nlm_file *) kmalloc(sizeof(*file), GFP_KERNEL); | 103 | file = (struct nlm_file *) kmalloc(sizeof(*file), GFP_KERNEL); |
@@ -124,11 +150,10 @@ out_free: | |||
124 | static inline void | 150 | static inline void |
125 | nlm_delete_file(struct nlm_file *file) | 151 | nlm_delete_file(struct nlm_file *file) |
126 | { | 152 | { |
127 | struct inode *inode = file->f_file->f_dentry->d_inode; | ||
128 | struct nlm_file **fp, *f; | 153 | struct nlm_file **fp, *f; |
129 | 154 | ||
130 | dprintk("lockd: closing file %s/%ld\n", | 155 | nlm_debug_print_file("closing file", file); |
131 | inode->i_sb->s_id, inode->i_ino); | 156 | |
132 | fp = nlm_files + file->f_hash; | 157 | fp = nlm_files + file->f_hash; |
133 | while ((f = *fp) != NULL) { | 158 | while ((f = *fp) != NULL) { |
134 | if (f == file) { | 159 | if (f == file) { |
diff --git a/fs/mbcache.c b/fs/mbcache.c index 298997f17475..0f1e4530670f 100644 --- a/fs/mbcache.c +++ b/fs/mbcache.c | |||
@@ -301,8 +301,7 @@ fail: | |||
301 | if (cache) { | 301 | if (cache) { |
302 | while (--m >= 0) | 302 | while (--m >= 0) |
303 | kfree(cache->c_indexes_hash[m]); | 303 | kfree(cache->c_indexes_hash[m]); |
304 | if (cache->c_block_hash) | 304 | kfree(cache->c_block_hash); |
305 | kfree(cache->c_block_hash); | ||
306 | kfree(cache); | 305 | kfree(cache); |
307 | } | 306 | } |
308 | return NULL; | 307 | return NULL; |
diff --git a/fs/namei.c b/fs/namei.c index c5769c4fcab1..6dbbd42d8b95 100644 --- a/fs/namei.c +++ b/fs/namei.c | |||
@@ -256,6 +256,38 @@ int permission(struct inode *inode, int mask, struct nameidata *nd) | |||
256 | return security_inode_permission(inode, mask, nd); | 256 | return security_inode_permission(inode, mask, nd); |
257 | } | 257 | } |
258 | 258 | ||
259 | /** | ||
260 | * vfs_permission - check for access rights to a given path | ||
261 | * @nd: lookup result that describes the path | ||
262 | * @mask: right to check for (%MAY_READ, %MAY_WRITE, %MAY_EXEC) | ||
263 | * | ||
264 | * Used to check for read/write/execute permissions on a path. | ||
265 | * We use "fsuid" for this, letting us set arbitrary permissions | ||
266 | * for filesystem access without changing the "normal" uids which | ||
267 | * are used for other things. | ||
268 | */ | ||
269 | int vfs_permission(struct nameidata *nd, int mask) | ||
270 | { | ||
271 | return permission(nd->dentry->d_inode, mask, nd); | ||
272 | } | ||
273 | |||
274 | /** | ||
275 | * file_permission - check for additional access rights to a given file | ||
276 | * @file: file to check access rights for | ||
277 | * @mask: right to check for (%MAY_READ, %MAY_WRITE, %MAY_EXEC) | ||
278 | * | ||
279 | * Used to check for read/write/execute permissions on an already opened | ||
280 | * file. | ||
281 | * | ||
282 | * Note: | ||
283 | * Do not use this function in new code. All access checks should | ||
284 | * be done using vfs_permission(). | ||
285 | */ | ||
286 | int file_permission(struct file *file, int mask) | ||
287 | { | ||
288 | return permission(file->f_dentry->d_inode, mask, NULL); | ||
289 | } | ||
290 | |||
259 | /* | 291 | /* |
260 | * get_write_access() gets write permission for a file. | 292 | * get_write_access() gets write permission for a file. |
261 | * put_write_access() releases this write permission. | 293 | * put_write_access() releases this write permission. |
@@ -765,9 +797,8 @@ static fastcall int __link_path_walk(const char * name, struct nameidata *nd) | |||
765 | 797 | ||
766 | nd->flags |= LOOKUP_CONTINUE; | 798 | nd->flags |= LOOKUP_CONTINUE; |
767 | err = exec_permission_lite(inode, nd); | 799 | err = exec_permission_lite(inode, nd); |
768 | if (err == -EAGAIN) { | 800 | if (err == -EAGAIN) |
769 | err = permission(inode, MAY_EXEC, nd); | 801 | err = vfs_permission(nd, MAY_EXEC); |
770 | } | ||
771 | if (err) | 802 | if (err) |
772 | break; | 803 | break; |
773 | 804 | ||
@@ -1109,8 +1140,9 @@ int path_lookup_open(const char *name, unsigned int lookup_flags, | |||
1109 | * @open_flags: open intent flags | 1140 | * @open_flags: open intent flags |
1110 | * @create_mode: create intent flags | 1141 | * @create_mode: create intent flags |
1111 | */ | 1142 | */ |
1112 | int path_lookup_create(const char *name, unsigned int lookup_flags, | 1143 | static int path_lookup_create(const char *name, unsigned int lookup_flags, |
1113 | struct nameidata *nd, int open_flags, int create_mode) | 1144 | struct nameidata *nd, int open_flags, |
1145 | int create_mode) | ||
1114 | { | 1146 | { |
1115 | return __path_lookup_intent_open(name, lookup_flags|LOOKUP_CREATE, nd, | 1147 | return __path_lookup_intent_open(name, lookup_flags|LOOKUP_CREATE, nd, |
1116 | open_flags, create_mode); | 1148 | open_flags, create_mode); |
@@ -1173,9 +1205,9 @@ out: | |||
1173 | return dentry; | 1205 | return dentry; |
1174 | } | 1206 | } |
1175 | 1207 | ||
1176 | struct dentry * lookup_hash(struct qstr *name, struct dentry * base) | 1208 | struct dentry * lookup_hash(struct nameidata *nd) |
1177 | { | 1209 | { |
1178 | return __lookup_hash(name, base, NULL); | 1210 | return __lookup_hash(&nd->last, nd->dentry, nd); |
1179 | } | 1211 | } |
1180 | 1212 | ||
1181 | /* SMP-safe */ | 1213 | /* SMP-safe */ |
@@ -1199,7 +1231,7 @@ struct dentry * lookup_one_len(const char * name, struct dentry * base, int len) | |||
1199 | } | 1231 | } |
1200 | this.hash = end_name_hash(hash); | 1232 | this.hash = end_name_hash(hash); |
1201 | 1233 | ||
1202 | return lookup_hash(&this, base); | 1234 | return __lookup_hash(&this, base, NULL); |
1203 | access: | 1235 | access: |
1204 | return ERR_PTR(-EACCES); | 1236 | return ERR_PTR(-EACCES); |
1205 | } | 1237 | } |
@@ -1407,7 +1439,7 @@ int may_open(struct nameidata *nd, int acc_mode, int flag) | |||
1407 | if (S_ISDIR(inode->i_mode) && (flag & FMODE_WRITE)) | 1439 | if (S_ISDIR(inode->i_mode) && (flag & FMODE_WRITE)) |
1408 | return -EISDIR; | 1440 | return -EISDIR; |
1409 | 1441 | ||
1410 | error = permission(inode, acc_mode, nd); | 1442 | error = vfs_permission(nd, acc_mode); |
1411 | if (error) | 1443 | if (error) |
1412 | return error; | 1444 | return error; |
1413 | 1445 | ||
@@ -1459,7 +1491,7 @@ int may_open(struct nameidata *nd, int acc_mode, int flag) | |||
1459 | if (!error) { | 1491 | if (!error) { |
1460 | DQUOT_INIT(inode); | 1492 | DQUOT_INIT(inode); |
1461 | 1493 | ||
1462 | error = do_truncate(dentry, 0); | 1494 | error = do_truncate(dentry, 0, NULL); |
1463 | } | 1495 | } |
1464 | put_write_access(inode); | 1496 | put_write_access(inode); |
1465 | if (error) | 1497 | if (error) |
@@ -1532,7 +1564,7 @@ int open_namei(const char * pathname, int flag, int mode, struct nameidata *nd) | |||
1532 | dir = nd->dentry; | 1564 | dir = nd->dentry; |
1533 | nd->flags &= ~LOOKUP_PARENT; | 1565 | nd->flags &= ~LOOKUP_PARENT; |
1534 | down(&dir->d_inode->i_sem); | 1566 | down(&dir->d_inode->i_sem); |
1535 | path.dentry = __lookup_hash(&nd->last, nd->dentry, nd); | 1567 | path.dentry = lookup_hash(nd); |
1536 | path.mnt = nd->mnt; | 1568 | path.mnt = nd->mnt; |
1537 | 1569 | ||
1538 | do_last: | 1570 | do_last: |
@@ -1634,7 +1666,7 @@ do_link: | |||
1634 | } | 1666 | } |
1635 | dir = nd->dentry; | 1667 | dir = nd->dentry; |
1636 | down(&dir->d_inode->i_sem); | 1668 | down(&dir->d_inode->i_sem); |
1637 | path.dentry = __lookup_hash(&nd->last, nd->dentry, nd); | 1669 | path.dentry = lookup_hash(nd); |
1638 | path.mnt = nd->mnt; | 1670 | path.mnt = nd->mnt; |
1639 | __putname(nd->last.name); | 1671 | __putname(nd->last.name); |
1640 | goto do_last; | 1672 | goto do_last; |
@@ -1666,7 +1698,7 @@ struct dentry *lookup_create(struct nameidata *nd, int is_dir) | |||
1666 | /* | 1698 | /* |
1667 | * Do the final lookup. | 1699 | * Do the final lookup. |
1668 | */ | 1700 | */ |
1669 | dentry = lookup_hash(&nd->last, nd->dentry); | 1701 | dentry = lookup_hash(nd); |
1670 | if (IS_ERR(dentry)) | 1702 | if (IS_ERR(dentry)) |
1671 | goto fail; | 1703 | goto fail; |
1672 | 1704 | ||
@@ -1901,7 +1933,7 @@ asmlinkage long sys_rmdir(const char __user * pathname) | |||
1901 | goto exit1; | 1933 | goto exit1; |
1902 | } | 1934 | } |
1903 | down(&nd.dentry->d_inode->i_sem); | 1935 | down(&nd.dentry->d_inode->i_sem); |
1904 | dentry = lookup_hash(&nd.last, nd.dentry); | 1936 | dentry = lookup_hash(&nd); |
1905 | error = PTR_ERR(dentry); | 1937 | error = PTR_ERR(dentry); |
1906 | if (!IS_ERR(dentry)) { | 1938 | if (!IS_ERR(dentry)) { |
1907 | error = vfs_rmdir(nd.dentry->d_inode, dentry); | 1939 | error = vfs_rmdir(nd.dentry->d_inode, dentry); |
@@ -1970,7 +2002,7 @@ asmlinkage long sys_unlink(const char __user * pathname) | |||
1970 | if (nd.last_type != LAST_NORM) | 2002 | if (nd.last_type != LAST_NORM) |
1971 | goto exit1; | 2003 | goto exit1; |
1972 | down(&nd.dentry->d_inode->i_sem); | 2004 | down(&nd.dentry->d_inode->i_sem); |
1973 | dentry = lookup_hash(&nd.last, nd.dentry); | 2005 | dentry = lookup_hash(&nd); |
1974 | error = PTR_ERR(dentry); | 2006 | error = PTR_ERR(dentry); |
1975 | if (!IS_ERR(dentry)) { | 2007 | if (!IS_ERR(dentry)) { |
1976 | /* Why not before? Because we want correct error value */ | 2008 | /* Why not before? Because we want correct error value */ |
@@ -2313,7 +2345,7 @@ static inline int do_rename(const char * oldname, const char * newname) | |||
2313 | 2345 | ||
2314 | trap = lock_rename(new_dir, old_dir); | 2346 | trap = lock_rename(new_dir, old_dir); |
2315 | 2347 | ||
2316 | old_dentry = lookup_hash(&oldnd.last, old_dir); | 2348 | old_dentry = lookup_hash(&oldnd); |
2317 | error = PTR_ERR(old_dentry); | 2349 | error = PTR_ERR(old_dentry); |
2318 | if (IS_ERR(old_dentry)) | 2350 | if (IS_ERR(old_dentry)) |
2319 | goto exit3; | 2351 | goto exit3; |
@@ -2333,7 +2365,7 @@ static inline int do_rename(const char * oldname, const char * newname) | |||
2333 | error = -EINVAL; | 2365 | error = -EINVAL; |
2334 | if (old_dentry == trap) | 2366 | if (old_dentry == trap) |
2335 | goto exit4; | 2367 | goto exit4; |
2336 | new_dentry = lookup_hash(&newnd.last, new_dir); | 2368 | new_dentry = lookup_hash(&newnd); |
2337 | error = PTR_ERR(new_dentry); | 2369 | error = PTR_ERR(new_dentry); |
2338 | if (IS_ERR(new_dentry)) | 2370 | if (IS_ERR(new_dentry)) |
2339 | goto exit4; | 2371 | goto exit4; |
@@ -2536,6 +2568,8 @@ EXPORT_SYMBOL(path_lookup); | |||
2536 | EXPORT_SYMBOL(path_release); | 2568 | EXPORT_SYMBOL(path_release); |
2537 | EXPORT_SYMBOL(path_walk); | 2569 | EXPORT_SYMBOL(path_walk); |
2538 | EXPORT_SYMBOL(permission); | 2570 | EXPORT_SYMBOL(permission); |
2571 | EXPORT_SYMBOL(vfs_permission); | ||
2572 | EXPORT_SYMBOL(file_permission); | ||
2539 | EXPORT_SYMBOL(unlock_rename); | 2573 | EXPORT_SYMBOL(unlock_rename); |
2540 | EXPORT_SYMBOL(vfs_create); | 2574 | EXPORT_SYMBOL(vfs_create); |
2541 | EXPORT_SYMBOL(vfs_follow_link); | 2575 | EXPORT_SYMBOL(vfs_follow_link); |
diff --git a/fs/namespace.c b/fs/namespace.c index 2fa9fdf7d6f5..2019899f2ab8 100644 --- a/fs/namespace.c +++ b/fs/namespace.c | |||
@@ -24,6 +24,7 @@ | |||
24 | #include <linux/mount.h> | 24 | #include <linux/mount.h> |
25 | #include <asm/uaccess.h> | 25 | #include <asm/uaccess.h> |
26 | #include <asm/unistd.h> | 26 | #include <asm/unistd.h> |
27 | #include "pnode.h" | ||
27 | 28 | ||
28 | extern int __init init_rootfs(void); | 29 | extern int __init init_rootfs(void); |
29 | 30 | ||
@@ -37,33 +38,39 @@ static inline int sysfs_init(void) | |||
37 | #endif | 38 | #endif |
38 | 39 | ||
39 | /* spinlock for vfsmount related operations, inplace of dcache_lock */ | 40 | /* spinlock for vfsmount related operations, inplace of dcache_lock */ |
40 | __cacheline_aligned_in_smp DEFINE_SPINLOCK(vfsmount_lock); | 41 | __cacheline_aligned_in_smp DEFINE_SPINLOCK(vfsmount_lock); |
42 | |||
43 | static int event; | ||
41 | 44 | ||
42 | static struct list_head *mount_hashtable; | 45 | static struct list_head *mount_hashtable; |
43 | static int hash_mask __read_mostly, hash_bits __read_mostly; | 46 | static int hash_mask __read_mostly, hash_bits __read_mostly; |
44 | static kmem_cache_t *mnt_cache; | 47 | static kmem_cache_t *mnt_cache; |
48 | static struct rw_semaphore namespace_sem; | ||
45 | 49 | ||
46 | static inline unsigned long hash(struct vfsmount *mnt, struct dentry *dentry) | 50 | static inline unsigned long hash(struct vfsmount *mnt, struct dentry *dentry) |
47 | { | 51 | { |
48 | unsigned long tmp = ((unsigned long) mnt / L1_CACHE_BYTES); | 52 | unsigned long tmp = ((unsigned long)mnt / L1_CACHE_BYTES); |
49 | tmp += ((unsigned long) dentry / L1_CACHE_BYTES); | 53 | tmp += ((unsigned long)dentry / L1_CACHE_BYTES); |
50 | tmp = tmp + (tmp >> hash_bits); | 54 | tmp = tmp + (tmp >> hash_bits); |
51 | return tmp & hash_mask; | 55 | return tmp & hash_mask; |
52 | } | 56 | } |
53 | 57 | ||
54 | struct vfsmount *alloc_vfsmnt(const char *name) | 58 | struct vfsmount *alloc_vfsmnt(const char *name) |
55 | { | 59 | { |
56 | struct vfsmount *mnt = kmem_cache_alloc(mnt_cache, GFP_KERNEL); | 60 | struct vfsmount *mnt = kmem_cache_alloc(mnt_cache, GFP_KERNEL); |
57 | if (mnt) { | 61 | if (mnt) { |
58 | memset(mnt, 0, sizeof(struct vfsmount)); | 62 | memset(mnt, 0, sizeof(struct vfsmount)); |
59 | atomic_set(&mnt->mnt_count,1); | 63 | atomic_set(&mnt->mnt_count, 1); |
60 | INIT_LIST_HEAD(&mnt->mnt_hash); | 64 | INIT_LIST_HEAD(&mnt->mnt_hash); |
61 | INIT_LIST_HEAD(&mnt->mnt_child); | 65 | INIT_LIST_HEAD(&mnt->mnt_child); |
62 | INIT_LIST_HEAD(&mnt->mnt_mounts); | 66 | INIT_LIST_HEAD(&mnt->mnt_mounts); |
63 | INIT_LIST_HEAD(&mnt->mnt_list); | 67 | INIT_LIST_HEAD(&mnt->mnt_list); |
64 | INIT_LIST_HEAD(&mnt->mnt_expire); | 68 | INIT_LIST_HEAD(&mnt->mnt_expire); |
69 | INIT_LIST_HEAD(&mnt->mnt_share); | ||
70 | INIT_LIST_HEAD(&mnt->mnt_slave_list); | ||
71 | INIT_LIST_HEAD(&mnt->mnt_slave); | ||
65 | if (name) { | 72 | if (name) { |
66 | int size = strlen(name)+1; | 73 | int size = strlen(name) + 1; |
67 | char *newname = kmalloc(size, GFP_KERNEL); | 74 | char *newname = kmalloc(size, GFP_KERNEL); |
68 | if (newname) { | 75 | if (newname) { |
69 | memcpy(newname, name, size); | 76 | memcpy(newname, name, size); |
@@ -81,36 +88,65 @@ void free_vfsmnt(struct vfsmount *mnt) | |||
81 | } | 88 | } |
82 | 89 | ||
83 | /* | 90 | /* |
84 | * Now, lookup_mnt increments the ref count before returning | 91 | * find the first or last mount at @dentry on vfsmount @mnt depending on |
85 | * the vfsmount struct. | 92 | * @dir. If @dir is set return the first mount else return the last mount. |
86 | */ | 93 | */ |
87 | struct vfsmount *lookup_mnt(struct vfsmount *mnt, struct dentry *dentry) | 94 | struct vfsmount *__lookup_mnt(struct vfsmount *mnt, struct dentry *dentry, |
95 | int dir) | ||
88 | { | 96 | { |
89 | struct list_head * head = mount_hashtable + hash(mnt, dentry); | 97 | struct list_head *head = mount_hashtable + hash(mnt, dentry); |
90 | struct list_head * tmp = head; | 98 | struct list_head *tmp = head; |
91 | struct vfsmount *p, *found = NULL; | 99 | struct vfsmount *p, *found = NULL; |
92 | 100 | ||
93 | spin_lock(&vfsmount_lock); | ||
94 | for (;;) { | 101 | for (;;) { |
95 | tmp = tmp->next; | 102 | tmp = dir ? tmp->next : tmp->prev; |
96 | p = NULL; | 103 | p = NULL; |
97 | if (tmp == head) | 104 | if (tmp == head) |
98 | break; | 105 | break; |
99 | p = list_entry(tmp, struct vfsmount, mnt_hash); | 106 | p = list_entry(tmp, struct vfsmount, mnt_hash); |
100 | if (p->mnt_parent == mnt && p->mnt_mountpoint == dentry) { | 107 | if (p->mnt_parent == mnt && p->mnt_mountpoint == dentry) { |
101 | found = mntget(p); | 108 | found = p; |
102 | break; | 109 | break; |
103 | } | 110 | } |
104 | } | 111 | } |
105 | spin_unlock(&vfsmount_lock); | ||
106 | return found; | 112 | return found; |
107 | } | 113 | } |
108 | 114 | ||
115 | /* | ||
116 | * lookup_mnt increments the ref count before returning | ||
117 | * the vfsmount struct. | ||
118 | */ | ||
119 | struct vfsmount *lookup_mnt(struct vfsmount *mnt, struct dentry *dentry) | ||
120 | { | ||
121 | struct vfsmount *child_mnt; | ||
122 | spin_lock(&vfsmount_lock); | ||
123 | if ((child_mnt = __lookup_mnt(mnt, dentry, 1))) | ||
124 | mntget(child_mnt); | ||
125 | spin_unlock(&vfsmount_lock); | ||
126 | return child_mnt; | ||
127 | } | ||
128 | |||
109 | static inline int check_mnt(struct vfsmount *mnt) | 129 | static inline int check_mnt(struct vfsmount *mnt) |
110 | { | 130 | { |
111 | return mnt->mnt_namespace == current->namespace; | 131 | return mnt->mnt_namespace == current->namespace; |
112 | } | 132 | } |
113 | 133 | ||
134 | static void touch_namespace(struct namespace *ns) | ||
135 | { | ||
136 | if (ns) { | ||
137 | ns->event = ++event; | ||
138 | wake_up_interruptible(&ns->poll); | ||
139 | } | ||
140 | } | ||
141 | |||
142 | static void __touch_namespace(struct namespace *ns) | ||
143 | { | ||
144 | if (ns && ns->event != event) { | ||
145 | ns->event = event; | ||
146 | wake_up_interruptible(&ns->poll); | ||
147 | } | ||
148 | } | ||
149 | |||
114 | static void detach_mnt(struct vfsmount *mnt, struct nameidata *old_nd) | 150 | static void detach_mnt(struct vfsmount *mnt, struct nameidata *old_nd) |
115 | { | 151 | { |
116 | old_nd->dentry = mnt->mnt_mountpoint; | 152 | old_nd->dentry = mnt->mnt_mountpoint; |
@@ -122,13 +158,43 @@ static void detach_mnt(struct vfsmount *mnt, struct nameidata *old_nd) | |||
122 | old_nd->dentry->d_mounted--; | 158 | old_nd->dentry->d_mounted--; |
123 | } | 159 | } |
124 | 160 | ||
161 | void mnt_set_mountpoint(struct vfsmount *mnt, struct dentry *dentry, | ||
162 | struct vfsmount *child_mnt) | ||
163 | { | ||
164 | child_mnt->mnt_parent = mntget(mnt); | ||
165 | child_mnt->mnt_mountpoint = dget(dentry); | ||
166 | dentry->d_mounted++; | ||
167 | } | ||
168 | |||
125 | static void attach_mnt(struct vfsmount *mnt, struct nameidata *nd) | 169 | static void attach_mnt(struct vfsmount *mnt, struct nameidata *nd) |
126 | { | 170 | { |
127 | mnt->mnt_parent = mntget(nd->mnt); | 171 | mnt_set_mountpoint(nd->mnt, nd->dentry, mnt); |
128 | mnt->mnt_mountpoint = dget(nd->dentry); | 172 | list_add_tail(&mnt->mnt_hash, mount_hashtable + |
129 | list_add(&mnt->mnt_hash, mount_hashtable+hash(nd->mnt, nd->dentry)); | 173 | hash(nd->mnt, nd->dentry)); |
130 | list_add_tail(&mnt->mnt_child, &nd->mnt->mnt_mounts); | 174 | list_add_tail(&mnt->mnt_child, &nd->mnt->mnt_mounts); |
131 | nd->dentry->d_mounted++; | 175 | } |
176 | |||
177 | /* | ||
178 | * the caller must hold vfsmount_lock | ||
179 | */ | ||
180 | static void commit_tree(struct vfsmount *mnt) | ||
181 | { | ||
182 | struct vfsmount *parent = mnt->mnt_parent; | ||
183 | struct vfsmount *m; | ||
184 | LIST_HEAD(head); | ||
185 | struct namespace *n = parent->mnt_namespace; | ||
186 | |||
187 | BUG_ON(parent == mnt); | ||
188 | |||
189 | list_add_tail(&head, &mnt->mnt_list); | ||
190 | list_for_each_entry(m, &head, mnt_list) | ||
191 | m->mnt_namespace = n; | ||
192 | list_splice(&head, n->list.prev); | ||
193 | |||
194 | list_add_tail(&mnt->mnt_hash, mount_hashtable + | ||
195 | hash(parent, mnt->mnt_mountpoint)); | ||
196 | list_add_tail(&mnt->mnt_child, &parent->mnt_mounts); | ||
197 | touch_namespace(n); | ||
132 | } | 198 | } |
133 | 199 | ||
134 | static struct vfsmount *next_mnt(struct vfsmount *p, struct vfsmount *root) | 200 | static struct vfsmount *next_mnt(struct vfsmount *p, struct vfsmount *root) |
@@ -147,8 +213,18 @@ static struct vfsmount *next_mnt(struct vfsmount *p, struct vfsmount *root) | |||
147 | return list_entry(next, struct vfsmount, mnt_child); | 213 | return list_entry(next, struct vfsmount, mnt_child); |
148 | } | 214 | } |
149 | 215 | ||
150 | static struct vfsmount * | 216 | static struct vfsmount *skip_mnt_tree(struct vfsmount *p) |
151 | clone_mnt(struct vfsmount *old, struct dentry *root) | 217 | { |
218 | struct list_head *prev = p->mnt_mounts.prev; | ||
219 | while (prev != &p->mnt_mounts) { | ||
220 | p = list_entry(prev, struct vfsmount, mnt_child); | ||
221 | prev = p->mnt_mounts.prev; | ||
222 | } | ||
223 | return p; | ||
224 | } | ||
225 | |||
226 | static struct vfsmount *clone_mnt(struct vfsmount *old, struct dentry *root, | ||
227 | int flag) | ||
152 | { | 228 | { |
153 | struct super_block *sb = old->mnt_sb; | 229 | struct super_block *sb = old->mnt_sb; |
154 | struct vfsmount *mnt = alloc_vfsmnt(old->mnt_devname); | 230 | struct vfsmount *mnt = alloc_vfsmnt(old->mnt_devname); |
@@ -160,19 +236,34 @@ clone_mnt(struct vfsmount *old, struct dentry *root) | |||
160 | mnt->mnt_root = dget(root); | 236 | mnt->mnt_root = dget(root); |
161 | mnt->mnt_mountpoint = mnt->mnt_root; | 237 | mnt->mnt_mountpoint = mnt->mnt_root; |
162 | mnt->mnt_parent = mnt; | 238 | mnt->mnt_parent = mnt; |
163 | mnt->mnt_namespace = current->namespace; | 239 | |
240 | if (flag & CL_SLAVE) { | ||
241 | list_add(&mnt->mnt_slave, &old->mnt_slave_list); | ||
242 | mnt->mnt_master = old; | ||
243 | CLEAR_MNT_SHARED(mnt); | ||
244 | } else { | ||
245 | if ((flag & CL_PROPAGATION) || IS_MNT_SHARED(old)) | ||
246 | list_add(&mnt->mnt_share, &old->mnt_share); | ||
247 | if (IS_MNT_SLAVE(old)) | ||
248 | list_add(&mnt->mnt_slave, &old->mnt_slave); | ||
249 | mnt->mnt_master = old->mnt_master; | ||
250 | } | ||
251 | if (flag & CL_MAKE_SHARED) | ||
252 | set_mnt_shared(mnt); | ||
164 | 253 | ||
165 | /* stick the duplicate mount on the same expiry list | 254 | /* stick the duplicate mount on the same expiry list |
166 | * as the original if that was on one */ | 255 | * as the original if that was on one */ |
167 | spin_lock(&vfsmount_lock); | 256 | if (flag & CL_EXPIRE) { |
168 | if (!list_empty(&old->mnt_expire)) | 257 | spin_lock(&vfsmount_lock); |
169 | list_add(&mnt->mnt_expire, &old->mnt_expire); | 258 | if (!list_empty(&old->mnt_expire)) |
170 | spin_unlock(&vfsmount_lock); | 259 | list_add(&mnt->mnt_expire, &old->mnt_expire); |
260 | spin_unlock(&vfsmount_lock); | ||
261 | } | ||
171 | } | 262 | } |
172 | return mnt; | 263 | return mnt; |
173 | } | 264 | } |
174 | 265 | ||
175 | void __mntput(struct vfsmount *mnt) | 266 | static inline void __mntput(struct vfsmount *mnt) |
176 | { | 267 | { |
177 | struct super_block *sb = mnt->mnt_sb; | 268 | struct super_block *sb = mnt->mnt_sb; |
178 | dput(mnt->mnt_root); | 269 | dput(mnt->mnt_root); |
@@ -180,7 +271,46 @@ void __mntput(struct vfsmount *mnt) | |||
180 | deactivate_super(sb); | 271 | deactivate_super(sb); |
181 | } | 272 | } |
182 | 273 | ||
183 | EXPORT_SYMBOL(__mntput); | 274 | void mntput_no_expire(struct vfsmount *mnt) |
275 | { | ||
276 | repeat: | ||
277 | if (atomic_dec_and_lock(&mnt->mnt_count, &vfsmount_lock)) { | ||
278 | if (likely(!mnt->mnt_pinned)) { | ||
279 | spin_unlock(&vfsmount_lock); | ||
280 | __mntput(mnt); | ||
281 | return; | ||
282 | } | ||
283 | atomic_add(mnt->mnt_pinned + 1, &mnt->mnt_count); | ||
284 | mnt->mnt_pinned = 0; | ||
285 | spin_unlock(&vfsmount_lock); | ||
286 | acct_auto_close_mnt(mnt); | ||
287 | security_sb_umount_close(mnt); | ||
288 | goto repeat; | ||
289 | } | ||
290 | } | ||
291 | |||
292 | EXPORT_SYMBOL(mntput_no_expire); | ||
293 | |||
294 | void mnt_pin(struct vfsmount *mnt) | ||
295 | { | ||
296 | spin_lock(&vfsmount_lock); | ||
297 | mnt->mnt_pinned++; | ||
298 | spin_unlock(&vfsmount_lock); | ||
299 | } | ||
300 | |||
301 | EXPORT_SYMBOL(mnt_pin); | ||
302 | |||
303 | void mnt_unpin(struct vfsmount *mnt) | ||
304 | { | ||
305 | spin_lock(&vfsmount_lock); | ||
306 | if (mnt->mnt_pinned) { | ||
307 | atomic_inc(&mnt->mnt_count); | ||
308 | mnt->mnt_pinned--; | ||
309 | } | ||
310 | spin_unlock(&vfsmount_lock); | ||
311 | } | ||
312 | |||
313 | EXPORT_SYMBOL(mnt_unpin); | ||
184 | 314 | ||
185 | /* iterator */ | 315 | /* iterator */ |
186 | static void *m_start(struct seq_file *m, loff_t *pos) | 316 | static void *m_start(struct seq_file *m, loff_t *pos) |
@@ -189,7 +319,7 @@ static void *m_start(struct seq_file *m, loff_t *pos) | |||
189 | struct list_head *p; | 319 | struct list_head *p; |
190 | loff_t l = *pos; | 320 | loff_t l = *pos; |
191 | 321 | ||
192 | down_read(&n->sem); | 322 | down_read(&namespace_sem); |
193 | list_for_each(p, &n->list) | 323 | list_for_each(p, &n->list) |
194 | if (!l--) | 324 | if (!l--) |
195 | return list_entry(p, struct vfsmount, mnt_list); | 325 | return list_entry(p, struct vfsmount, mnt_list); |
@@ -201,13 +331,12 @@ static void *m_next(struct seq_file *m, void *v, loff_t *pos) | |||
201 | struct namespace *n = m->private; | 331 | struct namespace *n = m->private; |
202 | struct list_head *p = ((struct vfsmount *)v)->mnt_list.next; | 332 | struct list_head *p = ((struct vfsmount *)v)->mnt_list.next; |
203 | (*pos)++; | 333 | (*pos)++; |
204 | return p==&n->list ? NULL : list_entry(p, struct vfsmount, mnt_list); | 334 | return p == &n->list ? NULL : list_entry(p, struct vfsmount, mnt_list); |
205 | } | 335 | } |
206 | 336 | ||
207 | static void m_stop(struct seq_file *m, void *v) | 337 | static void m_stop(struct seq_file *m, void *v) |
208 | { | 338 | { |
209 | struct namespace *n = m->private; | 339 | up_read(&namespace_sem); |
210 | up_read(&n->sem); | ||
211 | } | 340 | } |
212 | 341 | ||
213 | static inline void mangle(struct seq_file *m, const char *s) | 342 | static inline void mangle(struct seq_file *m, const char *s) |
@@ -275,35 +404,14 @@ struct seq_operations mounts_op = { | |||
275 | */ | 404 | */ |
276 | int may_umount_tree(struct vfsmount *mnt) | 405 | int may_umount_tree(struct vfsmount *mnt) |
277 | { | 406 | { |
278 | struct list_head *next; | 407 | int actual_refs = 0; |
279 | struct vfsmount *this_parent = mnt; | 408 | int minimum_refs = 0; |
280 | int actual_refs; | 409 | struct vfsmount *p; |
281 | int minimum_refs; | ||
282 | 410 | ||
283 | spin_lock(&vfsmount_lock); | 411 | spin_lock(&vfsmount_lock); |
284 | actual_refs = atomic_read(&mnt->mnt_count); | 412 | for (p = mnt; p; p = next_mnt(p, mnt)) { |
285 | minimum_refs = 2; | ||
286 | repeat: | ||
287 | next = this_parent->mnt_mounts.next; | ||
288 | resume: | ||
289 | while (next != &this_parent->mnt_mounts) { | ||
290 | struct vfsmount *p = list_entry(next, struct vfsmount, mnt_child); | ||
291 | |||
292 | next = next->next; | ||
293 | |||
294 | actual_refs += atomic_read(&p->mnt_count); | 413 | actual_refs += atomic_read(&p->mnt_count); |
295 | minimum_refs += 2; | 414 | minimum_refs += 2; |
296 | |||
297 | if (!list_empty(&p->mnt_mounts)) { | ||
298 | this_parent = p; | ||
299 | goto repeat; | ||
300 | } | ||
301 | } | ||
302 | |||
303 | if (this_parent != mnt) { | ||
304 | next = this_parent->mnt_child.next; | ||
305 | this_parent = this_parent->mnt_parent; | ||
306 | goto resume; | ||
307 | } | 415 | } |
308 | spin_unlock(&vfsmount_lock); | 416 | spin_unlock(&vfsmount_lock); |
309 | 417 | ||
@@ -330,45 +438,67 @@ EXPORT_SYMBOL(may_umount_tree); | |||
330 | */ | 438 | */ |
331 | int may_umount(struct vfsmount *mnt) | 439 | int may_umount(struct vfsmount *mnt) |
332 | { | 440 | { |
333 | if (atomic_read(&mnt->mnt_count) > 2) | 441 | int ret = 0; |
334 | return -EBUSY; | 442 | spin_lock(&vfsmount_lock); |
335 | return 0; | 443 | if (propagate_mount_busy(mnt, 2)) |
444 | ret = -EBUSY; | ||
445 | spin_unlock(&vfsmount_lock); | ||
446 | return ret; | ||
336 | } | 447 | } |
337 | 448 | ||
338 | EXPORT_SYMBOL(may_umount); | 449 | EXPORT_SYMBOL(may_umount); |
339 | 450 | ||
340 | static void umount_tree(struct vfsmount *mnt) | 451 | void release_mounts(struct list_head *head) |
452 | { | ||
453 | struct vfsmount *mnt; | ||
454 | while(!list_empty(head)) { | ||
455 | mnt = list_entry(head->next, struct vfsmount, mnt_hash); | ||
456 | list_del_init(&mnt->mnt_hash); | ||
457 | if (mnt->mnt_parent != mnt) { | ||
458 | struct dentry *dentry; | ||
459 | struct vfsmount *m; | ||
460 | spin_lock(&vfsmount_lock); | ||
461 | dentry = mnt->mnt_mountpoint; | ||
462 | m = mnt->mnt_parent; | ||
463 | mnt->mnt_mountpoint = mnt->mnt_root; | ||
464 | mnt->mnt_parent = mnt; | ||
465 | spin_unlock(&vfsmount_lock); | ||
466 | dput(dentry); | ||
467 | mntput(m); | ||
468 | } | ||
469 | mntput(mnt); | ||
470 | } | ||
471 | } | ||
472 | |||
473 | void umount_tree(struct vfsmount *mnt, int propagate, struct list_head *kill) | ||
341 | { | 474 | { |
342 | struct vfsmount *p; | 475 | struct vfsmount *p; |
343 | LIST_HEAD(kill); | ||
344 | 476 | ||
345 | for (p = mnt; p; p = next_mnt(p, mnt)) { | 477 | for (p = mnt; p; p = next_mnt(p, mnt)) { |
346 | list_del(&p->mnt_list); | 478 | list_del(&p->mnt_hash); |
347 | list_add(&p->mnt_list, &kill); | 479 | list_add(&p->mnt_hash, kill); |
348 | p->mnt_namespace = NULL; | ||
349 | } | 480 | } |
350 | 481 | ||
351 | while (!list_empty(&kill)) { | 482 | if (propagate) |
352 | mnt = list_entry(kill.next, struct vfsmount, mnt_list); | 483 | propagate_umount(kill); |
353 | list_del_init(&mnt->mnt_list); | 484 | |
354 | list_del_init(&mnt->mnt_expire); | 485 | list_for_each_entry(p, kill, mnt_hash) { |
355 | if (mnt->mnt_parent == mnt) { | 486 | list_del_init(&p->mnt_expire); |
356 | spin_unlock(&vfsmount_lock); | 487 | list_del_init(&p->mnt_list); |
357 | } else { | 488 | __touch_namespace(p->mnt_namespace); |
358 | struct nameidata old_nd; | 489 | p->mnt_namespace = NULL; |
359 | detach_mnt(mnt, &old_nd); | 490 | list_del_init(&p->mnt_child); |
360 | spin_unlock(&vfsmount_lock); | 491 | if (p->mnt_parent != p) |
361 | path_release(&old_nd); | 492 | mnt->mnt_mountpoint->d_mounted--; |
362 | } | 493 | change_mnt_propagation(p, MS_PRIVATE); |
363 | mntput(mnt); | ||
364 | spin_lock(&vfsmount_lock); | ||
365 | } | 494 | } |
366 | } | 495 | } |
367 | 496 | ||
368 | static int do_umount(struct vfsmount *mnt, int flags) | 497 | static int do_umount(struct vfsmount *mnt, int flags) |
369 | { | 498 | { |
370 | struct super_block * sb = mnt->mnt_sb; | 499 | struct super_block *sb = mnt->mnt_sb; |
371 | int retval; | 500 | int retval; |
501 | LIST_HEAD(umount_list); | ||
372 | 502 | ||
373 | retval = security_sb_umount(mnt, flags); | 503 | retval = security_sb_umount(mnt, flags); |
374 | if (retval) | 504 | if (retval) |
@@ -403,7 +533,7 @@ static int do_umount(struct vfsmount *mnt, int flags) | |||
403 | */ | 533 | */ |
404 | 534 | ||
405 | lock_kernel(); | 535 | lock_kernel(); |
406 | if( (flags&MNT_FORCE) && sb->s_op->umount_begin) | 536 | if ((flags & MNT_FORCE) && sb->s_op->umount_begin) |
407 | sb->s_op->umount_begin(sb); | 537 | sb->s_op->umount_begin(sb); |
408 | unlock_kernel(); | 538 | unlock_kernel(); |
409 | 539 | ||
@@ -432,29 +562,21 @@ static int do_umount(struct vfsmount *mnt, int flags) | |||
432 | return retval; | 562 | return retval; |
433 | } | 563 | } |
434 | 564 | ||
435 | down_write(¤t->namespace->sem); | 565 | down_write(&namespace_sem); |
436 | spin_lock(&vfsmount_lock); | 566 | spin_lock(&vfsmount_lock); |
567 | event++; | ||
437 | 568 | ||
438 | if (atomic_read(&sb->s_active) == 1) { | ||
439 | /* last instance - try to be smart */ | ||
440 | spin_unlock(&vfsmount_lock); | ||
441 | lock_kernel(); | ||
442 | DQUOT_OFF(sb); | ||
443 | acct_auto_close(sb); | ||
444 | unlock_kernel(); | ||
445 | security_sb_umount_close(mnt); | ||
446 | spin_lock(&vfsmount_lock); | ||
447 | } | ||
448 | retval = -EBUSY; | 569 | retval = -EBUSY; |
449 | if (atomic_read(&mnt->mnt_count) == 2 || flags & MNT_DETACH) { | 570 | if (flags & MNT_DETACH || !propagate_mount_busy(mnt, 2)) { |
450 | if (!list_empty(&mnt->mnt_list)) | 571 | if (!list_empty(&mnt->mnt_list)) |
451 | umount_tree(mnt); | 572 | umount_tree(mnt, 1, &umount_list); |
452 | retval = 0; | 573 | retval = 0; |
453 | } | 574 | } |
454 | spin_unlock(&vfsmount_lock); | 575 | spin_unlock(&vfsmount_lock); |
455 | if (retval) | 576 | if (retval) |
456 | security_sb_umount_busy(mnt); | 577 | security_sb_umount_busy(mnt); |
457 | up_write(¤t->namespace->sem); | 578 | up_write(&namespace_sem); |
579 | release_mounts(&umount_list); | ||
458 | return retval; | 580 | return retval; |
459 | } | 581 | } |
460 | 582 | ||
@@ -494,12 +616,11 @@ out: | |||
494 | #ifdef __ARCH_WANT_SYS_OLDUMOUNT | 616 | #ifdef __ARCH_WANT_SYS_OLDUMOUNT |
495 | 617 | ||
496 | /* | 618 | /* |
497 | * The 2.0 compatible umount. No flags. | 619 | * The 2.0 compatible umount. No flags. |
498 | */ | 620 | */ |
499 | |||
500 | asmlinkage long sys_oldumount(char __user * name) | 621 | asmlinkage long sys_oldumount(char __user * name) |
501 | { | 622 | { |
502 | return sys_umount(name,0); | 623 | return sys_umount(name, 0); |
503 | } | 624 | } |
504 | 625 | ||
505 | #endif | 626 | #endif |
@@ -516,14 +637,13 @@ static int mount_is_safe(struct nameidata *nd) | |||
516 | if (current->uid != nd->dentry->d_inode->i_uid) | 637 | if (current->uid != nd->dentry->d_inode->i_uid) |
517 | return -EPERM; | 638 | return -EPERM; |
518 | } | 639 | } |
519 | if (permission(nd->dentry->d_inode, MAY_WRITE, nd)) | 640 | if (vfs_permission(nd, MAY_WRITE)) |
520 | return -EPERM; | 641 | return -EPERM; |
521 | return 0; | 642 | return 0; |
522 | #endif | 643 | #endif |
523 | } | 644 | } |
524 | 645 | ||
525 | static int | 646 | static int lives_below_in_same_fs(struct dentry *d, struct dentry *dentry) |
526 | lives_below_in_same_fs(struct dentry *d, struct dentry *dentry) | ||
527 | { | 647 | { |
528 | while (1) { | 648 | while (1) { |
529 | if (d == dentry) | 649 | if (d == dentry) |
@@ -534,12 +654,16 @@ lives_below_in_same_fs(struct dentry *d, struct dentry *dentry) | |||
534 | } | 654 | } |
535 | } | 655 | } |
536 | 656 | ||
537 | static struct vfsmount *copy_tree(struct vfsmount *mnt, struct dentry *dentry) | 657 | struct vfsmount *copy_tree(struct vfsmount *mnt, struct dentry *dentry, |
658 | int flag) | ||
538 | { | 659 | { |
539 | struct vfsmount *res, *p, *q, *r, *s; | 660 | struct vfsmount *res, *p, *q, *r, *s; |
540 | struct nameidata nd; | 661 | struct nameidata nd; |
541 | 662 | ||
542 | res = q = clone_mnt(mnt, dentry); | 663 | if (!(flag & CL_COPY_ALL) && IS_MNT_UNBINDABLE(mnt)) |
664 | return NULL; | ||
665 | |||
666 | res = q = clone_mnt(mnt, dentry, flag); | ||
543 | if (!q) | 667 | if (!q) |
544 | goto Enomem; | 668 | goto Enomem; |
545 | q->mnt_mountpoint = mnt->mnt_mountpoint; | 669 | q->mnt_mountpoint = mnt->mnt_mountpoint; |
@@ -550,6 +674,10 @@ static struct vfsmount *copy_tree(struct vfsmount *mnt, struct dentry *dentry) | |||
550 | continue; | 674 | continue; |
551 | 675 | ||
552 | for (s = r; s; s = next_mnt(s, r)) { | 676 | for (s = r; s; s = next_mnt(s, r)) { |
677 | if (!(flag & CL_COPY_ALL) && IS_MNT_UNBINDABLE(s)) { | ||
678 | s = skip_mnt_tree(s); | ||
679 | continue; | ||
680 | } | ||
553 | while (p != s->mnt_parent) { | 681 | while (p != s->mnt_parent) { |
554 | p = p->mnt_parent; | 682 | p = p->mnt_parent; |
555 | q = q->mnt_parent; | 683 | q = q->mnt_parent; |
@@ -557,7 +685,7 @@ static struct vfsmount *copy_tree(struct vfsmount *mnt, struct dentry *dentry) | |||
557 | p = s; | 685 | p = s; |
558 | nd.mnt = q; | 686 | nd.mnt = q; |
559 | nd.dentry = p->mnt_mountpoint; | 687 | nd.dentry = p->mnt_mountpoint; |
560 | q = clone_mnt(p, p->mnt_root); | 688 | q = clone_mnt(p, p->mnt_root, flag); |
561 | if (!q) | 689 | if (!q) |
562 | goto Enomem; | 690 | goto Enomem; |
563 | spin_lock(&vfsmount_lock); | 691 | spin_lock(&vfsmount_lock); |
@@ -567,15 +695,114 @@ static struct vfsmount *copy_tree(struct vfsmount *mnt, struct dentry *dentry) | |||
567 | } | 695 | } |
568 | } | 696 | } |
569 | return res; | 697 | return res; |
570 | Enomem: | 698 | Enomem: |
571 | if (res) { | 699 | if (res) { |
700 | LIST_HEAD(umount_list); | ||
572 | spin_lock(&vfsmount_lock); | 701 | spin_lock(&vfsmount_lock); |
573 | umount_tree(res); | 702 | umount_tree(res, 0, &umount_list); |
574 | spin_unlock(&vfsmount_lock); | 703 | spin_unlock(&vfsmount_lock); |
704 | release_mounts(&umount_list); | ||
575 | } | 705 | } |
576 | return NULL; | 706 | return NULL; |
577 | } | 707 | } |
578 | 708 | ||
709 | /* | ||
710 | * @source_mnt : mount tree to be attached | ||
711 | * @nd : place the mount tree @source_mnt is attached | ||
712 | * @parent_nd : if non-null, detach the source_mnt from its parent and | ||
713 | * store the parent mount and mountpoint dentry. | ||
714 | * (done when source_mnt is moved) | ||
715 | * | ||
716 | * NOTE: in the table below explains the semantics when a source mount | ||
717 | * of a given type is attached to a destination mount of a given type. | ||
718 | * --------------------------------------------------------------------------- | ||
719 | * | BIND MOUNT OPERATION | | ||
720 | * |************************************************************************** | ||
721 | * | source-->| shared | private | slave | unbindable | | ||
722 | * | dest | | | | | | ||
723 | * | | | | | | | | ||
724 | * | v | | | | | | ||
725 | * |************************************************************************** | ||
726 | * | shared | shared (++) | shared (+) | shared(+++)| invalid | | ||
727 | * | | | | | | | ||
728 | * |non-shared| shared (+) | private | slave (*) | invalid | | ||
729 | * *************************************************************************** | ||
730 | * A bind operation clones the source mount and mounts the clone on the | ||
731 | * destination mount. | ||
732 | * | ||
733 | * (++) the cloned mount is propagated to all the mounts in the propagation | ||
734 | * tree of the destination mount and the cloned mount is added to | ||
735 | * the peer group of the source mount. | ||
736 | * (+) the cloned mount is created under the destination mount and is marked | ||
737 | * as shared. The cloned mount is added to the peer group of the source | ||
738 | * mount. | ||
739 | * (+++) the mount is propagated to all the mounts in the propagation tree | ||
740 | * of the destination mount and the cloned mount is made slave | ||
741 | * of the same master as that of the source mount. The cloned mount | ||
742 | * is marked as 'shared and slave'. | ||
743 | * (*) the cloned mount is made a slave of the same master as that of the | ||
744 | * source mount. | ||
745 | * | ||
746 | * --------------------------------------------------------------------------- | ||
747 | * | MOVE MOUNT OPERATION | | ||
748 | * |************************************************************************** | ||
749 | * | source-->| shared | private | slave | unbindable | | ||
750 | * | dest | | | | | | ||
751 | * | | | | | | | | ||
752 | * | v | | | | | | ||
753 | * |************************************************************************** | ||
754 | * | shared | shared (+) | shared (+) | shared(+++) | invalid | | ||
755 | * | | | | | | | ||
756 | * |non-shared| shared (+*) | private | slave (*) | unbindable | | ||
757 | * *************************************************************************** | ||
758 | * | ||
759 | * (+) the mount is moved to the destination. And is then propagated to | ||
760 | * all the mounts in the propagation tree of the destination mount. | ||
761 | * (+*) the mount is moved to the destination. | ||
762 | * (+++) the mount is moved to the destination and is then propagated to | ||
763 | * all the mounts belonging to the destination mount's propagation tree. | ||
764 | * the mount is marked as 'shared and slave'. | ||
765 | * (*) the mount continues to be a slave at the new location. | ||
766 | * | ||
767 | * if the source mount is a tree, the operations explained above is | ||
768 | * applied to each mount in the tree. | ||
769 | * Must be called without spinlocks held, since this function can sleep | ||
770 | * in allocations. | ||
771 | */ | ||
772 | static int attach_recursive_mnt(struct vfsmount *source_mnt, | ||
773 | struct nameidata *nd, struct nameidata *parent_nd) | ||
774 | { | ||
775 | LIST_HEAD(tree_list); | ||
776 | struct vfsmount *dest_mnt = nd->mnt; | ||
777 | struct dentry *dest_dentry = nd->dentry; | ||
778 | struct vfsmount *child, *p; | ||
779 | |||
780 | if (propagate_mnt(dest_mnt, dest_dentry, source_mnt, &tree_list)) | ||
781 | return -EINVAL; | ||
782 | |||
783 | if (IS_MNT_SHARED(dest_mnt)) { | ||
784 | for (p = source_mnt; p; p = next_mnt(p, source_mnt)) | ||
785 | set_mnt_shared(p); | ||
786 | } | ||
787 | |||
788 | spin_lock(&vfsmount_lock); | ||
789 | if (parent_nd) { | ||
790 | detach_mnt(source_mnt, parent_nd); | ||
791 | attach_mnt(source_mnt, nd); | ||
792 | touch_namespace(current->namespace); | ||
793 | } else { | ||
794 | mnt_set_mountpoint(dest_mnt, dest_dentry, source_mnt); | ||
795 | commit_tree(source_mnt); | ||
796 | } | ||
797 | |||
798 | list_for_each_entry_safe(child, p, &tree_list, mnt_hash) { | ||
799 | list_del_init(&child->mnt_hash); | ||
800 | commit_tree(child); | ||
801 | } | ||
802 | spin_unlock(&vfsmount_lock); | ||
803 | return 0; | ||
804 | } | ||
805 | |||
579 | static int graft_tree(struct vfsmount *mnt, struct nameidata *nd) | 806 | static int graft_tree(struct vfsmount *mnt, struct nameidata *nd) |
580 | { | 807 | { |
581 | int err; | 808 | int err; |
@@ -596,17 +823,8 @@ static int graft_tree(struct vfsmount *mnt, struct nameidata *nd) | |||
596 | goto out_unlock; | 823 | goto out_unlock; |
597 | 824 | ||
598 | err = -ENOENT; | 825 | err = -ENOENT; |
599 | spin_lock(&vfsmount_lock); | 826 | if (IS_ROOT(nd->dentry) || !d_unhashed(nd->dentry)) |
600 | if (IS_ROOT(nd->dentry) || !d_unhashed(nd->dentry)) { | 827 | err = attach_recursive_mnt(mnt, nd, NULL); |
601 | struct list_head head; | ||
602 | |||
603 | attach_mnt(mnt, nd); | ||
604 | list_add_tail(&head, &mnt->mnt_list); | ||
605 | list_splice(&head, current->namespace->list.prev); | ||
606 | mntget(mnt); | ||
607 | err = 0; | ||
608 | } | ||
609 | spin_unlock(&vfsmount_lock); | ||
610 | out_unlock: | 828 | out_unlock: |
611 | up(&nd->dentry->d_inode->i_sem); | 829 | up(&nd->dentry->d_inode->i_sem); |
612 | if (!err) | 830 | if (!err) |
@@ -615,6 +833,27 @@ out_unlock: | |||
615 | } | 833 | } |
616 | 834 | ||
617 | /* | 835 | /* |
836 | * recursively change the type of the mountpoint. | ||
837 | */ | ||
838 | static int do_change_type(struct nameidata *nd, int flag) | ||
839 | { | ||
840 | struct vfsmount *m, *mnt = nd->mnt; | ||
841 | int recurse = flag & MS_REC; | ||
842 | int type = flag & ~MS_REC; | ||
843 | |||
844 | if (nd->dentry != nd->mnt->mnt_root) | ||
845 | return -EINVAL; | ||
846 | |||
847 | down_write(&namespace_sem); | ||
848 | spin_lock(&vfsmount_lock); | ||
849 | for (m = mnt; m; m = (recurse ? next_mnt(m, mnt) : NULL)) | ||
850 | change_mnt_propagation(m, type); | ||
851 | spin_unlock(&vfsmount_lock); | ||
852 | up_write(&namespace_sem); | ||
853 | return 0; | ||
854 | } | ||
855 | |||
856 | /* | ||
618 | * do loopback mount. | 857 | * do loopback mount. |
619 | */ | 858 | */ |
620 | static int do_loopback(struct nameidata *nd, char *old_name, int recurse) | 859 | static int do_loopback(struct nameidata *nd, char *old_name, int recurse) |
@@ -630,32 +869,34 @@ static int do_loopback(struct nameidata *nd, char *old_name, int recurse) | |||
630 | if (err) | 869 | if (err) |
631 | return err; | 870 | return err; |
632 | 871 | ||
633 | down_write(¤t->namespace->sem); | 872 | down_write(&namespace_sem); |
634 | err = -EINVAL; | 873 | err = -EINVAL; |
635 | if (check_mnt(nd->mnt) && (!recurse || check_mnt(old_nd.mnt))) { | 874 | if (IS_MNT_UNBINDABLE(old_nd.mnt)) |
636 | err = -ENOMEM; | 875 | goto out; |
637 | if (recurse) | ||
638 | mnt = copy_tree(old_nd.mnt, old_nd.dentry); | ||
639 | else | ||
640 | mnt = clone_mnt(old_nd.mnt, old_nd.dentry); | ||
641 | } | ||
642 | 876 | ||
643 | if (mnt) { | 877 | if (!check_mnt(nd->mnt) || !check_mnt(old_nd.mnt)) |
644 | /* stop bind mounts from expiring */ | 878 | goto out; |
879 | |||
880 | err = -ENOMEM; | ||
881 | if (recurse) | ||
882 | mnt = copy_tree(old_nd.mnt, old_nd.dentry, 0); | ||
883 | else | ||
884 | mnt = clone_mnt(old_nd.mnt, old_nd.dentry, 0); | ||
885 | |||
886 | if (!mnt) | ||
887 | goto out; | ||
888 | |||
889 | err = graft_tree(mnt, nd); | ||
890 | if (err) { | ||
891 | LIST_HEAD(umount_list); | ||
645 | spin_lock(&vfsmount_lock); | 892 | spin_lock(&vfsmount_lock); |
646 | list_del_init(&mnt->mnt_expire); | 893 | umount_tree(mnt, 0, &umount_list); |
647 | spin_unlock(&vfsmount_lock); | 894 | spin_unlock(&vfsmount_lock); |
648 | 895 | release_mounts(&umount_list); | |
649 | err = graft_tree(mnt, nd); | ||
650 | if (err) { | ||
651 | spin_lock(&vfsmount_lock); | ||
652 | umount_tree(mnt); | ||
653 | spin_unlock(&vfsmount_lock); | ||
654 | } else | ||
655 | mntput(mnt); | ||
656 | } | 896 | } |
657 | 897 | ||
658 | up_write(¤t->namespace->sem); | 898 | out: |
899 | up_write(&namespace_sem); | ||
659 | path_release(&old_nd); | 900 | path_release(&old_nd); |
660 | return err; | 901 | return err; |
661 | } | 902 | } |
@@ -665,12 +906,11 @@ static int do_loopback(struct nameidata *nd, char *old_name, int recurse) | |||
665 | * If you've mounted a non-root directory somewhere and want to do remount | 906 | * If you've mounted a non-root directory somewhere and want to do remount |
666 | * on it - tough luck. | 907 | * on it - tough luck. |
667 | */ | 908 | */ |
668 | |||
669 | static int do_remount(struct nameidata *nd, int flags, int mnt_flags, | 909 | static int do_remount(struct nameidata *nd, int flags, int mnt_flags, |
670 | void *data) | 910 | void *data) |
671 | { | 911 | { |
672 | int err; | 912 | int err; |
673 | struct super_block * sb = nd->mnt->mnt_sb; | 913 | struct super_block *sb = nd->mnt->mnt_sb; |
674 | 914 | ||
675 | if (!capable(CAP_SYS_ADMIN)) | 915 | if (!capable(CAP_SYS_ADMIN)) |
676 | return -EPERM; | 916 | return -EPERM; |
@@ -684,13 +924,23 @@ static int do_remount(struct nameidata *nd, int flags, int mnt_flags, | |||
684 | down_write(&sb->s_umount); | 924 | down_write(&sb->s_umount); |
685 | err = do_remount_sb(sb, flags, data, 0); | 925 | err = do_remount_sb(sb, flags, data, 0); |
686 | if (!err) | 926 | if (!err) |
687 | nd->mnt->mnt_flags=mnt_flags; | 927 | nd->mnt->mnt_flags = mnt_flags; |
688 | up_write(&sb->s_umount); | 928 | up_write(&sb->s_umount); |
689 | if (!err) | 929 | if (!err) |
690 | security_sb_post_remount(nd->mnt, flags, data); | 930 | security_sb_post_remount(nd->mnt, flags, data); |
691 | return err; | 931 | return err; |
692 | } | 932 | } |
693 | 933 | ||
934 | static inline int tree_contains_unbindable(struct vfsmount *mnt) | ||
935 | { | ||
936 | struct vfsmount *p; | ||
937 | for (p = mnt; p; p = next_mnt(p, mnt)) { | ||
938 | if (IS_MNT_UNBINDABLE(p)) | ||
939 | return 1; | ||
940 | } | ||
941 | return 0; | ||
942 | } | ||
943 | |||
694 | static int do_move_mount(struct nameidata *nd, char *old_name) | 944 | static int do_move_mount(struct nameidata *nd, char *old_name) |
695 | { | 945 | { |
696 | struct nameidata old_nd, parent_nd; | 946 | struct nameidata old_nd, parent_nd; |
@@ -704,8 +954,8 @@ static int do_move_mount(struct nameidata *nd, char *old_name) | |||
704 | if (err) | 954 | if (err) |
705 | return err; | 955 | return err; |
706 | 956 | ||
707 | down_write(¤t->namespace->sem); | 957 | down_write(&namespace_sem); |
708 | while(d_mountpoint(nd->dentry) && follow_down(&nd->mnt, &nd->dentry)) | 958 | while (d_mountpoint(nd->dentry) && follow_down(&nd->mnt, &nd->dentry)) |
709 | ; | 959 | ; |
710 | err = -EINVAL; | 960 | err = -EINVAL; |
711 | if (!check_mnt(nd->mnt) || !check_mnt(old_nd.mnt)) | 961 | if (!check_mnt(nd->mnt) || !check_mnt(old_nd.mnt)) |
@@ -716,39 +966,47 @@ static int do_move_mount(struct nameidata *nd, char *old_name) | |||
716 | if (IS_DEADDIR(nd->dentry->d_inode)) | 966 | if (IS_DEADDIR(nd->dentry->d_inode)) |
717 | goto out1; | 967 | goto out1; |
718 | 968 | ||
719 | spin_lock(&vfsmount_lock); | ||
720 | if (!IS_ROOT(nd->dentry) && d_unhashed(nd->dentry)) | 969 | if (!IS_ROOT(nd->dentry) && d_unhashed(nd->dentry)) |
721 | goto out2; | 970 | goto out1; |
722 | 971 | ||
723 | err = -EINVAL; | 972 | err = -EINVAL; |
724 | if (old_nd.dentry != old_nd.mnt->mnt_root) | 973 | if (old_nd.dentry != old_nd.mnt->mnt_root) |
725 | goto out2; | 974 | goto out1; |
726 | 975 | ||
727 | if (old_nd.mnt == old_nd.mnt->mnt_parent) | 976 | if (old_nd.mnt == old_nd.mnt->mnt_parent) |
728 | goto out2; | 977 | goto out1; |
729 | 978 | ||
730 | if (S_ISDIR(nd->dentry->d_inode->i_mode) != | 979 | if (S_ISDIR(nd->dentry->d_inode->i_mode) != |
731 | S_ISDIR(old_nd.dentry->d_inode->i_mode)) | 980 | S_ISDIR(old_nd.dentry->d_inode->i_mode)) |
732 | goto out2; | 981 | goto out1; |
733 | 982 | /* | |
983 | * Don't move a mount residing in a shared parent. | ||
984 | */ | ||
985 | if (old_nd.mnt->mnt_parent && IS_MNT_SHARED(old_nd.mnt->mnt_parent)) | ||
986 | goto out1; | ||
987 | /* | ||
988 | * Don't move a mount tree containing unbindable mounts to a destination | ||
989 | * mount which is shared. | ||
990 | */ | ||
991 | if (IS_MNT_SHARED(nd->mnt) && tree_contains_unbindable(old_nd.mnt)) | ||
992 | goto out1; | ||
734 | err = -ELOOP; | 993 | err = -ELOOP; |
735 | for (p = nd->mnt; p->mnt_parent!=p; p = p->mnt_parent) | 994 | for (p = nd->mnt; p->mnt_parent != p; p = p->mnt_parent) |
736 | if (p == old_nd.mnt) | 995 | if (p == old_nd.mnt) |
737 | goto out2; | 996 | goto out1; |
738 | err = 0; | ||
739 | 997 | ||
740 | detach_mnt(old_nd.mnt, &parent_nd); | 998 | if ((err = attach_recursive_mnt(old_nd.mnt, nd, &parent_nd))) |
741 | attach_mnt(old_nd.mnt, nd); | 999 | goto out1; |
742 | 1000 | ||
1001 | spin_lock(&vfsmount_lock); | ||
743 | /* if the mount is moved, it should no longer be expire | 1002 | /* if the mount is moved, it should no longer be expire |
744 | * automatically */ | 1003 | * automatically */ |
745 | list_del_init(&old_nd.mnt->mnt_expire); | 1004 | list_del_init(&old_nd.mnt->mnt_expire); |
746 | out2: | ||
747 | spin_unlock(&vfsmount_lock); | 1005 | spin_unlock(&vfsmount_lock); |
748 | out1: | 1006 | out1: |
749 | up(&nd->dentry->d_inode->i_sem); | 1007 | up(&nd->dentry->d_inode->i_sem); |
750 | out: | 1008 | out: |
751 | up_write(¤t->namespace->sem); | 1009 | up_write(&namespace_sem); |
752 | if (!err) | 1010 | if (!err) |
753 | path_release(&parent_nd); | 1011 | path_release(&parent_nd); |
754 | path_release(&old_nd); | 1012 | path_release(&old_nd); |
@@ -787,9 +1045,9 @@ int do_add_mount(struct vfsmount *newmnt, struct nameidata *nd, | |||
787 | { | 1045 | { |
788 | int err; | 1046 | int err; |
789 | 1047 | ||
790 | down_write(¤t->namespace->sem); | 1048 | down_write(&namespace_sem); |
791 | /* Something was mounted here while we slept */ | 1049 | /* Something was mounted here while we slept */ |
792 | while(d_mountpoint(nd->dentry) && follow_down(&nd->mnt, &nd->dentry)) | 1050 | while (d_mountpoint(nd->dentry) && follow_down(&nd->mnt, &nd->dentry)) |
793 | ; | 1051 | ; |
794 | err = -EINVAL; | 1052 | err = -EINVAL; |
795 | if (!check_mnt(nd->mnt)) | 1053 | if (!check_mnt(nd->mnt)) |
@@ -806,25 +1064,28 @@ int do_add_mount(struct vfsmount *newmnt, struct nameidata *nd, | |||
806 | goto unlock; | 1064 | goto unlock; |
807 | 1065 | ||
808 | newmnt->mnt_flags = mnt_flags; | 1066 | newmnt->mnt_flags = mnt_flags; |
809 | newmnt->mnt_namespace = current->namespace; | 1067 | if ((err = graft_tree(newmnt, nd))) |
810 | err = graft_tree(newmnt, nd); | 1068 | goto unlock; |
811 | 1069 | ||
812 | if (err == 0 && fslist) { | 1070 | if (fslist) { |
813 | /* add to the specified expiration list */ | 1071 | /* add to the specified expiration list */ |
814 | spin_lock(&vfsmount_lock); | 1072 | spin_lock(&vfsmount_lock); |
815 | list_add_tail(&newmnt->mnt_expire, fslist); | 1073 | list_add_tail(&newmnt->mnt_expire, fslist); |
816 | spin_unlock(&vfsmount_lock); | 1074 | spin_unlock(&vfsmount_lock); |
817 | } | 1075 | } |
1076 | up_write(&namespace_sem); | ||
1077 | return 0; | ||
818 | 1078 | ||
819 | unlock: | 1079 | unlock: |
820 | up_write(¤t->namespace->sem); | 1080 | up_write(&namespace_sem); |
821 | mntput(newmnt); | 1081 | mntput(newmnt); |
822 | return err; | 1082 | return err; |
823 | } | 1083 | } |
824 | 1084 | ||
825 | EXPORT_SYMBOL_GPL(do_add_mount); | 1085 | EXPORT_SYMBOL_GPL(do_add_mount); |
826 | 1086 | ||
827 | static void expire_mount(struct vfsmount *mnt, struct list_head *mounts) | 1087 | static void expire_mount(struct vfsmount *mnt, struct list_head *mounts, |
1088 | struct list_head *umounts) | ||
828 | { | 1089 | { |
829 | spin_lock(&vfsmount_lock); | 1090 | spin_lock(&vfsmount_lock); |
830 | 1091 | ||
@@ -841,27 +1102,13 @@ static void expire_mount(struct vfsmount *mnt, struct list_head *mounts) | |||
841 | * Check that it is still dead: the count should now be 2 - as | 1102 | * Check that it is still dead: the count should now be 2 - as |
842 | * contributed by the vfsmount parent and the mntget above | 1103 | * contributed by the vfsmount parent and the mntget above |
843 | */ | 1104 | */ |
844 | if (atomic_read(&mnt->mnt_count) == 2) { | 1105 | if (!propagate_mount_busy(mnt, 2)) { |
845 | struct nameidata old_nd; | ||
846 | |||
847 | /* delete from the namespace */ | 1106 | /* delete from the namespace */ |
1107 | touch_namespace(mnt->mnt_namespace); | ||
848 | list_del_init(&mnt->mnt_list); | 1108 | list_del_init(&mnt->mnt_list); |
849 | mnt->mnt_namespace = NULL; | 1109 | mnt->mnt_namespace = NULL; |
850 | detach_mnt(mnt, &old_nd); | 1110 | umount_tree(mnt, 1, umounts); |
851 | spin_unlock(&vfsmount_lock); | 1111 | spin_unlock(&vfsmount_lock); |
852 | path_release(&old_nd); | ||
853 | |||
854 | /* | ||
855 | * Now lay it to rest if this was the last ref on the superblock | ||
856 | */ | ||
857 | if (atomic_read(&mnt->mnt_sb->s_active) == 1) { | ||
858 | /* last instance - try to be smart */ | ||
859 | lock_kernel(); | ||
860 | DQUOT_OFF(mnt->mnt_sb); | ||
861 | acct_auto_close(mnt->mnt_sb); | ||
862 | unlock_kernel(); | ||
863 | } | ||
864 | mntput(mnt); | ||
865 | } else { | 1112 | } else { |
866 | /* | 1113 | /* |
867 | * Someone brought it back to life whilst we didn't have any | 1114 | * Someone brought it back to life whilst we didn't have any |
@@ -910,6 +1157,7 @@ void mark_mounts_for_expiry(struct list_head *mounts) | |||
910 | * - dispose of the corpse | 1157 | * - dispose of the corpse |
911 | */ | 1158 | */ |
912 | while (!list_empty(&graveyard)) { | 1159 | while (!list_empty(&graveyard)) { |
1160 | LIST_HEAD(umounts); | ||
913 | mnt = list_entry(graveyard.next, struct vfsmount, mnt_expire); | 1161 | mnt = list_entry(graveyard.next, struct vfsmount, mnt_expire); |
914 | list_del_init(&mnt->mnt_expire); | 1162 | list_del_init(&mnt->mnt_expire); |
915 | 1163 | ||
@@ -921,13 +1169,12 @@ void mark_mounts_for_expiry(struct list_head *mounts) | |||
921 | get_namespace(namespace); | 1169 | get_namespace(namespace); |
922 | 1170 | ||
923 | spin_unlock(&vfsmount_lock); | 1171 | spin_unlock(&vfsmount_lock); |
924 | down_write(&namespace->sem); | 1172 | down_write(&namespace_sem); |
925 | expire_mount(mnt, mounts); | 1173 | expire_mount(mnt, mounts, &umounts); |
926 | up_write(&namespace->sem); | 1174 | up_write(&namespace_sem); |
927 | 1175 | release_mounts(&umounts); | |
928 | mntput(mnt); | 1176 | mntput(mnt); |
929 | put_namespace(namespace); | 1177 | put_namespace(namespace); |
930 | |||
931 | spin_lock(&vfsmount_lock); | 1178 | spin_lock(&vfsmount_lock); |
932 | } | 1179 | } |
933 | 1180 | ||
@@ -942,8 +1189,8 @@ EXPORT_SYMBOL_GPL(mark_mounts_for_expiry); | |||
942 | * Note that this function differs from copy_from_user() in that it will oops | 1189 | * Note that this function differs from copy_from_user() in that it will oops |
943 | * on bad values of `to', rather than returning a short copy. | 1190 | * on bad values of `to', rather than returning a short copy. |
944 | */ | 1191 | */ |
945 | static long | 1192 | static long exact_copy_from_user(void *to, const void __user * from, |
946 | exact_copy_from_user(void *to, const void __user *from, unsigned long n) | 1193 | unsigned long n) |
947 | { | 1194 | { |
948 | char *t = to; | 1195 | char *t = to; |
949 | const char __user *f = from; | 1196 | const char __user *f = from; |
@@ -964,12 +1211,12 @@ exact_copy_from_user(void *to, const void __user *from, unsigned long n) | |||
964 | return n; | 1211 | return n; |
965 | } | 1212 | } |
966 | 1213 | ||
967 | int copy_mount_options(const void __user *data, unsigned long *where) | 1214 | int copy_mount_options(const void __user * data, unsigned long *where) |
968 | { | 1215 | { |
969 | int i; | 1216 | int i; |
970 | unsigned long page; | 1217 | unsigned long page; |
971 | unsigned long size; | 1218 | unsigned long size; |
972 | 1219 | ||
973 | *where = 0; | 1220 | *where = 0; |
974 | if (!data) | 1221 | if (!data) |
975 | return 0; | 1222 | return 0; |
@@ -988,7 +1235,7 @@ int copy_mount_options(const void __user *data, unsigned long *where) | |||
988 | 1235 | ||
989 | i = size - exact_copy_from_user((void *)page, data, size); | 1236 | i = size - exact_copy_from_user((void *)page, data, size); |
990 | if (!i) { | 1237 | if (!i) { |
991 | free_page(page); | 1238 | free_page(page); |
992 | return -EFAULT; | 1239 | return -EFAULT; |
993 | } | 1240 | } |
994 | if (i != PAGE_SIZE) | 1241 | if (i != PAGE_SIZE) |
@@ -1011,7 +1258,7 @@ int copy_mount_options(const void __user *data, unsigned long *where) | |||
1011 | * Therefore, if this magic number is present, it carries no information | 1258 | * Therefore, if this magic number is present, it carries no information |
1012 | * and must be discarded. | 1259 | * and must be discarded. |
1013 | */ | 1260 | */ |
1014 | long do_mount(char * dev_name, char * dir_name, char *type_page, | 1261 | long do_mount(char *dev_name, char *dir_name, char *type_page, |
1015 | unsigned long flags, void *data_page) | 1262 | unsigned long flags, void *data_page) |
1016 | { | 1263 | { |
1017 | struct nameidata nd; | 1264 | struct nameidata nd; |
@@ -1039,7 +1286,7 @@ long do_mount(char * dev_name, char * dir_name, char *type_page, | |||
1039 | mnt_flags |= MNT_NODEV; | 1286 | mnt_flags |= MNT_NODEV; |
1040 | if (flags & MS_NOEXEC) | 1287 | if (flags & MS_NOEXEC) |
1041 | mnt_flags |= MNT_NOEXEC; | 1288 | mnt_flags |= MNT_NOEXEC; |
1042 | flags &= ~(MS_NOSUID|MS_NOEXEC|MS_NODEV|MS_ACTIVE); | 1289 | flags &= ~(MS_NOSUID | MS_NOEXEC | MS_NODEV | MS_ACTIVE); |
1043 | 1290 | ||
1044 | /* ... and get the mountpoint */ | 1291 | /* ... and get the mountpoint */ |
1045 | retval = path_lookup(dir_name, LOOKUP_FOLLOW, &nd); | 1292 | retval = path_lookup(dir_name, LOOKUP_FOLLOW, &nd); |
@@ -1055,6 +1302,8 @@ long do_mount(char * dev_name, char * dir_name, char *type_page, | |||
1055 | data_page); | 1302 | data_page); |
1056 | else if (flags & MS_BIND) | 1303 | else if (flags & MS_BIND) |
1057 | retval = do_loopback(&nd, dev_name, flags & MS_REC); | 1304 | retval = do_loopback(&nd, dev_name, flags & MS_REC); |
1305 | else if (flags & (MS_SHARED | MS_PRIVATE | MS_SLAVE | MS_UNBINDABLE)) | ||
1306 | retval = do_change_type(&nd, flags); | ||
1058 | else if (flags & MS_MOVE) | 1307 | else if (flags & MS_MOVE) |
1059 | retval = do_move_mount(&nd, dev_name); | 1308 | retval = do_move_mount(&nd, dev_name); |
1060 | else | 1309 | else |
@@ -1091,14 +1340,16 @@ int copy_namespace(int flags, struct task_struct *tsk) | |||
1091 | goto out; | 1340 | goto out; |
1092 | 1341 | ||
1093 | atomic_set(&new_ns->count, 1); | 1342 | atomic_set(&new_ns->count, 1); |
1094 | init_rwsem(&new_ns->sem); | ||
1095 | INIT_LIST_HEAD(&new_ns->list); | 1343 | INIT_LIST_HEAD(&new_ns->list); |
1344 | init_waitqueue_head(&new_ns->poll); | ||
1345 | new_ns->event = 0; | ||
1096 | 1346 | ||
1097 | down_write(&tsk->namespace->sem); | 1347 | down_write(&namespace_sem); |
1098 | /* First pass: copy the tree topology */ | 1348 | /* First pass: copy the tree topology */ |
1099 | new_ns->root = copy_tree(namespace->root, namespace->root->mnt_root); | 1349 | new_ns->root = copy_tree(namespace->root, namespace->root->mnt_root, |
1350 | CL_COPY_ALL | CL_EXPIRE); | ||
1100 | if (!new_ns->root) { | 1351 | if (!new_ns->root) { |
1101 | up_write(&tsk->namespace->sem); | 1352 | up_write(&namespace_sem); |
1102 | kfree(new_ns); | 1353 | kfree(new_ns); |
1103 | goto out; | 1354 | goto out; |
1104 | } | 1355 | } |
@@ -1132,7 +1383,7 @@ int copy_namespace(int flags, struct task_struct *tsk) | |||
1132 | p = next_mnt(p, namespace->root); | 1383 | p = next_mnt(p, namespace->root); |
1133 | q = next_mnt(q, new_ns->root); | 1384 | q = next_mnt(q, new_ns->root); |
1134 | } | 1385 | } |
1135 | up_write(&tsk->namespace->sem); | 1386 | up_write(&namespace_sem); |
1136 | 1387 | ||
1137 | tsk->namespace = new_ns; | 1388 | tsk->namespace = new_ns; |
1138 | 1389 | ||
@@ -1161,7 +1412,7 @@ asmlinkage long sys_mount(char __user * dev_name, char __user * dir_name, | |||
1161 | unsigned long dev_page; | 1412 | unsigned long dev_page; |
1162 | char *dir_page; | 1413 | char *dir_page; |
1163 | 1414 | ||
1164 | retval = copy_mount_options (type, &type_page); | 1415 | retval = copy_mount_options(type, &type_page); |
1165 | if (retval < 0) | 1416 | if (retval < 0) |
1166 | return retval; | 1417 | return retval; |
1167 | 1418 | ||
@@ -1170,17 +1421,17 @@ asmlinkage long sys_mount(char __user * dev_name, char __user * dir_name, | |||
1170 | if (IS_ERR(dir_page)) | 1421 | if (IS_ERR(dir_page)) |
1171 | goto out1; | 1422 | goto out1; |
1172 | 1423 | ||
1173 | retval = copy_mount_options (dev_name, &dev_page); | 1424 | retval = copy_mount_options(dev_name, &dev_page); |
1174 | if (retval < 0) | 1425 | if (retval < 0) |
1175 | goto out2; | 1426 | goto out2; |
1176 | 1427 | ||
1177 | retval = copy_mount_options (data, &data_page); | 1428 | retval = copy_mount_options(data, &data_page); |
1178 | if (retval < 0) | 1429 | if (retval < 0) |
1179 | goto out3; | 1430 | goto out3; |
1180 | 1431 | ||
1181 | lock_kernel(); | 1432 | lock_kernel(); |
1182 | retval = do_mount((char*)dev_page, dir_page, (char*)type_page, | 1433 | retval = do_mount((char *)dev_page, dir_page, (char *)type_page, |
1183 | flags, (void*)data_page); | 1434 | flags, (void *)data_page); |
1184 | unlock_kernel(); | 1435 | unlock_kernel(); |
1185 | free_page(data_page); | 1436 | free_page(data_page); |
1186 | 1437 | ||
@@ -1249,9 +1500,11 @@ static void chroot_fs_refs(struct nameidata *old_nd, struct nameidata *new_nd) | |||
1249 | if (fs) { | 1500 | if (fs) { |
1250 | atomic_inc(&fs->count); | 1501 | atomic_inc(&fs->count); |
1251 | task_unlock(p); | 1502 | task_unlock(p); |
1252 | if (fs->root==old_nd->dentry&&fs->rootmnt==old_nd->mnt) | 1503 | if (fs->root == old_nd->dentry |
1504 | && fs->rootmnt == old_nd->mnt) | ||
1253 | set_fs_root(fs, new_nd->mnt, new_nd->dentry); | 1505 | set_fs_root(fs, new_nd->mnt, new_nd->dentry); |
1254 | if (fs->pwd==old_nd->dentry&&fs->pwdmnt==old_nd->mnt) | 1506 | if (fs->pwd == old_nd->dentry |
1507 | && fs->pwdmnt == old_nd->mnt) | ||
1255 | set_fs_pwd(fs, new_nd->mnt, new_nd->dentry); | 1508 | set_fs_pwd(fs, new_nd->mnt, new_nd->dentry); |
1256 | put_fs_struct(fs); | 1509 | put_fs_struct(fs); |
1257 | } else | 1510 | } else |
@@ -1281,8 +1534,8 @@ static void chroot_fs_refs(struct nameidata *old_nd, struct nameidata *new_nd) | |||
1281 | * though, so you may need to say mount --bind /nfs/my_root /nfs/my_root | 1534 | * though, so you may need to say mount --bind /nfs/my_root /nfs/my_root |
1282 | * first. | 1535 | * first. |
1283 | */ | 1536 | */ |
1284 | 1537 | asmlinkage long sys_pivot_root(const char __user * new_root, | |
1285 | asmlinkage long sys_pivot_root(const char __user *new_root, const char __user *put_old) | 1538 | const char __user * put_old) |
1286 | { | 1539 | { |
1287 | struct vfsmount *tmp; | 1540 | struct vfsmount *tmp; |
1288 | struct nameidata new_nd, old_nd, parent_nd, root_parent, user_nd; | 1541 | struct nameidata new_nd, old_nd, parent_nd, root_parent, user_nd; |
@@ -1293,14 +1546,15 @@ asmlinkage long sys_pivot_root(const char __user *new_root, const char __user *p | |||
1293 | 1546 | ||
1294 | lock_kernel(); | 1547 | lock_kernel(); |
1295 | 1548 | ||
1296 | error = __user_walk(new_root, LOOKUP_FOLLOW|LOOKUP_DIRECTORY, &new_nd); | 1549 | error = __user_walk(new_root, LOOKUP_FOLLOW | LOOKUP_DIRECTORY, |
1550 | &new_nd); | ||
1297 | if (error) | 1551 | if (error) |
1298 | goto out0; | 1552 | goto out0; |
1299 | error = -EINVAL; | 1553 | error = -EINVAL; |
1300 | if (!check_mnt(new_nd.mnt)) | 1554 | if (!check_mnt(new_nd.mnt)) |
1301 | goto out1; | 1555 | goto out1; |
1302 | 1556 | ||
1303 | error = __user_walk(put_old, LOOKUP_FOLLOW|LOOKUP_DIRECTORY, &old_nd); | 1557 | error = __user_walk(put_old, LOOKUP_FOLLOW | LOOKUP_DIRECTORY, &old_nd); |
1304 | if (error) | 1558 | if (error) |
1305 | goto out1; | 1559 | goto out1; |
1306 | 1560 | ||
@@ -1314,9 +1568,13 @@ asmlinkage long sys_pivot_root(const char __user *new_root, const char __user *p | |||
1314 | user_nd.mnt = mntget(current->fs->rootmnt); | 1568 | user_nd.mnt = mntget(current->fs->rootmnt); |
1315 | user_nd.dentry = dget(current->fs->root); | 1569 | user_nd.dentry = dget(current->fs->root); |
1316 | read_unlock(¤t->fs->lock); | 1570 | read_unlock(¤t->fs->lock); |
1317 | down_write(¤t->namespace->sem); | 1571 | down_write(&namespace_sem); |
1318 | down(&old_nd.dentry->d_inode->i_sem); | 1572 | down(&old_nd.dentry->d_inode->i_sem); |
1319 | error = -EINVAL; | 1573 | error = -EINVAL; |
1574 | if (IS_MNT_SHARED(old_nd.mnt) || | ||
1575 | IS_MNT_SHARED(new_nd.mnt->mnt_parent) || | ||
1576 | IS_MNT_SHARED(user_nd.mnt->mnt_parent)) | ||
1577 | goto out2; | ||
1320 | if (!check_mnt(user_nd.mnt)) | 1578 | if (!check_mnt(user_nd.mnt)) |
1321 | goto out2; | 1579 | goto out2; |
1322 | error = -ENOENT; | 1580 | error = -ENOENT; |
@@ -1356,6 +1614,7 @@ asmlinkage long sys_pivot_root(const char __user *new_root, const char __user *p | |||
1356 | detach_mnt(user_nd.mnt, &root_parent); | 1614 | detach_mnt(user_nd.mnt, &root_parent); |
1357 | attach_mnt(user_nd.mnt, &old_nd); /* mount old root on put_old */ | 1615 | attach_mnt(user_nd.mnt, &old_nd); /* mount old root on put_old */ |
1358 | attach_mnt(new_nd.mnt, &root_parent); /* mount new_root on / */ | 1616 | attach_mnt(new_nd.mnt, &root_parent); /* mount new_root on / */ |
1617 | touch_namespace(current->namespace); | ||
1359 | spin_unlock(&vfsmount_lock); | 1618 | spin_unlock(&vfsmount_lock); |
1360 | chroot_fs_refs(&user_nd, &new_nd); | 1619 | chroot_fs_refs(&user_nd, &new_nd); |
1361 | security_sb_post_pivotroot(&user_nd, &new_nd); | 1620 | security_sb_post_pivotroot(&user_nd, &new_nd); |
@@ -1364,7 +1623,7 @@ asmlinkage long sys_pivot_root(const char __user *new_root, const char __user *p | |||
1364 | path_release(&parent_nd); | 1623 | path_release(&parent_nd); |
1365 | out2: | 1624 | out2: |
1366 | up(&old_nd.dentry->d_inode->i_sem); | 1625 | up(&old_nd.dentry->d_inode->i_sem); |
1367 | up_write(¤t->namespace->sem); | 1626 | up_write(&namespace_sem); |
1368 | path_release(&user_nd); | 1627 | path_release(&user_nd); |
1369 | path_release(&old_nd); | 1628 | path_release(&old_nd); |
1370 | out1: | 1629 | out1: |
@@ -1391,7 +1650,8 @@ static void __init init_mount_tree(void) | |||
1391 | panic("Can't allocate initial namespace"); | 1650 | panic("Can't allocate initial namespace"); |
1392 | atomic_set(&namespace->count, 1); | 1651 | atomic_set(&namespace->count, 1); |
1393 | INIT_LIST_HEAD(&namespace->list); | 1652 | INIT_LIST_HEAD(&namespace->list); |
1394 | init_rwsem(&namespace->sem); | 1653 | init_waitqueue_head(&namespace->poll); |
1654 | namespace->event = 0; | ||
1395 | list_add(&mnt->mnt_list, &namespace->list); | 1655 | list_add(&mnt->mnt_list, &namespace->list); |
1396 | namespace->root = mnt; | 1656 | namespace->root = mnt; |
1397 | mnt->mnt_namespace = namespace; | 1657 | mnt->mnt_namespace = namespace; |
@@ -1414,11 +1674,12 @@ void __init mnt_init(unsigned long mempages) | |||
1414 | unsigned int nr_hash; | 1674 | unsigned int nr_hash; |
1415 | int i; | 1675 | int i; |
1416 | 1676 | ||
1677 | init_rwsem(&namespace_sem); | ||
1678 | |||
1417 | mnt_cache = kmem_cache_create("mnt_cache", sizeof(struct vfsmount), | 1679 | mnt_cache = kmem_cache_create("mnt_cache", sizeof(struct vfsmount), |
1418 | 0, SLAB_HWCACHE_ALIGN|SLAB_PANIC, NULL, NULL); | 1680 | 0, SLAB_HWCACHE_ALIGN | SLAB_PANIC, NULL, NULL); |
1419 | 1681 | ||
1420 | mount_hashtable = (struct list_head *) | 1682 | mount_hashtable = (struct list_head *)__get_free_page(GFP_ATOMIC); |
1421 | __get_free_page(GFP_ATOMIC); | ||
1422 | 1683 | ||
1423 | if (!mount_hashtable) | 1684 | if (!mount_hashtable) |
1424 | panic("Failed to allocate mount hash table\n"); | 1685 | panic("Failed to allocate mount hash table\n"); |
@@ -1440,7 +1701,7 @@ void __init mnt_init(unsigned long mempages) | |||
1440 | * from the number of bits we can fit. | 1701 | * from the number of bits we can fit. |
1441 | */ | 1702 | */ |
1442 | nr_hash = 1UL << hash_bits; | 1703 | nr_hash = 1UL << hash_bits; |
1443 | hash_mask = nr_hash-1; | 1704 | hash_mask = nr_hash - 1; |
1444 | 1705 | ||
1445 | printk("Mount-cache hash table entries: %d\n", nr_hash); | 1706 | printk("Mount-cache hash table entries: %d\n", nr_hash); |
1446 | 1707 | ||
@@ -1460,12 +1721,14 @@ void __init mnt_init(unsigned long mempages) | |||
1460 | void __put_namespace(struct namespace *namespace) | 1721 | void __put_namespace(struct namespace *namespace) |
1461 | { | 1722 | { |
1462 | struct vfsmount *root = namespace->root; | 1723 | struct vfsmount *root = namespace->root; |
1724 | LIST_HEAD(umount_list); | ||
1463 | namespace->root = NULL; | 1725 | namespace->root = NULL; |
1464 | spin_unlock(&vfsmount_lock); | 1726 | spin_unlock(&vfsmount_lock); |
1465 | down_write(&namespace->sem); | 1727 | down_write(&namespace_sem); |
1466 | spin_lock(&vfsmount_lock); | 1728 | spin_lock(&vfsmount_lock); |
1467 | umount_tree(root); | 1729 | umount_tree(root, 0, &umount_list); |
1468 | spin_unlock(&vfsmount_lock); | 1730 | spin_unlock(&vfsmount_lock); |
1469 | up_write(&namespace->sem); | 1731 | up_write(&namespace_sem); |
1732 | release_mounts(&umount_list); | ||
1470 | kfree(namespace); | 1733 | kfree(namespace); |
1471 | } | 1734 | } |
diff --git a/fs/ncpfs/ioctl.c b/fs/ncpfs/ioctl.c index 88df79356a1f..fd3efdca5ae3 100644 --- a/fs/ncpfs/ioctl.c +++ b/fs/ncpfs/ioctl.c | |||
@@ -30,11 +30,13 @@ | |||
30 | #define NCP_PACKET_SIZE_INTERNAL 65536 | 30 | #define NCP_PACKET_SIZE_INTERNAL 65536 |
31 | 31 | ||
32 | static int | 32 | static int |
33 | ncp_get_fs_info(struct ncp_server* server, struct inode* inode, struct ncp_fs_info __user *arg) | 33 | ncp_get_fs_info(struct ncp_server * server, struct file *file, |
34 | struct ncp_fs_info __user *arg) | ||
34 | { | 35 | { |
36 | struct inode *inode = file->f_dentry->d_inode; | ||
35 | struct ncp_fs_info info; | 37 | struct ncp_fs_info info; |
36 | 38 | ||
37 | if ((permission(inode, MAY_WRITE, NULL) != 0) | 39 | if ((file_permission(file, MAY_WRITE) != 0) |
38 | && (current->uid != server->m.mounted_uid)) { | 40 | && (current->uid != server->m.mounted_uid)) { |
39 | return -EACCES; | 41 | return -EACCES; |
40 | } | 42 | } |
@@ -58,11 +60,13 @@ ncp_get_fs_info(struct ncp_server* server, struct inode* inode, struct ncp_fs_in | |||
58 | } | 60 | } |
59 | 61 | ||
60 | static int | 62 | static int |
61 | ncp_get_fs_info_v2(struct ncp_server* server, struct inode* inode, struct ncp_fs_info_v2 __user * arg) | 63 | ncp_get_fs_info_v2(struct ncp_server * server, struct file *file, |
64 | struct ncp_fs_info_v2 __user * arg) | ||
62 | { | 65 | { |
66 | struct inode *inode = file->f_dentry->d_inode; | ||
63 | struct ncp_fs_info_v2 info2; | 67 | struct ncp_fs_info_v2 info2; |
64 | 68 | ||
65 | if ((permission(inode, MAY_WRITE, NULL) != 0) | 69 | if ((file_permission(file, MAY_WRITE) != 0) |
66 | && (current->uid != server->m.mounted_uid)) { | 70 | && (current->uid != server->m.mounted_uid)) { |
67 | return -EACCES; | 71 | return -EACCES; |
68 | } | 72 | } |
@@ -190,7 +194,7 @@ int ncp_ioctl(struct inode *inode, struct file *filp, | |||
190 | switch (cmd) { | 194 | switch (cmd) { |
191 | case NCP_IOC_NCPREQUEST: | 195 | case NCP_IOC_NCPREQUEST: |
192 | 196 | ||
193 | if ((permission(inode, MAY_WRITE, NULL) != 0) | 197 | if ((file_permission(filp, MAY_WRITE) != 0) |
194 | && (current->uid != server->m.mounted_uid)) { | 198 | && (current->uid != server->m.mounted_uid)) { |
195 | return -EACCES; | 199 | return -EACCES; |
196 | } | 200 | } |
@@ -245,16 +249,16 @@ int ncp_ioctl(struct inode *inode, struct file *filp, | |||
245 | return ncp_conn_logged_in(inode->i_sb); | 249 | return ncp_conn_logged_in(inode->i_sb); |
246 | 250 | ||
247 | case NCP_IOC_GET_FS_INFO: | 251 | case NCP_IOC_GET_FS_INFO: |
248 | return ncp_get_fs_info(server, inode, argp); | 252 | return ncp_get_fs_info(server, filp, argp); |
249 | 253 | ||
250 | case NCP_IOC_GET_FS_INFO_V2: | 254 | case NCP_IOC_GET_FS_INFO_V2: |
251 | return ncp_get_fs_info_v2(server, inode, argp); | 255 | return ncp_get_fs_info_v2(server, filp, argp); |
252 | 256 | ||
253 | case NCP_IOC_GETMOUNTUID2: | 257 | case NCP_IOC_GETMOUNTUID2: |
254 | { | 258 | { |
255 | unsigned long tmp = server->m.mounted_uid; | 259 | unsigned long tmp = server->m.mounted_uid; |
256 | 260 | ||
257 | if ( (permission(inode, MAY_READ, NULL) != 0) | 261 | if ((file_permission(filp, MAY_READ) != 0) |
258 | && (current->uid != server->m.mounted_uid)) | 262 | && (current->uid != server->m.mounted_uid)) |
259 | { | 263 | { |
260 | return -EACCES; | 264 | return -EACCES; |
@@ -268,7 +272,7 @@ int ncp_ioctl(struct inode *inode, struct file *filp, | |||
268 | { | 272 | { |
269 | struct ncp_setroot_ioctl sr; | 273 | struct ncp_setroot_ioctl sr; |
270 | 274 | ||
271 | if ( (permission(inode, MAY_READ, NULL) != 0) | 275 | if ((file_permission(filp, MAY_READ) != 0) |
272 | && (current->uid != server->m.mounted_uid)) | 276 | && (current->uid != server->m.mounted_uid)) |
273 | { | 277 | { |
274 | return -EACCES; | 278 | return -EACCES; |
@@ -343,7 +347,7 @@ int ncp_ioctl(struct inode *inode, struct file *filp, | |||
343 | 347 | ||
344 | #ifdef CONFIG_NCPFS_PACKET_SIGNING | 348 | #ifdef CONFIG_NCPFS_PACKET_SIGNING |
345 | case NCP_IOC_SIGN_INIT: | 349 | case NCP_IOC_SIGN_INIT: |
346 | if ((permission(inode, MAY_WRITE, NULL) != 0) | 350 | if ((file_permission(filp, MAY_WRITE) != 0) |
347 | && (current->uid != server->m.mounted_uid)) | 351 | && (current->uid != server->m.mounted_uid)) |
348 | { | 352 | { |
349 | return -EACCES; | 353 | return -EACCES; |
@@ -366,7 +370,7 @@ int ncp_ioctl(struct inode *inode, struct file *filp, | |||
366 | return 0; | 370 | return 0; |
367 | 371 | ||
368 | case NCP_IOC_SIGN_WANTED: | 372 | case NCP_IOC_SIGN_WANTED: |
369 | if ( (permission(inode, MAY_READ, NULL) != 0) | 373 | if ((file_permission(filp, MAY_READ) != 0) |
370 | && (current->uid != server->m.mounted_uid)) | 374 | && (current->uid != server->m.mounted_uid)) |
371 | { | 375 | { |
372 | return -EACCES; | 376 | return -EACCES; |
@@ -379,7 +383,7 @@ int ncp_ioctl(struct inode *inode, struct file *filp, | |||
379 | { | 383 | { |
380 | int newstate; | 384 | int newstate; |
381 | 385 | ||
382 | if ( (permission(inode, MAY_WRITE, NULL) != 0) | 386 | if ((file_permission(filp, MAY_WRITE) != 0) |
383 | && (current->uid != server->m.mounted_uid)) | 387 | && (current->uid != server->m.mounted_uid)) |
384 | { | 388 | { |
385 | return -EACCES; | 389 | return -EACCES; |
@@ -400,7 +404,7 @@ int ncp_ioctl(struct inode *inode, struct file *filp, | |||
400 | 404 | ||
401 | #ifdef CONFIG_NCPFS_IOCTL_LOCKING | 405 | #ifdef CONFIG_NCPFS_IOCTL_LOCKING |
402 | case NCP_IOC_LOCKUNLOCK: | 406 | case NCP_IOC_LOCKUNLOCK: |
403 | if ( (permission(inode, MAY_WRITE, NULL) != 0) | 407 | if ((file_permission(filp, MAY_WRITE) != 0) |
404 | && (current->uid != server->m.mounted_uid)) | 408 | && (current->uid != server->m.mounted_uid)) |
405 | { | 409 | { |
406 | return -EACCES; | 410 | return -EACCES; |
@@ -605,7 +609,7 @@ outrel: | |||
605 | #endif /* CONFIG_NCPFS_NLS */ | 609 | #endif /* CONFIG_NCPFS_NLS */ |
606 | 610 | ||
607 | case NCP_IOC_SETDENTRYTTL: | 611 | case NCP_IOC_SETDENTRYTTL: |
608 | if ((permission(inode, MAY_WRITE, NULL) != 0) && | 612 | if ((file_permission(filp, MAY_WRITE) != 0) && |
609 | (current->uid != server->m.mounted_uid)) | 613 | (current->uid != server->m.mounted_uid)) |
610 | return -EACCES; | 614 | return -EACCES; |
611 | { | 615 | { |
@@ -635,7 +639,7 @@ outrel: | |||
635 | so we have this out of switch */ | 639 | so we have this out of switch */ |
636 | if (cmd == NCP_IOC_GETMOUNTUID) { | 640 | if (cmd == NCP_IOC_GETMOUNTUID) { |
637 | __kernel_uid_t uid = 0; | 641 | __kernel_uid_t uid = 0; |
638 | if ((permission(inode, MAY_READ, NULL) != 0) | 642 | if ((file_permission(filp, MAY_READ) != 0) |
639 | && (current->uid != server->m.mounted_uid)) { | 643 | && (current->uid != server->m.mounted_uid)) { |
640 | return -EACCES; | 644 | return -EACCES; |
641 | } | 645 | } |
diff --git a/fs/nfs/delegation.c b/fs/nfs/delegation.c index 44135af9894c..618a327027b3 100644 --- a/fs/nfs/delegation.c +++ b/fs/nfs/delegation.c | |||
@@ -31,11 +31,42 @@ static void nfs_free_delegation(struct nfs_delegation *delegation) | |||
31 | kfree(delegation); | 31 | kfree(delegation); |
32 | } | 32 | } |
33 | 33 | ||
34 | static int nfs_delegation_claim_locks(struct nfs_open_context *ctx, struct nfs4_state *state) | ||
35 | { | ||
36 | struct inode *inode = state->inode; | ||
37 | struct file_lock *fl; | ||
38 | int status; | ||
39 | |||
40 | for (fl = inode->i_flock; fl != 0; fl = fl->fl_next) { | ||
41 | if (!(fl->fl_flags & (FL_POSIX|FL_FLOCK))) | ||
42 | continue; | ||
43 | if ((struct nfs_open_context *)fl->fl_file->private_data != ctx) | ||
44 | continue; | ||
45 | status = nfs4_lock_delegation_recall(state, fl); | ||
46 | if (status >= 0) | ||
47 | continue; | ||
48 | switch (status) { | ||
49 | default: | ||
50 | printk(KERN_ERR "%s: unhandled error %d.\n", | ||
51 | __FUNCTION__, status); | ||
52 | case -NFS4ERR_EXPIRED: | ||
53 | /* kill_proc(fl->fl_pid, SIGLOST, 1); */ | ||
54 | case -NFS4ERR_STALE_CLIENTID: | ||
55 | nfs4_schedule_state_recovery(NFS_SERVER(inode)->nfs4_state); | ||
56 | goto out_err; | ||
57 | } | ||
58 | } | ||
59 | return 0; | ||
60 | out_err: | ||
61 | return status; | ||
62 | } | ||
63 | |||
34 | static void nfs_delegation_claim_opens(struct inode *inode) | 64 | static void nfs_delegation_claim_opens(struct inode *inode) |
35 | { | 65 | { |
36 | struct nfs_inode *nfsi = NFS_I(inode); | 66 | struct nfs_inode *nfsi = NFS_I(inode); |
37 | struct nfs_open_context *ctx; | 67 | struct nfs_open_context *ctx; |
38 | struct nfs4_state *state; | 68 | struct nfs4_state *state; |
69 | int err; | ||
39 | 70 | ||
40 | again: | 71 | again: |
41 | spin_lock(&inode->i_lock); | 72 | spin_lock(&inode->i_lock); |
@@ -47,9 +78,12 @@ again: | |||
47 | continue; | 78 | continue; |
48 | get_nfs_open_context(ctx); | 79 | get_nfs_open_context(ctx); |
49 | spin_unlock(&inode->i_lock); | 80 | spin_unlock(&inode->i_lock); |
50 | if (nfs4_open_delegation_recall(ctx->dentry, state) < 0) | 81 | err = nfs4_open_delegation_recall(ctx->dentry, state); |
51 | return; | 82 | if (err >= 0) |
83 | err = nfs_delegation_claim_locks(ctx, state); | ||
52 | put_nfs_open_context(ctx); | 84 | put_nfs_open_context(ctx); |
85 | if (err != 0) | ||
86 | return; | ||
53 | goto again; | 87 | goto again; |
54 | } | 88 | } |
55 | spin_unlock(&inode->i_lock); | 89 | spin_unlock(&inode->i_lock); |
@@ -115,8 +149,7 @@ int nfs_inode_set_delegation(struct inode *inode, struct rpc_cred *cred, struct | |||
115 | } | 149 | } |
116 | } | 150 | } |
117 | spin_unlock(&clp->cl_lock); | 151 | spin_unlock(&clp->cl_lock); |
118 | if (delegation != NULL) | 152 | kfree(delegation); |
119 | kfree(delegation); | ||
120 | return status; | 153 | return status; |
121 | } | 154 | } |
122 | 155 | ||
diff --git a/fs/nfs/delegation.h b/fs/nfs/delegation.h index 8017846b561f..2fcc30de924b 100644 --- a/fs/nfs/delegation.h +++ b/fs/nfs/delegation.h | |||
@@ -38,6 +38,7 @@ void nfs_delegation_reap_unclaimed(struct nfs4_client *clp); | |||
38 | /* NFSv4 delegation-related procedures */ | 38 | /* NFSv4 delegation-related procedures */ |
39 | int nfs4_proc_delegreturn(struct inode *inode, struct rpc_cred *cred, const nfs4_stateid *stateid); | 39 | int nfs4_proc_delegreturn(struct inode *inode, struct rpc_cred *cred, const nfs4_stateid *stateid); |
40 | int nfs4_open_delegation_recall(struct dentry *dentry, struct nfs4_state *state); | 40 | int nfs4_open_delegation_recall(struct dentry *dentry, struct nfs4_state *state); |
41 | int nfs4_lock_delegation_recall(struct nfs4_state *state, struct file_lock *fl); | ||
41 | 42 | ||
42 | static inline int nfs_have_delegation(struct inode *inode, int flags) | 43 | static inline int nfs_have_delegation(struct inode *inode, int flags) |
43 | { | 44 | { |
diff --git a/fs/nfs/dir.c b/fs/nfs/dir.c index 8272ed3fc707..7370583b61e5 100644 --- a/fs/nfs/dir.c +++ b/fs/nfs/dir.c | |||
@@ -1257,6 +1257,9 @@ dentry->d_parent->d_name.name, dentry->d_name.name); | |||
1257 | sprintf(silly, ".nfs%*.*lx", | 1257 | sprintf(silly, ".nfs%*.*lx", |
1258 | i_inosize, i_inosize, dentry->d_inode->i_ino); | 1258 | i_inosize, i_inosize, dentry->d_inode->i_ino); |
1259 | 1259 | ||
1260 | /* Return delegation in anticipation of the rename */ | ||
1261 | nfs_inode_return_delegation(dentry->d_inode); | ||
1262 | |||
1260 | sdentry = NULL; | 1263 | sdentry = NULL; |
1261 | do { | 1264 | do { |
1262 | char *suffix = silly + slen - countersize; | 1265 | char *suffix = silly + slen - countersize; |
diff --git a/fs/nfs/direct.c b/fs/nfs/direct.c index 6537f2c4ae44..b497c71384e8 100644 --- a/fs/nfs/direct.c +++ b/fs/nfs/direct.c | |||
@@ -655,7 +655,6 @@ nfs_file_direct_read(struct kiocb *iocb, char __user *buf, size_t count, loff_t | |||
655 | struct file *file = iocb->ki_filp; | 655 | struct file *file = iocb->ki_filp; |
656 | struct nfs_open_context *ctx = | 656 | struct nfs_open_context *ctx = |
657 | (struct nfs_open_context *) file->private_data; | 657 | (struct nfs_open_context *) file->private_data; |
658 | struct dentry *dentry = file->f_dentry; | ||
659 | struct address_space *mapping = file->f_mapping; | 658 | struct address_space *mapping = file->f_mapping; |
660 | struct inode *inode = mapping->host; | 659 | struct inode *inode = mapping->host; |
661 | struct iovec iov = { | 660 | struct iovec iov = { |
@@ -664,7 +663,8 @@ nfs_file_direct_read(struct kiocb *iocb, char __user *buf, size_t count, loff_t | |||
664 | }; | 663 | }; |
665 | 664 | ||
666 | dprintk("nfs: direct read(%s/%s, %lu@%lu)\n", | 665 | dprintk("nfs: direct read(%s/%s, %lu@%lu)\n", |
667 | dentry->d_parent->d_name.name, dentry->d_name.name, | 666 | file->f_dentry->d_parent->d_name.name, |
667 | file->f_dentry->d_name.name, | ||
668 | (unsigned long) count, (unsigned long) pos); | 668 | (unsigned long) count, (unsigned long) pos); |
669 | 669 | ||
670 | if (!is_sync_kiocb(iocb)) | 670 | if (!is_sync_kiocb(iocb)) |
@@ -730,7 +730,6 @@ nfs_file_direct_write(struct kiocb *iocb, const char __user *buf, size_t count, | |||
730 | struct file *file = iocb->ki_filp; | 730 | struct file *file = iocb->ki_filp; |
731 | struct nfs_open_context *ctx = | 731 | struct nfs_open_context *ctx = |
732 | (struct nfs_open_context *) file->private_data; | 732 | (struct nfs_open_context *) file->private_data; |
733 | struct dentry *dentry = file->f_dentry; | ||
734 | struct address_space *mapping = file->f_mapping; | 733 | struct address_space *mapping = file->f_mapping; |
735 | struct inode *inode = mapping->host; | 734 | struct inode *inode = mapping->host; |
736 | struct iovec iov = { | 735 | struct iovec iov = { |
@@ -739,8 +738,9 @@ nfs_file_direct_write(struct kiocb *iocb, const char __user *buf, size_t count, | |||
739 | }; | 738 | }; |
740 | 739 | ||
741 | dfprintk(VFS, "nfs: direct write(%s/%s(%ld), %lu@%lu)\n", | 740 | dfprintk(VFS, "nfs: direct write(%s/%s(%ld), %lu@%lu)\n", |
742 | dentry->d_parent->d_name.name, dentry->d_name.name, | 741 | file->f_dentry->d_parent->d_name.name, |
743 | inode->i_ino, (unsigned long) count, (unsigned long) pos); | 742 | file->f_dentry->d_name.name, inode->i_ino, |
743 | (unsigned long) count, (unsigned long) pos); | ||
744 | 744 | ||
745 | if (!is_sync_kiocb(iocb)) | 745 | if (!is_sync_kiocb(iocb)) |
746 | goto out; | 746 | goto out; |
diff --git a/fs/nfs/inode.c b/fs/nfs/inode.c index fc0f12ba89cc..6391d8964214 100644 --- a/fs/nfs/inode.c +++ b/fs/nfs/inode.c | |||
@@ -1009,13 +1009,18 @@ void nfs_file_set_open_context(struct file *filp, struct nfs_open_context *ctx) | |||
1009 | spin_unlock(&inode->i_lock); | 1009 | spin_unlock(&inode->i_lock); |
1010 | } | 1010 | } |
1011 | 1011 | ||
1012 | struct nfs_open_context *nfs_find_open_context(struct inode *inode, int mode) | 1012 | /* |
1013 | * Given an inode, search for an open context with the desired characteristics | ||
1014 | */ | ||
1015 | struct nfs_open_context *nfs_find_open_context(struct inode *inode, struct rpc_cred *cred, int mode) | ||
1013 | { | 1016 | { |
1014 | struct nfs_inode *nfsi = NFS_I(inode); | 1017 | struct nfs_inode *nfsi = NFS_I(inode); |
1015 | struct nfs_open_context *pos, *ctx = NULL; | 1018 | struct nfs_open_context *pos, *ctx = NULL; |
1016 | 1019 | ||
1017 | spin_lock(&inode->i_lock); | 1020 | spin_lock(&inode->i_lock); |
1018 | list_for_each_entry(pos, &nfsi->open_files, list) { | 1021 | list_for_each_entry(pos, &nfsi->open_files, list) { |
1022 | if (cred != NULL && pos->cred != cred) | ||
1023 | continue; | ||
1019 | if ((pos->mode & mode) == mode) { | 1024 | if ((pos->mode & mode) == mode) { |
1020 | ctx = get_nfs_open_context(pos); | 1025 | ctx = get_nfs_open_context(pos); |
1021 | break; | 1026 | break; |
@@ -1683,8 +1688,7 @@ static void nfs_kill_super(struct super_block *s) | |||
1683 | 1688 | ||
1684 | rpciod_down(); /* release rpciod */ | 1689 | rpciod_down(); /* release rpciod */ |
1685 | 1690 | ||
1686 | if (server->hostname != NULL) | 1691 | kfree(server->hostname); |
1687 | kfree(server->hostname); | ||
1688 | kfree(server); | 1692 | kfree(server); |
1689 | } | 1693 | } |
1690 | 1694 | ||
@@ -1903,8 +1907,7 @@ nfs_copy_user_string(char *dst, struct nfs_string *src, int maxlen) | |||
1903 | return ERR_PTR(-ENOMEM); | 1907 | return ERR_PTR(-ENOMEM); |
1904 | } | 1908 | } |
1905 | if (copy_from_user(dst, src->data, maxlen)) { | 1909 | if (copy_from_user(dst, src->data, maxlen)) { |
1906 | if (p != NULL) | 1910 | kfree(p); |
1907 | kfree(p); | ||
1908 | return ERR_PTR(-EFAULT); | 1911 | return ERR_PTR(-EFAULT); |
1909 | } | 1912 | } |
1910 | dst[maxlen] = '\0'; | 1913 | dst[maxlen] = '\0'; |
@@ -1995,10 +1998,8 @@ static struct super_block *nfs4_get_sb(struct file_system_type *fs_type, | |||
1995 | out_err: | 1998 | out_err: |
1996 | s = (struct super_block *)p; | 1999 | s = (struct super_block *)p; |
1997 | out_free: | 2000 | out_free: |
1998 | if (server->mnt_path) | 2001 | kfree(server->mnt_path); |
1999 | kfree(server->mnt_path); | 2002 | kfree(server->hostname); |
2000 | if (server->hostname) | ||
2001 | kfree(server->hostname); | ||
2002 | kfree(server); | 2003 | kfree(server); |
2003 | return s; | 2004 | return s; |
2004 | } | 2005 | } |
@@ -2018,8 +2019,7 @@ static void nfs4_kill_super(struct super_block *sb) | |||
2018 | 2019 | ||
2019 | destroy_nfsv4_state(server); | 2020 | destroy_nfsv4_state(server); |
2020 | 2021 | ||
2021 | if (server->hostname != NULL) | 2022 | kfree(server->hostname); |
2022 | kfree(server->hostname); | ||
2023 | kfree(server); | 2023 | kfree(server); |
2024 | } | 2024 | } |
2025 | 2025 | ||
diff --git a/fs/nfs/nfs4_fs.h b/fs/nfs/nfs4_fs.h index 78a53f5a9f18..b7f262dcb6e3 100644 --- a/fs/nfs/nfs4_fs.h +++ b/fs/nfs/nfs4_fs.h | |||
@@ -214,7 +214,7 @@ extern int nfs4_proc_setclientid(struct nfs4_client *, u32, unsigned short); | |||
214 | extern int nfs4_proc_setclientid_confirm(struct nfs4_client *); | 214 | extern int nfs4_proc_setclientid_confirm(struct nfs4_client *); |
215 | extern int nfs4_proc_async_renew(struct nfs4_client *); | 215 | extern int nfs4_proc_async_renew(struct nfs4_client *); |
216 | extern int nfs4_proc_renew(struct nfs4_client *); | 216 | extern int nfs4_proc_renew(struct nfs4_client *); |
217 | extern int nfs4_do_close(struct inode *inode, struct nfs4_state *state, mode_t mode); | 217 | extern int nfs4_do_close(struct inode *inode, struct nfs4_state *state); |
218 | extern struct dentry *nfs4_atomic_open(struct inode *, struct dentry *, struct nameidata *); | 218 | extern struct dentry *nfs4_atomic_open(struct inode *, struct dentry *, struct nameidata *); |
219 | extern int nfs4_open_revalidate(struct inode *, struct dentry *, int, struct nameidata *); | 219 | extern int nfs4_open_revalidate(struct inode *, struct dentry *, int, struct nameidata *); |
220 | 220 | ||
@@ -247,7 +247,7 @@ extern void nfs4_drop_state_owner(struct nfs4_state_owner *); | |||
247 | extern struct nfs4_state * nfs4_get_open_state(struct inode *, struct nfs4_state_owner *); | 247 | extern struct nfs4_state * nfs4_get_open_state(struct inode *, struct nfs4_state_owner *); |
248 | extern void nfs4_put_open_state(struct nfs4_state *); | 248 | extern void nfs4_put_open_state(struct nfs4_state *); |
249 | extern void nfs4_close_state(struct nfs4_state *, mode_t); | 249 | extern void nfs4_close_state(struct nfs4_state *, mode_t); |
250 | extern struct nfs4_state *nfs4_find_state(struct inode *, struct rpc_cred *, mode_t mode); | 250 | extern void nfs4_state_set_mode_locked(struct nfs4_state *, mode_t); |
251 | extern void nfs4_schedule_state_recovery(struct nfs4_client *); | 251 | extern void nfs4_schedule_state_recovery(struct nfs4_client *); |
252 | extern void nfs4_put_lock_state(struct nfs4_lock_state *lsp); | 252 | extern void nfs4_put_lock_state(struct nfs4_lock_state *lsp); |
253 | extern int nfs4_set_lock_state(struct nfs4_state *state, struct file_lock *fl); | 253 | extern int nfs4_set_lock_state(struct nfs4_state *state, struct file_lock *fl); |
diff --git a/fs/nfs/nfs4proc.c b/fs/nfs/nfs4proc.c index 933e13b383f8..21482b2518f6 100644 --- a/fs/nfs/nfs4proc.c +++ b/fs/nfs/nfs4proc.c | |||
@@ -214,16 +214,15 @@ static void update_open_stateid(struct nfs4_state *state, nfs4_stateid *stateid, | |||
214 | struct inode *inode = state->inode; | 214 | struct inode *inode = state->inode; |
215 | 215 | ||
216 | open_flags &= (FMODE_READ|FMODE_WRITE); | 216 | open_flags &= (FMODE_READ|FMODE_WRITE); |
217 | /* Protect against nfs4_find_state() */ | 217 | /* Protect against nfs4_find_state_byowner() */ |
218 | spin_lock(&state->owner->so_lock); | 218 | spin_lock(&state->owner->so_lock); |
219 | spin_lock(&inode->i_lock); | 219 | spin_lock(&inode->i_lock); |
220 | state->state |= open_flags; | 220 | memcpy(&state->stateid, stateid, sizeof(state->stateid)); |
221 | /* NB! List reordering - see the reclaim code for why. */ | 221 | if ((open_flags & FMODE_WRITE)) |
222 | if ((open_flags & FMODE_WRITE) && 0 == state->nwriters++) | 222 | state->nwriters++; |
223 | list_move(&state->open_states, &state->owner->so_states); | ||
224 | if (open_flags & FMODE_READ) | 223 | if (open_flags & FMODE_READ) |
225 | state->nreaders++; | 224 | state->nreaders++; |
226 | memcpy(&state->stateid, stateid, sizeof(state->stateid)); | 225 | nfs4_state_set_mode_locked(state, state->state | open_flags); |
227 | spin_unlock(&inode->i_lock); | 226 | spin_unlock(&inode->i_lock); |
228 | spin_unlock(&state->owner->so_lock); | 227 | spin_unlock(&state->owner->so_lock); |
229 | } | 228 | } |
@@ -896,7 +895,6 @@ static void nfs4_close_done(struct rpc_task *task) | |||
896 | break; | 895 | break; |
897 | case -NFS4ERR_STALE_STATEID: | 896 | case -NFS4ERR_STALE_STATEID: |
898 | case -NFS4ERR_EXPIRED: | 897 | case -NFS4ERR_EXPIRED: |
899 | state->state = calldata->arg.open_flags; | ||
900 | nfs4_schedule_state_recovery(server->nfs4_state); | 898 | nfs4_schedule_state_recovery(server->nfs4_state); |
901 | break; | 899 | break; |
902 | default: | 900 | default: |
@@ -906,7 +904,6 @@ static void nfs4_close_done(struct rpc_task *task) | |||
906 | } | 904 | } |
907 | } | 905 | } |
908 | nfs_refresh_inode(calldata->inode, calldata->res.fattr); | 906 | nfs_refresh_inode(calldata->inode, calldata->res.fattr); |
909 | state->state = calldata->arg.open_flags; | ||
910 | nfs4_free_closedata(calldata); | 907 | nfs4_free_closedata(calldata); |
911 | } | 908 | } |
912 | 909 | ||
@@ -920,24 +917,26 @@ static void nfs4_close_begin(struct rpc_task *task) | |||
920 | .rpc_resp = &calldata->res, | 917 | .rpc_resp = &calldata->res, |
921 | .rpc_cred = state->owner->so_cred, | 918 | .rpc_cred = state->owner->so_cred, |
922 | }; | 919 | }; |
923 | int mode = 0; | 920 | int mode = 0, old_mode; |
924 | int status; | 921 | int status; |
925 | 922 | ||
926 | status = nfs_wait_on_sequence(calldata->arg.seqid, task); | 923 | status = nfs_wait_on_sequence(calldata->arg.seqid, task); |
927 | if (status != 0) | 924 | if (status != 0) |
928 | return; | 925 | return; |
929 | /* Don't reorder reads */ | ||
930 | smp_rmb(); | ||
931 | /* Recalculate the new open mode in case someone reopened the file | 926 | /* Recalculate the new open mode in case someone reopened the file |
932 | * while we were waiting in line to be scheduled. | 927 | * while we were waiting in line to be scheduled. |
933 | */ | 928 | */ |
934 | if (state->nreaders != 0) | 929 | spin_lock(&state->owner->so_lock); |
935 | mode |= FMODE_READ; | 930 | spin_lock(&calldata->inode->i_lock); |
936 | if (state->nwriters != 0) | 931 | mode = old_mode = state->state; |
937 | mode |= FMODE_WRITE; | 932 | if (state->nreaders == 0) |
938 | if (test_bit(NFS_DELEGATED_STATE, &state->flags)) | 933 | mode &= ~FMODE_READ; |
939 | state->state = mode; | 934 | if (state->nwriters == 0) |
940 | if (mode == state->state) { | 935 | mode &= ~FMODE_WRITE; |
936 | nfs4_state_set_mode_locked(state, mode); | ||
937 | spin_unlock(&calldata->inode->i_lock); | ||
938 | spin_unlock(&state->owner->so_lock); | ||
939 | if (mode == old_mode || test_bit(NFS_DELEGATED_STATE, &state->flags)) { | ||
941 | nfs4_free_closedata(calldata); | 940 | nfs4_free_closedata(calldata); |
942 | task->tk_exit = NULL; | 941 | task->tk_exit = NULL; |
943 | rpc_exit(task, 0); | 942 | rpc_exit(task, 0); |
@@ -961,7 +960,7 @@ static void nfs4_close_begin(struct rpc_task *task) | |||
961 | * | 960 | * |
962 | * NOTE: Caller must be holding the sp->so_owner semaphore! | 961 | * NOTE: Caller must be holding the sp->so_owner semaphore! |
963 | */ | 962 | */ |
964 | int nfs4_do_close(struct inode *inode, struct nfs4_state *state, mode_t mode) | 963 | int nfs4_do_close(struct inode *inode, struct nfs4_state *state) |
965 | { | 964 | { |
966 | struct nfs_server *server = NFS_SERVER(inode); | 965 | struct nfs_server *server = NFS_SERVER(inode); |
967 | struct nfs4_closedata *calldata; | 966 | struct nfs4_closedata *calldata; |
@@ -1275,7 +1274,8 @@ nfs4_proc_setattr(struct dentry *dentry, struct nfs_fattr *fattr, | |||
1275 | { | 1274 | { |
1276 | struct rpc_cred *cred; | 1275 | struct rpc_cred *cred; |
1277 | struct inode *inode = dentry->d_inode; | 1276 | struct inode *inode = dentry->d_inode; |
1278 | struct nfs4_state *state; | 1277 | struct nfs_open_context *ctx; |
1278 | struct nfs4_state *state = NULL; | ||
1279 | int status; | 1279 | int status; |
1280 | 1280 | ||
1281 | nfs_fattr_init(fattr); | 1281 | nfs_fattr_init(fattr); |
@@ -1283,22 +1283,18 @@ nfs4_proc_setattr(struct dentry *dentry, struct nfs_fattr *fattr, | |||
1283 | cred = rpcauth_lookupcred(NFS_SERVER(inode)->client->cl_auth, 0); | 1283 | cred = rpcauth_lookupcred(NFS_SERVER(inode)->client->cl_auth, 0); |
1284 | if (IS_ERR(cred)) | 1284 | if (IS_ERR(cred)) |
1285 | return PTR_ERR(cred); | 1285 | return PTR_ERR(cred); |
1286 | /* Search for an existing WRITE delegation first */ | 1286 | |
1287 | state = nfs4_open_delegated(inode, FMODE_WRITE, cred); | 1287 | /* Search for an existing open(O_WRITE) file */ |
1288 | if (!IS_ERR(state)) { | 1288 | ctx = nfs_find_open_context(inode, cred, FMODE_WRITE); |
1289 | /* NB: nfs4_open_delegated() bumps the inode->i_count */ | 1289 | if (ctx != NULL) |
1290 | iput(inode); | 1290 | state = ctx->state; |
1291 | } else { | ||
1292 | /* Search for an existing open(O_WRITE) stateid */ | ||
1293 | state = nfs4_find_state(inode, cred, FMODE_WRITE); | ||
1294 | } | ||
1295 | 1291 | ||
1296 | status = nfs4_do_setattr(NFS_SERVER(inode), fattr, | 1292 | status = nfs4_do_setattr(NFS_SERVER(inode), fattr, |
1297 | NFS_FH(inode), sattr, state); | 1293 | NFS_FH(inode), sattr, state); |
1298 | if (status == 0) | 1294 | if (status == 0) |
1299 | nfs_setattr_update_inode(inode, sattr); | 1295 | nfs_setattr_update_inode(inode, sattr); |
1300 | if (state != NULL) | 1296 | if (ctx != NULL) |
1301 | nfs4_close_state(state, FMODE_WRITE); | 1297 | put_nfs_open_context(ctx); |
1302 | put_rpccred(cred); | 1298 | put_rpccred(cred); |
1303 | return status; | 1299 | return status; |
1304 | } | 1300 | } |
@@ -2599,12 +2595,10 @@ int nfs4_handle_exception(const struct nfs_server *server, int errorcode, struct | |||
2599 | case -NFS4ERR_GRACE: | 2595 | case -NFS4ERR_GRACE: |
2600 | case -NFS4ERR_DELAY: | 2596 | case -NFS4ERR_DELAY: |
2601 | ret = nfs4_delay(server->client, &exception->timeout); | 2597 | ret = nfs4_delay(server->client, &exception->timeout); |
2602 | if (ret == 0) | 2598 | if (ret != 0) |
2603 | exception->retry = 1; | 2599 | break; |
2604 | break; | ||
2605 | case -NFS4ERR_OLD_STATEID: | 2600 | case -NFS4ERR_OLD_STATEID: |
2606 | if (ret == 0) | 2601 | exception->retry = 1; |
2607 | exception->retry = 1; | ||
2608 | } | 2602 | } |
2609 | /* We failed to handle the error */ | 2603 | /* We failed to handle the error */ |
2610 | return nfs4_map_errors(ret); | 2604 | return nfs4_map_errors(ret); |
@@ -2924,6 +2918,10 @@ static int nfs4_proc_unlck(struct nfs4_state *state, int cmd, struct file_lock * | |||
2924 | struct nfs4_lock_state *lsp; | 2918 | struct nfs4_lock_state *lsp; |
2925 | int status; | 2919 | int status; |
2926 | 2920 | ||
2921 | /* Is this a delegated lock? */ | ||
2922 | if (test_bit(NFS_DELEGATED_STATE, &state->flags)) | ||
2923 | return do_vfs_lock(request->fl_file, request); | ||
2924 | |||
2927 | status = nfs4_set_lock_state(state, request); | 2925 | status = nfs4_set_lock_state(state, request); |
2928 | if (status != 0) | 2926 | if (status != 0) |
2929 | return status; | 2927 | return status; |
@@ -3038,6 +3036,9 @@ static int nfs4_lock_reclaim(struct nfs4_state *state, struct file_lock *request | |||
3038 | struct nfs4_exception exception = { }; | 3036 | struct nfs4_exception exception = { }; |
3039 | int err; | 3037 | int err; |
3040 | 3038 | ||
3039 | /* Cache the lock if possible... */ | ||
3040 | if (test_bit(NFS_DELEGATED_STATE, &state->flags)) | ||
3041 | return 0; | ||
3041 | do { | 3042 | do { |
3042 | err = _nfs4_do_setlk(state, F_SETLK, request, 1); | 3043 | err = _nfs4_do_setlk(state, F_SETLK, request, 1); |
3043 | if (err != -NFS4ERR_DELAY) | 3044 | if (err != -NFS4ERR_DELAY) |
@@ -3053,6 +3054,9 @@ static int nfs4_lock_expired(struct nfs4_state *state, struct file_lock *request | |||
3053 | struct nfs4_exception exception = { }; | 3054 | struct nfs4_exception exception = { }; |
3054 | int err; | 3055 | int err; |
3055 | 3056 | ||
3057 | err = nfs4_set_lock_state(state, request); | ||
3058 | if (err != 0) | ||
3059 | return err; | ||
3056 | do { | 3060 | do { |
3057 | err = _nfs4_do_setlk(state, F_SETLK, request, 0); | 3061 | err = _nfs4_do_setlk(state, F_SETLK, request, 0); |
3058 | if (err != -NFS4ERR_DELAY) | 3062 | if (err != -NFS4ERR_DELAY) |
@@ -3068,15 +3072,25 @@ static int _nfs4_proc_setlk(struct nfs4_state *state, int cmd, struct file_lock | |||
3068 | int status; | 3072 | int status; |
3069 | 3073 | ||
3070 | down_read(&clp->cl_sem); | 3074 | down_read(&clp->cl_sem); |
3071 | status = nfs4_set_lock_state(state, request); | 3075 | /* Is this a delegated open? */ |
3072 | if (status == 0) | 3076 | if (test_bit(NFS_DELEGATED_STATE, &state->flags)) { |
3073 | status = _nfs4_do_setlk(state, cmd, request, 0); | 3077 | /* Yes: cache locks! */ |
3074 | if (status == 0) { | 3078 | status = do_vfs_lock(request->fl_file, request); |
3075 | /* Note: we always want to sleep here! */ | 3079 | /* ...but avoid races with delegation recall... */ |
3076 | request->fl_flags |= FL_SLEEP; | 3080 | if (status < 0 || test_bit(NFS_DELEGATED_STATE, &state->flags)) |
3077 | if (do_vfs_lock(request->fl_file, request) < 0) | 3081 | goto out; |
3078 | printk(KERN_WARNING "%s: VFS is out of sync with lock manager!\n", __FUNCTION__); | ||
3079 | } | 3082 | } |
3083 | status = nfs4_set_lock_state(state, request); | ||
3084 | if (status != 0) | ||
3085 | goto out; | ||
3086 | status = _nfs4_do_setlk(state, cmd, request, 0); | ||
3087 | if (status != 0) | ||
3088 | goto out; | ||
3089 | /* Note: we always want to sleep here! */ | ||
3090 | request->fl_flags |= FL_SLEEP; | ||
3091 | if (do_vfs_lock(request->fl_file, request) < 0) | ||
3092 | printk(KERN_WARNING "%s: VFS is out of sync with lock manager!\n", __FUNCTION__); | ||
3093 | out: | ||
3080 | up_read(&clp->cl_sem); | 3094 | up_read(&clp->cl_sem); |
3081 | return status; | 3095 | return status; |
3082 | } | 3096 | } |
@@ -3130,6 +3144,24 @@ nfs4_proc_lock(struct file *filp, int cmd, struct file_lock *request) | |||
3130 | return status; | 3144 | return status; |
3131 | } | 3145 | } |
3132 | 3146 | ||
3147 | int nfs4_lock_delegation_recall(struct nfs4_state *state, struct file_lock *fl) | ||
3148 | { | ||
3149 | struct nfs_server *server = NFS_SERVER(state->inode); | ||
3150 | struct nfs4_exception exception = { }; | ||
3151 | int err; | ||
3152 | |||
3153 | err = nfs4_set_lock_state(state, fl); | ||
3154 | if (err != 0) | ||
3155 | goto out; | ||
3156 | do { | ||
3157 | err = _nfs4_do_setlk(state, F_SETLK, fl, 0); | ||
3158 | if (err != -NFS4ERR_DELAY) | ||
3159 | break; | ||
3160 | err = nfs4_handle_exception(server, err, &exception); | ||
3161 | } while (exception.retry); | ||
3162 | out: | ||
3163 | return err; | ||
3164 | } | ||
3133 | 3165 | ||
3134 | #define XATTR_NAME_NFSV4_ACL "system.nfs4_acl" | 3166 | #define XATTR_NAME_NFSV4_ACL "system.nfs4_acl" |
3135 | 3167 | ||
diff --git a/fs/nfs/nfs4state.c b/fs/nfs/nfs4state.c index 2d5a6a2b9dec..0675f3215e0a 100644 --- a/fs/nfs/nfs4state.c +++ b/fs/nfs/nfs4state.c | |||
@@ -69,10 +69,8 @@ init_nfsv4_state(struct nfs_server *server) | |||
69 | void | 69 | void |
70 | destroy_nfsv4_state(struct nfs_server *server) | 70 | destroy_nfsv4_state(struct nfs_server *server) |
71 | { | 71 | { |
72 | if (server->mnt_path) { | 72 | kfree(server->mnt_path); |
73 | kfree(server->mnt_path); | 73 | server->mnt_path = NULL; |
74 | server->mnt_path = NULL; | ||
75 | } | ||
76 | if (server->nfs4_state) { | 74 | if (server->nfs4_state) { |
77 | nfs4_put_client(server->nfs4_state); | 75 | nfs4_put_client(server->nfs4_state); |
78 | server->nfs4_state = NULL; | 76 | server->nfs4_state = NULL; |
@@ -311,8 +309,7 @@ struct nfs4_state_owner *nfs4_get_state_owner(struct nfs_server *server, struct | |||
311 | new = NULL; | 309 | new = NULL; |
312 | } | 310 | } |
313 | spin_unlock(&clp->cl_lock); | 311 | spin_unlock(&clp->cl_lock); |
314 | if (new) | 312 | kfree(new); |
315 | kfree(new); | ||
316 | if (sp != NULL) | 313 | if (sp != NULL) |
317 | return sp; | 314 | return sp; |
318 | put_rpccred(cred); | 315 | put_rpccred(cred); |
@@ -366,30 +363,21 @@ nfs4_alloc_open_state(void) | |||
366 | return state; | 363 | return state; |
367 | } | 364 | } |
368 | 365 | ||
369 | static struct nfs4_state * | 366 | void |
370 | __nfs4_find_state(struct inode *inode, struct rpc_cred *cred, mode_t mode) | 367 | nfs4_state_set_mode_locked(struct nfs4_state *state, mode_t mode) |
371 | { | 368 | { |
372 | struct nfs_inode *nfsi = NFS_I(inode); | 369 | if (state->state == mode) |
373 | struct nfs4_state *state; | 370 | return; |
374 | 371 | /* NB! List reordering - see the reclaim code for why. */ | |
375 | mode &= (FMODE_READ|FMODE_WRITE); | 372 | if ((mode & FMODE_WRITE) != (state->state & FMODE_WRITE)) { |
376 | list_for_each_entry(state, &nfsi->open_states, inode_states) { | ||
377 | if (state->owner->so_cred != cred) | ||
378 | continue; | ||
379 | if ((mode & FMODE_READ) != 0 && state->nreaders == 0) | ||
380 | continue; | ||
381 | if ((mode & FMODE_WRITE) != 0 && state->nwriters == 0) | ||
382 | continue; | ||
383 | if ((state->state & mode) != mode) | ||
384 | continue; | ||
385 | atomic_inc(&state->count); | ||
386 | if (mode & FMODE_READ) | ||
387 | state->nreaders++; | ||
388 | if (mode & FMODE_WRITE) | 373 | if (mode & FMODE_WRITE) |
389 | state->nwriters++; | 374 | list_move(&state->open_states, &state->owner->so_states); |
390 | return state; | 375 | else |
376 | list_move_tail(&state->open_states, &state->owner->so_states); | ||
391 | } | 377 | } |
392 | return NULL; | 378 | if (mode == 0) |
379 | list_del_init(&state->inode_states); | ||
380 | state->state = mode; | ||
393 | } | 381 | } |
394 | 382 | ||
395 | static struct nfs4_state * | 383 | static struct nfs4_state * |
@@ -400,7 +388,7 @@ __nfs4_find_state_byowner(struct inode *inode, struct nfs4_state_owner *owner) | |||
400 | 388 | ||
401 | list_for_each_entry(state, &nfsi->open_states, inode_states) { | 389 | list_for_each_entry(state, &nfsi->open_states, inode_states) { |
402 | /* Is this in the process of being freed? */ | 390 | /* Is this in the process of being freed? */ |
403 | if (state->nreaders == 0 && state->nwriters == 0) | 391 | if (state->state == 0) |
404 | continue; | 392 | continue; |
405 | if (state->owner == owner) { | 393 | if (state->owner == owner) { |
406 | atomic_inc(&state->count); | 394 | atomic_inc(&state->count); |
@@ -410,17 +398,6 @@ __nfs4_find_state_byowner(struct inode *inode, struct nfs4_state_owner *owner) | |||
410 | return NULL; | 398 | return NULL; |
411 | } | 399 | } |
412 | 400 | ||
413 | struct nfs4_state * | ||
414 | nfs4_find_state(struct inode *inode, struct rpc_cred *cred, mode_t mode) | ||
415 | { | ||
416 | struct nfs4_state *state; | ||
417 | |||
418 | spin_lock(&inode->i_lock); | ||
419 | state = __nfs4_find_state(inode, cred, mode); | ||
420 | spin_unlock(&inode->i_lock); | ||
421 | return state; | ||
422 | } | ||
423 | |||
424 | static void | 401 | static void |
425 | nfs4_free_open_state(struct nfs4_state *state) | 402 | nfs4_free_open_state(struct nfs4_state *state) |
426 | { | 403 | { |
@@ -481,7 +458,6 @@ void nfs4_put_open_state(struct nfs4_state *state) | |||
481 | spin_unlock(&inode->i_lock); | 458 | spin_unlock(&inode->i_lock); |
482 | spin_unlock(&owner->so_lock); | 459 | spin_unlock(&owner->so_lock); |
483 | iput(inode); | 460 | iput(inode); |
484 | BUG_ON (state->state != 0); | ||
485 | nfs4_free_open_state(state); | 461 | nfs4_free_open_state(state); |
486 | nfs4_put_state_owner(owner); | 462 | nfs4_put_state_owner(owner); |
487 | } | 463 | } |
@@ -493,7 +469,7 @@ void nfs4_close_state(struct nfs4_state *state, mode_t mode) | |||
493 | { | 469 | { |
494 | struct inode *inode = state->inode; | 470 | struct inode *inode = state->inode; |
495 | struct nfs4_state_owner *owner = state->owner; | 471 | struct nfs4_state_owner *owner = state->owner; |
496 | int newstate; | 472 | int oldstate, newstate = 0; |
497 | 473 | ||
498 | atomic_inc(&owner->so_count); | 474 | atomic_inc(&owner->so_count); |
499 | /* Protect against nfs4_find_state() */ | 475 | /* Protect against nfs4_find_state() */ |
@@ -503,30 +479,20 @@ void nfs4_close_state(struct nfs4_state *state, mode_t mode) | |||
503 | state->nreaders--; | 479 | state->nreaders--; |
504 | if (mode & FMODE_WRITE) | 480 | if (mode & FMODE_WRITE) |
505 | state->nwriters--; | 481 | state->nwriters--; |
506 | if (state->nwriters == 0) { | 482 | oldstate = newstate = state->state; |
507 | if (state->nreaders == 0) | 483 | if (state->nreaders == 0) |
508 | list_del_init(&state->inode_states); | 484 | newstate &= ~FMODE_READ; |
509 | /* See reclaim code */ | 485 | if (state->nwriters == 0) |
510 | list_move_tail(&state->open_states, &owner->so_states); | 486 | newstate &= ~FMODE_WRITE; |
487 | if (test_bit(NFS_DELEGATED_STATE, &state->flags)) { | ||
488 | nfs4_state_set_mode_locked(state, newstate); | ||
489 | oldstate = newstate; | ||
511 | } | 490 | } |
512 | spin_unlock(&inode->i_lock); | 491 | spin_unlock(&inode->i_lock); |
513 | spin_unlock(&owner->so_lock); | 492 | spin_unlock(&owner->so_lock); |
514 | newstate = 0; | 493 | |
515 | if (state->state != 0) { | 494 | if (oldstate != newstate && nfs4_do_close(inode, state) == 0) |
516 | if (state->nreaders) | 495 | return; |
517 | newstate |= FMODE_READ; | ||
518 | if (state->nwriters) | ||
519 | newstate |= FMODE_WRITE; | ||
520 | if (state->state == newstate) | ||
521 | goto out; | ||
522 | if (test_bit(NFS_DELEGATED_STATE, &state->flags)) { | ||
523 | state->state = newstate; | ||
524 | goto out; | ||
525 | } | ||
526 | if (nfs4_do_close(inode, state, newstate) == 0) | ||
527 | return; | ||
528 | } | ||
529 | out: | ||
530 | nfs4_put_open_state(state); | 496 | nfs4_put_open_state(state); |
531 | nfs4_put_state_owner(owner); | 497 | nfs4_put_state_owner(owner); |
532 | } | 498 | } |
@@ -815,7 +781,7 @@ static int nfs4_reclaim_locks(struct nfs4_state_recovery_ops *ops, struct nfs4_s | |||
815 | int status = 0; | 781 | int status = 0; |
816 | 782 | ||
817 | for (fl = inode->i_flock; fl != 0; fl = fl->fl_next) { | 783 | for (fl = inode->i_flock; fl != 0; fl = fl->fl_next) { |
818 | if (!(fl->fl_flags & FL_POSIX)) | 784 | if (!(fl->fl_flags & (FL_POSIX|FL_FLOCK))) |
819 | continue; | 785 | continue; |
820 | if (((struct nfs_open_context *)fl->fl_file->private_data)->state != state) | 786 | if (((struct nfs_open_context *)fl->fl_file->private_data)->state != state) |
821 | continue; | 787 | continue; |
@@ -830,7 +796,7 @@ static int nfs4_reclaim_locks(struct nfs4_state_recovery_ops *ops, struct nfs4_s | |||
830 | case -NFS4ERR_NO_GRACE: | 796 | case -NFS4ERR_NO_GRACE: |
831 | case -NFS4ERR_RECLAIM_BAD: | 797 | case -NFS4ERR_RECLAIM_BAD: |
832 | case -NFS4ERR_RECLAIM_CONFLICT: | 798 | case -NFS4ERR_RECLAIM_CONFLICT: |
833 | /* kill_proc(fl->fl_owner, SIGLOST, 1); */ | 799 | /* kill_proc(fl->fl_pid, SIGLOST, 1); */ |
834 | break; | 800 | break; |
835 | case -NFS4ERR_STALE_CLIENTID: | 801 | case -NFS4ERR_STALE_CLIENTID: |
836 | goto out_err; | 802 | goto out_err; |
diff --git a/fs/nfs/read.c b/fs/nfs/read.c index 43b03b19731b..5f20eafba8ec 100644 --- a/fs/nfs/read.c +++ b/fs/nfs/read.c | |||
@@ -507,7 +507,7 @@ int nfs_readpage(struct file *file, struct page *page) | |||
507 | goto out_error; | 507 | goto out_error; |
508 | 508 | ||
509 | if (file == NULL) { | 509 | if (file == NULL) { |
510 | ctx = nfs_find_open_context(inode, FMODE_READ); | 510 | ctx = nfs_find_open_context(inode, NULL, FMODE_READ); |
511 | if (ctx == NULL) | 511 | if (ctx == NULL) |
512 | return -EBADF; | 512 | return -EBADF; |
513 | } else | 513 | } else |
@@ -576,7 +576,7 @@ int nfs_readpages(struct file *filp, struct address_space *mapping, | |||
576 | nr_pages); | 576 | nr_pages); |
577 | 577 | ||
578 | if (filp == NULL) { | 578 | if (filp == NULL) { |
579 | desc.ctx = nfs_find_open_context(inode, FMODE_READ); | 579 | desc.ctx = nfs_find_open_context(inode, NULL, FMODE_READ); |
580 | if (desc.ctx == NULL) | 580 | if (desc.ctx == NULL) |
581 | return -EBADF; | 581 | return -EBADF; |
582 | } else | 582 | } else |
diff --git a/fs/nfs/unlink.c b/fs/nfs/unlink.c index f732541a3332..d639d172d568 100644 --- a/fs/nfs/unlink.c +++ b/fs/nfs/unlink.c | |||
@@ -52,8 +52,7 @@ nfs_put_unlinkdata(struct nfs_unlinkdata *data) | |||
52 | { | 52 | { |
53 | if (--data->count == 0) { | 53 | if (--data->count == 0) { |
54 | nfs_detach_unlinkdata(data); | 54 | nfs_detach_unlinkdata(data); |
55 | if (data->name.name != NULL) | 55 | kfree(data->name.name); |
56 | kfree(data->name.name); | ||
57 | kfree(data); | 56 | kfree(data); |
58 | } | 57 | } |
59 | } | 58 | } |
diff --git a/fs/nfs/write.c b/fs/nfs/write.c index 819a65f5071f..8f71e766cc5d 100644 --- a/fs/nfs/write.c +++ b/fs/nfs/write.c | |||
@@ -294,7 +294,7 @@ int nfs_writepage(struct page *page, struct writeback_control *wbc) | |||
294 | if (page->index >= end_index+1 || !offset) | 294 | if (page->index >= end_index+1 || !offset) |
295 | goto out; | 295 | goto out; |
296 | do_it: | 296 | do_it: |
297 | ctx = nfs_find_open_context(inode, FMODE_WRITE); | 297 | ctx = nfs_find_open_context(inode, NULL, FMODE_WRITE); |
298 | if (ctx == NULL) { | 298 | if (ctx == NULL) { |
299 | err = -EBADF; | 299 | err = -EBADF; |
300 | goto out; | 300 | goto out; |
@@ -734,14 +734,14 @@ int nfs_updatepage(struct file *file, struct page *page, | |||
734 | unsigned int offset, unsigned int count) | 734 | unsigned int offset, unsigned int count) |
735 | { | 735 | { |
736 | struct nfs_open_context *ctx = (struct nfs_open_context *)file->private_data; | 736 | struct nfs_open_context *ctx = (struct nfs_open_context *)file->private_data; |
737 | struct dentry *dentry = file->f_dentry; | ||
738 | struct inode *inode = page->mapping->host; | 737 | struct inode *inode = page->mapping->host; |
739 | struct nfs_page *req; | 738 | struct nfs_page *req; |
740 | int status = 0; | 739 | int status = 0; |
741 | 740 | ||
742 | dprintk("NFS: nfs_updatepage(%s/%s %d@%Ld)\n", | 741 | dprintk("NFS: nfs_updatepage(%s/%s %d@%Ld)\n", |
743 | dentry->d_parent->d_name.name, dentry->d_name.name, | 742 | file->f_dentry->d_parent->d_name.name, |
744 | count, (long long)(page_offset(page) +offset)); | 743 | file->f_dentry->d_name.name, count, |
744 | (long long)(page_offset(page) +offset)); | ||
745 | 745 | ||
746 | if (IS_SYNC(inode)) { | 746 | if (IS_SYNC(inode)) { |
747 | status = nfs_writepage_sync(ctx, inode, page, offset, count, 0); | 747 | status = nfs_writepage_sync(ctx, inode, page, offset, count, 0); |
@@ -850,7 +850,6 @@ static void nfs_write_rpcsetup(struct nfs_page *req, | |||
850 | unsigned int count, unsigned int offset, | 850 | unsigned int count, unsigned int offset, |
851 | int how) | 851 | int how) |
852 | { | 852 | { |
853 | struct rpc_task *task = &data->task; | ||
854 | struct inode *inode; | 853 | struct inode *inode; |
855 | 854 | ||
856 | /* Set up the RPC argument and reply structs | 855 | /* Set up the RPC argument and reply structs |
@@ -881,7 +880,7 @@ static void nfs_write_rpcsetup(struct nfs_page *req, | |||
881 | data->task.tk_release = nfs_writedata_release; | 880 | data->task.tk_release = nfs_writedata_release; |
882 | 881 | ||
883 | dprintk("NFS: %4d initiated write call (req %s/%Ld, %u bytes @ offset %Lu)\n", | 882 | dprintk("NFS: %4d initiated write call (req %s/%Ld, %u bytes @ offset %Lu)\n", |
884 | task->tk_pid, | 883 | data->task.tk_pid, |
885 | inode->i_sb->s_id, | 884 | inode->i_sb->s_id, |
886 | (long long)NFS_FILEID(inode), | 885 | (long long)NFS_FILEID(inode), |
887 | count, | 886 | count, |
@@ -1217,7 +1216,6 @@ static void nfs_commit_release(struct rpc_task *task) | |||
1217 | static void nfs_commit_rpcsetup(struct list_head *head, | 1216 | static void nfs_commit_rpcsetup(struct list_head *head, |
1218 | struct nfs_write_data *data, int how) | 1217 | struct nfs_write_data *data, int how) |
1219 | { | 1218 | { |
1220 | struct rpc_task *task = &data->task; | ||
1221 | struct nfs_page *first; | 1219 | struct nfs_page *first; |
1222 | struct inode *inode; | 1220 | struct inode *inode; |
1223 | 1221 | ||
@@ -1248,7 +1246,7 @@ static void nfs_commit_rpcsetup(struct list_head *head, | |||
1248 | /* Release requests */ | 1246 | /* Release requests */ |
1249 | data->task.tk_release = nfs_commit_release; | 1247 | data->task.tk_release = nfs_commit_release; |
1250 | 1248 | ||
1251 | dprintk("NFS: %4d initiated commit call\n", task->tk_pid); | 1249 | dprintk("NFS: %4d initiated commit call\n", data->task.tk_pid); |
1252 | } | 1250 | } |
1253 | 1251 | ||
1254 | /* | 1252 | /* |
diff --git a/fs/nfsd/export.c b/fs/nfsd/export.c index 057aff745506..417ec02df44f 100644 --- a/fs/nfsd/export.c +++ b/fs/nfsd/export.c | |||
@@ -190,8 +190,7 @@ static int expkey_parse(struct cache_detail *cd, char *mesg, int mlen) | |||
190 | out: | 190 | out: |
191 | if (dom) | 191 | if (dom) |
192 | auth_domain_put(dom); | 192 | auth_domain_put(dom); |
193 | if (buf) | 193 | kfree(buf); |
194 | kfree(buf); | ||
195 | return err; | 194 | return err; |
196 | } | 195 | } |
197 | 196 | ||
@@ -428,8 +427,7 @@ static int svc_export_parse(struct cache_detail *cd, char *mesg, int mlen) | |||
428 | path_release(&nd); | 427 | path_release(&nd); |
429 | if (dom) | 428 | if (dom) |
430 | auth_domain_put(dom); | 429 | auth_domain_put(dom); |
431 | if (buf) | 430 | kfree(buf); |
432 | kfree(buf); | ||
433 | return err; | 431 | return err; |
434 | } | 432 | } |
435 | 433 | ||
diff --git a/fs/nfsd/nfs3xdr.c b/fs/nfsd/nfs3xdr.c index e0e134d6baba..9147b8524d05 100644 --- a/fs/nfsd/nfs3xdr.c +++ b/fs/nfsd/nfs3xdr.c | |||
@@ -366,7 +366,8 @@ nfs3svc_decode_writeargs(struct svc_rqst *rqstp, u32 *p, | |||
366 | len = args->len = ntohl(*p++); | 366 | len = args->len = ntohl(*p++); |
367 | 367 | ||
368 | hdr = (void*)p - rqstp->rq_arg.head[0].iov_base; | 368 | hdr = (void*)p - rqstp->rq_arg.head[0].iov_base; |
369 | if (rqstp->rq_arg.len < len + hdr) | 369 | if (rqstp->rq_arg.len < hdr || |
370 | rqstp->rq_arg.len - hdr < len) | ||
370 | return 0; | 371 | return 0; |
371 | 372 | ||
372 | args->vec[0].iov_base = (void*)p; | 373 | args->vec[0].iov_base = (void*)p; |
diff --git a/fs/nfsd/nfs4xdr.c b/fs/nfsd/nfs4xdr.c index 4c4146350236..dcd673186944 100644 --- a/fs/nfsd/nfs4xdr.c +++ b/fs/nfsd/nfs4xdr.c | |||
@@ -151,8 +151,7 @@ static u32 *read_buf(struct nfsd4_compoundargs *argp, int nbytes) | |||
151 | if (nbytes <= sizeof(argp->tmp)) | 151 | if (nbytes <= sizeof(argp->tmp)) |
152 | p = argp->tmp; | 152 | p = argp->tmp; |
153 | else { | 153 | else { |
154 | if (argp->tmpp) | 154 | kfree(argp->tmpp); |
155 | kfree(argp->tmpp); | ||
156 | p = argp->tmpp = kmalloc(nbytes, GFP_KERNEL); | 155 | p = argp->tmpp = kmalloc(nbytes, GFP_KERNEL); |
157 | if (!p) | 156 | if (!p) |
158 | return NULL; | 157 | return NULL; |
@@ -2476,10 +2475,8 @@ void nfsd4_release_compoundargs(struct nfsd4_compoundargs *args) | |||
2476 | kfree(args->ops); | 2475 | kfree(args->ops); |
2477 | args->ops = args->iops; | 2476 | args->ops = args->iops; |
2478 | } | 2477 | } |
2479 | if (args->tmpp) { | 2478 | kfree(args->tmpp); |
2480 | kfree(args->tmpp); | 2479 | args->tmpp = NULL; |
2481 | args->tmpp = NULL; | ||
2482 | } | ||
2483 | while (args->to_free) { | 2480 | while (args->to_free) { |
2484 | struct tmpbuf *tb = args->to_free; | 2481 | struct tmpbuf *tb = args->to_free; |
2485 | args->to_free = tb->next; | 2482 | args->to_free = tb->next; |
diff --git a/fs/nfsd/nfscache.c b/fs/nfsd/nfscache.c index 119e4d4495b8..d852ebb538e3 100644 --- a/fs/nfsd/nfscache.c +++ b/fs/nfsd/nfscache.c | |||
@@ -93,8 +93,7 @@ nfsd_cache_shutdown(void) | |||
93 | 93 | ||
94 | cache_disabled = 1; | 94 | cache_disabled = 1; |
95 | 95 | ||
96 | if (hash_list) | 96 | kfree (hash_list); |
97 | kfree (hash_list); | ||
98 | hash_list = NULL; | 97 | hash_list = NULL; |
99 | } | 98 | } |
100 | 99 | ||
diff --git a/fs/nfsd/nfsctl.c b/fs/nfsd/nfsctl.c index 841c562991e8..a0871b3efeb7 100644 --- a/fs/nfsd/nfsctl.c +++ b/fs/nfsd/nfsctl.c | |||
@@ -23,6 +23,7 @@ | |||
23 | #include <linux/seq_file.h> | 23 | #include <linux/seq_file.h> |
24 | #include <linux/pagemap.h> | 24 | #include <linux/pagemap.h> |
25 | #include <linux/init.h> | 25 | #include <linux/init.h> |
26 | #include <linux/string.h> | ||
26 | 27 | ||
27 | #include <linux/nfs.h> | 28 | #include <linux/nfs.h> |
28 | #include <linux/nfsd_idmap.h> | 29 | #include <linux/nfsd_idmap.h> |
@@ -35,6 +36,8 @@ | |||
35 | 36 | ||
36 | #include <asm/uaccess.h> | 37 | #include <asm/uaccess.h> |
37 | 38 | ||
39 | unsigned int nfsd_versbits = ~0; | ||
40 | |||
38 | /* | 41 | /* |
39 | * We have a single directory with 9 nodes in it. | 42 | * We have a single directory with 9 nodes in it. |
40 | */ | 43 | */ |
@@ -50,8 +53,15 @@ enum { | |||
50 | NFSD_List, | 53 | NFSD_List, |
51 | NFSD_Fh, | 54 | NFSD_Fh, |
52 | NFSD_Threads, | 55 | NFSD_Threads, |
56 | NFSD_Versions, | ||
57 | /* | ||
58 | * The below MUST come last. Otherwise we leave a hole in nfsd_files[] | ||
59 | * with !CONFIG_NFSD_V4 and simple_fill_super() goes oops | ||
60 | */ | ||
61 | #ifdef CONFIG_NFSD_V4 | ||
53 | NFSD_Leasetime, | 62 | NFSD_Leasetime, |
54 | NFSD_RecoveryDir, | 63 | NFSD_RecoveryDir, |
64 | #endif | ||
55 | }; | 65 | }; |
56 | 66 | ||
57 | /* | 67 | /* |
@@ -66,8 +76,11 @@ static ssize_t write_getfd(struct file *file, char *buf, size_t size); | |||
66 | static ssize_t write_getfs(struct file *file, char *buf, size_t size); | 76 | static ssize_t write_getfs(struct file *file, char *buf, size_t size); |
67 | static ssize_t write_filehandle(struct file *file, char *buf, size_t size); | 77 | static ssize_t write_filehandle(struct file *file, char *buf, size_t size); |
68 | static ssize_t write_threads(struct file *file, char *buf, size_t size); | 78 | static ssize_t write_threads(struct file *file, char *buf, size_t size); |
79 | static ssize_t write_versions(struct file *file, char *buf, size_t size); | ||
80 | #ifdef CONFIG_NFSD_V4 | ||
69 | static ssize_t write_leasetime(struct file *file, char *buf, size_t size); | 81 | static ssize_t write_leasetime(struct file *file, char *buf, size_t size); |
70 | static ssize_t write_recoverydir(struct file *file, char *buf, size_t size); | 82 | static ssize_t write_recoverydir(struct file *file, char *buf, size_t size); |
83 | #endif | ||
71 | 84 | ||
72 | static ssize_t (*write_op[])(struct file *, char *, size_t) = { | 85 | static ssize_t (*write_op[])(struct file *, char *, size_t) = { |
73 | [NFSD_Svc] = write_svc, | 86 | [NFSD_Svc] = write_svc, |
@@ -79,8 +92,11 @@ static ssize_t (*write_op[])(struct file *, char *, size_t) = { | |||
79 | [NFSD_Getfs] = write_getfs, | 92 | [NFSD_Getfs] = write_getfs, |
80 | [NFSD_Fh] = write_filehandle, | 93 | [NFSD_Fh] = write_filehandle, |
81 | [NFSD_Threads] = write_threads, | 94 | [NFSD_Threads] = write_threads, |
95 | [NFSD_Versions] = write_versions, | ||
96 | #ifdef CONFIG_NFSD_V4 | ||
82 | [NFSD_Leasetime] = write_leasetime, | 97 | [NFSD_Leasetime] = write_leasetime, |
83 | [NFSD_RecoveryDir] = write_recoverydir, | 98 | [NFSD_RecoveryDir] = write_recoverydir, |
99 | #endif | ||
84 | }; | 100 | }; |
85 | 101 | ||
86 | static ssize_t nfsctl_transaction_write(struct file *file, const char __user *buf, size_t size, loff_t *pos) | 102 | static ssize_t nfsctl_transaction_write(struct file *file, const char __user *buf, size_t size, loff_t *pos) |
@@ -104,9 +120,23 @@ static ssize_t nfsctl_transaction_write(struct file *file, const char __user *bu | |||
104 | return rv; | 120 | return rv; |
105 | } | 121 | } |
106 | 122 | ||
123 | static ssize_t nfsctl_transaction_read(struct file *file, char __user *buf, size_t size, loff_t *pos) | ||
124 | { | ||
125 | if (! file->private_data) { | ||
126 | /* An attempt to read a transaction file without writing | ||
127 | * causes a 0-byte write so that the file can return | ||
128 | * state information | ||
129 | */ | ||
130 | ssize_t rv = nfsctl_transaction_write(file, buf, 0, pos); | ||
131 | if (rv < 0) | ||
132 | return rv; | ||
133 | } | ||
134 | return simple_transaction_read(file, buf, size, pos); | ||
135 | } | ||
136 | |||
107 | static struct file_operations transaction_ops = { | 137 | static struct file_operations transaction_ops = { |
108 | .write = nfsctl_transaction_write, | 138 | .write = nfsctl_transaction_write, |
109 | .read = simple_transaction_read, | 139 | .read = nfsctl_transaction_read, |
110 | .release = simple_transaction_release, | 140 | .release = simple_transaction_release, |
111 | }; | 141 | }; |
112 | 142 | ||
@@ -329,6 +359,70 @@ static ssize_t write_threads(struct file *file, char *buf, size_t size) | |||
329 | return strlen(buf); | 359 | return strlen(buf); |
330 | } | 360 | } |
331 | 361 | ||
362 | static ssize_t write_versions(struct file *file, char *buf, size_t size) | ||
363 | { | ||
364 | /* | ||
365 | * Format: | ||
366 | * [-/+]vers [-/+]vers ... | ||
367 | */ | ||
368 | char *mesg = buf; | ||
369 | char *vers, sign; | ||
370 | int len, num; | ||
371 | ssize_t tlen = 0; | ||
372 | char *sep; | ||
373 | |||
374 | if (size>0) { | ||
375 | if (nfsd_serv) | ||
376 | return -EBUSY; | ||
377 | if (buf[size-1] != '\n') | ||
378 | return -EINVAL; | ||
379 | buf[size-1] = 0; | ||
380 | |||
381 | vers = mesg; | ||
382 | len = qword_get(&mesg, vers, size); | ||
383 | if (len <= 0) return -EINVAL; | ||
384 | do { | ||
385 | sign = *vers; | ||
386 | if (sign == '+' || sign == '-') | ||
387 | num = simple_strtol((vers+1), NULL, 0); | ||
388 | else | ||
389 | num = simple_strtol(vers, NULL, 0); | ||
390 | switch(num) { | ||
391 | case 2: | ||
392 | case 3: | ||
393 | case 4: | ||
394 | if (sign != '-') | ||
395 | NFSCTL_VERSET(nfsd_versbits, num); | ||
396 | else | ||
397 | NFSCTL_VERUNSET(nfsd_versbits, num); | ||
398 | break; | ||
399 | default: | ||
400 | return -EINVAL; | ||
401 | } | ||
402 | vers += len + 1; | ||
403 | tlen += len; | ||
404 | } while ((len = qword_get(&mesg, vers, size)) > 0); | ||
405 | /* If all get turned off, turn them back on, as | ||
406 | * having no versions is BAD | ||
407 | */ | ||
408 | if ((nfsd_versbits & NFSCTL_VERALL)==0) | ||
409 | nfsd_versbits = NFSCTL_VERALL; | ||
410 | } | ||
411 | /* Now write current state into reply buffer */ | ||
412 | len = 0; | ||
413 | sep = ""; | ||
414 | for (num=2 ; num <= 4 ; num++) | ||
415 | if (NFSCTL_VERISSET(NFSCTL_VERALL, num)) { | ||
416 | len += sprintf(buf+len, "%s%c%d", sep, | ||
417 | NFSCTL_VERISSET(nfsd_versbits, num)?'+':'-', | ||
418 | num); | ||
419 | sep = " "; | ||
420 | } | ||
421 | len += sprintf(buf+len, "\n"); | ||
422 | return len; | ||
423 | } | ||
424 | |||
425 | #ifdef CONFIG_NFSD_V4 | ||
332 | extern time_t nfs4_leasetime(void); | 426 | extern time_t nfs4_leasetime(void); |
333 | 427 | ||
334 | static ssize_t write_leasetime(struct file *file, char *buf, size_t size) | 428 | static ssize_t write_leasetime(struct file *file, char *buf, size_t size) |
@@ -370,6 +464,7 @@ static ssize_t write_recoverydir(struct file *file, char *buf, size_t size) | |||
370 | status = nfs4_reset_recoverydir(recdir); | 464 | status = nfs4_reset_recoverydir(recdir); |
371 | return strlen(buf); | 465 | return strlen(buf); |
372 | } | 466 | } |
467 | #endif | ||
373 | 468 | ||
374 | /*----------------------------------------------------------------------------*/ | 469 | /*----------------------------------------------------------------------------*/ |
375 | /* | 470 | /* |
@@ -389,6 +484,7 @@ static int nfsd_fill_super(struct super_block * sb, void * data, int silent) | |||
389 | [NFSD_List] = {"exports", &exports_operations, S_IRUGO}, | 484 | [NFSD_List] = {"exports", &exports_operations, S_IRUGO}, |
390 | [NFSD_Fh] = {"filehandle", &transaction_ops, S_IWUSR|S_IRUSR}, | 485 | [NFSD_Fh] = {"filehandle", &transaction_ops, S_IWUSR|S_IRUSR}, |
391 | [NFSD_Threads] = {"threads", &transaction_ops, S_IWUSR|S_IRUSR}, | 486 | [NFSD_Threads] = {"threads", &transaction_ops, S_IWUSR|S_IRUSR}, |
487 | [NFSD_Versions] = {"versions", &transaction_ops, S_IWUSR|S_IRUSR}, | ||
392 | #ifdef CONFIG_NFSD_V4 | 488 | #ifdef CONFIG_NFSD_V4 |
393 | [NFSD_Leasetime] = {"nfsv4leasetime", &transaction_ops, S_IWUSR|S_IRUSR}, | 489 | [NFSD_Leasetime] = {"nfsv4leasetime", &transaction_ops, S_IWUSR|S_IRUSR}, |
394 | [NFSD_RecoveryDir] = {"nfsv4recoverydir", &transaction_ops, S_IWUSR|S_IRUSR}, | 490 | [NFSD_RecoveryDir] = {"nfsv4recoverydir", &transaction_ops, S_IWUSR|S_IRUSR}, |
diff --git a/fs/nfsd/nfssvc.c b/fs/nfsd/nfssvc.c index 1697539a7171..89ed04696865 100644 --- a/fs/nfsd/nfssvc.c +++ b/fs/nfsd/nfssvc.c | |||
@@ -30,6 +30,7 @@ | |||
30 | #include <linux/nfsd/nfsd.h> | 30 | #include <linux/nfsd/nfsd.h> |
31 | #include <linux/nfsd/stats.h> | 31 | #include <linux/nfsd/stats.h> |
32 | #include <linux/nfsd/cache.h> | 32 | #include <linux/nfsd/cache.h> |
33 | #include <linux/nfsd/syscall.h> | ||
33 | #include <linux/lockd/bind.h> | 34 | #include <linux/lockd/bind.h> |
34 | #include <linux/nfsacl.h> | 35 | #include <linux/nfsacl.h> |
35 | 36 | ||
@@ -52,7 +53,7 @@ | |||
52 | extern struct svc_program nfsd_program; | 53 | extern struct svc_program nfsd_program; |
53 | static void nfsd(struct svc_rqst *rqstp); | 54 | static void nfsd(struct svc_rqst *rqstp); |
54 | struct timeval nfssvc_boot; | 55 | struct timeval nfssvc_boot; |
55 | static struct svc_serv *nfsd_serv; | 56 | struct svc_serv *nfsd_serv; |
56 | static atomic_t nfsd_busy; | 57 | static atomic_t nfsd_busy; |
57 | static unsigned long nfsd_last_call; | 58 | static unsigned long nfsd_last_call; |
58 | static DEFINE_SPINLOCK(nfsd_call_lock); | 59 | static DEFINE_SPINLOCK(nfsd_call_lock); |
@@ -63,6 +64,31 @@ struct nfsd_list { | |||
63 | }; | 64 | }; |
64 | static struct list_head nfsd_list = LIST_HEAD_INIT(nfsd_list); | 65 | static struct list_head nfsd_list = LIST_HEAD_INIT(nfsd_list); |
65 | 66 | ||
67 | static struct svc_version * nfsd_version[] = { | ||
68 | [2] = &nfsd_version2, | ||
69 | #if defined(CONFIG_NFSD_V3) | ||
70 | [3] = &nfsd_version3, | ||
71 | #endif | ||
72 | #if defined(CONFIG_NFSD_V4) | ||
73 | [4] = &nfsd_version4, | ||
74 | #endif | ||
75 | }; | ||
76 | |||
77 | #define NFSD_MINVERS 2 | ||
78 | #define NFSD_NRVERS (sizeof(nfsd_version)/sizeof(nfsd_version[0])) | ||
79 | static struct svc_version *nfsd_versions[NFSD_NRVERS]; | ||
80 | |||
81 | struct svc_program nfsd_program = { | ||
82 | .pg_prog = NFS_PROGRAM, /* program number */ | ||
83 | .pg_nvers = NFSD_NRVERS, /* nr of entries in nfsd_version */ | ||
84 | .pg_vers = nfsd_versions, /* version table */ | ||
85 | .pg_name = "nfsd", /* program name */ | ||
86 | .pg_class = "nfsd", /* authentication class */ | ||
87 | .pg_stats = &nfsd_svcstats, /* version table */ | ||
88 | .pg_authenticate = &svc_set_client, /* export authentication */ | ||
89 | |||
90 | }; | ||
91 | |||
66 | /* | 92 | /* |
67 | * Maximum number of nfsd processes | 93 | * Maximum number of nfsd processes |
68 | */ | 94 | */ |
@@ -80,11 +106,12 @@ int | |||
80 | nfsd_svc(unsigned short port, int nrservs) | 106 | nfsd_svc(unsigned short port, int nrservs) |
81 | { | 107 | { |
82 | int error; | 108 | int error; |
83 | int none_left; | 109 | int none_left, found_one, i; |
84 | struct list_head *victim; | 110 | struct list_head *victim; |
85 | 111 | ||
86 | lock_kernel(); | 112 | lock_kernel(); |
87 | dprintk("nfsd: creating service\n"); | 113 | dprintk("nfsd: creating service: vers 0x%x\n", |
114 | nfsd_versbits); | ||
88 | error = -EINVAL; | 115 | error = -EINVAL; |
89 | if (nrservs <= 0) | 116 | if (nrservs <= 0) |
90 | nrservs = 0; | 117 | nrservs = 0; |
@@ -99,6 +126,27 @@ nfsd_svc(unsigned short port, int nrservs) | |||
99 | if (error<0) | 126 | if (error<0) |
100 | goto out; | 127 | goto out; |
101 | if (!nfsd_serv) { | 128 | if (!nfsd_serv) { |
129 | /* | ||
130 | * Use the nfsd_ctlbits to define which | ||
131 | * versions that will be advertised. | ||
132 | * If nfsd_ctlbits doesn't list any version, | ||
133 | * export them all. | ||
134 | */ | ||
135 | found_one = 0; | ||
136 | |||
137 | for (i = NFSD_MINVERS; i < NFSD_NRVERS; i++) { | ||
138 | if (NFSCTL_VERISSET(nfsd_versbits, i)) { | ||
139 | nfsd_program.pg_vers[i] = nfsd_version[i]; | ||
140 | found_one = 1; | ||
141 | } else | ||
142 | nfsd_program.pg_vers[i] = NULL; | ||
143 | } | ||
144 | |||
145 | if (!found_one) { | ||
146 | for (i = NFSD_MINVERS; i < NFSD_NRVERS; i++) | ||
147 | nfsd_program.pg_vers[i] = nfsd_version[i]; | ||
148 | } | ||
149 | |||
102 | atomic_set(&nfsd_busy, 0); | 150 | atomic_set(&nfsd_busy, 0); |
103 | error = -ENOMEM; | 151 | error = -ENOMEM; |
104 | nfsd_serv = svc_create(&nfsd_program, NFSD_BUFSIZE); | 152 | nfsd_serv = svc_create(&nfsd_program, NFSD_BUFSIZE); |
@@ -379,6 +427,7 @@ static struct svc_program nfsd_acl_program = { | |||
379 | .pg_name = "nfsd", | 427 | .pg_name = "nfsd", |
380 | .pg_class = "nfsd", | 428 | .pg_class = "nfsd", |
381 | .pg_stats = &nfsd_acl_svcstats, | 429 | .pg_stats = &nfsd_acl_svcstats, |
430 | .pg_authenticate = &svc_set_client, | ||
382 | }; | 431 | }; |
383 | 432 | ||
384 | static struct svc_stat nfsd_acl_svcstats = { | 433 | static struct svc_stat nfsd_acl_svcstats = { |
@@ -389,28 +438,3 @@ static struct svc_stat nfsd_acl_svcstats = { | |||
389 | #else | 438 | #else |
390 | #define nfsd_acl_program_p NULL | 439 | #define nfsd_acl_program_p NULL |
391 | #endif /* defined(CONFIG_NFSD_V2_ACL) || defined(CONFIG_NFSD_V3_ACL) */ | 440 | #endif /* defined(CONFIG_NFSD_V2_ACL) || defined(CONFIG_NFSD_V3_ACL) */ |
392 | |||
393 | extern struct svc_version nfsd_version2, nfsd_version3, nfsd_version4; | ||
394 | |||
395 | static struct svc_version * nfsd_version[] = { | ||
396 | [2] = &nfsd_version2, | ||
397 | #if defined(CONFIG_NFSD_V3) | ||
398 | [3] = &nfsd_version3, | ||
399 | #endif | ||
400 | #if defined(CONFIG_NFSD_V4) | ||
401 | [4] = &nfsd_version4, | ||
402 | #endif | ||
403 | }; | ||
404 | |||
405 | #define NFSD_NRVERS (sizeof(nfsd_version)/sizeof(nfsd_version[0])) | ||
406 | struct svc_program nfsd_program = { | ||
407 | .pg_next = nfsd_acl_program_p, | ||
408 | .pg_prog = NFS_PROGRAM, /* program number */ | ||
409 | .pg_nvers = NFSD_NRVERS, /* nr of entries in nfsd_version */ | ||
410 | .pg_vers = nfsd_version, /* version table */ | ||
411 | .pg_name = "nfsd", /* program name */ | ||
412 | .pg_class = "nfsd", /* authentication class */ | ||
413 | .pg_stats = &nfsd_svcstats, /* version table */ | ||
414 | .pg_authenticate = &svc_set_client, /* export authentication */ | ||
415 | |||
416 | }; | ||
diff --git a/fs/nfsd/vfs.c b/fs/nfsd/vfs.c index 4f2cd3d27566..af7c3c3074b0 100644 --- a/fs/nfsd/vfs.c +++ b/fs/nfsd/vfs.c | |||
@@ -254,12 +254,19 @@ nfsd_setattr(struct svc_rqst *rqstp, struct svc_fh *fhp, struct iattr *iap, | |||
254 | 254 | ||
255 | /* Get inode */ | 255 | /* Get inode */ |
256 | err = fh_verify(rqstp, fhp, ftype, accmode); | 256 | err = fh_verify(rqstp, fhp, ftype, accmode); |
257 | if (err || !iap->ia_valid) | 257 | if (err) |
258 | goto out; | 258 | goto out; |
259 | 259 | ||
260 | dentry = fhp->fh_dentry; | 260 | dentry = fhp->fh_dentry; |
261 | inode = dentry->d_inode; | 261 | inode = dentry->d_inode; |
262 | 262 | ||
263 | /* Ignore any mode updates on symlinks */ | ||
264 | if (S_ISLNK(inode->i_mode)) | ||
265 | iap->ia_valid &= ~ATTR_MODE; | ||
266 | |||
267 | if (!iap->ia_valid) | ||
268 | goto out; | ||
269 | |||
263 | /* NFSv2 does not differentiate between "set-[ac]time-to-now" | 270 | /* NFSv2 does not differentiate between "set-[ac]time-to-now" |
264 | * which only requires access, and "set-[ac]time-to-X" which | 271 | * which only requires access, and "set-[ac]time-to-X" which |
265 | * requires ownership. | 272 | * requires ownership. |
@@ -194,7 +194,7 @@ out: | |||
194 | return error; | 194 | return error; |
195 | } | 195 | } |
196 | 196 | ||
197 | int do_truncate(struct dentry *dentry, loff_t length) | 197 | int do_truncate(struct dentry *dentry, loff_t length, struct file *filp) |
198 | { | 198 | { |
199 | int err; | 199 | int err; |
200 | struct iattr newattrs; | 200 | struct iattr newattrs; |
@@ -205,6 +205,10 @@ int do_truncate(struct dentry *dentry, loff_t length) | |||
205 | 205 | ||
206 | newattrs.ia_size = length; | 206 | newattrs.ia_size = length; |
207 | newattrs.ia_valid = ATTR_SIZE | ATTR_CTIME; | 207 | newattrs.ia_valid = ATTR_SIZE | ATTR_CTIME; |
208 | if (filp) { | ||
209 | newattrs.ia_file = filp; | ||
210 | newattrs.ia_valid |= ATTR_FILE; | ||
211 | } | ||
208 | 212 | ||
209 | down(&dentry->d_inode->i_sem); | 213 | down(&dentry->d_inode->i_sem); |
210 | err = notify_change(dentry, &newattrs); | 214 | err = notify_change(dentry, &newattrs); |
@@ -236,7 +240,7 @@ static inline long do_sys_truncate(const char __user * path, loff_t length) | |||
236 | if (!S_ISREG(inode->i_mode)) | 240 | if (!S_ISREG(inode->i_mode)) |
237 | goto dput_and_out; | 241 | goto dput_and_out; |
238 | 242 | ||
239 | error = permission(inode,MAY_WRITE,&nd); | 243 | error = vfs_permission(&nd, MAY_WRITE); |
240 | if (error) | 244 | if (error) |
241 | goto dput_and_out; | 245 | goto dput_and_out; |
242 | 246 | ||
@@ -262,7 +266,7 @@ static inline long do_sys_truncate(const char __user * path, loff_t length) | |||
262 | error = locks_verify_truncate(inode, NULL, length); | 266 | error = locks_verify_truncate(inode, NULL, length); |
263 | if (!error) { | 267 | if (!error) { |
264 | DQUOT_INIT(inode); | 268 | DQUOT_INIT(inode); |
265 | error = do_truncate(nd.dentry, length); | 269 | error = do_truncate(nd.dentry, length, NULL); |
266 | } | 270 | } |
267 | put_write_access(inode); | 271 | put_write_access(inode); |
268 | 272 | ||
@@ -314,7 +318,7 @@ static inline long do_sys_ftruncate(unsigned int fd, loff_t length, int small) | |||
314 | 318 | ||
315 | error = locks_verify_truncate(inode, file, length); | 319 | error = locks_verify_truncate(inode, file, length); |
316 | if (!error) | 320 | if (!error) |
317 | error = do_truncate(dentry, length); | 321 | error = do_truncate(dentry, length, file); |
318 | out_putf: | 322 | out_putf: |
319 | fput(file); | 323 | fput(file); |
320 | out: | 324 | out: |
@@ -390,7 +394,7 @@ asmlinkage long sys_utime(char __user * filename, struct utimbuf __user * times) | |||
390 | goto dput_and_out; | 394 | goto dput_and_out; |
391 | 395 | ||
392 | if (current->fsuid != inode->i_uid && | 396 | if (current->fsuid != inode->i_uid && |
393 | (error = permission(inode,MAY_WRITE,&nd)) != 0) | 397 | (error = vfs_permission(&nd, MAY_WRITE)) != 0) |
394 | goto dput_and_out; | 398 | goto dput_and_out; |
395 | } | 399 | } |
396 | down(&inode->i_sem); | 400 | down(&inode->i_sem); |
@@ -443,7 +447,7 @@ long do_utimes(char __user * filename, struct timeval * times) | |||
443 | goto dput_and_out; | 447 | goto dput_and_out; |
444 | 448 | ||
445 | if (current->fsuid != inode->i_uid && | 449 | if (current->fsuid != inode->i_uid && |
446 | (error = permission(inode,MAY_WRITE,&nd)) != 0) | 450 | (error = vfs_permission(&nd, MAY_WRITE)) != 0) |
447 | goto dput_and_out; | 451 | goto dput_and_out; |
448 | } | 452 | } |
449 | down(&inode->i_sem); | 453 | down(&inode->i_sem); |
@@ -502,7 +506,7 @@ asmlinkage long sys_access(const char __user * filename, int mode) | |||
502 | 506 | ||
503 | res = __user_walk(filename, LOOKUP_FOLLOW|LOOKUP_ACCESS, &nd); | 507 | res = __user_walk(filename, LOOKUP_FOLLOW|LOOKUP_ACCESS, &nd); |
504 | if (!res) { | 508 | if (!res) { |
505 | res = permission(nd.dentry->d_inode, mode, &nd); | 509 | res = vfs_permission(&nd, mode); |
506 | /* SuS v2 requires we report a read only fs too */ | 510 | /* SuS v2 requires we report a read only fs too */ |
507 | if(!res && (mode & S_IWOTH) && IS_RDONLY(nd.dentry->d_inode) | 511 | if(!res && (mode & S_IWOTH) && IS_RDONLY(nd.dentry->d_inode) |
508 | && !special_file(nd.dentry->d_inode->i_mode)) | 512 | && !special_file(nd.dentry->d_inode->i_mode)) |
@@ -526,7 +530,7 @@ asmlinkage long sys_chdir(const char __user * filename) | |||
526 | if (error) | 530 | if (error) |
527 | goto out; | 531 | goto out; |
528 | 532 | ||
529 | error = permission(nd.dentry->d_inode,MAY_EXEC,&nd); | 533 | error = vfs_permission(&nd, MAY_EXEC); |
530 | if (error) | 534 | if (error) |
531 | goto dput_and_out; | 535 | goto dput_and_out; |
532 | 536 | ||
@@ -559,7 +563,7 @@ asmlinkage long sys_fchdir(unsigned int fd) | |||
559 | if (!S_ISDIR(inode->i_mode)) | 563 | if (!S_ISDIR(inode->i_mode)) |
560 | goto out_putf; | 564 | goto out_putf; |
561 | 565 | ||
562 | error = permission(inode, MAY_EXEC, NULL); | 566 | error = file_permission(file, MAY_EXEC); |
563 | if (!error) | 567 | if (!error) |
564 | set_fs_pwd(current->fs, mnt, dentry); | 568 | set_fs_pwd(current->fs, mnt, dentry); |
565 | out_putf: | 569 | out_putf: |
@@ -577,7 +581,7 @@ asmlinkage long sys_chroot(const char __user * filename) | |||
577 | if (error) | 581 | if (error) |
578 | goto out; | 582 | goto out; |
579 | 583 | ||
580 | error = permission(nd.dentry->d_inode,MAY_EXEC,&nd); | 584 | error = vfs_permission(&nd, MAY_EXEC); |
581 | if (error) | 585 | if (error) |
582 | goto dput_and_out; | 586 | goto dput_and_out; |
583 | 587 | ||
@@ -887,6 +891,10 @@ struct file *nameidata_to_filp(struct nameidata *nd, int flags) | |||
887 | return filp; | 891 | return filp; |
888 | } | 892 | } |
889 | 893 | ||
894 | /* | ||
895 | * dentry_open() will have done dput(dentry) and mntput(mnt) if it returns an | ||
896 | * error. | ||
897 | */ | ||
890 | struct file *dentry_open(struct dentry *dentry, struct vfsmount *mnt, int flags) | 898 | struct file *dentry_open(struct dentry *dentry, struct vfsmount *mnt, int flags) |
891 | { | 899 | { |
892 | int error; | 900 | int error; |
@@ -894,8 +902,11 @@ struct file *dentry_open(struct dentry *dentry, struct vfsmount *mnt, int flags) | |||
894 | 902 | ||
895 | error = -ENFILE; | 903 | error = -ENFILE; |
896 | f = get_empty_filp(); | 904 | f = get_empty_filp(); |
897 | if (f == NULL) | 905 | if (f == NULL) { |
906 | dput(dentry); | ||
907 | mntput(mnt); | ||
898 | return ERR_PTR(error); | 908 | return ERR_PTR(error); |
909 | } | ||
899 | 910 | ||
900 | return __dentry_open(dentry, mnt, flags, f, NULL); | 911 | return __dentry_open(dentry, mnt, flags, f, NULL); |
901 | } | 912 | } |
diff --git a/fs/openpromfs/inode.c b/fs/openpromfs/inode.c index 1be11ce96b0f..aeb0106890e4 100644 --- a/fs/openpromfs/inode.c +++ b/fs/openpromfs/inode.c | |||
@@ -1088,8 +1088,7 @@ static void __exit exit_openprom_fs(void) | |||
1088 | unregister_filesystem(&openprom_fs_type); | 1088 | unregister_filesystem(&openprom_fs_type); |
1089 | free_pages ((unsigned long)nodes, alloced); | 1089 | free_pages ((unsigned long)nodes, alloced); |
1090 | for (i = 0; i < aliases_nodes; i++) | 1090 | for (i = 0; i < aliases_nodes; i++) |
1091 | if (alias_names [i]) | 1091 | kfree (alias_names [i]); |
1092 | kfree (alias_names [i]); | ||
1093 | nodes = NULL; | 1092 | nodes = NULL; |
1094 | } | 1093 | } |
1095 | 1094 | ||
diff --git a/fs/partitions/ibm.c b/fs/partitions/ibm.c index d59dcbf2bd4a..6327bcb2d73d 100644 --- a/fs/partitions/ibm.c +++ b/fs/partitions/ibm.c | |||
@@ -29,7 +29,7 @@ | |||
29 | * cyl-cyl-head-head structure | 29 | * cyl-cyl-head-head structure |
30 | */ | 30 | */ |
31 | static inline int | 31 | static inline int |
32 | cchh2blk (cchh_t *ptr, struct hd_geometry *geo) { | 32 | cchh2blk (struct vtoc_cchh *ptr, struct hd_geometry *geo) { |
33 | return ptr->cc * geo->heads * geo->sectors + | 33 | return ptr->cc * geo->heads * geo->sectors + |
34 | ptr->hh * geo->sectors; | 34 | ptr->hh * geo->sectors; |
35 | } | 35 | } |
@@ -40,7 +40,7 @@ cchh2blk (cchh_t *ptr, struct hd_geometry *geo) { | |||
40 | * cyl-cyl-head-head-block structure | 40 | * cyl-cyl-head-head-block structure |
41 | */ | 41 | */ |
42 | static inline int | 42 | static inline int |
43 | cchhb2blk (cchhb_t *ptr, struct hd_geometry *geo) { | 43 | cchhb2blk (struct vtoc_cchhb *ptr, struct hd_geometry *geo) { |
44 | return ptr->cc * geo->heads * geo->sectors + | 44 | return ptr->cc * geo->heads * geo->sectors + |
45 | ptr->hh * geo->sectors + | 45 | ptr->hh * geo->sectors + |
46 | ptr->b; | 46 | ptr->b; |
@@ -56,7 +56,7 @@ ibm_partition(struct parsed_partitions *state, struct block_device *bdev) | |||
56 | struct hd_geometry *geo; | 56 | struct hd_geometry *geo; |
57 | char type[5] = {0,}; | 57 | char type[5] = {0,}; |
58 | char name[7] = {0,}; | 58 | char name[7] = {0,}; |
59 | volume_label_t *vlabel; | 59 | struct vtoc_volume_label *vlabel; |
60 | unsigned char *data; | 60 | unsigned char *data; |
61 | Sector sect; | 61 | Sector sect; |
62 | 62 | ||
@@ -64,7 +64,8 @@ ibm_partition(struct parsed_partitions *state, struct block_device *bdev) | |||
64 | goto out_noinfo; | 64 | goto out_noinfo; |
65 | if ((geo = kmalloc(sizeof(struct hd_geometry), GFP_KERNEL)) == NULL) | 65 | if ((geo = kmalloc(sizeof(struct hd_geometry), GFP_KERNEL)) == NULL) |
66 | goto out_nogeo; | 66 | goto out_nogeo; |
67 | if ((vlabel = kmalloc(sizeof(volume_label_t), GFP_KERNEL)) == NULL) | 67 | if ((vlabel = kmalloc(sizeof(struct vtoc_volume_label), |
68 | GFP_KERNEL)) == NULL) | ||
68 | goto out_novlab; | 69 | goto out_novlab; |
69 | 70 | ||
70 | if (ioctl_by_bdev(bdev, BIODASDINFO, (unsigned long)info) != 0 || | 71 | if (ioctl_by_bdev(bdev, BIODASDINFO, (unsigned long)info) != 0 || |
@@ -86,7 +87,7 @@ ibm_partition(struct parsed_partitions *state, struct block_device *bdev) | |||
86 | strncpy(name, data + 8, 6); | 87 | strncpy(name, data + 8, 6); |
87 | else | 88 | else |
88 | strncpy(name, data + 4, 6); | 89 | strncpy(name, data + 4, 6); |
89 | memcpy (vlabel, data, sizeof(volume_label_t)); | 90 | memcpy (vlabel, data, sizeof(struct vtoc_volume_label)); |
90 | put_dev_sector(sect); | 91 | put_dev_sector(sect); |
91 | 92 | ||
92 | EBCASC(type, 4); | 93 | EBCASC(type, 4); |
@@ -129,9 +130,9 @@ ibm_partition(struct parsed_partitions *state, struct block_device *bdev) | |||
129 | counter = 0; | 130 | counter = 0; |
130 | while ((data = read_dev_sector(bdev, blk*(blocksize/512), | 131 | while ((data = read_dev_sector(bdev, blk*(blocksize/512), |
131 | §)) != NULL) { | 132 | §)) != NULL) { |
132 | format1_label_t f1; | 133 | struct vtoc_format1_label f1; |
133 | 134 | ||
134 | memcpy(&f1, data, sizeof(format1_label_t)); | 135 | memcpy(&f1, data, sizeof(struct vtoc_format1_label)); |
135 | put_dev_sector(sect); | 136 | put_dev_sector(sect); |
136 | 137 | ||
137 | /* skip FMT4 / FMT5 / FMT7 labels */ | 138 | /* skip FMT4 / FMT5 / FMT7 labels */ |
diff --git a/fs/pnode.c b/fs/pnode.c new file mode 100644 index 000000000000..aeeec8ba8dd2 --- /dev/null +++ b/fs/pnode.c | |||
@@ -0,0 +1,305 @@ | |||
1 | /* | ||
2 | * linux/fs/pnode.c | ||
3 | * | ||
4 | * (C) Copyright IBM Corporation 2005. | ||
5 | * Released under GPL v2. | ||
6 | * Author : Ram Pai (linuxram@us.ibm.com) | ||
7 | * | ||
8 | */ | ||
9 | #include <linux/namespace.h> | ||
10 | #include <linux/mount.h> | ||
11 | #include <linux/fs.h> | ||
12 | #include "pnode.h" | ||
13 | |||
14 | /* return the next shared peer mount of @p */ | ||
15 | static inline struct vfsmount *next_peer(struct vfsmount *p) | ||
16 | { | ||
17 | return list_entry(p->mnt_share.next, struct vfsmount, mnt_share); | ||
18 | } | ||
19 | |||
20 | static inline struct vfsmount *first_slave(struct vfsmount *p) | ||
21 | { | ||
22 | return list_entry(p->mnt_slave_list.next, struct vfsmount, mnt_slave); | ||
23 | } | ||
24 | |||
25 | static inline struct vfsmount *next_slave(struct vfsmount *p) | ||
26 | { | ||
27 | return list_entry(p->mnt_slave.next, struct vfsmount, mnt_slave); | ||
28 | } | ||
29 | |||
30 | static int do_make_slave(struct vfsmount *mnt) | ||
31 | { | ||
32 | struct vfsmount *peer_mnt = mnt, *master = mnt->mnt_master; | ||
33 | struct vfsmount *slave_mnt; | ||
34 | |||
35 | /* | ||
36 | * slave 'mnt' to a peer mount that has the | ||
37 | * same root dentry. If none is available than | ||
38 | * slave it to anything that is available. | ||
39 | */ | ||
40 | while ((peer_mnt = next_peer(peer_mnt)) != mnt && | ||
41 | peer_mnt->mnt_root != mnt->mnt_root) ; | ||
42 | |||
43 | if (peer_mnt == mnt) { | ||
44 | peer_mnt = next_peer(mnt); | ||
45 | if (peer_mnt == mnt) | ||
46 | peer_mnt = NULL; | ||
47 | } | ||
48 | list_del_init(&mnt->mnt_share); | ||
49 | |||
50 | if (peer_mnt) | ||
51 | master = peer_mnt; | ||
52 | |||
53 | if (master) { | ||
54 | list_for_each_entry(slave_mnt, &mnt->mnt_slave_list, mnt_slave) | ||
55 | slave_mnt->mnt_master = master; | ||
56 | list_del(&mnt->mnt_slave); | ||
57 | list_add(&mnt->mnt_slave, &master->mnt_slave_list); | ||
58 | list_splice(&mnt->mnt_slave_list, master->mnt_slave_list.prev); | ||
59 | INIT_LIST_HEAD(&mnt->mnt_slave_list); | ||
60 | } else { | ||
61 | struct list_head *p = &mnt->mnt_slave_list; | ||
62 | while (!list_empty(p)) { | ||
63 | slave_mnt = list_entry(p->next, | ||
64 | struct vfsmount, mnt_slave); | ||
65 | list_del_init(&slave_mnt->mnt_slave); | ||
66 | slave_mnt->mnt_master = NULL; | ||
67 | } | ||
68 | } | ||
69 | mnt->mnt_master = master; | ||
70 | CLEAR_MNT_SHARED(mnt); | ||
71 | INIT_LIST_HEAD(&mnt->mnt_slave_list); | ||
72 | return 0; | ||
73 | } | ||
74 | |||
75 | void change_mnt_propagation(struct vfsmount *mnt, int type) | ||
76 | { | ||
77 | if (type == MS_SHARED) { | ||
78 | set_mnt_shared(mnt); | ||
79 | return; | ||
80 | } | ||
81 | do_make_slave(mnt); | ||
82 | if (type != MS_SLAVE) { | ||
83 | list_del_init(&mnt->mnt_slave); | ||
84 | mnt->mnt_master = NULL; | ||
85 | if (type == MS_UNBINDABLE) | ||
86 | mnt->mnt_flags |= MNT_UNBINDABLE; | ||
87 | } | ||
88 | } | ||
89 | |||
90 | /* | ||
91 | * get the next mount in the propagation tree. | ||
92 | * @m: the mount seen last | ||
93 | * @origin: the original mount from where the tree walk initiated | ||
94 | */ | ||
95 | static struct vfsmount *propagation_next(struct vfsmount *m, | ||
96 | struct vfsmount *origin) | ||
97 | { | ||
98 | /* are there any slaves of this mount? */ | ||
99 | if (!IS_MNT_NEW(m) && !list_empty(&m->mnt_slave_list)) | ||
100 | return first_slave(m); | ||
101 | |||
102 | while (1) { | ||
103 | struct vfsmount *next; | ||
104 | struct vfsmount *master = m->mnt_master; | ||
105 | |||
106 | if ( master == origin->mnt_master ) { | ||
107 | next = next_peer(m); | ||
108 | return ((next == origin) ? NULL : next); | ||
109 | } else if (m->mnt_slave.next != &master->mnt_slave_list) | ||
110 | return next_slave(m); | ||
111 | |||
112 | /* back at master */ | ||
113 | m = master; | ||
114 | } | ||
115 | } | ||
116 | |||
117 | /* | ||
118 | * return the source mount to be used for cloning | ||
119 | * | ||
120 | * @dest the current destination mount | ||
121 | * @last_dest the last seen destination mount | ||
122 | * @last_src the last seen source mount | ||
123 | * @type return CL_SLAVE if the new mount has to be | ||
124 | * cloned as a slave. | ||
125 | */ | ||
126 | static struct vfsmount *get_source(struct vfsmount *dest, | ||
127 | struct vfsmount *last_dest, | ||
128 | struct vfsmount *last_src, | ||
129 | int *type) | ||
130 | { | ||
131 | struct vfsmount *p_last_src = NULL; | ||
132 | struct vfsmount *p_last_dest = NULL; | ||
133 | *type = CL_PROPAGATION;; | ||
134 | |||
135 | if (IS_MNT_SHARED(dest)) | ||
136 | *type |= CL_MAKE_SHARED; | ||
137 | |||
138 | while (last_dest != dest->mnt_master) { | ||
139 | p_last_dest = last_dest; | ||
140 | p_last_src = last_src; | ||
141 | last_dest = last_dest->mnt_master; | ||
142 | last_src = last_src->mnt_master; | ||
143 | } | ||
144 | |||
145 | if (p_last_dest) { | ||
146 | do { | ||
147 | p_last_dest = next_peer(p_last_dest); | ||
148 | } while (IS_MNT_NEW(p_last_dest)); | ||
149 | } | ||
150 | |||
151 | if (dest != p_last_dest) { | ||
152 | *type |= CL_SLAVE; | ||
153 | return last_src; | ||
154 | } else | ||
155 | return p_last_src; | ||
156 | } | ||
157 | |||
158 | /* | ||
159 | * mount 'source_mnt' under the destination 'dest_mnt' at | ||
160 | * dentry 'dest_dentry'. And propagate that mount to | ||
161 | * all the peer and slave mounts of 'dest_mnt'. | ||
162 | * Link all the new mounts into a propagation tree headed at | ||
163 | * source_mnt. Also link all the new mounts using ->mnt_list | ||
164 | * headed at source_mnt's ->mnt_list | ||
165 | * | ||
166 | * @dest_mnt: destination mount. | ||
167 | * @dest_dentry: destination dentry. | ||
168 | * @source_mnt: source mount. | ||
169 | * @tree_list : list of heads of trees to be attached. | ||
170 | */ | ||
171 | int propagate_mnt(struct vfsmount *dest_mnt, struct dentry *dest_dentry, | ||
172 | struct vfsmount *source_mnt, struct list_head *tree_list) | ||
173 | { | ||
174 | struct vfsmount *m, *child; | ||
175 | int ret = 0; | ||
176 | struct vfsmount *prev_dest_mnt = dest_mnt; | ||
177 | struct vfsmount *prev_src_mnt = source_mnt; | ||
178 | LIST_HEAD(tmp_list); | ||
179 | LIST_HEAD(umount_list); | ||
180 | |||
181 | for (m = propagation_next(dest_mnt, dest_mnt); m; | ||
182 | m = propagation_next(m, dest_mnt)) { | ||
183 | int type; | ||
184 | struct vfsmount *source; | ||
185 | |||
186 | if (IS_MNT_NEW(m)) | ||
187 | continue; | ||
188 | |||
189 | source = get_source(m, prev_dest_mnt, prev_src_mnt, &type); | ||
190 | |||
191 | if (!(child = copy_tree(source, source->mnt_root, type))) { | ||
192 | ret = -ENOMEM; | ||
193 | list_splice(tree_list, tmp_list.prev); | ||
194 | goto out; | ||
195 | } | ||
196 | |||
197 | if (is_subdir(dest_dentry, m->mnt_root)) { | ||
198 | mnt_set_mountpoint(m, dest_dentry, child); | ||
199 | list_add_tail(&child->mnt_hash, tree_list); | ||
200 | } else { | ||
201 | /* | ||
202 | * This can happen if the parent mount was bind mounted | ||
203 | * on some subdirectory of a shared/slave mount. | ||
204 | */ | ||
205 | list_add_tail(&child->mnt_hash, &tmp_list); | ||
206 | } | ||
207 | prev_dest_mnt = m; | ||
208 | prev_src_mnt = child; | ||
209 | } | ||
210 | out: | ||
211 | spin_lock(&vfsmount_lock); | ||
212 | while (!list_empty(&tmp_list)) { | ||
213 | child = list_entry(tmp_list.next, struct vfsmount, mnt_hash); | ||
214 | list_del_init(&child->mnt_hash); | ||
215 | umount_tree(child, 0, &umount_list); | ||
216 | } | ||
217 | spin_unlock(&vfsmount_lock); | ||
218 | release_mounts(&umount_list); | ||
219 | return ret; | ||
220 | } | ||
221 | |||
222 | /* | ||
223 | * return true if the refcount is greater than count | ||
224 | */ | ||
225 | static inline int do_refcount_check(struct vfsmount *mnt, int count) | ||
226 | { | ||
227 | int mycount = atomic_read(&mnt->mnt_count); | ||
228 | return (mycount > count); | ||
229 | } | ||
230 | |||
231 | /* | ||
232 | * check if the mount 'mnt' can be unmounted successfully. | ||
233 | * @mnt: the mount to be checked for unmount | ||
234 | * NOTE: unmounting 'mnt' would naturally propagate to all | ||
235 | * other mounts its parent propagates to. | ||
236 | * Check if any of these mounts that **do not have submounts** | ||
237 | * have more references than 'refcnt'. If so return busy. | ||
238 | */ | ||
239 | int propagate_mount_busy(struct vfsmount *mnt, int refcnt) | ||
240 | { | ||
241 | struct vfsmount *m, *child; | ||
242 | struct vfsmount *parent = mnt->mnt_parent; | ||
243 | int ret = 0; | ||
244 | |||
245 | if (mnt == parent) | ||
246 | return do_refcount_check(mnt, refcnt); | ||
247 | |||
248 | /* | ||
249 | * quickly check if the current mount can be unmounted. | ||
250 | * If not, we don't have to go checking for all other | ||
251 | * mounts | ||
252 | */ | ||
253 | if (!list_empty(&mnt->mnt_mounts) || do_refcount_check(mnt, refcnt)) | ||
254 | return 1; | ||
255 | |||
256 | for (m = propagation_next(parent, parent); m; | ||
257 | m = propagation_next(m, parent)) { | ||
258 | child = __lookup_mnt(m, mnt->mnt_mountpoint, 0); | ||
259 | if (child && list_empty(&child->mnt_mounts) && | ||
260 | (ret = do_refcount_check(child, 1))) | ||
261 | break; | ||
262 | } | ||
263 | return ret; | ||
264 | } | ||
265 | |||
266 | /* | ||
267 | * NOTE: unmounting 'mnt' naturally propagates to all other mounts its | ||
268 | * parent propagates to. | ||
269 | */ | ||
270 | static void __propagate_umount(struct vfsmount *mnt) | ||
271 | { | ||
272 | struct vfsmount *parent = mnt->mnt_parent; | ||
273 | struct vfsmount *m; | ||
274 | |||
275 | BUG_ON(parent == mnt); | ||
276 | |||
277 | for (m = propagation_next(parent, parent); m; | ||
278 | m = propagation_next(m, parent)) { | ||
279 | |||
280 | struct vfsmount *child = __lookup_mnt(m, | ||
281 | mnt->mnt_mountpoint, 0); | ||
282 | /* | ||
283 | * umount the child only if the child has no | ||
284 | * other children | ||
285 | */ | ||
286 | if (child && list_empty(&child->mnt_mounts)) { | ||
287 | list_del(&child->mnt_hash); | ||
288 | list_add_tail(&child->mnt_hash, &mnt->mnt_hash); | ||
289 | } | ||
290 | } | ||
291 | } | ||
292 | |||
293 | /* | ||
294 | * collect all mounts that receive propagation from the mount in @list, | ||
295 | * and return these additional mounts in the same list. | ||
296 | * @list: the list of mounts to be unmounted. | ||
297 | */ | ||
298 | int propagate_umount(struct list_head *list) | ||
299 | { | ||
300 | struct vfsmount *mnt; | ||
301 | |||
302 | list_for_each_entry(mnt, list, mnt_hash) | ||
303 | __propagate_umount(mnt); | ||
304 | return 0; | ||
305 | } | ||
diff --git a/fs/pnode.h b/fs/pnode.h new file mode 100644 index 000000000000..020e1bb60fdb --- /dev/null +++ b/fs/pnode.h | |||
@@ -0,0 +1,37 @@ | |||
1 | /* | ||
2 | * linux/fs/pnode.h | ||
3 | * | ||
4 | * (C) Copyright IBM Corporation 2005. | ||
5 | * Released under GPL v2. | ||
6 | * | ||
7 | */ | ||
8 | #ifndef _LINUX_PNODE_H | ||
9 | #define _LINUX_PNODE_H | ||
10 | |||
11 | #include <linux/list.h> | ||
12 | #include <linux/mount.h> | ||
13 | |||
14 | #define IS_MNT_SHARED(mnt) (mnt->mnt_flags & MNT_SHARED) | ||
15 | #define IS_MNT_SLAVE(mnt) (mnt->mnt_master) | ||
16 | #define IS_MNT_NEW(mnt) (!mnt->mnt_namespace) | ||
17 | #define CLEAR_MNT_SHARED(mnt) (mnt->mnt_flags &= ~MNT_SHARED) | ||
18 | #define IS_MNT_UNBINDABLE(mnt) (mnt->mnt_flags & MNT_UNBINDABLE) | ||
19 | |||
20 | #define CL_EXPIRE 0x01 | ||
21 | #define CL_SLAVE 0x02 | ||
22 | #define CL_COPY_ALL 0x04 | ||
23 | #define CL_MAKE_SHARED 0x08 | ||
24 | #define CL_PROPAGATION 0x10 | ||
25 | |||
26 | static inline void set_mnt_shared(struct vfsmount *mnt) | ||
27 | { | ||
28 | mnt->mnt_flags &= ~MNT_PNODE_MASK; | ||
29 | mnt->mnt_flags |= MNT_SHARED; | ||
30 | } | ||
31 | |||
32 | void change_mnt_propagation(struct vfsmount *, int); | ||
33 | int propagate_mnt(struct vfsmount *, struct dentry *, struct vfsmount *, | ||
34 | struct list_head *); | ||
35 | int propagate_umount(struct list_head *); | ||
36 | int propagate_mount_busy(struct vfsmount *, int); | ||
37 | #endif /* _LINUX_PNODE_H */ | ||
diff --git a/fs/proc/base.c b/fs/proc/base.c index a170450aadb1..634355e16986 100644 --- a/fs/proc/base.c +++ b/fs/proc/base.c | |||
@@ -70,6 +70,7 @@ | |||
70 | #include <linux/seccomp.h> | 70 | #include <linux/seccomp.h> |
71 | #include <linux/cpuset.h> | 71 | #include <linux/cpuset.h> |
72 | #include <linux/audit.h> | 72 | #include <linux/audit.h> |
73 | #include <linux/poll.h> | ||
73 | #include "internal.h" | 74 | #include "internal.h" |
74 | 75 | ||
75 | /* | 76 | /* |
@@ -660,26 +661,38 @@ static struct file_operations proc_smaps_operations = { | |||
660 | #endif | 661 | #endif |
661 | 662 | ||
662 | extern struct seq_operations mounts_op; | 663 | extern struct seq_operations mounts_op; |
664 | struct proc_mounts { | ||
665 | struct seq_file m; | ||
666 | int event; | ||
667 | }; | ||
668 | |||
663 | static int mounts_open(struct inode *inode, struct file *file) | 669 | static int mounts_open(struct inode *inode, struct file *file) |
664 | { | 670 | { |
665 | struct task_struct *task = proc_task(inode); | 671 | struct task_struct *task = proc_task(inode); |
666 | int ret = seq_open(file, &mounts_op); | 672 | struct namespace *namespace; |
673 | struct proc_mounts *p; | ||
674 | int ret = -EINVAL; | ||
667 | 675 | ||
668 | if (!ret) { | 676 | task_lock(task); |
669 | struct seq_file *m = file->private_data; | 677 | namespace = task->namespace; |
670 | struct namespace *namespace; | 678 | if (namespace) |
671 | task_lock(task); | 679 | get_namespace(namespace); |
672 | namespace = task->namespace; | 680 | task_unlock(task); |
673 | if (namespace) | 681 | |
674 | get_namespace(namespace); | 682 | if (namespace) { |
675 | task_unlock(task); | 683 | ret = -ENOMEM; |
676 | 684 | p = kmalloc(sizeof(struct proc_mounts), GFP_KERNEL); | |
677 | if (namespace) | 685 | if (p) { |
678 | m->private = namespace; | 686 | file->private_data = &p->m; |
679 | else { | 687 | ret = seq_open(file, &mounts_op); |
680 | seq_release(inode, file); | 688 | if (!ret) { |
681 | ret = -EINVAL; | 689 | p->m.private = namespace; |
690 | p->event = namespace->event; | ||
691 | return 0; | ||
692 | } | ||
693 | kfree(p); | ||
682 | } | 694 | } |
695 | put_namespace(namespace); | ||
683 | } | 696 | } |
684 | return ret; | 697 | return ret; |
685 | } | 698 | } |
@@ -692,11 +705,30 @@ static int mounts_release(struct inode *inode, struct file *file) | |||
692 | return seq_release(inode, file); | 705 | return seq_release(inode, file); |
693 | } | 706 | } |
694 | 707 | ||
708 | static unsigned mounts_poll(struct file *file, poll_table *wait) | ||
709 | { | ||
710 | struct proc_mounts *p = file->private_data; | ||
711 | struct namespace *ns = p->m.private; | ||
712 | unsigned res = 0; | ||
713 | |||
714 | poll_wait(file, &ns->poll, wait); | ||
715 | |||
716 | spin_lock(&vfsmount_lock); | ||
717 | if (p->event != ns->event) { | ||
718 | p->event = ns->event; | ||
719 | res = POLLERR; | ||
720 | } | ||
721 | spin_unlock(&vfsmount_lock); | ||
722 | |||
723 | return res; | ||
724 | } | ||
725 | |||
695 | static struct file_operations proc_mounts_operations = { | 726 | static struct file_operations proc_mounts_operations = { |
696 | .open = mounts_open, | 727 | .open = mounts_open, |
697 | .read = seq_read, | 728 | .read = seq_read, |
698 | .llseek = seq_lseek, | 729 | .llseek = seq_lseek, |
699 | .release = mounts_release, | 730 | .release = mounts_release, |
731 | .poll = mounts_poll, | ||
700 | }; | 732 | }; |
701 | 733 | ||
702 | #define PROC_BLOCK_SIZE (3*1024) /* 4K page size but our output routines use some slack for overruns */ | 734 | #define PROC_BLOCK_SIZE (3*1024) /* 4K page size but our output routines use some slack for overruns */ |
diff --git a/fs/proc/proc_devtree.c b/fs/proc/proc_devtree.c index 6fd57f154197..fb117b74809e 100644 --- a/fs/proc/proc_devtree.c +++ b/fs/proc/proc_devtree.c | |||
@@ -49,6 +49,39 @@ static int property_read_proc(char *page, char **start, off_t off, | |||
49 | */ | 49 | */ |
50 | 50 | ||
51 | /* | 51 | /* |
52 | * Add a property to a node | ||
53 | */ | ||
54 | static struct proc_dir_entry * | ||
55 | __proc_device_tree_add_prop(struct proc_dir_entry *de, struct property *pp) | ||
56 | { | ||
57 | struct proc_dir_entry *ent; | ||
58 | |||
59 | /* | ||
60 | * Unfortunately proc_register puts each new entry | ||
61 | * at the beginning of the list. So we rearrange them. | ||
62 | */ | ||
63 | ent = create_proc_read_entry(pp->name, | ||
64 | strncmp(pp->name, "security-", 9) | ||
65 | ? S_IRUGO : S_IRUSR, de, | ||
66 | property_read_proc, pp); | ||
67 | if (ent == NULL) | ||
68 | return NULL; | ||
69 | |||
70 | if (!strncmp(pp->name, "security-", 9)) | ||
71 | ent->size = 0; /* don't leak number of password chars */ | ||
72 | else | ||
73 | ent->size = pp->length; | ||
74 | |||
75 | return ent; | ||
76 | } | ||
77 | |||
78 | |||
79 | void proc_device_tree_add_prop(struct proc_dir_entry *pde, struct property *prop) | ||
80 | { | ||
81 | __proc_device_tree_add_prop(pde, prop); | ||
82 | } | ||
83 | |||
84 | /* | ||
52 | * Process a node, adding entries for its children and its properties. | 85 | * Process a node, adding entries for its children and its properties. |
53 | */ | 86 | */ |
54 | void proc_device_tree_add_node(struct device_node *np, | 87 | void proc_device_tree_add_node(struct device_node *np, |
@@ -57,11 +90,9 @@ void proc_device_tree_add_node(struct device_node *np, | |||
57 | struct property *pp; | 90 | struct property *pp; |
58 | struct proc_dir_entry *ent; | 91 | struct proc_dir_entry *ent; |
59 | struct device_node *child; | 92 | struct device_node *child; |
60 | struct proc_dir_entry *list = NULL, **lastp; | ||
61 | const char *p; | 93 | const char *p; |
62 | 94 | ||
63 | set_node_proc_entry(np, de); | 95 | set_node_proc_entry(np, de); |
64 | lastp = &list; | ||
65 | for (child = NULL; (child = of_get_next_child(np, child));) { | 96 | for (child = NULL; (child = of_get_next_child(np, child));) { |
66 | p = strrchr(child->full_name, '/'); | 97 | p = strrchr(child->full_name, '/'); |
67 | if (!p) | 98 | if (!p) |
@@ -71,9 +102,6 @@ void proc_device_tree_add_node(struct device_node *np, | |||
71 | ent = proc_mkdir(p, de); | 102 | ent = proc_mkdir(p, de); |
72 | if (ent == 0) | 103 | if (ent == 0) |
73 | break; | 104 | break; |
74 | *lastp = ent; | ||
75 | ent->next = NULL; | ||
76 | lastp = &ent->next; | ||
77 | proc_device_tree_add_node(child, ent); | 105 | proc_device_tree_add_node(child, ent); |
78 | } | 106 | } |
79 | of_node_put(child); | 107 | of_node_put(child); |
@@ -84,7 +112,7 @@ void proc_device_tree_add_node(struct device_node *np, | |||
84 | * properties are quite unimportant for us though, thus we | 112 | * properties are quite unimportant for us though, thus we |
85 | * simply "skip" them here, but we do have to check. | 113 | * simply "skip" them here, but we do have to check. |
86 | */ | 114 | */ |
87 | for (ent = list; ent != NULL; ent = ent->next) | 115 | for (ent = de->subdir; ent != NULL; ent = ent->next) |
88 | if (!strcmp(ent->name, pp->name)) | 116 | if (!strcmp(ent->name, pp->name)) |
89 | break; | 117 | break; |
90 | if (ent != NULL) { | 118 | if (ent != NULL) { |
@@ -94,25 +122,10 @@ void proc_device_tree_add_node(struct device_node *np, | |||
94 | continue; | 122 | continue; |
95 | } | 123 | } |
96 | 124 | ||
97 | /* | 125 | ent = __proc_device_tree_add_prop(de, pp); |
98 | * Unfortunately proc_register puts each new entry | ||
99 | * at the beginning of the list. So we rearrange them. | ||
100 | */ | ||
101 | ent = create_proc_read_entry(pp->name, | ||
102 | strncmp(pp->name, "security-", 9) | ||
103 | ? S_IRUGO : S_IRUSR, de, | ||
104 | property_read_proc, pp); | ||
105 | if (ent == 0) | 126 | if (ent == 0) |
106 | break; | 127 | break; |
107 | if (!strncmp(pp->name, "security-", 9)) | ||
108 | ent->size = 0; /* don't leak number of password chars */ | ||
109 | else | ||
110 | ent->size = pp->length; | ||
111 | ent->next = NULL; | ||
112 | *lastp = ent; | ||
113 | lastp = &ent->next; | ||
114 | } | 128 | } |
115 | de->subdir = list; | ||
116 | } | 129 | } |
117 | 130 | ||
118 | /* | 131 | /* |
diff --git a/fs/quota.c b/fs/quota.c index f5d1cff55196..612e04db4b93 100644 --- a/fs/quota.c +++ b/fs/quota.c | |||
@@ -15,6 +15,7 @@ | |||
15 | #include <linux/security.h> | 15 | #include <linux/security.h> |
16 | #include <linux/syscalls.h> | 16 | #include <linux/syscalls.h> |
17 | #include <linux/buffer_head.h> | 17 | #include <linux/buffer_head.h> |
18 | #include <linux/quotaops.h> | ||
18 | 19 | ||
19 | /* Check validity of generic quotactl commands */ | 20 | /* Check validity of generic quotactl commands */ |
20 | static int generic_quotactl_valid(struct super_block *sb, int type, int cmd, qid_t id) | 21 | static int generic_quotactl_valid(struct super_block *sb, int type, int cmd, qid_t id) |
@@ -118,6 +119,10 @@ static int xqm_quotactl_valid(struct super_block *sb, int type, int cmd, qid_t i | |||
118 | if (!sb->s_qcop->get_xquota) | 119 | if (!sb->s_qcop->get_xquota) |
119 | return -ENOSYS; | 120 | return -ENOSYS; |
120 | break; | 121 | break; |
122 | case Q_XQUOTASYNC: | ||
123 | if (!sb->s_qcop->quota_sync) | ||
124 | return -ENOSYS; | ||
125 | break; | ||
121 | default: | 126 | default: |
122 | return -EINVAL; | 127 | return -EINVAL; |
123 | } | 128 | } |
@@ -128,7 +133,7 @@ static int xqm_quotactl_valid(struct super_block *sb, int type, int cmd, qid_t i | |||
128 | (type == XQM_GRPQUOTA && !in_egroup_p(id))) && | 133 | (type == XQM_GRPQUOTA && !in_egroup_p(id))) && |
129 | !capable(CAP_SYS_ADMIN)) | 134 | !capable(CAP_SYS_ADMIN)) |
130 | return -EPERM; | 135 | return -EPERM; |
131 | } else if (cmd != Q_XGETQSTAT) { | 136 | } else if (cmd != Q_XGETQSTAT && cmd != Q_XQUOTASYNC) { |
132 | if (!capable(CAP_SYS_ADMIN)) | 137 | if (!capable(CAP_SYS_ADMIN)) |
133 | return -EPERM; | 138 | return -EPERM; |
134 | } | 139 | } |
@@ -322,6 +327,8 @@ static int do_quotactl(struct super_block *sb, int type, int cmd, qid_t id, void | |||
322 | return -EFAULT; | 327 | return -EFAULT; |
323 | return 0; | 328 | return 0; |
324 | } | 329 | } |
330 | case Q_XQUOTASYNC: | ||
331 | return sb->s_qcop->quota_sync(sb, type); | ||
325 | /* We never reach here unless validity check is broken */ | 332 | /* We never reach here unless validity check is broken */ |
326 | default: | 333 | default: |
327 | BUG(); | 334 | BUG(); |
diff --git a/fs/reiserfs/file.c b/fs/reiserfs/file.c index c20babd6216d..7892a865b58a 100644 --- a/fs/reiserfs/file.c +++ b/fs/reiserfs/file.c | |||
@@ -251,12 +251,12 @@ static int reiserfs_allocate_blocks_for_region(struct reiserfs_transaction_handl | |||
251 | blocks_to_allocate, | 251 | blocks_to_allocate, |
252 | blocks_to_allocate); | 252 | blocks_to_allocate); |
253 | if (res != CARRY_ON) { | 253 | if (res != CARRY_ON) { |
254 | res = -ENOSPC; | 254 | res = res == QUOTA_EXCEEDED ? -EDQUOT : -ENOSPC; |
255 | pathrelse(&path); | 255 | pathrelse(&path); |
256 | goto error_exit; | 256 | goto error_exit; |
257 | } | 257 | } |
258 | } else { | 258 | } else { |
259 | res = -ENOSPC; | 259 | res = res == QUOTA_EXCEEDED ? -EDQUOT : -ENOSPC; |
260 | pathrelse(&path); | 260 | pathrelse(&path); |
261 | goto error_exit; | 261 | goto error_exit; |
262 | } | 262 | } |
diff --git a/fs/seq_file.c b/fs/seq_file.c index 38ef913767ff..7c40570b71dc 100644 --- a/fs/seq_file.c +++ b/fs/seq_file.c | |||
@@ -28,13 +28,17 @@ | |||
28 | */ | 28 | */ |
29 | int seq_open(struct file *file, struct seq_operations *op) | 29 | int seq_open(struct file *file, struct seq_operations *op) |
30 | { | 30 | { |
31 | struct seq_file *p = kmalloc(sizeof(*p), GFP_KERNEL); | 31 | struct seq_file *p = file->private_data; |
32 | if (!p) | 32 | |
33 | return -ENOMEM; | 33 | if (!p) { |
34 | p = kmalloc(sizeof(*p), GFP_KERNEL); | ||
35 | if (!p) | ||
36 | return -ENOMEM; | ||
37 | file->private_data = p; | ||
38 | } | ||
34 | memset(p, 0, sizeof(*p)); | 39 | memset(p, 0, sizeof(*p)); |
35 | sema_init(&p->sem, 1); | 40 | sema_init(&p->sem, 1); |
36 | p->op = op; | 41 | p->op = op; |
37 | file->private_data = p; | ||
38 | 42 | ||
39 | /* | 43 | /* |
40 | * Wrappers around seq_open(e.g. swaps_open) need to be | 44 | * Wrappers around seq_open(e.g. swaps_open) need to be |
diff --git a/fs/smbfs/request.c b/fs/smbfs/request.c index 2d85dd7415bb..a0f296d9928a 100644 --- a/fs/smbfs/request.c +++ b/fs/smbfs/request.c | |||
@@ -786,8 +786,7 @@ int smb_request_recv(struct smb_sb_info *server) | |||
786 | /* We should never be called with any of these states */ | 786 | /* We should never be called with any of these states */ |
787 | case SMB_RECV_END: | 787 | case SMB_RECV_END: |
788 | case SMB_RECV_REQUEST: | 788 | case SMB_RECV_REQUEST: |
789 | server->rstate = SMB_RECV_END; | 789 | BUG(); |
790 | break; | ||
791 | } | 790 | } |
792 | 791 | ||
793 | if (result < 0) { | 792 | if (result < 0) { |
diff --git a/fs/smbfs/symlink.c b/fs/smbfs/symlink.c index 0c64bc3a0127..cdc53c4fb381 100644 --- a/fs/smbfs/symlink.c +++ b/fs/smbfs/symlink.c | |||
@@ -45,7 +45,7 @@ static void *smb_follow_link(struct dentry *dentry, struct nameidata *nd) | |||
45 | int len = smb_proc_read_link(server_from_dentry(dentry), | 45 | int len = smb_proc_read_link(server_from_dentry(dentry), |
46 | dentry, link, PATH_MAX - 1); | 46 | dentry, link, PATH_MAX - 1); |
47 | if (len < 0) { | 47 | if (len < 0) { |
48 | putname(link); | 48 | __putname(link); |
49 | link = ERR_PTR(len); | 49 | link = ERR_PTR(len); |
50 | } else { | 50 | } else { |
51 | link[len] = 0; | 51 | link[len] = 0; |
@@ -59,7 +59,7 @@ static void smb_put_link(struct dentry *dentry, struct nameidata *nd, void *p) | |||
59 | { | 59 | { |
60 | char *s = nd_get_link(nd); | 60 | char *s = nd_get_link(nd); |
61 | if (!IS_ERR(s)) | 61 | if (!IS_ERR(s)) |
62 | putname(s); | 62 | __putname(s); |
63 | } | 63 | } |
64 | 64 | ||
65 | struct inode_operations smb_link_inode_operations = | 65 | struct inode_operations smb_link_inode_operations = |
diff --git a/fs/super.c b/fs/super.c index f60155ec7780..6689dded3c84 100644 --- a/fs/super.c +++ b/fs/super.c | |||
@@ -171,6 +171,7 @@ void deactivate_super(struct super_block *s) | |||
171 | if (atomic_dec_and_lock(&s->s_active, &sb_lock)) { | 171 | if (atomic_dec_and_lock(&s->s_active, &sb_lock)) { |
172 | s->s_count -= S_BIAS-1; | 172 | s->s_count -= S_BIAS-1; |
173 | spin_unlock(&sb_lock); | 173 | spin_unlock(&sb_lock); |
174 | DQUOT_OFF(s); | ||
174 | down_write(&s->s_umount); | 175 | down_write(&s->s_umount); |
175 | fs->kill_sb(s); | 176 | fs->kill_sb(s); |
176 | put_filesystem(fs); | 177 | put_filesystem(fs); |
@@ -474,8 +475,6 @@ rescan: | |||
474 | return NULL; | 475 | return NULL; |
475 | } | 476 | } |
476 | 477 | ||
477 | EXPORT_SYMBOL(user_get_super); | ||
478 | |||
479 | asmlinkage long sys_ustat(unsigned dev, struct ustat __user * ubuf) | 478 | asmlinkage long sys_ustat(unsigned dev, struct ustat __user * ubuf) |
480 | { | 479 | { |
481 | struct super_block *s; | 480 | struct super_block *s; |
diff --git a/fs/udf/file.c b/fs/udf/file.c index bb40d63f328f..01f520c71dc1 100644 --- a/fs/udf/file.c +++ b/fs/udf/file.c | |||
@@ -186,7 +186,7 @@ int udf_ioctl(struct inode *inode, struct file *filp, unsigned int cmd, | |||
186 | { | 186 | { |
187 | int result = -EINVAL; | 187 | int result = -EINVAL; |
188 | 188 | ||
189 | if ( permission(inode, MAY_READ, NULL) != 0 ) | 189 | if ( file_permission(filp, MAY_READ) != 0 ) |
190 | { | 190 | { |
191 | udf_debug("no permission to access inode %lu\n", | 191 | udf_debug("no permission to access inode %lu\n", |
192 | inode->i_ino); | 192 | inode->i_ino); |
diff --git a/fs/udf/udf_sb.h b/fs/udf/udf_sb.h index 0e54922daa09..663669810be6 100644 --- a/fs/udf/udf_sb.h +++ b/fs/udf/udf_sb.h | |||
@@ -39,8 +39,7 @@ static inline struct udf_sb_info *UDF_SB(struct super_block *sb) | |||
39 | {\ | 39 | {\ |
40 | if (UDF_SB(X))\ | 40 | if (UDF_SB(X))\ |
41 | {\ | 41 | {\ |
42 | if (UDF_SB_PARTMAPS(X))\ | 42 | kfree(UDF_SB_PARTMAPS(X));\ |
43 | kfree(UDF_SB_PARTMAPS(X));\ | ||
44 | UDF_SB_PARTMAPS(X) = NULL;\ | 43 | UDF_SB_PARTMAPS(X) = NULL;\ |
45 | }\ | 44 | }\ |
46 | } | 45 | } |
diff --git a/fs/ufs/super.c b/fs/ufs/super.c index f036d694ba5a..54828ebcf1ba 100644 --- a/fs/ufs/super.c +++ b/fs/ufs/super.c | |||
@@ -472,13 +472,14 @@ static int ufs_read_cylinder_structures (struct super_block *sb) { | |||
472 | return 1; | 472 | return 1; |
473 | 473 | ||
474 | failed: | 474 | failed: |
475 | if (base) kfree (base); | 475 | kfree (base); |
476 | if (sbi->s_ucg) { | 476 | if (sbi->s_ucg) { |
477 | for (i = 0; i < uspi->s_ncg; i++) | 477 | for (i = 0; i < uspi->s_ncg; i++) |
478 | if (sbi->s_ucg[i]) brelse (sbi->s_ucg[i]); | 478 | if (sbi->s_ucg[i]) |
479 | brelse (sbi->s_ucg[i]); | ||
479 | kfree (sbi->s_ucg); | 480 | kfree (sbi->s_ucg); |
480 | for (i = 0; i < UFS_MAX_GROUP_LOADED; i++) | 481 | for (i = 0; i < UFS_MAX_GROUP_LOADED; i++) |
481 | if (sbi->s_ucpi[i]) kfree (sbi->s_ucpi[i]); | 482 | kfree (sbi->s_ucpi[i]); |
482 | } | 483 | } |
483 | UFSD(("EXIT (FAILED)\n")) | 484 | UFSD(("EXIT (FAILED)\n")) |
484 | return 0; | 485 | return 0; |
@@ -981,9 +982,10 @@ magic_found: | |||
981 | dalloc_failed: | 982 | dalloc_failed: |
982 | iput(inode); | 983 | iput(inode); |
983 | failed: | 984 | failed: |
984 | if (ubh) ubh_brelse_uspi (uspi); | 985 | if (ubh) |
985 | if (uspi) kfree (uspi); | 986 | ubh_brelse_uspi (uspi); |
986 | if (sbi) kfree(sbi); | 987 | kfree (uspi); |
988 | kfree(sbi); | ||
987 | sb->s_fs_info = NULL; | 989 | sb->s_fs_info = NULL; |
988 | UFSD(("EXIT (FAILED)\n")) | 990 | UFSD(("EXIT (FAILED)\n")) |
989 | return -EINVAL; | 991 | return -EINVAL; |
diff --git a/fs/xattr.c b/fs/xattr.c index f6e00c0e114f..a9db22557998 100644 --- a/fs/xattr.c +++ b/fs/xattr.c | |||
@@ -74,8 +74,7 @@ setxattr(struct dentry *d, char __user *name, void __user *value, | |||
74 | } | 74 | } |
75 | out: | 75 | out: |
76 | up(&d->d_inode->i_sem); | 76 | up(&d->d_inode->i_sem); |
77 | if (kvalue) | 77 | kfree(kvalue); |
78 | kfree(kvalue); | ||
79 | return error; | 78 | return error; |
80 | } | 79 | } |
81 | 80 | ||
@@ -173,8 +172,7 @@ getxattr(struct dentry *d, char __user *name, void __user *value, size_t size) | |||
173 | error = -E2BIG; | 172 | error = -E2BIG; |
174 | } | 173 | } |
175 | out: | 174 | out: |
176 | if (kvalue) | 175 | kfree(kvalue); |
177 | kfree(kvalue); | ||
178 | return error; | 176 | return error; |
179 | } | 177 | } |
180 | 178 | ||
@@ -259,8 +257,7 @@ listxattr(struct dentry *d, char __user *list, size_t size) | |||
259 | error = -E2BIG; | 257 | error = -E2BIG; |
260 | } | 258 | } |
261 | out: | 259 | out: |
262 | if (klist) | 260 | kfree(klist); |
263 | kfree(klist); | ||
264 | return error; | 261 | return error; |
265 | } | 262 | } |
266 | 263 | ||
diff --git a/fs/xfs/Kconfig b/fs/xfs/Kconfig index 8e8f32dabe53..bac27d66151d 100644 --- a/fs/xfs/Kconfig +++ b/fs/xfs/Kconfig | |||
@@ -24,7 +24,7 @@ config XFS_EXPORT | |||
24 | default y | 24 | default y |
25 | 25 | ||
26 | config XFS_QUOTA | 26 | config XFS_QUOTA |
27 | tristate "XFS Quota support" | 27 | bool "XFS Quota support" |
28 | depends on XFS_FS | 28 | depends on XFS_FS |
29 | help | 29 | help |
30 | If you say Y here, you will be able to set limits for disk usage on | 30 | If you say Y here, you will be able to set limits for disk usage on |
diff --git a/fs/xfs/Makefile-linux-2.6 b/fs/xfs/Makefile-linux-2.6 index d8c87fa21ad1..97bd4743b461 100644 --- a/fs/xfs/Makefile-linux-2.6 +++ b/fs/xfs/Makefile-linux-2.6 | |||
@@ -109,7 +109,6 @@ xfs-y += xfs_alloc.o \ | |||
109 | xfs_dfrag.o \ | 109 | xfs_dfrag.o \ |
110 | xfs_log.o \ | 110 | xfs_log.o \ |
111 | xfs_log_recover.o \ | 111 | xfs_log_recover.o \ |
112 | xfs_macros.o \ | ||
113 | xfs_mount.o \ | 112 | xfs_mount.o \ |
114 | xfs_rename.o \ | 113 | xfs_rename.o \ |
115 | xfs_trans.o \ | 114 | xfs_trans.o \ |
diff --git a/fs/xfs/linux-2.6/kmem.c b/fs/xfs/linux-2.6/kmem.c index 3c92162dc728..aba7fcf881a2 100644 --- a/fs/xfs/linux-2.6/kmem.c +++ b/fs/xfs/linux-2.6/kmem.c | |||
@@ -1,49 +1,32 @@ | |||
1 | /* | 1 | /* |
2 | * Copyright (c) 2000-2004 Silicon Graphics, Inc. All Rights Reserved. | 2 | * Copyright (c) 2000-2005 Silicon Graphics, Inc. |
3 | * All Rights Reserved. | ||
3 | * | 4 | * |
4 | * This program is free software; you can redistribute it and/or modify it | 5 | * This program is free software; you can redistribute it and/or |
5 | * under the terms of version 2 of the GNU General Public License as | 6 | * modify it under the terms of the GNU General Public License as |
6 | * published by the Free Software Foundation. | 7 | * published by the Free Software Foundation. |
7 | * | 8 | * |
8 | * This program is distributed in the hope that it would be useful, but | 9 | * This program is distributed in the hope that it would be useful, |
9 | * WITHOUT ANY WARRANTY; without even the implied warranty of | 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
12 | * GNU General Public License for more details. | ||
11 | * | 13 | * |
12 | * Further, this software is distributed without any warranty that it is | 14 | * You should have received a copy of the GNU General Public License |
13 | * free of the rightful claim of any third person regarding infringement | 15 | * along with this program; if not, write the Free Software Foundation, |
14 | * or the like. Any license provided herein, whether implied or | 16 | * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
15 | * otherwise, applies only to this software file. Patent licenses, if | ||
16 | * any, provided herein do not apply to combinations of this program with | ||
17 | * other software, or any other product whatsoever. | ||
18 | * | ||
19 | * You should have received a copy of the GNU General Public License along | ||
20 | * with this program; if not, write the Free Software Foundation, Inc., 59 | ||
21 | * Temple Place - Suite 330, Boston MA 02111-1307, USA. | ||
22 | * | ||
23 | * Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy, | ||
24 | * Mountain View, CA 94043, or: | ||
25 | * | ||
26 | * http://www.sgi.com | ||
27 | * | ||
28 | * For further information regarding this notice, see: | ||
29 | * | ||
30 | * http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/ | ||
31 | */ | 17 | */ |
32 | |||
33 | #include <linux/sched.h> | 18 | #include <linux/sched.h> |
34 | #include <linux/mm.h> | 19 | #include <linux/mm.h> |
35 | #include <linux/vmalloc.h> | 20 | #include <linux/vmalloc.h> |
36 | #include <linux/highmem.h> | 21 | #include <linux/highmem.h> |
37 | #include <linux/swap.h> | 22 | #include <linux/swap.h> |
38 | #include <linux/blkdev.h> | 23 | #include <linux/blkdev.h> |
39 | |||
40 | #include "time.h" | 24 | #include "time.h" |
41 | #include "kmem.h" | 25 | #include "kmem.h" |
42 | 26 | ||
43 | #define MAX_VMALLOCS 6 | 27 | #define MAX_VMALLOCS 6 |
44 | #define MAX_SLAB_SIZE 0x20000 | 28 | #define MAX_SLAB_SIZE 0x20000 |
45 | 29 | ||
46 | |||
47 | void * | 30 | void * |
48 | kmem_alloc(size_t size, unsigned int __nocast flags) | 31 | kmem_alloc(size_t size, unsigned int __nocast flags) |
49 | { | 32 | { |
diff --git a/fs/xfs/linux-2.6/kmem.h b/fs/xfs/linux-2.6/kmem.h index f4bb78c268c0..c64a29cdfff3 100644 --- a/fs/xfs/linux-2.6/kmem.h +++ b/fs/xfs/linux-2.6/kmem.h | |||
@@ -1,33 +1,19 @@ | |||
1 | /* | 1 | /* |
2 | * Copyright (c) 2000-2004 Silicon Graphics, Inc. All Rights Reserved. | 2 | * Copyright (c) 2000-2005 Silicon Graphics, Inc. |
3 | * All Rights Reserved. | ||
3 | * | 4 | * |
4 | * This program is free software; you can redistribute it and/or modify it | 5 | * This program is free software; you can redistribute it and/or |
5 | * under the terms of version 2 of the GNU General Public License as | 6 | * modify it under the terms of the GNU General Public License as |
6 | * published by the Free Software Foundation. | 7 | * published by the Free Software Foundation. |
7 | * | 8 | * |
8 | * This program is distributed in the hope that it would be useful, but | 9 | * This program is distributed in the hope that it would be useful, |
9 | * WITHOUT ANY WARRANTY; without even the implied warranty of | 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
12 | * GNU General Public License for more details. | ||
11 | * | 13 | * |
12 | * Further, this software is distributed without any warranty that it is | 14 | * You should have received a copy of the GNU General Public License |
13 | * free of the rightful claim of any third person regarding infringement | 15 | * along with this program; if not, write the Free Software Foundation, |
14 | * or the like. Any license provided herein, whether implied or | 16 | * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
15 | * otherwise, applies only to this software file. Patent licenses, if | ||
16 | * any, provided herein do not apply to combinations of this program with | ||
17 | * other software, or any other product whatsoever. | ||
18 | * | ||
19 | * You should have received a copy of the GNU General Public License along | ||
20 | * with this program; if not, write the Free Software Foundation, Inc., 59 | ||
21 | * Temple Place - Suite 330, Boston MA 02111-1307, USA. | ||
22 | * | ||
23 | * Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy, | ||
24 | * Mountain View, CA 94043, or: | ||
25 | * | ||
26 | * http://www.sgi.com | ||
27 | * | ||
28 | * For further information regarding this notice, see: | ||
29 | * | ||
30 | * http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/ | ||
31 | */ | 17 | */ |
32 | #ifndef __XFS_SUPPORT_KMEM_H__ | 18 | #ifndef __XFS_SUPPORT_KMEM_H__ |
33 | #define __XFS_SUPPORT_KMEM_H__ | 19 | #define __XFS_SUPPORT_KMEM_H__ |
@@ -44,8 +30,8 @@ | |||
44 | #define KM_NOFS 0x0004u | 30 | #define KM_NOFS 0x0004u |
45 | #define KM_MAYFAIL 0x0008u | 31 | #define KM_MAYFAIL 0x0008u |
46 | 32 | ||
47 | #define kmem_zone kmem_cache_s | 33 | #define kmem_zone kmem_cache |
48 | #define kmem_zone_t kmem_cache_t | 34 | #define kmem_zone_t struct kmem_cache |
49 | 35 | ||
50 | typedef unsigned long xfs_pflags_t; | 36 | typedef unsigned long xfs_pflags_t; |
51 | 37 | ||
@@ -83,7 +69,7 @@ typedef unsigned long xfs_pflags_t; | |||
83 | 69 | ||
84 | static __inline gfp_t kmem_flags_convert(unsigned int __nocast flags) | 70 | static __inline gfp_t kmem_flags_convert(unsigned int __nocast flags) |
85 | { | 71 | { |
86 | gfp_t lflags = __GFP_NOWARN; /* we'll report problems, if need be */ | 72 | gfp_t lflags = __GFP_NOWARN; /* we'll report problems, if need be */ |
87 | 73 | ||
88 | #ifdef DEBUG | 74 | #ifdef DEBUG |
89 | if (unlikely(flags & ~(KM_SLEEP|KM_NOSLEEP|KM_NOFS|KM_MAYFAIL))) { | 75 | if (unlikely(flags & ~(KM_SLEEP|KM_NOSLEEP|KM_NOFS|KM_MAYFAIL))) { |
@@ -102,7 +88,7 @@ static __inline gfp_t kmem_flags_convert(unsigned int __nocast flags) | |||
102 | if (PFLAGS_TEST_FSTRANS() || (flags & KM_NOFS)) | 88 | if (PFLAGS_TEST_FSTRANS() || (flags & KM_NOFS)) |
103 | lflags &= ~__GFP_FS; | 89 | lflags &= ~__GFP_FS; |
104 | } | 90 | } |
105 | 91 | ||
106 | return lflags; | 92 | return lflags; |
107 | } | 93 | } |
108 | 94 | ||
@@ -125,13 +111,13 @@ kmem_zone_destroy(kmem_zone_t *zone) | |||
125 | BUG(); | 111 | BUG(); |
126 | } | 112 | } |
127 | 113 | ||
128 | extern void *kmem_zone_zalloc(kmem_zone_t *, unsigned int __nocast); | 114 | extern void *kmem_zone_zalloc(kmem_zone_t *, unsigned int __nocast); |
129 | extern void *kmem_zone_alloc(kmem_zone_t *, unsigned int __nocast); | 115 | extern void *kmem_zone_alloc(kmem_zone_t *, unsigned int __nocast); |
130 | 116 | ||
131 | extern void *kmem_alloc(size_t, unsigned int __nocast); | 117 | extern void *kmem_alloc(size_t, unsigned int __nocast); |
132 | extern void *kmem_realloc(void *, size_t, size_t, unsigned int __nocast); | 118 | extern void *kmem_realloc(void *, size_t, size_t, unsigned int __nocast); |
133 | extern void *kmem_zalloc(size_t, unsigned int __nocast); | 119 | extern void *kmem_zalloc(size_t, unsigned int __nocast); |
134 | extern void kmem_free(void *, size_t); | 120 | extern void kmem_free(void *, size_t); |
135 | 121 | ||
136 | typedef struct shrinker *kmem_shaker_t; | 122 | typedef struct shrinker *kmem_shaker_t; |
137 | typedef int (*kmem_shake_func_t)(int, gfp_t); | 123 | typedef int (*kmem_shake_func_t)(int, gfp_t); |
diff --git a/fs/xfs/linux-2.6/mrlock.h b/fs/xfs/linux-2.6/mrlock.h index d2c11a098ff2..16b44c3c2362 100644 --- a/fs/xfs/linux-2.6/mrlock.h +++ b/fs/xfs/linux-2.6/mrlock.h | |||
@@ -1,33 +1,19 @@ | |||
1 | /* | 1 | /* |
2 | * Copyright (c) 2000-2004 Silicon Graphics, Inc. All Rights Reserved. | 2 | * Copyright (c) 2000-2005 Silicon Graphics, Inc. |
3 | * All Rights Reserved. | ||
3 | * | 4 | * |
4 | * This program is free software; you can redistribute it and/or modify it | 5 | * This program is free software; you can redistribute it and/or |
5 | * under the terms of version 2 of the GNU General Public License as | 6 | * modify it under the terms of the GNU General Public License as |
6 | * published by the Free Software Foundation. | 7 | * published by the Free Software Foundation. |
7 | * | 8 | * |
8 | * This program is distributed in the hope that it would be useful, but | 9 | * This program is distributed in the hope that it would be useful, |
9 | * WITHOUT ANY WARRANTY; without even the implied warranty of | 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
12 | * GNU General Public License for more details. | ||
11 | * | 13 | * |
12 | * Further, this software is distributed without any warranty that it is | 14 | * You should have received a copy of the GNU General Public License |
13 | * free of the rightful claim of any third person regarding infringement | 15 | * along with this program; if not, write the Free Software Foundation, |
14 | * or the like. Any license provided herein, whether implied or | 16 | * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
15 | * otherwise, applies only to this software file. Patent licenses, if | ||
16 | * any, provided herein do not apply to combinations of this program with | ||
17 | * other software, or any other product whatsoever. | ||
18 | * | ||
19 | * You should have received a copy of the GNU General Public License along | ||
20 | * with this program; if not, write the Free Software Foundation, Inc., 59 | ||
21 | * Temple Place - Suite 330, Boston MA 02111-1307, USA. | ||
22 | * | ||
23 | * Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy, | ||
24 | * Mountain View, CA 94043, or: | ||
25 | * | ||
26 | * http://www.sgi.com | ||
27 | * | ||
28 | * For further information regarding this notice, see: | ||
29 | * | ||
30 | * http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/ | ||
31 | */ | 17 | */ |
32 | #ifndef __XFS_SUPPORT_MRLOCK_H__ | 18 | #ifndef __XFS_SUPPORT_MRLOCK_H__ |
33 | #define __XFS_SUPPORT_MRLOCK_H__ | 19 | #define __XFS_SUPPORT_MRLOCK_H__ |
diff --git a/fs/xfs/linux-2.6/mutex.h b/fs/xfs/linux-2.6/mutex.h index 0b296bb944cb..ce773d89a923 100644 --- a/fs/xfs/linux-2.6/mutex.h +++ b/fs/xfs/linux-2.6/mutex.h | |||
@@ -1,33 +1,19 @@ | |||
1 | /* | 1 | /* |
2 | * Copyright (c) 2000-2003 Silicon Graphics, Inc. All Rights Reserved. | 2 | * Copyright (c) 2000-2003,2005 Silicon Graphics, Inc. |
3 | * All Rights Reserved. | ||
3 | * | 4 | * |
4 | * This program is free software; you can redistribute it and/or modify it | 5 | * This program is free software; you can redistribute it and/or |
5 | * under the terms of version 2 of the GNU General Public License as | 6 | * modify it under the terms of the GNU General Public License as |
6 | * published by the Free Software Foundation. | 7 | * published by the Free Software Foundation. |
7 | * | 8 | * |
8 | * This program is distributed in the hope that it would be useful, but | 9 | * This program is distributed in the hope that it would be useful, |
9 | * WITHOUT ANY WARRANTY; without even the implied warranty of | 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
12 | * GNU General Public License for more details. | ||
11 | * | 13 | * |
12 | * Further, this software is distributed without any warranty that it is | 14 | * You should have received a copy of the GNU General Public License |
13 | * free of the rightful claim of any third person regarding infringement | 15 | * along with this program; if not, write the Free Software Foundation, |
14 | * or the like. Any license provided herein, whether implied or | 16 | * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
15 | * otherwise, applies only to this software file. Patent licenses, if | ||
16 | * any, provided herein do not apply to combinations of this program with | ||
17 | * other software, or any other product whatsoever. | ||
18 | * | ||
19 | * You should have received a copy of the GNU General Public License along | ||
20 | * with this program; if not, write the Free Software Foundation, Inc., 59 | ||
21 | * Temple Place - Suite 330, Boston MA 02111-1307, USA. | ||
22 | * | ||
23 | * Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy, | ||
24 | * Mountain View, CA 94043, or: | ||
25 | * | ||
26 | * http://www.sgi.com | ||
27 | * | ||
28 | * For further information regarding this notice, see: | ||
29 | * | ||
30 | * http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/ | ||
31 | */ | 17 | */ |
32 | #ifndef __XFS_SUPPORT_MUTEX_H__ | 18 | #ifndef __XFS_SUPPORT_MUTEX_H__ |
33 | #define __XFS_SUPPORT_MUTEX_H__ | 19 | #define __XFS_SUPPORT_MUTEX_H__ |
diff --git a/fs/xfs/linux-2.6/sema.h b/fs/xfs/linux-2.6/sema.h index 30b67b4e1cbf..194a84490bd1 100644 --- a/fs/xfs/linux-2.6/sema.h +++ b/fs/xfs/linux-2.6/sema.h | |||
@@ -1,33 +1,19 @@ | |||
1 | /* | 1 | /* |
2 | * Copyright (c) 2000-2002 Silicon Graphics, Inc. All Rights Reserved. | 2 | * Copyright (c) 2000-2002,2005 Silicon Graphics, Inc. |
3 | * All Rights Reserved. | ||
3 | * | 4 | * |
4 | * This program is free software; you can redistribute it and/or modify it | 5 | * This program is free software; you can redistribute it and/or |
5 | * under the terms of version 2 of the GNU General Public License as | 6 | * modify it under the terms of the GNU General Public License as |
6 | * published by the Free Software Foundation. | 7 | * published by the Free Software Foundation. |
7 | * | 8 | * |
8 | * This program is distributed in the hope that it would be useful, but | 9 | * This program is distributed in the hope that it would be useful, |
9 | * WITHOUT ANY WARRANTY; without even the implied warranty of | 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
12 | * GNU General Public License for more details. | ||
11 | * | 13 | * |
12 | * Further, this software is distributed without any warranty that it is | 14 | * You should have received a copy of the GNU General Public License |
13 | * free of the rightful claim of any third person regarding infringement | 15 | * along with this program; if not, write the Free Software Foundation, |
14 | * or the like. Any license provided herein, whether implied or | 16 | * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
15 | * otherwise, applies only to this software file. Patent licenses, if | ||
16 | * any, provided herein do not apply to combinations of this program with | ||
17 | * other software, or any other product whatsoever. | ||
18 | * | ||
19 | * You should have received a copy of the GNU General Public License along | ||
20 | * with this program; if not, write the Free Software Foundation, Inc., 59 | ||
21 | * Temple Place - Suite 330, Boston MA 02111-1307, USA. | ||
22 | * | ||
23 | * Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy, | ||
24 | * Mountain View, CA 94043, or: | ||
25 | * | ||
26 | * http://www.sgi.com | ||
27 | * | ||
28 | * For further information regarding this notice, see: | ||
29 | * | ||
30 | * http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/ | ||
31 | */ | 17 | */ |
32 | #ifndef __XFS_SUPPORT_SEMA_H__ | 18 | #ifndef __XFS_SUPPORT_SEMA_H__ |
33 | #define __XFS_SUPPORT_SEMA_H__ | 19 | #define __XFS_SUPPORT_SEMA_H__ |
diff --git a/fs/xfs/linux-2.6/spin.h b/fs/xfs/linux-2.6/spin.h index 0039504069a5..50a6191178f4 100644 --- a/fs/xfs/linux-2.6/spin.h +++ b/fs/xfs/linux-2.6/spin.h | |||
@@ -1,33 +1,19 @@ | |||
1 | /* | 1 | /* |
2 | * Copyright (c) 2000-2002 Silicon Graphics, Inc. All Rights Reserved. | 2 | * Copyright (c) 2000-2002,2005 Silicon Graphics, Inc. |
3 | * All Rights Reserved. | ||
3 | * | 4 | * |
4 | * This program is free software; you can redistribute it and/or modify it | 5 | * This program is free software; you can redistribute it and/or |
5 | * under the terms of version 2 of the GNU General Public License as | 6 | * modify it under the terms of the GNU General Public License as |
6 | * published by the Free Software Foundation. | 7 | * published by the Free Software Foundation. |
7 | * | 8 | * |
8 | * This program is distributed in the hope that it would be useful, but | 9 | * This program is distributed in the hope that it would be useful, |
9 | * WITHOUT ANY WARRANTY; without even the implied warranty of | 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
12 | * GNU General Public License for more details. | ||
11 | * | 13 | * |
12 | * Further, this software is distributed without any warranty that it is | 14 | * You should have received a copy of the GNU General Public License |
13 | * free of the rightful claim of any third person regarding infringement | 15 | * along with this program; if not, write the Free Software Foundation, |
14 | * or the like. Any license provided herein, whether implied or | 16 | * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
15 | * otherwise, applies only to this software file. Patent licenses, if | ||
16 | * any, provided herein do not apply to combinations of this program with | ||
17 | * other software, or any other product whatsoever. | ||
18 | * | ||
19 | * You should have received a copy of the GNU General Public License along | ||
20 | * with this program; if not, write the Free Software Foundation, Inc., 59 | ||
21 | * Temple Place - Suite 330, Boston MA 02111-1307, USA. | ||
22 | * | ||
23 | * Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy, | ||
24 | * Mountain View, CA 94043, or: | ||
25 | * | ||
26 | * http://www.sgi.com | ||
27 | * | ||
28 | * For further information regarding this notice, see: | ||
29 | * | ||
30 | * http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/ | ||
31 | */ | 17 | */ |
32 | #ifndef __XFS_SUPPORT_SPIN_H__ | 18 | #ifndef __XFS_SUPPORT_SPIN_H__ |
33 | #define __XFS_SUPPORT_SPIN_H__ | 19 | #define __XFS_SUPPORT_SPIN_H__ |
diff --git a/fs/xfs/linux-2.6/sv.h b/fs/xfs/linux-2.6/sv.h index 821d3167e05b..9a8ad481b008 100644 --- a/fs/xfs/linux-2.6/sv.h +++ b/fs/xfs/linux-2.6/sv.h | |||
@@ -1,33 +1,19 @@ | |||
1 | /* | 1 | /* |
2 | * Copyright (c) 2000-2002 Silicon Graphics, Inc. All Rights Reserved. | 2 | * Copyright (c) 2000-2002,2005 Silicon Graphics, Inc. |
3 | * All Rights Reserved. | ||
3 | * | 4 | * |
4 | * This program is free software; you can redistribute it and/or modify it | 5 | * This program is free software; you can redistribute it and/or |
5 | * under the terms of version 2 of the GNU General Public License as | 6 | * modify it under the terms of the GNU General Public License as |
6 | * published by the Free Software Foundation. | 7 | * published by the Free Software Foundation. |
7 | * | 8 | * |
8 | * This program is distributed in the hope that it would be useful, but | 9 | * This program is distributed in the hope that it would be useful, |
9 | * WITHOUT ANY WARRANTY; without even the implied warranty of | 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
12 | * GNU General Public License for more details. | ||
11 | * | 13 | * |
12 | * Further, this software is distributed without any warranty that it is | 14 | * You should have received a copy of the GNU General Public License |
13 | * free of the rightful claim of any third person regarding infringement | 15 | * along with this program; if not, write the Free Software Foundation, |
14 | * or the like. Any license provided herein, whether implied or | 16 | * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
15 | * otherwise, applies only to this software file. Patent licenses, if | ||
16 | * any, provided herein do not apply to combinations of this program with | ||
17 | * other software, or any other product whatsoever. | ||
18 | * | ||
19 | * You should have received a copy of the GNU General Public License along | ||
20 | * with this program; if not, write the Free Software Foundation, Inc., 59 | ||
21 | * Temple Place - Suite 330, Boston MA 02111-1307, USA. | ||
22 | * | ||
23 | * Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy, | ||
24 | * Mountain View, CA 94043, or: | ||
25 | * | ||
26 | * http://www.sgi.com | ||
27 | * | ||
28 | * For further information regarding this notice, see: | ||
29 | * | ||
30 | * http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/ | ||
31 | */ | 17 | */ |
32 | #ifndef __XFS_SUPPORT_SV_H__ | 18 | #ifndef __XFS_SUPPORT_SV_H__ |
33 | #define __XFS_SUPPORT_SV_H__ | 19 | #define __XFS_SUPPORT_SV_H__ |
diff --git a/fs/xfs/linux-2.6/time.h b/fs/xfs/linux-2.6/time.h index b0d2873ab274..387e695a184c 100644 --- a/fs/xfs/linux-2.6/time.h +++ b/fs/xfs/linux-2.6/time.h | |||
@@ -1,33 +1,19 @@ | |||
1 | /* | 1 | /* |
2 | * Copyright (c) 2000-2003 Silicon Graphics, Inc. All Rights Reserved. | 2 | * Copyright (c) 2000-2003,2005 Silicon Graphics, Inc. |
3 | * All Rights Reserved. | ||
3 | * | 4 | * |
4 | * This program is free software; you can redistribute it and/or modify it | 5 | * This program is free software; you can redistribute it and/or |
5 | * under the terms of version 2 of the GNU General Public License as | 6 | * modify it under the terms of the GNU General Public License as |
6 | * published by the Free Software Foundation. | 7 | * published by the Free Software Foundation. |
7 | * | 8 | * |
8 | * This program is distributed in the hope that it would be useful, but | 9 | * This program is distributed in the hope that it would be useful, |
9 | * WITHOUT ANY WARRANTY; without even the implied warranty of | 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
12 | * GNU General Public License for more details. | ||
11 | * | 13 | * |
12 | * Further, this software is distributed without any warranty that it is | 14 | * You should have received a copy of the GNU General Public License |
13 | * free of the rightful claim of any third person regarding infringement | 15 | * along with this program; if not, write the Free Software Foundation, |
14 | * or the like. Any license provided herein, whether implied or | 16 | * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
15 | * otherwise, applies only to this software file. Patent licenses, if | ||
16 | * any, provided herein do not apply to combinations of this program with | ||
17 | * other software, or any other product whatsoever. | ||
18 | * | ||
19 | * You should have received a copy of the GNU General Public License along | ||
20 | * with this program; if not, write the Free Software Foundation, Inc., 59 | ||
21 | * Temple Place - Suite 330, Boston MA 02111-1307, USA. | ||
22 | * | ||
23 | * Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy, | ||
24 | * Mountain View, CA 94043, or: | ||
25 | * | ||
26 | * http://www.sgi.com | ||
27 | * | ||
28 | * For further information regarding this notice, see: | ||
29 | * | ||
30 | * http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/ | ||
31 | */ | 17 | */ |
32 | #ifndef __XFS_SUPPORT_TIME_H__ | 18 | #ifndef __XFS_SUPPORT_TIME_H__ |
33 | #define __XFS_SUPPORT_TIME_H__ | 19 | #define __XFS_SUPPORT_TIME_H__ |
diff --git a/fs/xfs/linux-2.6/xfs_aops.c b/fs/xfs/linux-2.6/xfs_aops.c index 7aa398724706..c6108971b4e6 100644 --- a/fs/xfs/linux-2.6/xfs_aops.c +++ b/fs/xfs/linux-2.6/xfs_aops.c | |||
@@ -1,39 +1,26 @@ | |||
1 | /* | 1 | /* |
2 | * Copyright (c) 2000-2005 Silicon Graphics, Inc. All Rights Reserved. | 2 | * Copyright (c) 2000-2005 Silicon Graphics, Inc. |
3 | * All Rights Reserved. | ||
3 | * | 4 | * |
4 | * This program is free software; you can redistribute it and/or modify it | 5 | * This program is free software; you can redistribute it and/or |
5 | * under the terms of version 2 of the GNU General Public License as | 6 | * modify it under the terms of the GNU General Public License as |
6 | * published by the Free Software Foundation. | 7 | * published by the Free Software Foundation. |
7 | * | 8 | * |
8 | * This program is distributed in the hope that it would be useful, but | 9 | * This program is distributed in the hope that it would be useful, |
9 | * WITHOUT ANY WARRANTY; without even the implied warranty of | 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
12 | * GNU General Public License for more details. | ||
11 | * | 13 | * |
12 | * Further, this software is distributed without any warranty that it is | 14 | * You should have received a copy of the GNU General Public License |
13 | * free of the rightful claim of any third person regarding infringement | 15 | * along with this program; if not, write the Free Software Foundation, |
14 | * or the like. Any license provided herein, whether implied or | 16 | * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
15 | * otherwise, applies only to this software file. Patent licenses, if | ||
16 | * any, provided herein do not apply to combinations of this program with | ||
17 | * other software, or any other product whatsoever. | ||
18 | * | ||
19 | * You should have received a copy of the GNU General Public License along | ||
20 | * with this program; if not, write the Free Software Foundation, Inc., 59 | ||
21 | * Temple Place - Suite 330, Boston MA 02111-1307, USA. | ||
22 | * | ||
23 | * Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy, | ||
24 | * Mountain View, CA 94043, or: | ||
25 | * | ||
26 | * http://www.sgi.com | ||
27 | * | ||
28 | * For further information regarding this notice, see: | ||
29 | * | ||
30 | * http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/ | ||
31 | */ | 17 | */ |
32 | |||
33 | #include "xfs.h" | 18 | #include "xfs.h" |
34 | #include "xfs_inum.h" | 19 | #include "xfs_bit.h" |
35 | #include "xfs_log.h" | 20 | #include "xfs_log.h" |
21 | #include "xfs_inum.h" | ||
36 | #include "xfs_sb.h" | 22 | #include "xfs_sb.h" |
23 | #include "xfs_ag.h" | ||
37 | #include "xfs_dir.h" | 24 | #include "xfs_dir.h" |
38 | #include "xfs_dir2.h" | 25 | #include "xfs_dir2.h" |
39 | #include "xfs_trans.h" | 26 | #include "xfs_trans.h" |
@@ -42,13 +29,13 @@ | |||
42 | #include "xfs_bmap_btree.h" | 29 | #include "xfs_bmap_btree.h" |
43 | #include "xfs_alloc_btree.h" | 30 | #include "xfs_alloc_btree.h" |
44 | #include "xfs_ialloc_btree.h" | 31 | #include "xfs_ialloc_btree.h" |
45 | #include "xfs_alloc.h" | ||
46 | #include "xfs_btree.h" | ||
47 | #include "xfs_attr_sf.h" | ||
48 | #include "xfs_dir_sf.h" | 32 | #include "xfs_dir_sf.h" |
49 | #include "xfs_dir2_sf.h" | 33 | #include "xfs_dir2_sf.h" |
34 | #include "xfs_attr_sf.h" | ||
50 | #include "xfs_dinode.h" | 35 | #include "xfs_dinode.h" |
51 | #include "xfs_inode.h" | 36 | #include "xfs_inode.h" |
37 | #include "xfs_alloc.h" | ||
38 | #include "xfs_btree.h" | ||
52 | #include "xfs_error.h" | 39 | #include "xfs_error.h" |
53 | #include "xfs_rw.h" | 40 | #include "xfs_rw.h" |
54 | #include "xfs_iomap.h" | 41 | #include "xfs_iomap.h" |
@@ -761,8 +748,9 @@ xfs_page_state_convert( | |||
761 | if (page->index >= end_index) { | 748 | if (page->index >= end_index) { |
762 | if ((page->index >= end_index + 1) || | 749 | if ((page->index >= end_index + 1) || |
763 | !(i_size_read(inode) & (PAGE_CACHE_SIZE - 1))) { | 750 | !(i_size_read(inode) & (PAGE_CACHE_SIZE - 1))) { |
764 | err = -EIO; | 751 | if (startio) |
765 | goto error; | 752 | unlock_page(page); |
753 | return 0; | ||
766 | } | 754 | } |
767 | } | 755 | } |
768 | 756 | ||
@@ -948,15 +936,18 @@ __linvfs_get_block( | |||
948 | { | 936 | { |
949 | vnode_t *vp = LINVFS_GET_VP(inode); | 937 | vnode_t *vp = LINVFS_GET_VP(inode); |
950 | xfs_iomap_t iomap; | 938 | xfs_iomap_t iomap; |
939 | xfs_off_t offset; | ||
940 | ssize_t size; | ||
951 | int retpbbm = 1; | 941 | int retpbbm = 1; |
952 | int error; | 942 | int error; |
953 | ssize_t size; | ||
954 | loff_t offset = (loff_t)iblock << inode->i_blkbits; | ||
955 | 943 | ||
956 | if (blocks) | 944 | if (blocks) { |
957 | size = blocks << inode->i_blkbits; | 945 | offset = blocks << inode->i_blkbits; /* 64 bit goodness */ |
958 | else | 946 | size = (ssize_t) min_t(xfs_off_t, offset, LONG_MAX); |
947 | } else { | ||
959 | size = 1 << inode->i_blkbits; | 948 | size = 1 << inode->i_blkbits; |
949 | } | ||
950 | offset = (xfs_off_t)iblock << inode->i_blkbits; | ||
960 | 951 | ||
961 | VOP_BMAP(vp, offset, size, | 952 | VOP_BMAP(vp, offset, size, |
962 | create ? flags : BMAPI_READ, &iomap, &retpbbm, error); | 953 | create ? flags : BMAPI_READ, &iomap, &retpbbm, error); |
@@ -967,8 +958,8 @@ __linvfs_get_block( | |||
967 | return 0; | 958 | return 0; |
968 | 959 | ||
969 | if (iomap.iomap_bn != IOMAP_DADDR_NULL) { | 960 | if (iomap.iomap_bn != IOMAP_DADDR_NULL) { |
970 | xfs_daddr_t bn; | 961 | xfs_daddr_t bn; |
971 | loff_t delta; | 962 | xfs_off_t delta; |
972 | 963 | ||
973 | /* For unwritten extents do not report a disk address on | 964 | /* For unwritten extents do not report a disk address on |
974 | * the read case (treat as if we're reading into a hole). | 965 | * the read case (treat as if we're reading into a hole). |
@@ -1000,9 +991,8 @@ __linvfs_get_block( | |||
1000 | */ | 991 | */ |
1001 | if (create && | 992 | if (create && |
1002 | ((!buffer_mapped(bh_result) && !buffer_uptodate(bh_result)) || | 993 | ((!buffer_mapped(bh_result) && !buffer_uptodate(bh_result)) || |
1003 | (offset >= i_size_read(inode)) || (iomap.iomap_flags & IOMAP_NEW))) { | 994 | (offset >= i_size_read(inode)) || (iomap.iomap_flags & IOMAP_NEW))) |
1004 | set_buffer_new(bh_result); | 995 | set_buffer_new(bh_result); |
1005 | } | ||
1006 | 996 | ||
1007 | if (iomap.iomap_flags & IOMAP_DELAY) { | 997 | if (iomap.iomap_flags & IOMAP_DELAY) { |
1008 | BUG_ON(direct); | 998 | BUG_ON(direct); |
@@ -1014,9 +1004,11 @@ __linvfs_get_block( | |||
1014 | } | 1004 | } |
1015 | 1005 | ||
1016 | if (blocks) { | 1006 | if (blocks) { |
1017 | bh_result->b_size = (ssize_t)min( | 1007 | ASSERT(iomap.iomap_bsize - iomap.iomap_delta > 0); |
1018 | (loff_t)(iomap.iomap_bsize - iomap.iomap_delta), | 1008 | offset = min_t(xfs_off_t, |
1019 | (loff_t)(blocks << inode->i_blkbits)); | 1009 | iomap.iomap_bsize - iomap.iomap_delta, |
1010 | blocks << inode->i_blkbits); | ||
1011 | bh_result->b_size = (u32) min_t(xfs_off_t, UINT_MAX, offset); | ||
1020 | } | 1012 | } |
1021 | 1013 | ||
1022 | return 0; | 1014 | return 0; |
diff --git a/fs/xfs/linux-2.6/xfs_aops.h b/fs/xfs/linux-2.6/xfs_aops.h index 2fa62974a04d..4720758a9ade 100644 --- a/fs/xfs/linux-2.6/xfs_aops.h +++ b/fs/xfs/linux-2.6/xfs_aops.h | |||
@@ -1,33 +1,19 @@ | |||
1 | /* | 1 | /* |
2 | * Copyright (c) 2005 Silicon Graphics, Inc. All Rights Reserved. | 2 | * Copyright (c) 2005 Silicon Graphics, Inc. |
3 | * All Rights Reserved. | ||
3 | * | 4 | * |
4 | * This program is free software; you can redistribute it and/or modify it | 5 | * This program is free software; you can redistribute it and/or |
5 | * under the terms of version 2 of the GNU General Public License as | 6 | * modify it under the terms of the GNU General Public License as |
6 | * published by the Free Software Foundation. | 7 | * published by the Free Software Foundation. |
7 | * | 8 | * |
8 | * This program is distributed in the hope that it would be useful, but | 9 | * This program is distributed in the hope that it would be useful, |
9 | * WITHOUT ANY WARRANTY; without even the implied warranty of | 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
12 | * GNU General Public License for more details. | ||
11 | * | 13 | * |
12 | * Further, this software is distributed without any warranty that it is | 14 | * You should have received a copy of the GNU General Public License |
13 | * free of the rightful claim of any third person regarding infringement | 15 | * along with this program; if not, write the Free Software Foundation, |
14 | * or the like. Any license provided herein, whether implied or | 16 | * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
15 | * otherwise, applies only to this software file. Patent licenses, if | ||
16 | * any, provided herein do not apply to combinations of this program with | ||
17 | * other software, or any other product whatsoever. | ||
18 | * | ||
19 | * You should have received a copy of the GNU General Public License along | ||
20 | * with this program; if not, write the Free Software Foundation, Inc., 59 | ||
21 | * Temple Place - Suite 330, Boston MA 02111-1307, USA. | ||
22 | * | ||
23 | * Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy, | ||
24 | * Mountain View, CA 94043, or: | ||
25 | * | ||
26 | * http://www.sgi.com | ||
27 | * | ||
28 | * For further information regarding this notice, see: | ||
29 | * | ||
30 | * http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/ | ||
31 | */ | 17 | */ |
32 | #ifndef __XFS_AOPS_H__ | 18 | #ifndef __XFS_AOPS_H__ |
33 | #define __XFS_AOPS_H__ | 19 | #define __XFS_AOPS_H__ |
diff --git a/fs/xfs/linux-2.6/xfs_buf.c b/fs/xfs/linux-2.6/xfs_buf.c index 4cd46abe8434..6fe21d2b8847 100644 --- a/fs/xfs/linux-2.6/xfs_buf.c +++ b/fs/xfs/linux-2.6/xfs_buf.c | |||
@@ -1,46 +1,20 @@ | |||
1 | /* | 1 | /* |
2 | * Copyright (c) 2000-2005 Silicon Graphics, Inc. All Rights Reserved. | 2 | * Copyright (c) 2000-2005 Silicon Graphics, Inc. |
3 | * All Rights Reserved. | ||
3 | * | 4 | * |
4 | * This program is free software; you can redistribute it and/or modify it | 5 | * This program is free software; you can redistribute it and/or |
5 | * under the terms of version 2 of the GNU General Public License as | 6 | * modify it under the terms of the GNU General Public License as |
6 | * published by the Free Software Foundation. | 7 | * published by the Free Software Foundation. |
7 | * | 8 | * |
8 | * This program is distributed in the hope that it would be useful, but | 9 | * This program is distributed in the hope that it would be useful, |
9 | * WITHOUT ANY WARRANTY; without even the implied warranty of | 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
11 | * | 12 | * GNU General Public License for more details. |
12 | * Further, this software is distributed without any warranty that it is | ||
13 | * free of the rightful claim of any third person regarding infringement | ||
14 | * or the like. Any license provided herein, whether implied or | ||
15 | * otherwise, applies only to this software file. Patent licenses, if | ||
16 | * any, provided herein do not apply to combinations of this program with | ||
17 | * other software, or any other product whatsoever. | ||
18 | * | ||
19 | * You should have received a copy of the GNU General Public License along | ||
20 | * with this program; if not, write the Free Software Foundation, Inc., 59 | ||
21 | * Temple Place - Suite 330, Boston MA 02111-1307, USA. | ||
22 | * | ||
23 | * Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy, | ||
24 | * Mountain View, CA 94043, or: | ||
25 | * | ||
26 | * http://www.sgi.com | ||
27 | * | ||
28 | * For further information regarding this notice, see: | ||
29 | * | ||
30 | * http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/ | ||
31 | */ | ||
32 | |||
33 | /* | ||
34 | * The xfs_buf.c code provides an abstract buffer cache model on top | ||
35 | * of the Linux page cache. Cached metadata blocks for a file system | ||
36 | * are hashed to the inode for the block device. xfs_buf.c assembles | ||
37 | * buffers (xfs_buf_t) on demand to aggregate such cached pages for I/O. | ||
38 | * | ||
39 | * Written by Steve Lord, Jim Mostek, Russell Cattelan | ||
40 | * and Rajagopal Ananthanarayanan ("ananth") at SGI. | ||
41 | * | 13 | * |
14 | * You should have received a copy of the GNU General Public License | ||
15 | * along with this program; if not, write the Free Software Foundation, | ||
16 | * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA | ||
42 | */ | 17 | */ |
43 | |||
44 | #include <linux/stddef.h> | 18 | #include <linux/stddef.h> |
45 | #include <linux/errno.h> | 19 | #include <linux/errno.h> |
46 | #include <linux/slab.h> | 20 | #include <linux/slab.h> |
@@ -55,13 +29,8 @@ | |||
55 | #include <linux/blkdev.h> | 29 | #include <linux/blkdev.h> |
56 | #include <linux/hash.h> | 30 | #include <linux/hash.h> |
57 | #include <linux/kthread.h> | 31 | #include <linux/kthread.h> |
58 | |||
59 | #include "xfs_linux.h" | 32 | #include "xfs_linux.h" |
60 | 33 | ||
61 | /* | ||
62 | * File wide globals | ||
63 | */ | ||
64 | |||
65 | STATIC kmem_cache_t *pagebuf_zone; | 34 | STATIC kmem_cache_t *pagebuf_zone; |
66 | STATIC kmem_shaker_t pagebuf_shake; | 35 | STATIC kmem_shaker_t pagebuf_shake; |
67 | STATIC int xfsbufd_wakeup(int, gfp_t); | 36 | STATIC int xfsbufd_wakeup(int, gfp_t); |
@@ -70,10 +39,6 @@ STATIC void pagebuf_delwri_queue(xfs_buf_t *, int); | |||
70 | STATIC struct workqueue_struct *xfslogd_workqueue; | 39 | STATIC struct workqueue_struct *xfslogd_workqueue; |
71 | struct workqueue_struct *xfsdatad_workqueue; | 40 | struct workqueue_struct *xfsdatad_workqueue; |
72 | 41 | ||
73 | /* | ||
74 | * Pagebuf debugging | ||
75 | */ | ||
76 | |||
77 | #ifdef PAGEBUF_TRACE | 42 | #ifdef PAGEBUF_TRACE |
78 | void | 43 | void |
79 | pagebuf_trace( | 44 | pagebuf_trace( |
@@ -112,10 +77,6 @@ ktrace_t *pagebuf_trace_buf; | |||
112 | # define PB_GET_OWNER(pb) do { } while (0) | 77 | # define PB_GET_OWNER(pb) do { } while (0) |
113 | #endif | 78 | #endif |
114 | 79 | ||
115 | /* | ||
116 | * Pagebuf allocation / freeing. | ||
117 | */ | ||
118 | |||
119 | #define pb_to_gfp(flags) \ | 80 | #define pb_to_gfp(flags) \ |
120 | ((((flags) & PBF_READ_AHEAD) ? __GFP_NORETRY : \ | 81 | ((((flags) & PBF_READ_AHEAD) ? __GFP_NORETRY : \ |
121 | ((flags) & PBF_DONT_BLOCK) ? GFP_NOFS : GFP_KERNEL) | __GFP_NOWARN) | 82 | ((flags) & PBF_DONT_BLOCK) ? GFP_NOFS : GFP_KERNEL) | __GFP_NOWARN) |
@@ -123,7 +84,6 @@ ktrace_t *pagebuf_trace_buf; | |||
123 | #define pb_to_km(flags) \ | 84 | #define pb_to_km(flags) \ |
124 | (((flags) & PBF_DONT_BLOCK) ? KM_NOFS : KM_SLEEP) | 85 | (((flags) & PBF_DONT_BLOCK) ? KM_NOFS : KM_SLEEP) |
125 | 86 | ||
126 | |||
127 | #define pagebuf_allocate(flags) \ | 87 | #define pagebuf_allocate(flags) \ |
128 | kmem_zone_alloc(pagebuf_zone, pb_to_km(flags)) | 88 | kmem_zone_alloc(pagebuf_zone, pb_to_km(flags)) |
129 | #define pagebuf_deallocate(pb) \ | 89 | #define pagebuf_deallocate(pb) \ |
@@ -286,7 +246,7 @@ _pagebuf_initialize( | |||
286 | * most cases but may be reset (e.g. XFS recovery). | 246 | * most cases but may be reset (e.g. XFS recovery). |
287 | */ | 247 | */ |
288 | pb->pb_buffer_length = pb->pb_count_desired = range_length; | 248 | pb->pb_buffer_length = pb->pb_count_desired = range_length; |
289 | pb->pb_flags = flags | PBF_NONE; | 249 | pb->pb_flags = flags; |
290 | pb->pb_bn = XFS_BUF_DADDR_NULL; | 250 | pb->pb_bn = XFS_BUF_DADDR_NULL; |
291 | atomic_set(&pb->pb_pin_count, 0); | 251 | atomic_set(&pb->pb_pin_count, 0); |
292 | init_waitqueue_head(&pb->pb_waiters); | 252 | init_waitqueue_head(&pb->pb_waiters); |
@@ -458,14 +418,8 @@ _pagebuf_lookup_pages( | |||
458 | unlock_page(bp->pb_pages[i]); | 418 | unlock_page(bp->pb_pages[i]); |
459 | } | 419 | } |
460 | 420 | ||
461 | if (page_count) { | 421 | if (page_count == bp->pb_page_count) |
462 | /* if we have any uptodate pages, mark that in the buffer */ | 422 | bp->pb_flags |= PBF_DONE; |
463 | bp->pb_flags &= ~PBF_NONE; | ||
464 | |||
465 | /* if some pages aren't uptodate, mark that in the buffer */ | ||
466 | if (page_count != bp->pb_page_count) | ||
467 | bp->pb_flags |= PBF_PARTIAL; | ||
468 | } | ||
469 | 423 | ||
470 | PB_TRACE(bp, "lookup_pages", (long)page_count); | 424 | PB_TRACE(bp, "lookup_pages", (long)page_count); |
471 | return error; | 425 | return error; |
@@ -676,7 +630,7 @@ xfs_buf_read_flags( | |||
676 | 630 | ||
677 | pb = xfs_buf_get_flags(target, ioff, isize, flags); | 631 | pb = xfs_buf_get_flags(target, ioff, isize, flags); |
678 | if (pb) { | 632 | if (pb) { |
679 | if (PBF_NOT_DONE(pb)) { | 633 | if (!XFS_BUF_ISDONE(pb)) { |
680 | PB_TRACE(pb, "read", (unsigned long)flags); | 634 | PB_TRACE(pb, "read", (unsigned long)flags); |
681 | XFS_STATS_INC(pb_get_read); | 635 | XFS_STATS_INC(pb_get_read); |
682 | pagebuf_iostart(pb, flags); | 636 | pagebuf_iostart(pb, flags); |
@@ -813,7 +767,7 @@ pagebuf_get_no_daddr( | |||
813 | bp = pagebuf_allocate(0); | 767 | bp = pagebuf_allocate(0); |
814 | if (unlikely(bp == NULL)) | 768 | if (unlikely(bp == NULL)) |
815 | goto fail; | 769 | goto fail; |
816 | _pagebuf_initialize(bp, target, 0, len, PBF_FORCEIO); | 770 | _pagebuf_initialize(bp, target, 0, len, 0); |
817 | 771 | ||
818 | try_again: | 772 | try_again: |
819 | data = kmem_alloc(malloc_len, KM_SLEEP | KM_MAYFAIL); | 773 | data = kmem_alloc(malloc_len, KM_SLEEP | KM_MAYFAIL); |
@@ -876,39 +830,18 @@ pagebuf_rele( | |||
876 | 830 | ||
877 | PB_TRACE(pb, "rele", pb->pb_relse); | 831 | PB_TRACE(pb, "rele", pb->pb_relse); |
878 | 832 | ||
879 | /* | ||
880 | * pagebuf_lookup buffers are not hashed, not delayed write, | ||
881 | * and don't have their own release routines. Special case. | ||
882 | */ | ||
883 | if (unlikely(!hash)) { | ||
884 | ASSERT(!pb->pb_relse); | ||
885 | if (atomic_dec_and_test(&pb->pb_hold)) | ||
886 | xfs_buf_free(pb); | ||
887 | return; | ||
888 | } | ||
889 | |||
890 | if (atomic_dec_and_lock(&pb->pb_hold, &hash->bh_lock)) { | 833 | if (atomic_dec_and_lock(&pb->pb_hold, &hash->bh_lock)) { |
891 | int do_free = 1; | ||
892 | |||
893 | if (pb->pb_relse) { | 834 | if (pb->pb_relse) { |
894 | atomic_inc(&pb->pb_hold); | 835 | atomic_inc(&pb->pb_hold); |
895 | spin_unlock(&hash->bh_lock); | 836 | spin_unlock(&hash->bh_lock); |
896 | (*(pb->pb_relse)) (pb); | 837 | (*(pb->pb_relse)) (pb); |
897 | spin_lock(&hash->bh_lock); | 838 | } else if (pb->pb_flags & PBF_FS_MANAGED) { |
898 | do_free = 0; | ||
899 | } | ||
900 | |||
901 | if (pb->pb_flags & PBF_FS_MANAGED) { | ||
902 | do_free = 0; | ||
903 | } | ||
904 | |||
905 | if (do_free) { | ||
906 | ASSERT((pb->pb_flags & (PBF_DELWRI|_PBF_DELWRI_Q)) == 0); | ||
907 | list_del_init(&pb->pb_hash_list); | ||
908 | spin_unlock(&hash->bh_lock); | 839 | spin_unlock(&hash->bh_lock); |
909 | pagebuf_free(pb); | ||
910 | } else { | 840 | } else { |
841 | ASSERT(!(pb->pb_flags & (PBF_DELWRI|_PBF_DELWRI_Q))); | ||
842 | list_del_init(&pb->pb_hash_list); | ||
911 | spin_unlock(&hash->bh_lock); | 843 | spin_unlock(&hash->bh_lock); |
844 | pagebuf_free(pb); | ||
912 | } | 845 | } |
913 | } else { | 846 | } else { |
914 | /* | 847 | /* |
@@ -1121,21 +1054,18 @@ pagebuf_iodone_work( | |||
1121 | void | 1054 | void |
1122 | pagebuf_iodone( | 1055 | pagebuf_iodone( |
1123 | xfs_buf_t *pb, | 1056 | xfs_buf_t *pb, |
1124 | int dataio, | ||
1125 | int schedule) | 1057 | int schedule) |
1126 | { | 1058 | { |
1127 | pb->pb_flags &= ~(PBF_READ | PBF_WRITE); | 1059 | pb->pb_flags &= ~(PBF_READ | PBF_WRITE); |
1128 | if (pb->pb_error == 0) { | 1060 | if (pb->pb_error == 0) |
1129 | pb->pb_flags &= ~(PBF_PARTIAL | PBF_NONE); | 1061 | pb->pb_flags |= PBF_DONE; |
1130 | } | ||
1131 | 1062 | ||
1132 | PB_TRACE(pb, "iodone", pb->pb_iodone); | 1063 | PB_TRACE(pb, "iodone", pb->pb_iodone); |
1133 | 1064 | ||
1134 | if ((pb->pb_iodone) || (pb->pb_flags & PBF_ASYNC)) { | 1065 | if ((pb->pb_iodone) || (pb->pb_flags & PBF_ASYNC)) { |
1135 | if (schedule) { | 1066 | if (schedule) { |
1136 | INIT_WORK(&pb->pb_iodone_work, pagebuf_iodone_work, pb); | 1067 | INIT_WORK(&pb->pb_iodone_work, pagebuf_iodone_work, pb); |
1137 | queue_work(dataio ? xfsdatad_workqueue : | 1068 | queue_work(xfslogd_workqueue, &pb->pb_iodone_work); |
1138 | xfslogd_workqueue, &pb->pb_iodone_work); | ||
1139 | } else { | 1069 | } else { |
1140 | pagebuf_iodone_work(pb); | 1070 | pagebuf_iodone_work(pb); |
1141 | } | 1071 | } |
@@ -1235,7 +1165,7 @@ _pagebuf_iodone( | |||
1235 | { | 1165 | { |
1236 | if (atomic_dec_and_test(&pb->pb_io_remaining) == 1) { | 1166 | if (atomic_dec_and_test(&pb->pb_io_remaining) == 1) { |
1237 | pb->pb_locked = 0; | 1167 | pb->pb_locked = 0; |
1238 | pagebuf_iodone(pb, (pb->pb_flags & PBF_FS_DATAIOD), schedule); | 1168 | pagebuf_iodone(pb, schedule); |
1239 | } | 1169 | } |
1240 | } | 1170 | } |
1241 | 1171 | ||
@@ -1304,6 +1234,11 @@ _pagebuf_ioapply( | |||
1304 | rw = (pb->pb_flags & PBF_READ) ? READ : WRITE; | 1234 | rw = (pb->pb_flags & PBF_READ) ? READ : WRITE; |
1305 | } | 1235 | } |
1306 | 1236 | ||
1237 | if (pb->pb_flags & PBF_ORDERED) { | ||
1238 | ASSERT(!(pb->pb_flags & PBF_READ)); | ||
1239 | rw = WRITE_BARRIER; | ||
1240 | } | ||
1241 | |||
1307 | /* Special code path for reading a sub page size pagebuf in -- | 1242 | /* Special code path for reading a sub page size pagebuf in -- |
1308 | * we populate up the whole page, and hence the other metadata | 1243 | * we populate up the whole page, and hence the other metadata |
1309 | * in the same page. This optimization is only valid when the | 1244 | * in the same page. This optimization is only valid when the |
@@ -1750,8 +1685,8 @@ STATIC int xfsbufd_force_sleep; | |||
1750 | 1685 | ||
1751 | STATIC int | 1686 | STATIC int |
1752 | xfsbufd_wakeup( | 1687 | xfsbufd_wakeup( |
1753 | int priority, | 1688 | int priority, |
1754 | gfp_t mask) | 1689 | gfp_t mask) |
1755 | { | 1690 | { |
1756 | if (xfsbufd_force_sleep) | 1691 | if (xfsbufd_force_sleep) |
1757 | return 0; | 1692 | return 0; |
@@ -1781,8 +1716,8 @@ xfsbufd( | |||
1781 | xfsbufd_force_sleep = 0; | 1716 | xfsbufd_force_sleep = 0; |
1782 | } | 1717 | } |
1783 | 1718 | ||
1784 | schedule_timeout_interruptible | 1719 | schedule_timeout_interruptible( |
1785 | (xfs_buf_timer_centisecs * msecs_to_jiffies(10)); | 1720 | xfs_buf_timer_centisecs * msecs_to_jiffies(10)); |
1786 | 1721 | ||
1787 | age = xfs_buf_age_centisecs * msecs_to_jiffies(10); | 1722 | age = xfs_buf_age_centisecs * msecs_to_jiffies(10); |
1788 | spin_lock(&pbd_delwrite_lock); | 1723 | spin_lock(&pbd_delwrite_lock); |
@@ -1891,14 +1826,22 @@ xfs_flush_buftarg( | |||
1891 | return pincount; | 1826 | return pincount; |
1892 | } | 1827 | } |
1893 | 1828 | ||
1894 | STATIC int | 1829 | int __init |
1895 | xfs_buf_daemons_start(void) | 1830 | pagebuf_init(void) |
1896 | { | 1831 | { |
1897 | int error = -ENOMEM; | 1832 | int error = -ENOMEM; |
1898 | 1833 | ||
1834 | #ifdef PAGEBUF_TRACE | ||
1835 | pagebuf_trace_buf = ktrace_alloc(PAGEBUF_TRACE_SIZE, KM_SLEEP); | ||
1836 | #endif | ||
1837 | |||
1838 | pagebuf_zone = kmem_zone_init(sizeof(xfs_buf_t), "xfs_buf"); | ||
1839 | if (!pagebuf_zone) | ||
1840 | goto out_free_trace_buf; | ||
1841 | |||
1899 | xfslogd_workqueue = create_workqueue("xfslogd"); | 1842 | xfslogd_workqueue = create_workqueue("xfslogd"); |
1900 | if (!xfslogd_workqueue) | 1843 | if (!xfslogd_workqueue) |
1901 | goto out; | 1844 | goto out_free_buf_zone; |
1902 | 1845 | ||
1903 | xfsdatad_workqueue = create_workqueue("xfsdatad"); | 1846 | xfsdatad_workqueue = create_workqueue("xfsdatad"); |
1904 | if (!xfsdatad_workqueue) | 1847 | if (!xfsdatad_workqueue) |
@@ -1909,82 +1852,37 @@ xfs_buf_daemons_start(void) | |||
1909 | error = PTR_ERR(xfsbufd_task); | 1852 | error = PTR_ERR(xfsbufd_task); |
1910 | goto out_destroy_xfsdatad_workqueue; | 1853 | goto out_destroy_xfsdatad_workqueue; |
1911 | } | 1854 | } |
1855 | |||
1856 | pagebuf_shake = kmem_shake_register(xfsbufd_wakeup); | ||
1857 | if (!pagebuf_shake) | ||
1858 | goto out_stop_xfsbufd; | ||
1859 | |||
1912 | return 0; | 1860 | return 0; |
1913 | 1861 | ||
1862 | out_stop_xfsbufd: | ||
1863 | kthread_stop(xfsbufd_task); | ||
1914 | out_destroy_xfsdatad_workqueue: | 1864 | out_destroy_xfsdatad_workqueue: |
1915 | destroy_workqueue(xfsdatad_workqueue); | 1865 | destroy_workqueue(xfsdatad_workqueue); |
1916 | out_destroy_xfslogd_workqueue: | 1866 | out_destroy_xfslogd_workqueue: |
1917 | destroy_workqueue(xfslogd_workqueue); | 1867 | destroy_workqueue(xfslogd_workqueue); |
1918 | out: | ||
1919 | return error; | ||
1920 | } | ||
1921 | |||
1922 | /* | ||
1923 | * Note: do not mark as __exit, it is called from pagebuf_terminate. | ||
1924 | */ | ||
1925 | STATIC void | ||
1926 | xfs_buf_daemons_stop(void) | ||
1927 | { | ||
1928 | kthread_stop(xfsbufd_task); | ||
1929 | destroy_workqueue(xfslogd_workqueue); | ||
1930 | destroy_workqueue(xfsdatad_workqueue); | ||
1931 | } | ||
1932 | |||
1933 | /* | ||
1934 | * Initialization and Termination | ||
1935 | */ | ||
1936 | |||
1937 | int __init | ||
1938 | pagebuf_init(void) | ||
1939 | { | ||
1940 | int error = -ENOMEM; | ||
1941 | |||
1942 | pagebuf_zone = kmem_zone_init(sizeof(xfs_buf_t), "xfs_buf"); | ||
1943 | if (!pagebuf_zone) | ||
1944 | goto out; | ||
1945 | |||
1946 | #ifdef PAGEBUF_TRACE | ||
1947 | pagebuf_trace_buf = ktrace_alloc(PAGEBUF_TRACE_SIZE, KM_SLEEP); | ||
1948 | #endif | ||
1949 | |||
1950 | error = xfs_buf_daemons_start(); | ||
1951 | if (error) | ||
1952 | goto out_free_buf_zone; | ||
1953 | |||
1954 | pagebuf_shake = kmem_shake_register(xfsbufd_wakeup); | ||
1955 | if (!pagebuf_shake) { | ||
1956 | error = -ENOMEM; | ||
1957 | goto out_stop_daemons; | ||
1958 | } | ||
1959 | |||
1960 | return 0; | ||
1961 | |||
1962 | out_stop_daemons: | ||
1963 | xfs_buf_daemons_stop(); | ||
1964 | out_free_buf_zone: | 1868 | out_free_buf_zone: |
1869 | kmem_zone_destroy(pagebuf_zone); | ||
1870 | out_free_trace_buf: | ||
1965 | #ifdef PAGEBUF_TRACE | 1871 | #ifdef PAGEBUF_TRACE |
1966 | ktrace_free(pagebuf_trace_buf); | 1872 | ktrace_free(pagebuf_trace_buf); |
1967 | #endif | 1873 | #endif |
1968 | kmem_zone_destroy(pagebuf_zone); | ||
1969 | out: | ||
1970 | return error; | 1874 | return error; |
1971 | } | 1875 | } |
1972 | 1876 | ||
1973 | |||
1974 | /* | ||
1975 | * pagebuf_terminate. | ||
1976 | * | ||
1977 | * Note: do not mark as __exit, this is also called from the __init code. | ||
1978 | */ | ||
1979 | void | 1877 | void |
1980 | pagebuf_terminate(void) | 1878 | pagebuf_terminate(void) |
1981 | { | 1879 | { |
1982 | xfs_buf_daemons_stop(); | 1880 | kmem_shake_deregister(pagebuf_shake); |
1983 | 1881 | kthread_stop(xfsbufd_task); | |
1882 | destroy_workqueue(xfsdatad_workqueue); | ||
1883 | destroy_workqueue(xfslogd_workqueue); | ||
1884 | kmem_zone_destroy(pagebuf_zone); | ||
1984 | #ifdef PAGEBUF_TRACE | 1885 | #ifdef PAGEBUF_TRACE |
1985 | ktrace_free(pagebuf_trace_buf); | 1886 | ktrace_free(pagebuf_trace_buf); |
1986 | #endif | 1887 | #endif |
1987 | |||
1988 | kmem_zone_destroy(pagebuf_zone); | ||
1989 | kmem_shake_deregister(pagebuf_shake); | ||
1990 | } | 1888 | } |
diff --git a/fs/xfs/linux-2.6/xfs_buf.h b/fs/xfs/linux-2.6/xfs_buf.h index 67c19f799232..237a35b915d1 100644 --- a/fs/xfs/linux-2.6/xfs_buf.h +++ b/fs/xfs/linux-2.6/xfs_buf.h | |||
@@ -1,39 +1,20 @@ | |||
1 | /* | 1 | /* |
2 | * Copyright (c) 2000-2004 Silicon Graphics, Inc. All Rights Reserved. | 2 | * Copyright (c) 2000-2005 Silicon Graphics, Inc. |
3 | * All Rights Reserved. | ||
3 | * | 4 | * |
4 | * This program is free software; you can redistribute it and/or modify it | 5 | * This program is free software; you can redistribute it and/or |
5 | * under the terms of version 2 of the GNU General Public License as | 6 | * modify it under the terms of the GNU General Public License as |
6 | * published by the Free Software Foundation. | 7 | * published by the Free Software Foundation. |
7 | * | 8 | * |
8 | * This program is distributed in the hope that it would be useful, but | 9 | * This program is distributed in the hope that it would be useful, |
9 | * WITHOUT ANY WARRANTY; without even the implied warranty of | 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
12 | * GNU General Public License for more details. | ||
11 | * | 13 | * |
12 | * Further, this software is distributed without any warranty that it is | 14 | * You should have received a copy of the GNU General Public License |
13 | * free of the rightful claim of any third person regarding infringement | 15 | * along with this program; if not, write the Free Software Foundation, |
14 | * or the like. Any license provided herein, whether implied or | 16 | * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
15 | * otherwise, applies only to this software file. Patent licenses, if | ||
16 | * any, provided herein do not apply to combinations of this program with | ||
17 | * other software, or any other product whatsoever. | ||
18 | * | ||
19 | * You should have received a copy of the GNU General Public License along | ||
20 | * with this program; if not, write the Free Software Foundation, Inc., 59 | ||
21 | * Temple Place - Suite 330, Boston MA 02111-1307, USA. | ||
22 | * | ||
23 | * Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy, | ||
24 | * Mountain View, CA 94043, or: | ||
25 | * | ||
26 | * http://www.sgi.com | ||
27 | * | ||
28 | * For further information regarding this notice, see: | ||
29 | * | ||
30 | * http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/ | ||
31 | */ | 17 | */ |
32 | |||
33 | /* | ||
34 | * Written by Steve Lord, Jim Mostek, Russell Cattelan at SGI | ||
35 | */ | ||
36 | |||
37 | #ifndef __XFS_BUF_H__ | 18 | #ifndef __XFS_BUF_H__ |
38 | #define __XFS_BUF_H__ | 19 | #define __XFS_BUF_H__ |
39 | 20 | ||
@@ -69,15 +50,12 @@ typedef enum page_buf_flags_e { /* pb_flags values */ | |||
69 | PBF_READ = (1 << 0), /* buffer intended for reading from device */ | 50 | PBF_READ = (1 << 0), /* buffer intended for reading from device */ |
70 | PBF_WRITE = (1 << 1), /* buffer intended for writing to device */ | 51 | PBF_WRITE = (1 << 1), /* buffer intended for writing to device */ |
71 | PBF_MAPPED = (1 << 2), /* buffer mapped (pb_addr valid) */ | 52 | PBF_MAPPED = (1 << 2), /* buffer mapped (pb_addr valid) */ |
72 | PBF_PARTIAL = (1 << 3), /* buffer partially read */ | ||
73 | PBF_ASYNC = (1 << 4), /* initiator will not wait for completion */ | 53 | PBF_ASYNC = (1 << 4), /* initiator will not wait for completion */ |
74 | PBF_NONE = (1 << 5), /* buffer not read at all */ | 54 | PBF_DONE = (1 << 5), /* all pages in the buffer uptodate */ |
75 | PBF_DELWRI = (1 << 6), /* buffer has dirty pages */ | 55 | PBF_DELWRI = (1 << 6), /* buffer has dirty pages */ |
76 | PBF_STALE = (1 << 7), /* buffer has been staled, do not find it */ | 56 | PBF_STALE = (1 << 7), /* buffer has been staled, do not find it */ |
77 | PBF_FS_MANAGED = (1 << 8), /* filesystem controls freeing memory */ | 57 | PBF_FS_MANAGED = (1 << 8), /* filesystem controls freeing memory */ |
78 | PBF_FS_DATAIOD = (1 << 9), /* schedule IO completion on fs datad */ | 58 | PBF_ORDERED = (1 << 11), /* use ordered writes */ |
79 | PBF_FORCEIO = (1 << 10), /* ignore any cache state */ | ||
80 | PBF_FLUSH = (1 << 11), /* flush disk write cache */ | ||
81 | PBF_READ_AHEAD = (1 << 12), /* asynchronous read-ahead */ | 59 | PBF_READ_AHEAD = (1 << 12), /* asynchronous read-ahead */ |
82 | 60 | ||
83 | /* flags used only as arguments to access routines */ | 61 | /* flags used only as arguments to access routines */ |
@@ -92,9 +70,6 @@ typedef enum page_buf_flags_e { /* pb_flags values */ | |||
92 | _PBF_DELWRI_Q = (1 << 21), /* buffer on delwri queue */ | 70 | _PBF_DELWRI_Q = (1 << 21), /* buffer on delwri queue */ |
93 | } page_buf_flags_t; | 71 | } page_buf_flags_t; |
94 | 72 | ||
95 | #define PBF_UPDATE (PBF_READ | PBF_WRITE) | ||
96 | #define PBF_NOT_DONE(pb) (((pb)->pb_flags & (PBF_PARTIAL|PBF_NONE)) != 0) | ||
97 | #define PBF_DONE(pb) (((pb)->pb_flags & (PBF_PARTIAL|PBF_NONE)) == 0) | ||
98 | 73 | ||
99 | typedef struct xfs_bufhash { | 74 | typedef struct xfs_bufhash { |
100 | struct list_head bh_list; | 75 | struct list_head bh_list; |
@@ -258,7 +233,6 @@ extern void pagebuf_unlock( /* unlock buffer */ | |||
258 | 233 | ||
259 | extern void pagebuf_iodone( /* mark buffer I/O complete */ | 234 | extern void pagebuf_iodone( /* mark buffer I/O complete */ |
260 | xfs_buf_t *, /* buffer to mark */ | 235 | xfs_buf_t *, /* buffer to mark */ |
261 | int, /* use data/log helper thread. */ | ||
262 | int); /* run completion locally, or in | 236 | int); /* run completion locally, or in |
263 | * a helper thread. */ | 237 | * a helper thread. */ |
264 | 238 | ||
@@ -378,21 +352,21 @@ extern void pagebuf_trace( | |||
378 | #define XFS_BUF_GETERROR(x) pagebuf_geterror(x) | 352 | #define XFS_BUF_GETERROR(x) pagebuf_geterror(x) |
379 | #define XFS_BUF_ISERROR(x) (pagebuf_geterror(x)?1:0) | 353 | #define XFS_BUF_ISERROR(x) (pagebuf_geterror(x)?1:0) |
380 | 354 | ||
381 | #define XFS_BUF_DONE(x) ((x)->pb_flags &= ~(PBF_PARTIAL|PBF_NONE)) | 355 | #define XFS_BUF_DONE(x) ((x)->pb_flags |= PBF_DONE) |
382 | #define XFS_BUF_UNDONE(x) ((x)->pb_flags |= PBF_PARTIAL|PBF_NONE) | 356 | #define XFS_BUF_UNDONE(x) ((x)->pb_flags &= ~PBF_DONE) |
383 | #define XFS_BUF_ISDONE(x) (!(PBF_NOT_DONE(x))) | 357 | #define XFS_BUF_ISDONE(x) ((x)->pb_flags & PBF_DONE) |
384 | 358 | ||
385 | #define XFS_BUF_BUSY(x) ((x)->pb_flags |= PBF_FORCEIO) | 359 | #define XFS_BUF_BUSY(x) do { } while (0) |
386 | #define XFS_BUF_UNBUSY(x) ((x)->pb_flags &= ~PBF_FORCEIO) | 360 | #define XFS_BUF_UNBUSY(x) do { } while (0) |
387 | #define XFS_BUF_ISBUSY(x) (1) | 361 | #define XFS_BUF_ISBUSY(x) (1) |
388 | 362 | ||
389 | #define XFS_BUF_ASYNC(x) ((x)->pb_flags |= PBF_ASYNC) | 363 | #define XFS_BUF_ASYNC(x) ((x)->pb_flags |= PBF_ASYNC) |
390 | #define XFS_BUF_UNASYNC(x) ((x)->pb_flags &= ~PBF_ASYNC) | 364 | #define XFS_BUF_UNASYNC(x) ((x)->pb_flags &= ~PBF_ASYNC) |
391 | #define XFS_BUF_ISASYNC(x) ((x)->pb_flags & PBF_ASYNC) | 365 | #define XFS_BUF_ISASYNC(x) ((x)->pb_flags & PBF_ASYNC) |
392 | 366 | ||
393 | #define XFS_BUF_FLUSH(x) ((x)->pb_flags |= PBF_FLUSH) | 367 | #define XFS_BUF_ORDERED(x) ((x)->pb_flags |= PBF_ORDERED) |
394 | #define XFS_BUF_UNFLUSH(x) ((x)->pb_flags &= ~PBF_FLUSH) | 368 | #define XFS_BUF_UNORDERED(x) ((x)->pb_flags &= ~PBF_ORDERED) |
395 | #define XFS_BUF_ISFLUSH(x) ((x)->pb_flags & PBF_FLUSH) | 369 | #define XFS_BUF_ISORDERED(x) ((x)->pb_flags & PBF_ORDERED) |
396 | 370 | ||
397 | #define XFS_BUF_SHUT(x) printk("XFS_BUF_SHUT not implemented yet\n") | 371 | #define XFS_BUF_SHUT(x) printk("XFS_BUF_SHUT not implemented yet\n") |
398 | #define XFS_BUF_UNSHUT(x) printk("XFS_BUF_UNSHUT not implemented yet\n") | 372 | #define XFS_BUF_UNSHUT(x) printk("XFS_BUF_UNSHUT not implemented yet\n") |
@@ -412,9 +386,6 @@ extern void pagebuf_trace( | |||
412 | 386 | ||
413 | #define XFS_BUF_BP_ISMAPPED(bp) 1 | 387 | #define XFS_BUF_BP_ISMAPPED(bp) 1 |
414 | 388 | ||
415 | #define XFS_BUF_DATAIO(x) ((x)->pb_flags |= PBF_FS_DATAIOD) | ||
416 | #define XFS_BUF_UNDATAIO(x) ((x)->pb_flags &= ~PBF_FS_DATAIOD) | ||
417 | |||
418 | #define XFS_BUF_IODONE_FUNC(buf) (buf)->pb_iodone | 389 | #define XFS_BUF_IODONE_FUNC(buf) (buf)->pb_iodone |
419 | #define XFS_BUF_SET_IODONE_FUNC(buf, func) \ | 390 | #define XFS_BUF_SET_IODONE_FUNC(buf, func) \ |
420 | (buf)->pb_iodone = (func) | 391 | (buf)->pb_iodone = (func) |
@@ -510,7 +481,7 @@ static inline void xfs_buf_relse(xfs_buf_t *bp) | |||
510 | pagebuf_trace(bp, id, NULL, (void *)__builtin_return_address(0)) | 481 | pagebuf_trace(bp, id, NULL, (void *)__builtin_return_address(0)) |
511 | 482 | ||
512 | #define xfs_biodone(pb) \ | 483 | #define xfs_biodone(pb) \ |
513 | pagebuf_iodone(pb, (pb->pb_flags & PBF_FS_DATAIOD), 0) | 484 | pagebuf_iodone(pb, 0) |
514 | 485 | ||
515 | #define xfs_biomove(pb, off, len, data, rw) \ | 486 | #define xfs_biomove(pb, off, len, data, rw) \ |
516 | pagebuf_iomove((pb), (off), (len), (data), \ | 487 | pagebuf_iomove((pb), (off), (len), (data), \ |
diff --git a/fs/xfs/linux-2.6/xfs_cred.h b/fs/xfs/linux-2.6/xfs_cred.h index 00c45849d41a..4af491024727 100644 --- a/fs/xfs/linux-2.6/xfs_cred.h +++ b/fs/xfs/linux-2.6/xfs_cred.h | |||
@@ -1,33 +1,19 @@ | |||
1 | /* | 1 | /* |
2 | * Copyright (c) 2000-2002 Silicon Graphics, Inc. All Rights Reserved. | 2 | * Copyright (c) 2000-2002,2005 Silicon Graphics, Inc. |
3 | * All Rights Reserved. | ||
3 | * | 4 | * |
4 | * This program is free software; you can redistribute it and/or modify it | 5 | * This program is free software; you can redistribute it and/or |
5 | * under the terms of version 2 of the GNU General Public License as | 6 | * modify it under the terms of the GNU General Public License as |
6 | * published by the Free Software Foundation. | 7 | * published by the Free Software Foundation. |
7 | * | 8 | * |
8 | * This program is distributed in the hope that it would be useful, but | 9 | * This program is distributed in the hope that it would be useful, |
9 | * WITHOUT ANY WARRANTY; without even the implied warranty of | 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
12 | * GNU General Public License for more details. | ||
11 | * | 13 | * |
12 | * Further, this software is distributed without any warranty that it is | 14 | * You should have received a copy of the GNU General Public License |
13 | * free of the rightful claim of any third person regarding infringement | 15 | * along with this program; if not, write the Free Software Foundation, |
14 | * or the like. Any license provided herein, whether implied or | 16 | * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
15 | * otherwise, applies only to this software file. Patent licenses, if | ||
16 | * any, provided herein do not apply to combinations of this program with | ||
17 | * other software, or any other product whatsoever. | ||
18 | * | ||
19 | * You should have received a copy of the GNU General Public License along | ||
20 | * with this program; if not, write the Free Software Foundation, Inc., 59 | ||
21 | * Temple Place - Suite 330, Boston MA 02111-1307, USA. | ||
22 | * | ||
23 | * Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy, | ||
24 | * Mountain View, CA 94043, or: | ||
25 | * | ||
26 | * http://www.sgi.com | ||
27 | * | ||
28 | * For further information regarding this notice, see: | ||
29 | * | ||
30 | * http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/ | ||
31 | */ | 17 | */ |
32 | #ifndef __XFS_CRED_H__ | 18 | #ifndef __XFS_CRED_H__ |
33 | #define __XFS_CRED_H__ | 19 | #define __XFS_CRED_H__ |
diff --git a/fs/xfs/linux-2.6/xfs_export.c b/fs/xfs/linux-2.6/xfs_export.c index f372a1a5e168..80eb249f2fa0 100644 --- a/fs/xfs/linux-2.6/xfs_export.c +++ b/fs/xfs/linux-2.6/xfs_export.c | |||
@@ -1,35 +1,20 @@ | |||
1 | /* | 1 | /* |
2 | * Copyright (c) 2004-2005 Silicon Graphics, Inc. All Rights Reserved. | 2 | * Copyright (c) 2004-2005 Silicon Graphics, Inc. |
3 | * All Rights Reserved. | ||
3 | * | 4 | * |
4 | * This program is free software; you can redistribute it and/or modify it | 5 | * This program is free software; you can redistribute it and/or |
5 | * under the terms of version 2 of the GNU General Public License as | 6 | * modify it under the terms of the GNU General Public License as |
6 | * published by the Free Software Foundation. | 7 | * published by the Free Software Foundation. |
7 | * | 8 | * |
8 | * This program is distributed in the hope that it would be useful, but | 9 | * This program is distributed in the hope that it would be useful, |
9 | * WITHOUT ANY WARRANTY; without even the implied warranty of | 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
12 | * GNU General Public License for more details. | ||
11 | * | 13 | * |
12 | * Further, this software is distributed without any warranty that it is | 14 | * You should have received a copy of the GNU General Public License |
13 | * free of the rightful claim of any third person regarding infringement | 15 | * along with this program; if not, write the Free Software Foundation, |
14 | * or the like. Any license provided herein, whether implied or | 16 | * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
15 | * otherwise, applies only to this software file. Patent licenses, if | ||
16 | * any, provided herein do not apply to combinations of this program with | ||
17 | * other software, or any other product whatsoever. | ||
18 | * | ||
19 | * You should have received a copy of the GNU General Public License along | ||
20 | * with this program; if not, write the Free Software Foundation, Inc., 59 | ||
21 | * Temple Place - Suite 330, Boston MA 02111-1307, USA. | ||
22 | * | ||
23 | * Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy, | ||
24 | * Mountain View, CA 94043, or: | ||
25 | * | ||
26 | * http://www.sgi.com | ||
27 | * | ||
28 | * For further information regarding this notice, see: | ||
29 | * | ||
30 | * http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/ | ||
31 | */ | 17 | */ |
32 | |||
33 | #include "xfs.h" | 18 | #include "xfs.h" |
34 | #include "xfs_types.h" | 19 | #include "xfs_types.h" |
35 | #include "xfs_dmapi.h" | 20 | #include "xfs_dmapi.h" |
@@ -41,7 +26,7 @@ | |||
41 | #include "xfs_export.h" | 26 | #include "xfs_export.h" |
42 | 27 | ||
43 | /* | 28 | /* |
44 | * XFS encode and decodes the fileid portion of NFS filehandles | 29 | * XFS encodes and decodes the fileid portion of NFS filehandles |
45 | * itself instead of letting the generic NFS code do it. This | 30 | * itself instead of letting the generic NFS code do it. This |
46 | * allows filesystems with 64 bit inode numbers to be exported. | 31 | * allows filesystems with 64 bit inode numbers to be exported. |
47 | * | 32 | * |
@@ -51,7 +36,6 @@ | |||
51 | * remains in that code. | 36 | * remains in that code. |
52 | */ | 37 | */ |
53 | 38 | ||
54 | |||
55 | STATIC struct dentry * | 39 | STATIC struct dentry * |
56 | linvfs_decode_fh( | 40 | linvfs_decode_fh( |
57 | struct super_block *sb, | 41 | struct super_block *sb, |
@@ -92,7 +76,7 @@ linvfs_decode_fh( | |||
92 | p = xfs_fileid_decode_fid2(p, &pfid, is64); | 76 | p = xfs_fileid_decode_fid2(p, &pfid, is64); |
93 | parent = &pfid; | 77 | parent = &pfid; |
94 | } | 78 | } |
95 | 79 | ||
96 | fh = (__u32 *)&ifid; | 80 | fh = (__u32 *)&ifid; |
97 | return find_exported_dentry(sb, fh, parent, acceptable, context); | 81 | return find_exported_dentry(sb, fh, parent, acceptable, context); |
98 | } | 82 | } |
@@ -112,9 +96,8 @@ linvfs_encode_fh( | |||
112 | int is64 = 0; | 96 | int is64 = 0; |
113 | #if XFS_BIG_INUMS | 97 | #if XFS_BIG_INUMS |
114 | vfs_t *vfs = LINVFS_GET_VFS(inode->i_sb); | 98 | vfs_t *vfs = LINVFS_GET_VFS(inode->i_sb); |
115 | xfs_mount_t *mp = XFS_VFSTOM(vfs); | 99 | |
116 | 100 | if (!(vfs->vfs_flag & VFS_32BITINODES)) { | |
117 | if (!(mp->m_flags & XFS_MOUNT_32BITINOOPT)) { | ||
118 | /* filesystem may contain 64bit inode numbers */ | 101 | /* filesystem may contain 64bit inode numbers */ |
119 | is64 = XFS_FILEID_TYPE_64FLAG; | 102 | is64 = XFS_FILEID_TYPE_64FLAG; |
120 | } | 103 | } |
diff --git a/fs/xfs/linux-2.6/xfs_export.h b/fs/xfs/linux-2.6/xfs_export.h index 60b2abac1c18..e5b0559700a4 100644 --- a/fs/xfs/linux-2.6/xfs_export.h +++ b/fs/xfs/linux-2.6/xfs_export.h | |||
@@ -1,33 +1,19 @@ | |||
1 | /* | 1 | /* |
2 | * Copyright (c) 2005 Silicon Graphics, Inc. All Rights Reserved. | 2 | * Copyright (c) 2005 Silicon Graphics, Inc. |
3 | * All Rights Reserved. | ||
3 | * | 4 | * |
4 | * This program is free software; you can redistribute it and/or modify it | 5 | * This program is free software; you can redistribute it and/or |
5 | * under the terms of version 2 of the GNU General Public License as | 6 | * modify it under the terms of the GNU General Public License as |
6 | * published by the Free Software Foundation. | 7 | * published by the Free Software Foundation. |
7 | * | 8 | * |
8 | * This program is distributed in the hope that it would be useful, but | 9 | * This program is distributed in the hope that it would be useful, |
9 | * WITHOUT ANY WARRANTY; without even the implied warranty of | 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
12 | * GNU General Public License for more details. | ||
11 | * | 13 | * |
12 | * Further, this software is distributed without any warranty that it is | 14 | * You should have received a copy of the GNU General Public License |
13 | * free of the rightful claim of any third person regarding infringement | 15 | * along with this program; if not, write the Free Software Foundation, |
14 | * or the like. Any license provided herein, whether implied or | 16 | * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
15 | * otherwise, applies only to this software file. Patent licenses, if | ||
16 | * any, provided herein do not apply to combinations of this program with | ||
17 | * other software, or any other product whatsoever. | ||
18 | * | ||
19 | * You should have received a copy of the GNU General Public License along | ||
20 | * with this program; if not, write the Free Software Foundation, Inc., 59 | ||
21 | * Temple Place - Suite 330, Boston MA 02111-1307, USA. | ||
22 | * | ||
23 | * Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy, | ||
24 | * Mountain View, CA 94043, or: | ||
25 | * | ||
26 | * http://www.sgi.com | ||
27 | * | ||
28 | * For further information regarding this notice, see: | ||
29 | * | ||
30 | * http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/ | ||
31 | */ | 17 | */ |
32 | #ifndef __XFS_EXPORT_H__ | 18 | #ifndef __XFS_EXPORT_H__ |
33 | #define __XFS_EXPORT_H__ | 19 | #define __XFS_EXPORT_H__ |
diff --git a/fs/xfs/linux-2.6/xfs_file.c b/fs/xfs/linux-2.6/xfs_file.c index 3881622bcf08..06111d0bbae4 100644 --- a/fs/xfs/linux-2.6/xfs_file.c +++ b/fs/xfs/linux-2.6/xfs_file.c | |||
@@ -1,39 +1,26 @@ | |||
1 | /* | 1 | /* |
2 | * Copyright (c) 2000-2005 Silicon Graphics, Inc. All Rights Reserved. | 2 | * Copyright (c) 2000-2005 Silicon Graphics, Inc. |
3 | * All Rights Reserved. | ||
3 | * | 4 | * |
4 | * This program is free software; you can redistribute it and/or modify it | 5 | * This program is free software; you can redistribute it and/or |
5 | * under the terms of version 2 of the GNU General Public License as | 6 | * modify it under the terms of the GNU General Public License as |
6 | * published by the Free Software Foundation. | 7 | * published by the Free Software Foundation. |
7 | * | 8 | * |
8 | * This program is distributed in the hope that it would be useful, but | 9 | * This program is distributed in the hope that it would be useful, |
9 | * WITHOUT ANY WARRANTY; without even the implied warranty of | 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
12 | * GNU General Public License for more details. | ||
11 | * | 13 | * |
12 | * Further, this software is distributed without any warranty that it is | 14 | * You should have received a copy of the GNU General Public License |
13 | * free of the rightful claim of any third person regarding infringement | 15 | * along with this program; if not, write the Free Software Foundation, |
14 | * or the like. Any license provided herein, whether implied or | 16 | * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
15 | * otherwise, applies only to this software file. Patent licenses, if | ||
16 | * any, provided herein do not apply to combinations of this program with | ||
17 | * other software, or any other product whatsoever. | ||
18 | * | ||
19 | * You should have received a copy of the GNU General Public License along | ||
20 | * with this program; if not, write the Free Software Foundation, Inc., 59 | ||
21 | * Temple Place - Suite 330, Boston MA 02111-1307, USA. | ||
22 | * | ||
23 | * Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy, | ||
24 | * Mountain View, CA 94043, or: | ||
25 | * | ||
26 | * http://www.sgi.com | ||
27 | * | ||
28 | * For further information regarding this notice, see: | ||
29 | * | ||
30 | * http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/ | ||
31 | */ | 17 | */ |
32 | |||
33 | #include "xfs.h" | 18 | #include "xfs.h" |
34 | #include "xfs_inum.h" | 19 | #include "xfs_bit.h" |
35 | #include "xfs_log.h" | 20 | #include "xfs_log.h" |
21 | #include "xfs_inum.h" | ||
36 | #include "xfs_sb.h" | 22 | #include "xfs_sb.h" |
23 | #include "xfs_ag.h" | ||
37 | #include "xfs_dir.h" | 24 | #include "xfs_dir.h" |
38 | #include "xfs_dir2.h" | 25 | #include "xfs_dir2.h" |
39 | #include "xfs_trans.h" | 26 | #include "xfs_trans.h" |
diff --git a/fs/xfs/linux-2.6/xfs_fs_subr.c b/fs/xfs/linux-2.6/xfs_fs_subr.c index 05ebd30ec96f..f89340c61bf2 100644 --- a/fs/xfs/linux-2.6/xfs_fs_subr.c +++ b/fs/xfs/linux-2.6/xfs_fs_subr.c | |||
@@ -1,33 +1,19 @@ | |||
1 | /* | 1 | /* |
2 | * Copyright (c) 2000-2002 Silicon Graphics, Inc. All Rights Reserved. | 2 | * Copyright (c) 2000-2002,2005 Silicon Graphics, Inc. |
3 | * All Rights Reserved. | ||
3 | * | 4 | * |
4 | * This program is free software; you can redistribute it and/or modify it | 5 | * This program is free software; you can redistribute it and/or |
5 | * under the terms of version 2 of the GNU General Public License as | 6 | * modify it under the terms of the GNU General Public License as |
6 | * published by the Free Software Foundation. | 7 | * published by the Free Software Foundation. |
7 | * | 8 | * |
8 | * This program is distributed in the hope that it would be useful, but | 9 | * This program is distributed in the hope that it would be useful, |
9 | * WITHOUT ANY WARRANTY; without even the implied warranty of | 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
12 | * GNU General Public License for more details. | ||
11 | * | 13 | * |
12 | * Further, this software is distributed without any warranty that it is | 14 | * You should have received a copy of the GNU General Public License |
13 | * free of the rightful claim of any third person regarding infringement | 15 | * along with this program; if not, write the Free Software Foundation, |
14 | * or the like. Any license provided herein, whether implied or | 16 | * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
15 | * otherwise, applies only to this software file. Patent licenses, if | ||
16 | * any, provided herein do not apply to combinations of this program with | ||
17 | * other software, or any other product whatsoever. | ||
18 | * | ||
19 | * You should have received a copy of the GNU General Public License along | ||
20 | * with this program; if not, write the Free Software Foundation, Inc., 59 | ||
21 | * Temple Place - Suite 330, Boston MA 02111-1307, USA. | ||
22 | * | ||
23 | * Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy, | ||
24 | * Mountain View, CA 94043, or: | ||
25 | * | ||
26 | * http://www.sgi.com | ||
27 | * | ||
28 | * For further information regarding this notice, see: | ||
29 | * | ||
30 | * http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/ | ||
31 | */ | 17 | */ |
32 | 18 | ||
33 | #include "xfs.h" | 19 | #include "xfs.h" |
@@ -117,6 +103,8 @@ fs_flush_pages( | |||
117 | 103 | ||
118 | if (VN_CACHED(vp)) { | 104 | if (VN_CACHED(vp)) { |
119 | filemap_fdatawrite(ip->i_mapping); | 105 | filemap_fdatawrite(ip->i_mapping); |
106 | if (flags & XFS_B_ASYNC) | ||
107 | return 0; | ||
120 | filemap_fdatawait(ip->i_mapping); | 108 | filemap_fdatawait(ip->i_mapping); |
121 | } | 109 | } |
122 | 110 | ||
diff --git a/fs/xfs/linux-2.6/xfs_fs_subr.h b/fs/xfs/linux-2.6/xfs_fs_subr.h index 2db9ddbd4567..aee9ccdd18f7 100644 --- a/fs/xfs/linux-2.6/xfs_fs_subr.h +++ b/fs/xfs/linux-2.6/xfs_fs_subr.h | |||
@@ -1,48 +1,29 @@ | |||
1 | /* | 1 | /* |
2 | * Copyright (c) 2000, 2002 Silicon Graphics, Inc. All Rights Reserved. | 2 | * Copyright (c) 2000,2002,2005 Silicon Graphics, Inc. |
3 | * All Rights Reserved. | ||
3 | * | 4 | * |
4 | * This program is free software; you can redistribute it and/or modify it | 5 | * This program is free software; you can redistribute it and/or |
5 | * under the terms of version 2 of the GNU General Public License as | 6 | * modify it under the terms of the GNU General Public License as |
6 | * published by the Free Software Foundation. | 7 | * published by the Free Software Foundation. |
7 | * | 8 | * |
8 | * This program is distributed in the hope that it would be useful, but | 9 | * This program is distributed in the hope that it would be useful, |
9 | * WITHOUT ANY WARRANTY; without even the implied warranty of | 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
12 | * GNU General Public License for more details. | ||
11 | * | 13 | * |
12 | * Further, this software is distributed without any warranty that it is | 14 | * You should have received a copy of the GNU General Public License |
13 | * free of the rightful claim of any third person regarding infringement | 15 | * along with this program; if not, write the Free Software Foundation, |
14 | * or the like. Any license provided herein, whether implied or | 16 | * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
15 | * otherwise, applies only to this software file. Patent licenses, if | ||
16 | * any, provided herein do not apply to combinations of this program with | ||
17 | * other software, or any other product whatsoever. | ||
18 | * | ||
19 | * You should have received a copy of the GNU General Public License along | ||
20 | * with this program; if not, write the Free Software Foundation, Inc., 59 | ||
21 | * Temple Place - Suite 330, Boston MA 02111-1307, USA. | ||
22 | * | ||
23 | * Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy, | ||
24 | * Mountain View, CA 94043, or: | ||
25 | * | ||
26 | * http://www.sgi.com | ||
27 | * | ||
28 | * For further information regarding this notice, see: | ||
29 | * | ||
30 | * http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/ | ||
31 | */ | ||
32 | #ifndef __XFS_SUBR_H__ | ||
33 | #define __XFS_SUBR_H__ | ||
34 | |||
35 | /* | ||
36 | * Utilities shared among file system implementations. | ||
37 | */ | 17 | */ |
18 | #ifndef __XFS_FS_SUBR_H__ | ||
19 | #define __XFS_FS_SUBR_H__ | ||
38 | 20 | ||
39 | struct cred; | 21 | struct cred; |
40 | 22 | extern int fs_noerr(void); | |
41 | extern int fs_noerr(void); | 23 | extern int fs_nosys(void); |
42 | extern int fs_nosys(void); | 24 | extern void fs_noval(void); |
43 | extern void fs_noval(void); | 25 | extern void fs_tosspages(bhv_desc_t *, xfs_off_t, xfs_off_t, int); |
44 | extern void fs_tosspages(bhv_desc_t *, xfs_off_t, xfs_off_t, int); | 26 | extern void fs_flushinval_pages(bhv_desc_t *, xfs_off_t, xfs_off_t, int); |
45 | extern void fs_flushinval_pages(bhv_desc_t *, xfs_off_t, xfs_off_t, int); | 27 | extern int fs_flush_pages(bhv_desc_t *, xfs_off_t, xfs_off_t, uint64_t, int); |
46 | extern int fs_flush_pages(bhv_desc_t *, xfs_off_t, xfs_off_t, uint64_t, int); | ||
47 | 28 | ||
48 | #endif /* __XFS_FS_SUBR_H__ */ | 29 | #endif /* __XFS_FS_SUBR_H__ */ |
diff --git a/fs/xfs/linux-2.6/xfs_globals.c b/fs/xfs/linux-2.6/xfs_globals.c index a6da5b4fd240..6e8085f34635 100644 --- a/fs/xfs/linux-2.6/xfs_globals.c +++ b/fs/xfs/linux-2.6/xfs_globals.c | |||
@@ -1,40 +1,20 @@ | |||
1 | /* | 1 | /* |
2 | * Copyright (c) 2000-2004 Silicon Graphics, Inc. All Rights Reserved. | 2 | * Copyright (c) 2000-2005 Silicon Graphics, Inc. |
3 | * All Rights Reserved. | ||
3 | * | 4 | * |
4 | * This program is free software; you can redistribute it and/or modify it | 5 | * This program is free software; you can redistribute it and/or |
5 | * under the terms of version 2 of the GNU General Public License as | 6 | * modify it under the terms of the GNU General Public License as |
6 | * published by the Free Software Foundation. | 7 | * published by the Free Software Foundation. |
7 | * | 8 | * |
8 | * This program is distributed in the hope that it would be useful, but | 9 | * This program is distributed in the hope that it would be useful, |
9 | * WITHOUT ANY WARRANTY; without even the implied warranty of | 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
12 | * GNU General Public License for more details. | ||
11 | * | 13 | * |
12 | * Further, this software is distributed without any warranty that it is | 14 | * You should have received a copy of the GNU General Public License |
13 | * free of the rightful claim of any third person regarding infringement | 15 | * along with this program; if not, write the Free Software Foundation, |
14 | * or the like. Any license provided herein, whether implied or | 16 | * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
15 | * otherwise, applies only to this software file. Patent licenses, if | ||
16 | * any, provided herein do not apply to combinations of this program with | ||
17 | * other software, or any other product whatsoever. | ||
18 | * | ||
19 | * You should have received a copy of the GNU General Public License along | ||
20 | * with this program; if not, write the Free Software Foundation, Inc., 59 | ||
21 | * Temple Place - Suite 330, Boston MA 02111-1307, USA. | ||
22 | * | ||
23 | * Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy, | ||
24 | * Mountain View, CA 94043, or: | ||
25 | * | ||
26 | * http://www.sgi.com | ||
27 | * | ||
28 | * For further information regarding this notice, see: | ||
29 | * | ||
30 | * http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/ | ||
31 | */ | 17 | */ |
32 | |||
33 | /* | ||
34 | * This file contains globals needed by XFS that were normally defined | ||
35 | * somewhere else in IRIX. | ||
36 | */ | ||
37 | |||
38 | #include "xfs.h" | 18 | #include "xfs.h" |
39 | #include "xfs_cred.h" | 19 | #include "xfs_cred.h" |
40 | #include "xfs_sysctl.h" | 20 | #include "xfs_sysctl.h" |
diff --git a/fs/xfs/linux-2.6/xfs_globals.h b/fs/xfs/linux-2.6/xfs_globals.h index e81e2f38a853..e1a22bfcf865 100644 --- a/fs/xfs/linux-2.6/xfs_globals.h +++ b/fs/xfs/linux-2.6/xfs_globals.h | |||
@@ -1,42 +1,23 @@ | |||
1 | /* | 1 | /* |
2 | * Copyright (c) 2000-2003 Silicon Graphics, Inc. All Rights Reserved. | 2 | * Copyright (c) 2000-2003,2005 Silicon Graphics, Inc. |
3 | * All Rights Reserved. | ||
3 | * | 4 | * |
4 | * This program is free software; you can redistribute it and/or modify it | 5 | * This program is free software; you can redistribute it and/or |
5 | * under the terms of version 2 of the GNU General Public License as | 6 | * modify it under the terms of the GNU General Public License as |
6 | * published by the Free Software Foundation. | 7 | * published by the Free Software Foundation. |
7 | * | 8 | * |
8 | * This program is distributed in the hope that it would be useful, but | 9 | * This program is distributed in the hope that it would be useful, |
9 | * WITHOUT ANY WARRANTY; without even the implied warranty of | 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
12 | * GNU General Public License for more details. | ||
11 | * | 13 | * |
12 | * Further, this software is distributed without any warranty that it is | 14 | * You should have received a copy of the GNU General Public License |
13 | * free of the rightful claim of any third person regarding infringement | 15 | * along with this program; if not, write the Free Software Foundation, |
14 | * or the like. Any license provided herein, whether implied or | 16 | * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
15 | * otherwise, applies only to this software file. Patent licenses, if | ||
16 | * any, provided herein do not apply to combinations of this program with | ||
17 | * other software, or any other product whatsoever. | ||
18 | * | ||
19 | * You should have received a copy of the GNU General Public License along | ||
20 | * with this program; if not, write the Free Software Foundation, Inc., 59 | ||
21 | * Temple Place - Suite 330, Boston MA 02111-1307, USA. | ||
22 | * | ||
23 | * Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy, | ||
24 | * Mountain View, CA 94043, or: | ||
25 | * | ||
26 | * http://www.sgi.com | ||
27 | * | ||
28 | * For further information regarding this notice, see: | ||
29 | * | ||
30 | * http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/ | ||
31 | */ | 17 | */ |
32 | #ifndef __XFS_GLOBALS_H__ | 18 | #ifndef __XFS_GLOBALS_H__ |
33 | #define __XFS_GLOBALS_H__ | 19 | #define __XFS_GLOBALS_H__ |
34 | 20 | ||
35 | /* | ||
36 | * This file declares globals needed by XFS that were normally defined | ||
37 | * somewhere else in IRIX. | ||
38 | */ | ||
39 | |||
40 | extern uint64_t xfs_panic_mask; /* set to cause more panics */ | 21 | extern uint64_t xfs_panic_mask; /* set to cause more panics */ |
41 | extern unsigned long xfs_physmem; | 22 | extern unsigned long xfs_physmem; |
42 | extern struct cred *sys_cred; | 23 | extern struct cred *sys_cred; |
diff --git a/fs/xfs/linux-2.6/xfs_ioctl.c b/fs/xfs/linux-2.6/xfs_ioctl.c index 6a3326bcd8d0..b78b5eb9e96c 100644 --- a/fs/xfs/linux-2.6/xfs_ioctl.c +++ b/fs/xfs/linux-2.6/xfs_ioctl.c | |||
@@ -1,67 +1,52 @@ | |||
1 | /* | 1 | /* |
2 | * Copyright (c) 2000-2003 Silicon Graphics, Inc. All Rights Reserved. | 2 | * Copyright (c) 2000-2005 Silicon Graphics, Inc. |
3 | * All Rights Reserved. | ||
3 | * | 4 | * |
4 | * This program is free software; you can redistribute it and/or modify it | 5 | * This program is free software; you can redistribute it and/or |
5 | * under the terms of version 2 of the GNU General Public License as | 6 | * modify it under the terms of the GNU General Public License as |
6 | * published by the Free Software Foundation. | 7 | * published by the Free Software Foundation. |
7 | * | 8 | * |
8 | * This program is distributed in the hope that it would be useful, but | 9 | * This program is distributed in the hope that it would be useful, |
9 | * WITHOUT ANY WARRANTY; without even the implied warranty of | 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
12 | * GNU General Public License for more details. | ||
11 | * | 13 | * |
12 | * Further, this software is distributed without any warranty that it is | 14 | * You should have received a copy of the GNU General Public License |
13 | * free of the rightful claim of any third person regarding infringement | 15 | * along with this program; if not, write the Free Software Foundation, |
14 | * or the like. Any license provided herein, whether implied or | 16 | * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
15 | * otherwise, applies only to this software file. Patent licenses, if | ||
16 | * any, provided herein do not apply to combinations of this program with | ||
17 | * other software, or any other product whatsoever. | ||
18 | * | ||
19 | * You should have received a copy of the GNU General Public License along | ||
20 | * with this program; if not, write the Free Software Foundation, Inc., 59 | ||
21 | * Temple Place - Suite 330, Boston MA 02111-1307, USA. | ||
22 | * | ||
23 | * Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy, | ||
24 | * Mountain View, CA 94043, or: | ||
25 | * | ||
26 | * http://www.sgi.com | ||
27 | * | ||
28 | * For further information regarding this notice, see: | ||
29 | * | ||
30 | * http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/ | ||
31 | */ | 17 | */ |
32 | |||
33 | #include "xfs.h" | 18 | #include "xfs.h" |
34 | |||
35 | #include "xfs_fs.h" | 19 | #include "xfs_fs.h" |
36 | #include "xfs_inum.h" | 20 | #include "xfs_bit.h" |
37 | #include "xfs_log.h" | 21 | #include "xfs_log.h" |
22 | #include "xfs_inum.h" | ||
38 | #include "xfs_trans.h" | 23 | #include "xfs_trans.h" |
39 | #include "xfs_sb.h" | 24 | #include "xfs_sb.h" |
25 | #include "xfs_ag.h" | ||
40 | #include "xfs_dir.h" | 26 | #include "xfs_dir.h" |
41 | #include "xfs_dir2.h" | 27 | #include "xfs_dir2.h" |
42 | #include "xfs_alloc.h" | 28 | #include "xfs_alloc.h" |
43 | #include "xfs_dmapi.h" | 29 | #include "xfs_dmapi.h" |
44 | #include "xfs_mount.h" | 30 | #include "xfs_mount.h" |
45 | #include "xfs_alloc_btree.h" | ||
46 | #include "xfs_bmap_btree.h" | 31 | #include "xfs_bmap_btree.h" |
32 | #include "xfs_alloc_btree.h" | ||
47 | #include "xfs_ialloc_btree.h" | 33 | #include "xfs_ialloc_btree.h" |
48 | #include "xfs_btree.h" | ||
49 | #include "xfs_ialloc.h" | ||
50 | #include "xfs_attr_sf.h" | ||
51 | #include "xfs_dir_sf.h" | 34 | #include "xfs_dir_sf.h" |
35 | #include "xfs_attr_sf.h" | ||
52 | #include "xfs_dir2_sf.h" | 36 | #include "xfs_dir2_sf.h" |
53 | #include "xfs_dinode.h" | 37 | #include "xfs_dinode.h" |
54 | #include "xfs_inode.h" | 38 | #include "xfs_inode.h" |
55 | #include "xfs_bmap.h" | 39 | #include "xfs_btree.h" |
56 | #include "xfs_bit.h" | 40 | #include "xfs_ialloc.h" |
57 | #include "xfs_rtalloc.h" | 41 | #include "xfs_rtalloc.h" |
58 | #include "xfs_error.h" | ||
59 | #include "xfs_itable.h" | 42 | #include "xfs_itable.h" |
43 | #include "xfs_error.h" | ||
60 | #include "xfs_rw.h" | 44 | #include "xfs_rw.h" |
61 | #include "xfs_acl.h" | 45 | #include "xfs_acl.h" |
62 | #include "xfs_cap.h" | 46 | #include "xfs_cap.h" |
63 | #include "xfs_mac.h" | 47 | #include "xfs_mac.h" |
64 | #include "xfs_attr.h" | 48 | #include "xfs_attr.h" |
49 | #include "xfs_bmap.h" | ||
65 | #include "xfs_buf_item.h" | 50 | #include "xfs_buf_item.h" |
66 | #include "xfs_utils.h" | 51 | #include "xfs_utils.h" |
67 | #include "xfs_dfrag.h" | 52 | #include "xfs_dfrag.h" |
diff --git a/fs/xfs/linux-2.6/xfs_ioctl32.c b/fs/xfs/linux-2.6/xfs_ioctl32.c index 4636b7f86f1f..c83ae15bb0e6 100644 --- a/fs/xfs/linux-2.6/xfs_ioctl32.c +++ b/fs/xfs/linux-2.6/xfs_ioctl32.c | |||
@@ -1,35 +1,20 @@ | |||
1 | /* | 1 | /* |
2 | * Copyright (c) 2004-2005 Silicon Graphics, Inc. All Rights Reserved. | 2 | * Copyright (c) 2004-2005 Silicon Graphics, Inc. |
3 | * All Rights Reserved. | ||
3 | * | 4 | * |
4 | * This program is free software; you can redistribute it and/or modify it | 5 | * This program is free software; you can redistribute it and/or |
5 | * under the terms of version 2 of the GNU General Public License as | 6 | * modify it under the terms of the GNU General Public License as |
6 | * published by the Free Software Foundation. | 7 | * published by the Free Software Foundation. |
7 | * | 8 | * |
8 | * This program is distributed in the hope that it would be useful, but | 9 | * This program is distributed in the hope that it would be useful, |
9 | * WITHOUT ANY WARRANTY; without even the implied warranty of | 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
12 | * GNU General Public License for more details. | ||
11 | * | 13 | * |
12 | * Further, this software is distributed without any warranty that it is | 14 | * You should have received a copy of the GNU General Public License |
13 | * free of the rightful claim of any third person regarding infringement | 15 | * along with this program; if not, write the Free Software Foundation, |
14 | * or the like. Any license provided herein, whether implied or | 16 | * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
15 | * otherwise, applies only to this software file. Patent licenses, if | ||
16 | * any, provided herein do not apply to combinations of this program with | ||
17 | * other software, or any other product whatsoever. | ||
18 | * | ||
19 | * You should have received a copy of the GNU General Public License along | ||
20 | * with this program; if not, write the Free Software Foundation, Inc., 59 | ||
21 | * Temple Place - Suite 330, Boston MA 02111-1307, USA. | ||
22 | * | ||
23 | * Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy, | ||
24 | * Mountain View, CA 94043, or: | ||
25 | * | ||
26 | * http://www.sgi.com | ||
27 | * | ||
28 | * For further information regarding this notice, see: | ||
29 | * | ||
30 | * http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/ | ||
31 | */ | 17 | */ |
32 | |||
33 | #include <linux/config.h> | 18 | #include <linux/config.h> |
34 | #include <linux/compat.h> | 19 | #include <linux/compat.h> |
35 | #include <linux/init.h> | 20 | #include <linux/init.h> |
@@ -39,7 +24,6 @@ | |||
39 | #include <linux/types.h> | 24 | #include <linux/types.h> |
40 | #include <linux/fs.h> | 25 | #include <linux/fs.h> |
41 | #include <asm/uaccess.h> | 26 | #include <asm/uaccess.h> |
42 | |||
43 | #include "xfs.h" | 27 | #include "xfs.h" |
44 | #include "xfs_types.h" | 28 | #include "xfs_types.h" |
45 | #include "xfs_fs.h" | 29 | #include "xfs_fs.h" |
diff --git a/fs/xfs/linux-2.6/xfs_ioctl32.h b/fs/xfs/linux-2.6/xfs_ioctl32.h index c874793a1dc9..011c273bec50 100644 --- a/fs/xfs/linux-2.6/xfs_ioctl32.h +++ b/fs/xfs/linux-2.6/xfs_ioctl32.h | |||
@@ -1,34 +1,24 @@ | |||
1 | /* | 1 | /* |
2 | * Copyright (c) 2004-2005 Silicon Graphics, Inc. All Rights Reserved. | 2 | * Copyright (c) 2004-2005 Silicon Graphics, Inc. |
3 | * All Rights Reserved. | ||
3 | * | 4 | * |
4 | * This program is free software; you can redistribute it and/or modify it | 5 | * This program is free software; you can redistribute it and/or |
5 | * under the terms of version 2 of the GNU General Public License as | 6 | * modify it under the terms of the GNU General Public License as |
6 | * published by the Free Software Foundation. | 7 | * published by the Free Software Foundation. |
7 | * | 8 | * |
8 | * This program is distributed in the hope that it would be useful, but | 9 | * This program is distributed in the hope that it would be useful, |
9 | * WITHOUT ANY WARRANTY; without even the implied warranty of | 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
12 | * GNU General Public License for more details. | ||
11 | * | 13 | * |
12 | * Further, this software is distributed without any warranty that it is | 14 | * You should have received a copy of the GNU General Public License |
13 | * free of the rightful claim of any third person regarding infringement | 15 | * along with this program; if not, write the Free Software Foundation, |
14 | * or the like. Any license provided herein, whether implied or | 16 | * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
15 | * otherwise, applies only to this software file. Patent licenses, if | ||
16 | * any, provided herein do not apply to combinations of this program with | ||
17 | * other software, or any other product whatsoever. | ||
18 | * | ||
19 | * You should have received a copy of the GNU General Public License along | ||
20 | * with this program; if not, write the Free Software Foundation, Inc., 59 | ||
21 | * Temple Place - Suite 330, Boston MA 02111-1307, USA. | ||
22 | * | ||
23 | * Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy, | ||
24 | * Mountain View, CA 94043, or: | ||
25 | * | ||
26 | * http://www.sgi.com | ||
27 | * | ||
28 | * For further information regarding this notice, see: | ||
29 | * | ||
30 | * http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/ | ||
31 | */ | 17 | */ |
18 | #ifndef __XFS_IOCTL32_H__ | ||
19 | #define __XFS_IOCTL32_H__ | ||
20 | |||
21 | extern long linvfs_compat_ioctl(struct file *, unsigned, unsigned long); | ||
22 | extern long linvfs_compat_invis_ioctl(struct file *f, unsigned, unsigned long); | ||
32 | 23 | ||
33 | long linvfs_compat_ioctl(struct file *f, unsigned cmd, unsigned long arg); | 24 | #endif /* __XFS_IOCTL32_H__ */ |
34 | long linvfs_compat_invis_ioctl(struct file *f, unsigned cmd, unsigned long arg); | ||
diff --git a/fs/xfs/linux-2.6/xfs_iops.c b/fs/xfs/linux-2.6/xfs_iops.c index 77708a8c9f87..14215a7db59f 100644 --- a/fs/xfs/linux-2.6/xfs_iops.c +++ b/fs/xfs/linux-2.6/xfs_iops.c | |||
@@ -1,39 +1,25 @@ | |||
1 | /* | 1 | /* |
2 | * Copyright (c) 2000-2004 Silicon Graphics, Inc. All Rights Reserved. | 2 | * Copyright (c) 2000-2005 Silicon Graphics, Inc. |
3 | * All Rights Reserved. | ||
3 | * | 4 | * |
4 | * This program is free software; you can redistribute it and/or modify it | 5 | * This program is free software; you can redistribute it and/or |
5 | * under the terms of version 2 of the GNU General Public License as | 6 | * modify it under the terms of the GNU General Public License as |
6 | * published by the Free Software Foundation. | 7 | * published by the Free Software Foundation. |
7 | * | 8 | * |
8 | * This program is distributed in the hope that it would be useful, but | 9 | * This program is distributed in the hope that it would be useful, |
9 | * WITHOUT ANY WARRANTY; without even the implied warranty of | 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
12 | * GNU General Public License for more details. | ||
11 | * | 13 | * |
12 | * Further, this software is distributed without any warranty that it is | 14 | * You should have received a copy of the GNU General Public License |
13 | * free of the rightful claim of any third person regarding infringement | 15 | * along with this program; if not, write the Free Software Foundation, |
14 | * or the like. Any license provided herein, whether implied or | 16 | * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
15 | * otherwise, applies only to this software file. Patent licenses, if | ||
16 | * any, provided herein do not apply to combinations of this program with | ||
17 | * other software, or any other product whatsoever. | ||
18 | * | ||
19 | * You should have received a copy of the GNU General Public License along | ||
20 | * with this program; if not, write the Free Software Foundation, Inc., 59 | ||
21 | * Temple Place - Suite 330, Boston MA 02111-1307, USA. | ||
22 | * | ||
23 | * Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy, | ||
24 | * Mountain View, CA 94043, or: | ||
25 | * | ||
26 | * http://www.sgi.com | ||
27 | * | ||
28 | * For further information regarding this notice, see: | ||
29 | * | ||
30 | * http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/ | ||
31 | */ | 17 | */ |
32 | |||
33 | #include "xfs.h" | 18 | #include "xfs.h" |
34 | #include "xfs_fs.h" | 19 | #include "xfs_fs.h" |
35 | #include "xfs_inum.h" | 20 | #include "xfs_bit.h" |
36 | #include "xfs_log.h" | 21 | #include "xfs_log.h" |
22 | #include "xfs_inum.h" | ||
37 | #include "xfs_trans.h" | 23 | #include "xfs_trans.h" |
38 | #include "xfs_sb.h" | 24 | #include "xfs_sb.h" |
39 | #include "xfs_ag.h" | 25 | #include "xfs_ag.h" |
@@ -43,18 +29,17 @@ | |||
43 | #include "xfs_dmapi.h" | 29 | #include "xfs_dmapi.h" |
44 | #include "xfs_quota.h" | 30 | #include "xfs_quota.h" |
45 | #include "xfs_mount.h" | 31 | #include "xfs_mount.h" |
46 | #include "xfs_alloc_btree.h" | ||
47 | #include "xfs_bmap_btree.h" | 32 | #include "xfs_bmap_btree.h" |
33 | #include "xfs_alloc_btree.h" | ||
48 | #include "xfs_ialloc_btree.h" | 34 | #include "xfs_ialloc_btree.h" |
49 | #include "xfs_btree.h" | ||
50 | #include "xfs_ialloc.h" | ||
51 | #include "xfs_attr_sf.h" | ||
52 | #include "xfs_dir_sf.h" | 35 | #include "xfs_dir_sf.h" |
53 | #include "xfs_dir2_sf.h" | 36 | #include "xfs_dir2_sf.h" |
37 | #include "xfs_attr_sf.h" | ||
54 | #include "xfs_dinode.h" | 38 | #include "xfs_dinode.h" |
55 | #include "xfs_inode.h" | 39 | #include "xfs_inode.h" |
56 | #include "xfs_bmap.h" | 40 | #include "xfs_bmap.h" |
57 | #include "xfs_bit.h" | 41 | #include "xfs_btree.h" |
42 | #include "xfs_ialloc.h" | ||
58 | #include "xfs_rtalloc.h" | 43 | #include "xfs_rtalloc.h" |
59 | #include "xfs_error.h" | 44 | #include "xfs_error.h" |
60 | #include "xfs_itable.h" | 45 | #include "xfs_itable.h" |
@@ -69,6 +54,137 @@ | |||
69 | #include <linux/xattr.h> | 54 | #include <linux/xattr.h> |
70 | #include <linux/namei.h> | 55 | #include <linux/namei.h> |
71 | 56 | ||
57 | /* | ||
58 | * Change the requested timestamp in the given inode. | ||
59 | * We don't lock across timestamp updates, and we don't log them but | ||
60 | * we do record the fact that there is dirty information in core. | ||
61 | * | ||
62 | * NOTE -- callers MUST combine XFS_ICHGTIME_MOD or XFS_ICHGTIME_CHG | ||
63 | * with XFS_ICHGTIME_ACC to be sure that access time | ||
64 | * update will take. Calling first with XFS_ICHGTIME_ACC | ||
65 | * and then XFS_ICHGTIME_MOD may fail to modify the access | ||
66 | * timestamp if the filesystem is mounted noacctm. | ||
67 | */ | ||
68 | void | ||
69 | xfs_ichgtime( | ||
70 | xfs_inode_t *ip, | ||
71 | int flags) | ||
72 | { | ||
73 | struct inode *inode = LINVFS_GET_IP(XFS_ITOV(ip)); | ||
74 | timespec_t tv; | ||
75 | |||
76 | /* | ||
77 | * We're not supposed to change timestamps in readonly-mounted | ||
78 | * filesystems. Throw it away if anyone asks us. | ||
79 | */ | ||
80 | if (unlikely(IS_RDONLY(inode))) | ||
81 | return; | ||
82 | |||
83 | /* | ||
84 | * Don't update access timestamps on reads if mounted "noatime". | ||
85 | * Throw it away if anyone asks us. | ||
86 | */ | ||
87 | if (unlikely( | ||
88 | (ip->i_mount->m_flags & XFS_MOUNT_NOATIME || IS_NOATIME(inode)) && | ||
89 | (flags & (XFS_ICHGTIME_ACC|XFS_ICHGTIME_MOD|XFS_ICHGTIME_CHG)) == | ||
90 | XFS_ICHGTIME_ACC)) | ||
91 | return; | ||
92 | |||
93 | nanotime(&tv); | ||
94 | if (flags & XFS_ICHGTIME_MOD) { | ||
95 | inode->i_mtime = tv; | ||
96 | ip->i_d.di_mtime.t_sec = (__int32_t)tv.tv_sec; | ||
97 | ip->i_d.di_mtime.t_nsec = (__int32_t)tv.tv_nsec; | ||
98 | } | ||
99 | if (flags & XFS_ICHGTIME_ACC) { | ||
100 | inode->i_atime = tv; | ||
101 | ip->i_d.di_atime.t_sec = (__int32_t)tv.tv_sec; | ||
102 | ip->i_d.di_atime.t_nsec = (__int32_t)tv.tv_nsec; | ||
103 | } | ||
104 | if (flags & XFS_ICHGTIME_CHG) { | ||
105 | inode->i_ctime = tv; | ||
106 | ip->i_d.di_ctime.t_sec = (__int32_t)tv.tv_sec; | ||
107 | ip->i_d.di_ctime.t_nsec = (__int32_t)tv.tv_nsec; | ||
108 | } | ||
109 | |||
110 | /* | ||
111 | * We update the i_update_core field _after_ changing | ||
112 | * the timestamps in order to coordinate properly with | ||
113 | * xfs_iflush() so that we don't lose timestamp updates. | ||
114 | * This keeps us from having to hold the inode lock | ||
115 | * while doing this. We use the SYNCHRONIZE macro to | ||
116 | * ensure that the compiler does not reorder the update | ||
117 | * of i_update_core above the timestamp updates above. | ||
118 | */ | ||
119 | SYNCHRONIZE(); | ||
120 | ip->i_update_core = 1; | ||
121 | if (!(inode->i_state & I_LOCK)) | ||
122 | mark_inode_dirty_sync(inode); | ||
123 | } | ||
124 | |||
125 | /* | ||
126 | * Variant on the above which avoids querying the system clock | ||
127 | * in situations where we know the Linux inode timestamps have | ||
128 | * just been updated (and so we can update our inode cheaply). | ||
129 | * We also skip the readonly and noatime checks here, they are | ||
130 | * also catered for already. | ||
131 | */ | ||
132 | void | ||
133 | xfs_ichgtime_fast( | ||
134 | xfs_inode_t *ip, | ||
135 | struct inode *inode, | ||
136 | int flags) | ||
137 | { | ||
138 | timespec_t *tvp; | ||
139 | |||
140 | /* | ||
141 | * We're not supposed to change timestamps in readonly-mounted | ||
142 | * filesystems. Throw it away if anyone asks us. | ||
143 | */ | ||
144 | if (unlikely(IS_RDONLY(inode))) | ||
145 | return; | ||
146 | |||
147 | /* | ||
148 | * Don't update access timestamps on reads if mounted "noatime". | ||
149 | * Throw it away if anyone asks us. | ||
150 | */ | ||
151 | if (unlikely( | ||
152 | (ip->i_mount->m_flags & XFS_MOUNT_NOATIME || IS_NOATIME(inode)) && | ||
153 | ((flags & (XFS_ICHGTIME_ACC|XFS_ICHGTIME_MOD|XFS_ICHGTIME_CHG)) == | ||
154 | XFS_ICHGTIME_ACC))) | ||
155 | return; | ||
156 | |||
157 | if (flags & XFS_ICHGTIME_MOD) { | ||
158 | tvp = &inode->i_mtime; | ||
159 | ip->i_d.di_mtime.t_sec = (__int32_t)tvp->tv_sec; | ||
160 | ip->i_d.di_mtime.t_nsec = (__int32_t)tvp->tv_nsec; | ||
161 | } | ||
162 | if (flags & XFS_ICHGTIME_ACC) { | ||
163 | tvp = &inode->i_atime; | ||
164 | ip->i_d.di_atime.t_sec = (__int32_t)tvp->tv_sec; | ||
165 | ip->i_d.di_atime.t_nsec = (__int32_t)tvp->tv_nsec; | ||
166 | } | ||
167 | if (flags & XFS_ICHGTIME_CHG) { | ||
168 | tvp = &inode->i_ctime; | ||
169 | ip->i_d.di_ctime.t_sec = (__int32_t)tvp->tv_sec; | ||
170 | ip->i_d.di_ctime.t_nsec = (__int32_t)tvp->tv_nsec; | ||
171 | } | ||
172 | |||
173 | /* | ||
174 | * We update the i_update_core field _after_ changing | ||
175 | * the timestamps in order to coordinate properly with | ||
176 | * xfs_iflush() so that we don't lose timestamp updates. | ||
177 | * This keeps us from having to hold the inode lock | ||
178 | * while doing this. We use the SYNCHRONIZE macro to | ||
179 | * ensure that the compiler does not reorder the update | ||
180 | * of i_update_core above the timestamp updates above. | ||
181 | */ | ||
182 | SYNCHRONIZE(); | ||
183 | ip->i_update_core = 1; | ||
184 | if (!(inode->i_state & I_LOCK)) | ||
185 | mark_inode_dirty_sync(inode); | ||
186 | } | ||
187 | |||
72 | 188 | ||
73 | /* | 189 | /* |
74 | * Pull the link count and size up from the xfs inode to the linux inode | 190 | * Pull the link count and size up from the xfs inode to the linux inode |
diff --git a/fs/xfs/linux-2.6/xfs_iops.h b/fs/xfs/linux-2.6/xfs_iops.h index 6a69a62c36b0..ee784b63acbf 100644 --- a/fs/xfs/linux-2.6/xfs_iops.h +++ b/fs/xfs/linux-2.6/xfs_iops.h | |||
@@ -1,33 +1,19 @@ | |||
1 | /* | 1 | /* |
2 | * Copyright (c) 2000-2003 Silicon Graphics, Inc. All Rights Reserved. | 2 | * Copyright (c) 2000-2003,2005 Silicon Graphics, Inc. |
3 | * All Rights Reserved. | ||
3 | * | 4 | * |
4 | * This program is free software; you can redistribute it and/or modify it | 5 | * This program is free software; you can redistribute it and/or |
5 | * under the terms of version 2 of the GNU General Public License as | 6 | * modify it under the terms of the GNU General Public License as |
6 | * published by the Free Software Foundation. | 7 | * published by the Free Software Foundation. |
7 | * | 8 | * |
8 | * This program is distributed in the hope that it would be useful, but | 9 | * This program is distributed in the hope that it would be useful, |
9 | * WITHOUT ANY WARRANTY; without even the implied warranty of | 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
12 | * GNU General Public License for more details. | ||
11 | * | 13 | * |
12 | * Further, this software is distributed without any warranty that it is | 14 | * You should have received a copy of the GNU General Public License |
13 | * free of the rightful claim of any third person regarding infringement | 15 | * along with this program; if not, write the Free Software Foundation, |
14 | * or the like. Any license provided herein, whether implied or | 16 | * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
15 | * otherwise, applies only to this software file. Patent licenses, if | ||
16 | * any, provided herein do not apply to combinations of this program with | ||
17 | * other software, or any other product whatsoever. | ||
18 | * | ||
19 | * You should have received a copy of the GNU General Public License along | ||
20 | * with this program; if not, write the Free Software Foundation, Inc., 59 | ||
21 | * Temple Place - Suite 330, Boston MA 02111-1307, USA. | ||
22 | * | ||
23 | * Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy, | ||
24 | * Mountain View, CA 94043, or: | ||
25 | * | ||
26 | * http://www.sgi.com | ||
27 | * | ||
28 | * For further information regarding this notice, see: | ||
29 | * | ||
30 | * http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/ | ||
31 | */ | 17 | */ |
32 | #ifndef __XFS_IOPS_H__ | 18 | #ifndef __XFS_IOPS_H__ |
33 | #define __XFS_IOPS_H__ | 19 | #define __XFS_IOPS_H__ |
@@ -48,4 +34,8 @@ extern void linvfs_unwritten_done(struct buffer_head *, int); | |||
48 | extern int xfs_ioctl(struct bhv_desc *, struct inode *, struct file *, | 34 | extern int xfs_ioctl(struct bhv_desc *, struct inode *, struct file *, |
49 | int, unsigned int, void __user *); | 35 | int, unsigned int, void __user *); |
50 | 36 | ||
37 | struct xfs_inode; | ||
38 | extern void xfs_ichgtime(struct xfs_inode *, int); | ||
39 | extern void xfs_ichgtime_fast(struct xfs_inode *, struct inode *, int); | ||
40 | |||
51 | #endif /* __XFS_IOPS_H__ */ | 41 | #endif /* __XFS_IOPS_H__ */ |
diff --git a/fs/xfs/linux-2.6/xfs_linux.h b/fs/xfs/linux-2.6/xfs_linux.h index 68c5d885ed9c..d8e21ba0cccc 100644 --- a/fs/xfs/linux-2.6/xfs_linux.h +++ b/fs/xfs/linux-2.6/xfs_linux.h | |||
@@ -1,33 +1,19 @@ | |||
1 | /* | 1 | /* |
2 | * Copyright (c) 2000-2004 Silicon Graphics, Inc. All Rights Reserved. | 2 | * Copyright (c) 2000-2005 Silicon Graphics, Inc. |
3 | * All Rights Reserved. | ||
3 | * | 4 | * |
4 | * This program is free software; you can redistribute it and/or modify it | 5 | * This program is free software; you can redistribute it and/or |
5 | * under the terms of version 2 of the GNU General Public License as | 6 | * modify it under the terms of the GNU General Public License as |
6 | * published by the Free Software Foundation. | 7 | * published by the Free Software Foundation. |
7 | * | 8 | * |
8 | * This program is distributed in the hope that it would be useful, but | 9 | * This program is distributed in the hope that it would be useful, |
9 | * WITHOUT ANY WARRANTY; without even the implied warranty of | 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
12 | * GNU General Public License for more details. | ||
11 | * | 13 | * |
12 | * Further, this software is distributed without any warranty that it is | 14 | * You should have received a copy of the GNU General Public License |
13 | * free of the rightful claim of any third person regarding infringement | 15 | * along with this program; if not, write the Free Software Foundation, |
14 | * or the like. Any license provided herein, whether implied or | 16 | * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
15 | * otherwise, applies only to this software file. Patent licenses, if | ||
16 | * any, provided herein do not apply to combinations of this program with | ||
17 | * other software, or any other product whatsoever. | ||
18 | * | ||
19 | * You should have received a copy of the GNU General Public License along | ||
20 | * with this program; if not, write the Free Software Foundation, Inc., 59 | ||
21 | * Temple Place - Suite 330, Boston MA 02111-1307, USA. | ||
22 | * | ||
23 | * Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy, | ||
24 | * Mountain View, CA 94043, or: | ||
25 | * | ||
26 | * http://www.sgi.com | ||
27 | * | ||
28 | * For further information regarding this notice, see: | ||
29 | * | ||
30 | * http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/ | ||
31 | */ | 17 | */ |
32 | #ifndef __XFS_LINUX__ | 18 | #ifndef __XFS_LINUX__ |
33 | #define __XFS_LINUX__ | 19 | #define __XFS_LINUX__ |
@@ -86,7 +72,6 @@ | |||
86 | #include <linux/init.h> | 72 | #include <linux/init.h> |
87 | #include <linux/list.h> | 73 | #include <linux/list.h> |
88 | #include <linux/proc_fs.h> | 74 | #include <linux/proc_fs.h> |
89 | #include <linux/version.h> | ||
90 | #include <linux/sort.h> | 75 | #include <linux/sort.h> |
91 | 76 | ||
92 | #include <asm/page.h> | 77 | #include <asm/page.h> |
@@ -197,10 +182,6 @@ static inline void set_buffer_unwritten_io(struct buffer_head *bh) | |||
197 | /* bytes to clicks */ | 182 | /* bytes to clicks */ |
198 | #define btoc(x) (((__psunsigned_t)(x)+(NBPC-1))>>BPCSHIFT) | 183 | #define btoc(x) (((__psunsigned_t)(x)+(NBPC-1))>>BPCSHIFT) |
199 | 184 | ||
200 | #ifndef CELL_CAPABLE | ||
201 | #define FSC_NOTIFY_NAME_CHANGED(vp) | ||
202 | #endif | ||
203 | |||
204 | #ifndef ENOATTR | 185 | #ifndef ENOATTR |
205 | #define ENOATTR ENODATA /* Attribute not found */ | 186 | #define ENOATTR ENODATA /* Attribute not found */ |
206 | #endif | 187 | #endif |
@@ -235,30 +216,18 @@ static inline void set_buffer_unwritten_io(struct buffer_head *bh) | |||
235 | #define Q_XSETPQLIM XQM_CMD(10) /* set projects disk limits */ | 216 | #define Q_XSETPQLIM XQM_CMD(10) /* set projects disk limits */ |
236 | #define Q_XGETPQUOTA XQM_CMD(11) /* get projects disk limits */ | 217 | #define Q_XGETPQUOTA XQM_CMD(11) /* get projects disk limits */ |
237 | 218 | ||
238 | /* IRIX uses a dynamic sizing algorithm (ndquot = 200 + numprocs*2) */ | 219 | #define dfltprid 0 |
239 | /* we may well need to fine-tune this if it ever becomes an issue. */ | ||
240 | #define DQUOT_MAX_HEURISTIC 1024 /* NR_DQUOTS */ | ||
241 | #define ndquot DQUOT_MAX_HEURISTIC | ||
242 | |||
243 | /* IRIX uses the current size of the name cache to guess a good value */ | ||
244 | /* - this isn't the same but is a good enough starting point for now. */ | ||
245 | #define DQUOT_HASH_HEURISTIC files_stat.nr_files | ||
246 | |||
247 | /* IRIX inodes maintain the project ID also, zero this field on Linux */ | ||
248 | #define DEFAULT_PROJID 0 | ||
249 | #define dfltprid DEFAULT_PROJID | ||
250 | |||
251 | #define MAXPATHLEN 1024 | 220 | #define MAXPATHLEN 1024 |
252 | 221 | ||
253 | #define MIN(a,b) (min(a,b)) | 222 | #define MIN(a,b) (min(a,b)) |
254 | #define MAX(a,b) (max(a,b)) | 223 | #define MAX(a,b) (max(a,b)) |
255 | #define howmany(x, y) (((x)+((y)-1))/(y)) | 224 | #define howmany(x, y) (((x)+((y)-1))/(y)) |
256 | #define roundup(x, y) ((((x)+((y)-1))/(y))*(y)) | 225 | #define roundup(x, y) ((((x)+((y)-1))/(y))*(y)) |
257 | #define qsort(a,n,s,fn) sort(a,n,s,fn,NULL) | ||
258 | 226 | ||
259 | /* | 227 | /* |
260 | * Various platform dependent calls that don't fit anywhere else | 228 | * Various platform dependent calls that don't fit anywhere else |
261 | */ | 229 | */ |
230 | #define xfs_sort(a,n,s,fn) sort(a,n,s,fn,NULL) | ||
262 | #define xfs_stack_trace() dump_stack() | 231 | #define xfs_stack_trace() dump_stack() |
263 | #define xfs_itruncate_data(ip, off) \ | 232 | #define xfs_itruncate_data(ip, off) \ |
264 | (-vmtruncate(LINVFS_GET_IP(XFS_ITOV(ip)), (off))) | 233 | (-vmtruncate(LINVFS_GET_IP(XFS_ITOV(ip)), (off))) |
diff --git a/fs/xfs/linux-2.6/xfs_lrw.c b/fs/xfs/linux-2.6/xfs_lrw.c index 3b5fabe8dae9..279e9bc92aba 100644 --- a/fs/xfs/linux-2.6/xfs_lrw.c +++ b/fs/xfs/linux-2.6/xfs_lrw.c | |||
@@ -1,44 +1,25 @@ | |||
1 | /* | 1 | /* |
2 | * Copyright (c) 2000-2003 Silicon Graphics, Inc. All Rights Reserved. | 2 | * Copyright (c) 2000-2003,2005 Silicon Graphics, Inc. |
3 | * All Rights Reserved. | ||
3 | * | 4 | * |
4 | * This program is free software; you can redistribute it and/or modify it | 5 | * This program is free software; you can redistribute it and/or |
5 | * under the terms of version 2 of the GNU General Public License as | 6 | * modify it under the terms of the GNU General Public License as |
6 | * published by the Free Software Foundation. | 7 | * published by the Free Software Foundation. |
7 | * | 8 | * |
8 | * This program is distributed in the hope that it would be useful, but | 9 | * This program is distributed in the hope that it would be useful, |
9 | * WITHOUT ANY WARRANTY; without even the implied warranty of | 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
12 | * GNU General Public License for more details. | ||
11 | * | 13 | * |
12 | * Further, this software is distributed without any warranty that it is | 14 | * You should have received a copy of the GNU General Public License |
13 | * free of the rightful claim of any third person regarding infringement | 15 | * along with this program; if not, write the Free Software Foundation, |
14 | * or the like. Any license provided herein, whether implied or | 16 | * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
15 | * otherwise, applies only to this software file. Patent licenses, if | ||
16 | * any, provided herein do not apply to combinations of this program with | ||
17 | * other software, or any other product whatsoever. | ||
18 | * | ||
19 | * You should have received a copy of the GNU General Public License along | ||
20 | * with this program; if not, write the Free Software Foundation, Inc., 59 | ||
21 | * Temple Place - Suite 330, Boston MA 02111-1307, USA. | ||
22 | * | ||
23 | * Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy, | ||
24 | * Mountain View, CA 94043, or: | ||
25 | * | ||
26 | * http://www.sgi.com | ||
27 | * | ||
28 | * For further information regarding this notice, see: | ||
29 | * | ||
30 | * http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/ | ||
31 | */ | 17 | */ |
32 | /* | ||
33 | * fs/xfs/linux/xfs_lrw.c (Linux Read Write stuff) | ||
34 | * | ||
35 | */ | ||
36 | |||
37 | #include "xfs.h" | 18 | #include "xfs.h" |
38 | |||
39 | #include "xfs_fs.h" | 19 | #include "xfs_fs.h" |
40 | #include "xfs_inum.h" | 20 | #include "xfs_bit.h" |
41 | #include "xfs_log.h" | 21 | #include "xfs_log.h" |
22 | #include "xfs_inum.h" | ||
42 | #include "xfs_trans.h" | 23 | #include "xfs_trans.h" |
43 | #include "xfs_sb.h" | 24 | #include "xfs_sb.h" |
44 | #include "xfs_ag.h" | 25 | #include "xfs_ag.h" |
@@ -48,18 +29,17 @@ | |||
48 | #include "xfs_dmapi.h" | 29 | #include "xfs_dmapi.h" |
49 | #include "xfs_quota.h" | 30 | #include "xfs_quota.h" |
50 | #include "xfs_mount.h" | 31 | #include "xfs_mount.h" |
51 | #include "xfs_alloc_btree.h" | ||
52 | #include "xfs_bmap_btree.h" | 32 | #include "xfs_bmap_btree.h" |
33 | #include "xfs_alloc_btree.h" | ||
53 | #include "xfs_ialloc_btree.h" | 34 | #include "xfs_ialloc_btree.h" |
54 | #include "xfs_btree.h" | ||
55 | #include "xfs_ialloc.h" | ||
56 | #include "xfs_attr_sf.h" | ||
57 | #include "xfs_dir_sf.h" | 35 | #include "xfs_dir_sf.h" |
58 | #include "xfs_dir2_sf.h" | 36 | #include "xfs_dir2_sf.h" |
37 | #include "xfs_attr_sf.h" | ||
59 | #include "xfs_dinode.h" | 38 | #include "xfs_dinode.h" |
60 | #include "xfs_inode.h" | 39 | #include "xfs_inode.h" |
61 | #include "xfs_bmap.h" | 40 | #include "xfs_bmap.h" |
62 | #include "xfs_bit.h" | 41 | #include "xfs_btree.h" |
42 | #include "xfs_ialloc.h" | ||
63 | #include "xfs_rtalloc.h" | 43 | #include "xfs_rtalloc.h" |
64 | #include "xfs_error.h" | 44 | #include "xfs_error.h" |
65 | #include "xfs_itable.h" | 45 | #include "xfs_itable.h" |
@@ -302,7 +282,7 @@ xfs_read( | |||
302 | xfs_iunlock(ip, XFS_IOLOCK_SHARED); | 282 | xfs_iunlock(ip, XFS_IOLOCK_SHARED); |
303 | 283 | ||
304 | if (likely(!(ioflags & IO_INVIS))) | 284 | if (likely(!(ioflags & IO_INVIS))) |
305 | xfs_ichgtime(ip, XFS_ICHGTIME_ACC); | 285 | xfs_ichgtime_fast(ip, inode, XFS_ICHGTIME_ACC); |
306 | 286 | ||
307 | unlock_isem: | 287 | unlock_isem: |
308 | if (unlikely(ioflags & IO_ISDIRECT)) | 288 | if (unlikely(ioflags & IO_ISDIRECT)) |
@@ -367,7 +347,7 @@ xfs_sendfile( | |||
367 | XFS_STATS_ADD(xs_read_bytes, ret); | 347 | XFS_STATS_ADD(xs_read_bytes, ret); |
368 | 348 | ||
369 | if (likely(!(ioflags & IO_INVIS))) | 349 | if (likely(!(ioflags & IO_INVIS))) |
370 | xfs_ichgtime(ip, XFS_ICHGTIME_ACC); | 350 | xfs_ichgtime_fast(ip, LINVFS_GET_IP(vp), XFS_ICHGTIME_ACC); |
371 | 351 | ||
372 | return ret; | 352 | return ret; |
373 | } | 353 | } |
@@ -732,15 +712,10 @@ start: | |||
732 | } | 712 | } |
733 | } | 713 | } |
734 | 714 | ||
735 | /* | 715 | if (likely(!(ioflags & IO_INVIS))) { |
736 | * On Linux, generic_file_write updates the times even if | ||
737 | * no data is copied in so long as the write had a size. | ||
738 | * | ||
739 | * We must update xfs' times since revalidate will overcopy xfs. | ||
740 | */ | ||
741 | if (!(ioflags & IO_INVIS)) { | ||
742 | xfs_ichgtime(xip, XFS_ICHGTIME_MOD | XFS_ICHGTIME_CHG); | ||
743 | inode_update_time(inode, 1); | 716 | inode_update_time(inode, 1); |
717 | xfs_ichgtime_fast(xip, inode, | ||
718 | XFS_ICHGTIME_MOD | XFS_ICHGTIME_CHG); | ||
744 | } | 719 | } |
745 | 720 | ||
746 | /* | 721 | /* |
diff --git a/fs/xfs/linux-2.6/xfs_lrw.h b/fs/xfs/linux-2.6/xfs_lrw.h index 6294dcdb797c..38864a88d42d 100644 --- a/fs/xfs/linux-2.6/xfs_lrw.h +++ b/fs/xfs/linux-2.6/xfs_lrw.h | |||
@@ -1,33 +1,19 @@ | |||
1 | /* | 1 | /* |
2 | * Copyright (c) 2000-2003 Silicon Graphics, Inc. All Rights Reserved. | 2 | * Copyright (c) 2000-2003,2005 Silicon Graphics, Inc. |
3 | * All Rights Reserved. | ||
3 | * | 4 | * |
4 | * This program is free software; you can redistribute it and/or modify it | 5 | * This program is free software; you can redistribute it and/or |
5 | * under the terms of version 2 of the GNU General Public License as | 6 | * modify it under the terms of the GNU General Public License as |
6 | * published by the Free Software Foundation. | 7 | * published by the Free Software Foundation. |
7 | * | 8 | * |
8 | * This program is distributed in the hope that it would be useful, but | 9 | * This program is distributed in the hope that it would be useful, |
9 | * WITHOUT ANY WARRANTY; without even the implied warranty of | 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
12 | * GNU General Public License for more details. | ||
11 | * | 13 | * |
12 | * Further, this software is distributed without any warranty that it is | 14 | * You should have received a copy of the GNU General Public License |
13 | * free of the rightful claim of any third person regarding infringement | 15 | * along with this program; if not, write the Free Software Foundation, |
14 | * or the like. Any license provided herein, whether implied or | 16 | * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
15 | * otherwise, applies only to this software file. Patent licenses, if | ||
16 | * any, provided herein do not apply to combinations of this program with | ||
17 | * other software, or any other product whatsoever. | ||
18 | * | ||
19 | * You should have received a copy of the GNU General Public License along | ||
20 | * with this program; if not, write the Free Software Foundation, Inc., 59 | ||
21 | * Temple Place - Suite 330, Boston MA 02111-1307, USA. | ||
22 | * | ||
23 | * Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy, | ||
24 | * Mountain View, CA 94043, or: | ||
25 | * | ||
26 | * http://www.sgi.com | ||
27 | * | ||
28 | * For further information regarding this notice, see: | ||
29 | * | ||
30 | * http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/ | ||
31 | */ | 17 | */ |
32 | #ifndef __XFS_LRW_H__ | 18 | #ifndef __XFS_LRW_H__ |
33 | #define __XFS_LRW_H__ | 19 | #define __XFS_LRW_H__ |
@@ -107,9 +93,4 @@ extern ssize_t xfs_sendfile(struct bhv_desc *, struct file *, | |||
107 | 93 | ||
108 | extern int xfs_dev_is_read_only(struct xfs_mount *, char *); | 94 | extern int xfs_dev_is_read_only(struct xfs_mount *, char *); |
109 | 95 | ||
110 | #define XFS_FSB_TO_DB_IO(io,fsb) \ | ||
111 | (((io)->io_flags & XFS_IOCORE_RT) ? \ | ||
112 | XFS_FSB_TO_BB((io)->io_mount, (fsb)) : \ | ||
113 | XFS_FSB_TO_DADDR((io)->io_mount, (fsb))) | ||
114 | |||
115 | #endif /* __XFS_LRW_H__ */ | 96 | #endif /* __XFS_LRW_H__ */ |
diff --git a/fs/xfs/linux-2.6/xfs_stats.c b/fs/xfs/linux-2.6/xfs_stats.c index aaf5ddba47f3..6c40a74be7c8 100644 --- a/fs/xfs/linux-2.6/xfs_stats.c +++ b/fs/xfs/linux-2.6/xfs_stats.c | |||
@@ -1,35 +1,20 @@ | |||
1 | /* | 1 | /* |
2 | * Copyright (c) 2000-2003 Silicon Graphics, Inc. All Rights Reserved. | 2 | * Copyright (c) 2000-2003,2005 Silicon Graphics, Inc. |
3 | * All Rights Reserved. | ||
3 | * | 4 | * |
4 | * This program is free software; you can redistribute it and/or modify it | 5 | * This program is free software; you can redistribute it and/or |
5 | * under the terms of version 2 of the GNU General Public License as | 6 | * modify it under the terms of the GNU General Public License as |
6 | * published by the Free Software Foundation. | 7 | * published by the Free Software Foundation. |
7 | * | 8 | * |
8 | * This program is distributed in the hope that it would be useful, but | 9 | * This program is distributed in the hope that it would be useful, |
9 | * WITHOUT ANY WARRANTY; without even the implied warranty of | 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
12 | * GNU General Public License for more details. | ||
11 | * | 13 | * |
12 | * Further, this software is distributed without any warranty that it is | 14 | * You should have received a copy of the GNU General Public License |
13 | * free of the rightful claim of any third person regarding infringement | 15 | * along with this program; if not, write the Free Software Foundation, |
14 | * or the like. Any license provided herein, whether implied or | 16 | * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
15 | * otherwise, applies only to this software file. Patent licenses, if | ||
16 | * any, provided herein do not apply to combinations of this program with | ||
17 | * other software, or any other product whatsoever. | ||
18 | * | ||
19 | * You should have received a copy of the GNU General Public License along | ||
20 | * with this program; if not, write the Free Software Foundation, Inc., 59 | ||
21 | * Temple Place - Suite 330, Boston MA 02111-1307, USA. | ||
22 | * | ||
23 | * Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy, | ||
24 | * Mountain View, CA 94043, or: | ||
25 | * | ||
26 | * http://www.sgi.com | ||
27 | * | ||
28 | * For further information regarding this notice, see: | ||
29 | * | ||
30 | * http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/ | ||
31 | */ | 17 | */ |
32 | |||
33 | #include "xfs.h" | 18 | #include "xfs.h" |
34 | #include <linux/proc_fs.h> | 19 | #include <linux/proc_fs.h> |
35 | 20 | ||
diff --git a/fs/xfs/linux-2.6/xfs_stats.h b/fs/xfs/linux-2.6/xfs_stats.h index 3f756a6c3eb0..50027c4a5618 100644 --- a/fs/xfs/linux-2.6/xfs_stats.h +++ b/fs/xfs/linux-2.6/xfs_stats.h | |||
@@ -1,33 +1,19 @@ | |||
1 | /* | 1 | /* |
2 | * Copyright (c) 2000 Silicon Graphics, Inc. All Rights Reserved. | 2 | * Copyright (c) 2000,2005 Silicon Graphics, Inc. |
3 | * All Rights Reserved. | ||
3 | * | 4 | * |
4 | * This program is free software; you can redistribute it and/or modify it | 5 | * This program is free software; you can redistribute it and/or |
5 | * under the terms of version 2 of the GNU General Public License as | 6 | * modify it under the terms of the GNU General Public License as |
6 | * published by the Free Software Foundation. | 7 | * published by the Free Software Foundation. |
7 | * | 8 | * |
8 | * This program is distributed in the hope that it would be useful, but | 9 | * This program is distributed in the hope that it would be useful, |
9 | * WITHOUT ANY WARRANTY; without even the implied warranty of | 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
12 | * GNU General Public License for more details. | ||
11 | * | 13 | * |
12 | * Further, this software is distributed without any warranty that it is | 14 | * You should have received a copy of the GNU General Public License |
13 | * free of the rightful claim of any third person regarding infringement | 15 | * along with this program; if not, write the Free Software Foundation, |
14 | * or the like. Any license provided herein, whether implied or | 16 | * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
15 | * otherwise, applies only to this software file. Patent licenses, if | ||
16 | * any, provided herein do not apply to combinations of this program with | ||
17 | * other software, or any other product whatsoever. | ||
18 | * | ||
19 | * You should have received a copy of the GNU General Public License along | ||
20 | * with this program; if not, write the Free Software Foundation, Inc., 59 | ||
21 | * Temple Place - Suite 330, Boston MA 02111-1307, USA. | ||
22 | * | ||
23 | * Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy, | ||
24 | * Mountain View, CA 94043, or: | ||
25 | * | ||
26 | * http://www.sgi.com | ||
27 | * | ||
28 | * For further information regarding this notice, see: | ||
29 | * | ||
30 | * http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/ | ||
31 | */ | 17 | */ |
32 | #ifndef __XFS_STATS_H__ | 18 | #ifndef __XFS_STATS_H__ |
33 | #define __XFS_STATS_H__ | 19 | #define __XFS_STATS_H__ |
diff --git a/fs/xfs/linux-2.6/xfs_super.c b/fs/xfs/linux-2.6/xfs_super.c index 2302454d8d47..6116b5bf433e 100644 --- a/fs/xfs/linux-2.6/xfs_super.c +++ b/fs/xfs/linux-2.6/xfs_super.c | |||
@@ -1,60 +1,45 @@ | |||
1 | /* | 1 | /* |
2 | * Copyright (c) 2000-2005 Silicon Graphics, Inc. All Rights Reserved. | 2 | * Copyright (c) 2000-2005 Silicon Graphics, Inc. |
3 | * All Rights Reserved. | ||
3 | * | 4 | * |
4 | * This program is free software; you can redistribute it and/or modify it | 5 | * This program is free software; you can redistribute it and/or |
5 | * under the terms of version 2 of the GNU General Public License as | 6 | * modify it under the terms of the GNU General Public License as |
6 | * published by the Free Software Foundation. | 7 | * published by the Free Software Foundation. |
7 | * | 8 | * |
8 | * This program is distributed in the hope that it would be useful, but | 9 | * This program is distributed in the hope that it would be useful, |
9 | * WITHOUT ANY WARRANTY; without even the implied warranty of | 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
12 | * GNU General Public License for more details. | ||
11 | * | 13 | * |
12 | * Further, this software is distributed without any warranty that it is | 14 | * You should have received a copy of the GNU General Public License |
13 | * free of the rightful claim of any third person regarding infringement | 15 | * along with this program; if not, write the Free Software Foundation, |
14 | * or the like. Any license provided herein, whether implied or | 16 | * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
15 | * otherwise, applies only to this software file. Patent licenses, if | ||
16 | * any, provided herein do not apply to combinations of this program with | ||
17 | * other software, or any other product whatsoever. | ||
18 | * | ||
19 | * You should have received a copy of the GNU General Public License along | ||
20 | * with this program; if not, write the Free Software Foundation, Inc., 59 | ||
21 | * Temple Place - Suite 330, Boston MA 02111-1307, USA. | ||
22 | * | ||
23 | * Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy, | ||
24 | * Mountain View, CA 94043, or: | ||
25 | * | ||
26 | * http://www.sgi.com | ||
27 | * | ||
28 | * For further information regarding this notice, see: | ||
29 | * | ||
30 | * http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/ | ||
31 | */ | 17 | */ |
32 | |||
33 | #include "xfs.h" | 18 | #include "xfs.h" |
34 | 19 | #include "xfs_bit.h" | |
35 | #include "xfs_inum.h" | ||
36 | #include "xfs_log.h" | 20 | #include "xfs_log.h" |
37 | #include "xfs_clnt.h" | 21 | #include "xfs_clnt.h" |
22 | #include "xfs_inum.h" | ||
38 | #include "xfs_trans.h" | 23 | #include "xfs_trans.h" |
39 | #include "xfs_sb.h" | 24 | #include "xfs_sb.h" |
25 | #include "xfs_ag.h" | ||
40 | #include "xfs_dir.h" | 26 | #include "xfs_dir.h" |
41 | #include "xfs_dir2.h" | 27 | #include "xfs_dir2.h" |
42 | #include "xfs_alloc.h" | 28 | #include "xfs_alloc.h" |
43 | #include "xfs_dmapi.h" | 29 | #include "xfs_dmapi.h" |
44 | #include "xfs_quota.h" | 30 | #include "xfs_quota.h" |
45 | #include "xfs_mount.h" | 31 | #include "xfs_mount.h" |
46 | #include "xfs_alloc_btree.h" | ||
47 | #include "xfs_bmap_btree.h" | 32 | #include "xfs_bmap_btree.h" |
33 | #include "xfs_alloc_btree.h" | ||
48 | #include "xfs_ialloc_btree.h" | 34 | #include "xfs_ialloc_btree.h" |
49 | #include "xfs_btree.h" | ||
50 | #include "xfs_ialloc.h" | ||
51 | #include "xfs_attr_sf.h" | ||
52 | #include "xfs_dir_sf.h" | 35 | #include "xfs_dir_sf.h" |
53 | #include "xfs_dir2_sf.h" | 36 | #include "xfs_dir2_sf.h" |
37 | #include "xfs_attr_sf.h" | ||
54 | #include "xfs_dinode.h" | 38 | #include "xfs_dinode.h" |
55 | #include "xfs_inode.h" | 39 | #include "xfs_inode.h" |
40 | #include "xfs_btree.h" | ||
41 | #include "xfs_ialloc.h" | ||
56 | #include "xfs_bmap.h" | 42 | #include "xfs_bmap.h" |
57 | #include "xfs_bit.h" | ||
58 | #include "xfs_rtalloc.h" | 43 | #include "xfs_rtalloc.h" |
59 | #include "xfs_error.h" | 44 | #include "xfs_error.h" |
60 | #include "xfs_itable.h" | 45 | #include "xfs_itable.h" |
@@ -189,7 +174,7 @@ xfs_revalidate_inode( | |||
189 | break; | 174 | break; |
190 | } | 175 | } |
191 | 176 | ||
192 | inode->i_blksize = PAGE_CACHE_SIZE; | 177 | inode->i_blksize = xfs_preferred_iosize(mp); |
193 | inode->i_generation = ip->i_d.di_gen; | 178 | inode->i_generation = ip->i_d.di_gen; |
194 | i_size_write(inode, ip->i_d.di_size); | 179 | i_size_write(inode, ip->i_d.di_size); |
195 | inode->i_blocks = | 180 | inode->i_blocks = |
@@ -278,6 +263,72 @@ xfs_blkdev_put( | |||
278 | close_bdev_excl(bdev); | 263 | close_bdev_excl(bdev); |
279 | } | 264 | } |
280 | 265 | ||
266 | /* | ||
267 | * Try to write out the superblock using barriers. | ||
268 | */ | ||
269 | STATIC int | ||
270 | xfs_barrier_test( | ||
271 | xfs_mount_t *mp) | ||
272 | { | ||
273 | xfs_buf_t *sbp = xfs_getsb(mp, 0); | ||
274 | int error; | ||
275 | |||
276 | XFS_BUF_UNDONE(sbp); | ||
277 | XFS_BUF_UNREAD(sbp); | ||
278 | XFS_BUF_UNDELAYWRITE(sbp); | ||
279 | XFS_BUF_WRITE(sbp); | ||
280 | XFS_BUF_UNASYNC(sbp); | ||
281 | XFS_BUF_ORDERED(sbp); | ||
282 | |||
283 | xfsbdstrat(mp, sbp); | ||
284 | error = xfs_iowait(sbp); | ||
285 | |||
286 | /* | ||
287 | * Clear all the flags we set and possible error state in the | ||
288 | * buffer. We only did the write to try out whether barriers | ||
289 | * worked and shouldn't leave any traces in the superblock | ||
290 | * buffer. | ||
291 | */ | ||
292 | XFS_BUF_DONE(sbp); | ||
293 | XFS_BUF_ERROR(sbp, 0); | ||
294 | XFS_BUF_UNORDERED(sbp); | ||
295 | |||
296 | xfs_buf_relse(sbp); | ||
297 | return error; | ||
298 | } | ||
299 | |||
300 | void | ||
301 | xfs_mountfs_check_barriers(xfs_mount_t *mp) | ||
302 | { | ||
303 | int error; | ||
304 | |||
305 | if (mp->m_logdev_targp != mp->m_ddev_targp) { | ||
306 | xfs_fs_cmn_err(CE_NOTE, mp, | ||
307 | "Disabling barriers, not supported with external log device"); | ||
308 | mp->m_flags &= ~XFS_MOUNT_BARRIER; | ||
309 | } | ||
310 | |||
311 | if (mp->m_ddev_targp->pbr_bdev->bd_disk->queue->ordered == | ||
312 | QUEUE_ORDERED_NONE) { | ||
313 | xfs_fs_cmn_err(CE_NOTE, mp, | ||
314 | "Disabling barriers, not supported by the underlying device"); | ||
315 | mp->m_flags &= ~XFS_MOUNT_BARRIER; | ||
316 | } | ||
317 | |||
318 | error = xfs_barrier_test(mp); | ||
319 | if (error) { | ||
320 | xfs_fs_cmn_err(CE_NOTE, mp, | ||
321 | "Disabling barriers, trial barrier write failed"); | ||
322 | mp->m_flags &= ~XFS_MOUNT_BARRIER; | ||
323 | } | ||
324 | } | ||
325 | |||
326 | void | ||
327 | xfs_blkdev_issue_flush( | ||
328 | xfs_buftarg_t *buftarg) | ||
329 | { | ||
330 | blkdev_issue_flush(buftarg->pbr_bdev, NULL); | ||
331 | } | ||
281 | 332 | ||
282 | STATIC struct inode * | 333 | STATIC struct inode * |
283 | linvfs_alloc_inode( | 334 | linvfs_alloc_inode( |
@@ -701,6 +752,18 @@ linvfs_show_options( | |||
701 | } | 752 | } |
702 | 753 | ||
703 | STATIC int | 754 | STATIC int |
755 | linvfs_quotasync( | ||
756 | struct super_block *sb, | ||
757 | int type) | ||
758 | { | ||
759 | struct vfs *vfsp = LINVFS_GET_VFS(sb); | ||
760 | int error; | ||
761 | |||
762 | VFS_QUOTACTL(vfsp, Q_XQUOTASYNC, 0, (caddr_t)NULL, error); | ||
763 | return -error; | ||
764 | } | ||
765 | |||
766 | STATIC int | ||
704 | linvfs_getxstate( | 767 | linvfs_getxstate( |
705 | struct super_block *sb, | 768 | struct super_block *sb, |
706 | struct fs_quota_stat *fqs) | 769 | struct fs_quota_stat *fqs) |
@@ -868,6 +931,7 @@ STATIC struct super_operations linvfs_sops = { | |||
868 | }; | 931 | }; |
869 | 932 | ||
870 | STATIC struct quotactl_ops linvfs_qops = { | 933 | STATIC struct quotactl_ops linvfs_qops = { |
934 | .quota_sync = linvfs_quotasync, | ||
871 | .get_xstate = linvfs_getxstate, | 935 | .get_xstate = linvfs_getxstate, |
872 | .set_xstate = linvfs_setxstate, | 936 | .set_xstate = linvfs_setxstate, |
873 | .get_xquota = linvfs_getxquota, | 937 | .get_xquota = linvfs_getxquota, |
diff --git a/fs/xfs/linux-2.6/xfs_super.h b/fs/xfs/linux-2.6/xfs_super.h index ec7e0035c731..df59408dca06 100644 --- a/fs/xfs/linux-2.6/xfs_super.h +++ b/fs/xfs/linux-2.6/xfs_super.h | |||
@@ -1,33 +1,19 @@ | |||
1 | /* | 1 | /* |
2 | * Copyright (c) 2000-2004 Silicon Graphics, Inc. All Rights Reserved. | 2 | * Copyright (c) 2000-2005 Silicon Graphics, Inc. |
3 | * All Rights Reserved. | ||
3 | * | 4 | * |
4 | * This program is free software; you can redistribute it and/or modify it | 5 | * This program is free software; you can redistribute it and/or |
5 | * under the terms of version 2 of the GNU General Public License as | 6 | * modify it under the terms of the GNU General Public License as |
6 | * published by the Free Software Foundation. | 7 | * published by the Free Software Foundation. |
7 | * | 8 | * |
8 | * This program is distributed in the hope that it would be useful, but | 9 | * This program is distributed in the hope that it would be useful, |
9 | * WITHOUT ANY WARRANTY; without even the implied warranty of | 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
12 | * GNU General Public License for more details. | ||
11 | * | 13 | * |
12 | * Further, this software is distributed without any warranty that it is | 14 | * You should have received a copy of the GNU General Public License |
13 | * free of the rightful claim of any third person regarding infringement | 15 | * along with this program; if not, write the Free Software Foundation, |
14 | * or the like. Any license provided herein, whether implied or | 16 | * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
15 | * otherwise, applies only to this software file. Patent licenses, if | ||
16 | * any, provided herein do not apply to combinations of this program with | ||
17 | * other software, or any other product whatsoever. | ||
18 | * | ||
19 | * You should have received a copy of the GNU General Public License along | ||
20 | * with this program; if not, write the Free Software Foundation, Inc., 59 | ||
21 | * Temple Place - Suite 330, Boston MA 02111-1307, USA. | ||
22 | * | ||
23 | * Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy, | ||
24 | * Mountain View, CA 94043, or: | ||
25 | * | ||
26 | * http://www.sgi.com | ||
27 | * | ||
28 | * For further information regarding this notice, see: | ||
29 | * | ||
30 | * http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/ | ||
31 | */ | 17 | */ |
32 | #ifndef __XFS_SUPER_H__ | 18 | #ifndef __XFS_SUPER_H__ |
33 | #define __XFS_SUPER_H__ | 19 | #define __XFS_SUPER_H__ |
@@ -132,6 +118,7 @@ extern void xfs_flush_device(struct xfs_inode *); | |||
132 | extern int xfs_blkdev_get(struct xfs_mount *, const char *, | 118 | extern int xfs_blkdev_get(struct xfs_mount *, const char *, |
133 | struct block_device **); | 119 | struct block_device **); |
134 | extern void xfs_blkdev_put(struct block_device *); | 120 | extern void xfs_blkdev_put(struct block_device *); |
121 | extern void xfs_blkdev_issue_flush(struct xfs_buftarg *); | ||
135 | 122 | ||
136 | extern struct export_operations linvfs_export_ops; | 123 | extern struct export_operations linvfs_export_ops; |
137 | 124 | ||
diff --git a/fs/xfs/linux-2.6/xfs_sysctl.c b/fs/xfs/linux-2.6/xfs_sysctl.c index 0dc010356f4d..a02564972420 100644 --- a/fs/xfs/linux-2.6/xfs_sysctl.c +++ b/fs/xfs/linux-2.6/xfs_sysctl.c | |||
@@ -1,44 +1,26 @@ | |||
1 | /* | 1 | /* |
2 | * Copyright (c) 2001-2004 Silicon Graphics, Inc. All Rights Reserved. | 2 | * Copyright (c) 2001-2005 Silicon Graphics, Inc. |
3 | * All Rights Reserved. | ||
3 | * | 4 | * |
4 | * This program is free software; you can redistribute it and/or modify it | 5 | * This program is free software; you can redistribute it and/or |
5 | * under the terms of version 2 of the GNU General Public License as | 6 | * modify it under the terms of the GNU General Public License as |
6 | * published by the Free Software Foundation. | 7 | * published by the Free Software Foundation. |
7 | * | 8 | * |
8 | * This program is distributed in the hope that it would be useful, but | 9 | * This program is distributed in the hope that it would be useful, |
9 | * WITHOUT ANY WARRANTY; without even the implied warranty of | 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
12 | * GNU General Public License for more details. | ||
11 | * | 13 | * |
12 | * Further, this software is distributed without any warranty that it is | 14 | * You should have received a copy of the GNU General Public License |
13 | * free of the rightful claim of any third person regarding infringement | 15 | * along with this program; if not, write the Free Software Foundation, |
14 | * or the like. Any license provided herein, whether implied or | 16 | * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
15 | * otherwise, applies only to this software file. Patent licenses, if | ||
16 | * any, provided herein do not apply to combinations of this program with | ||
17 | * other software, or any other product whatsoever. | ||
18 | * | ||
19 | * You should have received a copy of the GNU General Public License along | ||
20 | * with this program; if not, write the Free Software Foundation, Inc., 59 | ||
21 | * Temple Place - Suite 330, Boston MA 02111-1307, USA. | ||
22 | * | ||
23 | * Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy, | ||
24 | * Mountain View, CA 94043, or: | ||
25 | * | ||
26 | * http://www.sgi.com | ||
27 | * | ||
28 | * For further information regarding this notice, see: | ||
29 | * | ||
30 | * http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/ | ||
31 | */ | 17 | */ |
32 | |||
33 | #include "xfs.h" | 18 | #include "xfs.h" |
34 | #include "xfs_rw.h" | ||
35 | #include <linux/sysctl.h> | 19 | #include <linux/sysctl.h> |
36 | #include <linux/proc_fs.h> | 20 | #include <linux/proc_fs.h> |
37 | 21 | ||
38 | |||
39 | static struct ctl_table_header *xfs_table_header; | 22 | static struct ctl_table_header *xfs_table_header; |
40 | 23 | ||
41 | |||
42 | #ifdef CONFIG_PROC_FS | 24 | #ifdef CONFIG_PROC_FS |
43 | STATIC int | 25 | STATIC int |
44 | xfs_stats_clear_proc_handler( | 26 | xfs_stats_clear_proc_handler( |
@@ -76,7 +58,7 @@ xfs_stats_clear_proc_handler( | |||
76 | STATIC ctl_table xfs_table[] = { | 58 | STATIC ctl_table xfs_table[] = { |
77 | {XFS_RESTRICT_CHOWN, "restrict_chown", &xfs_params.restrict_chown.val, | 59 | {XFS_RESTRICT_CHOWN, "restrict_chown", &xfs_params.restrict_chown.val, |
78 | sizeof(int), 0644, NULL, &proc_dointvec_minmax, | 60 | sizeof(int), 0644, NULL, &proc_dointvec_minmax, |
79 | &sysctl_intvec, NULL, | 61 | &sysctl_intvec, NULL, |
80 | &xfs_params.restrict_chown.min, &xfs_params.restrict_chown.max}, | 62 | &xfs_params.restrict_chown.min, &xfs_params.restrict_chown.max}, |
81 | 63 | ||
82 | {XFS_SGID_INHERIT, "irix_sgid_inherit", &xfs_params.sgid_inherit.val, | 64 | {XFS_SGID_INHERIT, "irix_sgid_inherit", &xfs_params.sgid_inherit.val, |
@@ -86,22 +68,22 @@ STATIC ctl_table xfs_table[] = { | |||
86 | 68 | ||
87 | {XFS_SYMLINK_MODE, "irix_symlink_mode", &xfs_params.symlink_mode.val, | 69 | {XFS_SYMLINK_MODE, "irix_symlink_mode", &xfs_params.symlink_mode.val, |
88 | sizeof(int), 0644, NULL, &proc_dointvec_minmax, | 70 | sizeof(int), 0644, NULL, &proc_dointvec_minmax, |
89 | &sysctl_intvec, NULL, | 71 | &sysctl_intvec, NULL, |
90 | &xfs_params.symlink_mode.min, &xfs_params.symlink_mode.max}, | 72 | &xfs_params.symlink_mode.min, &xfs_params.symlink_mode.max}, |
91 | 73 | ||
92 | {XFS_PANIC_MASK, "panic_mask", &xfs_params.panic_mask.val, | 74 | {XFS_PANIC_MASK, "panic_mask", &xfs_params.panic_mask.val, |
93 | sizeof(int), 0644, NULL, &proc_dointvec_minmax, | 75 | sizeof(int), 0644, NULL, &proc_dointvec_minmax, |
94 | &sysctl_intvec, NULL, | 76 | &sysctl_intvec, NULL, |
95 | &xfs_params.panic_mask.min, &xfs_params.panic_mask.max}, | 77 | &xfs_params.panic_mask.min, &xfs_params.panic_mask.max}, |
96 | 78 | ||
97 | {XFS_ERRLEVEL, "error_level", &xfs_params.error_level.val, | 79 | {XFS_ERRLEVEL, "error_level", &xfs_params.error_level.val, |
98 | sizeof(int), 0644, NULL, &proc_dointvec_minmax, | 80 | sizeof(int), 0644, NULL, &proc_dointvec_minmax, |
99 | &sysctl_intvec, NULL, | 81 | &sysctl_intvec, NULL, |
100 | &xfs_params.error_level.min, &xfs_params.error_level.max}, | 82 | &xfs_params.error_level.min, &xfs_params.error_level.max}, |
101 | 83 | ||
102 | {XFS_SYNCD_TIMER, "xfssyncd_centisecs", &xfs_params.syncd_timer.val, | 84 | {XFS_SYNCD_TIMER, "xfssyncd_centisecs", &xfs_params.syncd_timer.val, |
103 | sizeof(int), 0644, NULL, &proc_dointvec_minmax, | 85 | sizeof(int), 0644, NULL, &proc_dointvec_minmax, |
104 | &sysctl_intvec, NULL, | 86 | &sysctl_intvec, NULL, |
105 | &xfs_params.syncd_timer.min, &xfs_params.syncd_timer.max}, | 87 | &xfs_params.syncd_timer.min, &xfs_params.syncd_timer.max}, |
106 | 88 | ||
107 | {XFS_INHERIT_SYNC, "inherit_sync", &xfs_params.inherit_sync.val, | 89 | {XFS_INHERIT_SYNC, "inherit_sync", &xfs_params.inherit_sync.val, |
@@ -118,7 +100,7 @@ STATIC ctl_table xfs_table[] = { | |||
118 | sizeof(int), 0644, NULL, &proc_dointvec_minmax, | 100 | sizeof(int), 0644, NULL, &proc_dointvec_minmax, |
119 | &sysctl_intvec, NULL, | 101 | &sysctl_intvec, NULL, |
120 | &xfs_params.inherit_noatim.min, &xfs_params.inherit_noatim.max}, | 102 | &xfs_params.inherit_noatim.min, &xfs_params.inherit_noatim.max}, |
121 | 103 | ||
122 | {XFS_BUF_TIMER, "xfsbufd_centisecs", &xfs_params.xfs_buf_timer.val, | 104 | {XFS_BUF_TIMER, "xfsbufd_centisecs", &xfs_params.xfs_buf_timer.val, |
123 | sizeof(int), 0644, NULL, &proc_dointvec_minmax, | 105 | sizeof(int), 0644, NULL, &proc_dointvec_minmax, |
124 | &sysctl_intvec, NULL, | 106 | &sysctl_intvec, NULL, |
@@ -136,14 +118,14 @@ STATIC ctl_table xfs_table[] = { | |||
136 | 118 | ||
137 | {XFS_ROTORSTEP, "rotorstep", &xfs_params.rotorstep.val, | 119 | {XFS_ROTORSTEP, "rotorstep", &xfs_params.rotorstep.val, |
138 | sizeof(int), 0644, NULL, &proc_dointvec_minmax, | 120 | sizeof(int), 0644, NULL, &proc_dointvec_minmax, |
139 | &sysctl_intvec, NULL, | 121 | &sysctl_intvec, NULL, |
140 | &xfs_params.rotorstep.min, &xfs_params.rotorstep.max}, | 122 | &xfs_params.rotorstep.min, &xfs_params.rotorstep.max}, |
141 | 123 | ||
142 | /* please keep this the last entry */ | 124 | /* please keep this the last entry */ |
143 | #ifdef CONFIG_PROC_FS | 125 | #ifdef CONFIG_PROC_FS |
144 | {XFS_STATS_CLEAR, "stats_clear", &xfs_params.stats_clear.val, | 126 | {XFS_STATS_CLEAR, "stats_clear", &xfs_params.stats_clear.val, |
145 | sizeof(int), 0644, NULL, &xfs_stats_clear_proc_handler, | 127 | sizeof(int), 0644, NULL, &xfs_stats_clear_proc_handler, |
146 | &sysctl_intvec, NULL, | 128 | &sysctl_intvec, NULL, |
147 | &xfs_params.stats_clear.min, &xfs_params.stats_clear.max}, | 129 | &xfs_params.stats_clear.min, &xfs_params.stats_clear.max}, |
148 | #endif /* CONFIG_PROC_FS */ | 130 | #endif /* CONFIG_PROC_FS */ |
149 | 131 | ||
diff --git a/fs/xfs/linux-2.6/xfs_sysctl.h b/fs/xfs/linux-2.6/xfs_sysctl.h index a39a95020a58..bc8c11f13722 100644 --- a/fs/xfs/linux-2.6/xfs_sysctl.h +++ b/fs/xfs/linux-2.6/xfs_sysctl.h | |||
@@ -1,35 +1,20 @@ | |||
1 | /* | 1 | /* |
2 | * Copyright (c) 2001-2004 Silicon Graphics, Inc. All Rights Reserved. | 2 | * Copyright (c) 2001-2005 Silicon Graphics, Inc. |
3 | * All Rights Reserved. | ||
3 | * | 4 | * |
4 | * This program is free software; you can redistribute it and/or modify it | 5 | * This program is free software; you can redistribute it and/or |
5 | * under the terms of version 2 of the GNU General Public License as | 6 | * modify it under the terms of the GNU General Public License as |
6 | * published by the Free Software Foundation. | 7 | * published by the Free Software Foundation. |
7 | * | 8 | * |
8 | * This program is distributed in the hope that it would be useful, but | 9 | * This program is distributed in the hope that it would be useful, |
9 | * WITHOUT ANY WARRANTY; without even the implied warranty of | 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
12 | * GNU General Public License for more details. | ||
11 | * | 13 | * |
12 | * Further, this software is distributed without any warranty that it is | 14 | * You should have received a copy of the GNU General Public License |
13 | * free of the rightful claim of any third person regarding infringement | 15 | * along with this program; if not, write the Free Software Foundation, |
14 | * or the like. Any license provided herein, whether implied or | 16 | * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
15 | * otherwise, applies only to this software file. Patent licenses, if | ||
16 | * any, provided herein do not apply to combinations of this program with | ||
17 | * other software, or any other product whatsoever. | ||
18 | * | ||
19 | * You should have received a copy of the GNU General Public License along | ||
20 | * with this program; if not, write the Free Software Foundation, Inc., 59 | ||
21 | * Temple Place - Suite 330, Boston MA 02111-1307, USA. | ||
22 | * | ||
23 | * Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy, | ||
24 | * Mountain View, CA 94043, or: | ||
25 | * | ||
26 | * http://www.sgi.com | ||
27 | * | ||
28 | * For further information regarding this notice, see: | ||
29 | * | ||
30 | * http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/ | ||
31 | */ | 17 | */ |
32 | |||
33 | #ifndef __XFS_SYSCTL_H__ | 18 | #ifndef __XFS_SYSCTL_H__ |
34 | #define __XFS_SYSCTL_H__ | 19 | #define __XFS_SYSCTL_H__ |
35 | 20 | ||
diff --git a/fs/xfs/linux-2.6/xfs_version.h b/fs/xfs/linux-2.6/xfs_version.h index 96f96394417e..f8d279d7563a 100644 --- a/fs/xfs/linux-2.6/xfs_version.h +++ b/fs/xfs/linux-2.6/xfs_version.h | |||
@@ -1,34 +1,22 @@ | |||
1 | /* | 1 | /* |
2 | * Copyright (c) 2001-2002 Silicon Graphics, Inc. All Rights Reserved. | 2 | * Copyright (c) 2001-2002,2005 Silicon Graphics, Inc. |
3 | * All Rights Reserved. | ||
3 | * | 4 | * |
4 | * This program is free software; you can redistribute it and/or modify it | 5 | * This program is free software; you can redistribute it and/or |
5 | * under the terms of version 2 of the GNU General Public License as | 6 | * modify it under the terms of the GNU General Public License as |
6 | * published by the Free Software Foundation. | 7 | * published by the Free Software Foundation. |
7 | * | 8 | * |
8 | * This program is distributed in the hope that it would be useful, but | 9 | * This program is distributed in the hope that it would be useful, |
9 | * WITHOUT ANY WARRANTY; without even the implied warranty of | 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
12 | * GNU General Public License for more details. | ||
11 | * | 13 | * |
12 | * Further, this software is distributed without any warranty that it is | 14 | * You should have received a copy of the GNU General Public License |
13 | * free of the rightful claim of any third person regarding infringement | 15 | * along with this program; if not, write the Free Software Foundation, |
14 | * or the like. Any license provided herein, whether implied or | 16 | * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
15 | * otherwise, applies only to this software file. Patent licenses, if | ||
16 | * any, provided herein do not apply to combinations of this program with | ||
17 | * other software, or any other product whatsoever. | ||
18 | * | ||
19 | * You should have received a copy of the GNU General Public License along | ||
20 | * with this program; if not, write the Free Software Foundation, Inc., 59 | ||
21 | * Temple Place - Suite 330, Boston MA 02111-1307, USA. | ||
22 | * | ||
23 | * Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy, | ||
24 | * Mountain View, CA 94043, or: | ||
25 | * | ||
26 | * http://www.sgi.com | ||
27 | * | ||
28 | * For further information regarding this notice, see: | ||
29 | * | ||
30 | * http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/ | ||
31 | */ | 17 | */ |
18 | #ifndef __XFS_VERSION_H__ | ||
19 | #define __XFS_VERSION_H__ | ||
32 | 20 | ||
33 | /* | 21 | /* |
34 | * Dummy file that can contain a timestamp to put into the | 22 | * Dummy file that can contain a timestamp to put into the |
@@ -36,9 +24,6 @@ | |||
36 | * running | 24 | * running |
37 | */ | 25 | */ |
38 | 26 | ||
39 | #ifndef __XFS_VERSION_H__ | ||
40 | #define __XFS_VERSION_H__ | ||
41 | |||
42 | #define XFS_VERSION_STRING "SGI XFS" | 27 | #define XFS_VERSION_STRING "SGI XFS" |
43 | 28 | ||
44 | #endif /* __XFS_VERSION_H__ */ | 29 | #endif /* __XFS_VERSION_H__ */ |
diff --git a/fs/xfs/linux-2.6/xfs_vfs.c b/fs/xfs/linux-2.6/xfs_vfs.c index 34cc902ec119..c855d62e5344 100644 --- a/fs/xfs/linux-2.6/xfs_vfs.c +++ b/fs/xfs/linux-2.6/xfs_vfs.c | |||
@@ -1,38 +1,22 @@ | |||
1 | /* | 1 | /* |
2 | * Copyright (c) 2000-2004 Silicon Graphics, Inc. All Rights Reserved. | 2 | * Copyright (c) 2000-2005 Silicon Graphics, Inc. |
3 | * All Rights Reserved. | ||
3 | * | 4 | * |
4 | * This program is free software; you can redistribute it and/or modify it | 5 | * This program is free software; you can redistribute it and/or |
5 | * under the terms of version 2 of the GNU General Public License as | 6 | * modify it under the terms of the GNU General Public License as |
6 | * published by the Free Software Foundation. | 7 | * published by the Free Software Foundation. |
7 | * | 8 | * |
8 | * This program is distributed in the hope that it would be useful, but | 9 | * This program is distributed in the hope that it would be useful, |
9 | * WITHOUT ANY WARRANTY; without even the implied warranty of | 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
12 | * GNU General Public License for more details. | ||
11 | * | 13 | * |
12 | * Further, this software is distributed without any warranty that it is | 14 | * You should have received a copy of the GNU General Public License |
13 | * free of the rightful claim of any third person regarding infringement | 15 | * along with this program; if not, write the Free Software Foundation, |
14 | * or the like. Any license provided herein, whether implied or | 16 | * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
15 | * otherwise, applies only to this software file. Patent licenses, if | ||
16 | * any, provided herein do not apply to combinations of this program with | ||
17 | * other software, or any other product whatsoever. | ||
18 | * | ||
19 | * You should have received a copy of the GNU General Public License along | ||
20 | * with this program; if not, write the Free Software Foundation, Inc., 59 | ||
21 | * Temple Place - Suite 330, Boston MA 02111-1307, USA. | ||
22 | * | ||
23 | * Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy, | ||
24 | * Mountain View, CA 94043, or: | ||
25 | * | ||
26 | * http://www.sgi.com | ||
27 | * | ||
28 | * For further information regarding this notice, see: | ||
29 | * | ||
30 | * http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/ | ||
31 | */ | 17 | */ |
32 | |||
33 | #include "xfs.h" | 18 | #include "xfs.h" |
34 | #include "xfs_fs.h" | 19 | #include "xfs_fs.h" |
35 | #include "xfs_macros.h" | ||
36 | #include "xfs_inum.h" | 20 | #include "xfs_inum.h" |
37 | #include "xfs_log.h" | 21 | #include "xfs_log.h" |
38 | #include "xfs_clnt.h" | 22 | #include "xfs_clnt.h" |
diff --git a/fs/xfs/linux-2.6/xfs_vfs.h b/fs/xfs/linux-2.6/xfs_vfs.h index f0ab574fb47a..57caf9eddee0 100644 --- a/fs/xfs/linux-2.6/xfs_vfs.h +++ b/fs/xfs/linux-2.6/xfs_vfs.h | |||
@@ -1,33 +1,19 @@ | |||
1 | /* | 1 | /* |
2 | * Copyright (c) 2000-2004 Silicon Graphics, Inc. All Rights Reserved. | 2 | * Copyright (c) 2000-2005 Silicon Graphics, Inc. |
3 | * All Rights Reserved. | ||
3 | * | 4 | * |
4 | * This program is free software; you can redistribute it and/or modify it | 5 | * This program is free software; you can redistribute it and/or |
5 | * under the terms of version 2 of the GNU General Public License as | 6 | * modify it under the terms of the GNU General Public License as |
6 | * published by the Free Software Foundation. | 7 | * published by the Free Software Foundation. |
7 | * | 8 | * |
8 | * This program is distributed in the hope that it would be useful, but | 9 | * This program is distributed in the hope that it would be useful, |
9 | * WITHOUT ANY WARRANTY; without even the implied warranty of | 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
12 | * GNU General Public License for more details. | ||
11 | * | 13 | * |
12 | * Further, this software is distributed without any warranty that it is | 14 | * You should have received a copy of the GNU General Public License |
13 | * free of the rightful claim of any third person regarding infringement | 15 | * along with this program; if not, write the Free Software Foundation, |
14 | * or the like. Any license provided herein, whether implied or | 16 | * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
15 | * otherwise, applies only to this software file. Patent licenses, if | ||
16 | * any, provided herein do not apply to combinations of this program with | ||
17 | * other software, or any other product whatsoever. | ||
18 | * | ||
19 | * You should have received a copy of the GNU General Public License along | ||
20 | * with this program; if not, write the Free Software Foundation, Inc., 59 | ||
21 | * Temple Place - Suite 330, Boston MA 02111-1307, USA. | ||
22 | * | ||
23 | * Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy, | ||
24 | * Mountain View, CA 94043, or: | ||
25 | * | ||
26 | * http://www.sgi.com | ||
27 | * | ||
28 | * For further information regarding this notice, see: | ||
29 | * | ||
30 | * http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/ | ||
31 | */ | 17 | */ |
32 | #ifndef __XFS_VFS_H__ | 18 | #ifndef __XFS_VFS_H__ |
33 | #define __XFS_VFS_H__ | 19 | #define __XFS_VFS_H__ |
@@ -95,6 +81,7 @@ typedef enum { | |||
95 | #define VFS_RDONLY 0x0001 /* read-only vfs */ | 81 | #define VFS_RDONLY 0x0001 /* read-only vfs */ |
96 | #define VFS_GRPID 0x0002 /* group-ID assigned from directory */ | 82 | #define VFS_GRPID 0x0002 /* group-ID assigned from directory */ |
97 | #define VFS_DMI 0x0004 /* filesystem has the DMI enabled */ | 83 | #define VFS_DMI 0x0004 /* filesystem has the DMI enabled */ |
84 | #define VFS_32BITINODES 0x0008 /* do not use inums above 32 bits */ | ||
98 | #define VFS_END 0x0008 /* max flag */ | 85 | #define VFS_END 0x0008 /* max flag */ |
99 | 86 | ||
100 | #define SYNC_ATTR 0x0001 /* sync attributes */ | 87 | #define SYNC_ATTR 0x0001 /* sync attributes */ |
diff --git a/fs/xfs/linux-2.6/xfs_vnode.c b/fs/xfs/linux-2.6/xfs_vnode.c index 268f45bf6a9a..e9bbcb4d6243 100644 --- a/fs/xfs/linux-2.6/xfs_vnode.c +++ b/fs/xfs/linux-2.6/xfs_vnode.c | |||
@@ -1,38 +1,22 @@ | |||
1 | /* | 1 | /* |
2 | * Copyright (c) 2000-2003 Silicon Graphics, Inc. All Rights Reserved. | 2 | * Copyright (c) 2000-2003,2005 Silicon Graphics, Inc. |
3 | * All Rights Reserved. | ||
3 | * | 4 | * |
4 | * This program is free software; you can redistribute it and/or modify it | 5 | * This program is free software; you can redistribute it and/or |
5 | * under the terms of version 2 of the GNU General Public License as | 6 | * modify it under the terms of the GNU General Public License as |
6 | * published by the Free Software Foundation. | 7 | * published by the Free Software Foundation. |
7 | * | 8 | * |
8 | * This program is distributed in the hope that it would be useful, but | 9 | * This program is distributed in the hope that it would be useful, |
9 | * WITHOUT ANY WARRANTY; without even the implied warranty of | 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
12 | * GNU General Public License for more details. | ||
11 | * | 13 | * |
12 | * Further, this software is distributed without any warranty that it is | 14 | * You should have received a copy of the GNU General Public License |
13 | * free of the rightful claim of any third person regarding infringement | 15 | * along with this program; if not, write the Free Software Foundation, |
14 | * or the like. Any license provided herein, whether implied or | 16 | * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
15 | * otherwise, applies only to this software file. Patent licenses, if | ||
16 | * any, provided herein do not apply to combinations of this program with | ||
17 | * other software, or any other product whatsoever. | ||
18 | * | ||
19 | * You should have received a copy of the GNU General Public License along | ||
20 | * with this program; if not, write the Free Software Foundation, Inc., 59 | ||
21 | * Temple Place - Suite 330, Boston MA 02111-1307, USA. | ||
22 | * | ||
23 | * Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy, | ||
24 | * Mountain View, CA 94043, or: | ||
25 | * | ||
26 | * http://www.sgi.com | ||
27 | * | ||
28 | * For further information regarding this notice, see: | ||
29 | * | ||
30 | * http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/ | ||
31 | */ | 17 | */ |
32 | |||
33 | #include "xfs.h" | 18 | #include "xfs.h" |
34 | 19 | ||
35 | |||
36 | uint64_t vn_generation; /* vnode generation number */ | 20 | uint64_t vn_generation; /* vnode generation number */ |
37 | DEFINE_SPINLOCK(vnumber_lock); | 21 | DEFINE_SPINLOCK(vnumber_lock); |
38 | 22 | ||
@@ -44,7 +28,6 @@ DEFINE_SPINLOCK(vnumber_lock); | |||
44 | #define vptosync(v) (&vsync[((unsigned long)v) % NVSYNC]) | 28 | #define vptosync(v) (&vsync[((unsigned long)v) % NVSYNC]) |
45 | STATIC wait_queue_head_t vsync[NVSYNC]; | 29 | STATIC wait_queue_head_t vsync[NVSYNC]; |
46 | 30 | ||
47 | |||
48 | void | 31 | void |
49 | vn_init(void) | 32 | vn_init(void) |
50 | { | 33 | { |
@@ -124,6 +107,7 @@ vn_revalidate_core( | |||
124 | inode->i_mtime = vap->va_mtime; | 107 | inode->i_mtime = vap->va_mtime; |
125 | inode->i_ctime = vap->va_ctime; | 108 | inode->i_ctime = vap->va_ctime; |
126 | inode->i_atime = vap->va_atime; | 109 | inode->i_atime = vap->va_atime; |
110 | inode->i_blksize = vap->va_blocksize; | ||
127 | if (vap->va_xflags & XFS_XFLAG_IMMUTABLE) | 111 | if (vap->va_xflags & XFS_XFLAG_IMMUTABLE) |
128 | inode->i_flags |= S_IMMUTABLE; | 112 | inode->i_flags |= S_IMMUTABLE; |
129 | else | 113 | else |
diff --git a/fs/xfs/linux-2.6/xfs_vnode.h b/fs/xfs/linux-2.6/xfs_vnode.h index 35f306cebb87..f2bbb327c081 100644 --- a/fs/xfs/linux-2.6/xfs_vnode.h +++ b/fs/xfs/linux-2.6/xfs_vnode.h | |||
@@ -1,33 +1,19 @@ | |||
1 | /* | 1 | /* |
2 | * Copyright (c) 2000-2005 Silicon Graphics, Inc. All Rights Reserved. | 2 | * Copyright (c) 2000-2005 Silicon Graphics, Inc. |
3 | * All Rights Reserved. | ||
3 | * | 4 | * |
4 | * This program is free software; you can redistribute it and/or modify it | 5 | * This program is free software; you can redistribute it and/or |
5 | * under the terms of version 2 of the GNU General Public License as | 6 | * modify it under the terms of the GNU General Public License as |
6 | * published by the Free Software Foundation. | 7 | * published by the Free Software Foundation. |
7 | * | 8 | * |
8 | * This program is distributed in the hope that it would be useful, but | 9 | * This program is distributed in the hope that it would be useful, |
9 | * WITHOUT ANY WARRANTY; without even the implied warranty of | 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
12 | * GNU General Public License for more details. | ||
11 | * | 13 | * |
12 | * Further, this software is distributed without any warranty that it is | 14 | * You should have received a copy of the GNU General Public License |
13 | * free of the rightful claim of any third person regarding infringement | 15 | * along with this program; if not, write the Free Software Foundation, |
14 | * or the like. Any license provided herein, whether implied or | 16 | * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
15 | * otherwise, applies only to this software file. Patent licenses, if | ||
16 | * any, provided herein do not apply to combinations of this program with | ||
17 | * other software, or any other product whatsoever. | ||
18 | * | ||
19 | * You should have received a copy of the GNU General Public License along | ||
20 | * with this program; if not, write the Free Software Foundation, Inc., 59 | ||
21 | * Temple Place - Suite 330, Boston MA 02111-1307, USA. | ||
22 | * | ||
23 | * Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy, | ||
24 | * Mountain View, CA 94043, or: | ||
25 | * | ||
26 | * http://www.sgi.com | ||
27 | * | ||
28 | * For further information regarding this notice, see: | ||
29 | * | ||
30 | * http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/ | ||
31 | * | 17 | * |
32 | * Portions Copyright (c) 1989, 1993 | 18 | * Portions Copyright (c) 1989, 1993 |
33 | * The Regents of the University of California. All rights reserved. | 19 | * The Regents of the University of California. All rights reserved. |
@@ -216,11 +202,12 @@ typedef void (*vop_rwunlock_t)(bhv_desc_t *, vrwlock_t); | |||
216 | typedef int (*vop_bmap_t)(bhv_desc_t *, xfs_off_t, ssize_t, int, | 202 | typedef int (*vop_bmap_t)(bhv_desc_t *, xfs_off_t, ssize_t, int, |
217 | struct xfs_iomap *, int *); | 203 | struct xfs_iomap *, int *); |
218 | typedef int (*vop_reclaim_t)(bhv_desc_t *); | 204 | typedef int (*vop_reclaim_t)(bhv_desc_t *); |
219 | typedef int (*vop_attr_get_t)(bhv_desc_t *, char *, char *, int *, int, | 205 | typedef int (*vop_attr_get_t)(bhv_desc_t *, const char *, char *, int *, |
220 | struct cred *); | 206 | int, struct cred *); |
221 | typedef int (*vop_attr_set_t)(bhv_desc_t *, char *, char *, int, int, | 207 | typedef int (*vop_attr_set_t)(bhv_desc_t *, const char *, char *, int, |
222 | struct cred *); | 208 | int, struct cred *); |
223 | typedef int (*vop_attr_remove_t)(bhv_desc_t *, char *, int, struct cred *); | 209 | typedef int (*vop_attr_remove_t)(bhv_desc_t *, const char *, |
210 | int, struct cred *); | ||
224 | typedef int (*vop_attr_list_t)(bhv_desc_t *, char *, int, int, | 211 | typedef int (*vop_attr_list_t)(bhv_desc_t *, char *, int, int, |
225 | struct attrlist_cursor_kern *, struct cred *); | 212 | struct attrlist_cursor_kern *, struct cred *); |
226 | typedef void (*vop_link_removed_t)(bhv_desc_t *, vnode_t *, int); | 213 | typedef void (*vop_link_removed_t)(bhv_desc_t *, vnode_t *, int); |
@@ -566,13 +553,6 @@ static __inline__ void vn_flagclr(struct vnode *vp, uint flag) | |||
566 | } | 553 | } |
567 | 554 | ||
568 | /* | 555 | /* |
569 | * Update modify/access/change times on the vnode | ||
570 | */ | ||
571 | #define VN_MTIMESET(vp, tvp) (LINVFS_GET_IP(vp)->i_mtime = *(tvp)) | ||
572 | #define VN_ATIMESET(vp, tvp) (LINVFS_GET_IP(vp)->i_atime = *(tvp)) | ||
573 | #define VN_CTIMESET(vp, tvp) (LINVFS_GET_IP(vp)->i_ctime = *(tvp)) | ||
574 | |||
575 | /* | ||
576 | * Dealing with bad inodes | 556 | * Dealing with bad inodes |
577 | */ | 557 | */ |
578 | static inline void vn_mark_bad(struct vnode *vp) | 558 | static inline void vn_mark_bad(struct vnode *vp) |
@@ -603,6 +583,7 @@ static inline int VN_BAD(struct vnode *vp) | |||
603 | #define ATTR_LAZY 0x80 /* set/get attributes lazily */ | 583 | #define ATTR_LAZY 0x80 /* set/get attributes lazily */ |
604 | #define ATTR_NONBLOCK 0x100 /* return EAGAIN if operation would block */ | 584 | #define ATTR_NONBLOCK 0x100 /* return EAGAIN if operation would block */ |
605 | #define ATTR_NOLOCK 0x200 /* Don't grab any conflicting locks */ | 585 | #define ATTR_NOLOCK 0x200 /* Don't grab any conflicting locks */ |
586 | #define ATTR_NOSIZETOK 0x400 /* Don't get the SIZE token */ | ||
606 | 587 | ||
607 | /* | 588 | /* |
608 | * Flags to VOP_FSYNC and VOP_RECLAIM. | 589 | * Flags to VOP_FSYNC and VOP_RECLAIM. |
diff --git a/fs/xfs/quota/Makefile b/fs/xfs/quota/Makefile deleted file mode 100644 index 7a4f725b2824..000000000000 --- a/fs/xfs/quota/Makefile +++ /dev/null | |||
@@ -1 +0,0 @@ | |||
1 | include $(TOPDIR)/fs/xfs/quota/Makefile-linux-$(VERSION).$(PATCHLEVEL) | ||
diff --git a/fs/xfs/quota/Makefile-linux-2.6 b/fs/xfs/quota/Makefile-linux-2.6 deleted file mode 100644 index 93e60e839355..000000000000 --- a/fs/xfs/quota/Makefile-linux-2.6 +++ /dev/null | |||
@@ -1,53 +0,0 @@ | |||
1 | # | ||
2 | # Copyright (c) 2000-2003 Silicon Graphics, Inc. All Rights Reserved. | ||
3 | # | ||
4 | # This program is free software; you can redistribute it and/or modify it | ||
5 | # under the terms of version 2 of the GNU General Public License as | ||
6 | # published by the Free Software Foundation. | ||
7 | # | ||
8 | # This program is distributed in the hope that it would be useful, but | ||
9 | # WITHOUT ANY WARRANTY; without even the implied warranty of | ||
10 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | ||
11 | # | ||
12 | # Further, this software is distributed without any warranty that it is | ||
13 | # free of the rightful claim of any third person regarding infringement | ||
14 | # or the like. Any license provided herein, whether implied or | ||
15 | # otherwise, applies only to this software file. Patent licenses, if | ||
16 | # any, provided herein do not apply to combinations of this program with | ||
17 | # other software, or any other product whatsoever. | ||
18 | # | ||
19 | # You should have received a copy of the GNU General Public License along | ||
20 | # with this program; if not, write the Free Software Foundation, Inc., 59 | ||
21 | # Temple Place - Suite 330, Boston MA 02111-1307, USA. | ||
22 | # | ||
23 | # Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy, | ||
24 | # Mountain View, CA 94043, or: | ||
25 | # | ||
26 | # http://www.sgi.com | ||
27 | # | ||
28 | # For further information regarding this notice, see: | ||
29 | # | ||
30 | # http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/ | ||
31 | # | ||
32 | |||
33 | EXTRA_CFLAGS += -I $(TOPDIR)/fs/xfs -I $(TOPDIR)/fs/xfs/linux-2.6 | ||
34 | |||
35 | ifeq ($(CONFIG_XFS_DEBUG),y) | ||
36 | EXTRA_CFLAGS += -g -DDEBUG | ||
37 | #EXTRA_CFLAGS += -DQUOTADEBUG | ||
38 | endif | ||
39 | ifeq ($(CONFIG_XFS_TRACE),y) | ||
40 | EXTRA_CFLAGS += -DXFS_DQUOT_TRACE | ||
41 | EXTRA_CFLAGS += -DXFS_VNODE_TRACE | ||
42 | endif | ||
43 | |||
44 | xfs-$(CONFIG_XFS_QUOTA) += xfs_dquot.o \ | ||
45 | xfs_dquot_item.o \ | ||
46 | xfs_trans_dquot.o \ | ||
47 | xfs_qm_syscalls.o \ | ||
48 | xfs_qm_bhv.o \ | ||
49 | xfs_qm.o | ||
50 | |||
51 | ifeq ($(CONFIG_XFS_QUOTA),y) | ||
52 | xfs-$(CONFIG_PROC_FS) += xfs_qm_stats.o | ||
53 | endif | ||
diff --git a/fs/xfs/quota/xfs_dquot.c b/fs/xfs/quota/xfs_dquot.c index e2e8d35fa4d0..00b5043dfa5a 100644 --- a/fs/xfs/quota/xfs_dquot.c +++ b/fs/xfs/quota/xfs_dquot.c | |||
@@ -1,39 +1,25 @@ | |||
1 | /* | 1 | /* |
2 | * Copyright (c) 2000-2003 Silicon Graphics, Inc. All Rights Reserved. | 2 | * Copyright (c) 2000-2003 Silicon Graphics, Inc. |
3 | * All Rights Reserved. | ||
3 | * | 4 | * |
4 | * This program is free software; you can redistribute it and/or modify it | 5 | * This program is free software; you can redistribute it and/or |
5 | * under the terms of version 2 of the GNU General Public License as | 6 | * modify it under the terms of the GNU General Public License as |
6 | * published by the Free Software Foundation. | 7 | * published by the Free Software Foundation. |
7 | * | 8 | * |
8 | * This program is distributed in the hope that it would be useful, but | 9 | * This program is distributed in the hope that it would be useful, |
9 | * WITHOUT ANY WARRANTY; without even the implied warranty of | 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
12 | * GNU General Public License for more details. | ||
11 | * | 13 | * |
12 | * Further, this software is distributed without any warranty that it is | 14 | * You should have received a copy of the GNU General Public License |
13 | * free of the rightful claim of any third person regarding infringement | 15 | * along with this program; if not, write the Free Software Foundation, |
14 | * or the like. Any license provided herein, whether implied or | 16 | * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
15 | * otherwise, applies only to this software file. Patent licenses, if | ||
16 | * any, provided herein do not apply to combinations of this program with | ||
17 | * other software, or any other product whatsoever. | ||
18 | * | ||
19 | * You should have received a copy of the GNU General Public License along | ||
20 | * with this program; if not, write the Free Software Foundation, Inc., 59 | ||
21 | * Temple Place - Suite 330, Boston MA 02111-1307, USA. | ||
22 | * | ||
23 | * Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy, | ||
24 | * Mountain View, CA 94043, or: | ||
25 | * | ||
26 | * http://www.sgi.com | ||
27 | * | ||
28 | * For further information regarding this notice, see: | ||
29 | * | ||
30 | * http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/ | ||
31 | */ | 17 | */ |
32 | |||
33 | #include "xfs.h" | 18 | #include "xfs.h" |
34 | #include "xfs_fs.h" | 19 | #include "xfs_fs.h" |
35 | #include "xfs_inum.h" | 20 | #include "xfs_bit.h" |
36 | #include "xfs_log.h" | 21 | #include "xfs_log.h" |
22 | #include "xfs_inum.h" | ||
37 | #include "xfs_trans.h" | 23 | #include "xfs_trans.h" |
38 | #include "xfs_sb.h" | 24 | #include "xfs_sb.h" |
39 | #include "xfs_ag.h" | 25 | #include "xfs_ag.h" |
@@ -43,18 +29,17 @@ | |||
43 | #include "xfs_dmapi.h" | 29 | #include "xfs_dmapi.h" |
44 | #include "xfs_quota.h" | 30 | #include "xfs_quota.h" |
45 | #include "xfs_mount.h" | 31 | #include "xfs_mount.h" |
46 | #include "xfs_alloc_btree.h" | ||
47 | #include "xfs_bmap_btree.h" | 32 | #include "xfs_bmap_btree.h" |
33 | #include "xfs_alloc_btree.h" | ||
48 | #include "xfs_ialloc_btree.h" | 34 | #include "xfs_ialloc_btree.h" |
49 | #include "xfs_btree.h" | ||
50 | #include "xfs_ialloc.h" | ||
51 | #include "xfs_attr_sf.h" | ||
52 | #include "xfs_dir_sf.h" | 35 | #include "xfs_dir_sf.h" |
53 | #include "xfs_dir2_sf.h" | 36 | #include "xfs_dir2_sf.h" |
37 | #include "xfs_attr_sf.h" | ||
54 | #include "xfs_dinode.h" | 38 | #include "xfs_dinode.h" |
55 | #include "xfs_inode.h" | 39 | #include "xfs_inode.h" |
40 | #include "xfs_btree.h" | ||
41 | #include "xfs_ialloc.h" | ||
56 | #include "xfs_bmap.h" | 42 | #include "xfs_bmap.h" |
57 | #include "xfs_bit.h" | ||
58 | #include "xfs_rtalloc.h" | 43 | #include "xfs_rtalloc.h" |
59 | #include "xfs_error.h" | 44 | #include "xfs_error.h" |
60 | #include "xfs_itable.h" | 45 | #include "xfs_itable.h" |
@@ -66,7 +51,6 @@ | |||
66 | #include "xfs_buf_item.h" | 51 | #include "xfs_buf_item.h" |
67 | #include "xfs_trans_space.h" | 52 | #include "xfs_trans_space.h" |
68 | #include "xfs_trans_priv.h" | 53 | #include "xfs_trans_priv.h" |
69 | |||
70 | #include "xfs_qm.h" | 54 | #include "xfs_qm.h" |
71 | 55 | ||
72 | 56 | ||
@@ -112,7 +96,7 @@ xfs_qm_dqinit( | |||
112 | 96 | ||
113 | brandnewdquot = xfs_qm_dqalloc_incore(&dqp); | 97 | brandnewdquot = xfs_qm_dqalloc_incore(&dqp); |
114 | dqp->dq_flags = type; | 98 | dqp->dq_flags = type; |
115 | INT_SET(dqp->q_core.d_id, ARCH_CONVERT, id); | 99 | dqp->q_core.d_id = cpu_to_be32(id); |
116 | dqp->q_mount = mp; | 100 | dqp->q_mount = mp; |
117 | 101 | ||
118 | /* | 102 | /* |
@@ -194,10 +178,10 @@ xfs_qm_dqinit_core( | |||
194 | /* | 178 | /* |
195 | * Caller has zero'd the entire dquot 'chunk' already. | 179 | * Caller has zero'd the entire dquot 'chunk' already. |
196 | */ | 180 | */ |
197 | INT_SET(d->dd_diskdq.d_magic, ARCH_CONVERT, XFS_DQUOT_MAGIC); | 181 | d->dd_diskdq.d_magic = cpu_to_be16(XFS_DQUOT_MAGIC); |
198 | INT_SET(d->dd_diskdq.d_version, ARCH_CONVERT, XFS_DQUOT_VERSION); | 182 | d->dd_diskdq.d_version = XFS_DQUOT_VERSION; |
199 | INT_SET(d->dd_diskdq.d_id, ARCH_CONVERT, id); | 183 | d->dd_diskdq.d_id = cpu_to_be32(id); |
200 | INT_SET(d->dd_diskdq.d_flags, ARCH_CONVERT, type); | 184 | d->dd_diskdq.d_flags = type; |
201 | } | 185 | } |
202 | 186 | ||
203 | 187 | ||
@@ -227,19 +211,13 @@ __xfs_dqtrace_entry( | |||
227 | (void *)(__psint_t)dqp->q_nrefs, | 211 | (void *)(__psint_t)dqp->q_nrefs, |
228 | (void *)(__psint_t)dqp->dq_flags, | 212 | (void *)(__psint_t)dqp->dq_flags, |
229 | (void *)(__psint_t)dqp->q_res_bcount, | 213 | (void *)(__psint_t)dqp->q_res_bcount, |
230 | (void *)(__psint_t)INT_GET(dqp->q_core.d_bcount, | 214 | (void *)(__psint_t)be64_to_cpu(dqp->q_core.d_bcount), |
231 | ARCH_CONVERT), | 215 | (void *)(__psint_t)be64_to_cpu(dqp->q_core.d_icount), |
232 | (void *)(__psint_t)INT_GET(dqp->q_core.d_icount, | 216 | (void *)(__psint_t)be64_to_cpu(dqp->q_core.d_blk_hardlimit), |
233 | ARCH_CONVERT), | 217 | (void *)(__psint_t)be64_to_cpu(dqp->q_core.d_blk_softlimit), |
234 | (void *)(__psint_t)INT_GET(dqp->q_core.d_blk_hardlimit, | 218 | (void *)(__psint_t)be64_to_cpu(dqp->q_core.d_ino_hardlimit), |
235 | ARCH_CONVERT), | 219 | (void *)(__psint_t)be64_to_cpu(dqp->q_core.d_ino_softlimit), |
236 | (void *)(__psint_t)INT_GET(dqp->q_core.d_blk_softlimit, | 220 | (void *)(__psint_t)be32_to_cpu(dqp->q_core.d_id), |
237 | ARCH_CONVERT), | ||
238 | (void *)(__psint_t)INT_GET(dqp->q_core.d_ino_hardlimit, | ||
239 | ARCH_CONVERT), | ||
240 | (void *)(__psint_t)INT_GET(dqp->q_core.d_ino_softlimit, | ||
241 | ARCH_CONVERT), | ||
242 | (void *)(__psint_t)INT_GET(dqp->q_core.d_id, ARCH_CONVERT), | ||
243 | (void *)(__psint_t)current_pid(), | 221 | (void *)(__psint_t)current_pid(), |
244 | (void *)(__psint_t)ino, | 222 | (void *)(__psint_t)ino, |
245 | (void *)(__psint_t)retaddr, | 223 | (void *)(__psint_t)retaddr, |
@@ -264,17 +242,17 @@ xfs_qm_adjust_dqlimits( | |||
264 | ASSERT(d->d_id); | 242 | ASSERT(d->d_id); |
265 | 243 | ||
266 | if (q->qi_bsoftlimit && !d->d_blk_softlimit) | 244 | if (q->qi_bsoftlimit && !d->d_blk_softlimit) |
267 | INT_SET(d->d_blk_softlimit, ARCH_CONVERT, q->qi_bsoftlimit); | 245 | d->d_blk_softlimit = cpu_to_be64(q->qi_bsoftlimit); |
268 | if (q->qi_bhardlimit && !d->d_blk_hardlimit) | 246 | if (q->qi_bhardlimit && !d->d_blk_hardlimit) |
269 | INT_SET(d->d_blk_hardlimit, ARCH_CONVERT, q->qi_bhardlimit); | 247 | d->d_blk_hardlimit = cpu_to_be64(q->qi_bhardlimit); |
270 | if (q->qi_isoftlimit && !d->d_ino_softlimit) | 248 | if (q->qi_isoftlimit && !d->d_ino_softlimit) |
271 | INT_SET(d->d_ino_softlimit, ARCH_CONVERT, q->qi_isoftlimit); | 249 | d->d_ino_softlimit = cpu_to_be64(q->qi_isoftlimit); |
272 | if (q->qi_ihardlimit && !d->d_ino_hardlimit) | 250 | if (q->qi_ihardlimit && !d->d_ino_hardlimit) |
273 | INT_SET(d->d_ino_hardlimit, ARCH_CONVERT, q->qi_ihardlimit); | 251 | d->d_ino_hardlimit = cpu_to_be64(q->qi_ihardlimit); |
274 | if (q->qi_rtbsoftlimit && !d->d_rtb_softlimit) | 252 | if (q->qi_rtbsoftlimit && !d->d_rtb_softlimit) |
275 | INT_SET(d->d_rtb_softlimit, ARCH_CONVERT, q->qi_rtbsoftlimit); | 253 | d->d_rtb_softlimit = cpu_to_be64(q->qi_rtbsoftlimit); |
276 | if (q->qi_rtbhardlimit && !d->d_rtb_hardlimit) | 254 | if (q->qi_rtbhardlimit && !d->d_rtb_hardlimit) |
277 | INT_SET(d->d_rtb_hardlimit, ARCH_CONVERT, q->qi_rtbhardlimit); | 255 | d->d_rtb_hardlimit = cpu_to_be64(q->qi_rtbhardlimit); |
278 | } | 256 | } |
279 | 257 | ||
280 | /* | 258 | /* |
@@ -298,81 +276,81 @@ xfs_qm_adjust_dqtimers( | |||
298 | ASSERT(d->d_id); | 276 | ASSERT(d->d_id); |
299 | 277 | ||
300 | #ifdef QUOTADEBUG | 278 | #ifdef QUOTADEBUG |
301 | if (INT_GET(d->d_blk_hardlimit, ARCH_CONVERT)) | 279 | if (d->d_blk_hardlimit) |
302 | ASSERT(INT_GET(d->d_blk_softlimit, ARCH_CONVERT) <= | 280 | ASSERT(be64_to_cpu(d->d_blk_softlimit) <= |
303 | INT_GET(d->d_blk_hardlimit, ARCH_CONVERT)); | 281 | be64_to_cpu(d->d_blk_hardlimit)); |
304 | if (INT_GET(d->d_ino_hardlimit, ARCH_CONVERT)) | 282 | if (d->d_ino_hardlimit) |
305 | ASSERT(INT_GET(d->d_ino_softlimit, ARCH_CONVERT) <= | 283 | ASSERT(be64_to_cpu(d->d_ino_softlimit) <= |
306 | INT_GET(d->d_ino_hardlimit, ARCH_CONVERT)); | 284 | be64_to_cpu(d->d_ino_hardlimit)); |
307 | if (INT_GET(d->d_rtb_hardlimit, ARCH_CONVERT)) | 285 | if (d->d_rtb_hardlimit) |
308 | ASSERT(INT_GET(d->d_rtb_softlimit, ARCH_CONVERT) <= | 286 | ASSERT(be64_to_cpu(d->d_rtb_softlimit) <= |
309 | INT_GET(d->d_rtb_hardlimit, ARCH_CONVERT)); | 287 | be64_to_cpu(d->d_rtb_hardlimit)); |
310 | #endif | 288 | #endif |
311 | if (!d->d_btimer) { | 289 | if (!d->d_btimer) { |
312 | if ((INT_GET(d->d_blk_softlimit, ARCH_CONVERT) && | 290 | if ((d->d_blk_softlimit && |
313 | (INT_GET(d->d_bcount, ARCH_CONVERT) >= | 291 | (be64_to_cpu(d->d_bcount) >= |
314 | INT_GET(d->d_blk_softlimit, ARCH_CONVERT))) || | 292 | be64_to_cpu(d->d_blk_softlimit))) || |
315 | (INT_GET(d->d_blk_hardlimit, ARCH_CONVERT) && | 293 | (d->d_blk_hardlimit && |
316 | (INT_GET(d->d_bcount, ARCH_CONVERT) >= | 294 | (be64_to_cpu(d->d_bcount) >= |
317 | INT_GET(d->d_blk_hardlimit, ARCH_CONVERT)))) { | 295 | be64_to_cpu(d->d_blk_hardlimit)))) { |
318 | INT_SET(d->d_btimer, ARCH_CONVERT, | 296 | d->d_btimer = cpu_to_be32(get_seconds() + |
319 | get_seconds() + XFS_QI_BTIMELIMIT(mp)); | 297 | XFS_QI_BTIMELIMIT(mp)); |
320 | } else { | 298 | } else { |
321 | d->d_bwarns = 0; | 299 | d->d_bwarns = 0; |
322 | } | 300 | } |
323 | } else { | 301 | } else { |
324 | if ((!d->d_blk_softlimit || | 302 | if ((!d->d_blk_softlimit || |
325 | (INT_GET(d->d_bcount, ARCH_CONVERT) < | 303 | (be64_to_cpu(d->d_bcount) < |
326 | INT_GET(d->d_blk_softlimit, ARCH_CONVERT))) && | 304 | be64_to_cpu(d->d_blk_softlimit))) && |
327 | (!d->d_blk_hardlimit || | 305 | (!d->d_blk_hardlimit || |
328 | (INT_GET(d->d_bcount, ARCH_CONVERT) < | 306 | (be64_to_cpu(d->d_bcount) < |
329 | INT_GET(d->d_blk_hardlimit, ARCH_CONVERT)))) { | 307 | be64_to_cpu(d->d_blk_hardlimit)))) { |
330 | d->d_btimer = 0; | 308 | d->d_btimer = 0; |
331 | } | 309 | } |
332 | } | 310 | } |
333 | 311 | ||
334 | if (!d->d_itimer) { | 312 | if (!d->d_itimer) { |
335 | if ((INT_GET(d->d_ino_softlimit, ARCH_CONVERT) && | 313 | if ((d->d_ino_softlimit && |
336 | (INT_GET(d->d_icount, ARCH_CONVERT) >= | 314 | (be64_to_cpu(d->d_icount) >= |
337 | INT_GET(d->d_ino_softlimit, ARCH_CONVERT))) || | 315 | be64_to_cpu(d->d_ino_softlimit))) || |
338 | (INT_GET(d->d_ino_hardlimit, ARCH_CONVERT) && | 316 | (d->d_ino_hardlimit && |
339 | (INT_GET(d->d_icount, ARCH_CONVERT) >= | 317 | (be64_to_cpu(d->d_icount) >= |
340 | INT_GET(d->d_ino_hardlimit, ARCH_CONVERT)))) { | 318 | be64_to_cpu(d->d_ino_hardlimit)))) { |
341 | INT_SET(d->d_itimer, ARCH_CONVERT, | 319 | d->d_itimer = cpu_to_be32(get_seconds() + |
342 | get_seconds() + XFS_QI_ITIMELIMIT(mp)); | 320 | XFS_QI_ITIMELIMIT(mp)); |
343 | } else { | 321 | } else { |
344 | d->d_iwarns = 0; | 322 | d->d_iwarns = 0; |
345 | } | 323 | } |
346 | } else { | 324 | } else { |
347 | if ((!d->d_ino_softlimit || | 325 | if ((!d->d_ino_softlimit || |
348 | (INT_GET(d->d_icount, ARCH_CONVERT) < | 326 | (be64_to_cpu(d->d_icount) < |
349 | INT_GET(d->d_ino_softlimit, ARCH_CONVERT))) && | 327 | be64_to_cpu(d->d_ino_softlimit))) && |
350 | (!d->d_ino_hardlimit || | 328 | (!d->d_ino_hardlimit || |
351 | (INT_GET(d->d_icount, ARCH_CONVERT) < | 329 | (be64_to_cpu(d->d_icount) < |
352 | INT_GET(d->d_ino_hardlimit, ARCH_CONVERT)))) { | 330 | be64_to_cpu(d->d_ino_hardlimit)))) { |
353 | d->d_itimer = 0; | 331 | d->d_itimer = 0; |
354 | } | 332 | } |
355 | } | 333 | } |
356 | 334 | ||
357 | if (!d->d_rtbtimer) { | 335 | if (!d->d_rtbtimer) { |
358 | if ((INT_GET(d->d_rtb_softlimit, ARCH_CONVERT) && | 336 | if ((d->d_rtb_softlimit && |
359 | (INT_GET(d->d_rtbcount, ARCH_CONVERT) >= | 337 | (be64_to_cpu(d->d_rtbcount) >= |
360 | INT_GET(d->d_rtb_softlimit, ARCH_CONVERT))) || | 338 | be64_to_cpu(d->d_rtb_softlimit))) || |
361 | (INT_GET(d->d_rtb_hardlimit, ARCH_CONVERT) && | 339 | (d->d_rtb_hardlimit && |
362 | (INT_GET(d->d_rtbcount, ARCH_CONVERT) >= | 340 | (be64_to_cpu(d->d_rtbcount) >= |
363 | INT_GET(d->d_rtb_hardlimit, ARCH_CONVERT)))) { | 341 | be64_to_cpu(d->d_rtb_hardlimit)))) { |
364 | INT_SET(d->d_rtbtimer, ARCH_CONVERT, | 342 | d->d_rtbtimer = cpu_to_be32(get_seconds() + |
365 | get_seconds() + XFS_QI_RTBTIMELIMIT(mp)); | 343 | XFS_QI_RTBTIMELIMIT(mp)); |
366 | } else { | 344 | } else { |
367 | d->d_rtbwarns = 0; | 345 | d->d_rtbwarns = 0; |
368 | } | 346 | } |
369 | } else { | 347 | } else { |
370 | if ((!d->d_rtb_softlimit || | 348 | if ((!d->d_rtb_softlimit || |
371 | (INT_GET(d->d_rtbcount, ARCH_CONVERT) < | 349 | (be64_to_cpu(d->d_rtbcount) < |
372 | INT_GET(d->d_rtb_softlimit, ARCH_CONVERT))) && | 350 | be64_to_cpu(d->d_rtb_softlimit))) && |
373 | (!d->d_rtb_hardlimit || | 351 | (!d->d_rtb_hardlimit || |
374 | (INT_GET(d->d_rtbcount, ARCH_CONVERT) < | 352 | (be64_to_cpu(d->d_rtbcount) < |
375 | INT_GET(d->d_rtb_hardlimit, ARCH_CONVERT)))) { | 353 | be64_to_cpu(d->d_rtb_hardlimit)))) { |
376 | d->d_rtbtimer = 0; | 354 | d->d_rtbtimer = 0; |
377 | } | 355 | } |
378 | } | 356 | } |
@@ -490,7 +468,7 @@ xfs_qm_dqalloc( | |||
490 | * Make a chunk of dquots out of this buffer and log | 468 | * Make a chunk of dquots out of this buffer and log |
491 | * the entire thing. | 469 | * the entire thing. |
492 | */ | 470 | */ |
493 | xfs_qm_init_dquot_blk(tp, mp, INT_GET(dqp->q_core.d_id, ARCH_CONVERT), | 471 | xfs_qm_init_dquot_blk(tp, mp, be32_to_cpu(dqp->q_core.d_id), |
494 | dqp->dq_flags & XFS_DQ_ALLTYPES, bp); | 472 | dqp->dq_flags & XFS_DQ_ALLTYPES, bp); |
495 | 473 | ||
496 | /* | 474 | /* |
@@ -554,7 +532,7 @@ xfs_qm_dqtobp( | |||
554 | xfs_trans_t *tp = (tpp ? *tpp : NULL); | 532 | xfs_trans_t *tp = (tpp ? *tpp : NULL); |
555 | 533 | ||
556 | mp = dqp->q_mount; | 534 | mp = dqp->q_mount; |
557 | id = INT_GET(dqp->q_core.d_id, ARCH_CONVERT); | 535 | id = be32_to_cpu(dqp->q_core.d_id); |
558 | nmaps = 1; | 536 | nmaps = 1; |
559 | newdquot = B_FALSE; | 537 | newdquot = B_FALSE; |
560 | 538 | ||
@@ -563,8 +541,7 @@ xfs_qm_dqtobp( | |||
563 | */ | 541 | */ |
564 | if (dqp->q_blkno == (xfs_daddr_t) 0) { | 542 | if (dqp->q_blkno == (xfs_daddr_t) 0) { |
565 | /* We use the id as an index */ | 543 | /* We use the id as an index */ |
566 | dqp->q_fileoffset = (xfs_fileoff_t) ((uint)id / | 544 | dqp->q_fileoffset = (xfs_fileoff_t)id / XFS_QM_DQPERBLK(mp); |
567 | XFS_QM_DQPERBLK(mp)); | ||
568 | nmaps = 1; | 545 | nmaps = 1; |
569 | quotip = XFS_DQ_TO_QIP(dqp); | 546 | quotip = XFS_DQ_TO_QIP(dqp); |
570 | xfs_ilock(quotip, XFS_ILOCK_SHARED); | 547 | xfs_ilock(quotip, XFS_ILOCK_SHARED); |
@@ -694,16 +671,16 @@ xfs_qm_dqread( | |||
694 | 671 | ||
695 | /* copy everything from disk dquot to the incore dquot */ | 672 | /* copy everything from disk dquot to the incore dquot */ |
696 | memcpy(&dqp->q_core, ddqp, sizeof(xfs_disk_dquot_t)); | 673 | memcpy(&dqp->q_core, ddqp, sizeof(xfs_disk_dquot_t)); |
697 | ASSERT(INT_GET(dqp->q_core.d_id, ARCH_CONVERT) == id); | 674 | ASSERT(be32_to_cpu(dqp->q_core.d_id) == id); |
698 | xfs_qm_dquot_logitem_init(dqp); | 675 | xfs_qm_dquot_logitem_init(dqp); |
699 | 676 | ||
700 | /* | 677 | /* |
701 | * Reservation counters are defined as reservation plus current usage | 678 | * Reservation counters are defined as reservation plus current usage |
702 | * to avoid having to add everytime. | 679 | * to avoid having to add everytime. |
703 | */ | 680 | */ |
704 | dqp->q_res_bcount = INT_GET(ddqp->d_bcount, ARCH_CONVERT); | 681 | dqp->q_res_bcount = be64_to_cpu(ddqp->d_bcount); |
705 | dqp->q_res_icount = INT_GET(ddqp->d_icount, ARCH_CONVERT); | 682 | dqp->q_res_icount = be64_to_cpu(ddqp->d_icount); |
706 | dqp->q_res_rtbcount = INT_GET(ddqp->d_rtbcount, ARCH_CONVERT); | 683 | dqp->q_res_rtbcount = be64_to_cpu(ddqp->d_rtbcount); |
707 | 684 | ||
708 | /* Mark the buf so that this will stay incore a little longer */ | 685 | /* Mark the buf so that this will stay incore a little longer */ |
709 | XFS_BUF_SET_VTYPE_REF(bp, B_FS_DQUOT, XFS_DQUOT_REF); | 686 | XFS_BUF_SET_VTYPE_REF(bp, B_FS_DQUOT, XFS_DQUOT_REF); |
@@ -829,7 +806,7 @@ xfs_qm_dqlookup( | |||
829 | * dqlock to look at the id field of the dquot, since the | 806 | * dqlock to look at the id field of the dquot, since the |
830 | * id can't be modified without the hashlock anyway. | 807 | * id can't be modified without the hashlock anyway. |
831 | */ | 808 | */ |
832 | if (INT_GET(dqp->q_core.d_id, ARCH_CONVERT) == id && dqp->q_mount == mp) { | 809 | if (be32_to_cpu(dqp->q_core.d_id) == id && dqp->q_mount == mp) { |
833 | xfs_dqtrace_entry(dqp, "DQFOUND BY LOOKUP"); | 810 | xfs_dqtrace_entry(dqp, "DQFOUND BY LOOKUP"); |
834 | /* | 811 | /* |
835 | * All in core dquots must be on the dqlist of mp | 812 | * All in core dquots must be on the dqlist of mp |
@@ -860,7 +837,7 @@ xfs_qm_dqlookup( | |||
860 | * id couldn't have changed; we had the hashlock all | 837 | * id couldn't have changed; we had the hashlock all |
861 | * along | 838 | * along |
862 | */ | 839 | */ |
863 | ASSERT(INT_GET(dqp->q_core.d_id, ARCH_CONVERT) == id); | 840 | ASSERT(be32_to_cpu(dqp->q_core.d_id) == id); |
864 | 841 | ||
865 | if (flist_locked) { | 842 | if (flist_locked) { |
866 | if (dqp->q_nrefs != 0) { | 843 | if (dqp->q_nrefs != 0) { |
@@ -1282,7 +1259,7 @@ xfs_qm_dqflush( | |||
1282 | return (error); | 1259 | return (error); |
1283 | } | 1260 | } |
1284 | 1261 | ||
1285 | if (xfs_qm_dqcheck(&dqp->q_core, INT_GET(ddqp->d_id, ARCH_CONVERT), | 1262 | if (xfs_qm_dqcheck(&dqp->q_core, be32_to_cpu(ddqp->d_id), |
1286 | 0, XFS_QMOPT_DOWARN, "dqflush (incore copy)")) { | 1263 | 0, XFS_QMOPT_DOWARN, "dqflush (incore copy)")) { |
1287 | xfs_force_shutdown(dqp->q_mount, XFS_CORRUPT_INCORE); | 1264 | xfs_force_shutdown(dqp->q_mount, XFS_CORRUPT_INCORE); |
1288 | return XFS_ERROR(EIO); | 1265 | return XFS_ERROR(EIO); |
@@ -1435,8 +1412,8 @@ xfs_dqlock2( | |||
1435 | { | 1412 | { |
1436 | if (d1 && d2) { | 1413 | if (d1 && d2) { |
1437 | ASSERT(d1 != d2); | 1414 | ASSERT(d1 != d2); |
1438 | if (INT_GET(d1->q_core.d_id, ARCH_CONVERT) > | 1415 | if (be32_to_cpu(d1->q_core.d_id) > |
1439 | INT_GET(d2->q_core.d_id, ARCH_CONVERT)) { | 1416 | be32_to_cpu(d2->q_core.d_id)) { |
1440 | xfs_dqlock(d2); | 1417 | xfs_dqlock(d2); |
1441 | xfs_dqlock(d1); | 1418 | xfs_dqlock(d1); |
1442 | } else { | 1419 | } else { |
@@ -1558,33 +1535,33 @@ xfs_qm_dqprint(xfs_dquot_t *dqp) | |||
1558 | { | 1535 | { |
1559 | cmn_err(CE_DEBUG, "-----------KERNEL DQUOT----------------"); | 1536 | cmn_err(CE_DEBUG, "-----------KERNEL DQUOT----------------"); |
1560 | cmn_err(CE_DEBUG, "---- dquotID = %d", | 1537 | cmn_err(CE_DEBUG, "---- dquotID = %d", |
1561 | (int)INT_GET(dqp->q_core.d_id, ARCH_CONVERT)); | 1538 | (int)be32_to_cpu(dqp->q_core.d_id)); |
1562 | cmn_err(CE_DEBUG, "---- type = %s", DQFLAGTO_TYPESTR(dqp)); | 1539 | cmn_err(CE_DEBUG, "---- type = %s", DQFLAGTO_TYPESTR(dqp)); |
1563 | cmn_err(CE_DEBUG, "---- fs = 0x%p", dqp->q_mount); | 1540 | cmn_err(CE_DEBUG, "---- fs = 0x%p", dqp->q_mount); |
1564 | cmn_err(CE_DEBUG, "---- blkno = 0x%x", (int) dqp->q_blkno); | 1541 | cmn_err(CE_DEBUG, "---- blkno = 0x%x", (int) dqp->q_blkno); |
1565 | cmn_err(CE_DEBUG, "---- boffset = 0x%x", (int) dqp->q_bufoffset); | 1542 | cmn_err(CE_DEBUG, "---- boffset = 0x%x", (int) dqp->q_bufoffset); |
1566 | cmn_err(CE_DEBUG, "---- blkhlimit = %Lu (0x%x)", | 1543 | cmn_err(CE_DEBUG, "---- blkhlimit = %Lu (0x%x)", |
1567 | INT_GET(dqp->q_core.d_blk_hardlimit, ARCH_CONVERT), | 1544 | be64_to_cpu(dqp->q_core.d_blk_hardlimit), |
1568 | (int) INT_GET(dqp->q_core.d_blk_hardlimit, ARCH_CONVERT)); | 1545 | (int)be64_to_cpu(dqp->q_core.d_blk_hardlimit)); |
1569 | cmn_err(CE_DEBUG, "---- blkslimit = %Lu (0x%x)", | 1546 | cmn_err(CE_DEBUG, "---- blkslimit = %Lu (0x%x)", |
1570 | INT_GET(dqp->q_core.d_blk_softlimit, ARCH_CONVERT), | 1547 | be64_to_cpu(dqp->q_core.d_blk_softlimit), |
1571 | (int)INT_GET(dqp->q_core.d_blk_softlimit, ARCH_CONVERT)); | 1548 | (int)be64_to_cpu(dqp->q_core.d_blk_softlimit)); |
1572 | cmn_err(CE_DEBUG, "---- inohlimit = %Lu (0x%x)", | 1549 | cmn_err(CE_DEBUG, "---- inohlimit = %Lu (0x%x)", |
1573 | INT_GET(dqp->q_core.d_ino_hardlimit, ARCH_CONVERT), | 1550 | be64_to_cpu(dqp->q_core.d_ino_hardlimit), |
1574 | (int)INT_GET(dqp->q_core.d_ino_hardlimit, ARCH_CONVERT)); | 1551 | (int)be64_to_cpu(dqp->q_core.d_ino_hardlimit)); |
1575 | cmn_err(CE_DEBUG, "---- inoslimit = %Lu (0x%x)", | 1552 | cmn_err(CE_DEBUG, "---- inoslimit = %Lu (0x%x)", |
1576 | INT_GET(dqp->q_core.d_ino_softlimit, ARCH_CONVERT), | 1553 | be64_to_cpu(dqp->q_core.d_ino_softlimit), |
1577 | (int)INT_GET(dqp->q_core.d_ino_softlimit, ARCH_CONVERT)); | 1554 | (int)be64_to_cpu(dqp->q_core.d_ino_softlimit)); |
1578 | cmn_err(CE_DEBUG, "---- bcount = %Lu (0x%x)", | 1555 | cmn_err(CE_DEBUG, "---- bcount = %Lu (0x%x)", |
1579 | INT_GET(dqp->q_core.d_bcount, ARCH_CONVERT), | 1556 | be64_to_cpu(dqp->q_core.d_bcount), |
1580 | (int)INT_GET(dqp->q_core.d_bcount, ARCH_CONVERT)); | 1557 | (int)be64_to_cpu(dqp->q_core.d_bcount)); |
1581 | cmn_err(CE_DEBUG, "---- icount = %Lu (0x%x)", | 1558 | cmn_err(CE_DEBUG, "---- icount = %Lu (0x%x)", |
1582 | INT_GET(dqp->q_core.d_icount, ARCH_CONVERT), | 1559 | be64_to_cpu(dqp->q_core.d_icount), |
1583 | (int)INT_GET(dqp->q_core.d_icount, ARCH_CONVERT)); | 1560 | (int)be64_to_cpu(dqp->q_core.d_icount)); |
1584 | cmn_err(CE_DEBUG, "---- btimer = %d", | 1561 | cmn_err(CE_DEBUG, "---- btimer = %d", |
1585 | (int)INT_GET(dqp->q_core.d_btimer, ARCH_CONVERT)); | 1562 | (int)be32_to_cpu(dqp->q_core.d_btimer)); |
1586 | cmn_err(CE_DEBUG, "---- itimer = %d", | 1563 | cmn_err(CE_DEBUG, "---- itimer = %d", |
1587 | (int)INT_GET(dqp->q_core.d_itimer, ARCH_CONVERT)); | 1564 | (int)be32_to_cpu(dqp->q_core.d_itimer)); |
1588 | cmn_err(CE_DEBUG, "---------------------------"); | 1565 | cmn_err(CE_DEBUG, "---------------------------"); |
1589 | } | 1566 | } |
1590 | #endif | 1567 | #endif |
diff --git a/fs/xfs/quota/xfs_dquot.h b/fs/xfs/quota/xfs_dquot.h index 8ebc87176c78..c0c629663a5c 100644 --- a/fs/xfs/quota/xfs_dquot.h +++ b/fs/xfs/quota/xfs_dquot.h | |||
@@ -1,33 +1,19 @@ | |||
1 | /* | 1 | /* |
2 | * Copyright (c) 2000-2005 Silicon Graphics, Inc. All Rights Reserved. | 2 | * Copyright (c) 2000-2005 Silicon Graphics, Inc. |
3 | * All Rights Reserved. | ||
3 | * | 4 | * |
4 | * This program is free software; you can redistribute it and/or modify it | 5 | * This program is free software; you can redistribute it and/or |
5 | * under the terms of version 2 of the GNU General Public License as | 6 | * modify it under the terms of the GNU General Public License as |
6 | * published by the Free Software Foundation. | 7 | * published by the Free Software Foundation. |
7 | * | 8 | * |
8 | * This program is distributed in the hope that it would be useful, but | 9 | * This program is distributed in the hope that it would be useful, |
9 | * WITHOUT ANY WARRANTY; without even the implied warranty of | 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
12 | * GNU General Public License for more details. | ||
11 | * | 13 | * |
12 | * Further, this software is distributed without any warranty that it is | 14 | * You should have received a copy of the GNU General Public License |
13 | * free of the rightful claim of any third person regarding infringement | 15 | * along with this program; if not, write the Free Software Foundation, |
14 | * or the like. Any license provided herein, whether implied or | 16 | * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
15 | * otherwise, applies only to this software file. Patent licenses, if | ||
16 | * any, provided herein do not apply to combinations of this program with | ||
17 | * other software, or any other product whatsoever. | ||
18 | * | ||
19 | * You should have received a copy of the GNU General Public License along | ||
20 | * with this program; if not, write the Free Software Foundation, Inc., 59 | ||
21 | * Temple Place - Suite 330, Boston MA 02111-1307, USA. | ||
22 | * | ||
23 | * Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy, | ||
24 | * Mountain View, CA 94043, or: | ||
25 | * | ||
26 | * http://www.sgi.com | ||
27 | * | ||
28 | * For further information regarding this notice, see: | ||
29 | * | ||
30 | * http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/ | ||
31 | */ | 17 | */ |
32 | #ifndef __XFS_DQUOT_H__ | 18 | #ifndef __XFS_DQUOT_H__ |
33 | #define __XFS_DQUOT_H__ | 19 | #define __XFS_DQUOT_H__ |
diff --git a/fs/xfs/quota/xfs_dquot_item.c b/fs/xfs/quota/xfs_dquot_item.c index e74eaa7dd1bc..2f69822344e5 100644 --- a/fs/xfs/quota/xfs_dquot_item.c +++ b/fs/xfs/quota/xfs_dquot_item.c | |||
@@ -1,39 +1,25 @@ | |||
1 | /* | 1 | /* |
2 | * Copyright (c) 2000-2003 Silicon Graphics, Inc. All Rights Reserved. | 2 | * Copyright (c) 2000-2003 Silicon Graphics, Inc. |
3 | * All Rights Reserved. | ||
3 | * | 4 | * |
4 | * This program is free software; you can redistribute it and/or modify it | 5 | * This program is free software; you can redistribute it and/or |
5 | * under the terms of version 2 of the GNU General Public License as | 6 | * modify it under the terms of the GNU General Public License as |
6 | * published by the Free Software Foundation. | 7 | * published by the Free Software Foundation. |
7 | * | 8 | * |
8 | * This program is distributed in the hope that it would be useful, but | 9 | * This program is distributed in the hope that it would be useful, |
9 | * WITHOUT ANY WARRANTY; without even the implied warranty of | 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
12 | * GNU General Public License for more details. | ||
11 | * | 13 | * |
12 | * Further, this software is distributed without any warranty that it is | 14 | * You should have received a copy of the GNU General Public License |
13 | * free of the rightful claim of any third person regarding infringement | 15 | * along with this program; if not, write the Free Software Foundation, |
14 | * or the like. Any license provided herein, whether implied or | 16 | * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
15 | * otherwise, applies only to this software file. Patent licenses, if | ||
16 | * any, provided herein do not apply to combinations of this program with | ||
17 | * other software, or any other product whatsoever. | ||
18 | * | ||
19 | * You should have received a copy of the GNU General Public License along | ||
20 | * with this program; if not, write the Free Software Foundation, Inc., 59 | ||
21 | * Temple Place - Suite 330, Boston MA 02111-1307, USA. | ||
22 | * | ||
23 | * Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy, | ||
24 | * Mountain View, CA 94043, or: | ||
25 | * | ||
26 | * http://www.sgi.com | ||
27 | * | ||
28 | * For further information regarding this notice, see: | ||
29 | * | ||
30 | * http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/ | ||
31 | */ | 17 | */ |
32 | |||
33 | #include "xfs.h" | 18 | #include "xfs.h" |
34 | #include "xfs_fs.h" | 19 | #include "xfs_fs.h" |
35 | #include "xfs_inum.h" | 20 | #include "xfs_bit.h" |
36 | #include "xfs_log.h" | 21 | #include "xfs_log.h" |
22 | #include "xfs_inum.h" | ||
37 | #include "xfs_trans.h" | 23 | #include "xfs_trans.h" |
38 | #include "xfs_sb.h" | 24 | #include "xfs_sb.h" |
39 | #include "xfs_ag.h" | 25 | #include "xfs_ag.h" |
@@ -43,18 +29,17 @@ | |||
43 | #include "xfs_dmapi.h" | 29 | #include "xfs_dmapi.h" |
44 | #include "xfs_quota.h" | 30 | #include "xfs_quota.h" |
45 | #include "xfs_mount.h" | 31 | #include "xfs_mount.h" |
46 | #include "xfs_alloc_btree.h" | ||
47 | #include "xfs_bmap_btree.h" | 32 | #include "xfs_bmap_btree.h" |
33 | #include "xfs_alloc_btree.h" | ||
48 | #include "xfs_ialloc_btree.h" | 34 | #include "xfs_ialloc_btree.h" |
49 | #include "xfs_btree.h" | ||
50 | #include "xfs_ialloc.h" | ||
51 | #include "xfs_attr_sf.h" | ||
52 | #include "xfs_dir_sf.h" | 35 | #include "xfs_dir_sf.h" |
53 | #include "xfs_dir2_sf.h" | 36 | #include "xfs_dir2_sf.h" |
37 | #include "xfs_attr_sf.h" | ||
54 | #include "xfs_dinode.h" | 38 | #include "xfs_dinode.h" |
55 | #include "xfs_inode.h" | 39 | #include "xfs_inode.h" |
56 | #include "xfs_bmap.h" | 40 | #include "xfs_bmap.h" |
57 | #include "xfs_bit.h" | 41 | #include "xfs_btree.h" |
42 | #include "xfs_ialloc.h" | ||
58 | #include "xfs_rtalloc.h" | 43 | #include "xfs_rtalloc.h" |
59 | #include "xfs_error.h" | 44 | #include "xfs_error.h" |
60 | #include "xfs_itable.h" | 45 | #include "xfs_itable.h" |
@@ -65,10 +50,8 @@ | |||
65 | #include "xfs_attr.h" | 50 | #include "xfs_attr.h" |
66 | #include "xfs_buf_item.h" | 51 | #include "xfs_buf_item.h" |
67 | #include "xfs_trans_priv.h" | 52 | #include "xfs_trans_priv.h" |
68 | |||
69 | #include "xfs_qm.h" | 53 | #include "xfs_qm.h" |
70 | 54 | ||
71 | |||
72 | /* | 55 | /* |
73 | * returns the number of iovecs needed to log the given dquot item. | 56 | * returns the number of iovecs needed to log the given dquot item. |
74 | */ | 57 | */ |
@@ -467,7 +450,7 @@ xfs_qm_dquot_logitem_init( | |||
467 | lp->qli_item.li_mountp = dqp->q_mount; | 450 | lp->qli_item.li_mountp = dqp->q_mount; |
468 | lp->qli_dquot = dqp; | 451 | lp->qli_dquot = dqp; |
469 | lp->qli_format.qlf_type = XFS_LI_DQUOT; | 452 | lp->qli_format.qlf_type = XFS_LI_DQUOT; |
470 | lp->qli_format.qlf_id = INT_GET(dqp->q_core.d_id, ARCH_CONVERT); | 453 | lp->qli_format.qlf_id = be32_to_cpu(dqp->q_core.d_id); |
471 | lp->qli_format.qlf_blkno = dqp->q_blkno; | 454 | lp->qli_format.qlf_blkno = dqp->q_blkno; |
472 | lp->qli_format.qlf_len = 1; | 455 | lp->qli_format.qlf_len = 1; |
473 | /* | 456 | /* |
diff --git a/fs/xfs/quota/xfs_dquot_item.h b/fs/xfs/quota/xfs_dquot_item.h index 9c6500dabcaa..5a632531f843 100644 --- a/fs/xfs/quota/xfs_dquot_item.h +++ b/fs/xfs/quota/xfs_dquot_item.h | |||
@@ -1,33 +1,19 @@ | |||
1 | /* | 1 | /* |
2 | * Copyright (c) 2000-2003 Silicon Graphics, Inc. All Rights Reserved. | 2 | * Copyright (c) 2000-2003 Silicon Graphics, Inc. |
3 | * All Rights Reserved. | ||
3 | * | 4 | * |
4 | * This program is free software; you can redistribute it and/or modify it | 5 | * This program is free software; you can redistribute it and/or |
5 | * under the terms of version 2 of the GNU General Public License as | 6 | * modify it under the terms of the GNU General Public License as |
6 | * published by the Free Software Foundation. | 7 | * published by the Free Software Foundation. |
7 | * | 8 | * |
8 | * This program is distributed in the hope that it would be useful, but | 9 | * This program is distributed in the hope that it would be useful, |
9 | * WITHOUT ANY WARRANTY; without even the implied warranty of | 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
12 | * GNU General Public License for more details. | ||
11 | * | 13 | * |
12 | * Further, this software is distributed without any warranty that it is | 14 | * You should have received a copy of the GNU General Public License |
13 | * free of the rightful claim of any third person regarding infringement | 15 | * along with this program; if not, write the Free Software Foundation, |
14 | * or the like. Any license provided herein, whether implied or | 16 | * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
15 | * otherwise, applies only to this software file. Patent licenses, if | ||
16 | * any, provided herein do not apply to combinations of this program with | ||
17 | * other software, or any other product whatsoever. | ||
18 | * | ||
19 | * You should have received a copy of the GNU General Public License along | ||
20 | * with this program; if not, write the Free Software Foundation, Inc., 59 | ||
21 | * Temple Place - Suite 330, Boston MA 02111-1307, USA. | ||
22 | * | ||
23 | * Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy, | ||
24 | * Mountain View, CA 94043, or: | ||
25 | * | ||
26 | * http://www.sgi.com | ||
27 | * | ||
28 | * For further information regarding this notice, see: | ||
29 | * | ||
30 | * http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/ | ||
31 | */ | 17 | */ |
32 | #ifndef __XFS_DQUOT_ITEM_H__ | 18 | #ifndef __XFS_DQUOT_ITEM_H__ |
33 | #define __XFS_DQUOT_ITEM_H__ | 19 | #define __XFS_DQUOT_ITEM_H__ |
diff --git a/fs/xfs/quota/xfs_qm.c b/fs/xfs/quota/xfs_qm.c index efde16e0a913..1aea42d71a64 100644 --- a/fs/xfs/quota/xfs_qm.c +++ b/fs/xfs/quota/xfs_qm.c | |||
@@ -1,39 +1,25 @@ | |||
1 | /* | 1 | /* |
2 | * Copyright (c) 2000-2005 Silicon Graphics, Inc. All Rights Reserved. | 2 | * Copyright (c) 2000-2005 Silicon Graphics, Inc. |
3 | * All Rights Reserved. | ||
3 | * | 4 | * |
4 | * This program is free software; you can redistribute it and/or modify it | 5 | * This program is free software; you can redistribute it and/or |
5 | * under the terms of version 2 of the GNU General Public License as | 6 | * modify it under the terms of the GNU General Public License as |
6 | * published by the Free Software Foundation. | 7 | * published by the Free Software Foundation. |
7 | * | 8 | * |
8 | * This program is distributed in the hope that it would be useful, but | 9 | * This program is distributed in the hope that it would be useful, |
9 | * WITHOUT ANY WARRANTY; without even the implied warranty of | 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
12 | * GNU General Public License for more details. | ||
11 | * | 13 | * |
12 | * Further, this software is distributed without any warranty that it is | 14 | * You should have received a copy of the GNU General Public License |
13 | * free of the rightful claim of any third person regarding infringement | 15 | * along with this program; if not, write the Free Software Foundation, |
14 | * or the like. Any license provided herein, whether implied or | 16 | * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
15 | * otherwise, applies only to this software file. Patent licenses, if | ||
16 | * any, provided herein do not apply to combinations of this program with | ||
17 | * other software, or any other product whatsoever. | ||
18 | * | ||
19 | * You should have received a copy of the GNU General Public License along | ||
20 | * with this program; if not, write the Free Software Foundation, Inc., 59 | ||
21 | * Temple Place - Suite 330, Boston MA 02111-1307, USA. | ||
22 | * | ||
23 | * Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy, | ||
24 | * Mountain View, CA 94043, or: | ||
25 | * | ||
26 | * http://www.sgi.com | ||
27 | * | ||
28 | * For further information regarding this notice, see: | ||
29 | * | ||
30 | * http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/ | ||
31 | */ | 17 | */ |
32 | |||
33 | #include "xfs.h" | 18 | #include "xfs.h" |
34 | #include "xfs_fs.h" | 19 | #include "xfs_fs.h" |
35 | #include "xfs_inum.h" | 20 | #include "xfs_bit.h" |
36 | #include "xfs_log.h" | 21 | #include "xfs_log.h" |
22 | #include "xfs_inum.h" | ||
37 | #include "xfs_clnt.h" | 23 | #include "xfs_clnt.h" |
38 | #include "xfs_trans.h" | 24 | #include "xfs_trans.h" |
39 | #include "xfs_sb.h" | 25 | #include "xfs_sb.h" |
@@ -44,21 +30,20 @@ | |||
44 | #include "xfs_dmapi.h" | 30 | #include "xfs_dmapi.h" |
45 | #include "xfs_quota.h" | 31 | #include "xfs_quota.h" |
46 | #include "xfs_mount.h" | 32 | #include "xfs_mount.h" |
47 | #include "xfs_alloc_btree.h" | ||
48 | #include "xfs_bmap_btree.h" | 33 | #include "xfs_bmap_btree.h" |
34 | #include "xfs_alloc_btree.h" | ||
49 | #include "xfs_ialloc_btree.h" | 35 | #include "xfs_ialloc_btree.h" |
50 | #include "xfs_btree.h" | ||
51 | #include "xfs_ialloc.h" | ||
52 | #include "xfs_attr_sf.h" | ||
53 | #include "xfs_dir_sf.h" | 36 | #include "xfs_dir_sf.h" |
54 | #include "xfs_dir2_sf.h" | 37 | #include "xfs_dir2_sf.h" |
38 | #include "xfs_attr_sf.h" | ||
55 | #include "xfs_dinode.h" | 39 | #include "xfs_dinode.h" |
56 | #include "xfs_inode.h" | 40 | #include "xfs_inode.h" |
57 | #include "xfs_bmap.h" | 41 | #include "xfs_btree.h" |
58 | #include "xfs_bit.h" | 42 | #include "xfs_ialloc.h" |
43 | #include "xfs_itable.h" | ||
59 | #include "xfs_rtalloc.h" | 44 | #include "xfs_rtalloc.h" |
60 | #include "xfs_error.h" | 45 | #include "xfs_error.h" |
61 | #include "xfs_itable.h" | 46 | #include "xfs_bmap.h" |
62 | #include "xfs_rw.h" | 47 | #include "xfs_rw.h" |
63 | #include "xfs_acl.h" | 48 | #include "xfs_acl.h" |
64 | #include "xfs_cap.h" | 49 | #include "xfs_cap.h" |
@@ -67,7 +52,6 @@ | |||
67 | #include "xfs_buf_item.h" | 52 | #include "xfs_buf_item.h" |
68 | #include "xfs_trans_space.h" | 53 | #include "xfs_trans_space.h" |
69 | #include "xfs_utils.h" | 54 | #include "xfs_utils.h" |
70 | |||
71 | #include "xfs_qm.h" | 55 | #include "xfs_qm.h" |
72 | 56 | ||
73 | /* | 57 | /* |
@@ -76,8 +60,9 @@ | |||
76 | * quota functionality, including maintaining the freelist and hash | 60 | * quota functionality, including maintaining the freelist and hash |
77 | * tables of dquots. | 61 | * tables of dquots. |
78 | */ | 62 | */ |
79 | mutex_t xfs_Gqm_lock; | 63 | mutex_t xfs_Gqm_lock; |
80 | struct xfs_qm *xfs_Gqm; | 64 | struct xfs_qm *xfs_Gqm; |
65 | uint ndquot; | ||
81 | 66 | ||
82 | kmem_zone_t *qm_dqzone; | 67 | kmem_zone_t *qm_dqzone; |
83 | kmem_zone_t *qm_dqtrxzone; | 68 | kmem_zone_t *qm_dqtrxzone; |
@@ -107,10 +92,10 @@ extern mutex_t qcheck_lock; | |||
107 | for (dqp = (l)->qh_next; dqp != NULL; dqp = dqp->NXT) { \ | 92 | for (dqp = (l)->qh_next; dqp != NULL; dqp = dqp->NXT) { \ |
108 | cmn_err(CE_DEBUG, " %d. \"%d (%s)\" " \ | 93 | cmn_err(CE_DEBUG, " %d. \"%d (%s)\" " \ |
109 | "bcnt = %d, icnt = %d, refs = %d", \ | 94 | "bcnt = %d, icnt = %d, refs = %d", \ |
110 | ++i, (int) INT_GET(dqp->q_core.d_id, ARCH_CONVERT), \ | 95 | ++i, (int) be32_to_cpu(dqp->q_core.d_id), \ |
111 | DQFLAGTO_TYPESTR(dqp), \ | 96 | DQFLAGTO_TYPESTR(dqp), \ |
112 | (int) INT_GET(dqp->q_core.d_bcount, ARCH_CONVERT), \ | 97 | (int) be64_to_cpu(dqp->q_core.d_bcount), \ |
113 | (int) INT_GET(dqp->q_core.d_icount, ARCH_CONVERT), \ | 98 | (int) be64_to_cpu(dqp->q_core.d_icount), \ |
114 | (int) dqp->q_nrefs); } \ | 99 | (int) dqp->q_nrefs); } \ |
115 | } | 100 | } |
116 | #else | 101 | #else |
@@ -124,25 +109,25 @@ extern mutex_t qcheck_lock; | |||
124 | STATIC struct xfs_qm * | 109 | STATIC struct xfs_qm * |
125 | xfs_Gqm_init(void) | 110 | xfs_Gqm_init(void) |
126 | { | 111 | { |
127 | xfs_qm_t *xqm; | 112 | xfs_dqhash_t *udqhash, *gdqhash; |
128 | int hsize, i; | 113 | xfs_qm_t *xqm; |
129 | 114 | uint i, hsize, flags = KM_SLEEP | KM_MAYFAIL; | |
130 | xqm = kmem_zalloc(sizeof(xfs_qm_t), KM_SLEEP); | ||
131 | ASSERT(xqm); | ||
132 | 115 | ||
133 | /* | 116 | /* |
134 | * Initialize the dquot hash tables. | 117 | * Initialize the dquot hash tables. |
135 | */ | 118 | */ |
136 | hsize = (DQUOT_HASH_HEURISTIC < XFS_QM_NCSIZE_THRESHOLD) ? | 119 | hsize = XFS_QM_HASHSIZE_HIGH; |
137 | XFS_QM_HASHSIZE_LOW : XFS_QM_HASHSIZE_HIGH; | 120 | while (!(udqhash = kmem_zalloc(hsize * sizeof(xfs_dqhash_t), flags))) { |
138 | xqm->qm_dqhashmask = hsize - 1; | 121 | if ((hsize >>= 1) <= XFS_QM_HASHSIZE_LOW) |
122 | flags = KM_SLEEP; | ||
123 | } | ||
124 | gdqhash = kmem_zalloc(hsize * sizeof(xfs_dqhash_t), KM_SLEEP); | ||
125 | ndquot = hsize << 8; | ||
139 | 126 | ||
140 | xqm->qm_usr_dqhtable = (xfs_dqhash_t *)kmem_zalloc(hsize * | 127 | xqm = kmem_zalloc(sizeof(xfs_qm_t), KM_SLEEP); |
141 | sizeof(xfs_dqhash_t), | 128 | xqm->qm_dqhashmask = hsize - 1; |
142 | KM_SLEEP); | 129 | xqm->qm_usr_dqhtable = udqhash; |
143 | xqm->qm_grp_dqhtable = (xfs_dqhash_t *)kmem_zalloc(hsize * | 130 | xqm->qm_grp_dqhtable = gdqhash; |
144 | sizeof(xfs_dqhash_t), | ||
145 | KM_SLEEP); | ||
146 | ASSERT(xqm->qm_usr_dqhtable != NULL); | 131 | ASSERT(xqm->qm_usr_dqhtable != NULL); |
147 | ASSERT(xqm->qm_grp_dqhtable != NULL); | 132 | ASSERT(xqm->qm_grp_dqhtable != NULL); |
148 | 133 | ||
@@ -743,7 +728,7 @@ xfs_qm_dqattach_one( | |||
743 | */ | 728 | */ |
744 | if (udqhint && | 729 | if (udqhint && |
745 | (dqp = udqhint->q_gdquot) && | 730 | (dqp = udqhint->q_gdquot) && |
746 | (INT_GET(dqp->q_core.d_id, ARCH_CONVERT) == id)) { | 731 | (be32_to_cpu(dqp->q_core.d_id) == id)) { |
747 | ASSERT(XFS_DQ_IS_LOCKED(udqhint)); | 732 | ASSERT(XFS_DQ_IS_LOCKED(udqhint)); |
748 | xfs_dqlock(dqp); | 733 | xfs_dqlock(dqp); |
749 | XFS_DQHOLD(dqp); | 734 | XFS_DQHOLD(dqp); |
@@ -1213,42 +1198,24 @@ xfs_qm_init_quotainfo( | |||
1213 | * a user or group before he or she can not perform any | 1198 | * a user or group before he or she can not perform any |
1214 | * more writing. If it is zero, a default is used. | 1199 | * more writing. If it is zero, a default is used. |
1215 | */ | 1200 | */ |
1216 | qinf->qi_btimelimit = | 1201 | qinf->qi_btimelimit = ddqp->d_btimer ? |
1217 | INT_GET(ddqp->d_btimer, ARCH_CONVERT) ? | 1202 | be32_to_cpu(ddqp->d_btimer) : XFS_QM_BTIMELIMIT; |
1218 | INT_GET(ddqp->d_btimer, ARCH_CONVERT) : | 1203 | qinf->qi_itimelimit = ddqp->d_itimer ? |
1219 | XFS_QM_BTIMELIMIT; | 1204 | be32_to_cpu(ddqp->d_itimer) : XFS_QM_ITIMELIMIT; |
1220 | qinf->qi_itimelimit = | 1205 | qinf->qi_rtbtimelimit = ddqp->d_rtbtimer ? |
1221 | INT_GET(ddqp->d_itimer, ARCH_CONVERT) ? | 1206 | be32_to_cpu(ddqp->d_rtbtimer) : XFS_QM_RTBTIMELIMIT; |
1222 | INT_GET(ddqp->d_itimer, ARCH_CONVERT) : | 1207 | qinf->qi_bwarnlimit = ddqp->d_bwarns ? |
1223 | XFS_QM_ITIMELIMIT; | 1208 | be16_to_cpu(ddqp->d_bwarns) : XFS_QM_BWARNLIMIT; |
1224 | qinf->qi_rtbtimelimit = | 1209 | qinf->qi_iwarnlimit = ddqp->d_iwarns ? |
1225 | INT_GET(ddqp->d_rtbtimer, ARCH_CONVERT) ? | 1210 | be16_to_cpu(ddqp->d_iwarns) : XFS_QM_IWARNLIMIT; |
1226 | INT_GET(ddqp->d_rtbtimer, ARCH_CONVERT) : | 1211 | qinf->qi_rtbwarnlimit = ddqp->d_rtbwarns ? |
1227 | XFS_QM_RTBTIMELIMIT; | 1212 | be16_to_cpu(ddqp->d_rtbwarns) : XFS_QM_RTBWARNLIMIT; |
1228 | qinf->qi_bwarnlimit = | 1213 | qinf->qi_bhardlimit = be64_to_cpu(ddqp->d_blk_hardlimit); |
1229 | INT_GET(ddqp->d_bwarns, ARCH_CONVERT) ? | 1214 | qinf->qi_bsoftlimit = be64_to_cpu(ddqp->d_blk_softlimit); |
1230 | INT_GET(ddqp->d_bwarns, ARCH_CONVERT) : | 1215 | qinf->qi_ihardlimit = be64_to_cpu(ddqp->d_ino_hardlimit); |
1231 | XFS_QM_BWARNLIMIT; | 1216 | qinf->qi_isoftlimit = be64_to_cpu(ddqp->d_ino_softlimit); |
1232 | qinf->qi_iwarnlimit = | 1217 | qinf->qi_rtbhardlimit = be64_to_cpu(ddqp->d_rtb_hardlimit); |
1233 | INT_GET(ddqp->d_iwarns, ARCH_CONVERT) ? | 1218 | qinf->qi_rtbsoftlimit = be64_to_cpu(ddqp->d_rtb_softlimit); |
1234 | INT_GET(ddqp->d_iwarns, ARCH_CONVERT) : | ||
1235 | XFS_QM_IWARNLIMIT; | ||
1236 | qinf->qi_rtbwarnlimit = | ||
1237 | INT_GET(ddqp->d_rtbwarns, ARCH_CONVERT) ? | ||
1238 | INT_GET(ddqp->d_rtbwarns, ARCH_CONVERT) : | ||
1239 | XFS_QM_RTBWARNLIMIT; | ||
1240 | qinf->qi_bhardlimit = | ||
1241 | INT_GET(ddqp->d_blk_hardlimit, ARCH_CONVERT); | ||
1242 | qinf->qi_bsoftlimit = | ||
1243 | INT_GET(ddqp->d_blk_softlimit, ARCH_CONVERT); | ||
1244 | qinf->qi_ihardlimit = | ||
1245 | INT_GET(ddqp->d_ino_hardlimit, ARCH_CONVERT); | ||
1246 | qinf->qi_isoftlimit = | ||
1247 | INT_GET(ddqp->d_ino_softlimit, ARCH_CONVERT); | ||
1248 | qinf->qi_rtbhardlimit = | ||
1249 | INT_GET(ddqp->d_rtb_hardlimit, ARCH_CONVERT); | ||
1250 | qinf->qi_rtbsoftlimit = | ||
1251 | INT_GET(ddqp->d_rtb_softlimit, ARCH_CONVERT); | ||
1252 | 1219 | ||
1253 | /* | 1220 | /* |
1254 | * We sent the XFS_QMOPT_DQSUSER flag to dqget because | 1221 | * We sent the XFS_QMOPT_DQSUSER flag to dqget because |
@@ -1527,15 +1494,15 @@ xfs_qm_reset_dqcounts( | |||
1527 | */ | 1494 | */ |
1528 | (void) xfs_qm_dqcheck(ddq, id+j, type, XFS_QMOPT_DQREPAIR, | 1495 | (void) xfs_qm_dqcheck(ddq, id+j, type, XFS_QMOPT_DQREPAIR, |
1529 | "xfs_quotacheck"); | 1496 | "xfs_quotacheck"); |
1530 | INT_SET(ddq->d_bcount, ARCH_CONVERT, 0ULL); | 1497 | ddq->d_bcount = 0; |
1531 | INT_SET(ddq->d_icount, ARCH_CONVERT, 0ULL); | 1498 | ddq->d_icount = 0; |
1532 | INT_SET(ddq->d_rtbcount, ARCH_CONVERT, 0ULL); | 1499 | ddq->d_rtbcount = 0; |
1533 | INT_SET(ddq->d_btimer, ARCH_CONVERT, (time_t)0); | 1500 | ddq->d_btimer = 0; |
1534 | INT_SET(ddq->d_itimer, ARCH_CONVERT, (time_t)0); | 1501 | ddq->d_itimer = 0; |
1535 | INT_SET(ddq->d_rtbtimer, ARCH_CONVERT, (time_t)0); | 1502 | ddq->d_rtbtimer = 0; |
1536 | INT_SET(ddq->d_bwarns, ARCH_CONVERT, 0UL); | 1503 | ddq->d_bwarns = 0; |
1537 | INT_SET(ddq->d_iwarns, ARCH_CONVERT, 0UL); | 1504 | ddq->d_iwarns = 0; |
1538 | INT_SET(ddq->d_rtbwarns, ARCH_CONVERT, 0UL); | 1505 | ddq->d_rtbwarns = 0; |
1539 | ddq = (xfs_disk_dquot_t *) ((xfs_dqblk_t *)ddq + 1); | 1506 | ddq = (xfs_disk_dquot_t *) ((xfs_dqblk_t *)ddq + 1); |
1540 | } | 1507 | } |
1541 | 1508 | ||
@@ -1708,14 +1675,14 @@ xfs_qm_quotacheck_dqadjust( | |||
1708 | * Adjust the inode count and the block count to reflect this inode's | 1675 | * Adjust the inode count and the block count to reflect this inode's |
1709 | * resource usage. | 1676 | * resource usage. |
1710 | */ | 1677 | */ |
1711 | INT_MOD(dqp->q_core.d_icount, ARCH_CONVERT, +1); | 1678 | be64_add(&dqp->q_core.d_icount, 1); |
1712 | dqp->q_res_icount++; | 1679 | dqp->q_res_icount++; |
1713 | if (nblks) { | 1680 | if (nblks) { |
1714 | INT_MOD(dqp->q_core.d_bcount, ARCH_CONVERT, nblks); | 1681 | be64_add(&dqp->q_core.d_bcount, nblks); |
1715 | dqp->q_res_bcount += nblks; | 1682 | dqp->q_res_bcount += nblks; |
1716 | } | 1683 | } |
1717 | if (rtblks) { | 1684 | if (rtblks) { |
1718 | INT_MOD(dqp->q_core.d_rtbcount, ARCH_CONVERT, rtblks); | 1685 | be64_add(&dqp->q_core.d_rtbcount, rtblks); |
1719 | dqp->q_res_rtbcount += rtblks; | 1686 | dqp->q_res_rtbcount += rtblks; |
1720 | } | 1687 | } |
1721 | 1688 | ||
@@ -2202,7 +2169,7 @@ xfs_qm_shake_freelist( | |||
2202 | xfs_dqtrace_entry(dqp, "DQSHAKE: UNLINKING"); | 2169 | xfs_dqtrace_entry(dqp, "DQSHAKE: UNLINKING"); |
2203 | #ifdef QUOTADEBUG | 2170 | #ifdef QUOTADEBUG |
2204 | cmn_err(CE_DEBUG, "Shake 0x%p, ID 0x%x\n", | 2171 | cmn_err(CE_DEBUG, "Shake 0x%p, ID 0x%x\n", |
2205 | dqp, INT_GET(dqp->q_core.d_id, ARCH_CONVERT)); | 2172 | dqp, be32_to_cpu(dqp->q_core.d_id)); |
2206 | #endif | 2173 | #endif |
2207 | ASSERT(dqp->q_nrefs == 0); | 2174 | ASSERT(dqp->q_nrefs == 0); |
2208 | nextdqp = dqp->dq_flnext; | 2175 | nextdqp = dqp->dq_flnext; |
@@ -2670,7 +2637,7 @@ xfs_qm_vop_chown_reserve( | |||
2670 | XFS_QMOPT_RES_RTBLKS : XFS_QMOPT_RES_REGBLKS; | 2637 | XFS_QMOPT_RES_RTBLKS : XFS_QMOPT_RES_REGBLKS; |
2671 | 2638 | ||
2672 | if (XFS_IS_UQUOTA_ON(mp) && udqp && | 2639 | if (XFS_IS_UQUOTA_ON(mp) && udqp && |
2673 | ip->i_d.di_uid != (uid_t)INT_GET(udqp->q_core.d_id, ARCH_CONVERT)) { | 2640 | ip->i_d.di_uid != (uid_t)be32_to_cpu(udqp->q_core.d_id)) { |
2674 | delblksudq = udqp; | 2641 | delblksudq = udqp; |
2675 | /* | 2642 | /* |
2676 | * If there are delayed allocation blocks, then we have to | 2643 | * If there are delayed allocation blocks, then we have to |
@@ -2683,10 +2650,10 @@ xfs_qm_vop_chown_reserve( | |||
2683 | } | 2650 | } |
2684 | } | 2651 | } |
2685 | if (XFS_IS_OQUOTA_ON(ip->i_mount) && gdqp) { | 2652 | if (XFS_IS_OQUOTA_ON(ip->i_mount) && gdqp) { |
2686 | if ((XFS_IS_GQUOTA_ON(ip->i_mount) && ip->i_d.di_gid != | 2653 | if ((XFS_IS_GQUOTA_ON(ip->i_mount) && |
2687 | INT_GET(gdqp->q_core.d_id, ARCH_CONVERT)) || | 2654 | ip->i_d.di_gid != be32_to_cpu(gdqp->q_core.d_id)) || |
2688 | (XFS_IS_PQUOTA_ON(ip->i_mount) && ip->i_d.di_projid != | 2655 | (XFS_IS_PQUOTA_ON(ip->i_mount) && |
2689 | INT_GET(gdqp->q_core.d_id, ARCH_CONVERT))) { | 2656 | ip->i_d.di_projid != be32_to_cpu(gdqp->q_core.d_id))) { |
2690 | delblksgdq = gdqp; | 2657 | delblksgdq = gdqp; |
2691 | if (delblks) { | 2658 | if (delblks) { |
2692 | ASSERT(ip->i_gdquot); | 2659 | ASSERT(ip->i_gdquot); |
@@ -2776,7 +2743,7 @@ xfs_qm_vop_dqattach_and_dqmod_newinode( | |||
2776 | xfs_dqunlock(udqp); | 2743 | xfs_dqunlock(udqp); |
2777 | ASSERT(ip->i_udquot == NULL); | 2744 | ASSERT(ip->i_udquot == NULL); |
2778 | ip->i_udquot = udqp; | 2745 | ip->i_udquot = udqp; |
2779 | ASSERT(ip->i_d.di_uid == INT_GET(udqp->q_core.d_id, ARCH_CONVERT)); | 2746 | ASSERT(ip->i_d.di_uid == be32_to_cpu(udqp->q_core.d_id)); |
2780 | xfs_trans_mod_dquot(tp, udqp, XFS_TRANS_DQ_ICOUNT, 1); | 2747 | xfs_trans_mod_dquot(tp, udqp, XFS_TRANS_DQ_ICOUNT, 1); |
2781 | } | 2748 | } |
2782 | if (gdqp) { | 2749 | if (gdqp) { |
@@ -2785,7 +2752,7 @@ xfs_qm_vop_dqattach_and_dqmod_newinode( | |||
2785 | xfs_dqunlock(gdqp); | 2752 | xfs_dqunlock(gdqp); |
2786 | ASSERT(ip->i_gdquot == NULL); | 2753 | ASSERT(ip->i_gdquot == NULL); |
2787 | ip->i_gdquot = gdqp; | 2754 | ip->i_gdquot = gdqp; |
2788 | ASSERT(ip->i_d.di_gid == INT_GET(gdqp->q_core.d_id, ARCH_CONVERT)); | 2755 | ASSERT(ip->i_d.di_gid == be32_to_cpu(gdqp->q_core.d_id)); |
2789 | xfs_trans_mod_dquot(tp, gdqp, XFS_TRANS_DQ_ICOUNT, 1); | 2756 | xfs_trans_mod_dquot(tp, gdqp, XFS_TRANS_DQ_ICOUNT, 1); |
2790 | } | 2757 | } |
2791 | } | 2758 | } |
diff --git a/fs/xfs/quota/xfs_qm.h b/fs/xfs/quota/xfs_qm.h index 0b00b3c67015..12da259f2fcb 100644 --- a/fs/xfs/quota/xfs_qm.h +++ b/fs/xfs/quota/xfs_qm.h | |||
@@ -1,33 +1,19 @@ | |||
1 | /* | 1 | /* |
2 | * Copyright (c) 2000-2005 Silicon Graphics, Inc. All Rights Reserved. | 2 | * Copyright (c) 2000-2005 Silicon Graphics, Inc. |
3 | * All Rights Reserved. | ||
3 | * | 4 | * |
4 | * This program is free software; you can redistribute it and/or modify it | 5 | * This program is free software; you can redistribute it and/or |
5 | * under the terms of version 2 of the GNU General Public License as | 6 | * modify it under the terms of the GNU General Public License as |
6 | * published by the Free Software Foundation. | 7 | * published by the Free Software Foundation. |
7 | * | 8 | * |
8 | * This program is distributed in the hope that it would be useful, but | 9 | * This program is distributed in the hope that it would be useful, |
9 | * WITHOUT ANY WARRANTY; without even the implied warranty of | 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
12 | * GNU General Public License for more details. | ||
11 | * | 13 | * |
12 | * Further, this software is distributed without any warranty that it is | 14 | * You should have received a copy of the GNU General Public License |
13 | * free of the rightful claim of any third person regarding infringement | 15 | * along with this program; if not, write the Free Software Foundation, |
14 | * or the like. Any license provided herein, whether implied or | 16 | * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
15 | * otherwise, applies only to this software file. Patent licenses, if | ||
16 | * any, provided herein do not apply to combinations of this program with | ||
17 | * other software, or any other product whatsoever. | ||
18 | * | ||
19 | * You should have received a copy of the GNU General Public License along | ||
20 | * with this program; if not, write the Free Software Foundation, Inc., 59 | ||
21 | * Temple Place - Suite 330, Boston MA 02111-1307, USA. | ||
22 | * | ||
23 | * Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy, | ||
24 | * Mountain View, CA 94043, or: | ||
25 | * | ||
26 | * http://www.sgi.com | ||
27 | * | ||
28 | * For further information regarding this notice, see: | ||
29 | * | ||
30 | * http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/ | ||
31 | */ | 17 | */ |
32 | #ifndef __XFS_QM_H__ | 18 | #ifndef __XFS_QM_H__ |
33 | #define __XFS_QM_H__ | 19 | #define __XFS_QM_H__ |
@@ -40,6 +26,7 @@ | |||
40 | struct xfs_qm; | 26 | struct xfs_qm; |
41 | struct xfs_inode; | 27 | struct xfs_inode; |
42 | 28 | ||
29 | extern uint ndquot; | ||
43 | extern mutex_t xfs_Gqm_lock; | 30 | extern mutex_t xfs_Gqm_lock; |
44 | extern struct xfs_qm *xfs_Gqm; | 31 | extern struct xfs_qm *xfs_Gqm; |
45 | extern kmem_zone_t *qm_dqzone; | 32 | extern kmem_zone_t *qm_dqzone; |
@@ -65,9 +52,8 @@ extern kmem_zone_t *qm_dqtrxzone; | |||
65 | /* | 52 | /* |
66 | * Dquot hashtable constants/threshold values. | 53 | * Dquot hashtable constants/threshold values. |
67 | */ | 54 | */ |
68 | #define XFS_QM_NCSIZE_THRESHOLD 5000 | 55 | #define XFS_QM_HASHSIZE_LOW (NBPP / sizeof(xfs_dqhash_t)) |
69 | #define XFS_QM_HASHSIZE_LOW 32 | 56 | #define XFS_QM_HASHSIZE_HIGH ((NBPP * 4) / sizeof(xfs_dqhash_t)) |
70 | #define XFS_QM_HASHSIZE_HIGH 64 | ||
71 | 57 | ||
72 | /* | 58 | /* |
73 | * We output a cmn_err when quotachecking a quota file with more than | 59 | * We output a cmn_err when quotachecking a quota file with more than |
diff --git a/fs/xfs/quota/xfs_qm_bhv.c b/fs/xfs/quota/xfs_qm_bhv.c index 8890a18a99d8..d9d2993de435 100644 --- a/fs/xfs/quota/xfs_qm_bhv.c +++ b/fs/xfs/quota/xfs_qm_bhv.c | |||
@@ -1,70 +1,55 @@ | |||
1 | /* | 1 | /* |
2 | * Copyright (c) 2000-2005 Silicon Graphics, Inc. All Rights Reserved. | 2 | * Copyright (c) 2000-2005 Silicon Graphics, Inc. |
3 | * All Rights Reserved. | ||
3 | * | 4 | * |
4 | * This program is free software; you can redistribute it and/or modify it | 5 | * This program is free software; you can redistribute it and/or |
5 | * under the terms of version 2 of the GNU General Public License as | 6 | * modify it under the terms of the GNU General Public License as |
6 | * published by the Free Software Foundation. | 7 | * published by the Free Software Foundation. |
7 | * | 8 | * |
8 | * This program is distributed in the hope that it would be useful, but | 9 | * This program is distributed in the hope that it would be useful, |
9 | * WITHOUT ANY WARRANTY; without even the implied warranty of | 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
12 | * GNU General Public License for more details. | ||
11 | * | 13 | * |
12 | * Further, this software is distributed without any warranty that it is | 14 | * You should have received a copy of the GNU General Public License |
13 | * free of the rightful claim of any third person regarding infringement | 15 | * along with this program; if not, write the Free Software Foundation, |
14 | * or the like. Any license provided herein, whether implied or | 16 | * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
15 | * otherwise, applies only to this software file. Patent licenses, if | ||
16 | * any, provided herein do not apply to combinations of this program with | ||
17 | * other software, or any other product whatsoever. | ||
18 | * | ||
19 | * You should have received a copy of the GNU General Public License along | ||
20 | * with this program; if not, write the Free Software Foundation, Inc., 59 | ||
21 | * Temple Place - Suite 330, Boston MA 02111-1307, USA. | ||
22 | * | ||
23 | * Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy, | ||
24 | * Mountain View, CA 94043, or: | ||
25 | * | ||
26 | * http://www.sgi.com | ||
27 | * | ||
28 | * For further information regarding this notice, see: | ||
29 | * | ||
30 | * http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/ | ||
31 | */ | 17 | */ |
32 | |||
33 | #include "xfs.h" | 18 | #include "xfs.h" |
34 | #include "xfs_fs.h" | 19 | #include "xfs_fs.h" |
35 | #include "xfs_inum.h" | 20 | #include "xfs_bit.h" |
36 | #include "xfs_log.h" | 21 | #include "xfs_log.h" |
22 | #include "xfs_inum.h" | ||
37 | #include "xfs_clnt.h" | 23 | #include "xfs_clnt.h" |
38 | #include "xfs_trans.h" | 24 | #include "xfs_trans.h" |
39 | #include "xfs_sb.h" | 25 | #include "xfs_sb.h" |
26 | #include "xfs_ag.h" | ||
40 | #include "xfs_dir.h" | 27 | #include "xfs_dir.h" |
41 | #include "xfs_dir2.h" | 28 | #include "xfs_dir2.h" |
42 | #include "xfs_alloc.h" | 29 | #include "xfs_alloc.h" |
43 | #include "xfs_dmapi.h" | 30 | #include "xfs_dmapi.h" |
44 | #include "xfs_quota.h" | 31 | #include "xfs_quota.h" |
45 | #include "xfs_mount.h" | 32 | #include "xfs_mount.h" |
46 | #include "xfs_alloc_btree.h" | ||
47 | #include "xfs_bmap_btree.h" | 33 | #include "xfs_bmap_btree.h" |
34 | #include "xfs_alloc_btree.h" | ||
48 | #include "xfs_ialloc_btree.h" | 35 | #include "xfs_ialloc_btree.h" |
49 | #include "xfs_btree.h" | ||
50 | #include "xfs_ialloc.h" | ||
51 | #include "xfs_attr_sf.h" | ||
52 | #include "xfs_dir_sf.h" | 36 | #include "xfs_dir_sf.h" |
53 | #include "xfs_dir2_sf.h" | 37 | #include "xfs_dir2_sf.h" |
38 | #include "xfs_attr_sf.h" | ||
54 | #include "xfs_dinode.h" | 39 | #include "xfs_dinode.h" |
55 | #include "xfs_inode.h" | 40 | #include "xfs_inode.h" |
41 | #include "xfs_ialloc.h" | ||
42 | #include "xfs_itable.h" | ||
43 | #include "xfs_btree.h" | ||
56 | #include "xfs_bmap.h" | 44 | #include "xfs_bmap.h" |
57 | #include "xfs_bit.h" | ||
58 | #include "xfs_rtalloc.h" | 45 | #include "xfs_rtalloc.h" |
59 | #include "xfs_error.h" | 46 | #include "xfs_error.h" |
60 | #include "xfs_itable.h" | ||
61 | #include "xfs_rw.h" | 47 | #include "xfs_rw.h" |
62 | #include "xfs_acl.h" | 48 | #include "xfs_acl.h" |
63 | #include "xfs_cap.h" | 49 | #include "xfs_cap.h" |
64 | #include "xfs_mac.h" | 50 | #include "xfs_mac.h" |
65 | #include "xfs_attr.h" | 51 | #include "xfs_attr.h" |
66 | #include "xfs_buf_item.h" | 52 | #include "xfs_buf_item.h" |
67 | |||
68 | #include "xfs_qm.h" | 53 | #include "xfs_qm.h" |
69 | 54 | ||
70 | #define MNTOPT_QUOTA "quota" /* disk quotas (user) */ | 55 | #define MNTOPT_QUOTA "quota" /* disk quotas (user) */ |
diff --git a/fs/xfs/quota/xfs_qm_stats.c b/fs/xfs/quota/xfs_qm_stats.c index 29978e037fee..0570f7733550 100644 --- a/fs/xfs/quota/xfs_qm_stats.c +++ b/fs/xfs/quota/xfs_qm_stats.c | |||
@@ -1,69 +1,54 @@ | |||
1 | /* | 1 | /* |
2 | * Copyright (c) 2000-2003 Silicon Graphics, Inc. All Rights Reserved. | 2 | * Copyright (c) 2000-2003 Silicon Graphics, Inc. |
3 | * All Rights Reserved. | ||
3 | * | 4 | * |
4 | * This program is free software; you can redistribute it and/or modify it | 5 | * This program is free software; you can redistribute it and/or |
5 | * under the terms of version 2 of the GNU General Public License as | 6 | * modify it under the terms of the GNU General Public License as |
6 | * published by the Free Software Foundation. | 7 | * published by the Free Software Foundation. |
7 | * | 8 | * |
8 | * This program is distributed in the hope that it would be useful, but | 9 | * This program is distributed in the hope that it would be useful, |
9 | * WITHOUT ANY WARRANTY; without even the implied warranty of | 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
12 | * GNU General Public License for more details. | ||
11 | * | 13 | * |
12 | * Further, this software is distributed without any warranty that it is | 14 | * You should have received a copy of the GNU General Public License |
13 | * free of the rightful claim of any third person regarding infringement | 15 | * along with this program; if not, write the Free Software Foundation, |
14 | * or the like. Any license provided herein, whether implied or | 16 | * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
15 | * otherwise, applies only to this software file. Patent licenses, if | ||
16 | * any, provided herein do not apply to combinations of this program with | ||
17 | * other software, or any other product whatsoever. | ||
18 | * | ||
19 | * You should have received a copy of the GNU General Public License along | ||
20 | * with this program; if not, write the Free Software Foundation, Inc., 59 | ||
21 | * Temple Place - Suite 330, Boston MA 02111-1307, USA. | ||
22 | * | ||
23 | * Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy, | ||
24 | * Mountain View, CA 94043, or: | ||
25 | * | ||
26 | * http://www.sgi.com | ||
27 | * | ||
28 | * For further information regarding this notice, see: | ||
29 | * | ||
30 | * http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/ | ||
31 | */ | 17 | */ |
32 | |||
33 | #include "xfs.h" | 18 | #include "xfs.h" |
34 | #include "xfs_fs.h" | 19 | #include "xfs_fs.h" |
35 | #include "xfs_inum.h" | 20 | #include "xfs_bit.h" |
36 | #include "xfs_log.h" | 21 | #include "xfs_log.h" |
22 | #include "xfs_inum.h" | ||
37 | #include "xfs_trans.h" | 23 | #include "xfs_trans.h" |
38 | #include "xfs_sb.h" | 24 | #include "xfs_sb.h" |
25 | #include "xfs_ag.h" | ||
39 | #include "xfs_dir.h" | 26 | #include "xfs_dir.h" |
40 | #include "xfs_dir2.h" | 27 | #include "xfs_dir2.h" |
41 | #include "xfs_alloc.h" | 28 | #include "xfs_alloc.h" |
42 | #include "xfs_dmapi.h" | 29 | #include "xfs_dmapi.h" |
43 | #include "xfs_quota.h" | 30 | #include "xfs_quota.h" |
44 | #include "xfs_mount.h" | 31 | #include "xfs_mount.h" |
45 | #include "xfs_alloc_btree.h" | ||
46 | #include "xfs_bmap_btree.h" | 32 | #include "xfs_bmap_btree.h" |
33 | #include "xfs_alloc_btree.h" | ||
47 | #include "xfs_ialloc_btree.h" | 34 | #include "xfs_ialloc_btree.h" |
48 | #include "xfs_btree.h" | ||
49 | #include "xfs_ialloc.h" | ||
50 | #include "xfs_attr_sf.h" | ||
51 | #include "xfs_dir_sf.h" | 35 | #include "xfs_dir_sf.h" |
52 | #include "xfs_dir2_sf.h" | 36 | #include "xfs_dir2_sf.h" |
37 | #include "xfs_attr_sf.h" | ||
53 | #include "xfs_dinode.h" | 38 | #include "xfs_dinode.h" |
54 | #include "xfs_inode.h" | 39 | #include "xfs_inode.h" |
40 | #include "xfs_ialloc.h" | ||
41 | #include "xfs_itable.h" | ||
55 | #include "xfs_bmap.h" | 42 | #include "xfs_bmap.h" |
56 | #include "xfs_bit.h" | 43 | #include "xfs_btree.h" |
57 | #include "xfs_rtalloc.h" | 44 | #include "xfs_rtalloc.h" |
58 | #include "xfs_error.h" | 45 | #include "xfs_error.h" |
59 | #include "xfs_itable.h" | ||
60 | #include "xfs_rw.h" | 46 | #include "xfs_rw.h" |
61 | #include "xfs_acl.h" | 47 | #include "xfs_acl.h" |
62 | #include "xfs_cap.h" | 48 | #include "xfs_cap.h" |
63 | #include "xfs_mac.h" | 49 | #include "xfs_mac.h" |
64 | #include "xfs_attr.h" | 50 | #include "xfs_attr.h" |
65 | #include "xfs_buf_item.h" | 51 | #include "xfs_buf_item.h" |
66 | |||
67 | #include "xfs_qm.h" | 52 | #include "xfs_qm.h" |
68 | 53 | ||
69 | struct xqmstats xqmstats; | 54 | struct xqmstats xqmstats; |
diff --git a/fs/xfs/quota/xfs_qm_stats.h b/fs/xfs/quota/xfs_qm_stats.h index 8093c5c284ec..a50ffabcf554 100644 --- a/fs/xfs/quota/xfs_qm_stats.h +++ b/fs/xfs/quota/xfs_qm_stats.h | |||
@@ -1,38 +1,23 @@ | |||
1 | /* | 1 | /* |
2 | * Copyright (c) 2002 Silicon Graphics, Inc. All Rights Reserved. | 2 | * Copyright (c) 2002 Silicon Graphics, Inc. |
3 | * All Rights Reserved. | ||
3 | * | 4 | * |
4 | * This program is free software; you can redistribute it and/or modify it | 5 | * This program is free software; you can redistribute it and/or |
5 | * under the terms of version 2 of the GNU General Public License as | 6 | * modify it under the terms of the GNU General Public License as |
6 | * published by the Free Software Foundation. | 7 | * published by the Free Software Foundation. |
7 | * | 8 | * |
8 | * This program is distributed in the hope that it would be useful, but | 9 | * This program is distributed in the hope that it would be useful, |
9 | * WITHOUT ANY WARRANTY; without even the implied warranty of | 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
12 | * GNU General Public License for more details. | ||
11 | * | 13 | * |
12 | * Further, this software is distributed without any warranty that it is | 14 | * You should have received a copy of the GNU General Public License |
13 | * free of the rightful claim of any third person regarding infringement | 15 | * along with this program; if not, write the Free Software Foundation, |
14 | * or the like. Any license provided herein, whether implied or | 16 | * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
15 | * otherwise, applies only to this software file. Patent licenses, if | ||
16 | * any, provided herein do not apply to combinations of this program with | ||
17 | * other software, or any other product whatsoever. | ||
18 | * | ||
19 | * You should have received a copy of the GNU General Public License along | ||
20 | * with this program; if not, write the Free Software Foundation, Inc., 59 | ||
21 | * Temple Place - Suite 330, Boston MA 02111-1307, USA. | ||
22 | * | ||
23 | * Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy, | ||
24 | * Mountain View, CA 94043, or: | ||
25 | * | ||
26 | * http://www.sgi.com | ||
27 | * | ||
28 | * For further information regarding this notice, see: | ||
29 | * | ||
30 | * http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/ | ||
31 | */ | 17 | */ |
32 | #ifndef __XFS_QM_STATS_H__ | 18 | #ifndef __XFS_QM_STATS_H__ |
33 | #define __XFS_QM_STATS_H__ | 19 | #define __XFS_QM_STATS_H__ |
34 | 20 | ||
35 | |||
36 | #if defined(CONFIG_PROC_FS) && !defined(XFS_STATS_OFF) | 21 | #if defined(CONFIG_PROC_FS) && !defined(XFS_STATS_OFF) |
37 | 22 | ||
38 | /* | 23 | /* |
diff --git a/fs/xfs/quota/xfs_qm_syscalls.c b/fs/xfs/quota/xfs_qm_syscalls.c index 15e02e8a9d4f..24690e1af659 100644 --- a/fs/xfs/quota/xfs_qm_syscalls.c +++ b/fs/xfs/quota/xfs_qm_syscalls.c | |||
@@ -1,62 +1,48 @@ | |||
1 | /* | 1 | /* |
2 | * Copyright (c) 2000-2003 Silicon Graphics, Inc. All Rights Reserved. | 2 | * Copyright (c) 2000-2005 Silicon Graphics, Inc. |
3 | * All Rights Reserved. | ||
3 | * | 4 | * |
4 | * This program is free software; you can redistribute it and/or modify it | 5 | * This program is free software; you can redistribute it and/or |
5 | * under the terms of version 2 of the GNU General Public License as | 6 | * modify it under the terms of the GNU General Public License as |
6 | * published by the Free Software Foundation. | 7 | * published by the Free Software Foundation. |
7 | * | 8 | * |
8 | * This program is distributed in the hope that it would be useful, but | 9 | * This program is distributed in the hope that it would be useful, |
9 | * WITHOUT ANY WARRANTY; without even the implied warranty of | 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
12 | * GNU General Public License for more details. | ||
11 | * | 13 | * |
12 | * Further, this software is distributed without any warranty that it is | 14 | * You should have received a copy of the GNU General Public License |
13 | * free of the rightful claim of any third person regarding infringement | 15 | * along with this program; if not, write the Free Software Foundation, |
14 | * or the like. Any license provided herein, whether implied or | 16 | * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
15 | * otherwise, applies only to this software file. Patent licenses, if | ||
16 | * any, provided herein do not apply to combinations of this program with | ||
17 | * other software, or any other product whatsoever. | ||
18 | * | ||
19 | * You should have received a copy of the GNU General Public License along | ||
20 | * with this program; if not, write the Free Software Foundation, Inc., 59 | ||
21 | * Temple Place - Suite 330, Boston MA 02111-1307, USA. | ||
22 | * | ||
23 | * Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy, | ||
24 | * Mountain View, CA 94043, or: | ||
25 | * | ||
26 | * http://www.sgi.com | ||
27 | * | ||
28 | * For further information regarding this notice, see: | ||
29 | * | ||
30 | * http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/ | ||
31 | */ | 17 | */ |
32 | |||
33 | #include "xfs.h" | 18 | #include "xfs.h" |
34 | #include "xfs_fs.h" | 19 | #include "xfs_fs.h" |
35 | #include "xfs_inum.h" | 20 | #include "xfs_bit.h" |
36 | #include "xfs_log.h" | 21 | #include "xfs_log.h" |
22 | #include "xfs_inum.h" | ||
37 | #include "xfs_trans.h" | 23 | #include "xfs_trans.h" |
38 | #include "xfs_sb.h" | 24 | #include "xfs_sb.h" |
25 | #include "xfs_ag.h" | ||
39 | #include "xfs_dir.h" | 26 | #include "xfs_dir.h" |
40 | #include "xfs_dir2.h" | 27 | #include "xfs_dir2.h" |
41 | #include "xfs_alloc.h" | 28 | #include "xfs_alloc.h" |
42 | #include "xfs_dmapi.h" | 29 | #include "xfs_dmapi.h" |
43 | #include "xfs_quota.h" | 30 | #include "xfs_quota.h" |
44 | #include "xfs_mount.h" | 31 | #include "xfs_mount.h" |
45 | #include "xfs_alloc_btree.h" | ||
46 | #include "xfs_bmap_btree.h" | 32 | #include "xfs_bmap_btree.h" |
33 | #include "xfs_alloc_btree.h" | ||
47 | #include "xfs_ialloc_btree.h" | 34 | #include "xfs_ialloc_btree.h" |
48 | #include "xfs_btree.h" | ||
49 | #include "xfs_ialloc.h" | ||
50 | #include "xfs_attr_sf.h" | ||
51 | #include "xfs_dir_sf.h" | 35 | #include "xfs_dir_sf.h" |
52 | #include "xfs_dir2_sf.h" | 36 | #include "xfs_dir2_sf.h" |
37 | #include "xfs_attr_sf.h" | ||
53 | #include "xfs_dinode.h" | 38 | #include "xfs_dinode.h" |
54 | #include "xfs_inode.h" | 39 | #include "xfs_inode.h" |
40 | #include "xfs_ialloc.h" | ||
41 | #include "xfs_itable.h" | ||
55 | #include "xfs_bmap.h" | 42 | #include "xfs_bmap.h" |
56 | #include "xfs_bit.h" | 43 | #include "xfs_btree.h" |
57 | #include "xfs_rtalloc.h" | 44 | #include "xfs_rtalloc.h" |
58 | #include "xfs_error.h" | 45 | #include "xfs_error.h" |
59 | #include "xfs_itable.h" | ||
60 | #include "xfs_rw.h" | 46 | #include "xfs_rw.h" |
61 | #include "xfs_acl.h" | 47 | #include "xfs_acl.h" |
62 | #include "xfs_cap.h" | 48 | #include "xfs_cap.h" |
@@ -64,7 +50,6 @@ | |||
64 | #include "xfs_attr.h" | 50 | #include "xfs_attr.h" |
65 | #include "xfs_buf_item.h" | 51 | #include "xfs_buf_item.h" |
66 | #include "xfs_utils.h" | 52 | #include "xfs_utils.h" |
67 | |||
68 | #include "xfs_qm.h" | 53 | #include "xfs_qm.h" |
69 | 54 | ||
70 | #ifdef DEBUG | 55 | #ifdef DEBUG |
@@ -109,10 +94,7 @@ xfs_qm_quotactl( | |||
109 | vfsp = bhvtovfs(bdp); | 94 | vfsp = bhvtovfs(bdp); |
110 | mp = XFS_VFSTOM(vfsp); | 95 | mp = XFS_VFSTOM(vfsp); |
111 | 96 | ||
112 | if (addr == NULL && cmd != Q_SYNC) | 97 | ASSERT(addr != NULL || cmd == Q_XQUOTASYNC); |
113 | return XFS_ERROR(EINVAL); | ||
114 | if (id < 0 && cmd != Q_SYNC) | ||
115 | return XFS_ERROR(EINVAL); | ||
116 | 98 | ||
117 | /* | 99 | /* |
118 | * The following commands are valid even when quotaoff. | 100 | * The following commands are valid even when quotaoff. |
@@ -122,7 +104,7 @@ xfs_qm_quotactl( | |||
122 | /* | 104 | /* |
123 | * Truncate quota files. quota must be off. | 105 | * Truncate quota files. quota must be off. |
124 | */ | 106 | */ |
125 | if (XFS_IS_QUOTA_ON(mp) || addr == NULL) | 107 | if (XFS_IS_QUOTA_ON(mp)) |
126 | return XFS_ERROR(EINVAL); | 108 | return XFS_ERROR(EINVAL); |
127 | if (vfsp->vfs_flag & VFS_RDONLY) | 109 | if (vfsp->vfs_flag & VFS_RDONLY) |
128 | return XFS_ERROR(EROFS); | 110 | return XFS_ERROR(EROFS); |
@@ -140,8 +122,6 @@ xfs_qm_quotactl( | |||
140 | * QUOTAON - enabling quota enforcement. | 122 | * QUOTAON - enabling quota enforcement. |
141 | * Quota accounting must be turned on at mount time. | 123 | * Quota accounting must be turned on at mount time. |
142 | */ | 124 | */ |
143 | if (addr == NULL) | ||
144 | return XFS_ERROR(EINVAL); | ||
145 | if (vfsp->vfs_flag & VFS_RDONLY) | 125 | if (vfsp->vfs_flag & VFS_RDONLY) |
146 | return XFS_ERROR(EROFS); | 126 | return XFS_ERROR(EROFS); |
147 | return (xfs_qm_scall_quotaon(mp, | 127 | return (xfs_qm_scall_quotaon(mp, |
@@ -152,6 +132,9 @@ xfs_qm_quotactl( | |||
152 | return XFS_ERROR(EROFS); | 132 | return XFS_ERROR(EROFS); |
153 | break; | 133 | break; |
154 | 134 | ||
135 | case Q_XQUOTASYNC: | ||
136 | return (xfs_sync_inodes(mp, SYNC_DELWRI, 0, NULL)); | ||
137 | |||
155 | default: | 138 | default: |
156 | break; | 139 | break; |
157 | } | 140 | } |
@@ -655,13 +638,13 @@ xfs_qm_scall_setqlim( | |||
655 | */ | 638 | */ |
656 | hard = (newlim->d_fieldmask & FS_DQ_BHARD) ? | 639 | hard = (newlim->d_fieldmask & FS_DQ_BHARD) ? |
657 | (xfs_qcnt_t) XFS_BB_TO_FSB(mp, newlim->d_blk_hardlimit) : | 640 | (xfs_qcnt_t) XFS_BB_TO_FSB(mp, newlim->d_blk_hardlimit) : |
658 | INT_GET(ddq->d_blk_hardlimit, ARCH_CONVERT); | 641 | be64_to_cpu(ddq->d_blk_hardlimit); |
659 | soft = (newlim->d_fieldmask & FS_DQ_BSOFT) ? | 642 | soft = (newlim->d_fieldmask & FS_DQ_BSOFT) ? |
660 | (xfs_qcnt_t) XFS_BB_TO_FSB(mp, newlim->d_blk_softlimit) : | 643 | (xfs_qcnt_t) XFS_BB_TO_FSB(mp, newlim->d_blk_softlimit) : |
661 | INT_GET(ddq->d_blk_softlimit, ARCH_CONVERT); | 644 | be64_to_cpu(ddq->d_blk_softlimit); |
662 | if (hard == 0 || hard >= soft) { | 645 | if (hard == 0 || hard >= soft) { |
663 | INT_SET(ddq->d_blk_hardlimit, ARCH_CONVERT, hard); | 646 | ddq->d_blk_hardlimit = cpu_to_be64(hard); |
664 | INT_SET(ddq->d_blk_softlimit, ARCH_CONVERT, soft); | 647 | ddq->d_blk_softlimit = cpu_to_be64(soft); |
665 | if (id == 0) { | 648 | if (id == 0) { |
666 | mp->m_quotainfo->qi_bhardlimit = hard; | 649 | mp->m_quotainfo->qi_bhardlimit = hard; |
667 | mp->m_quotainfo->qi_bsoftlimit = soft; | 650 | mp->m_quotainfo->qi_bsoftlimit = soft; |
@@ -671,13 +654,13 @@ xfs_qm_scall_setqlim( | |||
671 | } | 654 | } |
672 | hard = (newlim->d_fieldmask & FS_DQ_RTBHARD) ? | 655 | hard = (newlim->d_fieldmask & FS_DQ_RTBHARD) ? |
673 | (xfs_qcnt_t) XFS_BB_TO_FSB(mp, newlim->d_rtb_hardlimit) : | 656 | (xfs_qcnt_t) XFS_BB_TO_FSB(mp, newlim->d_rtb_hardlimit) : |
674 | INT_GET(ddq->d_rtb_hardlimit, ARCH_CONVERT); | 657 | be64_to_cpu(ddq->d_rtb_hardlimit); |
675 | soft = (newlim->d_fieldmask & FS_DQ_RTBSOFT) ? | 658 | soft = (newlim->d_fieldmask & FS_DQ_RTBSOFT) ? |
676 | (xfs_qcnt_t) XFS_BB_TO_FSB(mp, newlim->d_rtb_softlimit) : | 659 | (xfs_qcnt_t) XFS_BB_TO_FSB(mp, newlim->d_rtb_softlimit) : |
677 | INT_GET(ddq->d_rtb_softlimit, ARCH_CONVERT); | 660 | be64_to_cpu(ddq->d_rtb_softlimit); |
678 | if (hard == 0 || hard >= soft) { | 661 | if (hard == 0 || hard >= soft) { |
679 | INT_SET(ddq->d_rtb_hardlimit, ARCH_CONVERT, hard); | 662 | ddq->d_rtb_hardlimit = cpu_to_be64(hard); |
680 | INT_SET(ddq->d_rtb_softlimit, ARCH_CONVERT, soft); | 663 | ddq->d_rtb_softlimit = cpu_to_be64(soft); |
681 | if (id == 0) { | 664 | if (id == 0) { |
682 | mp->m_quotainfo->qi_rtbhardlimit = hard; | 665 | mp->m_quotainfo->qi_rtbhardlimit = hard; |
683 | mp->m_quotainfo->qi_rtbsoftlimit = soft; | 666 | mp->m_quotainfo->qi_rtbsoftlimit = soft; |
@@ -688,13 +671,13 @@ xfs_qm_scall_setqlim( | |||
688 | 671 | ||
689 | hard = (newlim->d_fieldmask & FS_DQ_IHARD) ? | 672 | hard = (newlim->d_fieldmask & FS_DQ_IHARD) ? |
690 | (xfs_qcnt_t) newlim->d_ino_hardlimit : | 673 | (xfs_qcnt_t) newlim->d_ino_hardlimit : |
691 | INT_GET(ddq->d_ino_hardlimit, ARCH_CONVERT); | 674 | be64_to_cpu(ddq->d_ino_hardlimit); |
692 | soft = (newlim->d_fieldmask & FS_DQ_ISOFT) ? | 675 | soft = (newlim->d_fieldmask & FS_DQ_ISOFT) ? |
693 | (xfs_qcnt_t) newlim->d_ino_softlimit : | 676 | (xfs_qcnt_t) newlim->d_ino_softlimit : |
694 | INT_GET(ddq->d_ino_softlimit, ARCH_CONVERT); | 677 | be64_to_cpu(ddq->d_ino_softlimit); |
695 | if (hard == 0 || hard >= soft) { | 678 | if (hard == 0 || hard >= soft) { |
696 | INT_SET(ddq->d_ino_hardlimit, ARCH_CONVERT, hard); | 679 | ddq->d_ino_hardlimit = cpu_to_be64(hard); |
697 | INT_SET(ddq->d_ino_softlimit, ARCH_CONVERT, soft); | 680 | ddq->d_ino_softlimit = cpu_to_be64(soft); |
698 | if (id == 0) { | 681 | if (id == 0) { |
699 | mp->m_quotainfo->qi_ihardlimit = hard; | 682 | mp->m_quotainfo->qi_ihardlimit = hard; |
700 | mp->m_quotainfo->qi_isoftlimit = soft; | 683 | mp->m_quotainfo->qi_isoftlimit = soft; |
@@ -707,11 +690,11 @@ xfs_qm_scall_setqlim( | |||
707 | * Update warnings counter(s) if requested | 690 | * Update warnings counter(s) if requested |
708 | */ | 691 | */ |
709 | if (newlim->d_fieldmask & FS_DQ_BWARNS) | 692 | if (newlim->d_fieldmask & FS_DQ_BWARNS) |
710 | INT_SET(ddq->d_bwarns, ARCH_CONVERT, newlim->d_bwarns); | 693 | ddq->d_bwarns = cpu_to_be16(newlim->d_bwarns); |
711 | if (newlim->d_fieldmask & FS_DQ_IWARNS) | 694 | if (newlim->d_fieldmask & FS_DQ_IWARNS) |
712 | INT_SET(ddq->d_iwarns, ARCH_CONVERT, newlim->d_iwarns); | 695 | ddq->d_iwarns = cpu_to_be16(newlim->d_iwarns); |
713 | if (newlim->d_fieldmask & FS_DQ_RTBWARNS) | 696 | if (newlim->d_fieldmask & FS_DQ_RTBWARNS) |
714 | INT_SET(ddq->d_rtbwarns, ARCH_CONVERT, newlim->d_rtbwarns); | 697 | ddq->d_rtbwarns = cpu_to_be16(newlim->d_rtbwarns); |
715 | 698 | ||
716 | if (id == 0) { | 699 | if (id == 0) { |
717 | /* | 700 | /* |
@@ -723,15 +706,15 @@ xfs_qm_scall_setqlim( | |||
723 | */ | 706 | */ |
724 | if (newlim->d_fieldmask & FS_DQ_BTIMER) { | 707 | if (newlim->d_fieldmask & FS_DQ_BTIMER) { |
725 | mp->m_quotainfo->qi_btimelimit = newlim->d_btimer; | 708 | mp->m_quotainfo->qi_btimelimit = newlim->d_btimer; |
726 | INT_SET(ddq->d_btimer, ARCH_CONVERT, newlim->d_btimer); | 709 | ddq->d_btimer = cpu_to_be32(newlim->d_btimer); |
727 | } | 710 | } |
728 | if (newlim->d_fieldmask & FS_DQ_ITIMER) { | 711 | if (newlim->d_fieldmask & FS_DQ_ITIMER) { |
729 | mp->m_quotainfo->qi_itimelimit = newlim->d_itimer; | 712 | mp->m_quotainfo->qi_itimelimit = newlim->d_itimer; |
730 | INT_SET(ddq->d_itimer, ARCH_CONVERT, newlim->d_itimer); | 713 | ddq->d_itimer = cpu_to_be32(newlim->d_itimer); |
731 | } | 714 | } |
732 | if (newlim->d_fieldmask & FS_DQ_RTBTIMER) { | 715 | if (newlim->d_fieldmask & FS_DQ_RTBTIMER) { |
733 | mp->m_quotainfo->qi_rtbtimelimit = newlim->d_rtbtimer; | 716 | mp->m_quotainfo->qi_rtbtimelimit = newlim->d_rtbtimer; |
734 | INT_SET(ddq->d_rtbtimer, ARCH_CONVERT, newlim->d_rtbtimer); | 717 | ddq->d_rtbtimer = cpu_to_be32(newlim->d_rtbtimer); |
735 | } | 718 | } |
736 | if (newlim->d_fieldmask & FS_DQ_BWARNS) | 719 | if (newlim->d_fieldmask & FS_DQ_BWARNS) |
737 | mp->m_quotainfo->qi_bwarnlimit = newlim->d_bwarns; | 720 | mp->m_quotainfo->qi_bwarnlimit = newlim->d_bwarns; |
@@ -902,33 +885,27 @@ xfs_qm_export_dquot( | |||
902 | { | 885 | { |
903 | memset(dst, 0, sizeof(*dst)); | 886 | memset(dst, 0, sizeof(*dst)); |
904 | dst->d_version = FS_DQUOT_VERSION; /* different from src->d_version */ | 887 | dst->d_version = FS_DQUOT_VERSION; /* different from src->d_version */ |
905 | dst->d_flags = | 888 | dst->d_flags = xfs_qm_export_qtype_flags(src->d_flags); |
906 | xfs_qm_export_qtype_flags(INT_GET(src->d_flags, ARCH_CONVERT)); | 889 | dst->d_id = be32_to_cpu(src->d_id); |
907 | dst->d_id = INT_GET(src->d_id, ARCH_CONVERT); | 890 | dst->d_blk_hardlimit = |
908 | dst->d_blk_hardlimit = (__uint64_t) | 891 | XFS_FSB_TO_BB(mp, be64_to_cpu(src->d_blk_hardlimit)); |
909 | XFS_FSB_TO_BB(mp, INT_GET(src->d_blk_hardlimit, ARCH_CONVERT)); | 892 | dst->d_blk_softlimit = |
910 | dst->d_blk_softlimit = (__uint64_t) | 893 | XFS_FSB_TO_BB(mp, be64_to_cpu(src->d_blk_softlimit)); |
911 | XFS_FSB_TO_BB(mp, INT_GET(src->d_blk_softlimit, ARCH_CONVERT)); | 894 | dst->d_ino_hardlimit = be64_to_cpu(src->d_ino_hardlimit); |
912 | dst->d_ino_hardlimit = (__uint64_t) | 895 | dst->d_ino_softlimit = be64_to_cpu(src->d_ino_softlimit); |
913 | INT_GET(src->d_ino_hardlimit, ARCH_CONVERT); | 896 | dst->d_bcount = XFS_FSB_TO_BB(mp, be64_to_cpu(src->d_bcount)); |
914 | dst->d_ino_softlimit = (__uint64_t) | 897 | dst->d_icount = be64_to_cpu(src->d_icount); |
915 | INT_GET(src->d_ino_softlimit, ARCH_CONVERT); | 898 | dst->d_btimer = be32_to_cpu(src->d_btimer); |
916 | dst->d_bcount = (__uint64_t) | 899 | dst->d_itimer = be32_to_cpu(src->d_itimer); |
917 | XFS_FSB_TO_BB(mp, INT_GET(src->d_bcount, ARCH_CONVERT)); | 900 | dst->d_iwarns = be16_to_cpu(src->d_iwarns); |
918 | dst->d_icount = (__uint64_t) INT_GET(src->d_icount, ARCH_CONVERT); | 901 | dst->d_bwarns = be16_to_cpu(src->d_bwarns); |
919 | dst->d_btimer = (__uint32_t) INT_GET(src->d_btimer, ARCH_CONVERT); | 902 | dst->d_rtb_hardlimit = |
920 | dst->d_itimer = (__uint32_t) INT_GET(src->d_itimer, ARCH_CONVERT); | 903 | XFS_FSB_TO_BB(mp, be64_to_cpu(src->d_rtb_hardlimit)); |
921 | dst->d_iwarns = INT_GET(src->d_iwarns, ARCH_CONVERT); | 904 | dst->d_rtb_softlimit = |
922 | dst->d_bwarns = INT_GET(src->d_bwarns, ARCH_CONVERT); | 905 | XFS_FSB_TO_BB(mp, be64_to_cpu(src->d_rtb_softlimit)); |
923 | 906 | dst->d_rtbcount = XFS_FSB_TO_BB(mp, be64_to_cpu(src->d_rtbcount)); | |
924 | dst->d_rtb_hardlimit = (__uint64_t) | 907 | dst->d_rtbtimer = be32_to_cpu(src->d_rtbtimer); |
925 | XFS_FSB_TO_BB(mp, INT_GET(src->d_rtb_hardlimit, ARCH_CONVERT)); | 908 | dst->d_rtbwarns = be16_to_cpu(src->d_rtbwarns); |
926 | dst->d_rtb_softlimit = (__uint64_t) | ||
927 | XFS_FSB_TO_BB(mp, INT_GET(src->d_rtb_softlimit, ARCH_CONVERT)); | ||
928 | dst->d_rtbcount = (__uint64_t) | ||
929 | XFS_FSB_TO_BB(mp, INT_GET(src->d_rtbcount, ARCH_CONVERT)); | ||
930 | dst->d_rtbtimer = (__uint32_t) INT_GET(src->d_rtbtimer, ARCH_CONVERT); | ||
931 | dst->d_rtbwarns = INT_GET(src->d_rtbwarns, ARCH_CONVERT); | ||
932 | 909 | ||
933 | /* | 910 | /* |
934 | * Internally, we don't reset all the timers when quota enforcement | 911 | * Internally, we don't reset all the timers when quota enforcement |
@@ -1222,10 +1199,10 @@ xfs_qm_dqtest_failed( | |||
1222 | qmtest_nfails++; | 1199 | qmtest_nfails++; |
1223 | if (error) | 1200 | if (error) |
1224 | cmn_err(CE_DEBUG, "quotacheck failed id=%d, err=%d\nreason: %s", | 1201 | cmn_err(CE_DEBUG, "quotacheck failed id=%d, err=%d\nreason: %s", |
1225 | INT_GET(d->d_id, ARCH_CONVERT), error, reason); | 1202 | d->d_id, error, reason); |
1226 | else | 1203 | else |
1227 | cmn_err(CE_DEBUG, "quotacheck failed id=%d (%s) [%d != %d]", | 1204 | cmn_err(CE_DEBUG, "quotacheck failed id=%d (%s) [%d != %d]", |
1228 | INT_GET(d->d_id, ARCH_CONVERT), reason, (int)a, (int)b); | 1205 | d->d_id, reason, (int)a, (int)b); |
1229 | xfs_qm_dqtest_print(d); | 1206 | xfs_qm_dqtest_print(d); |
1230 | if (dqp) | 1207 | if (dqp) |
1231 | xfs_qm_dqprint(dqp); | 1208 | xfs_qm_dqprint(dqp); |
@@ -1237,21 +1214,21 @@ xfs_dqtest_cmp2( | |||
1237 | xfs_dquot_t *dqp) | 1214 | xfs_dquot_t *dqp) |
1238 | { | 1215 | { |
1239 | int err = 0; | 1216 | int err = 0; |
1240 | if (INT_GET(dqp->q_core.d_icount, ARCH_CONVERT) != d->d_icount) { | 1217 | if (be64_to_cpu(dqp->q_core.d_icount) != d->d_icount) { |
1241 | xfs_qm_dqtest_failed(d, dqp, "icount mismatch", | 1218 | xfs_qm_dqtest_failed(d, dqp, "icount mismatch", |
1242 | INT_GET(dqp->q_core.d_icount, ARCH_CONVERT), | 1219 | be64_to_cpu(dqp->q_core.d_icount), |
1243 | d->d_icount, 0); | 1220 | d->d_icount, 0); |
1244 | err++; | 1221 | err++; |
1245 | } | 1222 | } |
1246 | if (INT_GET(dqp->q_core.d_bcount, ARCH_CONVERT) != d->d_bcount) { | 1223 | if (be64_to_cpu(dqp->q_core.d_bcount) != d->d_bcount) { |
1247 | xfs_qm_dqtest_failed(d, dqp, "bcount mismatch", | 1224 | xfs_qm_dqtest_failed(d, dqp, "bcount mismatch", |
1248 | INT_GET(dqp->q_core.d_bcount, ARCH_CONVERT), | 1225 | be64_to_cpu(dqp->q_core.d_bcount), |
1249 | d->d_bcount, 0); | 1226 | d->d_bcount, 0); |
1250 | err++; | 1227 | err++; |
1251 | } | 1228 | } |
1252 | if (INT_GET(dqp->q_core.d_blk_softlimit, ARCH_CONVERT) && | 1229 | if (dqp->q_core.d_blk_softlimit && |
1253 | INT_GET(dqp->q_core.d_bcount, ARCH_CONVERT) >= | 1230 | be64_to_cpu(dqp->q_core.d_bcount) >= |
1254 | INT_GET(dqp->q_core.d_blk_softlimit, ARCH_CONVERT)) { | 1231 | be64_to_cpu(dqp->q_core.d_blk_softlimit)) { |
1255 | if (!dqp->q_core.d_btimer && dqp->q_core.d_id) { | 1232 | if (!dqp->q_core.d_btimer && dqp->q_core.d_id) { |
1256 | cmn_err(CE_DEBUG, | 1233 | cmn_err(CE_DEBUG, |
1257 | "%d [%s] [0x%p] BLK TIMER NOT STARTED", | 1234 | "%d [%s] [0x%p] BLK TIMER NOT STARTED", |
@@ -1259,9 +1236,9 @@ xfs_dqtest_cmp2( | |||
1259 | err++; | 1236 | err++; |
1260 | } | 1237 | } |
1261 | } | 1238 | } |
1262 | if (INT_GET(dqp->q_core.d_ino_softlimit, ARCH_CONVERT) && | 1239 | if (dqp->q_core.d_ino_softlimit && |
1263 | INT_GET(dqp->q_core.d_icount, ARCH_CONVERT) >= | 1240 | be64_to_cpu(dqp->q_core.d_icount) >= |
1264 | INT_GET(dqp->q_core.d_ino_softlimit, ARCH_CONVERT)) { | 1241 | be64_to_cpu(dqp->q_core.d_ino_softlimit)) { |
1265 | if (!dqp->q_core.d_itimer && dqp->q_core.d_id) { | 1242 | if (!dqp->q_core.d_itimer && dqp->q_core.d_id) { |
1266 | cmn_err(CE_DEBUG, | 1243 | cmn_err(CE_DEBUG, |
1267 | "%d [%s] [0x%p] INO TIMER NOT STARTED", | 1244 | "%d [%s] [0x%p] INO TIMER NOT STARTED", |
diff --git a/fs/xfs/quota/xfs_quota_priv.h b/fs/xfs/quota/xfs_quota_priv.h index bf413e70ec07..7a9f3beb818c 100644 --- a/fs/xfs/quota/xfs_quota_priv.h +++ b/fs/xfs/quota/xfs_quota_priv.h | |||
@@ -1,33 +1,19 @@ | |||
1 | /* | 1 | /* |
2 | * Copyright (c) 2000-2003 Silicon Graphics, Inc. All Rights Reserved. | 2 | * Copyright (c) 2000-2003 Silicon Graphics, Inc. |
3 | * All Rights Reserved. | ||
3 | * | 4 | * |
4 | * This program is free software; you can redistribute it and/or modify it | 5 | * This program is free software; you can redistribute it and/or |
5 | * under the terms of version 2 of the GNU General Public License as | 6 | * modify it under the terms of the GNU General Public License as |
6 | * published by the Free Software Foundation. | 7 | * published by the Free Software Foundation. |
7 | * | 8 | * |
8 | * This program is distributed in the hope that it would be useful, but | 9 | * This program is distributed in the hope that it would be useful, |
9 | * WITHOUT ANY WARRANTY; without even the implied warranty of | 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
12 | * GNU General Public License for more details. | ||
11 | * | 13 | * |
12 | * Further, this software is distributed without any warranty that it is | 14 | * You should have received a copy of the GNU General Public License |
13 | * free of the rightful claim of any third person regarding infringement | 15 | * along with this program; if not, write the Free Software Foundation, |
14 | * or the like. Any license provided herein, whether implied or | 16 | * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
15 | * otherwise, applies only to this software file. Patent licenses, if | ||
16 | * any, provided herein do not apply to combinations of this program with | ||
17 | * other software, or any other product whatsoever. | ||
18 | * | ||
19 | * You should have received a copy of the GNU General Public License along | ||
20 | * with this program; if not, write the Free Software Foundation, Inc., 59 | ||
21 | * Temple Place - Suite 330, Boston MA 02111-1307, USA. | ||
22 | * | ||
23 | * Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy, | ||
24 | * Mountain View, CA 94043, or: | ||
25 | * | ||
26 | * http://www.sgi.com | ||
27 | * | ||
28 | * For further information regarding this notice, see: | ||
29 | * | ||
30 | * http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/ | ||
31 | */ | 17 | */ |
32 | #ifndef __XFS_QUOTA_PRIV_H__ | 18 | #ifndef __XFS_QUOTA_PRIV_H__ |
33 | #define __XFS_QUOTA_PRIV_H__ | 19 | #define __XFS_QUOTA_PRIV_H__ |
diff --git a/fs/xfs/quota/xfs_trans_dquot.c b/fs/xfs/quota/xfs_trans_dquot.c index 3b99daf8a640..3290975d31f7 100644 --- a/fs/xfs/quota/xfs_trans_dquot.c +++ b/fs/xfs/quota/xfs_trans_dquot.c | |||
@@ -1,39 +1,25 @@ | |||
1 | /* | 1 | /* |
2 | * Copyright (c) 2000-2002 Silicon Graphics, Inc. All Rights Reserved. | 2 | * Copyright (c) 2000-2002 Silicon Graphics, Inc. |
3 | * All Rights Reserved. | ||
3 | * | 4 | * |
4 | * This program is free software; you can redistribute it and/or modify it | 5 | * This program is free software; you can redistribute it and/or |
5 | * under the terms of version 2 of the GNU General Public License as | 6 | * modify it under the terms of the GNU General Public License as |
6 | * published by the Free Software Foundation. | 7 | * published by the Free Software Foundation. |
7 | * | 8 | * |
8 | * This program is distributed in the hope that it would be useful, but | 9 | * This program is distributed in the hope that it would be useful, |
9 | * WITHOUT ANY WARRANTY; without even the implied warranty of | 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
12 | * GNU General Public License for more details. | ||
11 | * | 13 | * |
12 | * Further, this software is distributed without any warranty that it is | 14 | * You should have received a copy of the GNU General Public License |
13 | * free of the rightful claim of any third person regarding infringement | 15 | * along with this program; if not, write the Free Software Foundation, |
14 | * or the like. Any license provided herein, whether implied or | 16 | * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
15 | * otherwise, applies only to this software file. Patent licenses, if | ||
16 | * any, provided herein do not apply to combinations of this program with | ||
17 | * other software, or any other product whatsoever. | ||
18 | * | ||
19 | * You should have received a copy of the GNU General Public License along | ||
20 | * with this program; if not, write the Free Software Foundation, Inc., 59 | ||
21 | * Temple Place - Suite 330, Boston MA 02111-1307, USA. | ||
22 | * | ||
23 | * Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy, | ||
24 | * Mountain View, CA 94043, or: | ||
25 | * | ||
26 | * http://www.sgi.com | ||
27 | * | ||
28 | * For further information regarding this notice, see: | ||
29 | * | ||
30 | * http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/ | ||
31 | */ | 17 | */ |
32 | |||
33 | #include "xfs.h" | 18 | #include "xfs.h" |
34 | #include "xfs_fs.h" | 19 | #include "xfs_fs.h" |
35 | #include "xfs_inum.h" | 20 | #include "xfs_bit.h" |
36 | #include "xfs_log.h" | 21 | #include "xfs_log.h" |
22 | #include "xfs_inum.h" | ||
37 | #include "xfs_trans.h" | 23 | #include "xfs_trans.h" |
38 | #include "xfs_sb.h" | 24 | #include "xfs_sb.h" |
39 | #include "xfs_ag.h" | 25 | #include "xfs_ag.h" |
@@ -43,21 +29,20 @@ | |||
43 | #include "xfs_dmapi.h" | 29 | #include "xfs_dmapi.h" |
44 | #include "xfs_quota.h" | 30 | #include "xfs_quota.h" |
45 | #include "xfs_mount.h" | 31 | #include "xfs_mount.h" |
46 | #include "xfs_alloc_btree.h" | ||
47 | #include "xfs_bmap_btree.h" | 32 | #include "xfs_bmap_btree.h" |
33 | #include "xfs_alloc_btree.h" | ||
48 | #include "xfs_ialloc_btree.h" | 34 | #include "xfs_ialloc_btree.h" |
49 | #include "xfs_btree.h" | ||
50 | #include "xfs_ialloc.h" | ||
51 | #include "xfs_attr_sf.h" | 35 | #include "xfs_attr_sf.h" |
52 | #include "xfs_dir_sf.h" | 36 | #include "xfs_dir_sf.h" |
53 | #include "xfs_dir2_sf.h" | 37 | #include "xfs_dir2_sf.h" |
54 | #include "xfs_dinode.h" | 38 | #include "xfs_dinode.h" |
55 | #include "xfs_inode.h" | 39 | #include "xfs_inode.h" |
40 | #include "xfs_ialloc.h" | ||
41 | #include "xfs_itable.h" | ||
42 | #include "xfs_btree.h" | ||
56 | #include "xfs_bmap.h" | 43 | #include "xfs_bmap.h" |
57 | #include "xfs_bit.h" | ||
58 | #include "xfs_rtalloc.h" | 44 | #include "xfs_rtalloc.h" |
59 | #include "xfs_error.h" | 45 | #include "xfs_error.h" |
60 | #include "xfs_itable.h" | ||
61 | #include "xfs_rw.h" | 46 | #include "xfs_rw.h" |
62 | #include "xfs_acl.h" | 47 | #include "xfs_acl.h" |
63 | #include "xfs_cap.h" | 48 | #include "xfs_cap.h" |
@@ -65,7 +50,6 @@ | |||
65 | #include "xfs_attr.h" | 50 | #include "xfs_attr.h" |
66 | #include "xfs_buf_item.h" | 51 | #include "xfs_buf_item.h" |
67 | #include "xfs_trans_priv.h" | 52 | #include "xfs_trans_priv.h" |
68 | |||
69 | #include "xfs_qm.h" | 53 | #include "xfs_qm.h" |
70 | 54 | ||
71 | STATIC void xfs_trans_alloc_dqinfo(xfs_trans_t *); | 55 | STATIC void xfs_trans_alloc_dqinfo(xfs_trans_t *); |
@@ -429,25 +413,25 @@ xfs_trans_apply_dquot_deltas( | |||
429 | qtrx->qt_delrtb_delta; | 413 | qtrx->qt_delrtb_delta; |
430 | #ifdef QUOTADEBUG | 414 | #ifdef QUOTADEBUG |
431 | if (totalbdelta < 0) | 415 | if (totalbdelta < 0) |
432 | ASSERT(INT_GET(d->d_bcount, ARCH_CONVERT) >= | 416 | ASSERT(be64_to_cpu(d->d_bcount) >= |
433 | (xfs_qcnt_t) -totalbdelta); | 417 | (xfs_qcnt_t) -totalbdelta); |
434 | 418 | ||
435 | if (totalrtbdelta < 0) | 419 | if (totalrtbdelta < 0) |
436 | ASSERT(INT_GET(d->d_rtbcount, ARCH_CONVERT) >= | 420 | ASSERT(be64_to_cpu(d->d_rtbcount) >= |
437 | (xfs_qcnt_t) -totalrtbdelta); | 421 | (xfs_qcnt_t) -totalrtbdelta); |
438 | 422 | ||
439 | if (qtrx->qt_icount_delta < 0) | 423 | if (qtrx->qt_icount_delta < 0) |
440 | ASSERT(INT_GET(d->d_icount, ARCH_CONVERT) >= | 424 | ASSERT(be64_to_cpu(d->d_icount) >= |
441 | (xfs_qcnt_t) -qtrx->qt_icount_delta); | 425 | (xfs_qcnt_t) -qtrx->qt_icount_delta); |
442 | #endif | 426 | #endif |
443 | if (totalbdelta) | 427 | if (totalbdelta) |
444 | INT_MOD(d->d_bcount, ARCH_CONVERT, (xfs_qcnt_t)totalbdelta); | 428 | be64_add(&d->d_bcount, (xfs_qcnt_t)totalbdelta); |
445 | 429 | ||
446 | if (qtrx->qt_icount_delta) | 430 | if (qtrx->qt_icount_delta) |
447 | INT_MOD(d->d_icount, ARCH_CONVERT, (xfs_qcnt_t)qtrx->qt_icount_delta); | 431 | be64_add(&d->d_icount, (xfs_qcnt_t)qtrx->qt_icount_delta); |
448 | 432 | ||
449 | if (totalrtbdelta) | 433 | if (totalrtbdelta) |
450 | INT_MOD(d->d_rtbcount, ARCH_CONVERT, (xfs_qcnt_t)totalrtbdelta); | 434 | be64_add(&d->d_rtbcount, (xfs_qcnt_t)totalrtbdelta); |
451 | 435 | ||
452 | /* | 436 | /* |
453 | * Get any default limits in use. | 437 | * Get any default limits in use. |
@@ -531,11 +515,11 @@ xfs_trans_apply_dquot_deltas( | |||
531 | } | 515 | } |
532 | 516 | ||
533 | ASSERT(dqp->q_res_bcount >= | 517 | ASSERT(dqp->q_res_bcount >= |
534 | INT_GET(dqp->q_core.d_bcount, ARCH_CONVERT)); | 518 | be64_to_cpu(dqp->q_core.d_bcount)); |
535 | ASSERT(dqp->q_res_icount >= | 519 | ASSERT(dqp->q_res_icount >= |
536 | INT_GET(dqp->q_core.d_icount, ARCH_CONVERT)); | 520 | be64_to_cpu(dqp->q_core.d_icount)); |
537 | ASSERT(dqp->q_res_rtbcount >= | 521 | ASSERT(dqp->q_res_rtbcount >= |
538 | INT_GET(dqp->q_core.d_rtbcount, ARCH_CONVERT)); | 522 | be64_to_cpu(dqp->q_core.d_rtbcount)); |
539 | } | 523 | } |
540 | /* | 524 | /* |
541 | * Do the group quotas next | 525 | * Do the group quotas next |
@@ -642,26 +626,26 @@ xfs_trans_dqresv( | |||
642 | } | 626 | } |
643 | ASSERT(XFS_DQ_IS_LOCKED(dqp)); | 627 | ASSERT(XFS_DQ_IS_LOCKED(dqp)); |
644 | if (flags & XFS_TRANS_DQ_RES_BLKS) { | 628 | if (flags & XFS_TRANS_DQ_RES_BLKS) { |
645 | hardlimit = INT_GET(dqp->q_core.d_blk_hardlimit, ARCH_CONVERT); | 629 | hardlimit = be64_to_cpu(dqp->q_core.d_blk_hardlimit); |
646 | if (!hardlimit) | 630 | if (!hardlimit) |
647 | hardlimit = q->qi_bhardlimit; | 631 | hardlimit = q->qi_bhardlimit; |
648 | softlimit = INT_GET(dqp->q_core.d_blk_softlimit, ARCH_CONVERT); | 632 | softlimit = be64_to_cpu(dqp->q_core.d_blk_softlimit); |
649 | if (!softlimit) | 633 | if (!softlimit) |
650 | softlimit = q->qi_bsoftlimit; | 634 | softlimit = q->qi_bsoftlimit; |
651 | timer = INT_GET(dqp->q_core.d_btimer, ARCH_CONVERT); | 635 | timer = be32_to_cpu(dqp->q_core.d_btimer); |
652 | warns = INT_GET(dqp->q_core.d_bwarns, ARCH_CONVERT); | 636 | warns = be16_to_cpu(dqp->q_core.d_bwarns); |
653 | warnlimit = XFS_QI_BWARNLIMIT(dqp->q_mount); | 637 | warnlimit = XFS_QI_BWARNLIMIT(dqp->q_mount); |
654 | resbcountp = &dqp->q_res_bcount; | 638 | resbcountp = &dqp->q_res_bcount; |
655 | } else { | 639 | } else { |
656 | ASSERT(flags & XFS_TRANS_DQ_RES_RTBLKS); | 640 | ASSERT(flags & XFS_TRANS_DQ_RES_RTBLKS); |
657 | hardlimit = INT_GET(dqp->q_core.d_rtb_hardlimit, ARCH_CONVERT); | 641 | hardlimit = be64_to_cpu(dqp->q_core.d_rtb_hardlimit); |
658 | if (!hardlimit) | 642 | if (!hardlimit) |
659 | hardlimit = q->qi_rtbhardlimit; | 643 | hardlimit = q->qi_rtbhardlimit; |
660 | softlimit = INT_GET(dqp->q_core.d_rtb_softlimit, ARCH_CONVERT); | 644 | softlimit = be64_to_cpu(dqp->q_core.d_rtb_softlimit); |
661 | if (!softlimit) | 645 | if (!softlimit) |
662 | softlimit = q->qi_rtbsoftlimit; | 646 | softlimit = q->qi_rtbsoftlimit; |
663 | timer = INT_GET(dqp->q_core.d_rtbtimer, ARCH_CONVERT); | 647 | timer = be32_to_cpu(dqp->q_core.d_rtbtimer); |
664 | warns = INT_GET(dqp->q_core.d_rtbwarns, ARCH_CONVERT); | 648 | warns = be16_to_cpu(dqp->q_core.d_rtbwarns); |
665 | warnlimit = XFS_QI_RTBWARNLIMIT(dqp->q_mount); | 649 | warnlimit = XFS_QI_RTBWARNLIMIT(dqp->q_mount); |
666 | resbcountp = &dqp->q_res_rtbcount; | 650 | resbcountp = &dqp->q_res_rtbcount; |
667 | } | 651 | } |
@@ -700,16 +684,14 @@ xfs_trans_dqresv( | |||
700 | } | 684 | } |
701 | } | 685 | } |
702 | if (ninos > 0) { | 686 | if (ninos > 0) { |
703 | count = INT_GET(dqp->q_core.d_icount, ARCH_CONVERT); | 687 | count = be64_to_cpu(dqp->q_core.d_icount); |
704 | timer = INT_GET(dqp->q_core.d_itimer, ARCH_CONVERT); | 688 | timer = be32_to_cpu(dqp->q_core.d_itimer); |
705 | warns = INT_GET(dqp->q_core.d_iwarns, ARCH_CONVERT); | 689 | warns = be16_to_cpu(dqp->q_core.d_iwarns); |
706 | warnlimit = XFS_QI_IWARNLIMIT(dqp->q_mount); | 690 | warnlimit = XFS_QI_IWARNLIMIT(dqp->q_mount); |
707 | hardlimit = INT_GET(dqp->q_core.d_ino_hardlimit, | 691 | hardlimit = be64_to_cpu(dqp->q_core.d_ino_hardlimit); |
708 | ARCH_CONVERT); | ||
709 | if (!hardlimit) | 692 | if (!hardlimit) |
710 | hardlimit = q->qi_ihardlimit; | 693 | hardlimit = q->qi_ihardlimit; |
711 | softlimit = INT_GET(dqp->q_core.d_ino_softlimit, | 694 | softlimit = be64_to_cpu(dqp->q_core.d_ino_softlimit); |
712 | ARCH_CONVERT); | ||
713 | if (!softlimit) | 695 | if (!softlimit) |
714 | softlimit = q->qi_isoftlimit; | 696 | softlimit = q->qi_isoftlimit; |
715 | if (hardlimit > 0ULL && count >= hardlimit) { | 697 | if (hardlimit > 0ULL && count >= hardlimit) { |
@@ -756,9 +738,9 @@ xfs_trans_dqresv( | |||
756 | XFS_TRANS_DQ_RES_INOS, | 738 | XFS_TRANS_DQ_RES_INOS, |
757 | ninos); | 739 | ninos); |
758 | } | 740 | } |
759 | ASSERT(dqp->q_res_bcount >= INT_GET(dqp->q_core.d_bcount, ARCH_CONVERT)); | 741 | ASSERT(dqp->q_res_bcount >= be64_to_cpu(dqp->q_core.d_bcount)); |
760 | ASSERT(dqp->q_res_rtbcount >= INT_GET(dqp->q_core.d_rtbcount, ARCH_CONVERT)); | 742 | ASSERT(dqp->q_res_rtbcount >= be64_to_cpu(dqp->q_core.d_rtbcount)); |
761 | ASSERT(dqp->q_res_icount >= INT_GET(dqp->q_core.d_icount, ARCH_CONVERT)); | 743 | ASSERT(dqp->q_res_icount >= be64_to_cpu(dqp->q_core.d_icount)); |
762 | 744 | ||
763 | error_return: | 745 | error_return: |
764 | if (! (flags & XFS_QMOPT_DQLOCK)) { | 746 | if (! (flags & XFS_QMOPT_DQLOCK)) { |
diff --git a/fs/xfs/support/debug.c b/fs/xfs/support/debug.c index 4e1a5ec22fa3..bb6dc91ea261 100644 --- a/fs/xfs/support/debug.c +++ b/fs/xfs/support/debug.c | |||
@@ -1,38 +1,22 @@ | |||
1 | /* | 1 | /* |
2 | * Copyright (c) 2000-2003 Silicon Graphics, Inc. All Rights Reserved. | 2 | * Copyright (c) 2000-2003,2005 Silicon Graphics, Inc. |
3 | * All Rights Reserved. | ||
3 | * | 4 | * |
4 | * This program is free software; you can redistribute it and/or modify it | 5 | * This program is free software; you can redistribute it and/or |
5 | * under the terms of version 2 of the GNU General Public License as | 6 | * modify it under the terms of the GNU General Public License as |
6 | * published by the Free Software Foundation. | 7 | * published by the Free Software Foundation. |
7 | * | 8 | * |
8 | * This program is distributed in the hope that it would be useful, but | 9 | * This program is distributed in the hope that it would be useful, |
9 | * WITHOUT ANY WARRANTY; without even the implied warranty of | 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
12 | * GNU General Public License for more details. | ||
11 | * | 13 | * |
12 | * Further, this software is distributed without any warranty that it is | 14 | * You should have received a copy of the GNU General Public License |
13 | * free of the rightful claim of any third person regarding infringement | 15 | * along with this program; if not, write the Free Software Foundation, |
14 | * or the like. Any license provided herein, whether implied or | 16 | * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
15 | * otherwise, applies only to this software file. Patent licenses, if | ||
16 | * any, provided herein do not apply to combinations of this program with | ||
17 | * other software, or any other product whatsoever. | ||
18 | * | ||
19 | * You should have received a copy of the GNU General Public License along | ||
20 | * with this program; if not, write the Free Software Foundation, Inc., 59 | ||
21 | * Temple Place - Suite 330, Boston MA 02111-1307, USA. | ||
22 | * | ||
23 | * Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy, | ||
24 | * Mountain View, CA 94043, or: | ||
25 | * | ||
26 | * http://www.sgi.com | ||
27 | * | ||
28 | * For further information regarding this notice, see: | ||
29 | * | ||
30 | * http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/ | ||
31 | */ | 17 | */ |
32 | |||
33 | #include "debug.h" | 18 | #include "debug.h" |
34 | #include "spin.h" | 19 | #include "spin.h" |
35 | |||
36 | #include <asm/page.h> | 20 | #include <asm/page.h> |
37 | #include <linux/sched.h> | 21 | #include <linux/sched.h> |
38 | #include <linux/kernel.h> | 22 | #include <linux/kernel.h> |
diff --git a/fs/xfs/support/debug.h b/fs/xfs/support/debug.h index c5b9365a7e2a..aff558664c32 100644 --- a/fs/xfs/support/debug.h +++ b/fs/xfs/support/debug.h | |||
@@ -1,33 +1,19 @@ | |||
1 | /* | 1 | /* |
2 | * Copyright (c) 2000-2004 Silicon Graphics, Inc. All Rights Reserved. | 2 | * Copyright (c) 2000-2005 Silicon Graphics, Inc. |
3 | * All Rights Reserved. | ||
3 | * | 4 | * |
4 | * This program is free software; you can redistribute it and/or modify it | 5 | * This program is free software; you can redistribute it and/or |
5 | * under the terms of version 2 of the GNU General Public License as | 6 | * modify it under the terms of the GNU General Public License as |
6 | * published by the Free Software Foundation. | 7 | * published by the Free Software Foundation. |
7 | * | 8 | * |
8 | * This program is distributed in the hope that it would be useful, but | 9 | * This program is distributed in the hope that it would be useful, |
9 | * WITHOUT ANY WARRANTY; without even the implied warranty of | 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
12 | * GNU General Public License for more details. | ||
11 | * | 13 | * |
12 | * Further, this software is distributed without any warranty that it is | 14 | * You should have received a copy of the GNU General Public License |
13 | * free of the rightful claim of any third person regarding infringement | 15 | * along with this program; if not, write the Free Software Foundation, |
14 | * or the like. Any license provided herein, whether implied or | 16 | * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
15 | * otherwise, applies only to this software file. Patent licenses, if | ||
16 | * any, provided herein do not apply to combinations of this program with | ||
17 | * other software, or any other product whatsoever. | ||
18 | * | ||
19 | * You should have received a copy of the GNU General Public License along | ||
20 | * with this program; if not, write the Free Software Foundation, Inc., 59 | ||
21 | * Temple Place - Suite 330, Boston MA 02111-1307, USA. | ||
22 | * | ||
23 | * Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy, | ||
24 | * Mountain View, CA 94043, or: | ||
25 | * | ||
26 | * http://www.sgi.com | ||
27 | * | ||
28 | * For further information regarding this notice, see: | ||
29 | * | ||
30 | * http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/ | ||
31 | */ | 17 | */ |
32 | #ifndef __XFS_SUPPORT_DEBUG_H__ | 18 | #ifndef __XFS_SUPPORT_DEBUG_H__ |
33 | #define __XFS_SUPPORT_DEBUG_H__ | 19 | #define __XFS_SUPPORT_DEBUG_H__ |
@@ -41,9 +27,10 @@ | |||
41 | #define CE_ALERT 1 /* alert */ | 27 | #define CE_ALERT 1 /* alert */ |
42 | #define CE_PANIC 0 /* panic */ | 28 | #define CE_PANIC 0 /* panic */ |
43 | 29 | ||
44 | extern void icmn_err(int, char *, va_list); | 30 | extern void icmn_err(int, char *, va_list) |
45 | /* PRINTFLIKE2 */ | 31 | __attribute__ ((format (printf, 2, 0))); |
46 | extern void cmn_err(int, char *, ...); | 32 | extern void cmn_err(int, char *, ...) |
33 | __attribute__ ((format (printf, 2, 3))); | ||
47 | 34 | ||
48 | #ifndef STATIC | 35 | #ifndef STATIC |
49 | # define STATIC static | 36 | # define STATIC static |
diff --git a/fs/xfs/support/ktrace.c b/fs/xfs/support/ktrace.c index fa8394f9437d..841aa4c15b8a 100644 --- a/fs/xfs/support/ktrace.c +++ b/fs/xfs/support/ktrace.c | |||
@@ -1,35 +1,20 @@ | |||
1 | /* | 1 | /* |
2 | * Copyright (c) 2000-2003 Silicon Graphics, Inc. All Rights Reserved. | 2 | * Copyright (c) 2000-2003,2005 Silicon Graphics, Inc. |
3 | * All Rights Reserved. | ||
3 | * | 4 | * |
4 | * This program is free software; you can redistribute it and/or modify it | 5 | * This program is free software; you can redistribute it and/or |
5 | * under the terms of version 2 of the GNU General Public License as | 6 | * modify it under the terms of the GNU General Public License as |
6 | * published by the Free Software Foundation. | 7 | * published by the Free Software Foundation. |
7 | * | 8 | * |
8 | * This program is distributed in the hope that it would be useful, but | 9 | * This program is distributed in the hope that it would be useful, |
9 | * WITHOUT ANY WARRANTY; without even the implied warranty of | 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
12 | * GNU General Public License for more details. | ||
11 | * | 13 | * |
12 | * Further, this software is distributed without any warranty that it is | 14 | * You should have received a copy of the GNU General Public License |
13 | * free of the rightful claim of any third person regarding infringement | 15 | * along with this program; if not, write the Free Software Foundation, |
14 | * or the like. Any license provided herein, whether implied or | 16 | * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
15 | * otherwise, applies only to this software file. Patent licenses, if | ||
16 | * any, provided herein do not apply to combinations of this program with | ||
17 | * other software, or any other product whatsoever. | ||
18 | * | ||
19 | * You should have received a copy of the GNU General Public License along | ||
20 | * with this program; if not, write the Free Software Foundation, Inc., 59 | ||
21 | * Temple Place - Suite 330, Boston MA 02111-1307, USA. | ||
22 | * | ||
23 | * Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy, | ||
24 | * Mountain View, CA 94043, or: | ||
25 | * | ||
26 | * http://www.sgi.com | ||
27 | * | ||
28 | * For further information regarding this notice, see: | ||
29 | * | ||
30 | * http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/ | ||
31 | */ | 17 | */ |
32 | |||
33 | #include <xfs.h> | 18 | #include <xfs.h> |
34 | 19 | ||
35 | static kmem_zone_t *ktrace_hdr_zone; | 20 | static kmem_zone_t *ktrace_hdr_zone; |
@@ -65,7 +50,7 @@ ktrace_uninit(void) | |||
65 | * number of entries. | 50 | * number of entries. |
66 | */ | 51 | */ |
67 | ktrace_t * | 52 | ktrace_t * |
68 | ktrace_alloc(int nentries, int sleep) | 53 | ktrace_alloc(int nentries, unsigned int __nocast sleep) |
69 | { | 54 | { |
70 | ktrace_t *ktp; | 55 | ktrace_t *ktp; |
71 | ktrace_entry_t *ktep; | 56 | ktrace_entry_t *ktep; |
diff --git a/fs/xfs/support/ktrace.h b/fs/xfs/support/ktrace.h index 92d1a1a5d04b..0d73216287c0 100644 --- a/fs/xfs/support/ktrace.h +++ b/fs/xfs/support/ktrace.h | |||
@@ -1,33 +1,19 @@ | |||
1 | /* | 1 | /* |
2 | * Copyright (c) 2000-2003 Silicon Graphics, Inc. All Rights Reserved. | 2 | * Copyright (c) 2000-2003,2005 Silicon Graphics, Inc. |
3 | * All Rights Reserved. | ||
3 | * | 4 | * |
4 | * This program is free software; you can redistribute it and/or modify it | 5 | * This program is free software; you can redistribute it and/or |
5 | * under the terms of version 2 of the GNU General Public License as | 6 | * modify it under the terms of the GNU General Public License as |
6 | * published by the Free Software Foundation. | 7 | * published by the Free Software Foundation. |
7 | * | 8 | * |
8 | * This program is distributed in the hope that it would be useful, but | 9 | * This program is distributed in the hope that it would be useful, |
9 | * WITHOUT ANY WARRANTY; without even the implied warranty of | 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
12 | * GNU General Public License for more details. | ||
11 | * | 13 | * |
12 | * Further, this software is distributed without any warranty that it is | 14 | * You should have received a copy of the GNU General Public License |
13 | * free of the rightful claim of any third person regarding infringement | 15 | * along with this program; if not, write the Free Software Foundation, |
14 | * or the like. Any license provided herein, whether implied or | 16 | * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
15 | * otherwise, applies only to this software file. Patent licenses, if | ||
16 | * any, provided herein do not apply to combinations of this program with | ||
17 | * other software, or any other product whatsoever. | ||
18 | * | ||
19 | * You should have received a copy of the GNU General Public License along | ||
20 | * with this program; if not, write the Free Software Foundation, Inc., 59 | ||
21 | * Temple Place - Suite 330, Boston MA 02111-1307, USA. | ||
22 | * | ||
23 | * Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy, | ||
24 | * Mountain View, CA 94043, or: | ||
25 | * | ||
26 | * http://www.sgi.com | ||
27 | * | ||
28 | * For further information regarding this notice, see: | ||
29 | * | ||
30 | * http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/ | ||
31 | */ | 17 | */ |
32 | #ifndef __XFS_SUPPORT_KTRACE_H__ | 18 | #ifndef __XFS_SUPPORT_KTRACE_H__ |
33 | #define __XFS_SUPPORT_KTRACE_H__ | 19 | #define __XFS_SUPPORT_KTRACE_H__ |
@@ -66,7 +52,7 @@ typedef struct ktrace_snap { | |||
66 | extern void ktrace_init(int zentries); | 52 | extern void ktrace_init(int zentries); |
67 | extern void ktrace_uninit(void); | 53 | extern void ktrace_uninit(void); |
68 | 54 | ||
69 | extern ktrace_t *ktrace_alloc(int, int); | 55 | extern ktrace_t *ktrace_alloc(int, unsigned int __nocast); |
70 | extern void ktrace_free(ktrace_t *); | 56 | extern void ktrace_free(ktrace_t *); |
71 | 57 | ||
72 | extern void ktrace_enter( | 58 | extern void ktrace_enter( |
diff --git a/fs/xfs/support/move.c b/fs/xfs/support/move.c index 15b5194f16b2..caefa17b80fe 100644 --- a/fs/xfs/support/move.c +++ b/fs/xfs/support/move.c | |||
@@ -1,35 +1,20 @@ | |||
1 | /* | 1 | /* |
2 | * Copyright (c) 2000-2003 Silicon Graphics, Inc. All Rights Reserved. | 2 | * Copyright (c) 2000-2003,2005 Silicon Graphics, Inc. |
3 | * All Rights Reserved. | ||
3 | * | 4 | * |
4 | * This program is free software; you can redistribute it and/or modify it | 5 | * This program is free software; you can redistribute it and/or |
5 | * under the terms of version 2 of the GNU General Public License as | 6 | * modify it under the terms of the GNU General Public License as |
6 | * published by the Free Software Foundation. | 7 | * published by the Free Software Foundation. |
7 | * | 8 | * |
8 | * This program is distributed in the hope that it would be useful, but | 9 | * This program is distributed in the hope that it would be useful, |
9 | * WITHOUT ANY WARRANTY; without even the implied warranty of | 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
12 | * GNU General Public License for more details. | ||
11 | * | 13 | * |
12 | * Further, this software is distributed without any warranty that it is | 14 | * You should have received a copy of the GNU General Public License |
13 | * free of the rightful claim of any third person regarding infringement | 15 | * along with this program; if not, write the Free Software Foundation, |
14 | * or the like. Any license provided herein, whether implied or | 16 | * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
15 | * otherwise, applies only to this software file. Patent licenses, if | ||
16 | * any, provided herein do not apply to combinations of this program with | ||
17 | * other software, or any other product whatsoever. | ||
18 | * | ||
19 | * You should have received a copy of the GNU General Public License along | ||
20 | * with this program; if not, write the Free Software Foundation, Inc., 59 | ||
21 | * Temple Place - Suite 330, Boston MA 02111-1307, USA. | ||
22 | * | ||
23 | * Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy, | ||
24 | * Mountain View, CA 94043, or: | ||
25 | * | ||
26 | * http://www.sgi.com | ||
27 | * | ||
28 | * For further information regarding this notice, see: | ||
29 | * | ||
30 | * http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/ | ||
31 | */ | 17 | */ |
32 | |||
33 | #include <xfs.h> | 18 | #include <xfs.h> |
34 | 19 | ||
35 | /* Read from kernel buffer at src to user/kernel buffer defined | 20 | /* Read from kernel buffer at src to user/kernel buffer defined |
diff --git a/fs/xfs/support/move.h b/fs/xfs/support/move.h index 3d406dc1c89e..97a2498d2da3 100644 --- a/fs/xfs/support/move.h +++ b/fs/xfs/support/move.h | |||
@@ -1,34 +1,20 @@ | |||
1 | /* | 1 | /* |
2 | * Copyright (c) 2000-2003 Silicon Graphics, Inc. All Rights Reserved. | 2 | * Copyright (c) 2000-2003,2005 Silicon Graphics, Inc. |
3 | * All Rights Reserved. | ||
3 | * | 4 | * |
4 | * This program is free software; you can redistribute it and/or modify it | 5 | * This program is free software; you can redistribute it and/or |
5 | * under the terms of version 2 of the GNU General Public License as | 6 | * modify it under the terms of the GNU General Public License as |
6 | * published by the Free Software Foundation. | 7 | * published by the Free Software Foundation. |
7 | * | 8 | * |
8 | * This program is distributed in the hope that it would be useful, but | 9 | * This program is distributed in the hope that it would be useful, |
9 | * WITHOUT ANY WARRANTY; without even the implied warranty of | 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
12 | * GNU General Public License for more details. | ||
11 | * | 13 | * |
12 | * Further, this software is distributed without any warranty that it is | 14 | * You should have received a copy of the GNU General Public License |
13 | * free of the rightful claim of any third person regarding infringement | 15 | * along with this program; if not, write the Free Software Foundation, |
14 | * or the like. Any license provided herein, whether implied or | 16 | * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
15 | * otherwise, applies only to this software file. Patent licenses, if | ||
16 | * any, provided herein do not apply to combinations of this program with | ||
17 | * other software, or any other product whatsoever. | ||
18 | * | 17 | * |
19 | * You should have received a copy of the GNU General Public License along | ||
20 | * with this program; if not, write the Free Software Foundation, Inc., 59 | ||
21 | * Temple Place - Suite 330, Boston MA 02111-1307, USA. | ||
22 | * | ||
23 | * Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy, | ||
24 | * Mountain View, CA 94043, or: | ||
25 | * | ||
26 | * http://www.sgi.com | ||
27 | * | ||
28 | * For further information regarding this notice, see: | ||
29 | * | ||
30 | * http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/ | ||
31 | * | ||
32 | * Portions Copyright (c) 1982, 1986, 1993, 1994 | 18 | * Portions Copyright (c) 1982, 1986, 1993, 1994 |
33 | * The Regents of the University of California. All rights reserved. | 19 | * The Regents of the University of California. All rights reserved. |
34 | * | 20 | * |
diff --git a/fs/xfs/support/qsort.c b/fs/xfs/support/qsort.c deleted file mode 100644 index 1ec824140cf7..000000000000 --- a/fs/xfs/support/qsort.c +++ /dev/null | |||
@@ -1,155 +0,0 @@ | |||
1 | /* | ||
2 | * Copyright (c) 1992, 1993 | ||
3 | * The Regents of the University of California. All rights reserved. | ||
4 | * | ||
5 | * Redistribution and use in source and binary forms, with or without | ||
6 | * modification, are permitted provided that the following conditions | ||
7 | * are met: | ||
8 | * 1. Redistributions of source code must retain the above copyright | ||
9 | * notice, this list of conditions and the following disclaimer. | ||
10 | * 2. Redistributions in binary form must reproduce the above copyright | ||
11 | * notice, this list of conditions and the following disclaimer in the | ||
12 | * documentation and/or other materials provided with the distribution. | ||
13 | * 3. Neither the name of the University nor the names of its contributors | ||
14 | * may be used to endorse or promote products derived from this software | ||
15 | * without specific prior written permission. | ||
16 | * | ||
17 | * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND | ||
18 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | ||
19 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | ||
20 | * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE | ||
21 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | ||
22 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | ||
23 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | ||
24 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | ||
25 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | ||
26 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | ||
27 | * SUCH DAMAGE. | ||
28 | */ | ||
29 | |||
30 | #include <linux/kernel.h> | ||
31 | #include <linux/string.h> | ||
32 | |||
33 | /* | ||
34 | * Qsort routine from Bentley & McIlroy's "Engineering a Sort Function". | ||
35 | */ | ||
36 | #define swapcode(TYPE, parmi, parmj, n) { \ | ||
37 | long i = (n) / sizeof (TYPE); \ | ||
38 | register TYPE *pi = (TYPE *) (parmi); \ | ||
39 | register TYPE *pj = (TYPE *) (parmj); \ | ||
40 | do { \ | ||
41 | register TYPE t = *pi; \ | ||
42 | *pi++ = *pj; \ | ||
43 | *pj++ = t; \ | ||
44 | } while (--i > 0); \ | ||
45 | } | ||
46 | |||
47 | #define SWAPINIT(a, es) swaptype = ((char *)a - (char *)0) % sizeof(long) || \ | ||
48 | es % sizeof(long) ? 2 : es == sizeof(long)? 0 : 1; | ||
49 | |||
50 | static __inline void | ||
51 | swapfunc(char *a, char *b, int n, int swaptype) | ||
52 | { | ||
53 | if (swaptype <= 1) | ||
54 | swapcode(long, a, b, n) | ||
55 | else | ||
56 | swapcode(char, a, b, n) | ||
57 | } | ||
58 | |||
59 | #define swap(a, b) \ | ||
60 | if (swaptype == 0) { \ | ||
61 | long t = *(long *)(a); \ | ||
62 | *(long *)(a) = *(long *)(b); \ | ||
63 | *(long *)(b) = t; \ | ||
64 | } else \ | ||
65 | swapfunc(a, b, es, swaptype) | ||
66 | |||
67 | #define vecswap(a, b, n) if ((n) > 0) swapfunc(a, b, n, swaptype) | ||
68 | |||
69 | static __inline char * | ||
70 | med3(char *a, char *b, char *c, int (*cmp)(const void *, const void *)) | ||
71 | { | ||
72 | return cmp(a, b) < 0 ? | ||
73 | (cmp(b, c) < 0 ? b : (cmp(a, c) < 0 ? c : a )) | ||
74 | :(cmp(b, c) > 0 ? b : (cmp(a, c) < 0 ? a : c )); | ||
75 | } | ||
76 | |||
77 | void | ||
78 | qsort(void *aa, size_t n, size_t es, int (*cmp)(const void *, const void *)) | ||
79 | { | ||
80 | char *pa, *pb, *pc, *pd, *pl, *pm, *pn; | ||
81 | int d, r, swaptype, swap_cnt; | ||
82 | register char *a = aa; | ||
83 | |||
84 | loop: SWAPINIT(a, es); | ||
85 | swap_cnt = 0; | ||
86 | if (n < 7) { | ||
87 | for (pm = (char *)a + es; pm < (char *) a + n * es; pm += es) | ||
88 | for (pl = pm; pl > (char *) a && cmp(pl - es, pl) > 0; | ||
89 | pl -= es) | ||
90 | swap(pl, pl - es); | ||
91 | return; | ||
92 | } | ||
93 | pm = (char *)a + (n / 2) * es; | ||
94 | if (n > 7) { | ||
95 | pl = (char *)a; | ||
96 | pn = (char *)a + (n - 1) * es; | ||
97 | if (n > 40) { | ||
98 | d = (n / 8) * es; | ||
99 | pl = med3(pl, pl + d, pl + 2 * d, cmp); | ||
100 | pm = med3(pm - d, pm, pm + d, cmp); | ||
101 | pn = med3(pn - 2 * d, pn - d, pn, cmp); | ||
102 | } | ||
103 | pm = med3(pl, pm, pn, cmp); | ||
104 | } | ||
105 | swap(a, pm); | ||
106 | pa = pb = (char *)a + es; | ||
107 | |||
108 | pc = pd = (char *)a + (n - 1) * es; | ||
109 | for (;;) { | ||
110 | while (pb <= pc && (r = cmp(pb, a)) <= 0) { | ||
111 | if (r == 0) { | ||
112 | swap_cnt = 1; | ||
113 | swap(pa, pb); | ||
114 | pa += es; | ||
115 | } | ||
116 | pb += es; | ||
117 | } | ||
118 | while (pb <= pc && (r = cmp(pc, a)) >= 0) { | ||
119 | if (r == 0) { | ||
120 | swap_cnt = 1; | ||
121 | swap(pc, pd); | ||
122 | pd -= es; | ||
123 | } | ||
124 | pc -= es; | ||
125 | } | ||
126 | if (pb > pc) | ||
127 | break; | ||
128 | swap(pb, pc); | ||
129 | swap_cnt = 1; | ||
130 | pb += es; | ||
131 | pc -= es; | ||
132 | } | ||
133 | if (swap_cnt == 0) { /* Switch to insertion sort */ | ||
134 | for (pm = (char *) a + es; pm < (char *) a + n * es; pm += es) | ||
135 | for (pl = pm; pl > (char *) a && cmp(pl - es, pl) > 0; | ||
136 | pl -= es) | ||
137 | swap(pl, pl - es); | ||
138 | return; | ||
139 | } | ||
140 | |||
141 | pn = (char *)a + n * es; | ||
142 | r = min(pa - (char *)a, pb - pa); | ||
143 | vecswap(a, pb - r, r); | ||
144 | r = min((long)(pd - pc), (long)(pn - pd - es)); | ||
145 | vecswap(pb, pn - r, r); | ||
146 | if ((r = pb - pa) > es) | ||
147 | qsort(a, r / es, es, cmp); | ||
148 | if ((r = pd - pc) > es) { | ||
149 | /* Iterate rather than recurse to save stack space */ | ||
150 | a = pn - r; | ||
151 | n = r / es; | ||
152 | goto loop; | ||
153 | } | ||
154 | /* qsort(pn - r, r / es, es, cmp);*/ | ||
155 | } | ||
diff --git a/fs/xfs/support/qsort.h b/fs/xfs/support/qsort.h deleted file mode 100644 index 94263106d716..000000000000 --- a/fs/xfs/support/qsort.h +++ /dev/null | |||
@@ -1,41 +0,0 @@ | |||
1 | /* | ||
2 | * Copyright (c) 2000-2002 Silicon Graphics, Inc. All Rights Reserved. | ||
3 | * | ||
4 | * This program is free software; you can redistribute it and/or modify it | ||
5 | * under the terms of version 2 of the GNU General Public License as | ||
6 | * published by the Free Software Foundation. | ||
7 | * | ||
8 | * This program is distributed in the hope that it would be useful, but | ||
9 | * WITHOUT ANY WARRANTY; without even the implied warranty of | ||
10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | ||
11 | * | ||
12 | * Further, this software is distributed without any warranty that it is | ||
13 | * free of the rightful claim of any third person regarding infringement | ||
14 | * or the like. Any license provided herein, whether implied or | ||
15 | * otherwise, applies only to this software file. Patent licenses, if | ||
16 | * any, provided herein do not apply to combinations of this program with | ||
17 | * other software, or any other product whatsoever. | ||
18 | * | ||
19 | * You should have received a copy of the GNU General Public License along | ||
20 | * with this program; if not, write the Free Software Foundation, Inc., 59 | ||
21 | * Temple Place - Suite 330, Boston MA 02111-1307, USA. | ||
22 | * | ||
23 | * Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy, | ||
24 | * Mountain View, CA 94043, or: | ||
25 | * | ||
26 | * http://www.sgi.com | ||
27 | * | ||
28 | * For further information regarding this notice, see: | ||
29 | * | ||
30 | * http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/ | ||
31 | */ | ||
32 | |||
33 | #ifndef QSORT_H | ||
34 | #define QSORT_H | ||
35 | |||
36 | extern void qsort (void *const pbase, | ||
37 | size_t total_elems, | ||
38 | size_t size, | ||
39 | int (*cmp)(const void *, const void *)); | ||
40 | |||
41 | #endif | ||
diff --git a/fs/xfs/support/uuid.c b/fs/xfs/support/uuid.c index 81f40cfcb267..70ce40914c8a 100644 --- a/fs/xfs/support/uuid.c +++ b/fs/xfs/support/uuid.c | |||
@@ -1,35 +1,20 @@ | |||
1 | /* | 1 | /* |
2 | * Copyright (c) 2000-2003 Silicon Graphics, Inc. All Rights Reserved. | 2 | * Copyright (c) 2000-2003,2005 Silicon Graphics, Inc. |
3 | * All Rights Reserved. | ||
3 | * | 4 | * |
4 | * This program is free software; you can redistribute it and/or modify it | 5 | * This program is free software; you can redistribute it and/or |
5 | * under the terms of version 2 of the GNU General Public License as | 6 | * modify it under the terms of the GNU General Public License as |
6 | * published by the Free Software Foundation. | 7 | * published by the Free Software Foundation. |
7 | * | 8 | * |
8 | * This program is distributed in the hope that it would be useful, but | 9 | * This program is distributed in the hope that it would be useful, |
9 | * WITHOUT ANY WARRANTY; without even the implied warranty of | 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
12 | * GNU General Public License for more details. | ||
11 | * | 13 | * |
12 | * Further, this software is distributed without any warranty that it is | 14 | * You should have received a copy of the GNU General Public License |
13 | * free of the rightful claim of any third person regarding infringement | 15 | * along with this program; if not, write the Free Software Foundation, |
14 | * or the like. Any license provided herein, whether implied or | 16 | * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
15 | * otherwise, applies only to this software file. Patent licenses, if | ||
16 | * any, provided herein do not apply to combinations of this program with | ||
17 | * other software, or any other product whatsoever. | ||
18 | * | ||
19 | * You should have received a copy of the GNU General Public License along | ||
20 | * with this program; if not, write the Free Software Foundation, Inc., 59 | ||
21 | * Temple Place - Suite 330, Boston MA 02111-1307, USA. | ||
22 | * | ||
23 | * Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy, | ||
24 | * Mountain View, CA 94043, or: | ||
25 | * | ||
26 | * http://www.sgi.com | ||
27 | * | ||
28 | * For further information regarding this notice, see: | ||
29 | * | ||
30 | * http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/ | ||
31 | */ | 17 | */ |
32 | |||
33 | #include <xfs.h> | 18 | #include <xfs.h> |
34 | 19 | ||
35 | static mutex_t uuid_monitor; | 20 | static mutex_t uuid_monitor; |
diff --git a/fs/xfs/support/uuid.h b/fs/xfs/support/uuid.h index 5220ea58ba2b..b6f5922199ba 100644 --- a/fs/xfs/support/uuid.h +++ b/fs/xfs/support/uuid.h | |||
@@ -1,33 +1,19 @@ | |||
1 | /* | 1 | /* |
2 | * Copyright (c) 2000-2003 Silicon Graphics, Inc. All Rights Reserved. | 2 | * Copyright (c) 2000-2003,2005 Silicon Graphics, Inc. |
3 | * All Rights Reserved. | ||
3 | * | 4 | * |
4 | * This program is free software; you can redistribute it and/or modify it | 5 | * This program is free software; you can redistribute it and/or |
5 | * under the terms of version 2 of the GNU General Public License as | 6 | * modify it under the terms of the GNU General Public License as |
6 | * published by the Free Software Foundation. | 7 | * published by the Free Software Foundation. |
7 | * | 8 | * |
8 | * This program is distributed in the hope that it would be useful, but | 9 | * This program is distributed in the hope that it would be useful, |
9 | * WITHOUT ANY WARRANTY; without even the implied warranty of | 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
12 | * GNU General Public License for more details. | ||
11 | * | 13 | * |
12 | * Further, this software is distributed without any warranty that it is | 14 | * You should have received a copy of the GNU General Public License |
13 | * free of the rightful claim of any third person regarding infringement | 15 | * along with this program; if not, write the Free Software Foundation, |
14 | * or the like. Any license provided herein, whether implied or | 16 | * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
15 | * otherwise, applies only to this software file. Patent licenses, if | ||
16 | * any, provided herein do not apply to combinations of this program with | ||
17 | * other software, or any other product whatsoever. | ||
18 | * | ||
19 | * You should have received a copy of the GNU General Public License along | ||
20 | * with this program; if not, write the Free Software Foundation, Inc., 59 | ||
21 | * Temple Place - Suite 330, Boston MA 02111-1307, USA. | ||
22 | * | ||
23 | * Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy, | ||
24 | * Mountain View, CA 94043, or: | ||
25 | * | ||
26 | * http://www.sgi.com | ||
27 | * | ||
28 | * For further information regarding this notice, see: | ||
29 | * | ||
30 | * http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/ | ||
31 | */ | 17 | */ |
32 | #ifndef __XFS_SUPPORT_UUID_H__ | 18 | #ifndef __XFS_SUPPORT_UUID_H__ |
33 | #define __XFS_SUPPORT_UUID_H__ | 19 | #define __XFS_SUPPORT_UUID_H__ |
@@ -36,13 +22,13 @@ typedef struct { | |||
36 | unsigned char __u_bits[16]; | 22 | unsigned char __u_bits[16]; |
37 | } uuid_t; | 23 | } uuid_t; |
38 | 24 | ||
39 | void uuid_init(void); | 25 | extern void uuid_init(void); |
40 | void uuid_create_nil(uuid_t *uuid); | 26 | extern void uuid_create_nil(uuid_t *uuid); |
41 | int uuid_is_nil(uuid_t *uuid); | 27 | extern int uuid_is_nil(uuid_t *uuid); |
42 | int uuid_equal(uuid_t *uuid1, uuid_t *uuid2); | 28 | extern int uuid_equal(uuid_t *uuid1, uuid_t *uuid2); |
43 | void uuid_getnodeuniq(uuid_t *uuid, int fsid [2]); | 29 | extern void uuid_getnodeuniq(uuid_t *uuid, int fsid [2]); |
44 | __uint64_t uuid_hash64(uuid_t *uuid); | 30 | extern __uint64_t uuid_hash64(uuid_t *uuid); |
45 | int uuid_table_insert(uuid_t *uuid); | 31 | extern int uuid_table_insert(uuid_t *uuid); |
46 | void uuid_table_remove(uuid_t *uuid); | 32 | extern void uuid_table_remove(uuid_t *uuid); |
47 | 33 | ||
48 | #endif /* __XFS_SUPPORT_UUID_H__ */ | 34 | #endif /* __XFS_SUPPORT_UUID_H__ */ |
diff --git a/fs/xfs/xfs.h b/fs/xfs/xfs.h index 7e276dcaf4dc..1a48dbb902a7 100644 --- a/fs/xfs/xfs.h +++ b/fs/xfs/xfs.h | |||
@@ -1,40 +1,21 @@ | |||
1 | /* | 1 | /* |
2 | * Copyright (c) 2000-2004 Silicon Graphics, Inc. All Rights Reserved. | 2 | * Copyright (c) 2000-2003,2005 Silicon Graphics, Inc. |
3 | * All Rights Reserved. | ||
3 | * | 4 | * |
4 | * This program is free software; you can redistribute it and/or modify it | 5 | * This program is free software; you can redistribute it and/or |
5 | * under the terms of version 2 of the GNU General Public License as | 6 | * modify it under the terms of the GNU General Public License as |
6 | * published by the Free Software Foundation. | 7 | * published by the Free Software Foundation. |
7 | * | 8 | * |
8 | * This program is distributed in the hope that it would be useful, but | 9 | * This program is distributed in the hope that it would be useful, |
9 | * WITHOUT ANY WARRANTY; without even the implied warranty of | 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
12 | * GNU General Public License for more details. | ||
11 | * | 13 | * |
12 | * Further, this software is distributed without any warranty that it is | 14 | * You should have received a copy of the GNU General Public License |
13 | * free of the rightful claim of any third person regarding infringement | 15 | * along with this program; if not, write the Free Software Foundation, |
14 | * or the like. Any license provided herein, whether implied or | 16 | * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
15 | * otherwise, applies only to this software file. Patent licenses, if | ||
16 | * any, provided herein do not apply to combinations of this program with | ||
17 | * other software, or any other product whatsoever. | ||
18 | * | ||
19 | * You should have received a copy of the GNU General Public License along | ||
20 | * with this program; if not, write the Free Software Foundation, Inc., 59 | ||
21 | * Temple Place - Suite 330, Boston MA 02111-1307, USA. | ||
22 | * | ||
23 | * Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy, | ||
24 | * Mountain View, CA 94043, or: | ||
25 | * | ||
26 | * http://www.sgi.com | ||
27 | * | ||
28 | * For further information regarding this notice, see: | ||
29 | * | ||
30 | * http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/ | ||
31 | */ | 17 | */ |
32 | #ifndef __XFS_H__ | 18 | #ifndef __XFS_H__ |
33 | #define __XFS_H__ | 19 | #define __XFS_H__ |
34 | |||
35 | #include <linux-2.6/xfs_linux.h> | 20 | #include <linux-2.6/xfs_linux.h> |
36 | |||
37 | #include <xfs_fs.h> | ||
38 | #include <xfs_macros.h> | ||
39 | |||
40 | #endif /* __XFS_H__ */ | 21 | #endif /* __XFS_H__ */ |
diff --git a/fs/xfs/xfs_acl.c b/fs/xfs/xfs_acl.c index 92fd1d67f878..cc9c91b9e771 100644 --- a/fs/xfs/xfs_acl.c +++ b/fs/xfs/xfs_acl.c | |||
@@ -1,49 +1,37 @@ | |||
1 | /* | 1 | /* |
2 | * Copyright (c) 2001-2002 Silicon Graphics, Inc. All Rights Reserved. | 2 | * Copyright (c) 2001-2002,2005 Silicon Graphics, Inc. |
3 | * All Rights Reserved. | ||
3 | * | 4 | * |
4 | * This program is free software; you can redistribute it and/or modify it | 5 | * This program is free software; you can redistribute it and/or |
5 | * under the terms of version 2 of the GNU General Public License as | 6 | * modify it under the terms of the GNU General Public License as |
6 | * published by the Free Software Foundation. | 7 | * published by the Free Software Foundation. |
7 | * | 8 | * |
8 | * This program is distributed in the hope that it would be useful, but | 9 | * This program is distributed in the hope that it would be useful, |
9 | * WITHOUT ANY WARRANTY; without even the implied warranty of | 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
12 | * GNU General Public License for more details. | ||
11 | * | 13 | * |
12 | * Further, this software is distributed without any warranty that it is | 14 | * You should have received a copy of the GNU General Public License |
13 | * free of the rightful claim of any third person regarding infringement | 15 | * along with this program; if not, write the Free Software Foundation, |
14 | * or the like. Any license provided herein, whether implied or | 16 | * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
15 | * otherwise, applies only to this software file. Patent licenses, if | ||
16 | * any, provided herein do not apply to combinations of this program with | ||
17 | * other software, or any other product whatsoever. | ||
18 | * | ||
19 | * You should have received a copy of the GNU General Public License along | ||
20 | * with this program; if not, write the Free Software Foundation, Inc., 59 | ||
21 | * Temple Place - Suite 330, Boston MA 02111-1307, USA. | ||
22 | * | ||
23 | * Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy, | ||
24 | * Mountain View, CA 94043, or: | ||
25 | * | ||
26 | * http://www.sgi.com | ||
27 | * | ||
28 | * For further information regarding this notice, see: | ||
29 | * | ||
30 | * http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/ | ||
31 | */ | 17 | */ |
32 | |||
33 | #include "xfs.h" | 18 | #include "xfs.h" |
34 | 19 | #include "xfs_fs.h" | |
20 | #include "xfs_types.h" | ||
21 | #include "xfs_bit.h" | ||
35 | #include "xfs_inum.h" | 22 | #include "xfs_inum.h" |
23 | #include "xfs_ag.h" | ||
36 | #include "xfs_dir.h" | 24 | #include "xfs_dir.h" |
37 | #include "xfs_dir2.h" | 25 | #include "xfs_dir2.h" |
38 | #include "xfs_alloc_btree.h" | ||
39 | #include "xfs_bmap_btree.h" | 26 | #include "xfs_bmap_btree.h" |
27 | #include "xfs_alloc_btree.h" | ||
40 | #include "xfs_ialloc_btree.h" | 28 | #include "xfs_ialloc_btree.h" |
41 | #include "xfs_btree.h" | ||
42 | #include "xfs_attr_sf.h" | ||
43 | #include "xfs_dir_sf.h" | 29 | #include "xfs_dir_sf.h" |
44 | #include "xfs_dir2_sf.h" | 30 | #include "xfs_dir2_sf.h" |
31 | #include "xfs_attr_sf.h" | ||
45 | #include "xfs_dinode.h" | 32 | #include "xfs_dinode.h" |
46 | #include "xfs_inode.h" | 33 | #include "xfs_inode.h" |
34 | #include "xfs_btree.h" | ||
47 | #include "xfs_acl.h" | 35 | #include "xfs_acl.h" |
48 | #include "xfs_mac.h" | 36 | #include "xfs_mac.h" |
49 | #include "xfs_attr.h" | 37 | #include "xfs_attr.h" |
@@ -155,7 +143,7 @@ posix_acl_xattr_to_xfs( | |||
155 | } | 143 | } |
156 | 144 | ||
157 | /* | 145 | /* |
158 | * Comparison function called from qsort(). | 146 | * Comparison function called from xfs_sort(). |
159 | * Primary key is ae_tag, secondary key is ae_id. | 147 | * Primary key is ae_tag, secondary key is ae_id. |
160 | */ | 148 | */ |
161 | STATIC int | 149 | STATIC int |
@@ -189,8 +177,8 @@ posix_acl_xfs_to_xattr( | |||
189 | return -ERANGE; | 177 | return -ERANGE; |
190 | 178 | ||
191 | /* Need to sort src XFS ACL by <ae_tag,ae_id> */ | 179 | /* Need to sort src XFS ACL by <ae_tag,ae_id> */ |
192 | qsort(src->acl_entry, src->acl_cnt, sizeof(src->acl_entry[0]), | 180 | xfs_sort(src->acl_entry, src->acl_cnt, sizeof(src->acl_entry[0]), |
193 | xfs_acl_entry_compare); | 181 | xfs_acl_entry_compare); |
194 | 182 | ||
195 | dest->a_version = cpu_to_le32(POSIX_ACL_XATTR_VERSION); | 183 | dest->a_version = cpu_to_le32(POSIX_ACL_XATTR_VERSION); |
196 | dest_entry = &dest->a_entries[0]; | 184 | dest_entry = &dest->a_entries[0]; |
@@ -448,6 +436,7 @@ xfs_acl_access( | |||
448 | int seen_userobj = 0; | 436 | int seen_userobj = 0; |
449 | 437 | ||
450 | matched.ae_tag = 0; /* Invalid type */ | 438 | matched.ae_tag = 0; /* Invalid type */ |
439 | matched.ae_perm = 0; | ||
451 | md >>= 6; /* Normalize the bits for comparison */ | 440 | md >>= 6; /* Normalize the bits for comparison */ |
452 | 441 | ||
453 | for (i = 0; i < fap->acl_cnt; i++) { | 442 | for (i = 0; i < fap->acl_cnt; i++) { |
diff --git a/fs/xfs/xfs_acl.h b/fs/xfs/xfs_acl.h index 0363eb46d357..f9315bc960cb 100644 --- a/fs/xfs/xfs_acl.h +++ b/fs/xfs/xfs_acl.h | |||
@@ -1,33 +1,19 @@ | |||
1 | /* | 1 | /* |
2 | * Copyright (c) 2001-2004 Silicon Graphics, Inc. All Rights Reserved. | 2 | * Copyright (c) 2001-2005 Silicon Graphics, Inc. |
3 | * All Rights Reserved. | ||
3 | * | 4 | * |
4 | * This program is free software; you can redistribute it and/or modify it | 5 | * This program is free software; you can redistribute it and/or |
5 | * under the terms of version 2 of the GNU General Public License as | 6 | * modify it under the terms of the GNU General Public License as |
6 | * published by the Free Software Foundation. | 7 | * published by the Free Software Foundation. |
7 | * | 8 | * |
8 | * This program is distributed in the hope that it would be useful, but | 9 | * This program is distributed in the hope that it would be useful, |
9 | * WITHOUT ANY WARRANTY; without even the implied warranty of | 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
12 | * GNU General Public License for more details. | ||
11 | * | 13 | * |
12 | * Further, this software is distributed without any warranty that it is | 14 | * You should have received a copy of the GNU General Public License |
13 | * free of the rightful claim of any third person regarding infringement | 15 | * along with this program; if not, write the Free Software Foundation, |
14 | * or the like. Any license provided herein, whether implied or | 16 | * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
15 | * otherwise, applies only to this software file. Patent licenses, if | ||
16 | * any, provided herein do not apply to combinations of this program with | ||
17 | * other software, or any other product whatsoever. | ||
18 | * | ||
19 | * You should have received a copy of the GNU General Public License along | ||
20 | * with this program; if not, write the Free Software Foundation, Inc., 59 | ||
21 | * Temple Place - Suite 330, Boston MA 02111-1307, USA. | ||
22 | * | ||
23 | * Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy, | ||
24 | * Mountain View, CA 94043, or: | ||
25 | * | ||
26 | * http://www.sgi.com | ||
27 | * | ||
28 | * For further information regarding this notice, see: | ||
29 | * | ||
30 | * http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/ | ||
31 | */ | 17 | */ |
32 | #ifndef __XFS_ACL_H__ | 18 | #ifndef __XFS_ACL_H__ |
33 | #define __XFS_ACL_H__ | 19 | #define __XFS_ACL_H__ |
diff --git a/fs/xfs/xfs_ag.h b/fs/xfs/xfs_ag.h index 96b70f7fba39..a96e2ffce0cc 100644 --- a/fs/xfs/xfs_ag.h +++ b/fs/xfs/xfs_ag.h | |||
@@ -1,33 +1,19 @@ | |||
1 | /* | 1 | /* |
2 | * Copyright (c) 2000-2003 Silicon Graphics, Inc. All Rights Reserved. | 2 | * Copyright (c) 2000-2003,2005 Silicon Graphics, Inc. |
3 | * All Rights Reserved. | ||
3 | * | 4 | * |
4 | * This program is free software; you can redistribute it and/or modify it | 5 | * This program is free software; you can redistribute it and/or |
5 | * under the terms of version 2 of the GNU General Public License as | 6 | * modify it under the terms of the GNU General Public License as |
6 | * published by the Free Software Foundation. | 7 | * published by the Free Software Foundation. |
7 | * | 8 | * |
8 | * This program is distributed in the hope that it would be useful, but | 9 | * This program is distributed in the hope that it would be useful, |
9 | * WITHOUT ANY WARRANTY; without even the implied warranty of | 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
12 | * GNU General Public License for more details. | ||
11 | * | 13 | * |
12 | * Further, this software is distributed without any warranty that it is | 14 | * You should have received a copy of the GNU General Public License |
13 | * free of the rightful claim of any third person regarding infringement | 15 | * along with this program; if not, write the Free Software Foundation, |
14 | * or the like. Any license provided herein, whether implied or | 16 | * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
15 | * otherwise, applies only to this software file. Patent licenses, if | ||
16 | * any, provided herein do not apply to combinations of this program with | ||
17 | * other software, or any other product whatsoever. | ||
18 | * | ||
19 | * You should have received a copy of the GNU General Public License along | ||
20 | * with this program; if not, write the Free Software Foundation, Inc., 59 | ||
21 | * Temple Place - Suite 330, Boston MA 02111-1307, USA. | ||
22 | * | ||
23 | * Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy, | ||
24 | * Mountain View, CA 94043, or: | ||
25 | * | ||
26 | * http://www.sgi.com | ||
27 | * | ||
28 | * For further information regarding this notice, see: | ||
29 | * | ||
30 | * http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/ | ||
31 | */ | 17 | */ |
32 | #ifndef __XFS_AG_H__ | 18 | #ifndef __XFS_AG_H__ |
33 | #define __XFS_AG_H__ | 19 | #define __XFS_AG_H__ |
@@ -46,18 +32,9 @@ struct xfs_trans; | |||
46 | #define XFS_AGI_MAGIC 0x58414749 /* 'XAGI' */ | 32 | #define XFS_AGI_MAGIC 0x58414749 /* 'XAGI' */ |
47 | #define XFS_AGF_VERSION 1 | 33 | #define XFS_AGF_VERSION 1 |
48 | #define XFS_AGI_VERSION 1 | 34 | #define XFS_AGI_VERSION 1 |
49 | #if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_AGF_GOOD_VERSION) | 35 | |
50 | int xfs_agf_good_version(unsigned v); | 36 | #define XFS_AGF_GOOD_VERSION(v) ((v) == XFS_AGF_VERSION) |
51 | #define XFS_AGF_GOOD_VERSION(v) xfs_agf_good_version(v) | 37 | #define XFS_AGI_GOOD_VERSION(v) ((v) == XFS_AGI_VERSION) |
52 | #else | ||
53 | #define XFS_AGF_GOOD_VERSION(v) ((v) == XFS_AGF_VERSION) | ||
54 | #endif | ||
55 | #if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_AGI_GOOD_VERSION) | ||
56 | int xfs_agi_good_version(unsigned v); | ||
57 | #define XFS_AGI_GOOD_VERSION(v) xfs_agi_good_version(v) | ||
58 | #else | ||
59 | #define XFS_AGI_GOOD_VERSION(v) ((v) == XFS_AGI_VERSION) | ||
60 | #endif | ||
61 | 38 | ||
62 | /* | 39 | /* |
63 | * Btree number 0 is bno, 1 is cnt. This value gives the size of the | 40 | * Btree number 0 is bno, 1 is cnt. This value gives the size of the |
@@ -71,27 +48,26 @@ int xfs_agi_good_version(unsigned v); | |||
71 | * are > 64k, our value cannot be confused for an EFS superblock's. | 48 | * are > 64k, our value cannot be confused for an EFS superblock's. |
72 | */ | 49 | */ |
73 | 50 | ||
74 | typedef struct xfs_agf | 51 | typedef struct xfs_agf { |
75 | { | ||
76 | /* | 52 | /* |
77 | * Common allocation group header information | 53 | * Common allocation group header information |
78 | */ | 54 | */ |
79 | __uint32_t agf_magicnum; /* magic number == XFS_AGF_MAGIC */ | 55 | __be32 agf_magicnum; /* magic number == XFS_AGF_MAGIC */ |
80 | __uint32_t agf_versionnum; /* header version == XFS_AGF_VERSION */ | 56 | __be32 agf_versionnum; /* header version == XFS_AGF_VERSION */ |
81 | xfs_agnumber_t agf_seqno; /* sequence # starting from 0 */ | 57 | __be32 agf_seqno; /* sequence # starting from 0 */ |
82 | xfs_agblock_t agf_length; /* size in blocks of a.g. */ | 58 | __be32 agf_length; /* size in blocks of a.g. */ |
83 | /* | 59 | /* |
84 | * Freespace information | 60 | * Freespace information |
85 | */ | 61 | */ |
86 | xfs_agblock_t agf_roots[XFS_BTNUM_AGF]; /* root blocks */ | 62 | __be32 agf_roots[XFS_BTNUM_AGF]; /* root blocks */ |
87 | __uint32_t agf_spare0; /* spare field */ | 63 | __be32 agf_spare0; /* spare field */ |
88 | __uint32_t agf_levels[XFS_BTNUM_AGF]; /* btree levels */ | 64 | __be32 agf_levels[XFS_BTNUM_AGF]; /* btree levels */ |
89 | __uint32_t agf_spare1; /* spare field */ | 65 | __be32 agf_spare1; /* spare field */ |
90 | __uint32_t agf_flfirst; /* first freelist block's index */ | 66 | __be32 agf_flfirst; /* first freelist block's index */ |
91 | __uint32_t agf_fllast; /* last freelist block's index */ | 67 | __be32 agf_fllast; /* last freelist block's index */ |
92 | __uint32_t agf_flcount; /* count of blocks in freelist */ | 68 | __be32 agf_flcount; /* count of blocks in freelist */ |
93 | xfs_extlen_t agf_freeblks; /* total free blocks */ | 69 | __be32 agf_freeblks; /* total free blocks */ |
94 | xfs_extlen_t agf_longest; /* longest free space */ | 70 | __be32 agf_longest; /* longest free space */ |
95 | } xfs_agf_t; | 71 | } xfs_agf_t; |
96 | 72 | ||
97 | #define XFS_AGF_MAGICNUM 0x00000001 | 73 | #define XFS_AGF_MAGICNUM 0x00000001 |
@@ -110,43 +86,39 @@ typedef struct xfs_agf | |||
110 | 86 | ||
111 | /* disk block (xfs_daddr_t) in the AG */ | 87 | /* disk block (xfs_daddr_t) in the AG */ |
112 | #define XFS_AGF_DADDR(mp) ((xfs_daddr_t)(1 << (mp)->m_sectbb_log)) | 88 | #define XFS_AGF_DADDR(mp) ((xfs_daddr_t)(1 << (mp)->m_sectbb_log)) |
113 | #if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_AGF_BLOCK) | 89 | #define XFS_AGF_BLOCK(mp) XFS_HDR_BLOCK(mp, XFS_AGF_DADDR(mp)) |
114 | xfs_agblock_t xfs_agf_block(struct xfs_mount *mp); | 90 | #define XFS_BUF_TO_AGF(bp) ((xfs_agf_t *)XFS_BUF_PTR(bp)) |
115 | #define XFS_AGF_BLOCK(mp) xfs_agf_block(mp) | 91 | |
116 | #else | ||
117 | #define XFS_AGF_BLOCK(mp) XFS_HDR_BLOCK(mp, XFS_AGF_DADDR(mp)) | ||
118 | #endif | ||
119 | 92 | ||
120 | /* | 93 | /* |
121 | * Size of the unlinked inode hash table in the agi. | 94 | * Size of the unlinked inode hash table in the agi. |
122 | */ | 95 | */ |
123 | #define XFS_AGI_UNLINKED_BUCKETS 64 | 96 | #define XFS_AGI_UNLINKED_BUCKETS 64 |
124 | 97 | ||
125 | typedef struct xfs_agi | 98 | typedef struct xfs_agi { |
126 | { | ||
127 | /* | 99 | /* |
128 | * Common allocation group header information | 100 | * Common allocation group header information |
129 | */ | 101 | */ |
130 | __uint32_t agi_magicnum; /* magic number == XFS_AGI_MAGIC */ | 102 | __be32 agi_magicnum; /* magic number == XFS_AGI_MAGIC */ |
131 | __uint32_t agi_versionnum; /* header version == XFS_AGI_VERSION */ | 103 | __be32 agi_versionnum; /* header version == XFS_AGI_VERSION */ |
132 | xfs_agnumber_t agi_seqno; /* sequence # starting from 0 */ | 104 | __be32 agi_seqno; /* sequence # starting from 0 */ |
133 | xfs_agblock_t agi_length; /* size in blocks of a.g. */ | 105 | __be32 agi_length; /* size in blocks of a.g. */ |
134 | /* | 106 | /* |
135 | * Inode information | 107 | * Inode information |
136 | * Inodes are mapped by interpreting the inode number, so no | 108 | * Inodes are mapped by interpreting the inode number, so no |
137 | * mapping data is needed here. | 109 | * mapping data is needed here. |
138 | */ | 110 | */ |
139 | xfs_agino_t agi_count; /* count of allocated inodes */ | 111 | __be32 agi_count; /* count of allocated inodes */ |
140 | xfs_agblock_t agi_root; /* root of inode btree */ | 112 | __be32 agi_root; /* root of inode btree */ |
141 | __uint32_t agi_level; /* levels in inode btree */ | 113 | __be32 agi_level; /* levels in inode btree */ |
142 | xfs_agino_t agi_freecount; /* number of free inodes */ | 114 | __be32 agi_freecount; /* number of free inodes */ |
143 | xfs_agino_t agi_newino; /* new inode just allocated */ | 115 | __be32 agi_newino; /* new inode just allocated */ |
144 | xfs_agino_t agi_dirino; /* last directory inode chunk */ | 116 | __be32 agi_dirino; /* last directory inode chunk */ |
145 | /* | 117 | /* |
146 | * Hash table of inodes which have been unlinked but are | 118 | * Hash table of inodes which have been unlinked but are |
147 | * still being referenced. | 119 | * still being referenced. |
148 | */ | 120 | */ |
149 | xfs_agino_t agi_unlinked[XFS_AGI_UNLINKED_BUCKETS]; | 121 | __be32 agi_unlinked[XFS_AGI_UNLINKED_BUCKETS]; |
150 | } xfs_agi_t; | 122 | } xfs_agi_t; |
151 | 123 | ||
152 | #define XFS_AGI_MAGICNUM 0x00000001 | 124 | #define XFS_AGI_MAGICNUM 0x00000001 |
@@ -165,25 +137,17 @@ typedef struct xfs_agi | |||
165 | 137 | ||
166 | /* disk block (xfs_daddr_t) in the AG */ | 138 | /* disk block (xfs_daddr_t) in the AG */ |
167 | #define XFS_AGI_DADDR(mp) ((xfs_daddr_t)(2 << (mp)->m_sectbb_log)) | 139 | #define XFS_AGI_DADDR(mp) ((xfs_daddr_t)(2 << (mp)->m_sectbb_log)) |
168 | #if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_AGI_BLOCK) | 140 | #define XFS_AGI_BLOCK(mp) XFS_HDR_BLOCK(mp, XFS_AGI_DADDR(mp)) |
169 | xfs_agblock_t xfs_agi_block(struct xfs_mount *mp); | 141 | #define XFS_BUF_TO_AGI(bp) ((xfs_agi_t *)XFS_BUF_PTR(bp)) |
170 | #define XFS_AGI_BLOCK(mp) xfs_agi_block(mp) | ||
171 | #else | ||
172 | #define XFS_AGI_BLOCK(mp) XFS_HDR_BLOCK(mp, XFS_AGI_DADDR(mp)) | ||
173 | #endif | ||
174 | 142 | ||
175 | /* | 143 | /* |
176 | * The third a.g. block contains the a.g. freelist, an array | 144 | * The third a.g. block contains the a.g. freelist, an array |
177 | * of block pointers to blocks owned by the allocation btree code. | 145 | * of block pointers to blocks owned by the allocation btree code. |
178 | */ | 146 | */ |
179 | #define XFS_AGFL_DADDR(mp) ((xfs_daddr_t)(3 << (mp)->m_sectbb_log)) | 147 | #define XFS_AGFL_DADDR(mp) ((xfs_daddr_t)(3 << (mp)->m_sectbb_log)) |
180 | #if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_AGFL_BLOCK) | 148 | #define XFS_AGFL_BLOCK(mp) XFS_HDR_BLOCK(mp, XFS_AGFL_DADDR(mp)) |
181 | xfs_agblock_t xfs_agfl_block(struct xfs_mount *mp); | ||
182 | #define XFS_AGFL_BLOCK(mp) xfs_agfl_block(mp) | ||
183 | #else | ||
184 | #define XFS_AGFL_BLOCK(mp) XFS_HDR_BLOCK(mp, XFS_AGFL_DADDR(mp)) | ||
185 | #endif | ||
186 | #define XFS_AGFL_SIZE(mp) ((mp)->m_sb.sb_sectsize / sizeof(xfs_agblock_t)) | 149 | #define XFS_AGFL_SIZE(mp) ((mp)->m_sb.sb_sectsize / sizeof(xfs_agblock_t)) |
150 | #define XFS_BUF_TO_AGFL(bp) ((xfs_agfl_t *)XFS_BUF_PTR(bp)) | ||
187 | 151 | ||
188 | typedef struct xfs_agfl { | 152 | typedef struct xfs_agfl { |
189 | xfs_agblock_t agfl_bno[1]; /* actually XFS_AGFL_SIZE(mp) */ | 153 | xfs_agblock_t agfl_bno[1]; /* actually XFS_AGFL_SIZE(mp) */ |
@@ -230,116 +194,38 @@ typedef struct xfs_perag | |||
230 | xfs_perag_busy_t *pagb_list; /* unstable blocks */ | 194 | xfs_perag_busy_t *pagb_list; /* unstable blocks */ |
231 | } xfs_perag_t; | 195 | } xfs_perag_t; |
232 | 196 | ||
233 | #if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_AG_MAXLEVELS) | 197 | #define XFS_AG_MAXLEVELS(mp) ((mp)->m_ag_maxlevels) |
234 | int xfs_ag_maxlevels(struct xfs_mount *mp); | ||
235 | #define XFS_AG_MAXLEVELS(mp) xfs_ag_maxlevels(mp) | ||
236 | #else | ||
237 | #define XFS_AG_MAXLEVELS(mp) ((mp)->m_ag_maxlevels) | ||
238 | #endif | ||
239 | #if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_MIN_FREELIST) | ||
240 | int xfs_min_freelist(xfs_agf_t *a, struct xfs_mount *mp); | ||
241 | #define XFS_MIN_FREELIST(a,mp) xfs_min_freelist(a,mp) | ||
242 | #else | ||
243 | #define XFS_MIN_FREELIST(a,mp) \ | ||
244 | XFS_MIN_FREELIST_RAW( \ | ||
245 | INT_GET((a)->agf_levels[XFS_BTNUM_BNOi], ARCH_CONVERT), \ | ||
246 | INT_GET((a)->agf_levels[XFS_BTNUM_CNTi], ARCH_CONVERT), mp) | ||
247 | #endif | ||
248 | #if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_MIN_FREELIST_PAG) | ||
249 | int xfs_min_freelist_pag(xfs_perag_t *pag, struct xfs_mount *mp); | ||
250 | #define XFS_MIN_FREELIST_PAG(pag,mp) xfs_min_freelist_pag(pag,mp) | ||
251 | #else | ||
252 | #define XFS_MIN_FREELIST_PAG(pag,mp) \ | ||
253 | XFS_MIN_FREELIST_RAW((uint_t)(pag)->pagf_levels[XFS_BTNUM_BNOi], \ | ||
254 | (uint_t)(pag)->pagf_levels[XFS_BTNUM_CNTi], mp) | ||
255 | #endif | ||
256 | #if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_MIN_FREELIST_RAW) | ||
257 | int xfs_min_freelist_raw(int bl, int cl, struct xfs_mount *mp); | ||
258 | #define XFS_MIN_FREELIST_RAW(bl,cl,mp) xfs_min_freelist_raw(bl,cl,mp) | ||
259 | #else | ||
260 | #define XFS_MIN_FREELIST_RAW(bl,cl,mp) \ | 198 | #define XFS_MIN_FREELIST_RAW(bl,cl,mp) \ |
261 | (MIN(bl + 1, XFS_AG_MAXLEVELS(mp)) + \ | 199 | (MIN(bl + 1, XFS_AG_MAXLEVELS(mp)) + MIN(cl + 1, XFS_AG_MAXLEVELS(mp))) |
262 | MIN(cl + 1, XFS_AG_MAXLEVELS(mp))) | 200 | #define XFS_MIN_FREELIST(a,mp) \ |
263 | #endif | 201 | (XFS_MIN_FREELIST_RAW( \ |
202 | be32_to_cpu((a)->agf_levels[XFS_BTNUM_BNOi]), \ | ||
203 | be32_to_cpu((a)->agf_levels[XFS_BTNUM_CNTi]), mp)) | ||
204 | #define XFS_MIN_FREELIST_PAG(pag,mp) \ | ||
205 | (XFS_MIN_FREELIST_RAW( \ | ||
206 | (uint_t)(pag)->pagf_levels[XFS_BTNUM_BNOi], \ | ||
207 | (uint_t)(pag)->pagf_levels[XFS_BTNUM_CNTi], mp)) | ||
264 | 208 | ||
265 | #if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_AGB_TO_FSB) | 209 | #define XFS_AGB_TO_FSB(mp,agno,agbno) \ |
266 | xfs_fsblock_t xfs_agb_to_fsb(struct xfs_mount *mp, xfs_agnumber_t agno, | ||
267 | xfs_agblock_t agbno); | ||
268 | #define XFS_AGB_TO_FSB(mp,agno,agbno) xfs_agb_to_fsb(mp,agno,agbno) | ||
269 | #else | ||
270 | #define XFS_AGB_TO_FSB(mp,agno,agbno) \ | ||
271 | (((xfs_fsblock_t)(agno) << (mp)->m_sb.sb_agblklog) | (agbno)) | 210 | (((xfs_fsblock_t)(agno) << (mp)->m_sb.sb_agblklog) | (agbno)) |
272 | #endif | 211 | #define XFS_FSB_TO_AGNO(mp,fsbno) \ |
273 | #if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_FSB_TO_AGNO) | ||
274 | xfs_agnumber_t xfs_fsb_to_agno(struct xfs_mount *mp, xfs_fsblock_t fsbno); | ||
275 | #define XFS_FSB_TO_AGNO(mp,fsbno) xfs_fsb_to_agno(mp,fsbno) | ||
276 | #else | ||
277 | #define XFS_FSB_TO_AGNO(mp,fsbno) \ | ||
278 | ((xfs_agnumber_t)((fsbno) >> (mp)->m_sb.sb_agblklog)) | 212 | ((xfs_agnumber_t)((fsbno) >> (mp)->m_sb.sb_agblklog)) |
279 | #endif | 213 | #define XFS_FSB_TO_AGBNO(mp,fsbno) \ |
280 | #if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_FSB_TO_AGBNO) | ||
281 | xfs_agblock_t xfs_fsb_to_agbno(struct xfs_mount *mp, xfs_fsblock_t fsbno); | ||
282 | #define XFS_FSB_TO_AGBNO(mp,fsbno) xfs_fsb_to_agbno(mp,fsbno) | ||
283 | #else | ||
284 | #define XFS_FSB_TO_AGBNO(mp,fsbno) \ | ||
285 | ((xfs_agblock_t)((fsbno) & XFS_MASK32LO((mp)->m_sb.sb_agblklog))) | 214 | ((xfs_agblock_t)((fsbno) & XFS_MASK32LO((mp)->m_sb.sb_agblklog))) |
286 | #endif | 215 | #define XFS_AGB_TO_DADDR(mp,agno,agbno) \ |
287 | 216 | ((xfs_daddr_t)XFS_FSB_TO_BB(mp, \ | |
288 | #if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_AGB_TO_DADDR) | 217 | (xfs_fsblock_t)(agno) * (mp)->m_sb.sb_agblocks + (agbno))) |
289 | xfs_daddr_t xfs_agb_to_daddr(struct xfs_mount *mp, xfs_agnumber_t agno, | 218 | #define XFS_AG_DADDR(mp,agno,d) (XFS_AGB_TO_DADDR(mp, agno, 0) + (d)) |
290 | xfs_agblock_t agbno); | ||
291 | #define XFS_AGB_TO_DADDR(mp,agno,agbno) xfs_agb_to_daddr(mp,agno,agbno) | ||
292 | #else | ||
293 | #define XFS_AGB_TO_DADDR(mp,agno,agbno) \ | ||
294 | ((xfs_daddr_t)(XFS_FSB_TO_BB(mp, \ | ||
295 | (xfs_fsblock_t)(agno) * (mp)->m_sb.sb_agblocks + (agbno)))) | ||
296 | #endif | ||
297 | /* | ||
298 | * XFS_DADDR_TO_AGNO and XFS_DADDR_TO_AGBNO moved to xfs_mount.h | ||
299 | * to avoid header file ordering change | ||
300 | */ | ||
301 | |||
302 | #if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_AG_DADDR) | ||
303 | xfs_daddr_t xfs_ag_daddr(struct xfs_mount *mp, xfs_agnumber_t agno, | ||
304 | xfs_daddr_t d); | ||
305 | #define XFS_AG_DADDR(mp,agno,d) xfs_ag_daddr(mp,agno,d) | ||
306 | #else | ||
307 | #define XFS_AG_DADDR(mp,agno,d) (XFS_AGB_TO_DADDR(mp, agno, 0) + (d)) | ||
308 | #endif | ||
309 | |||
310 | #if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_BUF_TO_AGF) | ||
311 | xfs_agf_t *xfs_buf_to_agf(struct xfs_buf *bp); | ||
312 | #define XFS_BUF_TO_AGF(bp) xfs_buf_to_agf(bp) | ||
313 | #else | ||
314 | #define XFS_BUF_TO_AGF(bp) ((xfs_agf_t *)XFS_BUF_PTR(bp)) | ||
315 | #endif | ||
316 | #if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_BUF_TO_AGI) | ||
317 | xfs_agi_t *xfs_buf_to_agi(struct xfs_buf *bp); | ||
318 | #define XFS_BUF_TO_AGI(bp) xfs_buf_to_agi(bp) | ||
319 | #else | ||
320 | #define XFS_BUF_TO_AGI(bp) ((xfs_agi_t *)XFS_BUF_PTR(bp)) | ||
321 | #endif | ||
322 | #if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_BUF_TO_AGFL) | ||
323 | xfs_agfl_t *xfs_buf_to_agfl(struct xfs_buf *bp); | ||
324 | #define XFS_BUF_TO_AGFL(bp) xfs_buf_to_agfl(bp) | ||
325 | #else | ||
326 | #define XFS_BUF_TO_AGFL(bp) ((xfs_agfl_t *)XFS_BUF_PTR(bp)) | ||
327 | #endif | ||
328 | 219 | ||
329 | /* | 220 | /* |
330 | * For checking for bad ranges of xfs_daddr_t's, covering multiple | 221 | * For checking for bad ranges of xfs_daddr_t's, covering multiple |
331 | * allocation groups or a single xfs_daddr_t that's a superblock copy. | 222 | * allocation groups or a single xfs_daddr_t that's a superblock copy. |
332 | */ | 223 | */ |
333 | #if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_AG_CHECK_DADDR) | ||
334 | void xfs_ag_check_daddr(struct xfs_mount *mp, xfs_daddr_t d, xfs_extlen_t len); | ||
335 | #define XFS_AG_CHECK_DADDR(mp,d,len) xfs_ag_check_daddr(mp,d,len) | ||
336 | #else | ||
337 | #define XFS_AG_CHECK_DADDR(mp,d,len) \ | 224 | #define XFS_AG_CHECK_DADDR(mp,d,len) \ |
338 | ((len) == 1 ? \ | 225 | ((len) == 1 ? \ |
339 | ASSERT((d) == XFS_SB_DADDR || \ | 226 | ASSERT((d) == XFS_SB_DADDR || \ |
340 | XFS_DADDR_TO_AGBNO(mp, d) != XFS_SB_DADDR) : \ | 227 | XFS_DADDR_TO_AGBNO(mp, d) != XFS_SB_DADDR) : \ |
341 | ASSERT(XFS_DADDR_TO_AGNO(mp, d) == \ | 228 | ASSERT(XFS_DADDR_TO_AGNO(mp, d) == \ |
342 | XFS_DADDR_TO_AGNO(mp, (d) + (len) - 1))) | 229 | XFS_DADDR_TO_AGNO(mp, (d) + (len) - 1))) |
343 | #endif | ||
344 | 230 | ||
345 | #endif /* __XFS_AG_H__ */ | 231 | #endif /* __XFS_AG_H__ */ |
diff --git a/fs/xfs/xfs_alloc.c b/fs/xfs/xfs_alloc.c index dcfe19703620..f4328e1e2a74 100644 --- a/fs/xfs/xfs_alloc.c +++ b/fs/xfs/xfs_alloc.c | |||
@@ -1,56 +1,44 @@ | |||
1 | /* | 1 | /* |
2 | * Copyright (c) 2000-2002 Silicon Graphics, Inc. All Rights Reserved. | 2 | * Copyright (c) 2000-2002,2005 Silicon Graphics, Inc. |
3 | * All Rights Reserved. | ||
3 | * | 4 | * |
4 | * This program is free software; you can redistribute it and/or modify it | 5 | * This program is free software; you can redistribute it and/or |
5 | * under the terms of version 2 of the GNU General Public License as | 6 | * modify it under the terms of the GNU General Public License as |
6 | * published by the Free Software Foundation. | 7 | * published by the Free Software Foundation. |
7 | * | 8 | * |
8 | * This program is distributed in the hope that it would be useful, but | 9 | * This program is distributed in the hope that it would be useful, |
9 | * WITHOUT ANY WARRANTY; without even the implied warranty of | 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
12 | * GNU General Public License for more details. | ||
11 | * | 13 | * |
12 | * Further, this software is distributed without any warranty that it is | 14 | * You should have received a copy of the GNU General Public License |
13 | * free of the rightful claim of any third person regarding infringement | 15 | * along with this program; if not, write the Free Software Foundation, |
14 | * or the like. Any license provided herein, whether implied or | 16 | * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
15 | * otherwise, applies only to this software file. Patent licenses, if | ||
16 | * any, provided herein do not apply to combinations of this program with | ||
17 | * other software, or any other product whatsoever. | ||
18 | * | ||
19 | * You should have received a copy of the GNU General Public License along | ||
20 | * with this program; if not, write the Free Software Foundation, Inc., 59 | ||
21 | * Temple Place - Suite 330, Boston MA 02111-1307, USA. | ||
22 | * | ||
23 | * Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy, | ||
24 | * Mountain View, CA 94043, or: | ||
25 | * | ||
26 | * http://www.sgi.com | ||
27 | * | ||
28 | * For further information regarding this notice, see: | ||
29 | * | ||
30 | * http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/ | ||
31 | */ | ||
32 | |||
33 | /* | ||
34 | * Free space allocation for XFS. | ||
35 | */ | 17 | */ |
36 | #include "xfs.h" | 18 | #include "xfs.h" |
37 | #include "xfs_macros.h" | 19 | #include "xfs_fs.h" |
38 | #include "xfs_types.h" | 20 | #include "xfs_types.h" |
39 | #include "xfs_inum.h" | 21 | #include "xfs_bit.h" |
40 | #include "xfs_log.h" | 22 | #include "xfs_log.h" |
23 | #include "xfs_inum.h" | ||
41 | #include "xfs_trans.h" | 24 | #include "xfs_trans.h" |
42 | #include "xfs_sb.h" | 25 | #include "xfs_sb.h" |
43 | #include "xfs_ag.h" | 26 | #include "xfs_ag.h" |
44 | #include "xfs_dir.h" | 27 | #include "xfs_dir.h" |
28 | #include "xfs_dir2.h" | ||
45 | #include "xfs_dmapi.h" | 29 | #include "xfs_dmapi.h" |
46 | #include "xfs_mount.h" | 30 | #include "xfs_mount.h" |
47 | #include "xfs_alloc_btree.h" | ||
48 | #include "xfs_bmap_btree.h" | 31 | #include "xfs_bmap_btree.h" |
32 | #include "xfs_alloc_btree.h" | ||
49 | #include "xfs_ialloc_btree.h" | 33 | #include "xfs_ialloc_btree.h" |
34 | #include "xfs_dir_sf.h" | ||
35 | #include "xfs_dir2_sf.h" | ||
36 | #include "xfs_attr_sf.h" | ||
37 | #include "xfs_dinode.h" | ||
38 | #include "xfs_inode.h" | ||
50 | #include "xfs_btree.h" | 39 | #include "xfs_btree.h" |
51 | #include "xfs_ialloc.h" | 40 | #include "xfs_ialloc.h" |
52 | #include "xfs_alloc.h" | 41 | #include "xfs_alloc.h" |
53 | #include "xfs_bit.h" | ||
54 | #include "xfs_error.h" | 42 | #include "xfs_error.h" |
55 | 43 | ||
56 | 44 | ||
@@ -243,8 +231,8 @@ xfs_alloc_fix_minleft( | |||
243 | if (args->minleft == 0) | 231 | if (args->minleft == 0) |
244 | return 1; | 232 | return 1; |
245 | agf = XFS_BUF_TO_AGF(args->agbp); | 233 | agf = XFS_BUF_TO_AGF(args->agbp); |
246 | diff = INT_GET(agf->agf_freeblks, ARCH_CONVERT) | 234 | diff = be32_to_cpu(agf->agf_freeblks) |
247 | + INT_GET(agf->agf_flcount, ARCH_CONVERT) | 235 | + be32_to_cpu(agf->agf_flcount) |
248 | - args->len - args->minleft; | 236 | - args->len - args->minleft; |
249 | if (diff >= 0) | 237 | if (diff >= 0) |
250 | return 1; | 238 | return 1; |
@@ -319,7 +307,8 @@ xfs_alloc_fixup_trees( | |||
319 | bnoblock = XFS_BUF_TO_ALLOC_BLOCK(bno_cur->bc_bufs[0]); | 307 | bnoblock = XFS_BUF_TO_ALLOC_BLOCK(bno_cur->bc_bufs[0]); |
320 | cntblock = XFS_BUF_TO_ALLOC_BLOCK(cnt_cur->bc_bufs[0]); | 308 | cntblock = XFS_BUF_TO_ALLOC_BLOCK(cnt_cur->bc_bufs[0]); |
321 | XFS_WANT_CORRUPTED_RETURN( | 309 | XFS_WANT_CORRUPTED_RETURN( |
322 | INT_GET(bnoblock->bb_numrecs, ARCH_CONVERT) == INT_GET(cntblock->bb_numrecs, ARCH_CONVERT)); | 310 | be16_to_cpu(bnoblock->bb_numrecs) == |
311 | be16_to_cpu(cntblock->bb_numrecs)); | ||
323 | } | 312 | } |
324 | } | 313 | } |
325 | #endif | 314 | #endif |
@@ -505,21 +494,17 @@ xfs_alloc_trace_modagf( | |||
505 | (void *)str, | 494 | (void *)str, |
506 | (void *)mp, | 495 | (void *)mp, |
507 | (void *)(__psint_t)flags, | 496 | (void *)(__psint_t)flags, |
508 | (void *)(__psunsigned_t)INT_GET(agf->agf_seqno, ARCH_CONVERT), | 497 | (void *)(__psunsigned_t)be32_to_cpu(agf->agf_seqno), |
509 | (void *)(__psunsigned_t)INT_GET(agf->agf_length, ARCH_CONVERT), | 498 | (void *)(__psunsigned_t)be32_to_cpu(agf->agf_length), |
510 | (void *)(__psunsigned_t)INT_GET(agf->agf_roots[XFS_BTNUM_BNO], | 499 | (void *)(__psunsigned_t)be32_to_cpu(agf->agf_roots[XFS_BTNUM_BNO]), |
511 | ARCH_CONVERT), | 500 | (void *)(__psunsigned_t)be32_to_cpu(agf->agf_roots[XFS_BTNUM_CNT]), |
512 | (void *)(__psunsigned_t)INT_GET(agf->agf_roots[XFS_BTNUM_CNT], | 501 | (void *)(__psunsigned_t)be32_to_cpu(agf->agf_levels[XFS_BTNUM_BNO]), |
513 | ARCH_CONVERT), | 502 | (void *)(__psunsigned_t)be32_to_cpu(agf->agf_levels[XFS_BTNUM_CNT]), |
514 | (void *)(__psunsigned_t)INT_GET(agf->agf_levels[XFS_BTNUM_BNO], | 503 | (void *)(__psunsigned_t)be32_to_cpu(agf->agf_flfirst), |
515 | ARCH_CONVERT), | 504 | (void *)(__psunsigned_t)be32_to_cpu(agf->agf_fllast), |
516 | (void *)(__psunsigned_t)INT_GET(agf->agf_levels[XFS_BTNUM_CNT], | 505 | (void *)(__psunsigned_t)be32_to_cpu(agf->agf_flcount), |
517 | ARCH_CONVERT), | 506 | (void *)(__psunsigned_t)be32_to_cpu(agf->agf_freeblks), |
518 | (void *)(__psunsigned_t)INT_GET(agf->agf_flfirst, ARCH_CONVERT), | 507 | (void *)(__psunsigned_t)be32_to_cpu(agf->agf_longest)); |
519 | (void *)(__psunsigned_t)INT_GET(agf->agf_fllast, ARCH_CONVERT), | ||
520 | (void *)(__psunsigned_t)INT_GET(agf->agf_flcount, ARCH_CONVERT), | ||
521 | (void *)(__psunsigned_t)INT_GET(agf->agf_freeblks, ARCH_CONVERT), | ||
522 | (void *)(__psunsigned_t)INT_GET(agf->agf_longest, ARCH_CONVERT)); | ||
523 | } | 508 | } |
524 | 509 | ||
525 | STATIC void | 510 | STATIC void |
@@ -612,12 +597,12 @@ xfs_alloc_ag_vextent( | |||
612 | if (!(args->wasfromfl)) { | 597 | if (!(args->wasfromfl)) { |
613 | 598 | ||
614 | agf = XFS_BUF_TO_AGF(args->agbp); | 599 | agf = XFS_BUF_TO_AGF(args->agbp); |
615 | INT_MOD(agf->agf_freeblks, ARCH_CONVERT, -(args->len)); | 600 | be32_add(&agf->agf_freeblks, -(args->len)); |
616 | xfs_trans_agblocks_delta(args->tp, | 601 | xfs_trans_agblocks_delta(args->tp, |
617 | -((long)(args->len))); | 602 | -((long)(args->len))); |
618 | args->pag->pagf_freeblks -= args->len; | 603 | args->pag->pagf_freeblks -= args->len; |
619 | ASSERT(INT_GET(agf->agf_freeblks, ARCH_CONVERT) | 604 | ASSERT(be32_to_cpu(agf->agf_freeblks) <= |
620 | <= INT_GET(agf->agf_length, ARCH_CONVERT)); | 605 | be32_to_cpu(agf->agf_length)); |
621 | TRACE_MODAGF(NULL, agf, XFS_AGF_FREEBLKS); | 606 | TRACE_MODAGF(NULL, agf, XFS_AGF_FREEBLKS); |
622 | xfs_alloc_log_agf(args->tp, args->agbp, | 607 | xfs_alloc_log_agf(args->tp, args->agbp, |
623 | XFS_AGF_FREEBLKS); | 608 | XFS_AGF_FREEBLKS); |
@@ -723,8 +708,7 @@ xfs_alloc_ag_vextent_exact( | |||
723 | cnt_cur = xfs_btree_init_cursor(args->mp, args->tp, args->agbp, | 708 | cnt_cur = xfs_btree_init_cursor(args->mp, args->tp, args->agbp, |
724 | args->agno, XFS_BTNUM_CNT, NULL, 0); | 709 | args->agno, XFS_BTNUM_CNT, NULL, 0); |
725 | ASSERT(args->agbno + args->len <= | 710 | ASSERT(args->agbno + args->len <= |
726 | INT_GET(XFS_BUF_TO_AGF(args->agbp)->agf_length, | 711 | be32_to_cpu(XFS_BUF_TO_AGF(args->agbp)->agf_length)); |
727 | ARCH_CONVERT)); | ||
728 | if ((error = xfs_alloc_fixup_trees(cnt_cur, bno_cur, fbno, flen, | 712 | if ((error = xfs_alloc_fixup_trees(cnt_cur, bno_cur, fbno, flen, |
729 | args->agbno, args->len, XFSA_FIXUP_BNO_OK))) { | 713 | args->agbno, args->len, XFSA_FIXUP_BNO_OK))) { |
730 | xfs_btree_del_cursor(cnt_cur, XFS_BTREE_ERROR); | 714 | xfs_btree_del_cursor(cnt_cur, XFS_BTREE_ERROR); |
@@ -897,8 +881,7 @@ xfs_alloc_ag_vextent_near( | |||
897 | goto error0; | 881 | goto error0; |
898 | XFS_WANT_CORRUPTED_GOTO(i == 1, error0); | 882 | XFS_WANT_CORRUPTED_GOTO(i == 1, error0); |
899 | ltend = ltbno + ltlen; | 883 | ltend = ltbno + ltlen; |
900 | ASSERT(ltend <= INT_GET(XFS_BUF_TO_AGF(args->agbp)->agf_length, | 884 | ASSERT(ltend <= be32_to_cpu(XFS_BUF_TO_AGF(args->agbp)->agf_length)); |
901 | ARCH_CONVERT)); | ||
902 | args->len = blen; | 885 | args->len = blen; |
903 | if (!xfs_alloc_fix_minleft(args)) { | 886 | if (!xfs_alloc_fix_minleft(args)) { |
904 | xfs_btree_del_cursor(cnt_cur, XFS_BTREE_NOERROR); | 887 | xfs_btree_del_cursor(cnt_cur, XFS_BTREE_NOERROR); |
@@ -1253,8 +1236,7 @@ xfs_alloc_ag_vextent_near( | |||
1253 | ltlen, <new); | 1236 | ltlen, <new); |
1254 | ASSERT(ltnew >= ltbno); | 1237 | ASSERT(ltnew >= ltbno); |
1255 | ASSERT(ltnew + rlen <= ltend); | 1238 | ASSERT(ltnew + rlen <= ltend); |
1256 | ASSERT(ltnew + rlen <= INT_GET(XFS_BUF_TO_AGF(args->agbp)->agf_length, | 1239 | ASSERT(ltnew + rlen <= be32_to_cpu(XFS_BUF_TO_AGF(args->agbp)->agf_length)); |
1257 | ARCH_CONVERT)); | ||
1258 | args->agbno = ltnew; | 1240 | args->agbno = ltnew; |
1259 | if ((error = xfs_alloc_fixup_trees(cnt_cur, bno_cur_lt, ltbno, ltlen, | 1241 | if ((error = xfs_alloc_fixup_trees(cnt_cur, bno_cur_lt, ltbno, ltlen, |
1260 | ltnew, rlen, XFSA_FIXUP_BNO_OK))) | 1242 | ltnew, rlen, XFSA_FIXUP_BNO_OK))) |
@@ -1417,8 +1399,7 @@ xfs_alloc_ag_vextent_size( | |||
1417 | args->agbno = rbno; | 1399 | args->agbno = rbno; |
1418 | XFS_WANT_CORRUPTED_GOTO( | 1400 | XFS_WANT_CORRUPTED_GOTO( |
1419 | args->agbno + args->len <= | 1401 | args->agbno + args->len <= |
1420 | INT_GET(XFS_BUF_TO_AGF(args->agbp)->agf_length, | 1402 | be32_to_cpu(XFS_BUF_TO_AGF(args->agbp)->agf_length), |
1421 | ARCH_CONVERT), | ||
1422 | error0); | 1403 | error0); |
1423 | TRACE_ALLOC("normal", args); | 1404 | TRACE_ALLOC("normal", args); |
1424 | return 0; | 1405 | return 0; |
@@ -1466,8 +1447,8 @@ xfs_alloc_ag_vextent_small( | |||
1466 | * freelist. | 1447 | * freelist. |
1467 | */ | 1448 | */ |
1468 | else if (args->minlen == 1 && args->alignment == 1 && !args->isfl && | 1449 | else if (args->minlen == 1 && args->alignment == 1 && !args->isfl && |
1469 | (INT_GET(XFS_BUF_TO_AGF(args->agbp)->agf_flcount, | 1450 | (be32_to_cpu(XFS_BUF_TO_AGF(args->agbp)->agf_flcount) |
1470 | ARCH_CONVERT) > args->minleft)) { | 1451 | > args->minleft)) { |
1471 | if ((error = xfs_alloc_get_freelist(args->tp, args->agbp, &fbno))) | 1452 | if ((error = xfs_alloc_get_freelist(args->tp, args->agbp, &fbno))) |
1472 | goto error0; | 1453 | goto error0; |
1473 | if (fbno != NULLAGBLOCK) { | 1454 | if (fbno != NULLAGBLOCK) { |
@@ -1482,8 +1463,7 @@ xfs_alloc_ag_vextent_small( | |||
1482 | args->agbno = fbno; | 1463 | args->agbno = fbno; |
1483 | XFS_WANT_CORRUPTED_GOTO( | 1464 | XFS_WANT_CORRUPTED_GOTO( |
1484 | args->agbno + args->len <= | 1465 | args->agbno + args->len <= |
1485 | INT_GET(XFS_BUF_TO_AGF(args->agbp)->agf_length, | 1466 | be32_to_cpu(XFS_BUF_TO_AGF(args->agbp)->agf_length), |
1486 | ARCH_CONVERT), | ||
1487 | error0); | 1467 | error0); |
1488 | args->wasfromfl = 1; | 1468 | args->wasfromfl = 1; |
1489 | TRACE_ALLOC("freelist", args); | 1469 | TRACE_ALLOC("freelist", args); |
@@ -1757,12 +1737,12 @@ xfs_free_ag_extent( | |||
1757 | 1737 | ||
1758 | agf = XFS_BUF_TO_AGF(agbp); | 1738 | agf = XFS_BUF_TO_AGF(agbp); |
1759 | pag = &mp->m_perag[agno]; | 1739 | pag = &mp->m_perag[agno]; |
1760 | INT_MOD(agf->agf_freeblks, ARCH_CONVERT, len); | 1740 | be32_add(&agf->agf_freeblks, len); |
1761 | xfs_trans_agblocks_delta(tp, len); | 1741 | xfs_trans_agblocks_delta(tp, len); |
1762 | pag->pagf_freeblks += len; | 1742 | pag->pagf_freeblks += len; |
1763 | XFS_WANT_CORRUPTED_GOTO( | 1743 | XFS_WANT_CORRUPTED_GOTO( |
1764 | INT_GET(agf->agf_freeblks, ARCH_CONVERT) | 1744 | be32_to_cpu(agf->agf_freeblks) <= |
1765 | <= INT_GET(agf->agf_length, ARCH_CONVERT), | 1745 | be32_to_cpu(agf->agf_length), |
1766 | error0); | 1746 | error0); |
1767 | TRACE_MODAGF(NULL, agf, XFS_AGF_FREEBLKS); | 1747 | TRACE_MODAGF(NULL, agf, XFS_AGF_FREEBLKS); |
1768 | xfs_alloc_log_agf(tp, agbp, XFS_AGF_FREEBLKS); | 1748 | xfs_alloc_log_agf(tp, agbp, XFS_AGF_FREEBLKS); |
@@ -1909,18 +1889,18 @@ xfs_alloc_fix_freelist( | |||
1909 | */ | 1889 | */ |
1910 | agf = XFS_BUF_TO_AGF(agbp); | 1890 | agf = XFS_BUF_TO_AGF(agbp); |
1911 | need = XFS_MIN_FREELIST(agf, mp); | 1891 | need = XFS_MIN_FREELIST(agf, mp); |
1912 | delta = need > INT_GET(agf->agf_flcount, ARCH_CONVERT) ? | 1892 | delta = need > be32_to_cpu(agf->agf_flcount) ? |
1913 | (need - INT_GET(agf->agf_flcount, ARCH_CONVERT)) : 0; | 1893 | (need - be32_to_cpu(agf->agf_flcount)) : 0; |
1914 | /* | 1894 | /* |
1915 | * If there isn't enough total or single-extent, reject it. | 1895 | * If there isn't enough total or single-extent, reject it. |
1916 | */ | 1896 | */ |
1917 | longest = INT_GET(agf->agf_longest, ARCH_CONVERT); | 1897 | longest = be32_to_cpu(agf->agf_longest); |
1918 | longest = (longest > delta) ? (longest - delta) : | 1898 | longest = (longest > delta) ? (longest - delta) : |
1919 | (INT_GET(agf->agf_flcount, ARCH_CONVERT) > 0 || longest > 0); | 1899 | (be32_to_cpu(agf->agf_flcount) > 0 || longest > 0); |
1920 | if (args->minlen + args->alignment + args->minalignslop - 1 > longest || | 1900 | if (args->minlen + args->alignment + args->minalignslop - 1 > longest || |
1921 | (args->minleft && | 1901 | (args->minleft && |
1922 | (int)(INT_GET(agf->agf_freeblks, ARCH_CONVERT) + | 1902 | (int)(be32_to_cpu(agf->agf_freeblks) + |
1923 | INT_GET(agf->agf_flcount, ARCH_CONVERT) - need - args->total) < | 1903 | be32_to_cpu(agf->agf_flcount) - need - args->total) < |
1924 | (int)args->minleft)) { | 1904 | (int)args->minleft)) { |
1925 | xfs_trans_brelse(tp, agbp); | 1905 | xfs_trans_brelse(tp, agbp); |
1926 | args->agbp = NULL; | 1906 | args->agbp = NULL; |
@@ -1929,7 +1909,7 @@ xfs_alloc_fix_freelist( | |||
1929 | /* | 1909 | /* |
1930 | * Make the freelist shorter if it's too long. | 1910 | * Make the freelist shorter if it's too long. |
1931 | */ | 1911 | */ |
1932 | while (INT_GET(agf->agf_flcount, ARCH_CONVERT) > need) { | 1912 | while (be32_to_cpu(agf->agf_flcount) > need) { |
1933 | xfs_buf_t *bp; | 1913 | xfs_buf_t *bp; |
1934 | 1914 | ||
1935 | if ((error = xfs_alloc_get_freelist(tp, agbp, &bno))) | 1915 | if ((error = xfs_alloc_get_freelist(tp, agbp, &bno))) |
@@ -1956,9 +1936,9 @@ xfs_alloc_fix_freelist( | |||
1956 | /* | 1936 | /* |
1957 | * Make the freelist longer if it's too short. | 1937 | * Make the freelist longer if it's too short. |
1958 | */ | 1938 | */ |
1959 | while (INT_GET(agf->agf_flcount, ARCH_CONVERT) < need) { | 1939 | while (be32_to_cpu(agf->agf_flcount) < need) { |
1960 | targs.agbno = 0; | 1940 | targs.agbno = 0; |
1961 | targs.maxlen = need - INT_GET(agf->agf_flcount, ARCH_CONVERT); | 1941 | targs.maxlen = need - be32_to_cpu(agf->agf_flcount); |
1962 | /* | 1942 | /* |
1963 | * Allocate as many blocks as possible at once. | 1943 | * Allocate as many blocks as possible at once. |
1964 | */ | 1944 | */ |
@@ -2018,19 +1998,19 @@ xfs_alloc_get_freelist( | |||
2018 | */ | 1998 | */ |
2019 | mp = tp->t_mountp; | 1999 | mp = tp->t_mountp; |
2020 | if ((error = xfs_alloc_read_agfl(mp, tp, | 2000 | if ((error = xfs_alloc_read_agfl(mp, tp, |
2021 | INT_GET(agf->agf_seqno, ARCH_CONVERT), &agflbp))) | 2001 | be32_to_cpu(agf->agf_seqno), &agflbp))) |
2022 | return error; | 2002 | return error; |
2023 | agfl = XFS_BUF_TO_AGFL(agflbp); | 2003 | agfl = XFS_BUF_TO_AGFL(agflbp); |
2024 | /* | 2004 | /* |
2025 | * Get the block number and update the data structures. | 2005 | * Get the block number and update the data structures. |
2026 | */ | 2006 | */ |
2027 | bno = INT_GET(agfl->agfl_bno[INT_GET(agf->agf_flfirst, ARCH_CONVERT)], ARCH_CONVERT); | 2007 | bno = INT_GET(agfl->agfl_bno[be32_to_cpu(agf->agf_flfirst)], ARCH_CONVERT); |
2028 | INT_MOD(agf->agf_flfirst, ARCH_CONVERT, 1); | 2008 | be32_add(&agf->agf_flfirst, 1); |
2029 | xfs_trans_brelse(tp, agflbp); | 2009 | xfs_trans_brelse(tp, agflbp); |
2030 | if (INT_GET(agf->agf_flfirst, ARCH_CONVERT) == XFS_AGFL_SIZE(mp)) | 2010 | if (be32_to_cpu(agf->agf_flfirst) == XFS_AGFL_SIZE(mp)) |
2031 | agf->agf_flfirst = 0; | 2011 | agf->agf_flfirst = 0; |
2032 | pag = &mp->m_perag[INT_GET(agf->agf_seqno, ARCH_CONVERT)]; | 2012 | pag = &mp->m_perag[be32_to_cpu(agf->agf_seqno)]; |
2033 | INT_MOD(agf->agf_flcount, ARCH_CONVERT, -1); | 2013 | be32_add(&agf->agf_flcount, -1); |
2034 | xfs_trans_agflist_delta(tp, -1); | 2014 | xfs_trans_agflist_delta(tp, -1); |
2035 | pag->pagf_flcount--; | 2015 | pag->pagf_flcount--; |
2036 | TRACE_MODAGF(NULL, agf, XFS_AGF_FLFIRST | XFS_AGF_FLCOUNT); | 2016 | TRACE_MODAGF(NULL, agf, XFS_AGF_FLFIRST | XFS_AGF_FLCOUNT); |
@@ -2045,7 +2025,7 @@ xfs_alloc_get_freelist( | |||
2045 | * the freeing transaction must be pushed to disk NOW by forcing | 2025 | * the freeing transaction must be pushed to disk NOW by forcing |
2046 | * to disk all iclogs up that transaction's LSN. | 2026 | * to disk all iclogs up that transaction's LSN. |
2047 | */ | 2027 | */ |
2048 | xfs_alloc_search_busy(tp, INT_GET(agf->agf_seqno, ARCH_CONVERT), bno, 1); | 2028 | xfs_alloc_search_busy(tp, be32_to_cpu(agf->agf_seqno), bno, 1); |
2049 | return 0; | 2029 | return 0; |
2050 | } | 2030 | } |
2051 | 2031 | ||
@@ -2123,18 +2103,18 @@ xfs_alloc_put_freelist( | |||
2123 | mp = tp->t_mountp; | 2103 | mp = tp->t_mountp; |
2124 | 2104 | ||
2125 | if (!agflbp && (error = xfs_alloc_read_agfl(mp, tp, | 2105 | if (!agflbp && (error = xfs_alloc_read_agfl(mp, tp, |
2126 | INT_GET(agf->agf_seqno, ARCH_CONVERT), &agflbp))) | 2106 | be32_to_cpu(agf->agf_seqno), &agflbp))) |
2127 | return error; | 2107 | return error; |
2128 | agfl = XFS_BUF_TO_AGFL(agflbp); | 2108 | agfl = XFS_BUF_TO_AGFL(agflbp); |
2129 | INT_MOD(agf->agf_fllast, ARCH_CONVERT, 1); | 2109 | be32_add(&agf->agf_fllast, 1); |
2130 | if (INT_GET(agf->agf_fllast, ARCH_CONVERT) == XFS_AGFL_SIZE(mp)) | 2110 | if (be32_to_cpu(agf->agf_fllast) == XFS_AGFL_SIZE(mp)) |
2131 | agf->agf_fllast = 0; | 2111 | agf->agf_fllast = 0; |
2132 | pag = &mp->m_perag[INT_GET(agf->agf_seqno, ARCH_CONVERT)]; | 2112 | pag = &mp->m_perag[be32_to_cpu(agf->agf_seqno)]; |
2133 | INT_MOD(agf->agf_flcount, ARCH_CONVERT, 1); | 2113 | be32_add(&agf->agf_flcount, 1); |
2134 | xfs_trans_agflist_delta(tp, 1); | 2114 | xfs_trans_agflist_delta(tp, 1); |
2135 | pag->pagf_flcount++; | 2115 | pag->pagf_flcount++; |
2136 | ASSERT(INT_GET(agf->agf_flcount, ARCH_CONVERT) <= XFS_AGFL_SIZE(mp)); | 2116 | ASSERT(be32_to_cpu(agf->agf_flcount) <= XFS_AGFL_SIZE(mp)); |
2137 | blockp = &agfl->agfl_bno[INT_GET(agf->agf_fllast, ARCH_CONVERT)]; | 2117 | blockp = &agfl->agfl_bno[be32_to_cpu(agf->agf_fllast)]; |
2138 | INT_SET(*blockp, ARCH_CONVERT, bno); | 2118 | INT_SET(*blockp, ARCH_CONVERT, bno); |
2139 | TRACE_MODAGF(NULL, agf, XFS_AGF_FLLAST | XFS_AGF_FLCOUNT); | 2119 | TRACE_MODAGF(NULL, agf, XFS_AGF_FLLAST | XFS_AGF_FLCOUNT); |
2140 | xfs_alloc_log_agf(tp, agbp, XFS_AGF_FLLAST | XFS_AGF_FLCOUNT); | 2120 | xfs_alloc_log_agf(tp, agbp, XFS_AGF_FLLAST | XFS_AGF_FLCOUNT); |
@@ -2181,14 +2161,12 @@ xfs_alloc_read_agf( | |||
2181 | */ | 2161 | */ |
2182 | agf = XFS_BUF_TO_AGF(bp); | 2162 | agf = XFS_BUF_TO_AGF(bp); |
2183 | agf_ok = | 2163 | agf_ok = |
2184 | INT_GET(agf->agf_magicnum, ARCH_CONVERT) == XFS_AGF_MAGIC && | 2164 | be32_to_cpu(agf->agf_magicnum) == XFS_AGF_MAGIC && |
2185 | XFS_AGF_GOOD_VERSION( | 2165 | XFS_AGF_GOOD_VERSION(be32_to_cpu(agf->agf_versionnum)) && |
2186 | INT_GET(agf->agf_versionnum, ARCH_CONVERT)) && | 2166 | be32_to_cpu(agf->agf_freeblks) <= be32_to_cpu(agf->agf_length) && |
2187 | INT_GET(agf->agf_freeblks, ARCH_CONVERT) <= | 2167 | be32_to_cpu(agf->agf_flfirst) < XFS_AGFL_SIZE(mp) && |
2188 | INT_GET(agf->agf_length, ARCH_CONVERT) && | 2168 | be32_to_cpu(agf->agf_fllast) < XFS_AGFL_SIZE(mp) && |
2189 | INT_GET(agf->agf_flfirst, ARCH_CONVERT) < XFS_AGFL_SIZE(mp) && | 2169 | be32_to_cpu(agf->agf_flcount) <= XFS_AGFL_SIZE(mp); |
2190 | INT_GET(agf->agf_fllast, ARCH_CONVERT) < XFS_AGFL_SIZE(mp) && | ||
2191 | INT_GET(agf->agf_flcount, ARCH_CONVERT) <= XFS_AGFL_SIZE(mp); | ||
2192 | if (unlikely(XFS_TEST_ERROR(!agf_ok, mp, XFS_ERRTAG_ALLOC_READ_AGF, | 2170 | if (unlikely(XFS_TEST_ERROR(!agf_ok, mp, XFS_ERRTAG_ALLOC_READ_AGF, |
2193 | XFS_RANDOM_ALLOC_READ_AGF))) { | 2171 | XFS_RANDOM_ALLOC_READ_AGF))) { |
2194 | XFS_CORRUPTION_ERROR("xfs_alloc_read_agf", | 2172 | XFS_CORRUPTION_ERROR("xfs_alloc_read_agf", |
@@ -2198,13 +2176,13 @@ xfs_alloc_read_agf( | |||
2198 | } | 2176 | } |
2199 | pag = &mp->m_perag[agno]; | 2177 | pag = &mp->m_perag[agno]; |
2200 | if (!pag->pagf_init) { | 2178 | if (!pag->pagf_init) { |
2201 | pag->pagf_freeblks = INT_GET(agf->agf_freeblks, ARCH_CONVERT); | 2179 | pag->pagf_freeblks = be32_to_cpu(agf->agf_freeblks); |
2202 | pag->pagf_flcount = INT_GET(agf->agf_flcount, ARCH_CONVERT); | 2180 | pag->pagf_flcount = be32_to_cpu(agf->agf_flcount); |
2203 | pag->pagf_longest = INT_GET(agf->agf_longest, ARCH_CONVERT); | 2181 | pag->pagf_longest = be32_to_cpu(agf->agf_longest); |
2204 | pag->pagf_levels[XFS_BTNUM_BNOi] = | 2182 | pag->pagf_levels[XFS_BTNUM_BNOi] = |
2205 | INT_GET(agf->agf_levels[XFS_BTNUM_BNOi], ARCH_CONVERT); | 2183 | be32_to_cpu(agf->agf_levels[XFS_BTNUM_BNOi]); |
2206 | pag->pagf_levels[XFS_BTNUM_CNTi] = | 2184 | pag->pagf_levels[XFS_BTNUM_CNTi] = |
2207 | INT_GET(agf->agf_levels[XFS_BTNUM_CNTi], ARCH_CONVERT); | 2185 | be32_to_cpu(agf->agf_levels[XFS_BTNUM_CNTi]); |
2208 | spinlock_init(&pag->pagb_lock, "xfspagb"); | 2186 | spinlock_init(&pag->pagb_lock, "xfspagb"); |
2209 | pag->pagb_list = kmem_zalloc(XFS_PAGB_NUM_SLOTS * | 2187 | pag->pagb_list = kmem_zalloc(XFS_PAGB_NUM_SLOTS * |
2210 | sizeof(xfs_perag_busy_t), KM_SLEEP); | 2188 | sizeof(xfs_perag_busy_t), KM_SLEEP); |
@@ -2212,13 +2190,13 @@ xfs_alloc_read_agf( | |||
2212 | } | 2190 | } |
2213 | #ifdef DEBUG | 2191 | #ifdef DEBUG |
2214 | else if (!XFS_FORCED_SHUTDOWN(mp)) { | 2192 | else if (!XFS_FORCED_SHUTDOWN(mp)) { |
2215 | ASSERT(pag->pagf_freeblks == INT_GET(agf->agf_freeblks, ARCH_CONVERT)); | 2193 | ASSERT(pag->pagf_freeblks == be32_to_cpu(agf->agf_freeblks)); |
2216 | ASSERT(pag->pagf_flcount == INT_GET(agf->agf_flcount, ARCH_CONVERT)); | 2194 | ASSERT(pag->pagf_flcount == be32_to_cpu(agf->agf_flcount)); |
2217 | ASSERT(pag->pagf_longest == INT_GET(agf->agf_longest, ARCH_CONVERT)); | 2195 | ASSERT(pag->pagf_longest == be32_to_cpu(agf->agf_longest)); |
2218 | ASSERT(pag->pagf_levels[XFS_BTNUM_BNOi] == | 2196 | ASSERT(pag->pagf_levels[XFS_BTNUM_BNOi] == |
2219 | INT_GET(agf->agf_levels[XFS_BTNUM_BNOi], ARCH_CONVERT)); | 2197 | be32_to_cpu(agf->agf_levels[XFS_BTNUM_BNOi])); |
2220 | ASSERT(pag->pagf_levels[XFS_BTNUM_CNTi] == | 2198 | ASSERT(pag->pagf_levels[XFS_BTNUM_CNTi] == |
2221 | INT_GET(agf->agf_levels[XFS_BTNUM_CNTi], ARCH_CONVERT)); | 2199 | be32_to_cpu(agf->agf_levels[XFS_BTNUM_CNTi])); |
2222 | } | 2200 | } |
2223 | #endif | 2201 | #endif |
2224 | XFS_BUF_SET_VTYPE_REF(bp, B_FS_AGF, XFS_AGF_REF); | 2202 | XFS_BUF_SET_VTYPE_REF(bp, B_FS_AGF, XFS_AGF_REF); |
@@ -2467,7 +2445,7 @@ xfs_free_extent( | |||
2467 | #ifdef DEBUG | 2445 | #ifdef DEBUG |
2468 | ASSERT(args.agbp != NULL); | 2446 | ASSERT(args.agbp != NULL); |
2469 | agf = XFS_BUF_TO_AGF(args.agbp); | 2447 | agf = XFS_BUF_TO_AGF(args.agbp); |
2470 | ASSERT(args.agbno + len <= INT_GET(agf->agf_length, ARCH_CONVERT)); | 2448 | ASSERT(args.agbno + len <= be32_to_cpu(agf->agf_length)); |
2471 | #endif | 2449 | #endif |
2472 | error = xfs_free_ag_extent(tp, args.agbp, args.agno, args.agbno, | 2450 | error = xfs_free_ag_extent(tp, args.agbp, args.agno, args.agbno, |
2473 | len, 0); | 2451 | len, 0); |
diff --git a/fs/xfs/xfs_alloc.h b/fs/xfs/xfs_alloc.h index 72329c86351c..3546dea27b7d 100644 --- a/fs/xfs/xfs_alloc.h +++ b/fs/xfs/xfs_alloc.h | |||
@@ -1,33 +1,19 @@ | |||
1 | /* | 1 | /* |
2 | * Copyright (c) 2000-2002 Silicon Graphics, Inc. All Rights Reserved. | 2 | * Copyright (c) 2000-2002,2005 Silicon Graphics, Inc. |
3 | * All Rights Reserved. | ||
3 | * | 4 | * |
4 | * This program is free software; you can redistribute it and/or modify it | 5 | * This program is free software; you can redistribute it and/or |
5 | * under the terms of version 2 of the GNU General Public License as | 6 | * modify it under the terms of the GNU General Public License as |
6 | * published by the Free Software Foundation. | 7 | * published by the Free Software Foundation. |
7 | * | 8 | * |
8 | * This program is distributed in the hope that it would be useful, but | 9 | * This program is distributed in the hope that it would be useful, |
9 | * WITHOUT ANY WARRANTY; without even the implied warranty of | 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
12 | * GNU General Public License for more details. | ||
11 | * | 13 | * |
12 | * Further, this software is distributed without any warranty that it is | 14 | * You should have received a copy of the GNU General Public License |
13 | * free of the rightful claim of any third person regarding infringement | 15 | * along with this program; if not, write the Free Software Foundation, |
14 | * or the like. Any license provided herein, whether implied or | 16 | * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
15 | * otherwise, applies only to this software file. Patent licenses, if | ||
16 | * any, provided herein do not apply to combinations of this program with | ||
17 | * other software, or any other product whatsoever. | ||
18 | * | ||
19 | * You should have received a copy of the GNU General Public License along | ||
20 | * with this program; if not, write the Free Software Foundation, Inc., 59 | ||
21 | * Temple Place - Suite 330, Boston MA 02111-1307, USA. | ||
22 | * | ||
23 | * Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy, | ||
24 | * Mountain View, CA 94043, or: | ||
25 | * | ||
26 | * http://www.sgi.com | ||
27 | * | ||
28 | * For further information regarding this notice, see: | ||
29 | * | ||
30 | * http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/ | ||
31 | */ | 17 | */ |
32 | #ifndef __XFS_ALLOC_H__ | 18 | #ifndef __XFS_ALLOC_H__ |
33 | #define __XFS_ALLOC_H__ | 19 | #define __XFS_ALLOC_H__ |
diff --git a/fs/xfs/xfs_alloc_btree.c b/fs/xfs/xfs_alloc_btree.c index e0355a12d946..a1d92da86ccd 100644 --- a/fs/xfs/xfs_alloc_btree.c +++ b/fs/xfs/xfs_alloc_btree.c | |||
@@ -1,53 +1,41 @@ | |||
1 | /* | 1 | /* |
2 | * Copyright (c) 2000-2001 Silicon Graphics, Inc. All Rights Reserved. | 2 | * Copyright (c) 2000-2001,2005 Silicon Graphics, Inc. |
3 | * All Rights Reserved. | ||
3 | * | 4 | * |
4 | * This program is free software; you can redistribute it and/or modify it | 5 | * This program is free software; you can redistribute it and/or |
5 | * under the terms of version 2 of the GNU General Public License as | 6 | * modify it under the terms of the GNU General Public License as |
6 | * published by the Free Software Foundation. | 7 | * published by the Free Software Foundation. |
7 | * | 8 | * |
8 | * This program is distributed in the hope that it would be useful, but | 9 | * This program is distributed in the hope that it would be useful, |
9 | * WITHOUT ANY WARRANTY; without even the implied warranty of | 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
12 | * GNU General Public License for more details. | ||
11 | * | 13 | * |
12 | * Further, this software is distributed without any warranty that it is | 14 | * You should have received a copy of the GNU General Public License |
13 | * free of the rightful claim of any third person regarding infringement | 15 | * along with this program; if not, write the Free Software Foundation, |
14 | * or the like. Any license provided herein, whether implied or | 16 | * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
15 | * otherwise, applies only to this software file. Patent licenses, if | ||
16 | * any, provided herein do not apply to combinations of this program with | ||
17 | * other software, or any other product whatsoever. | ||
18 | * | ||
19 | * You should have received a copy of the GNU General Public License along | ||
20 | * with this program; if not, write the Free Software Foundation, Inc., 59 | ||
21 | * Temple Place - Suite 330, Boston MA 02111-1307, USA. | ||
22 | * | ||
23 | * Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy, | ||
24 | * Mountain View, CA 94043, or: | ||
25 | * | ||
26 | * http://www.sgi.com | ||
27 | * | ||
28 | * For further information regarding this notice, see: | ||
29 | * | ||
30 | * http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/ | ||
31 | */ | 17 | */ |
32 | |||
33 | /* | ||
34 | * Free space allocation for XFS. | ||
35 | */ | ||
36 | |||
37 | #include "xfs.h" | 18 | #include "xfs.h" |
38 | #include "xfs_macros.h" | 19 | #include "xfs_fs.h" |
39 | #include "xfs_types.h" | 20 | #include "xfs_types.h" |
40 | #include "xfs_inum.h" | 21 | #include "xfs_bit.h" |
41 | #include "xfs_log.h" | 22 | #include "xfs_log.h" |
23 | #include "xfs_inum.h" | ||
42 | #include "xfs_trans.h" | 24 | #include "xfs_trans.h" |
43 | #include "xfs_sb.h" | 25 | #include "xfs_sb.h" |
44 | #include "xfs_ag.h" | 26 | #include "xfs_ag.h" |
45 | #include "xfs_dir.h" | 27 | #include "xfs_dir.h" |
28 | #include "xfs_dir2.h" | ||
46 | #include "xfs_dmapi.h" | 29 | #include "xfs_dmapi.h" |
47 | #include "xfs_mount.h" | 30 | #include "xfs_mount.h" |
31 | #include "xfs_bmap_btree.h" | ||
48 | #include "xfs_alloc_btree.h" | 32 | #include "xfs_alloc_btree.h" |
49 | #include "xfs_ialloc_btree.h" | 33 | #include "xfs_ialloc_btree.h" |
50 | #include "xfs_bmap_btree.h" | 34 | #include "xfs_dir_sf.h" |
35 | #include "xfs_dir2_sf.h" | ||
36 | #include "xfs_attr_sf.h" | ||
37 | #include "xfs_dinode.h" | ||
38 | #include "xfs_inode.h" | ||
51 | #include "xfs_btree.h" | 39 | #include "xfs_btree.h" |
52 | #include "xfs_ialloc.h" | 40 | #include "xfs_ialloc.h" |
53 | #include "xfs_alloc.h" | 41 | #include "xfs_alloc.h" |
@@ -129,7 +117,7 @@ xfs_alloc_delrec( | |||
129 | /* | 117 | /* |
130 | * Fail if we're off the end of the block. | 118 | * Fail if we're off the end of the block. |
131 | */ | 119 | */ |
132 | if (ptr > INT_GET(block->bb_numrecs, ARCH_CONVERT)) { | 120 | if (ptr > be16_to_cpu(block->bb_numrecs)) { |
133 | *stat = 0; | 121 | *stat = 0; |
134 | return 0; | 122 | return 0; |
135 | } | 123 | } |
@@ -143,18 +131,18 @@ xfs_alloc_delrec( | |||
143 | lkp = XFS_ALLOC_KEY_ADDR(block, 1, cur); | 131 | lkp = XFS_ALLOC_KEY_ADDR(block, 1, cur); |
144 | lpp = XFS_ALLOC_PTR_ADDR(block, 1, cur); | 132 | lpp = XFS_ALLOC_PTR_ADDR(block, 1, cur); |
145 | #ifdef DEBUG | 133 | #ifdef DEBUG |
146 | for (i = ptr; i < INT_GET(block->bb_numrecs, ARCH_CONVERT); i++) { | 134 | for (i = ptr; i < be16_to_cpu(block->bb_numrecs); i++) { |
147 | if ((error = xfs_btree_check_sptr(cur, INT_GET(lpp[i], ARCH_CONVERT), level))) | 135 | if ((error = xfs_btree_check_sptr(cur, be32_to_cpu(lpp[i]), level))) |
148 | return error; | 136 | return error; |
149 | } | 137 | } |
150 | #endif | 138 | #endif |
151 | if (ptr < INT_GET(block->bb_numrecs, ARCH_CONVERT)) { | 139 | if (ptr < be16_to_cpu(block->bb_numrecs)) { |
152 | memmove(&lkp[ptr - 1], &lkp[ptr], | 140 | memmove(&lkp[ptr - 1], &lkp[ptr], |
153 | (INT_GET(block->bb_numrecs, ARCH_CONVERT) - ptr) * sizeof(*lkp)); /* INT_: mem copy */ | 141 | (be16_to_cpu(block->bb_numrecs) - ptr) * sizeof(*lkp)); |
154 | memmove(&lpp[ptr - 1], &lpp[ptr], | 142 | memmove(&lpp[ptr - 1], &lpp[ptr], |
155 | (INT_GET(block->bb_numrecs, ARCH_CONVERT) - ptr) * sizeof(*lpp)); /* INT_: mem copy */ | 143 | (be16_to_cpu(block->bb_numrecs) - ptr) * sizeof(*lpp)); |
156 | xfs_alloc_log_ptrs(cur, bp, ptr, INT_GET(block->bb_numrecs, ARCH_CONVERT) - 1); | 144 | xfs_alloc_log_ptrs(cur, bp, ptr, be16_to_cpu(block->bb_numrecs) - 1); |
157 | xfs_alloc_log_keys(cur, bp, ptr, INT_GET(block->bb_numrecs, ARCH_CONVERT) - 1); | 145 | xfs_alloc_log_keys(cur, bp, ptr, be16_to_cpu(block->bb_numrecs) - 1); |
158 | } | 146 | } |
159 | } | 147 | } |
160 | /* | 148 | /* |
@@ -163,25 +151,25 @@ xfs_alloc_delrec( | |||
163 | */ | 151 | */ |
164 | else { | 152 | else { |
165 | lrp = XFS_ALLOC_REC_ADDR(block, 1, cur); | 153 | lrp = XFS_ALLOC_REC_ADDR(block, 1, cur); |
166 | if (ptr < INT_GET(block->bb_numrecs, ARCH_CONVERT)) { | 154 | if (ptr < be16_to_cpu(block->bb_numrecs)) { |
167 | memmove(&lrp[ptr - 1], &lrp[ptr], | 155 | memmove(&lrp[ptr - 1], &lrp[ptr], |
168 | (INT_GET(block->bb_numrecs, ARCH_CONVERT) - ptr) * sizeof(*lrp)); | 156 | (be16_to_cpu(block->bb_numrecs) - ptr) * sizeof(*lrp)); |
169 | xfs_alloc_log_recs(cur, bp, ptr, INT_GET(block->bb_numrecs, ARCH_CONVERT) - 1); | 157 | xfs_alloc_log_recs(cur, bp, ptr, be16_to_cpu(block->bb_numrecs) - 1); |
170 | } | 158 | } |
171 | /* | 159 | /* |
172 | * If it's the first record in the block, we'll need a key | 160 | * If it's the first record in the block, we'll need a key |
173 | * structure to pass up to the next level (updkey). | 161 | * structure to pass up to the next level (updkey). |
174 | */ | 162 | */ |
175 | if (ptr == 1) { | 163 | if (ptr == 1) { |
176 | key.ar_startblock = lrp->ar_startblock; /* INT_: direct copy */ | 164 | key.ar_startblock = lrp->ar_startblock; |
177 | key.ar_blockcount = lrp->ar_blockcount; /* INT_: direct copy */ | 165 | key.ar_blockcount = lrp->ar_blockcount; |
178 | lkp = &key; | 166 | lkp = &key; |
179 | } | 167 | } |
180 | } | 168 | } |
181 | /* | 169 | /* |
182 | * Decrement and log the number of entries in the block. | 170 | * Decrement and log the number of entries in the block. |
183 | */ | 171 | */ |
184 | INT_MOD(block->bb_numrecs, ARCH_CONVERT, -1); | 172 | be16_add(&block->bb_numrecs, -1); |
185 | xfs_alloc_log_block(cur->bc_tp, bp, XFS_BB_NUMRECS); | 173 | xfs_alloc_log_block(cur->bc_tp, bp, XFS_BB_NUMRECS); |
186 | /* | 174 | /* |
187 | * See if the longest free extent in the allocation group was | 175 | * See if the longest free extent in the allocation group was |
@@ -194,24 +182,24 @@ xfs_alloc_delrec( | |||
194 | 182 | ||
195 | if (level == 0 && | 183 | if (level == 0 && |
196 | cur->bc_btnum == XFS_BTNUM_CNT && | 184 | cur->bc_btnum == XFS_BTNUM_CNT && |
197 | INT_GET(block->bb_rightsib, ARCH_CONVERT) == NULLAGBLOCK && | 185 | be32_to_cpu(block->bb_rightsib) == NULLAGBLOCK && |
198 | ptr > INT_GET(block->bb_numrecs, ARCH_CONVERT)) { | 186 | ptr > be16_to_cpu(block->bb_numrecs)) { |
199 | ASSERT(ptr == INT_GET(block->bb_numrecs, ARCH_CONVERT) + 1); | 187 | ASSERT(ptr == be16_to_cpu(block->bb_numrecs) + 1); |
200 | /* | 188 | /* |
201 | * There are still records in the block. Grab the size | 189 | * There are still records in the block. Grab the size |
202 | * from the last one. | 190 | * from the last one. |
203 | */ | 191 | */ |
204 | if (INT_GET(block->bb_numrecs, ARCH_CONVERT)) { | 192 | if (be16_to_cpu(block->bb_numrecs)) { |
205 | rrp = XFS_ALLOC_REC_ADDR(block, INT_GET(block->bb_numrecs, ARCH_CONVERT), cur); | 193 | rrp = XFS_ALLOC_REC_ADDR(block, be16_to_cpu(block->bb_numrecs), cur); |
206 | INT_COPY(agf->agf_longest, rrp->ar_blockcount, ARCH_CONVERT); | 194 | agf->agf_longest = rrp->ar_blockcount; |
207 | } | 195 | } |
208 | /* | 196 | /* |
209 | * No free extents left. | 197 | * No free extents left. |
210 | */ | 198 | */ |
211 | else | 199 | else |
212 | agf->agf_longest = 0; | 200 | agf->agf_longest = 0; |
213 | mp->m_perag[INT_GET(agf->agf_seqno, ARCH_CONVERT)].pagf_longest = | 201 | mp->m_perag[be32_to_cpu(agf->agf_seqno)].pagf_longest = |
214 | INT_GET(agf->agf_longest, ARCH_CONVERT); | 202 | be32_to_cpu(agf->agf_longest); |
215 | xfs_alloc_log_agf(cur->bc_tp, cur->bc_private.a.agbp, | 203 | xfs_alloc_log_agf(cur->bc_tp, cur->bc_private.a.agbp, |
216 | XFS_AGF_LONGEST); | 204 | XFS_AGF_LONGEST); |
217 | } | 205 | } |
@@ -225,15 +213,15 @@ xfs_alloc_delrec( | |||
225 | * and it's NOT the leaf level, | 213 | * and it's NOT the leaf level, |
226 | * then we can get rid of this level. | 214 | * then we can get rid of this level. |
227 | */ | 215 | */ |
228 | if (INT_GET(block->bb_numrecs, ARCH_CONVERT) == 1 && level > 0) { | 216 | if (be16_to_cpu(block->bb_numrecs) == 1 && level > 0) { |
229 | /* | 217 | /* |
230 | * lpp is still set to the first pointer in the block. | 218 | * lpp is still set to the first pointer in the block. |
231 | * Make it the new root of the btree. | 219 | * Make it the new root of the btree. |
232 | */ | 220 | */ |
233 | bno = INT_GET(agf->agf_roots[cur->bc_btnum], ARCH_CONVERT); | 221 | bno = be32_to_cpu(agf->agf_roots[cur->bc_btnum]); |
234 | INT_COPY(agf->agf_roots[cur->bc_btnum], *lpp, ARCH_CONVERT); | 222 | agf->agf_roots[cur->bc_btnum] = *lpp; |
235 | INT_MOD(agf->agf_levels[cur->bc_btnum], ARCH_CONVERT, -1); | 223 | be32_add(&agf->agf_levels[cur->bc_btnum], -1); |
236 | mp->m_perag[INT_GET(agf->agf_seqno, ARCH_CONVERT)].pagf_levels[cur->bc_btnum]--; | 224 | mp->m_perag[be32_to_cpu(agf->agf_seqno)].pagf_levels[cur->bc_btnum]--; |
237 | /* | 225 | /* |
238 | * Put this buffer/block on the ag's freelist. | 226 | * Put this buffer/block on the ag's freelist. |
239 | */ | 227 | */ |
@@ -255,7 +243,7 @@ xfs_alloc_delrec( | |||
255 | * that freed the block. | 243 | * that freed the block. |
256 | */ | 244 | */ |
257 | xfs_alloc_mark_busy(cur->bc_tp, | 245 | xfs_alloc_mark_busy(cur->bc_tp, |
258 | INT_GET(agf->agf_seqno, ARCH_CONVERT), bno, 1); | 246 | be32_to_cpu(agf->agf_seqno), bno, 1); |
259 | 247 | ||
260 | xfs_trans_agbtree_delta(cur->bc_tp, -1); | 248 | xfs_trans_agbtree_delta(cur->bc_tp, -1); |
261 | xfs_alloc_log_agf(cur->bc_tp, cur->bc_private.a.agbp, | 249 | xfs_alloc_log_agf(cur->bc_tp, cur->bc_private.a.agbp, |
@@ -281,7 +269,7 @@ xfs_alloc_delrec( | |||
281 | * If the number of records remaining in the block is at least | 269 | * If the number of records remaining in the block is at least |
282 | * the minimum, we're done. | 270 | * the minimum, we're done. |
283 | */ | 271 | */ |
284 | if (INT_GET(block->bb_numrecs, ARCH_CONVERT) >= XFS_ALLOC_BLOCK_MINRECS(level, cur)) { | 272 | if (be16_to_cpu(block->bb_numrecs) >= XFS_ALLOC_BLOCK_MINRECS(level, cur)) { |
285 | if (level > 0 && (error = xfs_alloc_decrement(cur, level, &i))) | 273 | if (level > 0 && (error = xfs_alloc_decrement(cur, level, &i))) |
286 | return error; | 274 | return error; |
287 | *stat = 1; | 275 | *stat = 1; |
@@ -292,8 +280,8 @@ xfs_alloc_delrec( | |||
292 | * tree balanced. Look at the left and right sibling blocks to | 280 | * tree balanced. Look at the left and right sibling blocks to |
293 | * see if we can re-balance by moving only one record. | 281 | * see if we can re-balance by moving only one record. |
294 | */ | 282 | */ |
295 | rbno = INT_GET(block->bb_rightsib, ARCH_CONVERT); | 283 | rbno = be32_to_cpu(block->bb_rightsib); |
296 | lbno = INT_GET(block->bb_leftsib, ARCH_CONVERT); | 284 | lbno = be32_to_cpu(block->bb_leftsib); |
297 | bno = NULLAGBLOCK; | 285 | bno = NULLAGBLOCK; |
298 | ASSERT(rbno != NULLAGBLOCK || lbno != NULLAGBLOCK); | 286 | ASSERT(rbno != NULLAGBLOCK || lbno != NULLAGBLOCK); |
299 | /* | 287 | /* |
@@ -330,18 +318,18 @@ xfs_alloc_delrec( | |||
330 | /* | 318 | /* |
331 | * Grab the current block number, for future use. | 319 | * Grab the current block number, for future use. |
332 | */ | 320 | */ |
333 | bno = INT_GET(right->bb_leftsib, ARCH_CONVERT); | 321 | bno = be32_to_cpu(right->bb_leftsib); |
334 | /* | 322 | /* |
335 | * If right block is full enough so that removing one entry | 323 | * If right block is full enough so that removing one entry |
336 | * won't make it too empty, and left-shifting an entry out | 324 | * won't make it too empty, and left-shifting an entry out |
337 | * of right to us works, we're done. | 325 | * of right to us works, we're done. |
338 | */ | 326 | */ |
339 | if (INT_GET(right->bb_numrecs, ARCH_CONVERT) - 1 >= | 327 | if (be16_to_cpu(right->bb_numrecs) - 1 >= |
340 | XFS_ALLOC_BLOCK_MINRECS(level, cur)) { | 328 | XFS_ALLOC_BLOCK_MINRECS(level, cur)) { |
341 | if ((error = xfs_alloc_lshift(tcur, level, &i))) | 329 | if ((error = xfs_alloc_lshift(tcur, level, &i))) |
342 | goto error0; | 330 | goto error0; |
343 | if (i) { | 331 | if (i) { |
344 | ASSERT(INT_GET(block->bb_numrecs, ARCH_CONVERT) >= | 332 | ASSERT(be16_to_cpu(block->bb_numrecs) >= |
345 | XFS_ALLOC_BLOCK_MINRECS(level, cur)); | 333 | XFS_ALLOC_BLOCK_MINRECS(level, cur)); |
346 | xfs_btree_del_cursor(tcur, | 334 | xfs_btree_del_cursor(tcur, |
347 | XFS_BTREE_NOERROR); | 335 | XFS_BTREE_NOERROR); |
@@ -358,7 +346,7 @@ xfs_alloc_delrec( | |||
358 | * future reference, and fix up the temp cursor to point | 346 | * future reference, and fix up the temp cursor to point |
359 | * to our block again (last record). | 347 | * to our block again (last record). |
360 | */ | 348 | */ |
361 | rrecs = INT_GET(right->bb_numrecs, ARCH_CONVERT); | 349 | rrecs = be16_to_cpu(right->bb_numrecs); |
362 | if (lbno != NULLAGBLOCK) { | 350 | if (lbno != NULLAGBLOCK) { |
363 | i = xfs_btree_firstrec(tcur, level); | 351 | i = xfs_btree_firstrec(tcur, level); |
364 | XFS_WANT_CORRUPTED_GOTO(i == 1, error0); | 352 | XFS_WANT_CORRUPTED_GOTO(i == 1, error0); |
@@ -394,18 +382,18 @@ xfs_alloc_delrec( | |||
394 | /* | 382 | /* |
395 | * Grab the current block number, for future use. | 383 | * Grab the current block number, for future use. |
396 | */ | 384 | */ |
397 | bno = INT_GET(left->bb_rightsib, ARCH_CONVERT); | 385 | bno = be32_to_cpu(left->bb_rightsib); |
398 | /* | 386 | /* |
399 | * If left block is full enough so that removing one entry | 387 | * If left block is full enough so that removing one entry |
400 | * won't make it too empty, and right-shifting an entry out | 388 | * won't make it too empty, and right-shifting an entry out |
401 | * of left to us works, we're done. | 389 | * of left to us works, we're done. |
402 | */ | 390 | */ |
403 | if (INT_GET(left->bb_numrecs, ARCH_CONVERT) - 1 >= | 391 | if (be16_to_cpu(left->bb_numrecs) - 1 >= |
404 | XFS_ALLOC_BLOCK_MINRECS(level, cur)) { | 392 | XFS_ALLOC_BLOCK_MINRECS(level, cur)) { |
405 | if ((error = xfs_alloc_rshift(tcur, level, &i))) | 393 | if ((error = xfs_alloc_rshift(tcur, level, &i))) |
406 | goto error0; | 394 | goto error0; |
407 | if (i) { | 395 | if (i) { |
408 | ASSERT(INT_GET(block->bb_numrecs, ARCH_CONVERT) >= | 396 | ASSERT(be16_to_cpu(block->bb_numrecs) >= |
409 | XFS_ALLOC_BLOCK_MINRECS(level, cur)); | 397 | XFS_ALLOC_BLOCK_MINRECS(level, cur)); |
410 | xfs_btree_del_cursor(tcur, | 398 | xfs_btree_del_cursor(tcur, |
411 | XFS_BTREE_NOERROR); | 399 | XFS_BTREE_NOERROR); |
@@ -419,7 +407,7 @@ xfs_alloc_delrec( | |||
419 | * Otherwise, grab the number of records in right for | 407 | * Otherwise, grab the number of records in right for |
420 | * future reference. | 408 | * future reference. |
421 | */ | 409 | */ |
422 | lrecs = INT_GET(left->bb_numrecs, ARCH_CONVERT); | 410 | lrecs = be16_to_cpu(left->bb_numrecs); |
423 | } | 411 | } |
424 | /* | 412 | /* |
425 | * Delete the temp cursor, we're done with it. | 413 | * Delete the temp cursor, we're done with it. |
@@ -433,7 +421,7 @@ xfs_alloc_delrec( | |||
433 | * See if we can join with the left neighbor block. | 421 | * See if we can join with the left neighbor block. |
434 | */ | 422 | */ |
435 | if (lbno != NULLAGBLOCK && | 423 | if (lbno != NULLAGBLOCK && |
436 | lrecs + INT_GET(block->bb_numrecs, ARCH_CONVERT) <= XFS_ALLOC_BLOCK_MAXRECS(level, cur)) { | 424 | lrecs + be16_to_cpu(block->bb_numrecs) <= XFS_ALLOC_BLOCK_MAXRECS(level, cur)) { |
437 | /* | 425 | /* |
438 | * Set "right" to be the starting block, | 426 | * Set "right" to be the starting block, |
439 | * "left" to be the left neighbor. | 427 | * "left" to be the left neighbor. |
@@ -453,7 +441,7 @@ xfs_alloc_delrec( | |||
453 | * If that won't work, see if we can join with the right neighbor block. | 441 | * If that won't work, see if we can join with the right neighbor block. |
454 | */ | 442 | */ |
455 | else if (rbno != NULLAGBLOCK && | 443 | else if (rbno != NULLAGBLOCK && |
456 | rrecs + INT_GET(block->bb_numrecs, ARCH_CONVERT) <= | 444 | rrecs + be16_to_cpu(block->bb_numrecs) <= |
457 | XFS_ALLOC_BLOCK_MAXRECS(level, cur)) { | 445 | XFS_ALLOC_BLOCK_MAXRECS(level, cur)) { |
458 | /* | 446 | /* |
459 | * Set "left" to be the starting block, | 447 | * Set "left" to be the starting block, |
@@ -488,31 +476,34 @@ xfs_alloc_delrec( | |||
488 | /* | 476 | /* |
489 | * It's a non-leaf. Move keys and pointers. | 477 | * It's a non-leaf. Move keys and pointers. |
490 | */ | 478 | */ |
491 | lkp = XFS_ALLOC_KEY_ADDR(left, INT_GET(left->bb_numrecs, ARCH_CONVERT) + 1, cur); | 479 | lkp = XFS_ALLOC_KEY_ADDR(left, be16_to_cpu(left->bb_numrecs) + 1, cur); |
492 | lpp = XFS_ALLOC_PTR_ADDR(left, INT_GET(left->bb_numrecs, ARCH_CONVERT) + 1, cur); | 480 | lpp = XFS_ALLOC_PTR_ADDR(left, be16_to_cpu(left->bb_numrecs) + 1, cur); |
493 | rkp = XFS_ALLOC_KEY_ADDR(right, 1, cur); | 481 | rkp = XFS_ALLOC_KEY_ADDR(right, 1, cur); |
494 | rpp = XFS_ALLOC_PTR_ADDR(right, 1, cur); | 482 | rpp = XFS_ALLOC_PTR_ADDR(right, 1, cur); |
495 | #ifdef DEBUG | 483 | #ifdef DEBUG |
496 | for (i = 0; i < INT_GET(right->bb_numrecs, ARCH_CONVERT); i++) { | 484 | for (i = 0; i < be16_to_cpu(right->bb_numrecs); i++) { |
497 | if ((error = xfs_btree_check_sptr(cur, INT_GET(rpp[i], ARCH_CONVERT), level))) | 485 | if ((error = xfs_btree_check_sptr(cur, be32_to_cpu(rpp[i]), level))) |
498 | return error; | 486 | return error; |
499 | } | 487 | } |
500 | #endif | 488 | #endif |
501 | memcpy(lkp, rkp, INT_GET(right->bb_numrecs, ARCH_CONVERT) * sizeof(*lkp)); /* INT_: structure copy */ | 489 | memcpy(lkp, rkp, be16_to_cpu(right->bb_numrecs) * sizeof(*lkp)); |
502 | memcpy(lpp, rpp, INT_GET(right->bb_numrecs, ARCH_CONVERT) * sizeof(*lpp)); /* INT_: structure copy */ | 490 | memcpy(lpp, rpp, be16_to_cpu(right->bb_numrecs) * sizeof(*lpp)); |
503 | xfs_alloc_log_keys(cur, lbp, INT_GET(left->bb_numrecs, ARCH_CONVERT) + 1, | 491 | xfs_alloc_log_keys(cur, lbp, be16_to_cpu(left->bb_numrecs) + 1, |
504 | INT_GET(left->bb_numrecs, ARCH_CONVERT) + INT_GET(right->bb_numrecs, ARCH_CONVERT)); | 492 | be16_to_cpu(left->bb_numrecs) + |
505 | xfs_alloc_log_ptrs(cur, lbp, INT_GET(left->bb_numrecs, ARCH_CONVERT) + 1, | 493 | be16_to_cpu(right->bb_numrecs)); |
506 | INT_GET(left->bb_numrecs, ARCH_CONVERT) + INT_GET(right->bb_numrecs, ARCH_CONVERT)); | 494 | xfs_alloc_log_ptrs(cur, lbp, be16_to_cpu(left->bb_numrecs) + 1, |
495 | be16_to_cpu(left->bb_numrecs) + | ||
496 | be16_to_cpu(right->bb_numrecs)); | ||
507 | } else { | 497 | } else { |
508 | /* | 498 | /* |
509 | * It's a leaf. Move records. | 499 | * It's a leaf. Move records. |
510 | */ | 500 | */ |
511 | lrp = XFS_ALLOC_REC_ADDR(left, INT_GET(left->bb_numrecs, ARCH_CONVERT) + 1, cur); | 501 | lrp = XFS_ALLOC_REC_ADDR(left, be16_to_cpu(left->bb_numrecs) + 1, cur); |
512 | rrp = XFS_ALLOC_REC_ADDR(right, 1, cur); | 502 | rrp = XFS_ALLOC_REC_ADDR(right, 1, cur); |
513 | memcpy(lrp, rrp, INT_GET(right->bb_numrecs, ARCH_CONVERT) * sizeof(*lrp)); | 503 | memcpy(lrp, rrp, be16_to_cpu(right->bb_numrecs) * sizeof(*lrp)); |
514 | xfs_alloc_log_recs(cur, lbp, INT_GET(left->bb_numrecs, ARCH_CONVERT) + 1, | 504 | xfs_alloc_log_recs(cur, lbp, be16_to_cpu(left->bb_numrecs) + 1, |
515 | INT_GET(left->bb_numrecs, ARCH_CONVERT) + INT_GET(right->bb_numrecs, ARCH_CONVERT)); | 505 | be16_to_cpu(left->bb_numrecs) + |
506 | be16_to_cpu(right->bb_numrecs)); | ||
516 | } | 507 | } |
517 | /* | 508 | /* |
518 | * If we joined with the left neighbor, set the buffer in the | 509 | * If we joined with the left neighbor, set the buffer in the |
@@ -520,7 +511,7 @@ xfs_alloc_delrec( | |||
520 | */ | 511 | */ |
521 | if (bp != lbp) { | 512 | if (bp != lbp) { |
522 | xfs_btree_setbuf(cur, level, lbp); | 513 | xfs_btree_setbuf(cur, level, lbp); |
523 | cur->bc_ptrs[level] += INT_GET(left->bb_numrecs, ARCH_CONVERT); | 514 | cur->bc_ptrs[level] += be16_to_cpu(left->bb_numrecs); |
524 | } | 515 | } |
525 | /* | 516 | /* |
526 | * If we joined with the right neighbor and there's a level above | 517 | * If we joined with the right neighbor and there's a level above |
@@ -532,28 +523,28 @@ xfs_alloc_delrec( | |||
532 | /* | 523 | /* |
533 | * Fix up the number of records in the surviving block. | 524 | * Fix up the number of records in the surviving block. |
534 | */ | 525 | */ |
535 | INT_MOD(left->bb_numrecs, ARCH_CONVERT, INT_GET(right->bb_numrecs, ARCH_CONVERT)); | 526 | be16_add(&left->bb_numrecs, be16_to_cpu(right->bb_numrecs)); |
536 | /* | 527 | /* |
537 | * Fix up the right block pointer in the surviving block, and log it. | 528 | * Fix up the right block pointer in the surviving block, and log it. |
538 | */ | 529 | */ |
539 | left->bb_rightsib = right->bb_rightsib; /* INT_: direct copy */ | 530 | left->bb_rightsib = right->bb_rightsib; |
540 | xfs_alloc_log_block(cur->bc_tp, lbp, XFS_BB_NUMRECS | XFS_BB_RIGHTSIB); | 531 | xfs_alloc_log_block(cur->bc_tp, lbp, XFS_BB_NUMRECS | XFS_BB_RIGHTSIB); |
541 | /* | 532 | /* |
542 | * If there is a right sibling now, make it point to the | 533 | * If there is a right sibling now, make it point to the |
543 | * remaining block. | 534 | * remaining block. |
544 | */ | 535 | */ |
545 | if (INT_GET(left->bb_rightsib, ARCH_CONVERT) != NULLAGBLOCK) { | 536 | if (be32_to_cpu(left->bb_rightsib) != NULLAGBLOCK) { |
546 | xfs_alloc_block_t *rrblock; | 537 | xfs_alloc_block_t *rrblock; |
547 | xfs_buf_t *rrbp; | 538 | xfs_buf_t *rrbp; |
548 | 539 | ||
549 | if ((error = xfs_btree_read_bufs(mp, cur->bc_tp, | 540 | if ((error = xfs_btree_read_bufs(mp, cur->bc_tp, |
550 | cur->bc_private.a.agno, INT_GET(left->bb_rightsib, ARCH_CONVERT), 0, | 541 | cur->bc_private.a.agno, be32_to_cpu(left->bb_rightsib), 0, |
551 | &rrbp, XFS_ALLOC_BTREE_REF))) | 542 | &rrbp, XFS_ALLOC_BTREE_REF))) |
552 | return error; | 543 | return error; |
553 | rrblock = XFS_BUF_TO_ALLOC_BLOCK(rrbp); | 544 | rrblock = XFS_BUF_TO_ALLOC_BLOCK(rrbp); |
554 | if ((error = xfs_btree_check_sblock(cur, rrblock, level, rrbp))) | 545 | if ((error = xfs_btree_check_sblock(cur, rrblock, level, rrbp))) |
555 | return error; | 546 | return error; |
556 | INT_SET(rrblock->bb_leftsib, ARCH_CONVERT, lbno); | 547 | rrblock->bb_leftsib = cpu_to_be32(lbno); |
557 | xfs_alloc_log_block(cur->bc_tp, rrbp, XFS_BB_LEFTSIB); | 548 | xfs_alloc_log_block(cur->bc_tp, rrbp, XFS_BB_LEFTSIB); |
558 | } | 549 | } |
559 | /* | 550 | /* |
@@ -574,10 +565,9 @@ xfs_alloc_delrec( | |||
574 | * busy block is allocated, the iclog is pushed up to the | 565 | * busy block is allocated, the iclog is pushed up to the |
575 | * LSN that freed the block. | 566 | * LSN that freed the block. |
576 | */ | 567 | */ |
577 | xfs_alloc_mark_busy(cur->bc_tp, | 568 | xfs_alloc_mark_busy(cur->bc_tp, be32_to_cpu(agf->agf_seqno), bno, 1); |
578 | INT_GET(agf->agf_seqno, ARCH_CONVERT), bno, 1); | ||
579 | |||
580 | xfs_trans_agbtree_delta(cur->bc_tp, -1); | 569 | xfs_trans_agbtree_delta(cur->bc_tp, -1); |
570 | |||
581 | /* | 571 | /* |
582 | * Adjust the current level's cursor so that we're left referring | 572 | * Adjust the current level's cursor so that we're left referring |
583 | * to the right node, after we're done. | 573 | * to the right node, after we're done. |
@@ -625,7 +615,15 @@ xfs_alloc_insrec( | |||
625 | int ptr; /* index in btree block for this rec */ | 615 | int ptr; /* index in btree block for this rec */ |
626 | xfs_alloc_rec_t *rp; /* pointer to btree records */ | 616 | xfs_alloc_rec_t *rp; /* pointer to btree records */ |
627 | 617 | ||
628 | ASSERT(INT_GET(recp->ar_blockcount, ARCH_CONVERT) > 0); | 618 | ASSERT(be32_to_cpu(recp->ar_blockcount) > 0); |
619 | |||
620 | /* | ||
621 | * GCC doesn't understand the (arguably complex) control flow in | ||
622 | * this function and complains about uninitialized structure fields | ||
623 | * without this. | ||
624 | */ | ||
625 | memset(&nrec, 0, sizeof(nrec)); | ||
626 | |||
629 | /* | 627 | /* |
630 | * If we made it to the root level, allocate a new root block | 628 | * If we made it to the root level, allocate a new root block |
631 | * and we're done. | 629 | * and we're done. |
@@ -641,8 +639,8 @@ xfs_alloc_insrec( | |||
641 | /* | 639 | /* |
642 | * Make a key out of the record data to be inserted, and save it. | 640 | * Make a key out of the record data to be inserted, and save it. |
643 | */ | 641 | */ |
644 | key.ar_startblock = recp->ar_startblock; /* INT_: direct copy */ | 642 | key.ar_startblock = recp->ar_startblock; |
645 | key.ar_blockcount = recp->ar_blockcount; /* INT_: direct copy */ | 643 | key.ar_blockcount = recp->ar_blockcount; |
646 | optr = ptr = cur->bc_ptrs[level]; | 644 | optr = ptr = cur->bc_ptrs[level]; |
647 | /* | 645 | /* |
648 | * If we're off the left edge, return failure. | 646 | * If we're off the left edge, return failure. |
@@ -663,7 +661,7 @@ xfs_alloc_insrec( | |||
663 | /* | 661 | /* |
664 | * Check that the new entry is being inserted in the right place. | 662 | * Check that the new entry is being inserted in the right place. |
665 | */ | 663 | */ |
666 | if (ptr <= INT_GET(block->bb_numrecs, ARCH_CONVERT)) { | 664 | if (ptr <= be16_to_cpu(block->bb_numrecs)) { |
667 | if (level == 0) { | 665 | if (level == 0) { |
668 | rp = XFS_ALLOC_REC_ADDR(block, ptr, cur); | 666 | rp = XFS_ALLOC_REC_ADDR(block, ptr, cur); |
669 | xfs_btree_check_rec(cur->bc_btnum, recp, rp); | 667 | xfs_btree_check_rec(cur->bc_btnum, recp, rp); |
@@ -679,7 +677,7 @@ xfs_alloc_insrec( | |||
679 | * If the block is full, we can't insert the new entry until we | 677 | * If the block is full, we can't insert the new entry until we |
680 | * make the block un-full. | 678 | * make the block un-full. |
681 | */ | 679 | */ |
682 | if (INT_GET(block->bb_numrecs, ARCH_CONVERT) == XFS_ALLOC_BLOCK_MAXRECS(level, cur)) { | 680 | if (be16_to_cpu(block->bb_numrecs) == XFS_ALLOC_BLOCK_MAXRECS(level, cur)) { |
683 | /* | 681 | /* |
684 | * First, try shifting an entry to the right neighbor. | 682 | * First, try shifting an entry to the right neighbor. |
685 | */ | 683 | */ |
@@ -716,8 +714,8 @@ xfs_alloc_insrec( | |||
716 | return error; | 714 | return error; |
717 | #endif | 715 | #endif |
718 | ptr = cur->bc_ptrs[level]; | 716 | ptr = cur->bc_ptrs[level]; |
719 | nrec.ar_startblock = nkey.ar_startblock; /* INT_: direct copy */ | 717 | nrec.ar_startblock = nkey.ar_startblock; |
720 | nrec.ar_blockcount = nkey.ar_blockcount; /* INT_: direct copy */ | 718 | nrec.ar_blockcount = nkey.ar_blockcount; |
721 | } | 719 | } |
722 | /* | 720 | /* |
723 | * Otherwise the insert fails. | 721 | * Otherwise the insert fails. |
@@ -741,15 +739,15 @@ xfs_alloc_insrec( | |||
741 | kp = XFS_ALLOC_KEY_ADDR(block, 1, cur); | 739 | kp = XFS_ALLOC_KEY_ADDR(block, 1, cur); |
742 | pp = XFS_ALLOC_PTR_ADDR(block, 1, cur); | 740 | pp = XFS_ALLOC_PTR_ADDR(block, 1, cur); |
743 | #ifdef DEBUG | 741 | #ifdef DEBUG |
744 | for (i = INT_GET(block->bb_numrecs, ARCH_CONVERT); i >= ptr; i--) { | 742 | for (i = be16_to_cpu(block->bb_numrecs); i >= ptr; i--) { |
745 | if ((error = xfs_btree_check_sptr(cur, INT_GET(pp[i - 1], ARCH_CONVERT), level))) | 743 | if ((error = xfs_btree_check_sptr(cur, be32_to_cpu(pp[i - 1]), level))) |
746 | return error; | 744 | return error; |
747 | } | 745 | } |
748 | #endif | 746 | #endif |
749 | memmove(&kp[ptr], &kp[ptr - 1], | 747 | memmove(&kp[ptr], &kp[ptr - 1], |
750 | (INT_GET(block->bb_numrecs, ARCH_CONVERT) - ptr + 1) * sizeof(*kp)); /* INT_: copy */ | 748 | (be16_to_cpu(block->bb_numrecs) - ptr + 1) * sizeof(*kp)); |
751 | memmove(&pp[ptr], &pp[ptr - 1], | 749 | memmove(&pp[ptr], &pp[ptr - 1], |
752 | (INT_GET(block->bb_numrecs, ARCH_CONVERT) - ptr + 1) * sizeof(*pp)); /* INT_: copy */ | 750 | (be16_to_cpu(block->bb_numrecs) - ptr + 1) * sizeof(*pp)); |
753 | #ifdef DEBUG | 751 | #ifdef DEBUG |
754 | if ((error = xfs_btree_check_sptr(cur, *bnop, level))) | 752 | if ((error = xfs_btree_check_sptr(cur, *bnop, level))) |
755 | return error; | 753 | return error; |
@@ -758,12 +756,12 @@ xfs_alloc_insrec( | |||
758 | * Now stuff the new data in, bump numrecs and log the new data. | 756 | * Now stuff the new data in, bump numrecs and log the new data. |
759 | */ | 757 | */ |
760 | kp[ptr - 1] = key; | 758 | kp[ptr - 1] = key; |
761 | INT_SET(pp[ptr - 1], ARCH_CONVERT, *bnop); | 759 | pp[ptr - 1] = cpu_to_be32(*bnop); |
762 | INT_MOD(block->bb_numrecs, ARCH_CONVERT, +1); | 760 | be16_add(&block->bb_numrecs, 1); |
763 | xfs_alloc_log_keys(cur, bp, ptr, INT_GET(block->bb_numrecs, ARCH_CONVERT)); | 761 | xfs_alloc_log_keys(cur, bp, ptr, be16_to_cpu(block->bb_numrecs)); |
764 | xfs_alloc_log_ptrs(cur, bp, ptr, INT_GET(block->bb_numrecs, ARCH_CONVERT)); | 762 | xfs_alloc_log_ptrs(cur, bp, ptr, be16_to_cpu(block->bb_numrecs)); |
765 | #ifdef DEBUG | 763 | #ifdef DEBUG |
766 | if (ptr < INT_GET(block->bb_numrecs, ARCH_CONVERT)) | 764 | if (ptr < be16_to_cpu(block->bb_numrecs)) |
767 | xfs_btree_check_key(cur->bc_btnum, kp + ptr - 1, | 765 | xfs_btree_check_key(cur->bc_btnum, kp + ptr - 1, |
768 | kp + ptr); | 766 | kp + ptr); |
769 | #endif | 767 | #endif |
@@ -773,16 +771,16 @@ xfs_alloc_insrec( | |||
773 | */ | 771 | */ |
774 | rp = XFS_ALLOC_REC_ADDR(block, 1, cur); | 772 | rp = XFS_ALLOC_REC_ADDR(block, 1, cur); |
775 | memmove(&rp[ptr], &rp[ptr - 1], | 773 | memmove(&rp[ptr], &rp[ptr - 1], |
776 | (INT_GET(block->bb_numrecs, ARCH_CONVERT) - ptr + 1) * sizeof(*rp)); | 774 | (be16_to_cpu(block->bb_numrecs) - ptr + 1) * sizeof(*rp)); |
777 | /* | 775 | /* |
778 | * Now stuff the new record in, bump numrecs | 776 | * Now stuff the new record in, bump numrecs |
779 | * and log the new data. | 777 | * and log the new data. |
780 | */ | 778 | */ |
781 | rp[ptr - 1] = *recp; /* INT_: struct copy */ | 779 | rp[ptr - 1] = *recp; /* INT_: struct copy */ |
782 | INT_MOD(block->bb_numrecs, ARCH_CONVERT, +1); | 780 | be16_add(&block->bb_numrecs, 1); |
783 | xfs_alloc_log_recs(cur, bp, ptr, INT_GET(block->bb_numrecs, ARCH_CONVERT)); | 781 | xfs_alloc_log_recs(cur, bp, ptr, be16_to_cpu(block->bb_numrecs)); |
784 | #ifdef DEBUG | 782 | #ifdef DEBUG |
785 | if (ptr < INT_GET(block->bb_numrecs, ARCH_CONVERT)) | 783 | if (ptr < be16_to_cpu(block->bb_numrecs)) |
786 | xfs_btree_check_rec(cur->bc_btnum, rp + ptr - 1, | 784 | xfs_btree_check_rec(cur->bc_btnum, rp + ptr - 1, |
787 | rp + ptr); | 785 | rp + ptr); |
788 | #endif | 786 | #endif |
@@ -804,16 +802,16 @@ xfs_alloc_insrec( | |||
804 | agf = XFS_BUF_TO_AGF(cur->bc_private.a.agbp); | 802 | agf = XFS_BUF_TO_AGF(cur->bc_private.a.agbp); |
805 | if (level == 0 && | 803 | if (level == 0 && |
806 | cur->bc_btnum == XFS_BTNUM_CNT && | 804 | cur->bc_btnum == XFS_BTNUM_CNT && |
807 | INT_GET(block->bb_rightsib, ARCH_CONVERT) == NULLAGBLOCK && | 805 | be32_to_cpu(block->bb_rightsib) == NULLAGBLOCK && |
808 | INT_GET(recp->ar_blockcount, ARCH_CONVERT) > INT_GET(agf->agf_longest, ARCH_CONVERT)) { | 806 | be32_to_cpu(recp->ar_blockcount) > be32_to_cpu(agf->agf_longest)) { |
809 | /* | 807 | /* |
810 | * If this is a leaf in the by-size btree and there | 808 | * If this is a leaf in the by-size btree and there |
811 | * is no right sibling block and this block is bigger | 809 | * is no right sibling block and this block is bigger |
812 | * than the previous longest block, update it. | 810 | * than the previous longest block, update it. |
813 | */ | 811 | */ |
814 | INT_COPY(agf->agf_longest, recp->ar_blockcount, ARCH_CONVERT); | 812 | agf->agf_longest = recp->ar_blockcount; |
815 | cur->bc_mp->m_perag[INT_GET(agf->agf_seqno, ARCH_CONVERT)].pagf_longest | 813 | cur->bc_mp->m_perag[be32_to_cpu(agf->agf_seqno)].pagf_longest |
816 | = INT_GET(recp->ar_blockcount, ARCH_CONVERT); | 814 | = be32_to_cpu(recp->ar_blockcount); |
817 | xfs_alloc_log_agf(cur->bc_tp, cur->bc_private.a.agbp, | 815 | xfs_alloc_log_agf(cur->bc_tp, cur->bc_private.a.agbp, |
818 | XFS_AGF_LONGEST); | 816 | XFS_AGF_LONGEST); |
819 | } | 817 | } |
@@ -923,8 +921,9 @@ xfs_alloc_log_recs( | |||
923 | 921 | ||
924 | agf = XFS_BUF_TO_AGF(cur->bc_private.a.agbp); | 922 | agf = XFS_BUF_TO_AGF(cur->bc_private.a.agbp); |
925 | for (p = &rp[rfirst - 1]; p <= &rp[rlast - 1]; p++) | 923 | for (p = &rp[rfirst - 1]; p <= &rp[rlast - 1]; p++) |
926 | ASSERT(INT_GET(p->ar_startblock, ARCH_CONVERT) + INT_GET(p->ar_blockcount, ARCH_CONVERT) <= | 924 | ASSERT(be32_to_cpu(p->ar_startblock) + |
927 | INT_GET(agf->agf_length, ARCH_CONVERT)); | 925 | be32_to_cpu(p->ar_blockcount) <= |
926 | be32_to_cpu(agf->agf_length)); | ||
928 | } | 927 | } |
929 | #endif | 928 | #endif |
930 | first = (int)((xfs_caddr_t)&rp[rfirst - 1] - (xfs_caddr_t)block); | 929 | first = (int)((xfs_caddr_t)&rp[rfirst - 1] - (xfs_caddr_t)block); |
@@ -961,8 +960,8 @@ xfs_alloc_lookup( | |||
961 | xfs_agf_t *agf; /* a.g. freespace header */ | 960 | xfs_agf_t *agf; /* a.g. freespace header */ |
962 | 961 | ||
963 | agf = XFS_BUF_TO_AGF(cur->bc_private.a.agbp); | 962 | agf = XFS_BUF_TO_AGF(cur->bc_private.a.agbp); |
964 | agno = INT_GET(agf->agf_seqno, ARCH_CONVERT); | 963 | agno = be32_to_cpu(agf->agf_seqno); |
965 | agbno = INT_GET(agf->agf_roots[cur->bc_btnum], ARCH_CONVERT); | 964 | agbno = be32_to_cpu(agf->agf_roots[cur->bc_btnum]); |
966 | } | 965 | } |
967 | /* | 966 | /* |
968 | * Iterate over each level in the btree, starting at the root. | 967 | * Iterate over each level in the btree, starting at the root. |
@@ -1029,7 +1028,7 @@ xfs_alloc_lookup( | |||
1029 | * Set low and high entry numbers, 1-based. | 1028 | * Set low and high entry numbers, 1-based. |
1030 | */ | 1029 | */ |
1031 | low = 1; | 1030 | low = 1; |
1032 | if (!(high = INT_GET(block->bb_numrecs, ARCH_CONVERT))) { | 1031 | if (!(high = be16_to_cpu(block->bb_numrecs))) { |
1033 | /* | 1032 | /* |
1034 | * If the block is empty, the tree must | 1033 | * If the block is empty, the tree must |
1035 | * be an empty leaf. | 1034 | * be an empty leaf. |
@@ -1058,14 +1057,14 @@ xfs_alloc_lookup( | |||
1058 | xfs_alloc_key_t *kkp; | 1057 | xfs_alloc_key_t *kkp; |
1059 | 1058 | ||
1060 | kkp = kkbase + keyno - 1; | 1059 | kkp = kkbase + keyno - 1; |
1061 | startblock = INT_GET(kkp->ar_startblock, ARCH_CONVERT); | 1060 | startblock = be32_to_cpu(kkp->ar_startblock); |
1062 | blockcount = INT_GET(kkp->ar_blockcount, ARCH_CONVERT); | 1061 | blockcount = be32_to_cpu(kkp->ar_blockcount); |
1063 | } else { | 1062 | } else { |
1064 | xfs_alloc_rec_t *krp; | 1063 | xfs_alloc_rec_t *krp; |
1065 | 1064 | ||
1066 | krp = krbase + keyno - 1; | 1065 | krp = krbase + keyno - 1; |
1067 | startblock = INT_GET(krp->ar_startblock, ARCH_CONVERT); | 1066 | startblock = be32_to_cpu(krp->ar_startblock); |
1068 | blockcount = INT_GET(krp->ar_blockcount, ARCH_CONVERT); | 1067 | blockcount = be32_to_cpu(krp->ar_blockcount); |
1069 | } | 1068 | } |
1070 | /* | 1069 | /* |
1071 | * Compute difference to get next direction. | 1070 | * Compute difference to get next direction. |
@@ -1105,7 +1104,7 @@ xfs_alloc_lookup( | |||
1105 | */ | 1104 | */ |
1106 | if (diff > 0 && --keyno < 1) | 1105 | if (diff > 0 && --keyno < 1) |
1107 | keyno = 1; | 1106 | keyno = 1; |
1108 | agbno = INT_GET(*XFS_ALLOC_PTR_ADDR(block, keyno, cur), ARCH_CONVERT); | 1107 | agbno = be32_to_cpu(*XFS_ALLOC_PTR_ADDR(block, keyno, cur)); |
1109 | #ifdef DEBUG | 1108 | #ifdef DEBUG |
1110 | if ((error = xfs_btree_check_sptr(cur, agbno, level))) | 1109 | if ((error = xfs_btree_check_sptr(cur, agbno, level))) |
1111 | return error; | 1110 | return error; |
@@ -1124,8 +1123,8 @@ xfs_alloc_lookup( | |||
1124 | * not the last block, we're in the wrong block. | 1123 | * not the last block, we're in the wrong block. |
1125 | */ | 1124 | */ |
1126 | if (dir == XFS_LOOKUP_GE && | 1125 | if (dir == XFS_LOOKUP_GE && |
1127 | keyno > INT_GET(block->bb_numrecs, ARCH_CONVERT) && | 1126 | keyno > be16_to_cpu(block->bb_numrecs) && |
1128 | INT_GET(block->bb_rightsib, ARCH_CONVERT) != NULLAGBLOCK) { | 1127 | be32_to_cpu(block->bb_rightsib) != NULLAGBLOCK) { |
1129 | int i; | 1128 | int i; |
1130 | 1129 | ||
1131 | cur->bc_ptrs[0] = keyno; | 1130 | cur->bc_ptrs[0] = keyno; |
@@ -1142,7 +1141,7 @@ xfs_alloc_lookup( | |||
1142 | /* | 1141 | /* |
1143 | * Return if we succeeded or not. | 1142 | * Return if we succeeded or not. |
1144 | */ | 1143 | */ |
1145 | if (keyno == 0 || keyno > INT_GET(block->bb_numrecs, ARCH_CONVERT)) | 1144 | if (keyno == 0 || keyno > be16_to_cpu(block->bb_numrecs)) |
1146 | *stat = 0; | 1145 | *stat = 0; |
1147 | else | 1146 | else |
1148 | *stat = ((dir != XFS_LOOKUP_EQ) || (diff == 0)); | 1147 | *stat = ((dir != XFS_LOOKUP_EQ) || (diff == 0)); |
@@ -1185,7 +1184,7 @@ xfs_alloc_lshift( | |||
1185 | /* | 1184 | /* |
1186 | * If we've got no left sibling then we can't shift an entry left. | 1185 | * If we've got no left sibling then we can't shift an entry left. |
1187 | */ | 1186 | */ |
1188 | if (INT_GET(right->bb_leftsib, ARCH_CONVERT) == NULLAGBLOCK) { | 1187 | if (be32_to_cpu(right->bb_leftsib) == NULLAGBLOCK) { |
1189 | *stat = 0; | 1188 | *stat = 0; |
1190 | return 0; | 1189 | return 0; |
1191 | } | 1190 | } |
@@ -1201,8 +1200,8 @@ xfs_alloc_lshift( | |||
1201 | * Set up the left neighbor as "left". | 1200 | * Set up the left neighbor as "left". |
1202 | */ | 1201 | */ |
1203 | if ((error = xfs_btree_read_bufs(cur->bc_mp, cur->bc_tp, | 1202 | if ((error = xfs_btree_read_bufs(cur->bc_mp, cur->bc_tp, |
1204 | cur->bc_private.a.agno, INT_GET(right->bb_leftsib, ARCH_CONVERT), 0, &lbp, | 1203 | cur->bc_private.a.agno, be32_to_cpu(right->bb_leftsib), |
1205 | XFS_ALLOC_BTREE_REF))) | 1204 | 0, &lbp, XFS_ALLOC_BTREE_REF))) |
1206 | return error; | 1205 | return error; |
1207 | left = XFS_BUF_TO_ALLOC_BLOCK(lbp); | 1206 | left = XFS_BUF_TO_ALLOC_BLOCK(lbp); |
1208 | if ((error = xfs_btree_check_sblock(cur, left, level, lbp))) | 1207 | if ((error = xfs_btree_check_sblock(cur, left, level, lbp))) |
@@ -1210,11 +1209,11 @@ xfs_alloc_lshift( | |||
1210 | /* | 1209 | /* |
1211 | * If it's full, it can't take another entry. | 1210 | * If it's full, it can't take another entry. |
1212 | */ | 1211 | */ |
1213 | if (INT_GET(left->bb_numrecs, ARCH_CONVERT) == XFS_ALLOC_BLOCK_MAXRECS(level, cur)) { | 1212 | if (be16_to_cpu(left->bb_numrecs) == XFS_ALLOC_BLOCK_MAXRECS(level, cur)) { |
1214 | *stat = 0; | 1213 | *stat = 0; |
1215 | return 0; | 1214 | return 0; |
1216 | } | 1215 | } |
1217 | nrec = INT_GET(left->bb_numrecs, ARCH_CONVERT) + 1; | 1216 | nrec = be16_to_cpu(left->bb_numrecs) + 1; |
1218 | /* | 1217 | /* |
1219 | * If non-leaf, copy a key and a ptr to the left block. | 1218 | * If non-leaf, copy a key and a ptr to the left block. |
1220 | */ | 1219 | */ |
@@ -1229,7 +1228,7 @@ xfs_alloc_lshift( | |||
1229 | lpp = XFS_ALLOC_PTR_ADDR(left, nrec, cur); | 1228 | lpp = XFS_ALLOC_PTR_ADDR(left, nrec, cur); |
1230 | rpp = XFS_ALLOC_PTR_ADDR(right, 1, cur); | 1229 | rpp = XFS_ALLOC_PTR_ADDR(right, 1, cur); |
1231 | #ifdef DEBUG | 1230 | #ifdef DEBUG |
1232 | if ((error = xfs_btree_check_sptr(cur, INT_GET(*rpp, ARCH_CONVERT), level))) | 1231 | if ((error = xfs_btree_check_sptr(cur, be32_to_cpu(*rpp), level))) |
1233 | return error; | 1232 | return error; |
1234 | #endif | 1233 | #endif |
1235 | *lpp = *rpp; /* INT_: copy */ | 1234 | *lpp = *rpp; /* INT_: copy */ |
@@ -1251,30 +1250,30 @@ xfs_alloc_lshift( | |||
1251 | /* | 1250 | /* |
1252 | * Bump and log left's numrecs, decrement and log right's numrecs. | 1251 | * Bump and log left's numrecs, decrement and log right's numrecs. |
1253 | */ | 1252 | */ |
1254 | INT_MOD(left->bb_numrecs, ARCH_CONVERT, +1); | 1253 | be16_add(&left->bb_numrecs, 1); |
1255 | xfs_alloc_log_block(cur->bc_tp, lbp, XFS_BB_NUMRECS); | 1254 | xfs_alloc_log_block(cur->bc_tp, lbp, XFS_BB_NUMRECS); |
1256 | INT_MOD(right->bb_numrecs, ARCH_CONVERT, -1); | 1255 | be16_add(&right->bb_numrecs, -1); |
1257 | xfs_alloc_log_block(cur->bc_tp, rbp, XFS_BB_NUMRECS); | 1256 | xfs_alloc_log_block(cur->bc_tp, rbp, XFS_BB_NUMRECS); |
1258 | /* | 1257 | /* |
1259 | * Slide the contents of right down one entry. | 1258 | * Slide the contents of right down one entry. |
1260 | */ | 1259 | */ |
1261 | if (level > 0) { | 1260 | if (level > 0) { |
1262 | #ifdef DEBUG | 1261 | #ifdef DEBUG |
1263 | for (i = 0; i < INT_GET(right->bb_numrecs, ARCH_CONVERT); i++) { | 1262 | for (i = 0; i < be16_to_cpu(right->bb_numrecs); i++) { |
1264 | if ((error = xfs_btree_check_sptr(cur, INT_GET(rpp[i + 1], ARCH_CONVERT), | 1263 | if ((error = xfs_btree_check_sptr(cur, be32_to_cpu(rpp[i + 1]), |
1265 | level))) | 1264 | level))) |
1266 | return error; | 1265 | return error; |
1267 | } | 1266 | } |
1268 | #endif | 1267 | #endif |
1269 | memmove(rkp, rkp + 1, INT_GET(right->bb_numrecs, ARCH_CONVERT) * sizeof(*rkp)); | 1268 | memmove(rkp, rkp + 1, be16_to_cpu(right->bb_numrecs) * sizeof(*rkp)); |
1270 | memmove(rpp, rpp + 1, INT_GET(right->bb_numrecs, ARCH_CONVERT) * sizeof(*rpp)); | 1269 | memmove(rpp, rpp + 1, be16_to_cpu(right->bb_numrecs) * sizeof(*rpp)); |
1271 | xfs_alloc_log_keys(cur, rbp, 1, INT_GET(right->bb_numrecs, ARCH_CONVERT)); | 1270 | xfs_alloc_log_keys(cur, rbp, 1, be16_to_cpu(right->bb_numrecs)); |
1272 | xfs_alloc_log_ptrs(cur, rbp, 1, INT_GET(right->bb_numrecs, ARCH_CONVERT)); | 1271 | xfs_alloc_log_ptrs(cur, rbp, 1, be16_to_cpu(right->bb_numrecs)); |
1273 | } else { | 1272 | } else { |
1274 | memmove(rrp, rrp + 1, INT_GET(right->bb_numrecs, ARCH_CONVERT) * sizeof(*rrp)); | 1273 | memmove(rrp, rrp + 1, be16_to_cpu(right->bb_numrecs) * sizeof(*rrp)); |
1275 | xfs_alloc_log_recs(cur, rbp, 1, INT_GET(right->bb_numrecs, ARCH_CONVERT)); | 1274 | xfs_alloc_log_recs(cur, rbp, 1, be16_to_cpu(right->bb_numrecs)); |
1276 | key.ar_startblock = rrp->ar_startblock; /* INT_: direct copy */ | 1275 | key.ar_startblock = rrp->ar_startblock; |
1277 | key.ar_blockcount = rrp->ar_blockcount; /* INT_: direct copy */ | 1276 | key.ar_blockcount = rrp->ar_blockcount; |
1278 | rkp = &key; | 1277 | rkp = &key; |
1279 | } | 1278 | } |
1280 | /* | 1279 | /* |
@@ -1339,9 +1338,9 @@ xfs_alloc_newroot( | |||
1339 | xfs_agnumber_t seqno; | 1338 | xfs_agnumber_t seqno; |
1340 | 1339 | ||
1341 | agf = XFS_BUF_TO_AGF(cur->bc_private.a.agbp); | 1340 | agf = XFS_BUF_TO_AGF(cur->bc_private.a.agbp); |
1342 | INT_SET(agf->agf_roots[cur->bc_btnum], ARCH_CONVERT, nbno); | 1341 | agf->agf_roots[cur->bc_btnum] = cpu_to_be32(nbno); |
1343 | INT_MOD(agf->agf_levels[cur->bc_btnum], ARCH_CONVERT, 1); | 1342 | be32_add(&agf->agf_levels[cur->bc_btnum], 1); |
1344 | seqno = INT_GET(agf->agf_seqno, ARCH_CONVERT); | 1343 | seqno = be32_to_cpu(agf->agf_seqno); |
1345 | mp->m_perag[seqno].pagf_levels[cur->bc_btnum]++; | 1344 | mp->m_perag[seqno].pagf_levels[cur->bc_btnum]++; |
1346 | xfs_alloc_log_agf(cur->bc_tp, cur->bc_private.a.agbp, | 1345 | xfs_alloc_log_agf(cur->bc_tp, cur->bc_private.a.agbp, |
1347 | XFS_AGF_ROOTS | XFS_AGF_LEVELS); | 1346 | XFS_AGF_ROOTS | XFS_AGF_LEVELS); |
@@ -1358,12 +1357,12 @@ xfs_alloc_newroot( | |||
1358 | if ((error = xfs_btree_check_sblock(cur, left, cur->bc_nlevels - 1, lbp))) | 1357 | if ((error = xfs_btree_check_sblock(cur, left, cur->bc_nlevels - 1, lbp))) |
1359 | return error; | 1358 | return error; |
1360 | #endif | 1359 | #endif |
1361 | if (INT_GET(left->bb_rightsib, ARCH_CONVERT) != NULLAGBLOCK) { | 1360 | if (be32_to_cpu(left->bb_rightsib) != NULLAGBLOCK) { |
1362 | /* | 1361 | /* |
1363 | * Our block is left, pick up the right block. | 1362 | * Our block is left, pick up the right block. |
1364 | */ | 1363 | */ |
1365 | lbno = XFS_DADDR_TO_AGBNO(mp, XFS_BUF_ADDR(lbp)); | 1364 | lbno = XFS_DADDR_TO_AGBNO(mp, XFS_BUF_ADDR(lbp)); |
1366 | rbno = INT_GET(left->bb_rightsib, ARCH_CONVERT); | 1365 | rbno = be32_to_cpu(left->bb_rightsib); |
1367 | if ((error = xfs_btree_read_bufs(mp, cur->bc_tp, | 1366 | if ((error = xfs_btree_read_bufs(mp, cur->bc_tp, |
1368 | cur->bc_private.a.agno, rbno, 0, &rbp, | 1367 | cur->bc_private.a.agno, rbno, 0, &rbp, |
1369 | XFS_ALLOC_BTREE_REF))) | 1368 | XFS_ALLOC_BTREE_REF))) |
@@ -1380,7 +1379,7 @@ xfs_alloc_newroot( | |||
1380 | rbp = lbp; | 1379 | rbp = lbp; |
1381 | right = left; | 1380 | right = left; |
1382 | rbno = XFS_DADDR_TO_AGBNO(mp, XFS_BUF_ADDR(rbp)); | 1381 | rbno = XFS_DADDR_TO_AGBNO(mp, XFS_BUF_ADDR(rbp)); |
1383 | lbno = INT_GET(right->bb_leftsib, ARCH_CONVERT); | 1382 | lbno = be32_to_cpu(right->bb_leftsib); |
1384 | if ((error = xfs_btree_read_bufs(mp, cur->bc_tp, | 1383 | if ((error = xfs_btree_read_bufs(mp, cur->bc_tp, |
1385 | cur->bc_private.a.agno, lbno, 0, &lbp, | 1384 | cur->bc_private.a.agno, lbno, 0, &lbp, |
1386 | XFS_ALLOC_BTREE_REF))) | 1385 | XFS_ALLOC_BTREE_REF))) |
@@ -1394,11 +1393,11 @@ xfs_alloc_newroot( | |||
1394 | /* | 1393 | /* |
1395 | * Fill in the new block's btree header and log it. | 1394 | * Fill in the new block's btree header and log it. |
1396 | */ | 1395 | */ |
1397 | INT_SET(new->bb_magic, ARCH_CONVERT, xfs_magics[cur->bc_btnum]); | 1396 | new->bb_magic = cpu_to_be32(xfs_magics[cur->bc_btnum]); |
1398 | INT_SET(new->bb_level, ARCH_CONVERT, (__uint16_t)cur->bc_nlevels); | 1397 | new->bb_level = cpu_to_be16(cur->bc_nlevels); |
1399 | INT_SET(new->bb_numrecs, ARCH_CONVERT, 2); | 1398 | new->bb_numrecs = cpu_to_be16(2); |
1400 | INT_SET(new->bb_leftsib, ARCH_CONVERT, NULLAGBLOCK); | 1399 | new->bb_leftsib = cpu_to_be32(NULLAGBLOCK); |
1401 | INT_SET(new->bb_rightsib, ARCH_CONVERT, NULLAGBLOCK); | 1400 | new->bb_rightsib = cpu_to_be32(NULLAGBLOCK); |
1402 | xfs_alloc_log_block(cur->bc_tp, nbp, XFS_BB_ALL_BITS); | 1401 | xfs_alloc_log_block(cur->bc_tp, nbp, XFS_BB_ALL_BITS); |
1403 | ASSERT(lbno != NULLAGBLOCK && rbno != NULLAGBLOCK); | 1402 | ASSERT(lbno != NULLAGBLOCK && rbno != NULLAGBLOCK); |
1404 | /* | 1403 | /* |
@@ -1408,18 +1407,18 @@ xfs_alloc_newroot( | |||
1408 | xfs_alloc_key_t *kp; /* btree key pointer */ | 1407 | xfs_alloc_key_t *kp; /* btree key pointer */ |
1409 | 1408 | ||
1410 | kp = XFS_ALLOC_KEY_ADDR(new, 1, cur); | 1409 | kp = XFS_ALLOC_KEY_ADDR(new, 1, cur); |
1411 | if (INT_GET(left->bb_level, ARCH_CONVERT) > 0) { | 1410 | if (be16_to_cpu(left->bb_level) > 0) { |
1412 | kp[0] = *XFS_ALLOC_KEY_ADDR(left, 1, cur); /* INT_: structure copy */ | 1411 | kp[0] = *XFS_ALLOC_KEY_ADDR(left, 1, cur); /* INT_: structure copy */ |
1413 | kp[1] = *XFS_ALLOC_KEY_ADDR(right, 1, cur);/* INT_: structure copy */ | 1412 | kp[1] = *XFS_ALLOC_KEY_ADDR(right, 1, cur);/* INT_: structure copy */ |
1414 | } else { | 1413 | } else { |
1415 | xfs_alloc_rec_t *rp; /* btree record pointer */ | 1414 | xfs_alloc_rec_t *rp; /* btree record pointer */ |
1416 | 1415 | ||
1417 | rp = XFS_ALLOC_REC_ADDR(left, 1, cur); | 1416 | rp = XFS_ALLOC_REC_ADDR(left, 1, cur); |
1418 | kp[0].ar_startblock = rp->ar_startblock; /* INT_: direct copy */ | 1417 | kp[0].ar_startblock = rp->ar_startblock; |
1419 | kp[0].ar_blockcount = rp->ar_blockcount; /* INT_: direct copy */ | 1418 | kp[0].ar_blockcount = rp->ar_blockcount; |
1420 | rp = XFS_ALLOC_REC_ADDR(right, 1, cur); | 1419 | rp = XFS_ALLOC_REC_ADDR(right, 1, cur); |
1421 | kp[1].ar_startblock = rp->ar_startblock; /* INT_: direct copy */ | 1420 | kp[1].ar_startblock = rp->ar_startblock; |
1422 | kp[1].ar_blockcount = rp->ar_blockcount; /* INT_: direct copy */ | 1421 | kp[1].ar_blockcount = rp->ar_blockcount; |
1423 | } | 1422 | } |
1424 | } | 1423 | } |
1425 | xfs_alloc_log_keys(cur, nbp, 1, 2); | 1424 | xfs_alloc_log_keys(cur, nbp, 1, 2); |
@@ -1430,8 +1429,8 @@ xfs_alloc_newroot( | |||
1430 | xfs_alloc_ptr_t *pp; /* btree address pointer */ | 1429 | xfs_alloc_ptr_t *pp; /* btree address pointer */ |
1431 | 1430 | ||
1432 | pp = XFS_ALLOC_PTR_ADDR(new, 1, cur); | 1431 | pp = XFS_ALLOC_PTR_ADDR(new, 1, cur); |
1433 | INT_SET(pp[0], ARCH_CONVERT, lbno); | 1432 | pp[0] = cpu_to_be32(lbno); |
1434 | INT_SET(pp[1], ARCH_CONVERT, rbno); | 1433 | pp[1] = cpu_to_be32(rbno); |
1435 | } | 1434 | } |
1436 | xfs_alloc_log_ptrs(cur, nbp, 1, 2); | 1435 | xfs_alloc_log_ptrs(cur, nbp, 1, 2); |
1437 | /* | 1436 | /* |
@@ -1476,7 +1475,7 @@ xfs_alloc_rshift( | |||
1476 | /* | 1475 | /* |
1477 | * If we've got no right sibling then we can't shift an entry right. | 1476 | * If we've got no right sibling then we can't shift an entry right. |
1478 | */ | 1477 | */ |
1479 | if (INT_GET(left->bb_rightsib, ARCH_CONVERT) == NULLAGBLOCK) { | 1478 | if (be32_to_cpu(left->bb_rightsib) == NULLAGBLOCK) { |
1480 | *stat = 0; | 1479 | *stat = 0; |
1481 | return 0; | 1480 | return 0; |
1482 | } | 1481 | } |
@@ -1484,7 +1483,7 @@ xfs_alloc_rshift( | |||
1484 | * If the cursor entry is the one that would be moved, don't | 1483 | * If the cursor entry is the one that would be moved, don't |
1485 | * do it... it's too complicated. | 1484 | * do it... it's too complicated. |
1486 | */ | 1485 | */ |
1487 | if (cur->bc_ptrs[level] >= INT_GET(left->bb_numrecs, ARCH_CONVERT)) { | 1486 | if (cur->bc_ptrs[level] >= be16_to_cpu(left->bb_numrecs)) { |
1488 | *stat = 0; | 1487 | *stat = 0; |
1489 | return 0; | 1488 | return 0; |
1490 | } | 1489 | } |
@@ -1492,8 +1491,8 @@ xfs_alloc_rshift( | |||
1492 | * Set up the right neighbor as "right". | 1491 | * Set up the right neighbor as "right". |
1493 | */ | 1492 | */ |
1494 | if ((error = xfs_btree_read_bufs(cur->bc_mp, cur->bc_tp, | 1493 | if ((error = xfs_btree_read_bufs(cur->bc_mp, cur->bc_tp, |
1495 | cur->bc_private.a.agno, INT_GET(left->bb_rightsib, ARCH_CONVERT), 0, &rbp, | 1494 | cur->bc_private.a.agno, be32_to_cpu(left->bb_rightsib), |
1496 | XFS_ALLOC_BTREE_REF))) | 1495 | 0, &rbp, XFS_ALLOC_BTREE_REF))) |
1497 | return error; | 1496 | return error; |
1498 | right = XFS_BUF_TO_ALLOC_BLOCK(rbp); | 1497 | right = XFS_BUF_TO_ALLOC_BLOCK(rbp); |
1499 | if ((error = xfs_btree_check_sblock(cur, right, level, rbp))) | 1498 | if ((error = xfs_btree_check_sblock(cur, right, level, rbp))) |
@@ -1501,7 +1500,7 @@ xfs_alloc_rshift( | |||
1501 | /* | 1500 | /* |
1502 | * If it's full, it can't take another entry. | 1501 | * If it's full, it can't take another entry. |
1503 | */ | 1502 | */ |
1504 | if (INT_GET(right->bb_numrecs, ARCH_CONVERT) == XFS_ALLOC_BLOCK_MAXRECS(level, cur)) { | 1503 | if (be16_to_cpu(right->bb_numrecs) == XFS_ALLOC_BLOCK_MAXRECS(level, cur)) { |
1505 | *stat = 0; | 1504 | *stat = 0; |
1506 | return 0; | 1505 | return 0; |
1507 | } | 1506 | } |
@@ -1514,47 +1513,47 @@ xfs_alloc_rshift( | |||
1514 | xfs_alloc_ptr_t *lpp; /* address pointer for left block */ | 1513 | xfs_alloc_ptr_t *lpp; /* address pointer for left block */ |
1515 | xfs_alloc_ptr_t *rpp; /* address pointer for right block */ | 1514 | xfs_alloc_ptr_t *rpp; /* address pointer for right block */ |
1516 | 1515 | ||
1517 | lkp = XFS_ALLOC_KEY_ADDR(left, INT_GET(left->bb_numrecs, ARCH_CONVERT), cur); | 1516 | lkp = XFS_ALLOC_KEY_ADDR(left, be16_to_cpu(left->bb_numrecs), cur); |
1518 | lpp = XFS_ALLOC_PTR_ADDR(left, INT_GET(left->bb_numrecs, ARCH_CONVERT), cur); | 1517 | lpp = XFS_ALLOC_PTR_ADDR(left, be16_to_cpu(left->bb_numrecs), cur); |
1519 | rkp = XFS_ALLOC_KEY_ADDR(right, 1, cur); | 1518 | rkp = XFS_ALLOC_KEY_ADDR(right, 1, cur); |
1520 | rpp = XFS_ALLOC_PTR_ADDR(right, 1, cur); | 1519 | rpp = XFS_ALLOC_PTR_ADDR(right, 1, cur); |
1521 | #ifdef DEBUG | 1520 | #ifdef DEBUG |
1522 | for (i = INT_GET(right->bb_numrecs, ARCH_CONVERT) - 1; i >= 0; i--) { | 1521 | for (i = be16_to_cpu(right->bb_numrecs) - 1; i >= 0; i--) { |
1523 | if ((error = xfs_btree_check_sptr(cur, INT_GET(rpp[i], ARCH_CONVERT), level))) | 1522 | if ((error = xfs_btree_check_sptr(cur, be32_to_cpu(rpp[i]), level))) |
1524 | return error; | 1523 | return error; |
1525 | } | 1524 | } |
1526 | #endif | 1525 | #endif |
1527 | memmove(rkp + 1, rkp, INT_GET(right->bb_numrecs, ARCH_CONVERT) * sizeof(*rkp)); | 1526 | memmove(rkp + 1, rkp, be16_to_cpu(right->bb_numrecs) * sizeof(*rkp)); |
1528 | memmove(rpp + 1, rpp, INT_GET(right->bb_numrecs, ARCH_CONVERT) * sizeof(*rpp)); | 1527 | memmove(rpp + 1, rpp, be16_to_cpu(right->bb_numrecs) * sizeof(*rpp)); |
1529 | #ifdef DEBUG | 1528 | #ifdef DEBUG |
1530 | if ((error = xfs_btree_check_sptr(cur, INT_GET(*lpp, ARCH_CONVERT), level))) | 1529 | if ((error = xfs_btree_check_sptr(cur, be32_to_cpu(*lpp), level))) |
1531 | return error; | 1530 | return error; |
1532 | #endif | 1531 | #endif |
1533 | *rkp = *lkp; /* INT_: copy */ | 1532 | *rkp = *lkp; /* INT_: copy */ |
1534 | *rpp = *lpp; /* INT_: copy */ | 1533 | *rpp = *lpp; /* INT_: copy */ |
1535 | xfs_alloc_log_keys(cur, rbp, 1, INT_GET(right->bb_numrecs, ARCH_CONVERT) + 1); | 1534 | xfs_alloc_log_keys(cur, rbp, 1, be16_to_cpu(right->bb_numrecs) + 1); |
1536 | xfs_alloc_log_ptrs(cur, rbp, 1, INT_GET(right->bb_numrecs, ARCH_CONVERT) + 1); | 1535 | xfs_alloc_log_ptrs(cur, rbp, 1, be16_to_cpu(right->bb_numrecs) + 1); |
1537 | xfs_btree_check_key(cur->bc_btnum, rkp, rkp + 1); | 1536 | xfs_btree_check_key(cur->bc_btnum, rkp, rkp + 1); |
1538 | } else { | 1537 | } else { |
1539 | xfs_alloc_rec_t *lrp; /* record pointer for left block */ | 1538 | xfs_alloc_rec_t *lrp; /* record pointer for left block */ |
1540 | xfs_alloc_rec_t *rrp; /* record pointer for right block */ | 1539 | xfs_alloc_rec_t *rrp; /* record pointer for right block */ |
1541 | 1540 | ||
1542 | lrp = XFS_ALLOC_REC_ADDR(left, INT_GET(left->bb_numrecs, ARCH_CONVERT), cur); | 1541 | lrp = XFS_ALLOC_REC_ADDR(left, be16_to_cpu(left->bb_numrecs), cur); |
1543 | rrp = XFS_ALLOC_REC_ADDR(right, 1, cur); | 1542 | rrp = XFS_ALLOC_REC_ADDR(right, 1, cur); |
1544 | memmove(rrp + 1, rrp, INT_GET(right->bb_numrecs, ARCH_CONVERT) * sizeof(*rrp)); | 1543 | memmove(rrp + 1, rrp, be16_to_cpu(right->bb_numrecs) * sizeof(*rrp)); |
1545 | *rrp = *lrp; | 1544 | *rrp = *lrp; |
1546 | xfs_alloc_log_recs(cur, rbp, 1, INT_GET(right->bb_numrecs, ARCH_CONVERT) + 1); | 1545 | xfs_alloc_log_recs(cur, rbp, 1, be16_to_cpu(right->bb_numrecs) + 1); |
1547 | key.ar_startblock = rrp->ar_startblock; /* INT_: direct copy */ | 1546 | key.ar_startblock = rrp->ar_startblock; |
1548 | key.ar_blockcount = rrp->ar_blockcount; /* INT_: direct copy */ | 1547 | key.ar_blockcount = rrp->ar_blockcount; |
1549 | rkp = &key; | 1548 | rkp = &key; |
1550 | xfs_btree_check_rec(cur->bc_btnum, rrp, rrp + 1); | 1549 | xfs_btree_check_rec(cur->bc_btnum, rrp, rrp + 1); |
1551 | } | 1550 | } |
1552 | /* | 1551 | /* |
1553 | * Decrement and log left's numrecs, bump and log right's numrecs. | 1552 | * Decrement and log left's numrecs, bump and log right's numrecs. |
1554 | */ | 1553 | */ |
1555 | INT_MOD(left->bb_numrecs, ARCH_CONVERT, -1); | 1554 | be16_add(&left->bb_numrecs, -1); |
1556 | xfs_alloc_log_block(cur->bc_tp, lbp, XFS_BB_NUMRECS); | 1555 | xfs_alloc_log_block(cur->bc_tp, lbp, XFS_BB_NUMRECS); |
1557 | INT_MOD(right->bb_numrecs, ARCH_CONVERT, +1); | 1556 | be16_add(&right->bb_numrecs, 1); |
1558 | xfs_alloc_log_block(cur->bc_tp, rbp, XFS_BB_NUMRECS); | 1557 | xfs_alloc_log_block(cur->bc_tp, rbp, XFS_BB_NUMRECS); |
1559 | /* | 1558 | /* |
1560 | * Using a temporary cursor, update the parent key values of the | 1559 | * Using a temporary cursor, update the parent key values of the |
@@ -1627,17 +1626,17 @@ xfs_alloc_split( | |||
1627 | /* | 1626 | /* |
1628 | * Fill in the btree header for the new block. | 1627 | * Fill in the btree header for the new block. |
1629 | */ | 1628 | */ |
1630 | INT_SET(right->bb_magic, ARCH_CONVERT, xfs_magics[cur->bc_btnum]); | 1629 | right->bb_magic = cpu_to_be32(xfs_magics[cur->bc_btnum]); |
1631 | right->bb_level = left->bb_level; /* INT_: direct copy */ | 1630 | right->bb_level = left->bb_level; |
1632 | INT_SET(right->bb_numrecs, ARCH_CONVERT, (__uint16_t)(INT_GET(left->bb_numrecs, ARCH_CONVERT) / 2)); | 1631 | right->bb_numrecs = cpu_to_be16(be16_to_cpu(left->bb_numrecs) / 2); |
1633 | /* | 1632 | /* |
1634 | * Make sure that if there's an odd number of entries now, that | 1633 | * Make sure that if there's an odd number of entries now, that |
1635 | * each new block will have the same number of entries. | 1634 | * each new block will have the same number of entries. |
1636 | */ | 1635 | */ |
1637 | if ((INT_GET(left->bb_numrecs, ARCH_CONVERT) & 1) && | 1636 | if ((be16_to_cpu(left->bb_numrecs) & 1) && |
1638 | cur->bc_ptrs[level] <= INT_GET(right->bb_numrecs, ARCH_CONVERT) + 1) | 1637 | cur->bc_ptrs[level] <= be16_to_cpu(right->bb_numrecs) + 1) |
1639 | INT_MOD(right->bb_numrecs, ARCH_CONVERT, +1); | 1638 | be16_add(&right->bb_numrecs, 1); |
1640 | i = INT_GET(left->bb_numrecs, ARCH_CONVERT) - INT_GET(right->bb_numrecs, ARCH_CONVERT) + 1; | 1639 | i = be16_to_cpu(left->bb_numrecs) - be16_to_cpu(right->bb_numrecs) + 1; |
1641 | /* | 1640 | /* |
1642 | * For non-leaf blocks, copy keys and addresses over to the new block. | 1641 | * For non-leaf blocks, copy keys and addresses over to the new block. |
1643 | */ | 1642 | */ |
@@ -1652,15 +1651,15 @@ xfs_alloc_split( | |||
1652 | rkp = XFS_ALLOC_KEY_ADDR(right, 1, cur); | 1651 | rkp = XFS_ALLOC_KEY_ADDR(right, 1, cur); |
1653 | rpp = XFS_ALLOC_PTR_ADDR(right, 1, cur); | 1652 | rpp = XFS_ALLOC_PTR_ADDR(right, 1, cur); |
1654 | #ifdef DEBUG | 1653 | #ifdef DEBUG |
1655 | for (i = 0; i < INT_GET(right->bb_numrecs, ARCH_CONVERT); i++) { | 1654 | for (i = 0; i < be16_to_cpu(right->bb_numrecs); i++) { |
1656 | if ((error = xfs_btree_check_sptr(cur, INT_GET(lpp[i], ARCH_CONVERT), level))) | 1655 | if ((error = xfs_btree_check_sptr(cur, be32_to_cpu(lpp[i]), level))) |
1657 | return error; | 1656 | return error; |
1658 | } | 1657 | } |
1659 | #endif | 1658 | #endif |
1660 | memcpy(rkp, lkp, INT_GET(right->bb_numrecs, ARCH_CONVERT) * sizeof(*rkp)); /* INT_: copy */ | 1659 | memcpy(rkp, lkp, be16_to_cpu(right->bb_numrecs) * sizeof(*rkp)); |
1661 | memcpy(rpp, lpp, INT_GET(right->bb_numrecs, ARCH_CONVERT) * sizeof(*rpp)); /* INT_: copy */ | 1660 | memcpy(rpp, lpp, be16_to_cpu(right->bb_numrecs) * sizeof(*rpp)); |
1662 | xfs_alloc_log_keys(cur, rbp, 1, INT_GET(right->bb_numrecs, ARCH_CONVERT)); | 1661 | xfs_alloc_log_keys(cur, rbp, 1, be16_to_cpu(right->bb_numrecs)); |
1663 | xfs_alloc_log_ptrs(cur, rbp, 1, INT_GET(right->bb_numrecs, ARCH_CONVERT)); | 1662 | xfs_alloc_log_ptrs(cur, rbp, 1, be16_to_cpu(right->bb_numrecs)); |
1664 | *keyp = *rkp; | 1663 | *keyp = *rkp; |
1665 | } | 1664 | } |
1666 | /* | 1665 | /* |
@@ -1672,38 +1671,38 @@ xfs_alloc_split( | |||
1672 | 1671 | ||
1673 | lrp = XFS_ALLOC_REC_ADDR(left, i, cur); | 1672 | lrp = XFS_ALLOC_REC_ADDR(left, i, cur); |
1674 | rrp = XFS_ALLOC_REC_ADDR(right, 1, cur); | 1673 | rrp = XFS_ALLOC_REC_ADDR(right, 1, cur); |
1675 | memcpy(rrp, lrp, INT_GET(right->bb_numrecs, ARCH_CONVERT) * sizeof(*rrp)); | 1674 | memcpy(rrp, lrp, be16_to_cpu(right->bb_numrecs) * sizeof(*rrp)); |
1676 | xfs_alloc_log_recs(cur, rbp, 1, INT_GET(right->bb_numrecs, ARCH_CONVERT)); | 1675 | xfs_alloc_log_recs(cur, rbp, 1, be16_to_cpu(right->bb_numrecs)); |
1677 | keyp->ar_startblock = rrp->ar_startblock; /* INT_: direct copy */ | 1676 | keyp->ar_startblock = rrp->ar_startblock; |
1678 | keyp->ar_blockcount = rrp->ar_blockcount; /* INT_: direct copy */ | 1677 | keyp->ar_blockcount = rrp->ar_blockcount; |
1679 | } | 1678 | } |
1680 | /* | 1679 | /* |
1681 | * Find the left block number by looking in the buffer. | 1680 | * Find the left block number by looking in the buffer. |
1682 | * Adjust numrecs, sibling pointers. | 1681 | * Adjust numrecs, sibling pointers. |
1683 | */ | 1682 | */ |
1684 | lbno = XFS_DADDR_TO_AGBNO(cur->bc_mp, XFS_BUF_ADDR(lbp)); | 1683 | lbno = XFS_DADDR_TO_AGBNO(cur->bc_mp, XFS_BUF_ADDR(lbp)); |
1685 | INT_MOD(left->bb_numrecs, ARCH_CONVERT, -(INT_GET(right->bb_numrecs, ARCH_CONVERT))); | 1684 | be16_add(&left->bb_numrecs, -(be16_to_cpu(right->bb_numrecs))); |
1686 | right->bb_rightsib = left->bb_rightsib; /* INT_: direct copy */ | 1685 | right->bb_rightsib = left->bb_rightsib; |
1687 | INT_SET(left->bb_rightsib, ARCH_CONVERT, rbno); | 1686 | left->bb_rightsib = cpu_to_be32(rbno); |
1688 | INT_SET(right->bb_leftsib, ARCH_CONVERT, lbno); | 1687 | right->bb_leftsib = cpu_to_be32(lbno); |
1689 | xfs_alloc_log_block(cur->bc_tp, rbp, XFS_BB_ALL_BITS); | 1688 | xfs_alloc_log_block(cur->bc_tp, rbp, XFS_BB_ALL_BITS); |
1690 | xfs_alloc_log_block(cur->bc_tp, lbp, XFS_BB_NUMRECS | XFS_BB_RIGHTSIB); | 1689 | xfs_alloc_log_block(cur->bc_tp, lbp, XFS_BB_NUMRECS | XFS_BB_RIGHTSIB); |
1691 | /* | 1690 | /* |
1692 | * If there's a block to the new block's right, make that block | 1691 | * If there's a block to the new block's right, make that block |
1693 | * point back to right instead of to left. | 1692 | * point back to right instead of to left. |
1694 | */ | 1693 | */ |
1695 | if (INT_GET(right->bb_rightsib, ARCH_CONVERT) != NULLAGBLOCK) { | 1694 | if (be32_to_cpu(right->bb_rightsib) != NULLAGBLOCK) { |
1696 | xfs_alloc_block_t *rrblock; /* rr btree block */ | 1695 | xfs_alloc_block_t *rrblock; /* rr btree block */ |
1697 | xfs_buf_t *rrbp; /* buffer for rrblock */ | 1696 | xfs_buf_t *rrbp; /* buffer for rrblock */ |
1698 | 1697 | ||
1699 | if ((error = xfs_btree_read_bufs(cur->bc_mp, cur->bc_tp, | 1698 | if ((error = xfs_btree_read_bufs(cur->bc_mp, cur->bc_tp, |
1700 | cur->bc_private.a.agno, INT_GET(right->bb_rightsib, ARCH_CONVERT), 0, | 1699 | cur->bc_private.a.agno, be32_to_cpu(right->bb_rightsib), 0, |
1701 | &rrbp, XFS_ALLOC_BTREE_REF))) | 1700 | &rrbp, XFS_ALLOC_BTREE_REF))) |
1702 | return error; | 1701 | return error; |
1703 | rrblock = XFS_BUF_TO_ALLOC_BLOCK(rrbp); | 1702 | rrblock = XFS_BUF_TO_ALLOC_BLOCK(rrbp); |
1704 | if ((error = xfs_btree_check_sblock(cur, rrblock, level, rrbp))) | 1703 | if ((error = xfs_btree_check_sblock(cur, rrblock, level, rrbp))) |
1705 | return error; | 1704 | return error; |
1706 | INT_SET(rrblock->bb_leftsib, ARCH_CONVERT, rbno); | 1705 | rrblock->bb_leftsib = cpu_to_be32(rbno); |
1707 | xfs_alloc_log_block(cur->bc_tp, rrbp, XFS_BB_LEFTSIB); | 1706 | xfs_alloc_log_block(cur->bc_tp, rrbp, XFS_BB_LEFTSIB); |
1708 | } | 1707 | } |
1709 | /* | 1708 | /* |
@@ -1711,9 +1710,9 @@ xfs_alloc_split( | |||
1711 | * If it's just pointing past the last entry in left, then we'll | 1710 | * If it's just pointing past the last entry in left, then we'll |
1712 | * insert there, so don't change anything in that case. | 1711 | * insert there, so don't change anything in that case. |
1713 | */ | 1712 | */ |
1714 | if (cur->bc_ptrs[level] > INT_GET(left->bb_numrecs, ARCH_CONVERT) + 1) { | 1713 | if (cur->bc_ptrs[level] > be16_to_cpu(left->bb_numrecs) + 1) { |
1715 | xfs_btree_setbuf(cur, level, rbp); | 1714 | xfs_btree_setbuf(cur, level, rbp); |
1716 | cur->bc_ptrs[level] -= INT_GET(left->bb_numrecs, ARCH_CONVERT); | 1715 | cur->bc_ptrs[level] -= be16_to_cpu(left->bb_numrecs); |
1717 | } | 1716 | } |
1718 | /* | 1717 | /* |
1719 | * If there are more levels, we'll need another cursor which refers to | 1718 | * If there are more levels, we'll need another cursor which refers to |
@@ -1811,7 +1810,7 @@ xfs_alloc_decrement( | |||
1811 | /* | 1810 | /* |
1812 | * If we just went off the left edge of the tree, return failure. | 1811 | * If we just went off the left edge of the tree, return failure. |
1813 | */ | 1812 | */ |
1814 | if (INT_GET(block->bb_leftsib, ARCH_CONVERT) == NULLAGBLOCK) { | 1813 | if (be32_to_cpu(block->bb_leftsib) == NULLAGBLOCK) { |
1815 | *stat = 0; | 1814 | *stat = 0; |
1816 | return 0; | 1815 | return 0; |
1817 | } | 1816 | } |
@@ -1840,7 +1839,7 @@ xfs_alloc_decrement( | |||
1840 | xfs_agblock_t agbno; /* block number of btree block */ | 1839 | xfs_agblock_t agbno; /* block number of btree block */ |
1841 | xfs_buf_t *bp; /* buffer pointer for block */ | 1840 | xfs_buf_t *bp; /* buffer pointer for block */ |
1842 | 1841 | ||
1843 | agbno = INT_GET(*XFS_ALLOC_PTR_ADDR(block, cur->bc_ptrs[lev], cur), ARCH_CONVERT); | 1842 | agbno = be32_to_cpu(*XFS_ALLOC_PTR_ADDR(block, cur->bc_ptrs[lev], cur)); |
1844 | if ((error = xfs_btree_read_bufs(cur->bc_mp, cur->bc_tp, | 1843 | if ((error = xfs_btree_read_bufs(cur->bc_mp, cur->bc_tp, |
1845 | cur->bc_private.a.agno, agbno, 0, &bp, | 1844 | cur->bc_private.a.agno, agbno, 0, &bp, |
1846 | XFS_ALLOC_BTREE_REF))) | 1845 | XFS_ALLOC_BTREE_REF))) |
@@ -1850,7 +1849,7 @@ xfs_alloc_decrement( | |||
1850 | block = XFS_BUF_TO_ALLOC_BLOCK(bp); | 1849 | block = XFS_BUF_TO_ALLOC_BLOCK(bp); |
1851 | if ((error = xfs_btree_check_sblock(cur, block, lev, bp))) | 1850 | if ((error = xfs_btree_check_sblock(cur, block, lev, bp))) |
1852 | return error; | 1851 | return error; |
1853 | cur->bc_ptrs[lev] = INT_GET(block->bb_numrecs, ARCH_CONVERT); | 1852 | cur->bc_ptrs[lev] = be16_to_cpu(block->bb_numrecs); |
1854 | } | 1853 | } |
1855 | *stat = 1; | 1854 | *stat = 1; |
1856 | return 0; | 1855 | return 0; |
@@ -1917,7 +1916,7 @@ xfs_alloc_get_rec( | |||
1917 | /* | 1916 | /* |
1918 | * Off the right end or left end, return failure. | 1917 | * Off the right end or left end, return failure. |
1919 | */ | 1918 | */ |
1920 | if (ptr > INT_GET(block->bb_numrecs, ARCH_CONVERT) || ptr <= 0) { | 1919 | if (ptr > be16_to_cpu(block->bb_numrecs) || ptr <= 0) { |
1921 | *stat = 0; | 1920 | *stat = 0; |
1922 | return 0; | 1921 | return 0; |
1923 | } | 1922 | } |
@@ -1928,8 +1927,8 @@ xfs_alloc_get_rec( | |||
1928 | xfs_alloc_rec_t *rec; /* record data */ | 1927 | xfs_alloc_rec_t *rec; /* record data */ |
1929 | 1928 | ||
1930 | rec = XFS_ALLOC_REC_ADDR(block, ptr, cur); | 1929 | rec = XFS_ALLOC_REC_ADDR(block, ptr, cur); |
1931 | *bno = INT_GET(rec->ar_startblock, ARCH_CONVERT); | 1930 | *bno = be32_to_cpu(rec->ar_startblock); |
1932 | *len = INT_GET(rec->ar_blockcount, ARCH_CONVERT); | 1931 | *len = be32_to_cpu(rec->ar_blockcount); |
1933 | } | 1932 | } |
1934 | *stat = 1; | 1933 | *stat = 1; |
1935 | return 0; | 1934 | return 0; |
@@ -1968,14 +1967,14 @@ xfs_alloc_increment( | |||
1968 | * Increment the ptr at this level. If we're still in the block | 1967 | * Increment the ptr at this level. If we're still in the block |
1969 | * then we're done. | 1968 | * then we're done. |
1970 | */ | 1969 | */ |
1971 | if (++cur->bc_ptrs[level] <= INT_GET(block->bb_numrecs, ARCH_CONVERT)) { | 1970 | if (++cur->bc_ptrs[level] <= be16_to_cpu(block->bb_numrecs)) { |
1972 | *stat = 1; | 1971 | *stat = 1; |
1973 | return 0; | 1972 | return 0; |
1974 | } | 1973 | } |
1975 | /* | 1974 | /* |
1976 | * If we just went off the right edge of the tree, return failure. | 1975 | * If we just went off the right edge of the tree, return failure. |
1977 | */ | 1976 | */ |
1978 | if (INT_GET(block->bb_rightsib, ARCH_CONVERT) == NULLAGBLOCK) { | 1977 | if (be32_to_cpu(block->bb_rightsib) == NULLAGBLOCK) { |
1979 | *stat = 0; | 1978 | *stat = 0; |
1980 | return 0; | 1979 | return 0; |
1981 | } | 1980 | } |
@@ -1990,7 +1989,7 @@ xfs_alloc_increment( | |||
1990 | if ((error = xfs_btree_check_sblock(cur, block, lev, bp))) | 1989 | if ((error = xfs_btree_check_sblock(cur, block, lev, bp))) |
1991 | return error; | 1990 | return error; |
1992 | #endif | 1991 | #endif |
1993 | if (++cur->bc_ptrs[lev] <= INT_GET(block->bb_numrecs, ARCH_CONVERT)) | 1992 | if (++cur->bc_ptrs[lev] <= be16_to_cpu(block->bb_numrecs)) |
1994 | break; | 1993 | break; |
1995 | /* | 1994 | /* |
1996 | * Read-ahead the right block, we're going to read it | 1995 | * Read-ahead the right block, we're going to read it |
@@ -2010,7 +2009,7 @@ xfs_alloc_increment( | |||
2010 | lev > level; ) { | 2009 | lev > level; ) { |
2011 | xfs_agblock_t agbno; /* block number of btree block */ | 2010 | xfs_agblock_t agbno; /* block number of btree block */ |
2012 | 2011 | ||
2013 | agbno = INT_GET(*XFS_ALLOC_PTR_ADDR(block, cur->bc_ptrs[lev], cur), ARCH_CONVERT); | 2012 | agbno = be32_to_cpu(*XFS_ALLOC_PTR_ADDR(block, cur->bc_ptrs[lev], cur)); |
2014 | if ((error = xfs_btree_read_bufs(cur->bc_mp, cur->bc_tp, | 2013 | if ((error = xfs_btree_read_bufs(cur->bc_mp, cur->bc_tp, |
2015 | cur->bc_private.a.agno, agbno, 0, &bp, | 2014 | cur->bc_private.a.agno, agbno, 0, &bp, |
2016 | XFS_ALLOC_BTREE_REF))) | 2015 | XFS_ALLOC_BTREE_REF))) |
@@ -2045,8 +2044,8 @@ xfs_alloc_insert( | |||
2045 | 2044 | ||
2046 | level = 0; | 2045 | level = 0; |
2047 | nbno = NULLAGBLOCK; | 2046 | nbno = NULLAGBLOCK; |
2048 | INT_SET(nrec.ar_startblock, ARCH_CONVERT, cur->bc_rec.a.ar_startblock); | 2047 | nrec.ar_startblock = cpu_to_be32(cur->bc_rec.a.ar_startblock); |
2049 | INT_SET(nrec.ar_blockcount, ARCH_CONVERT, cur->bc_rec.a.ar_blockcount); | 2048 | nrec.ar_blockcount = cpu_to_be32(cur->bc_rec.a.ar_blockcount); |
2050 | ncur = (xfs_btree_cur_t *)0; | 2049 | ncur = (xfs_btree_cur_t *)0; |
2051 | pcur = cur; | 2050 | pcur = cur; |
2052 | /* | 2051 | /* |
@@ -2167,8 +2166,8 @@ xfs_alloc_update( | |||
2167 | /* | 2166 | /* |
2168 | * Fill in the new contents and log them. | 2167 | * Fill in the new contents and log them. |
2169 | */ | 2168 | */ |
2170 | INT_SET(rp->ar_startblock, ARCH_CONVERT, bno); | 2169 | rp->ar_startblock = cpu_to_be32(bno); |
2171 | INT_SET(rp->ar_blockcount, ARCH_CONVERT, len); | 2170 | rp->ar_blockcount = cpu_to_be32(len); |
2172 | xfs_alloc_log_recs(cur, cur->bc_bufs[0], ptr, ptr); | 2171 | xfs_alloc_log_recs(cur, cur->bc_bufs[0], ptr, ptr); |
2173 | } | 2172 | } |
2174 | /* | 2173 | /* |
@@ -2177,15 +2176,15 @@ xfs_alloc_update( | |||
2177 | * extent in the a.g., which we cache in the a.g. freelist header. | 2176 | * extent in the a.g., which we cache in the a.g. freelist header. |
2178 | */ | 2177 | */ |
2179 | if (cur->bc_btnum == XFS_BTNUM_CNT && | 2178 | if (cur->bc_btnum == XFS_BTNUM_CNT && |
2180 | INT_GET(block->bb_rightsib, ARCH_CONVERT) == NULLAGBLOCK && | 2179 | be32_to_cpu(block->bb_rightsib) == NULLAGBLOCK && |
2181 | ptr == INT_GET(block->bb_numrecs, ARCH_CONVERT)) { | 2180 | ptr == be16_to_cpu(block->bb_numrecs)) { |
2182 | xfs_agf_t *agf; /* a.g. freespace header */ | 2181 | xfs_agf_t *agf; /* a.g. freespace header */ |
2183 | xfs_agnumber_t seqno; | 2182 | xfs_agnumber_t seqno; |
2184 | 2183 | ||
2185 | agf = XFS_BUF_TO_AGF(cur->bc_private.a.agbp); | 2184 | agf = XFS_BUF_TO_AGF(cur->bc_private.a.agbp); |
2186 | seqno = INT_GET(agf->agf_seqno, ARCH_CONVERT); | 2185 | seqno = be32_to_cpu(agf->agf_seqno); |
2187 | cur->bc_mp->m_perag[seqno].pagf_longest = len; | 2186 | cur->bc_mp->m_perag[seqno].pagf_longest = len; |
2188 | INT_SET(agf->agf_longest, ARCH_CONVERT, len); | 2187 | agf->agf_longest = cpu_to_be32(len); |
2189 | xfs_alloc_log_agf(cur->bc_tp, cur->bc_private.a.agbp, | 2188 | xfs_alloc_log_agf(cur->bc_tp, cur->bc_private.a.agbp, |
2190 | XFS_AGF_LONGEST); | 2189 | XFS_AGF_LONGEST); |
2191 | } | 2190 | } |
@@ -2195,8 +2194,8 @@ xfs_alloc_update( | |||
2195 | if (ptr == 1) { | 2194 | if (ptr == 1) { |
2196 | xfs_alloc_key_t key; /* key containing [bno, len] */ | 2195 | xfs_alloc_key_t key; /* key containing [bno, len] */ |
2197 | 2196 | ||
2198 | INT_SET(key.ar_startblock, ARCH_CONVERT, bno); | 2197 | key.ar_startblock = cpu_to_be32(bno); |
2199 | INT_SET(key.ar_blockcount, ARCH_CONVERT, len); | 2198 | key.ar_blockcount = cpu_to_be32(len); |
2200 | if ((error = xfs_alloc_updkey(cur, &key, 1))) | 2199 | if ((error = xfs_alloc_updkey(cur, &key, 1))) |
2201 | return error; | 2200 | return error; |
2202 | } | 2201 | } |
diff --git a/fs/xfs/xfs_alloc_btree.h b/fs/xfs/xfs_alloc_btree.h index ed5161a572ef..bce81c7a4fdc 100644 --- a/fs/xfs/xfs_alloc_btree.h +++ b/fs/xfs/xfs_alloc_btree.h | |||
@@ -1,33 +1,19 @@ | |||
1 | /* | 1 | /* |
2 | * Copyright (c) 2000 Silicon Graphics, Inc. All Rights Reserved. | 2 | * Copyright (c) 2000,2005 Silicon Graphics, Inc. |
3 | * All Rights Reserved. | ||
3 | * | 4 | * |
4 | * This program is free software; you can redistribute it and/or modify it | 5 | * This program is free software; you can redistribute it and/or |
5 | * under the terms of version 2 of the GNU General Public License as | 6 | * modify it under the terms of the GNU General Public License as |
6 | * published by the Free Software Foundation. | 7 | * published by the Free Software Foundation. |
7 | * | 8 | * |
8 | * This program is distributed in the hope that it would be useful, but | 9 | * This program is distributed in the hope that it would be useful, |
9 | * WITHOUT ANY WARRANTY; without even the implied warranty of | 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
12 | * GNU General Public License for more details. | ||
11 | * | 13 | * |
12 | * Further, this software is distributed without any warranty that it is | 14 | * You should have received a copy of the GNU General Public License |
13 | * free of the rightful claim of any third person regarding infringement | 15 | * along with this program; if not, write the Free Software Foundation, |
14 | * or the like. Any license provided herein, whether implied or | 16 | * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
15 | * otherwise, applies only to this software file. Patent licenses, if | ||
16 | * any, provided herein do not apply to combinations of this program with | ||
17 | * other software, or any other product whatsoever. | ||
18 | * | ||
19 | * You should have received a copy of the GNU General Public License along | ||
20 | * with this program; if not, write the Free Software Foundation, Inc., 59 | ||
21 | * Temple Place - Suite 330, Boston MA 02111-1307, USA. | ||
22 | * | ||
23 | * Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy, | ||
24 | * Mountain View, CA 94043, or: | ||
25 | * | ||
26 | * http://www.sgi.com | ||
27 | * | ||
28 | * For further information regarding this notice, see: | ||
29 | * | ||
30 | * http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/ | ||
31 | */ | 17 | */ |
32 | #ifndef __XFS_ALLOC_BTREE_H__ | 18 | #ifndef __XFS_ALLOC_BTREE_H__ |
33 | #define __XFS_ALLOC_BTREE_H__ | 19 | #define __XFS_ALLOC_BTREE_H__ |
@@ -52,48 +38,29 @@ struct xfs_mount; | |||
52 | /* | 38 | /* |
53 | * Data record/key structure | 39 | * Data record/key structure |
54 | */ | 40 | */ |
55 | typedef struct xfs_alloc_rec | 41 | typedef struct xfs_alloc_rec { |
56 | { | 42 | __be32 ar_startblock; /* starting block number */ |
43 | __be32 ar_blockcount; /* count of free blocks */ | ||
44 | } xfs_alloc_rec_t, xfs_alloc_key_t; | ||
45 | |||
46 | typedef struct xfs_alloc_rec_incore { | ||
57 | xfs_agblock_t ar_startblock; /* starting block number */ | 47 | xfs_agblock_t ar_startblock; /* starting block number */ |
58 | xfs_extlen_t ar_blockcount; /* count of free blocks */ | 48 | xfs_extlen_t ar_blockcount; /* count of free blocks */ |
59 | } xfs_alloc_rec_t, xfs_alloc_key_t; | 49 | } xfs_alloc_rec_incore_t; |
60 | 50 | ||
61 | typedef xfs_agblock_t xfs_alloc_ptr_t; /* btree pointer type */ | 51 | /* btree pointer type */ |
62 | /* btree block header type */ | 52 | typedef __be32 xfs_alloc_ptr_t; |
53 | /* btree block header type */ | ||
63 | typedef struct xfs_btree_sblock xfs_alloc_block_t; | 54 | typedef struct xfs_btree_sblock xfs_alloc_block_t; |
64 | 55 | ||
65 | #if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_BUF_TO_ALLOC_BLOCK) | 56 | #define XFS_BUF_TO_ALLOC_BLOCK(bp) ((xfs_alloc_block_t *)XFS_BUF_PTR(bp)) |
66 | xfs_alloc_block_t *xfs_buf_to_alloc_block(struct xfs_buf *bp); | ||
67 | #define XFS_BUF_TO_ALLOC_BLOCK(bp) xfs_buf_to_alloc_block(bp) | ||
68 | #else | ||
69 | #define XFS_BUF_TO_ALLOC_BLOCK(bp) ((xfs_alloc_block_t *)(XFS_BUF_PTR(bp))) | ||
70 | #endif | ||
71 | 57 | ||
72 | /* | 58 | /* |
73 | * Real block structures have a size equal to the disk block size. | 59 | * Real block structures have a size equal to the disk block size. |
74 | */ | 60 | */ |
75 | |||
76 | #if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_ALLOC_BLOCK_SIZE) | ||
77 | int xfs_alloc_block_size(int lev, struct xfs_btree_cur *cur); | ||
78 | #define XFS_ALLOC_BLOCK_SIZE(lev,cur) xfs_alloc_block_size(lev,cur) | ||
79 | #else | ||
80 | #define XFS_ALLOC_BLOCK_SIZE(lev,cur) (1 << (cur)->bc_blocklog) | 61 | #define XFS_ALLOC_BLOCK_SIZE(lev,cur) (1 << (cur)->bc_blocklog) |
81 | #endif | 62 | #define XFS_ALLOC_BLOCK_MAXRECS(lev,cur) ((cur)->bc_mp->m_alloc_mxr[lev != 0]) |
82 | 63 | #define XFS_ALLOC_BLOCK_MINRECS(lev,cur) ((cur)->bc_mp->m_alloc_mnr[lev != 0]) | |
83 | #if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_ALLOC_BLOCK_MAXRECS) | ||
84 | int xfs_alloc_block_maxrecs(int lev, struct xfs_btree_cur *cur); | ||
85 | #define XFS_ALLOC_BLOCK_MAXRECS(lev,cur) xfs_alloc_block_maxrecs(lev,cur) | ||
86 | #else | ||
87 | #define XFS_ALLOC_BLOCK_MAXRECS(lev,cur) \ | ||
88 | ((cur)->bc_mp->m_alloc_mxr[lev != 0]) | ||
89 | #endif | ||
90 | #if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_ALLOC_BLOCK_MINRECS) | ||
91 | int xfs_alloc_block_minrecs(int lev, struct xfs_btree_cur *cur); | ||
92 | #define XFS_ALLOC_BLOCK_MINRECS(lev,cur) xfs_alloc_block_minrecs(lev,cur) | ||
93 | #else | ||
94 | #define XFS_ALLOC_BLOCK_MINRECS(lev,cur) \ | ||
95 | ((cur)->bc_mp->m_alloc_mnr[lev != 0]) | ||
96 | #endif | ||
97 | 64 | ||
98 | /* | 65 | /* |
99 | * Minimum and maximum blocksize and sectorsize. | 66 | * Minimum and maximum blocksize and sectorsize. |
@@ -113,145 +80,80 @@ int xfs_alloc_block_minrecs(int lev, struct xfs_btree_cur *cur); | |||
113 | * Block numbers in the AG: | 80 | * Block numbers in the AG: |
114 | * SB is sector 0, AGF is sector 1, AGI is sector 2, AGFL is sector 3. | 81 | * SB is sector 0, AGF is sector 1, AGI is sector 2, AGFL is sector 3. |
115 | */ | 82 | */ |
116 | #if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_BNO_BLOCK) | ||
117 | xfs_agblock_t xfs_bno_block(struct xfs_mount *mp); | ||
118 | #define XFS_BNO_BLOCK(mp) xfs_bno_block(mp) | ||
119 | #else | ||
120 | #define XFS_BNO_BLOCK(mp) ((xfs_agblock_t)(XFS_AGFL_BLOCK(mp) + 1)) | 83 | #define XFS_BNO_BLOCK(mp) ((xfs_agblock_t)(XFS_AGFL_BLOCK(mp) + 1)) |
121 | #endif | ||
122 | #if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_CNT_BLOCK) | ||
123 | xfs_agblock_t xfs_cnt_block(struct xfs_mount *mp); | ||
124 | #define XFS_CNT_BLOCK(mp) xfs_cnt_block(mp) | ||
125 | #else | ||
126 | #define XFS_CNT_BLOCK(mp) ((xfs_agblock_t)(XFS_BNO_BLOCK(mp) + 1)) | 84 | #define XFS_CNT_BLOCK(mp) ((xfs_agblock_t)(XFS_BNO_BLOCK(mp) + 1)) |
127 | #endif | ||
128 | 85 | ||
129 | /* | 86 | /* |
130 | * Record, key, and pointer address macros for btree blocks. | 87 | * Record, key, and pointer address macros for btree blocks. |
131 | */ | 88 | */ |
132 | #if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_ALLOC_REC_ADDR) | ||
133 | xfs_alloc_rec_t *xfs_alloc_rec_addr(xfs_alloc_block_t *bb, int i, | ||
134 | struct xfs_btree_cur *cur); | ||
135 | #define XFS_ALLOC_REC_ADDR(bb,i,cur) xfs_alloc_rec_addr(bb,i,cur) | ||
136 | #else | ||
137 | #define XFS_ALLOC_REC_ADDR(bb,i,cur) \ | 89 | #define XFS_ALLOC_REC_ADDR(bb,i,cur) \ |
138 | XFS_BTREE_REC_ADDR(XFS_ALLOC_BLOCK_SIZE(0,cur), xfs_alloc, bb, i, \ | 90 | XFS_BTREE_REC_ADDR(XFS_ALLOC_BLOCK_SIZE(0,cur), xfs_alloc, \ |
139 | XFS_ALLOC_BLOCK_MAXRECS(0, cur)) | 91 | bb, i, XFS_ALLOC_BLOCK_MAXRECS(0, cur)) |
140 | #endif | ||
141 | 92 | ||
142 | #if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_ALLOC_KEY_ADDR) | ||
143 | xfs_alloc_key_t *xfs_alloc_key_addr(xfs_alloc_block_t *bb, int i, | ||
144 | struct xfs_btree_cur *cur); | ||
145 | #define XFS_ALLOC_KEY_ADDR(bb,i,cur) xfs_alloc_key_addr(bb,i,cur) | ||
146 | #else | ||
147 | #define XFS_ALLOC_KEY_ADDR(bb,i,cur) \ | 93 | #define XFS_ALLOC_KEY_ADDR(bb,i,cur) \ |
148 | XFS_BTREE_KEY_ADDR(XFS_ALLOC_BLOCK_SIZE(1,cur), xfs_alloc, bb, i, \ | 94 | XFS_BTREE_KEY_ADDR(XFS_ALLOC_BLOCK_SIZE(1,cur), xfs_alloc, \ |
149 | XFS_ALLOC_BLOCK_MAXRECS(1, cur)) | 95 | bb, i, XFS_ALLOC_BLOCK_MAXRECS(1, cur)) |
150 | #endif | ||
151 | 96 | ||
152 | #if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_ALLOC_PTR_ADDR) | ||
153 | xfs_alloc_ptr_t *xfs_alloc_ptr_addr(xfs_alloc_block_t *bb, int i, | ||
154 | struct xfs_btree_cur *cur); | ||
155 | #define XFS_ALLOC_PTR_ADDR(bb,i,cur) xfs_alloc_ptr_addr(bb,i,cur) | ||
156 | #else | ||
157 | #define XFS_ALLOC_PTR_ADDR(bb,i,cur) \ | 97 | #define XFS_ALLOC_PTR_ADDR(bb,i,cur) \ |
158 | XFS_BTREE_PTR_ADDR(XFS_ALLOC_BLOCK_SIZE(1,cur), xfs_alloc, bb, i, \ | 98 | XFS_BTREE_PTR_ADDR(XFS_ALLOC_BLOCK_SIZE(1,cur), xfs_alloc, \ |
159 | XFS_ALLOC_BLOCK_MAXRECS(1, cur)) | 99 | bb, i, XFS_ALLOC_BLOCK_MAXRECS(1, cur)) |
160 | #endif | ||
161 | |||
162 | /* | ||
163 | * Prototypes for externally visible routines. | ||
164 | */ | ||
165 | 100 | ||
166 | /* | 101 | /* |
167 | * Decrement cursor by one record at the level. | 102 | * Decrement cursor by one record at the level. |
168 | * For nonzero levels the leaf-ward information is untouched. | 103 | * For nonzero levels the leaf-ward information is untouched. |
169 | */ | 104 | */ |
170 | int /* error */ | 105 | extern int xfs_alloc_decrement(struct xfs_btree_cur *cur, int level, int *stat); |
171 | xfs_alloc_decrement( | ||
172 | struct xfs_btree_cur *cur, /* btree cursor */ | ||
173 | int level, /* level in btree, 0 is leaf */ | ||
174 | int *stat); /* success/failure */ | ||
175 | 106 | ||
176 | /* | 107 | /* |
177 | * Delete the record pointed to by cur. | 108 | * Delete the record pointed to by cur. |
178 | * The cursor refers to the place where the record was (could be inserted) | 109 | * The cursor refers to the place where the record was (could be inserted) |
179 | * when the operation returns. | 110 | * when the operation returns. |
180 | */ | 111 | */ |
181 | int /* error */ | 112 | extern int xfs_alloc_delete(struct xfs_btree_cur *cur, int *stat); |
182 | xfs_alloc_delete( | ||
183 | struct xfs_btree_cur *cur, /* btree cursor */ | ||
184 | int *stat); /* success/failure */ | ||
185 | 113 | ||
186 | /* | 114 | /* |
187 | * Get the data from the pointed-to record. | 115 | * Get the data from the pointed-to record. |
188 | */ | 116 | */ |
189 | int /* error */ | 117 | extern int xfs_alloc_get_rec(struct xfs_btree_cur *cur, xfs_agblock_t *bno, |
190 | xfs_alloc_get_rec( | 118 | xfs_extlen_t *len, int *stat); |
191 | struct xfs_btree_cur *cur, /* btree cursor */ | ||
192 | xfs_agblock_t *bno, /* output: starting block of extent */ | ||
193 | xfs_extlen_t *len, /* output: length of extent */ | ||
194 | int *stat); /* output: success/failure */ | ||
195 | 119 | ||
196 | /* | 120 | /* |
197 | * Increment cursor by one record at the level. | 121 | * Increment cursor by one record at the level. |
198 | * For nonzero levels the leaf-ward information is untouched. | 122 | * For nonzero levels the leaf-ward information is untouched. |
199 | */ | 123 | */ |
200 | int /* error */ | 124 | extern int xfs_alloc_increment(struct xfs_btree_cur *cur, int level, int *stat); |
201 | xfs_alloc_increment( | ||
202 | struct xfs_btree_cur *cur, /* btree cursor */ | ||
203 | int level, /* level in btree, 0 is leaf */ | ||
204 | int *stat); /* success/failure */ | ||
205 | 125 | ||
206 | /* | 126 | /* |
207 | * Insert the current record at the point referenced by cur. | 127 | * Insert the current record at the point referenced by cur. |
208 | * The cursor may be inconsistent on return if splits have been done. | 128 | * The cursor may be inconsistent on return if splits have been done. |
209 | */ | 129 | */ |
210 | int /* error */ | 130 | extern int xfs_alloc_insert(struct xfs_btree_cur *cur, int *stat); |
211 | xfs_alloc_insert( | ||
212 | struct xfs_btree_cur *cur, /* btree cursor */ | ||
213 | int *stat); /* success/failure */ | ||
214 | 131 | ||
215 | /* | 132 | /* |
216 | * Lookup the record equal to [bno, len] in the btree given by cur. | 133 | * Lookup the record equal to [bno, len] in the btree given by cur. |
217 | */ | 134 | */ |
218 | int /* error */ | 135 | extern int xfs_alloc_lookup_eq(struct xfs_btree_cur *cur, xfs_agblock_t bno, |
219 | xfs_alloc_lookup_eq( | 136 | xfs_extlen_t len, int *stat); |
220 | struct xfs_btree_cur *cur, /* btree cursor */ | ||
221 | xfs_agblock_t bno, /* starting block of extent */ | ||
222 | xfs_extlen_t len, /* length of extent */ | ||
223 | int *stat); /* success/failure */ | ||
224 | 137 | ||
225 | /* | 138 | /* |
226 | * Lookup the first record greater than or equal to [bno, len] | 139 | * Lookup the first record greater than or equal to [bno, len] |
227 | * in the btree given by cur. | 140 | * in the btree given by cur. |
228 | */ | 141 | */ |
229 | int /* error */ | 142 | extern int xfs_alloc_lookup_ge(struct xfs_btree_cur *cur, xfs_agblock_t bno, |
230 | xfs_alloc_lookup_ge( | 143 | xfs_extlen_t len, int *stat); |
231 | struct xfs_btree_cur *cur, /* btree cursor */ | ||
232 | xfs_agblock_t bno, /* starting block of extent */ | ||
233 | xfs_extlen_t len, /* length of extent */ | ||
234 | int *stat); /* success/failure */ | ||
235 | 144 | ||
236 | /* | 145 | /* |
237 | * Lookup the first record less than or equal to [bno, len] | 146 | * Lookup the first record less than or equal to [bno, len] |
238 | * in the btree given by cur. | 147 | * in the btree given by cur. |
239 | */ | 148 | */ |
240 | int /* error */ | 149 | extern int xfs_alloc_lookup_le(struct xfs_btree_cur *cur, xfs_agblock_t bno, |
241 | xfs_alloc_lookup_le( | 150 | xfs_extlen_t len, int *stat); |
242 | struct xfs_btree_cur *cur, /* btree cursor */ | ||
243 | xfs_agblock_t bno, /* starting block of extent */ | ||
244 | xfs_extlen_t len, /* length of extent */ | ||
245 | int *stat); /* success/failure */ | ||
246 | 151 | ||
247 | /* | 152 | /* |
248 | * Update the record referred to by cur, to the value given by [bno, len]. | 153 | * Update the record referred to by cur, to the value given by [bno, len]. |
249 | * This either works (return 0) or gets an EFSCORRUPTED error. | 154 | * This either works (return 0) or gets an EFSCORRUPTED error. |
250 | */ | 155 | */ |
251 | int /* error */ | 156 | extern int xfs_alloc_update(struct xfs_btree_cur *cur, xfs_agblock_t bno, |
252 | xfs_alloc_update( | 157 | xfs_extlen_t len); |
253 | struct xfs_btree_cur *cur, /* btree cursor */ | ||
254 | xfs_agblock_t bno, /* starting block of extent */ | ||
255 | xfs_extlen_t len); /* length of extent */ | ||
256 | 158 | ||
257 | #endif /* __XFS_ALLOC_BTREE_H__ */ | 159 | #endif /* __XFS_ALLOC_BTREE_H__ */ |
diff --git a/fs/xfs/xfs_arch.h b/fs/xfs/xfs_arch.h index 5ab0dd885b1b..68e5051d8e24 100644 --- a/fs/xfs/xfs_arch.h +++ b/fs/xfs/xfs_arch.h | |||
@@ -1,33 +1,19 @@ | |||
1 | /* | 1 | /* |
2 | * Copyright (c) 2000-2002 Silicon Graphics, Inc. All Rights Reserved. | 2 | * Copyright (c) 2000-2002,2005 Silicon Graphics, Inc. |
3 | * All Rights Reserved. | ||
3 | * | 4 | * |
4 | * This program is free software; you can redistribute it and/or modify it | 5 | * This program is free software; you can redistribute it and/or |
5 | * under the terms of version 2 of the GNU General Public License as | 6 | * modify it under the terms of the GNU General Public License as |
6 | * published by the Free Software Foundation. | 7 | * published by the Free Software Foundation. |
7 | * | 8 | * |
8 | * This program is distributed in the hope that it would be useful, but | 9 | * This program is distributed in the hope that it would be useful, |
9 | * WITHOUT ANY WARRANTY; without even the implied warranty of | 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
12 | * GNU General Public License for more details. | ||
11 | * | 13 | * |
12 | * Further, this software is distributed without any warranty that it is | 14 | * You should have received a copy of the GNU General Public License |
13 | * free of the rightful claim of any third person regarding infringement | 15 | * along with this program; if not, write the Free Software Foundation, |
14 | * or the like. Any license provided herein, whether implied or | 16 | * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
15 | * otherwise, applies only to this software file. Patent licenses, if | ||
16 | * any, provided herein do not apply to combinations of this program with | ||
17 | * other software, or any other product whatsoever. | ||
18 | * | ||
19 | * You should have received a copy of the GNU General Public License along | ||
20 | * with this program; if not, write the Free Software Foundation, Inc., 59 | ||
21 | * Temple Place - Suite 330, Boston MA 02111-1307, USA. | ||
22 | * | ||
23 | * Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy, | ||
24 | * Mountain View, CA 94043, or: | ||
25 | * | ||
26 | * http://www.sgi.com | ||
27 | * | ||
28 | * For further information regarding this notice, see: | ||
29 | * | ||
30 | * http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/ | ||
31 | */ | 17 | */ |
32 | #ifndef __XFS_ARCH_H__ | 18 | #ifndef __XFS_ARCH_H__ |
33 | #define __XFS_ARCH_H__ | 19 | #define __XFS_ARCH_H__ |
@@ -168,6 +154,21 @@ | |||
168 | } \ | 154 | } \ |
169 | } | 155 | } |
170 | 156 | ||
157 | static inline void be16_add(__be16 *a, __s16 b) | ||
158 | { | ||
159 | *a = cpu_to_be16(be16_to_cpu(*a) + b); | ||
160 | } | ||
161 | |||
162 | static inline void be32_add(__be32 *a, __s32 b) | ||
163 | { | ||
164 | *a = cpu_to_be32(be32_to_cpu(*a) + b); | ||
165 | } | ||
166 | |||
167 | static inline void be64_add(__be64 *a, __s64 b) | ||
168 | { | ||
169 | *a = cpu_to_be64(be64_to_cpu(*a) + b); | ||
170 | } | ||
171 | |||
171 | /* | 172 | /* |
172 | * In directories inode numbers are stored as unaligned arrays of unsigned | 173 | * In directories inode numbers are stored as unaligned arrays of unsigned |
173 | * 8bit integers on disk. | 174 | * 8bit integers on disk. |
diff --git a/fs/xfs/xfs_attr.c b/fs/xfs/xfs_attr.c index a41ad3a5e554..5484eeb460c8 100644 --- a/fs/xfs/xfs_attr.c +++ b/fs/xfs/xfs_attr.c | |||
@@ -1,41 +1,26 @@ | |||
1 | /* | 1 | /* |
2 | * Copyright (c) 2000-2004 Silicon Graphics, Inc. All Rights Reserved. | 2 | * Copyright (c) 2000-2005 Silicon Graphics, Inc. |
3 | * All Rights Reserved. | ||
3 | * | 4 | * |
4 | * This program is free software; you can redistribute it and/or modify it | 5 | * This program is free software; you can redistribute it and/or |
5 | * under the terms of version 2 of the GNU General Public License as | 6 | * modify it under the terms of the GNU General Public License as |
6 | * published by the Free Software Foundation. | 7 | * published by the Free Software Foundation. |
7 | * | 8 | * |
8 | * This program is distributed in the hope that it would be useful, but | 9 | * This program is distributed in the hope that it would be useful, |
9 | * WITHOUT ANY WARRANTY; without even the implied warranty of | 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
12 | * GNU General Public License for more details. | ||
11 | * | 13 | * |
12 | * Further, this software is distributed without any warranty that it is | 14 | * You should have received a copy of the GNU General Public License |
13 | * free of the rightful claim of any third person regarding infringement | 15 | * along with this program; if not, write the Free Software Foundation, |
14 | * or the like. Any license provided herein, whether implied or | 16 | * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
15 | * otherwise, applies only to this software file. Patent licenses, if | ||
16 | * any, provided herein do not apply to combinations of this program with | ||
17 | * other software, or any other product whatsoever. | ||
18 | * | ||
19 | * You should have received a copy of the GNU General Public License along | ||
20 | * with this program; if not, write the Free Software Foundation, Inc., 59 | ||
21 | * Temple Place - Suite 330, Boston MA 02111-1307, USA. | ||
22 | * | ||
23 | * Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy, | ||
24 | * Mountain View, CA 94043, or: | ||
25 | * | ||
26 | * http://www.sgi.com | ||
27 | * | ||
28 | * For further information regarding this notice, see: | ||
29 | * | ||
30 | * http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/ | ||
31 | */ | 17 | */ |
32 | |||
33 | #include "xfs.h" | 18 | #include "xfs.h" |
34 | 19 | #include "xfs_fs.h" | |
35 | #include "xfs_macros.h" | ||
36 | #include "xfs_types.h" | 20 | #include "xfs_types.h" |
37 | #include "xfs_inum.h" | 21 | #include "xfs_bit.h" |
38 | #include "xfs_log.h" | 22 | #include "xfs_log.h" |
23 | #include "xfs_inum.h" | ||
39 | #include "xfs_trans.h" | 24 | #include "xfs_trans.h" |
40 | #include "xfs_sb.h" | 25 | #include "xfs_sb.h" |
41 | #include "xfs_ag.h" | 26 | #include "xfs_ag.h" |
@@ -43,27 +28,26 @@ | |||
43 | #include "xfs_dir2.h" | 28 | #include "xfs_dir2.h" |
44 | #include "xfs_dmapi.h" | 29 | #include "xfs_dmapi.h" |
45 | #include "xfs_mount.h" | 30 | #include "xfs_mount.h" |
46 | #include "xfs_alloc_btree.h" | 31 | #include "xfs_da_btree.h" |
47 | #include "xfs_bmap_btree.h" | 32 | #include "xfs_bmap_btree.h" |
33 | #include "xfs_alloc_btree.h" | ||
48 | #include "xfs_ialloc_btree.h" | 34 | #include "xfs_ialloc_btree.h" |
49 | #include "xfs_alloc.h" | ||
50 | #include "xfs_btree.h" | ||
51 | #include "xfs_attr_sf.h" | ||
52 | #include "xfs_dir_sf.h" | 35 | #include "xfs_dir_sf.h" |
53 | #include "xfs_dir2_sf.h" | 36 | #include "xfs_dir2_sf.h" |
37 | #include "xfs_attr_sf.h" | ||
54 | #include "xfs_dinode.h" | 38 | #include "xfs_dinode.h" |
55 | #include "xfs_inode_item.h" | ||
56 | #include "xfs_inode.h" | 39 | #include "xfs_inode.h" |
40 | #include "xfs_alloc.h" | ||
41 | #include "xfs_btree.h" | ||
42 | #include "xfs_inode_item.h" | ||
57 | #include "xfs_bmap.h" | 43 | #include "xfs_bmap.h" |
58 | #include "xfs_da_btree.h" | ||
59 | #include "xfs_attr.h" | 44 | #include "xfs_attr.h" |
60 | #include "xfs_attr_leaf.h" | 45 | #include "xfs_attr_leaf.h" |
61 | #include "xfs_error.h" | 46 | #include "xfs_error.h" |
62 | #include "xfs_bit.h" | ||
63 | #include "xfs_quota.h" | 47 | #include "xfs_quota.h" |
64 | #include "xfs_rw.h" | ||
65 | #include "xfs_trans_space.h" | 48 | #include "xfs_trans_space.h" |
66 | #include "xfs_acl.h" | 49 | #include "xfs_acl.h" |
50 | #include "xfs_rw.h" | ||
67 | 51 | ||
68 | /* | 52 | /* |
69 | * xfs_attr.c | 53 | * xfs_attr.c |
@@ -122,7 +106,7 @@ ktrace_t *xfs_attr_trace_buf; | |||
122 | *========================================================================*/ | 106 | *========================================================================*/ |
123 | 107 | ||
124 | int | 108 | int |
125 | xfs_attr_fetch(xfs_inode_t *ip, char *name, int namelen, | 109 | xfs_attr_fetch(xfs_inode_t *ip, const char *name, int namelen, |
126 | char *value, int *valuelenp, int flags, struct cred *cred) | 110 | char *value, int *valuelenp, int flags, struct cred *cred) |
127 | { | 111 | { |
128 | xfs_da_args_t args; | 112 | xfs_da_args_t args; |
@@ -177,7 +161,7 @@ xfs_attr_fetch(xfs_inode_t *ip, char *name, int namelen, | |||
177 | } | 161 | } |
178 | 162 | ||
179 | int | 163 | int |
180 | xfs_attr_get(bhv_desc_t *bdp, char *name, char *value, int *valuelenp, | 164 | xfs_attr_get(bhv_desc_t *bdp, const char *name, char *value, int *valuelenp, |
181 | int flags, struct cred *cred) | 165 | int flags, struct cred *cred) |
182 | { | 166 | { |
183 | xfs_inode_t *ip = XFS_BHVTOI(bdp); | 167 | xfs_inode_t *ip = XFS_BHVTOI(bdp); |
@@ -200,40 +184,18 @@ xfs_attr_get(bhv_desc_t *bdp, char *name, char *value, int *valuelenp, | |||
200 | return(error); | 184 | return(error); |
201 | } | 185 | } |
202 | 186 | ||
203 | /*ARGSUSED*/ | 187 | STATIC int |
204 | int /* error */ | 188 | xfs_attr_set_int(xfs_inode_t *dp, const char *name, int namelen, |
205 | xfs_attr_set(bhv_desc_t *bdp, char *name, char *value, int valuelen, int flags, | 189 | char *value, int valuelen, int flags) |
206 | struct cred *cred) | ||
207 | { | 190 | { |
208 | xfs_da_args_t args; | 191 | xfs_da_args_t args; |
209 | xfs_inode_t *dp; | ||
210 | xfs_fsblock_t firstblock; | 192 | xfs_fsblock_t firstblock; |
211 | xfs_bmap_free_t flist; | 193 | xfs_bmap_free_t flist; |
212 | int error, err2, committed; | 194 | int error, err2, committed; |
213 | int local, size; | 195 | int local, size; |
214 | uint nblks; | 196 | uint nblks; |
215 | xfs_mount_t *mp; | 197 | xfs_mount_t *mp = dp->i_mount; |
216 | int rsvd = (flags & ATTR_ROOT) != 0; | 198 | int rsvd = (flags & ATTR_ROOT) != 0; |
217 | int namelen; | ||
218 | |||
219 | namelen = strlen(name); | ||
220 | if (namelen >= MAXNAMELEN) | ||
221 | return EFAULT; /* match IRIX behaviour */ | ||
222 | |||
223 | XFS_STATS_INC(xs_attr_set); | ||
224 | |||
225 | dp = XFS_BHVTOI(bdp); | ||
226 | mp = dp->i_mount; | ||
227 | if (XFS_FORCED_SHUTDOWN(mp)) | ||
228 | return (EIO); | ||
229 | |||
230 | xfs_ilock(dp, XFS_ILOCK_SHARED); | ||
231 | if (!(flags & ATTR_SECURE) && | ||
232 | (error = xfs_iaccess(dp, S_IWUSR, cred))) { | ||
233 | xfs_iunlock(dp, XFS_ILOCK_SHARED); | ||
234 | return(XFS_ERROR(error)); | ||
235 | } | ||
236 | xfs_iunlock(dp, XFS_ILOCK_SHARED); | ||
237 | 199 | ||
238 | /* | 200 | /* |
239 | * Attach the dquots to the inode. | 201 | * Attach the dquots to the inode. |
@@ -242,12 +204,18 @@ xfs_attr_set(bhv_desc_t *bdp, char *name, char *value, int valuelen, int flags, | |||
242 | return (error); | 204 | return (error); |
243 | 205 | ||
244 | /* | 206 | /* |
207 | * Determine space new attribute will use, and if it would be | ||
208 | * "local" or "remote" (note: local != inline). | ||
209 | */ | ||
210 | size = xfs_attr_leaf_newentsize(namelen, valuelen, | ||
211 | mp->m_sb.sb_blocksize, &local); | ||
212 | |||
213 | /* | ||
245 | * If the inode doesn't have an attribute fork, add one. | 214 | * If the inode doesn't have an attribute fork, add one. |
246 | * (inode must not be locked when we call this routine) | 215 | * (inode must not be locked when we call this routine) |
247 | */ | 216 | */ |
248 | if (XFS_IFORK_Q(dp) == 0) { | 217 | if (XFS_IFORK_Q(dp) == 0) { |
249 | error = xfs_bmap_add_attrfork(dp, rsvd); | 218 | if ((error = xfs_bmap_add_attrfork(dp, size, rsvd))) |
250 | if (error) | ||
251 | return(error); | 219 | return(error); |
252 | } | 220 | } |
253 | 221 | ||
@@ -265,13 +233,9 @@ xfs_attr_set(bhv_desc_t *bdp, char *name, char *value, int valuelen, int flags, | |||
265 | args.firstblock = &firstblock; | 233 | args.firstblock = &firstblock; |
266 | args.flist = &flist; | 234 | args.flist = &flist; |
267 | args.whichfork = XFS_ATTR_FORK; | 235 | args.whichfork = XFS_ATTR_FORK; |
236 | args.addname = 1; | ||
268 | args.oknoent = 1; | 237 | args.oknoent = 1; |
269 | 238 | ||
270 | /* Determine space new attribute will use, and if it will be inline | ||
271 | * or out of line. | ||
272 | */ | ||
273 | size = xfs_attr_leaf_newentsize(&args, mp->m_sb.sb_blocksize, &local); | ||
274 | |||
275 | nblks = XFS_DAENTER_SPACE_RES(mp, XFS_ATTR_FORK); | 239 | nblks = XFS_DAENTER_SPACE_RES(mp, XFS_ATTR_FORK); |
276 | if (local) { | 240 | if (local) { |
277 | if (size > (mp->m_sb.sb_blocksize >> 1)) { | 241 | if (size > (mp->m_sb.sb_blocksize >> 1)) { |
@@ -343,7 +307,7 @@ xfs_attr_set(bhv_desc_t *bdp, char *name, char *value, int valuelen, int flags, | |||
343 | * Build initial attribute list (if required). | 307 | * Build initial attribute list (if required). |
344 | */ | 308 | */ |
345 | if (dp->i_d.di_aformat == XFS_DINODE_FMT_EXTENTS) | 309 | if (dp->i_d.di_aformat == XFS_DINODE_FMT_EXTENTS) |
346 | (void)xfs_attr_shortform_create(&args); | 310 | xfs_attr_shortform_create(&args); |
347 | 311 | ||
348 | /* | 312 | /* |
349 | * Try to add the attr to the attribute list in | 313 | * Try to add the attr to the attribute list in |
@@ -456,32 +420,21 @@ out: | |||
456 | return(error); | 420 | return(error); |
457 | } | 421 | } |
458 | 422 | ||
459 | /* | 423 | int |
460 | * Generic handler routine to remove a name from an attribute list. | 424 | xfs_attr_set(bhv_desc_t *bdp, const char *name, char *value, int valuelen, int flags, |
461 | * Transitions attribute list from Btree to shortform as necessary. | 425 | struct cred *cred) |
462 | */ | ||
463 | /*ARGSUSED*/ | ||
464 | int /* error */ | ||
465 | xfs_attr_remove(bhv_desc_t *bdp, char *name, int flags, struct cred *cred) | ||
466 | { | 426 | { |
467 | xfs_da_args_t args; | 427 | xfs_inode_t *dp; |
468 | xfs_inode_t *dp; | 428 | int namelen, error; |
469 | xfs_fsblock_t firstblock; | ||
470 | xfs_bmap_free_t flist; | ||
471 | int error; | ||
472 | xfs_mount_t *mp; | ||
473 | int namelen; | ||
474 | 429 | ||
475 | ASSERT(MAXNAMELEN-1<=0xff); /* length is stored in uint8 */ | ||
476 | namelen = strlen(name); | 430 | namelen = strlen(name); |
477 | if (namelen>=MAXNAMELEN) | 431 | if (namelen >= MAXNAMELEN) |
478 | return EFAULT; /* match irix behaviour */ | 432 | return EFAULT; /* match IRIX behaviour */ |
479 | 433 | ||
480 | XFS_STATS_INC(xs_attr_remove); | 434 | XFS_STATS_INC(xs_attr_set); |
481 | 435 | ||
482 | dp = XFS_BHVTOI(bdp); | 436 | dp = XFS_BHVTOI(bdp); |
483 | mp = dp->i_mount; | 437 | if (XFS_FORCED_SHUTDOWN(dp->i_mount)) |
484 | if (XFS_FORCED_SHUTDOWN(mp)) | ||
485 | return (EIO); | 438 | return (EIO); |
486 | 439 | ||
487 | xfs_ilock(dp, XFS_ILOCK_SHARED); | 440 | xfs_ilock(dp, XFS_ILOCK_SHARED); |
@@ -489,14 +442,25 @@ xfs_attr_remove(bhv_desc_t *bdp, char *name, int flags, struct cred *cred) | |||
489 | (error = xfs_iaccess(dp, S_IWUSR, cred))) { | 442 | (error = xfs_iaccess(dp, S_IWUSR, cred))) { |
490 | xfs_iunlock(dp, XFS_ILOCK_SHARED); | 443 | xfs_iunlock(dp, XFS_ILOCK_SHARED); |
491 | return(XFS_ERROR(error)); | 444 | return(XFS_ERROR(error)); |
492 | } else if (XFS_IFORK_Q(dp) == 0 || | ||
493 | (dp->i_d.di_aformat == XFS_DINODE_FMT_EXTENTS && | ||
494 | dp->i_d.di_anextents == 0)) { | ||
495 | xfs_iunlock(dp, XFS_ILOCK_SHARED); | ||
496 | return(XFS_ERROR(ENOATTR)); | ||
497 | } | 445 | } |
498 | xfs_iunlock(dp, XFS_ILOCK_SHARED); | 446 | xfs_iunlock(dp, XFS_ILOCK_SHARED); |
499 | 447 | ||
448 | return xfs_attr_set_int(dp, name, namelen, value, valuelen, flags); | ||
449 | } | ||
450 | |||
451 | /* | ||
452 | * Generic handler routine to remove a name from an attribute list. | ||
453 | * Transitions attribute list from Btree to shortform as necessary. | ||
454 | */ | ||
455 | STATIC int | ||
456 | xfs_attr_remove_int(xfs_inode_t *dp, const char *name, int namelen, int flags) | ||
457 | { | ||
458 | xfs_da_args_t args; | ||
459 | xfs_fsblock_t firstblock; | ||
460 | xfs_bmap_free_t flist; | ||
461 | int error; | ||
462 | xfs_mount_t *mp = dp->i_mount; | ||
463 | |||
500 | /* | 464 | /* |
501 | * Fill in the arg structure for this request. | 465 | * Fill in the arg structure for this request. |
502 | */ | 466 | */ |
@@ -544,7 +508,6 @@ xfs_attr_remove(bhv_desc_t *bdp, char *name, int flags, struct cred *cred) | |||
544 | XFS_ATTRRM_LOG_COUNT))) { | 508 | XFS_ATTRRM_LOG_COUNT))) { |
545 | xfs_trans_cancel(args.trans, 0); | 509 | xfs_trans_cancel(args.trans, 0); |
546 | return(error); | 510 | return(error); |
547 | |||
548 | } | 511 | } |
549 | 512 | ||
550 | xfs_ilock(dp, XFS_ILOCK_EXCL); | 513 | xfs_ilock(dp, XFS_ILOCK_EXCL); |
@@ -612,6 +575,38 @@ out: | |||
612 | return(error); | 575 | return(error); |
613 | } | 576 | } |
614 | 577 | ||
578 | int | ||
579 | xfs_attr_remove(bhv_desc_t *bdp, const char *name, int flags, struct cred *cred) | ||
580 | { | ||
581 | xfs_inode_t *dp; | ||
582 | int namelen, error; | ||
583 | |||
584 | namelen = strlen(name); | ||
585 | if (namelen >= MAXNAMELEN) | ||
586 | return EFAULT; /* match IRIX behaviour */ | ||
587 | |||
588 | XFS_STATS_INC(xs_attr_remove); | ||
589 | |||
590 | dp = XFS_BHVTOI(bdp); | ||
591 | if (XFS_FORCED_SHUTDOWN(dp->i_mount)) | ||
592 | return (EIO); | ||
593 | |||
594 | xfs_ilock(dp, XFS_ILOCK_SHARED); | ||
595 | if (!(flags & ATTR_SECURE) && | ||
596 | (error = xfs_iaccess(dp, S_IWUSR, cred))) { | ||
597 | xfs_iunlock(dp, XFS_ILOCK_SHARED); | ||
598 | return(XFS_ERROR(error)); | ||
599 | } else if (XFS_IFORK_Q(dp) == 0 || | ||
600 | (dp->i_d.di_aformat == XFS_DINODE_FMT_EXTENTS && | ||
601 | dp->i_d.di_anextents == 0)) { | ||
602 | xfs_iunlock(dp, XFS_ILOCK_SHARED); | ||
603 | return(XFS_ERROR(ENOATTR)); | ||
604 | } | ||
605 | xfs_iunlock(dp, XFS_ILOCK_SHARED); | ||
606 | |||
607 | return xfs_attr_remove_int(dp, name, namelen, flags); | ||
608 | } | ||
609 | |||
615 | /* | 610 | /* |
616 | * Generate a list of extended attribute names and optionally | 611 | * Generate a list of extended attribute names and optionally |
617 | * also value lengths. Positive return value follows the XFS | 612 | * also value lengths. Positive return value follows the XFS |
@@ -811,7 +806,7 @@ out: | |||
811 | STATIC int | 806 | STATIC int |
812 | xfs_attr_shortform_addname(xfs_da_args_t *args) | 807 | xfs_attr_shortform_addname(xfs_da_args_t *args) |
813 | { | 808 | { |
814 | int newsize, retval; | 809 | int newsize, forkoff, retval; |
815 | 810 | ||
816 | retval = xfs_attr_shortform_lookup(args); | 811 | retval = xfs_attr_shortform_lookup(args); |
817 | if ((args->flags & ATTR_REPLACE) && (retval == ENOATTR)) { | 812 | if ((args->flags & ATTR_REPLACE) && (retval == ENOATTR)) { |
@@ -823,16 +818,18 @@ xfs_attr_shortform_addname(xfs_da_args_t *args) | |||
823 | ASSERT(retval == 0); | 818 | ASSERT(retval == 0); |
824 | } | 819 | } |
825 | 820 | ||
821 | if (args->namelen >= XFS_ATTR_SF_ENTSIZE_MAX || | ||
822 | args->valuelen >= XFS_ATTR_SF_ENTSIZE_MAX) | ||
823 | return(XFS_ERROR(ENOSPC)); | ||
824 | |||
826 | newsize = XFS_ATTR_SF_TOTSIZE(args->dp); | 825 | newsize = XFS_ATTR_SF_TOTSIZE(args->dp); |
827 | newsize += XFS_ATTR_SF_ENTSIZE_BYNAME(args->namelen, args->valuelen); | 826 | newsize += XFS_ATTR_SF_ENTSIZE_BYNAME(args->namelen, args->valuelen); |
828 | if ((newsize <= XFS_IFORK_ASIZE(args->dp)) && | 827 | |
829 | (args->namelen < XFS_ATTR_SF_ENTSIZE_MAX) && | 828 | forkoff = xfs_attr_shortform_bytesfit(args->dp, newsize); |
830 | (args->valuelen < XFS_ATTR_SF_ENTSIZE_MAX)) { | 829 | if (!forkoff) |
831 | retval = xfs_attr_shortform_add(args); | ||
832 | ASSERT(retval == 0); | ||
833 | } else { | ||
834 | return(XFS_ERROR(ENOSPC)); | 830 | return(XFS_ERROR(ENOSPC)); |
835 | } | 831 | |
832 | xfs_attr_shortform_add(args, forkoff); | ||
836 | return(0); | 833 | return(0); |
837 | } | 834 | } |
838 | 835 | ||
@@ -852,7 +849,7 @@ xfs_attr_leaf_addname(xfs_da_args_t *args) | |||
852 | { | 849 | { |
853 | xfs_inode_t *dp; | 850 | xfs_inode_t *dp; |
854 | xfs_dabuf_t *bp; | 851 | xfs_dabuf_t *bp; |
855 | int retval, error, committed; | 852 | int retval, error, committed, forkoff; |
856 | 853 | ||
857 | /* | 854 | /* |
858 | * Read the (only) block in the attribute list in. | 855 | * Read the (only) block in the attribute list in. |
@@ -995,9 +992,9 @@ xfs_attr_leaf_addname(xfs_da_args_t *args) | |||
995 | /* | 992 | /* |
996 | * If the result is small enough, shrink it all into the inode. | 993 | * If the result is small enough, shrink it all into the inode. |
997 | */ | 994 | */ |
998 | if (xfs_attr_shortform_allfit(bp, dp)) { | 995 | if ((forkoff = xfs_attr_shortform_allfit(bp, dp))) { |
999 | XFS_BMAP_INIT(args->flist, args->firstblock); | 996 | XFS_BMAP_INIT(args->flist, args->firstblock); |
1000 | error = xfs_attr_leaf_to_shortform(bp, args); | 997 | error = xfs_attr_leaf_to_shortform(bp, args, forkoff); |
1001 | /* bp is gone due to xfs_da_shrink_inode */ | 998 | /* bp is gone due to xfs_da_shrink_inode */ |
1002 | if (!error) { | 999 | if (!error) { |
1003 | error = xfs_bmap_finish(&args->trans, | 1000 | error = xfs_bmap_finish(&args->trans, |
@@ -1049,8 +1046,7 @@ xfs_attr_leaf_removename(xfs_da_args_t *args) | |||
1049 | { | 1046 | { |
1050 | xfs_inode_t *dp; | 1047 | xfs_inode_t *dp; |
1051 | xfs_dabuf_t *bp; | 1048 | xfs_dabuf_t *bp; |
1052 | int committed; | 1049 | int error, committed, forkoff; |
1053 | int error; | ||
1054 | 1050 | ||
1055 | /* | 1051 | /* |
1056 | * Remove the attribute. | 1052 | * Remove the attribute. |
@@ -1075,9 +1071,9 @@ xfs_attr_leaf_removename(xfs_da_args_t *args) | |||
1075 | /* | 1071 | /* |
1076 | * If the result is small enough, shrink it all into the inode. | 1072 | * If the result is small enough, shrink it all into the inode. |
1077 | */ | 1073 | */ |
1078 | if (xfs_attr_shortform_allfit(bp, dp)) { | 1074 | if ((forkoff = xfs_attr_shortform_allfit(bp, dp))) { |
1079 | XFS_BMAP_INIT(args->flist, args->firstblock); | 1075 | XFS_BMAP_INIT(args->flist, args->firstblock); |
1080 | error = xfs_attr_leaf_to_shortform(bp, args); | 1076 | error = xfs_attr_leaf_to_shortform(bp, args, forkoff); |
1081 | /* bp is gone due to xfs_da_shrink_inode */ | 1077 | /* bp is gone due to xfs_da_shrink_inode */ |
1082 | if (!error) { | 1078 | if (!error) { |
1083 | error = xfs_bmap_finish(&args->trans, args->flist, | 1079 | error = xfs_bmap_finish(&args->trans, args->flist, |
@@ -1448,7 +1444,7 @@ xfs_attr_node_removename(xfs_da_args_t *args) | |||
1448 | xfs_da_state_blk_t *blk; | 1444 | xfs_da_state_blk_t *blk; |
1449 | xfs_inode_t *dp; | 1445 | xfs_inode_t *dp; |
1450 | xfs_dabuf_t *bp; | 1446 | xfs_dabuf_t *bp; |
1451 | int retval, error, committed; | 1447 | int retval, error, committed, forkoff; |
1452 | 1448 | ||
1453 | /* | 1449 | /* |
1454 | * Tie a string around our finger to remind us where we are. | 1450 | * Tie a string around our finger to remind us where we are. |
@@ -1569,9 +1565,9 @@ xfs_attr_node_removename(xfs_da_args_t *args) | |||
1569 | bp->data)->hdr.info.magic, ARCH_CONVERT) | 1565 | bp->data)->hdr.info.magic, ARCH_CONVERT) |
1570 | == XFS_ATTR_LEAF_MAGIC); | 1566 | == XFS_ATTR_LEAF_MAGIC); |
1571 | 1567 | ||
1572 | if (xfs_attr_shortform_allfit(bp, dp)) { | 1568 | if ((forkoff = xfs_attr_shortform_allfit(bp, dp))) { |
1573 | XFS_BMAP_INIT(args->flist, args->firstblock); | 1569 | XFS_BMAP_INIT(args->flist, args->firstblock); |
1574 | error = xfs_attr_leaf_to_shortform(bp, args); | 1570 | error = xfs_attr_leaf_to_shortform(bp, args, forkoff); |
1575 | /* bp is gone due to xfs_da_shrink_inode */ | 1571 | /* bp is gone due to xfs_da_shrink_inode */ |
1576 | if (!error) { | 1572 | if (!error) { |
1577 | error = xfs_bmap_finish(&args->trans, | 1573 | error = xfs_bmap_finish(&args->trans, |
diff --git a/fs/xfs/xfs_attr.h b/fs/xfs/xfs_attr.h index 45ab1c542baf..b2c7b9fcded3 100644 --- a/fs/xfs/xfs_attr.h +++ b/fs/xfs/xfs_attr.h | |||
@@ -1,33 +1,19 @@ | |||
1 | /* | 1 | /* |
2 | * Copyright (c) 2000, 2002-2003 Silicon Graphics, Inc. All Rights Reserved. | 2 | * Copyright (c) 2000,2002-2003,2005 Silicon Graphics, Inc. |
3 | * All Rights Reserved. | ||
3 | * | 4 | * |
4 | * This program is free software; you can redistribute it and/or modify it | 5 | * This program is free software; you can redistribute it and/or |
5 | * under the terms of version 2 of the GNU General Public License as | 6 | * modify it under the terms of the GNU General Public License as |
6 | * published by the Free Software Foundation. | 7 | * published by the Free Software Foundation. |
7 | * | 8 | * |
8 | * This program is distributed in the hope that it would be useful, but | 9 | * This program is distributed in the hope that it would be useful, |
9 | * WITHOUT ANY WARRANTY; without even the implied warranty of | 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
12 | * GNU General Public License for more details. | ||
11 | * | 13 | * |
12 | * Further, this software is distributed without any warranty that it is | 14 | * You should have received a copy of the GNU General Public License |
13 | * free of the rightful claim of any third person regarding infringement | 15 | * along with this program; if not, write the Free Software Foundation, |
14 | * or the like. Any license provided herein, whether implied or | 16 | * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
15 | * otherwise, applies only to this software file. Patent licenses, if | ||
16 | * any, provided herein do not apply to combinations of this program with | ||
17 | * other software, or any other product whatsoever. | ||
18 | * | ||
19 | * You should have received a copy of the GNU General Public License along | ||
20 | * with this program; if not, write the Free Software Foundation, Inc., 59 | ||
21 | * Temple Place - Suite 330, Boston MA 02111-1307, USA. | ||
22 | * | ||
23 | * Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy, | ||
24 | * Mountain View, CA 94043, or: | ||
25 | * | ||
26 | * http://www.sgi.com | ||
27 | * | ||
28 | * For further information regarding this notice, see: | ||
29 | * | ||
30 | * http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/ | ||
31 | */ | 17 | */ |
32 | #ifndef __XFS_ATTR_H__ | 18 | #ifndef __XFS_ATTR_H__ |
33 | #define __XFS_ATTR_H__ | 19 | #define __XFS_ATTR_H__ |
@@ -172,15 +158,15 @@ struct xfs_da_args; | |||
172 | /* | 158 | /* |
173 | * Overall external interface routines. | 159 | * Overall external interface routines. |
174 | */ | 160 | */ |
175 | int xfs_attr_get(bhv_desc_t *, char *, char *, int *, int, struct cred *); | 161 | int xfs_attr_get(bhv_desc_t *, const char *, char *, int *, int, struct cred *); |
176 | int xfs_attr_set(bhv_desc_t *, char *, char *, int, int, struct cred *); | 162 | int xfs_attr_set(bhv_desc_t *, const char *, char *, int, int, struct cred *); |
177 | int xfs_attr_remove(bhv_desc_t *, char *, int, struct cred *); | 163 | int xfs_attr_remove(bhv_desc_t *, const char *, int, struct cred *); |
178 | int xfs_attr_list(bhv_desc_t *, char *, int, int, | 164 | int xfs_attr_list(bhv_desc_t *, char *, int, int, |
179 | struct attrlist_cursor_kern *, struct cred *); | 165 | struct attrlist_cursor_kern *, struct cred *); |
180 | int xfs_attr_inactive(struct xfs_inode *dp); | 166 | int xfs_attr_inactive(struct xfs_inode *dp); |
181 | 167 | ||
182 | int xfs_attr_shortform_getvalue(struct xfs_da_args *); | 168 | int xfs_attr_shortform_getvalue(struct xfs_da_args *); |
183 | int xfs_attr_fetch(struct xfs_inode *, char *, int, | 169 | int xfs_attr_fetch(struct xfs_inode *, const char *, int, |
184 | char *, int *, int, struct cred *); | 170 | char *, int *, int, struct cred *); |
185 | 171 | ||
186 | #endif /* __XFS_ATTR_H__ */ | 172 | #endif /* __XFS_ATTR_H__ */ |
diff --git a/fs/xfs/xfs_attr_leaf.c b/fs/xfs/xfs_attr_leaf.c index 1cdd574c63a9..35e557b00db2 100644 --- a/fs/xfs/xfs_attr_leaf.c +++ b/fs/xfs/xfs_attr_leaf.c | |||
@@ -1,46 +1,26 @@ | |||
1 | /* | 1 | /* |
2 | * Copyright (c) 2000-2003 Silicon Graphics, Inc. All Rights Reserved. | 2 | * Copyright (c) 2000-2005 Silicon Graphics, Inc. |
3 | * All Rights Reserved. | ||
3 | * | 4 | * |
4 | * This program is free software; you can redistribute it and/or modify it | 5 | * This program is free software; you can redistribute it and/or |
5 | * under the terms of version 2 of the GNU General Public License as | 6 | * modify it under the terms of the GNU General Public License as |
6 | * published by the Free Software Foundation. | 7 | * published by the Free Software Foundation. |
7 | * | 8 | * |
8 | * This program is distributed in the hope that it would be useful, but | 9 | * This program is distributed in the hope that it would be useful, |
9 | * WITHOUT ANY WARRANTY; without even the implied warranty of | 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
12 | * GNU General Public License for more details. | ||
11 | * | 13 | * |
12 | * Further, this software is distributed without any warranty that it is | 14 | * You should have received a copy of the GNU General Public License |
13 | * free of the rightful claim of any third person regarding infringement | 15 | * along with this program; if not, write the Free Software Foundation, |
14 | * or the like. Any license provided herein, whether implied or | 16 | * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
15 | * otherwise, applies only to this software file. Patent licenses, if | ||
16 | * any, provided herein do not apply to combinations of this program with | ||
17 | * other software, or any other product whatsoever. | ||
18 | * | ||
19 | * You should have received a copy of the GNU General Public License along | ||
20 | * with this program; if not, write the Free Software Foundation, Inc., 59 | ||
21 | * Temple Place - Suite 330, Boston MA 02111-1307, USA. | ||
22 | * | ||
23 | * Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy, | ||
24 | * Mountain View, CA 94043, or: | ||
25 | * | ||
26 | * http://www.sgi.com | ||
27 | * | ||
28 | * For further information regarding this notice, see: | ||
29 | * | ||
30 | * http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/ | ||
31 | */ | 17 | */ |
32 | /* | ||
33 | * xfs_attr_leaf.c | ||
34 | * | ||
35 | * GROT: figure out how to recover gracefully when bmap returns ENOSPC. | ||
36 | */ | ||
37 | |||
38 | #include "xfs.h" | 18 | #include "xfs.h" |
39 | 19 | #include "xfs_fs.h" | |
40 | #include "xfs_macros.h" | ||
41 | #include "xfs_types.h" | 20 | #include "xfs_types.h" |
42 | #include "xfs_inum.h" | 21 | #include "xfs_bit.h" |
43 | #include "xfs_log.h" | 22 | #include "xfs_log.h" |
23 | #include "xfs_inum.h" | ||
44 | #include "xfs_trans.h" | 24 | #include "xfs_trans.h" |
45 | #include "xfs_sb.h" | 25 | #include "xfs_sb.h" |
46 | #include "xfs_ag.h" | 26 | #include "xfs_ag.h" |
@@ -48,23 +28,22 @@ | |||
48 | #include "xfs_dir2.h" | 28 | #include "xfs_dir2.h" |
49 | #include "xfs_dmapi.h" | 29 | #include "xfs_dmapi.h" |
50 | #include "xfs_mount.h" | 30 | #include "xfs_mount.h" |
51 | #include "xfs_alloc_btree.h" | 31 | #include "xfs_da_btree.h" |
52 | #include "xfs_bmap_btree.h" | 32 | #include "xfs_bmap_btree.h" |
33 | #include "xfs_alloc_btree.h" | ||
53 | #include "xfs_ialloc_btree.h" | 34 | #include "xfs_ialloc_btree.h" |
54 | #include "xfs_alloc.h" | 35 | #include "xfs_alloc.h" |
55 | #include "xfs_btree.h" | 36 | #include "xfs_btree.h" |
56 | #include "xfs_attr_sf.h" | ||
57 | #include "xfs_dir_sf.h" | 37 | #include "xfs_dir_sf.h" |
58 | #include "xfs_dir2_sf.h" | 38 | #include "xfs_dir2_sf.h" |
39 | #include "xfs_attr_sf.h" | ||
59 | #include "xfs_dinode.h" | 40 | #include "xfs_dinode.h" |
60 | #include "xfs_inode_item.h" | ||
61 | #include "xfs_inode.h" | 41 | #include "xfs_inode.h" |
42 | #include "xfs_inode_item.h" | ||
62 | #include "xfs_bmap.h" | 43 | #include "xfs_bmap.h" |
63 | #include "xfs_da_btree.h" | ||
64 | #include "xfs_attr.h" | 44 | #include "xfs_attr.h" |
65 | #include "xfs_attr_leaf.h" | 45 | #include "xfs_attr_leaf.h" |
66 | #include "xfs_error.h" | 46 | #include "xfs_error.h" |
67 | #include "xfs_bit.h" | ||
68 | 47 | ||
69 | /* | 48 | /* |
70 | * xfs_attr_leaf.c | 49 | * xfs_attr_leaf.c |
@@ -118,13 +97,82 @@ STATIC int xfs_attr_put_listent(xfs_attr_list_context_t *context, | |||
118 | 97 | ||
119 | 98 | ||
120 | /*======================================================================== | 99 | /*======================================================================== |
121 | * External routines when dirsize < XFS_LITINO(mp). | 100 | * External routines when attribute fork size < XFS_LITINO(mp). |
122 | *========================================================================*/ | 101 | *========================================================================*/ |
123 | 102 | ||
124 | /* | 103 | /* |
125 | * Create the initial contents of a shortform attribute list. | 104 | * Query whether the requested number of additional bytes of extended |
105 | * attribute space will be able to fit inline. | ||
106 | * Returns zero if not, else the di_forkoff fork offset to be used in the | ||
107 | * literal area for attribute data once the new bytes have been added. | ||
108 | * | ||
109 | * di_forkoff must be 8 byte aligned, hence is stored as a >>3 value; | ||
110 | * special case for dev/uuid inodes, they have fixed size data forks. | ||
126 | */ | 111 | */ |
127 | int | 112 | int |
113 | xfs_attr_shortform_bytesfit(xfs_inode_t *dp, int bytes) | ||
114 | { | ||
115 | int offset; | ||
116 | int minforkoff; /* lower limit on valid forkoff locations */ | ||
117 | int maxforkoff; /* upper limit on valid forkoff locations */ | ||
118 | xfs_mount_t *mp = dp->i_mount; | ||
119 | |||
120 | offset = (XFS_LITINO(mp) - bytes) >> 3; /* rounded down */ | ||
121 | |||
122 | switch (dp->i_d.di_format) { | ||
123 | case XFS_DINODE_FMT_DEV: | ||
124 | minforkoff = roundup(sizeof(xfs_dev_t), 8) >> 3; | ||
125 | return (offset >= minforkoff) ? minforkoff : 0; | ||
126 | case XFS_DINODE_FMT_UUID: | ||
127 | minforkoff = roundup(sizeof(uuid_t), 8) >> 3; | ||
128 | return (offset >= minforkoff) ? minforkoff : 0; | ||
129 | } | ||
130 | |||
131 | if (unlikely(mp->m_flags & XFS_MOUNT_COMPAT_ATTR)) { | ||
132 | if (bytes <= XFS_IFORK_ASIZE(dp)) | ||
133 | return mp->m_attroffset >> 3; | ||
134 | return 0; | ||
135 | } | ||
136 | |||
137 | /* data fork btree root can have at least this many key/ptr pairs */ | ||
138 | minforkoff = MAX(dp->i_df.if_bytes, XFS_BMDR_SPACE_CALC(MINDBTPTRS)); | ||
139 | minforkoff = roundup(minforkoff, 8) >> 3; | ||
140 | |||
141 | /* attr fork btree root can have at least this many key/ptr pairs */ | ||
142 | maxforkoff = XFS_LITINO(mp) - XFS_BMDR_SPACE_CALC(MINABTPTRS); | ||
143 | maxforkoff = maxforkoff >> 3; /* rounded down */ | ||
144 | |||
145 | if (offset >= minforkoff && offset < maxforkoff) | ||
146 | return offset; | ||
147 | if (offset >= maxforkoff) | ||
148 | return maxforkoff; | ||
149 | return 0; | ||
150 | } | ||
151 | |||
152 | /* | ||
153 | * Switch on the ATTR2 superblock bit (implies also FEATURES2) | ||
154 | */ | ||
155 | STATIC void | ||
156 | xfs_sbversion_add_attr2(xfs_mount_t *mp, xfs_trans_t *tp) | ||
157 | { | ||
158 | unsigned long s; | ||
159 | |||
160 | if (!(mp->m_flags & XFS_MOUNT_COMPAT_ATTR) && | ||
161 | !(XFS_SB_VERSION_HASATTR2(&mp->m_sb))) { | ||
162 | s = XFS_SB_LOCK(mp); | ||
163 | if (!XFS_SB_VERSION_HASATTR2(&mp->m_sb)) { | ||
164 | XFS_SB_VERSION_ADDATTR2(&mp->m_sb); | ||
165 | XFS_SB_UNLOCK(mp, s); | ||
166 | xfs_mod_sb(tp, XFS_SB_VERSIONNUM | XFS_SB_FEATURES2); | ||
167 | } else | ||
168 | XFS_SB_UNLOCK(mp, s); | ||
169 | } | ||
170 | } | ||
171 | |||
172 | /* | ||
173 | * Create the initial contents of a shortform attribute list. | ||
174 | */ | ||
175 | void | ||
128 | xfs_attr_shortform_create(xfs_da_args_t *args) | 176 | xfs_attr_shortform_create(xfs_da_args_t *args) |
129 | { | 177 | { |
130 | xfs_attr_sf_hdr_t *hdr; | 178 | xfs_attr_sf_hdr_t *hdr; |
@@ -148,29 +196,37 @@ xfs_attr_shortform_create(xfs_da_args_t *args) | |||
148 | hdr->count = 0; | 196 | hdr->count = 0; |
149 | INT_SET(hdr->totsize, ARCH_CONVERT, sizeof(*hdr)); | 197 | INT_SET(hdr->totsize, ARCH_CONVERT, sizeof(*hdr)); |
150 | xfs_trans_log_inode(args->trans, dp, XFS_ILOG_CORE | XFS_ILOG_ADATA); | 198 | xfs_trans_log_inode(args->trans, dp, XFS_ILOG_CORE | XFS_ILOG_ADATA); |
151 | return(0); | ||
152 | } | 199 | } |
153 | 200 | ||
154 | /* | 201 | /* |
155 | * Add a name/value pair to the shortform attribute list. | 202 | * Add a name/value pair to the shortform attribute list. |
156 | * Overflow from the inode has already been checked for. | 203 | * Overflow from the inode has already been checked for. |
157 | */ | 204 | */ |
158 | int | 205 | void |
159 | xfs_attr_shortform_add(xfs_da_args_t *args) | 206 | xfs_attr_shortform_add(xfs_da_args_t *args, int forkoff) |
160 | { | 207 | { |
161 | xfs_attr_shortform_t *sf; | 208 | xfs_attr_shortform_t *sf; |
162 | xfs_attr_sf_entry_t *sfe; | 209 | xfs_attr_sf_entry_t *sfe; |
163 | int i, offset, size; | 210 | int i, offset, size; |
211 | xfs_mount_t *mp; | ||
164 | xfs_inode_t *dp; | 212 | xfs_inode_t *dp; |
165 | xfs_ifork_t *ifp; | 213 | xfs_ifork_t *ifp; |
166 | 214 | ||
167 | dp = args->dp; | 215 | dp = args->dp; |
216 | mp = dp->i_mount; | ||
217 | dp->i_d.di_forkoff = forkoff; | ||
218 | dp->i_df.if_ext_max = | ||
219 | XFS_IFORK_DSIZE(dp) / (uint)sizeof(xfs_bmbt_rec_t); | ||
220 | dp->i_afp->if_ext_max = | ||
221 | XFS_IFORK_ASIZE(dp) / (uint)sizeof(xfs_bmbt_rec_t); | ||
222 | |||
168 | ifp = dp->i_afp; | 223 | ifp = dp->i_afp; |
169 | ASSERT(ifp->if_flags & XFS_IFINLINE); | 224 | ASSERT(ifp->if_flags & XFS_IFINLINE); |
170 | sf = (xfs_attr_shortform_t *)ifp->if_u1.if_data; | 225 | sf = (xfs_attr_shortform_t *)ifp->if_u1.if_data; |
171 | sfe = &sf->list[0]; | 226 | sfe = &sf->list[0]; |
172 | for (i = 0; i < INT_GET(sf->hdr.count, ARCH_CONVERT); | 227 | for (i = 0; i < INT_GET(sf->hdr.count, ARCH_CONVERT); |
173 | sfe = XFS_ATTR_SF_NEXTENTRY(sfe), i++) { | 228 | sfe = XFS_ATTR_SF_NEXTENTRY(sfe), i++) { |
229 | #ifdef DEBUG | ||
174 | if (sfe->namelen != args->namelen) | 230 | if (sfe->namelen != args->namelen) |
175 | continue; | 231 | continue; |
176 | if (memcmp(args->name, sfe->nameval, args->namelen) != 0) | 232 | if (memcmp(args->name, sfe->nameval, args->namelen) != 0) |
@@ -181,7 +237,8 @@ xfs_attr_shortform_add(xfs_da_args_t *args) | |||
181 | if (((args->flags & ATTR_ROOT) != 0) != | 237 | if (((args->flags & ATTR_ROOT) != 0) != |
182 | ((sfe->flags & XFS_ATTR_ROOT) != 0)) | 238 | ((sfe->flags & XFS_ATTR_ROOT) != 0)) |
183 | continue; | 239 | continue; |
184 | return(XFS_ERROR(EEXIST)); | 240 | ASSERT(0); |
241 | #endif | ||
185 | } | 242 | } |
186 | 243 | ||
187 | offset = (char *)sfe - (char *)sf; | 244 | offset = (char *)sfe - (char *)sf; |
@@ -200,11 +257,11 @@ xfs_attr_shortform_add(xfs_da_args_t *args) | |||
200 | INT_MOD(sf->hdr.totsize, ARCH_CONVERT, size); | 257 | INT_MOD(sf->hdr.totsize, ARCH_CONVERT, size); |
201 | xfs_trans_log_inode(args->trans, dp, XFS_ILOG_CORE | XFS_ILOG_ADATA); | 258 | xfs_trans_log_inode(args->trans, dp, XFS_ILOG_CORE | XFS_ILOG_ADATA); |
202 | 259 | ||
203 | return(0); | 260 | xfs_sbversion_add_attr2(mp, args->trans); |
204 | } | 261 | } |
205 | 262 | ||
206 | /* | 263 | /* |
207 | * Remove a name from the shortform attribute list structure. | 264 | * Remove an attribute from the shortform attribute list structure. |
208 | */ | 265 | */ |
209 | int | 266 | int |
210 | xfs_attr_shortform_remove(xfs_da_args_t *args) | 267 | xfs_attr_shortform_remove(xfs_da_args_t *args) |
@@ -212,17 +269,16 @@ xfs_attr_shortform_remove(xfs_da_args_t *args) | |||
212 | xfs_attr_shortform_t *sf; | 269 | xfs_attr_shortform_t *sf; |
213 | xfs_attr_sf_entry_t *sfe; | 270 | xfs_attr_sf_entry_t *sfe; |
214 | int base, size=0, end, totsize, i; | 271 | int base, size=0, end, totsize, i; |
272 | xfs_mount_t *mp; | ||
215 | xfs_inode_t *dp; | 273 | xfs_inode_t *dp; |
216 | 274 | ||
217 | /* | ||
218 | * Remove the attribute. | ||
219 | */ | ||
220 | dp = args->dp; | 275 | dp = args->dp; |
276 | mp = dp->i_mount; | ||
221 | base = sizeof(xfs_attr_sf_hdr_t); | 277 | base = sizeof(xfs_attr_sf_hdr_t); |
222 | sf = (xfs_attr_shortform_t *)dp->i_afp->if_u1.if_data; | 278 | sf = (xfs_attr_shortform_t *)dp->i_afp->if_u1.if_data; |
223 | sfe = &sf->list[0]; | 279 | sfe = &sf->list[0]; |
224 | for (i = 0; i < INT_GET(sf->hdr.count, ARCH_CONVERT); | 280 | end = INT_GET(sf->hdr.count, ARCH_CONVERT); |
225 | sfe = XFS_ATTR_SF_NEXTENTRY(sfe), | 281 | for (i = 0; i < end; sfe = XFS_ATTR_SF_NEXTENTRY(sfe), |
226 | base += size, i++) { | 282 | base += size, i++) { |
227 | size = XFS_ATTR_SF_ENTSIZE(sfe); | 283 | size = XFS_ATTR_SF_ENTSIZE(sfe); |
228 | if (sfe->namelen != args->namelen) | 284 | if (sfe->namelen != args->namelen) |
@@ -237,19 +293,51 @@ xfs_attr_shortform_remove(xfs_da_args_t *args) | |||
237 | continue; | 293 | continue; |
238 | break; | 294 | break; |
239 | } | 295 | } |
240 | if (i == INT_GET(sf->hdr.count, ARCH_CONVERT)) | 296 | if (i == end) |
241 | return(XFS_ERROR(ENOATTR)); | 297 | return(XFS_ERROR(ENOATTR)); |
242 | 298 | ||
299 | /* | ||
300 | * Fix up the attribute fork data, covering the hole | ||
301 | */ | ||
243 | end = base + size; | 302 | end = base + size; |
244 | totsize = INT_GET(sf->hdr.totsize, ARCH_CONVERT); | 303 | totsize = INT_GET(sf->hdr.totsize, ARCH_CONVERT); |
245 | if (end != totsize) { | 304 | if (end != totsize) |
246 | memmove(&((char *)sf)[base], &((char *)sf)[end], | 305 | memmove(&((char *)sf)[base], &((char *)sf)[end], totsize - end); |
247 | totsize - end); | ||
248 | } | ||
249 | INT_MOD(sf->hdr.count, ARCH_CONVERT, -1); | 306 | INT_MOD(sf->hdr.count, ARCH_CONVERT, -1); |
250 | INT_MOD(sf->hdr.totsize, ARCH_CONVERT, -size); | 307 | INT_MOD(sf->hdr.totsize, ARCH_CONVERT, -size); |
251 | xfs_idata_realloc(dp, -size, XFS_ATTR_FORK); | 308 | |
252 | xfs_trans_log_inode(args->trans, dp, XFS_ILOG_CORE | XFS_ILOG_ADATA); | 309 | /* |
310 | * Fix up the start offset of the attribute fork | ||
311 | */ | ||
312 | totsize -= size; | ||
313 | if (totsize == sizeof(xfs_attr_sf_hdr_t) && !args->addname) { | ||
314 | /* | ||
315 | * Last attribute now removed, revert to original | ||
316 | * inode format making all literal area available | ||
317 | * to the data fork once more. | ||
318 | */ | ||
319 | xfs_idestroy_fork(dp, XFS_ATTR_FORK); | ||
320 | dp->i_d.di_forkoff = 0; | ||
321 | dp->i_d.di_aformat = XFS_DINODE_FMT_EXTENTS; | ||
322 | ASSERT(dp->i_d.di_anextents == 0); | ||
323 | ASSERT(dp->i_afp == NULL); | ||
324 | dp->i_df.if_ext_max = | ||
325 | XFS_IFORK_DSIZE(dp) / (uint)sizeof(xfs_bmbt_rec_t); | ||
326 | xfs_trans_log_inode(args->trans, dp, XFS_ILOG_CORE); | ||
327 | } else { | ||
328 | xfs_idata_realloc(dp, -size, XFS_ATTR_FORK); | ||
329 | dp->i_d.di_forkoff = xfs_attr_shortform_bytesfit(dp, totsize); | ||
330 | ASSERT(dp->i_d.di_forkoff); | ||
331 | ASSERT(totsize > sizeof(xfs_attr_sf_hdr_t) || args->addname); | ||
332 | dp->i_afp->if_ext_max = | ||
333 | XFS_IFORK_ASIZE(dp) / (uint)sizeof(xfs_bmbt_rec_t); | ||
334 | dp->i_df.if_ext_max = | ||
335 | XFS_IFORK_DSIZE(dp) / (uint)sizeof(xfs_bmbt_rec_t); | ||
336 | xfs_trans_log_inode(args->trans, dp, | ||
337 | XFS_ILOG_CORE | XFS_ILOG_ADATA); | ||
338 | } | ||
339 | |||
340 | xfs_sbversion_add_attr2(mp, args->trans); | ||
253 | 341 | ||
254 | return(0); | 342 | return(0); |
255 | } | 343 | } |
@@ -561,7 +649,7 @@ xfs_attr_shortform_list(xfs_attr_list_context_t *context) | |||
561 | /* | 649 | /* |
562 | * Sort the entries on hash then entno. | 650 | * Sort the entries on hash then entno. |
563 | */ | 651 | */ |
564 | qsort(sbuf, nsbuf, sizeof(*sbuf), xfs_attr_shortform_compare); | 652 | xfs_sort(sbuf, nsbuf, sizeof(*sbuf), xfs_attr_shortform_compare); |
565 | 653 | ||
566 | /* | 654 | /* |
567 | * Re-find our place IN THE SORTED LIST. | 655 | * Re-find our place IN THE SORTED LIST. |
@@ -649,14 +737,16 @@ xfs_attr_shortform_allfit(xfs_dabuf_t *bp, xfs_inode_t *dp) | |||
649 | + name_loc->namelen | 737 | + name_loc->namelen |
650 | + INT_GET(name_loc->valuelen, ARCH_CONVERT); | 738 | + INT_GET(name_loc->valuelen, ARCH_CONVERT); |
651 | } | 739 | } |
652 | return( bytes < XFS_IFORK_ASIZE(dp) ); | 740 | if (bytes == sizeof(struct xfs_attr_sf_hdr)) |
741 | return(-1); | ||
742 | return(xfs_attr_shortform_bytesfit(dp, bytes)); | ||
653 | } | 743 | } |
654 | 744 | ||
655 | /* | 745 | /* |
656 | * Convert a leaf attribute list to shortform attribute list | 746 | * Convert a leaf attribute list to shortform attribute list |
657 | */ | 747 | */ |
658 | int | 748 | int |
659 | xfs_attr_leaf_to_shortform(xfs_dabuf_t *bp, xfs_da_args_t *args) | 749 | xfs_attr_leaf_to_shortform(xfs_dabuf_t *bp, xfs_da_args_t *args, int forkoff) |
660 | { | 750 | { |
661 | xfs_attr_leafblock_t *leaf; | 751 | xfs_attr_leafblock_t *leaf; |
662 | xfs_attr_leaf_entry_t *entry; | 752 | xfs_attr_leaf_entry_t *entry; |
@@ -683,9 +773,25 @@ xfs_attr_leaf_to_shortform(xfs_dabuf_t *bp, xfs_da_args_t *args) | |||
683 | error = xfs_da_shrink_inode(args, 0, bp); | 773 | error = xfs_da_shrink_inode(args, 0, bp); |
684 | if (error) | 774 | if (error) |
685 | goto out; | 775 | goto out; |
686 | error = xfs_attr_shortform_create(args); | 776 | |
687 | if (error) | 777 | if (forkoff == -1) { |
778 | /* | ||
779 | * Last attribute was removed, revert to original | ||
780 | * inode format making all literal area available | ||
781 | * to the data fork once more. | ||
782 | */ | ||
783 | xfs_idestroy_fork(dp, XFS_ATTR_FORK); | ||
784 | dp->i_d.di_forkoff = 0; | ||
785 | dp->i_d.di_aformat = XFS_DINODE_FMT_EXTENTS; | ||
786 | ASSERT(dp->i_d.di_anextents == 0); | ||
787 | ASSERT(dp->i_afp == NULL); | ||
788 | dp->i_df.if_ext_max = | ||
789 | XFS_IFORK_DSIZE(dp) / (uint)sizeof(xfs_bmbt_rec_t); | ||
790 | xfs_trans_log_inode(args->trans, dp, XFS_ILOG_CORE); | ||
688 | goto out; | 791 | goto out; |
792 | } | ||
793 | |||
794 | xfs_attr_shortform_create(args); | ||
689 | 795 | ||
690 | /* | 796 | /* |
691 | * Copy the attributes | 797 | * Copy the attributes |
@@ -713,7 +819,7 @@ xfs_attr_leaf_to_shortform(xfs_dabuf_t *bp, xfs_da_args_t *args) | |||
713 | nargs.hashval = INT_GET(entry->hashval, ARCH_CONVERT); | 819 | nargs.hashval = INT_GET(entry->hashval, ARCH_CONVERT); |
714 | nargs.flags = (entry->flags & XFS_ATTR_SECURE) ? ATTR_SECURE : | 820 | nargs.flags = (entry->flags & XFS_ATTR_SECURE) ? ATTR_SECURE : |
715 | ((entry->flags & XFS_ATTR_ROOT) ? ATTR_ROOT : 0); | 821 | ((entry->flags & XFS_ATTR_ROOT) ? ATTR_ROOT : 0); |
716 | xfs_attr_shortform_add(&nargs); | 822 | xfs_attr_shortform_add(&nargs, forkoff); |
717 | } | 823 | } |
718 | error = 0; | 824 | error = 0; |
719 | 825 | ||
@@ -898,7 +1004,7 @@ xfs_attr_leaf_add(xfs_dabuf_t *bp, xfs_da_args_t *args) | |||
898 | ASSERT((args->index >= 0) | 1004 | ASSERT((args->index >= 0) |
899 | && (args->index <= INT_GET(leaf->hdr.count, ARCH_CONVERT))); | 1005 | && (args->index <= INT_GET(leaf->hdr.count, ARCH_CONVERT))); |
900 | hdr = &leaf->hdr; | 1006 | hdr = &leaf->hdr; |
901 | entsize = xfs_attr_leaf_newentsize(args, | 1007 | entsize = xfs_attr_leaf_newentsize(args->namelen, args->valuelen, |
902 | args->trans->t_mountp->m_sb.sb_blocksize, NULL); | 1008 | args->trans->t_mountp->m_sb.sb_blocksize, NULL); |
903 | 1009 | ||
904 | /* | 1010 | /* |
@@ -995,13 +1101,14 @@ xfs_attr_leaf_add_work(xfs_dabuf_t *bp, xfs_da_args_t *args, int mapindex) | |||
995 | mp = args->trans->t_mountp; | 1101 | mp = args->trans->t_mountp; |
996 | ASSERT(INT_GET(map->base, ARCH_CONVERT) < XFS_LBSIZE(mp)); | 1102 | ASSERT(INT_GET(map->base, ARCH_CONVERT) < XFS_LBSIZE(mp)); |
997 | ASSERT((INT_GET(map->base, ARCH_CONVERT) & 0x3) == 0); | 1103 | ASSERT((INT_GET(map->base, ARCH_CONVERT) & 0x3) == 0); |
998 | ASSERT(INT_GET(map->size, ARCH_CONVERT) | 1104 | ASSERT(INT_GET(map->size, ARCH_CONVERT) >= |
999 | >= xfs_attr_leaf_newentsize(args, | 1105 | xfs_attr_leaf_newentsize(args->namelen, args->valuelen, |
1000 | mp->m_sb.sb_blocksize, NULL)); | 1106 | mp->m_sb.sb_blocksize, NULL)); |
1001 | ASSERT(INT_GET(map->size, ARCH_CONVERT) < XFS_LBSIZE(mp)); | 1107 | ASSERT(INT_GET(map->size, ARCH_CONVERT) < XFS_LBSIZE(mp)); |
1002 | ASSERT((INT_GET(map->size, ARCH_CONVERT) & 0x3) == 0); | 1108 | ASSERT((INT_GET(map->size, ARCH_CONVERT) & 0x3) == 0); |
1003 | INT_MOD(map->size, ARCH_CONVERT, | 1109 | INT_MOD(map->size, ARCH_CONVERT, |
1004 | -xfs_attr_leaf_newentsize(args, mp->m_sb.sb_blocksize, &tmp)); | 1110 | -xfs_attr_leaf_newentsize(args->namelen, args->valuelen, |
1111 | mp->m_sb.sb_blocksize, &tmp)); | ||
1005 | INT_SET(entry->nameidx, ARCH_CONVERT, | 1112 | INT_SET(entry->nameidx, ARCH_CONVERT, |
1006 | INT_GET(map->base, ARCH_CONVERT) | 1113 | INT_GET(map->base, ARCH_CONVERT) |
1007 | + INT_GET(map->size, ARCH_CONVERT)); | 1114 | + INT_GET(map->size, ARCH_CONVERT)); |
@@ -1357,8 +1464,10 @@ xfs_attr_leaf_figure_balance(xfs_da_state_t *state, | |||
1357 | half = (max+1) * sizeof(*entry); | 1464 | half = (max+1) * sizeof(*entry); |
1358 | half += INT_GET(hdr1->usedbytes, ARCH_CONVERT) | 1465 | half += INT_GET(hdr1->usedbytes, ARCH_CONVERT) |
1359 | + INT_GET(hdr2->usedbytes, ARCH_CONVERT) | 1466 | + INT_GET(hdr2->usedbytes, ARCH_CONVERT) |
1360 | + xfs_attr_leaf_newentsize(state->args, | 1467 | + xfs_attr_leaf_newentsize( |
1361 | state->blocksize, NULL); | 1468 | state->args->namelen, |
1469 | state->args->valuelen, | ||
1470 | state->blocksize, NULL); | ||
1362 | half /= 2; | 1471 | half /= 2; |
1363 | lastdelta = state->blocksize; | 1472 | lastdelta = state->blocksize; |
1364 | entry = &leaf1->entries[0]; | 1473 | entry = &leaf1->entries[0]; |
@@ -1370,9 +1479,10 @@ xfs_attr_leaf_figure_balance(xfs_da_state_t *state, | |||
1370 | */ | 1479 | */ |
1371 | if (count == blk1->index) { | 1480 | if (count == blk1->index) { |
1372 | tmp = totallen + sizeof(*entry) + | 1481 | tmp = totallen + sizeof(*entry) + |
1373 | xfs_attr_leaf_newentsize(state->args, | 1482 | xfs_attr_leaf_newentsize( |
1374 | state->blocksize, | 1483 | state->args->namelen, |
1375 | NULL); | 1484 | state->args->valuelen, |
1485 | state->blocksize, NULL); | ||
1376 | if (XFS_ATTR_ABS(half - tmp) > lastdelta) | 1486 | if (XFS_ATTR_ABS(half - tmp) > lastdelta) |
1377 | break; | 1487 | break; |
1378 | lastdelta = XFS_ATTR_ABS(half - tmp); | 1488 | lastdelta = XFS_ATTR_ABS(half - tmp); |
@@ -1408,9 +1518,10 @@ xfs_attr_leaf_figure_balance(xfs_da_state_t *state, | |||
1408 | totallen -= count * sizeof(*entry); | 1518 | totallen -= count * sizeof(*entry); |
1409 | if (foundit) { | 1519 | if (foundit) { |
1410 | totallen -= sizeof(*entry) + | 1520 | totallen -= sizeof(*entry) + |
1411 | xfs_attr_leaf_newentsize(state->args, | 1521 | xfs_attr_leaf_newentsize( |
1412 | state->blocksize, | 1522 | state->args->namelen, |
1413 | NULL); | 1523 | state->args->valuelen, |
1524 | state->blocksize, NULL); | ||
1414 | } | 1525 | } |
1415 | 1526 | ||
1416 | *countarg = count; | 1527 | *countarg = count; |
@@ -2253,17 +2364,17 @@ xfs_attr_leaf_entsize(xfs_attr_leafblock_t *leaf, int index) | |||
2253 | * a "local" or a "remote" attribute. | 2364 | * a "local" or a "remote" attribute. |
2254 | */ | 2365 | */ |
2255 | int | 2366 | int |
2256 | xfs_attr_leaf_newentsize(xfs_da_args_t *args, int blocksize, int *local) | 2367 | xfs_attr_leaf_newentsize(int namelen, int valuelen, int blocksize, int *local) |
2257 | { | 2368 | { |
2258 | int size; | 2369 | int size; |
2259 | 2370 | ||
2260 | size = XFS_ATTR_LEAF_ENTSIZE_LOCAL(args->namelen, args->valuelen); | 2371 | size = XFS_ATTR_LEAF_ENTSIZE_LOCAL(namelen, valuelen); |
2261 | if (size < XFS_ATTR_LEAF_ENTSIZE_LOCAL_MAX(blocksize)) { | 2372 | if (size < XFS_ATTR_LEAF_ENTSIZE_LOCAL_MAX(blocksize)) { |
2262 | if (local) { | 2373 | if (local) { |
2263 | *local = 1; | 2374 | *local = 1; |
2264 | } | 2375 | } |
2265 | } else { | 2376 | } else { |
2266 | size = XFS_ATTR_LEAF_ENTSIZE_REMOTE(args->namelen); | 2377 | size = XFS_ATTR_LEAF_ENTSIZE_REMOTE(namelen); |
2267 | if (local) { | 2378 | if (local) { |
2268 | *local = 0; | 2379 | *local = 0; |
2269 | } | 2380 | } |
diff --git a/fs/xfs/xfs_attr_leaf.h b/fs/xfs/xfs_attr_leaf.h index 0a4cfad6df91..f6143ff251a0 100644 --- a/fs/xfs/xfs_attr_leaf.h +++ b/fs/xfs/xfs_attr_leaf.h | |||
@@ -1,33 +1,19 @@ | |||
1 | /* | 1 | /* |
2 | * Copyright (c) 2000, 2002-2003 Silicon Graphics, Inc. All Rights Reserved. | 2 | * Copyright (c) 2000,2002-2003,2005 Silicon Graphics, Inc. |
3 | * All Rights Reserved. | ||
3 | * | 4 | * |
4 | * This program is free software; you can redistribute it and/or modify it | 5 | * This program is free software; you can redistribute it and/or |
5 | * under the terms of version 2 of the GNU General Public License as | 6 | * modify it under the terms of the GNU General Public License as |
6 | * published by the Free Software Foundation. | 7 | * published by the Free Software Foundation. |
7 | * | 8 | * |
8 | * This program is distributed in the hope that it would be useful, but | 9 | * This program is distributed in the hope that it would be useful, |
9 | * WITHOUT ANY WARRANTY; without even the implied warranty of | 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
12 | * GNU General Public License for more details. | ||
11 | * | 13 | * |
12 | * Further, this software is distributed without any warranty that it is | 14 | * You should have received a copy of the GNU General Public License |
13 | * free of the rightful claim of any third person regarding infringement | 15 | * along with this program; if not, write the Free Software Foundation, |
14 | * or the like. Any license provided herein, whether implied or | 16 | * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
15 | * otherwise, applies only to this software file. Patent licenses, if | ||
16 | * any, provided herein do not apply to combinations of this program with | ||
17 | * other software, or any other product whatsoever. | ||
18 | * | ||
19 | * You should have received a copy of the GNU General Public License along | ||
20 | * with this program; if not, write the Free Software Foundation, Inc., 59 | ||
21 | * Temple Place - Suite 330, Boston MA 02111-1307, USA. | ||
22 | * | ||
23 | * Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy, | ||
24 | * Mountain View, CA 94043, or: | ||
25 | * | ||
26 | * http://www.sgi.com | ||
27 | * | ||
28 | * For further information regarding this notice, see: | ||
29 | * | ||
30 | * http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/ | ||
31 | */ | 17 | */ |
32 | #ifndef __XFS_ATTR_LEAF_H__ | 18 | #ifndef __XFS_ATTR_LEAF_H__ |
33 | #define __XFS_ATTR_LEAF_H__ | 19 | #define __XFS_ATTR_LEAF_H__ |
@@ -146,65 +132,58 @@ typedef struct xfs_attr_leaf_name_remote xfs_attr_leaf_name_remote_t; | |||
146 | /* | 132 | /* |
147 | * Cast typed pointers for "local" and "remote" name/value structs. | 133 | * Cast typed pointers for "local" and "remote" name/value structs. |
148 | */ | 134 | */ |
149 | #if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_ATTR_LEAF_NAME_REMOTE) | ||
150 | xfs_attr_leaf_name_remote_t * | ||
151 | xfs_attr_leaf_name_remote(xfs_attr_leafblock_t *leafp, int idx); | ||
152 | #define XFS_ATTR_LEAF_NAME_REMOTE(leafp,idx) \ | 135 | #define XFS_ATTR_LEAF_NAME_REMOTE(leafp,idx) \ |
153 | xfs_attr_leaf_name_remote(leafp,idx) | 136 | xfs_attr_leaf_name_remote(leafp,idx) |
154 | #else | 137 | static inline xfs_attr_leaf_name_remote_t * |
155 | #define XFS_ATTR_LEAF_NAME_REMOTE(leafp,idx) /* remote name struct ptr */ \ | 138 | xfs_attr_leaf_name_remote(xfs_attr_leafblock_t *leafp, int idx) |
156 | ((xfs_attr_leaf_name_remote_t *) \ | 139 | { |
157 | &((char *)(leafp))[ INT_GET((leafp)->entries[idx].nameidx, ARCH_CONVERT) ]) | 140 | return (xfs_attr_leaf_name_remote_t *) &((char *) |
158 | #endif | 141 | (leafp))[INT_GET((leafp)->entries[idx].nameidx, ARCH_CONVERT)]; |
159 | #if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_ATTR_LEAF_NAME_LOCAL) | 142 | } |
160 | xfs_attr_leaf_name_local_t * | 143 | |
161 | xfs_attr_leaf_name_local(xfs_attr_leafblock_t *leafp, int idx); | ||
162 | #define XFS_ATTR_LEAF_NAME_LOCAL(leafp,idx) \ | 144 | #define XFS_ATTR_LEAF_NAME_LOCAL(leafp,idx) \ |
163 | xfs_attr_leaf_name_local(leafp,idx) | 145 | xfs_attr_leaf_name_local(leafp,idx) |
164 | #else | 146 | static inline xfs_attr_leaf_name_local_t * |
165 | #define XFS_ATTR_LEAF_NAME_LOCAL(leafp,idx) /* local name struct ptr */ \ | 147 | xfs_attr_leaf_name_local(xfs_attr_leafblock_t *leafp, int idx) |
166 | ((xfs_attr_leaf_name_local_t *) \ | 148 | { |
167 | &((char *)(leafp))[ INT_GET((leafp)->entries[idx].nameidx, ARCH_CONVERT) ]) | 149 | return (xfs_attr_leaf_name_local_t *) &((char *) |
168 | #endif | 150 | (leafp))[INT_GET((leafp)->entries[idx].nameidx, ARCH_CONVERT)]; |
169 | #if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_ATTR_LEAF_NAME) | 151 | } |
170 | char *xfs_attr_leaf_name(xfs_attr_leafblock_t *leafp, int idx); | 152 | |
171 | #define XFS_ATTR_LEAF_NAME(leafp,idx) xfs_attr_leaf_name(leafp,idx) | 153 | #define XFS_ATTR_LEAF_NAME(leafp,idx) xfs_attr_leaf_name(leafp,idx) |
172 | #else | 154 | static inline char *xfs_attr_leaf_name(xfs_attr_leafblock_t *leafp, int idx) |
173 | #define XFS_ATTR_LEAF_NAME(leafp,idx) /* generic name struct ptr */ \ | 155 | { |
174 | (&((char *)(leafp))[ INT_GET((leafp)->entries[idx].nameidx, ARCH_CONVERT) ]) | 156 | return (&((char *) |
175 | #endif | 157 | (leafp))[INT_GET((leafp)->entries[idx].nameidx, ARCH_CONVERT)]); |
158 | } | ||
176 | 159 | ||
177 | /* | 160 | /* |
178 | * Calculate total bytes used (including trailing pad for alignment) for | 161 | * Calculate total bytes used (including trailing pad for alignment) for |
179 | * a "local" name/value structure, a "remote" name/value structure, and | 162 | * a "local" name/value structure, a "remote" name/value structure, and |
180 | * a pointer which might be either. | 163 | * a pointer which might be either. |
181 | */ | 164 | */ |
182 | #if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_ATTR_LEAF_ENTSIZE_REMOTE) | ||
183 | int xfs_attr_leaf_entsize_remote(int nlen); | ||
184 | #define XFS_ATTR_LEAF_ENTSIZE_REMOTE(nlen) \ | 165 | #define XFS_ATTR_LEAF_ENTSIZE_REMOTE(nlen) \ |
185 | xfs_attr_leaf_entsize_remote(nlen) | 166 | xfs_attr_leaf_entsize_remote(nlen) |
186 | #else | 167 | static inline int xfs_attr_leaf_entsize_remote(int nlen) |
187 | #define XFS_ATTR_LEAF_ENTSIZE_REMOTE(nlen) /* space for remote struct */ \ | 168 | { |
188 | (((uint)sizeof(xfs_attr_leaf_name_remote_t) - 1 + (nlen) + \ | 169 | return ((uint)sizeof(xfs_attr_leaf_name_remote_t) - 1 + (nlen) + \ |
189 | XFS_ATTR_LEAF_NAME_ALIGN - 1) & ~(XFS_ATTR_LEAF_NAME_ALIGN - 1)) | 170 | XFS_ATTR_LEAF_NAME_ALIGN - 1) & ~(XFS_ATTR_LEAF_NAME_ALIGN - 1); |
190 | #endif | 171 | } |
191 | #if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_ATTR_LEAF_ENTSIZE_LOCAL) | 172 | |
192 | int xfs_attr_leaf_entsize_local(int nlen, int vlen); | ||
193 | #define XFS_ATTR_LEAF_ENTSIZE_LOCAL(nlen,vlen) \ | 173 | #define XFS_ATTR_LEAF_ENTSIZE_LOCAL(nlen,vlen) \ |
194 | xfs_attr_leaf_entsize_local(nlen,vlen) | 174 | xfs_attr_leaf_entsize_local(nlen,vlen) |
195 | #else | 175 | static inline int xfs_attr_leaf_entsize_local(int nlen, int vlen) |
196 | #define XFS_ATTR_LEAF_ENTSIZE_LOCAL(nlen,vlen) /* space for local struct */ \ | 176 | { |
197 | (((uint)sizeof(xfs_attr_leaf_name_local_t) - 1 + (nlen) + (vlen) + \ | 177 | return ((uint)sizeof(xfs_attr_leaf_name_local_t) - 1 + (nlen) + (vlen) + |
198 | XFS_ATTR_LEAF_NAME_ALIGN - 1) & ~(XFS_ATTR_LEAF_NAME_ALIGN - 1)) | 178 | XFS_ATTR_LEAF_NAME_ALIGN - 1) & ~(XFS_ATTR_LEAF_NAME_ALIGN - 1); |
199 | #endif | 179 | } |
200 | #if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_ATTR_LEAF_ENTSIZE_LOCAL_MAX) | 180 | |
201 | int xfs_attr_leaf_entsize_local_max(int bsize); | ||
202 | #define XFS_ATTR_LEAF_ENTSIZE_LOCAL_MAX(bsize) \ | 181 | #define XFS_ATTR_LEAF_ENTSIZE_LOCAL_MAX(bsize) \ |
203 | xfs_attr_leaf_entsize_local_max(bsize) | 182 | xfs_attr_leaf_entsize_local_max(bsize) |
204 | #else | 183 | static inline int xfs_attr_leaf_entsize_local_max(int bsize) |
205 | #define XFS_ATTR_LEAF_ENTSIZE_LOCAL_MAX(bsize) /* max local struct size */ \ | 184 | { |
206 | (((bsize) >> 1) + ((bsize) >> 2)) | 185 | return (((bsize) >> 1) + ((bsize) >> 2)); |
207 | #endif | 186 | } |
208 | 187 | ||
209 | 188 | ||
210 | /*======================================================================== | 189 | /*======================================================================== |
@@ -237,23 +216,25 @@ typedef struct xfs_attr_inactive_list { | |||
237 | *========================================================================*/ | 216 | *========================================================================*/ |
238 | 217 | ||
239 | /* | 218 | /* |
240 | * Internal routines when dirsize < XFS_LITINO(mp). | 219 | * Internal routines when attribute fork size < XFS_LITINO(mp). |
241 | */ | 220 | */ |
242 | int xfs_attr_shortform_create(struct xfs_da_args *args); | 221 | void xfs_attr_shortform_create(struct xfs_da_args *args); |
243 | int xfs_attr_shortform_add(struct xfs_da_args *add); | 222 | void xfs_attr_shortform_add(struct xfs_da_args *args, int forkoff); |
244 | int xfs_attr_shortform_lookup(struct xfs_da_args *args); | 223 | int xfs_attr_shortform_lookup(struct xfs_da_args *args); |
245 | int xfs_attr_shortform_getvalue(struct xfs_da_args *args); | 224 | int xfs_attr_shortform_getvalue(struct xfs_da_args *args); |
246 | int xfs_attr_shortform_to_leaf(struct xfs_da_args *args); | 225 | int xfs_attr_shortform_to_leaf(struct xfs_da_args *args); |
247 | int xfs_attr_shortform_remove(struct xfs_da_args *remove); | 226 | int xfs_attr_shortform_remove(struct xfs_da_args *args); |
248 | int xfs_attr_shortform_list(struct xfs_attr_list_context *context); | 227 | int xfs_attr_shortform_list(struct xfs_attr_list_context *context); |
249 | int xfs_attr_shortform_allfit(struct xfs_dabuf *bp, struct xfs_inode *dp); | 228 | int xfs_attr_shortform_allfit(struct xfs_dabuf *bp, struct xfs_inode *dp); |
229 | int xfs_attr_shortform_bytesfit(xfs_inode_t *dp, int bytes); | ||
230 | |||
250 | 231 | ||
251 | /* | 232 | /* |
252 | * Internal routines when dirsize == XFS_LBSIZE(mp). | 233 | * Internal routines when attribute fork size == XFS_LBSIZE(mp). |
253 | */ | 234 | */ |
254 | int xfs_attr_leaf_to_node(struct xfs_da_args *args); | 235 | int xfs_attr_leaf_to_node(struct xfs_da_args *args); |
255 | int xfs_attr_leaf_to_shortform(struct xfs_dabuf *bp, | 236 | int xfs_attr_leaf_to_shortform(struct xfs_dabuf *bp, |
256 | struct xfs_da_args *args); | 237 | struct xfs_da_args *args, int forkoff); |
257 | int xfs_attr_leaf_clearflag(struct xfs_da_args *args); | 238 | int xfs_attr_leaf_clearflag(struct xfs_da_args *args); |
258 | int xfs_attr_leaf_setflag(struct xfs_da_args *args); | 239 | int xfs_attr_leaf_setflag(struct xfs_da_args *args); |
259 | int xfs_attr_leaf_flipflags(xfs_da_args_t *args); | 240 | int xfs_attr_leaf_flipflags(xfs_da_args_t *args); |
@@ -289,7 +270,7 @@ int xfs_attr_root_inactive(struct xfs_trans **trans, struct xfs_inode *dp); | |||
289 | xfs_dahash_t xfs_attr_leaf_lasthash(struct xfs_dabuf *bp, int *count); | 270 | xfs_dahash_t xfs_attr_leaf_lasthash(struct xfs_dabuf *bp, int *count); |
290 | int xfs_attr_leaf_order(struct xfs_dabuf *leaf1_bp, | 271 | int xfs_attr_leaf_order(struct xfs_dabuf *leaf1_bp, |
291 | struct xfs_dabuf *leaf2_bp); | 272 | struct xfs_dabuf *leaf2_bp); |
292 | int xfs_attr_leaf_newentsize(struct xfs_da_args *args, int blocksize, | 273 | int xfs_attr_leaf_newentsize(int namelen, int valuelen, int blocksize, |
293 | int *local); | 274 | int *local); |
294 | int xfs_attr_rolltrans(struct xfs_trans **transp, struct xfs_inode *dp); | 275 | int xfs_attr_rolltrans(struct xfs_trans **transp, struct xfs_inode *dp); |
295 | 276 | ||
diff --git a/fs/xfs/xfs_attr_sf.h b/fs/xfs/xfs_attr_sf.h index ef7d2942d306..ffed6ca81a52 100644 --- a/fs/xfs/xfs_attr_sf.h +++ b/fs/xfs/xfs_attr_sf.h | |||
@@ -1,33 +1,19 @@ | |||
1 | /* | 1 | /* |
2 | * Copyright (c) 2000, 2002 Silicon Graphics, Inc. All Rights Reserved. | 2 | * Copyright (c) 2000,2002,2005 Silicon Graphics, Inc. |
3 | * All Rights Reserved. | ||
3 | * | 4 | * |
4 | * This program is free software; you can redistribute it and/or modify it | 5 | * This program is free software; you can redistribute it and/or |
5 | * under the terms of version 2 of the GNU General Public License as | 6 | * modify it under the terms of the GNU General Public License as |
6 | * published by the Free Software Foundation. | 7 | * published by the Free Software Foundation. |
7 | * | 8 | * |
8 | * This program is distributed in the hope that it would be useful, but | 9 | * This program is distributed in the hope that it would be useful, |
9 | * WITHOUT ANY WARRANTY; without even the implied warranty of | 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
12 | * GNU General Public License for more details. | ||
11 | * | 13 | * |
12 | * Further, this software is distributed without any warranty that it is | 14 | * You should have received a copy of the GNU General Public License |
13 | * free of the rightful claim of any third person regarding infringement | 15 | * along with this program; if not, write the Free Software Foundation, |
14 | * or the like. Any license provided herein, whether implied or | 16 | * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
15 | * otherwise, applies only to this software file. Patent licenses, if | ||
16 | * any, provided herein do not apply to combinations of this program with | ||
17 | * other software, or any other product whatsoever. | ||
18 | * | ||
19 | * You should have received a copy of the GNU General Public License along | ||
20 | * with this program; if not, write the Free Software Foundation, Inc., 59 | ||
21 | * Temple Place - Suite 330, Boston MA 02111-1307, USA. | ||
22 | * | ||
23 | * Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy, | ||
24 | * Mountain View, CA 94043, or: | ||
25 | * | ||
26 | * http://www.sgi.com | ||
27 | * | ||
28 | * For further information regarding this notice, see: | ||
29 | * | ||
30 | * http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/ | ||
31 | */ | 17 | */ |
32 | #ifndef __XFS_ATTR_SF_H__ | 18 | #ifndef __XFS_ATTR_SF_H__ |
33 | #define __XFS_ATTR_SF_H__ | 19 | #define __XFS_ATTR_SF_H__ |
@@ -71,38 +57,17 @@ typedef struct xfs_attr_sf_sort { | |||
71 | char *name; /* name value, pointer into buffer */ | 57 | char *name; /* name value, pointer into buffer */ |
72 | } xfs_attr_sf_sort_t; | 58 | } xfs_attr_sf_sort_t; |
73 | 59 | ||
74 | #if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_ATTR_SF_ENTSIZE_BYNAME) | ||
75 | int xfs_attr_sf_entsize_byname(int nlen, int vlen); | ||
76 | #define XFS_ATTR_SF_ENTSIZE_BYNAME(nlen,vlen) \ | ||
77 | xfs_attr_sf_entsize_byname(nlen,vlen) | ||
78 | #else | ||
79 | #define XFS_ATTR_SF_ENTSIZE_BYNAME(nlen,vlen) /* space name/value uses */ \ | 60 | #define XFS_ATTR_SF_ENTSIZE_BYNAME(nlen,vlen) /* space name/value uses */ \ |
80 | ((int)sizeof(xfs_attr_sf_entry_t)-1 + (nlen)+(vlen)) | 61 | (((int)sizeof(xfs_attr_sf_entry_t)-1 + (nlen)+(vlen))) |
81 | #endif | ||
82 | #define XFS_ATTR_SF_ENTSIZE_MAX /* max space for name&value */ \ | 62 | #define XFS_ATTR_SF_ENTSIZE_MAX /* max space for name&value */ \ |
83 | ((1 << (NBBY*(int)sizeof(__uint8_t))) - 1) | 63 | ((1 << (NBBY*(int)sizeof(__uint8_t))) - 1) |
84 | #if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_ATTR_SF_ENTSIZE) | ||
85 | int xfs_attr_sf_entsize(xfs_attr_sf_entry_t *sfep); | ||
86 | #define XFS_ATTR_SF_ENTSIZE(sfep) xfs_attr_sf_entsize(sfep) | ||
87 | #else | ||
88 | #define XFS_ATTR_SF_ENTSIZE(sfep) /* space an entry uses */ \ | 64 | #define XFS_ATTR_SF_ENTSIZE(sfep) /* space an entry uses */ \ |
89 | ((int)sizeof(xfs_attr_sf_entry_t)-1 + (sfep)->namelen+(sfep)->valuelen) | 65 | ((int)sizeof(xfs_attr_sf_entry_t)-1 + (sfep)->namelen+(sfep)->valuelen) |
90 | #endif | ||
91 | #if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_ATTR_SF_NEXTENTRY) | ||
92 | xfs_attr_sf_entry_t *xfs_attr_sf_nextentry(xfs_attr_sf_entry_t *sfep); | ||
93 | #define XFS_ATTR_SF_NEXTENTRY(sfep) xfs_attr_sf_nextentry(sfep) | ||
94 | #else | ||
95 | #define XFS_ATTR_SF_NEXTENTRY(sfep) /* next entry in struct */ \ | 66 | #define XFS_ATTR_SF_NEXTENTRY(sfep) /* next entry in struct */ \ |
96 | ((xfs_attr_sf_entry_t *) \ | 67 | ((xfs_attr_sf_entry_t *)((char *)(sfep) + XFS_ATTR_SF_ENTSIZE(sfep))) |
97 | ((char *)(sfep) + XFS_ATTR_SF_ENTSIZE(sfep))) | ||
98 | #endif | ||
99 | #if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_ATTR_SF_TOTSIZE) | ||
100 | int xfs_attr_sf_totsize(struct xfs_inode *dp); | ||
101 | #define XFS_ATTR_SF_TOTSIZE(dp) xfs_attr_sf_totsize(dp) | ||
102 | #else | ||
103 | #define XFS_ATTR_SF_TOTSIZE(dp) /* total space in use */ \ | 68 | #define XFS_ATTR_SF_TOTSIZE(dp) /* total space in use */ \ |
104 | (INT_GET(((xfs_attr_shortform_t *)((dp)->i_afp->if_u1.if_data))->hdr.totsize, ARCH_CONVERT)) | 69 | (INT_GET(((xfs_attr_shortform_t *) \ |
105 | #endif | 70 | ((dp)->i_afp->if_u1.if_data))->hdr.totsize, ARCH_CONVERT)) |
106 | 71 | ||
107 | #if defined(XFS_ATTR_TRACE) | 72 | #if defined(XFS_ATTR_TRACE) |
108 | /* | 73 | /* |
diff --git a/fs/xfs/xfs_behavior.c b/fs/xfs/xfs_behavior.c index 16088e175ecc..9880adae3938 100644 --- a/fs/xfs/xfs_behavior.c +++ b/fs/xfs/xfs_behavior.c | |||
@@ -1,34 +1,19 @@ | |||
1 | /* | 1 | /* |
2 | * Copyright (c) 2000-2003 Silicon Graphics, Inc. All Rights Reserved. | 2 | * Copyright (c) 2000-2003,2005 Silicon Graphics, Inc. |
3 | * All Rights Reserved. | ||
3 | * | 4 | * |
4 | * This program is free software; you can redistribute it and/or modify it | 5 | * This program is free software; you can redistribute it and/or |
5 | * under the terms of version 2 of the GNU General Public License as | 6 | * modify it under the terms of the GNU General Public License as |
6 | * published by the Free Software Foundation. | 7 | * published by the Free Software Foundation. |
7 | * | 8 | * |
8 | * This program is distributed in the hope that it would be useful, but | 9 | * This program is distributed in the hope that it would be useful, |
9 | * WITHOUT ANY WARRANTY; without even the implied warranty of | 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
11 | * | 12 | * GNU General Public License for more details. |
12 | * Further, this software is distributed without any warranty that it is | ||
13 | * free of the rightful claim of any third person regarding infringement | ||
14 | * or the like. Any license provided herein, whether implied or | ||
15 | * otherwise, applies only to this software file. Patent licenses, if | ||
16 | * any, provided herein do not apply to combinations of this program with | ||
17 | * other software, or any other product whatsoever. | ||
18 | * | ||
19 | * You should have received a copy of the GNU General Public License along | ||
20 | * with this program; if not, write the Free Software Foundation, Inc., 59 | ||
21 | * Temple Place - Suite 330, Boston MA 02111-1307, USA. | ||
22 | * | ||
23 | * Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy, | ||
24 | * Mountain View, CA 94043, or: | ||
25 | * | ||
26 | * http://www.sgi.com | ||
27 | * | ||
28 | * For further information regarding this notice, see: | ||
29 | * | ||
30 | * http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/ | ||
31 | * | 13 | * |
14 | * You should have received a copy of the GNU General Public License | ||
15 | * along with this program; if not, write the Free Software Foundation, | ||
16 | * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA | ||
32 | */ | 17 | */ |
33 | #include "xfs.h" | 18 | #include "xfs.h" |
34 | 19 | ||
diff --git a/fs/xfs/xfs_behavior.h b/fs/xfs/xfs_behavior.h index d5ed5a843921..2cd89bb5ab10 100644 --- a/fs/xfs/xfs_behavior.h +++ b/fs/xfs/xfs_behavior.h | |||
@@ -1,33 +1,19 @@ | |||
1 | /* | 1 | /* |
2 | * Copyright (c) 2000-2003 Silicon Graphics, Inc. All Rights Reserved. | 2 | * Copyright (c) 2000-2003,2005 Silicon Graphics, Inc. |
3 | * All Rights Reserved. | ||
3 | * | 4 | * |
4 | * This program is free software; you can redistribute it and/or modify it | 5 | * This program is free software; you can redistribute it and/or |
5 | * under the terms of version 2 of the GNU General Public License as | 6 | * modify it under the terms of the GNU General Public License as |
6 | * published by the Free Software Foundation. | 7 | * published by the Free Software Foundation. |
7 | * | 8 | * |
8 | * This program is distributed in the hope that it would be useful, but | 9 | * This program is distributed in the hope that it would be useful, |
9 | * WITHOUT ANY WARRANTY; without even the implied warranty of | 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
12 | * GNU General Public License for more details. | ||
11 | * | 13 | * |
12 | * Further, this software is distributed without any warranty that it is | 14 | * You should have received a copy of the GNU General Public License |
13 | * free of the rightful claim of any third person regarding infringement | 15 | * along with this program; if not, write the Free Software Foundation, |
14 | * or the like. Any license provided herein, whether implied or | 16 | * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
15 | * otherwise, applies only to this software file. Patent licenses, if | ||
16 | * any, provided herein do not apply to combinations of this program with | ||
17 | * other software, or any other product whatsoever. | ||
18 | * | ||
19 | * You should have received a copy of the GNU General Public License along | ||
20 | * with this program; if not, write the Free Software Foundation, Inc., 59 | ||
21 | * Temple Place - Suite 330, Boston MA 02111-1307, USA. | ||
22 | * | ||
23 | * Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy, | ||
24 | * Mountain View, CA 94043, or: | ||
25 | * | ||
26 | * http://www.sgi.com | ||
27 | * | ||
28 | * For further information regarding this notice, see: | ||
29 | * | ||
30 | * http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/ | ||
31 | */ | 17 | */ |
32 | #ifndef __XFS_BEHAVIOR_H__ | 18 | #ifndef __XFS_BEHAVIOR_H__ |
33 | #define __XFS_BEHAVIOR_H__ | 19 | #define __XFS_BEHAVIOR_H__ |
diff --git a/fs/xfs/xfs_bit.c b/fs/xfs/xfs_bit.c index 76c9ad3875ef..43be6a7e47c6 100644 --- a/fs/xfs/xfs_bit.c +++ b/fs/xfs/xfs_bit.c | |||
@@ -1,45 +1,29 @@ | |||
1 | /* | 1 | /* |
2 | * Copyright (c) 2000-2004 Silicon Graphics, Inc. All Rights Reserved. | 2 | * Copyright (c) 2000-2005 Silicon Graphics, Inc. |
3 | * All Rights Reserved. | ||
3 | * | 4 | * |
4 | * This program is free software; you can redistribute it and/or modify it | 5 | * This program is free software; you can redistribute it and/or |
5 | * under the terms of version 2 of the GNU General Public License as | 6 | * modify it under the terms of the GNU General Public License as |
6 | * published by the Free Software Foundation. | 7 | * published by the Free Software Foundation. |
7 | * | 8 | * |
8 | * This program is distributed in the hope that it would be useful, but | 9 | * This program is distributed in the hope that it would be useful, |
9 | * WITHOUT ANY WARRANTY; without even the implied warranty of | 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
12 | * GNU General Public License for more details. | ||
11 | * | 13 | * |
12 | * Further, this software is distributed without any warranty that it is | 14 | * You should have received a copy of the GNU General Public License |
13 | * free of the rightful claim of any third person regarding infringement | 15 | * along with this program; if not, write the Free Software Foundation, |
14 | * or the like. Any license provided herein, whether implied or | 16 | * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
15 | * otherwise, applies only to this software file. Patent licenses, if | ||
16 | * any, provided herein do not apply to combinations of this program with | ||
17 | * other software, or any other product whatsoever. | ||
18 | * | ||
19 | * You should have received a copy of the GNU General Public License along | ||
20 | * with this program; if not, write the Free Software Foundation, Inc., 59 | ||
21 | * Temple Place - Suite 330, Boston MA 02111-1307, USA. | ||
22 | * | ||
23 | * Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy, | ||
24 | * Mountain View, CA 94043, or: | ||
25 | * | ||
26 | * http://www.sgi.com | ||
27 | * | ||
28 | * For further information regarding this notice, see: | ||
29 | * | ||
30 | * http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/ | ||
31 | */ | 17 | */ |
32 | |||
33 | /* | ||
34 | * XFS bit manipulation routines, used in non-realtime code. | ||
35 | */ | ||
36 | |||
37 | #include "xfs.h" | 18 | #include "xfs.h" |
38 | #include "xfs_bit.h" | 19 | #include "xfs_bit.h" |
39 | #include "xfs_log.h" | 20 | #include "xfs_log.h" |
40 | #include "xfs_trans.h" | 21 | #include "xfs_trans.h" |
41 | #include "xfs_buf_item.h" | 22 | #include "xfs_buf_item.h" |
42 | 23 | ||
24 | /* | ||
25 | * XFS bit manipulation routines, used in non-realtime code. | ||
26 | */ | ||
43 | 27 | ||
44 | #ifndef HAVE_ARCH_HIGHBIT | 28 | #ifndef HAVE_ARCH_HIGHBIT |
45 | /* | 29 | /* |
diff --git a/fs/xfs/xfs_bit.h b/fs/xfs/xfs_bit.h index 1e7f57ddf7a8..0bbe56817542 100644 --- a/fs/xfs/xfs_bit.h +++ b/fs/xfs/xfs_bit.h | |||
@@ -1,33 +1,19 @@ | |||
1 | /* | 1 | /* |
2 | * Copyright (c) 2000, 2002 Silicon Graphics, Inc. All Rights Reserved. | 2 | * Copyright (c) 2000,2002,2005 Silicon Graphics, Inc. |
3 | * All Rights Reserved. | ||
3 | * | 4 | * |
4 | * This program is free software; you can redistribute it and/or modify it | 5 | * This program is free software; you can redistribute it and/or |
5 | * under the terms of version 2 of the GNU General Public License as | 6 | * modify it under the terms of the GNU General Public License as |
6 | * published by the Free Software Foundation. | 7 | * published by the Free Software Foundation. |
7 | * | 8 | * |
8 | * This program is distributed in the hope that it would be useful, but | 9 | * This program is distributed in the hope that it would be useful, |
9 | * WITHOUT ANY WARRANTY; without even the implied warranty of | 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
12 | * GNU General Public License for more details. | ||
11 | * | 13 | * |
12 | * Further, this software is distributed without any warranty that it is | 14 | * You should have received a copy of the GNU General Public License |
13 | * free of the rightful claim of any third person regarding infringement | 15 | * along with this program; if not, write the Free Software Foundation, |
14 | * or the like. Any license provided herein, whether implied or | 16 | * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
15 | * otherwise, applies only to this software file. Patent licenses, if | ||
16 | * any, provided herein do not apply to combinations of this program with | ||
17 | * other software, or any other product whatsoever. | ||
18 | * | ||
19 | * You should have received a copy of the GNU General Public License along | ||
20 | * with this program; if not, write the Free Software Foundation, Inc., 59 | ||
21 | * Temple Place - Suite 330, Boston MA 02111-1307, USA. | ||
22 | * | ||
23 | * Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy, | ||
24 | * Mountain View, CA 94043, or: | ||
25 | * | ||
26 | * http://www.sgi.com | ||
27 | * | ||
28 | * For further information regarding this notice, see: | ||
29 | * | ||
30 | * http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/ | ||
31 | */ | 17 | */ |
32 | #ifndef __XFS_BIT_H__ | 18 | #ifndef __XFS_BIT_H__ |
33 | #define __XFS_BIT_H__ | 19 | #define __XFS_BIT_H__ |
@@ -39,30 +25,26 @@ | |||
39 | /* | 25 | /* |
40 | * masks with n high/low bits set, 32-bit values & 64-bit values | 26 | * masks with n high/low bits set, 32-bit values & 64-bit values |
41 | */ | 27 | */ |
42 | #if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_MASK32HI) | ||
43 | __uint32_t xfs_mask32hi(int n); | ||
44 | #define XFS_MASK32HI(n) xfs_mask32hi(n) | 28 | #define XFS_MASK32HI(n) xfs_mask32hi(n) |
45 | #else | 29 | static inline __uint32_t xfs_mask32hi(int n) |
46 | #define XFS_MASK32HI(n) ((__uint32_t)-1 << (32 - (n))) | 30 | { |
47 | #endif | 31 | return (__uint32_t)-1 << (32 - (n)); |
48 | #if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_MASK64HI) | 32 | } |
49 | __uint64_t xfs_mask64hi(int n); | ||
50 | #define XFS_MASK64HI(n) xfs_mask64hi(n) | 33 | #define XFS_MASK64HI(n) xfs_mask64hi(n) |
51 | #else | 34 | static inline __uint64_t xfs_mask64hi(int n) |
52 | #define XFS_MASK64HI(n) ((__uint64_t)-1 << (64 - (n))) | 35 | { |
53 | #endif | 36 | return (__uint64_t)-1 << (64 - (n)); |
54 | #if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_MASK32LO) | 37 | } |
55 | __uint32_t xfs_mask32lo(int n); | ||
56 | #define XFS_MASK32LO(n) xfs_mask32lo(n) | 38 | #define XFS_MASK32LO(n) xfs_mask32lo(n) |
57 | #else | 39 | static inline __uint32_t xfs_mask32lo(int n) |
58 | #define XFS_MASK32LO(n) (((__uint32_t)1 << (n)) - 1) | 40 | { |
59 | #endif | 41 | return ((__uint32_t)1 << (n)) - 1; |
60 | #if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_MASK64LO) | 42 | } |
61 | __uint64_t xfs_mask64lo(int n); | ||
62 | #define XFS_MASK64LO(n) xfs_mask64lo(n) | 43 | #define XFS_MASK64LO(n) xfs_mask64lo(n) |
63 | #else | 44 | static inline __uint64_t xfs_mask64lo(int n) |
64 | #define XFS_MASK64LO(n) (((__uint64_t)1 << (n)) - 1) | 45 | { |
65 | #endif | 46 | return ((__uint64_t)1 << (n)) - 1; |
47 | } | ||
66 | 48 | ||
67 | /* Get high bit set out of 32-bit argument, -1 if none set */ | 49 | /* Get high bit set out of 32-bit argument, -1 if none set */ |
68 | extern int xfs_highbit32(__uint32_t v); | 50 | extern int xfs_highbit32(__uint32_t v); |
diff --git a/fs/xfs/xfs_bmap.c b/fs/xfs/xfs_bmap.c index 3e76def1283d..e415a4698e9c 100644 --- a/fs/xfs/xfs_bmap.c +++ b/fs/xfs/xfs_bmap.c | |||
@@ -1,68 +1,53 @@ | |||
1 | /* | 1 | /* |
2 | * Copyright (c) 2000-2004 Silicon Graphics, Inc. All Rights Reserved. | 2 | * Copyright (c) 2000-2005 Silicon Graphics, Inc. |
3 | * All Rights Reserved. | ||
3 | * | 4 | * |
4 | * This program is free software; you can redistribute it and/or modify it | 5 | * This program is free software; you can redistribute it and/or |
5 | * under the terms of version 2 of the GNU General Public License as | 6 | * modify it under the terms of the GNU General Public License as |
6 | * published by the Free Software Foundation. | 7 | * published by the Free Software Foundation. |
7 | * | 8 | * |
8 | * This program is distributed in the hope that it would be useful, but | 9 | * This program is distributed in the hope that it would be useful, |
9 | * WITHOUT ANY WARRANTY; without even the implied warranty of | 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
12 | * GNU General Public License for more details. | ||
11 | * | 13 | * |
12 | * Further, this software is distributed without any warranty that it is | 14 | * You should have received a copy of the GNU General Public License |
13 | * free of the rightful claim of any third person regarding infringement | 15 | * along with this program; if not, write the Free Software Foundation, |
14 | * or the like. Any license provided herein, whether implied or | 16 | * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
15 | * otherwise, applies only to this software file. Patent licenses, if | ||
16 | * any, provided herein do not apply to combinations of this program with | ||
17 | * other software, or any other product whatsoever. | ||
18 | * | ||
19 | * You should have received a copy of the GNU General Public License along | ||
20 | * with this program; if not, write the Free Software Foundation, Inc., 59 | ||
21 | * Temple Place - Suite 330, Boston MA 02111-1307, USA. | ||
22 | * | ||
23 | * Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy, | ||
24 | * Mountain View, CA 94043, or: | ||
25 | * | ||
26 | * http://www.sgi.com | ||
27 | * | ||
28 | * For further information regarding this notice, see: | ||
29 | * | ||
30 | * http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/ | ||
31 | */ | 17 | */ |
32 | |||
33 | #include "xfs.h" | 18 | #include "xfs.h" |
34 | 19 | #include "xfs_fs.h" | |
35 | #include "xfs_macros.h" | ||
36 | #include "xfs_types.h" | 20 | #include "xfs_types.h" |
37 | #include "xfs_inum.h" | 21 | #include "xfs_bit.h" |
38 | #include "xfs_log.h" | 22 | #include "xfs_log.h" |
23 | #include "xfs_inum.h" | ||
39 | #include "xfs_trans.h" | 24 | #include "xfs_trans.h" |
40 | #include "xfs_sb.h" | 25 | #include "xfs_sb.h" |
41 | #include "xfs_ag.h" | 26 | #include "xfs_ag.h" |
42 | #include "xfs_dir.h" | 27 | #include "xfs_dir.h" |
43 | #include "xfs_dir2.h" | 28 | #include "xfs_dir2.h" |
44 | #include "xfs_dmapi.h" | 29 | #include "xfs_da_btree.h" |
45 | #include "xfs_mount.h" | ||
46 | #include "xfs_alloc_btree.h" | ||
47 | #include "xfs_bmap_btree.h" | 30 | #include "xfs_bmap_btree.h" |
31 | #include "xfs_alloc_btree.h" | ||
48 | #include "xfs_ialloc_btree.h" | 32 | #include "xfs_ialloc_btree.h" |
49 | #include "xfs_btree.h" | ||
50 | #include "xfs_ialloc.h" | ||
51 | #include "xfs_attr_sf.h" | ||
52 | #include "xfs_dir_sf.h" | 33 | #include "xfs_dir_sf.h" |
53 | #include "xfs_dir2_sf.h" | 34 | #include "xfs_dir2_sf.h" |
35 | #include "xfs_attr_sf.h" | ||
54 | #include "xfs_dinode.h" | 36 | #include "xfs_dinode.h" |
55 | #include "xfs_inode_item.h" | ||
56 | #include "xfs_inode.h" | 37 | #include "xfs_inode.h" |
38 | #include "xfs_btree.h" | ||
39 | #include "xfs_dmapi.h" | ||
40 | #include "xfs_mount.h" | ||
41 | #include "xfs_ialloc.h" | ||
57 | #include "xfs_itable.h" | 42 | #include "xfs_itable.h" |
43 | #include "xfs_inode_item.h" | ||
58 | #include "xfs_extfree_item.h" | 44 | #include "xfs_extfree_item.h" |
59 | #include "xfs_alloc.h" | 45 | #include "xfs_alloc.h" |
60 | #include "xfs_bmap.h" | 46 | #include "xfs_bmap.h" |
61 | #include "xfs_rtalloc.h" | 47 | #include "xfs_rtalloc.h" |
62 | #include "xfs_error.h" | 48 | #include "xfs_error.h" |
63 | #include "xfs_da_btree.h" | ||
64 | #include "xfs_dir_leaf.h" | 49 | #include "xfs_dir_leaf.h" |
65 | #include "xfs_bit.h" | 50 | #include "xfs_attr_leaf.h" |
66 | #include "xfs_rw.h" | 51 | #include "xfs_rw.h" |
67 | #include "xfs_quota.h" | 52 | #include "xfs_quota.h" |
68 | #include "xfs_trans_space.h" | 53 | #include "xfs_trans_space.h" |
@@ -438,6 +423,12 @@ xfs_bmap_count_leaves( | |||
438 | int numrecs, | 423 | int numrecs, |
439 | int *count); | 424 | int *count); |
440 | 425 | ||
426 | STATIC int | ||
427 | xfs_bmap_disk_count_leaves( | ||
428 | xfs_bmbt_rec_t *frp, | ||
429 | int numrecs, | ||
430 | int *count); | ||
431 | |||
441 | /* | 432 | /* |
442 | * Bmap internal routines. | 433 | * Bmap internal routines. |
443 | */ | 434 | */ |
@@ -2772,8 +2763,8 @@ xfs_bmap_btree_to_extents( | |||
2772 | ASSERT(ifp->if_flags & XFS_IFEXTENTS); | 2763 | ASSERT(ifp->if_flags & XFS_IFEXTENTS); |
2773 | ASSERT(XFS_IFORK_FORMAT(ip, whichfork) == XFS_DINODE_FMT_BTREE); | 2764 | ASSERT(XFS_IFORK_FORMAT(ip, whichfork) == XFS_DINODE_FMT_BTREE); |
2774 | rblock = ifp->if_broot; | 2765 | rblock = ifp->if_broot; |
2775 | ASSERT(INT_GET(rblock->bb_level, ARCH_CONVERT) == 1); | 2766 | ASSERT(be16_to_cpu(rblock->bb_level) == 1); |
2776 | ASSERT(INT_GET(rblock->bb_numrecs, ARCH_CONVERT) == 1); | 2767 | ASSERT(be16_to_cpu(rblock->bb_numrecs) == 1); |
2777 | ASSERT(XFS_BMAP_BROOT_MAXRECS(ifp->if_broot_bytes) == 1); | 2768 | ASSERT(XFS_BMAP_BROOT_MAXRECS(ifp->if_broot_bytes) == 1); |
2778 | mp = ip->i_mount; | 2769 | mp = ip->i_mount; |
2779 | pp = XFS_BMAP_BROOT_PTR_ADDR(rblock, 1, ifp->if_broot_bytes); | 2770 | pp = XFS_BMAP_BROOT_PTR_ADDR(rblock, 1, ifp->if_broot_bytes); |
@@ -3216,11 +3207,11 @@ xfs_bmap_extents_to_btree( | |||
3216 | * Fill in the root. | 3207 | * Fill in the root. |
3217 | */ | 3208 | */ |
3218 | block = ifp->if_broot; | 3209 | block = ifp->if_broot; |
3219 | INT_SET(block->bb_magic, ARCH_CONVERT, XFS_BMAP_MAGIC); | 3210 | block->bb_magic = cpu_to_be32(XFS_BMAP_MAGIC); |
3220 | INT_SET(block->bb_level, ARCH_CONVERT, 1); | 3211 | block->bb_level = cpu_to_be16(1); |
3221 | INT_SET(block->bb_numrecs, ARCH_CONVERT, 1); | 3212 | block->bb_numrecs = cpu_to_be16(1); |
3222 | INT_SET(block->bb_leftsib, ARCH_CONVERT, NULLDFSBNO); | 3213 | block->bb_leftsib = cpu_to_be64(NULLDFSBNO); |
3223 | INT_SET(block->bb_rightsib, ARCH_CONVERT, NULLDFSBNO); | 3214 | block->bb_rightsib = cpu_to_be64(NULLDFSBNO); |
3224 | /* | 3215 | /* |
3225 | * Need a cursor. Can't allocate until bb_level is filled in. | 3216 | * Need a cursor. Can't allocate until bb_level is filled in. |
3226 | */ | 3217 | */ |
@@ -3273,10 +3264,10 @@ xfs_bmap_extents_to_btree( | |||
3273 | * Fill in the child block. | 3264 | * Fill in the child block. |
3274 | */ | 3265 | */ |
3275 | ablock = XFS_BUF_TO_BMBT_BLOCK(abp); | 3266 | ablock = XFS_BUF_TO_BMBT_BLOCK(abp); |
3276 | INT_SET(ablock->bb_magic, ARCH_CONVERT, XFS_BMAP_MAGIC); | 3267 | ablock->bb_magic = cpu_to_be32(XFS_BMAP_MAGIC); |
3277 | ablock->bb_level = 0; | 3268 | ablock->bb_level = 0; |
3278 | INT_SET(ablock->bb_leftsib, ARCH_CONVERT, NULLDFSBNO); | 3269 | ablock->bb_leftsib = cpu_to_be64(NULLDFSBNO); |
3279 | INT_SET(ablock->bb_rightsib, ARCH_CONVERT, NULLDFSBNO); | 3270 | ablock->bb_rightsib = cpu_to_be64(NULLDFSBNO); |
3280 | arp = XFS_BMAP_REC_IADDR(ablock, 1, cur); | 3271 | arp = XFS_BMAP_REC_IADDR(ablock, 1, cur); |
3281 | nextents = ifp->if_bytes / (uint)sizeof(xfs_bmbt_rec_t); | 3272 | nextents = ifp->if_bytes / (uint)sizeof(xfs_bmbt_rec_t); |
3282 | for (ep = ifp->if_u1.if_extents, cnt = i = 0; i < nextents; i++, ep++) { | 3273 | for (ep = ifp->if_u1.if_extents, cnt = i = 0; i < nextents; i++, ep++) { |
@@ -3286,8 +3277,8 @@ xfs_bmap_extents_to_btree( | |||
3286 | arp++; cnt++; | 3277 | arp++; cnt++; |
3287 | } | 3278 | } |
3288 | } | 3279 | } |
3289 | INT_SET(ablock->bb_numrecs, ARCH_CONVERT, cnt); | 3280 | ASSERT(cnt == XFS_IFORK_NEXTENTS(ip, whichfork)); |
3290 | ASSERT(INT_GET(ablock->bb_numrecs, ARCH_CONVERT) == XFS_IFORK_NEXTENTS(ip, whichfork)); | 3281 | ablock->bb_numrecs = cpu_to_be16(cnt); |
3291 | /* | 3282 | /* |
3292 | * Fill in the root key and pointer. | 3283 | * Fill in the root key and pointer. |
3293 | */ | 3284 | */ |
@@ -3301,7 +3292,7 @@ xfs_bmap_extents_to_btree( | |||
3301 | * the root is at the right level. | 3292 | * the root is at the right level. |
3302 | */ | 3293 | */ |
3303 | xfs_bmbt_log_block(cur, abp, XFS_BB_ALL_BITS); | 3294 | xfs_bmbt_log_block(cur, abp, XFS_BB_ALL_BITS); |
3304 | xfs_bmbt_log_recs(cur, abp, 1, INT_GET(ablock->bb_numrecs, ARCH_CONVERT)); | 3295 | xfs_bmbt_log_recs(cur, abp, 1, be16_to_cpu(ablock->bb_numrecs)); |
3305 | ASSERT(*curp == NULL); | 3296 | ASSERT(*curp == NULL); |
3306 | *curp = cur; | 3297 | *curp = cur; |
3307 | *logflagsp = XFS_ILOG_CORE | XFS_ILOG_FBROOT(whichfork); | 3298 | *logflagsp = XFS_ILOG_CORE | XFS_ILOG_FBROOT(whichfork); |
@@ -3337,6 +3328,29 @@ xfs_bmap_insert_exlist( | |||
3337 | } | 3328 | } |
3338 | 3329 | ||
3339 | /* | 3330 | /* |
3331 | * Helper routine to reset inode di_forkoff field when switching | ||
3332 | * attribute fork from local to extent format - we reset it where | ||
3333 | * possible to make space available for inline data fork extents. | ||
3334 | */ | ||
3335 | STATIC void | ||
3336 | xfs_bmap_forkoff_reset( | ||
3337 | xfs_mount_t *mp, | ||
3338 | xfs_inode_t *ip, | ||
3339 | int whichfork) | ||
3340 | { | ||
3341 | if (whichfork == XFS_ATTR_FORK && | ||
3342 | (ip->i_d.di_format != XFS_DINODE_FMT_DEV) && | ||
3343 | (ip->i_d.di_format != XFS_DINODE_FMT_UUID) && | ||
3344 | ((mp->m_attroffset >> 3) > ip->i_d.di_forkoff)) { | ||
3345 | ip->i_d.di_forkoff = mp->m_attroffset >> 3; | ||
3346 | ip->i_df.if_ext_max = XFS_IFORK_DSIZE(ip) / | ||
3347 | (uint)sizeof(xfs_bmbt_rec_t); | ||
3348 | ip->i_afp->if_ext_max = XFS_IFORK_ASIZE(ip) / | ||
3349 | (uint)sizeof(xfs_bmbt_rec_t); | ||
3350 | } | ||
3351 | } | ||
3352 | |||
3353 | /* | ||
3340 | * Convert a local file to an extents file. | 3354 | * Convert a local file to an extents file. |
3341 | * This code is out of bounds for data forks of regular files, | 3355 | * This code is out of bounds for data forks of regular files, |
3342 | * since the file data needs to get logged so things will stay consistent. | 3356 | * since the file data needs to get logged so things will stay consistent. |
@@ -3403,6 +3417,7 @@ xfs_bmap_local_to_extents( | |||
3403 | memcpy((char *)XFS_BUF_PTR(bp), ifp->if_u1.if_data, | 3417 | memcpy((char *)XFS_BUF_PTR(bp), ifp->if_u1.if_data, |
3404 | ifp->if_bytes); | 3418 | ifp->if_bytes); |
3405 | xfs_trans_log_buf(tp, bp, 0, ifp->if_bytes - 1); | 3419 | xfs_trans_log_buf(tp, bp, 0, ifp->if_bytes - 1); |
3420 | xfs_bmap_forkoff_reset(args.mp, ip, whichfork); | ||
3406 | xfs_idata_realloc(ip, -ifp->if_bytes, whichfork); | 3421 | xfs_idata_realloc(ip, -ifp->if_bytes, whichfork); |
3407 | xfs_iext_realloc(ip, 1, whichfork); | 3422 | xfs_iext_realloc(ip, 1, whichfork); |
3408 | ep = ifp->if_u1.if_extents; | 3423 | ep = ifp->if_u1.if_extents; |
@@ -3413,8 +3428,10 @@ xfs_bmap_local_to_extents( | |||
3413 | XFS_TRANS_MOD_DQUOT_BYINO(args.mp, tp, ip, | 3428 | XFS_TRANS_MOD_DQUOT_BYINO(args.mp, tp, ip, |
3414 | XFS_TRANS_DQ_BCOUNT, 1L); | 3429 | XFS_TRANS_DQ_BCOUNT, 1L); |
3415 | flags |= XFS_ILOG_FEXT(whichfork); | 3430 | flags |= XFS_ILOG_FEXT(whichfork); |
3416 | } else | 3431 | } else { |
3417 | ASSERT(XFS_IFORK_NEXTENTS(ip, whichfork) == 0); | 3432 | ASSERT(XFS_IFORK_NEXTENTS(ip, whichfork) == 0); |
3433 | xfs_bmap_forkoff_reset(ip->i_mount, ip, whichfork); | ||
3434 | } | ||
3418 | ifp->if_flags &= ~XFS_IFINLINE; | 3435 | ifp->if_flags &= ~XFS_IFINLINE; |
3419 | ifp->if_flags |= XFS_IFEXTENTS; | 3436 | ifp->if_flags |= XFS_IFEXTENTS; |
3420 | XFS_IFORK_FMT_SET(ip, whichfork, XFS_DINODE_FMT_EXTENTS); | 3437 | XFS_IFORK_FMT_SET(ip, whichfork, XFS_DINODE_FMT_EXTENTS); |
@@ -3796,22 +3813,24 @@ xfs_bunmap_trace( | |||
3796 | int /* error code */ | 3813 | int /* error code */ |
3797 | xfs_bmap_add_attrfork( | 3814 | xfs_bmap_add_attrfork( |
3798 | xfs_inode_t *ip, /* incore inode pointer */ | 3815 | xfs_inode_t *ip, /* incore inode pointer */ |
3799 | int rsvd) /* OK to allocated reserved blocks in trans */ | 3816 | int size, /* space new attribute needs */ |
3817 | int rsvd) /* xact may use reserved blks */ | ||
3800 | { | 3818 | { |
3801 | int blks; /* space reservation */ | ||
3802 | int committed; /* xaction was committed */ | ||
3803 | int error; /* error return value */ | ||
3804 | xfs_fsblock_t firstblock; /* 1st block/ag allocated */ | 3819 | xfs_fsblock_t firstblock; /* 1st block/ag allocated */ |
3805 | xfs_bmap_free_t flist; /* freed extent list */ | 3820 | xfs_bmap_free_t flist; /* freed extent list */ |
3806 | int logflags; /* logging flags */ | ||
3807 | xfs_mount_t *mp; /* mount structure */ | 3821 | xfs_mount_t *mp; /* mount structure */ |
3808 | unsigned long s; /* spinlock spl value */ | ||
3809 | xfs_trans_t *tp; /* transaction pointer */ | 3822 | xfs_trans_t *tp; /* transaction pointer */ |
3823 | unsigned long s; /* spinlock spl value */ | ||
3824 | int blks; /* space reservation */ | ||
3825 | int version = 1; /* superblock attr version */ | ||
3826 | int committed; /* xaction was committed */ | ||
3827 | int logflags; /* logging flags */ | ||
3828 | int error; /* error return value */ | ||
3810 | 3829 | ||
3830 | ASSERT(XFS_IFORK_Q(ip) == 0); | ||
3811 | ASSERT(ip->i_df.if_ext_max == | 3831 | ASSERT(ip->i_df.if_ext_max == |
3812 | XFS_IFORK_DSIZE(ip) / (uint)sizeof(xfs_bmbt_rec_t)); | 3832 | XFS_IFORK_DSIZE(ip) / (uint)sizeof(xfs_bmbt_rec_t)); |
3813 | if (XFS_IFORK_Q(ip)) | 3833 | |
3814 | return 0; | ||
3815 | mp = ip->i_mount; | 3834 | mp = ip->i_mount; |
3816 | ASSERT(!XFS_NOT_DQATTACHED(mp, ip)); | 3835 | ASSERT(!XFS_NOT_DQATTACHED(mp, ip)); |
3817 | tp = xfs_trans_alloc(mp, XFS_TRANS_ADDAFORK); | 3836 | tp = xfs_trans_alloc(mp, XFS_TRANS_ADDAFORK); |
@@ -3853,7 +3872,11 @@ xfs_bmap_add_attrfork( | |||
3853 | case XFS_DINODE_FMT_LOCAL: | 3872 | case XFS_DINODE_FMT_LOCAL: |
3854 | case XFS_DINODE_FMT_EXTENTS: | 3873 | case XFS_DINODE_FMT_EXTENTS: |
3855 | case XFS_DINODE_FMT_BTREE: | 3874 | case XFS_DINODE_FMT_BTREE: |
3856 | ip->i_d.di_forkoff = mp->m_attroffset >> 3; | 3875 | ip->i_d.di_forkoff = xfs_attr_shortform_bytesfit(ip, size); |
3876 | if (!ip->i_d.di_forkoff) | ||
3877 | ip->i_d.di_forkoff = mp->m_attroffset >> 3; | ||
3878 | else if (!(mp->m_flags & XFS_MOUNT_COMPAT_ATTR)) | ||
3879 | version = 2; | ||
3857 | break; | 3880 | break; |
3858 | default: | 3881 | default: |
3859 | ASSERT(0); | 3882 | ASSERT(0); |
@@ -3890,12 +3913,22 @@ xfs_bmap_add_attrfork( | |||
3890 | xfs_trans_log_inode(tp, ip, logflags); | 3913 | xfs_trans_log_inode(tp, ip, logflags); |
3891 | if (error) | 3914 | if (error) |
3892 | goto error2; | 3915 | goto error2; |
3893 | if (!XFS_SB_VERSION_HASATTR(&mp->m_sb)) { | 3916 | if (!XFS_SB_VERSION_HASATTR(&mp->m_sb) || |
3917 | (!XFS_SB_VERSION_HASATTR2(&mp->m_sb) && version == 2)) { | ||
3918 | __int64_t sbfields = 0; | ||
3919 | |||
3894 | s = XFS_SB_LOCK(mp); | 3920 | s = XFS_SB_LOCK(mp); |
3895 | if (!XFS_SB_VERSION_HASATTR(&mp->m_sb)) { | 3921 | if (!XFS_SB_VERSION_HASATTR(&mp->m_sb)) { |
3896 | XFS_SB_VERSION_ADDATTR(&mp->m_sb); | 3922 | XFS_SB_VERSION_ADDATTR(&mp->m_sb); |
3923 | sbfields |= XFS_SB_VERSIONNUM; | ||
3924 | } | ||
3925 | if (!XFS_SB_VERSION_HASATTR2(&mp->m_sb) && version == 2) { | ||
3926 | XFS_SB_VERSION_ADDATTR2(&mp->m_sb); | ||
3927 | sbfields |= (XFS_SB_VERSIONNUM | XFS_SB_FEATURES2); | ||
3928 | } | ||
3929 | if (sbfields) { | ||
3897 | XFS_SB_UNLOCK(mp, s); | 3930 | XFS_SB_UNLOCK(mp, s); |
3898 | xfs_mod_sb(tp, XFS_SB_VERSIONNUM); | 3931 | xfs_mod_sb(tp, sbfields); |
3899 | } else | 3932 | } else |
3900 | XFS_SB_UNLOCK(mp, s); | 3933 | XFS_SB_UNLOCK(mp, s); |
3901 | } | 3934 | } |
@@ -3988,13 +4021,19 @@ xfs_bmap_compute_maxlevels( | |||
3988 | * (a signed 32-bit number, xfs_extnum_t), or by di_anextents | 4021 | * (a signed 32-bit number, xfs_extnum_t), or by di_anextents |
3989 | * (a signed 16-bit number, xfs_aextnum_t). | 4022 | * (a signed 16-bit number, xfs_aextnum_t). |
3990 | */ | 4023 | */ |
3991 | maxleafents = (whichfork == XFS_DATA_FORK) ? MAXEXTNUM : MAXAEXTNUM; | 4024 | if (whichfork == XFS_DATA_FORK) { |
4025 | maxleafents = MAXEXTNUM; | ||
4026 | sz = (mp->m_flags & XFS_MOUNT_COMPAT_ATTR) ? | ||
4027 | mp->m_attroffset : XFS_BMDR_SPACE_CALC(MINDBTPTRS); | ||
4028 | } else { | ||
4029 | maxleafents = MAXAEXTNUM; | ||
4030 | sz = (mp->m_flags & XFS_MOUNT_COMPAT_ATTR) ? | ||
4031 | mp->m_sb.sb_inodesize - mp->m_attroffset : | ||
4032 | XFS_BMDR_SPACE_CALC(MINABTPTRS); | ||
4033 | } | ||
4034 | maxrootrecs = (int)XFS_BTREE_BLOCK_MAXRECS(sz, xfs_bmdr, 0); | ||
3992 | minleafrecs = mp->m_bmap_dmnr[0]; | 4035 | minleafrecs = mp->m_bmap_dmnr[0]; |
3993 | minnoderecs = mp->m_bmap_dmnr[1]; | 4036 | minnoderecs = mp->m_bmap_dmnr[1]; |
3994 | sz = (whichfork == XFS_DATA_FORK) ? | ||
3995 | mp->m_attroffset : | ||
3996 | mp->m_sb.sb_inodesize - mp->m_attroffset; | ||
3997 | maxrootrecs = (int)XFS_BTREE_BLOCK_MAXRECS(sz, xfs_bmdr, 0); | ||
3998 | maxblocks = (maxleafents + minleafrecs - 1) / minleafrecs; | 4037 | maxblocks = (maxleafents + minleafrecs - 1) / minleafrecs; |
3999 | for (level = 1; maxblocks > 1; level++) { | 4038 | for (level = 1; maxblocks > 1; level++) { |
4000 | if (maxblocks <= maxrootrecs) | 4039 | if (maxblocks <= maxrootrecs) |
@@ -4332,8 +4371,8 @@ xfs_bmap_read_extents( | |||
4332 | /* | 4371 | /* |
4333 | * Root level must use BMAP_BROOT_PTR_ADDR macro to get ptr out. | 4372 | * Root level must use BMAP_BROOT_PTR_ADDR macro to get ptr out. |
4334 | */ | 4373 | */ |
4335 | ASSERT(INT_GET(block->bb_level, ARCH_CONVERT) > 0); | 4374 | level = be16_to_cpu(block->bb_level); |
4336 | level = INT_GET(block->bb_level, ARCH_CONVERT); | 4375 | ASSERT(level > 0); |
4337 | pp = XFS_BMAP_BROOT_PTR_ADDR(block, 1, ifp->if_broot_bytes); | 4376 | pp = XFS_BMAP_BROOT_PTR_ADDR(block, 1, ifp->if_broot_bytes); |
4338 | ASSERT(INT_GET(*pp, ARCH_CONVERT) != NULLDFSBNO); | 4377 | ASSERT(INT_GET(*pp, ARCH_CONVERT) != NULLDFSBNO); |
4339 | ASSERT(XFS_FSB_TO_AGNO(mp, INT_GET(*pp, ARCH_CONVERT)) < mp->m_sb.sb_agcount); | 4378 | ASSERT(XFS_FSB_TO_AGNO(mp, INT_GET(*pp, ARCH_CONVERT)) < mp->m_sb.sb_agcount); |
@@ -4376,7 +4415,7 @@ xfs_bmap_read_extents( | |||
4376 | xfs_extnum_t num_recs; | 4415 | xfs_extnum_t num_recs; |
4377 | 4416 | ||
4378 | 4417 | ||
4379 | num_recs = INT_GET(block->bb_numrecs, ARCH_CONVERT); | 4418 | num_recs = be16_to_cpu(block->bb_numrecs); |
4380 | if (unlikely(i + num_recs > room)) { | 4419 | if (unlikely(i + num_recs > room)) { |
4381 | ASSERT(i + num_recs <= room); | 4420 | ASSERT(i + num_recs <= room); |
4382 | xfs_fs_cmn_err(CE_WARN, ip->i_mount, | 4421 | xfs_fs_cmn_err(CE_WARN, ip->i_mount, |
@@ -4393,7 +4432,7 @@ xfs_bmap_read_extents( | |||
4393 | /* | 4432 | /* |
4394 | * Read-ahead the next leaf block, if any. | 4433 | * Read-ahead the next leaf block, if any. |
4395 | */ | 4434 | */ |
4396 | nextbno = INT_GET(block->bb_rightsib, ARCH_CONVERT); | 4435 | nextbno = be64_to_cpu(block->bb_rightsib); |
4397 | if (nextbno != NULLFSBLOCK) | 4436 | if (nextbno != NULLFSBLOCK) |
4398 | xfs_btree_reada_bufl(mp, nextbno, 1); | 4437 | xfs_btree_reada_bufl(mp, nextbno, 1); |
4399 | /* | 4438 | /* |
@@ -4650,7 +4689,7 @@ xfs_bmapi( | |||
4650 | } | 4689 | } |
4651 | if (wr && *firstblock == NULLFSBLOCK) { | 4690 | if (wr && *firstblock == NULLFSBLOCK) { |
4652 | if (XFS_IFORK_FORMAT(ip, whichfork) == XFS_DINODE_FMT_BTREE) | 4691 | if (XFS_IFORK_FORMAT(ip, whichfork) == XFS_DINODE_FMT_BTREE) |
4653 | minleft = INT_GET(ifp->if_broot->bb_level, ARCH_CONVERT) + 1; | 4692 | minleft = be16_to_cpu(ifp->if_broot->bb_level) + 1; |
4654 | else | 4693 | else |
4655 | minleft = 1; | 4694 | minleft = 1; |
4656 | } else | 4695 | } else |
@@ -5692,12 +5731,13 @@ xfs_getbmap( | |||
5692 | out.bmv_offset = XFS_FSB_TO_BB(mp, map[i].br_startoff); | 5731 | out.bmv_offset = XFS_FSB_TO_BB(mp, map[i].br_startoff); |
5693 | out.bmv_length = XFS_FSB_TO_BB(mp, map[i].br_blockcount); | 5732 | out.bmv_length = XFS_FSB_TO_BB(mp, map[i].br_blockcount); |
5694 | ASSERT(map[i].br_startblock != DELAYSTARTBLOCK); | 5733 | ASSERT(map[i].br_startblock != DELAYSTARTBLOCK); |
5695 | if (prealloced && | 5734 | if (map[i].br_startblock == HOLESTARTBLOCK && |
5696 | map[i].br_startblock == HOLESTARTBLOCK && | 5735 | ((prealloced && out.bmv_offset + out.bmv_length == bmvend) || |
5697 | out.bmv_offset + out.bmv_length == bmvend) { | 5736 | whichfork == XFS_ATTR_FORK )) { |
5698 | /* | 5737 | /* |
5699 | * came to hole at end of file | 5738 | * came to hole at end of file or the end of |
5700 | */ | 5739 | attribute fork |
5740 | */ | ||
5701 | goto unlock_and_return; | 5741 | goto unlock_and_return; |
5702 | } else { | 5742 | } else { |
5703 | out.bmv_block = | 5743 | out.bmv_block = |
@@ -5927,10 +5967,10 @@ xfs_check_block( | |||
5927 | xfs_bmbt_ptr_t *pp, *thispa; /* pointer to block address */ | 5967 | xfs_bmbt_ptr_t *pp, *thispa; /* pointer to block address */ |
5928 | xfs_bmbt_key_t *prevp, *keyp; | 5968 | xfs_bmbt_key_t *prevp, *keyp; |
5929 | 5969 | ||
5930 | ASSERT(INT_GET(block->bb_level, ARCH_CONVERT) > 0); | 5970 | ASSERT(be16_to_cpu(block->bb_level) > 0); |
5931 | 5971 | ||
5932 | prevp = NULL; | 5972 | prevp = NULL; |
5933 | for( i = 1; i <= INT_GET(block->bb_numrecs, ARCH_CONVERT);i++) { | 5973 | for( i = 1; i <= be16_to_cpu(block->bb_numrecs); i++) { |
5934 | dmxr = mp->m_bmap_dmxr[0]; | 5974 | dmxr = mp->m_bmap_dmxr[0]; |
5935 | 5975 | ||
5936 | if (root) { | 5976 | if (root) { |
@@ -5955,7 +5995,7 @@ xfs_check_block( | |||
5955 | pp = XFS_BTREE_PTR_ADDR(mp->m_sb.sb_blocksize, | 5995 | pp = XFS_BTREE_PTR_ADDR(mp->m_sb.sb_blocksize, |
5956 | xfs_bmbt, block, i, dmxr); | 5996 | xfs_bmbt, block, i, dmxr); |
5957 | } | 5997 | } |
5958 | for (j = i+1; j <= INT_GET(block->bb_numrecs, ARCH_CONVERT); j++) { | 5998 | for (j = i+1; j <= be16_to_cpu(block->bb_numrecs); j++) { |
5959 | if (root) { | 5999 | if (root) { |
5960 | thispa = XFS_BMAP_BROOT_PTR_ADDR(block, j, sz); | 6000 | thispa = XFS_BMAP_BROOT_PTR_ADDR(block, j, sz); |
5961 | } else { | 6001 | } else { |
@@ -6008,8 +6048,8 @@ xfs_bmap_check_leaf_extents( | |||
6008 | /* | 6048 | /* |
6009 | * Root level must use BMAP_BROOT_PTR_ADDR macro to get ptr out. | 6049 | * Root level must use BMAP_BROOT_PTR_ADDR macro to get ptr out. |
6010 | */ | 6050 | */ |
6011 | ASSERT(INT_GET(block->bb_level, ARCH_CONVERT) > 0); | 6051 | level = be16_to_cpu(block->bb_level); |
6012 | level = INT_GET(block->bb_level, ARCH_CONVERT); | 6052 | ASSERT(level > 0); |
6013 | xfs_check_block(block, mp, 1, ifp->if_broot_bytes); | 6053 | xfs_check_block(block, mp, 1, ifp->if_broot_bytes); |
6014 | pp = XFS_BMAP_BROOT_PTR_ADDR(block, 1, ifp->if_broot_bytes); | 6054 | pp = XFS_BMAP_BROOT_PTR_ADDR(block, 1, ifp->if_broot_bytes); |
6015 | ASSERT(INT_GET(*pp, ARCH_CONVERT) != NULLDFSBNO); | 6055 | ASSERT(INT_GET(*pp, ARCH_CONVERT) != NULLDFSBNO); |
@@ -6069,13 +6109,13 @@ xfs_bmap_check_leaf_extents( | |||
6069 | xfs_extnum_t num_recs; | 6109 | xfs_extnum_t num_recs; |
6070 | 6110 | ||
6071 | 6111 | ||
6072 | num_recs = INT_GET(block->bb_numrecs, ARCH_CONVERT); | 6112 | num_recs = be16_to_cpu(block->bb_numrecs); |
6073 | 6113 | ||
6074 | /* | 6114 | /* |
6075 | * Read-ahead the next leaf block, if any. | 6115 | * Read-ahead the next leaf block, if any. |
6076 | */ | 6116 | */ |
6077 | 6117 | ||
6078 | nextbno = INT_GET(block->bb_rightsib, ARCH_CONVERT); | 6118 | nextbno = be64_to_cpu(block->bb_rightsib); |
6079 | 6119 | ||
6080 | /* | 6120 | /* |
6081 | * Check all the extents to make sure they are OK. | 6121 | * Check all the extents to make sure they are OK. |
@@ -6131,7 +6171,7 @@ error0: | |||
6131 | xfs_trans_brelse(NULL, bp); | 6171 | xfs_trans_brelse(NULL, bp); |
6132 | error_norelse: | 6172 | error_norelse: |
6133 | cmn_err(CE_WARN, "%s: BAD after btree leaves for %d extents", | 6173 | cmn_err(CE_WARN, "%s: BAD after btree leaves for %d extents", |
6134 | i, __FUNCTION__); | 6174 | __FUNCTION__, i); |
6135 | panic("%s: CORRUPTED BTREE OR SOMETHING", __FUNCTION__); | 6175 | panic("%s: CORRUPTED BTREE OR SOMETHING", __FUNCTION__); |
6136 | return; | 6176 | return; |
6137 | } | 6177 | } |
@@ -6172,8 +6212,8 @@ xfs_bmap_count_blocks( | |||
6172 | * Root level must use BMAP_BROOT_PTR_ADDR macro to get ptr out. | 6212 | * Root level must use BMAP_BROOT_PTR_ADDR macro to get ptr out. |
6173 | */ | 6213 | */ |
6174 | block = ifp->if_broot; | 6214 | block = ifp->if_broot; |
6175 | ASSERT(INT_GET(block->bb_level, ARCH_CONVERT) > 0); | 6215 | level = be16_to_cpu(block->bb_level); |
6176 | level = INT_GET(block->bb_level, ARCH_CONVERT); | 6216 | ASSERT(level > 0); |
6177 | pp = XFS_BMAP_BROOT_PTR_ADDR(block, 1, ifp->if_broot_bytes); | 6217 | pp = XFS_BMAP_BROOT_PTR_ADDR(block, 1, ifp->if_broot_bytes); |
6178 | ASSERT(INT_GET(*pp, ARCH_CONVERT) != NULLDFSBNO); | 6218 | ASSERT(INT_GET(*pp, ARCH_CONVERT) != NULLDFSBNO); |
6179 | ASSERT(XFS_FSB_TO_AGNO(mp, INT_GET(*pp, ARCH_CONVERT)) < mp->m_sb.sb_agcount); | 6219 | ASSERT(XFS_FSB_TO_AGNO(mp, INT_GET(*pp, ARCH_CONVERT)) < mp->m_sb.sb_agcount); |
@@ -6218,14 +6258,14 @@ xfs_bmap_count_tree( | |||
6218 | 6258 | ||
6219 | if (--level) { | 6259 | if (--level) { |
6220 | /* Not at node above leafs, count this level of nodes */ | 6260 | /* Not at node above leafs, count this level of nodes */ |
6221 | nextbno = INT_GET(block->bb_rightsib, ARCH_CONVERT); | 6261 | nextbno = be64_to_cpu(block->bb_rightsib); |
6222 | while (nextbno != NULLFSBLOCK) { | 6262 | while (nextbno != NULLFSBLOCK) { |
6223 | if ((error = xfs_btree_read_bufl(mp, tp, nextbno, | 6263 | if ((error = xfs_btree_read_bufl(mp, tp, nextbno, |
6224 | 0, &nbp, XFS_BMAP_BTREE_REF))) | 6264 | 0, &nbp, XFS_BMAP_BTREE_REF))) |
6225 | return error; | 6265 | return error; |
6226 | *count += 1; | 6266 | *count += 1; |
6227 | nextblock = XFS_BUF_TO_BMBT_BLOCK(nbp); | 6267 | nextblock = XFS_BUF_TO_BMBT_BLOCK(nbp); |
6228 | nextbno = INT_GET(nextblock->bb_rightsib, ARCH_CONVERT); | 6268 | nextbno = be64_to_cpu(nextblock->bb_rightsib); |
6229 | xfs_trans_brelse(tp, nbp); | 6269 | xfs_trans_brelse(tp, nbp); |
6230 | } | 6270 | } |
6231 | 6271 | ||
@@ -6244,11 +6284,11 @@ xfs_bmap_count_tree( | |||
6244 | } else { | 6284 | } else { |
6245 | /* count all level 1 nodes and their leaves */ | 6285 | /* count all level 1 nodes and their leaves */ |
6246 | for (;;) { | 6286 | for (;;) { |
6247 | nextbno = INT_GET(block->bb_rightsib, ARCH_CONVERT); | 6287 | nextbno = be64_to_cpu(block->bb_rightsib); |
6248 | numrecs = INT_GET(block->bb_numrecs, ARCH_CONVERT); | 6288 | numrecs = be16_to_cpu(block->bb_numrecs); |
6249 | frp = XFS_BTREE_REC_ADDR(mp->m_sb.sb_blocksize, | 6289 | frp = XFS_BTREE_REC_ADDR(mp->m_sb.sb_blocksize, |
6250 | xfs_bmbt, block, 1, mp->m_bmap_dmxr[0]); | 6290 | xfs_bmbt, block, 1, mp->m_bmap_dmxr[0]); |
6251 | if (unlikely(xfs_bmap_count_leaves(frp, numrecs, count) < 0)) { | 6291 | if (unlikely(xfs_bmap_disk_count_leaves(frp, numrecs, count) < 0)) { |
6252 | xfs_trans_brelse(tp, bp); | 6292 | xfs_trans_brelse(tp, bp); |
6253 | XFS_ERROR_REPORT("xfs_bmap_count_tree(2)", | 6293 | XFS_ERROR_REPORT("xfs_bmap_count_tree(2)", |
6254 | XFS_ERRLEVEL_LOW, mp); | 6294 | XFS_ERRLEVEL_LOW, mp); |
@@ -6280,6 +6320,22 @@ xfs_bmap_count_leaves( | |||
6280 | int b; | 6320 | int b; |
6281 | 6321 | ||
6282 | for ( b = 1; b <= numrecs; b++, frp++) | 6322 | for ( b = 1; b <= numrecs; b++, frp++) |
6323 | *count += xfs_bmbt_get_blockcount(frp); | ||
6324 | return 0; | ||
6325 | } | ||
6326 | |||
6327 | /* | ||
6328 | * Count leaf blocks given a pointer to an extent list originally in btree format. | ||
6329 | */ | ||
6330 | int | ||
6331 | xfs_bmap_disk_count_leaves( | ||
6332 | xfs_bmbt_rec_t *frp, | ||
6333 | int numrecs, | ||
6334 | int *count) | ||
6335 | { | ||
6336 | int b; | ||
6337 | |||
6338 | for ( b = 1; b <= numrecs; b++, frp++) | ||
6283 | *count += xfs_bmbt_disk_get_blockcount(frp); | 6339 | *count += xfs_bmbt_disk_get_blockcount(frp); |
6284 | return 0; | 6340 | return 0; |
6285 | } | 6341 | } |
diff --git a/fs/xfs/xfs_bmap.h b/fs/xfs/xfs_bmap.h index e6d22ec9b2e4..2e0717a01309 100644 --- a/fs/xfs/xfs_bmap.h +++ b/fs/xfs/xfs_bmap.h | |||
@@ -1,33 +1,19 @@ | |||
1 | /* | 1 | /* |
2 | * Copyright (c) 2000-2003 Silicon Graphics, Inc. All Rights Reserved. | 2 | * Copyright (c) 2000-2003,2005 Silicon Graphics, Inc. |
3 | * All Rights Reserved. | ||
3 | * | 4 | * |
4 | * This program is free software; you can redistribute it and/or modify it | 5 | * This program is free software; you can redistribute it and/or |
5 | * under the terms of version 2 of the GNU General Public License as | 6 | * modify it under the terms of the GNU General Public License as |
6 | * published by the Free Software Foundation. | 7 | * published by the Free Software Foundation. |
7 | * | 8 | * |
8 | * This program is distributed in the hope that it would be useful, but | 9 | * This program is distributed in the hope that it would be useful, |
9 | * WITHOUT ANY WARRANTY; without even the implied warranty of | 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
12 | * GNU General Public License for more details. | ||
11 | * | 13 | * |
12 | * Further, this software is distributed without any warranty that it is | 14 | * You should have received a copy of the GNU General Public License |
13 | * free of the rightful claim of any third person regarding infringement | 15 | * along with this program; if not, write the Free Software Foundation, |
14 | * or the like. Any license provided herein, whether implied or | 16 | * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
15 | * otherwise, applies only to this software file. Patent licenses, if | ||
16 | * any, provided herein do not apply to combinations of this program with | ||
17 | * other software, or any other product whatsoever. | ||
18 | * | ||
19 | * You should have received a copy of the GNU General Public License along | ||
20 | * with this program; if not, write the Free Software Foundation, Inc., 59 | ||
21 | * Temple Place - Suite 330, Boston MA 02111-1307, USA. | ||
22 | * | ||
23 | * Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy, | ||
24 | * Mountain View, CA 94043, or: | ||
25 | * | ||
26 | * http://www.sgi.com | ||
27 | * | ||
28 | * For further information regarding this notice, see: | ||
29 | * | ||
30 | * http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/ | ||
31 | */ | 17 | */ |
32 | #ifndef __XFS_BMAP_H__ | 18 | #ifndef __XFS_BMAP_H__ |
33 | #define __XFS_BMAP_H__ | 19 | #define __XFS_BMAP_H__ |
@@ -77,12 +63,11 @@ typedef struct xfs_bmap_free | |||
77 | /* combine contig. space */ | 63 | /* combine contig. space */ |
78 | #define XFS_BMAPI_CONTIG 0x400 /* must allocate only one extent */ | 64 | #define XFS_BMAPI_CONTIG 0x400 /* must allocate only one extent */ |
79 | 65 | ||
80 | #if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_BMAPI_AFLAG) | ||
81 | int xfs_bmapi_aflag(int w); | ||
82 | #define XFS_BMAPI_AFLAG(w) xfs_bmapi_aflag(w) | 66 | #define XFS_BMAPI_AFLAG(w) xfs_bmapi_aflag(w) |
83 | #else | 67 | static inline int xfs_bmapi_aflag(int w) |
84 | #define XFS_BMAPI_AFLAG(w) ((w) == XFS_ATTR_FORK ? XFS_BMAPI_ATTRFORK : 0) | 68 | { |
85 | #endif | 69 | return (w == XFS_ATTR_FORK ? XFS_BMAPI_ATTRFORK : 0); |
70 | } | ||
86 | 71 | ||
87 | /* | 72 | /* |
88 | * Special values for xfs_bmbt_irec_t br_startblock field. | 73 | * Special values for xfs_bmbt_irec_t br_startblock field. |
@@ -90,14 +75,12 @@ int xfs_bmapi_aflag(int w); | |||
90 | #define DELAYSTARTBLOCK ((xfs_fsblock_t)-1LL) | 75 | #define DELAYSTARTBLOCK ((xfs_fsblock_t)-1LL) |
91 | #define HOLESTARTBLOCK ((xfs_fsblock_t)-2LL) | 76 | #define HOLESTARTBLOCK ((xfs_fsblock_t)-2LL) |
92 | 77 | ||
93 | #if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_BMAP_INIT) | ||
94 | void xfs_bmap_init(xfs_bmap_free_t *flp, xfs_fsblock_t *fbp); | ||
95 | #define XFS_BMAP_INIT(flp,fbp) xfs_bmap_init(flp,fbp) | 78 | #define XFS_BMAP_INIT(flp,fbp) xfs_bmap_init(flp,fbp) |
96 | #else | 79 | static inline void xfs_bmap_init(xfs_bmap_free_t *flp, xfs_fsblock_t *fbp) |
97 | #define XFS_BMAP_INIT(flp,fbp) \ | 80 | { |
98 | ((flp)->xbf_first = NULL, (flp)->xbf_count = 0, \ | 81 | ((flp)->xbf_first = NULL, (flp)->xbf_count = 0, \ |
99 | (flp)->xbf_low = 0, *(fbp) = NULLFSBLOCK) | 82 | (flp)->xbf_low = 0, *(fbp) = NULLFSBLOCK); |
100 | #endif | 83 | } |
101 | 84 | ||
102 | /* | 85 | /* |
103 | * Argument structure for xfs_bmap_alloc. | 86 | * Argument structure for xfs_bmap_alloc. |
@@ -156,7 +139,8 @@ xfs_bmap_trace_exlist( | |||
156 | int /* error code */ | 139 | int /* error code */ |
157 | xfs_bmap_add_attrfork( | 140 | xfs_bmap_add_attrfork( |
158 | struct xfs_inode *ip, /* incore inode pointer */ | 141 | struct xfs_inode *ip, /* incore inode pointer */ |
159 | int rsvd); /* flag for reserved block allocation */ | 142 | int size, /* space needed for new attribute */ |
143 | int rsvd); /* flag for reserved block allocation */ | ||
160 | 144 | ||
161 | /* | 145 | /* |
162 | * Add the extent to the list of extents to be free at transaction end. | 146 | * Add the extent to the list of extents to be free at transaction end. |
diff --git a/fs/xfs/xfs_bmap_btree.c b/fs/xfs/xfs_bmap_btree.c index 09a77b17565b..3f1383d160e8 100644 --- a/fs/xfs/xfs_bmap_btree.c +++ b/fs/xfs/xfs_bmap_btree.c | |||
@@ -1,41 +1,26 @@ | |||
1 | /* | 1 | /* |
2 | * Copyright (c) 2000-2003 Silicon Graphics, Inc. All Rights Reserved. | 2 | * Copyright (c) 2000-2003,2005 Silicon Graphics, Inc. |
3 | * All Rights Reserved. | ||
3 | * | 4 | * |
4 | * This program is free software; you can redistribute it and/or modify it | 5 | * This program is free software; you can redistribute it and/or |
5 | * under the terms of version 2 of the GNU General Public License as | 6 | * modify it under the terms of the GNU General Public License as |
6 | * published by the Free Software Foundation. | 7 | * published by the Free Software Foundation. |
7 | * | 8 | * |
8 | * This program is distributed in the hope that it would be useful, but | 9 | * This program is distributed in the hope that it would be useful, |
9 | * WITHOUT ANY WARRANTY; without even the implied warranty of | 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
12 | * GNU General Public License for more details. | ||
11 | * | 13 | * |
12 | * Further, this software is distributed without any warranty that it is | 14 | * You should have received a copy of the GNU General Public License |
13 | * free of the rightful claim of any third person regarding infringement | 15 | * along with this program; if not, write the Free Software Foundation, |
14 | * or the like. Any license provided herein, whether implied or | 16 | * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
15 | * otherwise, applies only to this software file. Patent licenses, if | ||
16 | * any, provided herein do not apply to combinations of this program with | ||
17 | * other software, or any other product whatsoever. | ||
18 | * | ||
19 | * You should have received a copy of the GNU General Public License along | ||
20 | * with this program; if not, write the Free Software Foundation, Inc., 59 | ||
21 | * Temple Place - Suite 330, Boston MA 02111-1307, USA. | ||
22 | * | ||
23 | * Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy, | ||
24 | * Mountain View, CA 94043, or: | ||
25 | * | ||
26 | * http://www.sgi.com | ||
27 | * | ||
28 | * For further information regarding this notice, see: | ||
29 | * | ||
30 | * http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/ | ||
31 | */ | 17 | */ |
32 | |||
33 | #include "xfs.h" | 18 | #include "xfs.h" |
34 | 19 | #include "xfs_fs.h" | |
35 | #include "xfs_macros.h" | ||
36 | #include "xfs_types.h" | 20 | #include "xfs_types.h" |
37 | #include "xfs_inum.h" | 21 | #include "xfs_bit.h" |
38 | #include "xfs_log.h" | 22 | #include "xfs_log.h" |
23 | #include "xfs_inum.h" | ||
39 | #include "xfs_trans.h" | 24 | #include "xfs_trans.h" |
40 | #include "xfs_sb.h" | 25 | #include "xfs_sb.h" |
41 | #include "xfs_ag.h" | 26 | #include "xfs_ag.h" |
@@ -43,20 +28,19 @@ | |||
43 | #include "xfs_dir2.h" | 28 | #include "xfs_dir2.h" |
44 | #include "xfs_dmapi.h" | 29 | #include "xfs_dmapi.h" |
45 | #include "xfs_mount.h" | 30 | #include "xfs_mount.h" |
46 | #include "xfs_alloc_btree.h" | ||
47 | #include "xfs_bmap_btree.h" | 31 | #include "xfs_bmap_btree.h" |
32 | #include "xfs_alloc_btree.h" | ||
48 | #include "xfs_ialloc_btree.h" | 33 | #include "xfs_ialloc_btree.h" |
49 | #include "xfs_btree.h" | ||
50 | #include "xfs_ialloc.h" | ||
51 | #include "xfs_itable.h" | ||
52 | #include "xfs_attr_sf.h" | ||
53 | #include "xfs_dir_sf.h" | 34 | #include "xfs_dir_sf.h" |
54 | #include "xfs_dir2_sf.h" | 35 | #include "xfs_dir2_sf.h" |
36 | #include "xfs_attr_sf.h" | ||
55 | #include "xfs_dinode.h" | 37 | #include "xfs_dinode.h" |
56 | #include "xfs_inode_item.h" | ||
57 | #include "xfs_inode.h" | 38 | #include "xfs_inode.h" |
39 | #include "xfs_inode_item.h" | ||
58 | #include "xfs_alloc.h" | 40 | #include "xfs_alloc.h" |
59 | #include "xfs_bit.h" | 41 | #include "xfs_btree.h" |
42 | #include "xfs_ialloc.h" | ||
43 | #include "xfs_itable.h" | ||
60 | #include "xfs_bmap.h" | 44 | #include "xfs_bmap.h" |
61 | #include "xfs_error.h" | 45 | #include "xfs_error.h" |
62 | #include "xfs_quota.h" | 46 | #include "xfs_quota.h" |
@@ -382,7 +366,7 @@ xfs_bmbt_delrec( | |||
382 | return 0; | 366 | return 0; |
383 | } | 367 | } |
384 | block = xfs_bmbt_get_block(cur, level, &bp); | 368 | block = xfs_bmbt_get_block(cur, level, &bp); |
385 | numrecs = INT_GET(block->bb_numrecs, ARCH_CONVERT); | 369 | numrecs = be16_to_cpu(block->bb_numrecs); |
386 | #ifdef DEBUG | 370 | #ifdef DEBUG |
387 | if ((error = xfs_btree_check_lblock(cur, block, level, bp))) { | 371 | if ((error = xfs_btree_check_lblock(cur, block, level, bp))) { |
388 | XFS_BMBT_TRACE_CURSOR(cur, ERROR); | 372 | XFS_BMBT_TRACE_CURSOR(cur, ERROR); |
@@ -427,7 +411,7 @@ xfs_bmbt_delrec( | |||
427 | } | 411 | } |
428 | } | 412 | } |
429 | numrecs--; | 413 | numrecs--; |
430 | INT_SET(block->bb_numrecs, ARCH_CONVERT, numrecs); | 414 | block->bb_numrecs = cpu_to_be16(numrecs); |
431 | xfs_bmbt_log_block(cur, bp, XFS_BB_NUMRECS); | 415 | xfs_bmbt_log_block(cur, bp, XFS_BB_NUMRECS); |
432 | /* | 416 | /* |
433 | * We're at the root level. | 417 | * We're at the root level. |
@@ -463,8 +447,8 @@ xfs_bmbt_delrec( | |||
463 | *stat = 1; | 447 | *stat = 1; |
464 | return 0; | 448 | return 0; |
465 | } | 449 | } |
466 | rbno = INT_GET(block->bb_rightsib, ARCH_CONVERT); | 450 | rbno = be64_to_cpu(block->bb_rightsib); |
467 | lbno = INT_GET(block->bb_leftsib, ARCH_CONVERT); | 451 | lbno = be64_to_cpu(block->bb_leftsib); |
468 | /* | 452 | /* |
469 | * One child of root, need to get a chance to copy its contents | 453 | * One child of root, need to get a chance to copy its contents |
470 | * into the root and delete it. Can't go up to next level, | 454 | * into the root and delete it. Can't go up to next level, |
@@ -508,15 +492,15 @@ xfs_bmbt_delrec( | |||
508 | goto error0; | 492 | goto error0; |
509 | } | 493 | } |
510 | #endif | 494 | #endif |
511 | bno = INT_GET(right->bb_leftsib, ARCH_CONVERT); | 495 | bno = be64_to_cpu(right->bb_leftsib); |
512 | if (INT_GET(right->bb_numrecs, ARCH_CONVERT) - 1 >= | 496 | if (be16_to_cpu(right->bb_numrecs) - 1 >= |
513 | XFS_BMAP_BLOCK_IMINRECS(level, cur)) { | 497 | XFS_BMAP_BLOCK_IMINRECS(level, cur)) { |
514 | if ((error = xfs_bmbt_lshift(tcur, level, &i))) { | 498 | if ((error = xfs_bmbt_lshift(tcur, level, &i))) { |
515 | XFS_BMBT_TRACE_CURSOR(cur, ERROR); | 499 | XFS_BMBT_TRACE_CURSOR(cur, ERROR); |
516 | goto error0; | 500 | goto error0; |
517 | } | 501 | } |
518 | if (i) { | 502 | if (i) { |
519 | ASSERT(INT_GET(block->bb_numrecs, ARCH_CONVERT) >= | 503 | ASSERT(be16_to_cpu(block->bb_numrecs) >= |
520 | XFS_BMAP_BLOCK_IMINRECS(level, tcur)); | 504 | XFS_BMAP_BLOCK_IMINRECS(level, tcur)); |
521 | xfs_btree_del_cursor(tcur, XFS_BTREE_NOERROR); | 505 | xfs_btree_del_cursor(tcur, XFS_BTREE_NOERROR); |
522 | tcur = NULL; | 506 | tcur = NULL; |
@@ -533,7 +517,7 @@ xfs_bmbt_delrec( | |||
533 | return 0; | 517 | return 0; |
534 | } | 518 | } |
535 | } | 519 | } |
536 | rrecs = INT_GET(right->bb_numrecs, ARCH_CONVERT); | 520 | rrecs = be16_to_cpu(right->bb_numrecs); |
537 | if (lbno != NULLFSBLOCK) { | 521 | if (lbno != NULLFSBLOCK) { |
538 | i = xfs_btree_firstrec(tcur, level); | 522 | i = xfs_btree_firstrec(tcur, level); |
539 | XFS_WANT_CORRUPTED_GOTO(i == 1, error0); | 523 | XFS_WANT_CORRUPTED_GOTO(i == 1, error0); |
@@ -564,15 +548,15 @@ xfs_bmbt_delrec( | |||
564 | goto error0; | 548 | goto error0; |
565 | } | 549 | } |
566 | #endif | 550 | #endif |
567 | bno = INT_GET(left->bb_rightsib, ARCH_CONVERT); | 551 | bno = be64_to_cpu(left->bb_rightsib); |
568 | if (INT_GET(left->bb_numrecs, ARCH_CONVERT) - 1 >= | 552 | if (be16_to_cpu(left->bb_numrecs) - 1 >= |
569 | XFS_BMAP_BLOCK_IMINRECS(level, cur)) { | 553 | XFS_BMAP_BLOCK_IMINRECS(level, cur)) { |
570 | if ((error = xfs_bmbt_rshift(tcur, level, &i))) { | 554 | if ((error = xfs_bmbt_rshift(tcur, level, &i))) { |
571 | XFS_BMBT_TRACE_CURSOR(cur, ERROR); | 555 | XFS_BMBT_TRACE_CURSOR(cur, ERROR); |
572 | goto error0; | 556 | goto error0; |
573 | } | 557 | } |
574 | if (i) { | 558 | if (i) { |
575 | ASSERT(INT_GET(block->bb_numrecs, ARCH_CONVERT) >= | 559 | ASSERT(be16_to_cpu(block->bb_numrecs) >= |
576 | XFS_BMAP_BLOCK_IMINRECS(level, tcur)); | 560 | XFS_BMAP_BLOCK_IMINRECS(level, tcur)); |
577 | xfs_btree_del_cursor(tcur, XFS_BTREE_NOERROR); | 561 | xfs_btree_del_cursor(tcur, XFS_BTREE_NOERROR); |
578 | tcur = NULL; | 562 | tcur = NULL; |
@@ -583,14 +567,14 @@ xfs_bmbt_delrec( | |||
583 | return 0; | 567 | return 0; |
584 | } | 568 | } |
585 | } | 569 | } |
586 | lrecs = INT_GET(left->bb_numrecs, ARCH_CONVERT); | 570 | lrecs = be16_to_cpu(left->bb_numrecs); |
587 | } | 571 | } |
588 | xfs_btree_del_cursor(tcur, XFS_BTREE_NOERROR); | 572 | xfs_btree_del_cursor(tcur, XFS_BTREE_NOERROR); |
589 | tcur = NULL; | 573 | tcur = NULL; |
590 | mp = cur->bc_mp; | 574 | mp = cur->bc_mp; |
591 | ASSERT(bno != NULLFSBLOCK); | 575 | ASSERT(bno != NULLFSBLOCK); |
592 | if (lbno != NULLFSBLOCK && | 576 | if (lbno != NULLFSBLOCK && |
593 | lrecs + INT_GET(block->bb_numrecs, ARCH_CONVERT) <= XFS_BMAP_BLOCK_IMAXRECS(level, cur)) { | 577 | lrecs + be16_to_cpu(block->bb_numrecs) <= XFS_BMAP_BLOCK_IMAXRECS(level, cur)) { |
594 | rbno = bno; | 578 | rbno = bno; |
595 | right = block; | 579 | right = block; |
596 | rbp = bp; | 580 | rbp = bp; |
@@ -605,7 +589,7 @@ xfs_bmbt_delrec( | |||
605 | goto error0; | 589 | goto error0; |
606 | } | 590 | } |
607 | } else if (rbno != NULLFSBLOCK && | 591 | } else if (rbno != NULLFSBLOCK && |
608 | rrecs + INT_GET(block->bb_numrecs, ARCH_CONVERT) <= | 592 | rrecs + be16_to_cpu(block->bb_numrecs) <= |
609 | XFS_BMAP_BLOCK_IMAXRECS(level, cur)) { | 593 | XFS_BMAP_BLOCK_IMAXRECS(level, cur)) { |
610 | lbno = bno; | 594 | lbno = bno; |
611 | left = block; | 595 | left = block; |
@@ -620,7 +604,7 @@ xfs_bmbt_delrec( | |||
620 | XFS_BMBT_TRACE_CURSOR(cur, ERROR); | 604 | XFS_BMBT_TRACE_CURSOR(cur, ERROR); |
621 | goto error0; | 605 | goto error0; |
622 | } | 606 | } |
623 | lrecs = INT_GET(left->bb_numrecs, ARCH_CONVERT); | 607 | lrecs = be16_to_cpu(left->bb_numrecs); |
624 | } else { | 608 | } else { |
625 | if (level > 0 && (error = xfs_bmbt_decrement(cur, level, &i))) { | 609 | if (level > 0 && (error = xfs_bmbt_decrement(cur, level, &i))) { |
626 | XFS_BMBT_TRACE_CURSOR(cur, ERROR); | 610 | XFS_BMBT_TRACE_CURSOR(cur, ERROR); |
@@ -630,8 +614,8 @@ xfs_bmbt_delrec( | |||
630 | *stat = 1; | 614 | *stat = 1; |
631 | return 0; | 615 | return 0; |
632 | } | 616 | } |
633 | numlrecs = INT_GET(left->bb_numrecs, ARCH_CONVERT); | 617 | numlrecs = be16_to_cpu(left->bb_numrecs); |
634 | numrrecs = INT_GET(right->bb_numrecs, ARCH_CONVERT); | 618 | numrrecs = be16_to_cpu(right->bb_numrecs); |
635 | if (level > 0) { | 619 | if (level > 0) { |
636 | lkp = XFS_BMAP_KEY_IADDR(left, numlrecs + 1, cur); | 620 | lkp = XFS_BMAP_KEY_IADDR(left, numlrecs + 1, cur); |
637 | lpp = XFS_BMAP_PTR_IADDR(left, numlrecs + 1, cur); | 621 | lpp = XFS_BMAP_PTR_IADDR(left, numlrecs + 1, cur); |
@@ -655,12 +639,12 @@ xfs_bmbt_delrec( | |||
655 | memcpy(lrp, rrp, numrrecs * sizeof(*lrp)); | 639 | memcpy(lrp, rrp, numrrecs * sizeof(*lrp)); |
656 | xfs_bmbt_log_recs(cur, lbp, numlrecs + 1, numlrecs + numrrecs); | 640 | xfs_bmbt_log_recs(cur, lbp, numlrecs + 1, numlrecs + numrrecs); |
657 | } | 641 | } |
658 | INT_MOD(left->bb_numrecs, ARCH_CONVERT, numrrecs); | 642 | be16_add(&left->bb_numrecs, numrrecs); |
659 | left->bb_rightsib = right->bb_rightsib; /* INT_: direct copy */ | 643 | left->bb_rightsib = right->bb_rightsib; |
660 | xfs_bmbt_log_block(cur, lbp, XFS_BB_RIGHTSIB | XFS_BB_NUMRECS); | 644 | xfs_bmbt_log_block(cur, lbp, XFS_BB_RIGHTSIB | XFS_BB_NUMRECS); |
661 | if (INT_GET(left->bb_rightsib, ARCH_CONVERT) != NULLDFSBNO) { | 645 | if (be64_to_cpu(left->bb_rightsib) != NULLDFSBNO) { |
662 | if ((error = xfs_btree_read_bufl(mp, cur->bc_tp, | 646 | if ((error = xfs_btree_read_bufl(mp, cur->bc_tp, |
663 | INT_GET(left->bb_rightsib, ARCH_CONVERT), | 647 | be64_to_cpu(left->bb_rightsib), |
664 | 0, &rrbp, XFS_BMAP_BTREE_REF))) { | 648 | 0, &rrbp, XFS_BMAP_BTREE_REF))) { |
665 | XFS_BMBT_TRACE_CURSOR(cur, ERROR); | 649 | XFS_BMBT_TRACE_CURSOR(cur, ERROR); |
666 | goto error0; | 650 | goto error0; |
@@ -670,7 +654,7 @@ xfs_bmbt_delrec( | |||
670 | XFS_BMBT_TRACE_CURSOR(cur, ERROR); | 654 | XFS_BMBT_TRACE_CURSOR(cur, ERROR); |
671 | goto error0; | 655 | goto error0; |
672 | } | 656 | } |
673 | INT_SET(rrblock->bb_leftsib, ARCH_CONVERT, lbno); | 657 | rrblock->bb_leftsib = cpu_to_be64(lbno); |
674 | xfs_bmbt_log_block(cur, rrbp, XFS_BB_LEFTSIB); | 658 | xfs_bmbt_log_block(cur, rrbp, XFS_BB_LEFTSIB); |
675 | } | 659 | } |
676 | xfs_bmap_add_free(XFS_DADDR_TO_FSB(mp, XFS_BUF_ADDR(rbp)), 1, | 660 | xfs_bmap_add_free(XFS_DADDR_TO_FSB(mp, XFS_BUF_ADDR(rbp)), 1, |
@@ -727,7 +711,7 @@ xfs_bmbt_get_rec( | |||
727 | if ((error = xfs_btree_check_lblock(cur, block, 0, bp))) | 711 | if ((error = xfs_btree_check_lblock(cur, block, 0, bp))) |
728 | return error; | 712 | return error; |
729 | #endif | 713 | #endif |
730 | if (ptr > INT_GET(block->bb_numrecs, ARCH_CONVERT) || ptr <= 0) { | 714 | if (ptr > be16_to_cpu(block->bb_numrecs) || ptr <= 0) { |
731 | *stat = 0; | 715 | *stat = 0; |
732 | return 0; | 716 | return 0; |
733 | } | 717 | } |
@@ -788,7 +772,7 @@ xfs_bmbt_insrec( | |||
788 | } | 772 | } |
789 | XFS_STATS_INC(xs_bmbt_insrec); | 773 | XFS_STATS_INC(xs_bmbt_insrec); |
790 | block = xfs_bmbt_get_block(cur, level, &bp); | 774 | block = xfs_bmbt_get_block(cur, level, &bp); |
791 | numrecs = INT_GET(block->bb_numrecs, ARCH_CONVERT); | 775 | numrecs = be16_to_cpu(block->bb_numrecs); |
792 | #ifdef DEBUG | 776 | #ifdef DEBUG |
793 | if ((error = xfs_btree_check_lblock(cur, block, level, bp))) { | 777 | if ((error = xfs_btree_check_lblock(cur, block, level, bp))) { |
794 | XFS_BMBT_TRACE_CURSOR(cur, ERROR); | 778 | XFS_BMBT_TRACE_CURSOR(cur, ERROR); |
@@ -870,7 +854,7 @@ xfs_bmbt_insrec( | |||
870 | } | 854 | } |
871 | } | 855 | } |
872 | } | 856 | } |
873 | numrecs = INT_GET(block->bb_numrecs, ARCH_CONVERT); | 857 | numrecs = be16_to_cpu(block->bb_numrecs); |
874 | if (level > 0) { | 858 | if (level > 0) { |
875 | kp = XFS_BMAP_KEY_IADDR(block, 1, cur); | 859 | kp = XFS_BMAP_KEY_IADDR(block, 1, cur); |
876 | pp = XFS_BMAP_PTR_IADDR(block, 1, cur); | 860 | pp = XFS_BMAP_PTR_IADDR(block, 1, cur); |
@@ -897,7 +881,7 @@ xfs_bmbt_insrec( | |||
897 | kp[ptr - 1] = key; | 881 | kp[ptr - 1] = key; |
898 | INT_SET(pp[ptr - 1], ARCH_CONVERT, *bnop); | 882 | INT_SET(pp[ptr - 1], ARCH_CONVERT, *bnop); |
899 | numrecs++; | 883 | numrecs++; |
900 | INT_SET(block->bb_numrecs, ARCH_CONVERT, numrecs); | 884 | block->bb_numrecs = cpu_to_be16(numrecs); |
901 | xfs_bmbt_log_keys(cur, bp, ptr, numrecs); | 885 | xfs_bmbt_log_keys(cur, bp, ptr, numrecs); |
902 | xfs_bmbt_log_ptrs(cur, bp, ptr, numrecs); | 886 | xfs_bmbt_log_ptrs(cur, bp, ptr, numrecs); |
903 | } else { | 887 | } else { |
@@ -906,7 +890,7 @@ xfs_bmbt_insrec( | |||
906 | (numrecs - ptr + 1) * sizeof(*rp)); | 890 | (numrecs - ptr + 1) * sizeof(*rp)); |
907 | rp[ptr - 1] = *recp; | 891 | rp[ptr - 1] = *recp; |
908 | numrecs++; | 892 | numrecs++; |
909 | INT_SET(block->bb_numrecs, ARCH_CONVERT, numrecs); | 893 | block->bb_numrecs = cpu_to_be16(numrecs); |
910 | xfs_bmbt_log_recs(cur, bp, ptr, numrecs); | 894 | xfs_bmbt_log_recs(cur, bp, ptr, numrecs); |
911 | } | 895 | } |
912 | xfs_bmbt_log_block(cur, bp, XFS_BB_NUMRECS); | 896 | xfs_bmbt_log_block(cur, bp, XFS_BB_NUMRECS); |
@@ -971,7 +955,7 @@ xfs_bmbt_killroot( | |||
971 | /* | 955 | /* |
972 | * Give up if the root has multiple children. | 956 | * Give up if the root has multiple children. |
973 | */ | 957 | */ |
974 | if (INT_GET(block->bb_numrecs, ARCH_CONVERT) != 1) { | 958 | if (be16_to_cpu(block->bb_numrecs) != 1) { |
975 | XFS_BMBT_TRACE_CURSOR(cur, EXIT); | 959 | XFS_BMBT_TRACE_CURSOR(cur, EXIT); |
976 | return 0; | 960 | return 0; |
977 | } | 961 | } |
@@ -982,37 +966,37 @@ xfs_bmbt_killroot( | |||
982 | */ | 966 | */ |
983 | cbp = cur->bc_bufs[level - 1]; | 967 | cbp = cur->bc_bufs[level - 1]; |
984 | cblock = XFS_BUF_TO_BMBT_BLOCK(cbp); | 968 | cblock = XFS_BUF_TO_BMBT_BLOCK(cbp); |
985 | if (INT_GET(cblock->bb_numrecs, ARCH_CONVERT) > XFS_BMAP_BLOCK_DMAXRECS(level, cur)) { | 969 | if (be16_to_cpu(cblock->bb_numrecs) > XFS_BMAP_BLOCK_DMAXRECS(level, cur)) { |
986 | XFS_BMBT_TRACE_CURSOR(cur, EXIT); | 970 | XFS_BMBT_TRACE_CURSOR(cur, EXIT); |
987 | return 0; | 971 | return 0; |
988 | } | 972 | } |
989 | ASSERT(INT_GET(cblock->bb_leftsib, ARCH_CONVERT) == NULLDFSBNO); | 973 | ASSERT(be64_to_cpu(cblock->bb_leftsib) == NULLDFSBNO); |
990 | ASSERT(INT_GET(cblock->bb_rightsib, ARCH_CONVERT) == NULLDFSBNO); | 974 | ASSERT(be64_to_cpu(cblock->bb_rightsib) == NULLDFSBNO); |
991 | ip = cur->bc_private.b.ip; | 975 | ip = cur->bc_private.b.ip; |
992 | ifp = XFS_IFORK_PTR(ip, cur->bc_private.b.whichfork); | 976 | ifp = XFS_IFORK_PTR(ip, cur->bc_private.b.whichfork); |
993 | ASSERT(XFS_BMAP_BLOCK_IMAXRECS(level, cur) == | 977 | ASSERT(XFS_BMAP_BLOCK_IMAXRECS(level, cur) == |
994 | XFS_BMAP_BROOT_MAXRECS(ifp->if_broot_bytes)); | 978 | XFS_BMAP_BROOT_MAXRECS(ifp->if_broot_bytes)); |
995 | i = (int)(INT_GET(cblock->bb_numrecs, ARCH_CONVERT) - XFS_BMAP_BLOCK_IMAXRECS(level, cur)); | 979 | i = (int)(be16_to_cpu(cblock->bb_numrecs) - XFS_BMAP_BLOCK_IMAXRECS(level, cur)); |
996 | if (i) { | 980 | if (i) { |
997 | xfs_iroot_realloc(ip, i, cur->bc_private.b.whichfork); | 981 | xfs_iroot_realloc(ip, i, cur->bc_private.b.whichfork); |
998 | block = ifp->if_broot; | 982 | block = ifp->if_broot; |
999 | } | 983 | } |
1000 | INT_MOD(block->bb_numrecs, ARCH_CONVERT, i); | 984 | be16_add(&block->bb_numrecs, i); |
1001 | ASSERT(INT_GET(block->bb_numrecs, ARCH_CONVERT) == INT_GET(cblock->bb_numrecs, ARCH_CONVERT)); | 985 | ASSERT(block->bb_numrecs == cblock->bb_numrecs); |
1002 | kp = XFS_BMAP_KEY_IADDR(block, 1, cur); | 986 | kp = XFS_BMAP_KEY_IADDR(block, 1, cur); |
1003 | ckp = XFS_BMAP_KEY_IADDR(cblock, 1, cur); | 987 | ckp = XFS_BMAP_KEY_IADDR(cblock, 1, cur); |
1004 | memcpy(kp, ckp, INT_GET(block->bb_numrecs, ARCH_CONVERT) * sizeof(*kp)); | 988 | memcpy(kp, ckp, be16_to_cpu(block->bb_numrecs) * sizeof(*kp)); |
1005 | pp = XFS_BMAP_PTR_IADDR(block, 1, cur); | 989 | pp = XFS_BMAP_PTR_IADDR(block, 1, cur); |
1006 | cpp = XFS_BMAP_PTR_IADDR(cblock, 1, cur); | 990 | cpp = XFS_BMAP_PTR_IADDR(cblock, 1, cur); |
1007 | #ifdef DEBUG | 991 | #ifdef DEBUG |
1008 | for (i = 0; i < INT_GET(cblock->bb_numrecs, ARCH_CONVERT); i++) { | 992 | for (i = 0; i < be16_to_cpu(cblock->bb_numrecs); i++) { |
1009 | if ((error = xfs_btree_check_lptr(cur, INT_GET(cpp[i], ARCH_CONVERT), level - 1))) { | 993 | if ((error = xfs_btree_check_lptr(cur, INT_GET(cpp[i], ARCH_CONVERT), level - 1))) { |
1010 | XFS_BMBT_TRACE_CURSOR(cur, ERROR); | 994 | XFS_BMBT_TRACE_CURSOR(cur, ERROR); |
1011 | return error; | 995 | return error; |
1012 | } | 996 | } |
1013 | } | 997 | } |
1014 | #endif | 998 | #endif |
1015 | memcpy(pp, cpp, INT_GET(block->bb_numrecs, ARCH_CONVERT) * sizeof(*pp)); | 999 | memcpy(pp, cpp, be16_to_cpu(block->bb_numrecs) * sizeof(*pp)); |
1016 | xfs_bmap_add_free(XFS_DADDR_TO_FSB(cur->bc_mp, XFS_BUF_ADDR(cbp)), 1, | 1000 | xfs_bmap_add_free(XFS_DADDR_TO_FSB(cur->bc_mp, XFS_BUF_ADDR(cbp)), 1, |
1017 | cur->bc_private.b.flist, cur->bc_mp); | 1001 | cur->bc_private.b.flist, cur->bc_mp); |
1018 | ip->i_d.di_nblocks--; | 1002 | ip->i_d.di_nblocks--; |
@@ -1020,7 +1004,7 @@ xfs_bmbt_killroot( | |||
1020 | XFS_TRANS_DQ_BCOUNT, -1L); | 1004 | XFS_TRANS_DQ_BCOUNT, -1L); |
1021 | xfs_trans_binval(cur->bc_tp, cbp); | 1005 | xfs_trans_binval(cur->bc_tp, cbp); |
1022 | cur->bc_bufs[level - 1] = NULL; | 1006 | cur->bc_bufs[level - 1] = NULL; |
1023 | INT_MOD(block->bb_level, ARCH_CONVERT, -1); | 1007 | be16_add(&block->bb_level, -1); |
1024 | xfs_trans_log_inode(cur->bc_tp, ip, | 1008 | xfs_trans_log_inode(cur->bc_tp, ip, |
1025 | XFS_ILOG_CORE | XFS_ILOG_FBROOT(cur->bc_private.b.whichfork)); | 1009 | XFS_ILOG_CORE | XFS_ILOG_FBROOT(cur->bc_private.b.whichfork)); |
1026 | cur->bc_nlevels--; | 1010 | cur->bc_nlevels--; |
@@ -1176,7 +1160,7 @@ xfs_bmbt_lookup( | |||
1176 | else | 1160 | else |
1177 | krbase = XFS_BMAP_REC_IADDR(block, 1, cur); | 1161 | krbase = XFS_BMAP_REC_IADDR(block, 1, cur); |
1178 | low = 1; | 1162 | low = 1; |
1179 | if (!(high = INT_GET(block->bb_numrecs, ARCH_CONVERT))) { | 1163 | if (!(high = be16_to_cpu(block->bb_numrecs))) { |
1180 | ASSERT(level == 0); | 1164 | ASSERT(level == 0); |
1181 | cur->bc_ptrs[0] = dir != XFS_LOOKUP_LE; | 1165 | cur->bc_ptrs[0] = dir != XFS_LOOKUP_LE; |
1182 | XFS_BMBT_TRACE_CURSOR(cur, EXIT); | 1166 | XFS_BMBT_TRACE_CURSOR(cur, EXIT); |
@@ -1223,8 +1207,8 @@ xfs_bmbt_lookup( | |||
1223 | * If ge search and we went off the end of the block, but it's | 1207 | * If ge search and we went off the end of the block, but it's |
1224 | * not the last block, we're in the wrong block. | 1208 | * not the last block, we're in the wrong block. |
1225 | */ | 1209 | */ |
1226 | if (dir == XFS_LOOKUP_GE && keyno > INT_GET(block->bb_numrecs, ARCH_CONVERT) && | 1210 | if (dir == XFS_LOOKUP_GE && keyno > be16_to_cpu(block->bb_numrecs) && |
1227 | INT_GET(block->bb_rightsib, ARCH_CONVERT) != NULLDFSBNO) { | 1211 | be64_to_cpu(block->bb_rightsib) != NULLDFSBNO) { |
1228 | cur->bc_ptrs[0] = keyno; | 1212 | cur->bc_ptrs[0] = keyno; |
1229 | if ((error = xfs_bmbt_increment(cur, 0, &i))) { | 1213 | if ((error = xfs_bmbt_increment(cur, 0, &i))) { |
1230 | XFS_BMBT_TRACE_CURSOR(cur, ERROR); | 1214 | XFS_BMBT_TRACE_CURSOR(cur, ERROR); |
@@ -1239,7 +1223,7 @@ xfs_bmbt_lookup( | |||
1239 | else if (dir == XFS_LOOKUP_LE && diff > 0) | 1223 | else if (dir == XFS_LOOKUP_LE && diff > 0) |
1240 | keyno--; | 1224 | keyno--; |
1241 | cur->bc_ptrs[0] = keyno; | 1225 | cur->bc_ptrs[0] = keyno; |
1242 | if (keyno == 0 || keyno > INT_GET(block->bb_numrecs, ARCH_CONVERT)) { | 1226 | if (keyno == 0 || keyno > be16_to_cpu(block->bb_numrecs)) { |
1243 | XFS_BMBT_TRACE_CURSOR(cur, EXIT); | 1227 | XFS_BMBT_TRACE_CURSOR(cur, EXIT); |
1244 | *stat = 0; | 1228 | *stat = 0; |
1245 | } else { | 1229 | } else { |
@@ -1296,7 +1280,7 @@ xfs_bmbt_lshift( | |||
1296 | return error; | 1280 | return error; |
1297 | } | 1281 | } |
1298 | #endif | 1282 | #endif |
1299 | if (INT_GET(right->bb_leftsib, ARCH_CONVERT) == NULLDFSBNO) { | 1283 | if (be64_to_cpu(right->bb_leftsib) == NULLDFSBNO) { |
1300 | XFS_BMBT_TRACE_CURSOR(cur, EXIT); | 1284 | XFS_BMBT_TRACE_CURSOR(cur, EXIT); |
1301 | *stat = 0; | 1285 | *stat = 0; |
1302 | return 0; | 1286 | return 0; |
@@ -1307,7 +1291,7 @@ xfs_bmbt_lshift( | |||
1307 | return 0; | 1291 | return 0; |
1308 | } | 1292 | } |
1309 | mp = cur->bc_mp; | 1293 | mp = cur->bc_mp; |
1310 | if ((error = xfs_btree_read_bufl(mp, cur->bc_tp, INT_GET(right->bb_leftsib, ARCH_CONVERT), 0, | 1294 | if ((error = xfs_btree_read_bufl(mp, cur->bc_tp, be64_to_cpu(right->bb_leftsib), 0, |
1311 | &lbp, XFS_BMAP_BTREE_REF))) { | 1295 | &lbp, XFS_BMAP_BTREE_REF))) { |
1312 | XFS_BMBT_TRACE_CURSOR(cur, ERROR); | 1296 | XFS_BMBT_TRACE_CURSOR(cur, ERROR); |
1313 | return error; | 1297 | return error; |
@@ -1317,12 +1301,12 @@ xfs_bmbt_lshift( | |||
1317 | XFS_BMBT_TRACE_CURSOR(cur, ERROR); | 1301 | XFS_BMBT_TRACE_CURSOR(cur, ERROR); |
1318 | return error; | 1302 | return error; |
1319 | } | 1303 | } |
1320 | if (INT_GET(left->bb_numrecs, ARCH_CONVERT) == XFS_BMAP_BLOCK_IMAXRECS(level, cur)) { | 1304 | if (be16_to_cpu(left->bb_numrecs) == XFS_BMAP_BLOCK_IMAXRECS(level, cur)) { |
1321 | XFS_BMBT_TRACE_CURSOR(cur, EXIT); | 1305 | XFS_BMBT_TRACE_CURSOR(cur, EXIT); |
1322 | *stat = 0; | 1306 | *stat = 0; |
1323 | return 0; | 1307 | return 0; |
1324 | } | 1308 | } |
1325 | lrecs = INT_GET(left->bb_numrecs, ARCH_CONVERT) + 1; | 1309 | lrecs = be16_to_cpu(left->bb_numrecs) + 1; |
1326 | if (level > 0) { | 1310 | if (level > 0) { |
1327 | lkp = XFS_BMAP_KEY_IADDR(left, lrecs, cur); | 1311 | lkp = XFS_BMAP_KEY_IADDR(left, lrecs, cur); |
1328 | rkp = XFS_BMAP_KEY_IADDR(right, 1, cur); | 1312 | rkp = XFS_BMAP_KEY_IADDR(right, 1, cur); |
@@ -1344,7 +1328,7 @@ xfs_bmbt_lshift( | |||
1344 | *lrp = *rrp; | 1328 | *lrp = *rrp; |
1345 | xfs_bmbt_log_recs(cur, lbp, lrecs, lrecs); | 1329 | xfs_bmbt_log_recs(cur, lbp, lrecs, lrecs); |
1346 | } | 1330 | } |
1347 | INT_SET(left->bb_numrecs, ARCH_CONVERT, lrecs); | 1331 | left->bb_numrecs = cpu_to_be16(lrecs); |
1348 | xfs_bmbt_log_block(cur, lbp, XFS_BB_NUMRECS); | 1332 | xfs_bmbt_log_block(cur, lbp, XFS_BB_NUMRECS); |
1349 | #ifdef DEBUG | 1333 | #ifdef DEBUG |
1350 | if (level > 0) | 1334 | if (level > 0) |
@@ -1352,8 +1336,8 @@ xfs_bmbt_lshift( | |||
1352 | else | 1336 | else |
1353 | xfs_btree_check_rec(XFS_BTNUM_BMAP, lrp - 1, lrp); | 1337 | xfs_btree_check_rec(XFS_BTNUM_BMAP, lrp - 1, lrp); |
1354 | #endif | 1338 | #endif |
1355 | rrecs = INT_GET(right->bb_numrecs, ARCH_CONVERT) - 1; | 1339 | rrecs = be16_to_cpu(right->bb_numrecs) - 1; |
1356 | INT_SET(right->bb_numrecs, ARCH_CONVERT, rrecs); | 1340 | right->bb_numrecs = cpu_to_be16(rrecs); |
1357 | xfs_bmbt_log_block(cur, rbp, XFS_BB_NUMRECS); | 1341 | xfs_bmbt_log_block(cur, rbp, XFS_BB_NUMRECS); |
1358 | if (level > 0) { | 1342 | if (level > 0) { |
1359 | #ifdef DEBUG | 1343 | #ifdef DEBUG |
@@ -1430,18 +1414,18 @@ xfs_bmbt_rshift( | |||
1430 | return error; | 1414 | return error; |
1431 | } | 1415 | } |
1432 | #endif | 1416 | #endif |
1433 | if (INT_GET(left->bb_rightsib, ARCH_CONVERT) == NULLDFSBNO) { | 1417 | if (be64_to_cpu(left->bb_rightsib) == NULLDFSBNO) { |
1434 | XFS_BMBT_TRACE_CURSOR(cur, EXIT); | 1418 | XFS_BMBT_TRACE_CURSOR(cur, EXIT); |
1435 | *stat = 0; | 1419 | *stat = 0; |
1436 | return 0; | 1420 | return 0; |
1437 | } | 1421 | } |
1438 | if (cur->bc_ptrs[level] >= INT_GET(left->bb_numrecs, ARCH_CONVERT)) { | 1422 | if (cur->bc_ptrs[level] >= be16_to_cpu(left->bb_numrecs)) { |
1439 | XFS_BMBT_TRACE_CURSOR(cur, EXIT); | 1423 | XFS_BMBT_TRACE_CURSOR(cur, EXIT); |
1440 | *stat = 0; | 1424 | *stat = 0; |
1441 | return 0; | 1425 | return 0; |
1442 | } | 1426 | } |
1443 | mp = cur->bc_mp; | 1427 | mp = cur->bc_mp; |
1444 | if ((error = xfs_btree_read_bufl(mp, cur->bc_tp, INT_GET(left->bb_rightsib, ARCH_CONVERT), 0, | 1428 | if ((error = xfs_btree_read_bufl(mp, cur->bc_tp, be64_to_cpu(left->bb_rightsib), 0, |
1445 | &rbp, XFS_BMAP_BTREE_REF))) { | 1429 | &rbp, XFS_BMAP_BTREE_REF))) { |
1446 | XFS_BMBT_TRACE_CURSOR(cur, ERROR); | 1430 | XFS_BMBT_TRACE_CURSOR(cur, ERROR); |
1447 | return error; | 1431 | return error; |
@@ -1451,26 +1435,26 @@ xfs_bmbt_rshift( | |||
1451 | XFS_BMBT_TRACE_CURSOR(cur, ERROR); | 1435 | XFS_BMBT_TRACE_CURSOR(cur, ERROR); |
1452 | return error; | 1436 | return error; |
1453 | } | 1437 | } |
1454 | if (INT_GET(right->bb_numrecs, ARCH_CONVERT) == XFS_BMAP_BLOCK_IMAXRECS(level, cur)) { | 1438 | if (be16_to_cpu(right->bb_numrecs) == XFS_BMAP_BLOCK_IMAXRECS(level, cur)) { |
1455 | XFS_BMBT_TRACE_CURSOR(cur, EXIT); | 1439 | XFS_BMBT_TRACE_CURSOR(cur, EXIT); |
1456 | *stat = 0; | 1440 | *stat = 0; |
1457 | return 0; | 1441 | return 0; |
1458 | } | 1442 | } |
1459 | if (level > 0) { | 1443 | if (level > 0) { |
1460 | lkp = XFS_BMAP_KEY_IADDR(left, INT_GET(left->bb_numrecs, ARCH_CONVERT), cur); | 1444 | lkp = XFS_BMAP_KEY_IADDR(left, be16_to_cpu(left->bb_numrecs), cur); |
1461 | lpp = XFS_BMAP_PTR_IADDR(left, INT_GET(left->bb_numrecs, ARCH_CONVERT), cur); | 1445 | lpp = XFS_BMAP_PTR_IADDR(left, be16_to_cpu(left->bb_numrecs), cur); |
1462 | rkp = XFS_BMAP_KEY_IADDR(right, 1, cur); | 1446 | rkp = XFS_BMAP_KEY_IADDR(right, 1, cur); |
1463 | rpp = XFS_BMAP_PTR_IADDR(right, 1, cur); | 1447 | rpp = XFS_BMAP_PTR_IADDR(right, 1, cur); |
1464 | #ifdef DEBUG | 1448 | #ifdef DEBUG |
1465 | for (i = INT_GET(right->bb_numrecs, ARCH_CONVERT) - 1; i >= 0; i--) { | 1449 | for (i = be16_to_cpu(right->bb_numrecs) - 1; i >= 0; i--) { |
1466 | if ((error = xfs_btree_check_lptr(cur, INT_GET(rpp[i], ARCH_CONVERT), level))) { | 1450 | if ((error = xfs_btree_check_lptr(cur, INT_GET(rpp[i], ARCH_CONVERT), level))) { |
1467 | XFS_BMBT_TRACE_CURSOR(cur, ERROR); | 1451 | XFS_BMBT_TRACE_CURSOR(cur, ERROR); |
1468 | return error; | 1452 | return error; |
1469 | } | 1453 | } |
1470 | } | 1454 | } |
1471 | #endif | 1455 | #endif |
1472 | memmove(rkp + 1, rkp, INT_GET(right->bb_numrecs, ARCH_CONVERT) * sizeof(*rkp)); | 1456 | memmove(rkp + 1, rkp, be16_to_cpu(right->bb_numrecs) * sizeof(*rkp)); |
1473 | memmove(rpp + 1, rpp, INT_GET(right->bb_numrecs, ARCH_CONVERT) * sizeof(*rpp)); | 1457 | memmove(rpp + 1, rpp, be16_to_cpu(right->bb_numrecs) * sizeof(*rpp)); |
1474 | #ifdef DEBUG | 1458 | #ifdef DEBUG |
1475 | if ((error = xfs_btree_check_lptr(cur, INT_GET(*lpp, ARCH_CONVERT), level))) { | 1459 | if ((error = xfs_btree_check_lptr(cur, INT_GET(*lpp, ARCH_CONVERT), level))) { |
1476 | XFS_BMBT_TRACE_CURSOR(cur, ERROR); | 1460 | XFS_BMBT_TRACE_CURSOR(cur, ERROR); |
@@ -1479,21 +1463,21 @@ xfs_bmbt_rshift( | |||
1479 | #endif | 1463 | #endif |
1480 | *rkp = *lkp; | 1464 | *rkp = *lkp; |
1481 | *rpp = *lpp; /* INT_: direct copy */ | 1465 | *rpp = *lpp; /* INT_: direct copy */ |
1482 | xfs_bmbt_log_keys(cur, rbp, 1, INT_GET(right->bb_numrecs, ARCH_CONVERT) + 1); | 1466 | xfs_bmbt_log_keys(cur, rbp, 1, be16_to_cpu(right->bb_numrecs) + 1); |
1483 | xfs_bmbt_log_ptrs(cur, rbp, 1, INT_GET(right->bb_numrecs, ARCH_CONVERT) + 1); | 1467 | xfs_bmbt_log_ptrs(cur, rbp, 1, be16_to_cpu(right->bb_numrecs) + 1); |
1484 | } else { | 1468 | } else { |
1485 | lrp = XFS_BMAP_REC_IADDR(left, INT_GET(left->bb_numrecs, ARCH_CONVERT), cur); | 1469 | lrp = XFS_BMAP_REC_IADDR(left, be16_to_cpu(left->bb_numrecs), cur); |
1486 | rrp = XFS_BMAP_REC_IADDR(right, 1, cur); | 1470 | rrp = XFS_BMAP_REC_IADDR(right, 1, cur); |
1487 | memmove(rrp + 1, rrp, INT_GET(right->bb_numrecs, ARCH_CONVERT) * sizeof(*rrp)); | 1471 | memmove(rrp + 1, rrp, be16_to_cpu(right->bb_numrecs) * sizeof(*rrp)); |
1488 | *rrp = *lrp; | 1472 | *rrp = *lrp; |
1489 | xfs_bmbt_log_recs(cur, rbp, 1, INT_GET(right->bb_numrecs, ARCH_CONVERT) + 1); | 1473 | xfs_bmbt_log_recs(cur, rbp, 1, be16_to_cpu(right->bb_numrecs) + 1); |
1490 | INT_SET(key.br_startoff, ARCH_CONVERT, | 1474 | INT_SET(key.br_startoff, ARCH_CONVERT, |
1491 | xfs_bmbt_disk_get_startoff(rrp)); | 1475 | xfs_bmbt_disk_get_startoff(rrp)); |
1492 | rkp = &key; | 1476 | rkp = &key; |
1493 | } | 1477 | } |
1494 | INT_MOD(left->bb_numrecs, ARCH_CONVERT, -1); | 1478 | be16_add(&left->bb_numrecs, -1); |
1495 | xfs_bmbt_log_block(cur, lbp, XFS_BB_NUMRECS); | 1479 | xfs_bmbt_log_block(cur, lbp, XFS_BB_NUMRECS); |
1496 | INT_MOD(right->bb_numrecs, ARCH_CONVERT, +1); | 1480 | be16_add(&right->bb_numrecs, 1); |
1497 | #ifdef DEBUG | 1481 | #ifdef DEBUG |
1498 | if (level > 0) | 1482 | if (level > 0) |
1499 | xfs_btree_check_key(XFS_BTNUM_BMAP, rkp, rkp + 1); | 1483 | xfs_btree_check_key(XFS_BTNUM_BMAP, rkp, rkp + 1); |
@@ -1624,47 +1608,47 @@ xfs_bmbt_split( | |||
1624 | return error; | 1608 | return error; |
1625 | } | 1609 | } |
1626 | #endif | 1610 | #endif |
1627 | INT_SET(right->bb_magic, ARCH_CONVERT, XFS_BMAP_MAGIC); | 1611 | right->bb_magic = cpu_to_be32(XFS_BMAP_MAGIC); |
1628 | right->bb_level = left->bb_level; /* INT_: direct copy */ | 1612 | right->bb_level = left->bb_level; |
1629 | INT_SET(right->bb_numrecs, ARCH_CONVERT, (__uint16_t)(INT_GET(left->bb_numrecs, ARCH_CONVERT) / 2)); | 1613 | right->bb_numrecs = cpu_to_be16(be16_to_cpu(left->bb_numrecs) / 2); |
1630 | if ((INT_GET(left->bb_numrecs, ARCH_CONVERT) & 1) && | 1614 | if ((be16_to_cpu(left->bb_numrecs) & 1) && |
1631 | cur->bc_ptrs[level] <= INT_GET(right->bb_numrecs, ARCH_CONVERT) + 1) | 1615 | cur->bc_ptrs[level] <= be16_to_cpu(right->bb_numrecs) + 1) |
1632 | INT_MOD(right->bb_numrecs, ARCH_CONVERT, +1); | 1616 | be16_add(&right->bb_numrecs, 1); |
1633 | i = INT_GET(left->bb_numrecs, ARCH_CONVERT) - INT_GET(right->bb_numrecs, ARCH_CONVERT) + 1; | 1617 | i = be16_to_cpu(left->bb_numrecs) - be16_to_cpu(right->bb_numrecs) + 1; |
1634 | if (level > 0) { | 1618 | if (level > 0) { |
1635 | lkp = XFS_BMAP_KEY_IADDR(left, i, cur); | 1619 | lkp = XFS_BMAP_KEY_IADDR(left, i, cur); |
1636 | lpp = XFS_BMAP_PTR_IADDR(left, i, cur); | 1620 | lpp = XFS_BMAP_PTR_IADDR(left, i, cur); |
1637 | rkp = XFS_BMAP_KEY_IADDR(right, 1, cur); | 1621 | rkp = XFS_BMAP_KEY_IADDR(right, 1, cur); |
1638 | rpp = XFS_BMAP_PTR_IADDR(right, 1, cur); | 1622 | rpp = XFS_BMAP_PTR_IADDR(right, 1, cur); |
1639 | #ifdef DEBUG | 1623 | #ifdef DEBUG |
1640 | for (i = 0; i < INT_GET(right->bb_numrecs, ARCH_CONVERT); i++) { | 1624 | for (i = 0; i < be16_to_cpu(right->bb_numrecs); i++) { |
1641 | if ((error = xfs_btree_check_lptr(cur, INT_GET(lpp[i], ARCH_CONVERT), level))) { | 1625 | if ((error = xfs_btree_check_lptr(cur, INT_GET(lpp[i], ARCH_CONVERT), level))) { |
1642 | XFS_BMBT_TRACE_CURSOR(cur, ERROR); | 1626 | XFS_BMBT_TRACE_CURSOR(cur, ERROR); |
1643 | return error; | 1627 | return error; |
1644 | } | 1628 | } |
1645 | } | 1629 | } |
1646 | #endif | 1630 | #endif |
1647 | memcpy(rkp, lkp, INT_GET(right->bb_numrecs, ARCH_CONVERT) * sizeof(*rkp)); | 1631 | memcpy(rkp, lkp, be16_to_cpu(right->bb_numrecs) * sizeof(*rkp)); |
1648 | memcpy(rpp, lpp, INT_GET(right->bb_numrecs, ARCH_CONVERT) * sizeof(*rpp)); | 1632 | memcpy(rpp, lpp, be16_to_cpu(right->bb_numrecs) * sizeof(*rpp)); |
1649 | xfs_bmbt_log_keys(cur, rbp, 1, INT_GET(right->bb_numrecs, ARCH_CONVERT)); | 1633 | xfs_bmbt_log_keys(cur, rbp, 1, be16_to_cpu(right->bb_numrecs)); |
1650 | xfs_bmbt_log_ptrs(cur, rbp, 1, INT_GET(right->bb_numrecs, ARCH_CONVERT)); | 1634 | xfs_bmbt_log_ptrs(cur, rbp, 1, be16_to_cpu(right->bb_numrecs)); |
1651 | keyp->br_startoff = INT_GET(rkp->br_startoff, ARCH_CONVERT); | 1635 | keyp->br_startoff = INT_GET(rkp->br_startoff, ARCH_CONVERT); |
1652 | } else { | 1636 | } else { |
1653 | lrp = XFS_BMAP_REC_IADDR(left, i, cur); | 1637 | lrp = XFS_BMAP_REC_IADDR(left, i, cur); |
1654 | rrp = XFS_BMAP_REC_IADDR(right, 1, cur); | 1638 | rrp = XFS_BMAP_REC_IADDR(right, 1, cur); |
1655 | memcpy(rrp, lrp, INT_GET(right->bb_numrecs, ARCH_CONVERT) * sizeof(*rrp)); | 1639 | memcpy(rrp, lrp, be16_to_cpu(right->bb_numrecs) * sizeof(*rrp)); |
1656 | xfs_bmbt_log_recs(cur, rbp, 1, INT_GET(right->bb_numrecs, ARCH_CONVERT)); | 1640 | xfs_bmbt_log_recs(cur, rbp, 1, be16_to_cpu(right->bb_numrecs)); |
1657 | keyp->br_startoff = xfs_bmbt_disk_get_startoff(rrp); | 1641 | keyp->br_startoff = xfs_bmbt_disk_get_startoff(rrp); |
1658 | } | 1642 | } |
1659 | INT_MOD(left->bb_numrecs, ARCH_CONVERT, -(INT_GET(right->bb_numrecs, ARCH_CONVERT))); | 1643 | be16_add(&left->bb_numrecs, -(be16_to_cpu(right->bb_numrecs))); |
1660 | right->bb_rightsib = left->bb_rightsib; /* INT_: direct copy */ | 1644 | right->bb_rightsib = left->bb_rightsib; |
1661 | INT_SET(left->bb_rightsib, ARCH_CONVERT, args.fsbno); | 1645 | left->bb_rightsib = cpu_to_be64(args.fsbno); |
1662 | INT_SET(right->bb_leftsib, ARCH_CONVERT, lbno); | 1646 | right->bb_leftsib = cpu_to_be64(lbno); |
1663 | xfs_bmbt_log_block(cur, rbp, XFS_BB_ALL_BITS); | 1647 | xfs_bmbt_log_block(cur, rbp, XFS_BB_ALL_BITS); |
1664 | xfs_bmbt_log_block(cur, lbp, XFS_BB_NUMRECS | XFS_BB_RIGHTSIB); | 1648 | xfs_bmbt_log_block(cur, lbp, XFS_BB_NUMRECS | XFS_BB_RIGHTSIB); |
1665 | if (INT_GET(right->bb_rightsib, ARCH_CONVERT) != NULLDFSBNO) { | 1649 | if (be64_to_cpu(right->bb_rightsib) != NULLDFSBNO) { |
1666 | if ((error = xfs_btree_read_bufl(args.mp, args.tp, | 1650 | if ((error = xfs_btree_read_bufl(args.mp, args.tp, |
1667 | INT_GET(right->bb_rightsib, ARCH_CONVERT), 0, &rrbp, | 1651 | be64_to_cpu(right->bb_rightsib), 0, &rrbp, |
1668 | XFS_BMAP_BTREE_REF))) { | 1652 | XFS_BMAP_BTREE_REF))) { |
1669 | XFS_BMBT_TRACE_CURSOR(cur, ERROR); | 1653 | XFS_BMBT_TRACE_CURSOR(cur, ERROR); |
1670 | return error; | 1654 | return error; |
@@ -1674,12 +1658,12 @@ xfs_bmbt_split( | |||
1674 | XFS_BMBT_TRACE_CURSOR(cur, ERROR); | 1658 | XFS_BMBT_TRACE_CURSOR(cur, ERROR); |
1675 | return error; | 1659 | return error; |
1676 | } | 1660 | } |
1677 | INT_SET(rrblock->bb_leftsib, ARCH_CONVERT, args.fsbno); | 1661 | rrblock->bb_leftsib = cpu_to_be64(args.fsbno); |
1678 | xfs_bmbt_log_block(cur, rrbp, XFS_BB_LEFTSIB); | 1662 | xfs_bmbt_log_block(cur, rrbp, XFS_BB_LEFTSIB); |
1679 | } | 1663 | } |
1680 | if (cur->bc_ptrs[level] > INT_GET(left->bb_numrecs, ARCH_CONVERT) + 1) { | 1664 | if (cur->bc_ptrs[level] > be16_to_cpu(left->bb_numrecs) + 1) { |
1681 | xfs_btree_setbuf(cur, level, rbp); | 1665 | xfs_btree_setbuf(cur, level, rbp); |
1682 | cur->bc_ptrs[level] -= INT_GET(left->bb_numrecs, ARCH_CONVERT); | 1666 | cur->bc_ptrs[level] -= be16_to_cpu(left->bb_numrecs); |
1683 | } | 1667 | } |
1684 | if (level + 1 < cur->bc_nlevels) { | 1668 | if (level + 1 < cur->bc_nlevels) { |
1685 | if ((error = xfs_btree_dup_cursor(cur, curp))) { | 1669 | if ((error = xfs_btree_dup_cursor(cur, curp))) { |
@@ -1751,18 +1735,18 @@ xfs_bmdr_to_bmbt( | |||
1751 | xfs_bmbt_key_t *tkp; | 1735 | xfs_bmbt_key_t *tkp; |
1752 | xfs_bmbt_ptr_t *tpp; | 1736 | xfs_bmbt_ptr_t *tpp; |
1753 | 1737 | ||
1754 | INT_SET(rblock->bb_magic, ARCH_CONVERT, XFS_BMAP_MAGIC); | 1738 | rblock->bb_magic = cpu_to_be32(XFS_BMAP_MAGIC); |
1755 | rblock->bb_level = dblock->bb_level; /* both in on-disk format */ | 1739 | rblock->bb_level = dblock->bb_level; |
1756 | ASSERT(INT_GET(rblock->bb_level, ARCH_CONVERT) > 0); | 1740 | ASSERT(be16_to_cpu(rblock->bb_level) > 0); |
1757 | rblock->bb_numrecs = dblock->bb_numrecs;/* both in on-disk format */ | 1741 | rblock->bb_numrecs = dblock->bb_numrecs; |
1758 | INT_SET(rblock->bb_leftsib, ARCH_CONVERT, NULLDFSBNO); | 1742 | rblock->bb_leftsib = cpu_to_be64(NULLDFSBNO); |
1759 | INT_SET(rblock->bb_rightsib, ARCH_CONVERT, NULLDFSBNO); | 1743 | rblock->bb_rightsib = cpu_to_be64(NULLDFSBNO); |
1760 | dmxr = (int)XFS_BTREE_BLOCK_MAXRECS(dblocklen, xfs_bmdr, 0); | 1744 | dmxr = (int)XFS_BTREE_BLOCK_MAXRECS(dblocklen, xfs_bmdr, 0); |
1761 | fkp = XFS_BTREE_KEY_ADDR(dblocklen, xfs_bmdr, dblock, 1, dmxr); | 1745 | fkp = XFS_BTREE_KEY_ADDR(dblocklen, xfs_bmdr, dblock, 1, dmxr); |
1762 | tkp = XFS_BMAP_BROOT_KEY_ADDR(rblock, 1, rblocklen); | 1746 | tkp = XFS_BMAP_BROOT_KEY_ADDR(rblock, 1, rblocklen); |
1763 | fpp = XFS_BTREE_PTR_ADDR(dblocklen, xfs_bmdr, dblock, 1, dmxr); | 1747 | fpp = XFS_BTREE_PTR_ADDR(dblocklen, xfs_bmdr, dblock, 1, dmxr); |
1764 | tpp = XFS_BMAP_BROOT_PTR_ADDR(rblock, 1, rblocklen); | 1748 | tpp = XFS_BMAP_BROOT_PTR_ADDR(rblock, 1, rblocklen); |
1765 | dmxr = INT_GET(dblock->bb_numrecs, ARCH_CONVERT); | 1749 | dmxr = be16_to_cpu(dblock->bb_numrecs); |
1766 | memcpy(tkp, fkp, sizeof(*fkp) * dmxr); | 1750 | memcpy(tkp, fkp, sizeof(*fkp) * dmxr); |
1767 | memcpy(tpp, fpp, sizeof(*fpp) * dmxr); /* INT_: direct copy */ | 1751 | memcpy(tpp, fpp, sizeof(*fpp) * dmxr); /* INT_: direct copy */ |
1768 | } | 1752 | } |
@@ -1805,7 +1789,7 @@ xfs_bmbt_decrement( | |||
1805 | return error; | 1789 | return error; |
1806 | } | 1790 | } |
1807 | #endif | 1791 | #endif |
1808 | if (INT_GET(block->bb_leftsib, ARCH_CONVERT) == NULLDFSBNO) { | 1792 | if (be64_to_cpu(block->bb_leftsib) == NULLDFSBNO) { |
1809 | XFS_BMBT_TRACE_CURSOR(cur, EXIT); | 1793 | XFS_BMBT_TRACE_CURSOR(cur, EXIT); |
1810 | *stat = 0; | 1794 | *stat = 0; |
1811 | return 0; | 1795 | return 0; |
@@ -1837,7 +1821,7 @@ xfs_bmbt_decrement( | |||
1837 | XFS_BMBT_TRACE_CURSOR(cur, ERROR); | 1821 | XFS_BMBT_TRACE_CURSOR(cur, ERROR); |
1838 | return error; | 1822 | return error; |
1839 | } | 1823 | } |
1840 | cur->bc_ptrs[lev] = INT_GET(block->bb_numrecs, ARCH_CONVERT); | 1824 | cur->bc_ptrs[lev] = be16_to_cpu(block->bb_numrecs); |
1841 | } | 1825 | } |
1842 | XFS_BMBT_TRACE_CURSOR(cur, EXIT); | 1826 | XFS_BMBT_TRACE_CURSOR(cur, EXIT); |
1843 | *stat = 1; | 1827 | *stat = 1; |
@@ -2123,12 +2107,12 @@ xfs_bmbt_increment( | |||
2123 | return error; | 2107 | return error; |
2124 | } | 2108 | } |
2125 | #endif | 2109 | #endif |
2126 | if (++cur->bc_ptrs[level] <= INT_GET(block->bb_numrecs, ARCH_CONVERT)) { | 2110 | if (++cur->bc_ptrs[level] <= be16_to_cpu(block->bb_numrecs)) { |
2127 | XFS_BMBT_TRACE_CURSOR(cur, EXIT); | 2111 | XFS_BMBT_TRACE_CURSOR(cur, EXIT); |
2128 | *stat = 1; | 2112 | *stat = 1; |
2129 | return 0; | 2113 | return 0; |
2130 | } | 2114 | } |
2131 | if (INT_GET(block->bb_rightsib, ARCH_CONVERT) == NULLDFSBNO) { | 2115 | if (be64_to_cpu(block->bb_rightsib) == NULLDFSBNO) { |
2132 | XFS_BMBT_TRACE_CURSOR(cur, EXIT); | 2116 | XFS_BMBT_TRACE_CURSOR(cur, EXIT); |
2133 | *stat = 0; | 2117 | *stat = 0; |
2134 | return 0; | 2118 | return 0; |
@@ -2141,7 +2125,7 @@ xfs_bmbt_increment( | |||
2141 | return error; | 2125 | return error; |
2142 | } | 2126 | } |
2143 | #endif | 2127 | #endif |
2144 | if (++cur->bc_ptrs[lev] <= INT_GET(block->bb_numrecs, ARCH_CONVERT)) | 2128 | if (++cur->bc_ptrs[lev] <= be16_to_cpu(block->bb_numrecs)) |
2145 | break; | 2129 | break; |
2146 | if (lev < cur->bc_nlevels - 1) | 2130 | if (lev < cur->bc_nlevels - 1) |
2147 | xfs_btree_readahead(cur, lev, XFS_BTCUR_RIGHTRA); | 2131 | xfs_btree_readahead(cur, lev, XFS_BTCUR_RIGHTRA); |
@@ -2403,23 +2387,23 @@ xfs_bmbt_newroot( | |||
2403 | bp = xfs_btree_get_bufl(args.mp, cur->bc_tp, args.fsbno, 0); | 2387 | bp = xfs_btree_get_bufl(args.mp, cur->bc_tp, args.fsbno, 0); |
2404 | cblock = XFS_BUF_TO_BMBT_BLOCK(bp); | 2388 | cblock = XFS_BUF_TO_BMBT_BLOCK(bp); |
2405 | *cblock = *block; | 2389 | *cblock = *block; |
2406 | INT_MOD(block->bb_level, ARCH_CONVERT, +1); | 2390 | be16_add(&block->bb_level, 1); |
2407 | INT_SET(block->bb_numrecs, ARCH_CONVERT, 1); | 2391 | block->bb_numrecs = cpu_to_be16(1); |
2408 | cur->bc_nlevels++; | 2392 | cur->bc_nlevels++; |
2409 | cur->bc_ptrs[level + 1] = 1; | 2393 | cur->bc_ptrs[level + 1] = 1; |
2410 | kp = XFS_BMAP_KEY_IADDR(block, 1, cur); | 2394 | kp = XFS_BMAP_KEY_IADDR(block, 1, cur); |
2411 | ckp = XFS_BMAP_KEY_IADDR(cblock, 1, cur); | 2395 | ckp = XFS_BMAP_KEY_IADDR(cblock, 1, cur); |
2412 | memcpy(ckp, kp, INT_GET(cblock->bb_numrecs, ARCH_CONVERT) * sizeof(*kp)); | 2396 | memcpy(ckp, kp, be16_to_cpu(cblock->bb_numrecs) * sizeof(*kp)); |
2413 | cpp = XFS_BMAP_PTR_IADDR(cblock, 1, cur); | 2397 | cpp = XFS_BMAP_PTR_IADDR(cblock, 1, cur); |
2414 | #ifdef DEBUG | 2398 | #ifdef DEBUG |
2415 | for (i = 0; i < INT_GET(cblock->bb_numrecs, ARCH_CONVERT); i++) { | 2399 | for (i = 0; i < be16_to_cpu(cblock->bb_numrecs); i++) { |
2416 | if ((error = xfs_btree_check_lptr(cur, INT_GET(pp[i], ARCH_CONVERT), level))) { | 2400 | if ((error = xfs_btree_check_lptr(cur, INT_GET(pp[i], ARCH_CONVERT), level))) { |
2417 | XFS_BMBT_TRACE_CURSOR(cur, ERROR); | 2401 | XFS_BMBT_TRACE_CURSOR(cur, ERROR); |
2418 | return error; | 2402 | return error; |
2419 | } | 2403 | } |
2420 | } | 2404 | } |
2421 | #endif | 2405 | #endif |
2422 | memcpy(cpp, pp, INT_GET(cblock->bb_numrecs, ARCH_CONVERT) * sizeof(*pp)); | 2406 | memcpy(cpp, pp, be16_to_cpu(cblock->bb_numrecs) * sizeof(*pp)); |
2423 | #ifdef DEBUG | 2407 | #ifdef DEBUG |
2424 | if ((error = xfs_btree_check_lptr(cur, (xfs_bmbt_ptr_t)args.fsbno, | 2408 | if ((error = xfs_btree_check_lptr(cur, (xfs_bmbt_ptr_t)args.fsbno, |
2425 | level))) { | 2409 | level))) { |
@@ -2428,7 +2412,7 @@ xfs_bmbt_newroot( | |||
2428 | } | 2412 | } |
2429 | #endif | 2413 | #endif |
2430 | INT_SET(*pp, ARCH_CONVERT, args.fsbno); | 2414 | INT_SET(*pp, ARCH_CONVERT, args.fsbno); |
2431 | xfs_iroot_realloc(cur->bc_private.b.ip, 1 - INT_GET(cblock->bb_numrecs, ARCH_CONVERT), | 2415 | xfs_iroot_realloc(cur->bc_private.b.ip, 1 - be16_to_cpu(cblock->bb_numrecs), |
2432 | cur->bc_private.b.whichfork); | 2416 | cur->bc_private.b.whichfork); |
2433 | xfs_btree_setbuf(cur, level, bp); | 2417 | xfs_btree_setbuf(cur, level, bp); |
2434 | /* | 2418 | /* |
@@ -2436,8 +2420,8 @@ xfs_bmbt_newroot( | |||
2436 | * the root is at the right level. | 2420 | * the root is at the right level. |
2437 | */ | 2421 | */ |
2438 | xfs_bmbt_log_block(cur, bp, XFS_BB_ALL_BITS); | 2422 | xfs_bmbt_log_block(cur, bp, XFS_BB_ALL_BITS); |
2439 | xfs_bmbt_log_keys(cur, bp, 1, INT_GET(cblock->bb_numrecs, ARCH_CONVERT)); | 2423 | xfs_bmbt_log_keys(cur, bp, 1, be16_to_cpu(cblock->bb_numrecs)); |
2440 | xfs_bmbt_log_ptrs(cur, bp, 1, INT_GET(cblock->bb_numrecs, ARCH_CONVERT)); | 2424 | xfs_bmbt_log_ptrs(cur, bp, 1, be16_to_cpu(cblock->bb_numrecs)); |
2441 | XFS_BMBT_TRACE_CURSOR(cur, EXIT); | 2425 | XFS_BMBT_TRACE_CURSOR(cur, EXIT); |
2442 | *logflags |= | 2426 | *logflags |= |
2443 | XFS_ILOG_CORE | XFS_ILOG_FBROOT(cur->bc_private.b.whichfork); | 2427 | XFS_ILOG_CORE | XFS_ILOG_FBROOT(cur->bc_private.b.whichfork); |
@@ -2705,18 +2689,18 @@ xfs_bmbt_to_bmdr( | |||
2705 | xfs_bmbt_key_t *tkp; | 2689 | xfs_bmbt_key_t *tkp; |
2706 | xfs_bmbt_ptr_t *tpp; | 2690 | xfs_bmbt_ptr_t *tpp; |
2707 | 2691 | ||
2708 | ASSERT(INT_GET(rblock->bb_magic, ARCH_CONVERT) == XFS_BMAP_MAGIC); | 2692 | ASSERT(be32_to_cpu(rblock->bb_magic) == XFS_BMAP_MAGIC); |
2709 | ASSERT(INT_GET(rblock->bb_leftsib, ARCH_CONVERT) == NULLDFSBNO); | 2693 | ASSERT(be64_to_cpu(rblock->bb_leftsib) == NULLDFSBNO); |
2710 | ASSERT(INT_GET(rblock->bb_rightsib, ARCH_CONVERT) == NULLDFSBNO); | 2694 | ASSERT(be64_to_cpu(rblock->bb_rightsib) == NULLDFSBNO); |
2711 | ASSERT(INT_GET(rblock->bb_level, ARCH_CONVERT) > 0); | 2695 | ASSERT(be16_to_cpu(rblock->bb_level) > 0); |
2712 | dblock->bb_level = rblock->bb_level; /* both in on-disk format */ | 2696 | dblock->bb_level = rblock->bb_level; |
2713 | dblock->bb_numrecs = rblock->bb_numrecs;/* both in on-disk format */ | 2697 | dblock->bb_numrecs = rblock->bb_numrecs; |
2714 | dmxr = (int)XFS_BTREE_BLOCK_MAXRECS(dblocklen, xfs_bmdr, 0); | 2698 | dmxr = (int)XFS_BTREE_BLOCK_MAXRECS(dblocklen, xfs_bmdr, 0); |
2715 | fkp = XFS_BMAP_BROOT_KEY_ADDR(rblock, 1, rblocklen); | 2699 | fkp = XFS_BMAP_BROOT_KEY_ADDR(rblock, 1, rblocklen); |
2716 | tkp = XFS_BTREE_KEY_ADDR(dblocklen, xfs_bmdr, dblock, 1, dmxr); | 2700 | tkp = XFS_BTREE_KEY_ADDR(dblocklen, xfs_bmdr, dblock, 1, dmxr); |
2717 | fpp = XFS_BMAP_BROOT_PTR_ADDR(rblock, 1, rblocklen); | 2701 | fpp = XFS_BMAP_BROOT_PTR_ADDR(rblock, 1, rblocklen); |
2718 | tpp = XFS_BTREE_PTR_ADDR(dblocklen, xfs_bmdr, dblock, 1, dmxr); | 2702 | tpp = XFS_BTREE_PTR_ADDR(dblocklen, xfs_bmdr, dblock, 1, dmxr); |
2719 | dmxr = INT_GET(dblock->bb_numrecs, ARCH_CONVERT); | 2703 | dmxr = be16_to_cpu(dblock->bb_numrecs); |
2720 | memcpy(tkp, fkp, sizeof(*fkp) * dmxr); | 2704 | memcpy(tkp, fkp, sizeof(*fkp) * dmxr); |
2721 | memcpy(tpp, fpp, sizeof(*fpp) * dmxr); /* INT_: direct copy */ | 2705 | memcpy(tpp, fpp, sizeof(*fpp) * dmxr); /* INT_: direct copy */ |
2722 | } | 2706 | } |
diff --git a/fs/xfs/xfs_bmap_btree.h b/fs/xfs/xfs_bmap_btree.h index 2cf4fe45cbcb..e095a2d344ae 100644 --- a/fs/xfs/xfs_bmap_btree.h +++ b/fs/xfs/xfs_bmap_btree.h | |||
@@ -1,33 +1,19 @@ | |||
1 | /* | 1 | /* |
2 | * Copyright (c) 2000,2002-2004 Silicon Graphics, Inc. All Rights Reserved. | 2 | * Copyright (c) 2000,2002-2005 Silicon Graphics, Inc. |
3 | * All Rights Reserved. | ||
3 | * | 4 | * |
4 | * This program is free software; you can redistribute it and/or modify it | 5 | * This program is free software; you can redistribute it and/or |
5 | * under the terms of version 2 of the GNU General Public License as | 6 | * modify it under the terms of the GNU General Public License as |
6 | * published by the Free Software Foundation. | 7 | * published by the Free Software Foundation. |
7 | * | 8 | * |
8 | * This program is distributed in the hope that it would be useful, but | 9 | * This program is distributed in the hope that it would be useful, |
9 | * WITHOUT ANY WARRANTY; without even the implied warranty of | 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
12 | * GNU General Public License for more details. | ||
11 | * | 13 | * |
12 | * Further, this software is distributed without any warranty that it is | 14 | * You should have received a copy of the GNU General Public License |
13 | * free of the rightful claim of any third person regarding infringement | 15 | * along with this program; if not, write the Free Software Foundation, |
14 | * or the like. Any license provided herein, whether implied or | 16 | * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
15 | * otherwise, applies only to this software file. Patent licenses, if | ||
16 | * any, provided herein do not apply to combinations of this program with | ||
17 | * other software, or any other product whatsoever. | ||
18 | * | ||
19 | * You should have received a copy of the GNU General Public License along | ||
20 | * with this program; if not, write the Free Software Foundation, Inc., 59 | ||
21 | * Temple Place - Suite 330, Boston MA 02111-1307, USA. | ||
22 | * | ||
23 | * Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy, | ||
24 | * Mountain View, CA 94043, or: | ||
25 | * | ||
26 | * http://www.sgi.com | ||
27 | * | ||
28 | * For further information regarding this notice, see: | ||
29 | * | ||
30 | * http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/ | ||
31 | */ | 17 | */ |
32 | #ifndef __XFS_BMAP_BTREE_H__ | 18 | #ifndef __XFS_BMAP_BTREE_H__ |
33 | #define __XFS_BMAP_BTREE_H__ | 19 | #define __XFS_BMAP_BTREE_H__ |
@@ -42,10 +28,9 @@ struct xfs_inode; | |||
42 | /* | 28 | /* |
43 | * Bmap root header, on-disk form only. | 29 | * Bmap root header, on-disk form only. |
44 | */ | 30 | */ |
45 | typedef struct xfs_bmdr_block | 31 | typedef struct xfs_bmdr_block { |
46 | { | 32 | __be16 bb_level; /* 0 is a leaf */ |
47 | __uint16_t bb_level; /* 0 is a leaf */ | 33 | __be16 bb_numrecs; /* current # of data records */ |
48 | __uint16_t bb_numrecs; /* current # of data records */ | ||
49 | } xfs_bmdr_block_t; | 34 | } xfs_bmdr_block_t; |
50 | 35 | ||
51 | /* | 36 | /* |
@@ -114,31 +99,31 @@ typedef xfs_bmbt_rec_64_t xfs_bmbt_rec_t, xfs_bmdr_rec_t; | |||
114 | (((((xfs_fsblock_t)1) << STARTBLOCKMASKBITS) - 1) << STARTBLOCKVALBITS) | 99 | (((((xfs_fsblock_t)1) << STARTBLOCKMASKBITS) - 1) << STARTBLOCKVALBITS) |
115 | #define DSTARTBLOCKMASK \ | 100 | #define DSTARTBLOCKMASK \ |
116 | (((((xfs_dfsbno_t)1) << DSTARTBLOCKMASKBITS) - 1) << STARTBLOCKVALBITS) | 101 | (((((xfs_dfsbno_t)1) << DSTARTBLOCKMASKBITS) - 1) << STARTBLOCKVALBITS) |
117 | #if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_ISNULLSTARTBLOCK) | 102 | |
118 | int isnullstartblock(xfs_fsblock_t x); | ||
119 | #define ISNULLSTARTBLOCK(x) isnullstartblock(x) | 103 | #define ISNULLSTARTBLOCK(x) isnullstartblock(x) |
120 | #else | 104 | static inline int isnullstartblock(xfs_fsblock_t x) |
121 | #define ISNULLSTARTBLOCK(x) (((x) & STARTBLOCKMASK) == STARTBLOCKMASK) | 105 | { |
122 | #endif | 106 | return ((x) & STARTBLOCKMASK) == STARTBLOCKMASK; |
123 | #if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_ISNULLDSTARTBLOCK) | 107 | } |
124 | int isnulldstartblock(xfs_dfsbno_t x); | 108 | |
125 | #define ISNULLDSTARTBLOCK(x) isnulldstartblock(x) | 109 | #define ISNULLDSTARTBLOCK(x) isnulldstartblock(x) |
126 | #else | 110 | static inline int isnulldstartblock(xfs_dfsbno_t x) |
127 | #define ISNULLDSTARTBLOCK(x) (((x) & DSTARTBLOCKMASK) == DSTARTBLOCKMASK) | 111 | { |
128 | #endif | 112 | return ((x) & DSTARTBLOCKMASK) == DSTARTBLOCKMASK; |
129 | #if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_NULLSTARTBLOCK) | 113 | } |
130 | xfs_fsblock_t nullstartblock(int k); | 114 | |
131 | #define NULLSTARTBLOCK(k) nullstartblock(k) | 115 | #define NULLSTARTBLOCK(k) nullstartblock(k) |
132 | #else | 116 | static inline xfs_fsblock_t nullstartblock(int k) |
133 | #define NULLSTARTBLOCK(k) \ | 117 | { |
134 | ((ASSERT(k < (1 << STARTBLOCKVALBITS))), (STARTBLOCKMASK | (k))) | 118 | ASSERT(k < (1 << STARTBLOCKVALBITS)); |
135 | #endif | 119 | return STARTBLOCKMASK | (k); |
136 | #if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_STARTBLOCKVAL) | 120 | } |
137 | xfs_filblks_t startblockval(xfs_fsblock_t x); | 121 | |
138 | #define STARTBLOCKVAL(x) startblockval(x) | 122 | #define STARTBLOCKVAL(x) startblockval(x) |
139 | #else | 123 | static inline xfs_filblks_t startblockval(xfs_fsblock_t x) |
140 | #define STARTBLOCKVAL(x) ((xfs_filblks_t)((x) & ~STARTBLOCKMASK)) | 124 | { |
141 | #endif | 125 | return (xfs_filblks_t)((x) & ~STARTBLOCKMASK); |
126 | } | ||
142 | 127 | ||
143 | /* | 128 | /* |
144 | * Possible extent formats. | 129 | * Possible extent formats. |
@@ -159,14 +144,9 @@ typedef enum { | |||
159 | /* | 144 | /* |
160 | * Extent state and extent format macros. | 145 | * Extent state and extent format macros. |
161 | */ | 146 | */ |
162 | #if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_EXTFMT_INODE ) | 147 | #define XFS_EXTFMT_INODE(x) \ |
163 | xfs_exntfmt_t xfs_extfmt_inode(struct xfs_inode *ip); | 148 | (XFS_SB_VERSION_HASEXTFLGBIT(&((x)->i_mount->m_sb)) ? \ |
164 | #define XFS_EXTFMT_INODE(x) xfs_extfmt_inode(x) | 149 | XFS_EXTFMT_HASSTATE : XFS_EXTFMT_NOSTATE) |
165 | #else | ||
166 | #define XFS_EXTFMT_INODE(x) \ | ||
167 | (XFS_SB_VERSION_HASEXTFLGBIT(&((x)->i_mount->m_sb)) ? \ | ||
168 | XFS_EXTFMT_HASSTATE : XFS_EXTFMT_NOSTATE) | ||
169 | #endif | ||
170 | #define ISUNWRITTEN(x) ((x)->br_state == XFS_EXT_UNWRITTEN) | 150 | #define ISUNWRITTEN(x) ((x)->br_state == XFS_EXT_UNWRITTEN) |
171 | 151 | ||
172 | /* | 152 | /* |
@@ -192,248 +172,110 @@ typedef xfs_dfsbno_t xfs_bmbt_ptr_t, xfs_bmdr_ptr_t; /* btree pointer type */ | |||
192 | /* btree block header type */ | 172 | /* btree block header type */ |
193 | typedef struct xfs_btree_lblock xfs_bmbt_block_t; | 173 | typedef struct xfs_btree_lblock xfs_bmbt_block_t; |
194 | 174 | ||
195 | #if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_BUF_TO_BMBT_BLOCK) | 175 | #define XFS_BUF_TO_BMBT_BLOCK(bp) ((xfs_bmbt_block_t *)XFS_BUF_PTR(bp)) |
196 | xfs_bmbt_block_t *xfs_buf_to_bmbt_block(struct xfs_buf *bp); | ||
197 | #define XFS_BUF_TO_BMBT_BLOCK(bp) xfs_buf_to_bmbt_block(bp) | ||
198 | #else | ||
199 | #define XFS_BUF_TO_BMBT_BLOCK(bp) ((xfs_bmbt_block_t *)(XFS_BUF_PTR(bp))) | ||
200 | #endif | ||
201 | 176 | ||
202 | #if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_BMAP_RBLOCK_DSIZE) | 177 | #define XFS_BMAP_IBLOCK_SIZE(lev,cur) (1 << (cur)->bc_blocklog) |
203 | int xfs_bmap_rblock_dsize(int lev, struct xfs_btree_cur *cur); | 178 | #define XFS_BMAP_RBLOCK_DSIZE(lev,cur) ((cur)->bc_private.b.forksize) |
204 | #define XFS_BMAP_RBLOCK_DSIZE(lev,cur) xfs_bmap_rblock_dsize(lev,cur) | 179 | #define XFS_BMAP_RBLOCK_ISIZE(lev,cur) \ |
205 | #else | ||
206 | #define XFS_BMAP_RBLOCK_DSIZE(lev,cur) ((cur)->bc_private.b.forksize) | ||
207 | #endif | ||
208 | #if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_BMAP_RBLOCK_ISIZE) | ||
209 | int xfs_bmap_rblock_isize(int lev, struct xfs_btree_cur *cur); | ||
210 | #define XFS_BMAP_RBLOCK_ISIZE(lev,cur) xfs_bmap_rblock_isize(lev,cur) | ||
211 | #else | ||
212 | #define XFS_BMAP_RBLOCK_ISIZE(lev,cur) \ | ||
213 | ((int)XFS_IFORK_PTR((cur)->bc_private.b.ip, \ | 180 | ((int)XFS_IFORK_PTR((cur)->bc_private.b.ip, \ |
214 | (cur)->bc_private.b.whichfork)->if_broot_bytes) | 181 | (cur)->bc_private.b.whichfork)->if_broot_bytes) |
215 | #endif | ||
216 | #if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_BMAP_IBLOCK_SIZE) | ||
217 | int xfs_bmap_iblock_size(int lev, struct xfs_btree_cur *cur); | ||
218 | #define XFS_BMAP_IBLOCK_SIZE(lev,cur) xfs_bmap_iblock_size(lev,cur) | ||
219 | #else | ||
220 | #define XFS_BMAP_IBLOCK_SIZE(lev,cur) (1 << (cur)->bc_blocklog) | ||
221 | #endif | ||
222 | 182 | ||
223 | #if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_BMAP_BLOCK_DSIZE) | 183 | #define XFS_BMAP_BLOCK_DSIZE(lev,cur) \ |
224 | int xfs_bmap_block_dsize(int lev, struct xfs_btree_cur *cur); | 184 | (((lev) == (cur)->bc_nlevels - 1 ? \ |
225 | #define XFS_BMAP_BLOCK_DSIZE(lev,cur) xfs_bmap_block_dsize(lev,cur) | 185 | XFS_BMAP_RBLOCK_DSIZE(lev,cur) : XFS_BMAP_IBLOCK_SIZE(lev,cur))) |
226 | #else | 186 | #define XFS_BMAP_BLOCK_ISIZE(lev,cur) \ |
227 | #define XFS_BMAP_BLOCK_DSIZE(lev,cur) \ | 187 | (((lev) == (cur)->bc_nlevels - 1 ? \ |
228 | ((lev) == (cur)->bc_nlevels - 1 ? \ | 188 | XFS_BMAP_RBLOCK_ISIZE(lev,cur) : XFS_BMAP_IBLOCK_SIZE(lev,cur))) |
229 | XFS_BMAP_RBLOCK_DSIZE(lev,cur) : \ | ||
230 | XFS_BMAP_IBLOCK_SIZE(lev,cur)) | ||
231 | #endif | ||
232 | #if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_BMAP_BLOCK_ISIZE) | ||
233 | int xfs_bmap_block_isize(int lev, struct xfs_btree_cur *cur); | ||
234 | #define XFS_BMAP_BLOCK_ISIZE(lev,cur) xfs_bmap_block_isize(lev,cur) | ||
235 | #else | ||
236 | #define XFS_BMAP_BLOCK_ISIZE(lev,cur) \ | ||
237 | ((lev) == (cur)->bc_nlevels - 1 ? \ | ||
238 | XFS_BMAP_RBLOCK_ISIZE(lev,cur) : \ | ||
239 | XFS_BMAP_IBLOCK_SIZE(lev,cur)) | ||
240 | #endif | ||
241 | 189 | ||
242 | #if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_BMAP_BLOCK_DMAXRECS) | ||
243 | int xfs_bmap_block_dmaxrecs(int lev, struct xfs_btree_cur *cur); | ||
244 | #define XFS_BMAP_BLOCK_DMAXRECS(lev,cur) xfs_bmap_block_dmaxrecs(lev,cur) | ||
245 | #else | ||
246 | #define XFS_BMAP_BLOCK_DMAXRECS(lev,cur) \ | 190 | #define XFS_BMAP_BLOCK_DMAXRECS(lev,cur) \ |
247 | ((lev) == (cur)->bc_nlevels - 1 ? \ | 191 | (((lev) == (cur)->bc_nlevels - 1 ? \ |
248 | XFS_BTREE_BLOCK_MAXRECS(XFS_BMAP_RBLOCK_DSIZE(lev,cur), \ | 192 | XFS_BTREE_BLOCK_MAXRECS(XFS_BMAP_RBLOCK_DSIZE(lev,cur), \ |
249 | xfs_bmdr, (lev) == 0) : \ | 193 | xfs_bmdr, (lev) == 0) : \ |
250 | ((cur)->bc_mp->m_bmap_dmxr[(lev) != 0])) | 194 | ((cur)->bc_mp->m_bmap_dmxr[(lev) != 0]))) |
251 | #endif | ||
252 | #if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_BMAP_BLOCK_IMAXRECS) | ||
253 | int xfs_bmap_block_imaxrecs(int lev, struct xfs_btree_cur *cur); | ||
254 | #define XFS_BMAP_BLOCK_IMAXRECS(lev,cur) xfs_bmap_block_imaxrecs(lev,cur) | ||
255 | #else | ||
256 | #define XFS_BMAP_BLOCK_IMAXRECS(lev,cur) \ | 195 | #define XFS_BMAP_BLOCK_IMAXRECS(lev,cur) \ |
257 | ((lev) == (cur)->bc_nlevels - 1 ? \ | 196 | (((lev) == (cur)->bc_nlevels - 1 ? \ |
258 | XFS_BTREE_BLOCK_MAXRECS(XFS_BMAP_RBLOCK_ISIZE(lev,cur), \ | 197 | XFS_BTREE_BLOCK_MAXRECS(XFS_BMAP_RBLOCK_ISIZE(lev,cur),\ |
259 | xfs_bmbt, (lev) == 0) : \ | 198 | xfs_bmbt, (lev) == 0) : \ |
260 | ((cur)->bc_mp->m_bmap_dmxr[(lev) != 0])) | 199 | ((cur)->bc_mp->m_bmap_dmxr[(lev) != 0]))) |
261 | #endif | ||
262 | 200 | ||
263 | #if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_BMAP_BLOCK_DMINRECS) | ||
264 | int xfs_bmap_block_dminrecs(int lev, struct xfs_btree_cur *cur); | ||
265 | #define XFS_BMAP_BLOCK_DMINRECS(lev,cur) xfs_bmap_block_dminrecs(lev,cur) | ||
266 | #else | ||
267 | #define XFS_BMAP_BLOCK_DMINRECS(lev,cur) \ | 201 | #define XFS_BMAP_BLOCK_DMINRECS(lev,cur) \ |
268 | ((lev) == (cur)->bc_nlevels - 1 ? \ | 202 | (((lev) == (cur)->bc_nlevels - 1 ? \ |
269 | XFS_BTREE_BLOCK_MINRECS(XFS_BMAP_RBLOCK_DSIZE(lev,cur), \ | 203 | XFS_BTREE_BLOCK_MINRECS(XFS_BMAP_RBLOCK_DSIZE(lev,cur),\ |
270 | xfs_bmdr, (lev) == 0) : \ | 204 | xfs_bmdr, (lev) == 0) : \ |
271 | ((cur)->bc_mp->m_bmap_dmnr[(lev) != 0])) | 205 | ((cur)->bc_mp->m_bmap_dmnr[(lev) != 0]))) |
272 | #endif | ||
273 | #if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_BMAP_BLOCK_IMINRECS) | ||
274 | int xfs_bmap_block_iminrecs(int lev, struct xfs_btree_cur *cur); | ||
275 | #define XFS_BMAP_BLOCK_IMINRECS(lev,cur) xfs_bmap_block_iminrecs(lev,cur) | ||
276 | #else | ||
277 | #define XFS_BMAP_BLOCK_IMINRECS(lev,cur) \ | 206 | #define XFS_BMAP_BLOCK_IMINRECS(lev,cur) \ |
278 | ((lev) == (cur)->bc_nlevels - 1 ? \ | 207 | (((lev) == (cur)->bc_nlevels - 1 ? \ |
279 | XFS_BTREE_BLOCK_MINRECS(XFS_BMAP_RBLOCK_ISIZE(lev,cur), \ | 208 | XFS_BTREE_BLOCK_MINRECS(XFS_BMAP_RBLOCK_ISIZE(lev,cur),\ |
280 | xfs_bmbt, (lev) == 0) : \ | 209 | xfs_bmbt, (lev) == 0) : \ |
281 | ((cur)->bc_mp->m_bmap_dmnr[(lev) != 0])) | 210 | ((cur)->bc_mp->m_bmap_dmnr[(lev) != 0]))) |
282 | #endif | 211 | |
283 | 212 | #define XFS_BMAP_REC_DADDR(bb,i,cur) \ | |
284 | #if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_BMAP_REC_DADDR) | 213 | (XFS_BTREE_REC_ADDR(XFS_BMAP_BLOCK_DSIZE( \ |
285 | xfs_bmbt_rec_t * | 214 | be16_to_cpu((bb)->bb_level), cur), \ |
286 | xfs_bmap_rec_daddr(xfs_bmbt_block_t *bb, int i, struct xfs_btree_cur *cur); | 215 | xfs_bmbt, bb, i, XFS_BMAP_BLOCK_DMAXRECS( \ |
287 | #define XFS_BMAP_REC_DADDR(bb,i,cur) xfs_bmap_rec_daddr(bb,i,cur) | 216 | be16_to_cpu((bb)->bb_level), cur))) |
288 | #else | 217 | #define XFS_BMAP_REC_IADDR(bb,i,cur) \ |
289 | #define XFS_BMAP_REC_DADDR(bb,i,cur) \ | 218 | (XFS_BTREE_REC_ADDR(XFS_BMAP_BLOCK_ISIZE( \ |
290 | XFS_BTREE_REC_ADDR(XFS_BMAP_BLOCK_DSIZE( \ | 219 | be16_to_cpu((bb)->bb_level), cur), \ |
291 | INT_GET((bb)->bb_level, ARCH_CONVERT), cur), \ | 220 | xfs_bmbt, bb, i, XFS_BMAP_BLOCK_IMAXRECS( \ |
292 | xfs_bmbt, bb, i, XFS_BMAP_BLOCK_DMAXRECS( \ | 221 | be16_to_cpu((bb)->bb_level), cur))) |
293 | INT_GET((bb)->bb_level, ARCH_CONVERT), cur)) | 222 | |
294 | #endif | 223 | #define XFS_BMAP_KEY_DADDR(bb,i,cur) \ |
295 | #if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_BMAP_REC_IADDR) | 224 | (XFS_BTREE_KEY_ADDR(XFS_BMAP_BLOCK_DSIZE( \ |
296 | xfs_bmbt_rec_t * | 225 | be16_to_cpu((bb)->bb_level), cur), \ |
297 | xfs_bmap_rec_iaddr(xfs_bmbt_block_t *bb, int i, struct xfs_btree_cur *cur); | 226 | xfs_bmbt, bb, i, XFS_BMAP_BLOCK_DMAXRECS( \ |
298 | #define XFS_BMAP_REC_IADDR(bb,i,cur) xfs_bmap_rec_iaddr(bb,i,cur) | 227 | be16_to_cpu((bb)->bb_level), cur))) |
299 | #else | 228 | #define XFS_BMAP_KEY_IADDR(bb,i,cur) \ |
300 | #define XFS_BMAP_REC_IADDR(bb,i,cur) \ | 229 | (XFS_BTREE_KEY_ADDR(XFS_BMAP_BLOCK_ISIZE( \ |
301 | XFS_BTREE_REC_ADDR(XFS_BMAP_BLOCK_ISIZE( \ | 230 | be16_to_cpu((bb)->bb_level), cur), \ |
302 | INT_GET((bb)->bb_level, ARCH_CONVERT), cur), \ | 231 | xfs_bmbt, bb, i, XFS_BMAP_BLOCK_IMAXRECS( \ |
303 | xfs_bmbt, bb, i, XFS_BMAP_BLOCK_IMAXRECS( \ | 232 | be16_to_cpu((bb)->bb_level), cur))) |
304 | INT_GET((bb)->bb_level, ARCH_CONVERT), cur)) | 233 | |
305 | #endif | 234 | #define XFS_BMAP_PTR_DADDR(bb,i,cur) \ |
306 | 235 | (XFS_BTREE_PTR_ADDR(XFS_BMAP_BLOCK_DSIZE( \ | |
307 | #if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_BMAP_KEY_DADDR) | 236 | be16_to_cpu((bb)->bb_level), cur), \ |
308 | xfs_bmbt_key_t * | 237 | xfs_bmbt, bb, i, XFS_BMAP_BLOCK_DMAXRECS( \ |
309 | xfs_bmap_key_daddr(xfs_bmbt_block_t *bb, int i, struct xfs_btree_cur *cur); | 238 | be16_to_cpu((bb)->bb_level), cur))) |
310 | #define XFS_BMAP_KEY_DADDR(bb,i,cur) xfs_bmap_key_daddr(bb,i,cur) | 239 | #define XFS_BMAP_PTR_IADDR(bb,i,cur) \ |
311 | #else | 240 | (XFS_BTREE_PTR_ADDR(XFS_BMAP_BLOCK_ISIZE( \ |
312 | #define XFS_BMAP_KEY_DADDR(bb,i,cur) \ | 241 | be16_to_cpu((bb)->bb_level), cur), \ |
313 | XFS_BTREE_KEY_ADDR(XFS_BMAP_BLOCK_DSIZE( \ | 242 | xfs_bmbt, bb, i, XFS_BMAP_BLOCK_IMAXRECS( \ |
314 | INT_GET((bb)->bb_level, ARCH_CONVERT), cur), \ | 243 | be16_to_cpu((bb)->bb_level), cur))) |
315 | xfs_bmbt, bb, i, XFS_BMAP_BLOCK_DMAXRECS( \ | ||
316 | INT_GET((bb)->bb_level, ARCH_CONVERT), cur)) | ||
317 | #endif | ||
318 | #if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_BMAP_KEY_IADDR) | ||
319 | xfs_bmbt_key_t * | ||
320 | xfs_bmap_key_iaddr(xfs_bmbt_block_t *bb, int i, struct xfs_btree_cur *cur); | ||
321 | #define XFS_BMAP_KEY_IADDR(bb,i,cur) xfs_bmap_key_iaddr(bb,i,cur) | ||
322 | #else | ||
323 | #define XFS_BMAP_KEY_IADDR(bb,i,cur) \ | ||
324 | XFS_BTREE_KEY_ADDR(XFS_BMAP_BLOCK_ISIZE( \ | ||
325 | INT_GET((bb)->bb_level, ARCH_CONVERT), cur), \ | ||
326 | xfs_bmbt, bb, i, XFS_BMAP_BLOCK_IMAXRECS( \ | ||
327 | INT_GET((bb)->bb_level, ARCH_CONVERT), cur)) | ||
328 | #endif | ||
329 | |||
330 | #if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_BMAP_PTR_DADDR) | ||
331 | xfs_bmbt_ptr_t * | ||
332 | xfs_bmap_ptr_daddr(xfs_bmbt_block_t *bb, int i, struct xfs_btree_cur *cur); | ||
333 | #define XFS_BMAP_PTR_DADDR(bb,i,cur) xfs_bmap_ptr_daddr(bb,i,cur) | ||
334 | #else | ||
335 | #define XFS_BMAP_PTR_DADDR(bb,i,cur) \ | ||
336 | XFS_BTREE_PTR_ADDR(XFS_BMAP_BLOCK_DSIZE( \ | ||
337 | INT_GET((bb)->bb_level, ARCH_CONVERT), cur), \ | ||
338 | xfs_bmbt, bb, i, XFS_BMAP_BLOCK_DMAXRECS( \ | ||
339 | INT_GET((bb)->bb_level, ARCH_CONVERT), cur)) | ||
340 | #endif | ||
341 | #if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_BMAP_PTR_IADDR) | ||
342 | xfs_bmbt_ptr_t * | ||
343 | xfs_bmap_ptr_iaddr(xfs_bmbt_block_t *bb, int i, struct xfs_btree_cur *cur); | ||
344 | #define XFS_BMAP_PTR_IADDR(bb,i,cur) xfs_bmap_ptr_iaddr(bb,i,cur) | ||
345 | #else | ||
346 | #define XFS_BMAP_PTR_IADDR(bb,i,cur) \ | ||
347 | XFS_BTREE_PTR_ADDR(XFS_BMAP_BLOCK_ISIZE( \ | ||
348 | INT_GET((bb)->bb_level, ARCH_CONVERT), cur), \ | ||
349 | xfs_bmbt, bb, i, XFS_BMAP_BLOCK_IMAXRECS( \ | ||
350 | INT_GET((bb)->bb_level, ARCH_CONVERT), cur)) | ||
351 | #endif | ||
352 | 244 | ||
353 | /* | 245 | /* |
354 | * These are to be used when we know the size of the block and | 246 | * These are to be used when we know the size of the block and |
355 | * we don't have a cursor. | 247 | * we don't have a cursor. |
356 | */ | 248 | */ |
357 | #if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_BMAP_BROOT_REC_ADDR) | ||
358 | xfs_bmbt_rec_t *xfs_bmap_broot_rec_addr(xfs_bmbt_block_t *bb, int i, int sz); | ||
359 | #define XFS_BMAP_BROOT_REC_ADDR(bb,i,sz) xfs_bmap_broot_rec_addr(bb,i,sz) | ||
360 | #else | ||
361 | #define XFS_BMAP_BROOT_REC_ADDR(bb,i,sz) \ | 249 | #define XFS_BMAP_BROOT_REC_ADDR(bb,i,sz) \ |
362 | XFS_BTREE_REC_ADDR(sz,xfs_bmbt,bb,i,XFS_BMAP_BROOT_MAXRECS(sz)) | 250 | (XFS_BTREE_REC_ADDR(sz,xfs_bmbt,bb,i,XFS_BMAP_BROOT_MAXRECS(sz))) |
363 | #endif | ||
364 | #if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_BMAP_BROOT_KEY_ADDR) | ||
365 | xfs_bmbt_key_t *xfs_bmap_broot_key_addr(xfs_bmbt_block_t *bb, int i, int sz); | ||
366 | #define XFS_BMAP_BROOT_KEY_ADDR(bb,i,sz) xfs_bmap_broot_key_addr(bb,i,sz) | ||
367 | #else | ||
368 | #define XFS_BMAP_BROOT_KEY_ADDR(bb,i,sz) \ | 251 | #define XFS_BMAP_BROOT_KEY_ADDR(bb,i,sz) \ |
369 | XFS_BTREE_KEY_ADDR(sz,xfs_bmbt,bb,i,XFS_BMAP_BROOT_MAXRECS(sz)) | 252 | (XFS_BTREE_KEY_ADDR(sz,xfs_bmbt,bb,i,XFS_BMAP_BROOT_MAXRECS(sz))) |
370 | #endif | ||
371 | #if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_BMAP_BROOT_PTR_ADDR) | ||
372 | xfs_bmbt_ptr_t *xfs_bmap_broot_ptr_addr(xfs_bmbt_block_t *bb, int i, int sz); | ||
373 | #define XFS_BMAP_BROOT_PTR_ADDR(bb,i,sz) xfs_bmap_broot_ptr_addr(bb,i,sz) | ||
374 | #else | ||
375 | #define XFS_BMAP_BROOT_PTR_ADDR(bb,i,sz) \ | 253 | #define XFS_BMAP_BROOT_PTR_ADDR(bb,i,sz) \ |
376 | XFS_BTREE_PTR_ADDR(sz,xfs_bmbt,bb,i,XFS_BMAP_BROOT_MAXRECS(sz)) | 254 | (XFS_BTREE_PTR_ADDR(sz,xfs_bmbt,bb,i,XFS_BMAP_BROOT_MAXRECS(sz))) |
377 | #endif | 255 | |
256 | #define XFS_BMAP_BROOT_NUMRECS(bb) be16_to_cpu((bb)->bb_numrecs) | ||
257 | #define XFS_BMAP_BROOT_MAXRECS(sz) XFS_BTREE_BLOCK_MAXRECS(sz,xfs_bmbt,0) | ||
378 | 258 | ||
379 | #if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_BMAP_BROOT_NUMRECS) | ||
380 | int xfs_bmap_broot_numrecs(xfs_bmdr_block_t *bb); | ||
381 | #define XFS_BMAP_BROOT_NUMRECS(bb) xfs_bmap_broot_numrecs(bb) | ||
382 | #else | ||
383 | #define XFS_BMAP_BROOT_NUMRECS(bb) (INT_GET((bb)->bb_numrecs, ARCH_CONVERT)) | ||
384 | #endif | ||
385 | #if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_BMAP_BROOT_MAXRECS) | ||
386 | int xfs_bmap_broot_maxrecs(int sz); | ||
387 | #define XFS_BMAP_BROOT_MAXRECS(sz) xfs_bmap_broot_maxrecs(sz) | ||
388 | #else | ||
389 | #define XFS_BMAP_BROOT_MAXRECS(sz) XFS_BTREE_BLOCK_MAXRECS(sz,xfs_bmbt,0) | ||
390 | #endif | ||
391 | #if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_BMAP_BROOT_SPACE_CALC) | ||
392 | int xfs_bmap_broot_space_calc(int nrecs); | ||
393 | #define XFS_BMAP_BROOT_SPACE_CALC(nrecs) xfs_bmap_broot_space_calc(nrecs) | ||
394 | #else | ||
395 | #define XFS_BMAP_BROOT_SPACE_CALC(nrecs) \ | 259 | #define XFS_BMAP_BROOT_SPACE_CALC(nrecs) \ |
396 | ((int)(sizeof(xfs_bmbt_block_t) + \ | 260 | (int)(sizeof(xfs_bmbt_block_t) + \ |
397 | ((nrecs) * (sizeof(xfs_bmbt_key_t) + sizeof(xfs_bmbt_ptr_t))))) | 261 | ((nrecs) * (sizeof(xfs_bmbt_key_t) + sizeof(xfs_bmbt_ptr_t)))) |
398 | #endif | 262 | |
399 | #if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_BMAP_BROOT_SPACE) | ||
400 | int xfs_bmap_broot_space(xfs_bmdr_block_t *bb); | ||
401 | #define XFS_BMAP_BROOT_SPACE(bb) xfs_bmap_broot_space(bb) | ||
402 | #else | ||
403 | #define XFS_BMAP_BROOT_SPACE(bb) \ | 263 | #define XFS_BMAP_BROOT_SPACE(bb) \ |
404 | XFS_BMAP_BROOT_SPACE_CALC(INT_GET((bb)->bb_numrecs, ARCH_CONVERT)) | 264 | (XFS_BMAP_BROOT_SPACE_CALC(be16_to_cpu((bb)->bb_numrecs))) |
405 | #endif | 265 | #define XFS_BMDR_SPACE_CALC(nrecs) \ |
406 | #if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_BMDR_SPACE_CALC) | 266 | (int)(sizeof(xfs_bmdr_block_t) + \ |
407 | int xfs_bmdr_space_calc(int nrecs); | 267 | ((nrecs) * (sizeof(xfs_bmbt_key_t) + sizeof(xfs_bmbt_ptr_t)))) |
408 | #define XFS_BMDR_SPACE_CALC(nrecs) xfs_bmdr_space_calc(nrecs) | ||
409 | #else | ||
410 | #define XFS_BMDR_SPACE_CALC(nrecs) \ | ||
411 | ((int)(sizeof(xfs_bmdr_block_t) + \ | ||
412 | ((nrecs) * (sizeof(xfs_bmbt_key_t) + sizeof(xfs_bmbt_ptr_t))))) | ||
413 | #endif | ||
414 | 268 | ||
415 | /* | 269 | /* |
416 | * Maximum number of bmap btree levels. | 270 | * Maximum number of bmap btree levels. |
417 | */ | 271 | */ |
418 | #if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_BM_MAXLEVELS) | 272 | #define XFS_BM_MAXLEVELS(mp,w) ((mp)->m_bm_maxlevels[(w)]) |
419 | int xfs_bm_maxlevels(struct xfs_mount *mp, int w); | ||
420 | #define XFS_BM_MAXLEVELS(mp,w) xfs_bm_maxlevels(mp,w) | ||
421 | #else | ||
422 | #define XFS_BM_MAXLEVELS(mp,w) ((mp)->m_bm_maxlevels[w]) | ||
423 | #endif | ||
424 | 273 | ||
425 | #if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_BMAP_SANITY_CHECK) | 274 | #define XFS_BMAP_SANITY_CHECK(mp,bb,level) \ |
426 | int xfs_bmap_sanity_check(struct xfs_mount *mp, xfs_bmbt_block_t *bb, | 275 | (be32_to_cpu((bb)->bb_magic) == XFS_BMAP_MAGIC && \ |
427 | int level); | 276 | be16_to_cpu((bb)->bb_level) == level && \ |
428 | #define XFS_BMAP_SANITY_CHECK(mp,bb,level) \ | 277 | be16_to_cpu((bb)->bb_numrecs) > 0 && \ |
429 | xfs_bmap_sanity_check(mp,bb,level) | 278 | be16_to_cpu((bb)->bb_numrecs) <= (mp)->m_bmap_dmxr[(level) != 0]) |
430 | #else | ||
431 | #define XFS_BMAP_SANITY_CHECK(mp,bb,level) \ | ||
432 | (INT_GET((bb)->bb_magic, ARCH_CONVERT) == XFS_BMAP_MAGIC && \ | ||
433 | INT_GET((bb)->bb_level, ARCH_CONVERT) == level && \ | ||
434 | INT_GET((bb)->bb_numrecs, ARCH_CONVERT) > 0 && \ | ||
435 | INT_GET((bb)->bb_numrecs, ARCH_CONVERT) <= (mp)->m_bmap_dmxr[(level) != 0]) | ||
436 | #endif | ||
437 | 279 | ||
438 | 280 | ||
439 | #ifdef __KERNEL__ | 281 | #ifdef __KERNEL__ |
@@ -459,234 +301,84 @@ extern ktrace_t *xfs_bmbt_trace_buf; | |||
459 | /* | 301 | /* |
460 | * Prototypes for xfs_bmap.c to call. | 302 | * Prototypes for xfs_bmap.c to call. |
461 | */ | 303 | */ |
462 | 304 | extern void xfs_bmdr_to_bmbt(xfs_bmdr_block_t *, int, xfs_bmbt_block_t *, int); | |
463 | void | 305 | extern int xfs_bmbt_decrement(struct xfs_btree_cur *, int, int *); |
464 | xfs_bmdr_to_bmbt( | 306 | extern int xfs_bmbt_delete(struct xfs_btree_cur *, int *); |
465 | xfs_bmdr_block_t *, | 307 | extern void xfs_bmbt_get_all(xfs_bmbt_rec_t *r, xfs_bmbt_irec_t *s); |
466 | int, | 308 | extern xfs_bmbt_block_t *xfs_bmbt_get_block(struct xfs_btree_cur *cur, |
467 | xfs_bmbt_block_t *, | 309 | int, struct xfs_buf **bpp); |
468 | int); | 310 | extern xfs_filblks_t xfs_bmbt_get_blockcount(xfs_bmbt_rec_t *r); |
469 | 311 | extern xfs_fsblock_t xfs_bmbt_get_startblock(xfs_bmbt_rec_t *r); | |
470 | int | 312 | extern xfs_fileoff_t xfs_bmbt_get_startoff(xfs_bmbt_rec_t *r); |
471 | xfs_bmbt_decrement( | 313 | extern xfs_exntst_t xfs_bmbt_get_state(xfs_bmbt_rec_t *r); |
472 | struct xfs_btree_cur *, | ||
473 | int, | ||
474 | int *); | ||
475 | |||
476 | int | ||
477 | xfs_bmbt_delete( | ||
478 | struct xfs_btree_cur *, | ||
479 | int *); | ||
480 | |||
481 | void | ||
482 | xfs_bmbt_get_all( | ||
483 | xfs_bmbt_rec_t *r, | ||
484 | xfs_bmbt_irec_t *s); | ||
485 | |||
486 | xfs_bmbt_block_t * | ||
487 | xfs_bmbt_get_block( | ||
488 | struct xfs_btree_cur *cur, | ||
489 | int level, | ||
490 | struct xfs_buf **bpp); | ||
491 | |||
492 | xfs_filblks_t | ||
493 | xfs_bmbt_get_blockcount( | ||
494 | xfs_bmbt_rec_t *r); | ||
495 | |||
496 | xfs_fsblock_t | ||
497 | xfs_bmbt_get_startblock( | ||
498 | xfs_bmbt_rec_t *r); | ||
499 | |||
500 | xfs_fileoff_t | ||
501 | xfs_bmbt_get_startoff( | ||
502 | xfs_bmbt_rec_t *r); | ||
503 | |||
504 | xfs_exntst_t | ||
505 | xfs_bmbt_get_state( | ||
506 | xfs_bmbt_rec_t *r); | ||
507 | 314 | ||
508 | #ifndef XFS_NATIVE_HOST | 315 | #ifndef XFS_NATIVE_HOST |
509 | void | 316 | extern void xfs_bmbt_disk_get_all(xfs_bmbt_rec_t *r, xfs_bmbt_irec_t *s); |
510 | xfs_bmbt_disk_get_all( | 317 | extern xfs_exntst_t xfs_bmbt_disk_get_state(xfs_bmbt_rec_t *r); |
511 | xfs_bmbt_rec_t *r, | 318 | extern xfs_filblks_t xfs_bmbt_disk_get_blockcount(xfs_bmbt_rec_t *r); |
512 | xfs_bmbt_irec_t *s); | 319 | extern xfs_fsblock_t xfs_bmbt_disk_get_startblock(xfs_bmbt_rec_t *r); |
513 | 320 | extern xfs_fileoff_t xfs_bmbt_disk_get_startoff(xfs_bmbt_rec_t *r); | |
514 | xfs_exntst_t | 321 | #else |
515 | xfs_bmbt_disk_get_state( | 322 | #define xfs_bmbt_disk_get_all(r, s) xfs_bmbt_get_all(r, s) |
516 | xfs_bmbt_rec_t *r); | 323 | #define xfs_bmbt_disk_get_state(r) xfs_bmbt_get_state(r) |
517 | 324 | #define xfs_bmbt_disk_get_blockcount(r) xfs_bmbt_get_blockcount(r) | |
518 | xfs_filblks_t | 325 | #define xfs_bmbt_disk_get_startblock(r) xfs_bmbt_get_blockcount(r) |
519 | xfs_bmbt_disk_get_blockcount( | 326 | #define xfs_bmbt_disk_get_startoff(r) xfs_bmbt_get_startoff(r) |
520 | xfs_bmbt_rec_t *r); | ||
521 | |||
522 | xfs_fsblock_t | ||
523 | xfs_bmbt_disk_get_startblock( | ||
524 | xfs_bmbt_rec_t *r); | ||
525 | |||
526 | xfs_fileoff_t | ||
527 | xfs_bmbt_disk_get_startoff( | ||
528 | xfs_bmbt_rec_t *r); | ||
529 | |||
530 | #else | ||
531 | #define xfs_bmbt_disk_get_all(r, s) \ | ||
532 | xfs_bmbt_get_all(r, s) | ||
533 | #define xfs_bmbt_disk_get_state(r) \ | ||
534 | xfs_bmbt_get_state(r) | ||
535 | #define xfs_bmbt_disk_get_blockcount(r) \ | ||
536 | xfs_bmbt_get_blockcount(r) | ||
537 | #define xfs_bmbt_disk_get_startblock(r) \ | ||
538 | xfs_bmbt_get_blockcount(r) | ||
539 | #define xfs_bmbt_disk_get_startoff(r) \ | ||
540 | xfs_bmbt_get_startoff(r) | ||
541 | #endif /* XFS_NATIVE_HOST */ | 327 | #endif /* XFS_NATIVE_HOST */ |
542 | 328 | ||
543 | int | 329 | extern int xfs_bmbt_increment(struct xfs_btree_cur *, int, int *); |
544 | xfs_bmbt_increment( | 330 | extern int xfs_bmbt_insert(struct xfs_btree_cur *, int *); |
545 | struct xfs_btree_cur *, | 331 | extern void xfs_bmbt_log_block(struct xfs_btree_cur *, struct xfs_buf *, int); |
546 | int, | 332 | extern void xfs_bmbt_log_recs(struct xfs_btree_cur *, struct xfs_buf *, int, |
547 | int *); | 333 | int); |
548 | 334 | extern int xfs_bmbt_lookup_eq(struct xfs_btree_cur *, xfs_fileoff_t, | |
549 | int | 335 | xfs_fsblock_t, xfs_filblks_t, int *); |
550 | xfs_bmbt_insert( | 336 | extern int xfs_bmbt_lookup_ge(struct xfs_btree_cur *, xfs_fileoff_t, |
551 | struct xfs_btree_cur *, | 337 | xfs_fsblock_t, xfs_filblks_t, int *); |
552 | int *); | ||
553 | |||
554 | void | ||
555 | xfs_bmbt_log_block( | ||
556 | struct xfs_btree_cur *, | ||
557 | struct xfs_buf *, | ||
558 | int); | ||
559 | |||
560 | void | ||
561 | xfs_bmbt_log_recs( | ||
562 | struct xfs_btree_cur *, | ||
563 | struct xfs_buf *, | ||
564 | int, | ||
565 | int); | ||
566 | |||
567 | int | ||
568 | xfs_bmbt_lookup_eq( | ||
569 | struct xfs_btree_cur *, | ||
570 | xfs_fileoff_t, | ||
571 | xfs_fsblock_t, | ||
572 | xfs_filblks_t, | ||
573 | int *); | ||
574 | |||
575 | int | ||
576 | xfs_bmbt_lookup_ge( | ||
577 | struct xfs_btree_cur *, | ||
578 | xfs_fileoff_t, | ||
579 | xfs_fsblock_t, | ||
580 | xfs_filblks_t, | ||
581 | int *); | ||
582 | 338 | ||
583 | /* | 339 | /* |
584 | * Give the bmap btree a new root block. Copy the old broot contents | 340 | * Give the bmap btree a new root block. Copy the old broot contents |
585 | * down into a real block and make the broot point to it. | 341 | * down into a real block and make the broot point to it. |
586 | */ | 342 | */ |
587 | int /* error */ | 343 | extern int xfs_bmbt_newroot(struct xfs_btree_cur *cur, int *lflags, int *stat); |
588 | xfs_bmbt_newroot( | 344 | |
589 | struct xfs_btree_cur *cur, /* btree cursor */ | 345 | extern void xfs_bmbt_set_all(xfs_bmbt_rec_t *r, xfs_bmbt_irec_t *s); |
590 | int *logflags, /* logging flags for inode */ | 346 | extern void xfs_bmbt_set_allf(xfs_bmbt_rec_t *r, xfs_fileoff_t o, |
591 | int *stat); /* return status - 0 fail */ | 347 | xfs_fsblock_t b, xfs_filblks_t c, xfs_exntst_t v); |
592 | 348 | extern void xfs_bmbt_set_blockcount(xfs_bmbt_rec_t *r, xfs_filblks_t v); | |
593 | void | 349 | extern void xfs_bmbt_set_startblock(xfs_bmbt_rec_t *r, xfs_fsblock_t v); |
594 | xfs_bmbt_set_all( | 350 | extern void xfs_bmbt_set_startoff(xfs_bmbt_rec_t *r, xfs_fileoff_t v); |
595 | xfs_bmbt_rec_t *r, | 351 | extern void xfs_bmbt_set_state(xfs_bmbt_rec_t *r, xfs_exntst_t v); |
596 | xfs_bmbt_irec_t *s); | ||
597 | |||
598 | void | ||
599 | xfs_bmbt_set_allf( | ||
600 | xfs_bmbt_rec_t *r, | ||
601 | xfs_fileoff_t o, | ||
602 | xfs_fsblock_t b, | ||
603 | xfs_filblks_t c, | ||
604 | xfs_exntst_t v); | ||
605 | |||
606 | void | ||
607 | xfs_bmbt_set_blockcount( | ||
608 | xfs_bmbt_rec_t *r, | ||
609 | xfs_filblks_t v); | ||
610 | |||
611 | void | ||
612 | xfs_bmbt_set_startblock( | ||
613 | xfs_bmbt_rec_t *r, | ||
614 | xfs_fsblock_t v); | ||
615 | |||
616 | void | ||
617 | xfs_bmbt_set_startoff( | ||
618 | xfs_bmbt_rec_t *r, | ||
619 | xfs_fileoff_t v); | ||
620 | |||
621 | void | ||
622 | xfs_bmbt_set_state( | ||
623 | xfs_bmbt_rec_t *r, | ||
624 | xfs_exntst_t v); | ||
625 | 352 | ||
626 | #ifndef XFS_NATIVE_HOST | 353 | #ifndef XFS_NATIVE_HOST |
627 | void | 354 | extern void xfs_bmbt_disk_set_all(xfs_bmbt_rec_t *r, xfs_bmbt_irec_t *s); |
628 | xfs_bmbt_disk_set_all( | 355 | extern void xfs_bmbt_disk_set_allf(xfs_bmbt_rec_t *r, xfs_fileoff_t o, |
629 | xfs_bmbt_rec_t *r, | 356 | xfs_fsblock_t b, xfs_filblks_t c, xfs_exntst_t v); |
630 | xfs_bmbt_irec_t *s); | ||
631 | |||
632 | void | ||
633 | xfs_bmbt_disk_set_allf( | ||
634 | xfs_bmbt_rec_t *r, | ||
635 | xfs_fileoff_t o, | ||
636 | xfs_fsblock_t b, | ||
637 | xfs_filblks_t c, | ||
638 | xfs_exntst_t v); | ||
639 | #else | 357 | #else |
640 | #define xfs_bmbt_disk_set_all(r, s) \ | 358 | #define xfs_bmbt_disk_set_all(r, s) xfs_bmbt_set_all(r, s) |
641 | xfs_bmbt_set_all(r, s) | 359 | #define xfs_bmbt_disk_set_allf(r, o, b, c, v) xfs_bmbt_set_allf(r, o, b, c, v) |
642 | #define xfs_bmbt_disk_set_allf(r, o, b, c, v) \ | ||
643 | xfs_bmbt_set_allf(r, o, b, c, v) | ||
644 | #endif /* XFS_NATIVE_HOST */ | 360 | #endif /* XFS_NATIVE_HOST */ |
645 | 361 | ||
646 | void | 362 | extern void xfs_bmbt_to_bmdr(xfs_bmbt_block_t *, int, xfs_bmdr_block_t *, int); |
647 | xfs_bmbt_to_bmdr( | 363 | extern int xfs_bmbt_update(struct xfs_btree_cur *, xfs_fileoff_t, |
648 | xfs_bmbt_block_t *, | 364 | xfs_fsblock_t, xfs_filblks_t, xfs_exntst_t); |
649 | int, | ||
650 | xfs_bmdr_block_t *, | ||
651 | int); | ||
652 | |||
653 | int | ||
654 | xfs_bmbt_update( | ||
655 | struct xfs_btree_cur *, | ||
656 | xfs_fileoff_t, | ||
657 | xfs_fsblock_t, | ||
658 | xfs_filblks_t, | ||
659 | xfs_exntst_t); | ||
660 | 365 | ||
661 | #ifdef DEBUG | 366 | #ifdef DEBUG |
662 | /* | 367 | /* |
663 | * Get the data from the pointed-to record. | 368 | * Get the data from the pointed-to record. |
664 | */ | 369 | */ |
665 | int | 370 | extern int xfs_bmbt_get_rec(struct xfs_btree_cur *, xfs_fileoff_t *, |
666 | xfs_bmbt_get_rec( | 371 | xfs_fsblock_t *, xfs_filblks_t *, |
667 | struct xfs_btree_cur *, | 372 | xfs_exntst_t *, int *); |
668 | xfs_fileoff_t *, | ||
669 | xfs_fsblock_t *, | ||
670 | xfs_filblks_t *, | ||
671 | xfs_exntst_t *, | ||
672 | int *); | ||
673 | #endif | 373 | #endif |
674 | 374 | ||
675 | |||
676 | /* | 375 | /* |
677 | * Search an extent list for the extent which includes block | 376 | * Search an extent list for the extent which includes block |
678 | * bno. | 377 | * bno. |
679 | */ | 378 | */ |
680 | xfs_bmbt_rec_t * | 379 | xfs_bmbt_rec_t *xfs_bmap_do_search_extents(xfs_bmbt_rec_t *, |
681 | xfs_bmap_do_search_extents( | 380 | xfs_extnum_t, xfs_extnum_t, xfs_fileoff_t, int *, |
682 | xfs_bmbt_rec_t *, | 381 | xfs_extnum_t *, xfs_bmbt_irec_t *, xfs_bmbt_irec_t *); |
683 | xfs_extnum_t, | ||
684 | xfs_extnum_t, | ||
685 | xfs_fileoff_t, | ||
686 | int *, | ||
687 | xfs_extnum_t *, | ||
688 | xfs_bmbt_irec_t *, | ||
689 | xfs_bmbt_irec_t *); | ||
690 | 382 | ||
691 | #endif /* __KERNEL__ */ | 383 | #endif /* __KERNEL__ */ |
692 | 384 | ||
diff --git a/fs/xfs/xfs_btree.c b/fs/xfs/xfs_btree.c index 0cc63d657a14..52d5d095fc35 100644 --- a/fs/xfs/xfs_btree.c +++ b/fs/xfs/xfs_btree.c | |||
@@ -1,45 +1,26 @@ | |||
1 | /* | 1 | /* |
2 | * Copyright (c) 2000-2002 Silicon Graphics, Inc. All Rights Reserved. | 2 | * Copyright (c) 2000-2002,2005 Silicon Graphics, Inc. |
3 | * All Rights Reserved. | ||
3 | * | 4 | * |
4 | * This program is free software; you can redistribute it and/or modify it | 5 | * This program is free software; you can redistribute it and/or |
5 | * under the terms of version 2 of the GNU General Public License as | 6 | * modify it under the terms of the GNU General Public License as |
6 | * published by the Free Software Foundation. | 7 | * published by the Free Software Foundation. |
7 | * | 8 | * |
8 | * This program is distributed in the hope that it would be useful, but | 9 | * This program is distributed in the hope that it would be useful, |
9 | * WITHOUT ANY WARRANTY; without even the implied warranty of | 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
12 | * GNU General Public License for more details. | ||
11 | * | 13 | * |
12 | * Further, this software is distributed without any warranty that it is | 14 | * You should have received a copy of the GNU General Public License |
13 | * free of the rightful claim of any third person regarding infringement | 15 | * along with this program; if not, write the Free Software Foundation, |
14 | * or the like. Any license provided herein, whether implied or | 16 | * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
15 | * otherwise, applies only to this software file. Patent licenses, if | ||
16 | * any, provided herein do not apply to combinations of this program with | ||
17 | * other software, or any other product whatsoever. | ||
18 | * | ||
19 | * You should have received a copy of the GNU General Public License along | ||
20 | * with this program; if not, write the Free Software Foundation, Inc., 59 | ||
21 | * Temple Place - Suite 330, Boston MA 02111-1307, USA. | ||
22 | * | ||
23 | * Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy, | ||
24 | * Mountain View, CA 94043, or: | ||
25 | * | ||
26 | * http://www.sgi.com | ||
27 | * | ||
28 | * For further information regarding this notice, see: | ||
29 | * | ||
30 | * http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/ | ||
31 | */ | 17 | */ |
32 | |||
33 | /* | ||
34 | * This file contains common code for the space manager's btree implementations. | ||
35 | */ | ||
36 | |||
37 | #include "xfs.h" | 18 | #include "xfs.h" |
38 | 19 | #include "xfs_fs.h" | |
39 | #include "xfs_macros.h" | ||
40 | #include "xfs_types.h" | 20 | #include "xfs_types.h" |
41 | #include "xfs_inum.h" | 21 | #include "xfs_bit.h" |
42 | #include "xfs_log.h" | 22 | #include "xfs_log.h" |
23 | #include "xfs_inum.h" | ||
43 | #include "xfs_trans.h" | 24 | #include "xfs_trans.h" |
44 | #include "xfs_sb.h" | 25 | #include "xfs_sb.h" |
45 | #include "xfs_ag.h" | 26 | #include "xfs_ag.h" |
@@ -47,17 +28,16 @@ | |||
47 | #include "xfs_dir2.h" | 28 | #include "xfs_dir2.h" |
48 | #include "xfs_dmapi.h" | 29 | #include "xfs_dmapi.h" |
49 | #include "xfs_mount.h" | 30 | #include "xfs_mount.h" |
50 | #include "xfs_alloc_btree.h" | ||
51 | #include "xfs_bmap_btree.h" | 31 | #include "xfs_bmap_btree.h" |
32 | #include "xfs_alloc_btree.h" | ||
52 | #include "xfs_ialloc_btree.h" | 33 | #include "xfs_ialloc_btree.h" |
53 | #include "xfs_btree.h" | ||
54 | #include "xfs_ialloc.h" | ||
55 | #include "xfs_attr_sf.h" | ||
56 | #include "xfs_dir_sf.h" | 34 | #include "xfs_dir_sf.h" |
57 | #include "xfs_dir2_sf.h" | 35 | #include "xfs_dir2_sf.h" |
36 | #include "xfs_attr_sf.h" | ||
58 | #include "xfs_dinode.h" | 37 | #include "xfs_dinode.h" |
59 | #include "xfs_inode.h" | 38 | #include "xfs_inode.h" |
60 | #include "xfs_bit.h" | 39 | #include "xfs_btree.h" |
40 | #include "xfs_ialloc.h" | ||
61 | #include "xfs_error.h" | 41 | #include "xfs_error.h" |
62 | 42 | ||
63 | /* | 43 | /* |
@@ -110,11 +90,14 @@ xfs_btree_maxrecs( | |||
110 | switch (cur->bc_btnum) { | 90 | switch (cur->bc_btnum) { |
111 | case XFS_BTNUM_BNO: | 91 | case XFS_BTNUM_BNO: |
112 | case XFS_BTNUM_CNT: | 92 | case XFS_BTNUM_CNT: |
113 | return (int)XFS_ALLOC_BLOCK_MAXRECS(INT_GET(block->bb_h.bb_level, ARCH_CONVERT), cur); | 93 | return (int)XFS_ALLOC_BLOCK_MAXRECS( |
94 | be16_to_cpu(block->bb_h.bb_level), cur); | ||
114 | case XFS_BTNUM_BMAP: | 95 | case XFS_BTNUM_BMAP: |
115 | return (int)XFS_BMAP_BLOCK_IMAXRECS(INT_GET(block->bb_h.bb_level, ARCH_CONVERT), cur); | 96 | return (int)XFS_BMAP_BLOCK_IMAXRECS( |
97 | be16_to_cpu(block->bb_h.bb_level), cur); | ||
116 | case XFS_BTNUM_INO: | 98 | case XFS_BTNUM_INO: |
117 | return (int)XFS_INOBT_BLOCK_MAXRECS(INT_GET(block->bb_h.bb_level, ARCH_CONVERT), cur); | 99 | return (int)XFS_INOBT_BLOCK_MAXRECS( |
100 | be16_to_cpu(block->bb_h.bb_level), cur); | ||
118 | default: | 101 | default: |
119 | ASSERT(0); | 102 | ASSERT(0); |
120 | return 0; | 103 | return 0; |
@@ -160,7 +143,7 @@ xfs_btree_check_key( | |||
160 | 143 | ||
161 | k1 = ak1; | 144 | k1 = ak1; |
162 | k2 = ak2; | 145 | k2 = ak2; |
163 | ASSERT(INT_GET(k1->ar_startblock, ARCH_CONVERT) < INT_GET(k2->ar_startblock, ARCH_CONVERT)); | 146 | ASSERT(be32_to_cpu(k1->ar_startblock) < be32_to_cpu(k2->ar_startblock)); |
164 | break; | 147 | break; |
165 | } | 148 | } |
166 | case XFS_BTNUM_CNT: { | 149 | case XFS_BTNUM_CNT: { |
@@ -169,9 +152,9 @@ xfs_btree_check_key( | |||
169 | 152 | ||
170 | k1 = ak1; | 153 | k1 = ak1; |
171 | k2 = ak2; | 154 | k2 = ak2; |
172 | ASSERT(INT_GET(k1->ar_blockcount, ARCH_CONVERT) < INT_GET(k2->ar_blockcount, ARCH_CONVERT) || | 155 | ASSERT(be32_to_cpu(k1->ar_blockcount) < be32_to_cpu(k2->ar_blockcount) || |
173 | (INT_GET(k1->ar_blockcount, ARCH_CONVERT) == INT_GET(k2->ar_blockcount, ARCH_CONVERT) && | 156 | (k1->ar_blockcount == k2->ar_blockcount && |
174 | INT_GET(k1->ar_startblock, ARCH_CONVERT) < INT_GET(k2->ar_startblock, ARCH_CONVERT))); | 157 | be32_to_cpu(k1->ar_startblock) < be32_to_cpu(k2->ar_startblock))); |
175 | break; | 158 | break; |
176 | } | 159 | } |
177 | case XFS_BTNUM_BMAP: { | 160 | case XFS_BTNUM_BMAP: { |
@@ -214,16 +197,16 @@ xfs_btree_check_lblock( | |||
214 | 197 | ||
215 | mp = cur->bc_mp; | 198 | mp = cur->bc_mp; |
216 | lblock_ok = | 199 | lblock_ok = |
217 | INT_GET(block->bb_magic, ARCH_CONVERT) == xfs_magics[cur->bc_btnum] && | 200 | be32_to_cpu(block->bb_magic) == xfs_magics[cur->bc_btnum] && |
218 | INT_GET(block->bb_level, ARCH_CONVERT) == level && | 201 | be16_to_cpu(block->bb_level) == level && |
219 | INT_GET(block->bb_numrecs, ARCH_CONVERT) <= | 202 | be16_to_cpu(block->bb_numrecs) <= |
220 | xfs_btree_maxrecs(cur, (xfs_btree_block_t *)block) && | 203 | xfs_btree_maxrecs(cur, (xfs_btree_block_t *)block) && |
221 | block->bb_leftsib && | 204 | block->bb_leftsib && |
222 | (INT_GET(block->bb_leftsib, ARCH_CONVERT) == NULLDFSBNO || | 205 | (be64_to_cpu(block->bb_leftsib) == NULLDFSBNO || |
223 | XFS_FSB_SANITY_CHECK(mp, INT_GET(block->bb_leftsib, ARCH_CONVERT))) && | 206 | XFS_FSB_SANITY_CHECK(mp, be64_to_cpu(block->bb_leftsib))) && |
224 | block->bb_rightsib && | 207 | block->bb_rightsib && |
225 | (INT_GET(block->bb_rightsib, ARCH_CONVERT) == NULLDFSBNO || | 208 | (be64_to_cpu(block->bb_rightsib) == NULLDFSBNO || |
226 | XFS_FSB_SANITY_CHECK(mp, INT_GET(block->bb_rightsib, ARCH_CONVERT))); | 209 | XFS_FSB_SANITY_CHECK(mp, be64_to_cpu(block->bb_rightsib))); |
227 | if (unlikely(XFS_TEST_ERROR(!lblock_ok, mp, XFS_ERRTAG_BTREE_CHECK_LBLOCK, | 210 | if (unlikely(XFS_TEST_ERROR(!lblock_ok, mp, XFS_ERRTAG_BTREE_CHECK_LBLOCK, |
228 | XFS_RANDOM_BTREE_CHECK_LBLOCK))) { | 211 | XFS_RANDOM_BTREE_CHECK_LBLOCK))) { |
229 | if (bp) | 212 | if (bp) |
@@ -271,8 +254,9 @@ xfs_btree_check_rec( | |||
271 | 254 | ||
272 | r1 = ar1; | 255 | r1 = ar1; |
273 | r2 = ar2; | 256 | r2 = ar2; |
274 | ASSERT(INT_GET(r1->ar_startblock, ARCH_CONVERT) + INT_GET(r1->ar_blockcount, ARCH_CONVERT) <= | 257 | ASSERT(be32_to_cpu(r1->ar_startblock) + |
275 | INT_GET(r2->ar_startblock, ARCH_CONVERT)); | 258 | be32_to_cpu(r1->ar_blockcount) <= |
259 | be32_to_cpu(r2->ar_startblock)); | ||
276 | break; | 260 | break; |
277 | } | 261 | } |
278 | case XFS_BTNUM_CNT: { | 262 | case XFS_BTNUM_CNT: { |
@@ -281,9 +265,9 @@ xfs_btree_check_rec( | |||
281 | 265 | ||
282 | r1 = ar1; | 266 | r1 = ar1; |
283 | r2 = ar2; | 267 | r2 = ar2; |
284 | ASSERT(INT_GET(r1->ar_blockcount, ARCH_CONVERT) < INT_GET(r2->ar_blockcount, ARCH_CONVERT) || | 268 | ASSERT(be32_to_cpu(r1->ar_blockcount) < be32_to_cpu(r2->ar_blockcount) || |
285 | (INT_GET(r1->ar_blockcount, ARCH_CONVERT) == INT_GET(r2->ar_blockcount, ARCH_CONVERT) && | 269 | (r1->ar_blockcount == r2->ar_blockcount && |
286 | INT_GET(r1->ar_startblock, ARCH_CONVERT) < INT_GET(r2->ar_startblock, ARCH_CONVERT))); | 270 | be32_to_cpu(r1->ar_startblock) < be32_to_cpu(r2->ar_startblock))); |
287 | break; | 271 | break; |
288 | } | 272 | } |
289 | case XFS_BTNUM_BMAP: { | 273 | case XFS_BTNUM_BMAP: { |
@@ -331,17 +315,17 @@ xfs_btree_check_sblock( | |||
331 | 315 | ||
332 | agbp = cur->bc_private.a.agbp; | 316 | agbp = cur->bc_private.a.agbp; |
333 | agf = XFS_BUF_TO_AGF(agbp); | 317 | agf = XFS_BUF_TO_AGF(agbp); |
334 | agflen = INT_GET(agf->agf_length, ARCH_CONVERT); | 318 | agflen = be32_to_cpu(agf->agf_length); |
335 | sblock_ok = | 319 | sblock_ok = |
336 | INT_GET(block->bb_magic, ARCH_CONVERT) == xfs_magics[cur->bc_btnum] && | 320 | be32_to_cpu(block->bb_magic) == xfs_magics[cur->bc_btnum] && |
337 | INT_GET(block->bb_level, ARCH_CONVERT) == level && | 321 | be16_to_cpu(block->bb_level) == level && |
338 | INT_GET(block->bb_numrecs, ARCH_CONVERT) <= | 322 | be16_to_cpu(block->bb_numrecs) <= |
339 | xfs_btree_maxrecs(cur, (xfs_btree_block_t *)block) && | 323 | xfs_btree_maxrecs(cur, (xfs_btree_block_t *)block) && |
340 | (INT_GET(block->bb_leftsib, ARCH_CONVERT) == NULLAGBLOCK || | 324 | (be32_to_cpu(block->bb_leftsib) == NULLAGBLOCK || |
341 | INT_GET(block->bb_leftsib, ARCH_CONVERT) < agflen) && | 325 | be32_to_cpu(block->bb_leftsib) < agflen) && |
342 | block->bb_leftsib && | 326 | block->bb_leftsib && |
343 | (INT_GET(block->bb_rightsib, ARCH_CONVERT) == NULLAGBLOCK || | 327 | (be32_to_cpu(block->bb_rightsib) == NULLAGBLOCK || |
344 | INT_GET(block->bb_rightsib, ARCH_CONVERT) < agflen) && | 328 | be32_to_cpu(block->bb_rightsib) < agflen) && |
345 | block->bb_rightsib; | 329 | block->bb_rightsib; |
346 | if (unlikely(XFS_TEST_ERROR(!sblock_ok, cur->bc_mp, | 330 | if (unlikely(XFS_TEST_ERROR(!sblock_ok, cur->bc_mp, |
347 | XFS_ERRTAG_BTREE_CHECK_SBLOCK, | 331 | XFS_ERRTAG_BTREE_CHECK_SBLOCK, |
@@ -372,7 +356,7 @@ xfs_btree_check_sptr( | |||
372 | XFS_WANT_CORRUPTED_RETURN( | 356 | XFS_WANT_CORRUPTED_RETURN( |
373 | level > 0 && | 357 | level > 0 && |
374 | ptr != NULLAGBLOCK && ptr != 0 && | 358 | ptr != NULLAGBLOCK && ptr != 0 && |
375 | ptr < INT_GET(agf->agf_length, ARCH_CONVERT)); | 359 | ptr < be32_to_cpu(agf->agf_length)); |
376 | return 0; | 360 | return 0; |
377 | } | 361 | } |
378 | 362 | ||
@@ -611,15 +595,15 @@ xfs_btree_init_cursor( | |||
611 | case XFS_BTNUM_BNO: | 595 | case XFS_BTNUM_BNO: |
612 | case XFS_BTNUM_CNT: | 596 | case XFS_BTNUM_CNT: |
613 | agf = XFS_BUF_TO_AGF(agbp); | 597 | agf = XFS_BUF_TO_AGF(agbp); |
614 | nlevels = INT_GET(agf->agf_levels[btnum], ARCH_CONVERT); | 598 | nlevels = be32_to_cpu(agf->agf_levels[btnum]); |
615 | break; | 599 | break; |
616 | case XFS_BTNUM_BMAP: | 600 | case XFS_BTNUM_BMAP: |
617 | ifp = XFS_IFORK_PTR(ip, whichfork); | 601 | ifp = XFS_IFORK_PTR(ip, whichfork); |
618 | nlevels = INT_GET(ifp->if_broot->bb_level, ARCH_CONVERT) + 1; | 602 | nlevels = be16_to_cpu(ifp->if_broot->bb_level) + 1; |
619 | break; | 603 | break; |
620 | case XFS_BTNUM_INO: | 604 | case XFS_BTNUM_INO: |
621 | agi = XFS_BUF_TO_AGI(agbp); | 605 | agi = XFS_BUF_TO_AGI(agbp); |
622 | nlevels = INT_GET(agi->agi_level, ARCH_CONVERT); | 606 | nlevels = be32_to_cpu(agi->agi_level); |
623 | break; | 607 | break; |
624 | default: | 608 | default: |
625 | ASSERT(0); | 609 | ASSERT(0); |
@@ -683,9 +667,9 @@ xfs_btree_islastblock( | |||
683 | block = xfs_btree_get_block(cur, level, &bp); | 667 | block = xfs_btree_get_block(cur, level, &bp); |
684 | xfs_btree_check_block(cur, block, level, bp); | 668 | xfs_btree_check_block(cur, block, level, bp); |
685 | if (XFS_BTREE_LONG_PTRS(cur->bc_btnum)) | 669 | if (XFS_BTREE_LONG_PTRS(cur->bc_btnum)) |
686 | return INT_GET(block->bb_u.l.bb_rightsib, ARCH_CONVERT) == NULLDFSBNO; | 670 | return be64_to_cpu(block->bb_u.l.bb_rightsib) == NULLDFSBNO; |
687 | else | 671 | else |
688 | return INT_GET(block->bb_u.s.bb_rightsib, ARCH_CONVERT) == NULLAGBLOCK; | 672 | return be32_to_cpu(block->bb_u.s.bb_rightsib) == NULLAGBLOCK; |
689 | } | 673 | } |
690 | 674 | ||
691 | /* | 675 | /* |
@@ -713,7 +697,7 @@ xfs_btree_lastrec( | |||
713 | /* | 697 | /* |
714 | * Set the ptr value to numrecs, that's the last record/key. | 698 | * Set the ptr value to numrecs, that's the last record/key. |
715 | */ | 699 | */ |
716 | cur->bc_ptrs[level] = INT_GET(block->bb_h.bb_numrecs, ARCH_CONVERT); | 700 | cur->bc_ptrs[level] = be16_to_cpu(block->bb_h.bb_numrecs); |
717 | return 1; | 701 | return 1; |
718 | } | 702 | } |
719 | 703 | ||
@@ -883,38 +867,38 @@ xfs_btree_readahead_core( | |||
883 | case XFS_BTNUM_BNO: | 867 | case XFS_BTNUM_BNO: |
884 | case XFS_BTNUM_CNT: | 868 | case XFS_BTNUM_CNT: |
885 | a = XFS_BUF_TO_ALLOC_BLOCK(cur->bc_bufs[lev]); | 869 | a = XFS_BUF_TO_ALLOC_BLOCK(cur->bc_bufs[lev]); |
886 | if ((lr & XFS_BTCUR_LEFTRA) && INT_GET(a->bb_leftsib, ARCH_CONVERT) != NULLAGBLOCK) { | 870 | if ((lr & XFS_BTCUR_LEFTRA) && be32_to_cpu(a->bb_leftsib) != NULLAGBLOCK) { |
887 | xfs_btree_reada_bufs(cur->bc_mp, cur->bc_private.a.agno, | 871 | xfs_btree_reada_bufs(cur->bc_mp, cur->bc_private.a.agno, |
888 | INT_GET(a->bb_leftsib, ARCH_CONVERT), 1); | 872 | be32_to_cpu(a->bb_leftsib), 1); |
889 | rval++; | 873 | rval++; |
890 | } | 874 | } |
891 | if ((lr & XFS_BTCUR_RIGHTRA) && INT_GET(a->bb_rightsib, ARCH_CONVERT) != NULLAGBLOCK) { | 875 | if ((lr & XFS_BTCUR_RIGHTRA) && be32_to_cpu(a->bb_rightsib) != NULLAGBLOCK) { |
892 | xfs_btree_reada_bufs(cur->bc_mp, cur->bc_private.a.agno, | 876 | xfs_btree_reada_bufs(cur->bc_mp, cur->bc_private.a.agno, |
893 | INT_GET(a->bb_rightsib, ARCH_CONVERT), 1); | 877 | be32_to_cpu(a->bb_rightsib), 1); |
894 | rval++; | 878 | rval++; |
895 | } | 879 | } |
896 | break; | 880 | break; |
897 | case XFS_BTNUM_BMAP: | 881 | case XFS_BTNUM_BMAP: |
898 | b = XFS_BUF_TO_BMBT_BLOCK(cur->bc_bufs[lev]); | 882 | b = XFS_BUF_TO_BMBT_BLOCK(cur->bc_bufs[lev]); |
899 | if ((lr & XFS_BTCUR_LEFTRA) && INT_GET(b->bb_leftsib, ARCH_CONVERT) != NULLDFSBNO) { | 883 | if ((lr & XFS_BTCUR_LEFTRA) && be64_to_cpu(b->bb_leftsib) != NULLDFSBNO) { |
900 | xfs_btree_reada_bufl(cur->bc_mp, INT_GET(b->bb_leftsib, ARCH_CONVERT), 1); | 884 | xfs_btree_reada_bufl(cur->bc_mp, be64_to_cpu(b->bb_leftsib), 1); |
901 | rval++; | 885 | rval++; |
902 | } | 886 | } |
903 | if ((lr & XFS_BTCUR_RIGHTRA) && INT_GET(b->bb_rightsib, ARCH_CONVERT) != NULLDFSBNO) { | 887 | if ((lr & XFS_BTCUR_RIGHTRA) && be64_to_cpu(b->bb_rightsib) != NULLDFSBNO) { |
904 | xfs_btree_reada_bufl(cur->bc_mp, INT_GET(b->bb_rightsib, ARCH_CONVERT), 1); | 888 | xfs_btree_reada_bufl(cur->bc_mp, be64_to_cpu(b->bb_rightsib), 1); |
905 | rval++; | 889 | rval++; |
906 | } | 890 | } |
907 | break; | 891 | break; |
908 | case XFS_BTNUM_INO: | 892 | case XFS_BTNUM_INO: |
909 | i = XFS_BUF_TO_INOBT_BLOCK(cur->bc_bufs[lev]); | 893 | i = XFS_BUF_TO_INOBT_BLOCK(cur->bc_bufs[lev]); |
910 | if ((lr & XFS_BTCUR_LEFTRA) && INT_GET(i->bb_leftsib, ARCH_CONVERT) != NULLAGBLOCK) { | 894 | if ((lr & XFS_BTCUR_LEFTRA) && be32_to_cpu(i->bb_leftsib) != NULLAGBLOCK) { |
911 | xfs_btree_reada_bufs(cur->bc_mp, cur->bc_private.i.agno, | 895 | xfs_btree_reada_bufs(cur->bc_mp, cur->bc_private.i.agno, |
912 | INT_GET(i->bb_leftsib, ARCH_CONVERT), 1); | 896 | be32_to_cpu(i->bb_leftsib), 1); |
913 | rval++; | 897 | rval++; |
914 | } | 898 | } |
915 | if ((lr & XFS_BTCUR_RIGHTRA) && INT_GET(i->bb_rightsib, ARCH_CONVERT) != NULLAGBLOCK) { | 899 | if ((lr & XFS_BTCUR_RIGHTRA) && be32_to_cpu(i->bb_rightsib) != NULLAGBLOCK) { |
916 | xfs_btree_reada_bufs(cur->bc_mp, cur->bc_private.i.agno, | 900 | xfs_btree_reada_bufs(cur->bc_mp, cur->bc_private.i.agno, |
917 | INT_GET(i->bb_rightsib, ARCH_CONVERT), 1); | 901 | be32_to_cpu(i->bb_rightsib), 1); |
918 | rval++; | 902 | rval++; |
919 | } | 903 | } |
920 | break; | 904 | break; |
@@ -946,14 +930,14 @@ xfs_btree_setbuf( | |||
946 | return; | 930 | return; |
947 | b = XFS_BUF_TO_BLOCK(bp); | 931 | b = XFS_BUF_TO_BLOCK(bp); |
948 | if (XFS_BTREE_LONG_PTRS(cur->bc_btnum)) { | 932 | if (XFS_BTREE_LONG_PTRS(cur->bc_btnum)) { |
949 | if (INT_GET(b->bb_u.l.bb_leftsib, ARCH_CONVERT) == NULLDFSBNO) | 933 | if (be64_to_cpu(b->bb_u.l.bb_leftsib) == NULLDFSBNO) |
950 | cur->bc_ra[lev] |= XFS_BTCUR_LEFTRA; | 934 | cur->bc_ra[lev] |= XFS_BTCUR_LEFTRA; |
951 | if (INT_GET(b->bb_u.l.bb_rightsib, ARCH_CONVERT) == NULLDFSBNO) | 935 | if (be64_to_cpu(b->bb_u.l.bb_rightsib) == NULLDFSBNO) |
952 | cur->bc_ra[lev] |= XFS_BTCUR_RIGHTRA; | 936 | cur->bc_ra[lev] |= XFS_BTCUR_RIGHTRA; |
953 | } else { | 937 | } else { |
954 | if (INT_GET(b->bb_u.s.bb_leftsib, ARCH_CONVERT) == NULLAGBLOCK) | 938 | if (be32_to_cpu(b->bb_u.s.bb_leftsib) == NULLAGBLOCK) |
955 | cur->bc_ra[lev] |= XFS_BTCUR_LEFTRA; | 939 | cur->bc_ra[lev] |= XFS_BTCUR_LEFTRA; |
956 | if (INT_GET(b->bb_u.s.bb_rightsib, ARCH_CONVERT) == NULLAGBLOCK) | 940 | if (be32_to_cpu(b->bb_u.s.bb_rightsib) == NULLAGBLOCK) |
957 | cur->bc_ra[lev] |= XFS_BTCUR_RIGHTRA; | 941 | cur->bc_ra[lev] |= XFS_BTCUR_RIGHTRA; |
958 | } | 942 | } |
959 | } | 943 | } |
diff --git a/fs/xfs/xfs_btree.h b/fs/xfs/xfs_btree.h index 09b4e1532a35..44f1bd98064a 100644 --- a/fs/xfs/xfs_btree.h +++ b/fs/xfs/xfs_btree.h | |||
@@ -1,33 +1,19 @@ | |||
1 | /* | 1 | /* |
2 | * Copyright (c) 2000-2001 Silicon Graphics, Inc. All Rights Reserved. | 2 | * Copyright (c) 2000-2001,2005 Silicon Graphics, Inc. |
3 | * All Rights Reserved. | ||
3 | * | 4 | * |
4 | * This program is free software; you can redistribute it and/or modify it | 5 | * This program is free software; you can redistribute it and/or |
5 | * under the terms of version 2 of the GNU General Public License as | 6 | * modify it under the terms of the GNU General Public License as |
6 | * published by the Free Software Foundation. | 7 | * published by the Free Software Foundation. |
7 | * | 8 | * |
8 | * This program is distributed in the hope that it would be useful, but | 9 | * This program is distributed in the hope that it would be useful, |
9 | * WITHOUT ANY WARRANTY; without even the implied warranty of | 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
12 | * GNU General Public License for more details. | ||
11 | * | 13 | * |
12 | * Further, this software is distributed without any warranty that it is | 14 | * You should have received a copy of the GNU General Public License |
13 | * free of the rightful claim of any third person regarding infringement | 15 | * along with this program; if not, write the Free Software Foundation, |
14 | * or the like. Any license provided herein, whether implied or | 16 | * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
15 | * otherwise, applies only to this software file. Patent licenses, if | ||
16 | * any, provided herein do not apply to combinations of this program with | ||
17 | * other software, or any other product whatsoever. | ||
18 | * | ||
19 | * You should have received a copy of the GNU General Public License along | ||
20 | * with this program; if not, write the Free Software Foundation, Inc., 59 | ||
21 | * Temple Place - Suite 330, Boston MA 02111-1307, USA. | ||
22 | * | ||
23 | * Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy, | ||
24 | * Mountain View, CA 94043, or: | ||
25 | * | ||
26 | * http://www.sgi.com | ||
27 | * | ||
28 | * For further information regarding this notice, see: | ||
29 | * | ||
30 | * http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/ | ||
31 | */ | 17 | */ |
32 | #ifndef __XFS_BTREE_H__ | 18 | #ifndef __XFS_BTREE_H__ |
33 | #define __XFS_BTREE_H__ | 19 | #define __XFS_BTREE_H__ |
@@ -53,25 +39,23 @@ struct xfs_trans; | |||
53 | /* | 39 | /* |
54 | * Short form header: space allocation btrees. | 40 | * Short form header: space allocation btrees. |
55 | */ | 41 | */ |
56 | typedef struct xfs_btree_sblock | 42 | typedef struct xfs_btree_sblock { |
57 | { | 43 | __be32 bb_magic; /* magic number for block type */ |
58 | __uint32_t bb_magic; /* magic number for block type */ | 44 | __be16 bb_level; /* 0 is a leaf */ |
59 | __uint16_t bb_level; /* 0 is a leaf */ | 45 | __be16 bb_numrecs; /* current # of data records */ |
60 | __uint16_t bb_numrecs; /* current # of data records */ | 46 | __be32 bb_leftsib; /* left sibling block or NULLAGBLOCK */ |
61 | xfs_agblock_t bb_leftsib; /* left sibling block or NULLAGBLOCK */ | 47 | __be32 bb_rightsib; /* right sibling block or NULLAGBLOCK */ |
62 | xfs_agblock_t bb_rightsib; /* right sibling block or NULLAGBLOCK */ | ||
63 | } xfs_btree_sblock_t; | 48 | } xfs_btree_sblock_t; |
64 | 49 | ||
65 | /* | 50 | /* |
66 | * Long form header: bmap btrees. | 51 | * Long form header: bmap btrees. |
67 | */ | 52 | */ |
68 | typedef struct xfs_btree_lblock | 53 | typedef struct xfs_btree_lblock { |
69 | { | 54 | __be32 bb_magic; /* magic number for block type */ |
70 | __uint32_t bb_magic; /* magic number for block type */ | 55 | __be16 bb_level; /* 0 is a leaf */ |
71 | __uint16_t bb_level; /* 0 is a leaf */ | 56 | __be16 bb_numrecs; /* current # of data records */ |
72 | __uint16_t bb_numrecs; /* current # of data records */ | 57 | __be64 bb_leftsib; /* left sibling block or NULLDFSBNO */ |
73 | xfs_dfsbno_t bb_leftsib; /* left sibling block or NULLDFSBNO */ | 58 | __be64 bb_rightsib; /* right sibling block or NULLDFSBNO */ |
74 | xfs_dfsbno_t bb_rightsib; /* right sibling block or NULLDFSBNO */ | ||
75 | } xfs_btree_lblock_t; | 59 | } xfs_btree_lblock_t; |
76 | 60 | ||
77 | /* | 61 | /* |
@@ -79,24 +63,23 @@ typedef struct xfs_btree_lblock | |||
79 | */ | 63 | */ |
80 | typedef struct xfs_btree_hdr | 64 | typedef struct xfs_btree_hdr |
81 | { | 65 | { |
82 | __uint32_t bb_magic; /* magic number for block type */ | 66 | __be32 bb_magic; /* magic number for block type */ |
83 | __uint16_t bb_level; /* 0 is a leaf */ | 67 | __be16 bb_level; /* 0 is a leaf */ |
84 | __uint16_t bb_numrecs; /* current # of data records */ | 68 | __be16 bb_numrecs; /* current # of data records */ |
85 | } xfs_btree_hdr_t; | 69 | } xfs_btree_hdr_t; |
86 | 70 | ||
87 | typedef struct xfs_btree_block | 71 | typedef struct xfs_btree_block { |
88 | { | ||
89 | xfs_btree_hdr_t bb_h; /* header */ | 72 | xfs_btree_hdr_t bb_h; /* header */ |
90 | union { | 73 | union { |
91 | struct { | 74 | struct { |
92 | xfs_agblock_t bb_leftsib; | 75 | __be32 bb_leftsib; |
93 | xfs_agblock_t bb_rightsib; | 76 | __be32 bb_rightsib; |
94 | } s; /* short form pointers */ | 77 | } s; /* short form pointers */ |
95 | struct { | 78 | struct { |
96 | xfs_dfsbno_t bb_leftsib; | 79 | __be64 bb_leftsib; |
97 | xfs_dfsbno_t bb_rightsib; | 80 | __be64 bb_rightsib; |
98 | } l; /* long form pointers */ | 81 | } l; /* long form pointers */ |
99 | } bb_u; /* rest */ | 82 | } bb_u; /* rest */ |
100 | } xfs_btree_block_t; | 83 | } xfs_btree_block_t; |
101 | 84 | ||
102 | /* | 85 | /* |
@@ -113,12 +96,7 @@ typedef struct xfs_btree_block | |||
113 | /* | 96 | /* |
114 | * Boolean to select which form of xfs_btree_block_t.bb_u to use. | 97 | * Boolean to select which form of xfs_btree_block_t.bb_u to use. |
115 | */ | 98 | */ |
116 | #if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_BTREE_LONG_PTRS) | ||
117 | int xfs_btree_long_ptrs(xfs_btnum_t btnum); | ||
118 | #define XFS_BTREE_LONG_PTRS(btnum) ((btnum) == XFS_BTNUM_BMAP) | ||
119 | #else | ||
120 | #define XFS_BTREE_LONG_PTRS(btnum) ((btnum) == XFS_BTNUM_BMAP) | 99 | #define XFS_BTREE_LONG_PTRS(btnum) ((btnum) == XFS_BTNUM_BMAP) |
121 | #endif | ||
122 | 100 | ||
123 | /* | 101 | /* |
124 | * Magic numbers for btree blocks. | 102 | * Magic numbers for btree blocks. |
@@ -165,7 +143,7 @@ typedef struct xfs_btree_cur | |||
165 | struct xfs_trans *bc_tp; /* transaction we're in, if any */ | 143 | struct xfs_trans *bc_tp; /* transaction we're in, if any */ |
166 | struct xfs_mount *bc_mp; /* file system mount struct */ | 144 | struct xfs_mount *bc_mp; /* file system mount struct */ |
167 | union { | 145 | union { |
168 | xfs_alloc_rec_t a; | 146 | xfs_alloc_rec_incore_t a; |
169 | xfs_bmbt_irec_t b; | 147 | xfs_bmbt_irec_t b; |
170 | xfs_inobt_rec_t i; | 148 | xfs_inobt_rec_t i; |
171 | } bc_rec; /* current insert/search record value */ | 149 | } bc_rec; /* current insert/search record value */ |
@@ -205,24 +183,10 @@ typedef struct xfs_btree_cur | |||
205 | /* | 183 | /* |
206 | * Convert from buffer to btree block header. | 184 | * Convert from buffer to btree block header. |
207 | */ | 185 | */ |
208 | #if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_BUF_TO_BLOCK) | 186 | #define XFS_BUF_TO_BLOCK(bp) ((xfs_btree_block_t *)XFS_BUF_PTR(bp)) |
209 | xfs_btree_block_t *xfs_buf_to_block(struct xfs_buf *bp); | 187 | #define XFS_BUF_TO_LBLOCK(bp) ((xfs_btree_lblock_t *)XFS_BUF_PTR(bp)) |
210 | #define XFS_BUF_TO_BLOCK(bp) xfs_buf_to_block(bp) | 188 | #define XFS_BUF_TO_SBLOCK(bp) ((xfs_btree_sblock_t *)XFS_BUF_PTR(bp)) |
211 | #else | 189 | |
212 | #define XFS_BUF_TO_BLOCK(bp) ((xfs_btree_block_t *)(XFS_BUF_PTR(bp))) | ||
213 | #endif | ||
214 | #if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_BUF_TO_LBLOCK) | ||
215 | xfs_btree_lblock_t *xfs_buf_to_lblock(struct xfs_buf *bp); | ||
216 | #define XFS_BUF_TO_LBLOCK(bp) xfs_buf_to_lblock(bp) | ||
217 | #else | ||
218 | #define XFS_BUF_TO_LBLOCK(bp) ((xfs_btree_lblock_t *)(XFS_BUF_PTR(bp))) | ||
219 | #endif | ||
220 | #if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_BUF_TO_SBLOCK) | ||
221 | xfs_btree_sblock_t *xfs_buf_to_sblock(struct xfs_buf *bp); | ||
222 | #define XFS_BUF_TO_SBLOCK(bp) xfs_buf_to_sblock(bp) | ||
223 | #else | ||
224 | #define XFS_BUF_TO_SBLOCK(bp) ((xfs_btree_sblock_t *)(XFS_BUF_PTR(bp))) | ||
225 | #endif | ||
226 | 190 | ||
227 | #ifdef __KERNEL__ | 191 | #ifdef __KERNEL__ |
228 | 192 | ||
@@ -477,106 +441,33 @@ xfs_btree_setbuf( | |||
477 | /* | 441 | /* |
478 | * Min and max functions for extlen, agblock, fileoff, and filblks types. | 442 | * Min and max functions for extlen, agblock, fileoff, and filblks types. |
479 | */ | 443 | */ |
480 | #if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_EXTLEN_MIN) | ||
481 | xfs_extlen_t xfs_extlen_min(xfs_extlen_t a, xfs_extlen_t b); | ||
482 | #define XFS_EXTLEN_MIN(a,b) xfs_extlen_min(a,b) | ||
483 | #else | ||
484 | #define XFS_EXTLEN_MIN(a,b) \ | 444 | #define XFS_EXTLEN_MIN(a,b) \ |
485 | ((xfs_extlen_t)(a) < (xfs_extlen_t)(b) ? \ | 445 | ((xfs_extlen_t)(a) < (xfs_extlen_t)(b) ? \ |
486 | (xfs_extlen_t)(a) : (xfs_extlen_t)(b)) | 446 | (xfs_extlen_t)(a) : (xfs_extlen_t)(b)) |
487 | #endif | ||
488 | #if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_EXTLEN_MAX) | ||
489 | xfs_extlen_t xfs_extlen_max(xfs_extlen_t a, xfs_extlen_t b); | ||
490 | #define XFS_EXTLEN_MAX(a,b) xfs_extlen_max(a,b) | ||
491 | #else | ||
492 | #define XFS_EXTLEN_MAX(a,b) \ | 447 | #define XFS_EXTLEN_MAX(a,b) \ |
493 | ((xfs_extlen_t)(a) > (xfs_extlen_t)(b) ? \ | 448 | ((xfs_extlen_t)(a) > (xfs_extlen_t)(b) ? \ |
494 | (xfs_extlen_t)(a) : (xfs_extlen_t)(b)) | 449 | (xfs_extlen_t)(a) : (xfs_extlen_t)(b)) |
495 | #endif | ||
496 | |||
497 | #if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_AGBLOCK_MIN) | ||
498 | xfs_agblock_t xfs_agblock_min(xfs_agblock_t a, xfs_agblock_t b); | ||
499 | #define XFS_AGBLOCK_MIN(a,b) xfs_agblock_min(a,b) | ||
500 | #else | ||
501 | #define XFS_AGBLOCK_MIN(a,b) \ | 450 | #define XFS_AGBLOCK_MIN(a,b) \ |
502 | ((xfs_agblock_t)(a) < (xfs_agblock_t)(b) ? \ | 451 | ((xfs_agblock_t)(a) < (xfs_agblock_t)(b) ? \ |
503 | (xfs_agblock_t)(a) : (xfs_agblock_t)(b)) | 452 | (xfs_agblock_t)(a) : (xfs_agblock_t)(b)) |
504 | #endif | ||
505 | #if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_AGBLOCK_MAX) | ||
506 | xfs_agblock_t xfs_agblock_max(xfs_agblock_t a, xfs_agblock_t b); | ||
507 | #define XFS_AGBLOCK_MAX(a,b) xfs_agblock_max(a,b) | ||
508 | #else | ||
509 | #define XFS_AGBLOCK_MAX(a,b) \ | 453 | #define XFS_AGBLOCK_MAX(a,b) \ |
510 | ((xfs_agblock_t)(a) > (xfs_agblock_t)(b) ? \ | 454 | ((xfs_agblock_t)(a) > (xfs_agblock_t)(b) ? \ |
511 | (xfs_agblock_t)(a) : (xfs_agblock_t)(b)) | 455 | (xfs_agblock_t)(a) : (xfs_agblock_t)(b)) |
512 | #endif | ||
513 | |||
514 | #if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_FILEOFF_MIN) | ||
515 | xfs_fileoff_t xfs_fileoff_min(xfs_fileoff_t a, xfs_fileoff_t b); | ||
516 | #define XFS_FILEOFF_MIN(a,b) xfs_fileoff_min(a,b) | ||
517 | #else | ||
518 | #define XFS_FILEOFF_MIN(a,b) \ | 456 | #define XFS_FILEOFF_MIN(a,b) \ |
519 | ((xfs_fileoff_t)(a) < (xfs_fileoff_t)(b) ? \ | 457 | ((xfs_fileoff_t)(a) < (xfs_fileoff_t)(b) ? \ |
520 | (xfs_fileoff_t)(a) : (xfs_fileoff_t)(b)) | 458 | (xfs_fileoff_t)(a) : (xfs_fileoff_t)(b)) |
521 | #endif | ||
522 | #if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_FILEOFF_MAX) | ||
523 | xfs_fileoff_t xfs_fileoff_max(xfs_fileoff_t a, xfs_fileoff_t b); | ||
524 | #define XFS_FILEOFF_MAX(a,b) xfs_fileoff_max(a,b) | ||
525 | #else | ||
526 | #define XFS_FILEOFF_MAX(a,b) \ | 459 | #define XFS_FILEOFF_MAX(a,b) \ |
527 | ((xfs_fileoff_t)(a) > (xfs_fileoff_t)(b) ? \ | 460 | ((xfs_fileoff_t)(a) > (xfs_fileoff_t)(b) ? \ |
528 | (xfs_fileoff_t)(a) : (xfs_fileoff_t)(b)) | 461 | (xfs_fileoff_t)(a) : (xfs_fileoff_t)(b)) |
529 | #endif | ||
530 | |||
531 | #if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_FILBLKS_MIN) | ||
532 | xfs_filblks_t xfs_filblks_min(xfs_filblks_t a, xfs_filblks_t b); | ||
533 | #define XFS_FILBLKS_MIN(a,b) xfs_filblks_min(a,b) | ||
534 | #else | ||
535 | #define XFS_FILBLKS_MIN(a,b) \ | 462 | #define XFS_FILBLKS_MIN(a,b) \ |
536 | ((xfs_filblks_t)(a) < (xfs_filblks_t)(b) ? \ | 463 | ((xfs_filblks_t)(a) < (xfs_filblks_t)(b) ? \ |
537 | (xfs_filblks_t)(a) : (xfs_filblks_t)(b)) | 464 | (xfs_filblks_t)(a) : (xfs_filblks_t)(b)) |
538 | #endif | ||
539 | #if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_FILBLKS_MAX) | ||
540 | xfs_filblks_t xfs_filblks_max(xfs_filblks_t a, xfs_filblks_t b); | ||
541 | #define XFS_FILBLKS_MAX(a,b) xfs_filblks_max(a,b) | ||
542 | #else | ||
543 | #define XFS_FILBLKS_MAX(a,b) \ | 465 | #define XFS_FILBLKS_MAX(a,b) \ |
544 | ((xfs_filblks_t)(a) > (xfs_filblks_t)(b) ? \ | 466 | ((xfs_filblks_t)(a) > (xfs_filblks_t)(b) ? \ |
545 | (xfs_filblks_t)(a) : (xfs_filblks_t)(b)) | 467 | (xfs_filblks_t)(a) : (xfs_filblks_t)(b)) |
546 | #endif | 468 | |
547 | #if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_FSB_SANITY_CHECK) | ||
548 | int xfs_fsb_sanity_check(struct xfs_mount *mp, xfs_fsblock_t fsb); | ||
549 | #define XFS_FSB_SANITY_CHECK(mp,fsb) xfs_fsb_sanity_check(mp,fsb) | ||
550 | #else | ||
551 | #define XFS_FSB_SANITY_CHECK(mp,fsb) \ | 469 | #define XFS_FSB_SANITY_CHECK(mp,fsb) \ |
552 | (XFS_FSB_TO_AGNO(mp, fsb) < mp->m_sb.sb_agcount && \ | 470 | (XFS_FSB_TO_AGNO(mp, fsb) < mp->m_sb.sb_agcount && \ |
553 | XFS_FSB_TO_AGBNO(mp, fsb) < mp->m_sb.sb_agblocks) | 471 | XFS_FSB_TO_AGBNO(mp, fsb) < mp->m_sb.sb_agblocks) |
554 | #endif | ||
555 | |||
556 | /* | ||
557 | * Macros to set EFSCORRUPTED & return/branch. | ||
558 | */ | ||
559 | #define XFS_WANT_CORRUPTED_GOTO(x,l) \ | ||
560 | { \ | ||
561 | int fs_is_ok = (x); \ | ||
562 | ASSERT(fs_is_ok); \ | ||
563 | if (unlikely(!fs_is_ok)) { \ | ||
564 | XFS_ERROR_REPORT("XFS_WANT_CORRUPTED_GOTO", \ | ||
565 | XFS_ERRLEVEL_LOW, NULL); \ | ||
566 | error = XFS_ERROR(EFSCORRUPTED); \ | ||
567 | goto l; \ | ||
568 | } \ | ||
569 | } | ||
570 | |||
571 | #define XFS_WANT_CORRUPTED_RETURN(x) \ | ||
572 | { \ | ||
573 | int fs_is_ok = (x); \ | ||
574 | ASSERT(fs_is_ok); \ | ||
575 | if (unlikely(!fs_is_ok)) { \ | ||
576 | XFS_ERROR_REPORT("XFS_WANT_CORRUPTED_RETURN", \ | ||
577 | XFS_ERRLEVEL_LOW, NULL); \ | ||
578 | return XFS_ERROR(EFSCORRUPTED); \ | ||
579 | } \ | ||
580 | } | ||
581 | 472 | ||
582 | #endif /* __XFS_BTREE_H__ */ | 473 | #endif /* __XFS_BTREE_H__ */ |
diff --git a/fs/xfs/xfs_buf_item.c b/fs/xfs/xfs_buf_item.c index a264657acfd9..07e2324152b1 100644 --- a/fs/xfs/xfs_buf_item.c +++ b/fs/xfs/xfs_buf_item.c | |||
@@ -1,57 +1,33 @@ | |||
1 | /* | 1 | /* |
2 | * Copyright (c) 2000-2004 Silicon Graphics, Inc. All Rights Reserved. | 2 | * Copyright (c) 2000-2005 Silicon Graphics, Inc. |
3 | * All Rights Reserved. | ||
3 | * | 4 | * |
4 | * This program is free software; you can redistribute it and/or modify it | 5 | * This program is free software; you can redistribute it and/or |
5 | * under the terms of version 2 of the GNU General Public License as | 6 | * modify it under the terms of the GNU General Public License as |
6 | * published by the Free Software Foundation. | 7 | * published by the Free Software Foundation. |
7 | * | 8 | * |
8 | * This program is distributed in the hope that it would be useful, but | 9 | * This program is distributed in the hope that it would be useful, |
9 | * WITHOUT ANY WARRANTY; without even the implied warranty of | 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
12 | * GNU General Public License for more details. | ||
11 | * | 13 | * |
12 | * Further, this software is distributed without any warranty that it is | 14 | * You should have received a copy of the GNU General Public License |
13 | * free of the rightful claim of any third person regarding infringement | 15 | * along with this program; if not, write the Free Software Foundation, |
14 | * or the like. Any license provided herein, whether implied or | 16 | * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
15 | * otherwise, applies only to this software file. Patent licenses, if | ||
16 | * any, provided herein do not apply to combinations of this program with | ||
17 | * other software, or any other product whatsoever. | ||
18 | * | ||
19 | * You should have received a copy of the GNU General Public License along | ||
20 | * with this program; if not, write the Free Software Foundation, Inc., 59 | ||
21 | * Temple Place - Suite 330, Boston MA 02111-1307, USA. | ||
22 | * | ||
23 | * Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy, | ||
24 | * Mountain View, CA 94043, or: | ||
25 | * | ||
26 | * http://www.sgi.com | ||
27 | * | ||
28 | * For further information regarding this notice, see: | ||
29 | * | ||
30 | * http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/ | ||
31 | */ | ||
32 | |||
33 | /* | ||
34 | * This file contains the implementation of the xfs_buf_log_item. | ||
35 | * It contains the item operations used to manipulate the buf log | ||
36 | * items as well as utility routines used by the buffer specific | ||
37 | * transaction routines. | ||
38 | */ | 17 | */ |
39 | |||
40 | #include "xfs.h" | 18 | #include "xfs.h" |
41 | 19 | #include "xfs_fs.h" | |
42 | #include "xfs_macros.h" | ||
43 | #include "xfs_types.h" | 20 | #include "xfs_types.h" |
44 | #include "xfs_inum.h" | 21 | #include "xfs_bit.h" |
45 | #include "xfs_log.h" | 22 | #include "xfs_log.h" |
23 | #include "xfs_inum.h" | ||
46 | #include "xfs_trans.h" | 24 | #include "xfs_trans.h" |
47 | #include "xfs_buf_item.h" | ||
48 | #include "xfs_sb.h" | 25 | #include "xfs_sb.h" |
49 | #include "xfs_dir.h" | 26 | #include "xfs_dir.h" |
50 | #include "xfs_dmapi.h" | 27 | #include "xfs_dmapi.h" |
51 | #include "xfs_mount.h" | 28 | #include "xfs_mount.h" |
29 | #include "xfs_buf_item.h" | ||
52 | #include "xfs_trans_priv.h" | 30 | #include "xfs_trans_priv.h" |
53 | #include "xfs_rw.h" | ||
54 | #include "xfs_bit.h" | ||
55 | #include "xfs_error.h" | 31 | #include "xfs_error.h" |
56 | 32 | ||
57 | 33 | ||
diff --git a/fs/xfs/xfs_buf_item.h b/fs/xfs/xfs_buf_item.h index 01aed5f2d579..07c708c2b529 100644 --- a/fs/xfs/xfs_buf_item.h +++ b/fs/xfs/xfs_buf_item.h | |||
@@ -1,33 +1,19 @@ | |||
1 | /* | 1 | /* |
2 | * Copyright (c) 2000-2001 Silicon Graphics, Inc. All Rights Reserved. | 2 | * Copyright (c) 2000-2001,2005 Silicon Graphics, Inc. |
3 | * All Rights Reserved. | ||
3 | * | 4 | * |
4 | * This program is free software; you can redistribute it and/or modify it | 5 | * This program is free software; you can redistribute it and/or |
5 | * under the terms of version 2 of the GNU General Public License as | 6 | * modify it under the terms of the GNU General Public License as |
6 | * published by the Free Software Foundation. | 7 | * published by the Free Software Foundation. |
7 | * | 8 | * |
8 | * This program is distributed in the hope that it would be useful, but | 9 | * This program is distributed in the hope that it would be useful, |
9 | * WITHOUT ANY WARRANTY; without even the implied warranty of | 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
12 | * GNU General Public License for more details. | ||
11 | * | 13 | * |
12 | * Further, this software is distributed without any warranty that it is | 14 | * You should have received a copy of the GNU General Public License |
13 | * free of the rightful claim of any third person regarding infringement | 15 | * along with this program; if not, write the Free Software Foundation, |
14 | * or the like. Any license provided herein, whether implied or | 16 | * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
15 | * otherwise, applies only to this software file. Patent licenses, if | ||
16 | * any, provided herein do not apply to combinations of this program with | ||
17 | * other software, or any other product whatsoever. | ||
18 | * | ||
19 | * You should have received a copy of the GNU General Public License along | ||
20 | * with this program; if not, write the Free Software Foundation, Inc., 59 | ||
21 | * Temple Place - Suite 330, Boston MA 02111-1307, USA. | ||
22 | * | ||
23 | * Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy, | ||
24 | * Mountain View, CA 94043, or: | ||
25 | * | ||
26 | * http://www.sgi.com | ||
27 | * | ||
28 | * For further information regarding this notice, see: | ||
29 | * | ||
30 | * http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/ | ||
31 | */ | 17 | */ |
32 | #ifndef __XFS_BUF_ITEM_H__ | 18 | #ifndef __XFS_BUF_ITEM_H__ |
33 | #define __XFS_BUF_ITEM_H__ | 19 | #define __XFS_BUF_ITEM_H__ |
diff --git a/fs/xfs/xfs_cap.h b/fs/xfs/xfs_cap.h index 2deac7303758..433ec537f9bd 100644 --- a/fs/xfs/xfs_cap.h +++ b/fs/xfs/xfs_cap.h | |||
@@ -1,33 +1,19 @@ | |||
1 | /* | 1 | /* |
2 | * Copyright (c) 2000-2002 Silicon Graphics, Inc. All Rights Reserved. | 2 | * Copyright (c) 2000-2002,2005 Silicon Graphics, Inc. |
3 | * All Rights Reserved. | ||
3 | * | 4 | * |
4 | * This program is free software; you can redistribute it and/or modify it | 5 | * This program is free software; you can redistribute it and/or |
5 | * under the terms of version 2 of the GNU General Public License as | 6 | * modify it under the terms of the GNU General Public License as |
6 | * published by the Free Software Foundation. | 7 | * published by the Free Software Foundation. |
7 | * | 8 | * |
8 | * This program is distributed in the hope that it would be useful, but | 9 | * This program is distributed in the hope that it would be useful, |
9 | * WITHOUT ANY WARRANTY; without even the implied warranty of | 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
12 | * GNU General Public License for more details. | ||
11 | * | 13 | * |
12 | * Further, this software is distributed without any warranty that it is | 14 | * You should have received a copy of the GNU General Public License |
13 | * free of the rightful claim of any third person regarding infringement | 15 | * along with this program; if not, write the Free Software Foundation, |
14 | * or the like. Any license provided herein, whether implied or | 16 | * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
15 | * otherwise, applies only to this software file. Patent licenses, if | ||
16 | * any, provided herein do not apply to combinations of this program with | ||
17 | * other software, or any other product whatsoever. | ||
18 | * | ||
19 | * You should have received a copy of the GNU General Public License along | ||
20 | * with this program; if not, write the Free Software Foundation, Inc., 59 | ||
21 | * Temple Place - Suite 330, Boston MA 02111-1307, USA. | ||
22 | * | ||
23 | * Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy, | ||
24 | * Mountain View, CA 94043, or: | ||
25 | * | ||
26 | * http://www.sgi.com | ||
27 | * | ||
28 | * For further information regarding this notice, see: | ||
29 | * | ||
30 | * http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/ | ||
31 | */ | 17 | */ |
32 | #ifndef __XFS_CAP_H__ | 18 | #ifndef __XFS_CAP_H__ |
33 | #define __XFS_CAP_H__ | 19 | #define __XFS_CAP_H__ |
diff --git a/fs/xfs/xfs_clnt.h b/fs/xfs/xfs_clnt.h index b3215ffe0be8..328a528b926d 100644 --- a/fs/xfs/xfs_clnt.h +++ b/fs/xfs/xfs_clnt.h | |||
@@ -1,33 +1,19 @@ | |||
1 | /* | 1 | /* |
2 | * Copyright (c) 2000-2005 Silicon Graphics, Inc. All Rights Reserved. | 2 | * Copyright (c) 2000-2005 Silicon Graphics, Inc. |
3 | * All Rights Reserved. | ||
3 | * | 4 | * |
4 | * This program is free software; you can redistribute it and/or modify it | 5 | * This program is free software; you can redistribute it and/or |
5 | * under the terms of version 2 of the GNU General Public License as | 6 | * modify it under the terms of the GNU General Public License as |
6 | * published by the Free Software Foundation. | 7 | * published by the Free Software Foundation. |
7 | * | 8 | * |
8 | * This program is distributed in the hope that it would be useful, but | 9 | * This program is distributed in the hope that it would be useful, |
9 | * WITHOUT ANY WARRANTY; without even the implied warranty of | 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
12 | * GNU General Public License for more details. | ||
11 | * | 13 | * |
12 | * Further, this software is distributed without any warranty that it is | 14 | * You should have received a copy of the GNU General Public License |
13 | * free of the rightful claim of any third person regarding infringement | 15 | * along with this program; if not, write the Free Software Foundation, |
14 | * or the like. Any license provided herein, whether implied or | 16 | * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
15 | * otherwise, applies only to this software file. Patent licenses, if | ||
16 | * any, provided herein do not apply to combinations of this program with | ||
17 | * other software, or any other product whatsoever. | ||
18 | * | ||
19 | * You should have received a copy of the GNU General Public License along | ||
20 | * with this program; if not, write the Free Software Foundation, Inc., 59 | ||
21 | * Temple Place - Suite 330, Boston MA 02111-1307, USA. | ||
22 | * | ||
23 | * Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy, | ||
24 | * Mountain View, CA 94043, or: | ||
25 | * | ||
26 | * http://www.sgi.com | ||
27 | * | ||
28 | * For further information regarding this notice, see: | ||
29 | * | ||
30 | * http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/ | ||
31 | */ | 17 | */ |
32 | #ifndef __XFS_CLNT_H__ | 18 | #ifndef __XFS_CLNT_H__ |
33 | #define __XFS_CLNT_H__ | 19 | #define __XFS_CLNT_H__ |
@@ -55,6 +41,7 @@ | |||
55 | */ | 41 | */ |
56 | struct xfs_mount_args { | 42 | struct xfs_mount_args { |
57 | int flags; /* flags -> see XFSMNT_... macros below */ | 43 | int flags; /* flags -> see XFSMNT_... macros below */ |
44 | int flags2; /* flags -> see XFSMNT2_... macros below */ | ||
58 | int logbufs; /* Number of log buffers, -1 to default */ | 45 | int logbufs; /* Number of log buffers, -1 to default */ |
59 | int logbufsize; /* Size of log buffers, -1 to default */ | 46 | int logbufsize; /* Size of log buffers, -1 to default */ |
60 | char fsname[MAXNAMELEN+1]; /* data device name */ | 47 | char fsname[MAXNAMELEN+1]; /* data device name */ |
@@ -68,9 +55,9 @@ struct xfs_mount_args { | |||
68 | }; | 55 | }; |
69 | 56 | ||
70 | /* | 57 | /* |
71 | * XFS mount option flags | 58 | * XFS mount option flags -- args->flags1 |
72 | */ | 59 | */ |
73 | #define XFSMNT_CHKLOG 0x00000001 /* check log */ | 60 | #define XFSMNT_COMPAT_ATTR 0x00000001 /* do not use ATTR2 format */ |
74 | #define XFSMNT_WSYNC 0x00000002 /* safe mode nfs mount | 61 | #define XFSMNT_WSYNC 0x00000002 /* safe mode nfs mount |
75 | * compatible */ | 62 | * compatible */ |
76 | #define XFSMNT_INO64 0x00000004 /* move inode numbers up | 63 | #define XFSMNT_INO64 0x00000004 /* move inode numbers up |
@@ -91,7 +78,7 @@ struct xfs_mount_args { | |||
91 | #define XFSMNT_SHARED 0x00001000 /* shared XFS mount */ | 78 | #define XFSMNT_SHARED 0x00001000 /* shared XFS mount */ |
92 | #define XFSMNT_IOSIZE 0x00002000 /* optimize for I/O size */ | 79 | #define XFSMNT_IOSIZE 0x00002000 /* optimize for I/O size */ |
93 | #define XFSMNT_OSYNCISOSYNC 0x00004000 /* o_sync is REALLY o_sync */ | 80 | #define XFSMNT_OSYNCISOSYNC 0x00004000 /* o_sync is REALLY o_sync */ |
94 | /* (osyncisdsync is now default) */ | 81 | /* (osyncisdsync is default) */ |
95 | #define XFSMNT_32BITINODES 0x00200000 /* restrict inodes to 32 | 82 | #define XFSMNT_32BITINODES 0x00200000 /* restrict inodes to 32 |
96 | * bits of address space */ | 83 | * bits of address space */ |
97 | #define XFSMNT_GQUOTA 0x00400000 /* group quota accounting */ | 84 | #define XFSMNT_GQUOTA 0x00400000 /* group quota accounting */ |
@@ -99,12 +86,19 @@ struct xfs_mount_args { | |||
99 | * enforcement */ | 86 | * enforcement */ |
100 | #define XFSMNT_NOUUID 0x01000000 /* Ignore fs uuid */ | 87 | #define XFSMNT_NOUUID 0x01000000 /* Ignore fs uuid */ |
101 | #define XFSMNT_DMAPI 0x02000000 /* enable dmapi/xdsm */ | 88 | #define XFSMNT_DMAPI 0x02000000 /* enable dmapi/xdsm */ |
102 | #define XFSMNT_NOLOGFLUSH 0x04000000 /* Don't flush for log blocks */ | 89 | #define XFSMNT_BARRIER 0x04000000 /* use write barriers */ |
103 | #define XFSMNT_IDELETE 0x08000000 /* inode cluster delete */ | 90 | #define XFSMNT_IDELETE 0x08000000 /* inode cluster delete */ |
104 | #define XFSMNT_SWALLOC 0x10000000 /* turn on stripe width | 91 | #define XFSMNT_SWALLOC 0x10000000 /* turn on stripe width |
105 | * allocation */ | 92 | * allocation */ |
106 | #define XFSMNT_IHASHSIZE 0x20000000 /* inode hash table size */ | 93 | #define XFSMNT_IHASHSIZE 0x20000000 /* inode hash table size */ |
107 | #define XFSMNT_DIRSYNC 0x40000000 /* sync creat,link,unlink,rename | 94 | #define XFSMNT_DIRSYNC 0x40000000 /* sync creat,link,unlink,rename |
108 | * symlink,mkdir,rmdir,mknod */ | 95 | * symlink,mkdir,rmdir,mknod */ |
96 | #define XFSMNT_FLAGS2 0x80000000 /* more flags set in flags2 */ | ||
97 | |||
98 | /* | ||
99 | * XFS mount option flags -- args->flags2 | ||
100 | */ | ||
101 | #define XFSMNT2_COMPAT_IOSIZE 0x00000001 /* don't report large preferred | ||
102 | * I/O size in stat(2) */ | ||
109 | 103 | ||
110 | #endif /* __XFS_CLNT_H__ */ | 104 | #endif /* __XFS_CLNT_H__ */ |
diff --git a/fs/xfs/xfs_da_btree.c b/fs/xfs/xfs_da_btree.c index 8b792ddf2164..473671fa5c13 100644 --- a/fs/xfs/xfs_da_btree.c +++ b/fs/xfs/xfs_da_btree.c | |||
@@ -1,41 +1,26 @@ | |||
1 | /* | 1 | /* |
2 | * Copyright (c) 2000-2004 Silicon Graphics, Inc. All Rights Reserved. | 2 | * Copyright (c) 2000-2005 Silicon Graphics, Inc. |
3 | * All Rights Reserved. | ||
3 | * | 4 | * |
4 | * This program is free software; you can redistribute it and/or modify it | 5 | * This program is free software; you can redistribute it and/or |
5 | * under the terms of version 2 of the GNU General Public License as | 6 | * modify it under the terms of the GNU General Public License as |
6 | * published by the Free Software Foundation. | 7 | * published by the Free Software Foundation. |
7 | * | 8 | * |
8 | * This program is distributed in the hope that it would be useful, but | 9 | * This program is distributed in the hope that it would be useful, |
9 | * WITHOUT ANY WARRANTY; without even the implied warranty of | 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
12 | * GNU General Public License for more details. | ||
11 | * | 13 | * |
12 | * Further, this software is distributed without any warranty that it is | 14 | * You should have received a copy of the GNU General Public License |
13 | * free of the rightful claim of any third person regarding infringement | 15 | * along with this program; if not, write the Free Software Foundation, |
14 | * or the like. Any license provided herein, whether implied or | 16 | * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
15 | * otherwise, applies only to this software file. Patent licenses, if | ||
16 | * any, provided herein do not apply to combinations of this program with | ||
17 | * other software, or any other product whatsoever. | ||
18 | * | ||
19 | * You should have received a copy of the GNU General Public License along | ||
20 | * with this program; if not, write the Free Software Foundation, Inc., 59 | ||
21 | * Temple Place - Suite 330, Boston MA 02111-1307, USA. | ||
22 | * | ||
23 | * Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy, | ||
24 | * Mountain View, CA 94043, or: | ||
25 | * | ||
26 | * http://www.sgi.com | ||
27 | * | ||
28 | * For further information regarding this notice, see: | ||
29 | * | ||
30 | * http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/ | ||
31 | */ | 17 | */ |
32 | |||
33 | #include "xfs.h" | 18 | #include "xfs.h" |
34 | 19 | #include "xfs_fs.h" | |
35 | #include "xfs_macros.h" | ||
36 | #include "xfs_types.h" | 20 | #include "xfs_types.h" |
37 | #include "xfs_inum.h" | 21 | #include "xfs_bit.h" |
38 | #include "xfs_log.h" | 22 | #include "xfs_log.h" |
23 | #include "xfs_inum.h" | ||
39 | #include "xfs_trans.h" | 24 | #include "xfs_trans.h" |
40 | #include "xfs_sb.h" | 25 | #include "xfs_sb.h" |
41 | #include "xfs_ag.h" | 26 | #include "xfs_ag.h" |
@@ -43,19 +28,19 @@ | |||
43 | #include "xfs_dir2.h" | 28 | #include "xfs_dir2.h" |
44 | #include "xfs_dmapi.h" | 29 | #include "xfs_dmapi.h" |
45 | #include "xfs_mount.h" | 30 | #include "xfs_mount.h" |
46 | #include "xfs_alloc_btree.h" | 31 | #include "xfs_da_btree.h" |
47 | #include "xfs_bmap_btree.h" | 32 | #include "xfs_bmap_btree.h" |
33 | #include "xfs_alloc_btree.h" | ||
48 | #include "xfs_ialloc_btree.h" | 34 | #include "xfs_ialloc_btree.h" |
49 | #include "xfs_alloc.h" | ||
50 | #include "xfs_btree.h" | ||
51 | #include "xfs_attr_sf.h" | ||
52 | #include "xfs_dir_sf.h" | 35 | #include "xfs_dir_sf.h" |
53 | #include "xfs_dir2_sf.h" | 36 | #include "xfs_dir2_sf.h" |
37 | #include "xfs_attr_sf.h" | ||
54 | #include "xfs_dinode.h" | 38 | #include "xfs_dinode.h" |
55 | #include "xfs_inode_item.h" | ||
56 | #include "xfs_inode.h" | 39 | #include "xfs_inode.h" |
40 | #include "xfs_inode_item.h" | ||
41 | #include "xfs_alloc.h" | ||
42 | #include "xfs_btree.h" | ||
57 | #include "xfs_bmap.h" | 43 | #include "xfs_bmap.h" |
58 | #include "xfs_da_btree.h" | ||
59 | #include "xfs_attr.h" | 44 | #include "xfs_attr.h" |
60 | #include "xfs_attr_leaf.h" | 45 | #include "xfs_attr_leaf.h" |
61 | #include "xfs_dir_leaf.h" | 46 | #include "xfs_dir_leaf.h" |
@@ -64,7 +49,6 @@ | |||
64 | #include "xfs_dir2_block.h" | 49 | #include "xfs_dir2_block.h" |
65 | #include "xfs_dir2_node.h" | 50 | #include "xfs_dir2_node.h" |
66 | #include "xfs_error.h" | 51 | #include "xfs_error.h" |
67 | #include "xfs_bit.h" | ||
68 | 52 | ||
69 | /* | 53 | /* |
70 | * xfs_da_btree.c | 54 | * xfs_da_btree.c |
@@ -190,9 +174,6 @@ xfs_da_split(xfs_da_state_t *state) | |||
190 | */ | 174 | */ |
191 | switch (oldblk->magic) { | 175 | switch (oldblk->magic) { |
192 | case XFS_ATTR_LEAF_MAGIC: | 176 | case XFS_ATTR_LEAF_MAGIC: |
193 | #ifndef __KERNEL__ | ||
194 | return(ENOTTY); | ||
195 | #else | ||
196 | error = xfs_attr_leaf_split(state, oldblk, newblk); | 177 | error = xfs_attr_leaf_split(state, oldblk, newblk); |
197 | if ((error != 0) && (error != ENOSPC)) { | 178 | if ((error != 0) && (error != ENOSPC)) { |
198 | return(error); /* GROT: attr is inconsistent */ | 179 | return(error); /* GROT: attr is inconsistent */ |
@@ -218,7 +199,6 @@ xfs_da_split(xfs_da_state_t *state) | |||
218 | return(error); /* GROT: attr inconsistent */ | 199 | return(error); /* GROT: attr inconsistent */ |
219 | addblk = newblk; | 200 | addblk = newblk; |
220 | break; | 201 | break; |
221 | #endif | ||
222 | case XFS_DIR_LEAF_MAGIC: | 202 | case XFS_DIR_LEAF_MAGIC: |
223 | ASSERT(XFS_DIR_IS_V1(state->mp)); | 203 | ASSERT(XFS_DIR_IS_V1(state->mp)); |
224 | error = xfs_dir_leaf_split(state, oldblk, newblk); | 204 | error = xfs_dir_leaf_split(state, oldblk, newblk); |
@@ -449,7 +429,8 @@ xfs_da_node_split(xfs_da_state_t *state, xfs_da_state_blk_t *oldblk, | |||
449 | /* | 429 | /* |
450 | * With V2 the extra block is data or freespace. | 430 | * With V2 the extra block is data or freespace. |
451 | */ | 431 | */ |
452 | useextra = state->extravalid && XFS_DIR_IS_V1(state->mp); | 432 | useextra = state->extravalid && (XFS_DIR_IS_V1(state->mp) || |
433 | state->args->whichfork == XFS_ATTR_FORK); | ||
453 | newcount = 1 + useextra; | 434 | newcount = 1 + useextra; |
454 | /* | 435 | /* |
455 | * Do we have to split the node? | 436 | * Do we have to split the node? |
@@ -706,18 +687,12 @@ xfs_da_join(xfs_da_state_t *state) | |||
706 | */ | 687 | */ |
707 | switch (drop_blk->magic) { | 688 | switch (drop_blk->magic) { |
708 | case XFS_ATTR_LEAF_MAGIC: | 689 | case XFS_ATTR_LEAF_MAGIC: |
709 | #ifndef __KERNEL__ | ||
710 | error = ENOTTY; | ||
711 | #else | ||
712 | error = xfs_attr_leaf_toosmall(state, &action); | 690 | error = xfs_attr_leaf_toosmall(state, &action); |
713 | #endif | ||
714 | if (error) | 691 | if (error) |
715 | return(error); | 692 | return(error); |
716 | if (action == 0) | 693 | if (action == 0) |
717 | return(0); | 694 | return(0); |
718 | #ifdef __KERNEL__ | ||
719 | xfs_attr_leaf_unbalance(state, drop_blk, save_blk); | 695 | xfs_attr_leaf_unbalance(state, drop_blk, save_blk); |
720 | #endif | ||
721 | break; | 696 | break; |
722 | case XFS_DIR_LEAF_MAGIC: | 697 | case XFS_DIR_LEAF_MAGIC: |
723 | ASSERT(XFS_DIR_IS_V1(state->mp)); | 698 | ASSERT(XFS_DIR_IS_V1(state->mp)); |
@@ -973,13 +948,11 @@ xfs_da_fixhashpath(xfs_da_state_t *state, xfs_da_state_path_t *path) | |||
973 | level = path->active-1; | 948 | level = path->active-1; |
974 | blk = &path->blk[ level ]; | 949 | blk = &path->blk[ level ]; |
975 | switch (blk->magic) { | 950 | switch (blk->magic) { |
976 | #ifdef __KERNEL__ | ||
977 | case XFS_ATTR_LEAF_MAGIC: | 951 | case XFS_ATTR_LEAF_MAGIC: |
978 | lasthash = xfs_attr_leaf_lasthash(blk->bp, &count); | 952 | lasthash = xfs_attr_leaf_lasthash(blk->bp, &count); |
979 | if (count == 0) | 953 | if (count == 0) |
980 | return; | 954 | return; |
981 | break; | 955 | break; |
982 | #endif | ||
983 | case XFS_DIR_LEAF_MAGIC: | 956 | case XFS_DIR_LEAF_MAGIC: |
984 | ASSERT(XFS_DIR_IS_V1(state->mp)); | 957 | ASSERT(XFS_DIR_IS_V1(state->mp)); |
985 | lasthash = xfs_dir_leaf_lasthash(blk->bp, &count); | 958 | lasthash = xfs_dir_leaf_lasthash(blk->bp, &count); |
@@ -1220,12 +1193,10 @@ xfs_da_node_lookup_int(xfs_da_state_t *state, int *result) | |||
1220 | blkno = INT_GET(btree->before, ARCH_CONVERT); | 1193 | blkno = INT_GET(btree->before, ARCH_CONVERT); |
1221 | } | 1194 | } |
1222 | } | 1195 | } |
1223 | #ifdef __KERNEL__ | ||
1224 | else if (INT_GET(curr->magic, ARCH_CONVERT) == XFS_ATTR_LEAF_MAGIC) { | 1196 | else if (INT_GET(curr->magic, ARCH_CONVERT) == XFS_ATTR_LEAF_MAGIC) { |
1225 | blk->hashval = xfs_attr_leaf_lasthash(blk->bp, NULL); | 1197 | blk->hashval = xfs_attr_leaf_lasthash(blk->bp, NULL); |
1226 | break; | 1198 | break; |
1227 | } | 1199 | } |
1228 | #endif | ||
1229 | else if (INT_GET(curr->magic, ARCH_CONVERT) == XFS_DIR_LEAF_MAGIC) { | 1200 | else if (INT_GET(curr->magic, ARCH_CONVERT) == XFS_DIR_LEAF_MAGIC) { |
1230 | blk->hashval = xfs_dir_leaf_lasthash(blk->bp, NULL); | 1201 | blk->hashval = xfs_dir_leaf_lasthash(blk->bp, NULL); |
1231 | break; | 1202 | break; |
@@ -1252,13 +1223,11 @@ xfs_da_node_lookup_int(xfs_da_state_t *state, int *result) | |||
1252 | retval = xfs_dir2_leafn_lookup_int(blk->bp, args, | 1223 | retval = xfs_dir2_leafn_lookup_int(blk->bp, args, |
1253 | &blk->index, state); | 1224 | &blk->index, state); |
1254 | } | 1225 | } |
1255 | #ifdef __KERNEL__ | ||
1256 | else if (blk->magic == XFS_ATTR_LEAF_MAGIC) { | 1226 | else if (blk->magic == XFS_ATTR_LEAF_MAGIC) { |
1257 | retval = xfs_attr_leaf_lookup_int(blk->bp, args); | 1227 | retval = xfs_attr_leaf_lookup_int(blk->bp, args); |
1258 | blk->index = args->index; | 1228 | blk->index = args->index; |
1259 | args->blkno = blk->blkno; | 1229 | args->blkno = blk->blkno; |
1260 | } | 1230 | } |
1261 | #endif | ||
1262 | if (((retval == ENOENT) || (retval == ENOATTR)) && | 1231 | if (((retval == ENOENT) || (retval == ENOATTR)) && |
1263 | (blk->hashval == args->hashval)) { | 1232 | (blk->hashval == args->hashval)) { |
1264 | error = xfs_da_path_shift(state, &state->path, 1, 1, | 1233 | error = xfs_da_path_shift(state, &state->path, 1, 1, |
@@ -1268,12 +1237,10 @@ xfs_da_node_lookup_int(xfs_da_state_t *state, int *result) | |||
1268 | if (retval == 0) { | 1237 | if (retval == 0) { |
1269 | continue; | 1238 | continue; |
1270 | } | 1239 | } |
1271 | #ifdef __KERNEL__ | ||
1272 | else if (blk->magic == XFS_ATTR_LEAF_MAGIC) { | 1240 | else if (blk->magic == XFS_ATTR_LEAF_MAGIC) { |
1273 | /* path_shift() gives ENOENT */ | 1241 | /* path_shift() gives ENOENT */ |
1274 | retval = XFS_ERROR(ENOATTR); | 1242 | retval = XFS_ERROR(ENOATTR); |
1275 | } | 1243 | } |
1276 | #endif | ||
1277 | } | 1244 | } |
1278 | break; | 1245 | break; |
1279 | } | 1246 | } |
@@ -1312,11 +1279,9 @@ xfs_da_blk_link(xfs_da_state_t *state, xfs_da_state_blk_t *old_blk, | |||
1312 | ASSERT(old_blk->magic == new_blk->magic); | 1279 | ASSERT(old_blk->magic == new_blk->magic); |
1313 | 1280 | ||
1314 | switch (old_blk->magic) { | 1281 | switch (old_blk->magic) { |
1315 | #ifdef __KERNEL__ | ||
1316 | case XFS_ATTR_LEAF_MAGIC: | 1282 | case XFS_ATTR_LEAF_MAGIC: |
1317 | before = xfs_attr_leaf_order(old_blk->bp, new_blk->bp); | 1283 | before = xfs_attr_leaf_order(old_blk->bp, new_blk->bp); |
1318 | break; | 1284 | break; |
1319 | #endif | ||
1320 | case XFS_DIR_LEAF_MAGIC: | 1285 | case XFS_DIR_LEAF_MAGIC: |
1321 | ASSERT(XFS_DIR_IS_V1(state->mp)); | 1286 | ASSERT(XFS_DIR_IS_V1(state->mp)); |
1322 | before = xfs_dir_leaf_order(old_blk->bp, new_blk->bp); | 1287 | before = xfs_dir_leaf_order(old_blk->bp, new_blk->bp); |
@@ -1587,12 +1552,10 @@ xfs_da_path_shift(xfs_da_state_t *state, xfs_da_state_path_t *path, | |||
1587 | ASSERT(level == path->active-1); | 1552 | ASSERT(level == path->active-1); |
1588 | blk->index = 0; | 1553 | blk->index = 0; |
1589 | switch(blk->magic) { | 1554 | switch(blk->magic) { |
1590 | #ifdef __KERNEL__ | ||
1591 | case XFS_ATTR_LEAF_MAGIC: | 1555 | case XFS_ATTR_LEAF_MAGIC: |
1592 | blk->hashval = xfs_attr_leaf_lasthash(blk->bp, | 1556 | blk->hashval = xfs_attr_leaf_lasthash(blk->bp, |
1593 | NULL); | 1557 | NULL); |
1594 | break; | 1558 | break; |
1595 | #endif | ||
1596 | case XFS_DIR_LEAF_MAGIC: | 1559 | case XFS_DIR_LEAF_MAGIC: |
1597 | ASSERT(XFS_DIR_IS_V1(state->mp)); | 1560 | ASSERT(XFS_DIR_IS_V1(state->mp)); |
1598 | blk->hashval = xfs_dir_leaf_lasthash(blk->bp, | 1561 | blk->hashval = xfs_dir_leaf_lasthash(blk->bp, |
@@ -1626,19 +1589,10 @@ xfs_da_path_shift(xfs_da_state_t *state, xfs_da_state_path_t *path, | |||
1626 | * This is implemented with some source-level loop unrolling. | 1589 | * This is implemented with some source-level loop unrolling. |
1627 | */ | 1590 | */ |
1628 | xfs_dahash_t | 1591 | xfs_dahash_t |
1629 | xfs_da_hashname(uchar_t *name, int namelen) | 1592 | xfs_da_hashname(const uchar_t *name, int namelen) |
1630 | { | 1593 | { |
1631 | xfs_dahash_t hash; | 1594 | xfs_dahash_t hash; |
1632 | 1595 | ||
1633 | #ifdef SLOWVERSION | ||
1634 | /* | ||
1635 | * This is the old one-byte-at-a-time version. | ||
1636 | */ | ||
1637 | for (hash = 0; namelen > 0; namelen--) | ||
1638 | hash = *name++ ^ rol32(hash, 7); | ||
1639 | |||
1640 | return(hash); | ||
1641 | #else | ||
1642 | /* | 1596 | /* |
1643 | * Do four characters at a time as long as we can. | 1597 | * Do four characters at a time as long as we can. |
1644 | */ | 1598 | */ |
@@ -1657,12 +1611,9 @@ xfs_da_hashname(uchar_t *name, int namelen) | |||
1657 | return (name[0] << 7) ^ (name[1] << 0) ^ rol32(hash, 7 * 2); | 1611 | return (name[0] << 7) ^ (name[1] << 0) ^ rol32(hash, 7 * 2); |
1658 | case 1: | 1612 | case 1: |
1659 | return (name[0] << 0) ^ rol32(hash, 7 * 1); | 1613 | return (name[0] << 0) ^ rol32(hash, 7 * 1); |
1660 | case 0: | 1614 | default: /* case 0: */ |
1661 | return hash; | 1615 | return hash; |
1662 | } | 1616 | } |
1663 | /* NOTREACHED */ | ||
1664 | #endif | ||
1665 | return 0; /* keep gcc happy */ | ||
1666 | } | 1617 | } |
1667 | 1618 | ||
1668 | /* | 1619 | /* |
@@ -2200,20 +2151,16 @@ xfs_da_do_buf( | |||
2200 | error = bp ? XFS_BUF_GETERROR(bp) : XFS_ERROR(EIO); | 2151 | error = bp ? XFS_BUF_GETERROR(bp) : XFS_ERROR(EIO); |
2201 | break; | 2152 | break; |
2202 | case 1: | 2153 | case 1: |
2203 | #ifndef __KERNEL__ | ||
2204 | case 2: | 2154 | case 2: |
2205 | #endif | ||
2206 | bp = NULL; | 2155 | bp = NULL; |
2207 | error = xfs_trans_read_buf(mp, trans, mp->m_ddev_targp, | 2156 | error = xfs_trans_read_buf(mp, trans, mp->m_ddev_targp, |
2208 | mappedbno, nmapped, 0, &bp); | 2157 | mappedbno, nmapped, 0, &bp); |
2209 | break; | 2158 | break; |
2210 | #ifdef __KERNEL__ | ||
2211 | case 3: | 2159 | case 3: |
2212 | xfs_baread(mp->m_ddev_targp, mappedbno, nmapped); | 2160 | xfs_baread(mp->m_ddev_targp, mappedbno, nmapped); |
2213 | error = 0; | 2161 | error = 0; |
2214 | bp = NULL; | 2162 | bp = NULL; |
2215 | break; | 2163 | break; |
2216 | #endif | ||
2217 | } | 2164 | } |
2218 | if (error) { | 2165 | if (error) { |
2219 | if (bp) | 2166 | if (bp) |
diff --git a/fs/xfs/xfs_da_btree.h b/fs/xfs/xfs_da_btree.h index 3a9b9e809c60..41352113721a 100644 --- a/fs/xfs/xfs_da_btree.h +++ b/fs/xfs/xfs_da_btree.h | |||
@@ -1,33 +1,19 @@ | |||
1 | /* | 1 | /* |
2 | * Copyright (c) 2000, 2002 Silicon Graphics, Inc. All Rights Reserved. | 2 | * Copyright (c) 2000,2002,2005 Silicon Graphics, Inc. |
3 | * All Rights Reserved. | ||
3 | * | 4 | * |
4 | * This program is free software; you can redistribute it and/or modify it | 5 | * This program is free software; you can redistribute it and/or |
5 | * under the terms of version 2 of the GNU General Public License as | 6 | * modify it under the terms of the GNU General Public License as |
6 | * published by the Free Software Foundation. | 7 | * published by the Free Software Foundation. |
7 | * | 8 | * |
8 | * This program is distributed in the hope that it would be useful, but | 9 | * This program is distributed in the hope that it would be useful, |
9 | * WITHOUT ANY WARRANTY; without even the implied warranty of | 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
12 | * GNU General Public License for more details. | ||
11 | * | 13 | * |
12 | * Further, this software is distributed without any warranty that it is | 14 | * You should have received a copy of the GNU General Public License |
13 | * free of the rightful claim of any third person regarding infringement | 15 | * along with this program; if not, write the Free Software Foundation, |
14 | * or the like. Any license provided herein, whether implied or | 16 | * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
15 | * otherwise, applies only to this software file. Patent licenses, if | ||
16 | * any, provided herein do not apply to combinations of this program with | ||
17 | * other software, or any other product whatsoever. | ||
18 | * | ||
19 | * You should have received a copy of the GNU General Public License along | ||
20 | * with this program; if not, write the Free Software Foundation, Inc., 59 | ||
21 | * Temple Place - Suite 330, Boston MA 02111-1307, USA. | ||
22 | * | ||
23 | * Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy, | ||
24 | * Mountain View, CA 94043, or: | ||
25 | * | ||
26 | * http://www.sgi.com | ||
27 | * | ||
28 | * For further information regarding this notice, see: | ||
29 | * | ||
30 | * http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/ | ||
31 | */ | 17 | */ |
32 | #ifndef __XFS_DA_BTREE_H__ | 18 | #ifndef __XFS_DA_BTREE_H__ |
33 | #define __XFS_DA_BTREE_H__ | 19 | #define __XFS_DA_BTREE_H__ |
@@ -92,72 +78,24 @@ typedef struct xfs_da_node_entry xfs_da_node_entry_t; | |||
92 | 78 | ||
93 | #define XFS_DA_MAXHASH ((xfs_dahash_t)-1) /* largest valid hash value */ | 79 | #define XFS_DA_MAXHASH ((xfs_dahash_t)-1) /* largest valid hash value */ |
94 | 80 | ||
95 | /* | 81 | #define XFS_LBSIZE(mp) (mp)->m_sb.sb_blocksize |
96 | * Macros used by directory code to interface to the filesystem. | 82 | #define XFS_LBLOG(mp) (mp)->m_sb.sb_blocklog |
97 | */ | ||
98 | #if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_LBSIZE) | ||
99 | int xfs_lbsize(struct xfs_mount *mp); | ||
100 | #define XFS_LBSIZE(mp) xfs_lbsize(mp) | ||
101 | #else | ||
102 | #define XFS_LBSIZE(mp) ((mp)->m_sb.sb_blocksize) | ||
103 | #endif | ||
104 | #if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_LBLOG) | ||
105 | int xfs_lblog(struct xfs_mount *mp); | ||
106 | #define XFS_LBLOG(mp) xfs_lblog(mp) | ||
107 | #else | ||
108 | #define XFS_LBLOG(mp) ((mp)->m_sb.sb_blocklog) | ||
109 | #endif | ||
110 | 83 | ||
111 | /* | ||
112 | * Macros used by directory code to interface to the kernel | ||
113 | */ | ||
114 | |||
115 | /* | ||
116 | * Macros used to manipulate directory off_t's | ||
117 | */ | ||
118 | #if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_DA_MAKE_BNOENTRY) | ||
119 | __uint32_t xfs_da_make_bnoentry(struct xfs_mount *mp, xfs_dablk_t bno, | ||
120 | int entry); | ||
121 | #define XFS_DA_MAKE_BNOENTRY(mp,bno,entry) \ | 84 | #define XFS_DA_MAKE_BNOENTRY(mp,bno,entry) \ |
122 | xfs_da_make_bnoentry(mp,bno,entry) | ||
123 | #else | ||
124 | #define XFS_DA_MAKE_BNOENTRY(mp,bno,entry) \ | ||
125 | (((bno) << (mp)->m_dircook_elog) | (entry)) | 85 | (((bno) << (mp)->m_dircook_elog) | (entry)) |
126 | #endif | ||
127 | #if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_DA_MAKE_COOKIE) | ||
128 | xfs_off_t xfs_da_make_cookie(struct xfs_mount *mp, xfs_dablk_t bno, int entry, | ||
129 | xfs_dahash_t hash); | ||
130 | #define XFS_DA_MAKE_COOKIE(mp,bno,entry,hash) \ | 86 | #define XFS_DA_MAKE_COOKIE(mp,bno,entry,hash) \ |
131 | xfs_da_make_cookie(mp,bno,entry,hash) | ||
132 | #else | ||
133 | #define XFS_DA_MAKE_COOKIE(mp,bno,entry,hash) \ | ||
134 | (((xfs_off_t)XFS_DA_MAKE_BNOENTRY(mp, bno, entry) << 32) | (hash)) | 87 | (((xfs_off_t)XFS_DA_MAKE_BNOENTRY(mp, bno, entry) << 32) | (hash)) |
135 | #endif | 88 | #define XFS_DA_COOKIE_HASH(mp,cookie) ((xfs_dahash_t)cookie) |
136 | #if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_DA_COOKIE_HASH) | 89 | #define XFS_DA_COOKIE_BNO(mp,cookie) \ |
137 | xfs_dahash_t xfs_da_cookie_hash(struct xfs_mount *mp, xfs_off_t cookie); | 90 | ((((xfs_off_t)(cookie) >> 31) == -1LL ? \ |
138 | #define XFS_DA_COOKIE_HASH(mp,cookie) xfs_da_cookie_hash(mp,cookie) | ||
139 | #else | ||
140 | #define XFS_DA_COOKIE_HASH(mp,cookie) ((xfs_dahash_t)(cookie)) | ||
141 | #endif | ||
142 | #if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_DA_COOKIE_BNO) | ||
143 | xfs_dablk_t xfs_da_cookie_bno(struct xfs_mount *mp, xfs_off_t cookie); | ||
144 | #define XFS_DA_COOKIE_BNO(mp,cookie) xfs_da_cookie_bno(mp,cookie) | ||
145 | #else | ||
146 | #define XFS_DA_COOKIE_BNO(mp,cookie) \ | ||
147 | (((xfs_off_t)(cookie) >> 31) == -1LL ? \ | ||
148 | (xfs_dablk_t)0 : \ | 91 | (xfs_dablk_t)0 : \ |
149 | (xfs_dablk_t)((xfs_off_t)(cookie) >> ((mp)->m_dircook_elog + 32))) | 92 | (xfs_dablk_t)((xfs_off_t)(cookie) >> \ |
150 | #endif | 93 | ((mp)->m_dircook_elog + 32)))) |
151 | #if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_DA_COOKIE_ENTRY) | 94 | #define XFS_DA_COOKIE_ENTRY(mp,cookie) \ |
152 | int xfs_da_cookie_entry(struct xfs_mount *mp, xfs_off_t cookie); | 95 | ((((xfs_off_t)(cookie) >> 31) == -1LL ? \ |
153 | #define XFS_DA_COOKIE_ENTRY(mp,cookie) xfs_da_cookie_entry(mp,cookie) | ||
154 | #else | ||
155 | #define XFS_DA_COOKIE_ENTRY(mp,cookie) \ | ||
156 | (((xfs_off_t)(cookie) >> 31) == -1LL ? \ | ||
157 | (xfs_dablk_t)0 : \ | 96 | (xfs_dablk_t)0 : \ |
158 | (xfs_dablk_t)(((xfs_off_t)(cookie) >> 32) & \ | 97 | (xfs_dablk_t)(((xfs_off_t)(cookie) >> 32) & \ |
159 | ((1 << (mp)->m_dircook_elog) - 1))) | 98 | ((1 << (mp)->m_dircook_elog) - 1)))) |
160 | #endif | ||
161 | 99 | ||
162 | 100 | ||
163 | /*======================================================================== | 101 | /*======================================================================== |
@@ -168,7 +106,7 @@ int xfs_da_cookie_entry(struct xfs_mount *mp, xfs_off_t cookie); | |||
168 | * Structure to ease passing around component names. | 106 | * Structure to ease passing around component names. |
169 | */ | 107 | */ |
170 | typedef struct xfs_da_args { | 108 | typedef struct xfs_da_args { |
171 | uchar_t *name; /* string (maybe not NULL terminated) */ | 109 | const uchar_t *name; /* string (maybe not NULL terminated) */ |
172 | int namelen; /* length of string (maybe no NULL) */ | 110 | int namelen; /* length of string (maybe no NULL) */ |
173 | uchar_t *value; /* set of bytes (maybe contain NULLs) */ | 111 | uchar_t *value; /* set of bytes (maybe contain NULLs) */ |
174 | int valuelen; /* length of value */ | 112 | int valuelen; /* length of value */ |
@@ -314,7 +252,7 @@ xfs_daddr_t xfs_da_reada_buf(struct xfs_trans *trans, struct xfs_inode *dp, | |||
314 | int xfs_da_shrink_inode(xfs_da_args_t *args, xfs_dablk_t dead_blkno, | 252 | int xfs_da_shrink_inode(xfs_da_args_t *args, xfs_dablk_t dead_blkno, |
315 | xfs_dabuf_t *dead_buf); | 253 | xfs_dabuf_t *dead_buf); |
316 | 254 | ||
317 | uint xfs_da_hashname(uchar_t *name_string, int name_length); | 255 | uint xfs_da_hashname(const uchar_t *name_string, int name_length); |
318 | uint xfs_da_log2_roundup(uint i); | 256 | uint xfs_da_log2_roundup(uint i); |
319 | xfs_da_state_t *xfs_da_state_alloc(void); | 257 | xfs_da_state_t *xfs_da_state_alloc(void); |
320 | void xfs_da_state_free(xfs_da_state_t *state); | 258 | void xfs_da_state_free(xfs_da_state_t *state); |
diff --git a/fs/xfs/xfs_dfrag.c b/fs/xfs/xfs_dfrag.c index 681be5c93af5..070259a4254c 100644 --- a/fs/xfs/xfs_dfrag.c +++ b/fs/xfs/xfs_dfrag.c | |||
@@ -1,58 +1,44 @@ | |||
1 | /* | 1 | /* |
2 | * Copyright (c) 2000-2002 Silicon Graphics, Inc. All Rights Reserved. | 2 | * Copyright (c) 2000-2002,2005 Silicon Graphics, Inc. |
3 | * All Rights Reserved. | ||
3 | * | 4 | * |
4 | * This program is free software; you can redistribute it and/or modify it | 5 | * This program is free software; you can redistribute it and/or |
5 | * under the terms of version 2 of the GNU General Public License as | 6 | * modify it under the terms of the GNU General Public License as |
6 | * published by the Free Software Foundation. | 7 | * published by the Free Software Foundation. |
7 | * | 8 | * |
8 | * This program is distributed in the hope that it would be useful, but | 9 | * This program is distributed in the hope that it would be useful, |
9 | * WITHOUT ANY WARRANTY; without even the implied warranty of | 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
12 | * GNU General Public License for more details. | ||
11 | * | 13 | * |
12 | * Further, this software is distributed without any warranty that it is | 14 | * You should have received a copy of the GNU General Public License |
13 | * free of the rightful claim of any third person regarding infringement | 15 | * along with this program; if not, write the Free Software Foundation, |
14 | * or the like. Any license provided herein, whether implied or | 16 | * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
15 | * otherwise, applies only to this software file. Patent licenses, if | ||
16 | * any, provided herein do not apply to combinations of this program with | ||
17 | * other software, or any other product whatsoever. | ||
18 | * | ||
19 | * You should have received a copy of the GNU General Public License along | ||
20 | * with this program; if not, write the Free Software Foundation, Inc., 59 | ||
21 | * Temple Place - Suite 330, Boston MA 02111-1307, USA. | ||
22 | * | ||
23 | * Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy, | ||
24 | * Mountain View, CA 94043, or: | ||
25 | * | ||
26 | * http://www.sgi.com | ||
27 | * | ||
28 | * For further information regarding this notice, see: | ||
29 | * | ||
30 | * http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/ | ||
31 | */ | 17 | */ |
32 | |||
33 | #include "xfs.h" | 18 | #include "xfs.h" |
34 | #include "xfs_macros.h" | 19 | #include "xfs_fs.h" |
35 | #include "xfs_types.h" | 20 | #include "xfs_types.h" |
36 | #include "xfs_inum.h" | 21 | #include "xfs_bit.h" |
37 | #include "xfs_log.h" | 22 | #include "xfs_log.h" |
23 | #include "xfs_inum.h" | ||
38 | #include "xfs_trans.h" | 24 | #include "xfs_trans.h" |
39 | #include "xfs_sb.h" | 25 | #include "xfs_sb.h" |
26 | #include "xfs_ag.h" | ||
40 | #include "xfs_dir.h" | 27 | #include "xfs_dir.h" |
41 | #include "xfs_dir2.h" | 28 | #include "xfs_dir2.h" |
42 | #include "xfs_dmapi.h" | 29 | #include "xfs_dmapi.h" |
43 | #include "xfs_mount.h" | 30 | #include "xfs_mount.h" |
44 | #include "xfs_ag.h" | ||
45 | #include "xfs_alloc_btree.h" | ||
46 | #include "xfs_bmap_btree.h" | 31 | #include "xfs_bmap_btree.h" |
32 | #include "xfs_alloc_btree.h" | ||
47 | #include "xfs_ialloc_btree.h" | 33 | #include "xfs_ialloc_btree.h" |
48 | #include "xfs_btree.h" | ||
49 | #include "xfs_attr_sf.h" | ||
50 | #include "xfs_dir_sf.h" | 34 | #include "xfs_dir_sf.h" |
51 | #include "xfs_dir2_sf.h" | 35 | #include "xfs_dir2_sf.h" |
36 | #include "xfs_attr_sf.h" | ||
52 | #include "xfs_dinode.h" | 37 | #include "xfs_dinode.h" |
53 | #include "xfs_inode_item.h" | ||
54 | #include "xfs_inode.h" | 38 | #include "xfs_inode.h" |
39 | #include "xfs_inode_item.h" | ||
55 | #include "xfs_bmap.h" | 40 | #include "xfs_bmap.h" |
41 | #include "xfs_btree.h" | ||
56 | #include "xfs_ialloc.h" | 42 | #include "xfs_ialloc.h" |
57 | #include "xfs_itable.h" | 43 | #include "xfs_itable.h" |
58 | #include "xfs_dfrag.h" | 44 | #include "xfs_dfrag.h" |
@@ -65,9 +51,9 @@ | |||
65 | */ | 51 | */ |
66 | int | 52 | int |
67 | xfs_swapext( | 53 | xfs_swapext( |
68 | xfs_swapext_t __user *sxp) | 54 | xfs_swapext_t __user *sxu) |
69 | { | 55 | { |
70 | xfs_swapext_t sx; | 56 | xfs_swapext_t *sxp; |
71 | xfs_inode_t *ip=NULL, *tip=NULL, *ips[2]; | 57 | xfs_inode_t *ip=NULL, *tip=NULL, *ips[2]; |
72 | xfs_trans_t *tp; | 58 | xfs_trans_t *tp; |
73 | xfs_mount_t *mp; | 59 | xfs_mount_t *mp; |
@@ -76,20 +62,29 @@ xfs_swapext( | |||
76 | vnode_t *vp, *tvp; | 62 | vnode_t *vp, *tvp; |
77 | bhv_desc_t *bdp, *tbdp; | 63 | bhv_desc_t *bdp, *tbdp; |
78 | vn_bhv_head_t *bhp, *tbhp; | 64 | vn_bhv_head_t *bhp, *tbhp; |
79 | uint lock_flags=0; | 65 | static uint lock_flags = XFS_ILOCK_EXCL | XFS_IOLOCK_EXCL; |
80 | int ilf_fields, tilf_fields; | 66 | int ilf_fields, tilf_fields; |
81 | int error = 0; | 67 | int error = 0; |
82 | xfs_ifork_t tempif, *ifp, *tifp; | 68 | xfs_ifork_t *tempifp, *ifp, *tifp; |
83 | __uint64_t tmp; | 69 | __uint64_t tmp; |
84 | int aforkblks = 0; | 70 | int aforkblks = 0; |
85 | int taforkblks = 0; | 71 | int taforkblks = 0; |
86 | int locked = 0; | 72 | char locked = 0; |
87 | 73 | ||
88 | if (copy_from_user(&sx, sxp, sizeof(sx))) | 74 | sxp = kmem_alloc(sizeof(xfs_swapext_t), KM_MAYFAIL); |
89 | return XFS_ERROR(EFAULT); | 75 | tempifp = kmem_alloc(sizeof(xfs_ifork_t), KM_MAYFAIL); |
76 | if (!sxp || !tempifp) { | ||
77 | error = XFS_ERROR(ENOMEM); | ||
78 | goto error0; | ||
79 | } | ||
80 | |||
81 | if (copy_from_user(sxp, sxu, sizeof(xfs_swapext_t))) { | ||
82 | error = XFS_ERROR(EFAULT); | ||
83 | goto error0; | ||
84 | } | ||
90 | 85 | ||
91 | /* Pull information for the target fd */ | 86 | /* Pull information for the target fd */ |
92 | if (((fp = fget((int)sx.sx_fdtarget)) == NULL) || | 87 | if (((fp = fget((int)sxp->sx_fdtarget)) == NULL) || |
93 | ((vp = LINVFS_GET_VP(fp->f_dentry->d_inode)) == NULL)) { | 88 | ((vp = LINVFS_GET_VP(fp->f_dentry->d_inode)) == NULL)) { |
94 | error = XFS_ERROR(EINVAL); | 89 | error = XFS_ERROR(EINVAL); |
95 | goto error0; | 90 | goto error0; |
@@ -104,7 +99,7 @@ xfs_swapext( | |||
104 | ip = XFS_BHVTOI(bdp); | 99 | ip = XFS_BHVTOI(bdp); |
105 | } | 100 | } |
106 | 101 | ||
107 | if (((tfp = fget((int)sx.sx_fdtmp)) == NULL) || | 102 | if (((tfp = fget((int)sxp->sx_fdtmp)) == NULL) || |
108 | ((tvp = LINVFS_GET_VP(tfp->f_dentry->d_inode)) == NULL)) { | 103 | ((tvp = LINVFS_GET_VP(tfp->f_dentry->d_inode)) == NULL)) { |
109 | error = XFS_ERROR(EINVAL); | 104 | error = XFS_ERROR(EINVAL); |
110 | goto error0; | 105 | goto error0; |
@@ -131,7 +126,7 @@ xfs_swapext( | |||
131 | 126 | ||
132 | mp = ip->i_mount; | 127 | mp = ip->i_mount; |
133 | 128 | ||
134 | sbp = &sx.sx_stat; | 129 | sbp = &sxp->sx_stat; |
135 | 130 | ||
136 | if (XFS_FORCED_SHUTDOWN(mp)) { | 131 | if (XFS_FORCED_SHUTDOWN(mp)) { |
137 | error = XFS_ERROR(EIO); | 132 | error = XFS_ERROR(EIO); |
@@ -148,7 +143,7 @@ xfs_swapext( | |||
148 | ips[0] = tip; | 143 | ips[0] = tip; |
149 | ips[1] = ip; | 144 | ips[1] = ip; |
150 | } | 145 | } |
151 | lock_flags = XFS_ILOCK_EXCL | XFS_IOLOCK_EXCL; | 146 | |
152 | xfs_lock_inodes(ips, 2, 0, lock_flags); | 147 | xfs_lock_inodes(ips, 2, 0, lock_flags); |
153 | 148 | ||
154 | /* Check permissions */ | 149 | /* Check permissions */ |
@@ -192,9 +187,9 @@ xfs_swapext( | |||
192 | } | 187 | } |
193 | 188 | ||
194 | /* Verify all data are being swapped */ | 189 | /* Verify all data are being swapped */ |
195 | if (sx.sx_offset != 0 || | 190 | if (sxp->sx_offset != 0 || |
196 | sx.sx_length != ip->i_d.di_size || | 191 | sxp->sx_length != ip->i_d.di_size || |
197 | sx.sx_length != tip->i_d.di_size) { | 192 | sxp->sx_length != tip->i_d.di_size) { |
198 | error = XFS_ERROR(EFAULT); | 193 | error = XFS_ERROR(EFAULT); |
199 | goto error0; | 194 | goto error0; |
200 | } | 195 | } |
@@ -255,7 +250,8 @@ xfs_swapext( | |||
255 | xfs_iunlock(ip, XFS_IOLOCK_EXCL); | 250 | xfs_iunlock(ip, XFS_IOLOCK_EXCL); |
256 | xfs_iunlock(tip, XFS_IOLOCK_EXCL); | 251 | xfs_iunlock(tip, XFS_IOLOCK_EXCL); |
257 | xfs_trans_cancel(tp, 0); | 252 | xfs_trans_cancel(tp, 0); |
258 | return error; | 253 | locked = 0; |
254 | goto error0; | ||
259 | } | 255 | } |
260 | xfs_lock_inodes(ips, 2, 0, XFS_ILOCK_EXCL); | 256 | xfs_lock_inodes(ips, 2, 0, XFS_ILOCK_EXCL); |
261 | 257 | ||
@@ -266,10 +262,8 @@ xfs_swapext( | |||
266 | (ip->i_d.di_aformat != XFS_DINODE_FMT_LOCAL)) { | 262 | (ip->i_d.di_aformat != XFS_DINODE_FMT_LOCAL)) { |
267 | error = xfs_bmap_count_blocks(tp, ip, XFS_ATTR_FORK, &aforkblks); | 263 | error = xfs_bmap_count_blocks(tp, ip, XFS_ATTR_FORK, &aforkblks); |
268 | if (error) { | 264 | if (error) { |
269 | xfs_iunlock(ip, lock_flags); | ||
270 | xfs_iunlock(tip, lock_flags); | ||
271 | xfs_trans_cancel(tp, 0); | 265 | xfs_trans_cancel(tp, 0); |
272 | return error; | 266 | goto error0; |
273 | } | 267 | } |
274 | } | 268 | } |
275 | if ( ((XFS_IFORK_Q(tip) != 0) && (tip->i_d.di_anextents > 0)) && | 269 | if ( ((XFS_IFORK_Q(tip) != 0) && (tip->i_d.di_anextents > 0)) && |
@@ -277,10 +271,8 @@ xfs_swapext( | |||
277 | error = xfs_bmap_count_blocks(tp, tip, XFS_ATTR_FORK, | 271 | error = xfs_bmap_count_blocks(tp, tip, XFS_ATTR_FORK, |
278 | &taforkblks); | 272 | &taforkblks); |
279 | if (error) { | 273 | if (error) { |
280 | xfs_iunlock(ip, lock_flags); | ||
281 | xfs_iunlock(tip, lock_flags); | ||
282 | xfs_trans_cancel(tp, 0); | 274 | xfs_trans_cancel(tp, 0); |
283 | return error; | 275 | goto error0; |
284 | } | 276 | } |
285 | } | 277 | } |
286 | 278 | ||
@@ -289,9 +281,9 @@ xfs_swapext( | |||
289 | */ | 281 | */ |
290 | ifp = &ip->i_df; | 282 | ifp = &ip->i_df; |
291 | tifp = &tip->i_df; | 283 | tifp = &tip->i_df; |
292 | tempif = *ifp; /* struct copy */ | 284 | *tempifp = *ifp; /* struct copy */ |
293 | *ifp = *tifp; /* struct copy */ | 285 | *ifp = *tifp; /* struct copy */ |
294 | *tifp = tempif; /* struct copy */ | 286 | *tifp = *tempifp; /* struct copy */ |
295 | 287 | ||
296 | /* | 288 | /* |
297 | * Fix the on-disk inode values | 289 | * Fix the on-disk inode values |
@@ -369,11 +361,7 @@ xfs_swapext( | |||
369 | } | 361 | } |
370 | 362 | ||
371 | error = xfs_trans_commit(tp, XFS_TRANS_SWAPEXT, NULL); | 363 | error = xfs_trans_commit(tp, XFS_TRANS_SWAPEXT, NULL); |
372 | 364 | locked = 0; | |
373 | fput(fp); | ||
374 | fput(tfp); | ||
375 | |||
376 | return error; | ||
377 | 365 | ||
378 | error0: | 366 | error0: |
379 | if (locked) { | 367 | if (locked) { |
@@ -381,8 +369,15 @@ xfs_swapext( | |||
381 | xfs_iunlock(tip, lock_flags); | 369 | xfs_iunlock(tip, lock_flags); |
382 | } | 370 | } |
383 | 371 | ||
384 | if (fp != NULL) fput(fp); | 372 | if (fp != NULL) |
385 | if (tfp != NULL) fput(tfp); | 373 | fput(fp); |
374 | if (tfp != NULL) | ||
375 | fput(tfp); | ||
376 | |||
377 | if (sxp != NULL) | ||
378 | kmem_free(sxp, sizeof(xfs_swapext_t)); | ||
379 | if (tempifp != NULL) | ||
380 | kmem_free(tempifp, sizeof(xfs_ifork_t)); | ||
386 | 381 | ||
387 | return error; | 382 | return error; |
388 | } | 383 | } |
diff --git a/fs/xfs/xfs_dfrag.h b/fs/xfs/xfs_dfrag.h index 904860594b8f..f678559abc45 100644 --- a/fs/xfs/xfs_dfrag.h +++ b/fs/xfs/xfs_dfrag.h | |||
@@ -1,33 +1,19 @@ | |||
1 | /* | 1 | /* |
2 | * Copyright (c) 2000 Silicon Graphics, Inc. All Rights Reserved. | 2 | * Copyright (c) 2000,2005 Silicon Graphics, Inc. |
3 | * All Rights Reserved. | ||
3 | * | 4 | * |
4 | * This program is free software; you can redistribute it and/or modify it | 5 | * This program is free software; you can redistribute it and/or |
5 | * under the terms of version 2 of the GNU General Public License as | 6 | * modify it under the terms of the GNU General Public License as |
6 | * published by the Free Software Foundation. | 7 | * published by the Free Software Foundation. |
7 | * | 8 | * |
8 | * This program is distributed in the hope that it would be useful, but | 9 | * This program is distributed in the hope that it would be useful, |
9 | * WITHOUT ANY WARRANTY; without even the implied warranty of | 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
12 | * GNU General Public License for more details. | ||
11 | * | 13 | * |
12 | * Further, this software is distributed without any warranty that it is | 14 | * You should have received a copy of the GNU General Public License |
13 | * free of the rightful claim of any third person regarding infringement | 15 | * along with this program; if not, write the Free Software Foundation, |
14 | * or the like. Any license provided herein, whether implied or | 16 | * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
15 | * otherwise, applies only to this software file. Patent licenses, if | ||
16 | * any, provided herein do not apply to combinations of this program with | ||
17 | * other software, or any other product whatsoever. | ||
18 | * | ||
19 | * You should have received a copy of the GNU General Public License along | ||
20 | * with this program; if not, write the Free Software Foundation, Inc., 59 | ||
21 | * Temple Place - Suite 330, Boston MA 02111-1307, USA. | ||
22 | * | ||
23 | * Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy, | ||
24 | * Mountain View, CA 94043, or: | ||
25 | * | ||
26 | * http://www.sgi.com | ||
27 | * | ||
28 | * For further information regarding this notice, see: | ||
29 | * | ||
30 | * http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/ | ||
31 | */ | 17 | */ |
32 | #ifndef __XFS_DFRAG_H__ | 18 | #ifndef __XFS_DFRAG_H__ |
33 | #define __XFS_DFRAG_H__ | 19 | #define __XFS_DFRAG_H__ |
diff --git a/fs/xfs/xfs_dinode.h b/fs/xfs/xfs_dinode.h index f5c932b064e6..c5a0e537ff1a 100644 --- a/fs/xfs/xfs_dinode.h +++ b/fs/xfs/xfs_dinode.h | |||
@@ -1,33 +1,19 @@ | |||
1 | /* | 1 | /* |
2 | * Copyright (c) 2000, 2002 Silicon Graphics, Inc. All Rights Reserved. | 2 | * Copyright (c) 2000,2002,2005 Silicon Graphics, Inc. |
3 | * All Rights Reserved. | ||
3 | * | 4 | * |
4 | * This program is free software; you can redistribute it and/or modify it | 5 | * This program is free software; you can redistribute it and/or |
5 | * under the terms of version 2 of the GNU General Public License as | 6 | * modify it under the terms of the GNU General Public License as |
6 | * published by the Free Software Foundation. | 7 | * published by the Free Software Foundation. |
7 | * | 8 | * |
8 | * This program is distributed in the hope that it would be useful, but | 9 | * This program is distributed in the hope that it would be useful, |
9 | * WITHOUT ANY WARRANTY; without even the implied warranty of | 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
12 | * GNU General Public License for more details. | ||
11 | * | 13 | * |
12 | * Further, this software is distributed without any warranty that it is | 14 | * You should have received a copy of the GNU General Public License |
13 | * free of the rightful claim of any third person regarding infringement | 15 | * along with this program; if not, write the Free Software Foundation, |
14 | * or the like. Any license provided herein, whether implied or | 16 | * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
15 | * otherwise, applies only to this software file. Patent licenses, if | ||
16 | * any, provided herein do not apply to combinations of this program with | ||
17 | * other software, or any other product whatsoever. | ||
18 | * | ||
19 | * You should have received a copy of the GNU General Public License along | ||
20 | * with this program; if not, write the Free Software Foundation, Inc., 59 | ||
21 | * Temple Place - Suite 330, Boston MA 02111-1307, USA. | ||
22 | * | ||
23 | * Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy, | ||
24 | * Mountain View, CA 94043, or: | ||
25 | * | ||
26 | * http://www.sgi.com | ||
27 | * | ||
28 | * For further information regarding this notice, see: | ||
29 | * | ||
30 | * http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/ | ||
31 | */ | 17 | */ |
32 | #ifndef __XFS_DINODE_H__ | 18 | #ifndef __XFS_DINODE_H__ |
33 | #define __XFS_DINODE_H__ | 19 | #define __XFS_DINODE_H__ |
@@ -37,13 +23,8 @@ struct xfs_mount; | |||
37 | 23 | ||
38 | #define XFS_DINODE_VERSION_1 1 | 24 | #define XFS_DINODE_VERSION_1 1 |
39 | #define XFS_DINODE_VERSION_2 2 | 25 | #define XFS_DINODE_VERSION_2 2 |
40 | #if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_DINODE_GOOD_VERSION) | 26 | #define XFS_DINODE_GOOD_VERSION(v) \ |
41 | int xfs_dinode_good_version(int v); | 27 | (((v) == XFS_DINODE_VERSION_1 || (v) == XFS_DINODE_VERSION_2)) |
42 | #define XFS_DINODE_GOOD_VERSION(v) xfs_dinode_good_version(v) | ||
43 | #else | ||
44 | #define XFS_DINODE_GOOD_VERSION(v) (((v) == XFS_DINODE_VERSION_1) || \ | ||
45 | ((v) == XFS_DINODE_VERSION_2)) | ||
46 | #endif | ||
47 | #define XFS_DINODE_MAGIC 0x494e /* 'IN' */ | 28 | #define XFS_DINODE_MAGIC 0x494e /* 'IN' */ |
48 | 29 | ||
49 | /* | 30 | /* |
@@ -184,75 +165,30 @@ typedef enum xfs_dinode_fmt | |||
184 | /* | 165 | /* |
185 | * Inode size for given fs. | 166 | * Inode size for given fs. |
186 | */ | 167 | */ |
187 | #if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_LITINO) | ||
188 | int xfs_litino(struct xfs_mount *mp); | ||
189 | #define XFS_LITINO(mp) xfs_litino(mp) | ||
190 | #else | ||
191 | #define XFS_LITINO(mp) ((mp)->m_litino) | 168 | #define XFS_LITINO(mp) ((mp)->m_litino) |
192 | #endif | ||
193 | #define XFS_BROOT_SIZE_ADJ \ | 169 | #define XFS_BROOT_SIZE_ADJ \ |
194 | (sizeof(xfs_bmbt_block_t) - sizeof(xfs_bmdr_block_t)) | 170 | (sizeof(xfs_bmbt_block_t) - sizeof(xfs_bmdr_block_t)) |
195 | 171 | ||
196 | /* | 172 | /* |
197 | * Fork identifiers. Here so utilities can use them without including | ||
198 | * xfs_inode.h. | ||
199 | */ | ||
200 | #define XFS_DATA_FORK 0 | ||
201 | #define XFS_ATTR_FORK 1 | ||
202 | |||
203 | /* | ||
204 | * Inode data & attribute fork sizes, per inode. | 173 | * Inode data & attribute fork sizes, per inode. |
205 | */ | 174 | */ |
206 | #if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_CFORK_Q) | ||
207 | int xfs_cfork_q_disk(xfs_dinode_core_t *dcp); | ||
208 | int xfs_cfork_q(xfs_dinode_core_t *dcp); | ||
209 | #define XFS_CFORK_Q_DISK(dcp) xfs_cfork_q_disk(dcp) | ||
210 | #define XFS_CFORK_Q(dcp) xfs_cfork_q(dcp) | ||
211 | #else | ||
212 | #define XFS_CFORK_Q_DISK(dcp) ((dcp)->di_forkoff != 0) | ||
213 | #define XFS_CFORK_Q(dcp) ((dcp)->di_forkoff != 0) | 175 | #define XFS_CFORK_Q(dcp) ((dcp)->di_forkoff != 0) |
176 | #define XFS_CFORK_Q_DISK(dcp) ((dcp)->di_forkoff != 0) | ||
214 | 177 | ||
215 | #endif | ||
216 | #if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_CFORK_BOFF) | ||
217 | int xfs_cfork_boff_disk(xfs_dinode_core_t *dcp); | ||
218 | int xfs_cfork_boff(xfs_dinode_core_t *dcp); | ||
219 | #define XFS_CFORK_BOFF_DISK(dcp) xfs_cfork_boff_disk(dcp) | ||
220 | #define XFS_CFORK_BOFF(dcp) xfs_cfork_boff(dcp) | ||
221 | #else | ||
222 | #define XFS_CFORK_BOFF_DISK(dcp) ((int)(INT_GET((dcp)->di_forkoff, ARCH_CONVERT) << 3)) | ||
223 | #define XFS_CFORK_BOFF(dcp) ((int)((dcp)->di_forkoff << 3)) | 178 | #define XFS_CFORK_BOFF(dcp) ((int)((dcp)->di_forkoff << 3)) |
179 | #define XFS_CFORK_BOFF_DISK(dcp) \ | ||
180 | ((int)(INT_GET((dcp)->di_forkoff, ARCH_CONVERT) << 3)) | ||
224 | 181 | ||
225 | #endif | ||
226 | #if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_CFORK_DSIZE) | ||
227 | int xfs_cfork_dsize_disk(xfs_dinode_core_t *dcp, struct xfs_mount *mp); | ||
228 | int xfs_cfork_dsize(xfs_dinode_core_t *dcp, struct xfs_mount *mp); | ||
229 | #define XFS_CFORK_DSIZE_DISK(dcp,mp) xfs_cfork_dsize_disk(dcp,mp) | ||
230 | #define XFS_CFORK_DSIZE(dcp,mp) xfs_cfork_dsize(dcp,mp) | ||
231 | #else | ||
232 | #define XFS_CFORK_DSIZE_DISK(dcp,mp) \ | 182 | #define XFS_CFORK_DSIZE_DISK(dcp,mp) \ |
233 | (XFS_CFORK_Q_DISK(dcp) ? XFS_CFORK_BOFF_DISK(dcp) : XFS_LITINO(mp)) | 183 | (XFS_CFORK_Q_DISK(dcp) ? XFS_CFORK_BOFF_DISK(dcp) : XFS_LITINO(mp)) |
234 | #define XFS_CFORK_DSIZE(dcp,mp) \ | 184 | #define XFS_CFORK_DSIZE(dcp,mp) \ |
235 | (XFS_CFORK_Q(dcp) ? XFS_CFORK_BOFF(dcp) : XFS_LITINO(mp)) | 185 | (XFS_CFORK_Q(dcp) ? XFS_CFORK_BOFF(dcp) : XFS_LITINO(mp)) |
236 | 186 | ||
237 | #endif | ||
238 | #if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_CFORK_ASIZE) | ||
239 | int xfs_cfork_asize_disk(xfs_dinode_core_t *dcp, struct xfs_mount *mp); | ||
240 | int xfs_cfork_asize(xfs_dinode_core_t *dcp, struct xfs_mount *mp); | ||
241 | #define XFS_CFORK_ASIZE_DISK(dcp,mp) xfs_cfork_asize_disk(dcp,mp) | ||
242 | #define XFS_CFORK_ASIZE(dcp,mp) xfs_cfork_asize(dcp,mp) | ||
243 | #else | ||
244 | #define XFS_CFORK_ASIZE_DISK(dcp,mp) \ | 187 | #define XFS_CFORK_ASIZE_DISK(dcp,mp) \ |
245 | (XFS_CFORK_Q_DISK(dcp) ? XFS_LITINO(mp) - XFS_CFORK_BOFF_DISK(dcp) : 0) | 188 | (XFS_CFORK_Q_DISK(dcp) ? XFS_LITINO(mp) - XFS_CFORK_BOFF_DISK(dcp) : 0) |
246 | #define XFS_CFORK_ASIZE(dcp,mp) \ | 189 | #define XFS_CFORK_ASIZE(dcp,mp) \ |
247 | (XFS_CFORK_Q(dcp) ? XFS_LITINO(mp) - XFS_CFORK_BOFF(dcp) : 0) | 190 | (XFS_CFORK_Q(dcp) ? XFS_LITINO(mp) - XFS_CFORK_BOFF(dcp) : 0) |
248 | 191 | ||
249 | #endif | ||
250 | #if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_CFORK_SIZE) | ||
251 | int xfs_cfork_size_disk(xfs_dinode_core_t *dcp, struct xfs_mount *mp, int w); | ||
252 | int xfs_cfork_size(xfs_dinode_core_t *dcp, struct xfs_mount *mp, int w); | ||
253 | #define XFS_CFORK_SIZE_DISK(dcp,mp,w) xfs_cfork_size_disk(dcp,mp,w) | ||
254 | #define XFS_CFORK_SIZE(dcp,mp,w) xfs_cfork_size(dcp,mp,w) | ||
255 | #else | ||
256 | #define XFS_CFORK_SIZE_DISK(dcp,mp,w) \ | 192 | #define XFS_CFORK_SIZE_DISK(dcp,mp,w) \ |
257 | ((w) == XFS_DATA_FORK ? \ | 193 | ((w) == XFS_DATA_FORK ? \ |
258 | XFS_CFORK_DSIZE_DISK(dcp, mp) : \ | 194 | XFS_CFORK_DSIZE_DISK(dcp, mp) : \ |
@@ -261,93 +197,26 @@ int xfs_cfork_size(xfs_dinode_core_t *dcp, struct xfs_mount *mp, int w); | |||
261 | ((w) == XFS_DATA_FORK ? \ | 197 | ((w) == XFS_DATA_FORK ? \ |
262 | XFS_CFORK_DSIZE(dcp, mp) : XFS_CFORK_ASIZE(dcp, mp)) | 198 | XFS_CFORK_DSIZE(dcp, mp) : XFS_CFORK_ASIZE(dcp, mp)) |
263 | 199 | ||
264 | #endif | 200 | #define XFS_DFORK_DSIZE(dip,mp) \ |
265 | 201 | XFS_CFORK_DSIZE_DISK(&(dip)->di_core, mp) | |
266 | #if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_DFORK_DSIZE) | 202 | #define XFS_DFORK_ASIZE(dip,mp) \ |
267 | int xfs_dfork_dsize(xfs_dinode_t *dip, struct xfs_mount *mp); | 203 | XFS_CFORK_ASIZE_DISK(&(dip)->di_core, mp) |
268 | #define XFS_DFORK_DSIZE(dip,mp) xfs_dfork_dsize(dip,mp) | 204 | #define XFS_DFORK_SIZE(dip,mp,w) \ |
269 | #else | 205 | XFS_CFORK_SIZE_DISK(&(dip)->di_core, mp, w) |
270 | #define XFS_DFORK_DSIZE(dip,mp) XFS_CFORK_DSIZE_DISK(&(dip)->di_core, mp) | ||
271 | |||
272 | #endif | ||
273 | #if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_DFORK_ASIZE) | ||
274 | int xfs_dfork_asize(xfs_dinode_t *dip, struct xfs_mount *mp); | ||
275 | #define XFS_DFORK_ASIZE(dip,mp) xfs_dfork_asize(dip,mp) | ||
276 | #else | ||
277 | #define XFS_DFORK_ASIZE(dip,mp) XFS_CFORK_ASIZE_DISK(&(dip)->di_core, mp) | ||
278 | 206 | ||
279 | #endif | ||
280 | #if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_DFORK_SIZE) | ||
281 | int xfs_dfork_size(xfs_dinode_t *dip, struct xfs_mount *mp, int w); | ||
282 | #define XFS_DFORK_SIZE(dip,mp,w) xfs_dfork_size(dip,mp,w) | ||
283 | #else | ||
284 | #define XFS_DFORK_SIZE(dip,mp,w) XFS_CFORK_SIZE_DISK(&(dip)->di_core, mp, w) | ||
285 | |||
286 | #endif | ||
287 | |||
288 | /* | ||
289 | * Macros for accessing per-fork disk inode information. | ||
290 | */ | ||
291 | #if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_DFORK_Q) | ||
292 | int xfs_dfork_q(xfs_dinode_t *dip); | ||
293 | #define XFS_DFORK_Q(dip) xfs_dfork_q(dip) | ||
294 | #else | ||
295 | #define XFS_DFORK_Q(dip) XFS_CFORK_Q_DISK(&(dip)->di_core) | 207 | #define XFS_DFORK_Q(dip) XFS_CFORK_Q_DISK(&(dip)->di_core) |
296 | |||
297 | #endif | ||
298 | #if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_DFORK_BOFF) | ||
299 | int xfs_dfork_boff(xfs_dinode_t *dip); | ||
300 | #define XFS_DFORK_BOFF(dip) xfs_dfork_boff(dip) | ||
301 | #else | ||
302 | #define XFS_DFORK_BOFF(dip) XFS_CFORK_BOFF_DISK(&(dip)->di_core) | 208 | #define XFS_DFORK_BOFF(dip) XFS_CFORK_BOFF_DISK(&(dip)->di_core) |
303 | |||
304 | #endif | ||
305 | #if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_DFORK_DPTR) | ||
306 | char *xfs_dfork_dptr(xfs_dinode_t *dip); | ||
307 | #define XFS_DFORK_DPTR(dip) xfs_dfork_dptr(dip) | ||
308 | #else | ||
309 | #define XFS_DFORK_DPTR(dip) ((dip)->di_u.di_c) | 209 | #define XFS_DFORK_DPTR(dip) ((dip)->di_u.di_c) |
310 | 210 | #define XFS_DFORK_APTR(dip) \ | |
311 | #endif | 211 | ((dip)->di_u.di_c + XFS_DFORK_BOFF(dip)) |
312 | #if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_DFORK_APTR) | ||
313 | char *xfs_dfork_aptr(xfs_dinode_t *dip); | ||
314 | #define XFS_DFORK_APTR(dip) xfs_dfork_aptr(dip) | ||
315 | #else | ||
316 | #define XFS_DFORK_APTR(dip) ((dip)->di_u.di_c + XFS_DFORK_BOFF(dip)) | ||
317 | |||
318 | #endif | ||
319 | #if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_DFORK_PTR) | ||
320 | char *xfs_dfork_ptr(xfs_dinode_t *dip, int w); | ||
321 | #define XFS_DFORK_PTR(dip,w) xfs_dfork_ptr(dip,w) | ||
322 | #else | ||
323 | #define XFS_DFORK_PTR(dip,w) \ | 212 | #define XFS_DFORK_PTR(dip,w) \ |
324 | ((w) == XFS_DATA_FORK ? XFS_DFORK_DPTR(dip) : XFS_DFORK_APTR(dip)) | 213 | ((w) == XFS_DATA_FORK ? XFS_DFORK_DPTR(dip) : XFS_DFORK_APTR(dip)) |
325 | 214 | #define XFS_CFORK_FORMAT(dcp,w) \ | |
326 | #endif | ||
327 | #if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_CFORK_FORMAT) | ||
328 | int xfs_cfork_format(xfs_dinode_core_t *dcp, int w); | ||
329 | #define XFS_CFORK_FORMAT(dcp,w) xfs_cfork_format(dcp,w) | ||
330 | #else | ||
331 | #define XFS_CFORK_FORMAT(dcp,w) \ | ||
332 | ((w) == XFS_DATA_FORK ? (dcp)->di_format : (dcp)->di_aformat) | 215 | ((w) == XFS_DATA_FORK ? (dcp)->di_format : (dcp)->di_aformat) |
333 | |||
334 | #endif | ||
335 | #if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_CFORK_FMT_SET) | ||
336 | void xfs_cfork_fmt_set(xfs_dinode_core_t *dcp, int w, int n); | ||
337 | #define XFS_CFORK_FMT_SET(dcp,w,n) xfs_cfork_fmt_set(dcp,w,n) | ||
338 | #else | ||
339 | #define XFS_CFORK_FMT_SET(dcp,w,n) \ | 216 | #define XFS_CFORK_FMT_SET(dcp,w,n) \ |
340 | ((w) == XFS_DATA_FORK ? \ | 217 | ((w) == XFS_DATA_FORK ? \ |
341 | ((dcp)->di_format = (n)) : \ | 218 | ((dcp)->di_format = (n)) : ((dcp)->di_aformat = (n))) |
342 | ((dcp)->di_aformat = (n))) | ||
343 | 219 | ||
344 | #endif | ||
345 | #if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_CFORK_NEXTENTS) | ||
346 | int xfs_cfork_nextents_disk(xfs_dinode_core_t *dcp, int w); | ||
347 | int xfs_cfork_nextents(xfs_dinode_core_t *dcp, int w); | ||
348 | #define XFS_CFORK_NEXTENTS_DISK(dcp,w) xfs_cfork_nextents_disk(dcp,w) | ||
349 | #define XFS_CFORK_NEXTENTS(dcp,w) xfs_cfork_nextents(dcp,w) | ||
350 | #else | ||
351 | #define XFS_CFORK_NEXTENTS_DISK(dcp,w) \ | 220 | #define XFS_CFORK_NEXTENTS_DISK(dcp,w) \ |
352 | ((w) == XFS_DATA_FORK ? \ | 221 | ((w) == XFS_DATA_FORK ? \ |
353 | INT_GET((dcp)->di_nextents, ARCH_CONVERT) : \ | 222 | INT_GET((dcp)->di_nextents, ARCH_CONVERT) : \ |
@@ -355,31 +224,13 @@ int xfs_cfork_nextents(xfs_dinode_core_t *dcp, int w); | |||
355 | #define XFS_CFORK_NEXTENTS(dcp,w) \ | 224 | #define XFS_CFORK_NEXTENTS(dcp,w) \ |
356 | ((w) == XFS_DATA_FORK ? (dcp)->di_nextents : (dcp)->di_anextents) | 225 | ((w) == XFS_DATA_FORK ? (dcp)->di_nextents : (dcp)->di_anextents) |
357 | 226 | ||
358 | #endif | ||
359 | #if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_CFORK_NEXT_SET) | ||
360 | void xfs_cfork_next_set(xfs_dinode_core_t *dcp, int w, int n); | ||
361 | #define XFS_CFORK_NEXT_SET(dcp,w,n) xfs_cfork_next_set(dcp,w,n) | ||
362 | #else | ||
363 | #define XFS_CFORK_NEXT_SET(dcp,w,n) \ | 227 | #define XFS_CFORK_NEXT_SET(dcp,w,n) \ |
364 | ((w) == XFS_DATA_FORK ? \ | 228 | ((w) == XFS_DATA_FORK ? \ |
365 | ((dcp)->di_nextents = (n)) : \ | 229 | ((dcp)->di_nextents = (n)) : ((dcp)->di_anextents = (n))) |
366 | ((dcp)->di_anextents = (n))) | ||
367 | |||
368 | #endif | ||
369 | 230 | ||
370 | #if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_DFORK_NEXTENTS) | ||
371 | int xfs_dfork_nextents(xfs_dinode_t *dip, int w); | ||
372 | #define XFS_DFORK_NEXTENTS(dip,w) xfs_dfork_nextents(dip,w) | ||
373 | #else | ||
374 | #define XFS_DFORK_NEXTENTS(dip,w) XFS_CFORK_NEXTENTS_DISK(&(dip)->di_core, w) | 231 | #define XFS_DFORK_NEXTENTS(dip,w) XFS_CFORK_NEXTENTS_DISK(&(dip)->di_core, w) |
375 | #endif | ||
376 | 232 | ||
377 | #if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_BUF_TO_DINODE) | 233 | #define XFS_BUF_TO_DINODE(bp) ((xfs_dinode_t *)XFS_BUF_PTR(bp)) |
378 | xfs_dinode_t *xfs_buf_to_dinode(struct xfs_buf *bp); | ||
379 | #define XFS_BUF_TO_DINODE(bp) xfs_buf_to_dinode(bp) | ||
380 | #else | ||
381 | #define XFS_BUF_TO_DINODE(bp) ((xfs_dinode_t *)(XFS_BUF_PTR(bp))) | ||
382 | #endif | ||
383 | 234 | ||
384 | /* | 235 | /* |
385 | * Values for di_flags | 236 | * Values for di_flags |
diff --git a/fs/xfs/xfs_dir.c b/fs/xfs/xfs_dir.c index ba30bc7682f2..3dd30391f551 100644 --- a/fs/xfs/xfs_dir.c +++ b/fs/xfs/xfs_dir.c | |||
@@ -1,59 +1,43 @@ | |||
1 | /* | 1 | /* |
2 | * Copyright (c) 2000-2001 Silicon Graphics, Inc. All Rights Reserved. | 2 | * Copyright (c) 2000-2001,2005 Silicon Graphics, Inc. |
3 | * All Rights Reserved. | ||
3 | * | 4 | * |
4 | * This program is free software; you can redistribute it and/or modify it | 5 | * This program is free software; you can redistribute it and/or |
5 | * under the terms of version 2 of the GNU General Public License as | 6 | * modify it under the terms of the GNU General Public License as |
6 | * published by the Free Software Foundation. | 7 | * published by the Free Software Foundation. |
7 | * | 8 | * |
8 | * This program is distributed in the hope that it would be useful, but | 9 | * This program is distributed in the hope that it would be useful, |
9 | * WITHOUT ANY WARRANTY; without even the implied warranty of | 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
12 | * GNU General Public License for more details. | ||
11 | * | 13 | * |
12 | * Further, this software is distributed without any warranty that it is | 14 | * You should have received a copy of the GNU General Public License |
13 | * free of the rightful claim of any third person regarding infringement | 15 | * along with this program; if not, write the Free Software Foundation, |
14 | * or the like. Any license provided herein, whether implied or | 16 | * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
15 | * otherwise, applies only to this software file. Patent licenses, if | ||
16 | * any, provided herein do not apply to combinations of this program with | ||
17 | * other software, or any other product whatsoever. | ||
18 | * | ||
19 | * You should have received a copy of the GNU General Public License along | ||
20 | * with this program; if not, write the Free Software Foundation, Inc., 59 | ||
21 | * Temple Place - Suite 330, Boston MA 02111-1307, USA. | ||
22 | * | ||
23 | * Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy, | ||
24 | * Mountain View, CA 94043, or: | ||
25 | * | ||
26 | * http://www.sgi.com | ||
27 | * | ||
28 | * For further information regarding this notice, see: | ||
29 | * | ||
30 | * http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/ | ||
31 | */ | 17 | */ |
32 | |||
33 | #include "xfs.h" | 18 | #include "xfs.h" |
34 | 19 | #include "xfs_fs.h" | |
35 | #include "xfs_macros.h" | ||
36 | #include "xfs_types.h" | 20 | #include "xfs_types.h" |
37 | #include "xfs_inum.h" | ||
38 | #include "xfs_log.h" | 21 | #include "xfs_log.h" |
22 | #include "xfs_inum.h" | ||
39 | #include "xfs_trans.h" | 23 | #include "xfs_trans.h" |
40 | #include "xfs_sb.h" | 24 | #include "xfs_sb.h" |
41 | #include "xfs_dir.h" | 25 | #include "xfs_dir.h" |
42 | #include "xfs_dir2.h" | 26 | #include "xfs_dir2.h" |
43 | #include "xfs_dmapi.h" | 27 | #include "xfs_dmapi.h" |
44 | #include "xfs_mount.h" | 28 | #include "xfs_mount.h" |
45 | #include "xfs_alloc_btree.h" | 29 | #include "xfs_da_btree.h" |
46 | #include "xfs_bmap_btree.h" | 30 | #include "xfs_bmap_btree.h" |
31 | #include "xfs_alloc_btree.h" | ||
47 | #include "xfs_ialloc_btree.h" | 32 | #include "xfs_ialloc_btree.h" |
48 | #include "xfs_alloc.h" | 33 | #include "xfs_alloc.h" |
49 | #include "xfs_btree.h" | 34 | #include "xfs_btree.h" |
50 | #include "xfs_attr_sf.h" | ||
51 | #include "xfs_dir_sf.h" | 35 | #include "xfs_dir_sf.h" |
52 | #include "xfs_dir2_sf.h" | 36 | #include "xfs_dir2_sf.h" |
37 | #include "xfs_attr_sf.h" | ||
53 | #include "xfs_dinode.h" | 38 | #include "xfs_dinode.h" |
54 | #include "xfs_inode.h" | 39 | #include "xfs_inode.h" |
55 | #include "xfs_bmap.h" | 40 | #include "xfs_bmap.h" |
56 | #include "xfs_da_btree.h" | ||
57 | #include "xfs_dir_leaf.h" | 41 | #include "xfs_dir_leaf.h" |
58 | #include "xfs_error.h" | 42 | #include "xfs_error.h" |
59 | 43 | ||
@@ -192,11 +176,23 @@ xfs_dir_mount(xfs_mount_t *mp) | |||
192 | uint shortcount, leafcount, count; | 176 | uint shortcount, leafcount, count; |
193 | 177 | ||
194 | mp->m_dirversion = 1; | 178 | mp->m_dirversion = 1; |
195 | shortcount = (mp->m_attroffset - (uint)sizeof(xfs_dir_sf_hdr_t)) / | 179 | if (mp->m_flags & XFS_MOUNT_COMPAT_ATTR) { |
196 | (uint)sizeof(xfs_dir_sf_entry_t); | 180 | shortcount = (mp->m_attroffset - |
197 | leafcount = (XFS_LBSIZE(mp) - (uint)sizeof(xfs_dir_leaf_hdr_t)) / | 181 | (uint)sizeof(xfs_dir_sf_hdr_t)) / |
198 | ((uint)sizeof(xfs_dir_leaf_entry_t) + | 182 | (uint)sizeof(xfs_dir_sf_entry_t); |
199 | (uint)sizeof(xfs_dir_leaf_name_t)); | 183 | leafcount = (XFS_LBSIZE(mp) - |
184 | (uint)sizeof(xfs_dir_leaf_hdr_t)) / | ||
185 | ((uint)sizeof(xfs_dir_leaf_entry_t) + | ||
186 | (uint)sizeof(xfs_dir_leaf_name_t)); | ||
187 | } else { | ||
188 | shortcount = (XFS_BMDR_SPACE_CALC(MINABTPTRS) - | ||
189 | (uint)sizeof(xfs_dir_sf_hdr_t)) / | ||
190 | (uint)sizeof(xfs_dir_sf_entry_t); | ||
191 | leafcount = (XFS_LBSIZE(mp) - | ||
192 | (uint)sizeof(xfs_dir_leaf_hdr_t)) / | ||
193 | ((uint)sizeof(xfs_dir_leaf_entry_t) + | ||
194 | (uint)sizeof(xfs_dir_leaf_name_t)); | ||
195 | } | ||
200 | count = shortcount > leafcount ? shortcount : leafcount; | 196 | count = shortcount > leafcount ? shortcount : leafcount; |
201 | mp->m_dircook_elog = xfs_da_log2_roundup(count + 1); | 197 | mp->m_dircook_elog = xfs_da_log2_roundup(count + 1); |
202 | ASSERT(mp->m_dircook_elog <= mp->m_sb.sb_blocklog); | 198 | ASSERT(mp->m_dircook_elog <= mp->m_sb.sb_blocklog); |
diff --git a/fs/xfs/xfs_dir.h b/fs/xfs/xfs_dir.h index 4dbc9f54cca5..488defe86ba6 100644 --- a/fs/xfs/xfs_dir.h +++ b/fs/xfs/xfs_dir.h | |||
@@ -1,33 +1,19 @@ | |||
1 | /* | 1 | /* |
2 | * Copyright (c) 2000 Silicon Graphics, Inc. All Rights Reserved. | 2 | * Copyright (c) 2000,2005 Silicon Graphics, Inc. |
3 | * All Rights Reserved. | ||
3 | * | 4 | * |
4 | * This program is free software; you can redistribute it and/or modify it | 5 | * This program is free software; you can redistribute it and/or |
5 | * under the terms of version 2 of the GNU General Public License as | 6 | * modify it under the terms of the GNU General Public License as |
6 | * published by the Free Software Foundation. | 7 | * published by the Free Software Foundation. |
7 | * | 8 | * |
8 | * This program is distributed in the hope that it would be useful, but | 9 | * This program is distributed in the hope that it would be useful, |
9 | * WITHOUT ANY WARRANTY; without even the implied warranty of | 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
12 | * GNU General Public License for more details. | ||
11 | * | 13 | * |
12 | * Further, this software is distributed without any warranty that it is | 14 | * You should have received a copy of the GNU General Public License |
13 | * free of the rightful claim of any third person regarding infringement | 15 | * along with this program; if not, write the Free Software Foundation, |
14 | * or the like. Any license provided herein, whether implied or | 16 | * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
15 | * otherwise, applies only to this software file. Patent licenses, if | ||
16 | * any, provided herein do not apply to combinations of this program with | ||
17 | * other software, or any other product whatsoever. | ||
18 | * | ||
19 | * You should have received a copy of the GNU General Public License along | ||
20 | * with this program; if not, write the Free Software Foundation, Inc., 59 | ||
21 | * Temple Place - Suite 330, Boston MA 02111-1307, USA. | ||
22 | * | ||
23 | * Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy, | ||
24 | * Mountain View, CA 94043, or: | ||
25 | * | ||
26 | * http://www.sgi.com | ||
27 | * | ||
28 | * For further information regarding this notice, see: | ||
29 | * | ||
30 | * http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/ | ||
31 | */ | 17 | */ |
32 | #ifndef __XFS_DIR_H__ | 18 | #ifndef __XFS_DIR_H__ |
33 | #define __XFS_DIR_H__ | 19 | #define __XFS_DIR_H__ |
diff --git a/fs/xfs/xfs_dir2.c b/fs/xfs/xfs_dir2.c index 49fc0a3695ae..022c8398ab62 100644 --- a/fs/xfs/xfs_dir2.c +++ b/fs/xfs/xfs_dir2.c | |||
@@ -1,46 +1,26 @@ | |||
1 | /* | 1 | /* |
2 | * Copyright (c) 2000-2001 Silicon Graphics, Inc. All Rights Reserved. | 2 | * Copyright (c) 2000-2001,2005 Silicon Graphics, Inc. |
3 | * All Rights Reserved. | ||
3 | * | 4 | * |
4 | * This program is free software; you can redistribute it and/or modify it | 5 | * This program is free software; you can redistribute it and/or |
5 | * under the terms of version 2 of the GNU General Public License as | 6 | * modify it under the terms of the GNU General Public License as |
6 | * published by the Free Software Foundation. | 7 | * published by the Free Software Foundation. |
7 | * | 8 | * |
8 | * This program is distributed in the hope that it would be useful, but | 9 | * This program is distributed in the hope that it would be useful, |
9 | * WITHOUT ANY WARRANTY; without even the implied warranty of | 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
12 | * GNU General Public License for more details. | ||
11 | * | 13 | * |
12 | * Further, this software is distributed without any warranty that it is | 14 | * You should have received a copy of the GNU General Public License |
13 | * free of the rightful claim of any third person regarding infringement | 15 | * along with this program; if not, write the Free Software Foundation, |
14 | * or the like. Any license provided herein, whether implied or | 16 | * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
15 | * otherwise, applies only to this software file. Patent licenses, if | ||
16 | * any, provided herein do not apply to combinations of this program with | ||
17 | * other software, or any other product whatsoever. | ||
18 | * | ||
19 | * You should have received a copy of the GNU General Public License along | ||
20 | * with this program; if not, write the Free Software Foundation, Inc., 59 | ||
21 | * Temple Place - Suite 330, Boston MA 02111-1307, USA. | ||
22 | * | ||
23 | * Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy, | ||
24 | * Mountain View, CA 94043, or: | ||
25 | * | ||
26 | * http://www.sgi.com | ||
27 | * | ||
28 | * For further information regarding this notice, see: | ||
29 | * | ||
30 | * http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/ | ||
31 | */ | 17 | */ |
32 | |||
33 | /* | ||
34 | * XFS v2 directory implmentation. | ||
35 | * Top-level and utility routines. | ||
36 | */ | ||
37 | |||
38 | #include "xfs.h" | 18 | #include "xfs.h" |
39 | 19 | #include "xfs_fs.h" | |
40 | #include "xfs_macros.h" | ||
41 | #include "xfs_types.h" | 20 | #include "xfs_types.h" |
42 | #include "xfs_inum.h" | 21 | #include "xfs_bit.h" |
43 | #include "xfs_log.h" | 22 | #include "xfs_log.h" |
23 | #include "xfs_inum.h" | ||
44 | #include "xfs_trans.h" | 24 | #include "xfs_trans.h" |
45 | #include "xfs_sb.h" | 25 | #include "xfs_sb.h" |
46 | #include "xfs_ag.h" | 26 | #include "xfs_ag.h" |
@@ -48,16 +28,16 @@ | |||
48 | #include "xfs_dir2.h" | 28 | #include "xfs_dir2.h" |
49 | #include "xfs_dmapi.h" | 29 | #include "xfs_dmapi.h" |
50 | #include "xfs_mount.h" | 30 | #include "xfs_mount.h" |
51 | #include "xfs_alloc_btree.h" | 31 | #include "xfs_da_btree.h" |
52 | #include "xfs_bmap_btree.h" | 32 | #include "xfs_bmap_btree.h" |
53 | #include "xfs_attr_sf.h" | 33 | #include "xfs_alloc_btree.h" |
54 | #include "xfs_dir_sf.h" | 34 | #include "xfs_dir_sf.h" |
55 | #include "xfs_dir2_sf.h" | 35 | #include "xfs_dir2_sf.h" |
36 | #include "xfs_attr_sf.h" | ||
56 | #include "xfs_dinode.h" | 37 | #include "xfs_dinode.h" |
57 | #include "xfs_inode_item.h" | ||
58 | #include "xfs_inode.h" | 38 | #include "xfs_inode.h" |
39 | #include "xfs_inode_item.h" | ||
59 | #include "xfs_bmap.h" | 40 | #include "xfs_bmap.h" |
60 | #include "xfs_da_btree.h" | ||
61 | #include "xfs_dir_leaf.h" | 41 | #include "xfs_dir_leaf.h" |
62 | #include "xfs_dir2_data.h" | 42 | #include "xfs_dir2_data.h" |
63 | #include "xfs_dir2_leaf.h" | 43 | #include "xfs_dir2_leaf.h" |
@@ -65,7 +45,6 @@ | |||
65 | #include "xfs_dir2_node.h" | 45 | #include "xfs_dir2_node.h" |
66 | #include "xfs_dir2_trace.h" | 46 | #include "xfs_dir2_trace.h" |
67 | #include "xfs_error.h" | 47 | #include "xfs_error.h" |
68 | #include "xfs_bit.h" | ||
69 | 48 | ||
70 | /* | 49 | /* |
71 | * Declarations for interface routines. | 50 | * Declarations for interface routines. |
diff --git a/fs/xfs/xfs_dir2.h b/fs/xfs/xfs_dir2.h index 8f4fc7f23bcd..7e24ffeda9e1 100644 --- a/fs/xfs/xfs_dir2.h +++ b/fs/xfs/xfs_dir2.h | |||
@@ -1,33 +1,19 @@ | |||
1 | /* | 1 | /* |
2 | * Copyright (c) 2000-2001 Silicon Graphics, Inc. All Rights Reserved. | 2 | * Copyright (c) 2000-2001,2005 Silicon Graphics, Inc. |
3 | * All Rights Reserved. | ||
3 | * | 4 | * |
4 | * This program is free software; you can redistribute it and/or modify it | 5 | * This program is free software; you can redistribute it and/or |
5 | * under the terms of version 2 of the GNU General Public License as | 6 | * modify it under the terms of the GNU General Public License as |
6 | * published by the Free Software Foundation. | 7 | * published by the Free Software Foundation. |
7 | * | 8 | * |
8 | * This program is distributed in the hope that it would be useful, but | 9 | * This program is distributed in the hope that it would be useful, |
9 | * WITHOUT ANY WARRANTY; without even the implied warranty of | 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
12 | * GNU General Public License for more details. | ||
11 | * | 13 | * |
12 | * Further, this software is distributed without any warranty that it is | 14 | * You should have received a copy of the GNU General Public License |
13 | * free of the rightful claim of any third person regarding infringement | 15 | * along with this program; if not, write the Free Software Foundation, |
14 | * or the like. Any license provided herein, whether implied or | 16 | * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
15 | * otherwise, applies only to this software file. Patent licenses, if | ||
16 | * any, provided herein do not apply to combinations of this program with | ||
17 | * other software, or any other product whatsoever. | ||
18 | * | ||
19 | * You should have received a copy of the GNU General Public License along | ||
20 | * with this program; if not, write the Free Software Foundation, Inc., 59 | ||
21 | * Temple Place - Suite 330, Boston MA 02111-1307, USA. | ||
22 | * | ||
23 | * Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy, | ||
24 | * Mountain View, CA 94043, or: | ||
25 | * | ||
26 | * http://www.sgi.com | ||
27 | * | ||
28 | * For further information regarding this notice, see: | ||
29 | * | ||
30 | * http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/ | ||
31 | */ | 17 | */ |
32 | #ifndef __XFS_DIR2_H__ | 18 | #ifndef __XFS_DIR2_H__ |
33 | #define __XFS_DIR2_H__ | 19 | #define __XFS_DIR2_H__ |
diff --git a/fs/xfs/xfs_dir2_block.c b/fs/xfs/xfs_dir2_block.c index bc4c40fcd479..31bc99faa704 100644 --- a/fs/xfs/xfs_dir2_block.c +++ b/fs/xfs/xfs_dir2_block.c | |||
@@ -1,61 +1,39 @@ | |||
1 | /* | 1 | /* |
2 | * Copyright (c) 2000-2003 Silicon Graphics, Inc. All Rights Reserved. | 2 | * Copyright (c) 2000-2003,2005 Silicon Graphics, Inc. |
3 | * All Rights Reserved. | ||
3 | * | 4 | * |
4 | * This program is free software; you can redistribute it and/or modify it | 5 | * This program is free software; you can redistribute it and/or |
5 | * under the terms of version 2 of the GNU General Public License as | 6 | * modify it under the terms of the GNU General Public License as |
6 | * published by the Free Software Foundation. | 7 | * published by the Free Software Foundation. |
7 | * | 8 | * |
8 | * This program is distributed in the hope that it would be useful, but | 9 | * This program is distributed in the hope that it would be useful, |
9 | * WITHOUT ANY WARRANTY; without even the implied warranty of | 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
12 | * GNU General Public License for more details. | ||
11 | * | 13 | * |
12 | * Further, this software is distributed without any warranty that it is | 14 | * You should have received a copy of the GNU General Public License |
13 | * free of the rightful claim of any third person regarding infringement | 15 | * along with this program; if not, write the Free Software Foundation, |
14 | * or the like. Any license provided herein, whether implied or | 16 | * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
15 | * otherwise, applies only to this software file. Patent licenses, if | ||
16 | * any, provided herein do not apply to combinations of this program with | ||
17 | * other software, or any other product whatsoever. | ||
18 | * | ||
19 | * You should have received a copy of the GNU General Public License along | ||
20 | * with this program; if not, write the Free Software Foundation, Inc., 59 | ||
21 | * Temple Place - Suite 330, Boston MA 02111-1307, USA. | ||
22 | * | ||
23 | * Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy, | ||
24 | * Mountain View, CA 94043, or: | ||
25 | * | ||
26 | * http://www.sgi.com | ||
27 | * | ||
28 | * For further information regarding this notice, see: | ||
29 | * | ||
30 | * http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/ | ||
31 | */ | 17 | */ |
32 | |||
33 | /* | ||
34 | * xfs_dir2_block.c | ||
35 | * XFS V2 directory implementation, single-block form. | ||
36 | * See xfs_dir2_block.h for the format. | ||
37 | */ | ||
38 | |||
39 | #include "xfs.h" | 18 | #include "xfs.h" |
40 | 19 | #include "xfs_fs.h" | |
41 | #include "xfs_macros.h" | ||
42 | #include "xfs_types.h" | 20 | #include "xfs_types.h" |
43 | #include "xfs_inum.h" | ||
44 | #include "xfs_log.h" | 21 | #include "xfs_log.h" |
22 | #include "xfs_inum.h" | ||
45 | #include "xfs_trans.h" | 23 | #include "xfs_trans.h" |
46 | #include "xfs_sb.h" | 24 | #include "xfs_sb.h" |
47 | #include "xfs_dir.h" | 25 | #include "xfs_dir.h" |
48 | #include "xfs_dir2.h" | 26 | #include "xfs_dir2.h" |
49 | #include "xfs_dmapi.h" | 27 | #include "xfs_dmapi.h" |
50 | #include "xfs_mount.h" | 28 | #include "xfs_mount.h" |
29 | #include "xfs_da_btree.h" | ||
51 | #include "xfs_bmap_btree.h" | 30 | #include "xfs_bmap_btree.h" |
52 | #include "xfs_attr_sf.h" | ||
53 | #include "xfs_dir_sf.h" | 31 | #include "xfs_dir_sf.h" |
54 | #include "xfs_dir2_sf.h" | 32 | #include "xfs_dir2_sf.h" |
33 | #include "xfs_attr_sf.h" | ||
55 | #include "xfs_dinode.h" | 34 | #include "xfs_dinode.h" |
56 | #include "xfs_inode_item.h" | ||
57 | #include "xfs_inode.h" | 35 | #include "xfs_inode.h" |
58 | #include "xfs_da_btree.h" | 36 | #include "xfs_inode_item.h" |
59 | #include "xfs_dir_leaf.h" | 37 | #include "xfs_dir_leaf.h" |
60 | #include "xfs_dir2_data.h" | 38 | #include "xfs_dir2_data.h" |
61 | #include "xfs_dir2_leaf.h" | 39 | #include "xfs_dir2_leaf.h" |
@@ -1234,7 +1212,7 @@ xfs_dir2_sf_to_block( | |||
1234 | /* | 1212 | /* |
1235 | * Sort the leaf entries by hash value. | 1213 | * Sort the leaf entries by hash value. |
1236 | */ | 1214 | */ |
1237 | qsort(blp, INT_GET(btp->count, ARCH_CONVERT), sizeof(*blp), xfs_dir2_block_sort); | 1215 | xfs_sort(blp, INT_GET(btp->count, ARCH_CONVERT), sizeof(*blp), xfs_dir2_block_sort); |
1238 | /* | 1216 | /* |
1239 | * Log the leaf entry area and tail. | 1217 | * Log the leaf entry area and tail. |
1240 | * Already logged the header in data_init, ignore needlog. | 1218 | * Already logged the header in data_init, ignore needlog. |
diff --git a/fs/xfs/xfs_dir2_block.h b/fs/xfs/xfs_dir2_block.h index 5a578b84e246..a2e5cb98a838 100644 --- a/fs/xfs/xfs_dir2_block.h +++ b/fs/xfs/xfs_dir2_block.h | |||
@@ -1,33 +1,19 @@ | |||
1 | /* | 1 | /* |
2 | * Copyright (c) 2000-2001 Silicon Graphics, Inc. All Rights Reserved. | 2 | * Copyright (c) 2000-2001,2005 Silicon Graphics, Inc. |
3 | * All Rights Reserved. | ||
3 | * | 4 | * |
4 | * This program is free software; you can redistribute it and/or modify it | 5 | * This program is free software; you can redistribute it and/or |
5 | * under the terms of version 2 of the GNU General Public License as | 6 | * modify it under the terms of the GNU General Public License as |
6 | * published by the Free Software Foundation. | 7 | * published by the Free Software Foundation. |
7 | * | 8 | * |
8 | * This program is distributed in the hope that it would be useful, but | 9 | * This program is distributed in the hope that it would be useful, |
9 | * WITHOUT ANY WARRANTY; without even the implied warranty of | 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
12 | * GNU General Public License for more details. | ||
11 | * | 13 | * |
12 | * Further, this software is distributed without any warranty that it is | 14 | * You should have received a copy of the GNU General Public License |
13 | * free of the rightful claim of any third person regarding infringement | 15 | * along with this program; if not, write the Free Software Foundation, |
14 | * or the like. Any license provided herein, whether implied or | 16 | * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
15 | * otherwise, applies only to this software file. Patent licenses, if | ||
16 | * any, provided herein do not apply to combinations of this program with | ||
17 | * other software, or any other product whatsoever. | ||
18 | * | ||
19 | * You should have received a copy of the GNU General Public License along | ||
20 | * with this program; if not, write the Free Software Foundation, Inc., 59 | ||
21 | * Temple Place - Suite 330, Boston MA 02111-1307, USA. | ||
22 | * | ||
23 | * Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy, | ||
24 | * Mountain View, CA 94043, or: | ||
25 | * | ||
26 | * http://www.sgi.com | ||
27 | * | ||
28 | * For further information regarding this notice, see: | ||
29 | * | ||
30 | * http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/ | ||
31 | */ | 17 | */ |
32 | #ifndef __XFS_DIR2_BLOCK_H__ | 18 | #ifndef __XFS_DIR2_BLOCK_H__ |
33 | #define __XFS_DIR2_BLOCK_H__ | 19 | #define __XFS_DIR2_BLOCK_H__ |
@@ -74,53 +60,37 @@ typedef struct xfs_dir2_block { | |||
74 | /* | 60 | /* |
75 | * Pointer to the leaf header embedded in a data block (1-block format) | 61 | * Pointer to the leaf header embedded in a data block (1-block format) |
76 | */ | 62 | */ |
77 | #if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_DIR2_BLOCK_TAIL_P) | ||
78 | xfs_dir2_block_tail_t * | ||
79 | xfs_dir2_block_tail_p(struct xfs_mount *mp, xfs_dir2_block_t *block); | ||
80 | #define XFS_DIR2_BLOCK_TAIL_P(mp,block) xfs_dir2_block_tail_p(mp,block) | 63 | #define XFS_DIR2_BLOCK_TAIL_P(mp,block) xfs_dir2_block_tail_p(mp,block) |
81 | #else | 64 | static inline xfs_dir2_block_tail_t * |
82 | #define XFS_DIR2_BLOCK_TAIL_P(mp,block) \ | 65 | xfs_dir2_block_tail_p(struct xfs_mount *mp, xfs_dir2_block_t *block) |
83 | (((xfs_dir2_block_tail_t *)((char *)(block) + (mp)->m_dirblksize)) - 1) | 66 | { |
84 | #endif | 67 | return (((xfs_dir2_block_tail_t *) |
68 | ((char *)(block) + (mp)->m_dirblksize)) - 1); | ||
69 | } | ||
85 | 70 | ||
86 | /* | 71 | /* |
87 | * Pointer to the leaf entries embedded in a data block (1-block format) | 72 | * Pointer to the leaf entries embedded in a data block (1-block format) |
88 | */ | 73 | */ |
89 | #if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_DIR2_BLOCK_LEAF_P) | 74 | #define XFS_DIR2_BLOCK_LEAF_P(btp) xfs_dir2_block_leaf_p(btp) |
90 | struct xfs_dir2_leaf_entry *xfs_dir2_block_leaf_p(xfs_dir2_block_tail_t *btp); | 75 | static inline struct xfs_dir2_leaf_entry * |
91 | #define XFS_DIR2_BLOCK_LEAF_P(btp) \ | 76 | xfs_dir2_block_leaf_p(xfs_dir2_block_tail_t *btp) |
92 | xfs_dir2_block_leaf_p(btp) | 77 | { |
93 | #else | 78 | return (((struct xfs_dir2_leaf_entry *) |
94 | #define XFS_DIR2_BLOCK_LEAF_P(btp) \ | 79 | (btp)) - INT_GET((btp)->count, ARCH_CONVERT)); |
95 | (((struct xfs_dir2_leaf_entry *)(btp)) - INT_GET((btp)->count, ARCH_CONVERT)) | 80 | } |
96 | #endif | ||
97 | 81 | ||
98 | /* | 82 | /* |
99 | * Function declarations. | 83 | * Function declarations. |
100 | */ | 84 | */ |
101 | 85 | extern int xfs_dir2_block_addname(struct xfs_da_args *args); | |
102 | extern int | 86 | extern int xfs_dir2_block_getdents(struct xfs_trans *tp, struct xfs_inode *dp, |
103 | xfs_dir2_block_addname(struct xfs_da_args *args); | 87 | struct uio *uio, int *eofp, |
104 | 88 | struct xfs_dirent *dbp, xfs_dir2_put_t put); | |
105 | extern int | 89 | extern int xfs_dir2_block_lookup(struct xfs_da_args *args); |
106 | xfs_dir2_block_getdents(struct xfs_trans *tp, struct xfs_inode *dp, | 90 | extern int xfs_dir2_block_removename(struct xfs_da_args *args); |
107 | struct uio *uio, int *eofp, struct xfs_dirent *dbp, | 91 | extern int xfs_dir2_block_replace(struct xfs_da_args *args); |
108 | xfs_dir2_put_t put); | 92 | extern int xfs_dir2_leaf_to_block(struct xfs_da_args *args, |
109 | 93 | struct xfs_dabuf *lbp, struct xfs_dabuf *dbp); | |
110 | extern int | 94 | extern int xfs_dir2_sf_to_block(struct xfs_da_args *args); |
111 | xfs_dir2_block_lookup(struct xfs_da_args *args); | ||
112 | |||
113 | extern int | ||
114 | xfs_dir2_block_removename(struct xfs_da_args *args); | ||
115 | |||
116 | extern int | ||
117 | xfs_dir2_block_replace(struct xfs_da_args *args); | ||
118 | |||
119 | extern int | ||
120 | xfs_dir2_leaf_to_block(struct xfs_da_args *args, struct xfs_dabuf *lbp, | ||
121 | struct xfs_dabuf *dbp); | ||
122 | |||
123 | extern int | ||
124 | xfs_dir2_sf_to_block(struct xfs_da_args *args); | ||
125 | 95 | ||
126 | #endif /* __XFS_DIR2_BLOCK_H__ */ | 96 | #endif /* __XFS_DIR2_BLOCK_H__ */ |
diff --git a/fs/xfs/xfs_dir2_data.c b/fs/xfs/xfs_dir2_data.c index a0aa0e44ff9d..5b7c47e2f14a 100644 --- a/fs/xfs/xfs_dir2_data.c +++ b/fs/xfs/xfs_dir2_data.c | |||
@@ -1,60 +1,38 @@ | |||
1 | /* | 1 | /* |
2 | * Copyright (c) 2000-2002 Silicon Graphics, Inc. All Rights Reserved. | 2 | * Copyright (c) 2000-2002,2005 Silicon Graphics, Inc. |
3 | * All Rights Reserved. | ||
3 | * | 4 | * |
4 | * This program is free software; you can redistribute it and/or modify it | 5 | * This program is free software; you can redistribute it and/or |
5 | * under the terms of version 2 of the GNU General Public License as | 6 | * modify it under the terms of the GNU General Public License as |
6 | * published by the Free Software Foundation. | 7 | * published by the Free Software Foundation. |
7 | * | 8 | * |
8 | * This program is distributed in the hope that it would be useful, but | 9 | * This program is distributed in the hope that it would be useful, |
9 | * WITHOUT ANY WARRANTY; without even the implied warranty of | 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
12 | * GNU General Public License for more details. | ||
11 | * | 13 | * |
12 | * Further, this software is distributed without any warranty that it is | 14 | * You should have received a copy of the GNU General Public License |
13 | * free of the rightful claim of any third person regarding infringement | 15 | * along with this program; if not, write the Free Software Foundation, |
14 | * or the like. Any license provided herein, whether implied or | 16 | * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
15 | * otherwise, applies only to this software file. Patent licenses, if | ||
16 | * any, provided herein do not apply to combinations of this program with | ||
17 | * other software, or any other product whatsoever. | ||
18 | * | ||
19 | * You should have received a copy of the GNU General Public License along | ||
20 | * with this program; if not, write the Free Software Foundation, Inc., 59 | ||
21 | * Temple Place - Suite 330, Boston MA 02111-1307, USA. | ||
22 | * | ||
23 | * Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy, | ||
24 | * Mountain View, CA 94043, or: | ||
25 | * | ||
26 | * http://www.sgi.com | ||
27 | * | ||
28 | * For further information regarding this notice, see: | ||
29 | * | ||
30 | * http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/ | ||
31 | */ | ||
32 | |||
33 | /* | ||
34 | * xfs_dir2_data.c | ||
35 | * Core data block handling routines for XFS V2 directories. | ||
36 | * See xfs_dir2_data.h for data structures. | ||
37 | */ | 17 | */ |
38 | |||
39 | #include "xfs.h" | 18 | #include "xfs.h" |
40 | 19 | #include "xfs_fs.h" | |
41 | #include "xfs_macros.h" | ||
42 | #include "xfs_types.h" | 20 | #include "xfs_types.h" |
43 | #include "xfs_inum.h" | ||
44 | #include "xfs_log.h" | 21 | #include "xfs_log.h" |
22 | #include "xfs_inum.h" | ||
45 | #include "xfs_trans.h" | 23 | #include "xfs_trans.h" |
46 | #include "xfs_sb.h" | 24 | #include "xfs_sb.h" |
47 | #include "xfs_dir.h" | 25 | #include "xfs_dir.h" |
48 | #include "xfs_dir2.h" | 26 | #include "xfs_dir2.h" |
49 | #include "xfs_dmapi.h" | 27 | #include "xfs_dmapi.h" |
50 | #include "xfs_mount.h" | 28 | #include "xfs_mount.h" |
29 | #include "xfs_da_btree.h" | ||
51 | #include "xfs_bmap_btree.h" | 30 | #include "xfs_bmap_btree.h" |
52 | #include "xfs_attr_sf.h" | ||
53 | #include "xfs_dir_sf.h" | 31 | #include "xfs_dir_sf.h" |
54 | #include "xfs_dir2_sf.h" | 32 | #include "xfs_dir2_sf.h" |
33 | #include "xfs_attr_sf.h" | ||
55 | #include "xfs_dinode.h" | 34 | #include "xfs_dinode.h" |
56 | #include "xfs_inode.h" | 35 | #include "xfs_inode.h" |
57 | #include "xfs_da_btree.h" | ||
58 | #include "xfs_dir_leaf.h" | 36 | #include "xfs_dir_leaf.h" |
59 | #include "xfs_dir2_data.h" | 37 | #include "xfs_dir2_data.h" |
60 | #include "xfs_dir2_leaf.h" | 38 | #include "xfs_dir2_leaf.h" |
diff --git a/fs/xfs/xfs_dir2_data.h b/fs/xfs/xfs_dir2_data.h index 476cac920bf5..5e3a7f9ec735 100644 --- a/fs/xfs/xfs_dir2_data.h +++ b/fs/xfs/xfs_dir2_data.h | |||
@@ -1,33 +1,19 @@ | |||
1 | /* | 1 | /* |
2 | * Copyright (c) 2000 Silicon Graphics, Inc. All Rights Reserved. | 2 | * Copyright (c) 2000,2005 Silicon Graphics, Inc. |
3 | * All Rights Reserved. | ||
3 | * | 4 | * |
4 | * This program is free software; you can redistribute it and/or modify it | 5 | * This program is free software; you can redistribute it and/or |
5 | * under the terms of version 2 of the GNU General Public License as | 6 | * modify it under the terms of the GNU General Public License as |
6 | * published by the Free Software Foundation. | 7 | * published by the Free Software Foundation. |
7 | * | 8 | * |
8 | * This program is distributed in the hope that it would be useful, but | 9 | * This program is distributed in the hope that it would be useful, |
9 | * WITHOUT ANY WARRANTY; without even the implied warranty of | 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
12 | * GNU General Public License for more details. | ||
11 | * | 13 | * |
12 | * Further, this software is distributed without any warranty that it is | 14 | * You should have received a copy of the GNU General Public License |
13 | * free of the rightful claim of any third person regarding infringement | 15 | * along with this program; if not, write the Free Software Foundation, |
14 | * or the like. Any license provided herein, whether implied or | 16 | * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
15 | * otherwise, applies only to this software file. Patent licenses, if | ||
16 | * any, provided herein do not apply to combinations of this program with | ||
17 | * other software, or any other product whatsoever. | ||
18 | * | ||
19 | * You should have received a copy of the GNU General Public License along | ||
20 | * with this program; if not, write the Free Software Foundation, Inc., 59 | ||
21 | * Temple Place - Suite 330, Boston MA 02111-1307, USA. | ||
22 | * | ||
23 | * Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy, | ||
24 | * Mountain View, CA 94043, or: | ||
25 | * | ||
26 | * http://www.sgi.com | ||
27 | * | ||
28 | * For further information regarding this notice, see: | ||
29 | * | ||
30 | * http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/ | ||
31 | */ | 17 | */ |
32 | #ifndef __XFS_DIR2_DATA_H__ | 18 | #ifndef __XFS_DIR2_DATA_H__ |
33 | #define __XFS_DIR2_DATA_H__ | 19 | #define __XFS_DIR2_DATA_H__ |
@@ -137,88 +123,65 @@ typedef struct xfs_dir2_data { | |||
137 | /* | 123 | /* |
138 | * Size of a data entry. | 124 | * Size of a data entry. |
139 | */ | 125 | */ |
140 | #if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_DIR2_DATA_ENTSIZE) | ||
141 | int xfs_dir2_data_entsize(int n); | ||
142 | #define XFS_DIR2_DATA_ENTSIZE(n) xfs_dir2_data_entsize(n) | 126 | #define XFS_DIR2_DATA_ENTSIZE(n) xfs_dir2_data_entsize(n) |
143 | #else | 127 | static inline int xfs_dir2_data_entsize(int n) |
144 | #define XFS_DIR2_DATA_ENTSIZE(n) \ | 128 | { |
145 | ((int)(roundup(offsetof(xfs_dir2_data_entry_t, name[0]) + (n) + \ | 129 | return (int)roundup(offsetof(xfs_dir2_data_entry_t, name[0]) + (n) + \ |
146 | (uint)sizeof(xfs_dir2_data_off_t), XFS_DIR2_DATA_ALIGN))) | 130 | (uint)sizeof(xfs_dir2_data_off_t), XFS_DIR2_DATA_ALIGN); |
147 | #endif | 131 | } |
148 | 132 | ||
149 | /* | 133 | /* |
150 | * Pointer to an entry's tag word. | 134 | * Pointer to an entry's tag word. |
151 | */ | 135 | */ |
152 | #if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_DIR2_DATA_ENTRY_TAG_P) | ||
153 | xfs_dir2_data_off_t *xfs_dir2_data_entry_tag_p(xfs_dir2_data_entry_t *dep); | ||
154 | #define XFS_DIR2_DATA_ENTRY_TAG_P(dep) xfs_dir2_data_entry_tag_p(dep) | 136 | #define XFS_DIR2_DATA_ENTRY_TAG_P(dep) xfs_dir2_data_entry_tag_p(dep) |
155 | #else | 137 | static inline xfs_dir2_data_off_t * |
156 | #define XFS_DIR2_DATA_ENTRY_TAG_P(dep) \ | 138 | xfs_dir2_data_entry_tag_p(xfs_dir2_data_entry_t *dep) |
157 | ((xfs_dir2_data_off_t *)\ | 139 | { |
158 | ((char *)(dep) + XFS_DIR2_DATA_ENTSIZE((dep)->namelen) - \ | 140 | return (xfs_dir2_data_off_t *) \ |
159 | (uint)sizeof(xfs_dir2_data_off_t))) | 141 | ((char *)(dep) + XFS_DIR2_DATA_ENTSIZE((dep)->namelen) - \ |
160 | #endif | 142 | (uint)sizeof(xfs_dir2_data_off_t)); |
143 | } | ||
161 | 144 | ||
162 | /* | 145 | /* |
163 | * Pointer to a freespace's tag word. | 146 | * Pointer to a freespace's tag word. |
164 | */ | 147 | */ |
165 | #if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_DIR2_DATA_UNUSED_TAG_P) | ||
166 | xfs_dir2_data_off_t *xfs_dir2_data_unused_tag_p(xfs_dir2_data_unused_t *dup); | ||
167 | #define XFS_DIR2_DATA_UNUSED_TAG_P(dup) \ | 148 | #define XFS_DIR2_DATA_UNUSED_TAG_P(dup) \ |
168 | xfs_dir2_data_unused_tag_p(dup) | 149 | xfs_dir2_data_unused_tag_p(dup) |
169 | #else | 150 | static inline xfs_dir2_data_off_t * |
170 | #define XFS_DIR2_DATA_UNUSED_TAG_P(dup) \ | 151 | xfs_dir2_data_unused_tag_p(xfs_dir2_data_unused_t *dup) |
171 | ((xfs_dir2_data_off_t *)\ | 152 | { |
172 | ((char *)(dup) + INT_GET((dup)->length, ARCH_CONVERT) \ | 153 | return (xfs_dir2_data_off_t *) \ |
173 | - (uint)sizeof(xfs_dir2_data_off_t))) | 154 | ((char *)(dup) + INT_GET((dup)->length, ARCH_CONVERT) \ |
174 | #endif | 155 | - (uint)sizeof(xfs_dir2_data_off_t)); |
156 | } | ||
175 | 157 | ||
176 | /* | 158 | /* |
177 | * Function declarations. | 159 | * Function declarations. |
178 | */ | 160 | */ |
179 | |||
180 | #ifdef DEBUG | 161 | #ifdef DEBUG |
181 | extern void | 162 | extern void xfs_dir2_data_check(struct xfs_inode *dp, struct xfs_dabuf *bp); |
182 | xfs_dir2_data_check(struct xfs_inode *dp, struct xfs_dabuf *bp); | ||
183 | #else | 163 | #else |
184 | #define xfs_dir2_data_check(dp,bp) | 164 | #define xfs_dir2_data_check(dp,bp) |
185 | #endif | 165 | #endif |
186 | 166 | extern xfs_dir2_data_free_t *xfs_dir2_data_freefind(xfs_dir2_data_t *d, | |
187 | extern xfs_dir2_data_free_t * | 167 | xfs_dir2_data_unused_t *dup); |
188 | xfs_dir2_data_freefind(xfs_dir2_data_t *d, | 168 | extern xfs_dir2_data_free_t *xfs_dir2_data_freeinsert(xfs_dir2_data_t *d, |
189 | xfs_dir2_data_unused_t *dup); | 169 | xfs_dir2_data_unused_t *dup, int *loghead); |
190 | 170 | extern void xfs_dir2_data_freescan(struct xfs_mount *mp, xfs_dir2_data_t *d, | |
191 | extern xfs_dir2_data_free_t * | 171 | int *loghead, char *aendp); |
192 | xfs_dir2_data_freeinsert(xfs_dir2_data_t *d, | 172 | extern int xfs_dir2_data_init(struct xfs_da_args *args, xfs_dir2_db_t blkno, |
193 | xfs_dir2_data_unused_t *dup, int *loghead); | 173 | struct xfs_dabuf **bpp); |
194 | 174 | extern void xfs_dir2_data_log_entry(struct xfs_trans *tp, struct xfs_dabuf *bp, | |
195 | extern void | ||
196 | xfs_dir2_data_freescan(struct xfs_mount *mp, xfs_dir2_data_t *d, | ||
197 | int *loghead, char *aendp); | ||
198 | |||
199 | extern int | ||
200 | xfs_dir2_data_init(struct xfs_da_args *args, xfs_dir2_db_t blkno, | ||
201 | struct xfs_dabuf **bpp); | ||
202 | |||
203 | extern void | ||
204 | xfs_dir2_data_log_entry(struct xfs_trans *tp, struct xfs_dabuf *bp, | ||
205 | xfs_dir2_data_entry_t *dep); | 175 | xfs_dir2_data_entry_t *dep); |
206 | 176 | extern void xfs_dir2_data_log_header(struct xfs_trans *tp, | |
207 | extern void | 177 | struct xfs_dabuf *bp); |
208 | xfs_dir2_data_log_header(struct xfs_trans *tp, struct xfs_dabuf *bp); | 178 | extern void xfs_dir2_data_log_unused(struct xfs_trans *tp, struct xfs_dabuf *bp, |
209 | 179 | xfs_dir2_data_unused_t *dup); | |
210 | extern void | 180 | extern void xfs_dir2_data_make_free(struct xfs_trans *tp, struct xfs_dabuf *bp, |
211 | xfs_dir2_data_log_unused(struct xfs_trans *tp, struct xfs_dabuf *bp, | ||
212 | xfs_dir2_data_unused_t *dup); | ||
213 | |||
214 | extern void | ||
215 | xfs_dir2_data_make_free(struct xfs_trans *tp, struct xfs_dabuf *bp, | ||
216 | xfs_dir2_data_aoff_t offset, | 181 | xfs_dir2_data_aoff_t offset, |
217 | xfs_dir2_data_aoff_t len, int *needlogp, | 182 | xfs_dir2_data_aoff_t len, int *needlogp, |
218 | int *needscanp); | 183 | int *needscanp); |
219 | 184 | extern void xfs_dir2_data_use_free(struct xfs_trans *tp, struct xfs_dabuf *bp, | |
220 | extern void | ||
221 | xfs_dir2_data_use_free(struct xfs_trans *tp, struct xfs_dabuf *bp, | ||
222 | xfs_dir2_data_unused_t *dup, | 185 | xfs_dir2_data_unused_t *dup, |
223 | xfs_dir2_data_aoff_t offset, | 186 | xfs_dir2_data_aoff_t offset, |
224 | xfs_dir2_data_aoff_t len, int *needlogp, | 187 | xfs_dir2_data_aoff_t len, int *needlogp, |
diff --git a/fs/xfs/xfs_dir2_leaf.c b/fs/xfs/xfs_dir2_leaf.c index 056f5283904b..d342b6b55239 100644 --- a/fs/xfs/xfs_dir2_leaf.c +++ b/fs/xfs/xfs_dir2_leaf.c | |||
@@ -1,49 +1,26 @@ | |||
1 | /* | 1 | /* |
2 | * Copyright (c) 2000-2003 Silicon Graphics, Inc. All Rights Reserved. | 2 | * Copyright (c) 2000-2003,2005 Silicon Graphics, Inc. |
3 | * All Rights Reserved. | ||
3 | * | 4 | * |
4 | * This program is free software; you can redistribute it and/or modify it | 5 | * This program is free software; you can redistribute it and/or |
5 | * under the terms of version 2 of the GNU General Public License as | 6 | * modify it under the terms of the GNU General Public License as |
6 | * published by the Free Software Foundation. | 7 | * published by the Free Software Foundation. |
7 | * | 8 | * |
8 | * This program is distributed in the hope that it would be useful, but | 9 | * This program is distributed in the hope that it would be useful, |
9 | * WITHOUT ANY WARRANTY; without even the implied warranty of | 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
12 | * GNU General Public License for more details. | ||
11 | * | 13 | * |
12 | * Further, this software is distributed without any warranty that it is | 14 | * You should have received a copy of the GNU General Public License |
13 | * free of the rightful claim of any third person regarding infringement | 15 | * along with this program; if not, write the Free Software Foundation, |
14 | * or the like. Any license provided herein, whether implied or | 16 | * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
15 | * otherwise, applies only to this software file. Patent licenses, if | ||
16 | * any, provided herein do not apply to combinations of this program with | ||
17 | * other software, or any other product whatsoever. | ||
18 | * | ||
19 | * You should have received a copy of the GNU General Public License along | ||
20 | * with this program; if not, write the Free Software Foundation, Inc., 59 | ||
21 | * Temple Place - Suite 330, Boston MA 02111-1307, USA. | ||
22 | * | ||
23 | * Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy, | ||
24 | * Mountain View, CA 94043, or: | ||
25 | * | ||
26 | * http://www.sgi.com | ||
27 | * | ||
28 | * For further information regarding this notice, see: | ||
29 | * | ||
30 | * http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/ | ||
31 | */ | ||
32 | |||
33 | /* | ||
34 | * xfs_dir2_leaf.c | ||
35 | * XFS directory version 2 implementation - single leaf form | ||
36 | * see xfs_dir2_leaf.h for data structures. | ||
37 | * These directories have multiple XFS_DIR2_DATA blocks and one | ||
38 | * XFS_DIR2_LEAF1 block containing the hash table and freespace map. | ||
39 | */ | 17 | */ |
40 | |||
41 | #include "xfs.h" | 18 | #include "xfs.h" |
42 | 19 | #include "xfs_fs.h" | |
43 | #include "xfs_macros.h" | ||
44 | #include "xfs_types.h" | 20 | #include "xfs_types.h" |
45 | #include "xfs_inum.h" | 21 | #include "xfs_bit.h" |
46 | #include "xfs_log.h" | 22 | #include "xfs_log.h" |
23 | #include "xfs_inum.h" | ||
47 | #include "xfs_trans.h" | 24 | #include "xfs_trans.h" |
48 | #include "xfs_sb.h" | 25 | #include "xfs_sb.h" |
49 | #include "xfs_ag.h" | 26 | #include "xfs_ag.h" |
@@ -51,6 +28,7 @@ | |||
51 | #include "xfs_dir2.h" | 28 | #include "xfs_dir2.h" |
52 | #include "xfs_dmapi.h" | 29 | #include "xfs_dmapi.h" |
53 | #include "xfs_mount.h" | 30 | #include "xfs_mount.h" |
31 | #include "xfs_da_btree.h" | ||
54 | #include "xfs_bmap_btree.h" | 32 | #include "xfs_bmap_btree.h" |
55 | #include "xfs_attr_sf.h" | 33 | #include "xfs_attr_sf.h" |
56 | #include "xfs_dir_sf.h" | 34 | #include "xfs_dir_sf.h" |
@@ -58,14 +36,12 @@ | |||
58 | #include "xfs_dinode.h" | 36 | #include "xfs_dinode.h" |
59 | #include "xfs_inode.h" | 37 | #include "xfs_inode.h" |
60 | #include "xfs_bmap.h" | 38 | #include "xfs_bmap.h" |
61 | #include "xfs_da_btree.h" | ||
62 | #include "xfs_dir2_data.h" | 39 | #include "xfs_dir2_data.h" |
63 | #include "xfs_dir2_leaf.h" | 40 | #include "xfs_dir2_leaf.h" |
64 | #include "xfs_dir2_block.h" | 41 | #include "xfs_dir2_block.h" |
65 | #include "xfs_dir2_node.h" | 42 | #include "xfs_dir2_node.h" |
66 | #include "xfs_dir2_trace.h" | 43 | #include "xfs_dir2_trace.h" |
67 | #include "xfs_error.h" | 44 | #include "xfs_error.h" |
68 | #include "xfs_bit.h" | ||
69 | 45 | ||
70 | /* | 46 | /* |
71 | * Local function declarations. | 47 | * Local function declarations. |
diff --git a/fs/xfs/xfs_dir2_leaf.h b/fs/xfs/xfs_dir2_leaf.h index 3303cd6f4c00..1393993d61e9 100644 --- a/fs/xfs/xfs_dir2_leaf.h +++ b/fs/xfs/xfs_dir2_leaf.h | |||
@@ -1,41 +1,23 @@ | |||
1 | /* | 1 | /* |
2 | * Copyright (c) 2000-2001 Silicon Graphics, Inc. All Rights Reserved. | 2 | * Copyright (c) 2000-2001,2005 Silicon Graphics, Inc. |
3 | * All Rights Reserved. | ||
3 | * | 4 | * |
4 | * This program is free software; you can redistribute it and/or modify it | 5 | * This program is free software; you can redistribute it and/or |
5 | * under the terms of version 2 of the GNU General Public License as | 6 | * modify it under the terms of the GNU General Public License as |
6 | * published by the Free Software Foundation. | 7 | * published by the Free Software Foundation. |
7 | * | 8 | * |
8 | * This program is distributed in the hope that it would be useful, but | 9 | * This program is distributed in the hope that it would be useful, |
9 | * WITHOUT ANY WARRANTY; without even the implied warranty of | 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
12 | * GNU General Public License for more details. | ||
11 | * | 13 | * |
12 | * Further, this software is distributed without any warranty that it is | 14 | * You should have received a copy of the GNU General Public License |
13 | * free of the rightful claim of any third person regarding infringement | 15 | * along with this program; if not, write the Free Software Foundation, |
14 | * or the like. Any license provided herein, whether implied or | 16 | * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
15 | * otherwise, applies only to this software file. Patent licenses, if | ||
16 | * any, provided herein do not apply to combinations of this program with | ||
17 | * other software, or any other product whatsoever. | ||
18 | * | ||
19 | * You should have received a copy of the GNU General Public License along | ||
20 | * with this program; if not, write the Free Software Foundation, Inc., 59 | ||
21 | * Temple Place - Suite 330, Boston MA 02111-1307, USA. | ||
22 | * | ||
23 | * Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy, | ||
24 | * Mountain View, CA 94043, or: | ||
25 | * | ||
26 | * http://www.sgi.com | ||
27 | * | ||
28 | * For further information regarding this notice, see: | ||
29 | * | ||
30 | * http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/ | ||
31 | */ | 17 | */ |
32 | #ifndef __XFS_DIR2_LEAF_H__ | 18 | #ifndef __XFS_DIR2_LEAF_H__ |
33 | #define __XFS_DIR2_LEAF_H__ | 19 | #define __XFS_DIR2_LEAF_H__ |
34 | 20 | ||
35 | /* | ||
36 | * Directory version 2, leaf block structures. | ||
37 | */ | ||
38 | |||
39 | struct uio; | 21 | struct uio; |
40 | struct xfs_dabuf; | 22 | struct xfs_dabuf; |
41 | struct xfs_da_args; | 23 | struct xfs_da_args; |
@@ -44,10 +26,6 @@ struct xfs_mount; | |||
44 | struct xfs_trans; | 26 | struct xfs_trans; |
45 | 27 | ||
46 | /* | 28 | /* |
47 | * Constants. | ||
48 | */ | ||
49 | |||
50 | /* | ||
51 | * Offset of the leaf/node space. First block in this space | 29 | * Offset of the leaf/node space. First block in this space |
52 | * is the btree root. | 30 | * is the btree root. |
53 | */ | 31 | */ |
@@ -57,10 +35,6 @@ struct xfs_trans; | |||
57 | XFS_DIR2_BYTE_TO_DB(mp, XFS_DIR2_LEAF_OFFSET) | 35 | XFS_DIR2_BYTE_TO_DB(mp, XFS_DIR2_LEAF_OFFSET) |
58 | 36 | ||
59 | /* | 37 | /* |
60 | * Types. | ||
61 | */ | ||
62 | |||
63 | /* | ||
64 | * Offset in data space of a data entry. | 38 | * Offset in data space of a data entry. |
65 | */ | 39 | */ |
66 | typedef __uint32_t xfs_dir2_dataptr_t; | 40 | typedef __uint32_t xfs_dir2_dataptr_t; |
@@ -68,10 +42,6 @@ typedef __uint32_t xfs_dir2_dataptr_t; | |||
68 | #define XFS_DIR2_NULL_DATAPTR ((xfs_dir2_dataptr_t)0) | 42 | #define XFS_DIR2_NULL_DATAPTR ((xfs_dir2_dataptr_t)0) |
69 | 43 | ||
70 | /* | 44 | /* |
71 | * Structures. | ||
72 | */ | ||
73 | |||
74 | /* | ||
75 | * Leaf block header. | 45 | * Leaf block header. |
76 | */ | 46 | */ |
77 | typedef struct xfs_dir2_leaf_hdr { | 47 | typedef struct xfs_dir2_leaf_hdr { |
@@ -109,245 +79,193 @@ typedef struct xfs_dir2_leaf { | |||
109 | } xfs_dir2_leaf_t; | 79 | } xfs_dir2_leaf_t; |
110 | 80 | ||
111 | /* | 81 | /* |
112 | * Macros. | 82 | * DB blocks here are logical directory block numbers, not filesystem blocks. |
113 | * The DB blocks are logical directory block numbers, not filesystem blocks. | ||
114 | */ | 83 | */ |
115 | 84 | ||
116 | #if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_DIR2_MAX_LEAF_ENTS) | 85 | #define XFS_DIR2_MAX_LEAF_ENTS(mp) xfs_dir2_max_leaf_ents(mp) |
117 | int | 86 | static inline int xfs_dir2_max_leaf_ents(struct xfs_mount *mp) |
118 | xfs_dir2_max_leaf_ents(struct xfs_mount *mp); | 87 | { |
119 | #define XFS_DIR2_MAX_LEAF_ENTS(mp) \ | 88 | return (int)(((mp)->m_dirblksize - (uint)sizeof(xfs_dir2_leaf_hdr_t)) / |
120 | xfs_dir2_max_leaf_ents(mp) | 89 | (uint)sizeof(xfs_dir2_leaf_entry_t)); |
121 | #else | 90 | } |
122 | #define XFS_DIR2_MAX_LEAF_ENTS(mp) \ | ||
123 | ((int)(((mp)->m_dirblksize - (uint)sizeof(xfs_dir2_leaf_hdr_t)) / \ | ||
124 | (uint)sizeof(xfs_dir2_leaf_entry_t))) | ||
125 | #endif | ||
126 | 91 | ||
127 | /* | 92 | /* |
128 | * Get address of the bestcount field in the single-leaf block. | 93 | * Get address of the bestcount field in the single-leaf block. |
129 | */ | 94 | */ |
130 | #if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_DIR2_LEAF_TAIL_P) | 95 | #define XFS_DIR2_LEAF_TAIL_P(mp,lp) xfs_dir2_leaf_tail_p(mp, lp) |
131 | xfs_dir2_leaf_tail_t * | 96 | static inline xfs_dir2_leaf_tail_t * |
132 | xfs_dir2_leaf_tail_p(struct xfs_mount *mp, xfs_dir2_leaf_t *lp); | 97 | xfs_dir2_leaf_tail_p(struct xfs_mount *mp, xfs_dir2_leaf_t *lp) |
133 | #define XFS_DIR2_LEAF_TAIL_P(mp,lp) \ | 98 | { |
134 | xfs_dir2_leaf_tail_p(mp, lp) | 99 | return (xfs_dir2_leaf_tail_t *) |
135 | #else | 100 | ((char *)(lp) + (mp)->m_dirblksize - |
136 | #define XFS_DIR2_LEAF_TAIL_P(mp,lp) \ | 101 | (uint)sizeof(xfs_dir2_leaf_tail_t)); |
137 | ((xfs_dir2_leaf_tail_t *)\ | 102 | } |
138 | ((char *)(lp) + (mp)->m_dirblksize - \ | ||
139 | (uint)sizeof(xfs_dir2_leaf_tail_t))) | ||
140 | #endif | ||
141 | 103 | ||
142 | /* | 104 | /* |
143 | * Get address of the bests array in the single-leaf block. | 105 | * Get address of the bests array in the single-leaf block. |
144 | */ | 106 | */ |
145 | #if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_DIR2_LEAF_BESTS_P) | ||
146 | xfs_dir2_data_off_t * | ||
147 | xfs_dir2_leaf_bests_p(xfs_dir2_leaf_tail_t *ltp); | ||
148 | #define XFS_DIR2_LEAF_BESTS_P(ltp) xfs_dir2_leaf_bests_p(ltp) | 107 | #define XFS_DIR2_LEAF_BESTS_P(ltp) xfs_dir2_leaf_bests_p(ltp) |
149 | #else | 108 | static inline xfs_dir2_data_off_t * |
150 | #define XFS_DIR2_LEAF_BESTS_P(ltp) \ | 109 | xfs_dir2_leaf_bests_p(xfs_dir2_leaf_tail_t *ltp) |
151 | ((xfs_dir2_data_off_t *)(ltp) - INT_GET((ltp)->bestcount, ARCH_CONVERT)) | 110 | { |
152 | #endif | 111 | return (xfs_dir2_data_off_t *) |
112 | (ltp) - INT_GET((ltp)->bestcount, ARCH_CONVERT); | ||
113 | } | ||
153 | 114 | ||
154 | /* | 115 | /* |
155 | * Convert dataptr to byte in file space | 116 | * Convert dataptr to byte in file space |
156 | */ | 117 | */ |
157 | #if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_DIR2_DATAPTR_TO_BYTE) | ||
158 | xfs_dir2_off_t | ||
159 | xfs_dir2_dataptr_to_byte(struct xfs_mount *mp, xfs_dir2_dataptr_t dp); | ||
160 | #define XFS_DIR2_DATAPTR_TO_BYTE(mp,dp) xfs_dir2_dataptr_to_byte(mp, dp) | 118 | #define XFS_DIR2_DATAPTR_TO_BYTE(mp,dp) xfs_dir2_dataptr_to_byte(mp, dp) |
161 | #else | 119 | static inline xfs_dir2_off_t |
162 | #define XFS_DIR2_DATAPTR_TO_BYTE(mp,dp) \ | 120 | xfs_dir2_dataptr_to_byte(struct xfs_mount *mp, xfs_dir2_dataptr_t dp) |
163 | ((xfs_dir2_off_t)(dp) << XFS_DIR2_DATA_ALIGN_LOG) | 121 | { |
164 | #endif | 122 | return (xfs_dir2_off_t)(dp) << XFS_DIR2_DATA_ALIGN_LOG; |
123 | } | ||
165 | 124 | ||
166 | /* | 125 | /* |
167 | * Convert byte in file space to dataptr. It had better be aligned. | 126 | * Convert byte in file space to dataptr. It had better be aligned. |
168 | */ | 127 | */ |
169 | #if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_DIR2_BYTE_TO_DATAPTR) | ||
170 | xfs_dir2_dataptr_t | ||
171 | xfs_dir2_byte_to_dataptr(struct xfs_mount *mp, xfs_dir2_off_t by); | ||
172 | #define XFS_DIR2_BYTE_TO_DATAPTR(mp,by) xfs_dir2_byte_to_dataptr(mp,by) | 128 | #define XFS_DIR2_BYTE_TO_DATAPTR(mp,by) xfs_dir2_byte_to_dataptr(mp,by) |
173 | #else | 129 | static inline xfs_dir2_dataptr_t |
174 | #define XFS_DIR2_BYTE_TO_DATAPTR(mp,by) \ | 130 | xfs_dir2_byte_to_dataptr(struct xfs_mount *mp, xfs_dir2_off_t by) |
175 | ((xfs_dir2_dataptr_t)((by) >> XFS_DIR2_DATA_ALIGN_LOG)) | 131 | { |
176 | #endif | 132 | return (xfs_dir2_dataptr_t)((by) >> XFS_DIR2_DATA_ALIGN_LOG); |
133 | } | ||
134 | |||
135 | /* | ||
136 | * Convert byte in space to (DB) block | ||
137 | */ | ||
138 | #define XFS_DIR2_BYTE_TO_DB(mp,by) xfs_dir2_byte_to_db(mp, by) | ||
139 | static inline xfs_dir2_db_t | ||
140 | xfs_dir2_byte_to_db(struct xfs_mount *mp, xfs_dir2_off_t by) | ||
141 | { | ||
142 | return (xfs_dir2_db_t)((by) >> \ | ||
143 | ((mp)->m_sb.sb_blocklog + (mp)->m_sb.sb_dirblklog)); | ||
144 | } | ||
177 | 145 | ||
178 | /* | 146 | /* |
179 | * Convert dataptr to a block number | 147 | * Convert dataptr to a block number |
180 | */ | 148 | */ |
181 | #if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_DIR2_DATAPTR_TO_DB) | ||
182 | xfs_dir2_db_t | ||
183 | xfs_dir2_dataptr_to_db(struct xfs_mount *mp, xfs_dir2_dataptr_t dp); | ||
184 | #define XFS_DIR2_DATAPTR_TO_DB(mp,dp) xfs_dir2_dataptr_to_db(mp, dp) | 149 | #define XFS_DIR2_DATAPTR_TO_DB(mp,dp) xfs_dir2_dataptr_to_db(mp, dp) |
185 | #else | 150 | static inline xfs_dir2_db_t |
186 | #define XFS_DIR2_DATAPTR_TO_DB(mp,dp) \ | 151 | xfs_dir2_dataptr_to_db(struct xfs_mount *mp, xfs_dir2_dataptr_t dp) |
187 | XFS_DIR2_BYTE_TO_DB(mp, XFS_DIR2_DATAPTR_TO_BYTE(mp, dp)) | 152 | { |
188 | #endif | 153 | return XFS_DIR2_BYTE_TO_DB(mp, XFS_DIR2_DATAPTR_TO_BYTE(mp, dp)); |
154 | } | ||
155 | |||
156 | /* | ||
157 | * Convert byte in space to offset in a block | ||
158 | */ | ||
159 | #define XFS_DIR2_BYTE_TO_OFF(mp,by) xfs_dir2_byte_to_off(mp, by) | ||
160 | static inline xfs_dir2_data_aoff_t | ||
161 | xfs_dir2_byte_to_off(struct xfs_mount *mp, xfs_dir2_off_t by) | ||
162 | { | ||
163 | return (xfs_dir2_data_aoff_t)((by) & \ | ||
164 | ((1 << ((mp)->m_sb.sb_blocklog + (mp)->m_sb.sb_dirblklog)) - 1)); | ||
165 | } | ||
189 | 166 | ||
190 | /* | 167 | /* |
191 | * Convert dataptr to a byte offset in a block | 168 | * Convert dataptr to a byte offset in a block |
192 | */ | 169 | */ |
193 | #if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_DIR2_DATAPTR_TO_OFF) | ||
194 | xfs_dir2_data_aoff_t | ||
195 | xfs_dir2_dataptr_to_off(struct xfs_mount *mp, xfs_dir2_dataptr_t dp); | ||
196 | #define XFS_DIR2_DATAPTR_TO_OFF(mp,dp) xfs_dir2_dataptr_to_off(mp, dp) | 170 | #define XFS_DIR2_DATAPTR_TO_OFF(mp,dp) xfs_dir2_dataptr_to_off(mp, dp) |
197 | #else | 171 | static inline xfs_dir2_data_aoff_t |
198 | #define XFS_DIR2_DATAPTR_TO_OFF(mp,dp) \ | 172 | xfs_dir2_dataptr_to_off(struct xfs_mount *mp, xfs_dir2_dataptr_t dp) |
199 | XFS_DIR2_BYTE_TO_OFF(mp, XFS_DIR2_DATAPTR_TO_BYTE(mp, dp)) | 173 | { |
200 | #endif | 174 | return XFS_DIR2_BYTE_TO_OFF(mp, XFS_DIR2_DATAPTR_TO_BYTE(mp, dp)); |
175 | } | ||
201 | 176 | ||
202 | /* | 177 | /* |
203 | * Convert block and offset to byte in space | 178 | * Convert block and offset to byte in space |
204 | */ | 179 | */ |
205 | #if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_DIR2_DB_OFF_TO_BYTE) | ||
206 | xfs_dir2_off_t | ||
207 | xfs_dir2_db_off_to_byte(struct xfs_mount *mp, xfs_dir2_db_t db, | ||
208 | xfs_dir2_data_aoff_t o); | ||
209 | #define XFS_DIR2_DB_OFF_TO_BYTE(mp,db,o) \ | 180 | #define XFS_DIR2_DB_OFF_TO_BYTE(mp,db,o) \ |
210 | xfs_dir2_db_off_to_byte(mp, db, o) | 181 | xfs_dir2_db_off_to_byte(mp, db, o) |
211 | #else | 182 | static inline xfs_dir2_off_t |
212 | #define XFS_DIR2_DB_OFF_TO_BYTE(mp,db,o) \ | 183 | xfs_dir2_db_off_to_byte(struct xfs_mount *mp, xfs_dir2_db_t db, |
213 | (((xfs_dir2_off_t)(db) << \ | 184 | xfs_dir2_data_aoff_t o) |
214 | ((mp)->m_sb.sb_blocklog + (mp)->m_sb.sb_dirblklog)) + (o)) | 185 | { |
215 | #endif | 186 | return ((xfs_dir2_off_t)(db) << \ |
187 | ((mp)->m_sb.sb_blocklog + (mp)->m_sb.sb_dirblklog)) + (o); | ||
188 | } | ||
216 | 189 | ||
217 | /* | 190 | /* |
218 | * Convert byte in space to (DB) block | 191 | * Convert block (DB) to block (dablk) |
219 | */ | 192 | */ |
220 | #if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_DIR2_BYTE_TO_DB) | 193 | #define XFS_DIR2_DB_TO_DA(mp,db) xfs_dir2_db_to_da(mp, db) |
221 | xfs_dir2_db_t xfs_dir2_byte_to_db(struct xfs_mount *mp, xfs_dir2_off_t by); | 194 | static inline xfs_dablk_t |
222 | #define XFS_DIR2_BYTE_TO_DB(mp,by) xfs_dir2_byte_to_db(mp, by) | 195 | xfs_dir2_db_to_da(struct xfs_mount *mp, xfs_dir2_db_t db) |
223 | #else | 196 | { |
224 | #define XFS_DIR2_BYTE_TO_DB(mp,by) \ | 197 | return (xfs_dablk_t)((db) << (mp)->m_sb.sb_dirblklog); |
225 | ((xfs_dir2_db_t)((by) >> \ | 198 | } |
226 | ((mp)->m_sb.sb_blocklog + (mp)->m_sb.sb_dirblklog))) | ||
227 | #endif | ||
228 | 199 | ||
229 | /* | 200 | /* |
230 | * Convert byte in space to (DA) block | 201 | * Convert byte in space to (DA) block |
231 | */ | 202 | */ |
232 | #if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_DIR2_BYTE_TO_DA) | ||
233 | xfs_dablk_t xfs_dir2_byte_to_da(struct xfs_mount *mp, xfs_dir2_off_t by); | ||
234 | #define XFS_DIR2_BYTE_TO_DA(mp,by) xfs_dir2_byte_to_da(mp, by) | 203 | #define XFS_DIR2_BYTE_TO_DA(mp,by) xfs_dir2_byte_to_da(mp, by) |
235 | #else | 204 | static inline xfs_dablk_t |
236 | #define XFS_DIR2_BYTE_TO_DA(mp,by) \ | 205 | xfs_dir2_byte_to_da(struct xfs_mount *mp, xfs_dir2_off_t by) |
237 | XFS_DIR2_DB_TO_DA(mp, XFS_DIR2_BYTE_TO_DB(mp, by)) | 206 | { |
238 | #endif | 207 | return XFS_DIR2_DB_TO_DA(mp, XFS_DIR2_BYTE_TO_DB(mp, by)); |
239 | 208 | } | |
240 | /* | ||
241 | * Convert byte in space to offset in a block | ||
242 | */ | ||
243 | #if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_DIR2_BYTE_TO_OFF) | ||
244 | xfs_dir2_data_aoff_t | ||
245 | xfs_dir2_byte_to_off(struct xfs_mount *mp, xfs_dir2_off_t by); | ||
246 | #define XFS_DIR2_BYTE_TO_OFF(mp,by) xfs_dir2_byte_to_off(mp, by) | ||
247 | #else | ||
248 | #define XFS_DIR2_BYTE_TO_OFF(mp,by) \ | ||
249 | ((xfs_dir2_data_aoff_t)((by) & \ | ||
250 | ((1 << ((mp)->m_sb.sb_blocklog + \ | ||
251 | (mp)->m_sb.sb_dirblklog)) - 1))) | ||
252 | #endif | ||
253 | 209 | ||
254 | /* | 210 | /* |
255 | * Convert block and offset to dataptr | 211 | * Convert block and offset to dataptr |
256 | */ | 212 | */ |
257 | #if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_DIR2_DB_OFF_TO_DATAPTR) | ||
258 | xfs_dir2_dataptr_t | ||
259 | xfs_dir2_db_off_to_dataptr(struct xfs_mount *mp, xfs_dir2_db_t db, | ||
260 | xfs_dir2_data_aoff_t o); | ||
261 | #define XFS_DIR2_DB_OFF_TO_DATAPTR(mp,db,o) \ | 213 | #define XFS_DIR2_DB_OFF_TO_DATAPTR(mp,db,o) \ |
262 | xfs_dir2_db_off_to_dataptr(mp, db, o) | 214 | xfs_dir2_db_off_to_dataptr(mp, db, o) |
263 | #else | 215 | static inline xfs_dir2_dataptr_t |
264 | #define XFS_DIR2_DB_OFF_TO_DATAPTR(mp,db,o) \ | 216 | xfs_dir2_db_off_to_dataptr(struct xfs_mount *mp, xfs_dir2_db_t db, |
265 | XFS_DIR2_BYTE_TO_DATAPTR(mp, XFS_DIR2_DB_OFF_TO_BYTE(mp, db, o)) | 217 | xfs_dir2_data_aoff_t o) |
266 | #endif | 218 | { |
267 | 219 | return XFS_DIR2_BYTE_TO_DATAPTR(mp, XFS_DIR2_DB_OFF_TO_BYTE(mp, db, o)); | |
268 | /* | 220 | } |
269 | * Convert block (DB) to block (dablk) | ||
270 | */ | ||
271 | #if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_DIR2_DB_TO_DA) | ||
272 | xfs_dablk_t xfs_dir2_db_to_da(struct xfs_mount *mp, xfs_dir2_db_t db); | ||
273 | #define XFS_DIR2_DB_TO_DA(mp,db) xfs_dir2_db_to_da(mp, db) | ||
274 | #else | ||
275 | #define XFS_DIR2_DB_TO_DA(mp,db) \ | ||
276 | ((xfs_dablk_t)((db) << (mp)->m_sb.sb_dirblklog)) | ||
277 | #endif | ||
278 | 221 | ||
279 | /* | 222 | /* |
280 | * Convert block (dablk) to block (DB) | 223 | * Convert block (dablk) to block (DB) |
281 | */ | 224 | */ |
282 | #if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_DIR2_DA_TO_DB) | ||
283 | xfs_dir2_db_t xfs_dir2_da_to_db(struct xfs_mount *mp, xfs_dablk_t da); | ||
284 | #define XFS_DIR2_DA_TO_DB(mp,da) xfs_dir2_da_to_db(mp, da) | 225 | #define XFS_DIR2_DA_TO_DB(mp,da) xfs_dir2_da_to_db(mp, da) |
285 | #else | 226 | static inline xfs_dir2_db_t |
286 | #define XFS_DIR2_DA_TO_DB(mp,da) \ | 227 | xfs_dir2_da_to_db(struct xfs_mount *mp, xfs_dablk_t da) |
287 | ((xfs_dir2_db_t)((da) >> (mp)->m_sb.sb_dirblklog)) | 228 | { |
288 | #endif | 229 | return (xfs_dir2_db_t)((da) >> (mp)->m_sb.sb_dirblklog); |
230 | } | ||
289 | 231 | ||
290 | /* | 232 | /* |
291 | * Convert block (dablk) to byte offset in space | 233 | * Convert block (dablk) to byte offset in space |
292 | */ | 234 | */ |
293 | #if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_DIR2_DA_TO_BYTE) | ||
294 | xfs_dir2_off_t xfs_dir2_da_to_byte(struct xfs_mount *mp, xfs_dablk_t da); | ||
295 | #define XFS_DIR2_DA_TO_BYTE(mp,da) xfs_dir2_da_to_byte(mp, da) | 235 | #define XFS_DIR2_DA_TO_BYTE(mp,da) xfs_dir2_da_to_byte(mp, da) |
296 | #else | 236 | static inline xfs_dir2_off_t |
297 | #define XFS_DIR2_DA_TO_BYTE(mp,da) \ | 237 | xfs_dir2_da_to_byte(struct xfs_mount *mp, xfs_dablk_t da) |
298 | XFS_DIR2_DB_OFF_TO_BYTE(mp, XFS_DIR2_DA_TO_DB(mp, da), 0) | 238 | { |
299 | #endif | 239 | return XFS_DIR2_DB_OFF_TO_BYTE(mp, XFS_DIR2_DA_TO_DB(mp, da), 0); |
240 | } | ||
300 | 241 | ||
301 | /* | 242 | /* |
302 | * Function declarations. | 243 | * Function declarations. |
303 | */ | 244 | */ |
304 | 245 | extern int xfs_dir2_block_to_leaf(struct xfs_da_args *args, | |
305 | extern int | 246 | struct xfs_dabuf *dbp); |
306 | xfs_dir2_block_to_leaf(struct xfs_da_args *args, struct xfs_dabuf *dbp); | 247 | extern int xfs_dir2_leaf_addname(struct xfs_da_args *args); |
307 | 248 | extern void xfs_dir2_leaf_compact(struct xfs_da_args *args, | |
308 | extern int | 249 | struct xfs_dabuf *bp); |
309 | xfs_dir2_leaf_addname(struct xfs_da_args *args); | 250 | extern void xfs_dir2_leaf_compact_x1(struct xfs_dabuf *bp, int *indexp, |
310 | 251 | int *lowstalep, int *highstalep, | |
311 | extern void | 252 | int *lowlogp, int *highlogp); |
312 | xfs_dir2_leaf_compact(struct xfs_da_args *args, struct xfs_dabuf *bp); | 253 | extern int xfs_dir2_leaf_getdents(struct xfs_trans *tp, struct xfs_inode *dp, |
313 | 254 | struct uio *uio, int *eofp, | |
314 | extern void | 255 | struct xfs_dirent *dbp, xfs_dir2_put_t put); |
315 | xfs_dir2_leaf_compact_x1(struct xfs_dabuf *bp, int *indexp, | 256 | extern int xfs_dir2_leaf_init(struct xfs_da_args *args, xfs_dir2_db_t bno, |
316 | int *lowstalep, int *highstalep, int *lowlogp, | 257 | struct xfs_dabuf **bpp, int magic); |
317 | int *highlogp); | 258 | extern void xfs_dir2_leaf_log_ents(struct xfs_trans *tp, struct xfs_dabuf *bp, |
318 | 259 | int first, int last); | |
319 | extern int | 260 | extern void xfs_dir2_leaf_log_header(struct xfs_trans *tp, |
320 | xfs_dir2_leaf_getdents(struct xfs_trans *tp, struct xfs_inode *dp, | 261 | struct xfs_dabuf *bp); |
321 | struct uio *uio, int *eofp, struct xfs_dirent *dbp, | 262 | extern int xfs_dir2_leaf_lookup(struct xfs_da_args *args); |
322 | xfs_dir2_put_t put); | 263 | extern int xfs_dir2_leaf_removename(struct xfs_da_args *args); |
323 | 264 | extern int xfs_dir2_leaf_replace(struct xfs_da_args *args); | |
324 | extern int | 265 | extern int xfs_dir2_leaf_search_hash(struct xfs_da_args *args, |
325 | xfs_dir2_leaf_init(struct xfs_da_args *args, xfs_dir2_db_t bno, | 266 | struct xfs_dabuf *lbp); |
326 | struct xfs_dabuf **bpp, int magic); | 267 | extern int xfs_dir2_leaf_trim_data(struct xfs_da_args *args, |
327 | 268 | struct xfs_dabuf *lbp, xfs_dir2_db_t db); | |
328 | extern void | 269 | extern int xfs_dir2_node_to_leaf(struct xfs_da_state *state); |
329 | xfs_dir2_leaf_log_ents(struct xfs_trans *tp, struct xfs_dabuf *bp, | ||
330 | int first, int last); | ||
331 | |||
332 | extern void | ||
333 | xfs_dir2_leaf_log_header(struct xfs_trans *tp, struct xfs_dabuf *bp); | ||
334 | |||
335 | extern int | ||
336 | xfs_dir2_leaf_lookup(struct xfs_da_args *args); | ||
337 | |||
338 | extern int | ||
339 | xfs_dir2_leaf_removename(struct xfs_da_args *args); | ||
340 | |||
341 | extern int | ||
342 | xfs_dir2_leaf_replace(struct xfs_da_args *args); | ||
343 | |||
344 | extern int | ||
345 | xfs_dir2_leaf_search_hash(struct xfs_da_args *args, | ||
346 | struct xfs_dabuf *lbp); | ||
347 | extern int | ||
348 | xfs_dir2_leaf_trim_data(struct xfs_da_args *args, struct xfs_dabuf *lbp, xfs_dir2_db_t db); | ||
349 | |||
350 | extern int | ||
351 | xfs_dir2_node_to_leaf(struct xfs_da_state *state); | ||
352 | 270 | ||
353 | #endif /* __XFS_DIR2_LEAF_H__ */ | 271 | #endif /* __XFS_DIR2_LEAF_H__ */ |
diff --git a/fs/xfs/xfs_dir2_node.c b/fs/xfs/xfs_dir2_node.c index a7615d86bfb7..641f8633d254 100644 --- a/fs/xfs/xfs_dir2_node.c +++ b/fs/xfs/xfs_dir2_node.c | |||
@@ -1,61 +1,39 @@ | |||
1 | /* | 1 | /* |
2 | * Copyright (c) 2000-2004 Silicon Graphics, Inc. All Rights Reserved. | 2 | * Copyright (c) 2000-2005 Silicon Graphics, Inc. |
3 | * All Rights Reserved. | ||
3 | * | 4 | * |
4 | * This program is free software; you can redistribute it and/or modify it | 5 | * This program is free software; you can redistribute it and/or |
5 | * under the terms of version 2 of the GNU General Public License as | 6 | * modify it under the terms of the GNU General Public License as |
6 | * published by the Free Software Foundation. | 7 | * published by the Free Software Foundation. |
7 | * | 8 | * |
8 | * This program is distributed in the hope that it would be useful, but | 9 | * This program is distributed in the hope that it would be useful, |
9 | * WITHOUT ANY WARRANTY; without even the implied warranty of | 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
12 | * GNU General Public License for more details. | ||
11 | * | 13 | * |
12 | * Further, this software is distributed without any warranty that it is | 14 | * You should have received a copy of the GNU General Public License |
13 | * free of the rightful claim of any third person regarding infringement | 15 | * along with this program; if not, write the Free Software Foundation, |
14 | * or the like. Any license provided herein, whether implied or | 16 | * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
15 | * otherwise, applies only to this software file. Patent licenses, if | ||
16 | * any, provided herein do not apply to combinations of this program with | ||
17 | * other software, or any other product whatsoever. | ||
18 | * | ||
19 | * You should have received a copy of the GNU General Public License along | ||
20 | * with this program; if not, write the Free Software Foundation, Inc., 59 | ||
21 | * Temple Place - Suite 330, Boston MA 02111-1307, USA. | ||
22 | * | ||
23 | * Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy, | ||
24 | * Mountain View, CA 94043, or: | ||
25 | * | ||
26 | * http://www.sgi.com | ||
27 | * | ||
28 | * For further information regarding this notice, see: | ||
29 | * | ||
30 | * http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/ | ||
31 | */ | ||
32 | |||
33 | /* | ||
34 | * xfs_dir2_node.c | ||
35 | * XFS directory implementation, version 2, node form files | ||
36 | * See data structures in xfs_dir2_node.h and xfs_da_btree.h. | ||
37 | */ | 17 | */ |
38 | |||
39 | #include "xfs.h" | 18 | #include "xfs.h" |
40 | 19 | #include "xfs_fs.h" | |
41 | #include "xfs_macros.h" | ||
42 | #include "xfs_types.h" | 20 | #include "xfs_types.h" |
43 | #include "xfs_inum.h" | ||
44 | #include "xfs_log.h" | 21 | #include "xfs_log.h" |
22 | #include "xfs_inum.h" | ||
45 | #include "xfs_trans.h" | 23 | #include "xfs_trans.h" |
46 | #include "xfs_sb.h" | 24 | #include "xfs_sb.h" |
47 | #include "xfs_dir.h" | 25 | #include "xfs_dir.h" |
48 | #include "xfs_dir2.h" | 26 | #include "xfs_dir2.h" |
49 | #include "xfs_dmapi.h" | 27 | #include "xfs_dmapi.h" |
50 | #include "xfs_mount.h" | 28 | #include "xfs_mount.h" |
29 | #include "xfs_da_btree.h" | ||
51 | #include "xfs_bmap_btree.h" | 30 | #include "xfs_bmap_btree.h" |
52 | #include "xfs_attr_sf.h" | ||
53 | #include "xfs_dir_sf.h" | 31 | #include "xfs_dir_sf.h" |
54 | #include "xfs_dir2_sf.h" | 32 | #include "xfs_dir2_sf.h" |
33 | #include "xfs_attr_sf.h" | ||
55 | #include "xfs_dinode.h" | 34 | #include "xfs_dinode.h" |
56 | #include "xfs_inode.h" | 35 | #include "xfs_inode.h" |
57 | #include "xfs_bmap.h" | 36 | #include "xfs_bmap.h" |
58 | #include "xfs_da_btree.h" | ||
59 | #include "xfs_dir2_data.h" | 37 | #include "xfs_dir2_data.h" |
60 | #include "xfs_dir2_leaf.h" | 38 | #include "xfs_dir2_leaf.h" |
61 | #include "xfs_dir2_block.h" | 39 | #include "xfs_dir2_block.h" |
diff --git a/fs/xfs/xfs_dir2_node.h b/fs/xfs/xfs_dir2_node.h index 96db420c7c5c..0ab8fbd59512 100644 --- a/fs/xfs/xfs_dir2_node.h +++ b/fs/xfs/xfs_dir2_node.h | |||
@@ -1,33 +1,19 @@ | |||
1 | /* | 1 | /* |
2 | * Copyright (c) 2000 Silicon Graphics, Inc. All Rights Reserved. | 2 | * Copyright (c) 2000,2005 Silicon Graphics, Inc. |
3 | * All Rights Reserved. | ||
3 | * | 4 | * |
4 | * This program is free software; you can redistribute it and/or modify it | 5 | * This program is free software; you can redistribute it and/or |
5 | * under the terms of version 2 of the GNU General Public License as | 6 | * modify it under the terms of the GNU General Public License as |
6 | * published by the Free Software Foundation. | 7 | * published by the Free Software Foundation. |
7 | * | 8 | * |
8 | * This program is distributed in the hope that it would be useful, but | 9 | * This program is distributed in the hope that it would be useful, |
9 | * WITHOUT ANY WARRANTY; without even the implied warranty of | 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
12 | * GNU General Public License for more details. | ||
11 | * | 13 | * |
12 | * Further, this software is distributed without any warranty that it is | 14 | * You should have received a copy of the GNU General Public License |
13 | * free of the rightful claim of any third person regarding infringement | 15 | * along with this program; if not, write the Free Software Foundation, |
14 | * or the like. Any license provided herein, whether implied or | 16 | * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
15 | * otherwise, applies only to this software file. Patent licenses, if | ||
16 | * any, provided herein do not apply to combinations of this program with | ||
17 | * other software, or any other product whatsoever. | ||
18 | * | ||
19 | * You should have received a copy of the GNU General Public License along | ||
20 | * with this program; if not, write the Free Software Foundation, Inc., 59 | ||
21 | * Temple Place - Suite 330, Boston MA 02111-1307, USA. | ||
22 | * | ||
23 | * Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy, | ||
24 | * Mountain View, CA 94043, or: | ||
25 | * | ||
26 | * http://www.sgi.com | ||
27 | * | ||
28 | * For further information regarding this notice, see: | ||
29 | * | ||
30 | * http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/ | ||
31 | */ | 17 | */ |
32 | #ifndef __XFS_DIR2_NODE_H__ | 18 | #ifndef __XFS_DIR2_NODE_H__ |
33 | #define __XFS_DIR2_NODE_H__ | 19 | #define __XFS_DIR2_NODE_H__ |
@@ -45,10 +31,6 @@ struct xfs_inode; | |||
45 | struct xfs_trans; | 31 | struct xfs_trans; |
46 | 32 | ||
47 | /* | 33 | /* |
48 | * Constants. | ||
49 | */ | ||
50 | |||
51 | /* | ||
52 | * Offset of the freespace index. | 34 | * Offset of the freespace index. |
53 | */ | 35 | */ |
54 | #define XFS_DIR2_FREE_SPACE 2 | 36 | #define XFS_DIR2_FREE_SPACE 2 |
@@ -58,9 +40,6 @@ struct xfs_trans; | |||
58 | 40 | ||
59 | #define XFS_DIR2_FREE_MAGIC 0x58443246 /* XD2F */ | 41 | #define XFS_DIR2_FREE_MAGIC 0x58443246 /* XD2F */ |
60 | 42 | ||
61 | /* | ||
62 | * Structures. | ||
63 | */ | ||
64 | typedef struct xfs_dir2_free_hdr { | 43 | typedef struct xfs_dir2_free_hdr { |
65 | __uint32_t magic; /* XFS_DIR2_FREE_MAGIC */ | 44 | __uint32_t magic; /* XFS_DIR2_FREE_MAGIC */ |
66 | __int32_t firstdb; /* db of first entry */ | 45 | __int32_t firstdb; /* db of first entry */ |
@@ -73,87 +52,53 @@ typedef struct xfs_dir2_free { | |||
73 | xfs_dir2_data_off_t bests[1]; /* best free counts */ | 52 | xfs_dir2_data_off_t bests[1]; /* best free counts */ |
74 | /* unused entries are -1 */ | 53 | /* unused entries are -1 */ |
75 | } xfs_dir2_free_t; | 54 | } xfs_dir2_free_t; |
55 | |||
76 | #define XFS_DIR2_MAX_FREE_BESTS(mp) \ | 56 | #define XFS_DIR2_MAX_FREE_BESTS(mp) \ |
77 | (((mp)->m_dirblksize - (uint)sizeof(xfs_dir2_free_hdr_t)) / \ | 57 | (((mp)->m_dirblksize - (uint)sizeof(xfs_dir2_free_hdr_t)) / \ |
78 | (uint)sizeof(xfs_dir2_data_off_t)) | 58 | (uint)sizeof(xfs_dir2_data_off_t)) |
79 | 59 | ||
80 | /* | 60 | /* |
81 | * Macros. | ||
82 | */ | ||
83 | |||
84 | /* | ||
85 | * Convert data space db to the corresponding free db. | 61 | * Convert data space db to the corresponding free db. |
86 | */ | 62 | */ |
87 | #if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_DIR2_DB_TO_FDB) | ||
88 | xfs_dir2_db_t | ||
89 | xfs_dir2_db_to_fdb(struct xfs_mount *mp, xfs_dir2_db_t db); | ||
90 | #define XFS_DIR2_DB_TO_FDB(mp,db) xfs_dir2_db_to_fdb(mp, db) | 63 | #define XFS_DIR2_DB_TO_FDB(mp,db) xfs_dir2_db_to_fdb(mp, db) |
91 | #else | 64 | static inline xfs_dir2_db_t |
92 | #define XFS_DIR2_DB_TO_FDB(mp,db) \ | 65 | xfs_dir2_db_to_fdb(struct xfs_mount *mp, xfs_dir2_db_t db) |
93 | (XFS_DIR2_FREE_FIRSTDB(mp) + (db) / XFS_DIR2_MAX_FREE_BESTS(mp)) | 66 | { |
94 | #endif | 67 | return (XFS_DIR2_FREE_FIRSTDB(mp) + (db) / XFS_DIR2_MAX_FREE_BESTS(mp)); |
68 | } | ||
95 | 69 | ||
96 | /* | 70 | /* |
97 | * Convert data space db to the corresponding index in a free db. | 71 | * Convert data space db to the corresponding index in a free db. |
98 | */ | 72 | */ |
99 | #if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_DIR2_DB_TO_FDINDEX) | ||
100 | int | ||
101 | xfs_dir2_db_to_fdindex(struct xfs_mount *mp, xfs_dir2_db_t db); | ||
102 | #define XFS_DIR2_DB_TO_FDINDEX(mp,db) xfs_dir2_db_to_fdindex(mp, db) | 73 | #define XFS_DIR2_DB_TO_FDINDEX(mp,db) xfs_dir2_db_to_fdindex(mp, db) |
103 | #else | 74 | static inline int |
104 | #define XFS_DIR2_DB_TO_FDINDEX(mp,db) ((db) % XFS_DIR2_MAX_FREE_BESTS(mp)) | 75 | xfs_dir2_db_to_fdindex(struct xfs_mount *mp, xfs_dir2_db_t db) |
105 | #endif | 76 | { |
106 | 77 | return ((db) % XFS_DIR2_MAX_FREE_BESTS(mp)); | |
107 | /* | 78 | } |
108 | * Functions. | 79 | |
109 | */ | 80 | extern void xfs_dir2_free_log_bests(struct xfs_trans *tp, struct xfs_dabuf *bp, |
110 | 81 | int first, int last); | |
111 | extern void | 82 | extern int xfs_dir2_leaf_to_node(struct xfs_da_args *args, |
112 | xfs_dir2_free_log_bests(struct xfs_trans *tp, struct xfs_dabuf *bp, | 83 | struct xfs_dabuf *lbp); |
113 | int first, int last); | 84 | extern xfs_dahash_t xfs_dir2_leafn_lasthash(struct xfs_dabuf *bp, int *count); |
114 | 85 | extern int xfs_dir2_leafn_lookup_int(struct xfs_dabuf *bp, | |
115 | extern int | 86 | struct xfs_da_args *args, int *indexp, |
116 | xfs_dir2_leaf_to_node(struct xfs_da_args *args, struct xfs_dabuf *lbp); | 87 | struct xfs_da_state *state); |
117 | 88 | extern int xfs_dir2_leafn_order(struct xfs_dabuf *leaf1_bp, | |
118 | extern xfs_dahash_t | 89 | struct xfs_dabuf *leaf2_bp); |
119 | xfs_dir2_leafn_lasthash(struct xfs_dabuf *bp, int *count); | 90 | extern int xfs_dir2_leafn_split(struct xfs_da_state *state, |
120 | 91 | struct xfs_da_state_blk *oldblk, | |
121 | extern int | 92 | struct xfs_da_state_blk *newblk); |
122 | xfs_dir2_leafn_lookup_int(struct xfs_dabuf *bp, | 93 | extern int xfs_dir2_leafn_toosmall(struct xfs_da_state *state, int *action); |
123 | struct xfs_da_args *args, int *indexp, | 94 | extern void xfs_dir2_leafn_unbalance(struct xfs_da_state *state, |
124 | struct xfs_da_state *state); | 95 | struct xfs_da_state_blk *drop_blk, |
125 | 96 | struct xfs_da_state_blk *save_blk); | |
126 | extern int | 97 | extern int xfs_dir2_node_addname(struct xfs_da_args *args); |
127 | xfs_dir2_leafn_order(struct xfs_dabuf *leaf1_bp, | 98 | extern int xfs_dir2_node_lookup(struct xfs_da_args *args); |
128 | struct xfs_dabuf *leaf2_bp); | 99 | extern int xfs_dir2_node_removename(struct xfs_da_args *args); |
129 | 100 | extern int xfs_dir2_node_replace(struct xfs_da_args *args); | |
130 | extern int | 101 | extern int xfs_dir2_node_trim_free(struct xfs_da_args *args, xfs_fileoff_t fo, |
131 | xfs_dir2_leafn_split(struct xfs_da_state *state, | 102 | int *rvalp); |
132 | struct xfs_da_state_blk *oldblk, | ||
133 | struct xfs_da_state_blk *newblk); | ||
134 | |||
135 | extern int | ||
136 | xfs_dir2_leafn_toosmall(struct xfs_da_state *state, int *action); | ||
137 | |||
138 | extern void | ||
139 | xfs_dir2_leafn_unbalance(struct xfs_da_state *state, | ||
140 | struct xfs_da_state_blk *drop_blk, | ||
141 | struct xfs_da_state_blk *save_blk); | ||
142 | |||
143 | extern int | ||
144 | xfs_dir2_node_addname(struct xfs_da_args *args); | ||
145 | |||
146 | extern int | ||
147 | xfs_dir2_node_lookup(struct xfs_da_args *args); | ||
148 | |||
149 | extern int | ||
150 | xfs_dir2_node_removename(struct xfs_da_args *args); | ||
151 | |||
152 | extern int | ||
153 | xfs_dir2_node_replace(struct xfs_da_args *args); | ||
154 | |||
155 | extern int | ||
156 | xfs_dir2_node_trim_free(struct xfs_da_args *args, xfs_fileoff_t fo, | ||
157 | int *rvalp); | ||
158 | 103 | ||
159 | #endif /* __XFS_DIR2_NODE_H__ */ | 104 | #endif /* __XFS_DIR2_NODE_H__ */ |
diff --git a/fs/xfs/xfs_dir2_sf.c b/fs/xfs/xfs_dir2_sf.c index 6bbc61674411..ec8e7476c8b7 100644 --- a/fs/xfs/xfs_dir2_sf.c +++ b/fs/xfs/xfs_dir2_sf.c | |||
@@ -1,60 +1,39 @@ | |||
1 | /* | 1 | /* |
2 | * Copyright (c) 2000-2003 Silicon Graphics, Inc. All Rights Reserved. | 2 | * Copyright (c) 2000-2003,2005 Silicon Graphics, Inc. |
3 | * All Rights Reserved. | ||
3 | * | 4 | * |
4 | * This program is free software; you can redistribute it and/or modify it | 5 | * This program is free software; you can redistribute it and/or |
5 | * under the terms of version 2 of the GNU General Public License as | 6 | * modify it under the terms of the GNU General Public License as |
6 | * published by the Free Software Foundation. | 7 | * published by the Free Software Foundation. |
7 | * | 8 | * |
8 | * This program is distributed in the hope that it would be useful, but | 9 | * This program is distributed in the hope that it would be useful, |
9 | * WITHOUT ANY WARRANTY; without even the implied warranty of | 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
12 | * GNU General Public License for more details. | ||
11 | * | 13 | * |
12 | * Further, this software is distributed without any warranty that it is | 14 | * You should have received a copy of the GNU General Public License |
13 | * free of the rightful claim of any third person regarding infringement | 15 | * along with this program; if not, write the Free Software Foundation, |
14 | * or the like. Any license provided herein, whether implied or | 16 | * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
15 | * otherwise, applies only to this software file. Patent licenses, if | ||
16 | * any, provided herein do not apply to combinations of this program with | ||
17 | * other software, or any other product whatsoever. | ||
18 | * | ||
19 | * You should have received a copy of the GNU General Public License along | ||
20 | * with this program; if not, write the Free Software Foundation, Inc., 59 | ||
21 | * Temple Place - Suite 330, Boston MA 02111-1307, USA. | ||
22 | * | ||
23 | * Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy, | ||
24 | * Mountain View, CA 94043, or: | ||
25 | * | ||
26 | * http://www.sgi.com | ||
27 | * | ||
28 | * For further information regarding this notice, see: | ||
29 | * | ||
30 | * http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/ | ||
31 | */ | 17 | */ |
32 | |||
33 | /* | ||
34 | * xfs_dir2_sf.c | ||
35 | * Shortform directory implementation for v2 directories. | ||
36 | */ | ||
37 | |||
38 | #include "xfs.h" | 18 | #include "xfs.h" |
39 | 19 | #include "xfs_fs.h" | |
40 | #include "xfs_macros.h" | ||
41 | #include "xfs_types.h" | 20 | #include "xfs_types.h" |
42 | #include "xfs_inum.h" | ||
43 | #include "xfs_log.h" | 21 | #include "xfs_log.h" |
22 | #include "xfs_inum.h" | ||
44 | #include "xfs_trans.h" | 23 | #include "xfs_trans.h" |
45 | #include "xfs_sb.h" | 24 | #include "xfs_sb.h" |
46 | #include "xfs_dir.h" | 25 | #include "xfs_dir.h" |
47 | #include "xfs_dir2.h" | 26 | #include "xfs_dir2.h" |
48 | #include "xfs_dmapi.h" | 27 | #include "xfs_dmapi.h" |
49 | #include "xfs_mount.h" | 28 | #include "xfs_mount.h" |
29 | #include "xfs_da_btree.h" | ||
50 | #include "xfs_bmap_btree.h" | 30 | #include "xfs_bmap_btree.h" |
51 | #include "xfs_attr_sf.h" | ||
52 | #include "xfs_dir_sf.h" | 31 | #include "xfs_dir_sf.h" |
53 | #include "xfs_dir2_sf.h" | 32 | #include "xfs_dir2_sf.h" |
33 | #include "xfs_attr_sf.h" | ||
54 | #include "xfs_dinode.h" | 34 | #include "xfs_dinode.h" |
55 | #include "xfs_inode_item.h" | ||
56 | #include "xfs_inode.h" | 35 | #include "xfs_inode.h" |
57 | #include "xfs_da_btree.h" | 36 | #include "xfs_inode_item.h" |
58 | #include "xfs_dir_leaf.h" | 37 | #include "xfs_dir_leaf.h" |
59 | #include "xfs_error.h" | 38 | #include "xfs_error.h" |
60 | #include "xfs_dir2_data.h" | 39 | #include "xfs_dir2_data.h" |
@@ -107,7 +86,7 @@ xfs_dir2_block_sfsize( | |||
107 | int isdotdot; /* entry is ".." */ | 86 | int isdotdot; /* entry is ".." */ |
108 | xfs_mount_t *mp; /* mount structure pointer */ | 87 | xfs_mount_t *mp; /* mount structure pointer */ |
109 | int namelen; /* total name bytes */ | 88 | int namelen; /* total name bytes */ |
110 | xfs_ino_t parent; /* parent inode number */ | 89 | xfs_ino_t parent = 0; /* parent inode number */ |
111 | int size=0; /* total computed size */ | 90 | int size=0; /* total computed size */ |
112 | 91 | ||
113 | mp = dp->i_mount; | 92 | mp = dp->i_mount; |
@@ -298,11 +277,11 @@ xfs_dir2_sf_addname( | |||
298 | int incr_isize; /* total change in size */ | 277 | int incr_isize; /* total change in size */ |
299 | int new_isize; /* di_size after adding name */ | 278 | int new_isize; /* di_size after adding name */ |
300 | int objchange; /* changing to 8-byte inodes */ | 279 | int objchange; /* changing to 8-byte inodes */ |
301 | xfs_dir2_data_aoff_t offset; /* offset for new entry */ | 280 | xfs_dir2_data_aoff_t offset = 0; /* offset for new entry */ |
302 | int old_isize; /* di_size before adding name */ | 281 | int old_isize; /* di_size before adding name */ |
303 | int pick; /* which algorithm to use */ | 282 | int pick; /* which algorithm to use */ |
304 | xfs_dir2_sf_t *sfp; /* shortform structure */ | 283 | xfs_dir2_sf_t *sfp; /* shortform structure */ |
305 | xfs_dir2_sf_entry_t *sfep; /* shortform entry */ | 284 | xfs_dir2_sf_entry_t *sfep = NULL; /* shortform entry */ |
306 | 285 | ||
307 | xfs_dir2_trace_args("sf_addname", args); | 286 | xfs_dir2_trace_args("sf_addname", args); |
308 | ASSERT(xfs_dir2_sf_lookup(args) == ENOENT); | 287 | ASSERT(xfs_dir2_sf_lookup(args) == ENOENT); |
diff --git a/fs/xfs/xfs_dir2_sf.h b/fs/xfs/xfs_dir2_sf.h index bac6f5a2a312..42f015b70018 100644 --- a/fs/xfs/xfs_dir2_sf.h +++ b/fs/xfs/xfs_dir2_sf.h | |||
@@ -1,33 +1,19 @@ | |||
1 | /* | 1 | /* |
2 | * Copyright (c) 2000-2001 Silicon Graphics, Inc. All Rights Reserved. | 2 | * Copyright (c) 2000-2001,2005 Silicon Graphics, Inc. |
3 | * All Rights Reserved. | ||
3 | * | 4 | * |
4 | * This program is free software; you can redistribute it and/or modify it | 5 | * This program is free software; you can redistribute it and/or |
5 | * under the terms of version 2 of the GNU General Public License as | 6 | * modify it under the terms of the GNU General Public License as |
6 | * published by the Free Software Foundation. | 7 | * published by the Free Software Foundation. |
7 | * | 8 | * |
8 | * This program is distributed in the hope that it would be useful, but | 9 | * This program is distributed in the hope that it would be useful, |
9 | * WITHOUT ANY WARRANTY; without even the implied warranty of | 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
12 | * GNU General Public License for more details. | ||
11 | * | 13 | * |
12 | * Further, this software is distributed without any warranty that it is | 14 | * You should have received a copy of the GNU General Public License |
13 | * free of the rightful claim of any third person regarding infringement | 15 | * along with this program; if not, write the Free Software Foundation, |
14 | * or the like. Any license provided herein, whether implied or | 16 | * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
15 | * otherwise, applies only to this software file. Patent licenses, if | ||
16 | * any, provided herein do not apply to combinations of this program with | ||
17 | * other software, or any other product whatsoever. | ||
18 | * | ||
19 | * You should have received a copy of the GNU General Public License along | ||
20 | * with this program; if not, write the Free Software Foundation, Inc., 59 | ||
21 | * Temple Place - Suite 330, Boston MA 02111-1307, USA. | ||
22 | * | ||
23 | * Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy, | ||
24 | * Mountain View, CA 94043, or: | ||
25 | * | ||
26 | * http://www.sgi.com | ||
27 | * | ||
28 | * For further information regarding this notice, see: | ||
29 | * | ||
30 | * http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/ | ||
31 | */ | 17 | */ |
32 | #ifndef __XFS_DIR2_SF_H__ | 18 | #ifndef __XFS_DIR2_SF_H__ |
33 | #define __XFS_DIR2_SF_H__ | 19 | #define __XFS_DIR2_SF_H__ |
@@ -104,140 +90,106 @@ typedef struct xfs_dir2_sf { | |||
104 | xfs_dir2_sf_entry_t list[1]; /* shortform entries */ | 90 | xfs_dir2_sf_entry_t list[1]; /* shortform entries */ |
105 | } xfs_dir2_sf_t; | 91 | } xfs_dir2_sf_t; |
106 | 92 | ||
107 | #if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_DIR2_SF_HDR_SIZE) | ||
108 | int xfs_dir2_sf_hdr_size(int i8count); | ||
109 | #define XFS_DIR2_SF_HDR_SIZE(i8count) xfs_dir2_sf_hdr_size(i8count) | 93 | #define XFS_DIR2_SF_HDR_SIZE(i8count) xfs_dir2_sf_hdr_size(i8count) |
110 | #else | 94 | static inline int xfs_dir2_sf_hdr_size(int i8count) |
111 | #define XFS_DIR2_SF_HDR_SIZE(i8count) \ | 95 | { |
112 | ((uint)sizeof(xfs_dir2_sf_hdr_t) - \ | 96 | return ((uint)sizeof(xfs_dir2_sf_hdr_t) - \ |
113 | ((i8count) == 0) * \ | 97 | ((i8count) == 0) * \ |
114 | ((uint)sizeof(xfs_dir2_ino8_t) - (uint)sizeof(xfs_dir2_ino4_t))) | 98 | ((uint)sizeof(xfs_dir2_ino8_t) - (uint)sizeof(xfs_dir2_ino4_t))); |
115 | #endif | 99 | } |
116 | 100 | ||
117 | #if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_DIR2_SF_INUMBERP) | ||
118 | xfs_dir2_inou_t *xfs_dir2_sf_inumberp(xfs_dir2_sf_entry_t *sfep); | ||
119 | #define XFS_DIR2_SF_INUMBERP(sfep) xfs_dir2_sf_inumberp(sfep) | 101 | #define XFS_DIR2_SF_INUMBERP(sfep) xfs_dir2_sf_inumberp(sfep) |
120 | #else | 102 | static inline xfs_dir2_inou_t *xfs_dir2_sf_inumberp(xfs_dir2_sf_entry_t *sfep) |
121 | #define XFS_DIR2_SF_INUMBERP(sfep) \ | 103 | { |
122 | ((xfs_dir2_inou_t *)&(sfep)->name[(sfep)->namelen]) | 104 | return (xfs_dir2_inou_t *)&(sfep)->name[(sfep)->namelen]; |
123 | #endif | 105 | } |
124 | |||
125 | #if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_DIR2_SF_GET_INUMBER) | ||
126 | xfs_intino_t xfs_dir2_sf_get_inumber(xfs_dir2_sf_t *sfp, xfs_dir2_inou_t *from); | ||
127 | #define XFS_DIR2_SF_GET_INUMBER(sfp, from) \ | ||
128 | xfs_dir2_sf_get_inumber(sfp, from) | ||
129 | 106 | ||
130 | #else | 107 | #define XFS_DIR2_SF_GET_INUMBER(sfp, from) \ |
131 | #define XFS_DIR2_SF_GET_INUMBER(sfp, from) \ | 108 | xfs_dir2_sf_get_inumber(sfp, from) |
132 | ((sfp)->hdr.i8count == 0 ? \ | 109 | static inline xfs_intino_t |
110 | xfs_dir2_sf_get_inumber(xfs_dir2_sf_t *sfp, xfs_dir2_inou_t *from) | ||
111 | { | ||
112 | return ((sfp)->hdr.i8count == 0 ? \ | ||
133 | (xfs_intino_t)XFS_GET_DIR_INO4((from)->i4) : \ | 113 | (xfs_intino_t)XFS_GET_DIR_INO4((from)->i4) : \ |
134 | (xfs_intino_t)XFS_GET_DIR_INO8((from)->i8)) | 114 | (xfs_intino_t)XFS_GET_DIR_INO8((from)->i8)); |
135 | #endif | 115 | } |
136 | 116 | ||
137 | #if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_DIR2_SF_PUT_INUMBER) | 117 | #define XFS_DIR2_SF_PUT_INUMBER(sfp,from,to) \ |
138 | void xfs_dir2_sf_put_inumber(xfs_dir2_sf_t *sfp, xfs_ino_t *from, | ||
139 | xfs_dir2_inou_t *to); | ||
140 | #define XFS_DIR2_SF_PUT_INUMBER(sfp,from,to) \ | ||
141 | xfs_dir2_sf_put_inumber(sfp,from,to) | 118 | xfs_dir2_sf_put_inumber(sfp,from,to) |
142 | #else | 119 | static inline void xfs_dir2_sf_put_inumber(xfs_dir2_sf_t *sfp, xfs_ino_t *from, |
143 | #define XFS_DIR2_SF_PUT_INUMBER(sfp,from,to) \ | 120 | xfs_dir2_inou_t *to) |
144 | if ((sfp)->hdr.i8count == 0) { \ | 121 | { |
145 | XFS_PUT_DIR_INO4(*(from), (to)->i4); \ | 122 | if ((sfp)->hdr.i8count == 0) |
146 | } else { \ | 123 | XFS_PUT_DIR_INO4(*(from), (to)->i4); |
147 | XFS_PUT_DIR_INO8(*(from), (to)->i8); \ | 124 | else |
148 | } | 125 | XFS_PUT_DIR_INO8(*(from), (to)->i8); |
149 | #endif | 126 | } |
150 | 127 | ||
151 | #if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_DIR2_SF_GET_OFFSET) | ||
152 | xfs_dir2_data_aoff_t xfs_dir2_sf_get_offset(xfs_dir2_sf_entry_t *sfep); | ||
153 | #define XFS_DIR2_SF_GET_OFFSET(sfep) \ | 128 | #define XFS_DIR2_SF_GET_OFFSET(sfep) \ |
154 | xfs_dir2_sf_get_offset(sfep) | 129 | xfs_dir2_sf_get_offset(sfep) |
155 | #else | 130 | static inline xfs_dir2_data_aoff_t |
156 | #define XFS_DIR2_SF_GET_OFFSET(sfep) \ | 131 | xfs_dir2_sf_get_offset(xfs_dir2_sf_entry_t *sfep) |
157 | INT_GET_UNALIGNED_16_BE(&(sfep)->offset.i) | 132 | { |
158 | #endif | 133 | return INT_GET_UNALIGNED_16_BE(&(sfep)->offset.i); |
134 | } | ||
159 | 135 | ||
160 | #if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_DIR2_SF_PUT_OFFSET) | ||
161 | void xfs_dir2_sf_put_offset(xfs_dir2_sf_entry_t *sfep, | ||
162 | xfs_dir2_data_aoff_t off); | ||
163 | #define XFS_DIR2_SF_PUT_OFFSET(sfep,off) \ | 136 | #define XFS_DIR2_SF_PUT_OFFSET(sfep,off) \ |
164 | xfs_dir2_sf_put_offset(sfep,off) | 137 | xfs_dir2_sf_put_offset(sfep,off) |
165 | #else | 138 | static inline void |
166 | #define XFS_DIR2_SF_PUT_OFFSET(sfep,off) \ | 139 | xfs_dir2_sf_put_offset(xfs_dir2_sf_entry_t *sfep, xfs_dir2_data_aoff_t off) |
167 | INT_SET_UNALIGNED_16_BE(&(sfep)->offset.i,off) | 140 | { |
168 | #endif | 141 | INT_SET_UNALIGNED_16_BE(&(sfep)->offset.i, off); |
142 | } | ||
169 | 143 | ||
170 | #if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_DIR2_SF_ENTSIZE_BYNAME) | ||
171 | int xfs_dir2_sf_entsize_byname(xfs_dir2_sf_t *sfp, int len); | ||
172 | #define XFS_DIR2_SF_ENTSIZE_BYNAME(sfp,len) \ | 144 | #define XFS_DIR2_SF_ENTSIZE_BYNAME(sfp,len) \ |
173 | xfs_dir2_sf_entsize_byname(sfp,len) | 145 | xfs_dir2_sf_entsize_byname(sfp,len) |
174 | #else | 146 | static inline int xfs_dir2_sf_entsize_byname(xfs_dir2_sf_t *sfp, int len) |
175 | #define XFS_DIR2_SF_ENTSIZE_BYNAME(sfp,len) /* space a name uses */ \ | 147 | { |
176 | ((uint)sizeof(xfs_dir2_sf_entry_t) - 1 + (len) - \ | 148 | return ((uint)sizeof(xfs_dir2_sf_entry_t) - 1 + (len) - \ |
177 | ((sfp)->hdr.i8count == 0) * \ | 149 | ((sfp)->hdr.i8count == 0) * \ |
178 | ((uint)sizeof(xfs_dir2_ino8_t) - (uint)sizeof(xfs_dir2_ino4_t))) | 150 | ((uint)sizeof(xfs_dir2_ino8_t) - (uint)sizeof(xfs_dir2_ino4_t))); |
179 | #endif | 151 | } |
180 | 152 | ||
181 | #if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_DIR2_SF_ENTSIZE_BYENTRY) | ||
182 | int xfs_dir2_sf_entsize_byentry(xfs_dir2_sf_t *sfp, xfs_dir2_sf_entry_t *sfep); | ||
183 | #define XFS_DIR2_SF_ENTSIZE_BYENTRY(sfp,sfep) \ | 153 | #define XFS_DIR2_SF_ENTSIZE_BYENTRY(sfp,sfep) \ |
184 | xfs_dir2_sf_entsize_byentry(sfp,sfep) | 154 | xfs_dir2_sf_entsize_byentry(sfp,sfep) |
185 | #else | 155 | static inline int |
186 | #define XFS_DIR2_SF_ENTSIZE_BYENTRY(sfp,sfep) /* space an entry uses */ \ | 156 | xfs_dir2_sf_entsize_byentry(xfs_dir2_sf_t *sfp, xfs_dir2_sf_entry_t *sfep) |
187 | ((uint)sizeof(xfs_dir2_sf_entry_t) - 1 + (sfep)->namelen - \ | 157 | { |
188 | ((sfp)->hdr.i8count == 0) * \ | 158 | return ((uint)sizeof(xfs_dir2_sf_entry_t) - 1 + (sfep)->namelen - \ |
189 | ((uint)sizeof(xfs_dir2_ino8_t) - (uint)sizeof(xfs_dir2_ino4_t))) | 159 | ((sfp)->hdr.i8count == 0) * \ |
190 | #endif | 160 | ((uint)sizeof(xfs_dir2_ino8_t) - (uint)sizeof(xfs_dir2_ino4_t))); |
191 | 161 | } | |
192 | #if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_DIR2_SF_FIRSTENTRY) | 162 | |
193 | xfs_dir2_sf_entry_t *xfs_dir2_sf_firstentry(xfs_dir2_sf_t *sfp); | ||
194 | #define XFS_DIR2_SF_FIRSTENTRY(sfp) xfs_dir2_sf_firstentry(sfp) | 163 | #define XFS_DIR2_SF_FIRSTENTRY(sfp) xfs_dir2_sf_firstentry(sfp) |
195 | #else | 164 | static inline xfs_dir2_sf_entry_t *xfs_dir2_sf_firstentry(xfs_dir2_sf_t *sfp) |
196 | #define XFS_DIR2_SF_FIRSTENTRY(sfp) /* first entry in struct */ \ | 165 | { |
197 | ((xfs_dir2_sf_entry_t *) \ | 166 | return ((xfs_dir2_sf_entry_t *) \ |
198 | ((char *)(sfp) + XFS_DIR2_SF_HDR_SIZE(sfp->hdr.i8count))) | 167 | ((char *)(sfp) + XFS_DIR2_SF_HDR_SIZE(sfp->hdr.i8count))); |
199 | #endif | 168 | } |
200 | 169 | ||
201 | #if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_DIR2_SF_NEXTENTRY) | 170 | #define XFS_DIR2_SF_NEXTENTRY(sfp,sfep) xfs_dir2_sf_nextentry(sfp,sfep) |
202 | xfs_dir2_sf_entry_t *xfs_dir2_sf_nextentry(xfs_dir2_sf_t *sfp, | 171 | static inline xfs_dir2_sf_entry_t * |
203 | xfs_dir2_sf_entry_t *sfep); | 172 | xfs_dir2_sf_nextentry(xfs_dir2_sf_t *sfp, xfs_dir2_sf_entry_t *sfep) |
204 | #define XFS_DIR2_SF_NEXTENTRY(sfp,sfep) xfs_dir2_sf_nextentry(sfp,sfep) | 173 | { |
205 | #else | 174 | return ((xfs_dir2_sf_entry_t *) \ |
206 | #define XFS_DIR2_SF_NEXTENTRY(sfp,sfep) /* next entry in struct */ \ | 175 | ((char *)(sfep) + XFS_DIR2_SF_ENTSIZE_BYENTRY(sfp,sfep))); |
207 | ((xfs_dir2_sf_entry_t *) \ | 176 | } |
208 | ((char *)(sfep) + XFS_DIR2_SF_ENTSIZE_BYENTRY(sfp,sfep))) | ||
209 | #endif | ||
210 | 177 | ||
211 | /* | 178 | /* |
212 | * Functions. | 179 | * Functions. |
213 | */ | 180 | */ |
214 | 181 | extern int xfs_dir2_block_sfsize(struct xfs_inode *dp, | |
215 | extern int | 182 | struct xfs_dir2_block *block, |
216 | xfs_dir2_block_sfsize(struct xfs_inode *dp, | 183 | xfs_dir2_sf_hdr_t *sfhp); |
217 | struct xfs_dir2_block *block, | 184 | extern int xfs_dir2_block_to_sf(struct xfs_da_args *args, struct xfs_dabuf *bp, |
218 | xfs_dir2_sf_hdr_t *sfhp); | 185 | int size, xfs_dir2_sf_hdr_t *sfhp); |
219 | 186 | extern int xfs_dir2_sf_addname(struct xfs_da_args *args); | |
220 | extern int | 187 | extern int xfs_dir2_sf_create(struct xfs_da_args *args, xfs_ino_t pino); |
221 | xfs_dir2_block_to_sf(struct xfs_da_args *args, struct xfs_dabuf *bp, | 188 | extern int xfs_dir2_sf_getdents(struct xfs_inode *dp, struct uio *uio, |
222 | int size, xfs_dir2_sf_hdr_t *sfhp); | 189 | int *eofp, struct xfs_dirent *dbp, |
223 | 190 | xfs_dir2_put_t put); | |
224 | extern int | 191 | extern int xfs_dir2_sf_lookup(struct xfs_da_args *args); |
225 | xfs_dir2_sf_addname(struct xfs_da_args *args); | 192 | extern int xfs_dir2_sf_removename(struct xfs_da_args *args); |
226 | 193 | extern int xfs_dir2_sf_replace(struct xfs_da_args *args); | |
227 | extern int | ||
228 | xfs_dir2_sf_create(struct xfs_da_args *args, xfs_ino_t pino); | ||
229 | |||
230 | extern int | ||
231 | xfs_dir2_sf_getdents(struct xfs_inode *dp, struct uio *uio, int *eofp, | ||
232 | struct xfs_dirent *dbp, xfs_dir2_put_t put); | ||
233 | |||
234 | extern int | ||
235 | xfs_dir2_sf_lookup(struct xfs_da_args *args); | ||
236 | |||
237 | extern int | ||
238 | xfs_dir2_sf_removename(struct xfs_da_args *args); | ||
239 | |||
240 | extern int | ||
241 | xfs_dir2_sf_replace(struct xfs_da_args *args); | ||
242 | 194 | ||
243 | #endif /* __XFS_DIR2_SF_H__ */ | 195 | #endif /* __XFS_DIR2_SF_H__ */ |
diff --git a/fs/xfs/xfs_dir2_trace.c b/fs/xfs/xfs_dir2_trace.c index 9d6417393140..c626943b4112 100644 --- a/fs/xfs/xfs_dir2_trace.c +++ b/fs/xfs/xfs_dir2_trace.c | |||
@@ -1,52 +1,33 @@ | |||
1 | /* | 1 | /* |
2 | * Copyright (c) 2000-2003 Silicon Graphics, Inc. All Rights Reserved. | 2 | * Copyright (c) 2000-2003,2005 Silicon Graphics, Inc. |
3 | * All Rights Reserved. | ||
3 | * | 4 | * |
4 | * This program is free software; you can redistribute it and/or modify it | 5 | * This program is free software; you can redistribute it and/or |
5 | * under the terms of version 2 of the GNU General Public License as | 6 | * modify it under the terms of the GNU General Public License as |
6 | * published by the Free Software Foundation. | 7 | * published by the Free Software Foundation. |
7 | * | 8 | * |
8 | * This program is distributed in the hope that it would be useful, but | 9 | * This program is distributed in the hope that it would be useful, |
9 | * WITHOUT ANY WARRANTY; without even the implied warranty of | 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
12 | * GNU General Public License for more details. | ||
11 | * | 13 | * |
12 | * Further, this software is distributed without any warranty that it is | 14 | * You should have received a copy of the GNU General Public License |
13 | * free of the rightful claim of any third person regarding infringement | 15 | * along with this program; if not, write the Free Software Foundation, |
14 | * or the like. Any license provided herein, whether implied or | 16 | * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
15 | * otherwise, applies only to this software file. Patent licenses, if | ||
16 | * any, provided herein do not apply to combinations of this program with | ||
17 | * other software, or any other product whatsoever. | ||
18 | * | ||
19 | * You should have received a copy of the GNU General Public License along | ||
20 | * with this program; if not, write the Free Software Foundation, Inc., 59 | ||
21 | * Temple Place - Suite 330, Boston MA 02111-1307, USA. | ||
22 | * | ||
23 | * Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy, | ||
24 | * Mountain View, CA 94043, or: | ||
25 | * | ||
26 | * http://www.sgi.com | ||
27 | * | ||
28 | * For further information regarding this notice, see: | ||
29 | * | ||
30 | * http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/ | ||
31 | */ | ||
32 | |||
33 | /* | ||
34 | * xfs_dir2_trace.c | ||
35 | * Tracing for xfs v2 directories. | ||
36 | */ | 17 | */ |
37 | #include "xfs.h" | 18 | #include "xfs.h" |
38 | 19 | #include "xfs_fs.h" | |
39 | #include "xfs_types.h" | 20 | #include "xfs_types.h" |
40 | #include "xfs_inum.h" | 21 | #include "xfs_inum.h" |
41 | #include "xfs_dir.h" | 22 | #include "xfs_dir.h" |
42 | #include "xfs_dir2.h" | 23 | #include "xfs_dir2.h" |
24 | #include "xfs_da_btree.h" | ||
43 | #include "xfs_bmap_btree.h" | 25 | #include "xfs_bmap_btree.h" |
44 | #include "xfs_attr_sf.h" | ||
45 | #include "xfs_dir_sf.h" | 26 | #include "xfs_dir_sf.h" |
46 | #include "xfs_dir2_sf.h" | 27 | #include "xfs_dir2_sf.h" |
28 | #include "xfs_attr_sf.h" | ||
47 | #include "xfs_dinode.h" | 29 | #include "xfs_dinode.h" |
48 | #include "xfs_inode.h" | 30 | #include "xfs_inode.h" |
49 | #include "xfs_da_btree.h" | ||
50 | #include "xfs_dir2_trace.h" | 31 | #include "xfs_dir2_trace.h" |
51 | 32 | ||
52 | #ifdef XFS_DIR2_TRACE | 33 | #ifdef XFS_DIR2_TRACE |
diff --git a/fs/xfs/xfs_dir2_trace.h b/fs/xfs/xfs_dir2_trace.h index 0a178bffa806..ca3c754f4822 100644 --- a/fs/xfs/xfs_dir2_trace.h +++ b/fs/xfs/xfs_dir2_trace.h | |||
@@ -1,33 +1,19 @@ | |||
1 | /* | 1 | /* |
2 | * Copyright (c) 2000 Silicon Graphics, Inc. All Rights Reserved. | 2 | * Copyright (c) 2000,2005 Silicon Graphics, Inc. |
3 | * All Rights Reserved. | ||
3 | * | 4 | * |
4 | * This program is free software; you can redistribute it and/or modify it | 5 | * This program is free software; you can redistribute it and/or |
5 | * under the terms of version 2 of the GNU General Public License as | 6 | * modify it under the terms of the GNU General Public License as |
6 | * published by the Free Software Foundation. | 7 | * published by the Free Software Foundation. |
7 | * | 8 | * |
8 | * This program is distributed in the hope that it would be useful, but | 9 | * This program is distributed in the hope that it would be useful, |
9 | * WITHOUT ANY WARRANTY; without even the implied warranty of | 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
12 | * GNU General Public License for more details. | ||
11 | * | 13 | * |
12 | * Further, this software is distributed without any warranty that it is | 14 | * You should have received a copy of the GNU General Public License |
13 | * free of the rightful claim of any third person regarding infringement | 15 | * along with this program; if not, write the Free Software Foundation, |
14 | * or the like. Any license provided herein, whether implied or | 16 | * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
15 | * otherwise, applies only to this software file. Patent licenses, if | ||
16 | * any, provided herein do not apply to combinations of this program with | ||
17 | * other software, or any other product whatsoever. | ||
18 | * | ||
19 | * You should have received a copy of the GNU General Public License along | ||
20 | * with this program; if not, write the Free Software Foundation, Inc., 59 | ||
21 | * Temple Place - Suite 330, Boston MA 02111-1307, USA. | ||
22 | * | ||
23 | * Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy, | ||
24 | * Mountain View, CA 94043, or: | ||
25 | * | ||
26 | * http://www.sgi.com | ||
27 | * | ||
28 | * For further information regarding this notice, see: | ||
29 | * | ||
30 | * http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/ | ||
31 | */ | 17 | */ |
32 | #ifndef __XFS_DIR2_TRACE_H__ | 18 | #ifndef __XFS_DIR2_TRACE_H__ |
33 | #define __XFS_DIR2_TRACE_H__ | 19 | #define __XFS_DIR2_TRACE_H__ |
diff --git a/fs/xfs/xfs_dir_leaf.c b/fs/xfs/xfs_dir_leaf.c index c2ea6171fb0e..950df31efc46 100644 --- a/fs/xfs/xfs_dir_leaf.c +++ b/fs/xfs/xfs_dir_leaf.c | |||
@@ -1,66 +1,44 @@ | |||
1 | /* | 1 | /* |
2 | * Copyright (c) 2000-2003 Silicon Graphics, Inc. All Rights Reserved. | 2 | * Copyright (c) 2000-2003,2005 Silicon Graphics, Inc. |
3 | * All Rights Reserved. | ||
3 | * | 4 | * |
4 | * This program is free software; you can redistribute it and/or modify it | 5 | * This program is free software; you can redistribute it and/or |
5 | * under the terms of version 2 of the GNU General Public License as | 6 | * modify it under the terms of the GNU General Public License as |
6 | * published by the Free Software Foundation. | 7 | * published by the Free Software Foundation. |
7 | * | 8 | * |
8 | * This program is distributed in the hope that it would be useful, but | 9 | * This program is distributed in the hope that it would be useful, |
9 | * WITHOUT ANY WARRANTY; without even the implied warranty of | 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
12 | * GNU General Public License for more details. | ||
11 | * | 13 | * |
12 | * Further, this software is distributed without any warranty that it is | 14 | * You should have received a copy of the GNU General Public License |
13 | * free of the rightful claim of any third person regarding infringement | 15 | * along with this program; if not, write the Free Software Foundation, |
14 | * or the like. Any license provided herein, whether implied or | 16 | * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
15 | * otherwise, applies only to this software file. Patent licenses, if | ||
16 | * any, provided herein do not apply to combinations of this program with | ||
17 | * other software, or any other product whatsoever. | ||
18 | * | ||
19 | * You should have received a copy of the GNU General Public License along | ||
20 | * with this program; if not, write the Free Software Foundation, Inc., 59 | ||
21 | * Temple Place - Suite 330, Boston MA 02111-1307, USA. | ||
22 | * | ||
23 | * Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy, | ||
24 | * Mountain View, CA 94043, or: | ||
25 | * | ||
26 | * http://www.sgi.com | ||
27 | * | ||
28 | * For further information regarding this notice, see: | ||
29 | * | ||
30 | * http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/ | ||
31 | */ | 17 | */ |
32 | |||
33 | /* | ||
34 | * xfs_dir_leaf.c | ||
35 | * | ||
36 | * GROT: figure out how to recover gracefully when bmap returns ENOSPC. | ||
37 | */ | ||
38 | |||
39 | #include "xfs.h" | 18 | #include "xfs.h" |
40 | 19 | #include "xfs_fs.h" | |
41 | #include "xfs_macros.h" | ||
42 | #include "xfs_types.h" | 20 | #include "xfs_types.h" |
43 | #include "xfs_inum.h" | ||
44 | #include "xfs_log.h" | 21 | #include "xfs_log.h" |
22 | #include "xfs_inum.h" | ||
45 | #include "xfs_trans.h" | 23 | #include "xfs_trans.h" |
46 | #include "xfs_sb.h" | 24 | #include "xfs_sb.h" |
47 | #include "xfs_dir.h" | 25 | #include "xfs_dir.h" |
48 | #include "xfs_dir2.h" | 26 | #include "xfs_dir2.h" |
49 | #include "xfs_dmapi.h" | 27 | #include "xfs_dmapi.h" |
50 | #include "xfs_mount.h" | 28 | #include "xfs_mount.h" |
51 | #include "xfs_alloc_btree.h" | 29 | #include "xfs_da_btree.h" |
52 | #include "xfs_bmap_btree.h" | 30 | #include "xfs_bmap_btree.h" |
31 | #include "xfs_alloc_btree.h" | ||
53 | #include "xfs_ialloc_btree.h" | 32 | #include "xfs_ialloc_btree.h" |
54 | #include "xfs_alloc.h" | ||
55 | #include "xfs_btree.h" | ||
56 | #include "xfs_attr_sf.h" | ||
57 | #include "xfs_dir_sf.h" | 33 | #include "xfs_dir_sf.h" |
58 | #include "xfs_dir2_sf.h" | 34 | #include "xfs_dir2_sf.h" |
35 | #include "xfs_attr_sf.h" | ||
59 | #include "xfs_dinode.h" | 36 | #include "xfs_dinode.h" |
60 | #include "xfs_inode_item.h" | ||
61 | #include "xfs_inode.h" | 37 | #include "xfs_inode.h" |
38 | #include "xfs_inode_item.h" | ||
39 | #include "xfs_alloc.h" | ||
40 | #include "xfs_btree.h" | ||
62 | #include "xfs_bmap.h" | 41 | #include "xfs_bmap.h" |
63 | #include "xfs_da_btree.h" | ||
64 | #include "xfs_dir_leaf.h" | 42 | #include "xfs_dir_leaf.h" |
65 | #include "xfs_error.h" | 43 | #include "xfs_error.h" |
66 | 44 | ||
@@ -508,7 +486,7 @@ xfs_dir_shortform_getdents(xfs_inode_t *dp, uio_t *uio, int *eofp, | |||
508 | /* | 486 | /* |
509 | * Sort the entries on hash then entno. | 487 | * Sort the entries on hash then entno. |
510 | */ | 488 | */ |
511 | qsort(sbuf, nsbuf, sizeof(*sbuf), xfs_dir_shortform_compare); | 489 | xfs_sort(sbuf, nsbuf, sizeof(*sbuf), xfs_dir_shortform_compare); |
512 | /* | 490 | /* |
513 | * Stuff in last entry. | 491 | * Stuff in last entry. |
514 | */ | 492 | */ |
@@ -650,7 +628,7 @@ xfs_dir_leaf_to_shortform(xfs_da_args_t *iargs) | |||
650 | xfs_dir_leaf_name_t *namest; | 628 | xfs_dir_leaf_name_t *namest; |
651 | xfs_da_args_t args; | 629 | xfs_da_args_t args; |
652 | xfs_inode_t *dp; | 630 | xfs_inode_t *dp; |
653 | xfs_ino_t parent; | 631 | xfs_ino_t parent = 0; |
654 | char *tmpbuffer; | 632 | char *tmpbuffer; |
655 | int retval, i; | 633 | int retval, i; |
656 | xfs_dabuf_t *bp; | 634 | xfs_dabuf_t *bp; |
diff --git a/fs/xfs/xfs_dir_leaf.h b/fs/xfs/xfs_dir_leaf.h index 480bffc1f29f..ab6b09eef9ab 100644 --- a/fs/xfs/xfs_dir_leaf.h +++ b/fs/xfs/xfs_dir_leaf.h | |||
@@ -1,33 +1,19 @@ | |||
1 | /* | 1 | /* |
2 | * Copyright (c) 2000-2001 Silicon Graphics, Inc. All Rights Reserved. | 2 | * Copyright (c) 2000-2001,2005 Silicon Graphics, Inc. |
3 | * All Rights Reserved. | ||
3 | * | 4 | * |
4 | * This program is free software; you can redistribute it and/or modify it | 5 | * This program is free software; you can redistribute it and/or |
5 | * under the terms of version 2 of the GNU General Public License as | 6 | * modify it under the terms of the GNU General Public License as |
6 | * published by the Free Software Foundation. | 7 | * published by the Free Software Foundation. |
7 | * | 8 | * |
8 | * This program is distributed in the hope that it would be useful, but | 9 | * This program is distributed in the hope that it would be useful, |
9 | * WITHOUT ANY WARRANTY; without even the implied warranty of | 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
12 | * GNU General Public License for more details. | ||
11 | * | 13 | * |
12 | * Further, this software is distributed without any warranty that it is | 14 | * You should have received a copy of the GNU General Public License |
13 | * free of the rightful claim of any third person regarding infringement | 15 | * along with this program; if not, write the Free Software Foundation, |
14 | * or the like. Any license provided herein, whether implied or | 16 | * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
15 | * otherwise, applies only to this software file. Patent licenses, if | ||
16 | * any, provided herein do not apply to combinations of this program with | ||
17 | * other software, or any other product whatsoever. | ||
18 | * | ||
19 | * You should have received a copy of the GNU General Public License along | ||
20 | * with this program; if not, write the Free Software Foundation, Inc., 59 | ||
21 | * Temple Place - Suite 330, Boston MA 02111-1307, USA. | ||
22 | * | ||
23 | * Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy, | ||
24 | * Mountain View, CA 94043, or: | ||
25 | * | ||
26 | * http://www.sgi.com | ||
27 | * | ||
28 | * For further information regarding this notice, see: | ||
29 | * | ||
30 | * http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/ | ||
31 | */ | 17 | */ |
32 | #ifndef __XFS_DIR_LEAF_H__ | 18 | #ifndef __XFS_DIR_LEAF_H__ |
33 | #define __XFS_DIR_LEAF_H__ | 19 | #define __XFS_DIR_LEAF_H__ |
@@ -152,30 +138,26 @@ typedef struct xfs_dir_put_args | |||
152 | struct uio *uio; /* uio control structure */ | 138 | struct uio *uio; /* uio control structure */ |
153 | } xfs_dir_put_args_t; | 139 | } xfs_dir_put_args_t; |
154 | 140 | ||
155 | #if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_DIR_LEAF_ENTSIZE_BYNAME) | ||
156 | int xfs_dir_leaf_entsize_byname(int len); | ||
157 | #define XFS_DIR_LEAF_ENTSIZE_BYNAME(len) xfs_dir_leaf_entsize_byname(len) | 141 | #define XFS_DIR_LEAF_ENTSIZE_BYNAME(len) xfs_dir_leaf_entsize_byname(len) |
158 | #else | 142 | static inline int xfs_dir_leaf_entsize_byname(int len) |
159 | #define XFS_DIR_LEAF_ENTSIZE_BYNAME(len) /* space a name will use */ \ | 143 | { |
160 | ((uint)sizeof(xfs_dir_leaf_name_t)-1 + len) | 144 | return (uint)sizeof(xfs_dir_leaf_name_t)-1 + len; |
161 | #endif | 145 | } |
162 | #if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_DIR_LEAF_ENTSIZE_BYENTRY) | 146 | |
163 | int xfs_dir_leaf_entsize_byentry(xfs_dir_leaf_entry_t *entry); | ||
164 | #define XFS_DIR_LEAF_ENTSIZE_BYENTRY(entry) \ | 147 | #define XFS_DIR_LEAF_ENTSIZE_BYENTRY(entry) \ |
165 | xfs_dir_leaf_entsize_byentry(entry) | 148 | xfs_dir_leaf_entsize_byentry(entry) |
166 | #else | 149 | static inline int xfs_dir_leaf_entsize_byentry(xfs_dir_leaf_entry_t *entry) |
167 | #define XFS_DIR_LEAF_ENTSIZE_BYENTRY(entry) /* space an entry will use */ \ | 150 | { |
168 | ((uint)sizeof(xfs_dir_leaf_name_t)-1 + (entry)->namelen) | 151 | return (uint)sizeof(xfs_dir_leaf_name_t)-1 + (entry)->namelen; |
169 | #endif | 152 | } |
170 | #if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_DIR_LEAF_NAMESTRUCT) | 153 | |
171 | xfs_dir_leaf_name_t * | ||
172 | xfs_dir_leaf_namestruct(xfs_dir_leafblock_t *leafp, int offset); | ||
173 | #define XFS_DIR_LEAF_NAMESTRUCT(leafp,offset) \ | 154 | #define XFS_DIR_LEAF_NAMESTRUCT(leafp,offset) \ |
174 | xfs_dir_leaf_namestruct(leafp,offset) | 155 | xfs_dir_leaf_namestruct(leafp,offset) |
175 | #else | 156 | static inline xfs_dir_leaf_name_t * |
176 | #define XFS_DIR_LEAF_NAMESTRUCT(leafp,offset) /* point to name struct */ \ | 157 | xfs_dir_leaf_namestruct(xfs_dir_leafblock_t *leafp, int offset) |
177 | ((xfs_dir_leaf_name_t *)&((char *)(leafp))[offset]) | 158 | { |
178 | #endif | 159 | return (xfs_dir_leaf_name_t *)&((char *)(leafp))[offset]; |
160 | } | ||
179 | 161 | ||
180 | /*======================================================================== | 162 | /*======================================================================== |
181 | * Function prototypes for the kernel. | 163 | * Function prototypes for the kernel. |
@@ -190,7 +172,7 @@ int xfs_dir_shortform_lookup(struct xfs_da_args *args); | |||
190 | int xfs_dir_shortform_to_leaf(struct xfs_da_args *args); | 172 | int xfs_dir_shortform_to_leaf(struct xfs_da_args *args); |
191 | int xfs_dir_shortform_removename(struct xfs_da_args *args); | 173 | int xfs_dir_shortform_removename(struct xfs_da_args *args); |
192 | int xfs_dir_shortform_getdents(struct xfs_inode *dp, struct uio *uio, int *eofp, | 174 | int xfs_dir_shortform_getdents(struct xfs_inode *dp, struct uio *uio, int *eofp, |
193 | struct xfs_dirent *dbp, xfs_dir_put_t put); | 175 | struct xfs_dirent *dbp, xfs_dir_put_t put); |
194 | int xfs_dir_shortform_replace(struct xfs_da_args *args); | 176 | int xfs_dir_shortform_replace(struct xfs_da_args *args); |
195 | 177 | ||
196 | /* | 178 | /* |
@@ -237,7 +219,6 @@ int xfs_dir_put_dirent64_direct(xfs_dir_put_args_t *pa); | |||
237 | int xfs_dir_put_dirent64_uio(xfs_dir_put_args_t *pa); | 219 | int xfs_dir_put_dirent64_uio(xfs_dir_put_args_t *pa); |
238 | int xfs_dir_ino_validate(struct xfs_mount *mp, xfs_ino_t ino); | 220 | int xfs_dir_ino_validate(struct xfs_mount *mp, xfs_ino_t ino); |
239 | 221 | ||
240 | |||
241 | /* | 222 | /* |
242 | * Global data. | 223 | * Global data. |
243 | */ | 224 | */ |
diff --git a/fs/xfs/xfs_dir_sf.h b/fs/xfs/xfs_dir_sf.h index a61bcfc2a87d..fe44c6f4d560 100644 --- a/fs/xfs/xfs_dir_sf.h +++ b/fs/xfs/xfs_dir_sf.h | |||
@@ -1,33 +1,19 @@ | |||
1 | /* | 1 | /* |
2 | * Copyright (c) 2000 Silicon Graphics, Inc. All Rights Reserved. | 2 | * Copyright (c) 2000,2005 Silicon Graphics, Inc. |
3 | * All Rights Reserved. | ||
3 | * | 4 | * |
4 | * This program is free software; you can redistribute it and/or modify it | 5 | * This program is free software; you can redistribute it and/or |
5 | * under the terms of version 2 of the GNU General Public License as | 6 | * modify it under the terms of the GNU General Public License as |
6 | * published by the Free Software Foundation. | 7 | * published by the Free Software Foundation. |
7 | * | 8 | * |
8 | * This program is distributed in the hope that it would be useful, but | 9 | * This program is distributed in the hope that it would be useful, |
9 | * WITHOUT ANY WARRANTY; without even the implied warranty of | 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
12 | * GNU General Public License for more details. | ||
11 | * | 13 | * |
12 | * Further, this software is distributed without any warranty that it is | 14 | * You should have received a copy of the GNU General Public License |
13 | * free of the rightful claim of any third person regarding infringement | 15 | * along with this program; if not, write the Free Software Foundation, |
14 | * or the like. Any license provided herein, whether implied or | 16 | * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
15 | * otherwise, applies only to this software file. Patent licenses, if | ||
16 | * any, provided herein do not apply to combinations of this program with | ||
17 | * other software, or any other product whatsoever. | ||
18 | * | ||
19 | * You should have received a copy of the GNU General Public License along | ||
20 | * with this program; if not, write the Free Software Foundation, Inc., 59 | ||
21 | * Temple Place - Suite 330, Boston MA 02111-1307, USA. | ||
22 | * | ||
23 | * Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy, | ||
24 | * Mountain View, CA 94043, or: | ||
25 | * | ||
26 | * http://www.sgi.com | ||
27 | * | ||
28 | * For further information regarding this notice, see: | ||
29 | * | ||
30 | * http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/ | ||
31 | */ | 17 | */ |
32 | #ifndef __XFS_DIR_SF_H__ | 18 | #ifndef __XFS_DIR_SF_H__ |
33 | #define __XFS_DIR_SF_H__ | 19 | #define __XFS_DIR_SF_H__ |
@@ -76,49 +62,44 @@ typedef struct xfs_dir_sf_sort { | |||
76 | char *name; /* name value, pointer into buffer */ | 62 | char *name; /* name value, pointer into buffer */ |
77 | } xfs_dir_sf_sort_t; | 63 | } xfs_dir_sf_sort_t; |
78 | 64 | ||
79 | #if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_DIR_SF_GET_DIRINO) | 65 | #define XFS_DIR_SF_GET_DIRINO(from,to) xfs_dir_sf_get_dirino(from, to) |
80 | void xfs_dir_sf_get_dirino(xfs_dir_ino_t *from, xfs_ino_t *to); | 66 | static inline void xfs_dir_sf_get_dirino(xfs_dir_ino_t *from, xfs_ino_t *to) |
81 | #define XFS_DIR_SF_GET_DIRINO(from,to) xfs_dir_sf_get_dirino(from, to) | 67 | { |
82 | #else | 68 | *(to) = XFS_GET_DIR_INO8(*from); |
83 | #define XFS_DIR_SF_GET_DIRINO(from,to) (*(to) = XFS_GET_DIR_INO8(*from)) | 69 | } |
84 | #endif | 70 | |
85 | #if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_DIR_SF_PUT_DIRINO) | 71 | #define XFS_DIR_SF_PUT_DIRINO(from,to) xfs_dir_sf_put_dirino(from, to) |
86 | void xfs_dir_sf_put_dirino(xfs_ino_t *from, xfs_dir_ino_t *to); | 72 | static inline void xfs_dir_sf_put_dirino(xfs_ino_t *from, xfs_dir_ino_t *to) |
87 | #define XFS_DIR_SF_PUT_DIRINO(from,to) xfs_dir_sf_put_dirino(from, to) | 73 | { |
88 | #else | 74 | XFS_PUT_DIR_INO8(*(from), *(to)); |
89 | #define XFS_DIR_SF_PUT_DIRINO(from,to) XFS_PUT_DIR_INO8(*(from), *(to)) | 75 | } |
90 | #endif | 76 | |
91 | #if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_DIR_SF_ENTSIZE_BYNAME) | 77 | #define XFS_DIR_SF_ENTSIZE_BYNAME(len) xfs_dir_sf_entsize_byname(len) |
92 | int xfs_dir_sf_entsize_byname(int len); | 78 | static inline int xfs_dir_sf_entsize_byname(int len) |
93 | #define XFS_DIR_SF_ENTSIZE_BYNAME(len) xfs_dir_sf_entsize_byname(len) | 79 | { |
94 | #else | 80 | return (uint)sizeof(xfs_dir_sf_entry_t)-1 + (len); |
95 | #define XFS_DIR_SF_ENTSIZE_BYNAME(len) /* space a name uses */ \ | 81 | } |
96 | ((uint)sizeof(xfs_dir_sf_entry_t)-1 + (len)) | 82 | |
97 | #endif | ||
98 | #if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_DIR_SF_ENTSIZE_BYENTRY) | ||
99 | int xfs_dir_sf_entsize_byentry(xfs_dir_sf_entry_t *sfep); | ||
100 | #define XFS_DIR_SF_ENTSIZE_BYENTRY(sfep) xfs_dir_sf_entsize_byentry(sfep) | 83 | #define XFS_DIR_SF_ENTSIZE_BYENTRY(sfep) xfs_dir_sf_entsize_byentry(sfep) |
101 | #else | 84 | static inline int xfs_dir_sf_entsize_byentry(xfs_dir_sf_entry_t *sfep) |
102 | #define XFS_DIR_SF_ENTSIZE_BYENTRY(sfep) /* space an entry uses */ \ | 85 | { |
103 | ((uint)sizeof(xfs_dir_sf_entry_t)-1 + (sfep)->namelen) | 86 | return (uint)sizeof(xfs_dir_sf_entry_t)-1 + (sfep)->namelen; |
104 | #endif | 87 | } |
105 | #if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_DIR_SF_NEXTENTRY) | 88 | |
106 | xfs_dir_sf_entry_t *xfs_dir_sf_nextentry(xfs_dir_sf_entry_t *sfep); | ||
107 | #define XFS_DIR_SF_NEXTENTRY(sfep) xfs_dir_sf_nextentry(sfep) | 89 | #define XFS_DIR_SF_NEXTENTRY(sfep) xfs_dir_sf_nextentry(sfep) |
108 | #else | 90 | static inline xfs_dir_sf_entry_t *xfs_dir_sf_nextentry(xfs_dir_sf_entry_t *sfep) |
109 | #define XFS_DIR_SF_NEXTENTRY(sfep) /* next entry in struct */ \ | 91 | { |
110 | ((xfs_dir_sf_entry_t *) \ | 92 | return (xfs_dir_sf_entry_t *) \ |
111 | ((char *)(sfep) + XFS_DIR_SF_ENTSIZE_BYENTRY(sfep))) | 93 | ((char *)(sfep) + XFS_DIR_SF_ENTSIZE_BYENTRY(sfep)); |
112 | #endif | 94 | } |
113 | #if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_DIR_SF_ALLFIT) | 95 | |
114 | int xfs_dir_sf_allfit(int count, int totallen); | ||
115 | #define XFS_DIR_SF_ALLFIT(count,totallen) \ | 96 | #define XFS_DIR_SF_ALLFIT(count,totallen) \ |
116 | xfs_dir_sf_allfit(count,totallen) | 97 | xfs_dir_sf_allfit(count,totallen) |
117 | #else | 98 | static inline int xfs_dir_sf_allfit(int count, int totallen) |
118 | #define XFS_DIR_SF_ALLFIT(count,totallen) /* will all entries fit? */ \ | 99 | { |
119 | ((uint)sizeof(xfs_dir_sf_hdr_t) + \ | 100 | return ((uint)sizeof(xfs_dir_sf_hdr_t) + \ |
120 | ((uint)sizeof(xfs_dir_sf_entry_t)-1)*(count) + (totallen)) | 101 | ((uint)sizeof(xfs_dir_sf_entry_t)-1)*(count) + (totallen)); |
121 | #endif | 102 | } |
122 | 103 | ||
123 | #if defined(XFS_DIR_TRACE) | 104 | #if defined(XFS_DIR_TRACE) |
124 | 105 | ||
diff --git a/fs/xfs/xfs_dmapi.h b/fs/xfs/xfs_dmapi.h index 19e872856f6b..864bf6955689 100644 --- a/fs/xfs/xfs_dmapi.h +++ b/fs/xfs/xfs_dmapi.h | |||
@@ -1,37 +1,24 @@ | |||
1 | /* | 1 | /* |
2 | * Copyright (c) 2000-2005 Silicon Graphics, Inc. All Rights Reserved. | 2 | * Copyright (c) 2000-2005 Silicon Graphics, Inc. |
3 | * All Rights Reserved. | ||
3 | * | 4 | * |
4 | * This program is free software; you can redistribute it and/or modify it | 5 | * This program is free software; you can redistribute it and/or |
5 | * under the terms of version 2 of the GNU General Public License as | 6 | * modify it under the terms of the GNU General Public License as |
6 | * published by the Free Software Foundation. | 7 | * published by the Free Software Foundation. |
7 | * | 8 | * |
8 | * This program is distributed in the hope that it would be useful, but | 9 | * This program is distributed in the hope that it would be useful, |
9 | * WITHOUT ANY WARRANTY; without even the implied warranty of | 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
12 | * GNU General Public License for more details. | ||
11 | * | 13 | * |
12 | * Further, this software is distributed without any warranty that it is | 14 | * You should have received a copy of the GNU General Public License |
13 | * free of the rightful claim of any third person regarding infringement | 15 | * along with this program; if not, write the Free Software Foundation, |
14 | * or the like. Any license provided herein, whether implied or | 16 | * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
15 | * otherwise, applies only to this software file. Patent licenses, if | ||
16 | * any, provided herein do not apply to combinations of this program with | ||
17 | * other software, or any other product whatsoever. | ||
18 | * | ||
19 | * You should have received a copy of the GNU General Public License along | ||
20 | * with this program; if not, write the Free Software Foundation, Inc., 59 | ||
21 | * Temple Place - Suite 330, Boston MA 02111-1307, USA. | ||
22 | * | ||
23 | * Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy, | ||
24 | * Mountain View, CA 94043, or: | ||
25 | * | ||
26 | * http://www.sgi.com | ||
27 | * | ||
28 | * For further information regarding this notice, see: | ||
29 | * | ||
30 | * http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/ | ||
31 | */ | 17 | */ |
32 | #ifndef __XFS_DMAPI_H__ | 18 | #ifndef __XFS_DMAPI_H__ |
33 | #define __XFS_DMAPI_H__ | 19 | #define __XFS_DMAPI_H__ |
34 | 20 | ||
21 | #include <linux/version.h> | ||
35 | /* Values used to define the on-disk version of dm_attrname_t. All | 22 | /* Values used to define the on-disk version of dm_attrname_t. All |
36 | * on-disk attribute names start with the 8-byte string "SGI_DMI_". | 23 | * on-disk attribute names start with the 8-byte string "SGI_DMI_". |
37 | * | 24 | * |
diff --git a/fs/xfs/xfs_dmops.c b/fs/xfs/xfs_dmops.c index cec54ba800eb..629795b3b3d5 100644 --- a/fs/xfs/xfs_dmops.c +++ b/fs/xfs/xfs_dmops.c | |||
@@ -1,40 +1,25 @@ | |||
1 | /* | 1 | /* |
2 | * Copyright (c) 2000-2003 Silicon Graphics, Inc. All Rights Reserved. | 2 | * Copyright (c) 2000-2003,2005 Silicon Graphics, Inc. |
3 | * All Rights Reserved. | ||
3 | * | 4 | * |
4 | * This program is free software; you can redistribute it and/or modify it | 5 | * This program is free software; you can redistribute it and/or |
5 | * under the terms of version 2 of the GNU General Public License as | 6 | * modify it under the terms of the GNU General Public License as |
6 | * published by the Free Software Foundation. | 7 | * published by the Free Software Foundation. |
7 | * | 8 | * |
8 | * This program is distributed in the hope that it would be useful, but | 9 | * This program is distributed in the hope that it would be useful, |
9 | * WITHOUT ANY WARRANTY; without even the implied warranty of | 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
12 | * GNU General Public License for more details. | ||
11 | * | 13 | * |
12 | * Further, this software is distributed without any warranty that it is | 14 | * You should have received a copy of the GNU General Public License |
13 | * free of the rightful claim of any third person regarding infringement | 15 | * along with this program; if not, write the Free Software Foundation, |
14 | * or the like. Any license provided herein, whether implied or | 16 | * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
15 | * otherwise, applies only to this software file. Patent licenses, if | ||
16 | * any, provided herein do not apply to combinations of this program with | ||
17 | * other software, or any other product whatsoever. | ||
18 | * | ||
19 | * You should have received a copy of the GNU General Public License along | ||
20 | * with this program; if not, write the Free Software Foundation, Inc., 59 | ||
21 | * Temple Place - Suite 330, Boston MA 02111-1307, USA. | ||
22 | * | ||
23 | * Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy, | ||
24 | * Mountain View, CA 94043, or: | ||
25 | * | ||
26 | * http://www.sgi.com | ||
27 | * | ||
28 | * For further information regarding this notice, see: | ||
29 | * | ||
30 | * http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/ | ||
31 | */ | 17 | */ |
32 | #include "xfs.h" | 18 | #include "xfs.h" |
33 | 19 | #include "xfs_fs.h" | |
34 | #include "xfs_macros.h" | ||
35 | #include "xfs_types.h" | 20 | #include "xfs_types.h" |
36 | #include "xfs_inum.h" | ||
37 | #include "xfs_log.h" | 21 | #include "xfs_log.h" |
22 | #include "xfs_inum.h" | ||
38 | #include "xfs_trans.h" | 23 | #include "xfs_trans.h" |
39 | #include "xfs_sb.h" | 24 | #include "xfs_sb.h" |
40 | #include "xfs_ag.h" | 25 | #include "xfs_ag.h" |
diff --git a/fs/xfs/xfs_error.c b/fs/xfs/xfs_error.c index dcd3fdd5c1f7..d7b6b5d16704 100644 --- a/fs/xfs/xfs_error.c +++ b/fs/xfs/xfs_error.c | |||
@@ -1,51 +1,35 @@ | |||
1 | /* | 1 | /* |
2 | * Copyright (c) 2000-2001 Silicon Graphics, Inc. All Rights Reserved. | 2 | * Copyright (c) 2000-2001,2005 Silicon Graphics, Inc. |
3 | * All Rights Reserved. | ||
3 | * | 4 | * |
4 | * This program is free software; you can redistribute it and/or modify it | 5 | * This program is free software; you can redistribute it and/or |
5 | * under the terms of version 2 of the GNU General Public License as | 6 | * modify it under the terms of the GNU General Public License as |
6 | * published by the Free Software Foundation. | 7 | * published by the Free Software Foundation. |
7 | * | 8 | * |
8 | * This program is distributed in the hope that it would be useful, but | 9 | * This program is distributed in the hope that it would be useful, |
9 | * WITHOUT ANY WARRANTY; without even the implied warranty of | 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
12 | * GNU General Public License for more details. | ||
11 | * | 13 | * |
12 | * Further, this software is distributed without any warranty that it is | 14 | * You should have received a copy of the GNU General Public License |
13 | * free of the rightful claim of any third person regarding infringement | 15 | * along with this program; if not, write the Free Software Foundation, |
14 | * or the like. Any license provided herein, whether implied or | 16 | * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
15 | * otherwise, applies only to this software file. Patent licenses, if | ||
16 | * any, provided herein do not apply to combinations of this program with | ||
17 | * other software, or any other product whatsoever. | ||
18 | * | ||
19 | * You should have received a copy of the GNU General Public License along | ||
20 | * with this program; if not, write the Free Software Foundation, Inc., 59 | ||
21 | * Temple Place - Suite 330, Boston MA 02111-1307, USA. | ||
22 | * | ||
23 | * Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy, | ||
24 | * Mountain View, CA 94043, or: | ||
25 | * | ||
26 | * http://www.sgi.com | ||
27 | * | ||
28 | * For further information regarding this notice, see: | ||
29 | * | ||
30 | * http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/ | ||
31 | */ | 17 | */ |
32 | |||
33 | #include "xfs.h" | 18 | #include "xfs.h" |
34 | 19 | #include "xfs_fs.h" | |
35 | #include "xfs_macros.h" | ||
36 | #include "xfs_types.h" | 20 | #include "xfs_types.h" |
37 | #include "xfs_inum.h" | ||
38 | #include "xfs_log.h" | 21 | #include "xfs_log.h" |
39 | #include "xfs_sb.h" | 22 | #include "xfs_inum.h" |
40 | #include "xfs_trans.h" | 23 | #include "xfs_trans.h" |
24 | #include "xfs_sb.h" | ||
41 | #include "xfs_dir.h" | 25 | #include "xfs_dir.h" |
42 | #include "xfs_dir2.h" | 26 | #include "xfs_dir2.h" |
43 | #include "xfs_dmapi.h" | 27 | #include "xfs_dmapi.h" |
44 | #include "xfs_mount.h" | 28 | #include "xfs_mount.h" |
45 | #include "xfs_bmap_btree.h" | 29 | #include "xfs_bmap_btree.h" |
46 | #include "xfs_attr_sf.h" | ||
47 | #include "xfs_dir_sf.h" | 30 | #include "xfs_dir_sf.h" |
48 | #include "xfs_dir2_sf.h" | 31 | #include "xfs_dir2_sf.h" |
32 | #include "xfs_attr_sf.h" | ||
49 | #include "xfs_dinode.h" | 33 | #include "xfs_dinode.h" |
50 | #include "xfs_inode.h" | 34 | #include "xfs_inode.h" |
51 | #include "xfs_utils.h" | 35 | #include "xfs_utils.h" |
diff --git a/fs/xfs/xfs_error.h b/fs/xfs/xfs_error.h index 52ee2b90b5ed..06d8a8426c16 100644 --- a/fs/xfs/xfs_error.h +++ b/fs/xfs/xfs_error.h | |||
@@ -1,39 +1,25 @@ | |||
1 | /* | 1 | /* |
2 | * Copyright (c) 2000-2002 Silicon Graphics, Inc. All Rights Reserved. | 2 | * Copyright (c) 2000-2002,2005 Silicon Graphics, Inc. |
3 | * All Rights Reserved. | ||
3 | * | 4 | * |
4 | * This program is free software; you can redistribute it and/or modify it | 5 | * This program is free software; you can redistribute it and/or |
5 | * under the terms of version 2 of the GNU General Public License as | 6 | * modify it under the terms of the GNU General Public License as |
6 | * published by the Free Software Foundation. | 7 | * published by the Free Software Foundation. |
7 | * | 8 | * |
8 | * This program is distributed in the hope that it would be useful, but | 9 | * This program is distributed in the hope that it would be useful, |
9 | * WITHOUT ANY WARRANTY; without even the implied warranty of | 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
12 | * GNU General Public License for more details. | ||
11 | * | 13 | * |
12 | * Further, this software is distributed without any warranty that it is | 14 | * You should have received a copy of the GNU General Public License |
13 | * free of the rightful claim of any third person regarding infringement | 15 | * along with this program; if not, write the Free Software Foundation, |
14 | * or the like. Any license provided herein, whether implied or | 16 | * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
15 | * otherwise, applies only to this software file. Patent licenses, if | ||
16 | * any, provided herein do not apply to combinations of this program with | ||
17 | * other software, or any other product whatsoever. | ||
18 | * | ||
19 | * You should have received a copy of the GNU General Public License along | ||
20 | * with this program; if not, write the Free Software Foundation, Inc., 59 | ||
21 | * Temple Place - Suite 330, Boston MA 02111-1307, USA. | ||
22 | * | ||
23 | * Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy, | ||
24 | * Mountain View, CA 94043, or: | ||
25 | * | ||
26 | * http://www.sgi.com | ||
27 | * | ||
28 | * For further information regarding this notice, see: | ||
29 | * | ||
30 | * http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/ | ||
31 | */ | 17 | */ |
32 | #ifndef __XFS_ERROR_H__ | 18 | #ifndef __XFS_ERROR_H__ |
33 | #define __XFS_ERROR_H__ | 19 | #define __XFS_ERROR_H__ |
34 | 20 | ||
35 | #define prdev(fmt,targ,args...) \ | 21 | #define prdev(fmt,targ,args...) \ |
36 | printk("XFS: device %s- " fmt "\n", XFS_BUFTARG_NAME(targ), ## args) | 22 | printk("XFS: device %s - " fmt "\n", XFS_BUFTARG_NAME(targ), ## args) |
37 | 23 | ||
38 | #define XFS_ERECOVER 1 /* Failure to recover log */ | 24 | #define XFS_ERECOVER 1 /* Failure to recover log */ |
39 | #define XFS_ELOGSTAT 2 /* Failure to stat log in user space */ | 25 | #define XFS_ELOGSTAT 2 /* Failure to stat log in user space */ |
@@ -54,24 +40,10 @@ extern int xfs_error_trap(int); | |||
54 | 40 | ||
55 | struct xfs_mount; | 41 | struct xfs_mount; |
56 | 42 | ||
57 | extern void | 43 | extern void xfs_error_report(char *tag, int level, struct xfs_mount *mp, |
58 | xfs_error_report( | 44 | char *fname, int linenum, inst_t *ra); |
59 | char *tag, | 45 | extern void xfs_corruption_error(char *tag, int level, struct xfs_mount *mp, |
60 | int level, | 46 | void *p, char *fname, int linenum, inst_t *ra); |
61 | struct xfs_mount *mp, | ||
62 | char *fname, | ||
63 | int linenum, | ||
64 | inst_t *ra); | ||
65 | |||
66 | extern void | ||
67 | xfs_corruption_error( | ||
68 | char *tag, | ||
69 | int level, | ||
70 | struct xfs_mount *mp, | ||
71 | void *p, | ||
72 | char *fname, | ||
73 | int linenum, | ||
74 | inst_t *ra); | ||
75 | 47 | ||
76 | #define XFS_ERROR_REPORT(e, lvl, mp) \ | 48 | #define XFS_ERROR_REPORT(e, lvl, mp) \ |
77 | xfs_error_report(e, lvl, mp, __FILE__, __LINE__, __return_address) | 49 | xfs_error_report(e, lvl, mp, __FILE__, __LINE__, __return_address) |
@@ -84,6 +56,32 @@ xfs_corruption_error( | |||
84 | #define XFS_ERRLEVEL_HIGH 5 | 56 | #define XFS_ERRLEVEL_HIGH 5 |
85 | 57 | ||
86 | /* | 58 | /* |
59 | * Macros to set EFSCORRUPTED & return/branch. | ||
60 | */ | ||
61 | #define XFS_WANT_CORRUPTED_GOTO(x,l) \ | ||
62 | { \ | ||
63 | int fs_is_ok = (x); \ | ||
64 | ASSERT(fs_is_ok); \ | ||
65 | if (unlikely(!fs_is_ok)) { \ | ||
66 | XFS_ERROR_REPORT("XFS_WANT_CORRUPTED_GOTO", \ | ||
67 | XFS_ERRLEVEL_LOW, NULL); \ | ||
68 | error = XFS_ERROR(EFSCORRUPTED); \ | ||
69 | goto l; \ | ||
70 | } \ | ||
71 | } | ||
72 | |||
73 | #define XFS_WANT_CORRUPTED_RETURN(x) \ | ||
74 | { \ | ||
75 | int fs_is_ok = (x); \ | ||
76 | ASSERT(fs_is_ok); \ | ||
77 | if (unlikely(!fs_is_ok)) { \ | ||
78 | XFS_ERROR_REPORT("XFS_WANT_CORRUPTED_RETURN", \ | ||
79 | XFS_ERRLEVEL_LOW, NULL); \ | ||
80 | return XFS_ERROR(EFSCORRUPTED); \ | ||
81 | } \ | ||
82 | } | ||
83 | |||
84 | /* | ||
87 | * error injection tags - the labels can be anything you want | 85 | * error injection tags - the labels can be anything you want |
88 | * but each tag should have its own unique number | 86 | * but each tag should have its own unique number |
89 | */ | 87 | */ |
@@ -139,8 +137,8 @@ xfs_corruption_error( | |||
139 | #define XFS_RANDOM_BMAPIFORMAT XFS_RANDOM_DEFAULT | 137 | #define XFS_RANDOM_BMAPIFORMAT XFS_RANDOM_DEFAULT |
140 | 138 | ||
141 | #if (defined(DEBUG) || defined(INDUCE_IO_ERROR)) | 139 | #if (defined(DEBUG) || defined(INDUCE_IO_ERROR)) |
142 | extern int xfs_error_test(int, int *, char *, int, char *, unsigned long); | 140 | extern int xfs_error_test(int, int *, char *, int, char *, unsigned long); |
143 | void xfs_error_test_init(void); | 141 | extern void xfs_error_test_init(void); |
144 | 142 | ||
145 | #define XFS_NUM_INJECT_ERROR 10 | 143 | #define XFS_NUM_INJECT_ERROR 10 |
146 | 144 | ||
@@ -156,12 +154,10 @@ void xfs_error_test_init(void); | |||
156 | (rf))) | 154 | (rf))) |
157 | #endif /* __ANSI_CPP__ */ | 155 | #endif /* __ANSI_CPP__ */ |
158 | 156 | ||
159 | int xfs_errortag_add(int error_tag, xfs_mount_t *mp); | 157 | extern int xfs_errortag_add(int error_tag, xfs_mount_t *mp); |
160 | int xfs_errortag_clear(int error_tag, xfs_mount_t *mp); | 158 | extern int xfs_errortag_clear(int error_tag, xfs_mount_t *mp); |
161 | 159 | extern int xfs_errortag_clearall(xfs_mount_t *mp); | |
162 | int xfs_errortag_clearall(xfs_mount_t *mp); | 160 | extern int xfs_errortag_clearall_umount(int64_t fsid, char *fsname, int loud); |
163 | int xfs_errortag_clearall_umount(int64_t fsid, char *fsname, | ||
164 | int loud); | ||
165 | #else | 161 | #else |
166 | #define XFS_TEST_ERROR(expr, mp, tag, rf) (expr) | 162 | #define XFS_TEST_ERROR(expr, mp, tag, rf) (expr) |
167 | #define xfs_errortag_add(tag, mp) (ENOSYS) | 163 | #define xfs_errortag_add(tag, mp) (ENOSYS) |
@@ -185,9 +181,9 @@ int xfs_errortag_clearall_umount(int64_t fsid, char *fsname, | |||
185 | 181 | ||
186 | struct xfs_mount; | 182 | struct xfs_mount; |
187 | /* PRINTFLIKE4 */ | 183 | /* PRINTFLIKE4 */ |
188 | void xfs_cmn_err(int panic_tag, int level, struct xfs_mount *mp, | 184 | extern void xfs_cmn_err(int panic_tag, int level, struct xfs_mount *mp, |
189 | char *fmt, ...); | 185 | char *fmt, ...); |
190 | /* PRINTFLIKE3 */ | 186 | /* PRINTFLIKE3 */ |
191 | void xfs_fs_cmn_err(int level, struct xfs_mount *mp, char *fmt, ...); | 187 | extern void xfs_fs_cmn_err(int level, struct xfs_mount *mp, char *fmt, ...); |
192 | 188 | ||
193 | #endif /* __XFS_ERROR_H__ */ | 189 | #endif /* __XFS_ERROR_H__ */ |
diff --git a/fs/xfs/xfs_extfree_item.c b/fs/xfs/xfs_extfree_item.c index cc7d1494a45d..f19282ec8549 100644 --- a/fs/xfs/xfs_extfree_item.c +++ b/fs/xfs/xfs_extfree_item.c | |||
@@ -1,46 +1,25 @@ | |||
1 | /* | 1 | /* |
2 | * Copyright (c) 2000-2001 Silicon Graphics, Inc. All Rights Reserved. | 2 | * Copyright (c) 2000-2001,2005 Silicon Graphics, Inc. |
3 | * All Rights Reserved. | ||
3 | * | 4 | * |
4 | * This program is free software; you can redistribute it and/or modify it | 5 | * This program is free software; you can redistribute it and/or |
5 | * under the terms of version 2 of the GNU General Public License as | 6 | * modify it under the terms of the GNU General Public License as |
6 | * published by the Free Software Foundation. | 7 | * published by the Free Software Foundation. |
7 | * | 8 | * |
8 | * This program is distributed in the hope that it would be useful, but | 9 | * This program is distributed in the hope that it would be useful, |
9 | * WITHOUT ANY WARRANTY; without even the implied warranty of | 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
12 | * GNU General Public License for more details. | ||
11 | * | 13 | * |
12 | * Further, this software is distributed without any warranty that it is | 14 | * You should have received a copy of the GNU General Public License |
13 | * free of the rightful claim of any third person regarding infringement | 15 | * along with this program; if not, write the Free Software Foundation, |
14 | * or the like. Any license provided herein, whether implied or | 16 | * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
15 | * otherwise, applies only to this software file. Patent licenses, if | ||
16 | * any, provided herein do not apply to combinations of this program with | ||
17 | * other software, or any other product whatsoever. | ||
18 | * | ||
19 | * You should have received a copy of the GNU General Public License along | ||
20 | * with this program; if not, write the Free Software Foundation, Inc., 59 | ||
21 | * Temple Place - Suite 330, Boston MA 02111-1307, USA. | ||
22 | * | ||
23 | * Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy, | ||
24 | * Mountain View, CA 94043, or: | ||
25 | * | ||
26 | * http://www.sgi.com | ||
27 | * | ||
28 | * For further information regarding this notice, see: | ||
29 | * | ||
30 | * http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/ | ||
31 | */ | ||
32 | |||
33 | /* | ||
34 | * This file contains the implementation of the xfs_efi_log_item | ||
35 | * and xfs_efd_log_item items. | ||
36 | */ | 17 | */ |
37 | |||
38 | #include "xfs.h" | 18 | #include "xfs.h" |
39 | 19 | #include "xfs_fs.h" | |
40 | #include "xfs_macros.h" | ||
41 | #include "xfs_types.h" | 20 | #include "xfs_types.h" |
42 | #include "xfs_inum.h" | ||
43 | #include "xfs_log.h" | 21 | #include "xfs_log.h" |
22 | #include "xfs_inum.h" | ||
44 | #include "xfs_trans.h" | 23 | #include "xfs_trans.h" |
45 | #include "xfs_buf_item.h" | 24 | #include "xfs_buf_item.h" |
46 | #include "xfs_sb.h" | 25 | #include "xfs_sb.h" |
diff --git a/fs/xfs/xfs_extfree_item.h b/fs/xfs/xfs_extfree_item.h index d433bac9f59d..5bf681708fec 100644 --- a/fs/xfs/xfs_extfree_item.h +++ b/fs/xfs/xfs_extfree_item.h | |||
@@ -1,33 +1,19 @@ | |||
1 | /* | 1 | /* |
2 | * Copyright (c) 2000 Silicon Graphics, Inc. All Rights Reserved. | 2 | * Copyright (c) 2000,2005 Silicon Graphics, Inc. |
3 | * All Rights Reserved. | ||
3 | * | 4 | * |
4 | * This program is free software; you can redistribute it and/or modify it | 5 | * This program is free software; you can redistribute it and/or |
5 | * under the terms of version 2 of the GNU General Public License as | 6 | * modify it under the terms of the GNU General Public License as |
6 | * published by the Free Software Foundation. | 7 | * published by the Free Software Foundation. |
7 | * | 8 | * |
8 | * This program is distributed in the hope that it would be useful, but | 9 | * This program is distributed in the hope that it would be useful, |
9 | * WITHOUT ANY WARRANTY; without even the implied warranty of | 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
12 | * GNU General Public License for more details. | ||
11 | * | 13 | * |
12 | * Further, this software is distributed without any warranty that it is | 14 | * You should have received a copy of the GNU General Public License |
13 | * free of the rightful claim of any third person regarding infringement | 15 | * along with this program; if not, write the Free Software Foundation, |
14 | * or the like. Any license provided herein, whether implied or | 16 | * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
15 | * otherwise, applies only to this software file. Patent licenses, if | ||
16 | * any, provided herein do not apply to combinations of this program with | ||
17 | * other software, or any other product whatsoever. | ||
18 | * | ||
19 | * You should have received a copy of the GNU General Public License along | ||
20 | * with this program; if not, write the Free Software Foundation, Inc., 59 | ||
21 | * Temple Place - Suite 330, Boston MA 02111-1307, USA. | ||
22 | * | ||
23 | * Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy, | ||
24 | * Mountain View, CA 94043, or: | ||
25 | * | ||
26 | * http://www.sgi.com | ||
27 | * | ||
28 | * For further information regarding this notice, see: | ||
29 | * | ||
30 | * http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/ | ||
31 | */ | 17 | */ |
32 | #ifndef __XFS_EXTFREE_ITEM_H__ | 18 | #ifndef __XFS_EXTFREE_ITEM_H__ |
33 | #define __XFS_EXTFREE_ITEM_H__ | 19 | #define __XFS_EXTFREE_ITEM_H__ |
diff --git a/fs/xfs/xfs_fs.h b/fs/xfs/xfs_fs.h index 095af0a5cff3..ba096f80f48d 100644 --- a/fs/xfs/xfs_fs.h +++ b/fs/xfs/xfs_fs.h | |||
@@ -1,34 +1,19 @@ | |||
1 | /* | 1 | /* |
2 | * Copyright (c) 1995-2003 Silicon Graphics, Inc. All Rights Reserved. | 2 | * Copyright (c) 1995-2005 Silicon Graphics, Inc. |
3 | * All Rights Reserved. | ||
3 | * | 4 | * |
4 | * This program is free software; you can redistribute it and/or modify it | 5 | * This program is free software; you can redistribute it and/or |
5 | * under the terms of version 2.1 of the GNU Lesser General Public License | 6 | * modify it under the terms of the GNU General Public License as |
6 | * as published by the Free Software Foundation. | 7 | * published by the Free Software Foundation. |
7 | * | 8 | * |
8 | * This program is distributed in the hope that it would be useful, but | 9 | * This program is distributed in the hope that it would be useful, |
9 | * WITHOUT ANY WARRANTY; without even the implied warranty of | 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
12 | * GNU General Public License for more details. | ||
11 | * | 13 | * |
12 | * Further, this software is distributed without any warranty that it is | 14 | * You should have received a copy of the GNU General Public License |
13 | * free of the rightful claim of any third person regarding infringement | 15 | * along with this program; if not, write the Free Software Foundation, |
14 | * or the like. Any license provided herein, whether implied or | 16 | * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
15 | * otherwise, applies only to this software file. Patent licenses, if | ||
16 | * any, provided herein do not apply to combinations of this program with | ||
17 | * other software, or any other product whatsoever. | ||
18 | * | ||
19 | * You should have received a copy of the GNU Lesser General Public | ||
20 | * License along with this program; if not, write the Free Software | ||
21 | * Foundation, Inc., 59 Temple Place - Suite 330, Boston MA 02111-1307, | ||
22 | * USA. | ||
23 | * | ||
24 | * Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy, | ||
25 | * Mountain View, CA 94043, or: | ||
26 | * | ||
27 | * http://www.sgi.com | ||
28 | * | ||
29 | * For further information regarding this notice, see: | ||
30 | * | ||
31 | * http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/ | ||
32 | */ | 17 | */ |
33 | #ifndef __XFS_FS_H__ | 18 | #ifndef __XFS_FS_H__ |
34 | #define __XFS_FS_H__ | 19 | #define __XFS_FS_H__ |
@@ -251,6 +236,7 @@ typedef struct xfs_fsop_resblks { | |||
251 | #define XFS_FSOP_GEOM_FLAGS_DIRV2 0x0080 /* directory version 2 */ | 236 | #define XFS_FSOP_GEOM_FLAGS_DIRV2 0x0080 /* directory version 2 */ |
252 | #define XFS_FSOP_GEOM_FLAGS_LOGV2 0x0100 /* log format version 2 */ | 237 | #define XFS_FSOP_GEOM_FLAGS_LOGV2 0x0100 /* log format version 2 */ |
253 | #define XFS_FSOP_GEOM_FLAGS_SECTOR 0x0200 /* sector sizes >1BB */ | 238 | #define XFS_FSOP_GEOM_FLAGS_SECTOR 0x0200 /* sector sizes >1BB */ |
239 | #define XFS_FSOP_GEOM_FLAGS_ATTR2 0x0400 /* inline attributes rework */ | ||
254 | 240 | ||
255 | 241 | ||
256 | /* | 242 | /* |
diff --git a/fs/xfs/xfs_fsops.c b/fs/xfs/xfs_fsops.c index ca535d613190..7ceabd0e2d9d 100644 --- a/fs/xfs/xfs_fsops.c +++ b/fs/xfs/xfs_fsops.c | |||
@@ -1,66 +1,51 @@ | |||
1 | /* | 1 | /* |
2 | * Copyright (c) 2000-2002 Silicon Graphics, Inc. All Rights Reserved. | 2 | * Copyright (c) 2000-2005 Silicon Graphics, Inc. |
3 | * All Rights Reserved. | ||
3 | * | 4 | * |
4 | * This program is free software; you can redistribute it and/or modify it | 5 | * This program is free software; you can redistribute it and/or |
5 | * under the terms of version 2 of the GNU General Public License as | 6 | * modify it under the terms of the GNU General Public License as |
6 | * published by the Free Software Foundation. | 7 | * published by the Free Software Foundation. |
7 | * | 8 | * |
8 | * This program is distributed in the hope that it would be useful, but | 9 | * This program is distributed in the hope that it would be useful, |
9 | * WITHOUT ANY WARRANTY; without even the implied warranty of | 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
12 | * GNU General Public License for more details. | ||
11 | * | 13 | * |
12 | * Further, this software is distributed without any warranty that it is | 14 | * You should have received a copy of the GNU General Public License |
13 | * free of the rightful claim of any third person regarding infringement | 15 | * along with this program; if not, write the Free Software Foundation, |
14 | * or the like. Any license provided herein, whether implied or | 16 | * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
15 | * otherwise, applies only to this software file. Patent licenses, if | ||
16 | * any, provided herein do not apply to combinations of this program with | ||
17 | * other software, or any other product whatsoever. | ||
18 | * | ||
19 | * You should have received a copy of the GNU General Public License along | ||
20 | * with this program; if not, write the Free Software Foundation, Inc., 59 | ||
21 | * Temple Place - Suite 330, Boston MA 02111-1307, USA. | ||
22 | * | ||
23 | * Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy, | ||
24 | * Mountain View, CA 94043, or: | ||
25 | * | ||
26 | * http://www.sgi.com | ||
27 | * | ||
28 | * For further information regarding this notice, see: | ||
29 | * | ||
30 | * http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/ | ||
31 | */ | 17 | */ |
32 | |||
33 | #include "xfs.h" | 18 | #include "xfs.h" |
34 | #include "xfs_macros.h" | 19 | #include "xfs_fs.h" |
35 | #include "xfs_types.h" | 20 | #include "xfs_types.h" |
21 | #include "xfs_bit.h" | ||
36 | #include "xfs_inum.h" | 22 | #include "xfs_inum.h" |
37 | #include "xfs_log.h" | 23 | #include "xfs_log.h" |
38 | #include "xfs_trans.h" | 24 | #include "xfs_trans.h" |
39 | #include "xfs_sb.h" | 25 | #include "xfs_sb.h" |
26 | #include "xfs_ag.h" | ||
40 | #include "xfs_dir.h" | 27 | #include "xfs_dir.h" |
28 | #include "xfs_dir2.h" | ||
41 | #include "xfs_dmapi.h" | 29 | #include "xfs_dmapi.h" |
42 | #include "xfs_mount.h" | 30 | #include "xfs_mount.h" |
43 | #include "xfs_ag.h" | ||
44 | #include "xfs_alloc_btree.h" | ||
45 | #include "xfs_bmap_btree.h" | 31 | #include "xfs_bmap_btree.h" |
32 | #include "xfs_alloc_btree.h" | ||
46 | #include "xfs_ialloc_btree.h" | 33 | #include "xfs_ialloc_btree.h" |
34 | #include "xfs_dir_sf.h" | ||
35 | #include "xfs_dir2_sf.h" | ||
36 | #include "xfs_attr_sf.h" | ||
37 | #include "xfs_dinode.h" | ||
38 | #include "xfs_inode.h" | ||
39 | #include "xfs_inode_item.h" | ||
47 | #include "xfs_btree.h" | 40 | #include "xfs_btree.h" |
48 | #include "xfs_error.h" | 41 | #include "xfs_error.h" |
49 | #include "xfs_alloc.h" | 42 | #include "xfs_alloc.h" |
50 | #include "xfs_ialloc.h" | 43 | #include "xfs_ialloc.h" |
51 | #include "xfs_fsops.h" | 44 | #include "xfs_fsops.h" |
52 | #include "xfs_itable.h" | 45 | #include "xfs_itable.h" |
53 | #include "xfs_rw.h" | ||
54 | #include "xfs_refcache.h" | ||
55 | #include "xfs_trans_space.h" | 46 | #include "xfs_trans_space.h" |
56 | #include "xfs_rtalloc.h" | 47 | #include "xfs_rtalloc.h" |
57 | #include "xfs_dir2.h" | 48 | #include "xfs_rw.h" |
58 | #include "xfs_attr_sf.h" | ||
59 | #include "xfs_dir_sf.h" | ||
60 | #include "xfs_dir2_sf.h" | ||
61 | #include "xfs_dinode.h" | ||
62 | #include "xfs_inode.h" | ||
63 | #include "xfs_inode_item.h" | ||
64 | 49 | ||
65 | /* | 50 | /* |
66 | * File system operations | 51 | * File system operations |
@@ -110,7 +95,9 @@ xfs_fs_geometry( | |||
110 | (XFS_SB_VERSION_HASDIRV2(&mp->m_sb) ? | 95 | (XFS_SB_VERSION_HASDIRV2(&mp->m_sb) ? |
111 | XFS_FSOP_GEOM_FLAGS_DIRV2 : 0) | | 96 | XFS_FSOP_GEOM_FLAGS_DIRV2 : 0) | |
112 | (XFS_SB_VERSION_HASSECTOR(&mp->m_sb) ? | 97 | (XFS_SB_VERSION_HASSECTOR(&mp->m_sb) ? |
113 | XFS_FSOP_GEOM_FLAGS_SECTOR : 0); | 98 | XFS_FSOP_GEOM_FLAGS_SECTOR : 0) | |
99 | (XFS_SB_VERSION_HASATTR2(&mp->m_sb) ? | ||
100 | XFS_FSOP_GEOM_FLAGS_ATTR2 : 0); | ||
114 | geo->logsectsize = XFS_SB_VERSION_HASSECTOR(&mp->m_sb) ? | 101 | geo->logsectsize = XFS_SB_VERSION_HASSECTOR(&mp->m_sb) ? |
115 | mp->m_sb.sb_logsectsize : BBSIZE; | 102 | mp->m_sb.sb_logsectsize : BBSIZE; |
116 | geo->rtsectsize = mp->m_sb.sb_blocksize; | 103 | geo->rtsectsize = mp->m_sb.sb_blocksize; |
@@ -184,7 +171,7 @@ xfs_growfs_data_private( | |||
184 | memset(&mp->m_perag[oagcount], 0, | 171 | memset(&mp->m_perag[oagcount], 0, |
185 | (nagcount - oagcount) * sizeof(xfs_perag_t)); | 172 | (nagcount - oagcount) * sizeof(xfs_perag_t)); |
186 | mp->m_flags |= XFS_MOUNT_32BITINODES; | 173 | mp->m_flags |= XFS_MOUNT_32BITINODES; |
187 | nagimax = xfs_initialize_perag(mp, nagcount); | 174 | nagimax = xfs_initialize_perag(XFS_MTOVFS(mp), mp, nagcount); |
188 | up_write(&mp->m_peraglock); | 175 | up_write(&mp->m_peraglock); |
189 | } | 176 | } |
190 | tp = xfs_trans_alloc(mp, XFS_TRANS_GROWFS); | 177 | tp = xfs_trans_alloc(mp, XFS_TRANS_GROWFS); |
@@ -204,28 +191,26 @@ xfs_growfs_data_private( | |||
204 | XFS_FSS_TO_BB(mp, 1), 0); | 191 | XFS_FSS_TO_BB(mp, 1), 0); |
205 | agf = XFS_BUF_TO_AGF(bp); | 192 | agf = XFS_BUF_TO_AGF(bp); |
206 | memset(agf, 0, mp->m_sb.sb_sectsize); | 193 | memset(agf, 0, mp->m_sb.sb_sectsize); |
207 | INT_SET(agf->agf_magicnum, ARCH_CONVERT, XFS_AGF_MAGIC); | 194 | agf->agf_magicnum = cpu_to_be32(XFS_AGF_MAGIC); |
208 | INT_SET(agf->agf_versionnum, ARCH_CONVERT, XFS_AGF_VERSION); | 195 | agf->agf_versionnum = cpu_to_be32(XFS_AGF_VERSION); |
209 | INT_SET(agf->agf_seqno, ARCH_CONVERT, agno); | 196 | agf->agf_seqno = cpu_to_be32(agno); |
210 | if (agno == nagcount - 1) | 197 | if (agno == nagcount - 1) |
211 | agsize = | 198 | agsize = |
212 | nb - | 199 | nb - |
213 | (agno * (xfs_rfsblock_t)mp->m_sb.sb_agblocks); | 200 | (agno * (xfs_rfsblock_t)mp->m_sb.sb_agblocks); |
214 | else | 201 | else |
215 | agsize = mp->m_sb.sb_agblocks; | 202 | agsize = mp->m_sb.sb_agblocks; |
216 | INT_SET(agf->agf_length, ARCH_CONVERT, agsize); | 203 | agf->agf_length = cpu_to_be32(agsize); |
217 | INT_SET(agf->agf_roots[XFS_BTNUM_BNOi], ARCH_CONVERT, | 204 | agf->agf_roots[XFS_BTNUM_BNOi] = cpu_to_be32(XFS_BNO_BLOCK(mp)); |
218 | XFS_BNO_BLOCK(mp)); | 205 | agf->agf_roots[XFS_BTNUM_CNTi] = cpu_to_be32(XFS_CNT_BLOCK(mp)); |
219 | INT_SET(agf->agf_roots[XFS_BTNUM_CNTi], ARCH_CONVERT, | 206 | agf->agf_levels[XFS_BTNUM_BNOi] = cpu_to_be32(1); |
220 | XFS_CNT_BLOCK(mp)); | 207 | agf->agf_levels[XFS_BTNUM_CNTi] = cpu_to_be32(1); |
221 | INT_SET(agf->agf_levels[XFS_BTNUM_BNOi], ARCH_CONVERT, 1); | ||
222 | INT_SET(agf->agf_levels[XFS_BTNUM_CNTi], ARCH_CONVERT, 1); | ||
223 | agf->agf_flfirst = 0; | 208 | agf->agf_flfirst = 0; |
224 | INT_SET(agf->agf_fllast, ARCH_CONVERT, XFS_AGFL_SIZE(mp) - 1); | 209 | agf->agf_fllast = cpu_to_be32(XFS_AGFL_SIZE(mp) - 1); |
225 | agf->agf_flcount = 0; | 210 | agf->agf_flcount = 0; |
226 | tmpsize = agsize - XFS_PREALLOC_BLOCKS(mp); | 211 | tmpsize = agsize - XFS_PREALLOC_BLOCKS(mp); |
227 | INT_SET(agf->agf_freeblks, ARCH_CONVERT, tmpsize); | 212 | agf->agf_freeblks = cpu_to_be32(tmpsize); |
228 | INT_SET(agf->agf_longest, ARCH_CONVERT, tmpsize); | 213 | agf->agf_longest = cpu_to_be32(tmpsize); |
229 | error = xfs_bwrite(mp, bp); | 214 | error = xfs_bwrite(mp, bp); |
230 | if (error) { | 215 | if (error) { |
231 | goto error0; | 216 | goto error0; |
@@ -238,19 +223,18 @@ xfs_growfs_data_private( | |||
238 | XFS_FSS_TO_BB(mp, 1), 0); | 223 | XFS_FSS_TO_BB(mp, 1), 0); |
239 | agi = XFS_BUF_TO_AGI(bp); | 224 | agi = XFS_BUF_TO_AGI(bp); |
240 | memset(agi, 0, mp->m_sb.sb_sectsize); | 225 | memset(agi, 0, mp->m_sb.sb_sectsize); |
241 | INT_SET(agi->agi_magicnum, ARCH_CONVERT, XFS_AGI_MAGIC); | 226 | agi->agi_magicnum = cpu_to_be32(XFS_AGI_MAGIC); |
242 | INT_SET(agi->agi_versionnum, ARCH_CONVERT, XFS_AGI_VERSION); | 227 | agi->agi_versionnum = cpu_to_be32(XFS_AGI_VERSION); |
243 | INT_SET(agi->agi_seqno, ARCH_CONVERT, agno); | 228 | agi->agi_seqno = cpu_to_be32(agno); |
244 | INT_SET(agi->agi_length, ARCH_CONVERT, agsize); | 229 | agi->agi_length = cpu_to_be32(agsize); |
245 | agi->agi_count = 0; | 230 | agi->agi_count = 0; |
246 | INT_SET(agi->agi_root, ARCH_CONVERT, XFS_IBT_BLOCK(mp)); | 231 | agi->agi_root = cpu_to_be32(XFS_IBT_BLOCK(mp)); |
247 | INT_SET(agi->agi_level, ARCH_CONVERT, 1); | 232 | agi->agi_level = cpu_to_be32(1); |
248 | agi->agi_freecount = 0; | 233 | agi->agi_freecount = 0; |
249 | INT_SET(agi->agi_newino, ARCH_CONVERT, NULLAGINO); | 234 | agi->agi_newino = cpu_to_be32(NULLAGINO); |
250 | INT_SET(agi->agi_dirino, ARCH_CONVERT, NULLAGINO); | 235 | agi->agi_dirino = cpu_to_be32(NULLAGINO); |
251 | for (bucket = 0; bucket < XFS_AGI_UNLINKED_BUCKETS; bucket++) | 236 | for (bucket = 0; bucket < XFS_AGI_UNLINKED_BUCKETS; bucket++) |
252 | INT_SET(agi->agi_unlinked[bucket], ARCH_CONVERT, | 237 | agi->agi_unlinked[bucket] = cpu_to_be32(NULLAGINO); |
253 | NULLAGINO); | ||
254 | error = xfs_bwrite(mp, bp); | 238 | error = xfs_bwrite(mp, bp); |
255 | if (error) { | 239 | if (error) { |
256 | goto error0; | 240 | goto error0; |
@@ -263,17 +247,16 @@ xfs_growfs_data_private( | |||
263 | BTOBB(mp->m_sb.sb_blocksize), 0); | 247 | BTOBB(mp->m_sb.sb_blocksize), 0); |
264 | block = XFS_BUF_TO_SBLOCK(bp); | 248 | block = XFS_BUF_TO_SBLOCK(bp); |
265 | memset(block, 0, mp->m_sb.sb_blocksize); | 249 | memset(block, 0, mp->m_sb.sb_blocksize); |
266 | INT_SET(block->bb_magic, ARCH_CONVERT, XFS_ABTB_MAGIC); | 250 | block->bb_magic = cpu_to_be32(XFS_ABTB_MAGIC); |
267 | block->bb_level = 0; | 251 | block->bb_level = 0; |
268 | INT_SET(block->bb_numrecs, ARCH_CONVERT, 1); | 252 | block->bb_numrecs = cpu_to_be16(1); |
269 | INT_SET(block->bb_leftsib, ARCH_CONVERT, NULLAGBLOCK); | 253 | block->bb_leftsib = cpu_to_be32(NULLAGBLOCK); |
270 | INT_SET(block->bb_rightsib, ARCH_CONVERT, NULLAGBLOCK); | 254 | block->bb_rightsib = cpu_to_be32(NULLAGBLOCK); |
271 | arec = XFS_BTREE_REC_ADDR(mp->m_sb.sb_blocksize, xfs_alloc, | 255 | arec = XFS_BTREE_REC_ADDR(mp->m_sb.sb_blocksize, xfs_alloc, |
272 | block, 1, mp->m_alloc_mxr[0]); | 256 | block, 1, mp->m_alloc_mxr[0]); |
273 | INT_SET(arec->ar_startblock, ARCH_CONVERT, | 257 | arec->ar_startblock = cpu_to_be32(XFS_PREALLOC_BLOCKS(mp)); |
274 | XFS_PREALLOC_BLOCKS(mp)); | 258 | arec->ar_blockcount = cpu_to_be32( |
275 | INT_SET(arec->ar_blockcount, ARCH_CONVERT, | 259 | agsize - be32_to_cpu(arec->ar_startblock)); |
276 | agsize - INT_GET(arec->ar_startblock, ARCH_CONVERT)); | ||
277 | error = xfs_bwrite(mp, bp); | 260 | error = xfs_bwrite(mp, bp); |
278 | if (error) { | 261 | if (error) { |
279 | goto error0; | 262 | goto error0; |
@@ -286,18 +269,17 @@ xfs_growfs_data_private( | |||
286 | BTOBB(mp->m_sb.sb_blocksize), 0); | 269 | BTOBB(mp->m_sb.sb_blocksize), 0); |
287 | block = XFS_BUF_TO_SBLOCK(bp); | 270 | block = XFS_BUF_TO_SBLOCK(bp); |
288 | memset(block, 0, mp->m_sb.sb_blocksize); | 271 | memset(block, 0, mp->m_sb.sb_blocksize); |
289 | INT_SET(block->bb_magic, ARCH_CONVERT, XFS_ABTC_MAGIC); | 272 | block->bb_magic = cpu_to_be32(XFS_ABTC_MAGIC); |
290 | block->bb_level = 0; | 273 | block->bb_level = 0; |
291 | INT_SET(block->bb_numrecs, ARCH_CONVERT, 1); | 274 | block->bb_numrecs = cpu_to_be16(1); |
292 | INT_SET(block->bb_leftsib, ARCH_CONVERT, NULLAGBLOCK); | 275 | block->bb_leftsib = cpu_to_be32(NULLAGBLOCK); |
293 | INT_SET(block->bb_rightsib, ARCH_CONVERT, NULLAGBLOCK); | 276 | block->bb_rightsib = cpu_to_be32(NULLAGBLOCK); |
294 | arec = XFS_BTREE_REC_ADDR(mp->m_sb.sb_blocksize, xfs_alloc, | 277 | arec = XFS_BTREE_REC_ADDR(mp->m_sb.sb_blocksize, xfs_alloc, |
295 | block, 1, mp->m_alloc_mxr[0]); | 278 | block, 1, mp->m_alloc_mxr[0]); |
296 | INT_SET(arec->ar_startblock, ARCH_CONVERT, | 279 | arec->ar_startblock = cpu_to_be32(XFS_PREALLOC_BLOCKS(mp)); |
297 | XFS_PREALLOC_BLOCKS(mp)); | 280 | arec->ar_blockcount = cpu_to_be32( |
298 | INT_SET(arec->ar_blockcount, ARCH_CONVERT, | 281 | agsize - be32_to_cpu(arec->ar_startblock)); |
299 | agsize - INT_GET(arec->ar_startblock, ARCH_CONVERT)); | 282 | nfree += be32_to_cpu(arec->ar_blockcount); |
300 | nfree += INT_GET(arec->ar_blockcount, ARCH_CONVERT); | ||
301 | error = xfs_bwrite(mp, bp); | 283 | error = xfs_bwrite(mp, bp); |
302 | if (error) { | 284 | if (error) { |
303 | goto error0; | 285 | goto error0; |
@@ -310,11 +292,11 @@ xfs_growfs_data_private( | |||
310 | BTOBB(mp->m_sb.sb_blocksize), 0); | 292 | BTOBB(mp->m_sb.sb_blocksize), 0); |
311 | block = XFS_BUF_TO_SBLOCK(bp); | 293 | block = XFS_BUF_TO_SBLOCK(bp); |
312 | memset(block, 0, mp->m_sb.sb_blocksize); | 294 | memset(block, 0, mp->m_sb.sb_blocksize); |
313 | INT_SET(block->bb_magic, ARCH_CONVERT, XFS_IBT_MAGIC); | 295 | block->bb_magic = cpu_to_be32(XFS_IBT_MAGIC); |
314 | block->bb_level = 0; | 296 | block->bb_level = 0; |
315 | block->bb_numrecs = 0; | 297 | block->bb_numrecs = 0; |
316 | INT_SET(block->bb_leftsib, ARCH_CONVERT, NULLAGBLOCK); | 298 | block->bb_leftsib = cpu_to_be32(NULLAGBLOCK); |
317 | INT_SET(block->bb_rightsib, ARCH_CONVERT, NULLAGBLOCK); | 299 | block->bb_rightsib = cpu_to_be32(NULLAGBLOCK); |
318 | error = xfs_bwrite(mp, bp); | 300 | error = xfs_bwrite(mp, bp); |
319 | if (error) { | 301 | if (error) { |
320 | goto error0; | 302 | goto error0; |
@@ -334,10 +316,9 @@ xfs_growfs_data_private( | |||
334 | } | 316 | } |
335 | ASSERT(bp); | 317 | ASSERT(bp); |
336 | agi = XFS_BUF_TO_AGI(bp); | 318 | agi = XFS_BUF_TO_AGI(bp); |
337 | INT_MOD(agi->agi_length, ARCH_CONVERT, new); | 319 | be32_add(&agi->agi_length, new); |
338 | ASSERT(nagcount == oagcount || | 320 | ASSERT(nagcount == oagcount || |
339 | INT_GET(agi->agi_length, ARCH_CONVERT) == | 321 | be32_to_cpu(agi->agi_length) == mp->m_sb.sb_agblocks); |
340 | mp->m_sb.sb_agblocks); | ||
341 | xfs_ialloc_log_agi(tp, bp, XFS_AGI_LENGTH); | 322 | xfs_ialloc_log_agi(tp, bp, XFS_AGI_LENGTH); |
342 | /* | 323 | /* |
343 | * Change agf length. | 324 | * Change agf length. |
@@ -348,14 +329,14 @@ xfs_growfs_data_private( | |||
348 | } | 329 | } |
349 | ASSERT(bp); | 330 | ASSERT(bp); |
350 | agf = XFS_BUF_TO_AGF(bp); | 331 | agf = XFS_BUF_TO_AGF(bp); |
351 | INT_MOD(agf->agf_length, ARCH_CONVERT, new); | 332 | be32_add(&agf->agf_length, new); |
352 | ASSERT(INT_GET(agf->agf_length, ARCH_CONVERT) == | 333 | ASSERT(be32_to_cpu(agf->agf_length) == |
353 | INT_GET(agi->agi_length, ARCH_CONVERT)); | 334 | be32_to_cpu(agi->agi_length)); |
354 | /* | 335 | /* |
355 | * Free the new space. | 336 | * Free the new space. |
356 | */ | 337 | */ |
357 | error = xfs_free_extent(tp, XFS_AGB_TO_FSB(mp, agno, | 338 | error = xfs_free_extent(tp, XFS_AGB_TO_FSB(mp, agno, |
358 | INT_GET(agf->agf_length, ARCH_CONVERT) - new), new); | 339 | be32_to_cpu(agf->agf_length) - new), new); |
359 | if (error) { | 340 | if (error) { |
360 | goto error0; | 341 | goto error0; |
361 | } | 342 | } |
diff --git a/fs/xfs/xfs_fsops.h b/fs/xfs/xfs_fsops.h index b61486173a61..f32713f14f9a 100644 --- a/fs/xfs/xfs_fsops.h +++ b/fs/xfs/xfs_fsops.h | |||
@@ -1,67 +1,29 @@ | |||
1 | /* | 1 | /* |
2 | * Copyright (c) 2000-2001 Silicon Graphics, Inc. All Rights Reserved. | 2 | * Copyright (c) 2000-2001,2005 Silicon Graphics, Inc. |
3 | * All Rights Reserved. | ||
3 | * | 4 | * |
4 | * This program is free software; you can redistribute it and/or modify it | 5 | * This program is free software; you can redistribute it and/or |
5 | * under the terms of version 2 of the GNU General Public License as | 6 | * modify it under the terms of the GNU General Public License as |
6 | * published by the Free Software Foundation. | 7 | * published by the Free Software Foundation. |
7 | * | 8 | * |
8 | * This program is distributed in the hope that it would be useful, but | 9 | * This program is distributed in the hope that it would be useful, |
9 | * WITHOUT ANY WARRANTY; without even the implied warranty of | 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
12 | * GNU General Public License for more details. | ||
11 | * | 13 | * |
12 | * Further, this software is distributed without any warranty that it is | 14 | * You should have received a copy of the GNU General Public License |
13 | * free of the rightful claim of any third person regarding infringement | 15 | * along with this program; if not, write the Free Software Foundation, |
14 | * or the like. Any license provided herein, whether implied or | 16 | * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
15 | * otherwise, applies only to this software file. Patent licenses, if | ||
16 | * any, provided herein do not apply to combinations of this program with | ||
17 | * other software, or any other product whatsoever. | ||
18 | * | ||
19 | * You should have received a copy of the GNU General Public License along | ||
20 | * with this program; if not, write the Free Software Foundation, Inc., 59 | ||
21 | * Temple Place - Suite 330, Boston MA 02111-1307, USA. | ||
22 | * | ||
23 | * Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy, | ||
24 | * Mountain View, CA 94043, or: | ||
25 | * | ||
26 | * http://www.sgi.com | ||
27 | * | ||
28 | * For further information regarding this notice, see: | ||
29 | * | ||
30 | * http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/ | ||
31 | */ | 17 | */ |
32 | #ifndef __XFS_FSOPS_H__ | 18 | #ifndef __XFS_FSOPS_H__ |
33 | #define __XFS_FSOPS_H__ | 19 | #define __XFS_FSOPS_H__ |
34 | 20 | ||
35 | int | 21 | extern int xfs_fs_geometry(xfs_mount_t *mp, xfs_fsop_geom_t *geo, int nversion); |
36 | xfs_fs_geometry( | 22 | extern int xfs_growfs_data(xfs_mount_t *mp, xfs_growfs_data_t *in); |
37 | xfs_mount_t *mp, | 23 | extern int xfs_growfs_log(xfs_mount_t *mp, xfs_growfs_log_t *in); |
38 | xfs_fsop_geom_t *geo, | 24 | extern int xfs_fs_counts(xfs_mount_t *mp, xfs_fsop_counts_t *cnt); |
39 | int new_version); | 25 | extern int xfs_reserve_blocks(xfs_mount_t *mp, __uint64_t *inval, |
40 | 26 | xfs_fsop_resblks_t *outval); | |
41 | int | 27 | extern int xfs_fs_goingdown(xfs_mount_t *mp, __uint32_t inflags); |
42 | xfs_growfs_data( | ||
43 | xfs_mount_t *mp, | ||
44 | xfs_growfs_data_t *in); | ||
45 | |||
46 | int | ||
47 | xfs_growfs_log( | ||
48 | xfs_mount_t *mp, | ||
49 | xfs_growfs_log_t *in); | ||
50 | |||
51 | int | ||
52 | xfs_fs_counts( | ||
53 | xfs_mount_t *mp, | ||
54 | xfs_fsop_counts_t *cnt); | ||
55 | |||
56 | int | ||
57 | xfs_reserve_blocks( | ||
58 | xfs_mount_t *mp, | ||
59 | __uint64_t *inval, | ||
60 | xfs_fsop_resblks_t *outval); | ||
61 | |||
62 | int | ||
63 | xfs_fs_goingdown( | ||
64 | xfs_mount_t *mp, | ||
65 | __uint32_t inflags); | ||
66 | 28 | ||
67 | #endif /* __XFS_FSOPS_H__ */ | 29 | #endif /* __XFS_FSOPS_H__ */ |
diff --git a/fs/xfs/xfs_ialloc.c b/fs/xfs/xfs_ialloc.c index ce5fee9eaec5..8f3fae1aa98a 100644 --- a/fs/xfs/xfs_ialloc.c +++ b/fs/xfs/xfs_ialloc.c | |||
@@ -1,41 +1,26 @@ | |||
1 | /* | 1 | /* |
2 | * Copyright (c) 2000-2002 Silicon Graphics, Inc. All Rights Reserved. | 2 | * Copyright (c) 2000-2002,2005 Silicon Graphics, Inc. |
3 | * All Rights Reserved. | ||
3 | * | 4 | * |
4 | * This program is free software; you can redistribute it and/or modify it | 5 | * This program is free software; you can redistribute it and/or |
5 | * under the terms of version 2 of the GNU General Public License as | 6 | * modify it under the terms of the GNU General Public License as |
6 | * published by the Free Software Foundation. | 7 | * published by the Free Software Foundation. |
7 | * | 8 | * |
8 | * This program is distributed in the hope that it would be useful, but | 9 | * This program is distributed in the hope that it would be useful, |
9 | * WITHOUT ANY WARRANTY; without even the implied warranty of | 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
12 | * GNU General Public License for more details. | ||
11 | * | 13 | * |
12 | * Further, this software is distributed without any warranty that it is | 14 | * You should have received a copy of the GNU General Public License |
13 | * free of the rightful claim of any third person regarding infringement | 15 | * along with this program; if not, write the Free Software Foundation, |
14 | * or the like. Any license provided herein, whether implied or | 16 | * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
15 | * otherwise, applies only to this software file. Patent licenses, if | ||
16 | * any, provided herein do not apply to combinations of this program with | ||
17 | * other software, or any other product whatsoever. | ||
18 | * | ||
19 | * You should have received a copy of the GNU General Public License along | ||
20 | * with this program; if not, write the Free Software Foundation, Inc., 59 | ||
21 | * Temple Place - Suite 330, Boston MA 02111-1307, USA. | ||
22 | * | ||
23 | * Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy, | ||
24 | * Mountain View, CA 94043, or: | ||
25 | * | ||
26 | * http://www.sgi.com | ||
27 | * | ||
28 | * For further information regarding this notice, see: | ||
29 | * | ||
30 | * http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/ | ||
31 | */ | 17 | */ |
32 | |||
33 | #include "xfs.h" | 18 | #include "xfs.h" |
34 | 19 | #include "xfs_fs.h" | |
35 | #include "xfs_macros.h" | ||
36 | #include "xfs_types.h" | 20 | #include "xfs_types.h" |
37 | #include "xfs_inum.h" | 21 | #include "xfs_bit.h" |
38 | #include "xfs_log.h" | 22 | #include "xfs_log.h" |
23 | #include "xfs_inum.h" | ||
39 | #include "xfs_trans.h" | 24 | #include "xfs_trans.h" |
40 | #include "xfs_sb.h" | 25 | #include "xfs_sb.h" |
41 | #include "xfs_ag.h" | 26 | #include "xfs_ag.h" |
@@ -43,18 +28,17 @@ | |||
43 | #include "xfs_dir2.h" | 28 | #include "xfs_dir2.h" |
44 | #include "xfs_dmapi.h" | 29 | #include "xfs_dmapi.h" |
45 | #include "xfs_mount.h" | 30 | #include "xfs_mount.h" |
46 | #include "xfs_alloc_btree.h" | ||
47 | #include "xfs_bmap_btree.h" | 31 | #include "xfs_bmap_btree.h" |
32 | #include "xfs_alloc_btree.h" | ||
48 | #include "xfs_ialloc_btree.h" | 33 | #include "xfs_ialloc_btree.h" |
49 | #include "xfs_btree.h" | ||
50 | #include "xfs_ialloc.h" | ||
51 | #include "xfs_attr_sf.h" | ||
52 | #include "xfs_dir_sf.h" | 34 | #include "xfs_dir_sf.h" |
53 | #include "xfs_dir2_sf.h" | 35 | #include "xfs_dir2_sf.h" |
36 | #include "xfs_attr_sf.h" | ||
54 | #include "xfs_dinode.h" | 37 | #include "xfs_dinode.h" |
55 | #include "xfs_inode.h" | 38 | #include "xfs_inode.h" |
39 | #include "xfs_btree.h" | ||
40 | #include "xfs_ialloc.h" | ||
56 | #include "xfs_alloc.h" | 41 | #include "xfs_alloc.h" |
57 | #include "xfs_bit.h" | ||
58 | #include "xfs_rtalloc.h" | 42 | #include "xfs_rtalloc.h" |
59 | #include "xfs_error.h" | 43 | #include "xfs_error.h" |
60 | #include "xfs_bmap.h" | 44 | #include "xfs_bmap.h" |
@@ -194,8 +178,8 @@ xfs_ialloc_ag_alloc( | |||
194 | * Ideally they should be spaced out through the a.g. | 178 | * Ideally they should be spaced out through the a.g. |
195 | * For now, just allocate blocks up front. | 179 | * For now, just allocate blocks up front. |
196 | */ | 180 | */ |
197 | args.agbno = INT_GET(agi->agi_root, ARCH_CONVERT); | 181 | args.agbno = be32_to_cpu(agi->agi_root); |
198 | args.fsbno = XFS_AGB_TO_FSB(args.mp, INT_GET(agi->agi_seqno, ARCH_CONVERT), | 182 | args.fsbno = XFS_AGB_TO_FSB(args.mp, be32_to_cpu(agi->agi_seqno), |
199 | args.agbno); | 183 | args.agbno); |
200 | /* | 184 | /* |
201 | * Allocate a fixed-size extent of inodes. | 185 | * Allocate a fixed-size extent of inodes. |
@@ -217,9 +201,9 @@ xfs_ialloc_ag_alloc( | |||
217 | */ | 201 | */ |
218 | if (isaligned && args.fsbno == NULLFSBLOCK) { | 202 | if (isaligned && args.fsbno == NULLFSBLOCK) { |
219 | args.type = XFS_ALLOCTYPE_NEAR_BNO; | 203 | args.type = XFS_ALLOCTYPE_NEAR_BNO; |
220 | args.agbno = INT_GET(agi->agi_root, ARCH_CONVERT); | 204 | args.agbno = be32_to_cpu(agi->agi_root); |
221 | args.fsbno = XFS_AGB_TO_FSB(args.mp, | 205 | args.fsbno = XFS_AGB_TO_FSB(args.mp, |
222 | INT_GET(agi->agi_seqno, ARCH_CONVERT), args.agbno); | 206 | be32_to_cpu(agi->agi_seqno), args.agbno); |
223 | if (XFS_SB_VERSION_HASALIGN(&args.mp->m_sb) && | 207 | if (XFS_SB_VERSION_HASALIGN(&args.mp->m_sb) && |
224 | args.mp->m_sb.sb_inoalignmt >= | 208 | args.mp->m_sb.sb_inoalignmt >= |
225 | XFS_B_TO_FSBT(args.mp, XFS_INODE_CLUSTER_SIZE(args.mp))) | 209 | XFS_B_TO_FSBT(args.mp, XFS_INODE_CLUSTER_SIZE(args.mp))) |
@@ -274,7 +258,7 @@ xfs_ialloc_ag_alloc( | |||
274 | /* | 258 | /* |
275 | * Get the block. | 259 | * Get the block. |
276 | */ | 260 | */ |
277 | d = XFS_AGB_TO_DADDR(args.mp, INT_GET(agi->agi_seqno, ARCH_CONVERT), | 261 | d = XFS_AGB_TO_DADDR(args.mp, be32_to_cpu(agi->agi_seqno), |
278 | args.agbno + (j * blks_per_cluster)); | 262 | args.agbno + (j * blks_per_cluster)); |
279 | fbuf = xfs_trans_get_buf(tp, args.mp->m_ddev_targp, d, | 263 | fbuf = xfs_trans_get_buf(tp, args.mp->m_ddev_targp, d, |
280 | args.mp->m_bsize * blks_per_cluster, | 264 | args.mp->m_bsize * blks_per_cluster, |
@@ -294,17 +278,17 @@ xfs_ialloc_ag_alloc( | |||
294 | } | 278 | } |
295 | xfs_trans_inode_alloc_buf(tp, fbuf); | 279 | xfs_trans_inode_alloc_buf(tp, fbuf); |
296 | } | 280 | } |
297 | INT_MOD(agi->agi_count, ARCH_CONVERT, newlen); | 281 | be32_add(&agi->agi_count, newlen); |
298 | INT_MOD(agi->agi_freecount, ARCH_CONVERT, newlen); | 282 | be32_add(&agi->agi_freecount, newlen); |
299 | down_read(&args.mp->m_peraglock); | 283 | down_read(&args.mp->m_peraglock); |
300 | args.mp->m_perag[INT_GET(agi->agi_seqno, ARCH_CONVERT)].pagi_freecount += newlen; | 284 | args.mp->m_perag[be32_to_cpu(agi->agi_seqno)].pagi_freecount += newlen; |
301 | up_read(&args.mp->m_peraglock); | 285 | up_read(&args.mp->m_peraglock); |
302 | INT_SET(agi->agi_newino, ARCH_CONVERT, newino); | 286 | agi->agi_newino = cpu_to_be32(newino); |
303 | /* | 287 | /* |
304 | * Insert records describing the new inode chunk into the btree. | 288 | * Insert records describing the new inode chunk into the btree. |
305 | */ | 289 | */ |
306 | cur = xfs_btree_init_cursor(args.mp, tp, agbp, | 290 | cur = xfs_btree_init_cursor(args.mp, tp, agbp, |
307 | INT_GET(agi->agi_seqno, ARCH_CONVERT), | 291 | be32_to_cpu(agi->agi_seqno), |
308 | XFS_BTNUM_INO, (xfs_inode_t *)0, 0); | 292 | XFS_BTNUM_INO, (xfs_inode_t *)0, 0); |
309 | for (thisino = newino; | 293 | for (thisino = newino; |
310 | thisino < newino + newlen; | 294 | thisino < newino + newlen; |
@@ -544,7 +528,7 @@ xfs_dialloc( | |||
544 | return 0; | 528 | return 0; |
545 | } | 529 | } |
546 | agi = XFS_BUF_TO_AGI(agbp); | 530 | agi = XFS_BUF_TO_AGI(agbp); |
547 | ASSERT(INT_GET(agi->agi_magicnum, ARCH_CONVERT) == XFS_AGI_MAGIC); | 531 | ASSERT(be32_to_cpu(agi->agi_magicnum) == XFS_AGI_MAGIC); |
548 | } else { | 532 | } else { |
549 | /* | 533 | /* |
550 | * Continue where we left off before. In this case, we | 534 | * Continue where we left off before. In this case, we |
@@ -552,12 +536,12 @@ xfs_dialloc( | |||
552 | */ | 536 | */ |
553 | agbp = *IO_agbp; | 537 | agbp = *IO_agbp; |
554 | agi = XFS_BUF_TO_AGI(agbp); | 538 | agi = XFS_BUF_TO_AGI(agbp); |
555 | ASSERT(INT_GET(agi->agi_magicnum, ARCH_CONVERT) == XFS_AGI_MAGIC); | 539 | ASSERT(be32_to_cpu(agi->agi_magicnum) == XFS_AGI_MAGIC); |
556 | ASSERT(INT_GET(agi->agi_freecount, ARCH_CONVERT) > 0); | 540 | ASSERT(be32_to_cpu(agi->agi_freecount) > 0); |
557 | } | 541 | } |
558 | mp = tp->t_mountp; | 542 | mp = tp->t_mountp; |
559 | agcount = mp->m_sb.sb_agcount; | 543 | agcount = mp->m_sb.sb_agcount; |
560 | agno = INT_GET(agi->agi_seqno, ARCH_CONVERT); | 544 | agno = be32_to_cpu(agi->agi_seqno); |
561 | tagno = agno; | 545 | tagno = agno; |
562 | pagno = XFS_INO_TO_AGNO(mp, parent); | 546 | pagno = XFS_INO_TO_AGNO(mp, parent); |
563 | pagino = XFS_INO_TO_AGINO(mp, parent); | 547 | pagino = XFS_INO_TO_AGINO(mp, parent); |
@@ -605,7 +589,7 @@ xfs_dialloc( | |||
605 | * can commit the current transaction and call | 589 | * can commit the current transaction and call |
606 | * us again where we left off. | 590 | * us again where we left off. |
607 | */ | 591 | */ |
608 | ASSERT(INT_GET(agi->agi_freecount, ARCH_CONVERT) > 0); | 592 | ASSERT(be32_to_cpu(agi->agi_freecount) > 0); |
609 | *alloc_done = B_TRUE; | 593 | *alloc_done = B_TRUE; |
610 | *IO_agbp = agbp; | 594 | *IO_agbp = agbp; |
611 | *inop = NULLFSINO; | 595 | *inop = NULLFSINO; |
@@ -636,7 +620,7 @@ nextag: | |||
636 | if (error) | 620 | if (error) |
637 | goto nextag; | 621 | goto nextag; |
638 | agi = XFS_BUF_TO_AGI(agbp); | 622 | agi = XFS_BUF_TO_AGI(agbp); |
639 | ASSERT(INT_GET(agi->agi_magicnum, ARCH_CONVERT) == XFS_AGI_MAGIC); | 623 | ASSERT(be32_to_cpu(agi->agi_magicnum) == XFS_AGI_MAGIC); |
640 | } | 624 | } |
641 | /* | 625 | /* |
642 | * Here with an allocation group that has a free inode. | 626 | * Here with an allocation group that has a free inode. |
@@ -645,14 +629,14 @@ nextag: | |||
645 | */ | 629 | */ |
646 | agno = tagno; | 630 | agno = tagno; |
647 | *IO_agbp = NULL; | 631 | *IO_agbp = NULL; |
648 | cur = xfs_btree_init_cursor(mp, tp, agbp, INT_GET(agi->agi_seqno, ARCH_CONVERT), | 632 | cur = xfs_btree_init_cursor(mp, tp, agbp, be32_to_cpu(agi->agi_seqno), |
649 | XFS_BTNUM_INO, (xfs_inode_t *)0, 0); | 633 | XFS_BTNUM_INO, (xfs_inode_t *)0, 0); |
650 | /* | 634 | /* |
651 | * If pagino is 0 (this is the root inode allocation) use newino. | 635 | * If pagino is 0 (this is the root inode allocation) use newino. |
652 | * This must work because we've just allocated some. | 636 | * This must work because we've just allocated some. |
653 | */ | 637 | */ |
654 | if (!pagino) | 638 | if (!pagino) |
655 | pagino = INT_GET(agi->agi_newino, ARCH_CONVERT); | 639 | pagino = be32_to_cpu(agi->agi_newino); |
656 | #ifdef DEBUG | 640 | #ifdef DEBUG |
657 | if (cur->bc_nlevels == 1) { | 641 | if (cur->bc_nlevels == 1) { |
658 | int freecount = 0; | 642 | int freecount = 0; |
@@ -670,7 +654,7 @@ nextag: | |||
670 | goto error0; | 654 | goto error0; |
671 | } while (i == 1); | 655 | } while (i == 1); |
672 | 656 | ||
673 | ASSERT(freecount == INT_GET(agi->agi_freecount, ARCH_CONVERT) || | 657 | ASSERT(freecount == be32_to_cpu(agi->agi_freecount) || |
674 | XFS_FORCED_SHUTDOWN(mp)); | 658 | XFS_FORCED_SHUTDOWN(mp)); |
675 | } | 659 | } |
676 | #endif | 660 | #endif |
@@ -829,9 +813,9 @@ nextag: | |||
829 | * In a different a.g. from the parent. | 813 | * In a different a.g. from the parent. |
830 | * See if the most recently allocated block has any free. | 814 | * See if the most recently allocated block has any free. |
831 | */ | 815 | */ |
832 | else if (INT_GET(agi->agi_newino, ARCH_CONVERT) != NULLAGINO) { | 816 | else if (be32_to_cpu(agi->agi_newino) != NULLAGINO) { |
833 | if ((error = xfs_inobt_lookup_eq(cur, | 817 | if ((error = xfs_inobt_lookup_eq(cur, |
834 | INT_GET(agi->agi_newino, ARCH_CONVERT), 0, 0, &i))) | 818 | be32_to_cpu(agi->agi_newino), 0, 0, &i))) |
835 | goto error0; | 819 | goto error0; |
836 | if (i == 1 && | 820 | if (i == 1 && |
837 | (error = xfs_inobt_get_rec(cur, &rec.ir_startino, | 821 | (error = xfs_inobt_get_rec(cur, &rec.ir_startino, |
@@ -878,7 +862,7 @@ nextag: | |||
878 | if ((error = xfs_inobt_update(cur, rec.ir_startino, rec.ir_freecount, | 862 | if ((error = xfs_inobt_update(cur, rec.ir_startino, rec.ir_freecount, |
879 | rec.ir_free))) | 863 | rec.ir_free))) |
880 | goto error0; | 864 | goto error0; |
881 | INT_MOD(agi->agi_freecount, ARCH_CONVERT, -1); | 865 | be32_add(&agi->agi_freecount, -1); |
882 | xfs_ialloc_log_agi(tp, agbp, XFS_AGI_FREECOUNT); | 866 | xfs_ialloc_log_agi(tp, agbp, XFS_AGI_FREECOUNT); |
883 | down_read(&mp->m_peraglock); | 867 | down_read(&mp->m_peraglock); |
884 | mp->m_perag[tagno].pagi_freecount--; | 868 | mp->m_perag[tagno].pagi_freecount--; |
@@ -898,7 +882,7 @@ nextag: | |||
898 | if ((error = xfs_inobt_increment(cur, 0, &i))) | 882 | if ((error = xfs_inobt_increment(cur, 0, &i))) |
899 | goto error0; | 883 | goto error0; |
900 | } while (i == 1); | 884 | } while (i == 1); |
901 | ASSERT(freecount == INT_GET(agi->agi_freecount, ARCH_CONVERT) || | 885 | ASSERT(freecount == be32_to_cpu(agi->agi_freecount) || |
902 | XFS_FORCED_SHUTDOWN(mp)); | 886 | XFS_FORCED_SHUTDOWN(mp)); |
903 | } | 887 | } |
904 | #endif | 888 | #endif |
@@ -957,8 +941,11 @@ xfs_difree( | |||
957 | agino = XFS_INO_TO_AGINO(mp, inode); | 941 | agino = XFS_INO_TO_AGINO(mp, inode); |
958 | if (inode != XFS_AGINO_TO_INO(mp, agno, agino)) { | 942 | if (inode != XFS_AGINO_TO_INO(mp, agno, agino)) { |
959 | cmn_err(CE_WARN, | 943 | cmn_err(CE_WARN, |
960 | "xfs_difree: inode != XFS_AGINO_TO_INO() (%d != %d) on %s. Returning EINVAL.", | 944 | "xfs_difree: inode != XFS_AGINO_TO_INO() " |
961 | inode, XFS_AGINO_TO_INO(mp, agno, agino), mp->m_fsname); | 945 | "(%llu != %llu) on %s. Returning EINVAL.", |
946 | (unsigned long long)inode, | ||
947 | (unsigned long long)XFS_AGINO_TO_INO(mp, agno, agino), | ||
948 | mp->m_fsname); | ||
962 | ASSERT(0); | 949 | ASSERT(0); |
963 | return XFS_ERROR(EINVAL); | 950 | return XFS_ERROR(EINVAL); |
964 | } | 951 | } |
@@ -983,8 +970,8 @@ xfs_difree( | |||
983 | return error; | 970 | return error; |
984 | } | 971 | } |
985 | agi = XFS_BUF_TO_AGI(agbp); | 972 | agi = XFS_BUF_TO_AGI(agbp); |
986 | ASSERT(INT_GET(agi->agi_magicnum, ARCH_CONVERT) == XFS_AGI_MAGIC); | 973 | ASSERT(be32_to_cpu(agi->agi_magicnum) == XFS_AGI_MAGIC); |
987 | ASSERT(agbno < INT_GET(agi->agi_length, ARCH_CONVERT)); | 974 | ASSERT(agbno < be32_to_cpu(agi->agi_length)); |
988 | /* | 975 | /* |
989 | * Initialize the cursor. | 976 | * Initialize the cursor. |
990 | */ | 977 | */ |
@@ -1006,7 +993,7 @@ xfs_difree( | |||
1006 | goto error0; | 993 | goto error0; |
1007 | } | 994 | } |
1008 | } while (i == 1); | 995 | } while (i == 1); |
1009 | ASSERT(freecount == INT_GET(agi->agi_freecount, ARCH_CONVERT) || | 996 | ASSERT(freecount == be32_to_cpu(agi->agi_freecount) || |
1010 | XFS_FORCED_SHUTDOWN(mp)); | 997 | XFS_FORCED_SHUTDOWN(mp)); |
1011 | } | 998 | } |
1012 | #endif | 999 | #endif |
@@ -1055,8 +1042,8 @@ xfs_difree( | |||
1055 | * to be freed when the transaction is committed. | 1042 | * to be freed when the transaction is committed. |
1056 | */ | 1043 | */ |
1057 | ilen = XFS_IALLOC_INODES(mp); | 1044 | ilen = XFS_IALLOC_INODES(mp); |
1058 | INT_MOD(agi->agi_count, ARCH_CONVERT, -ilen); | 1045 | be32_add(&agi->agi_count, -ilen); |
1059 | INT_MOD(agi->agi_freecount, ARCH_CONVERT, -(ilen - 1)); | 1046 | be32_add(&agi->agi_freecount, -(ilen - 1)); |
1060 | xfs_ialloc_log_agi(tp, agbp, XFS_AGI_COUNT | XFS_AGI_FREECOUNT); | 1047 | xfs_ialloc_log_agi(tp, agbp, XFS_AGI_COUNT | XFS_AGI_FREECOUNT); |
1061 | down_read(&mp->m_peraglock); | 1048 | down_read(&mp->m_peraglock); |
1062 | mp->m_perag[agno].pagi_freecount -= ilen - 1; | 1049 | mp->m_perag[agno].pagi_freecount -= ilen - 1; |
@@ -1085,7 +1072,7 @@ xfs_difree( | |||
1085 | /* | 1072 | /* |
1086 | * Change the inode free counts and log the ag/sb changes. | 1073 | * Change the inode free counts and log the ag/sb changes. |
1087 | */ | 1074 | */ |
1088 | INT_MOD(agi->agi_freecount, ARCH_CONVERT, 1); | 1075 | be32_add(&agi->agi_freecount, 1); |
1089 | xfs_ialloc_log_agi(tp, agbp, XFS_AGI_FREECOUNT); | 1076 | xfs_ialloc_log_agi(tp, agbp, XFS_AGI_FREECOUNT); |
1090 | down_read(&mp->m_peraglock); | 1077 | down_read(&mp->m_peraglock); |
1091 | mp->m_perag[agno].pagi_freecount++; | 1078 | mp->m_perag[agno].pagi_freecount++; |
@@ -1111,7 +1098,7 @@ xfs_difree( | |||
1111 | goto error0; | 1098 | goto error0; |
1112 | } | 1099 | } |
1113 | } while (i == 1); | 1100 | } while (i == 1); |
1114 | ASSERT(freecount == INT_GET(agi->agi_freecount, ARCH_CONVERT) || | 1101 | ASSERT(freecount == be32_to_cpu(agi->agi_freecount) || |
1115 | XFS_FORCED_SHUTDOWN(mp)); | 1102 | XFS_FORCED_SHUTDOWN(mp)); |
1116 | } | 1103 | } |
1117 | #endif | 1104 | #endif |
@@ -1320,7 +1307,7 @@ xfs_ialloc_log_agi( | |||
1320 | xfs_agi_t *agi; /* allocation group header */ | 1307 | xfs_agi_t *agi; /* allocation group header */ |
1321 | 1308 | ||
1322 | agi = XFS_BUF_TO_AGI(bp); | 1309 | agi = XFS_BUF_TO_AGI(bp); |
1323 | ASSERT(INT_GET(agi->agi_magicnum, ARCH_CONVERT) == XFS_AGI_MAGIC); | 1310 | ASSERT(be32_to_cpu(agi->agi_magicnum) == XFS_AGI_MAGIC); |
1324 | #endif | 1311 | #endif |
1325 | /* | 1312 | /* |
1326 | * Compute byte offsets for the first and last fields. | 1313 | * Compute byte offsets for the first and last fields. |
@@ -1362,9 +1349,8 @@ xfs_ialloc_read_agi( | |||
1362 | */ | 1349 | */ |
1363 | agi = XFS_BUF_TO_AGI(bp); | 1350 | agi = XFS_BUF_TO_AGI(bp); |
1364 | agi_ok = | 1351 | agi_ok = |
1365 | INT_GET(agi->agi_magicnum, ARCH_CONVERT) == XFS_AGI_MAGIC && | 1352 | be32_to_cpu(agi->agi_magicnum) == XFS_AGI_MAGIC && |
1366 | XFS_AGI_GOOD_VERSION( | 1353 | XFS_AGI_GOOD_VERSION(be32_to_cpu(agi->agi_versionnum)); |
1367 | INT_GET(agi->agi_versionnum, ARCH_CONVERT)); | ||
1368 | if (unlikely(XFS_TEST_ERROR(!agi_ok, mp, XFS_ERRTAG_IALLOC_READ_AGI, | 1354 | if (unlikely(XFS_TEST_ERROR(!agi_ok, mp, XFS_ERRTAG_IALLOC_READ_AGI, |
1369 | XFS_RANDOM_IALLOC_READ_AGI))) { | 1355 | XFS_RANDOM_IALLOC_READ_AGI))) { |
1370 | XFS_CORRUPTION_ERROR("xfs_ialloc_read_agi", XFS_ERRLEVEL_LOW, | 1356 | XFS_CORRUPTION_ERROR("xfs_ialloc_read_agi", XFS_ERRLEVEL_LOW, |
@@ -1374,16 +1360,15 @@ xfs_ialloc_read_agi( | |||
1374 | } | 1360 | } |
1375 | pag = &mp->m_perag[agno]; | 1361 | pag = &mp->m_perag[agno]; |
1376 | if (!pag->pagi_init) { | 1362 | if (!pag->pagi_init) { |
1377 | pag->pagi_freecount = INT_GET(agi->agi_freecount, ARCH_CONVERT); | 1363 | pag->pagi_freecount = be32_to_cpu(agi->agi_freecount); |
1378 | pag->pagi_init = 1; | 1364 | pag->pagi_init = 1; |
1379 | } else { | 1365 | } else { |
1380 | /* | 1366 | /* |
1381 | * It's possible for these to be out of sync if | 1367 | * It's possible for these to be out of sync if |
1382 | * we are in the middle of a forced shutdown. | 1368 | * we are in the middle of a forced shutdown. |
1383 | */ | 1369 | */ |
1384 | ASSERT(pag->pagi_freecount == | 1370 | ASSERT(pag->pagi_freecount == be32_to_cpu(agi->agi_freecount) || |
1385 | INT_GET(agi->agi_freecount, ARCH_CONVERT) | 1371 | XFS_FORCED_SHUTDOWN(mp)); |
1386 | || XFS_FORCED_SHUTDOWN(mp)); | ||
1387 | } | 1372 | } |
1388 | 1373 | ||
1389 | #ifdef DEBUG | 1374 | #ifdef DEBUG |
diff --git a/fs/xfs/xfs_ialloc.h b/fs/xfs/xfs_ialloc.h index db6d0015cecf..7f5debe1acb6 100644 --- a/fs/xfs/xfs_ialloc.h +++ b/fs/xfs/xfs_ialloc.h | |||
@@ -1,33 +1,19 @@ | |||
1 | /* | 1 | /* |
2 | * Copyright (c) 2000 Silicon Graphics, Inc. All Rights Reserved. | 2 | * Copyright (c) 2000,2005 Silicon Graphics, Inc. |
3 | * All Rights Reserved. | ||
3 | * | 4 | * |
4 | * This program is free software; you can redistribute it and/or modify it | 5 | * This program is free software; you can redistribute it and/or |
5 | * under the terms of version 2 of the GNU General Public License as | 6 | * modify it under the terms of the GNU General Public License as |
6 | * published by the Free Software Foundation. | 7 | * published by the Free Software Foundation. |
7 | * | 8 | * |
8 | * This program is distributed in the hope that it would be useful, but | 9 | * This program is distributed in the hope that it would be useful, |
9 | * WITHOUT ANY WARRANTY; without even the implied warranty of | 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
12 | * GNU General Public License for more details. | ||
11 | * | 13 | * |
12 | * Further, this software is distributed without any warranty that it is | 14 | * You should have received a copy of the GNU General Public License |
13 | * free of the rightful claim of any third person regarding infringement | 15 | * along with this program; if not, write the Free Software Foundation, |
14 | * or the like. Any license provided herein, whether implied or | 16 | * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
15 | * otherwise, applies only to this software file. Patent licenses, if | ||
16 | * any, provided herein do not apply to combinations of this program with | ||
17 | * other software, or any other product whatsoever. | ||
18 | * | ||
19 | * You should have received a copy of the GNU General Public License along | ||
20 | * with this program; if not, write the Free Software Foundation, Inc., 59 | ||
21 | * Temple Place - Suite 330, Boston MA 02111-1307, USA. | ||
22 | * | ||
23 | * Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy, | ||
24 | * Mountain View, CA 94043, or: | ||
25 | * | ||
26 | * http://www.sgi.com | ||
27 | * | ||
28 | * For further information regarding this notice, see: | ||
29 | * | ||
30 | * http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/ | ||
31 | */ | 17 | */ |
32 | #ifndef __XFS_IALLOC_H__ | 18 | #ifndef __XFS_IALLOC_H__ |
33 | #define __XFS_IALLOC_H__ | 19 | #define __XFS_IALLOC_H__ |
@@ -40,18 +26,8 @@ struct xfs_trans; | |||
40 | /* | 26 | /* |
41 | * Allocation parameters for inode allocation. | 27 | * Allocation parameters for inode allocation. |
42 | */ | 28 | */ |
43 | #if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_IALLOC_INODES) | 29 | #define XFS_IALLOC_INODES(mp) (mp)->m_ialloc_inos |
44 | int xfs_ialloc_inodes(struct xfs_mount *mp); | 30 | #define XFS_IALLOC_BLOCKS(mp) (mp)->m_ialloc_blks |
45 | #define XFS_IALLOC_INODES(mp) xfs_ialloc_inodes(mp) | ||
46 | #else | ||
47 | #define XFS_IALLOC_INODES(mp) ((mp)->m_ialloc_inos) | ||
48 | #endif | ||
49 | #if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_IALLOC_BLOCKS) | ||
50 | xfs_extlen_t xfs_ialloc_blocks(struct xfs_mount *mp); | ||
51 | #define XFS_IALLOC_BLOCKS(mp) xfs_ialloc_blocks(mp) | ||
52 | #else | ||
53 | #define XFS_IALLOC_BLOCKS(mp) ((mp)->m_ialloc_blks) | ||
54 | #endif | ||
55 | 31 | ||
56 | /* | 32 | /* |
57 | * For small block file systems, move inodes in clusters of this size. | 33 | * For small block file systems, move inodes in clusters of this size. |
@@ -67,31 +43,25 @@ xfs_extlen_t xfs_ialloc_blocks(struct xfs_mount *mp); | |||
67 | /* | 43 | /* |
68 | * Make an inode pointer out of the buffer/offset. | 44 | * Make an inode pointer out of the buffer/offset. |
69 | */ | 45 | */ |
70 | #if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_MAKE_IPTR) | ||
71 | struct xfs_dinode *xfs_make_iptr(struct xfs_mount *mp, struct xfs_buf *b, int o); | ||
72 | #define XFS_MAKE_IPTR(mp,b,o) xfs_make_iptr(mp,b,o) | 46 | #define XFS_MAKE_IPTR(mp,b,o) xfs_make_iptr(mp,b,o) |
73 | #else | 47 | static inline struct xfs_dinode * |
74 | #define XFS_MAKE_IPTR(mp,b,o) \ | 48 | xfs_make_iptr(struct xfs_mount *mp, struct xfs_buf *b, int o) |
75 | ((xfs_dinode_t *)(xfs_buf_offset(b, (o) << (mp)->m_sb.sb_inodelog))) | 49 | { |
76 | #endif | 50 | return (xfs_dinode_t *) |
51 | (xfs_buf_offset(b, o << (mp)->m_sb.sb_inodelog)); | ||
52 | } | ||
77 | 53 | ||
78 | /* | 54 | /* |
79 | * Find a free (set) bit in the inode bitmask. | 55 | * Find a free (set) bit in the inode bitmask. |
80 | */ | 56 | */ |
81 | #if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_IALLOC_FIND_FREE) | ||
82 | int xfs_ialloc_find_free(xfs_inofree_t *fp); | ||
83 | #define XFS_IALLOC_FIND_FREE(fp) xfs_ialloc_find_free(fp) | 57 | #define XFS_IALLOC_FIND_FREE(fp) xfs_ialloc_find_free(fp) |
84 | #else | 58 | static inline int xfs_ialloc_find_free(xfs_inofree_t *fp) |
85 | #define XFS_IALLOC_FIND_FREE(fp) xfs_lowbit64(*(fp)) | 59 | { |
86 | #endif | 60 | return xfs_lowbit64(*fp); |
61 | } | ||
87 | 62 | ||
88 | 63 | ||
89 | #ifdef __KERNEL__ | 64 | #ifdef __KERNEL__ |
90 | |||
91 | /* | ||
92 | * Prototypes for visible xfs_ialloc.c routines. | ||
93 | */ | ||
94 | |||
95 | /* | 65 | /* |
96 | * Allocate an inode on disk. | 66 | * Allocate an inode on disk. |
97 | * Mode is used to tell whether the new inode will need space, and whether | 67 | * Mode is used to tell whether the new inode will need space, and whether |
diff --git a/fs/xfs/xfs_ialloc_btree.c b/fs/xfs/xfs_ialloc_btree.c index 2d4daecec990..60c65683462d 100644 --- a/fs/xfs/xfs_ialloc_btree.c +++ b/fs/xfs/xfs_ialloc_btree.c | |||
@@ -1,63 +1,46 @@ | |||
1 | /* | 1 | /* |
2 | * Copyright (c) 2000-2001 Silicon Graphics, Inc. All Rights Reserved. | 2 | * Copyright (c) 2000-2001,2005 Silicon Graphics, Inc. |
3 | * All Rights Reserved. | ||
3 | * | 4 | * |
4 | * This program is free software; you can redistribute it and/or modify it | 5 | * This program is free software; you can redistribute it and/or |
5 | * under the terms of version 2 of the GNU General Public License as | 6 | * modify it under the terms of the GNU General Public License as |
6 | * published by the Free Software Foundation. | 7 | * published by the Free Software Foundation. |
7 | * | 8 | * |
8 | * This program is distributed in the hope that it would be useful, but | 9 | * This program is distributed in the hope that it would be useful, |
9 | * WITHOUT ANY WARRANTY; without even the implied warranty of | 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
12 | * GNU General Public License for more details. | ||
11 | * | 13 | * |
12 | * Further, this software is distributed without any warranty that it is | 14 | * You should have received a copy of the GNU General Public License |
13 | * free of the rightful claim of any third person regarding infringement | 15 | * along with this program; if not, write the Free Software Foundation, |
14 | * or the like. Any license provided herein, whether implied or | 16 | * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
15 | * otherwise, applies only to this software file. Patent licenses, if | ||
16 | * any, provided herein do not apply to combinations of this program with | ||
17 | * other software, or any other product whatsoever. | ||
18 | * | ||
19 | * You should have received a copy of the GNU General Public License along | ||
20 | * with this program; if not, write the Free Software Foundation, Inc., 59 | ||
21 | * Temple Place - Suite 330, Boston MA 02111-1307, USA. | ||
22 | * | ||
23 | * Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy, | ||
24 | * Mountain View, CA 94043, or: | ||
25 | * | ||
26 | * http://www.sgi.com | ||
27 | * | ||
28 | * For further information regarding this notice, see: | ||
29 | * | ||
30 | * http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/ | ||
31 | */ | 17 | */ |
32 | |||
33 | #include "xfs.h" | 18 | #include "xfs.h" |
34 | 19 | #include "xfs_fs.h" | |
35 | #include "xfs_macros.h" | ||
36 | #include "xfs_types.h" | 20 | #include "xfs_types.h" |
37 | #include "xfs_inum.h" | 21 | #include "xfs_bit.h" |
38 | #include "xfs_log.h" | 22 | #include "xfs_log.h" |
23 | #include "xfs_inum.h" | ||
39 | #include "xfs_trans.h" | 24 | #include "xfs_trans.h" |
40 | #include "xfs_sb.h" | 25 | #include "xfs_sb.h" |
41 | #include "xfs_ag.h" | 26 | #include "xfs_ag.h" |
42 | #include "xfs_dir.h" | 27 | #include "xfs_dir.h" |
28 | #include "xfs_dir2.h" | ||
43 | #include "xfs_dmapi.h" | 29 | #include "xfs_dmapi.h" |
44 | #include "xfs_mount.h" | 30 | #include "xfs_mount.h" |
45 | #include "xfs_alloc_btree.h" | ||
46 | #include "xfs_bmap_btree.h" | 31 | #include "xfs_bmap_btree.h" |
32 | #include "xfs_alloc_btree.h" | ||
47 | #include "xfs_ialloc_btree.h" | 33 | #include "xfs_ialloc_btree.h" |
34 | #include "xfs_dir_sf.h" | ||
35 | #include "xfs_dir2_sf.h" | ||
36 | #include "xfs_attr_sf.h" | ||
37 | #include "xfs_dinode.h" | ||
38 | #include "xfs_inode.h" | ||
48 | #include "xfs_btree.h" | 39 | #include "xfs_btree.h" |
49 | #include "xfs_ialloc.h" | 40 | #include "xfs_ialloc.h" |
50 | #include "xfs_alloc.h" | 41 | #include "xfs_alloc.h" |
51 | #include "xfs_error.h" | 42 | #include "xfs_error.h" |
52 | 43 | ||
53 | /* | ||
54 | * Inode allocation management for XFS. | ||
55 | */ | ||
56 | |||
57 | /* | ||
58 | * Prototypes for internal functions. | ||
59 | */ | ||
60 | |||
61 | STATIC void xfs_inobt_log_block(xfs_trans_t *, xfs_buf_t *, int); | 44 | STATIC void xfs_inobt_log_block(xfs_trans_t *, xfs_buf_t *, int); |
62 | STATIC void xfs_inobt_log_keys(xfs_btree_cur_t *, xfs_buf_t *, int, int); | 45 | STATIC void xfs_inobt_log_keys(xfs_btree_cur_t *, xfs_buf_t *, int, int); |
63 | STATIC void xfs_inobt_log_ptrs(xfs_btree_cur_t *, xfs_buf_t *, int, int); | 46 | STATIC void xfs_inobt_log_ptrs(xfs_btree_cur_t *, xfs_buf_t *, int, int); |
@@ -70,10 +53,6 @@ STATIC int xfs_inobt_split(xfs_btree_cur_t *, int, xfs_agblock_t *, | |||
70 | STATIC int xfs_inobt_updkey(xfs_btree_cur_t *, xfs_inobt_key_t *, int); | 53 | STATIC int xfs_inobt_updkey(xfs_btree_cur_t *, xfs_inobt_key_t *, int); |
71 | 54 | ||
72 | /* | 55 | /* |
73 | * Internal functions. | ||
74 | */ | ||
75 | |||
76 | /* | ||
77 | * Single level of the xfs_inobt_delete record deletion routine. | 56 | * Single level of the xfs_inobt_delete record deletion routine. |
78 | * Delete record pointed to by cur/level. | 57 | * Delete record pointed to by cur/level. |
79 | * Remove the record from its block then rebalance the tree. | 58 | * Remove the record from its block then rebalance the tree. |
@@ -139,7 +118,7 @@ xfs_inobt_delrec( | |||
139 | * Fail if we're off the end of the block. | 118 | * Fail if we're off the end of the block. |
140 | */ | 119 | */ |
141 | 120 | ||
142 | numrecs = INT_GET(block->bb_numrecs, ARCH_CONVERT); | 121 | numrecs = be16_to_cpu(block->bb_numrecs); |
143 | if (ptr > numrecs) { | 122 | if (ptr > numrecs) { |
144 | *stat = 0; | 123 | *stat = 0; |
145 | return 0; | 124 | return 0; |
@@ -154,7 +133,7 @@ xfs_inobt_delrec( | |||
154 | pp = XFS_INOBT_PTR_ADDR(block, 1, cur); | 133 | pp = XFS_INOBT_PTR_ADDR(block, 1, cur); |
155 | #ifdef DEBUG | 134 | #ifdef DEBUG |
156 | for (i = ptr; i < numrecs; i++) { | 135 | for (i = ptr; i < numrecs; i++) { |
157 | if ((error = xfs_btree_check_sptr(cur, INT_GET(pp[i], ARCH_CONVERT), level))) | 136 | if ((error = xfs_btree_check_sptr(cur, be32_to_cpu(pp[i]), level))) |
158 | return error; | 137 | return error; |
159 | } | 138 | } |
160 | #endif | 139 | #endif |
@@ -191,7 +170,7 @@ xfs_inobt_delrec( | |||
191 | * Decrement and log the number of entries in the block. | 170 | * Decrement and log the number of entries in the block. |
192 | */ | 171 | */ |
193 | numrecs--; | 172 | numrecs--; |
194 | INT_SET(block->bb_numrecs, ARCH_CONVERT, numrecs); | 173 | block->bb_numrecs = cpu_to_be16(numrecs); |
195 | xfs_inobt_log_block(cur->bc_tp, bp, XFS_BB_NUMRECS); | 174 | xfs_inobt_log_block(cur->bc_tp, bp, XFS_BB_NUMRECS); |
196 | /* | 175 | /* |
197 | * Is this the root level? If so, we're almost done. | 176 | * Is this the root level? If so, we're almost done. |
@@ -210,9 +189,9 @@ xfs_inobt_delrec( | |||
210 | * pp is still set to the first pointer in the block. | 189 | * pp is still set to the first pointer in the block. |
211 | * Make it the new root of the btree. | 190 | * Make it the new root of the btree. |
212 | */ | 191 | */ |
213 | bno = INT_GET(agi->agi_root, ARCH_CONVERT); | 192 | bno = be32_to_cpu(agi->agi_root); |
214 | agi->agi_root = *pp; | 193 | agi->agi_root = *pp; |
215 | INT_MOD(agi->agi_level, ARCH_CONVERT, -1); | 194 | be32_add(&agi->agi_level, -1); |
216 | /* | 195 | /* |
217 | * Free the block. | 196 | * Free the block. |
218 | */ | 197 | */ |
@@ -255,8 +234,8 @@ xfs_inobt_delrec( | |||
255 | * tree balanced. Look at the left and right sibling blocks to | 234 | * tree balanced. Look at the left and right sibling blocks to |
256 | * see if we can re-balance by moving only one record. | 235 | * see if we can re-balance by moving only one record. |
257 | */ | 236 | */ |
258 | rbno = INT_GET(block->bb_rightsib, ARCH_CONVERT); | 237 | rbno = be32_to_cpu(block->bb_rightsib); |
259 | lbno = INT_GET(block->bb_leftsib, ARCH_CONVERT); | 238 | lbno = be32_to_cpu(block->bb_leftsib); |
260 | bno = NULLAGBLOCK; | 239 | bno = NULLAGBLOCK; |
261 | ASSERT(rbno != NULLAGBLOCK || lbno != NULLAGBLOCK); | 240 | ASSERT(rbno != NULLAGBLOCK || lbno != NULLAGBLOCK); |
262 | /* | 241 | /* |
@@ -293,18 +272,18 @@ xfs_inobt_delrec( | |||
293 | /* | 272 | /* |
294 | * Grab the current block number, for future use. | 273 | * Grab the current block number, for future use. |
295 | */ | 274 | */ |
296 | bno = INT_GET(right->bb_leftsib, ARCH_CONVERT); | 275 | bno = be32_to_cpu(right->bb_leftsib); |
297 | /* | 276 | /* |
298 | * If right block is full enough so that removing one entry | 277 | * If right block is full enough so that removing one entry |
299 | * won't make it too empty, and left-shifting an entry out | 278 | * won't make it too empty, and left-shifting an entry out |
300 | * of right to us works, we're done. | 279 | * of right to us works, we're done. |
301 | */ | 280 | */ |
302 | if (INT_GET(right->bb_numrecs, ARCH_CONVERT) - 1 >= | 281 | if (be16_to_cpu(right->bb_numrecs) - 1 >= |
303 | XFS_INOBT_BLOCK_MINRECS(level, cur)) { | 282 | XFS_INOBT_BLOCK_MINRECS(level, cur)) { |
304 | if ((error = xfs_inobt_lshift(tcur, level, &i))) | 283 | if ((error = xfs_inobt_lshift(tcur, level, &i))) |
305 | goto error0; | 284 | goto error0; |
306 | if (i) { | 285 | if (i) { |
307 | ASSERT(INT_GET(block->bb_numrecs, ARCH_CONVERT) >= | 286 | ASSERT(be16_to_cpu(block->bb_numrecs) >= |
308 | XFS_INOBT_BLOCK_MINRECS(level, cur)); | 287 | XFS_INOBT_BLOCK_MINRECS(level, cur)); |
309 | xfs_btree_del_cursor(tcur, | 288 | xfs_btree_del_cursor(tcur, |
310 | XFS_BTREE_NOERROR); | 289 | XFS_BTREE_NOERROR); |
@@ -321,7 +300,7 @@ xfs_inobt_delrec( | |||
321 | * future reference, and fix up the temp cursor to point | 300 | * future reference, and fix up the temp cursor to point |
322 | * to our block again (last record). | 301 | * to our block again (last record). |
323 | */ | 302 | */ |
324 | rrecs = INT_GET(right->bb_numrecs, ARCH_CONVERT); | 303 | rrecs = be16_to_cpu(right->bb_numrecs); |
325 | if (lbno != NULLAGBLOCK) { | 304 | if (lbno != NULLAGBLOCK) { |
326 | xfs_btree_firstrec(tcur, level); | 305 | xfs_btree_firstrec(tcur, level); |
327 | if ((error = xfs_inobt_decrement(tcur, level, &i))) | 306 | if ((error = xfs_inobt_decrement(tcur, level, &i))) |
@@ -353,18 +332,18 @@ xfs_inobt_delrec( | |||
353 | /* | 332 | /* |
354 | * Grab the current block number, for future use. | 333 | * Grab the current block number, for future use. |
355 | */ | 334 | */ |
356 | bno = INT_GET(left->bb_rightsib, ARCH_CONVERT); | 335 | bno = be32_to_cpu(left->bb_rightsib); |
357 | /* | 336 | /* |
358 | * If left block is full enough so that removing one entry | 337 | * If left block is full enough so that removing one entry |
359 | * won't make it too empty, and right-shifting an entry out | 338 | * won't make it too empty, and right-shifting an entry out |
360 | * of left to us works, we're done. | 339 | * of left to us works, we're done. |
361 | */ | 340 | */ |
362 | if (INT_GET(left->bb_numrecs, ARCH_CONVERT) - 1 >= | 341 | if (be16_to_cpu(left->bb_numrecs) - 1 >= |
363 | XFS_INOBT_BLOCK_MINRECS(level, cur)) { | 342 | XFS_INOBT_BLOCK_MINRECS(level, cur)) { |
364 | if ((error = xfs_inobt_rshift(tcur, level, &i))) | 343 | if ((error = xfs_inobt_rshift(tcur, level, &i))) |
365 | goto error0; | 344 | goto error0; |
366 | if (i) { | 345 | if (i) { |
367 | ASSERT(INT_GET(block->bb_numrecs, ARCH_CONVERT) >= | 346 | ASSERT(be16_to_cpu(block->bb_numrecs) >= |
368 | XFS_INOBT_BLOCK_MINRECS(level, cur)); | 347 | XFS_INOBT_BLOCK_MINRECS(level, cur)); |
369 | xfs_btree_del_cursor(tcur, | 348 | xfs_btree_del_cursor(tcur, |
370 | XFS_BTREE_NOERROR); | 349 | XFS_BTREE_NOERROR); |
@@ -378,7 +357,7 @@ xfs_inobt_delrec( | |||
378 | * Otherwise, grab the number of records in right for | 357 | * Otherwise, grab the number of records in right for |
379 | * future reference. | 358 | * future reference. |
380 | */ | 359 | */ |
381 | lrecs = INT_GET(left->bb_numrecs, ARCH_CONVERT); | 360 | lrecs = be16_to_cpu(left->bb_numrecs); |
382 | } | 361 | } |
383 | /* | 362 | /* |
384 | * Delete the temp cursor, we're done with it. | 363 | * Delete the temp cursor, we're done with it. |
@@ -399,14 +378,14 @@ xfs_inobt_delrec( | |||
399 | */ | 378 | */ |
400 | rbno = bno; | 379 | rbno = bno; |
401 | right = block; | 380 | right = block; |
402 | rrecs = INT_GET(right->bb_numrecs, ARCH_CONVERT); | 381 | rrecs = be16_to_cpu(right->bb_numrecs); |
403 | rbp = bp; | 382 | rbp = bp; |
404 | if ((error = xfs_btree_read_bufs(mp, cur->bc_tp, | 383 | if ((error = xfs_btree_read_bufs(mp, cur->bc_tp, |
405 | cur->bc_private.i.agno, lbno, 0, &lbp, | 384 | cur->bc_private.i.agno, lbno, 0, &lbp, |
406 | XFS_INO_BTREE_REF))) | 385 | XFS_INO_BTREE_REF))) |
407 | return error; | 386 | return error; |
408 | left = XFS_BUF_TO_INOBT_BLOCK(lbp); | 387 | left = XFS_BUF_TO_INOBT_BLOCK(lbp); |
409 | lrecs = INT_GET(left->bb_numrecs, ARCH_CONVERT); | 388 | lrecs = be16_to_cpu(left->bb_numrecs); |
410 | if ((error = xfs_btree_check_sblock(cur, left, level, lbp))) | 389 | if ((error = xfs_btree_check_sblock(cur, left, level, lbp))) |
411 | return error; | 390 | return error; |
412 | } | 391 | } |
@@ -421,14 +400,14 @@ xfs_inobt_delrec( | |||
421 | */ | 400 | */ |
422 | lbno = bno; | 401 | lbno = bno; |
423 | left = block; | 402 | left = block; |
424 | lrecs = INT_GET(left->bb_numrecs, ARCH_CONVERT); | 403 | lrecs = be16_to_cpu(left->bb_numrecs); |
425 | lbp = bp; | 404 | lbp = bp; |
426 | if ((error = xfs_btree_read_bufs(mp, cur->bc_tp, | 405 | if ((error = xfs_btree_read_bufs(mp, cur->bc_tp, |
427 | cur->bc_private.i.agno, rbno, 0, &rbp, | 406 | cur->bc_private.i.agno, rbno, 0, &rbp, |
428 | XFS_INO_BTREE_REF))) | 407 | XFS_INO_BTREE_REF))) |
429 | return error; | 408 | return error; |
430 | right = XFS_BUF_TO_INOBT_BLOCK(rbp); | 409 | right = XFS_BUF_TO_INOBT_BLOCK(rbp); |
431 | rrecs = INT_GET(right->bb_numrecs, ARCH_CONVERT); | 410 | rrecs = be16_to_cpu(right->bb_numrecs); |
432 | if ((error = xfs_btree_check_sblock(cur, right, level, rbp))) | 411 | if ((error = xfs_btree_check_sblock(cur, right, level, rbp))) |
433 | return error; | 412 | return error; |
434 | } | 413 | } |
@@ -456,7 +435,7 @@ xfs_inobt_delrec( | |||
456 | rpp = XFS_INOBT_PTR_ADDR(right, 1, cur); | 435 | rpp = XFS_INOBT_PTR_ADDR(right, 1, cur); |
457 | #ifdef DEBUG | 436 | #ifdef DEBUG |
458 | for (i = 0; i < rrecs; i++) { | 437 | for (i = 0; i < rrecs; i++) { |
459 | if ((error = xfs_btree_check_sptr(cur, INT_GET(rpp[i], ARCH_CONVERT), level))) | 438 | if ((error = xfs_btree_check_sptr(cur, be32_to_cpu(rpp[i]), level))) |
460 | return error; | 439 | return error; |
461 | } | 440 | } |
462 | #endif | 441 | #endif |
@@ -492,7 +471,7 @@ xfs_inobt_delrec( | |||
492 | * Fix up the number of records in the surviving block. | 471 | * Fix up the number of records in the surviving block. |
493 | */ | 472 | */ |
494 | lrecs += rrecs; | 473 | lrecs += rrecs; |
495 | INT_SET(left->bb_numrecs, ARCH_CONVERT, lrecs); | 474 | left->bb_numrecs = cpu_to_be16(lrecs); |
496 | /* | 475 | /* |
497 | * Fix up the right block pointer in the surviving block, and log it. | 476 | * Fix up the right block pointer in the surviving block, and log it. |
498 | */ | 477 | */ |
@@ -502,18 +481,18 @@ xfs_inobt_delrec( | |||
502 | * If there is a right sibling now, make it point to the | 481 | * If there is a right sibling now, make it point to the |
503 | * remaining block. | 482 | * remaining block. |
504 | */ | 483 | */ |
505 | if (INT_GET(left->bb_rightsib, ARCH_CONVERT) != NULLAGBLOCK) { | 484 | if (be32_to_cpu(left->bb_rightsib) != NULLAGBLOCK) { |
506 | xfs_inobt_block_t *rrblock; | 485 | xfs_inobt_block_t *rrblock; |
507 | xfs_buf_t *rrbp; | 486 | xfs_buf_t *rrbp; |
508 | 487 | ||
509 | if ((error = xfs_btree_read_bufs(mp, cur->bc_tp, | 488 | if ((error = xfs_btree_read_bufs(mp, cur->bc_tp, |
510 | cur->bc_private.i.agno, INT_GET(left->bb_rightsib, ARCH_CONVERT), 0, | 489 | cur->bc_private.i.agno, be32_to_cpu(left->bb_rightsib), 0, |
511 | &rrbp, XFS_INO_BTREE_REF))) | 490 | &rrbp, XFS_INO_BTREE_REF))) |
512 | return error; | 491 | return error; |
513 | rrblock = XFS_BUF_TO_INOBT_BLOCK(rrbp); | 492 | rrblock = XFS_BUF_TO_INOBT_BLOCK(rrbp); |
514 | if ((error = xfs_btree_check_sblock(cur, rrblock, level, rrbp))) | 493 | if ((error = xfs_btree_check_sblock(cur, rrblock, level, rrbp))) |
515 | return error; | 494 | return error; |
516 | INT_SET(rrblock->bb_leftsib, ARCH_CONVERT, lbno); | 495 | rrblock->bb_leftsib = cpu_to_be32(lbno); |
517 | xfs_inobt_log_block(cur->bc_tp, rrbp, XFS_BB_LEFTSIB); | 496 | xfs_inobt_log_block(cur->bc_tp, rrbp, XFS_BB_LEFTSIB); |
518 | } | 497 | } |
519 | /* | 498 | /* |
@@ -572,6 +551,13 @@ xfs_inobt_insrec( | |||
572 | xfs_inobt_rec_t *rp=NULL; /* pointer to btree records */ | 551 | xfs_inobt_rec_t *rp=NULL; /* pointer to btree records */ |
573 | 552 | ||
574 | /* | 553 | /* |
554 | * GCC doesn't understand the (arguably complex) control flow in | ||
555 | * this function and complains about uninitialized structure fields | ||
556 | * without this. | ||
557 | */ | ||
558 | memset(&nrec, 0, sizeof(nrec)); | ||
559 | |||
560 | /* | ||
575 | * If we made it to the root level, allocate a new root block | 561 | * If we made it to the root level, allocate a new root block |
576 | * and we're done. | 562 | * and we're done. |
577 | */ | 563 | */ |
@@ -598,7 +584,7 @@ xfs_inobt_insrec( | |||
598 | */ | 584 | */ |
599 | bp = cur->bc_bufs[level]; | 585 | bp = cur->bc_bufs[level]; |
600 | block = XFS_BUF_TO_INOBT_BLOCK(bp); | 586 | block = XFS_BUF_TO_INOBT_BLOCK(bp); |
601 | numrecs = INT_GET(block->bb_numrecs, ARCH_CONVERT); | 587 | numrecs = be16_to_cpu(block->bb_numrecs); |
602 | #ifdef DEBUG | 588 | #ifdef DEBUG |
603 | if ((error = xfs_btree_check_sblock(cur, block, level, bp))) | 589 | if ((error = xfs_btree_check_sblock(cur, block, level, bp))) |
604 | return error; | 590 | return error; |
@@ -672,7 +658,7 @@ xfs_inobt_insrec( | |||
672 | * At this point we know there's room for our new entry in the block | 658 | * At this point we know there's room for our new entry in the block |
673 | * we're pointing at. | 659 | * we're pointing at. |
674 | */ | 660 | */ |
675 | numrecs = INT_GET(block->bb_numrecs, ARCH_CONVERT); | 661 | numrecs = be16_to_cpu(block->bb_numrecs); |
676 | if (level > 0) { | 662 | if (level > 0) { |
677 | /* | 663 | /* |
678 | * It's a non-leaf entry. Make a hole for the new data | 664 | * It's a non-leaf entry. Make a hole for the new data |
@@ -682,7 +668,7 @@ xfs_inobt_insrec( | |||
682 | pp = XFS_INOBT_PTR_ADDR(block, 1, cur); | 668 | pp = XFS_INOBT_PTR_ADDR(block, 1, cur); |
683 | #ifdef DEBUG | 669 | #ifdef DEBUG |
684 | for (i = numrecs; i >= ptr; i--) { | 670 | for (i = numrecs; i >= ptr; i--) { |
685 | if ((error = xfs_btree_check_sptr(cur, INT_GET(pp[i - 1], ARCH_CONVERT), level))) | 671 | if ((error = xfs_btree_check_sptr(cur, be32_to_cpu(pp[i - 1]), level))) |
686 | return error; | 672 | return error; |
687 | } | 673 | } |
688 | #endif | 674 | #endif |
@@ -698,9 +684,9 @@ xfs_inobt_insrec( | |||
698 | return error; | 684 | return error; |
699 | #endif | 685 | #endif |
700 | kp[ptr - 1] = key; /* INT_: struct copy */ | 686 | kp[ptr - 1] = key; /* INT_: struct copy */ |
701 | INT_SET(pp[ptr - 1], ARCH_CONVERT, *bnop); | 687 | pp[ptr - 1] = cpu_to_be32(*bnop); |
702 | numrecs++; | 688 | numrecs++; |
703 | INT_SET(block->bb_numrecs, ARCH_CONVERT, numrecs); | 689 | block->bb_numrecs = cpu_to_be16(numrecs); |
704 | xfs_inobt_log_keys(cur, bp, ptr, numrecs); | 690 | xfs_inobt_log_keys(cur, bp, ptr, numrecs); |
705 | xfs_inobt_log_ptrs(cur, bp, ptr, numrecs); | 691 | xfs_inobt_log_ptrs(cur, bp, ptr, numrecs); |
706 | } else { | 692 | } else { |
@@ -716,7 +702,7 @@ xfs_inobt_insrec( | |||
716 | */ | 702 | */ |
717 | rp[ptr - 1] = *recp; /* INT_: struct copy */ | 703 | rp[ptr - 1] = *recp; /* INT_: struct copy */ |
718 | numrecs++; | 704 | numrecs++; |
719 | INT_SET(block->bb_numrecs, ARCH_CONVERT, numrecs); | 705 | block->bb_numrecs = cpu_to_be16(numrecs); |
720 | xfs_inobt_log_recs(cur, bp, ptr, numrecs); | 706 | xfs_inobt_log_recs(cur, bp, ptr, numrecs); |
721 | } | 707 | } |
722 | /* | 708 | /* |
@@ -871,8 +857,8 @@ xfs_inobt_lookup( | |||
871 | xfs_agi_t *agi; /* a.g. inode header */ | 857 | xfs_agi_t *agi; /* a.g. inode header */ |
872 | 858 | ||
873 | agi = XFS_BUF_TO_AGI(cur->bc_private.i.agbp); | 859 | agi = XFS_BUF_TO_AGI(cur->bc_private.i.agbp); |
874 | agno = INT_GET(agi->agi_seqno, ARCH_CONVERT); | 860 | agno = be32_to_cpu(agi->agi_seqno); |
875 | agbno = INT_GET(agi->agi_root, ARCH_CONVERT); | 861 | agbno = be32_to_cpu(agi->agi_root); |
876 | } | 862 | } |
877 | /* | 863 | /* |
878 | * Iterate over each level in the btree, starting at the root. | 864 | * Iterate over each level in the btree, starting at the root. |
@@ -939,7 +925,7 @@ xfs_inobt_lookup( | |||
939 | * Set low and high entry numbers, 1-based. | 925 | * Set low and high entry numbers, 1-based. |
940 | */ | 926 | */ |
941 | low = 1; | 927 | low = 1; |
942 | if (!(high = INT_GET(block->bb_numrecs, ARCH_CONVERT))) { | 928 | if (!(high = be16_to_cpu(block->bb_numrecs))) { |
943 | /* | 929 | /* |
944 | * If the block is empty, the tree must | 930 | * If the block is empty, the tree must |
945 | * be an empty leaf. | 931 | * be an empty leaf. |
@@ -1006,7 +992,7 @@ xfs_inobt_lookup( | |||
1006 | */ | 992 | */ |
1007 | if (diff > 0 && --keyno < 1) | 993 | if (diff > 0 && --keyno < 1) |
1008 | keyno = 1; | 994 | keyno = 1; |
1009 | agbno = INT_GET(*XFS_INOBT_PTR_ADDR(block, keyno, cur), ARCH_CONVERT); | 995 | agbno = be32_to_cpu(*XFS_INOBT_PTR_ADDR(block, keyno, cur)); |
1010 | #ifdef DEBUG | 996 | #ifdef DEBUG |
1011 | if ((error = xfs_btree_check_sptr(cur, agbno, level))) | 997 | if ((error = xfs_btree_check_sptr(cur, agbno, level))) |
1012 | return error; | 998 | return error; |
@@ -1025,8 +1011,8 @@ xfs_inobt_lookup( | |||
1025 | * not the last block, we're in the wrong block. | 1011 | * not the last block, we're in the wrong block. |
1026 | */ | 1012 | */ |
1027 | if (dir == XFS_LOOKUP_GE && | 1013 | if (dir == XFS_LOOKUP_GE && |
1028 | keyno > INT_GET(block->bb_numrecs, ARCH_CONVERT) && | 1014 | keyno > be16_to_cpu(block->bb_numrecs) && |
1029 | INT_GET(block->bb_rightsib, ARCH_CONVERT) != NULLAGBLOCK) { | 1015 | be32_to_cpu(block->bb_rightsib) != NULLAGBLOCK) { |
1030 | int i; | 1016 | int i; |
1031 | 1017 | ||
1032 | cur->bc_ptrs[0] = keyno; | 1018 | cur->bc_ptrs[0] = keyno; |
@@ -1043,7 +1029,7 @@ xfs_inobt_lookup( | |||
1043 | /* | 1029 | /* |
1044 | * Return if we succeeded or not. | 1030 | * Return if we succeeded or not. |
1045 | */ | 1031 | */ |
1046 | if (keyno == 0 || keyno > INT_GET(block->bb_numrecs, ARCH_CONVERT)) | 1032 | if (keyno == 0 || keyno > be16_to_cpu(block->bb_numrecs)) |
1047 | *stat = 0; | 1033 | *stat = 0; |
1048 | else | 1034 | else |
1049 | *stat = ((dir != XFS_LOOKUP_EQ) || (diff == 0)); | 1035 | *stat = ((dir != XFS_LOOKUP_EQ) || (diff == 0)); |
@@ -1089,7 +1075,7 @@ xfs_inobt_lshift( | |||
1089 | /* | 1075 | /* |
1090 | * If we've got no left sibling then we can't shift an entry left. | 1076 | * If we've got no left sibling then we can't shift an entry left. |
1091 | */ | 1077 | */ |
1092 | if (INT_GET(right->bb_leftsib, ARCH_CONVERT) == NULLAGBLOCK) { | 1078 | if (be32_to_cpu(right->bb_leftsib) == NULLAGBLOCK) { |
1093 | *stat = 0; | 1079 | *stat = 0; |
1094 | return 0; | 1080 | return 0; |
1095 | } | 1081 | } |
@@ -1105,8 +1091,8 @@ xfs_inobt_lshift( | |||
1105 | * Set up the left neighbor as "left". | 1091 | * Set up the left neighbor as "left". |
1106 | */ | 1092 | */ |
1107 | if ((error = xfs_btree_read_bufs(cur->bc_mp, cur->bc_tp, | 1093 | if ((error = xfs_btree_read_bufs(cur->bc_mp, cur->bc_tp, |
1108 | cur->bc_private.i.agno, INT_GET(right->bb_leftsib, ARCH_CONVERT), 0, &lbp, | 1094 | cur->bc_private.i.agno, be32_to_cpu(right->bb_leftsib), |
1109 | XFS_INO_BTREE_REF))) | 1095 | 0, &lbp, XFS_INO_BTREE_REF))) |
1110 | return error; | 1096 | return error; |
1111 | left = XFS_BUF_TO_INOBT_BLOCK(lbp); | 1097 | left = XFS_BUF_TO_INOBT_BLOCK(lbp); |
1112 | if ((error = xfs_btree_check_sblock(cur, left, level, lbp))) | 1098 | if ((error = xfs_btree_check_sblock(cur, left, level, lbp))) |
@@ -1114,11 +1100,11 @@ xfs_inobt_lshift( | |||
1114 | /* | 1100 | /* |
1115 | * If it's full, it can't take another entry. | 1101 | * If it's full, it can't take another entry. |
1116 | */ | 1102 | */ |
1117 | if (INT_GET(left->bb_numrecs, ARCH_CONVERT) == XFS_INOBT_BLOCK_MAXRECS(level, cur)) { | 1103 | if (be16_to_cpu(left->bb_numrecs) == XFS_INOBT_BLOCK_MAXRECS(level, cur)) { |
1118 | *stat = 0; | 1104 | *stat = 0; |
1119 | return 0; | 1105 | return 0; |
1120 | } | 1106 | } |
1121 | nrec = INT_GET(left->bb_numrecs, ARCH_CONVERT) + 1; | 1107 | nrec = be16_to_cpu(left->bb_numrecs) + 1; |
1122 | /* | 1108 | /* |
1123 | * If non-leaf, copy a key and a ptr to the left block. | 1109 | * If non-leaf, copy a key and a ptr to the left block. |
1124 | */ | 1110 | */ |
@@ -1130,7 +1116,7 @@ xfs_inobt_lshift( | |||
1130 | lpp = XFS_INOBT_PTR_ADDR(left, nrec, cur); | 1116 | lpp = XFS_INOBT_PTR_ADDR(left, nrec, cur); |
1131 | rpp = XFS_INOBT_PTR_ADDR(right, 1, cur); | 1117 | rpp = XFS_INOBT_PTR_ADDR(right, 1, cur); |
1132 | #ifdef DEBUG | 1118 | #ifdef DEBUG |
1133 | if ((error = xfs_btree_check_sptr(cur, INT_GET(*rpp, ARCH_CONVERT), level))) | 1119 | if ((error = xfs_btree_check_sptr(cur, be32_to_cpu(*rpp), level))) |
1134 | return error; | 1120 | return error; |
1135 | #endif | 1121 | #endif |
1136 | *lpp = *rpp; /* INT_: no-change copy */ | 1122 | *lpp = *rpp; /* INT_: no-change copy */ |
@@ -1148,7 +1134,7 @@ xfs_inobt_lshift( | |||
1148 | /* | 1134 | /* |
1149 | * Bump and log left's numrecs, decrement and log right's numrecs. | 1135 | * Bump and log left's numrecs, decrement and log right's numrecs. |
1150 | */ | 1136 | */ |
1151 | INT_MOD(left->bb_numrecs, ARCH_CONVERT, +1); | 1137 | be16_add(&left->bb_numrecs, 1); |
1152 | xfs_inobt_log_block(cur->bc_tp, lbp, XFS_BB_NUMRECS); | 1138 | xfs_inobt_log_block(cur->bc_tp, lbp, XFS_BB_NUMRECS); |
1153 | #ifdef DEBUG | 1139 | #ifdef DEBUG |
1154 | if (level > 0) | 1140 | if (level > 0) |
@@ -1156,26 +1142,26 @@ xfs_inobt_lshift( | |||
1156 | else | 1142 | else |
1157 | xfs_btree_check_rec(cur->bc_btnum, lrp - 1, lrp); | 1143 | xfs_btree_check_rec(cur->bc_btnum, lrp - 1, lrp); |
1158 | #endif | 1144 | #endif |
1159 | INT_MOD(right->bb_numrecs, ARCH_CONVERT, -1); | 1145 | be16_add(&right->bb_numrecs, -1); |
1160 | xfs_inobt_log_block(cur->bc_tp, rbp, XFS_BB_NUMRECS); | 1146 | xfs_inobt_log_block(cur->bc_tp, rbp, XFS_BB_NUMRECS); |
1161 | /* | 1147 | /* |
1162 | * Slide the contents of right down one entry. | 1148 | * Slide the contents of right down one entry. |
1163 | */ | 1149 | */ |
1164 | if (level > 0) { | 1150 | if (level > 0) { |
1165 | #ifdef DEBUG | 1151 | #ifdef DEBUG |
1166 | for (i = 0; i < INT_GET(right->bb_numrecs, ARCH_CONVERT); i++) { | 1152 | for (i = 0; i < be16_to_cpu(right->bb_numrecs); i++) { |
1167 | if ((error = xfs_btree_check_sptr(cur, INT_GET(rpp[i + 1], ARCH_CONVERT), | 1153 | if ((error = xfs_btree_check_sptr(cur, be32_to_cpu(rpp[i + 1]), |
1168 | level))) | 1154 | level))) |
1169 | return error; | 1155 | return error; |
1170 | } | 1156 | } |
1171 | #endif | 1157 | #endif |
1172 | memmove(rkp, rkp + 1, INT_GET(right->bb_numrecs, ARCH_CONVERT) * sizeof(*rkp)); | 1158 | memmove(rkp, rkp + 1, be16_to_cpu(right->bb_numrecs) * sizeof(*rkp)); |
1173 | memmove(rpp, rpp + 1, INT_GET(right->bb_numrecs, ARCH_CONVERT) * sizeof(*rpp)); | 1159 | memmove(rpp, rpp + 1, be16_to_cpu(right->bb_numrecs) * sizeof(*rpp)); |
1174 | xfs_inobt_log_keys(cur, rbp, 1, INT_GET(right->bb_numrecs, ARCH_CONVERT)); | 1160 | xfs_inobt_log_keys(cur, rbp, 1, be16_to_cpu(right->bb_numrecs)); |
1175 | xfs_inobt_log_ptrs(cur, rbp, 1, INT_GET(right->bb_numrecs, ARCH_CONVERT)); | 1161 | xfs_inobt_log_ptrs(cur, rbp, 1, be16_to_cpu(right->bb_numrecs)); |
1176 | } else { | 1162 | } else { |
1177 | memmove(rrp, rrp + 1, INT_GET(right->bb_numrecs, ARCH_CONVERT) * sizeof(*rrp)); | 1163 | memmove(rrp, rrp + 1, be16_to_cpu(right->bb_numrecs) * sizeof(*rrp)); |
1178 | xfs_inobt_log_recs(cur, rbp, 1, INT_GET(right->bb_numrecs, ARCH_CONVERT)); | 1164 | xfs_inobt_log_recs(cur, rbp, 1, be16_to_cpu(right->bb_numrecs)); |
1179 | key.ir_startino = rrp->ir_startino; /* INT_: direct copy */ | 1165 | key.ir_startino = rrp->ir_startino; /* INT_: direct copy */ |
1180 | rkp = &key; | 1166 | rkp = &key; |
1181 | } | 1167 | } |
@@ -1227,7 +1213,7 @@ xfs_inobt_newroot( | |||
1227 | args.tp = cur->bc_tp; | 1213 | args.tp = cur->bc_tp; |
1228 | args.mp = cur->bc_mp; | 1214 | args.mp = cur->bc_mp; |
1229 | args.fsbno = XFS_AGB_TO_FSB(args.mp, cur->bc_private.i.agno, | 1215 | args.fsbno = XFS_AGB_TO_FSB(args.mp, cur->bc_private.i.agno, |
1230 | INT_GET(agi->agi_root, ARCH_CONVERT)); | 1216 | be32_to_cpu(agi->agi_root)); |
1231 | args.mod = args.minleft = args.alignment = args.total = args.wasdel = | 1217 | args.mod = args.minleft = args.alignment = args.total = args.wasdel = |
1232 | args.isfl = args.userdata = args.minalignslop = 0; | 1218 | args.isfl = args.userdata = args.minalignslop = 0; |
1233 | args.minlen = args.maxlen = args.prod = 1; | 1219 | args.minlen = args.maxlen = args.prod = 1; |
@@ -1247,8 +1233,8 @@ xfs_inobt_newroot( | |||
1247 | /* | 1233 | /* |
1248 | * Set the root data in the a.g. inode structure. | 1234 | * Set the root data in the a.g. inode structure. |
1249 | */ | 1235 | */ |
1250 | INT_SET(agi->agi_root, ARCH_CONVERT, args.agbno); | 1236 | agi->agi_root = cpu_to_be32(args.agbno); |
1251 | INT_MOD(agi->agi_level, ARCH_CONVERT, 1); | 1237 | be32_add(&agi->agi_level, 1); |
1252 | xfs_ialloc_log_agi(args.tp, cur->bc_private.i.agbp, | 1238 | xfs_ialloc_log_agi(args.tp, cur->bc_private.i.agbp, |
1253 | XFS_AGI_ROOT | XFS_AGI_LEVEL); | 1239 | XFS_AGI_ROOT | XFS_AGI_LEVEL); |
1254 | /* | 1240 | /* |
@@ -1263,14 +1249,14 @@ xfs_inobt_newroot( | |||
1263 | if ((error = xfs_btree_check_sblock(cur, block, cur->bc_nlevels - 1, bp))) | 1249 | if ((error = xfs_btree_check_sblock(cur, block, cur->bc_nlevels - 1, bp))) |
1264 | return error; | 1250 | return error; |
1265 | #endif | 1251 | #endif |
1266 | if (INT_GET(block->bb_rightsib, ARCH_CONVERT) != NULLAGBLOCK) { | 1252 | if (be32_to_cpu(block->bb_rightsib) != NULLAGBLOCK) { |
1267 | /* | 1253 | /* |
1268 | * Our block is left, pick up the right block. | 1254 | * Our block is left, pick up the right block. |
1269 | */ | 1255 | */ |
1270 | lbp = bp; | 1256 | lbp = bp; |
1271 | lbno = XFS_DADDR_TO_AGBNO(args.mp, XFS_BUF_ADDR(lbp)); | 1257 | lbno = XFS_DADDR_TO_AGBNO(args.mp, XFS_BUF_ADDR(lbp)); |
1272 | left = block; | 1258 | left = block; |
1273 | rbno = INT_GET(left->bb_rightsib, ARCH_CONVERT); | 1259 | rbno = be32_to_cpu(left->bb_rightsib); |
1274 | if ((error = xfs_btree_read_bufs(args.mp, args.tp, args.agno, | 1260 | if ((error = xfs_btree_read_bufs(args.mp, args.tp, args.agno, |
1275 | rbno, 0, &rbp, XFS_INO_BTREE_REF))) | 1261 | rbno, 0, &rbp, XFS_INO_BTREE_REF))) |
1276 | return error; | 1262 | return error; |
@@ -1287,7 +1273,7 @@ xfs_inobt_newroot( | |||
1287 | rbp = bp; | 1273 | rbp = bp; |
1288 | rbno = XFS_DADDR_TO_AGBNO(args.mp, XFS_BUF_ADDR(rbp)); | 1274 | rbno = XFS_DADDR_TO_AGBNO(args.mp, XFS_BUF_ADDR(rbp)); |
1289 | right = block; | 1275 | right = block; |
1290 | lbno = INT_GET(right->bb_leftsib, ARCH_CONVERT); | 1276 | lbno = be32_to_cpu(right->bb_leftsib); |
1291 | if ((error = xfs_btree_read_bufs(args.mp, args.tp, args.agno, | 1277 | if ((error = xfs_btree_read_bufs(args.mp, args.tp, args.agno, |
1292 | lbno, 0, &lbp, XFS_INO_BTREE_REF))) | 1278 | lbno, 0, &lbp, XFS_INO_BTREE_REF))) |
1293 | return error; | 1279 | return error; |
@@ -1301,18 +1287,18 @@ xfs_inobt_newroot( | |||
1301 | /* | 1287 | /* |
1302 | * Fill in the new block's btree header and log it. | 1288 | * Fill in the new block's btree header and log it. |
1303 | */ | 1289 | */ |
1304 | INT_SET(new->bb_magic, ARCH_CONVERT, xfs_magics[cur->bc_btnum]); | 1290 | new->bb_magic = cpu_to_be32(xfs_magics[cur->bc_btnum]); |
1305 | INT_SET(new->bb_level, ARCH_CONVERT, (__uint16_t)cur->bc_nlevels); | 1291 | new->bb_level = cpu_to_be16(cur->bc_nlevels); |
1306 | INT_SET(new->bb_numrecs, ARCH_CONVERT, 2); | 1292 | new->bb_numrecs = cpu_to_be16(2); |
1307 | INT_SET(new->bb_leftsib, ARCH_CONVERT, NULLAGBLOCK); | 1293 | new->bb_leftsib = cpu_to_be32(NULLAGBLOCK); |
1308 | INT_SET(new->bb_rightsib, ARCH_CONVERT, NULLAGBLOCK); | 1294 | new->bb_rightsib = cpu_to_be32(NULLAGBLOCK); |
1309 | xfs_inobt_log_block(args.tp, nbp, XFS_BB_ALL_BITS); | 1295 | xfs_inobt_log_block(args.tp, nbp, XFS_BB_ALL_BITS); |
1310 | ASSERT(lbno != NULLAGBLOCK && rbno != NULLAGBLOCK); | 1296 | ASSERT(lbno != NULLAGBLOCK && rbno != NULLAGBLOCK); |
1311 | /* | 1297 | /* |
1312 | * Fill in the key data in the new root. | 1298 | * Fill in the key data in the new root. |
1313 | */ | 1299 | */ |
1314 | kp = XFS_INOBT_KEY_ADDR(new, 1, cur); | 1300 | kp = XFS_INOBT_KEY_ADDR(new, 1, cur); |
1315 | if (INT_GET(left->bb_level, ARCH_CONVERT) > 0) { | 1301 | if (be16_to_cpu(left->bb_level) > 0) { |
1316 | kp[0] = *XFS_INOBT_KEY_ADDR(left, 1, cur); /* INT_: struct copy */ | 1302 | kp[0] = *XFS_INOBT_KEY_ADDR(left, 1, cur); /* INT_: struct copy */ |
1317 | kp[1] = *XFS_INOBT_KEY_ADDR(right, 1, cur); /* INT_: struct copy */ | 1303 | kp[1] = *XFS_INOBT_KEY_ADDR(right, 1, cur); /* INT_: struct copy */ |
1318 | } else { | 1304 | } else { |
@@ -1326,8 +1312,8 @@ xfs_inobt_newroot( | |||
1326 | * Fill in the pointer data in the new root. | 1312 | * Fill in the pointer data in the new root. |
1327 | */ | 1313 | */ |
1328 | pp = XFS_INOBT_PTR_ADDR(new, 1, cur); | 1314 | pp = XFS_INOBT_PTR_ADDR(new, 1, cur); |
1329 | INT_SET(pp[0], ARCH_CONVERT, lbno); | 1315 | pp[0] = cpu_to_be32(lbno); |
1330 | INT_SET(pp[1], ARCH_CONVERT, rbno); | 1316 | pp[1] = cpu_to_be32(rbno); |
1331 | xfs_inobt_log_ptrs(cur, nbp, 1, 2); | 1317 | xfs_inobt_log_ptrs(cur, nbp, 1, 2); |
1332 | /* | 1318 | /* |
1333 | * Fix up the cursor. | 1319 | * Fix up the cursor. |
@@ -1376,7 +1362,7 @@ xfs_inobt_rshift( | |||
1376 | /* | 1362 | /* |
1377 | * If we've got no right sibling then we can't shift an entry right. | 1363 | * If we've got no right sibling then we can't shift an entry right. |
1378 | */ | 1364 | */ |
1379 | if (INT_GET(left->bb_rightsib, ARCH_CONVERT) == NULLAGBLOCK) { | 1365 | if (be32_to_cpu(left->bb_rightsib) == NULLAGBLOCK) { |
1380 | *stat = 0; | 1366 | *stat = 0; |
1381 | return 0; | 1367 | return 0; |
1382 | } | 1368 | } |
@@ -1384,7 +1370,7 @@ xfs_inobt_rshift( | |||
1384 | * If the cursor entry is the one that would be moved, don't | 1370 | * If the cursor entry is the one that would be moved, don't |
1385 | * do it... it's too complicated. | 1371 | * do it... it's too complicated. |
1386 | */ | 1372 | */ |
1387 | if (cur->bc_ptrs[level] >= INT_GET(left->bb_numrecs, ARCH_CONVERT)) { | 1373 | if (cur->bc_ptrs[level] >= be16_to_cpu(left->bb_numrecs)) { |
1388 | *stat = 0; | 1374 | *stat = 0; |
1389 | return 0; | 1375 | return 0; |
1390 | } | 1376 | } |
@@ -1392,8 +1378,8 @@ xfs_inobt_rshift( | |||
1392 | * Set up the right neighbor as "right". | 1378 | * Set up the right neighbor as "right". |
1393 | */ | 1379 | */ |
1394 | if ((error = xfs_btree_read_bufs(cur->bc_mp, cur->bc_tp, | 1380 | if ((error = xfs_btree_read_bufs(cur->bc_mp, cur->bc_tp, |
1395 | cur->bc_private.i.agno, INT_GET(left->bb_rightsib, ARCH_CONVERT), 0, &rbp, | 1381 | cur->bc_private.i.agno, be32_to_cpu(left->bb_rightsib), |
1396 | XFS_INO_BTREE_REF))) | 1382 | 0, &rbp, XFS_INO_BTREE_REF))) |
1397 | return error; | 1383 | return error; |
1398 | right = XFS_BUF_TO_INOBT_BLOCK(rbp); | 1384 | right = XFS_BUF_TO_INOBT_BLOCK(rbp); |
1399 | if ((error = xfs_btree_check_sblock(cur, right, level, rbp))) | 1385 | if ((error = xfs_btree_check_sblock(cur, right, level, rbp))) |
@@ -1401,7 +1387,7 @@ xfs_inobt_rshift( | |||
1401 | /* | 1387 | /* |
1402 | * If it's full, it can't take another entry. | 1388 | * If it's full, it can't take another entry. |
1403 | */ | 1389 | */ |
1404 | if (INT_GET(right->bb_numrecs, ARCH_CONVERT) == XFS_INOBT_BLOCK_MAXRECS(level, cur)) { | 1390 | if (be16_to_cpu(right->bb_numrecs) == XFS_INOBT_BLOCK_MAXRECS(level, cur)) { |
1405 | *stat = 0; | 1391 | *stat = 0; |
1406 | return 0; | 1392 | return 0; |
1407 | } | 1393 | } |
@@ -1410,41 +1396,41 @@ xfs_inobt_rshift( | |||
1410 | * copy the last left block entry to the hole. | 1396 | * copy the last left block entry to the hole. |
1411 | */ | 1397 | */ |
1412 | if (level > 0) { | 1398 | if (level > 0) { |
1413 | lkp = XFS_INOBT_KEY_ADDR(left, INT_GET(left->bb_numrecs, ARCH_CONVERT), cur); | 1399 | lkp = XFS_INOBT_KEY_ADDR(left, be16_to_cpu(left->bb_numrecs), cur); |
1414 | lpp = XFS_INOBT_PTR_ADDR(left, INT_GET(left->bb_numrecs, ARCH_CONVERT), cur); | 1400 | lpp = XFS_INOBT_PTR_ADDR(left, be16_to_cpu(left->bb_numrecs), cur); |
1415 | rkp = XFS_INOBT_KEY_ADDR(right, 1, cur); | 1401 | rkp = XFS_INOBT_KEY_ADDR(right, 1, cur); |
1416 | rpp = XFS_INOBT_PTR_ADDR(right, 1, cur); | 1402 | rpp = XFS_INOBT_PTR_ADDR(right, 1, cur); |
1417 | #ifdef DEBUG | 1403 | #ifdef DEBUG |
1418 | for (i = INT_GET(right->bb_numrecs, ARCH_CONVERT) - 1; i >= 0; i--) { | 1404 | for (i = be16_to_cpu(right->bb_numrecs) - 1; i >= 0; i--) { |
1419 | if ((error = xfs_btree_check_sptr(cur, INT_GET(rpp[i], ARCH_CONVERT), level))) | 1405 | if ((error = xfs_btree_check_sptr(cur, be32_to_cpu(rpp[i]), level))) |
1420 | return error; | 1406 | return error; |
1421 | } | 1407 | } |
1422 | #endif | 1408 | #endif |
1423 | memmove(rkp + 1, rkp, INT_GET(right->bb_numrecs, ARCH_CONVERT) * sizeof(*rkp)); | 1409 | memmove(rkp + 1, rkp, be16_to_cpu(right->bb_numrecs) * sizeof(*rkp)); |
1424 | memmove(rpp + 1, rpp, INT_GET(right->bb_numrecs, ARCH_CONVERT) * sizeof(*rpp)); | 1410 | memmove(rpp + 1, rpp, be16_to_cpu(right->bb_numrecs) * sizeof(*rpp)); |
1425 | #ifdef DEBUG | 1411 | #ifdef DEBUG |
1426 | if ((error = xfs_btree_check_sptr(cur, INT_GET(*lpp, ARCH_CONVERT), level))) | 1412 | if ((error = xfs_btree_check_sptr(cur, be32_to_cpu(*lpp), level))) |
1427 | return error; | 1413 | return error; |
1428 | #endif | 1414 | #endif |
1429 | *rkp = *lkp; /* INT_: no change copy */ | 1415 | *rkp = *lkp; /* INT_: no change copy */ |
1430 | *rpp = *lpp; /* INT_: no change copy */ | 1416 | *rpp = *lpp; /* INT_: no change copy */ |
1431 | xfs_inobt_log_keys(cur, rbp, 1, INT_GET(right->bb_numrecs, ARCH_CONVERT) + 1); | 1417 | xfs_inobt_log_keys(cur, rbp, 1, be16_to_cpu(right->bb_numrecs) + 1); |
1432 | xfs_inobt_log_ptrs(cur, rbp, 1, INT_GET(right->bb_numrecs, ARCH_CONVERT) + 1); | 1418 | xfs_inobt_log_ptrs(cur, rbp, 1, be16_to_cpu(right->bb_numrecs) + 1); |
1433 | } else { | 1419 | } else { |
1434 | lrp = XFS_INOBT_REC_ADDR(left, INT_GET(left->bb_numrecs, ARCH_CONVERT), cur); | 1420 | lrp = XFS_INOBT_REC_ADDR(left, be16_to_cpu(left->bb_numrecs), cur); |
1435 | rrp = XFS_INOBT_REC_ADDR(right, 1, cur); | 1421 | rrp = XFS_INOBT_REC_ADDR(right, 1, cur); |
1436 | memmove(rrp + 1, rrp, INT_GET(right->bb_numrecs, ARCH_CONVERT) * sizeof(*rrp)); | 1422 | memmove(rrp + 1, rrp, be16_to_cpu(right->bb_numrecs) * sizeof(*rrp)); |
1437 | *rrp = *lrp; | 1423 | *rrp = *lrp; |
1438 | xfs_inobt_log_recs(cur, rbp, 1, INT_GET(right->bb_numrecs, ARCH_CONVERT) + 1); | 1424 | xfs_inobt_log_recs(cur, rbp, 1, be16_to_cpu(right->bb_numrecs) + 1); |
1439 | key.ir_startino = rrp->ir_startino; /* INT_: direct copy */ | 1425 | key.ir_startino = rrp->ir_startino; /* INT_: direct copy */ |
1440 | rkp = &key; | 1426 | rkp = &key; |
1441 | } | 1427 | } |
1442 | /* | 1428 | /* |
1443 | * Decrement and log left's numrecs, bump and log right's numrecs. | 1429 | * Decrement and log left's numrecs, bump and log right's numrecs. |
1444 | */ | 1430 | */ |
1445 | INT_MOD(left->bb_numrecs, ARCH_CONVERT, -1); | 1431 | be16_add(&left->bb_numrecs, -1); |
1446 | xfs_inobt_log_block(cur->bc_tp, lbp, XFS_BB_NUMRECS); | 1432 | xfs_inobt_log_block(cur->bc_tp, lbp, XFS_BB_NUMRECS); |
1447 | INT_MOD(right->bb_numrecs, ARCH_CONVERT, +1); | 1433 | be16_add(&right->bb_numrecs, 1); |
1448 | #ifdef DEBUG | 1434 | #ifdef DEBUG |
1449 | if (level > 0) | 1435 | if (level > 0) |
1450 | xfs_btree_check_key(cur->bc_btnum, rkp, rkp + 1); | 1436 | xfs_btree_check_key(cur->bc_btnum, rkp, rkp + 1); |
@@ -1536,17 +1522,17 @@ xfs_inobt_split( | |||
1536 | /* | 1522 | /* |
1537 | * Fill in the btree header for the new block. | 1523 | * Fill in the btree header for the new block. |
1538 | */ | 1524 | */ |
1539 | INT_SET(right->bb_magic, ARCH_CONVERT, xfs_magics[cur->bc_btnum]); | 1525 | right->bb_magic = cpu_to_be32(xfs_magics[cur->bc_btnum]); |
1540 | right->bb_level = left->bb_level; /* INT_: direct copy */ | 1526 | right->bb_level = left->bb_level; |
1541 | INT_SET(right->bb_numrecs, ARCH_CONVERT, (__uint16_t)(INT_GET(left->bb_numrecs, ARCH_CONVERT) / 2)); | 1527 | right->bb_numrecs = cpu_to_be16(be16_to_cpu(left->bb_numrecs) / 2); |
1542 | /* | 1528 | /* |
1543 | * Make sure that if there's an odd number of entries now, that | 1529 | * Make sure that if there's an odd number of entries now, that |
1544 | * each new block will have the same number of entries. | 1530 | * each new block will have the same number of entries. |
1545 | */ | 1531 | */ |
1546 | if ((INT_GET(left->bb_numrecs, ARCH_CONVERT) & 1) && | 1532 | if ((be16_to_cpu(left->bb_numrecs) & 1) && |
1547 | cur->bc_ptrs[level] <= INT_GET(right->bb_numrecs, ARCH_CONVERT) + 1) | 1533 | cur->bc_ptrs[level] <= be16_to_cpu(right->bb_numrecs) + 1) |
1548 | INT_MOD(right->bb_numrecs, ARCH_CONVERT, +1); | 1534 | be16_add(&right->bb_numrecs, 1); |
1549 | i = INT_GET(left->bb_numrecs, ARCH_CONVERT) - INT_GET(right->bb_numrecs, ARCH_CONVERT) + 1; | 1535 | i = be16_to_cpu(left->bb_numrecs) - be16_to_cpu(right->bb_numrecs) + 1; |
1550 | /* | 1536 | /* |
1551 | * For non-leaf blocks, copy keys and addresses over to the new block. | 1537 | * For non-leaf blocks, copy keys and addresses over to the new block. |
1552 | */ | 1538 | */ |
@@ -1556,15 +1542,15 @@ xfs_inobt_split( | |||
1556 | rkp = XFS_INOBT_KEY_ADDR(right, 1, cur); | 1542 | rkp = XFS_INOBT_KEY_ADDR(right, 1, cur); |
1557 | rpp = XFS_INOBT_PTR_ADDR(right, 1, cur); | 1543 | rpp = XFS_INOBT_PTR_ADDR(right, 1, cur); |
1558 | #ifdef DEBUG | 1544 | #ifdef DEBUG |
1559 | for (i = 0; i < INT_GET(right->bb_numrecs, ARCH_CONVERT); i++) { | 1545 | for (i = 0; i < be16_to_cpu(right->bb_numrecs); i++) { |
1560 | if ((error = xfs_btree_check_sptr(cur, INT_GET(lpp[i], ARCH_CONVERT), level))) | 1546 | if ((error = xfs_btree_check_sptr(cur, be32_to_cpu(lpp[i]), level))) |
1561 | return error; | 1547 | return error; |
1562 | } | 1548 | } |
1563 | #endif | 1549 | #endif |
1564 | memcpy(rkp, lkp, INT_GET(right->bb_numrecs, ARCH_CONVERT) * sizeof(*rkp)); | 1550 | memcpy(rkp, lkp, be16_to_cpu(right->bb_numrecs) * sizeof(*rkp)); |
1565 | memcpy(rpp, lpp, INT_GET(right->bb_numrecs, ARCH_CONVERT) * sizeof(*rpp)); | 1551 | memcpy(rpp, lpp, be16_to_cpu(right->bb_numrecs) * sizeof(*rpp)); |
1566 | xfs_inobt_log_keys(cur, rbp, 1, INT_GET(right->bb_numrecs, ARCH_CONVERT)); | 1552 | xfs_inobt_log_keys(cur, rbp, 1, be16_to_cpu(right->bb_numrecs)); |
1567 | xfs_inobt_log_ptrs(cur, rbp, 1, INT_GET(right->bb_numrecs, ARCH_CONVERT)); | 1553 | xfs_inobt_log_ptrs(cur, rbp, 1, be16_to_cpu(right->bb_numrecs)); |
1568 | *keyp = *rkp; | 1554 | *keyp = *rkp; |
1569 | } | 1555 | } |
1570 | /* | 1556 | /* |
@@ -1573,36 +1559,36 @@ xfs_inobt_split( | |||
1573 | else { | 1559 | else { |
1574 | lrp = XFS_INOBT_REC_ADDR(left, i, cur); | 1560 | lrp = XFS_INOBT_REC_ADDR(left, i, cur); |
1575 | rrp = XFS_INOBT_REC_ADDR(right, 1, cur); | 1561 | rrp = XFS_INOBT_REC_ADDR(right, 1, cur); |
1576 | memcpy(rrp, lrp, INT_GET(right->bb_numrecs, ARCH_CONVERT) * sizeof(*rrp)); | 1562 | memcpy(rrp, lrp, be16_to_cpu(right->bb_numrecs) * sizeof(*rrp)); |
1577 | xfs_inobt_log_recs(cur, rbp, 1, INT_GET(right->bb_numrecs, ARCH_CONVERT)); | 1563 | xfs_inobt_log_recs(cur, rbp, 1, be16_to_cpu(right->bb_numrecs)); |
1578 | keyp->ir_startino = rrp->ir_startino; /* INT_: direct copy */ | 1564 | keyp->ir_startino = rrp->ir_startino; /* INT_: direct copy */ |
1579 | } | 1565 | } |
1580 | /* | 1566 | /* |
1581 | * Find the left block number by looking in the buffer. | 1567 | * Find the left block number by looking in the buffer. |
1582 | * Adjust numrecs, sibling pointers. | 1568 | * Adjust numrecs, sibling pointers. |
1583 | */ | 1569 | */ |
1584 | INT_MOD(left->bb_numrecs, ARCH_CONVERT, -(INT_GET(right->bb_numrecs, ARCH_CONVERT))); | 1570 | be16_add(&left->bb_numrecs, -(be16_to_cpu(right->bb_numrecs))); |
1585 | right->bb_rightsib = left->bb_rightsib; /* INT_: direct copy */ | 1571 | right->bb_rightsib = left->bb_rightsib; |
1586 | INT_SET(left->bb_rightsib, ARCH_CONVERT, args.agbno); | 1572 | left->bb_rightsib = cpu_to_be32(args.agbno); |
1587 | INT_SET(right->bb_leftsib, ARCH_CONVERT, lbno); | 1573 | right->bb_leftsib = cpu_to_be32(lbno); |
1588 | xfs_inobt_log_block(args.tp, rbp, XFS_BB_ALL_BITS); | 1574 | xfs_inobt_log_block(args.tp, rbp, XFS_BB_ALL_BITS); |
1589 | xfs_inobt_log_block(args.tp, lbp, XFS_BB_NUMRECS | XFS_BB_RIGHTSIB); | 1575 | xfs_inobt_log_block(args.tp, lbp, XFS_BB_NUMRECS | XFS_BB_RIGHTSIB); |
1590 | /* | 1576 | /* |
1591 | * If there's a block to the new block's right, make that block | 1577 | * If there's a block to the new block's right, make that block |
1592 | * point back to right instead of to left. | 1578 | * point back to right instead of to left. |
1593 | */ | 1579 | */ |
1594 | if (INT_GET(right->bb_rightsib, ARCH_CONVERT) != NULLAGBLOCK) { | 1580 | if (be32_to_cpu(right->bb_rightsib) != NULLAGBLOCK) { |
1595 | xfs_inobt_block_t *rrblock; /* rr btree block */ | 1581 | xfs_inobt_block_t *rrblock; /* rr btree block */ |
1596 | xfs_buf_t *rrbp; /* buffer for rrblock */ | 1582 | xfs_buf_t *rrbp; /* buffer for rrblock */ |
1597 | 1583 | ||
1598 | if ((error = xfs_btree_read_bufs(args.mp, args.tp, args.agno, | 1584 | if ((error = xfs_btree_read_bufs(args.mp, args.tp, args.agno, |
1599 | INT_GET(right->bb_rightsib, ARCH_CONVERT), 0, &rrbp, | 1585 | be32_to_cpu(right->bb_rightsib), 0, &rrbp, |
1600 | XFS_INO_BTREE_REF))) | 1586 | XFS_INO_BTREE_REF))) |
1601 | return error; | 1587 | return error; |
1602 | rrblock = XFS_BUF_TO_INOBT_BLOCK(rrbp); | 1588 | rrblock = XFS_BUF_TO_INOBT_BLOCK(rrbp); |
1603 | if ((error = xfs_btree_check_sblock(cur, rrblock, level, rrbp))) | 1589 | if ((error = xfs_btree_check_sblock(cur, rrblock, level, rrbp))) |
1604 | return error; | 1590 | return error; |
1605 | INT_SET(rrblock->bb_leftsib, ARCH_CONVERT, args.agbno); | 1591 | rrblock->bb_leftsib = cpu_to_be32(args.agbno); |
1606 | xfs_inobt_log_block(args.tp, rrbp, XFS_BB_LEFTSIB); | 1592 | xfs_inobt_log_block(args.tp, rrbp, XFS_BB_LEFTSIB); |
1607 | } | 1593 | } |
1608 | /* | 1594 | /* |
@@ -1610,9 +1596,9 @@ xfs_inobt_split( | |||
1610 | * If it's just pointing past the last entry in left, then we'll | 1596 | * If it's just pointing past the last entry in left, then we'll |
1611 | * insert there, so don't change anything in that case. | 1597 | * insert there, so don't change anything in that case. |
1612 | */ | 1598 | */ |
1613 | if (cur->bc_ptrs[level] > INT_GET(left->bb_numrecs, ARCH_CONVERT) + 1) { | 1599 | if (cur->bc_ptrs[level] > be16_to_cpu(left->bb_numrecs) + 1) { |
1614 | xfs_btree_setbuf(cur, level, rbp); | 1600 | xfs_btree_setbuf(cur, level, rbp); |
1615 | cur->bc_ptrs[level] -= INT_GET(left->bb_numrecs, ARCH_CONVERT); | 1601 | cur->bc_ptrs[level] -= be16_to_cpu(left->bb_numrecs); |
1616 | } | 1602 | } |
1617 | /* | 1603 | /* |
1618 | * If there are more levels, we'll need another cursor which refers | 1604 | * If there are more levels, we'll need another cursor which refers |
@@ -1710,7 +1696,7 @@ xfs_inobt_decrement( | |||
1710 | /* | 1696 | /* |
1711 | * If we just went off the left edge of the tree, return failure. | 1697 | * If we just went off the left edge of the tree, return failure. |
1712 | */ | 1698 | */ |
1713 | if (INT_GET(block->bb_leftsib, ARCH_CONVERT) == NULLAGBLOCK) { | 1699 | if (be32_to_cpu(block->bb_leftsib) == NULLAGBLOCK) { |
1714 | *stat = 0; | 1700 | *stat = 0; |
1715 | return 0; | 1701 | return 0; |
1716 | } | 1702 | } |
@@ -1739,7 +1725,7 @@ xfs_inobt_decrement( | |||
1739 | xfs_agblock_t agbno; /* block number of btree block */ | 1725 | xfs_agblock_t agbno; /* block number of btree block */ |
1740 | xfs_buf_t *bp; /* buffer containing btree block */ | 1726 | xfs_buf_t *bp; /* buffer containing btree block */ |
1741 | 1727 | ||
1742 | agbno = INT_GET(*XFS_INOBT_PTR_ADDR(block, cur->bc_ptrs[lev], cur), ARCH_CONVERT); | 1728 | agbno = be32_to_cpu(*XFS_INOBT_PTR_ADDR(block, cur->bc_ptrs[lev], cur)); |
1743 | if ((error = xfs_btree_read_bufs(cur->bc_mp, cur->bc_tp, | 1729 | if ((error = xfs_btree_read_bufs(cur->bc_mp, cur->bc_tp, |
1744 | cur->bc_private.i.agno, agbno, 0, &bp, | 1730 | cur->bc_private.i.agno, agbno, 0, &bp, |
1745 | XFS_INO_BTREE_REF))) | 1731 | XFS_INO_BTREE_REF))) |
@@ -1749,7 +1735,7 @@ xfs_inobt_decrement( | |||
1749 | block = XFS_BUF_TO_INOBT_BLOCK(bp); | 1735 | block = XFS_BUF_TO_INOBT_BLOCK(bp); |
1750 | if ((error = xfs_btree_check_sblock(cur, block, lev, bp))) | 1736 | if ((error = xfs_btree_check_sblock(cur, block, lev, bp))) |
1751 | return error; | 1737 | return error; |
1752 | cur->bc_ptrs[lev] = INT_GET(block->bb_numrecs, ARCH_CONVERT); | 1738 | cur->bc_ptrs[lev] = be16_to_cpu(block->bb_numrecs); |
1753 | } | 1739 | } |
1754 | *stat = 1; | 1740 | *stat = 1; |
1755 | return 0; | 1741 | return 0; |
@@ -1821,7 +1807,7 @@ xfs_inobt_get_rec( | |||
1821 | /* | 1807 | /* |
1822 | * Off the right end or left end, return failure. | 1808 | * Off the right end or left end, return failure. |
1823 | */ | 1809 | */ |
1824 | if (ptr > INT_GET(block->bb_numrecs, ARCH_CONVERT) || ptr <= 0) { | 1810 | if (ptr > be16_to_cpu(block->bb_numrecs) || ptr <= 0) { |
1825 | *stat = 0; | 1811 | *stat = 0; |
1826 | return 0; | 1812 | return 0; |
1827 | } | 1813 | } |
@@ -1869,14 +1855,14 @@ xfs_inobt_increment( | |||
1869 | * Increment the ptr at this level. If we're still in the block | 1855 | * Increment the ptr at this level. If we're still in the block |
1870 | * then we're done. | 1856 | * then we're done. |
1871 | */ | 1857 | */ |
1872 | if (++cur->bc_ptrs[level] <= INT_GET(block->bb_numrecs, ARCH_CONVERT)) { | 1858 | if (++cur->bc_ptrs[level] <= be16_to_cpu(block->bb_numrecs)) { |
1873 | *stat = 1; | 1859 | *stat = 1; |
1874 | return 0; | 1860 | return 0; |
1875 | } | 1861 | } |
1876 | /* | 1862 | /* |
1877 | * If we just went off the right edge of the tree, return failure. | 1863 | * If we just went off the right edge of the tree, return failure. |
1878 | */ | 1864 | */ |
1879 | if (INT_GET(block->bb_rightsib, ARCH_CONVERT) == NULLAGBLOCK) { | 1865 | if (be32_to_cpu(block->bb_rightsib) == NULLAGBLOCK) { |
1880 | *stat = 0; | 1866 | *stat = 0; |
1881 | return 0; | 1867 | return 0; |
1882 | } | 1868 | } |
@@ -1891,7 +1877,7 @@ xfs_inobt_increment( | |||
1891 | if ((error = xfs_btree_check_sblock(cur, block, lev, bp))) | 1877 | if ((error = xfs_btree_check_sblock(cur, block, lev, bp))) |
1892 | return error; | 1878 | return error; |
1893 | #endif | 1879 | #endif |
1894 | if (++cur->bc_ptrs[lev] <= INT_GET(block->bb_numrecs, ARCH_CONVERT)) | 1880 | if (++cur->bc_ptrs[lev] <= be16_to_cpu(block->bb_numrecs)) |
1895 | break; | 1881 | break; |
1896 | /* | 1882 | /* |
1897 | * Read-ahead the right block, we're going to read it | 1883 | * Read-ahead the right block, we're going to read it |
@@ -1911,7 +1897,7 @@ xfs_inobt_increment( | |||
1911 | lev > level; ) { | 1897 | lev > level; ) { |
1912 | xfs_agblock_t agbno; /* block number of btree block */ | 1898 | xfs_agblock_t agbno; /* block number of btree block */ |
1913 | 1899 | ||
1914 | agbno = INT_GET(*XFS_INOBT_PTR_ADDR(block, cur->bc_ptrs[lev], cur), ARCH_CONVERT); | 1900 | agbno = be32_to_cpu(*XFS_INOBT_PTR_ADDR(block, cur->bc_ptrs[lev], cur)); |
1915 | if ((error = xfs_btree_read_bufs(cur->bc_mp, cur->bc_tp, | 1901 | if ((error = xfs_btree_read_bufs(cur->bc_mp, cur->bc_tp, |
1916 | cur->bc_private.i.agno, agbno, 0, &bp, | 1902 | cur->bc_private.i.agno, agbno, 0, &bp, |
1917 | XFS_INO_BTREE_REF))) | 1903 | XFS_INO_BTREE_REF))) |
diff --git a/fs/xfs/xfs_ialloc_btree.h b/fs/xfs/xfs_ialloc_btree.h index 44be188674a6..ae3904cb1ee8 100644 --- a/fs/xfs/xfs_ialloc_btree.h +++ b/fs/xfs/xfs_ialloc_btree.h | |||
@@ -1,33 +1,19 @@ | |||
1 | /* | 1 | /* |
2 | * Copyright (c) 2000 Silicon Graphics, Inc. All Rights Reserved. | 2 | * Copyright (c) 2000,2005 Silicon Graphics, Inc. |
3 | * All Rights Reserved. | ||
3 | * | 4 | * |
4 | * This program is free software; you can redistribute it and/or modify it | 5 | * This program is free software; you can redistribute it and/or |
5 | * under the terms of version 2 of the GNU General Public License as | 6 | * modify it under the terms of the GNU General Public License as |
6 | * published by the Free Software Foundation. | 7 | * published by the Free Software Foundation. |
7 | * | 8 | * |
8 | * This program is distributed in the hope that it would be useful, but | 9 | * This program is distributed in the hope that it would be useful, |
9 | * WITHOUT ANY WARRANTY; without even the implied warranty of | 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
12 | * GNU General Public License for more details. | ||
11 | * | 13 | * |
12 | * Further, this software is distributed without any warranty that it is | 14 | * You should have received a copy of the GNU General Public License |
13 | * free of the rightful claim of any third person regarding infringement | 15 | * along with this program; if not, write the Free Software Foundation, |
14 | * or the like. Any license provided herein, whether implied or | 16 | * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
15 | * otherwise, applies only to this software file. Patent licenses, if | ||
16 | * any, provided herein do not apply to combinations of this program with | ||
17 | * other software, or any other product whatsoever. | ||
18 | * | ||
19 | * You should have received a copy of the GNU General Public License along | ||
20 | * with this program; if not, write the Free Software Foundation, Inc., 59 | ||
21 | * Temple Place - Suite 330, Boston MA 02111-1307, USA. | ||
22 | * | ||
23 | * Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy, | ||
24 | * Mountain View, CA 94043, or: | ||
25 | * | ||
26 | * http://www.sgi.com | ||
27 | * | ||
28 | * For further information regarding this notice, see: | ||
29 | * | ||
30 | * http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/ | ||
31 | */ | 17 | */ |
32 | #ifndef __XFS_IALLOC_BTREE_H__ | 18 | #ifndef __XFS_IALLOC_BTREE_H__ |
33 | #define __XFS_IALLOC_BTREE_H__ | 19 | #define __XFS_IALLOC_BTREE_H__ |
@@ -51,14 +37,12 @@ typedef __uint64_t xfs_inofree_t; | |||
51 | #define XFS_INODES_PER_CHUNK_LOG (XFS_NBBYLOG + 3) | 37 | #define XFS_INODES_PER_CHUNK_LOG (XFS_NBBYLOG + 3) |
52 | #define XFS_INOBT_ALL_FREE ((xfs_inofree_t)-1) | 38 | #define XFS_INOBT_ALL_FREE ((xfs_inofree_t)-1) |
53 | 39 | ||
54 | #if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_INOBT_MASKN) | ||
55 | xfs_inofree_t xfs_inobt_maskn(int i, int n); | ||
56 | #define XFS_INOBT_MASKN(i,n) xfs_inobt_maskn(i,n) | 40 | #define XFS_INOBT_MASKN(i,n) xfs_inobt_maskn(i,n) |
57 | #else | 41 | static inline xfs_inofree_t xfs_inobt_maskn(int i, int n) |
58 | #define XFS_INOBT_MASKN(i,n) \ | 42 | { |
59 | ((((n) >= XFS_INODES_PER_CHUNK ? \ | 43 | return (((n) >= XFS_INODES_PER_CHUNK ? \ |
60 | (xfs_inofree_t)0 : ((xfs_inofree_t)1 << (n))) - 1) << (i)) | 44 | (xfs_inofree_t)0 : ((xfs_inofree_t)1 << (n))) - 1) << (i); |
61 | #endif | 45 | } |
62 | 46 | ||
63 | /* | 47 | /* |
64 | * Data record structure | 48 | * Data record structure |
@@ -78,241 +62,116 @@ typedef struct xfs_inobt_key | |||
78 | xfs_agino_t ir_startino; /* starting inode number */ | 62 | xfs_agino_t ir_startino; /* starting inode number */ |
79 | } xfs_inobt_key_t; | 63 | } xfs_inobt_key_t; |
80 | 64 | ||
81 | typedef xfs_agblock_t xfs_inobt_ptr_t; /* btree pointer type */ | 65 | /* btree pointer type */ |
82 | /* btree block header type */ | 66 | typedef __be32 xfs_inobt_ptr_t; |
67 | |||
68 | /* btree block header type */ | ||
83 | typedef struct xfs_btree_sblock xfs_inobt_block_t; | 69 | typedef struct xfs_btree_sblock xfs_inobt_block_t; |
84 | 70 | ||
85 | #if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_BUF_TO_INOBT_BLOCK) | 71 | #define XFS_BUF_TO_INOBT_BLOCK(bp) ((xfs_inobt_block_t *)XFS_BUF_PTR(bp)) |
86 | xfs_inobt_block_t *xfs_buf_to_inobt_block(struct xfs_buf *bp); | ||
87 | #define XFS_BUF_TO_INOBT_BLOCK(bp) xfs_buf_to_inobt_block(bp) | ||
88 | #else | ||
89 | #define XFS_BUF_TO_INOBT_BLOCK(bp) ((xfs_inobt_block_t *)(XFS_BUF_PTR(bp))) | ||
90 | #endif | ||
91 | 72 | ||
92 | /* | 73 | /* |
93 | * Bit manipulations for ir_free. | 74 | * Bit manipulations for ir_free. |
94 | */ | 75 | */ |
95 | #if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_INOBT_MASK) | ||
96 | xfs_inofree_t xfs_inobt_mask(int i); | ||
97 | #define XFS_INOBT_MASK(i) xfs_inobt_mask(i) | ||
98 | #else | ||
99 | #define XFS_INOBT_MASK(i) ((xfs_inofree_t)1 << (i)) | 76 | #define XFS_INOBT_MASK(i) ((xfs_inofree_t)1 << (i)) |
100 | #endif | 77 | #define XFS_INOBT_IS_FREE(rp,i) \ |
101 | #if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_INOBT_IS_FREE) | 78 | (((rp)->ir_free & XFS_INOBT_MASK(i)) != 0) |
102 | int xfs_inobt_is_free(xfs_inobt_rec_t *rp, int i); | 79 | #define XFS_INOBT_IS_FREE_DISK(rp,i) \ |
103 | #define XFS_INOBT_IS_FREE(rp,i) xfs_inobt_is_free(rp,i) | 80 | ((INT_GET((rp)->ir_free,ARCH_CONVERT) & XFS_INOBT_MASK(i)) != 0) |
104 | #define XFS_INOBT_IS_FREE_DISK(rp,i) xfs_inobt_is_free_disk(rp,i) | ||
105 | #else | ||
106 | #define XFS_INOBT_IS_FREE(rp,i) \ | ||
107 | (((rp)->ir_free & XFS_INOBT_MASK(i)) != 0) | ||
108 | #define XFS_INOBT_IS_FREE_DISK(rp,i) \ | ||
109 | ((INT_GET((rp)->ir_free, ARCH_CONVERT) & XFS_INOBT_MASK(i)) != 0) | ||
110 | #endif | ||
111 | #if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_INOBT_SET_FREE) | ||
112 | void xfs_inobt_set_free(xfs_inobt_rec_t *rp, int i); | ||
113 | #define XFS_INOBT_SET_FREE(rp,i) xfs_inobt_set_free(rp,i) | ||
114 | #else | ||
115 | #define XFS_INOBT_SET_FREE(rp,i) ((rp)->ir_free |= XFS_INOBT_MASK(i)) | 81 | #define XFS_INOBT_SET_FREE(rp,i) ((rp)->ir_free |= XFS_INOBT_MASK(i)) |
116 | #endif | ||
117 | #if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_INOBT_CLR_FREE) | ||
118 | void xfs_inobt_clr_free(xfs_inobt_rec_t *rp, int i); | ||
119 | #define XFS_INOBT_CLR_FREE(rp,i) xfs_inobt_clr_free(rp,i) | ||
120 | #else | ||
121 | #define XFS_INOBT_CLR_FREE(rp,i) ((rp)->ir_free &= ~XFS_INOBT_MASK(i)) | 82 | #define XFS_INOBT_CLR_FREE(rp,i) ((rp)->ir_free &= ~XFS_INOBT_MASK(i)) |
122 | #endif | ||
123 | 83 | ||
124 | /* | 84 | /* |
125 | * Real block structures have a size equal to the disk block size. | 85 | * Real block structures have a size equal to the disk block size. |
126 | */ | 86 | */ |
127 | #if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_INOBT_BLOCK_SIZE) | ||
128 | int xfs_inobt_block_size(int lev, struct xfs_btree_cur *cur); | ||
129 | #define XFS_INOBT_BLOCK_SIZE(lev,cur) xfs_inobt_block_size(lev,cur) | ||
130 | #else | ||
131 | #define XFS_INOBT_BLOCK_SIZE(lev,cur) (1 << (cur)->bc_blocklog) | 87 | #define XFS_INOBT_BLOCK_SIZE(lev,cur) (1 << (cur)->bc_blocklog) |
132 | #endif | 88 | #define XFS_INOBT_BLOCK_MAXRECS(lev,cur) ((cur)->bc_mp->m_inobt_mxr[lev != 0]) |
133 | 89 | #define XFS_INOBT_BLOCK_MINRECS(lev,cur) ((cur)->bc_mp->m_inobt_mnr[lev != 0]) | |
134 | #if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_INOBT_BLOCK_MAXRECS) | ||
135 | int xfs_inobt_block_maxrecs(int lev, struct xfs_btree_cur *cur); | ||
136 | #define XFS_INOBT_BLOCK_MAXRECS(lev,cur) xfs_inobt_block_maxrecs(lev,cur) | ||
137 | #else | ||
138 | #define XFS_INOBT_BLOCK_MAXRECS(lev,cur) \ | ||
139 | ((cur)->bc_mp->m_inobt_mxr[lev != 0]) | ||
140 | #endif | ||
141 | #if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_INOBT_BLOCK_MINRECS) | ||
142 | int xfs_inobt_block_minrecs(int lev, struct xfs_btree_cur *cur); | ||
143 | #define XFS_INOBT_BLOCK_MINRECS(lev,cur) xfs_inobt_block_minrecs(lev,cur) | ||
144 | #else | ||
145 | #define XFS_INOBT_BLOCK_MINRECS(lev,cur) \ | ||
146 | ((cur)->bc_mp->m_inobt_mnr[lev != 0]) | ||
147 | #endif | ||
148 | |||
149 | #if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_INOBT_IS_LAST_REC) | ||
150 | int xfs_inobt_is_last_rec(struct xfs_btree_cur *cur); | ||
151 | #define XFS_INOBT_IS_LAST_REC(cur) xfs_inobt_is_last_rec(cur) | ||
152 | #else | ||
153 | #define XFS_INOBT_IS_LAST_REC(cur) \ | 90 | #define XFS_INOBT_IS_LAST_REC(cur) \ |
154 | ((cur)->bc_ptrs[0] == \ | 91 | ((cur)->bc_ptrs[0] == be16_to_cpu(XFS_BUF_TO_INOBT_BLOCK((cur)->bc_bufs[0])->bb_numrecs)) |
155 | INT_GET(XFS_BUF_TO_INOBT_BLOCK((cur)->bc_bufs[0])->bb_numrecs, ARCH_CONVERT)) | ||
156 | #endif | ||
157 | 92 | ||
158 | /* | 93 | /* |
159 | * Maximum number of inode btree levels. | 94 | * Maximum number of inode btree levels. |
160 | */ | 95 | */ |
161 | #if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_IN_MAXLEVELS) | ||
162 | int xfs_in_maxlevels(struct xfs_mount *mp); | ||
163 | #define XFS_IN_MAXLEVELS(mp) xfs_in_maxlevels(mp) | ||
164 | #else | ||
165 | #define XFS_IN_MAXLEVELS(mp) ((mp)->m_in_maxlevels) | 96 | #define XFS_IN_MAXLEVELS(mp) ((mp)->m_in_maxlevels) |
166 | #endif | ||
167 | 97 | ||
168 | /* | 98 | /* |
169 | * block numbers in the AG. | 99 | * block numbers in the AG. |
170 | */ | 100 | */ |
171 | #if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_IBT_BLOCK) | 101 | #define XFS_IBT_BLOCK(mp) ((xfs_agblock_t)(XFS_CNT_BLOCK(mp) + 1)) |
172 | xfs_agblock_t xfs_ibt_block(struct xfs_mount *mp); | 102 | #define XFS_PREALLOC_BLOCKS(mp) ((xfs_agblock_t)(XFS_IBT_BLOCK(mp) + 1)) |
173 | #define XFS_IBT_BLOCK(mp) xfs_ibt_block(mp) | ||
174 | #else | ||
175 | #define XFS_IBT_BLOCK(mp) ((xfs_agblock_t)(XFS_CNT_BLOCK(mp) + 1)) | ||
176 | #endif | ||
177 | #if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_PREALLOC_BLOCKS) | ||
178 | xfs_agblock_t xfs_prealloc_blocks(struct xfs_mount *mp); | ||
179 | #define XFS_PREALLOC_BLOCKS(mp) xfs_prealloc_blocks(mp) | ||
180 | #else | ||
181 | #define XFS_PREALLOC_BLOCKS(mp) ((xfs_agblock_t)(XFS_IBT_BLOCK(mp) + 1)) | ||
182 | #endif | ||
183 | 103 | ||
184 | /* | 104 | /* |
185 | * Record, key, and pointer address macros for btree blocks. | 105 | * Record, key, and pointer address macros for btree blocks. |
186 | */ | 106 | */ |
187 | #if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_INOBT_REC_ADDR) | 107 | #define XFS_INOBT_REC_ADDR(bb,i,cur) \ |
188 | xfs_inobt_rec_t * | 108 | (XFS_BTREE_REC_ADDR(XFS_INOBT_BLOCK_SIZE(0,cur), xfs_inobt, bb, \ |
189 | xfs_inobt_rec_addr(xfs_inobt_block_t *bb, int i, struct xfs_btree_cur *cur); | 109 | i, XFS_INOBT_BLOCK_MAXRECS(0, cur))) |
190 | #define XFS_INOBT_REC_ADDR(bb,i,cur) xfs_inobt_rec_addr(bb,i,cur) | 110 | #define XFS_INOBT_KEY_ADDR(bb,i,cur) \ |
191 | #else | 111 | (XFS_BTREE_KEY_ADDR(XFS_INOBT_BLOCK_SIZE(1,cur), xfs_inobt, bb, \ |
192 | #define XFS_INOBT_REC_ADDR(bb,i,cur) \ | 112 | i, XFS_INOBT_BLOCK_MAXRECS(1, cur))) |
193 | XFS_BTREE_REC_ADDR(XFS_INOBT_BLOCK_SIZE(0,cur), xfs_inobt, bb, i, \ | ||
194 | XFS_INOBT_BLOCK_MAXRECS(0, cur)) | ||
195 | #endif | ||
196 | |||
197 | #if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_INOBT_KEY_ADDR) | ||
198 | xfs_inobt_key_t * | ||
199 | xfs_inobt_key_addr(xfs_inobt_block_t *bb, int i, struct xfs_btree_cur *cur); | ||
200 | #define XFS_INOBT_KEY_ADDR(bb,i,cur) xfs_inobt_key_addr(bb,i,cur) | ||
201 | #else | ||
202 | #define XFS_INOBT_KEY_ADDR(bb,i,cur) \ | ||
203 | XFS_BTREE_KEY_ADDR(XFS_INOBT_BLOCK_SIZE(1,cur), xfs_inobt, bb, i, \ | ||
204 | XFS_INOBT_BLOCK_MAXRECS(1, cur)) | ||
205 | #endif | ||
206 | 113 | ||
207 | #if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_INOBT_PTR_ADDR) | 114 | #define XFS_INOBT_PTR_ADDR(bb,i,cur) \ |
208 | xfs_inobt_ptr_t * | 115 | (XFS_BTREE_PTR_ADDR(XFS_INOBT_BLOCK_SIZE(1,cur), xfs_inobt, bb, \ |
209 | xfs_inobt_ptr_addr(xfs_inobt_block_t *bb, int i, struct xfs_btree_cur *cur); | 116 | i, XFS_INOBT_BLOCK_MAXRECS(1, cur))) |
210 | #define XFS_INOBT_PTR_ADDR(bb,i,cur) xfs_inobt_ptr_addr(bb,i,cur) | ||
211 | #else | ||
212 | #define XFS_INOBT_PTR_ADDR(bb,i,cur) \ | ||
213 | XFS_BTREE_PTR_ADDR(XFS_INOBT_BLOCK_SIZE(1,cur), xfs_inobt, bb, i, \ | ||
214 | XFS_INOBT_BLOCK_MAXRECS(1, cur)) | ||
215 | #endif | ||
216 | |||
217 | /* | ||
218 | * Prototypes for externally visible routines. | ||
219 | */ | ||
220 | 117 | ||
221 | /* | 118 | /* |
222 | * Decrement cursor by one record at the level. | 119 | * Decrement cursor by one record at the level. |
223 | * For nonzero levels the leaf-ward information is untouched. | 120 | * For nonzero levels the leaf-ward information is untouched. |
224 | */ | 121 | */ |
225 | int /* error */ | 122 | extern int xfs_inobt_decrement(struct xfs_btree_cur *cur, int level, int *stat); |
226 | xfs_inobt_decrement( | ||
227 | struct xfs_btree_cur *cur, /* btree cursor */ | ||
228 | int level, /* level in btree, 0 is leaf */ | ||
229 | int *stat); /* success/failure */ | ||
230 | 123 | ||
231 | /* | 124 | /* |
232 | * Delete the record pointed to by cur. | 125 | * Delete the record pointed to by cur. |
233 | * The cursor refers to the place where the record was (could be inserted) | 126 | * The cursor refers to the place where the record was (could be inserted) |
234 | * when the operation returns. | 127 | * when the operation returns. |
235 | */ | 128 | */ |
236 | int /* error */ | 129 | extern int xfs_inobt_delete(struct xfs_btree_cur *cur, int *stat); |
237 | xfs_inobt_delete( | ||
238 | struct xfs_btree_cur *cur, /* btree cursor */ | ||
239 | int *stat); /* success/failure */ | ||
240 | 130 | ||
241 | /* | 131 | /* |
242 | * Get the data from the pointed-to record. | 132 | * Get the data from the pointed-to record. |
243 | */ | 133 | */ |
244 | int /* error */ | 134 | extern int xfs_inobt_get_rec(struct xfs_btree_cur *cur, xfs_agino_t *ino, |
245 | xfs_inobt_get_rec( | 135 | __int32_t *fcnt, xfs_inofree_t *free, int *stat); |
246 | struct xfs_btree_cur *cur, /* btree cursor */ | ||
247 | xfs_agino_t *ino, /* output: starting inode of chunk */ | ||
248 | __int32_t *fcnt, /* output: number of free inodes */ | ||
249 | xfs_inofree_t *free, /* output: free inode mask */ | ||
250 | int *stat); /* output: success/failure */ | ||
251 | 136 | ||
252 | /* | 137 | /* |
253 | * Increment cursor by one record at the level. | 138 | * Increment cursor by one record at the level. |
254 | * For nonzero levels the leaf-ward information is untouched. | 139 | * For nonzero levels the leaf-ward information is untouched. |
255 | */ | 140 | */ |
256 | int /* error */ | 141 | extern int xfs_inobt_increment(struct xfs_btree_cur *cur, int level, int *stat); |
257 | xfs_inobt_increment( | ||
258 | struct xfs_btree_cur *cur, /* btree cursor */ | ||
259 | int level, /* level in btree, 0 is leaf */ | ||
260 | int *stat); /* success/failure */ | ||
261 | 142 | ||
262 | /* | 143 | /* |
263 | * Insert the current record at the point referenced by cur. | 144 | * Insert the current record at the point referenced by cur. |
264 | * The cursor may be inconsistent on return if splits have been done. | 145 | * The cursor may be inconsistent on return if splits have been done. |
265 | */ | 146 | */ |
266 | int /* error */ | 147 | extern int xfs_inobt_insert(struct xfs_btree_cur *cur, int *stat); |
267 | xfs_inobt_insert( | ||
268 | struct xfs_btree_cur *cur, /* btree cursor */ | ||
269 | int *stat); /* success/failure */ | ||
270 | 148 | ||
271 | /* | 149 | /* |
272 | * Lookup the record equal to ino in the btree given by cur. | 150 | * Lookup the record equal to ino in the btree given by cur. |
273 | */ | 151 | */ |
274 | int /* error */ | 152 | extern int xfs_inobt_lookup_eq(struct xfs_btree_cur *cur, xfs_agino_t ino, |
275 | xfs_inobt_lookup_eq( | 153 | __int32_t fcnt, xfs_inofree_t free, int *stat); |
276 | struct xfs_btree_cur *cur, /* btree cursor */ | ||
277 | xfs_agino_t ino, /* starting inode of chunk */ | ||
278 | __int32_t fcnt, /* free inode count */ | ||
279 | xfs_inofree_t free, /* free inode mask */ | ||
280 | int *stat); /* success/failure */ | ||
281 | 154 | ||
282 | /* | 155 | /* |
283 | * Lookup the first record greater than or equal to ino | 156 | * Lookup the first record greater than or equal to ino |
284 | * in the btree given by cur. | 157 | * in the btree given by cur. |
285 | */ | 158 | */ |
286 | int /* error */ | 159 | extern int xfs_inobt_lookup_ge(struct xfs_btree_cur *cur, xfs_agino_t ino, |
287 | xfs_inobt_lookup_ge( | 160 | __int32_t fcnt, xfs_inofree_t free, int *stat); |
288 | struct xfs_btree_cur *cur, /* btree cursor */ | ||
289 | xfs_agino_t ino, /* starting inode of chunk */ | ||
290 | __int32_t fcnt, /* free inode count */ | ||
291 | xfs_inofree_t free, /* free inode mask */ | ||
292 | int *stat); /* success/failure */ | ||
293 | 161 | ||
294 | /* | 162 | /* |
295 | * Lookup the first record less than or equal to ino | 163 | * Lookup the first record less than or equal to ino |
296 | * in the btree given by cur. | 164 | * in the btree given by cur. |
297 | */ | 165 | */ |
298 | int /* error */ | 166 | extern int xfs_inobt_lookup_le(struct xfs_btree_cur *cur, xfs_agino_t ino, |
299 | xfs_inobt_lookup_le( | 167 | __int32_t fcnt, xfs_inofree_t free, int *stat); |
300 | struct xfs_btree_cur *cur, /* btree cursor */ | ||
301 | xfs_agino_t ino, /* starting inode of chunk */ | ||
302 | __int32_t fcnt, /* free inode count */ | ||
303 | xfs_inofree_t free, /* free inode mask */ | ||
304 | int *stat); /* success/failure */ | ||
305 | 168 | ||
306 | /* | 169 | /* |
307 | * Update the record referred to by cur, to the value given | 170 | * Update the record referred to by cur, to the value given |
308 | * by [ino, fcnt, free]. | 171 | * by [ino, fcnt, free]. |
309 | * This either works (return 0) or gets an EFSCORRUPTED error. | 172 | * This either works (return 0) or gets an EFSCORRUPTED error. |
310 | */ | 173 | */ |
311 | int /* error */ | 174 | extern int xfs_inobt_update(struct xfs_btree_cur *cur, xfs_agino_t ino, |
312 | xfs_inobt_update( | 175 | __int32_t fcnt, xfs_inofree_t free); |
313 | struct xfs_btree_cur *cur, /* btree cursor */ | ||
314 | xfs_agino_t ino, /* starting inode of chunk */ | ||
315 | __int32_t fcnt, /* free inode count */ | ||
316 | xfs_inofree_t free); /* free inode mask */ | ||
317 | 176 | ||
318 | #endif /* __XFS_IALLOC_BTREE_H__ */ | 177 | #endif /* __XFS_IALLOC_BTREE_H__ */ |
diff --git a/fs/xfs/xfs_iget.c b/fs/xfs/xfs_iget.c index 0d9ae8fb4138..fc19eedbd11b 100644 --- a/fs/xfs/xfs_iget.c +++ b/fs/xfs/xfs_iget.c | |||
@@ -1,43 +1,26 @@ | |||
1 | /* | 1 | /* |
2 | * Copyright (c) 2000-2005 Silicon Graphics, Inc. All Rights Reserved. | 2 | * Copyright (c) 2000-2005 Silicon Graphics, Inc. |
3 | * All Rights Reserved. | ||
3 | * | 4 | * |
4 | * This program is free software; you can redistribute it and/or modify it | 5 | * This program is free software; you can redistribute it and/or |
5 | * under the terms of version 2 of the GNU General Public License as | 6 | * modify it under the terms of the GNU General Public License as |
6 | * published by the Free Software Foundation. | 7 | * published by the Free Software Foundation. |
7 | * | 8 | * |
8 | * This program is distributed in the hope that it would be useful, but | 9 | * This program is distributed in the hope that it would be useful, |
9 | * WITHOUT ANY WARRANTY; without even the implied warranty of | 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
12 | * GNU General Public License for more details. | ||
11 | * | 13 | * |
12 | * Further, this software is distributed without any warranty that it is | 14 | * You should have received a copy of the GNU General Public License |
13 | * free of the rightful claim of any third person regarding infringement | 15 | * along with this program; if not, write the Free Software Foundation, |
14 | * or the like. Any license provided herein, whether implied or | 16 | * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
15 | * otherwise, applies only to this software file. Patent licenses, if | ||
16 | * any, provided herein do not apply to combinations of this program with | ||
17 | * other software, or any other product whatsoever. | ||
18 | * | ||
19 | * You should have received a copy of the GNU General Public License along | ||
20 | * with this program; if not, write the Free Software Foundation, Inc., 59 | ||
21 | * Temple Place - Suite 330, Boston MA 02111-1307, USA. | ||
22 | * | ||
23 | * Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy, | ||
24 | * Mountain View, CA 94043, or: | ||
25 | * | ||
26 | * http://www.sgi.com | ||
27 | * | ||
28 | * For further information regarding this notice, see: | ||
29 | * | ||
30 | * http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/ | ||
31 | */ | 17 | */ |
32 | |||
33 | #include <linux/delay.h> | ||
34 | |||
35 | #include "xfs.h" | 18 | #include "xfs.h" |
36 | 19 | #include "xfs_fs.h" | |
37 | #include "xfs_macros.h" | ||
38 | #include "xfs_types.h" | 20 | #include "xfs_types.h" |
39 | #include "xfs_inum.h" | 21 | #include "xfs_bit.h" |
40 | #include "xfs_log.h" | 22 | #include "xfs_log.h" |
23 | #include "xfs_inum.h" | ||
41 | #include "xfs_trans.h" | 24 | #include "xfs_trans.h" |
42 | #include "xfs_sb.h" | 25 | #include "xfs_sb.h" |
43 | #include "xfs_ag.h" | 26 | #include "xfs_ag.h" |
@@ -45,19 +28,18 @@ | |||
45 | #include "xfs_dir2.h" | 28 | #include "xfs_dir2.h" |
46 | #include "xfs_dmapi.h" | 29 | #include "xfs_dmapi.h" |
47 | #include "xfs_mount.h" | 30 | #include "xfs_mount.h" |
48 | #include "xfs_alloc_btree.h" | ||
49 | #include "xfs_bmap_btree.h" | 31 | #include "xfs_bmap_btree.h" |
32 | #include "xfs_alloc_btree.h" | ||
50 | #include "xfs_ialloc_btree.h" | 33 | #include "xfs_ialloc_btree.h" |
51 | #include "xfs_btree.h" | ||
52 | #include "xfs_ialloc.h" | ||
53 | #include "xfs_attr_sf.h" | ||
54 | #include "xfs_dir_sf.h" | 34 | #include "xfs_dir_sf.h" |
55 | #include "xfs_dir2_sf.h" | 35 | #include "xfs_dir2_sf.h" |
36 | #include "xfs_attr_sf.h" | ||
56 | #include "xfs_dinode.h" | 37 | #include "xfs_dinode.h" |
57 | #include "xfs_inode.h" | 38 | #include "xfs_inode.h" |
39 | #include "xfs_btree.h" | ||
40 | #include "xfs_ialloc.h" | ||
58 | #include "xfs_quota.h" | 41 | #include "xfs_quota.h" |
59 | #include "xfs_utils.h" | 42 | #include "xfs_utils.h" |
60 | #include "xfs_bit.h" | ||
61 | 43 | ||
62 | /* | 44 | /* |
63 | * Initialize the inode hash table for the newly mounted file system. | 45 | * Initialize the inode hash table for the newly mounted file system. |
diff --git a/fs/xfs/xfs_imap.h b/fs/xfs/xfs_imap.h index e385064a066a..d36450003983 100644 --- a/fs/xfs/xfs_imap.h +++ b/fs/xfs/xfs_imap.h | |||
@@ -1,33 +1,19 @@ | |||
1 | /* | 1 | /* |
2 | * Copyright (c) 2000 Silicon Graphics, Inc. All Rights Reserved. | 2 | * Copyright (c) 2000,2005 Silicon Graphics, Inc. |
3 | * All Rights Reserved. | ||
3 | * | 4 | * |
4 | * This program is free software; you can redistribute it and/or modify it | 5 | * This program is free software; you can redistribute it and/or |
5 | * under the terms of version 2 of the GNU General Public License as | 6 | * modify it under the terms of the GNU General Public License as |
6 | * published by the Free Software Foundation. | 7 | * published by the Free Software Foundation. |
7 | * | 8 | * |
8 | * This program is distributed in the hope that it would be useful, but | 9 | * This program is distributed in the hope that it would be useful, |
9 | * WITHOUT ANY WARRANTY; without even the implied warranty of | 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
12 | * GNU General Public License for more details. | ||
11 | * | 13 | * |
12 | * Further, this software is distributed without any warranty that it is | 14 | * You should have received a copy of the GNU General Public License |
13 | * free of the rightful claim of any third person regarding infringement | 15 | * along with this program; if not, write the Free Software Foundation, |
14 | * or the like. Any license provided herein, whether implied or | 16 | * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
15 | * otherwise, applies only to this software file. Patent licenses, if | ||
16 | * any, provided herein do not apply to combinations of this program with | ||
17 | * other software, or any other product whatsoever. | ||
18 | * | ||
19 | * You should have received a copy of the GNU General Public License along | ||
20 | * with this program; if not, write the Free Software Foundation, Inc., 59 | ||
21 | * Temple Place - Suite 330, Boston MA 02111-1307, USA. | ||
22 | * | ||
23 | * Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy, | ||
24 | * Mountain View, CA 94043, or: | ||
25 | * | ||
26 | * http://www.sgi.com | ||
27 | * | ||
28 | * For further information regarding this notice, see: | ||
29 | * | ||
30 | * http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/ | ||
31 | */ | 17 | */ |
32 | #ifndef __XFS_IMAP_H__ | 18 | #ifndef __XFS_IMAP_H__ |
33 | #define __XFS_IMAP_H__ | 19 | #define __XFS_IMAP_H__ |
diff --git a/fs/xfs/xfs_inode.c b/fs/xfs/xfs_inode.c index db43308aae93..df0d4572d70a 100644 --- a/fs/xfs/xfs_inode.c +++ b/fs/xfs/xfs_inode.c | |||
@@ -1,40 +1,27 @@ | |||
1 | /* | 1 | /* |
2 | * Copyright (c) 2000-2003 Silicon Graphics, Inc. All Rights Reserved. | 2 | * Copyright (c) 2000-2003,2005 Silicon Graphics, Inc. |
3 | * All Rights Reserved. | ||
3 | * | 4 | * |
4 | * This program is free software; you can redistribute it and/or modify it | 5 | * This program is free software; you can redistribute it and/or |
5 | * under the terms of version 2 of the GNU General Public License as | 6 | * modify it under the terms of the GNU General Public License as |
6 | * published by the Free Software Foundation. | 7 | * published by the Free Software Foundation. |
7 | * | 8 | * |
8 | * This program is distributed in the hope that it would be useful, but | 9 | * This program is distributed in the hope that it would be useful, |
9 | * WITHOUT ANY WARRANTY; without even the implied warranty of | 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
12 | * GNU General Public License for more details. | ||
11 | * | 13 | * |
12 | * Further, this software is distributed without any warranty that it is | 14 | * You should have received a copy of the GNU General Public License |
13 | * free of the rightful claim of any third person regarding infringement | 15 | * along with this program; if not, write the Free Software Foundation, |
14 | * or the like. Any license provided herein, whether implied or | 16 | * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
15 | * otherwise, applies only to this software file. Patent licenses, if | ||
16 | * any, provided herein do not apply to combinations of this program with | ||
17 | * other software, or any other product whatsoever. | ||
18 | * | ||
19 | * You should have received a copy of the GNU General Public License along | ||
20 | * with this program; if not, write the Free Software Foundation, Inc., 59 | ||
21 | * Temple Place - Suite 330, Boston MA 02111-1307, USA. | ||
22 | * | ||
23 | * Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy, | ||
24 | * Mountain View, CA 94043, or: | ||
25 | * | ||
26 | * http://www.sgi.com | ||
27 | * | ||
28 | * For further information regarding this notice, see: | ||
29 | * | ||
30 | * http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/ | ||
31 | */ | 17 | */ |
32 | |||
33 | #include "xfs.h" | 18 | #include "xfs.h" |
34 | #include "xfs_macros.h" | 19 | #include "xfs_fs.h" |
35 | #include "xfs_types.h" | 20 | #include "xfs_types.h" |
36 | #include "xfs_inum.h" | 21 | #include "xfs_bit.h" |
37 | #include "xfs_log.h" | 22 | #include "xfs_log.h" |
23 | #include "xfs_inum.h" | ||
24 | #include "xfs_imap.h" | ||
38 | #include "xfs_trans.h" | 25 | #include "xfs_trans.h" |
39 | #include "xfs_trans_priv.h" | 26 | #include "xfs_trans_priv.h" |
40 | #include "xfs_sb.h" | 27 | #include "xfs_sb.h" |
@@ -43,24 +30,22 @@ | |||
43 | #include "xfs_dir2.h" | 30 | #include "xfs_dir2.h" |
44 | #include "xfs_dmapi.h" | 31 | #include "xfs_dmapi.h" |
45 | #include "xfs_mount.h" | 32 | #include "xfs_mount.h" |
46 | #include "xfs_alloc_btree.h" | ||
47 | #include "xfs_bmap_btree.h" | 33 | #include "xfs_bmap_btree.h" |
34 | #include "xfs_alloc_btree.h" | ||
48 | #include "xfs_ialloc_btree.h" | 35 | #include "xfs_ialloc_btree.h" |
49 | #include "xfs_btree.h" | ||
50 | #include "xfs_imap.h" | ||
51 | #include "xfs_alloc.h" | ||
52 | #include "xfs_ialloc.h" | ||
53 | #include "xfs_attr_sf.h" | ||
54 | #include "xfs_dir_sf.h" | 36 | #include "xfs_dir_sf.h" |
55 | #include "xfs_dir2_sf.h" | 37 | #include "xfs_dir2_sf.h" |
38 | #include "xfs_attr_sf.h" | ||
56 | #include "xfs_dinode.h" | 39 | #include "xfs_dinode.h" |
57 | #include "xfs_inode_item.h" | ||
58 | #include "xfs_inode.h" | 40 | #include "xfs_inode.h" |
59 | #include "xfs_bmap.h" | ||
60 | #include "xfs_buf_item.h" | 41 | #include "xfs_buf_item.h" |
42 | #include "xfs_inode_item.h" | ||
43 | #include "xfs_btree.h" | ||
44 | #include "xfs_alloc.h" | ||
45 | #include "xfs_ialloc.h" | ||
46 | #include "xfs_bmap.h" | ||
61 | #include "xfs_rw.h" | 47 | #include "xfs_rw.h" |
62 | #include "xfs_error.h" | 48 | #include "xfs_error.h" |
63 | #include "xfs_bit.h" | ||
64 | #include "xfs_utils.h" | 49 | #include "xfs_utils.h" |
65 | #include "xfs_dir2_trace.h" | 50 | #include "xfs_dir2_trace.h" |
66 | #include "xfs_quota.h" | 51 | #include "xfs_quota.h" |
@@ -194,9 +179,10 @@ xfs_inotobp( | |||
194 | if ((imap.im_blkno + imap.im_len) > | 179 | if ((imap.im_blkno + imap.im_len) > |
195 | XFS_FSB_TO_BB(mp, mp->m_sb.sb_dblocks)) { | 180 | XFS_FSB_TO_BB(mp, mp->m_sb.sb_dblocks)) { |
196 | cmn_err(CE_WARN, | 181 | cmn_err(CE_WARN, |
197 | "xfs_inotobp: inode number (%d + %d) maps to a block outside the bounds " | 182 | "xfs_inotobp: inode number (%llu + %d) maps to a block outside the bounds " |
198 | "of the file system %s. Returning EINVAL.", | 183 | "of the file system %s. Returning EINVAL.", |
199 | imap.im_blkno, imap.im_len,mp->m_fsname); | 184 | (unsigned long long)imap.im_blkno, |
185 | imap.im_len, mp->m_fsname); | ||
200 | return XFS_ERROR(EINVAL); | 186 | return XFS_ERROR(EINVAL); |
201 | } | 187 | } |
202 | 188 | ||
@@ -1878,8 +1864,8 @@ xfs_iunlink( | |||
1878 | */ | 1864 | */ |
1879 | agi = XFS_BUF_TO_AGI(agibp); | 1865 | agi = XFS_BUF_TO_AGI(agibp); |
1880 | agi_ok = | 1866 | agi_ok = |
1881 | INT_GET(agi->agi_magicnum, ARCH_CONVERT) == XFS_AGI_MAGIC && | 1867 | be32_to_cpu(agi->agi_magicnum) == XFS_AGI_MAGIC && |
1882 | XFS_AGI_GOOD_VERSION(INT_GET(agi->agi_versionnum, ARCH_CONVERT)); | 1868 | XFS_AGI_GOOD_VERSION(be32_to_cpu(agi->agi_versionnum)); |
1883 | if (unlikely(XFS_TEST_ERROR(!agi_ok, mp, XFS_ERRTAG_IUNLINK, | 1869 | if (unlikely(XFS_TEST_ERROR(!agi_ok, mp, XFS_ERRTAG_IUNLINK, |
1884 | XFS_RANDOM_IUNLINK))) { | 1870 | XFS_RANDOM_IUNLINK))) { |
1885 | XFS_CORRUPTION_ERROR("xfs_iunlink", XFS_ERRLEVEL_LOW, mp, agi); | 1871 | XFS_CORRUPTION_ERROR("xfs_iunlink", XFS_ERRLEVEL_LOW, mp, agi); |
@@ -1894,9 +1880,9 @@ xfs_iunlink( | |||
1894 | ASSERT(agino != 0); | 1880 | ASSERT(agino != 0); |
1895 | bucket_index = agino % XFS_AGI_UNLINKED_BUCKETS; | 1881 | bucket_index = agino % XFS_AGI_UNLINKED_BUCKETS; |
1896 | ASSERT(agi->agi_unlinked[bucket_index]); | 1882 | ASSERT(agi->agi_unlinked[bucket_index]); |
1897 | ASSERT(INT_GET(agi->agi_unlinked[bucket_index], ARCH_CONVERT) != agino); | 1883 | ASSERT(be32_to_cpu(agi->agi_unlinked[bucket_index]) != agino); |
1898 | 1884 | ||
1899 | if (INT_GET(agi->agi_unlinked[bucket_index], ARCH_CONVERT) != NULLAGINO) { | 1885 | if (be32_to_cpu(agi->agi_unlinked[bucket_index]) != NULLAGINO) { |
1900 | /* | 1886 | /* |
1901 | * There is already another inode in the bucket we need | 1887 | * There is already another inode in the bucket we need |
1902 | * to add ourselves to. Add us at the front of the list. | 1888 | * to add ourselves to. Add us at the front of the list. |
@@ -1923,7 +1909,7 @@ xfs_iunlink( | |||
1923 | * Point the bucket head pointer at the inode being inserted. | 1909 | * Point the bucket head pointer at the inode being inserted. |
1924 | */ | 1910 | */ |
1925 | ASSERT(agino != 0); | 1911 | ASSERT(agino != 0); |
1926 | INT_SET(agi->agi_unlinked[bucket_index], ARCH_CONVERT, agino); | 1912 | agi->agi_unlinked[bucket_index] = cpu_to_be32(agino); |
1927 | offset = offsetof(xfs_agi_t, agi_unlinked) + | 1913 | offset = offsetof(xfs_agi_t, agi_unlinked) + |
1928 | (sizeof(xfs_agino_t) * bucket_index); | 1914 | (sizeof(xfs_agino_t) * bucket_index); |
1929 | xfs_trans_log_buf(tp, agibp, offset, | 1915 | xfs_trans_log_buf(tp, agibp, offset, |
@@ -1981,8 +1967,8 @@ xfs_iunlink_remove( | |||
1981 | */ | 1967 | */ |
1982 | agi = XFS_BUF_TO_AGI(agibp); | 1968 | agi = XFS_BUF_TO_AGI(agibp); |
1983 | agi_ok = | 1969 | agi_ok = |
1984 | INT_GET(agi->agi_magicnum, ARCH_CONVERT) == XFS_AGI_MAGIC && | 1970 | be32_to_cpu(agi->agi_magicnum) == XFS_AGI_MAGIC && |
1985 | XFS_AGI_GOOD_VERSION(INT_GET(agi->agi_versionnum, ARCH_CONVERT)); | 1971 | XFS_AGI_GOOD_VERSION(be32_to_cpu(agi->agi_versionnum)); |
1986 | if (unlikely(XFS_TEST_ERROR(!agi_ok, mp, XFS_ERRTAG_IUNLINK_REMOVE, | 1972 | if (unlikely(XFS_TEST_ERROR(!agi_ok, mp, XFS_ERRTAG_IUNLINK_REMOVE, |
1987 | XFS_RANDOM_IUNLINK_REMOVE))) { | 1973 | XFS_RANDOM_IUNLINK_REMOVE))) { |
1988 | XFS_CORRUPTION_ERROR("xfs_iunlink_remove", XFS_ERRLEVEL_LOW, | 1974 | XFS_CORRUPTION_ERROR("xfs_iunlink_remove", XFS_ERRLEVEL_LOW, |
@@ -2000,10 +1986,10 @@ xfs_iunlink_remove( | |||
2000 | agino = XFS_INO_TO_AGINO(mp, ip->i_ino); | 1986 | agino = XFS_INO_TO_AGINO(mp, ip->i_ino); |
2001 | ASSERT(agino != 0); | 1987 | ASSERT(agino != 0); |
2002 | bucket_index = agino % XFS_AGI_UNLINKED_BUCKETS; | 1988 | bucket_index = agino % XFS_AGI_UNLINKED_BUCKETS; |
2003 | ASSERT(INT_GET(agi->agi_unlinked[bucket_index], ARCH_CONVERT) != NULLAGINO); | 1989 | ASSERT(be32_to_cpu(agi->agi_unlinked[bucket_index]) != NULLAGINO); |
2004 | ASSERT(agi->agi_unlinked[bucket_index]); | 1990 | ASSERT(agi->agi_unlinked[bucket_index]); |
2005 | 1991 | ||
2006 | if (INT_GET(agi->agi_unlinked[bucket_index], ARCH_CONVERT) == agino) { | 1992 | if (be32_to_cpu(agi->agi_unlinked[bucket_index]) == agino) { |
2007 | /* | 1993 | /* |
2008 | * We're at the head of the list. Get the inode's | 1994 | * We're at the head of the list. Get the inode's |
2009 | * on-disk buffer to see if there is anyone after us | 1995 | * on-disk buffer to see if there is anyone after us |
@@ -2037,7 +2023,7 @@ xfs_iunlink_remove( | |||
2037 | */ | 2023 | */ |
2038 | ASSERT(next_agino != 0); | 2024 | ASSERT(next_agino != 0); |
2039 | ASSERT(next_agino != agino); | 2025 | ASSERT(next_agino != agino); |
2040 | INT_SET(agi->agi_unlinked[bucket_index], ARCH_CONVERT, next_agino); | 2026 | agi->agi_unlinked[bucket_index] = cpu_to_be32(next_agino); |
2041 | offset = offsetof(xfs_agi_t, agi_unlinked) + | 2027 | offset = offsetof(xfs_agi_t, agi_unlinked) + |
2042 | (sizeof(xfs_agino_t) * bucket_index); | 2028 | (sizeof(xfs_agino_t) * bucket_index); |
2043 | xfs_trans_log_buf(tp, agibp, offset, | 2029 | xfs_trans_log_buf(tp, agibp, offset, |
@@ -2046,7 +2032,7 @@ xfs_iunlink_remove( | |||
2046 | /* | 2032 | /* |
2047 | * We need to search the list for the inode being freed. | 2033 | * We need to search the list for the inode being freed. |
2048 | */ | 2034 | */ |
2049 | next_agino = INT_GET(agi->agi_unlinked[bucket_index], ARCH_CONVERT); | 2035 | next_agino = be32_to_cpu(agi->agi_unlinked[bucket_index]); |
2050 | last_ibp = NULL; | 2036 | last_ibp = NULL; |
2051 | while (next_agino != agino) { | 2037 | while (next_agino != agino) { |
2052 | /* | 2038 | /* |
@@ -3687,73 +3673,6 @@ xfs_iroundup( | |||
3687 | return( 0 ); | 3673 | return( 0 ); |
3688 | } | 3674 | } |
3689 | 3675 | ||
3690 | /* | ||
3691 | * Change the requested timestamp in the given inode. | ||
3692 | * We don't lock across timestamp updates, and we don't log them but | ||
3693 | * we do record the fact that there is dirty information in core. | ||
3694 | * | ||
3695 | * NOTE -- callers MUST combine XFS_ICHGTIME_MOD or XFS_ICHGTIME_CHG | ||
3696 | * with XFS_ICHGTIME_ACC to be sure that access time | ||
3697 | * update will take. Calling first with XFS_ICHGTIME_ACC | ||
3698 | * and then XFS_ICHGTIME_MOD may fail to modify the access | ||
3699 | * timestamp if the filesystem is mounted noacctm. | ||
3700 | */ | ||
3701 | void | ||
3702 | xfs_ichgtime(xfs_inode_t *ip, | ||
3703 | int flags) | ||
3704 | { | ||
3705 | timespec_t tv; | ||
3706 | vnode_t *vp = XFS_ITOV(ip); | ||
3707 | struct inode *inode = LINVFS_GET_IP(vp); | ||
3708 | |||
3709 | /* | ||
3710 | * We're not supposed to change timestamps in readonly-mounted | ||
3711 | * filesystems. Throw it away if anyone asks us. | ||
3712 | */ | ||
3713 | if (unlikely(vp->v_vfsp->vfs_flag & VFS_RDONLY)) | ||
3714 | return; | ||
3715 | |||
3716 | /* | ||
3717 | * Don't update access timestamps on reads if mounted "noatime" | ||
3718 | * Throw it away if anyone asks us. | ||
3719 | */ | ||
3720 | if ((ip->i_mount->m_flags & XFS_MOUNT_NOATIME || IS_NOATIME(inode)) && | ||
3721 | ((flags & (XFS_ICHGTIME_ACC|XFS_ICHGTIME_MOD|XFS_ICHGTIME_CHG)) | ||
3722 | == XFS_ICHGTIME_ACC)) | ||
3723 | return; | ||
3724 | |||
3725 | nanotime(&tv); | ||
3726 | if (flags & XFS_ICHGTIME_MOD) { | ||
3727 | VN_MTIMESET(vp, &tv); | ||
3728 | ip->i_d.di_mtime.t_sec = (__int32_t)tv.tv_sec; | ||
3729 | ip->i_d.di_mtime.t_nsec = (__int32_t)tv.tv_nsec; | ||
3730 | } | ||
3731 | if (flags & XFS_ICHGTIME_ACC) { | ||
3732 | VN_ATIMESET(vp, &tv); | ||
3733 | ip->i_d.di_atime.t_sec = (__int32_t)tv.tv_sec; | ||
3734 | ip->i_d.di_atime.t_nsec = (__int32_t)tv.tv_nsec; | ||
3735 | } | ||
3736 | if (flags & XFS_ICHGTIME_CHG) { | ||
3737 | VN_CTIMESET(vp, &tv); | ||
3738 | ip->i_d.di_ctime.t_sec = (__int32_t)tv.tv_sec; | ||
3739 | ip->i_d.di_ctime.t_nsec = (__int32_t)tv.tv_nsec; | ||
3740 | } | ||
3741 | |||
3742 | /* | ||
3743 | * We update the i_update_core field _after_ changing | ||
3744 | * the timestamps in order to coordinate properly with | ||
3745 | * xfs_iflush() so that we don't lose timestamp updates. | ||
3746 | * This keeps us from having to hold the inode lock | ||
3747 | * while doing this. We use the SYNCHRONIZE macro to | ||
3748 | * ensure that the compiler does not reorder the update | ||
3749 | * of i_update_core above the timestamp updates above. | ||
3750 | */ | ||
3751 | SYNCHRONIZE(); | ||
3752 | ip->i_update_core = 1; | ||
3753 | if (!(inode->i_state & I_LOCK)) | ||
3754 | mark_inode_dirty_sync(inode); | ||
3755 | } | ||
3756 | |||
3757 | #ifdef XFS_ILOCK_TRACE | 3676 | #ifdef XFS_ILOCK_TRACE |
3758 | ktrace_t *xfs_ilock_trace_buf; | 3677 | ktrace_t *xfs_ilock_trace_buf; |
3759 | 3678 | ||
diff --git a/fs/xfs/xfs_inode.h b/fs/xfs/xfs_inode.h index 54d9e54c7c95..124d30e6143b 100644 --- a/fs/xfs/xfs_inode.h +++ b/fs/xfs/xfs_inode.h | |||
@@ -1,38 +1,30 @@ | |||
1 | /* | 1 | /* |
2 | * Copyright (c) 2000-2003 Silicon Graphics, Inc. All Rights Reserved. | 2 | * Copyright (c) 2000-2003,2005 Silicon Graphics, Inc. |
3 | * All Rights Reserved. | ||
3 | * | 4 | * |
4 | * This program is free software; you can redistribute it and/or modify it | 5 | * This program is free software; you can redistribute it and/or |
5 | * under the terms of version 2 of the GNU General Public License as | 6 | * modify it under the terms of the GNU General Public License as |
6 | * published by the Free Software Foundation. | 7 | * published by the Free Software Foundation. |
7 | * | 8 | * |
8 | * This program is distributed in the hope that it would be useful, but | 9 | * This program is distributed in the hope that it would be useful, |
9 | * WITHOUT ANY WARRANTY; without even the implied warranty of | 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
12 | * GNU General Public License for more details. | ||
11 | * | 13 | * |
12 | * Further, this software is distributed without any warranty that it is | 14 | * You should have received a copy of the GNU General Public License |
13 | * free of the rightful claim of any third person regarding infringement | 15 | * along with this program; if not, write the Free Software Foundation, |
14 | * or the like. Any license provided herein, whether implied or | 16 | * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
15 | * otherwise, applies only to this software file. Patent licenses, if | ||
16 | * any, provided herein do not apply to combinations of this program with | ||
17 | * other software, or any other product whatsoever. | ||
18 | * | ||
19 | * You should have received a copy of the GNU General Public License along | ||
20 | * with this program; if not, write the Free Software Foundation, Inc., 59 | ||
21 | * Temple Place - Suite 330, Boston MA 02111-1307, USA. | ||
22 | * | ||
23 | * Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy, | ||
24 | * Mountain View, CA 94043, or: | ||
25 | * | ||
26 | * http://www.sgi.com | ||
27 | * | ||
28 | * For further information regarding this notice, see: | ||
29 | * | ||
30 | * http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/ | ||
31 | */ | 17 | */ |
32 | #ifndef __XFS_INODE_H__ | 18 | #ifndef __XFS_INODE_H__ |
33 | #define __XFS_INODE_H__ | 19 | #define __XFS_INODE_H__ |
34 | 20 | ||
35 | /* | 21 | /* |
22 | * Fork identifiers. | ||
23 | */ | ||
24 | #define XFS_DATA_FORK 0 | ||
25 | #define XFS_ATTR_FORK 1 | ||
26 | |||
27 | /* | ||
36 | * File incore extent information, present for each of data & attr forks. | 28 | * File incore extent information, present for each of data & attr forks. |
37 | */ | 29 | */ |
38 | #define XFS_INLINE_EXTS 2 | 30 | #define XFS_INLINE_EXTS 2 |
@@ -107,24 +99,6 @@ extern void xfs_ilock_trace(struct xfs_inode *, int, unsigned int, inst_t *); | |||
107 | #define xfs_ilock_trace(i,n,f,ra) | 99 | #define xfs_ilock_trace(i,n,f,ra) |
108 | #endif | 100 | #endif |
109 | 101 | ||
110 | /* | ||
111 | * This structure is used to communicate which extents of a file | ||
112 | * were holes when a write started from xfs_write_file() to | ||
113 | * xfs_strat_read(). This is necessary so that we can know which | ||
114 | * blocks need to be zeroed when they are read in in xfs_strat_read() | ||
115 | * if they weren\'t allocated when the buffer given to xfs_strat_read() | ||
116 | * was mapped. | ||
117 | * | ||
118 | * We keep a list of these attached to the inode. The list is | ||
119 | * protected by the inode lock and the fact that the io lock is | ||
120 | * held exclusively by writers. | ||
121 | */ | ||
122 | typedef struct xfs_gap { | ||
123 | struct xfs_gap *xg_next; | ||
124 | xfs_fileoff_t xg_offset_fsb; | ||
125 | xfs_extlen_t xg_count_fsb; | ||
126 | } xfs_gap_t; | ||
127 | |||
128 | typedef struct dm_attrs_s { | 102 | typedef struct dm_attrs_s { |
129 | __uint32_t da_dmevmask; /* DMIG event mask */ | 103 | __uint32_t da_dmevmask; /* DMIG event mask */ |
130 | __uint16_t da_dmstate; /* DMIG state info */ | 104 | __uint16_t da_dmstate; /* DMIG state info */ |
@@ -311,60 +285,16 @@ typedef struct xfs_inode { | |||
311 | /* | 285 | /* |
312 | * Fork handling. | 286 | * Fork handling. |
313 | */ | 287 | */ |
314 | #if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_IFORK_PTR) | 288 | #define XFS_IFORK_PTR(ip,w) \ |
315 | xfs_ifork_t *xfs_ifork_ptr(xfs_inode_t *ip, int w); | 289 | ((w) == XFS_DATA_FORK ? &(ip)->i_df : (ip)->i_afp) |
316 | #define XFS_IFORK_PTR(ip,w) xfs_ifork_ptr(ip,w) | ||
317 | #else | ||
318 | #define XFS_IFORK_PTR(ip,w) ((w) == XFS_DATA_FORK ? &(ip)->i_df : (ip)->i_afp) | ||
319 | #endif | ||
320 | #if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_IFORK_Q) | ||
321 | int xfs_ifork_q(xfs_inode_t *ip); | ||
322 | #define XFS_IFORK_Q(ip) xfs_ifork_q(ip) | ||
323 | #else | ||
324 | #define XFS_IFORK_Q(ip) XFS_CFORK_Q(&(ip)->i_d) | 290 | #define XFS_IFORK_Q(ip) XFS_CFORK_Q(&(ip)->i_d) |
325 | #endif | ||
326 | #if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_IFORK_DSIZE) | ||
327 | int xfs_ifork_dsize(xfs_inode_t *ip); | ||
328 | #define XFS_IFORK_DSIZE(ip) xfs_ifork_dsize(ip) | ||
329 | #else | ||
330 | #define XFS_IFORK_DSIZE(ip) XFS_CFORK_DSIZE(&ip->i_d, ip->i_mount) | 291 | #define XFS_IFORK_DSIZE(ip) XFS_CFORK_DSIZE(&ip->i_d, ip->i_mount) |
331 | #endif | ||
332 | #if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_IFORK_ASIZE) | ||
333 | int xfs_ifork_asize(xfs_inode_t *ip); | ||
334 | #define XFS_IFORK_ASIZE(ip) xfs_ifork_asize(ip) | ||
335 | #else | ||
336 | #define XFS_IFORK_ASIZE(ip) XFS_CFORK_ASIZE(&ip->i_d, ip->i_mount) | 292 | #define XFS_IFORK_ASIZE(ip) XFS_CFORK_ASIZE(&ip->i_d, ip->i_mount) |
337 | #endif | ||
338 | #if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_IFORK_SIZE) | ||
339 | int xfs_ifork_size(xfs_inode_t *ip, int w); | ||
340 | #define XFS_IFORK_SIZE(ip,w) xfs_ifork_size(ip,w) | ||
341 | #else | ||
342 | #define XFS_IFORK_SIZE(ip,w) XFS_CFORK_SIZE(&ip->i_d, ip->i_mount, w) | 293 | #define XFS_IFORK_SIZE(ip,w) XFS_CFORK_SIZE(&ip->i_d, ip->i_mount, w) |
343 | #endif | ||
344 | #if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_IFORK_FORMAT) | ||
345 | int xfs_ifork_format(xfs_inode_t *ip, int w); | ||
346 | #define XFS_IFORK_FORMAT(ip,w) xfs_ifork_format(ip,w) | ||
347 | #else | ||
348 | #define XFS_IFORK_FORMAT(ip,w) XFS_CFORK_FORMAT(&ip->i_d, w) | 294 | #define XFS_IFORK_FORMAT(ip,w) XFS_CFORK_FORMAT(&ip->i_d, w) |
349 | #endif | ||
350 | #if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_IFORK_FMT_SET) | ||
351 | void xfs_ifork_fmt_set(xfs_inode_t *ip, int w, int n); | ||
352 | #define XFS_IFORK_FMT_SET(ip,w,n) xfs_ifork_fmt_set(ip,w,n) | ||
353 | #else | ||
354 | #define XFS_IFORK_FMT_SET(ip,w,n) XFS_CFORK_FMT_SET(&ip->i_d, w, n) | 295 | #define XFS_IFORK_FMT_SET(ip,w,n) XFS_CFORK_FMT_SET(&ip->i_d, w, n) |
355 | #endif | ||
356 | #if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_IFORK_NEXTENTS) | ||
357 | int xfs_ifork_nextents(xfs_inode_t *ip, int w); | ||
358 | #define XFS_IFORK_NEXTENTS(ip,w) xfs_ifork_nextents(ip,w) | ||
359 | #else | ||
360 | #define XFS_IFORK_NEXTENTS(ip,w) XFS_CFORK_NEXTENTS(&ip->i_d, w) | 296 | #define XFS_IFORK_NEXTENTS(ip,w) XFS_CFORK_NEXTENTS(&ip->i_d, w) |
361 | #endif | ||
362 | #if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_IFORK_NEXT_SET) | ||
363 | void xfs_ifork_next_set(xfs_inode_t *ip, int w, int n); | ||
364 | #define XFS_IFORK_NEXT_SET(ip,w,n) xfs_ifork_next_set(ip,w,n) | ||
365 | #else | ||
366 | #define XFS_IFORK_NEXT_SET(ip,w,n) XFS_CFORK_NEXT_SET(&ip->i_d, w, n) | 297 | #define XFS_IFORK_NEXT_SET(ip,w,n) XFS_CFORK_NEXT_SET(&ip->i_d, w, n) |
367 | #endif | ||
368 | 298 | ||
369 | 299 | ||
370 | #ifdef __KERNEL__ | 300 | #ifdef __KERNEL__ |
@@ -388,6 +318,7 @@ void xfs_ifork_next_set(xfs_inode_t *ip, int w, int n); | |||
388 | #define XFS_ILOCK_EXCL 0x004 | 318 | #define XFS_ILOCK_EXCL 0x004 |
389 | #define XFS_ILOCK_SHARED 0x008 | 319 | #define XFS_ILOCK_SHARED 0x008 |
390 | #define XFS_IUNLOCK_NONOTIFY 0x010 | 320 | #define XFS_IUNLOCK_NONOTIFY 0x010 |
321 | /* XFS_IOLOCK_NESTED 0x020 */ | ||
391 | #define XFS_EXTENT_TOKEN_RD 0x040 | 322 | #define XFS_EXTENT_TOKEN_RD 0x040 |
392 | #define XFS_SIZE_TOKEN_RD 0x080 | 323 | #define XFS_SIZE_TOKEN_RD 0x080 |
393 | #define XFS_EXTSIZE_RD (XFS_EXTENT_TOKEN_RD|XFS_SIZE_TOKEN_RD) | 324 | #define XFS_EXTSIZE_RD (XFS_EXTENT_TOKEN_RD|XFS_SIZE_TOKEN_RD) |
@@ -395,7 +326,7 @@ void xfs_ifork_next_set(xfs_inode_t *ip, int w, int n); | |||
395 | #define XFS_EXTENT_TOKEN_WR (XFS_EXTENT_TOKEN_RD | XFS_WILLLEND) | 326 | #define XFS_EXTENT_TOKEN_WR (XFS_EXTENT_TOKEN_RD | XFS_WILLLEND) |
396 | #define XFS_SIZE_TOKEN_WR (XFS_SIZE_TOKEN_RD | XFS_WILLLEND) | 327 | #define XFS_SIZE_TOKEN_WR (XFS_SIZE_TOKEN_RD | XFS_WILLLEND) |
397 | #define XFS_EXTSIZE_WR (XFS_EXTSIZE_RD | XFS_WILLLEND) | 328 | #define XFS_EXTSIZE_WR (XFS_EXTSIZE_RD | XFS_WILLLEND) |
398 | 329 | /* XFS_SIZE_TOKEN_WANT 0x200 */ | |
399 | 330 | ||
400 | #define XFS_LOCK_MASK \ | 331 | #define XFS_LOCK_MASK \ |
401 | (XFS_IOLOCK_EXCL | XFS_IOLOCK_SHARED | XFS_ILOCK_EXCL | \ | 332 | (XFS_IOLOCK_EXCL | XFS_IOLOCK_SHARED | XFS_ILOCK_EXCL | \ |
@@ -417,28 +348,11 @@ void xfs_ifork_next_set(xfs_inode_t *ip, int w, int n); | |||
417 | #define XFS_ITRUNC_DEFINITE 0x1 | 348 | #define XFS_ITRUNC_DEFINITE 0x1 |
418 | #define XFS_ITRUNC_MAYBE 0x2 | 349 | #define XFS_ITRUNC_MAYBE 0x2 |
419 | 350 | ||
420 | #if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_ITOV) | ||
421 | struct vnode *xfs_itov(xfs_inode_t *ip); | ||
422 | #define XFS_ITOV(ip) xfs_itov(ip) | ||
423 | #else | ||
424 | #define XFS_ITOV(ip) BHV_TO_VNODE(XFS_ITOBHV(ip)) | 351 | #define XFS_ITOV(ip) BHV_TO_VNODE(XFS_ITOBHV(ip)) |
425 | #endif | ||
426 | #define XFS_ITOV_NULL(ip) BHV_TO_VNODE_NULL(XFS_ITOBHV(ip)) | 352 | #define XFS_ITOV_NULL(ip) BHV_TO_VNODE_NULL(XFS_ITOBHV(ip)) |
427 | #if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_ITOBHV) | ||
428 | struct bhv_desc *xfs_itobhv(xfs_inode_t *ip); | ||
429 | #define XFS_ITOBHV(ip) xfs_itobhv(ip) | ||
430 | #else | ||
431 | #define XFS_ITOBHV(ip) ((struct bhv_desc *)(&((ip)->i_bhv_desc))) | 353 | #define XFS_ITOBHV(ip) ((struct bhv_desc *)(&((ip)->i_bhv_desc))) |
432 | #endif | 354 | #define XFS_BHVTOI(bhvp) ((xfs_inode_t *)((char *)(bhvp) - \ |
433 | #if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_BHVTOI) | 355 | (char *)&(((xfs_inode_t *)0)->i_bhv_desc))) |
434 | xfs_inode_t *xfs_bhvtoi(struct bhv_desc *bhvp); | ||
435 | #define XFS_BHVTOI(bhvp) xfs_bhvtoi(bhvp) | ||
436 | #else | ||
437 | #define XFS_BHVTOI(bhvp) \ | ||
438 | ((xfs_inode_t *)((char *)(bhvp) - \ | ||
439 | (char *)&(((xfs_inode_t *)0)->i_bhv_desc))) | ||
440 | #endif | ||
441 | |||
442 | #define BHV_IS_XFS(bdp) (BHV_OPS(bdp) == &xfs_vnodeops) | 356 | #define BHV_IS_XFS(bdp) (BHV_OPS(bdp) == &xfs_vnodeops) |
443 | 357 | ||
444 | /* | 358 | /* |
diff --git a/fs/xfs/xfs_inode_item.c b/fs/xfs/xfs_inode_item.c index 50e2cadf9091..7f3363c621e1 100644 --- a/fs/xfs/xfs_inode_item.c +++ b/fs/xfs/xfs_inode_item.c | |||
@@ -1,66 +1,46 @@ | |||
1 | /* | 1 | /* |
2 | * Copyright (c) 2000-2002 Silicon Graphics, Inc. All Rights Reserved. | 2 | * Copyright (c) 2000-2002,2005 Silicon Graphics, Inc. |
3 | * All Rights Reserved. | ||
3 | * | 4 | * |
4 | * This program is free software; you can redistribute it and/or modify it | 5 | * This program is free software; you can redistribute it and/or |
5 | * under the terms of version 2 of the GNU General Public License as | 6 | * modify it under the terms of the GNU General Public License as |
6 | * published by the Free Software Foundation. | 7 | * published by the Free Software Foundation. |
7 | * | 8 | * |
8 | * This program is distributed in the hope that it would be useful, but | 9 | * This program is distributed in the hope that it would be useful, |
9 | * WITHOUT ANY WARRANTY; without even the implied warranty of | 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
12 | * GNU General Public License for more details. | ||
11 | * | 13 | * |
12 | * Further, this software is distributed without any warranty that it is | 14 | * You should have received a copy of the GNU General Public License |
13 | * free of the rightful claim of any third person regarding infringement | 15 | * along with this program; if not, write the Free Software Foundation, |
14 | * or the like. Any license provided herein, whether implied or | 16 | * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
15 | * otherwise, applies only to this software file. Patent licenses, if | ||
16 | * any, provided herein do not apply to combinations of this program with | ||
17 | * other software, or any other product whatsoever. | ||
18 | * | ||
19 | * You should have received a copy of the GNU General Public License along | ||
20 | * with this program; if not, write the Free Software Foundation, Inc., 59 | ||
21 | * Temple Place - Suite 330, Boston MA 02111-1307, USA. | ||
22 | * | ||
23 | * Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy, | ||
24 | * Mountain View, CA 94043, or: | ||
25 | * | ||
26 | * http://www.sgi.com | ||
27 | * | ||
28 | * For further information regarding this notice, see: | ||
29 | * | ||
30 | * http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/ | ||
31 | */ | ||
32 | |||
33 | /* | ||
34 | * This file contains the implementation of the xfs_inode_log_item. | ||
35 | * It contains the item operations used to manipulate the inode log | ||
36 | * items as well as utility routines used by the inode specific | ||
37 | * transaction routines. | ||
38 | */ | 17 | */ |
39 | #include "xfs.h" | 18 | #include "xfs.h" |
40 | #include "xfs_macros.h" | 19 | #include "xfs_fs.h" |
41 | #include "xfs_types.h" | 20 | #include "xfs_types.h" |
42 | #include "xfs_inum.h" | 21 | #include "xfs_bit.h" |
43 | #include "xfs_log.h" | 22 | #include "xfs_log.h" |
23 | #include "xfs_inum.h" | ||
44 | #include "xfs_trans.h" | 24 | #include "xfs_trans.h" |
45 | #include "xfs_buf_item.h" | 25 | #include "xfs_buf_item.h" |
46 | #include "xfs_sb.h" | 26 | #include "xfs_sb.h" |
27 | #include "xfs_ag.h" | ||
47 | #include "xfs_dir.h" | 28 | #include "xfs_dir.h" |
48 | #include "xfs_dir2.h" | 29 | #include "xfs_dir2.h" |
49 | #include "xfs_dmapi.h" | 30 | #include "xfs_dmapi.h" |
50 | #include "xfs_mount.h" | 31 | #include "xfs_mount.h" |
51 | #include "xfs_trans_priv.h" | 32 | #include "xfs_trans_priv.h" |
52 | #include "xfs_ag.h" | ||
53 | #include "xfs_alloc_btree.h" | ||
54 | #include "xfs_bmap_btree.h" | 33 | #include "xfs_bmap_btree.h" |
34 | #include "xfs_alloc_btree.h" | ||
55 | #include "xfs_ialloc_btree.h" | 35 | #include "xfs_ialloc_btree.h" |
56 | #include "xfs_btree.h" | ||
57 | #include "xfs_ialloc.h" | ||
58 | #include "xfs_attr_sf.h" | ||
59 | #include "xfs_dir_sf.h" | 36 | #include "xfs_dir_sf.h" |
60 | #include "xfs_dir2_sf.h" | 37 | #include "xfs_dir2_sf.h" |
38 | #include "xfs_attr_sf.h" | ||
61 | #include "xfs_dinode.h" | 39 | #include "xfs_dinode.h" |
62 | #include "xfs_inode_item.h" | ||
63 | #include "xfs_inode.h" | 40 | #include "xfs_inode.h" |
41 | #include "xfs_inode_item.h" | ||
42 | #include "xfs_btree.h" | ||
43 | #include "xfs_ialloc.h" | ||
64 | #include "xfs_rw.h" | 44 | #include "xfs_rw.h" |
65 | 45 | ||
66 | 46 | ||
diff --git a/fs/xfs/xfs_inode_item.h b/fs/xfs/xfs_inode_item.h index d8775e0d6291..c5dbf93b6661 100644 --- a/fs/xfs/xfs_inode_item.h +++ b/fs/xfs/xfs_inode_item.h | |||
@@ -1,33 +1,19 @@ | |||
1 | /* | 1 | /* |
2 | * Copyright (c) 2000 Silicon Graphics, Inc. All Rights Reserved. | 2 | * Copyright (c) 2000,2005 Silicon Graphics, Inc. |
3 | * All Rights Reserved. | ||
3 | * | 4 | * |
4 | * This program is free software; you can redistribute it and/or modify it | 5 | * This program is free software; you can redistribute it and/or |
5 | * under the terms of version 2 of the GNU General Public License as | 6 | * modify it under the terms of the GNU General Public License as |
6 | * published by the Free Software Foundation. | 7 | * published by the Free Software Foundation. |
7 | * | 8 | * |
8 | * This program is distributed in the hope that it would be useful, but | 9 | * This program is distributed in the hope that it would be useful, |
9 | * WITHOUT ANY WARRANTY; without even the implied warranty of | 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
12 | * GNU General Public License for more details. | ||
11 | * | 13 | * |
12 | * Further, this software is distributed without any warranty that it is | 14 | * You should have received a copy of the GNU General Public License |
13 | * free of the rightful claim of any third person regarding infringement | 15 | * along with this program; if not, write the Free Software Foundation, |
14 | * or the like. Any license provided herein, whether implied or | 16 | * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
15 | * otherwise, applies only to this software file. Patent licenses, if | ||
16 | * any, provided herein do not apply to combinations of this program with | ||
17 | * other software, or any other product whatsoever. | ||
18 | * | ||
19 | * You should have received a copy of the GNU General Public License along | ||
20 | * with this program; if not, write the Free Software Foundation, Inc., 59 | ||
21 | * Temple Place - Suite 330, Boston MA 02111-1307, USA. | ||
22 | * | ||
23 | * Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy, | ||
24 | * Mountain View, CA 94043, or: | ||
25 | * | ||
26 | * http://www.sgi.com | ||
27 | * | ||
28 | * For further information regarding this notice, see: | ||
29 | * | ||
30 | * http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/ | ||
31 | */ | 17 | */ |
32 | #ifndef __XFS_INODE_ITEM_H__ | 18 | #ifndef __XFS_INODE_ITEM_H__ |
33 | #define __XFS_INODE_ITEM_H__ | 19 | #define __XFS_INODE_ITEM_H__ |
@@ -159,38 +145,33 @@ typedef struct xfs_inode_log_item { | |||
159 | } xfs_inode_log_item_t; | 145 | } xfs_inode_log_item_t; |
160 | 146 | ||
161 | 147 | ||
162 | #if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_ILOG_FDATA) | ||
163 | int xfs_ilog_fdata(int w); | ||
164 | #define XFS_ILOG_FDATA(w) xfs_ilog_fdata(w) | 148 | #define XFS_ILOG_FDATA(w) xfs_ilog_fdata(w) |
165 | #else | 149 | static inline int xfs_ilog_fdata(int w) |
166 | #define XFS_ILOG_FDATA(w) \ | 150 | { |
167 | ((w) == XFS_DATA_FORK ? XFS_ILOG_DDATA : XFS_ILOG_ADATA) | 151 | return (w == XFS_DATA_FORK ? XFS_ILOG_DDATA : XFS_ILOG_ADATA); |
168 | #endif | 152 | } |
169 | 153 | ||
170 | #endif /* __KERNEL__ */ | 154 | #endif /* __KERNEL__ */ |
171 | 155 | ||
172 | #if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_ILOG_FBROOT) | ||
173 | int xfs_ilog_fbroot(int w); | ||
174 | #define XFS_ILOG_FBROOT(w) xfs_ilog_fbroot(w) | 156 | #define XFS_ILOG_FBROOT(w) xfs_ilog_fbroot(w) |
175 | #else | 157 | static inline int xfs_ilog_fbroot(int w) |
176 | #define XFS_ILOG_FBROOT(w) \ | 158 | { |
177 | ((w) == XFS_DATA_FORK ? XFS_ILOG_DBROOT : XFS_ILOG_ABROOT) | 159 | return (w == XFS_DATA_FORK ? XFS_ILOG_DBROOT : XFS_ILOG_ABROOT); |
178 | #endif | 160 | } |
179 | #if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_ILOG_FEXT) | 161 | |
180 | int xfs_ilog_fext(int w); | ||
181 | #define XFS_ILOG_FEXT(w) xfs_ilog_fext(w) | 162 | #define XFS_ILOG_FEXT(w) xfs_ilog_fext(w) |
182 | #else | 163 | static inline int xfs_ilog_fext(int w) |
183 | #define XFS_ILOG_FEXT(w) \ | 164 | { |
184 | ((w) == XFS_DATA_FORK ? XFS_ILOG_DEXT : XFS_ILOG_AEXT) | 165 | return (w == XFS_DATA_FORK ? XFS_ILOG_DEXT : XFS_ILOG_AEXT); |
185 | #endif | 166 | } |
186 | 167 | ||
187 | #ifdef __KERNEL__ | 168 | #ifdef __KERNEL__ |
188 | 169 | ||
189 | void xfs_inode_item_init(struct xfs_inode *, struct xfs_mount *); | 170 | extern void xfs_inode_item_init(struct xfs_inode *, struct xfs_mount *); |
190 | void xfs_inode_item_destroy(struct xfs_inode *); | 171 | extern void xfs_inode_item_destroy(struct xfs_inode *); |
191 | void xfs_iflush_done(struct xfs_buf *, xfs_inode_log_item_t *); | 172 | extern void xfs_iflush_done(struct xfs_buf *, xfs_inode_log_item_t *); |
192 | void xfs_istale_done(struct xfs_buf *, xfs_inode_log_item_t *); | 173 | extern void xfs_istale_done(struct xfs_buf *, xfs_inode_log_item_t *); |
193 | void xfs_iflush_abort(struct xfs_inode *); | 174 | extern void xfs_iflush_abort(struct xfs_inode *); |
194 | 175 | ||
195 | #endif /* __KERNEL__ */ | 176 | #endif /* __KERNEL__ */ |
196 | 177 | ||
diff --git a/fs/xfs/xfs_inum.h b/fs/xfs/xfs_inum.h index a3af2d5a6eb7..7a28191cb0de 100644 --- a/fs/xfs/xfs_inum.h +++ b/fs/xfs/xfs_inum.h | |||
@@ -1,33 +1,19 @@ | |||
1 | /* | 1 | /* |
2 | * Copyright (c) 2000-2003 Silicon Graphics, Inc. All Rights Reserved. | 2 | * Copyright (c) 2000-2003,2005 Silicon Graphics, Inc. |
3 | * All Rights Reserved. | ||
3 | * | 4 | * |
4 | * This program is free software; you can redistribute it and/or modify it | 5 | * This program is free software; you can redistribute it and/or |
5 | * under the terms of version 2 of the GNU General Public License as | 6 | * modify it under the terms of the GNU General Public License as |
6 | * published by the Free Software Foundation. | 7 | * published by the Free Software Foundation. |
7 | * | 8 | * |
8 | * This program is distributed in the hope that it would be useful, but | 9 | * This program is distributed in the hope that it would be useful, |
9 | * WITHOUT ANY WARRANTY; without even the implied warranty of | 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
12 | * GNU General Public License for more details. | ||
11 | * | 13 | * |
12 | * Further, this software is distributed without any warranty that it is | 14 | * You should have received a copy of the GNU General Public License |
13 | * free of the rightful claim of any third person regarding infringement | 15 | * along with this program; if not, write the Free Software Foundation, |
14 | * or the like. Any license provided herein, whether implied or | 16 | * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
15 | * otherwise, applies only to this software file. Patent licenses, if | ||
16 | * any, provided herein do not apply to combinations of this program with | ||
17 | * other software, or any other product whatsoever. | ||
18 | * | ||
19 | * You should have received a copy of the GNU General Public License along | ||
20 | * with this program; if not, write the Free Software Foundation, Inc., 59 | ||
21 | * Temple Place - Suite 330, Boston MA 02111-1307, USA. | ||
22 | * | ||
23 | * Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy, | ||
24 | * Mountain View, CA 94043, or: | ||
25 | * | ||
26 | * http://www.sgi.com | ||
27 | * | ||
28 | * For further information regarding this notice, see: | ||
29 | * | ||
30 | * http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/ | ||
31 | */ | 17 | */ |
32 | #ifndef __XFS_INUM_H__ | 18 | #ifndef __XFS_INUM_H__ |
33 | #define __XFS_INUM_H__ | 19 | #define __XFS_INUM_H__ |
@@ -58,109 +44,31 @@ typedef __uint32_t xfs_intino_t; | |||
58 | 44 | ||
59 | struct xfs_mount; | 45 | struct xfs_mount; |
60 | 46 | ||
61 | #if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_INO_MASK) | 47 | #define XFS_INO_MASK(k) (__uint32_t)((1ULL << (k)) - 1) |
62 | __uint32_t xfs_ino_mask(int k); | 48 | #define XFS_INO_OFFSET_BITS(mp) (mp)->m_sb.sb_inopblog |
63 | #define XFS_INO_MASK(k) xfs_ino_mask(k) | 49 | #define XFS_INO_AGBNO_BITS(mp) (mp)->m_sb.sb_agblklog |
64 | #else | 50 | #define XFS_INO_AGINO_BITS(mp) (mp)->m_agino_log |
65 | #define XFS_INO_MASK(k) ((__uint32_t)((1ULL << (k)) - 1)) | 51 | #define XFS_INO_AGNO_BITS(mp) (mp)->m_agno_log |
66 | #endif | 52 | #define XFS_INO_BITS(mp) \ |
67 | #if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_INO_OFFSET_BITS) | 53 | XFS_INO_AGNO_BITS(mp) + XFS_INO_AGINO_BITS(mp) |
68 | int xfs_ino_offset_bits(struct xfs_mount *mp); | 54 | #define XFS_INO_TO_AGNO(mp,i) \ |
69 | #define XFS_INO_OFFSET_BITS(mp) xfs_ino_offset_bits(mp) | ||
70 | #else | ||
71 | #define XFS_INO_OFFSET_BITS(mp) ((mp)->m_sb.sb_inopblog) | ||
72 | #endif | ||
73 | #if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_INO_AGBNO_BITS) | ||
74 | int xfs_ino_agbno_bits(struct xfs_mount *mp); | ||
75 | #define XFS_INO_AGBNO_BITS(mp) xfs_ino_agbno_bits(mp) | ||
76 | #else | ||
77 | #define XFS_INO_AGBNO_BITS(mp) ((mp)->m_sb.sb_agblklog) | ||
78 | #endif | ||
79 | #if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_INO_AGINO_BITS) | ||
80 | int xfs_ino_agino_bits(struct xfs_mount *mp); | ||
81 | #define XFS_INO_AGINO_BITS(mp) xfs_ino_agino_bits(mp) | ||
82 | #else | ||
83 | #define XFS_INO_AGINO_BITS(mp) ((mp)->m_agino_log) | ||
84 | #endif | ||
85 | #if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_INO_AGNO_BITS) | ||
86 | int xfs_ino_agno_bits(struct xfs_mount *mp); | ||
87 | #define XFS_INO_AGNO_BITS(mp) xfs_ino_agno_bits(mp) | ||
88 | #else | ||
89 | #define XFS_INO_AGNO_BITS(mp) ((mp)->m_agno_log) | ||
90 | #endif | ||
91 | #if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_INO_BITS) | ||
92 | int xfs_ino_bits(struct xfs_mount *mp); | ||
93 | #define XFS_INO_BITS(mp) xfs_ino_bits(mp) | ||
94 | #else | ||
95 | #define XFS_INO_BITS(mp) (XFS_INO_AGNO_BITS(mp) + XFS_INO_AGINO_BITS(mp)) | ||
96 | #endif | ||
97 | |||
98 | #if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_INO_TO_AGNO) | ||
99 | xfs_agnumber_t xfs_ino_to_agno(struct xfs_mount *mp, xfs_ino_t i); | ||
100 | #define XFS_INO_TO_AGNO(mp,i) xfs_ino_to_agno(mp,i) | ||
101 | #else | ||
102 | #define XFS_INO_TO_AGNO(mp,i) \ | ||
103 | ((xfs_agnumber_t)((i) >> XFS_INO_AGINO_BITS(mp))) | 55 | ((xfs_agnumber_t)((i) >> XFS_INO_AGINO_BITS(mp))) |
104 | #endif | 56 | #define XFS_INO_TO_AGINO(mp,i) \ |
105 | #if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_INO_TO_AGINO) | ||
106 | xfs_agino_t xfs_ino_to_agino(struct xfs_mount *mp, xfs_ino_t i); | ||
107 | #define XFS_INO_TO_AGINO(mp,i) xfs_ino_to_agino(mp,i) | ||
108 | #else | ||
109 | #define XFS_INO_TO_AGINO(mp,i) \ | ||
110 | ((xfs_agino_t)(i) & XFS_INO_MASK(XFS_INO_AGINO_BITS(mp))) | 57 | ((xfs_agino_t)(i) & XFS_INO_MASK(XFS_INO_AGINO_BITS(mp))) |
111 | #endif | 58 | #define XFS_INO_TO_AGBNO(mp,i) \ |
112 | #if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_INO_TO_AGBNO) | ||
113 | xfs_agblock_t xfs_ino_to_agbno(struct xfs_mount *mp, xfs_ino_t i); | ||
114 | #define XFS_INO_TO_AGBNO(mp,i) xfs_ino_to_agbno(mp,i) | ||
115 | #else | ||
116 | #define XFS_INO_TO_AGBNO(mp,i) \ | ||
117 | (((xfs_agblock_t)(i) >> XFS_INO_OFFSET_BITS(mp)) & \ | 59 | (((xfs_agblock_t)(i) >> XFS_INO_OFFSET_BITS(mp)) & \ |
118 | XFS_INO_MASK(XFS_INO_AGBNO_BITS(mp))) | 60 | XFS_INO_MASK(XFS_INO_AGBNO_BITS(mp))) |
119 | #endif | 61 | #define XFS_INO_TO_OFFSET(mp,i) \ |
120 | #if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_INO_TO_OFFSET) | ||
121 | int xfs_ino_to_offset(struct xfs_mount *mp, xfs_ino_t i); | ||
122 | #define XFS_INO_TO_OFFSET(mp,i) xfs_ino_to_offset(mp,i) | ||
123 | #else | ||
124 | #define XFS_INO_TO_OFFSET(mp,i) \ | ||
125 | ((int)(i) & XFS_INO_MASK(XFS_INO_OFFSET_BITS(mp))) | 62 | ((int)(i) & XFS_INO_MASK(XFS_INO_OFFSET_BITS(mp))) |
126 | #endif | 63 | #define XFS_INO_TO_FSB(mp,i) \ |
127 | #if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_INO_TO_FSB) | ||
128 | xfs_fsblock_t xfs_ino_to_fsb(struct xfs_mount *mp, xfs_ino_t i); | ||
129 | #define XFS_INO_TO_FSB(mp,i) xfs_ino_to_fsb(mp,i) | ||
130 | #else | ||
131 | #define XFS_INO_TO_FSB(mp,i) \ | ||
132 | XFS_AGB_TO_FSB(mp, XFS_INO_TO_AGNO(mp,i), XFS_INO_TO_AGBNO(mp,i)) | 64 | XFS_AGB_TO_FSB(mp, XFS_INO_TO_AGNO(mp,i), XFS_INO_TO_AGBNO(mp,i)) |
133 | #endif | ||
134 | |||
135 | #if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_AGINO_TO_INO) | ||
136 | xfs_ino_t | ||
137 | xfs_agino_to_ino(struct xfs_mount *mp, xfs_agnumber_t a, xfs_agino_t i); | ||
138 | #define XFS_AGINO_TO_INO(mp,a,i) xfs_agino_to_ino(mp,a,i) | ||
139 | #else | ||
140 | #define XFS_AGINO_TO_INO(mp,a,i) \ | 65 | #define XFS_AGINO_TO_INO(mp,a,i) \ |
141 | (((xfs_ino_t)(a) << XFS_INO_AGINO_BITS(mp)) | (i)) | 66 | (((xfs_ino_t)(a) << XFS_INO_AGINO_BITS(mp)) | (i)) |
142 | #endif | ||
143 | #if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_AGINO_TO_AGBNO) | ||
144 | xfs_agblock_t xfs_agino_to_agbno(struct xfs_mount *mp, xfs_agino_t i); | ||
145 | #define XFS_AGINO_TO_AGBNO(mp,i) xfs_agino_to_agbno(mp,i) | ||
146 | #else | ||
147 | #define XFS_AGINO_TO_AGBNO(mp,i) ((i) >> XFS_INO_OFFSET_BITS(mp)) | 67 | #define XFS_AGINO_TO_AGBNO(mp,i) ((i) >> XFS_INO_OFFSET_BITS(mp)) |
148 | #endif | ||
149 | #if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_AGINO_TO_OFFSET) | ||
150 | int xfs_agino_to_offset(struct xfs_mount *mp, xfs_agino_t i); | ||
151 | #define XFS_AGINO_TO_OFFSET(mp,i) xfs_agino_to_offset(mp,i) | ||
152 | #else | ||
153 | #define XFS_AGINO_TO_OFFSET(mp,i) \ | 68 | #define XFS_AGINO_TO_OFFSET(mp,i) \ |
154 | ((i) & XFS_INO_MASK(XFS_INO_OFFSET_BITS(mp))) | 69 | ((i) & XFS_INO_MASK(XFS_INO_OFFSET_BITS(mp))) |
155 | #endif | ||
156 | |||
157 | #if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_OFFBNO_TO_AGINO) | ||
158 | xfs_agino_t xfs_offbno_to_agino(struct xfs_mount *mp, xfs_agblock_t b, int o); | ||
159 | #define XFS_OFFBNO_TO_AGINO(mp,b,o) xfs_offbno_to_agino(mp,b,o) | ||
160 | #else | ||
161 | #define XFS_OFFBNO_TO_AGINO(mp,b,o) \ | 70 | #define XFS_OFFBNO_TO_AGINO(mp,b,o) \ |
162 | ((xfs_agino_t)(((b) << XFS_INO_OFFSET_BITS(mp)) | (o))) | 71 | ((xfs_agino_t)(((b) << XFS_INO_OFFSET_BITS(mp)) | (o))) |
163 | #endif | ||
164 | 72 | ||
165 | #if XFS_BIG_INUMS | 73 | #if XFS_BIG_INUMS |
166 | #define XFS_MAXINUMBER ((xfs_ino_t)((1ULL << 56) - 1ULL)) | 74 | #define XFS_MAXINUMBER ((xfs_ino_t)((1ULL << 56) - 1ULL)) |
diff --git a/fs/xfs/xfs_iocore.c b/fs/xfs/xfs_iocore.c index 414ec496845f..a07815661a8c 100644 --- a/fs/xfs/xfs_iocore.c +++ b/fs/xfs/xfs_iocore.c | |||
@@ -1,40 +1,26 @@ | |||
1 | /* | 1 | /* |
2 | * Copyright (c) 2000-2003 Silicon Graphics, Inc. All Rights Reserved. | 2 | * Copyright (c) 2000-2003,2005 Silicon Graphics, Inc. |
3 | * All Rights Reserved. | ||
3 | * | 4 | * |
4 | * This program is free software; you can redistribute it and/or modify it | 5 | * This program is free software; you can redistribute it and/or |
5 | * under the terms of version 2 of the GNU General Public License as | 6 | * modify it under the terms of the GNU General Public License as |
6 | * published by the Free Software Foundation. | 7 | * published by the Free Software Foundation. |
7 | * | 8 | * |
8 | * This program is distributed in the hope that it would be useful, but | 9 | * This program is distributed in the hope that it would be useful, |
9 | * WITHOUT ANY WARRANTY; without even the implied warranty of | 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
12 | * GNU General Public License for more details. | ||
11 | * | 13 | * |
12 | * Further, this software is distributed without any warranty that it is | 14 | * You should have received a copy of the GNU General Public License |
13 | * free of the rightful claim of any third person regarding infringement | 15 | * along with this program; if not, write the Free Software Foundation, |
14 | * or the like. Any license provided herein, whether implied or | 16 | * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
15 | * otherwise, applies only to this software file. Patent licenses, if | ||
16 | * any, provided herein do not apply to combinations of this program with | ||
17 | * other software, or any other product whatsoever. | ||
18 | * | ||
19 | * You should have received a copy of the GNU General Public License along | ||
20 | * with this program; if not, write the Free Software Foundation, Inc., 59 | ||
21 | * Temple Place - Suite 330, Boston MA 02111-1307, USA. | ||
22 | * | ||
23 | * Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy, | ||
24 | * Mountain View, CA 94043, or: | ||
25 | * | ||
26 | * http://www.sgi.com | ||
27 | * | ||
28 | * For further information regarding this notice, see: | ||
29 | * | ||
30 | * http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/ | ||
31 | */ | 17 | */ |
32 | |||
33 | #include "xfs.h" | 18 | #include "xfs.h" |
34 | #include "xfs_macros.h" | 19 | #include "xfs_fs.h" |
35 | #include "xfs_types.h" | 20 | #include "xfs_types.h" |
36 | #include "xfs_inum.h" | 21 | #include "xfs_bit.h" |
37 | #include "xfs_log.h" | 22 | #include "xfs_log.h" |
23 | #include "xfs_inum.h" | ||
38 | #include "xfs_trans.h" | 24 | #include "xfs_trans.h" |
39 | #include "xfs_sb.h" | 25 | #include "xfs_sb.h" |
40 | #include "xfs_ag.h" | 26 | #include "xfs_ag.h" |
@@ -42,22 +28,21 @@ | |||
42 | #include "xfs_dir2.h" | 28 | #include "xfs_dir2.h" |
43 | #include "xfs_dmapi.h" | 29 | #include "xfs_dmapi.h" |
44 | #include "xfs_mount.h" | 30 | #include "xfs_mount.h" |
45 | #include "xfs_alloc_btree.h" | ||
46 | #include "xfs_bmap_btree.h" | 31 | #include "xfs_bmap_btree.h" |
32 | #include "xfs_alloc_btree.h" | ||
47 | #include "xfs_ialloc_btree.h" | 33 | #include "xfs_ialloc_btree.h" |
48 | #include "xfs_itable.h" | ||
49 | #include "xfs_btree.h" | ||
50 | #include "xfs_alloc.h" | ||
51 | #include "xfs_ialloc.h" | ||
52 | #include "xfs_attr_sf.h" | ||
53 | #include "xfs_dir_sf.h" | 34 | #include "xfs_dir_sf.h" |
54 | #include "xfs_dir2_sf.h" | 35 | #include "xfs_dir2_sf.h" |
36 | #include "xfs_attr_sf.h" | ||
55 | #include "xfs_dinode.h" | 37 | #include "xfs_dinode.h" |
56 | #include "xfs_inode_item.h" | ||
57 | #include "xfs_inode.h" | 38 | #include "xfs_inode.h" |
39 | #include "xfs_inode_item.h" | ||
40 | #include "xfs_itable.h" | ||
41 | #include "xfs_btree.h" | ||
42 | #include "xfs_alloc.h" | ||
43 | #include "xfs_ialloc.h" | ||
58 | #include "xfs_bmap.h" | 44 | #include "xfs_bmap.h" |
59 | #include "xfs_error.h" | 45 | #include "xfs_error.h" |
60 | #include "xfs_bit.h" | ||
61 | #include "xfs_rw.h" | 46 | #include "xfs_rw.h" |
62 | #include "xfs_quota.h" | 47 | #include "xfs_quota.h" |
63 | #include "xfs_trans_space.h" | 48 | #include "xfs_trans_space.h" |
diff --git a/fs/xfs/xfs_iomap.c b/fs/xfs/xfs_iomap.c index d0f5be63cddb..45a77a3a6c07 100644 --- a/fs/xfs/xfs_iomap.c +++ b/fs/xfs/xfs_iomap.c | |||
@@ -1,40 +1,25 @@ | |||
1 | /* | 1 | /* |
2 | * Copyright (c) 2000-2004 Silicon Graphics, Inc. All Rights Reserved. | 2 | * Copyright (c) 2000-2005 Silicon Graphics, Inc. |
3 | * All Rights Reserved. | ||
3 | * | 4 | * |
4 | * This program is free software; you can redistribute it and/or modify it | 5 | * This program is free software; you can redistribute it and/or |
5 | * under the terms of version 2 of the GNU General Public License as | 6 | * modify it under the terms of the GNU General Public License as |
6 | * published by the Free Software Foundation. | 7 | * published by the Free Software Foundation. |
7 | * | 8 | * |
8 | * This program is distributed in the hope that it would be useful, but | 9 | * This program is distributed in the hope that it would be useful, |
9 | * WITHOUT ANY WARRANTY; without even the implied warranty of | 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
12 | * GNU General Public License for more details. | ||
11 | * | 13 | * |
12 | * Further, this software is distributed without any warranty that it is | 14 | * You should have received a copy of the GNU General Public License |
13 | * free of the rightful claim of any third person regarding infringement | 15 | * along with this program; if not, write the Free Software Foundation, |
14 | * or the like. Any license provided herein, whether implied or | 16 | * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
15 | * otherwise, applies only to this software file. Patent licenses, if | ||
16 | * any, provided herein do not apply to combinations of this program with | ||
17 | * other software, or any other product whatsoever. | ||
18 | * | ||
19 | * You should have received a copy of the GNU General Public License along | ||
20 | * with this program; if not, write the Free Software Foundation, Inc., 59 | ||
21 | * Temple Place - Suite 330, Boston MA 02111-1307, USA. | ||
22 | * | ||
23 | * Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy, | ||
24 | * Mountain View, CA 94043, or: | ||
25 | * | ||
26 | * http://www.sgi.com | ||
27 | * | ||
28 | * For further information regarding this notice, see: | ||
29 | * | ||
30 | * http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/ | ||
31 | */ | 17 | */ |
32 | |||
33 | #include "xfs.h" | 18 | #include "xfs.h" |
34 | |||
35 | #include "xfs_fs.h" | 19 | #include "xfs_fs.h" |
36 | #include "xfs_inum.h" | 20 | #include "xfs_bit.h" |
37 | #include "xfs_log.h" | 21 | #include "xfs_log.h" |
22 | #include "xfs_inum.h" | ||
38 | #include "xfs_trans.h" | 23 | #include "xfs_trans.h" |
39 | #include "xfs_sb.h" | 24 | #include "xfs_sb.h" |
40 | #include "xfs_ag.h" | 25 | #include "xfs_ag.h" |
@@ -44,16 +29,16 @@ | |||
44 | #include "xfs_dmapi.h" | 29 | #include "xfs_dmapi.h" |
45 | #include "xfs_quota.h" | 30 | #include "xfs_quota.h" |
46 | #include "xfs_mount.h" | 31 | #include "xfs_mount.h" |
47 | #include "xfs_alloc_btree.h" | ||
48 | #include "xfs_bmap_btree.h" | 32 | #include "xfs_bmap_btree.h" |
33 | #include "xfs_alloc_btree.h" | ||
49 | #include "xfs_ialloc_btree.h" | 34 | #include "xfs_ialloc_btree.h" |
50 | #include "xfs_btree.h" | ||
51 | #include "xfs_ialloc.h" | ||
52 | #include "xfs_attr_sf.h" | ||
53 | #include "xfs_dir_sf.h" | 35 | #include "xfs_dir_sf.h" |
54 | #include "xfs_dir2_sf.h" | 36 | #include "xfs_dir2_sf.h" |
37 | #include "xfs_attr_sf.h" | ||
55 | #include "xfs_dinode.h" | 38 | #include "xfs_dinode.h" |
56 | #include "xfs_inode.h" | 39 | #include "xfs_inode.h" |
40 | #include "xfs_ialloc.h" | ||
41 | #include "xfs_btree.h" | ||
57 | #include "xfs_bmap.h" | 42 | #include "xfs_bmap.h" |
58 | #include "xfs_bit.h" | 43 | #include "xfs_bit.h" |
59 | #include "xfs_rtalloc.h" | 44 | #include "xfs_rtalloc.h" |
@@ -379,17 +364,15 @@ xfs_iomap_write_direct( | |||
379 | xfs_fileoff_t offset_fsb; | 364 | xfs_fileoff_t offset_fsb; |
380 | xfs_fileoff_t last_fsb; | 365 | xfs_fileoff_t last_fsb; |
381 | xfs_filblks_t count_fsb; | 366 | xfs_filblks_t count_fsb; |
382 | xfs_fsize_t isize; | ||
383 | xfs_fsblock_t firstfsb; | 367 | xfs_fsblock_t firstfsb; |
384 | int nimaps, maps; | 368 | int nimaps; |
385 | int error; | 369 | int error; |
386 | int bmapi_flag; | 370 | int bmapi_flag; |
387 | int quota_flag; | 371 | int quota_flag; |
388 | int rt; | 372 | int rt; |
389 | xfs_trans_t *tp; | 373 | xfs_trans_t *tp; |
390 | xfs_bmbt_irec_t imap[XFS_WRITE_IMAPS], *imapp; | 374 | xfs_bmbt_irec_t imap; |
391 | xfs_bmap_free_t free_list; | 375 | xfs_bmap_free_t free_list; |
392 | int aeof; | ||
393 | xfs_filblks_t qblocks, resblks; | 376 | xfs_filblks_t qblocks, resblks; |
394 | int committed; | 377 | int committed; |
395 | int resrtextents; | 378 | int resrtextents; |
@@ -402,15 +385,6 @@ xfs_iomap_write_direct( | |||
402 | if (error) | 385 | if (error) |
403 | return XFS_ERROR(error); | 386 | return XFS_ERROR(error); |
404 | 387 | ||
405 | maps = min(XFS_WRITE_IMAPS, *nmaps); | ||
406 | nimaps = maps; | ||
407 | |||
408 | isize = ip->i_d.di_size; | ||
409 | aeof = (offset + count) > isize; | ||
410 | |||
411 | if (io->io_new_size > isize) | ||
412 | isize = io->io_new_size; | ||
413 | |||
414 | offset_fsb = XFS_B_TO_FSBT(mp, offset); | 388 | offset_fsb = XFS_B_TO_FSBT(mp, offset); |
415 | last_fsb = XFS_B_TO_FSB(mp, ((xfs_ufsize_t)(offset + count))); | 389 | last_fsb = XFS_B_TO_FSB(mp, ((xfs_ufsize_t)(offset + count))); |
416 | count_fsb = last_fsb - offset_fsb; | 390 | count_fsb = last_fsb - offset_fsb; |
@@ -479,9 +453,8 @@ xfs_iomap_write_direct( | |||
479 | */ | 453 | */ |
480 | XFS_BMAP_INIT(&free_list, &firstfsb); | 454 | XFS_BMAP_INIT(&free_list, &firstfsb); |
481 | nimaps = 1; | 455 | nimaps = 1; |
482 | imapp = &imap[0]; | ||
483 | error = xfs_bmapi(tp, ip, offset_fsb, count_fsb, | 456 | error = xfs_bmapi(tp, ip, offset_fsb, count_fsb, |
484 | bmapi_flag, &firstfsb, 0, imapp, &nimaps, &free_list); | 457 | bmapi_flag, &firstfsb, 0, &imap, &nimaps, &free_list); |
485 | if (error) | 458 | if (error) |
486 | goto error0; | 459 | goto error0; |
487 | 460 | ||
@@ -503,7 +476,7 @@ xfs_iomap_write_direct( | |||
503 | goto error_out; | 476 | goto error_out; |
504 | } | 477 | } |
505 | 478 | ||
506 | *ret_imap = imap[0]; | 479 | *ret_imap = imap; |
507 | *nmaps = 1; | 480 | *nmaps = 1; |
508 | if ( !(io->io_flags & XFS_IOCORE_RT) && !ret_imap->br_startblock) { | 481 | if ( !(io->io_flags & XFS_IOCORE_RT) && !ret_imap->br_startblock) { |
509 | cmn_err(CE_PANIC,"Access to block zero: fs <%s> inode: %lld " | 482 | cmn_err(CE_PANIC,"Access to block zero: fs <%s> inode: %lld " |
diff --git a/fs/xfs/xfs_iomap.h b/fs/xfs/xfs_iomap.h index 4daaa5212102..fcd6d63bb68b 100644 --- a/fs/xfs/xfs_iomap.h +++ b/fs/xfs/xfs_iomap.h | |||
@@ -1,33 +1,19 @@ | |||
1 | /* | 1 | /* |
2 | * Copyright (c) 2003-2005 Silicon Graphics, Inc. All Rights Reserved. | 2 | * Copyright (c) 2003-2005 Silicon Graphics, Inc. |
3 | * All Rights Reserved. | ||
3 | * | 4 | * |
4 | * This program is free software; you can redistribute it and/or modify it | 5 | * This program is free software; you can redistribute it and/or |
5 | * under the terms of version 2 of the GNU General Public License as | 6 | * modify it under the terms of the GNU General Public License as |
6 | * published by the Free Software Foundation. | 7 | * published by the Free Software Foundation. |
7 | * | 8 | * |
8 | * This program is distributed in the hope that it would be useful, but | 9 | * This program is distributed in the hope that it would be useful, |
9 | * WITHOUT ANY WARRANTY; without even the implied warranty of | 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
12 | * GNU General Public License for more details. | ||
11 | * | 13 | * |
12 | * Further, this software is distributed without any warranty that it is | 14 | * You should have received a copy of the GNU General Public License |
13 | * free of the rightful claim of any third person regarding infringement | 15 | * along with this program; if not, write the Free Software Foundation, |
14 | * or the like. Any license provided herein, whether implied or | 16 | * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
15 | * otherwise, applies only to this software file. Patent licenses, if | ||
16 | * any, provided herein do not apply to combinations of this program with | ||
17 | * other software, or any other product whatsoever. | ||
18 | * | ||
19 | * You should have received a copy of the GNU General Public License along | ||
20 | * with this program; if not, write the Free Software Foundation, Inc., 59 | ||
21 | * Temple Place - Suite 330, Boston MA 02111-1307, USA. | ||
22 | * | ||
23 | * Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy, | ||
24 | * Mountain View, CA 94043, or: | ||
25 | * | ||
26 | * http://www.sgi.com | ||
27 | * | ||
28 | * For further information regarding this notice, see: | ||
29 | * | ||
30 | * http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/ | ||
31 | */ | 17 | */ |
32 | #ifndef __XFS_IOMAP_H__ | 18 | #ifndef __XFS_IOMAP_H__ |
33 | #define __XFS_IOMAP_H__ | 19 | #define __XFS_IOMAP_H__ |
diff --git a/fs/xfs/xfs_itable.c b/fs/xfs/xfs_itable.c index 8fbc8d378188..f63646ead816 100644 --- a/fs/xfs/xfs_itable.c +++ b/fs/xfs/xfs_itable.c | |||
@@ -1,59 +1,45 @@ | |||
1 | /* | 1 | /* |
2 | * Copyright (c) 2000-2002 Silicon Graphics, Inc. All Rights Reserved. | 2 | * Copyright (c) 2000-2002,2005 Silicon Graphics, Inc. |
3 | * All Rights Reserved. | ||
3 | * | 4 | * |
4 | * This program is free software; you can redistribute it and/or modify it | 5 | * This program is free software; you can redistribute it and/or |
5 | * under the terms of version 2 of the GNU General Public License as | 6 | * modify it under the terms of the GNU General Public License as |
6 | * published by the Free Software Foundation. | 7 | * published by the Free Software Foundation. |
7 | * | 8 | * |
8 | * This program is distributed in the hope that it would be useful, but | 9 | * This program is distributed in the hope that it would be useful, |
9 | * WITHOUT ANY WARRANTY; without even the implied warranty of | 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
12 | * GNU General Public License for more details. | ||
11 | * | 13 | * |
12 | * Further, this software is distributed without any warranty that it is | 14 | * You should have received a copy of the GNU General Public License |
13 | * free of the rightful claim of any third person regarding infringement | 15 | * along with this program; if not, write the Free Software Foundation, |
14 | * or the like. Any license provided herein, whether implied or | 16 | * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
15 | * otherwise, applies only to this software file. Patent licenses, if | ||
16 | * any, provided herein do not apply to combinations of this program with | ||
17 | * other software, or any other product whatsoever. | ||
18 | * | ||
19 | * You should have received a copy of the GNU General Public License along | ||
20 | * with this program; if not, write the Free Software Foundation, Inc., 59 | ||
21 | * Temple Place - Suite 330, Boston MA 02111-1307, USA. | ||
22 | * | ||
23 | * Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy, | ||
24 | * Mountain View, CA 94043, or: | ||
25 | * | ||
26 | * http://www.sgi.com | ||
27 | * | ||
28 | * For further information regarding this notice, see: | ||
29 | * | ||
30 | * http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/ | ||
31 | */ | 17 | */ |
32 | |||
33 | #include "xfs.h" | 18 | #include "xfs.h" |
34 | #include "xfs_macros.h" | 19 | #include "xfs_fs.h" |
35 | #include "xfs_types.h" | 20 | #include "xfs_types.h" |
36 | #include "xfs_inum.h" | 21 | #include "xfs_bit.h" |
37 | #include "xfs_log.h" | 22 | #include "xfs_log.h" |
23 | #include "xfs_inum.h" | ||
38 | #include "xfs_trans.h" | 24 | #include "xfs_trans.h" |
39 | #include "xfs_sb.h" | 25 | #include "xfs_sb.h" |
26 | #include "xfs_ag.h" | ||
40 | #include "xfs_dir.h" | 27 | #include "xfs_dir.h" |
41 | #include "xfs_dir2.h" | 28 | #include "xfs_dir2.h" |
42 | #include "xfs_dmapi.h" | 29 | #include "xfs_dmapi.h" |
43 | #include "xfs_mount.h" | 30 | #include "xfs_mount.h" |
44 | #include "xfs_ag.h" | ||
45 | #include "xfs_alloc_btree.h" | ||
46 | #include "xfs_bmap_btree.h" | 31 | #include "xfs_bmap_btree.h" |
32 | #include "xfs_alloc_btree.h" | ||
47 | #include "xfs_ialloc_btree.h" | 33 | #include "xfs_ialloc_btree.h" |
48 | #include "xfs_btree.h" | ||
49 | #include "xfs_attr_sf.h" | ||
50 | #include "xfs_dir_sf.h" | 34 | #include "xfs_dir_sf.h" |
51 | #include "xfs_dir2_sf.h" | 35 | #include "xfs_dir2_sf.h" |
36 | #include "xfs_attr_sf.h" | ||
52 | #include "xfs_dinode.h" | 37 | #include "xfs_dinode.h" |
53 | #include "xfs_inode.h" | 38 | #include "xfs_inode.h" |
54 | #include "xfs_ialloc.h" | 39 | #include "xfs_ialloc.h" |
55 | #include "xfs_itable.h" | 40 | #include "xfs_itable.h" |
56 | #include "xfs_error.h" | 41 | #include "xfs_error.h" |
42 | #include "xfs_btree.h" | ||
57 | 43 | ||
58 | #ifndef HAVE_USERACC | 44 | #ifndef HAVE_USERACC |
59 | #define useracc(ubuffer, size, flags, foo) (0) | 45 | #define useracc(ubuffer, size, flags, foo) (0) |
@@ -462,7 +448,7 @@ xfs_bulkstat( | |||
462 | while (error) { | 448 | while (error) { |
463 | agino += XFS_INODES_PER_CHUNK; | 449 | agino += XFS_INODES_PER_CHUNK; |
464 | if (XFS_AGINO_TO_AGBNO(mp, agino) >= | 450 | if (XFS_AGINO_TO_AGBNO(mp, agino) >= |
465 | INT_GET(agi->agi_length, ARCH_CONVERT)) | 451 | be32_to_cpu(agi->agi_length)) |
466 | break; | 452 | break; |
467 | error = xfs_inobt_lookup_ge(cur, agino, 0, 0, | 453 | error = xfs_inobt_lookup_ge(cur, agino, 0, 0, |
468 | &tmp); | 454 | &tmp); |
diff --git a/fs/xfs/xfs_itable.h b/fs/xfs/xfs_itable.h index 2be9d1805ab2..047d834ed210 100644 --- a/fs/xfs/xfs_itable.h +++ b/fs/xfs/xfs_itable.h | |||
@@ -1,33 +1,18 @@ | |||
1 | /* | 1 | /* |
2 | * Copyright (c) 2000-2001 Silicon Graphics, Inc. All Rights Reserved. | 2 | * Copyright (c) 2000-2001 Silicon Graphics, Inc. All Rights Reserved. |
3 | * | 3 | * |
4 | * This program is free software; you can redistribute it and/or modify it | 4 | * This program is free software; you can redistribute it and/or |
5 | * under the terms of version 2 of the GNU General Public License as | 5 | * modify it under the terms of the GNU General Public License as |
6 | * published by the Free Software Foundation. | 6 | * published by the Free Software Foundation. |
7 | * | 7 | * |
8 | * This program is distributed in the hope that it would be useful, but | 8 | * This program is distributed in the hope that it would be useful, |
9 | * WITHOUT ANY WARRANTY; without even the implied warranty of | 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
11 | * GNU General Public License for more details. | ||
11 | * | 12 | * |
12 | * Further, this software is distributed without any warranty that it is | 13 | * You should have received a copy of the GNU General Public License |
13 | * free of the rightful claim of any third person regarding infringement | 14 | * along with this program; if not, write the Free Software Foundation, |
14 | * or the like. Any license provided herein, whether implied or | 15 | * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
15 | * otherwise, applies only to this software file. Patent licenses, if | ||
16 | * any, provided herein do not apply to combinations of this program with | ||
17 | * other software, or any other product whatsoever. | ||
18 | * | ||
19 | * You should have received a copy of the GNU General Public License along | ||
20 | * with this program; if not, write the Free Software Foundation, Inc., 59 | ||
21 | * Temple Place - Suite 330, Boston MA 02111-1307, USA. | ||
22 | * | ||
23 | * Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy, | ||
24 | * Mountain View, CA 94043, or: | ||
25 | * | ||
26 | * http://www.sgi.com | ||
27 | * | ||
28 | * For further information regarding this notice, see: | ||
29 | * | ||
30 | * http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/ | ||
31 | */ | 16 | */ |
32 | #ifndef __XFS_ITABLE_H__ | 17 | #ifndef __XFS_ITABLE_H__ |
33 | #define __XFS_ITABLE_H__ | 18 | #define __XFS_ITABLE_H__ |
diff --git a/fs/xfs/xfs_log.c b/fs/xfs/xfs_log.c index 54a6f1142403..29af51275ca9 100644 --- a/fs/xfs/xfs_log.c +++ b/fs/xfs/xfs_log.c | |||
@@ -1,58 +1,47 @@ | |||
1 | /* | 1 | /* |
2 | * Copyright (c) 2000-2004 Silicon Graphics, Inc. All Rights Reserved. | 2 | * Copyright (c) 2000-2005 Silicon Graphics, Inc. |
3 | * All Rights Reserved. | ||
3 | * | 4 | * |
4 | * This program is free software; you can redistribute it and/or modify it | 5 | * This program is free software; you can redistribute it and/or |
5 | * under the terms of version 2 of the GNU General Public License as | 6 | * modify it under the terms of the GNU General Public License as |
6 | * published by the Free Software Foundation. | 7 | * published by the Free Software Foundation. |
7 | * | 8 | * |
8 | * This program is distributed in the hope that it would be useful, but | 9 | * This program is distributed in the hope that it would be useful, |
9 | * WITHOUT ANY WARRANTY; without even the implied warranty of | 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
12 | * GNU General Public License for more details. | ||
11 | * | 13 | * |
12 | * Further, this software is distributed without any warranty that it is | 14 | * You should have received a copy of the GNU General Public License |
13 | * free of the rightful claim of any third person regarding infringement | 15 | * along with this program; if not, write the Free Software Foundation, |
14 | * or the like. Any license provided herein, whether implied or | 16 | * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
15 | * otherwise, applies only to this software file. Patent licenses, if | ||
16 | * any, provided herein do not apply to combinations of this program with | ||
17 | * other software, or any other product whatsoever. | ||
18 | * | ||
19 | * You should have received a copy of the GNU General Public License along | ||
20 | * with this program; if not, write the Free Software Foundation, Inc., 59 | ||
21 | * Temple Place - Suite 330, Boston MA 02111-1307, USA. | ||
22 | * | ||
23 | * Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy, | ||
24 | * Mountain View, CA 94043, or: | ||
25 | * | ||
26 | * http://www.sgi.com | ||
27 | * | ||
28 | * For further information regarding this notice, see: | ||
29 | * | ||
30 | * http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/ | ||
31 | */ | 17 | */ |
32 | |||
33 | /* | ||
34 | * High level interface routines for log manager | ||
35 | */ | ||
36 | |||
37 | #include "xfs.h" | 18 | #include "xfs.h" |
38 | #include "xfs_macros.h" | 19 | #include "xfs_fs.h" |
39 | #include "xfs_types.h" | 20 | #include "xfs_types.h" |
40 | #include "xfs_inum.h" | 21 | #include "xfs_bit.h" |
41 | #include "xfs_ag.h" | ||
42 | #include "xfs_sb.h" | ||
43 | #include "xfs_log.h" | 22 | #include "xfs_log.h" |
23 | #include "xfs_inum.h" | ||
44 | #include "xfs_trans.h" | 24 | #include "xfs_trans.h" |
25 | #include "xfs_sb.h" | ||
26 | #include "xfs_ag.h" | ||
45 | #include "xfs_dir.h" | 27 | #include "xfs_dir.h" |
28 | #include "xfs_dir2.h" | ||
46 | #include "xfs_dmapi.h" | 29 | #include "xfs_dmapi.h" |
47 | #include "xfs_mount.h" | 30 | #include "xfs_mount.h" |
48 | #include "xfs_error.h" | 31 | #include "xfs_error.h" |
49 | #include "xfs_log_priv.h" | 32 | #include "xfs_log_priv.h" |
50 | #include "xfs_buf_item.h" | 33 | #include "xfs_buf_item.h" |
34 | #include "xfs_bmap_btree.h" | ||
51 | #include "xfs_alloc_btree.h" | 35 | #include "xfs_alloc_btree.h" |
36 | #include "xfs_ialloc_btree.h" | ||
52 | #include "xfs_log_recover.h" | 37 | #include "xfs_log_recover.h" |
53 | #include "xfs_bit.h" | ||
54 | #include "xfs_rw.h" | ||
55 | #include "xfs_trans_priv.h" | 38 | #include "xfs_trans_priv.h" |
39 | #include "xfs_dir_sf.h" | ||
40 | #include "xfs_dir2_sf.h" | ||
41 | #include "xfs_attr_sf.h" | ||
42 | #include "xfs_dinode.h" | ||
43 | #include "xfs_inode.h" | ||
44 | #include "xfs_rw.h" | ||
56 | 45 | ||
57 | 46 | ||
58 | #define xlog_write_adv_cnt(ptr, len, off, bytes) \ | 47 | #define xlog_write_adv_cnt(ptr, len, off, bytes) \ |
@@ -93,8 +82,11 @@ STATIC int xlog_state_release_iclog(xlog_t *log, | |||
93 | STATIC void xlog_state_switch_iclogs(xlog_t *log, | 82 | STATIC void xlog_state_switch_iclogs(xlog_t *log, |
94 | xlog_in_core_t *iclog, | 83 | xlog_in_core_t *iclog, |
95 | int eventual_size); | 84 | int eventual_size); |
96 | STATIC int xlog_state_sync(xlog_t *log, xfs_lsn_t lsn, uint flags); | 85 | STATIC int xlog_state_sync(xlog_t *log, |
97 | STATIC int xlog_state_sync_all(xlog_t *log, uint flags); | 86 | xfs_lsn_t lsn, |
87 | uint flags, | ||
88 | int *log_flushed); | ||
89 | STATIC int xlog_state_sync_all(xlog_t *log, uint flags, int *log_flushed); | ||
98 | STATIC void xlog_state_want_sync(xlog_t *log, xlog_in_core_t *iclog); | 90 | STATIC void xlog_state_want_sync(xlog_t *log, xlog_in_core_t *iclog); |
99 | 91 | ||
100 | /* local functions to manipulate grant head */ | 92 | /* local functions to manipulate grant head */ |
@@ -119,8 +111,7 @@ STATIC xlog_ticket_t *xlog_ticket_get(xlog_t *log, | |||
119 | uint flags); | 111 | uint flags); |
120 | STATIC void xlog_ticket_put(xlog_t *log, xlog_ticket_t *ticket); | 112 | STATIC void xlog_ticket_put(xlog_t *log, xlog_ticket_t *ticket); |
121 | 113 | ||
122 | /* local debug functions */ | 114 | #if defined(DEBUG) |
123 | #if defined(DEBUG) && !defined(XLOG_NOLOG) | ||
124 | STATIC void xlog_verify_dest_ptr(xlog_t *log, __psint_t ptr); | 115 | STATIC void xlog_verify_dest_ptr(xlog_t *log, __psint_t ptr); |
125 | STATIC void xlog_verify_grant_head(xlog_t *log, int equals); | 116 | STATIC void xlog_verify_grant_head(xlog_t *log, int equals); |
126 | STATIC void xlog_verify_iclog(xlog_t *log, xlog_in_core_t *iclog, | 117 | STATIC void xlog_verify_iclog(xlog_t *log, xlog_in_core_t *iclog, |
@@ -136,26 +127,7 @@ STATIC void xlog_verify_tail_lsn(xlog_t *log, xlog_in_core_t *iclog, | |||
136 | 127 | ||
137 | STATIC int xlog_iclogs_empty(xlog_t *log); | 128 | STATIC int xlog_iclogs_empty(xlog_t *log); |
138 | 129 | ||
139 | #ifdef DEBUG | ||
140 | int xlog_do_error = 0; | ||
141 | int xlog_req_num = 0; | ||
142 | int xlog_error_mod = 33; | ||
143 | #endif | ||
144 | |||
145 | #define XLOG_FORCED_SHUTDOWN(log) (log->l_flags & XLOG_IO_ERROR) | ||
146 | |||
147 | /* | ||
148 | * 0 => disable log manager | ||
149 | * 1 => enable log manager | ||
150 | * 2 => enable log manager and log debugging | ||
151 | */ | ||
152 | #if defined(XLOG_NOLOG) || defined(DEBUG) | ||
153 | int xlog_debug = 1; | ||
154 | xfs_buftarg_t *xlog_target; | ||
155 | #endif | ||
156 | |||
157 | #if defined(XFS_LOG_TRACE) | 130 | #if defined(XFS_LOG_TRACE) |
158 | |||
159 | void | 131 | void |
160 | xlog_trace_loggrant(xlog_t *log, xlog_ticket_t *tic, xfs_caddr_t string) | 132 | xlog_trace_loggrant(xlog_t *log, xlog_ticket_t *tic, xfs_caddr_t string) |
161 | { | 133 | { |
@@ -191,31 +163,16 @@ xlog_trace_loggrant(xlog_t *log, xlog_ticket_t *tic, xfs_caddr_t string) | |||
191 | void | 163 | void |
192 | xlog_trace_iclog(xlog_in_core_t *iclog, uint state) | 164 | xlog_trace_iclog(xlog_in_core_t *iclog, uint state) |
193 | { | 165 | { |
194 | pid_t pid; | ||
195 | |||
196 | pid = current_pid(); | ||
197 | |||
198 | if (!iclog->ic_trace) | 166 | if (!iclog->ic_trace) |
199 | iclog->ic_trace = ktrace_alloc(256, KM_SLEEP); | 167 | iclog->ic_trace = ktrace_alloc(256, KM_SLEEP); |
200 | ktrace_enter(iclog->ic_trace, | 168 | ktrace_enter(iclog->ic_trace, |
201 | (void *)((unsigned long)state), | 169 | (void *)((unsigned long)state), |
202 | (void *)((unsigned long)pid), | 170 | (void *)((unsigned long)current_pid()), |
203 | (void *)0, | 171 | (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, |
204 | (void *)0, | 172 | (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, |
205 | (void *)0, | 173 | (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, |
206 | (void *)0, | 174 | (void *)NULL, (void *)NULL); |
207 | (void *)0, | ||
208 | (void *)0, | ||
209 | (void *)0, | ||
210 | (void *)0, | ||
211 | (void *)0, | ||
212 | (void *)0, | ||
213 | (void *)0, | ||
214 | (void *)0, | ||
215 | (void *)0, | ||
216 | (void *)0); | ||
217 | } | 175 | } |
218 | |||
219 | #else | 176 | #else |
220 | #define xlog_trace_loggrant(log,tic,string) | 177 | #define xlog_trace_loggrant(log,tic,string) |
221 | #define xlog_trace_iclog(iclog,state) | 178 | #define xlog_trace_iclog(iclog,state) |
@@ -252,11 +209,6 @@ xfs_log_done(xfs_mount_t *mp, | |||
252 | xlog_ticket_t *ticket = (xfs_log_ticket_t) xtic; | 209 | xlog_ticket_t *ticket = (xfs_log_ticket_t) xtic; |
253 | xfs_lsn_t lsn = 0; | 210 | xfs_lsn_t lsn = 0; |
254 | 211 | ||
255 | #if defined(DEBUG) || defined(XLOG_NOLOG) | ||
256 | if (!xlog_debug && xlog_target == log->l_targ) | ||
257 | return 0; | ||
258 | #endif | ||
259 | |||
260 | if (XLOG_FORCED_SHUTDOWN(log) || | 212 | if (XLOG_FORCED_SHUTDOWN(log) || |
261 | /* | 213 | /* |
262 | * If nothing was ever written, don't write out commit record. | 214 | * If nothing was ever written, don't write out commit record. |
@@ -312,33 +264,28 @@ xfs_log_done(xfs_mount_t *mp, | |||
312 | * semaphore. | 264 | * semaphore. |
313 | */ | 265 | */ |
314 | int | 266 | int |
315 | xfs_log_force(xfs_mount_t *mp, | 267 | _xfs_log_force( |
316 | xfs_lsn_t lsn, | 268 | xfs_mount_t *mp, |
317 | uint flags) | 269 | xfs_lsn_t lsn, |
270 | uint flags, | ||
271 | int *log_flushed) | ||
318 | { | 272 | { |
319 | int rval; | 273 | xlog_t *log = mp->m_log; |
320 | xlog_t *log = mp->m_log; | 274 | int dummy; |
321 | 275 | ||
322 | #if defined(DEBUG) || defined(XLOG_NOLOG) | 276 | if (!log_flushed) |
323 | if (!xlog_debug && xlog_target == log->l_targ) | 277 | log_flushed = &dummy; |
324 | return 0; | ||
325 | #endif | ||
326 | 278 | ||
327 | ASSERT(flags & XFS_LOG_FORCE); | 279 | ASSERT(flags & XFS_LOG_FORCE); |
328 | 280 | ||
329 | XFS_STATS_INC(xs_log_force); | 281 | XFS_STATS_INC(xs_log_force); |
330 | 282 | ||
331 | if ((log->l_flags & XLOG_IO_ERROR) == 0) { | 283 | if (log->l_flags & XLOG_IO_ERROR) |
332 | if (lsn == 0) | 284 | return XFS_ERROR(EIO); |
333 | rval = xlog_state_sync_all(log, flags); | 285 | if (lsn == 0) |
334 | else | 286 | return xlog_state_sync_all(log, flags, log_flushed); |
335 | rval = xlog_state_sync(log, lsn, flags); | 287 | else |
336 | } else { | 288 | return xlog_state_sync(log, lsn, flags, log_flushed); |
337 | rval = XFS_ERROR(EIO); | ||
338 | } | ||
339 | |||
340 | return rval; | ||
341 | |||
342 | } /* xfs_log_force */ | 289 | } /* xfs_log_force */ |
343 | 290 | ||
344 | /* | 291 | /* |
@@ -356,10 +303,6 @@ xfs_log_notify(xfs_mount_t *mp, /* mount of partition */ | |||
356 | xlog_in_core_t *iclog = (xlog_in_core_t *)iclog_hndl; | 303 | xlog_in_core_t *iclog = (xlog_in_core_t *)iclog_hndl; |
357 | int abortflg, spl; | 304 | int abortflg, spl; |
358 | 305 | ||
359 | #if defined(DEBUG) || defined(XLOG_NOLOG) | ||
360 | if (!xlog_debug && xlog_target == log->l_targ) | ||
361 | return 0; | ||
362 | #endif | ||
363 | cb->cb_next = NULL; | 306 | cb->cb_next = NULL; |
364 | spl = LOG_LOCK(log); | 307 | spl = LOG_LOCK(log); |
365 | abortflg = (iclog->ic_state & XLOG_STATE_IOERROR); | 308 | abortflg = (iclog->ic_state & XLOG_STATE_IOERROR); |
@@ -410,13 +353,8 @@ xfs_log_reserve(xfs_mount_t *mp, | |||
410 | { | 353 | { |
411 | xlog_t *log = mp->m_log; | 354 | xlog_t *log = mp->m_log; |
412 | xlog_ticket_t *internal_ticket; | 355 | xlog_ticket_t *internal_ticket; |
413 | int retval; | 356 | int retval = 0; |
414 | 357 | ||
415 | #if defined(DEBUG) || defined(XLOG_NOLOG) | ||
416 | if (!xlog_debug && xlog_target == log->l_targ) | ||
417 | return 0; | ||
418 | #endif | ||
419 | retval = 0; | ||
420 | ASSERT(client == XFS_TRANSACTION || client == XFS_LOG); | 358 | ASSERT(client == XFS_TRANSACTION || client == XFS_LOG); |
421 | ASSERT((flags & XFS_LOG_NOSLEEP) == 0); | 359 | ASSERT((flags & XFS_LOG_NOSLEEP) == 0); |
422 | 360 | ||
@@ -478,12 +416,6 @@ xfs_log_mount(xfs_mount_t *mp, | |||
478 | 416 | ||
479 | mp->m_log = xlog_alloc_log(mp, log_target, blk_offset, num_bblks); | 417 | mp->m_log = xlog_alloc_log(mp, log_target, blk_offset, num_bblks); |
480 | 418 | ||
481 | #if defined(DEBUG) || defined(XLOG_NOLOG) | ||
482 | if (!xlog_debug) { | ||
483 | cmn_err(CE_NOTE, "log dev: %s", XFS_BUFTARG_NAME(log_target)); | ||
484 | return 0; | ||
485 | } | ||
486 | #endif | ||
487 | /* | 419 | /* |
488 | * skip log recovery on a norecovery mount. pretend it all | 420 | * skip log recovery on a norecovery mount. pretend it all |
489 | * just worked. | 421 | * just worked. |
@@ -587,11 +519,6 @@ xfs_log_unmount_write(xfs_mount_t *mp) | |||
587 | __uint32_t pad2; /* may as well make it 64 bits */ | 519 | __uint32_t pad2; /* may as well make it 64 bits */ |
588 | } magic = { XLOG_UNMOUNT_TYPE, 0, 0 }; | 520 | } magic = { XLOG_UNMOUNT_TYPE, 0, 0 }; |
589 | 521 | ||
590 | #if defined(DEBUG) || defined(XLOG_NOLOG) | ||
591 | if (!xlog_debug && xlog_target == log->l_targ) | ||
592 | return 0; | ||
593 | #endif | ||
594 | |||
595 | /* | 522 | /* |
596 | * Don't write out unmount record on read-only mounts. | 523 | * Don't write out unmount record on read-only mounts. |
597 | * Or, if we are doing a forced umount (typically because of IO errors). | 524 | * Or, if we are doing a forced umount (typically because of IO errors). |
@@ -718,12 +645,6 @@ xfs_log_write(xfs_mount_t * mp, | |||
718 | int error; | 645 | int error; |
719 | xlog_t *log = mp->m_log; | 646 | xlog_t *log = mp->m_log; |
720 | 647 | ||
721 | #if defined(DEBUG) || defined(XLOG_NOLOG) | ||
722 | if (!xlog_debug && xlog_target == log->l_targ) { | ||
723 | *start_lsn = 0; | ||
724 | return 0; | ||
725 | } | ||
726 | #endif | ||
727 | if (XLOG_FORCED_SHUTDOWN(log)) | 648 | if (XLOG_FORCED_SHUTDOWN(log)) |
728 | return XFS_ERROR(EIO); | 649 | return XFS_ERROR(EIO); |
729 | 650 | ||
@@ -743,11 +664,6 @@ xfs_log_move_tail(xfs_mount_t *mp, | |||
743 | int need_bytes, free_bytes, cycle, bytes; | 664 | int need_bytes, free_bytes, cycle, bytes; |
744 | SPLDECL(s); | 665 | SPLDECL(s); |
745 | 666 | ||
746 | #if defined(DEBUG) || defined(XLOG_NOLOG) | ||
747 | if (!xlog_debug && xlog_target == log->l_targ) | ||
748 | return; | ||
749 | #endif | ||
750 | /* XXXsup tmp */ | ||
751 | if (XLOG_FORCED_SHUTDOWN(log)) | 667 | if (XLOG_FORCED_SHUTDOWN(log)) |
752 | return; | 668 | return; |
753 | ASSERT(!XFS_FORCED_SHUTDOWN(mp)); | 669 | ASSERT(!XFS_FORCED_SHUTDOWN(mp)); |
@@ -1034,51 +950,22 @@ xlog_get_iclog_buffer_size(xfs_mount_t *mp, | |||
1034 | int size; | 950 | int size; |
1035 | int xhdrs; | 951 | int xhdrs; |
1036 | 952 | ||
1037 | #if defined(DEBUG) || defined(XLOG_NOLOG) | 953 | if (mp->m_logbufs <= 0) { |
1038 | /* | 954 | if (xfs_physmem <= btoc(128*1024*1024)) { |
1039 | * When logbufs == 0, someone has disabled the log from the FSTAB | 955 | log->l_iclog_bufs = XLOG_MIN_ICLOGS; |
1040 | * file. This is not a documented feature. We need to set xlog_debug | 956 | } else if (xfs_physmem <= btoc(400*1024*1024)) { |
1041 | * to zero (this deactivates the log) and set xlog_target to the | 957 | log->l_iclog_bufs = XLOG_MED_ICLOGS; |
1042 | * appropriate device. Only one filesystem may be affected as such | 958 | } else { /* 256K with 32K bufs */ |
1043 | * since this is just a performance hack to test what we might be able | 959 | log->l_iclog_bufs = XLOG_MAX_ICLOGS; |
1044 | * to get if the log were not present. | ||
1045 | */ | ||
1046 | if (mp->m_logbufs == 0) { | ||
1047 | xlog_debug = 0; | ||
1048 | xlog_target = log->l_targ; | ||
1049 | log->l_iclog_bufs = XLOG_MIN_ICLOGS; | ||
1050 | } else | ||
1051 | #endif | ||
1052 | { | ||
1053 | /* | ||
1054 | * This is the normal path. If m_logbufs == -1, then the | ||
1055 | * admin has chosen to use the system defaults for logbuffers. | ||
1056 | */ | ||
1057 | if (mp->m_logbufs == -1) { | ||
1058 | if (xfs_physmem <= btoc(128*1024*1024)) { | ||
1059 | log->l_iclog_bufs = XLOG_MIN_ICLOGS; | ||
1060 | } else if (xfs_physmem <= btoc(400*1024*1024)) { | ||
1061 | log->l_iclog_bufs = XLOG_MED_ICLOGS; | ||
1062 | } else { | ||
1063 | /* 256K with 32K bufs */ | ||
1064 | log->l_iclog_bufs = XLOG_MAX_ICLOGS; | ||
1065 | } | ||
1066 | } else | ||
1067 | log->l_iclog_bufs = mp->m_logbufs; | ||
1068 | |||
1069 | #if defined(DEBUG) || defined(XLOG_NOLOG) | ||
1070 | /* We are reactivating a filesystem after it was inactive */ | ||
1071 | if (log->l_targ == xlog_target) { | ||
1072 | xlog_target = NULL; | ||
1073 | xlog_debug = 1; | ||
1074 | } | 960 | } |
1075 | #endif | 961 | } else { |
962 | log->l_iclog_bufs = mp->m_logbufs; | ||
1076 | } | 963 | } |
1077 | 964 | ||
1078 | /* | 965 | /* |
1079 | * Buffer size passed in from mount system call. | 966 | * Buffer size passed in from mount system call. |
1080 | */ | 967 | */ |
1081 | if (mp->m_logbsize != -1) { | 968 | if (mp->m_logbsize > 0) { |
1082 | size = log->l_iclog_size = mp->m_logbsize; | 969 | size = log->l_iclog_size = mp->m_logbsize; |
1083 | log->l_iclog_size_log = 0; | 970 | log->l_iclog_size_log = 0; |
1084 | while (size != 1) { | 971 | while (size != 1) { |
@@ -1101,7 +988,7 @@ xlog_get_iclog_buffer_size(xfs_mount_t *mp, | |||
1101 | log->l_iclog_hsize = BBSIZE; | 988 | log->l_iclog_hsize = BBSIZE; |
1102 | log->l_iclog_heads = 1; | 989 | log->l_iclog_heads = 1; |
1103 | } | 990 | } |
1104 | return; | 991 | goto done; |
1105 | } | 992 | } |
1106 | 993 | ||
1107 | /* | 994 | /* |
@@ -1128,7 +1015,7 @@ xlog_get_iclog_buffer_size(xfs_mount_t *mp, | |||
1128 | if (mp->m_sb.sb_blocksize >= 16*1024) { | 1015 | if (mp->m_sb.sb_blocksize >= 16*1024) { |
1129 | log->l_iclog_size = XLOG_BIG_RECORD_BSIZE; | 1016 | log->l_iclog_size = XLOG_BIG_RECORD_BSIZE; |
1130 | log->l_iclog_size_log = XLOG_BIG_RECORD_BSHIFT; | 1017 | log->l_iclog_size_log = XLOG_BIG_RECORD_BSHIFT; |
1131 | if (mp->m_logbufs == -1) { | 1018 | if (mp->m_logbufs <= 0) { |
1132 | switch (mp->m_sb.sb_blocksize) { | 1019 | switch (mp->m_sb.sb_blocksize) { |
1133 | case 16*1024: /* 16 KB */ | 1020 | case 16*1024: /* 16 KB */ |
1134 | log->l_iclog_bufs = 3; | 1021 | log->l_iclog_bufs = 3; |
@@ -1145,6 +1032,12 @@ xlog_get_iclog_buffer_size(xfs_mount_t *mp, | |||
1145 | } | 1032 | } |
1146 | } | 1033 | } |
1147 | } | 1034 | } |
1035 | |||
1036 | done: /* are we being asked to make the sizes selected above visible? */ | ||
1037 | if (mp->m_logbufs == 0) | ||
1038 | mp->m_logbufs = log->l_iclog_bufs; | ||
1039 | if (mp->m_logbsize == 0) | ||
1040 | mp->m_logbsize = log->l_iclog_size; | ||
1148 | } /* xlog_get_iclog_buffer_size */ | 1041 | } /* xlog_get_iclog_buffer_size */ |
1149 | 1042 | ||
1150 | 1043 | ||
@@ -1467,14 +1360,13 @@ xlog_sync(xlog_t *log, | |||
1467 | XFS_BUF_BUSY(bp); | 1360 | XFS_BUF_BUSY(bp); |
1468 | XFS_BUF_ASYNC(bp); | 1361 | XFS_BUF_ASYNC(bp); |
1469 | /* | 1362 | /* |
1470 | * Do a disk write cache flush for the log block. | 1363 | * Do an ordered write for the log block. |
1471 | * This is a bit of a sledgehammer, it would be better | 1364 | * |
1472 | * to use a tag barrier here that just prevents reordering. | ||
1473 | * It may not be needed to flush the first split block in the log wrap | 1365 | * It may not be needed to flush the first split block in the log wrap |
1474 | * case, but do it anyways to be safe -AK | 1366 | * case, but do it anyways to be safe -AK |
1475 | */ | 1367 | */ |
1476 | if (!(log->l_mp->m_flags & XFS_MOUNT_NOLOGFLUSH)) | 1368 | if (log->l_mp->m_flags & XFS_MOUNT_BARRIER) |
1477 | XFS_BUF_FLUSH(bp); | 1369 | XFS_BUF_ORDERED(bp); |
1478 | 1370 | ||
1479 | ASSERT(XFS_BUF_ADDR(bp) <= log->l_logBBsize-1); | 1371 | ASSERT(XFS_BUF_ADDR(bp) <= log->l_logBBsize-1); |
1480 | ASSERT(XFS_BUF_ADDR(bp) + BTOBB(count) <= log->l_logBBsize); | 1372 | ASSERT(XFS_BUF_ADDR(bp) + BTOBB(count) <= log->l_logBBsize); |
@@ -1505,8 +1397,8 @@ xlog_sync(xlog_t *log, | |||
1505 | XFS_BUF_SET_FSPRIVATE(bp, iclog); | 1397 | XFS_BUF_SET_FSPRIVATE(bp, iclog); |
1506 | XFS_BUF_BUSY(bp); | 1398 | XFS_BUF_BUSY(bp); |
1507 | XFS_BUF_ASYNC(bp); | 1399 | XFS_BUF_ASYNC(bp); |
1508 | if (!(log->l_mp->m_flags & XFS_MOUNT_NOLOGFLUSH)) | 1400 | if (log->l_mp->m_flags & XFS_MOUNT_BARRIER) |
1509 | XFS_BUF_FLUSH(bp); | 1401 | XFS_BUF_ORDERED(bp); |
1510 | dptr = XFS_BUF_PTR(bp); | 1402 | dptr = XFS_BUF_PTR(bp); |
1511 | /* | 1403 | /* |
1512 | * Bump the cycle numbers at the start of each block | 1404 | * Bump the cycle numbers at the start of each block |
@@ -2951,7 +2843,7 @@ xlog_state_switch_iclogs(xlog_t *log, | |||
2951 | * not in the active nor dirty state. | 2843 | * not in the active nor dirty state. |
2952 | */ | 2844 | */ |
2953 | STATIC int | 2845 | STATIC int |
2954 | xlog_state_sync_all(xlog_t *log, uint flags) | 2846 | xlog_state_sync_all(xlog_t *log, uint flags, int *log_flushed) |
2955 | { | 2847 | { |
2956 | xlog_in_core_t *iclog; | 2848 | xlog_in_core_t *iclog; |
2957 | xfs_lsn_t lsn; | 2849 | xfs_lsn_t lsn; |
@@ -3000,6 +2892,7 @@ xlog_state_sync_all(xlog_t *log, uint flags) | |||
3000 | 2892 | ||
3001 | if (xlog_state_release_iclog(log, iclog)) | 2893 | if (xlog_state_release_iclog(log, iclog)) |
3002 | return XFS_ERROR(EIO); | 2894 | return XFS_ERROR(EIO); |
2895 | *log_flushed = 1; | ||
3003 | s = LOG_LOCK(log); | 2896 | s = LOG_LOCK(log); |
3004 | if (INT_GET(iclog->ic_header.h_lsn, ARCH_CONVERT) == lsn && | 2897 | if (INT_GET(iclog->ic_header.h_lsn, ARCH_CONVERT) == lsn && |
3005 | iclog->ic_state != XLOG_STATE_DIRTY) | 2898 | iclog->ic_state != XLOG_STATE_DIRTY) |
@@ -3043,6 +2936,7 @@ maybe_sleep: | |||
3043 | */ | 2936 | */ |
3044 | if (iclog->ic_state & XLOG_STATE_IOERROR) | 2937 | if (iclog->ic_state & XLOG_STATE_IOERROR) |
3045 | return XFS_ERROR(EIO); | 2938 | return XFS_ERROR(EIO); |
2939 | *log_flushed = 1; | ||
3046 | 2940 | ||
3047 | } else { | 2941 | } else { |
3048 | 2942 | ||
@@ -3068,7 +2962,8 @@ no_sleep: | |||
3068 | int | 2962 | int |
3069 | xlog_state_sync(xlog_t *log, | 2963 | xlog_state_sync(xlog_t *log, |
3070 | xfs_lsn_t lsn, | 2964 | xfs_lsn_t lsn, |
3071 | uint flags) | 2965 | uint flags, |
2966 | int *log_flushed) | ||
3072 | { | 2967 | { |
3073 | xlog_in_core_t *iclog; | 2968 | xlog_in_core_t *iclog; |
3074 | int already_slept = 0; | 2969 | int already_slept = 0; |
@@ -3120,6 +3015,7 @@ try_again: | |||
3120 | XFS_STATS_INC(xs_log_force_sleep); | 3015 | XFS_STATS_INC(xs_log_force_sleep); |
3121 | sv_wait(&iclog->ic_prev->ic_writesema, PSWP, | 3016 | sv_wait(&iclog->ic_prev->ic_writesema, PSWP, |
3122 | &log->l_icloglock, s); | 3017 | &log->l_icloglock, s); |
3018 | *log_flushed = 1; | ||
3123 | already_slept = 1; | 3019 | already_slept = 1; |
3124 | goto try_again; | 3020 | goto try_again; |
3125 | } else { | 3021 | } else { |
@@ -3128,6 +3024,7 @@ try_again: | |||
3128 | LOG_UNLOCK(log, s); | 3024 | LOG_UNLOCK(log, s); |
3129 | if (xlog_state_release_iclog(log, iclog)) | 3025 | if (xlog_state_release_iclog(log, iclog)) |
3130 | return XFS_ERROR(EIO); | 3026 | return XFS_ERROR(EIO); |
3027 | *log_flushed = 1; | ||
3131 | s = LOG_LOCK(log); | 3028 | s = LOG_LOCK(log); |
3132 | } | 3029 | } |
3133 | } | 3030 | } |
@@ -3152,6 +3049,7 @@ try_again: | |||
3152 | */ | 3049 | */ |
3153 | if (iclog->ic_state & XLOG_STATE_IOERROR) | 3050 | if (iclog->ic_state & XLOG_STATE_IOERROR) |
3154 | return XFS_ERROR(EIO); | 3051 | return XFS_ERROR(EIO); |
3052 | *log_flushed = 1; | ||
3155 | } else { /* just return */ | 3053 | } else { /* just return */ |
3156 | LOG_UNLOCK(log, s); | 3054 | LOG_UNLOCK(log, s); |
3157 | } | 3055 | } |
@@ -3392,7 +3290,7 @@ xlog_ticket_get(xlog_t *log, | |||
3392 | * | 3290 | * |
3393 | ****************************************************************************** | 3291 | ****************************************************************************** |
3394 | */ | 3292 | */ |
3395 | #if defined(DEBUG) && !defined(XLOG_NOLOG) | 3293 | #if defined(DEBUG) |
3396 | /* | 3294 | /* |
3397 | * Make sure that the destination ptr is within the valid data region of | 3295 | * Make sure that the destination ptr is within the valid data region of |
3398 | * one of the iclogs. This uses backup pointers stored in a different | 3296 | * one of the iclogs. This uses backup pointers stored in a different |
@@ -3533,7 +3431,9 @@ xlog_verify_iclog(xlog_t *log, | |||
3533 | } | 3431 | } |
3534 | } | 3432 | } |
3535 | if (clientid != XFS_TRANSACTION && clientid != XFS_LOG) | 3433 | if (clientid != XFS_TRANSACTION && clientid != XFS_LOG) |
3536 | cmn_err(CE_WARN, "xlog_verify_iclog: invalid clientid %d op 0x%p offset 0x%x", clientid, ophead, field_offset); | 3434 | cmn_err(CE_WARN, "xlog_verify_iclog: " |
3435 | "invalid clientid %d op 0x%p offset 0x%lx", | ||
3436 | clientid, ophead, (unsigned long)field_offset); | ||
3537 | 3437 | ||
3538 | /* check length */ | 3438 | /* check length */ |
3539 | field_offset = (__psint_t) | 3439 | field_offset = (__psint_t) |
@@ -3554,7 +3454,7 @@ xlog_verify_iclog(xlog_t *log, | |||
3554 | ptr += sizeof(xlog_op_header_t) + op_len; | 3454 | ptr += sizeof(xlog_op_header_t) + op_len; |
3555 | } | 3455 | } |
3556 | } /* xlog_verify_iclog */ | 3456 | } /* xlog_verify_iclog */ |
3557 | #endif /* DEBUG && !XLOG_NOLOG */ | 3457 | #endif |
3558 | 3458 | ||
3559 | /* | 3459 | /* |
3560 | * Mark all iclogs IOERROR. LOG_LOCK is held by the caller. | 3460 | * Mark all iclogs IOERROR. LOG_LOCK is held by the caller. |
@@ -3604,6 +3504,7 @@ xfs_log_force_umount( | |||
3604 | xlog_ticket_t *tic; | 3504 | xlog_ticket_t *tic; |
3605 | xlog_t *log; | 3505 | xlog_t *log; |
3606 | int retval; | 3506 | int retval; |
3507 | int dummy; | ||
3607 | SPLDECL(s); | 3508 | SPLDECL(s); |
3608 | SPLDECL(s2); | 3509 | SPLDECL(s2); |
3609 | 3510 | ||
@@ -3682,7 +3583,7 @@ xfs_log_force_umount( | |||
3682 | * Force the incore logs to disk before shutting the | 3583 | * Force the incore logs to disk before shutting the |
3683 | * log down completely. | 3584 | * log down completely. |
3684 | */ | 3585 | */ |
3685 | xlog_state_sync_all(log, XFS_LOG_FORCE|XFS_LOG_SYNC); | 3586 | xlog_state_sync_all(log, XFS_LOG_FORCE|XFS_LOG_SYNC, &dummy); |
3686 | s2 = LOG_LOCK(log); | 3587 | s2 = LOG_LOCK(log); |
3687 | retval = xlog_state_ioerror(log); | 3588 | retval = xlog_state_ioerror(log); |
3688 | LOG_UNLOCK(log, s2); | 3589 | LOG_UNLOCK(log, s2); |
diff --git a/fs/xfs/xfs_log.h b/fs/xfs/xfs_log.h index 18961119fc65..158829ca56f6 100644 --- a/fs/xfs/xfs_log.h +++ b/fs/xfs/xfs_log.h | |||
@@ -1,33 +1,19 @@ | |||
1 | /* | 1 | /* |
2 | * Copyright (c) 2000-2003 Silicon Graphics, Inc. All Rights Reserved. | 2 | * Copyright (c) 2000-2003,2005 Silicon Graphics, Inc. |
3 | * All Rights Reserved. | ||
3 | * | 4 | * |
4 | * This program is free software; you can redistribute it and/or modify it | 5 | * This program is free software; you can redistribute it and/or |
5 | * under the terms of version 2 of the GNU General Public License as | 6 | * modify it under the terms of the GNU General Public License as |
6 | * published by the Free Software Foundation. | 7 | * published by the Free Software Foundation. |
7 | * | 8 | * |
8 | * This program is distributed in the hope that it would be useful, but | 9 | * This program is distributed in the hope that it would be useful, |
9 | * WITHOUT ANY WARRANTY; without even the implied warranty of | 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
12 | * GNU General Public License for more details. | ||
11 | * | 13 | * |
12 | * Further, this software is distributed without any warranty that it is | 14 | * You should have received a copy of the GNU General Public License |
13 | * free of the rightful claim of any third person regarding infringement | 15 | * along with this program; if not, write the Free Software Foundation, |
14 | * or the like. Any license provided herein, whether implied or | 16 | * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
15 | * otherwise, applies only to this software file. Patent licenses, if | ||
16 | * any, provided herein do not apply to combinations of this program with | ||
17 | * other software, or any other product whatsoever. | ||
18 | * | ||
19 | * You should have received a copy of the GNU General Public License along | ||
20 | * with this program; if not, write the Free Software Foundation, Inc., 59 | ||
21 | * Temple Place - Suite 330, Boston MA 02111-1307, USA. | ||
22 | * | ||
23 | * Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy, | ||
24 | * Mountain View, CA 94043, or: | ||
25 | * | ||
26 | * http://www.sgi.com | ||
27 | * | ||
28 | * For further information regarding this notice, see: | ||
29 | * | ||
30 | * http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/ | ||
31 | */ | 17 | */ |
32 | #ifndef __XFS_LOG_H__ | 18 | #ifndef __XFS_LOG_H__ |
33 | #define __XFS_LOG_H__ | 19 | #define __XFS_LOG_H__ |
@@ -174,9 +160,12 @@ xfs_lsn_t xfs_log_done(struct xfs_mount *mp, | |||
174 | xfs_log_ticket_t ticket, | 160 | xfs_log_ticket_t ticket, |
175 | void **iclog, | 161 | void **iclog, |
176 | uint flags); | 162 | uint flags); |
177 | int xfs_log_force(struct xfs_mount *mp, | 163 | int _xfs_log_force(struct xfs_mount *mp, |
178 | xfs_lsn_t lsn, | 164 | xfs_lsn_t lsn, |
179 | uint flags); | 165 | uint flags, |
166 | int *log_forced); | ||
167 | #define xfs_log_force(mp, lsn, flags) \ | ||
168 | _xfs_log_force(mp, lsn, flags, NULL); | ||
180 | int xfs_log_mount(struct xfs_mount *mp, | 169 | int xfs_log_mount(struct xfs_mount *mp, |
181 | struct xfs_buftarg *log_target, | 170 | struct xfs_buftarg *log_target, |
182 | xfs_daddr_t start_block, | 171 | xfs_daddr_t start_block, |
diff --git a/fs/xfs/xfs_log_priv.h b/fs/xfs/xfs_log_priv.h index a884cea82fca..8f285149681f 100644 --- a/fs/xfs/xfs_log_priv.h +++ b/fs/xfs/xfs_log_priv.h | |||
@@ -1,33 +1,19 @@ | |||
1 | /* | 1 | /* |
2 | * Copyright (c) 2000-2003 Silicon Graphics, Inc. All Rights Reserved. | 2 | * Copyright (c) 2000-2003,2005 Silicon Graphics, Inc. |
3 | * All Rights Reserved. | ||
3 | * | 4 | * |
4 | * This program is free software; you can redistribute it and/or modify it | 5 | * This program is free software; you can redistribute it and/or |
5 | * under the terms of version 2 of the GNU General Public License as | 6 | * modify it under the terms of the GNU General Public License as |
6 | * published by the Free Software Foundation. | 7 | * published by the Free Software Foundation. |
7 | * | 8 | * |
8 | * This program is distributed in the hope that it would be useful, but | 9 | * This program is distributed in the hope that it would be useful, |
9 | * WITHOUT ANY WARRANTY; without even the implied warranty of | 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
12 | * GNU General Public License for more details. | ||
11 | * | 13 | * |
12 | * Further, this software is distributed without any warranty that it is | 14 | * You should have received a copy of the GNU General Public License |
13 | * free of the rightful claim of any third person regarding infringement | 15 | * along with this program; if not, write the Free Software Foundation, |
14 | * or the like. Any license provided herein, whether implied or | 16 | * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
15 | * otherwise, applies only to this software file. Patent licenses, if | ||
16 | * any, provided herein do not apply to combinations of this program with | ||
17 | * other software, or any other product whatsoever. | ||
18 | * | ||
19 | * You should have received a copy of the GNU General Public License along | ||
20 | * with this program; if not, write the Free Software Foundation, Inc., 59 | ||
21 | * Temple Place - Suite 330, Boston MA 02111-1307, USA. | ||
22 | * | ||
23 | * Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy, | ||
24 | * Mountain View, CA 94043, or: | ||
25 | * | ||
26 | * http://www.sgi.com | ||
27 | * | ||
28 | * For further information regarding this notice, see: | ||
29 | * | ||
30 | * http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/ | ||
31 | */ | 17 | */ |
32 | #ifndef __XFS_LOG_PRIV_H__ | 18 | #ifndef __XFS_LOG_PRIV_H__ |
33 | #define __XFS_LOG_PRIV_H__ | 19 | #define __XFS_LOG_PRIV_H__ |
@@ -35,6 +21,7 @@ | |||
35 | struct xfs_buf; | 21 | struct xfs_buf; |
36 | struct ktrace; | 22 | struct ktrace; |
37 | struct log; | 23 | struct log; |
24 | struct xlog_ticket; | ||
38 | struct xfs_buf_cancel; | 25 | struct xfs_buf_cancel; |
39 | struct xfs_mount; | 26 | struct xfs_mount; |
40 | 27 | ||
@@ -120,77 +107,6 @@ struct xfs_mount; | |||
120 | ((i) >> 24) | 107 | ((i) >> 24) |
121 | #endif | 108 | #endif |
122 | 109 | ||
123 | #if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XLOG_GRANT_SUB_SPACE) | ||
124 | void xlog_grant_sub_space(struct log *log, int bytes, int type); | ||
125 | #define XLOG_GRANT_SUB_SPACE(log,bytes,type) \ | ||
126 | xlog_grant_sub_space(log,bytes,type) | ||
127 | #else | ||
128 | #define XLOG_GRANT_SUB_SPACE(log,bytes,type) \ | ||
129 | { \ | ||
130 | if (type == 'w') { \ | ||
131 | (log)->l_grant_write_bytes -= (bytes); \ | ||
132 | if ((log)->l_grant_write_bytes < 0) { \ | ||
133 | (log)->l_grant_write_bytes += (log)->l_logsize; \ | ||
134 | (log)->l_grant_write_cycle--; \ | ||
135 | } \ | ||
136 | } else { \ | ||
137 | (log)->l_grant_reserve_bytes -= (bytes); \ | ||
138 | if ((log)->l_grant_reserve_bytes < 0) { \ | ||
139 | (log)->l_grant_reserve_bytes += (log)->l_logsize;\ | ||
140 | (log)->l_grant_reserve_cycle--; \ | ||
141 | } \ | ||
142 | } \ | ||
143 | } | ||
144 | #endif | ||
145 | #if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XLOG_GRANT_ADD_SPACE) | ||
146 | void xlog_grant_add_space(struct log *log, int bytes, int type); | ||
147 | #define XLOG_GRANT_ADD_SPACE(log,bytes,type) \ | ||
148 | xlog_grant_add_space(log,bytes,type) | ||
149 | #else | ||
150 | #define XLOG_GRANT_ADD_SPACE(log,bytes,type) \ | ||
151 | { \ | ||
152 | if (type == 'w') { \ | ||
153 | (log)->l_grant_write_bytes += (bytes); \ | ||
154 | if ((log)->l_grant_write_bytes > (log)->l_logsize) { \ | ||
155 | (log)->l_grant_write_bytes -= (log)->l_logsize; \ | ||
156 | (log)->l_grant_write_cycle++; \ | ||
157 | } \ | ||
158 | } else { \ | ||
159 | (log)->l_grant_reserve_bytes += (bytes); \ | ||
160 | if ((log)->l_grant_reserve_bytes > (log)->l_logsize) { \ | ||
161 | (log)->l_grant_reserve_bytes -= (log)->l_logsize;\ | ||
162 | (log)->l_grant_reserve_cycle++; \ | ||
163 | } \ | ||
164 | } \ | ||
165 | } | ||
166 | #endif | ||
167 | #define XLOG_INS_TICKETQ(q,tic) \ | ||
168 | { \ | ||
169 | if (q) { \ | ||
170 | (tic)->t_next = (q); \ | ||
171 | (tic)->t_prev = (q)->t_prev; \ | ||
172 | (q)->t_prev->t_next = (tic); \ | ||
173 | (q)->t_prev = (tic); \ | ||
174 | } else { \ | ||
175 | (tic)->t_prev = (tic)->t_next = (tic); \ | ||
176 | (q) = (tic); \ | ||
177 | } \ | ||
178 | (tic)->t_flags |= XLOG_TIC_IN_Q; \ | ||
179 | } | ||
180 | #define XLOG_DEL_TICKETQ(q,tic) \ | ||
181 | { \ | ||
182 | if ((tic) == (tic)->t_next) { \ | ||
183 | (q) = NULL; \ | ||
184 | } else { \ | ||
185 | (q) = (tic)->t_next; \ | ||
186 | (tic)->t_next->t_prev = (tic)->t_prev; \ | ||
187 | (tic)->t_prev->t_next = (tic)->t_next; \ | ||
188 | } \ | ||
189 | (tic)->t_next = (tic)->t_prev = NULL; \ | ||
190 | (tic)->t_flags &= ~XLOG_TIC_IN_Q; \ | ||
191 | } | ||
192 | |||
193 | |||
194 | #define GRANT_LOCK(log) mutex_spinlock(&(log)->l_grant_lock) | 110 | #define GRANT_LOCK(log) mutex_spinlock(&(log)->l_grant_lock) |
195 | #define GRANT_UNLOCK(log, s) mutex_spinunlock(&(log)->l_grant_lock, s) | 111 | #define GRANT_UNLOCK(log, s) mutex_spinunlock(&(log)->l_grant_lock, s) |
196 | #define LOG_LOCK(log) mutex_spinlock(&(log)->l_icloglock) | 112 | #define LOG_LOCK(log) mutex_spinlock(&(log)->l_icloglock) |
@@ -576,6 +492,77 @@ typedef struct log { | |||
576 | * alignment mask */ | 492 | * alignment mask */ |
577 | } xlog_t; | 493 | } xlog_t; |
578 | 494 | ||
495 | #define XLOG_FORCED_SHUTDOWN(log) ((log)->l_flags & XLOG_IO_ERROR) | ||
496 | |||
497 | #define XLOG_GRANT_SUB_SPACE(log,bytes,type) \ | ||
498 | xlog_grant_sub_space(log,bytes,type) | ||
499 | static inline void xlog_grant_sub_space(struct log *log, int bytes, int type) | ||
500 | { | ||
501 | if (type == 'w') { \ | ||
502 | (log)->l_grant_write_bytes -= (bytes); \ | ||
503 | if ((log)->l_grant_write_bytes < 0) { \ | ||
504 | (log)->l_grant_write_bytes += (log)->l_logsize; \ | ||
505 | (log)->l_grant_write_cycle--; \ | ||
506 | } \ | ||
507 | } else { \ | ||
508 | (log)->l_grant_reserve_bytes -= (bytes); \ | ||
509 | if ((log)->l_grant_reserve_bytes < 0) { \ | ||
510 | (log)->l_grant_reserve_bytes += (log)->l_logsize;\ | ||
511 | (log)->l_grant_reserve_cycle--; \ | ||
512 | } \ | ||
513 | } \ | ||
514 | } | ||
515 | |||
516 | #define XLOG_GRANT_ADD_SPACE(log,bytes,type) \ | ||
517 | xlog_grant_add_space(log,bytes,type) | ||
518 | static inline void | ||
519 | xlog_grant_add_space(struct log *log, int bytes, int type) | ||
520 | { | ||
521 | if (type == 'w') { \ | ||
522 | (log)->l_grant_write_bytes += (bytes); \ | ||
523 | if ((log)->l_grant_write_bytes > (log)->l_logsize) { \ | ||
524 | (log)->l_grant_write_bytes -= (log)->l_logsize; \ | ||
525 | (log)->l_grant_write_cycle++; \ | ||
526 | } \ | ||
527 | } else { \ | ||
528 | (log)->l_grant_reserve_bytes += (bytes); \ | ||
529 | if ((log)->l_grant_reserve_bytes > (log)->l_logsize) { \ | ||
530 | (log)->l_grant_reserve_bytes -= (log)->l_logsize;\ | ||
531 | (log)->l_grant_reserve_cycle++; \ | ||
532 | } \ | ||
533 | } \ | ||
534 | } | ||
535 | |||
536 | #define XLOG_INS_TICKETQ(q, tic) xlog_ins_ticketq(q, tic) | ||
537 | static inline void | ||
538 | xlog_ins_ticketq(struct xlog_ticket *q, struct xlog_ticket *tic) | ||
539 | { \ | ||
540 | if (q) { \ | ||
541 | (tic)->t_next = (q); \ | ||
542 | (tic)->t_prev = (q)->t_prev; \ | ||
543 | (q)->t_prev->t_next = (tic); \ | ||
544 | (q)->t_prev = (tic); \ | ||
545 | } else { \ | ||
546 | (tic)->t_prev = (tic)->t_next = (tic); \ | ||
547 | (q) = (tic); \ | ||
548 | } \ | ||
549 | (tic)->t_flags |= XLOG_TIC_IN_Q; \ | ||
550 | } | ||
551 | |||
552 | #define XLOG_DEL_TICKETQ(q, tic) xlog_del_ticketq(q, tic) | ||
553 | static inline void | ||
554 | xlog_del_ticketq(struct xlog_ticket *q, struct xlog_ticket *tic) | ||
555 | { \ | ||
556 | if ((tic) == (tic)->t_next) { \ | ||
557 | (q) = NULL; \ | ||
558 | } else { \ | ||
559 | (q) = (tic)->t_next; \ | ||
560 | (tic)->t_next->t_prev = (tic)->t_prev; \ | ||
561 | (tic)->t_prev->t_next = (tic)->t_next; \ | ||
562 | } \ | ||
563 | (tic)->t_next = (tic)->t_prev = NULL; \ | ||
564 | (tic)->t_flags &= ~XLOG_TIC_IN_Q; \ | ||
565 | } | ||
579 | 566 | ||
580 | /* common routines */ | 567 | /* common routines */ |
581 | extern xfs_lsn_t xlog_assign_tail_lsn(struct xfs_mount *mp); | 568 | extern xfs_lsn_t xlog_assign_tail_lsn(struct xfs_mount *mp); |
diff --git a/fs/xfs/xfs_log_recover.c b/fs/xfs/xfs_log_recover.c index 14faabaabf29..8ab7df768063 100644 --- a/fs/xfs/xfs_log_recover.c +++ b/fs/xfs/xfs_log_recover.c | |||
@@ -1,66 +1,51 @@ | |||
1 | /* | 1 | /* |
2 | * Copyright (c) 2000-2003 Silicon Graphics, Inc. All Rights Reserved. | 2 | * Copyright (c) 2000-2003,2005 Silicon Graphics, Inc. |
3 | * All Rights Reserved. | ||
3 | * | 4 | * |
4 | * This program is free software; you can redistribute it and/or modify it | 5 | * This program is free software; you can redistribute it and/or |
5 | * under the terms of version 2 of the GNU General Public License as | 6 | * modify it under the terms of the GNU General Public License as |
6 | * published by the Free Software Foundation. | 7 | * published by the Free Software Foundation. |
7 | * | 8 | * |
8 | * This program is distributed in the hope that it would be useful, but | 9 | * This program is distributed in the hope that it would be useful, |
9 | * WITHOUT ANY WARRANTY; without even the implied warranty of | 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
12 | * GNU General Public License for more details. | ||
11 | * | 13 | * |
12 | * Further, this software is distributed without any warranty that it is | 14 | * You should have received a copy of the GNU General Public License |
13 | * free of the rightful claim of any third person regarding infringement | 15 | * along with this program; if not, write the Free Software Foundation, |
14 | * or the like. Any license provided herein, whether implied or | 16 | * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
15 | * otherwise, applies only to this software file. Patent licenses, if | ||
16 | * any, provided herein do not apply to combinations of this program with | ||
17 | * other software, or any other product whatsoever. | ||
18 | * | ||
19 | * You should have received a copy of the GNU General Public License along | ||
20 | * with this program; if not, write the Free Software Foundation, Inc., 59 | ||
21 | * Temple Place - Suite 330, Boston MA 02111-1307, USA. | ||
22 | * | ||
23 | * Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy, | ||
24 | * Mountain View, CA 94043, or: | ||
25 | * | ||
26 | * http://www.sgi.com | ||
27 | * | ||
28 | * For further information regarding this notice, see: | ||
29 | * | ||
30 | * http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/ | ||
31 | */ | 17 | */ |
32 | |||
33 | #include "xfs.h" | 18 | #include "xfs.h" |
34 | #include "xfs_macros.h" | 19 | #include "xfs_fs.h" |
35 | #include "xfs_types.h" | 20 | #include "xfs_types.h" |
36 | #include "xfs_inum.h" | 21 | #include "xfs_bit.h" |
37 | #include "xfs_log.h" | 22 | #include "xfs_log.h" |
38 | #include "xfs_ag.h" | 23 | #include "xfs_inum.h" |
39 | #include "xfs_sb.h" | ||
40 | #include "xfs_trans.h" | 24 | #include "xfs_trans.h" |
25 | #include "xfs_sb.h" | ||
26 | #include "xfs_ag.h" | ||
41 | #include "xfs_dir.h" | 27 | #include "xfs_dir.h" |
42 | #include "xfs_dir2.h" | 28 | #include "xfs_dir2.h" |
43 | #include "xfs_dmapi.h" | 29 | #include "xfs_dmapi.h" |
44 | #include "xfs_mount.h" | 30 | #include "xfs_mount.h" |
45 | #include "xfs_error.h" | 31 | #include "xfs_error.h" |
46 | #include "xfs_bmap_btree.h" | 32 | #include "xfs_bmap_btree.h" |
47 | #include "xfs_alloc.h" | 33 | #include "xfs_alloc_btree.h" |
48 | #include "xfs_attr_sf.h" | 34 | #include "xfs_ialloc_btree.h" |
49 | #include "xfs_dir_sf.h" | 35 | #include "xfs_dir_sf.h" |
50 | #include "xfs_dir2_sf.h" | 36 | #include "xfs_dir2_sf.h" |
37 | #include "xfs_attr_sf.h" | ||
51 | #include "xfs_dinode.h" | 38 | #include "xfs_dinode.h" |
52 | #include "xfs_imap.h" | ||
53 | #include "xfs_inode_item.h" | ||
54 | #include "xfs_inode.h" | 39 | #include "xfs_inode.h" |
55 | #include "xfs_ialloc_btree.h" | 40 | #include "xfs_inode_item.h" |
41 | #include "xfs_imap.h" | ||
42 | #include "xfs_alloc.h" | ||
56 | #include "xfs_ialloc.h" | 43 | #include "xfs_ialloc.h" |
57 | #include "xfs_log_priv.h" | 44 | #include "xfs_log_priv.h" |
58 | #include "xfs_buf_item.h" | 45 | #include "xfs_buf_item.h" |
59 | #include "xfs_alloc_btree.h" | ||
60 | #include "xfs_log_recover.h" | 46 | #include "xfs_log_recover.h" |
61 | #include "xfs_extfree_item.h" | 47 | #include "xfs_extfree_item.h" |
62 | #include "xfs_trans_priv.h" | 48 | #include "xfs_trans_priv.h" |
63 | #include "xfs_bit.h" | ||
64 | #include "xfs_quota.h" | 49 | #include "xfs_quota.h" |
65 | #include "xfs_rw.h" | 50 | #include "xfs_rw.h" |
66 | 51 | ||
@@ -2013,79 +1998,74 @@ xfs_qm_dqcheck( | |||
2013 | * This is all fine; things are still consistent, and we haven't lost | 1998 | * This is all fine; things are still consistent, and we haven't lost |
2014 | * any quota information. Just don't complain about bad dquot blks. | 1999 | * any quota information. Just don't complain about bad dquot blks. |
2015 | */ | 2000 | */ |
2016 | if (INT_GET(ddq->d_magic, ARCH_CONVERT) != XFS_DQUOT_MAGIC) { | 2001 | if (be16_to_cpu(ddq->d_magic) != XFS_DQUOT_MAGIC) { |
2017 | if (flags & XFS_QMOPT_DOWARN) | 2002 | if (flags & XFS_QMOPT_DOWARN) |
2018 | cmn_err(CE_ALERT, | 2003 | cmn_err(CE_ALERT, |
2019 | "%s : XFS dquot ID 0x%x, magic 0x%x != 0x%x", | 2004 | "%s : XFS dquot ID 0x%x, magic 0x%x != 0x%x", |
2020 | str, id, | 2005 | str, id, be16_to_cpu(ddq->d_magic), XFS_DQUOT_MAGIC); |
2021 | INT_GET(ddq->d_magic, ARCH_CONVERT), XFS_DQUOT_MAGIC); | ||
2022 | errs++; | 2006 | errs++; |
2023 | } | 2007 | } |
2024 | if (INT_GET(ddq->d_version, ARCH_CONVERT) != XFS_DQUOT_VERSION) { | 2008 | if (ddq->d_version != XFS_DQUOT_VERSION) { |
2025 | if (flags & XFS_QMOPT_DOWARN) | 2009 | if (flags & XFS_QMOPT_DOWARN) |
2026 | cmn_err(CE_ALERT, | 2010 | cmn_err(CE_ALERT, |
2027 | "%s : XFS dquot ID 0x%x, version 0x%x != 0x%x", | 2011 | "%s : XFS dquot ID 0x%x, version 0x%x != 0x%x", |
2028 | str, id, | 2012 | str, id, ddq->d_version, XFS_DQUOT_VERSION); |
2029 | INT_GET(ddq->d_magic, ARCH_CONVERT), XFS_DQUOT_VERSION); | ||
2030 | errs++; | 2013 | errs++; |
2031 | } | 2014 | } |
2032 | 2015 | ||
2033 | if (INT_GET(ddq->d_flags, ARCH_CONVERT) != XFS_DQ_USER && | 2016 | if (ddq->d_flags != XFS_DQ_USER && |
2034 | INT_GET(ddq->d_flags, ARCH_CONVERT) != XFS_DQ_PROJ && | 2017 | ddq->d_flags != XFS_DQ_PROJ && |
2035 | INT_GET(ddq->d_flags, ARCH_CONVERT) != XFS_DQ_GROUP) { | 2018 | ddq->d_flags != XFS_DQ_GROUP) { |
2036 | if (flags & XFS_QMOPT_DOWARN) | 2019 | if (flags & XFS_QMOPT_DOWARN) |
2037 | cmn_err(CE_ALERT, | 2020 | cmn_err(CE_ALERT, |
2038 | "%s : XFS dquot ID 0x%x, unknown flags 0x%x", | 2021 | "%s : XFS dquot ID 0x%x, unknown flags 0x%x", |
2039 | str, id, INT_GET(ddq->d_flags, ARCH_CONVERT)); | 2022 | str, id, ddq->d_flags); |
2040 | errs++; | 2023 | errs++; |
2041 | } | 2024 | } |
2042 | 2025 | ||
2043 | if (id != -1 && id != INT_GET(ddq->d_id, ARCH_CONVERT)) { | 2026 | if (id != -1 && id != be32_to_cpu(ddq->d_id)) { |
2044 | if (flags & XFS_QMOPT_DOWARN) | 2027 | if (flags & XFS_QMOPT_DOWARN) |
2045 | cmn_err(CE_ALERT, | 2028 | cmn_err(CE_ALERT, |
2046 | "%s : ondisk-dquot 0x%p, ID mismatch: " | 2029 | "%s : ondisk-dquot 0x%p, ID mismatch: " |
2047 | "0x%x expected, found id 0x%x", | 2030 | "0x%x expected, found id 0x%x", |
2048 | str, ddq, id, INT_GET(ddq->d_id, ARCH_CONVERT)); | 2031 | str, ddq, id, be32_to_cpu(ddq->d_id)); |
2049 | errs++; | 2032 | errs++; |
2050 | } | 2033 | } |
2051 | 2034 | ||
2052 | if (!errs && ddq->d_id) { | 2035 | if (!errs && ddq->d_id) { |
2053 | if (INT_GET(ddq->d_blk_softlimit, ARCH_CONVERT) && | 2036 | if (ddq->d_blk_softlimit && |
2054 | INT_GET(ddq->d_bcount, ARCH_CONVERT) >= | 2037 | be64_to_cpu(ddq->d_bcount) >= |
2055 | INT_GET(ddq->d_blk_softlimit, ARCH_CONVERT)) { | 2038 | be64_to_cpu(ddq->d_blk_softlimit)) { |
2056 | if (!ddq->d_btimer) { | 2039 | if (!ddq->d_btimer) { |
2057 | if (flags & XFS_QMOPT_DOWARN) | 2040 | if (flags & XFS_QMOPT_DOWARN) |
2058 | cmn_err(CE_ALERT, | 2041 | cmn_err(CE_ALERT, |
2059 | "%s : Dquot ID 0x%x (0x%p) " | 2042 | "%s : Dquot ID 0x%x (0x%p) " |
2060 | "BLK TIMER NOT STARTED", | 2043 | "BLK TIMER NOT STARTED", |
2061 | str, (int) | 2044 | str, (int)be32_to_cpu(ddq->d_id), ddq); |
2062 | INT_GET(ddq->d_id, ARCH_CONVERT), ddq); | ||
2063 | errs++; | 2045 | errs++; |
2064 | } | 2046 | } |
2065 | } | 2047 | } |
2066 | if (INT_GET(ddq->d_ino_softlimit, ARCH_CONVERT) && | 2048 | if (ddq->d_ino_softlimit && |
2067 | INT_GET(ddq->d_icount, ARCH_CONVERT) >= | 2049 | be64_to_cpu(ddq->d_icount) >= |
2068 | INT_GET(ddq->d_ino_softlimit, ARCH_CONVERT)) { | 2050 | be64_to_cpu(ddq->d_ino_softlimit)) { |
2069 | if (!ddq->d_itimer) { | 2051 | if (!ddq->d_itimer) { |
2070 | if (flags & XFS_QMOPT_DOWARN) | 2052 | if (flags & XFS_QMOPT_DOWARN) |
2071 | cmn_err(CE_ALERT, | 2053 | cmn_err(CE_ALERT, |
2072 | "%s : Dquot ID 0x%x (0x%p) " | 2054 | "%s : Dquot ID 0x%x (0x%p) " |
2073 | "INODE TIMER NOT STARTED", | 2055 | "INODE TIMER NOT STARTED", |
2074 | str, (int) | 2056 | str, (int)be32_to_cpu(ddq->d_id), ddq); |
2075 | INT_GET(ddq->d_id, ARCH_CONVERT), ddq); | ||
2076 | errs++; | 2057 | errs++; |
2077 | } | 2058 | } |
2078 | } | 2059 | } |
2079 | if (INT_GET(ddq->d_rtb_softlimit, ARCH_CONVERT) && | 2060 | if (ddq->d_rtb_softlimit && |
2080 | INT_GET(ddq->d_rtbcount, ARCH_CONVERT) >= | 2061 | be64_to_cpu(ddq->d_rtbcount) >= |
2081 | INT_GET(ddq->d_rtb_softlimit, ARCH_CONVERT)) { | 2062 | be64_to_cpu(ddq->d_rtb_softlimit)) { |
2082 | if (!ddq->d_rtbtimer) { | 2063 | if (!ddq->d_rtbtimer) { |
2083 | if (flags & XFS_QMOPT_DOWARN) | 2064 | if (flags & XFS_QMOPT_DOWARN) |
2084 | cmn_err(CE_ALERT, | 2065 | cmn_err(CE_ALERT, |
2085 | "%s : Dquot ID 0x%x (0x%p) " | 2066 | "%s : Dquot ID 0x%x (0x%p) " |
2086 | "RTBLK TIMER NOT STARTED", | 2067 | "RTBLK TIMER NOT STARTED", |
2087 | str, (int) | 2068 | str, (int)be32_to_cpu(ddq->d_id), ddq); |
2088 | INT_GET(ddq->d_id, ARCH_CONVERT), ddq); | ||
2089 | errs++; | 2069 | errs++; |
2090 | } | 2070 | } |
2091 | } | 2071 | } |
@@ -2103,10 +2083,11 @@ xfs_qm_dqcheck( | |||
2103 | ASSERT(id != -1); | 2083 | ASSERT(id != -1); |
2104 | ASSERT(flags & XFS_QMOPT_DQREPAIR); | 2084 | ASSERT(flags & XFS_QMOPT_DQREPAIR); |
2105 | memset(d, 0, sizeof(xfs_dqblk_t)); | 2085 | memset(d, 0, sizeof(xfs_dqblk_t)); |
2106 | INT_SET(d->dd_diskdq.d_magic, ARCH_CONVERT, XFS_DQUOT_MAGIC); | 2086 | |
2107 | INT_SET(d->dd_diskdq.d_version, ARCH_CONVERT, XFS_DQUOT_VERSION); | 2087 | d->dd_diskdq.d_magic = cpu_to_be16(XFS_DQUOT_MAGIC); |
2108 | INT_SET(d->dd_diskdq.d_id, ARCH_CONVERT, id); | 2088 | d->dd_diskdq.d_version = XFS_DQUOT_VERSION; |
2109 | INT_SET(d->dd_diskdq.d_flags, ARCH_CONVERT, type); | 2089 | d->dd_diskdq.d_flags = type; |
2090 | d->dd_diskdq.d_id = cpu_to_be32(id); | ||
2110 | 2091 | ||
2111 | return errs; | 2092 | return errs; |
2112 | } | 2093 | } |
@@ -2226,8 +2207,9 @@ xlog_recover_do_buffer_trans( | |||
2226 | break; | 2207 | break; |
2227 | default: | 2208 | default: |
2228 | xfs_fs_cmn_err(CE_ALERT, log->l_mp, | 2209 | xfs_fs_cmn_err(CE_ALERT, log->l_mp, |
2229 | "xfs_log_recover: unknown buffer type 0x%x, dev %s", | 2210 | "xfs_log_recover: unknown buffer type 0x%x, logdev %s", |
2230 | buf_f->blf_type, XFS_BUFTARG_NAME(log->l_targ)); | 2211 | buf_f->blf_type, log->l_mp->m_logname ? |
2212 | log->l_mp->m_logname : "internal"); | ||
2231 | XFS_ERROR_REPORT("xlog_recover_do_buffer_trans", | 2213 | XFS_ERROR_REPORT("xlog_recover_do_buffer_trans", |
2232 | XFS_ERRLEVEL_LOW, log->l_mp); | 2214 | XFS_ERRLEVEL_LOW, log->l_mp); |
2233 | return XFS_ERROR(EFSCORRUPTED); | 2215 | return XFS_ERROR(EFSCORRUPTED); |
@@ -3178,13 +3160,12 @@ xlog_recover_clear_agi_bucket( | |||
3178 | } | 3160 | } |
3179 | 3161 | ||
3180 | agi = XFS_BUF_TO_AGI(agibp); | 3162 | agi = XFS_BUF_TO_AGI(agibp); |
3181 | if (INT_GET(agi->agi_magicnum, ARCH_CONVERT) != XFS_AGI_MAGIC) { | 3163 | if (be32_to_cpu(agi->agi_magicnum) != XFS_AGI_MAGIC) { |
3182 | xfs_trans_cancel(tp, XFS_TRANS_ABORT); | 3164 | xfs_trans_cancel(tp, XFS_TRANS_ABORT); |
3183 | return; | 3165 | return; |
3184 | } | 3166 | } |
3185 | ASSERT(INT_GET(agi->agi_magicnum, ARCH_CONVERT) == XFS_AGI_MAGIC); | ||
3186 | 3167 | ||
3187 | INT_SET(agi->agi_unlinked[bucket], ARCH_CONVERT, NULLAGINO); | 3168 | agi->agi_unlinked[bucket] = cpu_to_be32(NULLAGINO); |
3188 | offset = offsetof(xfs_agi_t, agi_unlinked) + | 3169 | offset = offsetof(xfs_agi_t, agi_unlinked) + |
3189 | (sizeof(xfs_agino_t) * bucket); | 3170 | (sizeof(xfs_agino_t) * bucket); |
3190 | xfs_trans_log_buf(tp, agibp, offset, | 3171 | xfs_trans_log_buf(tp, agibp, offset, |
@@ -3243,12 +3224,11 @@ xlog_recover_process_iunlinks( | |||
3243 | XFS_AG_DADDR(mp, agno, XFS_AGI_DADDR(mp))); | 3224 | XFS_AG_DADDR(mp, agno, XFS_AGI_DADDR(mp))); |
3244 | } | 3225 | } |
3245 | agi = XFS_BUF_TO_AGI(agibp); | 3226 | agi = XFS_BUF_TO_AGI(agibp); |
3246 | ASSERT(XFS_AGI_MAGIC == | 3227 | ASSERT(XFS_AGI_MAGIC == be32_to_cpu(agi->agi_magicnum)); |
3247 | INT_GET(agi->agi_magicnum, ARCH_CONVERT)); | ||
3248 | 3228 | ||
3249 | for (bucket = 0; bucket < XFS_AGI_UNLINKED_BUCKETS; bucket++) { | 3229 | for (bucket = 0; bucket < XFS_AGI_UNLINKED_BUCKETS; bucket++) { |
3250 | 3230 | ||
3251 | agino = INT_GET(agi->agi_unlinked[bucket], ARCH_CONVERT); | 3231 | agino = be32_to_cpu(agi->agi_unlinked[bucket]); |
3252 | while (agino != NULLAGINO) { | 3232 | while (agino != NULLAGINO) { |
3253 | 3233 | ||
3254 | /* | 3234 | /* |
@@ -3336,8 +3316,8 @@ xlog_recover_process_iunlinks( | |||
3336 | XFS_AGI_DADDR(mp))); | 3316 | XFS_AGI_DADDR(mp))); |
3337 | } | 3317 | } |
3338 | agi = XFS_BUF_TO_AGI(agibp); | 3318 | agi = XFS_BUF_TO_AGI(agibp); |
3339 | ASSERT(XFS_AGI_MAGIC == INT_GET( | 3319 | ASSERT(XFS_AGI_MAGIC == be32_to_cpu( |
3340 | agi->agi_magicnum, ARCH_CONVERT)); | 3320 | agi->agi_magicnum)); |
3341 | } | 3321 | } |
3342 | } | 3322 | } |
3343 | 3323 | ||
@@ -3938,8 +3918,9 @@ xlog_recover( | |||
3938 | } | 3918 | } |
3939 | 3919 | ||
3940 | cmn_err(CE_NOTE, | 3920 | cmn_err(CE_NOTE, |
3941 | "Starting XFS recovery on filesystem: %s (dev: %s)", | 3921 | "Starting XFS recovery on filesystem: %s (logdev: %s)", |
3942 | log->l_mp->m_fsname, XFS_BUFTARG_NAME(log->l_targ)); | 3922 | log->l_mp->m_fsname, log->l_mp->m_logname ? |
3923 | log->l_mp->m_logname : "internal"); | ||
3943 | 3924 | ||
3944 | error = xlog_do_recover(log, head_blk, tail_blk); | 3925 | error = xlog_do_recover(log, head_blk, tail_blk); |
3945 | log->l_flags |= XLOG_RECOVERY_NEEDED; | 3926 | log->l_flags |= XLOG_RECOVERY_NEEDED; |
@@ -3987,8 +3968,9 @@ xlog_recover_finish( | |||
3987 | xlog_recover_check_summary(log); | 3968 | xlog_recover_check_summary(log); |
3988 | 3969 | ||
3989 | cmn_err(CE_NOTE, | 3970 | cmn_err(CE_NOTE, |
3990 | "Ending XFS recovery on filesystem: %s (dev: %s)", | 3971 | "Ending XFS recovery on filesystem: %s (logdev: %s)", |
3991 | log->l_mp->m_fsname, XFS_BUFTARG_NAME(log->l_targ)); | 3972 | log->l_mp->m_fsname, log->l_mp->m_logname ? |
3973 | log->l_mp->m_logname : "internal"); | ||
3992 | log->l_flags &= ~XLOG_RECOVERY_NEEDED; | 3974 | log->l_flags &= ~XLOG_RECOVERY_NEEDED; |
3993 | } else { | 3975 | } else { |
3994 | cmn_err(CE_DEBUG, | 3976 | cmn_err(CE_DEBUG, |
@@ -4038,14 +4020,12 @@ xlog_recover_check_summary( | |||
4038 | mp, agfbp, agfdaddr); | 4020 | mp, agfbp, agfdaddr); |
4039 | } | 4021 | } |
4040 | agfp = XFS_BUF_TO_AGF(agfbp); | 4022 | agfp = XFS_BUF_TO_AGF(agfbp); |
4041 | ASSERT(XFS_AGF_MAGIC == | 4023 | ASSERT(XFS_AGF_MAGIC == be32_to_cpu(agfp->agf_magicnum)); |
4042 | INT_GET(agfp->agf_magicnum, ARCH_CONVERT)); | 4024 | ASSERT(XFS_AGF_GOOD_VERSION(be32_to_cpu(agfp->agf_versionnum))); |
4043 | ASSERT(XFS_AGF_GOOD_VERSION( | 4025 | ASSERT(be32_to_cpu(agfp->agf_seqno) == agno); |
4044 | INT_GET(agfp->agf_versionnum, ARCH_CONVERT))); | 4026 | |
4045 | ASSERT(INT_GET(agfp->agf_seqno, ARCH_CONVERT) == agno); | 4027 | freeblks += be32_to_cpu(agfp->agf_freeblks) + |
4046 | 4028 | be32_to_cpu(agfp->agf_flcount); | |
4047 | freeblks += INT_GET(agfp->agf_freeblks, ARCH_CONVERT) + | ||
4048 | INT_GET(agfp->agf_flcount, ARCH_CONVERT); | ||
4049 | xfs_buf_relse(agfbp); | 4029 | xfs_buf_relse(agfbp); |
4050 | 4030 | ||
4051 | agidaddr = XFS_AG_DADDR(mp, agno, XFS_AGI_DADDR(mp)); | 4031 | agidaddr = XFS_AG_DADDR(mp, agno, XFS_AGI_DADDR(mp)); |
@@ -4056,14 +4036,12 @@ xlog_recover_check_summary( | |||
4056 | mp, agibp, agidaddr); | 4036 | mp, agibp, agidaddr); |
4057 | } | 4037 | } |
4058 | agip = XFS_BUF_TO_AGI(agibp); | 4038 | agip = XFS_BUF_TO_AGI(agibp); |
4059 | ASSERT(XFS_AGI_MAGIC == | 4039 | ASSERT(XFS_AGI_MAGIC == be32_to_cpu(agip->agi_magicnum)); |
4060 | INT_GET(agip->agi_magicnum, ARCH_CONVERT)); | 4040 | ASSERT(XFS_AGI_GOOD_VERSION(be32_to_cpu(agip->agi_versionnum))); |
4061 | ASSERT(XFS_AGI_GOOD_VERSION( | 4041 | ASSERT(be32_to_cpu(agip->agi_seqno) == agno); |
4062 | INT_GET(agip->agi_versionnum, ARCH_CONVERT))); | 4042 | |
4063 | ASSERT(INT_GET(agip->agi_seqno, ARCH_CONVERT) == agno); | 4043 | itotal += be32_to_cpu(agip->agi_count); |
4064 | 4044 | ifree += be32_to_cpu(agip->agi_freecount); | |
4065 | itotal += INT_GET(agip->agi_count, ARCH_CONVERT); | ||
4066 | ifree += INT_GET(agip->agi_freecount, ARCH_CONVERT); | ||
4067 | xfs_buf_relse(agibp); | 4045 | xfs_buf_relse(agibp); |
4068 | } | 4046 | } |
4069 | 4047 | ||
diff --git a/fs/xfs/xfs_log_recover.h b/fs/xfs/xfs_log_recover.h index 42158b442b55..b22545555301 100644 --- a/fs/xfs/xfs_log_recover.h +++ b/fs/xfs/xfs_log_recover.h | |||
@@ -1,33 +1,19 @@ | |||
1 | /* | 1 | /* |
2 | * Copyright (c) 2000 Silicon Graphics, Inc. All Rights Reserved. | 2 | * Copyright (c) 2000,2005 Silicon Graphics, Inc. |
3 | * All Rights Reserved. | ||
3 | * | 4 | * |
4 | * This program is free software; you can redistribute it and/or modify it | 5 | * This program is free software; you can redistribute it and/or |
5 | * under the terms of version 2 of the GNU General Public License as | 6 | * modify it under the terms of the GNU General Public License as |
6 | * published by the Free Software Foundation. | 7 | * published by the Free Software Foundation. |
7 | * | 8 | * |
8 | * This program is distributed in the hope that it would be useful, but | 9 | * This program is distributed in the hope that it would be useful, |
9 | * WITHOUT ANY WARRANTY; without even the implied warranty of | 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
12 | * GNU General Public License for more details. | ||
11 | * | 13 | * |
12 | * Further, this software is distributed without any warranty that it is | 14 | * You should have received a copy of the GNU General Public License |
13 | * free of the rightful claim of any third person regarding infringement | 15 | * along with this program; if not, write the Free Software Foundation, |
14 | * or the like. Any license provided herein, whether implied or | 16 | * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
15 | * otherwise, applies only to this software file. Patent licenses, if | ||
16 | * any, provided herein do not apply to combinations of this program with | ||
17 | * other software, or any other product whatsoever. | ||
18 | * | ||
19 | * You should have received a copy of the GNU General Public License along | ||
20 | * with this program; if not, write the Free Software Foundation, Inc., 59 | ||
21 | * Temple Place - Suite 330, Boston MA 02111-1307, USA. | ||
22 | * | ||
23 | * Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy, | ||
24 | * Mountain View, CA 94043, or: | ||
25 | * | ||
26 | * http://www.sgi.com | ||
27 | * | ||
28 | * For further information regarding this notice, see: | ||
29 | * | ||
30 | * http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/ | ||
31 | */ | 17 | */ |
32 | #ifndef __XFS_LOG_RECOVER_H__ | 18 | #ifndef __XFS_LOG_RECOVER_H__ |
33 | #define __XFS_LOG_RECOVER_H__ | 19 | #define __XFS_LOG_RECOVER_H__ |
diff --git a/fs/xfs/xfs_mac.h b/fs/xfs/xfs_mac.h index 8d59aaffeb8e..18e0e98e03d0 100644 --- a/fs/xfs/xfs_mac.h +++ b/fs/xfs/xfs_mac.h | |||
@@ -1,33 +1,19 @@ | |||
1 | /* | 1 | /* |
2 | * Copyright (c) 2001-2002 Silicon Graphics, Inc. All Rights Reserved. | 2 | * Copyright (c) 2001-2002,2005 Silicon Graphics, Inc. |
3 | * All Rights Reserved. | ||
3 | * | 4 | * |
4 | * This program is free software; you can redistribute it and/or modify it | 5 | * This program is free software; you can redistribute it and/or |
5 | * under the terms of version 2 of the GNU General Public License as | 6 | * modify it under the terms of the GNU General Public License as |
6 | * published by the Free Software Foundation. | 7 | * published by the Free Software Foundation. |
7 | * | 8 | * |
8 | * This program is distributed in the hope that it would be useful, but | 9 | * This program is distributed in the hope that it would be useful, |
9 | * WITHOUT ANY WARRANTY; without even the implied warranty of | 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
12 | * GNU General Public License for more details. | ||
11 | * | 13 | * |
12 | * Further, this software is distributed without any warranty that it is | 14 | * You should have received a copy of the GNU General Public License |
13 | * free of the rightful claim of any third person regarding infringement | 15 | * along with this program; if not, write the Free Software Foundation, |
14 | * or the like. Any license provided herein, whether implied or | 16 | * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
15 | * otherwise, applies only to this software file. Patent licenses, if | ||
16 | * any, provided herein do not apply to combinations of this program with | ||
17 | * other software, or any other product whatsoever. | ||
18 | * | ||
19 | * You should have received a copy of the GNU General Public License along | ||
20 | * with this program; if not, write the Free Software Foundation, Inc., 59 | ||
21 | * Temple Place - Suite 330, Boston MA 02111-1307, USA. | ||
22 | * | ||
23 | * Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy, | ||
24 | * Mountain View, CA 94043, or: | ||
25 | * | ||
26 | * http://www.sgi.com | ||
27 | * | ||
28 | * For further information regarding this notice, see: | ||
29 | * | ||
30 | * http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/ | ||
31 | */ | 17 | */ |
32 | #ifndef __XFS_MAC_H__ | 18 | #ifndef __XFS_MAC_H__ |
33 | #define __XFS_MAC_H__ | 19 | #define __XFS_MAC_H__ |
diff --git a/fs/xfs/xfs_macros.c b/fs/xfs/xfs_macros.c deleted file mode 100644 index 698c2cd62858..000000000000 --- a/fs/xfs/xfs_macros.c +++ /dev/null | |||
@@ -1,2141 +0,0 @@ | |||
1 | /* | ||
2 | * Copyright (c) 2000-2003 Silicon Graphics, Inc. All Rights Reserved. | ||
3 | * | ||
4 | * This program is free software; you can redistribute it and/or modify it | ||
5 | * under the terms of version 2 of the GNU General Public License as | ||
6 | * published by the Free Software Foundation. | ||
7 | * | ||
8 | * This program is distributed in the hope that it would be useful, but | ||
9 | * WITHOUT ANY WARRANTY; without even the implied warranty of | ||
10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | ||
11 | * | ||
12 | * Further, this software is distributed without any warranty that it is | ||
13 | * free of the rightful claim of any third person regarding infringement | ||
14 | * or the like. Any license provided herein, whether implied or | ||
15 | * otherwise, applies only to this software file. Patent licenses, if | ||
16 | * any, provided herein do not apply to combinations of this program with | ||
17 | * other software, or any other product whatsoever. | ||
18 | * | ||
19 | * You should have received a copy of the GNU General Public License along | ||
20 | * with this program; if not, write the Free Software Foundation, Inc., 59 | ||
21 | * Temple Place - Suite 330, Boston MA 02111-1307, USA. | ||
22 | * | ||
23 | * Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy, | ||
24 | * Mountain View, CA 94043, or: | ||
25 | * | ||
26 | * http://www.sgi.com | ||
27 | * | ||
28 | * For further information regarding this notice, see: | ||
29 | * | ||
30 | * http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/ | ||
31 | */ | ||
32 | |||
33 | #define XFS_MACRO_C | ||
34 | |||
35 | #include "xfs.h" | ||
36 | #include "xfs_macros.h" | ||
37 | #include "xfs_types.h" | ||
38 | #include "xfs_inum.h" | ||
39 | #include "xfs_log.h" | ||
40 | #include "xfs_trans.h" | ||
41 | #include "xfs_sb.h" | ||
42 | #include "xfs_ag.h" | ||
43 | #include "xfs_dir.h" | ||
44 | #include "xfs_dir2.h" | ||
45 | #include "xfs_dmapi.h" | ||
46 | #include "xfs_mount.h" | ||
47 | #include "xfs_alloc_btree.h" | ||
48 | #include "xfs_ialloc_btree.h" | ||
49 | #include "xfs_bmap_btree.h" | ||
50 | #include "xfs_btree.h" | ||
51 | #include "xfs_attr_sf.h" | ||
52 | #include "xfs_dir_sf.h" | ||
53 | #include "xfs_dir2_sf.h" | ||
54 | #include "xfs_dinode.h" | ||
55 | #include "xfs_ialloc.h" | ||
56 | #include "xfs_inode_item.h" | ||
57 | #include "xfs_inode.h" | ||
58 | #include "xfs_bmap.h" | ||
59 | #include "xfs_rw.h" | ||
60 | #include "xfs_log_priv.h" | ||
61 | #include "xfs_da_btree.h" | ||
62 | #include "xfs_attr_leaf.h" | ||
63 | #include "xfs_dir_leaf.h" | ||
64 | #include "xfs_dir2_data.h" | ||
65 | #include "xfs_dir2_leaf.h" | ||
66 | #include "xfs_dir2_block.h" | ||
67 | #include "xfs_dir2_node.h" | ||
68 | #include "xfs_bit.h" | ||
69 | |||
70 | #if XFS_WANT_FUNCS_C || (XFS_WANT_SPACE_C && XFSSO_ISNULLDSTARTBLOCK) | ||
71 | int | ||
72 | isnulldstartblock(xfs_dfsbno_t x) | ||
73 | { | ||
74 | return ISNULLDSTARTBLOCK(x); | ||
75 | } | ||
76 | #endif | ||
77 | |||
78 | #if XFS_WANT_FUNCS_C || (XFS_WANT_SPACE_C && XFSSO_ISNULLSTARTBLOCK) | ||
79 | int | ||
80 | isnullstartblock(xfs_fsblock_t x) | ||
81 | { | ||
82 | return ISNULLSTARTBLOCK(x); | ||
83 | } | ||
84 | #endif | ||
85 | |||
86 | #if XFS_WANT_FUNCS_C || (XFS_WANT_SPACE_C && XFSSO_NULLSTARTBLOCK) | ||
87 | xfs_fsblock_t | ||
88 | nullstartblock(int k) | ||
89 | { | ||
90 | return NULLSTARTBLOCK(k); | ||
91 | } | ||
92 | #endif | ||
93 | |||
94 | #if XFS_WANT_FUNCS_C || (XFS_WANT_SPACE_C && XFSSO_STARTBLOCKVAL) | ||
95 | xfs_filblks_t | ||
96 | startblockval(xfs_fsblock_t x) | ||
97 | { | ||
98 | return STARTBLOCKVAL(x); | ||
99 | } | ||
100 | #endif | ||
101 | |||
102 | #if XFS_WANT_FUNCS_C || (XFS_WANT_SPACE_C && XFSSO_XFS_AG_CHECK_DADDR) | ||
103 | void | ||
104 | xfs_ag_check_daddr(xfs_mount_t *mp, xfs_daddr_t d, xfs_extlen_t len) | ||
105 | { | ||
106 | XFS_AG_CHECK_DADDR(mp, d, len); | ||
107 | } | ||
108 | #endif | ||
109 | |||
110 | #if XFS_WANT_FUNCS_C || (XFS_WANT_SPACE_C && XFSSO_XFS_AG_DADDR) | ||
111 | xfs_daddr_t | ||
112 | xfs_ag_daddr(xfs_mount_t *mp, xfs_agnumber_t agno, xfs_daddr_t d) | ||
113 | { | ||
114 | return XFS_AG_DADDR(mp, agno, d); | ||
115 | } | ||
116 | #endif | ||
117 | |||
118 | #if XFS_WANT_FUNCS_C || (XFS_WANT_SPACE_C && XFSSO_XFS_AG_MAXLEVELS) | ||
119 | int | ||
120 | xfs_ag_maxlevels(xfs_mount_t *mp) | ||
121 | { | ||
122 | return XFS_AG_MAXLEVELS(mp); | ||
123 | } | ||
124 | #endif | ||
125 | |||
126 | #if XFS_WANT_FUNCS_C || (XFS_WANT_SPACE_C && XFSSO_XFS_AGB_TO_DADDR) | ||
127 | xfs_daddr_t | ||
128 | xfs_agb_to_daddr(xfs_mount_t *mp, xfs_agnumber_t agno, xfs_agblock_t agbno) | ||
129 | { | ||
130 | return XFS_AGB_TO_DADDR(mp, agno, agbno); | ||
131 | } | ||
132 | #endif | ||
133 | |||
134 | #if XFS_WANT_FUNCS_C || (XFS_WANT_SPACE_C && XFSSO_XFS_AGB_TO_FSB) | ||
135 | xfs_fsblock_t | ||
136 | xfs_agb_to_fsb(xfs_mount_t *mp, xfs_agnumber_t agno, xfs_agblock_t agbno) | ||
137 | { | ||
138 | return XFS_AGB_TO_FSB(mp, agno, agbno); | ||
139 | } | ||
140 | #endif | ||
141 | |||
142 | #if XFS_WANT_FUNCS_C || (XFS_WANT_SPACE_C && XFSSO_XFS_AGBLOCK_MAX) | ||
143 | xfs_agblock_t | ||
144 | xfs_agblock_max(xfs_agblock_t a, xfs_agblock_t b) | ||
145 | { | ||
146 | return XFS_AGBLOCK_MAX(a, b); | ||
147 | } | ||
148 | #endif | ||
149 | |||
150 | #if XFS_WANT_FUNCS_C || (XFS_WANT_SPACE_C && XFSSO_XFS_AGBLOCK_MIN) | ||
151 | xfs_agblock_t | ||
152 | xfs_agblock_min(xfs_agblock_t a, xfs_agblock_t b) | ||
153 | { | ||
154 | return XFS_AGBLOCK_MIN(a, b); | ||
155 | } | ||
156 | #endif | ||
157 | |||
158 | #if XFS_WANT_FUNCS_C || (XFS_WANT_SPACE_C && XFSSO_XFS_AGF_BLOCK) | ||
159 | xfs_agblock_t | ||
160 | xfs_agf_block(xfs_mount_t *mp) | ||
161 | { | ||
162 | return XFS_AGF_BLOCK(mp); | ||
163 | } | ||
164 | #endif | ||
165 | |||
166 | #if XFS_WANT_FUNCS_C || (XFS_WANT_SPACE_C && XFSSO_XFS_AGF_GOOD_VERSION) | ||
167 | int | ||
168 | xfs_agf_good_version(unsigned v) | ||
169 | { | ||
170 | return XFS_AGF_GOOD_VERSION(v); | ||
171 | } | ||
172 | #endif | ||
173 | |||
174 | #if XFS_WANT_FUNCS_C || (XFS_WANT_SPACE_C && XFSSO_XFS_AGFL_BLOCK) | ||
175 | xfs_agblock_t | ||
176 | xfs_agfl_block(xfs_mount_t *mp) | ||
177 | { | ||
178 | return XFS_AGFL_BLOCK(mp); | ||
179 | } | ||
180 | #endif | ||
181 | |||
182 | #if XFS_WANT_FUNCS_C || (XFS_WANT_SPACE_C && XFSSO_XFS_AGI_BLOCK) | ||
183 | xfs_agblock_t | ||
184 | xfs_agi_block(xfs_mount_t *mp) | ||
185 | { | ||
186 | return XFS_AGI_BLOCK(mp); | ||
187 | } | ||
188 | #endif | ||
189 | |||
190 | #if XFS_WANT_FUNCS_C || (XFS_WANT_SPACE_C && XFSSO_XFS_AGI_GOOD_VERSION) | ||
191 | int | ||
192 | xfs_agi_good_version(unsigned v) | ||
193 | { | ||
194 | return XFS_AGI_GOOD_VERSION(v); | ||
195 | } | ||
196 | #endif | ||
197 | |||
198 | #if XFS_WANT_FUNCS_C || (XFS_WANT_SPACE_C && XFSSO_XFS_AGINO_TO_AGBNO) | ||
199 | xfs_agblock_t | ||
200 | xfs_agino_to_agbno(xfs_mount_t *mp, xfs_agino_t i) | ||
201 | { | ||
202 | return XFS_AGINO_TO_AGBNO(mp, i); | ||
203 | } | ||
204 | #endif | ||
205 | |||
206 | #if XFS_WANT_FUNCS_C || (XFS_WANT_SPACE_C && XFSSO_XFS_AGINO_TO_INO) | ||
207 | xfs_ino_t | ||
208 | xfs_agino_to_ino(xfs_mount_t *mp, xfs_agnumber_t a, xfs_agino_t i) | ||
209 | { | ||
210 | return XFS_AGINO_TO_INO(mp, a, i); | ||
211 | } | ||
212 | #endif | ||
213 | |||
214 | #if XFS_WANT_FUNCS_C || (XFS_WANT_SPACE_C && XFSSO_XFS_AGINO_TO_OFFSET) | ||
215 | int | ||
216 | xfs_agino_to_offset(xfs_mount_t *mp, xfs_agino_t i) | ||
217 | { | ||
218 | return XFS_AGINO_TO_OFFSET(mp, i); | ||
219 | } | ||
220 | #endif | ||
221 | |||
222 | #if XFS_WANT_FUNCS_C || (XFS_WANT_SPACE_C && XFSSO_XFS_ALLOC_BLOCK_MAXRECS) | ||
223 | int | ||
224 | xfs_alloc_block_maxrecs(int lev, xfs_btree_cur_t *cur) | ||
225 | { | ||
226 | return XFS_ALLOC_BLOCK_MAXRECS(lev, cur); | ||
227 | } | ||
228 | #endif | ||
229 | |||
230 | #if XFS_WANT_FUNCS_C || (XFS_WANT_SPACE_C && XFSSO_XFS_ALLOC_BLOCK_MINRECS) | ||
231 | int | ||
232 | xfs_alloc_block_minrecs(int lev, xfs_btree_cur_t *cur) | ||
233 | { | ||
234 | return XFS_ALLOC_BLOCK_MINRECS(lev, cur); | ||
235 | } | ||
236 | #endif | ||
237 | |||
238 | #if XFS_WANT_FUNCS_C || (XFS_WANT_SPACE_C && XFSSO_XFS_ALLOC_BLOCK_SIZE) | ||
239 | /*ARGSUSED1*/ | ||
240 | int | ||
241 | xfs_alloc_block_size(int lev, xfs_btree_cur_t *cur) | ||
242 | { | ||
243 | return XFS_ALLOC_BLOCK_SIZE(lev, cur); | ||
244 | } | ||
245 | #endif | ||
246 | |||
247 | #if XFS_WANT_FUNCS_C || (XFS_WANT_SPACE_C && XFSSO_XFS_ALLOC_KEY_ADDR) | ||
248 | /*ARGSUSED3*/ | ||
249 | xfs_alloc_key_t * | ||
250 | xfs_alloc_key_addr(xfs_alloc_block_t *bb, int i, xfs_btree_cur_t *cur) | ||
251 | { | ||
252 | return XFS_ALLOC_KEY_ADDR(bb, i, cur); | ||
253 | } | ||
254 | #endif | ||
255 | |||
256 | #if XFS_WANT_FUNCS_C || (XFS_WANT_SPACE_C && XFSSO_XFS_ALLOC_PTR_ADDR) | ||
257 | xfs_alloc_ptr_t * | ||
258 | xfs_alloc_ptr_addr(xfs_alloc_block_t *bb, int i, xfs_btree_cur_t *cur) | ||
259 | { | ||
260 | return XFS_ALLOC_PTR_ADDR(bb, i, cur); | ||
261 | } | ||
262 | #endif | ||
263 | |||
264 | #if XFS_WANT_FUNCS_C || (XFS_WANT_SPACE_C && XFSSO_XFS_ALLOC_REC_ADDR) | ||
265 | /*ARGSUSED3*/ | ||
266 | xfs_alloc_rec_t * | ||
267 | xfs_alloc_rec_addr(xfs_alloc_block_t *bb, int i, xfs_btree_cur_t *cur) | ||
268 | { | ||
269 | return XFS_ALLOC_REC_ADDR(bb, i, cur); | ||
270 | } | ||
271 | #endif | ||
272 | |||
273 | #if XFS_WANT_FUNCS_C || (XFS_WANT_SPACE_C && XFSSO_XFS_ATTR_LEAF_ENTSIZE_LOCAL) | ||
274 | int | ||
275 | xfs_attr_leaf_entsize_local(int nlen, int vlen) | ||
276 | { | ||
277 | return XFS_ATTR_LEAF_ENTSIZE_LOCAL(nlen, vlen); | ||
278 | } | ||
279 | #endif | ||
280 | |||
281 | #if XFS_WANT_FUNCS_C || (XFS_WANT_SPACE_C && XFSSO_XFS_ATTR_LEAF_ENTSIZE_LOCAL_MAX) | ||
282 | int | ||
283 | xfs_attr_leaf_entsize_local_max(int bsize) | ||
284 | { | ||
285 | return XFS_ATTR_LEAF_ENTSIZE_LOCAL_MAX(bsize); | ||
286 | } | ||
287 | #endif | ||
288 | |||
289 | #if XFS_WANT_FUNCS_C || (XFS_WANT_SPACE_C && XFSSO_XFS_ATTR_LEAF_ENTSIZE_REMOTE) | ||
290 | int | ||
291 | xfs_attr_leaf_entsize_remote(int nlen) | ||
292 | { | ||
293 | return XFS_ATTR_LEAF_ENTSIZE_REMOTE(nlen); | ||
294 | } | ||
295 | #endif | ||
296 | |||
297 | #if XFS_WANT_FUNCS_C || (XFS_WANT_SPACE_C && XFSSO_XFS_ATTR_LEAF_NAME) | ||
298 | char * | ||
299 | xfs_attr_leaf_name(xfs_attr_leafblock_t *leafp, int idx) | ||
300 | { | ||
301 | return XFS_ATTR_LEAF_NAME(leafp, idx); | ||
302 | } | ||
303 | #endif | ||
304 | |||
305 | #if XFS_WANT_FUNCS_C || (XFS_WANT_SPACE_C && XFSSO_XFS_ATTR_LEAF_NAME_LOCAL) | ||
306 | xfs_attr_leaf_name_local_t * | ||
307 | xfs_attr_leaf_name_local(xfs_attr_leafblock_t *leafp, int idx) | ||
308 | { | ||
309 | return XFS_ATTR_LEAF_NAME_LOCAL(leafp, idx); | ||
310 | } | ||
311 | #endif | ||
312 | |||
313 | #if XFS_WANT_FUNCS_C || (XFS_WANT_SPACE_C && XFSSO_XFS_ATTR_LEAF_NAME_REMOTE) | ||
314 | xfs_attr_leaf_name_remote_t * | ||
315 | xfs_attr_leaf_name_remote(xfs_attr_leafblock_t *leafp, int idx) | ||
316 | { | ||
317 | return XFS_ATTR_LEAF_NAME_REMOTE(leafp, idx); | ||
318 | } | ||
319 | #endif | ||
320 | |||
321 | #if XFS_WANT_FUNCS_C || (XFS_WANT_SPACE_C && XFSSO_XFS_ATTR_SF_ENTSIZE) | ||
322 | int | ||
323 | xfs_attr_sf_entsize(xfs_attr_sf_entry_t *sfep) | ||
324 | { | ||
325 | return XFS_ATTR_SF_ENTSIZE(sfep); | ||
326 | } | ||
327 | #endif | ||
328 | |||
329 | #if XFS_WANT_FUNCS_C || (XFS_WANT_SPACE_C && XFSSO_XFS_ATTR_SF_ENTSIZE_BYNAME) | ||
330 | int | ||
331 | xfs_attr_sf_entsize_byname(int nlen, int vlen) | ||
332 | { | ||
333 | return XFS_ATTR_SF_ENTSIZE_BYNAME(nlen, vlen); | ||
334 | } | ||
335 | #endif | ||
336 | |||
337 | #if XFS_WANT_FUNCS_C || (XFS_WANT_SPACE_C && XFSSO_XFS_ATTR_SF_NEXTENTRY) | ||
338 | xfs_attr_sf_entry_t * | ||
339 | xfs_attr_sf_nextentry(xfs_attr_sf_entry_t *sfep) | ||
340 | { | ||
341 | return XFS_ATTR_SF_NEXTENTRY(sfep); | ||
342 | } | ||
343 | #endif | ||
344 | |||
345 | #if XFS_WANT_FUNCS_C || (XFS_WANT_SPACE_C && XFSSO_XFS_ATTR_SF_TOTSIZE) | ||
346 | int | ||
347 | xfs_attr_sf_totsize(xfs_inode_t *dp) | ||
348 | { | ||
349 | return XFS_ATTR_SF_TOTSIZE(dp); | ||
350 | } | ||
351 | #endif | ||
352 | |||
353 | #if XFS_WANT_FUNCS_C || (XFS_WANT_SPACE_C && XFSSO_XFS_BHVTOI) | ||
354 | xfs_inode_t * | ||
355 | xfs_bhvtoi(bhv_desc_t *bhvp) | ||
356 | { | ||
357 | return XFS_BHVTOI(bhvp); | ||
358 | } | ||
359 | #endif | ||
360 | |||
361 | #if XFS_WANT_FUNCS_C || (XFS_WANT_SPACE_C && XFSSO_XFS_BHVTOM) | ||
362 | xfs_mount_t * | ||
363 | xfs_bhvtom(bhv_desc_t *bdp) | ||
364 | { | ||
365 | return XFS_BHVTOM(bdp); | ||
366 | } | ||
367 | #endif | ||
368 | |||
369 | #if XFS_WANT_FUNCS_C || (XFS_WANT_SPACE_C && XFSSO_XFS_VFSTOM) | ||
370 | xfs_mount_t * | ||
371 | xfs_vfstom(vfs_t *vfs) | ||
372 | { | ||
373 | return XFS_VFSTOM(vfs); | ||
374 | } | ||
375 | #endif | ||
376 | |||
377 | #if XFS_WANT_FUNCS_C || (XFS_WANT_SPACE_C && XFSSO_XFS_BM_MAXLEVELS) | ||
378 | int | ||
379 | xfs_bm_maxlevels(xfs_mount_t *mp, int w) | ||
380 | { | ||
381 | return XFS_BM_MAXLEVELS(mp, w); | ||
382 | } | ||
383 | #endif | ||
384 | |||
385 | #if XFS_WANT_FUNCS_C || (XFS_WANT_SPACE_C && XFSSO_XFS_BMAP_BLOCK_DMAXRECS) | ||
386 | int | ||
387 | xfs_bmap_block_dmaxrecs(int lev, xfs_btree_cur_t *cur) | ||
388 | { | ||
389 | return XFS_BMAP_BLOCK_DMAXRECS(lev, cur); | ||
390 | } | ||
391 | #endif | ||
392 | |||
393 | #if XFS_WANT_FUNCS_C || (XFS_WANT_SPACE_C && XFSSO_XFS_BMAP_BLOCK_DMINRECS) | ||
394 | int | ||
395 | xfs_bmap_block_dminrecs(int lev, xfs_btree_cur_t *cur) | ||
396 | { | ||
397 | return XFS_BMAP_BLOCK_DMINRECS(lev, cur); | ||
398 | } | ||
399 | #endif | ||
400 | |||
401 | #if XFS_WANT_FUNCS_C || (XFS_WANT_SPACE_C && XFSSO_XFS_BMAP_BLOCK_DSIZE) | ||
402 | int | ||
403 | xfs_bmap_block_dsize(int lev, xfs_btree_cur_t *cur) | ||
404 | { | ||
405 | return XFS_BMAP_BLOCK_DSIZE(lev, cur); | ||
406 | } | ||
407 | #endif | ||
408 | |||
409 | #if XFS_WANT_FUNCS_C || (XFS_WANT_SPACE_C && XFSSO_XFS_BMAP_BLOCK_IMAXRECS) | ||
410 | int | ||
411 | xfs_bmap_block_imaxrecs(int lev, xfs_btree_cur_t *cur) | ||
412 | { | ||
413 | return XFS_BMAP_BLOCK_IMAXRECS(lev, cur); | ||
414 | } | ||
415 | #endif | ||
416 | |||
417 | #if XFS_WANT_FUNCS_C || (XFS_WANT_SPACE_C && XFSSO_XFS_BMAP_BLOCK_IMINRECS) | ||
418 | int | ||
419 | xfs_bmap_block_iminrecs(int lev, xfs_btree_cur_t *cur) | ||
420 | { | ||
421 | return XFS_BMAP_BLOCK_IMINRECS(lev, cur); | ||
422 | } | ||
423 | #endif | ||
424 | |||
425 | #if XFS_WANT_FUNCS_C || (XFS_WANT_SPACE_C && XFSSO_XFS_BMAP_BLOCK_ISIZE) | ||
426 | int | ||
427 | xfs_bmap_block_isize(int lev, xfs_btree_cur_t *cur) | ||
428 | { | ||
429 | return XFS_BMAP_BLOCK_ISIZE(lev, cur); | ||
430 | } | ||
431 | #endif | ||
432 | |||
433 | #if XFS_WANT_FUNCS_C || (XFS_WANT_SPACE_C && XFSSO_XFS_BMAP_BROOT_KEY_ADDR) | ||
434 | /*ARGSUSED3*/ | ||
435 | xfs_bmbt_key_t * | ||
436 | xfs_bmap_broot_key_addr(xfs_bmbt_block_t *bb, int i, int sz) | ||
437 | { | ||
438 | return XFS_BMAP_BROOT_KEY_ADDR(bb, i, sz); | ||
439 | } | ||
440 | #endif | ||
441 | |||
442 | #if XFS_WANT_FUNCS_C || (XFS_WANT_SPACE_C && XFSSO_XFS_BMAP_BROOT_MAXRECS) | ||
443 | int | ||
444 | xfs_bmap_broot_maxrecs(int sz) | ||
445 | { | ||
446 | return XFS_BMAP_BROOT_MAXRECS(sz); | ||
447 | } | ||
448 | #endif | ||
449 | |||
450 | #if XFS_WANT_FUNCS_C || (XFS_WANT_SPACE_C && XFSSO_XFS_BMAP_BROOT_NUMRECS) | ||
451 | int | ||
452 | xfs_bmap_broot_numrecs(xfs_bmdr_block_t *bb) | ||
453 | { | ||
454 | return XFS_BMAP_BROOT_NUMRECS(bb); | ||
455 | } | ||
456 | #endif | ||
457 | |||
458 | #if XFS_WANT_FUNCS_C || (XFS_WANT_SPACE_C && XFSSO_XFS_BMAP_BROOT_PTR_ADDR) | ||
459 | xfs_bmbt_ptr_t * | ||
460 | xfs_bmap_broot_ptr_addr(xfs_bmbt_block_t *bb, int i, int sz) | ||
461 | { | ||
462 | return XFS_BMAP_BROOT_PTR_ADDR(bb, i, sz); | ||
463 | } | ||
464 | #endif | ||
465 | |||
466 | #if XFS_WANT_FUNCS_C || (XFS_WANT_SPACE_C && XFSSO_XFS_BMAP_BROOT_REC_ADDR) | ||
467 | /*ARGSUSED3*/ | ||
468 | xfs_bmbt_rec_t * | ||
469 | xfs_bmap_broot_rec_addr(xfs_bmbt_block_t *bb, int i, int sz) | ||
470 | { | ||
471 | return XFS_BMAP_BROOT_REC_ADDR(bb, i, sz); | ||
472 | } | ||
473 | #endif | ||
474 | |||
475 | #if XFS_WANT_FUNCS_C || (XFS_WANT_SPACE_C && XFSSO_XFS_BMAP_BROOT_SPACE) | ||
476 | int | ||
477 | xfs_bmap_broot_space(xfs_bmdr_block_t *bb) | ||
478 | { | ||
479 | return XFS_BMAP_BROOT_SPACE(bb); | ||
480 | } | ||
481 | #endif | ||
482 | |||
483 | #if XFS_WANT_FUNCS_C || (XFS_WANT_SPACE_C && XFSSO_XFS_BMAP_BROOT_SPACE_CALC) | ||
484 | int | ||
485 | xfs_bmap_broot_space_calc(int nrecs) | ||
486 | { | ||
487 | return XFS_BMAP_BROOT_SPACE_CALC(nrecs); | ||
488 | } | ||
489 | #endif | ||
490 | |||
491 | #if XFS_WANT_FUNCS_C || (XFS_WANT_SPACE_C && XFSSO_XFS_BMAP_IBLOCK_SIZE) | ||
492 | /*ARGSUSED1*/ | ||
493 | int | ||
494 | xfs_bmap_iblock_size(int lev, xfs_btree_cur_t *cur) | ||
495 | { | ||
496 | return XFS_BMAP_IBLOCK_SIZE(lev, cur); | ||
497 | } | ||
498 | #endif | ||
499 | |||
500 | #if XFS_WANT_FUNCS_C || (XFS_WANT_SPACE_C && XFSSO_XFS_BMAP_INIT) | ||
501 | void | ||
502 | xfs_bmap_init(xfs_bmap_free_t *flp, xfs_fsblock_t *fbp) | ||
503 | { | ||
504 | XFS_BMAP_INIT(flp, fbp); | ||
505 | } | ||
506 | #endif | ||
507 | |||
508 | #if XFS_WANT_FUNCS_C || (XFS_WANT_SPACE_C && XFSSO_XFS_BMAP_KEY_DADDR) | ||
509 | /*ARGSUSED3*/ | ||
510 | xfs_bmbt_key_t * | ||
511 | xfs_bmap_key_daddr(xfs_bmbt_block_t *bb, int i, xfs_btree_cur_t *cur) | ||
512 | { | ||
513 | return XFS_BMAP_KEY_DADDR(bb, i, cur); | ||
514 | } | ||
515 | #endif | ||
516 | |||
517 | #if XFS_WANT_FUNCS_C || (XFS_WANT_SPACE_C && XFSSO_XFS_BMAP_KEY_IADDR) | ||
518 | /*ARGSUSED3*/ | ||
519 | xfs_bmbt_key_t * | ||
520 | xfs_bmap_key_iaddr(xfs_bmbt_block_t *bb, int i, xfs_btree_cur_t *cur) | ||
521 | { | ||
522 | return XFS_BMAP_KEY_IADDR(bb, i, cur); | ||
523 | } | ||
524 | #endif | ||
525 | |||
526 | #if XFS_WANT_FUNCS_C || (XFS_WANT_SPACE_C && XFSSO_XFS_BMAP_PTR_DADDR) | ||
527 | xfs_bmbt_ptr_t * | ||
528 | xfs_bmap_ptr_daddr(xfs_bmbt_block_t *bb, int i, xfs_btree_cur_t *cur) | ||
529 | { | ||
530 | return XFS_BMAP_PTR_DADDR(bb, i, cur); | ||
531 | } | ||
532 | #endif | ||
533 | |||
534 | #if XFS_WANT_FUNCS_C || (XFS_WANT_SPACE_C && XFSSO_XFS_BMAP_PTR_IADDR) | ||
535 | xfs_bmbt_ptr_t * | ||
536 | xfs_bmap_ptr_iaddr(xfs_bmbt_block_t *bb, int i, xfs_btree_cur_t *cur) | ||
537 | { | ||
538 | return XFS_BMAP_PTR_IADDR(bb, i, cur); | ||
539 | } | ||
540 | #endif | ||
541 | |||
542 | #if XFS_WANT_FUNCS_C || (XFS_WANT_SPACE_C && XFSSO_XFS_BMAP_RBLOCK_DSIZE) | ||
543 | /*ARGSUSED1*/ | ||
544 | int | ||
545 | xfs_bmap_rblock_dsize(int lev, xfs_btree_cur_t *cur) | ||
546 | { | ||
547 | return XFS_BMAP_RBLOCK_DSIZE(lev, cur); | ||
548 | } | ||
549 | #endif | ||
550 | |||
551 | #if XFS_WANT_FUNCS_C || (XFS_WANT_SPACE_C && XFSSO_XFS_BMAP_RBLOCK_ISIZE) | ||
552 | /*ARGSUSED1*/ | ||
553 | int | ||
554 | xfs_bmap_rblock_isize(int lev, xfs_btree_cur_t *cur) | ||
555 | { | ||
556 | return XFS_BMAP_RBLOCK_ISIZE(lev, cur); | ||
557 | } | ||
558 | #endif | ||
559 | |||
560 | #if XFS_WANT_FUNCS_C || (XFS_WANT_SPACE_C && XFSSO_XFS_BMAP_REC_DADDR) | ||
561 | /*ARGSUSED3*/ | ||
562 | xfs_bmbt_rec_t * | ||
563 | xfs_bmap_rec_daddr(xfs_bmbt_block_t *bb, int i, xfs_btree_cur_t *cur) | ||
564 | { | ||
565 | return XFS_BMAP_REC_DADDR(bb, i, cur); | ||
566 | } | ||
567 | #endif | ||
568 | |||
569 | #if XFS_WANT_FUNCS_C || (XFS_WANT_SPACE_C && XFSSO_XFS_BMAP_REC_IADDR) | ||
570 | /*ARGSUSED3*/ | ||
571 | xfs_bmbt_rec_t * | ||
572 | xfs_bmap_rec_iaddr(xfs_bmbt_block_t *bb, int i, xfs_btree_cur_t *cur) | ||
573 | { | ||
574 | return XFS_BMAP_REC_IADDR(bb, i, cur); | ||
575 | } | ||
576 | #endif | ||
577 | |||
578 | #if XFS_WANT_FUNCS_C || (XFS_WANT_SPACE_C && XFSSO_XFS_BMAP_SANITY_CHECK) | ||
579 | int | ||
580 | xfs_bmap_sanity_check(xfs_mount_t *mp, xfs_bmbt_block_t *bb, int level) | ||
581 | { | ||
582 | return XFS_BMAP_SANITY_CHECK(mp, bb, level); | ||
583 | } | ||
584 | #endif | ||
585 | |||
586 | #if XFS_WANT_FUNCS_C || (XFS_WANT_SPACE_C && XFSSO_XFS_BMAPI_AFLAG) | ||
587 | int | ||
588 | xfs_bmapi_aflag(int w) | ||
589 | { | ||
590 | return XFS_BMAPI_AFLAG(w); | ||
591 | } | ||
592 | #endif | ||
593 | |||
594 | #if XFS_WANT_FUNCS_C || (XFS_WANT_SPACE_C && XFSSO_XFS_BMDR_SPACE_CALC) | ||
595 | int | ||
596 | xfs_bmdr_space_calc(int nrecs) | ||
597 | { | ||
598 | return XFS_BMDR_SPACE_CALC(nrecs); | ||
599 | } | ||
600 | #endif | ||
601 | |||
602 | #if XFS_WANT_FUNCS_C || (XFS_WANT_SPACE_C && XFSSO_XFS_BNO_BLOCK) | ||
603 | xfs_agblock_t | ||
604 | xfs_bno_block(xfs_mount_t *mp) | ||
605 | { | ||
606 | return XFS_BNO_BLOCK(mp); | ||
607 | } | ||
608 | #endif | ||
609 | |||
610 | #if XFS_WANT_FUNCS_C || (XFS_WANT_SPACE_C && XFSSO_XFS_BTREE_LONG_PTRS) | ||
611 | int | ||
612 | xfs_btree_long_ptrs(xfs_btnum_t btnum) | ||
613 | { | ||
614 | return XFS_BTREE_LONG_PTRS(btnum); | ||
615 | } | ||
616 | #endif | ||
617 | |||
618 | #if XFS_WANT_FUNCS_C || (XFS_WANT_SPACE_C && XFSSO_XFS_BUF_TO_AGF) | ||
619 | xfs_agf_t * | ||
620 | xfs_buf_to_agf(xfs_buf_t *bp) | ||
621 | { | ||
622 | return XFS_BUF_TO_AGF(bp); | ||
623 | } | ||
624 | #endif | ||
625 | |||
626 | #if XFS_WANT_FUNCS_C || (XFS_WANT_SPACE_C && XFSSO_XFS_BUF_TO_AGFL) | ||
627 | xfs_agfl_t * | ||
628 | xfs_buf_to_agfl(xfs_buf_t *bp) | ||
629 | { | ||
630 | return XFS_BUF_TO_AGFL(bp); | ||
631 | } | ||
632 | #endif | ||
633 | |||
634 | #if XFS_WANT_FUNCS_C || (XFS_WANT_SPACE_C && XFSSO_XFS_BUF_TO_AGI) | ||
635 | xfs_agi_t * | ||
636 | xfs_buf_to_agi(xfs_buf_t *bp) | ||
637 | { | ||
638 | return XFS_BUF_TO_AGI(bp); | ||
639 | } | ||
640 | #endif | ||
641 | |||
642 | #if XFS_WANT_FUNCS_C || (XFS_WANT_SPACE_C && XFSSO_XFS_BUF_TO_ALLOC_BLOCK) | ||
643 | xfs_alloc_block_t * | ||
644 | xfs_buf_to_alloc_block(xfs_buf_t *bp) | ||
645 | { | ||
646 | return XFS_BUF_TO_ALLOC_BLOCK(bp); | ||
647 | } | ||
648 | #endif | ||
649 | |||
650 | #if XFS_WANT_FUNCS_C || (XFS_WANT_SPACE_C && XFSSO_XFS_BUF_TO_BLOCK) | ||
651 | xfs_btree_block_t * | ||
652 | xfs_buf_to_block(xfs_buf_t *bp) | ||
653 | { | ||
654 | return XFS_BUF_TO_BLOCK(bp); | ||
655 | } | ||
656 | #endif | ||
657 | |||
658 | #if XFS_WANT_FUNCS_C || (XFS_WANT_SPACE_C && XFSSO_XFS_BUF_TO_BMBT_BLOCK) | ||
659 | xfs_bmbt_block_t * | ||
660 | xfs_buf_to_bmbt_block(xfs_buf_t *bp) | ||
661 | { | ||
662 | return XFS_BUF_TO_BMBT_BLOCK(bp); | ||
663 | } | ||
664 | #endif | ||
665 | |||
666 | #if XFS_WANT_FUNCS_C || (XFS_WANT_SPACE_C && XFSSO_XFS_BUF_TO_DINODE) | ||
667 | xfs_dinode_t * | ||
668 | xfs_buf_to_dinode(xfs_buf_t *bp) | ||
669 | { | ||
670 | return XFS_BUF_TO_DINODE(bp); | ||
671 | } | ||
672 | #endif | ||
673 | |||
674 | #if XFS_WANT_FUNCS_C || (XFS_WANT_SPACE_C && XFSSO_XFS_BUF_TO_INOBT_BLOCK) | ||
675 | xfs_inobt_block_t * | ||
676 | xfs_buf_to_inobt_block(xfs_buf_t *bp) | ||
677 | { | ||
678 | return XFS_BUF_TO_INOBT_BLOCK(bp); | ||
679 | } | ||
680 | #endif | ||
681 | |||
682 | #if XFS_WANT_FUNCS_C || (XFS_WANT_SPACE_C && XFSSO_XFS_BUF_TO_LBLOCK) | ||
683 | xfs_btree_lblock_t * | ||
684 | xfs_buf_to_lblock(xfs_buf_t *bp) | ||
685 | { | ||
686 | return XFS_BUF_TO_LBLOCK(bp); | ||
687 | } | ||
688 | #endif | ||
689 | |||
690 | #if XFS_WANT_FUNCS_C || (XFS_WANT_SPACE_C && XFSSO_XFS_BUF_TO_SBLOCK) | ||
691 | xfs_btree_sblock_t * | ||
692 | xfs_buf_to_sblock(xfs_buf_t *bp) | ||
693 | { | ||
694 | return XFS_BUF_TO_SBLOCK(bp); | ||
695 | } | ||
696 | #endif | ||
697 | |||
698 | #if XFS_WANT_FUNCS_C || (XFS_WANT_SPACE_C && XFSSO_XFS_BUF_TO_SBP) | ||
699 | xfs_sb_t * | ||
700 | xfs_buf_to_sbp(xfs_buf_t *bp) | ||
701 | { | ||
702 | return XFS_BUF_TO_SBP(bp); | ||
703 | } | ||
704 | #endif | ||
705 | |||
706 | #if XFS_WANT_FUNCS_C || (XFS_WANT_SPACE_C && XFSSO_XFS_CFORK_ASIZE) | ||
707 | int | ||
708 | xfs_cfork_asize_disk(xfs_dinode_core_t *dcp, xfs_mount_t *mp) | ||
709 | { | ||
710 | return XFS_CFORK_ASIZE_DISK(dcp, mp); | ||
711 | } | ||
712 | int | ||
713 | xfs_cfork_asize(xfs_dinode_core_t *dcp, xfs_mount_t *mp) | ||
714 | { | ||
715 | return XFS_CFORK_ASIZE(dcp, mp); | ||
716 | } | ||
717 | #endif | ||
718 | |||
719 | #if XFS_WANT_FUNCS_C || (XFS_WANT_SPACE_C && XFSSO_XFS_CFORK_BOFF) | ||
720 | int | ||
721 | xfs_cfork_boff_disk(xfs_dinode_core_t *dcp) | ||
722 | { | ||
723 | return XFS_CFORK_BOFF_DISK(dcp); | ||
724 | } | ||
725 | int | ||
726 | xfs_cfork_boff(xfs_dinode_core_t *dcp) | ||
727 | { | ||
728 | return XFS_CFORK_BOFF(dcp); | ||
729 | } | ||
730 | #endif | ||
731 | |||
732 | #if XFS_WANT_FUNCS_C || (XFS_WANT_SPACE_C && XFSSO_XFS_CFORK_DSIZE) | ||
733 | int | ||
734 | xfs_cfork_dsize_disk(xfs_dinode_core_t *dcp, xfs_mount_t *mp) | ||
735 | { | ||
736 | return XFS_CFORK_DSIZE_DISK(dcp, mp); | ||
737 | } | ||
738 | int | ||
739 | xfs_cfork_dsize(xfs_dinode_core_t *dcp, xfs_mount_t *mp) | ||
740 | { | ||
741 | return XFS_CFORK_DSIZE(dcp, mp); | ||
742 | } | ||
743 | #endif | ||
744 | |||
745 | #if XFS_WANT_FUNCS_C || (XFS_WANT_SPACE_C && XFSSO_XFS_CFORK_FMT_SET) | ||
746 | void | ||
747 | xfs_cfork_fmt_set(xfs_dinode_core_t *dcp, int w, int n) | ||
748 | { | ||
749 | XFS_CFORK_FMT_SET(dcp, w, n); | ||
750 | } | ||
751 | #endif | ||
752 | |||
753 | #if XFS_WANT_FUNCS_C || (XFS_WANT_SPACE_C && XFSSO_XFS_CFORK_FORMAT) | ||
754 | int | ||
755 | xfs_cfork_format(xfs_dinode_core_t *dcp, int w) | ||
756 | { | ||
757 | return XFS_CFORK_FORMAT(dcp, w); | ||
758 | } | ||
759 | #endif | ||
760 | |||
761 | #if XFS_WANT_FUNCS_C || (XFS_WANT_SPACE_C && XFSSO_XFS_CFORK_NEXT_SET) | ||
762 | void | ||
763 | xfs_cfork_next_set(xfs_dinode_core_t *dcp, int w, int n) | ||
764 | { | ||
765 | XFS_CFORK_NEXT_SET(dcp, w, n); | ||
766 | } | ||
767 | #endif | ||
768 | |||
769 | #if XFS_WANT_FUNCS_C || (XFS_WANT_SPACE_C && XFSSO_XFS_CFORK_NEXTENTS) | ||
770 | int | ||
771 | xfs_cfork_nextents_disk(xfs_dinode_core_t *dcp, int w) | ||
772 | { | ||
773 | return XFS_CFORK_NEXTENTS_DISK(dcp, w); | ||
774 | } | ||
775 | int | ||
776 | xfs_cfork_nextents(xfs_dinode_core_t *dcp, int w) | ||
777 | { | ||
778 | return XFS_CFORK_NEXTENTS(dcp, w); | ||
779 | } | ||
780 | #endif | ||
781 | |||
782 | #if XFS_WANT_FUNCS_C || (XFS_WANT_SPACE_C && XFSSO_XFS_CFORK_Q) | ||
783 | int | ||
784 | xfs_cfork_q_disk(xfs_dinode_core_t *dcp) | ||
785 | { | ||
786 | return XFS_CFORK_Q_DISK(dcp); | ||
787 | } | ||
788 | int | ||
789 | xfs_cfork_q(xfs_dinode_core_t *dcp) | ||
790 | { | ||
791 | return XFS_CFORK_Q(dcp); | ||
792 | } | ||
793 | #endif | ||
794 | |||
795 | #if XFS_WANT_FUNCS_C || (XFS_WANT_SPACE_C && XFSSO_XFS_CFORK_SIZE) | ||
796 | int | ||
797 | xfs_cfork_size_disk(xfs_dinode_core_t *dcp, xfs_mount_t *mp, int w) | ||
798 | { | ||
799 | return XFS_CFORK_SIZE_DISK(dcp, mp, w); | ||
800 | } | ||
801 | int | ||
802 | xfs_cfork_size(xfs_dinode_core_t *dcp, xfs_mount_t *mp, int w) | ||
803 | { | ||
804 | return XFS_CFORK_SIZE(dcp, mp, w); | ||
805 | } | ||
806 | #endif | ||
807 | |||
808 | #if XFS_WANT_FUNCS_C || (XFS_WANT_SPACE_C && XFSSO_XFS_CNT_BLOCK) | ||
809 | xfs_agblock_t | ||
810 | xfs_cnt_block(xfs_mount_t *mp) | ||
811 | { | ||
812 | return XFS_CNT_BLOCK(mp); | ||
813 | } | ||
814 | #endif | ||
815 | |||
816 | #if XFS_WANT_FUNCS_C || (XFS_WANT_SPACE_C && XFSSO_XFS_DA_COOKIE_BNO) | ||
817 | xfs_dablk_t | ||
818 | xfs_da_cookie_bno(xfs_mount_t *mp, xfs_off_t cookie) | ||
819 | { | ||
820 | return XFS_DA_COOKIE_BNO(mp, cookie); | ||
821 | } | ||
822 | #endif | ||
823 | |||
824 | #if XFS_WANT_FUNCS_C || (XFS_WANT_SPACE_C && XFSSO_XFS_DA_COOKIE_ENTRY) | ||
825 | int | ||
826 | xfs_da_cookie_entry(xfs_mount_t *mp, xfs_off_t cookie) | ||
827 | { | ||
828 | return XFS_DA_COOKIE_ENTRY(mp, cookie); | ||
829 | } | ||
830 | #endif | ||
831 | |||
832 | #if XFS_WANT_FUNCS_C || (XFS_WANT_SPACE_C && XFSSO_XFS_DA_COOKIE_HASH) | ||
833 | /*ARGSUSED1*/ | ||
834 | xfs_dahash_t | ||
835 | xfs_da_cookie_hash(xfs_mount_t *mp, xfs_off_t cookie) | ||
836 | { | ||
837 | return XFS_DA_COOKIE_HASH(mp, cookie); | ||
838 | } | ||
839 | #endif | ||
840 | |||
841 | #if XFS_WANT_FUNCS_C || (XFS_WANT_SPACE_C && XFSSO_XFS_DA_MAKE_BNOENTRY) | ||
842 | __uint32_t | ||
843 | xfs_da_make_bnoentry(xfs_mount_t *mp, xfs_dablk_t bno, int entry) | ||
844 | { | ||
845 | return XFS_DA_MAKE_BNOENTRY(mp, bno, entry); | ||
846 | } | ||
847 | #endif | ||
848 | |||
849 | #if XFS_WANT_FUNCS_C || (XFS_WANT_SPACE_C && XFSSO_XFS_DA_MAKE_COOKIE) | ||
850 | xfs_off_t | ||
851 | xfs_da_make_cookie(xfs_mount_t *mp, xfs_dablk_t bno, int entry, | ||
852 | xfs_dahash_t hash) | ||
853 | { | ||
854 | return XFS_DA_MAKE_COOKIE(mp, bno, entry, hash); | ||
855 | } | ||
856 | #endif | ||
857 | |||
858 | #if XFS_WANT_FUNCS_C || (XFS_WANT_SPACE_C && XFSSO_XFS_DADDR_TO_AGBNO) | ||
859 | xfs_agblock_t | ||
860 | xfs_daddr_to_agbno(xfs_mount_t *mp, xfs_daddr_t d) | ||
861 | { | ||
862 | return XFS_DADDR_TO_AGBNO(mp, d); | ||
863 | } | ||
864 | #endif | ||
865 | |||
866 | #if XFS_WANT_FUNCS_C || (XFS_WANT_SPACE_C && XFSSO_XFS_DADDR_TO_AGNO) | ||
867 | xfs_agnumber_t | ||
868 | xfs_daddr_to_agno(xfs_mount_t *mp, xfs_daddr_t d) | ||
869 | { | ||
870 | return XFS_DADDR_TO_AGNO(mp, d); | ||
871 | } | ||
872 | #endif | ||
873 | |||
874 | #if XFS_WANT_FUNCS_C || (XFS_WANT_SPACE_C && XFSSO_XFS_DADDR_TO_FSB) | ||
875 | xfs_fsblock_t | ||
876 | xfs_daddr_to_fsb(xfs_mount_t *mp, xfs_daddr_t d) | ||
877 | { | ||
878 | return XFS_DADDR_TO_FSB(mp, d); | ||
879 | } | ||
880 | #endif | ||
881 | |||
882 | #if XFS_WANT_FUNCS_C || (XFS_WANT_SPACE_C && XFSSO_XFS_DFORK_APTR) | ||
883 | char * | ||
884 | xfs_dfork_aptr(xfs_dinode_t *dip) | ||
885 | { | ||
886 | return XFS_DFORK_APTR(dip); | ||
887 | } | ||
888 | #endif | ||
889 | |||
890 | #if XFS_WANT_FUNCS_C || (XFS_WANT_SPACE_C && XFSSO_XFS_DFORK_ASIZE) | ||
891 | int | ||
892 | xfs_dfork_asize(xfs_dinode_t *dip, xfs_mount_t *mp) | ||
893 | { | ||
894 | return XFS_DFORK_ASIZE(dip, mp); | ||
895 | } | ||
896 | #endif | ||
897 | |||
898 | #if XFS_WANT_FUNCS_C || (XFS_WANT_SPACE_C && XFSSO_XFS_DFORK_BOFF) | ||
899 | int | ||
900 | xfs_dfork_boff(xfs_dinode_t *dip) | ||
901 | { | ||
902 | return XFS_DFORK_BOFF(dip); | ||
903 | } | ||
904 | #endif | ||
905 | |||
906 | #if XFS_WANT_FUNCS_C || (XFS_WANT_SPACE_C && XFSSO_XFS_DFORK_DPTR) | ||
907 | char * | ||
908 | xfs_dfork_dptr(xfs_dinode_t *dip) | ||
909 | { | ||
910 | return XFS_DFORK_DPTR(dip); | ||
911 | } | ||
912 | #endif | ||
913 | |||
914 | #if XFS_WANT_FUNCS_C || (XFS_WANT_SPACE_C && XFSSO_XFS_DFORK_DSIZE) | ||
915 | int | ||
916 | xfs_dfork_dsize(xfs_dinode_t *dip, xfs_mount_t *mp) | ||
917 | { | ||
918 | return XFS_DFORK_DSIZE(dip, mp); | ||
919 | } | ||
920 | #endif | ||
921 | |||
922 | #if XFS_WANT_FUNCS_C || (XFS_WANT_SPACE_C && XFSSO_XFS_DFORK_NEXTENTS) | ||
923 | int | ||
924 | xfs_dfork_nextents(xfs_dinode_t *dip, int w) | ||
925 | { | ||
926 | return XFS_DFORK_NEXTENTS(dip, w); | ||
927 | } | ||
928 | #endif | ||
929 | |||
930 | #if XFS_WANT_FUNCS_C || (XFS_WANT_SPACE_C && XFSSO_XFS_DFORK_PTR) | ||
931 | char * | ||
932 | xfs_dfork_ptr(xfs_dinode_t *dip, int w) | ||
933 | { | ||
934 | return XFS_DFORK_PTR(dip, w); | ||
935 | } | ||
936 | #endif | ||
937 | |||
938 | #if XFS_WANT_FUNCS_C || (XFS_WANT_SPACE_C && XFSSO_XFS_DFORK_Q) | ||
939 | int | ||
940 | xfs_dfork_q(xfs_dinode_t *dip) | ||
941 | { | ||
942 | return XFS_DFORK_Q(dip); | ||
943 | } | ||
944 | #endif | ||
945 | |||
946 | #if XFS_WANT_FUNCS_C || (XFS_WANT_SPACE_C && XFSSO_XFS_DFORK_SIZE) | ||
947 | int | ||
948 | xfs_dfork_size(xfs_dinode_t *dip, xfs_mount_t *mp, int w) | ||
949 | { | ||
950 | return XFS_DFORK_SIZE(dip, mp, w); | ||
951 | } | ||
952 | #endif | ||
953 | |||
954 | #if XFS_WANT_FUNCS_C || (XFS_WANT_SPACE_C && XFSSO_XFS_DINODE_GOOD_VERSION) | ||
955 | int | ||
956 | xfs_dinode_good_version(int v) | ||
957 | { | ||
958 | return XFS_DINODE_GOOD_VERSION(v); | ||
959 | } | ||
960 | #endif | ||
961 | |||
962 | #if XFS_WANT_FUNCS_C || (XFS_WANT_SPACE_C && XFSSO_XFS_DIR_LEAF_ENTSIZE_BYENTRY) | ||
963 | int | ||
964 | xfs_dir_leaf_entsize_byentry(xfs_dir_leaf_entry_t *entry) | ||
965 | { | ||
966 | return XFS_DIR_LEAF_ENTSIZE_BYENTRY(entry); | ||
967 | } | ||
968 | #endif | ||
969 | |||
970 | #if XFS_WANT_FUNCS_C || (XFS_WANT_SPACE_C && XFSSO_XFS_DIR_LEAF_ENTSIZE_BYNAME) | ||
971 | int | ||
972 | xfs_dir_leaf_entsize_byname(int len) | ||
973 | { | ||
974 | return XFS_DIR_LEAF_ENTSIZE_BYNAME(len); | ||
975 | } | ||
976 | #endif | ||
977 | |||
978 | #if XFS_WANT_FUNCS_C || (XFS_WANT_SPACE_C && XFSSO_XFS_DIR_LEAF_NAMESTRUCT) | ||
979 | xfs_dir_leaf_name_t * | ||
980 | xfs_dir_leaf_namestruct(xfs_dir_leafblock_t *leafp, int offset) | ||
981 | { | ||
982 | return XFS_DIR_LEAF_NAMESTRUCT(leafp, offset); | ||
983 | } | ||
984 | #endif | ||
985 | |||
986 | #if XFS_WANT_FUNCS_C || (XFS_WANT_SPACE_C && XFSSO_XFS_DIR_SF_ALLFIT) | ||
987 | int | ||
988 | xfs_dir_sf_allfit(int count, int totallen) | ||
989 | { | ||
990 | return XFS_DIR_SF_ALLFIT(count, totallen); | ||
991 | } | ||
992 | #endif | ||
993 | |||
994 | #if XFS_WANT_FUNCS_C || (XFS_WANT_SPACE_C && XFSSO_XFS_DIR_SF_ENTSIZE_BYENTRY) | ||
995 | int | ||
996 | xfs_dir_sf_entsize_byentry(xfs_dir_sf_entry_t *sfep) | ||
997 | { | ||
998 | return XFS_DIR_SF_ENTSIZE_BYENTRY(sfep); | ||
999 | } | ||
1000 | #endif | ||
1001 | |||
1002 | #if XFS_WANT_FUNCS_C || (XFS_WANT_SPACE_C && XFSSO_XFS_DIR_SF_ENTSIZE_BYNAME) | ||
1003 | int | ||
1004 | xfs_dir_sf_entsize_byname(int len) | ||
1005 | { | ||
1006 | return XFS_DIR_SF_ENTSIZE_BYNAME(len); | ||
1007 | } | ||
1008 | #endif | ||
1009 | |||
1010 | #if XFS_WANT_FUNCS_C || (XFS_WANT_SPACE_C && XFSSO_XFS_DIR_SF_GET_DIRINO) | ||
1011 | void | ||
1012 | xfs_dir_sf_get_dirino(xfs_dir_ino_t *from, xfs_ino_t *to) | ||
1013 | { | ||
1014 | XFS_DIR_SF_GET_DIRINO(from, to); | ||
1015 | } | ||
1016 | #endif | ||
1017 | |||
1018 | #if XFS_WANT_FUNCS_C || (XFS_WANT_SPACE_C && XFSSO_XFS_DIR_SF_NEXTENTRY) | ||
1019 | xfs_dir_sf_entry_t * | ||
1020 | xfs_dir_sf_nextentry(xfs_dir_sf_entry_t *sfep) | ||
1021 | { | ||
1022 | return XFS_DIR_SF_NEXTENTRY(sfep); | ||
1023 | } | ||
1024 | #endif | ||
1025 | |||
1026 | #if XFS_WANT_FUNCS_C || (XFS_WANT_SPACE_C && XFSSO_XFS_DIR_SF_PUT_DIRINO) | ||
1027 | void | ||
1028 | xfs_dir_sf_put_dirino(xfs_ino_t *from, xfs_dir_ino_t *to) | ||
1029 | { | ||
1030 | XFS_DIR_SF_PUT_DIRINO(from, to); | ||
1031 | } | ||
1032 | #endif | ||
1033 | |||
1034 | #if XFS_WANT_FUNCS_C || (XFS_WANT_SPACE_C && XFSSO_XFS_DIR2_BLOCK_LEAF_P) | ||
1035 | xfs_dir2_leaf_entry_t * | ||
1036 | xfs_dir2_block_leaf_p(xfs_dir2_block_tail_t *btp) | ||
1037 | { | ||
1038 | return XFS_DIR2_BLOCK_LEAF_P(btp); | ||
1039 | } | ||
1040 | #endif | ||
1041 | |||
1042 | #if XFS_WANT_FUNCS_C || (XFS_WANT_SPACE_C && XFSSO_XFS_DIR2_BLOCK_TAIL_P) | ||
1043 | xfs_dir2_block_tail_t * | ||
1044 | xfs_dir2_block_tail_p(xfs_mount_t *mp, xfs_dir2_block_t *block) | ||
1045 | { | ||
1046 | return XFS_DIR2_BLOCK_TAIL_P(mp, block); | ||
1047 | } | ||
1048 | #endif | ||
1049 | |||
1050 | #if XFS_WANT_FUNCS_C || (XFS_WANT_SPACE_C && XFSSO_XFS_DIR2_BYTE_TO_DA) | ||
1051 | xfs_dablk_t | ||
1052 | xfs_dir2_byte_to_da(xfs_mount_t *mp, xfs_dir2_off_t by) | ||
1053 | { | ||
1054 | return XFS_DIR2_BYTE_TO_DA(mp, by); | ||
1055 | } | ||
1056 | #endif | ||
1057 | |||
1058 | #if XFS_WANT_FUNCS_C || (XFS_WANT_SPACE_C && XFSSO_XFS_DIR2_BYTE_TO_DATAPTR) | ||
1059 | /* ARGSUSED */ | ||
1060 | xfs_dir2_dataptr_t | ||
1061 | xfs_dir2_byte_to_dataptr(xfs_mount_t *mp, xfs_dir2_off_t by) | ||
1062 | { | ||
1063 | return XFS_DIR2_BYTE_TO_DATAPTR(mp, by); | ||
1064 | } | ||
1065 | #endif | ||
1066 | |||
1067 | #if XFS_WANT_FUNCS_C || (XFS_WANT_SPACE_C && XFSSO_XFS_DIR2_BYTE_TO_DB) | ||
1068 | xfs_dir2_db_t | ||
1069 | xfs_dir2_byte_to_db(xfs_mount_t *mp, xfs_dir2_off_t by) | ||
1070 | { | ||
1071 | return XFS_DIR2_BYTE_TO_DB(mp, by); | ||
1072 | } | ||
1073 | #endif | ||
1074 | |||
1075 | #if XFS_WANT_FUNCS_C || (XFS_WANT_SPACE_C && XFSSO_XFS_DIR2_BYTE_TO_OFF) | ||
1076 | xfs_dir2_data_aoff_t | ||
1077 | xfs_dir2_byte_to_off(xfs_mount_t *mp, xfs_dir2_off_t by) | ||
1078 | { | ||
1079 | return XFS_DIR2_BYTE_TO_OFF(mp, by); | ||
1080 | } | ||
1081 | #endif | ||
1082 | |||
1083 | #if XFS_WANT_FUNCS_C || (XFS_WANT_SPACE_C && XFSSO_XFS_DIR2_DA_TO_BYTE) | ||
1084 | xfs_dir2_off_t | ||
1085 | xfs_dir2_da_to_byte(xfs_mount_t *mp, xfs_dablk_t da) | ||
1086 | { | ||
1087 | return XFS_DIR2_DA_TO_BYTE(mp, da); | ||
1088 | } | ||
1089 | #endif | ||
1090 | |||
1091 | #if XFS_WANT_FUNCS_C || (XFS_WANT_SPACE_C && XFSSO_XFS_DIR2_DA_TO_DB) | ||
1092 | xfs_dir2_db_t | ||
1093 | xfs_dir2_da_to_db(xfs_mount_t *mp, xfs_dablk_t da) | ||
1094 | { | ||
1095 | return XFS_DIR2_DA_TO_DB(mp, da); | ||
1096 | } | ||
1097 | #endif | ||
1098 | |||
1099 | #if XFS_WANT_FUNCS_C || (XFS_WANT_SPACE_C && XFSSO_XFS_DIR2_DATA_ENTRY_TAG_P) | ||
1100 | xfs_dir2_data_off_t * | ||
1101 | xfs_dir2_data_entry_tag_p(xfs_dir2_data_entry_t *dep) | ||
1102 | { | ||
1103 | return XFS_DIR2_DATA_ENTRY_TAG_P(dep); | ||
1104 | } | ||
1105 | #endif | ||
1106 | |||
1107 | #if XFS_WANT_FUNCS_C || (XFS_WANT_SPACE_C && XFSSO_XFS_DIR2_DATA_ENTSIZE) | ||
1108 | int | ||
1109 | xfs_dir2_data_entsize(int n) | ||
1110 | { | ||
1111 | return XFS_DIR2_DATA_ENTSIZE(n); | ||
1112 | } | ||
1113 | #endif | ||
1114 | |||
1115 | #if XFS_WANT_FUNCS_C || (XFS_WANT_SPACE_C && XFSSO_XFS_DIR2_DATA_UNUSED_TAG_P) | ||
1116 | xfs_dir2_data_off_t * | ||
1117 | xfs_dir2_data_unused_tag_p(xfs_dir2_data_unused_t *dup) | ||
1118 | { | ||
1119 | return XFS_DIR2_DATA_UNUSED_TAG_P(dup); | ||
1120 | } | ||
1121 | #endif | ||
1122 | |||
1123 | #if XFS_WANT_FUNCS_C || (XFS_WANT_SPACE_C && XFSSO_XFS_DIR2_DATAPTR_TO_BYTE) | ||
1124 | /* ARGSUSED */ | ||
1125 | xfs_dir2_off_t | ||
1126 | xfs_dir2_dataptr_to_byte(xfs_mount_t *mp, xfs_dir2_dataptr_t dp) | ||
1127 | { | ||
1128 | return XFS_DIR2_DATAPTR_TO_BYTE(mp, dp); | ||
1129 | } | ||
1130 | #endif | ||
1131 | |||
1132 | #if XFS_WANT_FUNCS_C || (XFS_WANT_SPACE_C && XFSSO_XFS_DIR2_DATAPTR_TO_DB) | ||
1133 | xfs_dir2_db_t | ||
1134 | xfs_dir2_dataptr_to_db(xfs_mount_t *mp, xfs_dir2_dataptr_t dp) | ||
1135 | { | ||
1136 | return XFS_DIR2_DATAPTR_TO_DB(mp, dp); | ||
1137 | } | ||
1138 | #endif | ||
1139 | |||
1140 | #if XFS_WANT_FUNCS_C || (XFS_WANT_SPACE_C && XFSSO_XFS_DIR2_DATAPTR_TO_OFF) | ||
1141 | xfs_dir2_data_aoff_t | ||
1142 | xfs_dir2_dataptr_to_off(xfs_mount_t *mp, xfs_dir2_dataptr_t dp) | ||
1143 | { | ||
1144 | return XFS_DIR2_DATAPTR_TO_OFF(mp, dp); | ||
1145 | } | ||
1146 | #endif | ||
1147 | |||
1148 | #if XFS_WANT_FUNCS_C || (XFS_WANT_SPACE_C && XFSSO_XFS_DIR2_DB_OFF_TO_BYTE) | ||
1149 | xfs_dir2_off_t | ||
1150 | xfs_dir2_db_off_to_byte(xfs_mount_t *mp, xfs_dir2_db_t db, | ||
1151 | xfs_dir2_data_aoff_t o) | ||
1152 | { | ||
1153 | return XFS_DIR2_DB_OFF_TO_BYTE(mp, db, o); | ||
1154 | } | ||
1155 | #endif | ||
1156 | |||
1157 | #if XFS_WANT_FUNCS_C || (XFS_WANT_SPACE_C && XFSSO_XFS_DIR2_DB_OFF_TO_DATAPTR) | ||
1158 | xfs_dir2_dataptr_t | ||
1159 | xfs_dir2_db_off_to_dataptr(xfs_mount_t *mp, xfs_dir2_db_t db, | ||
1160 | xfs_dir2_data_aoff_t o) | ||
1161 | { | ||
1162 | return XFS_DIR2_DB_OFF_TO_DATAPTR(mp, db, o); | ||
1163 | } | ||
1164 | #endif | ||
1165 | |||
1166 | #if XFS_WANT_FUNCS_C || (XFS_WANT_SPACE_C && XFSSO_XFS_DIR2_DB_TO_DA) | ||
1167 | xfs_dablk_t | ||
1168 | xfs_dir2_db_to_da(xfs_mount_t *mp, xfs_dir2_db_t db) | ||
1169 | { | ||
1170 | return XFS_DIR2_DB_TO_DA(mp, db); | ||
1171 | } | ||
1172 | #endif | ||
1173 | |||
1174 | #if XFS_WANT_FUNCS_C || (XFS_WANT_SPACE_C && XFSSO_XFS_DIR2_DB_TO_FDB) | ||
1175 | xfs_dir2_db_t | ||
1176 | xfs_dir2_db_to_fdb(xfs_mount_t *mp, xfs_dir2_db_t db) | ||
1177 | { | ||
1178 | return XFS_DIR2_DB_TO_FDB(mp, db); | ||
1179 | } | ||
1180 | #endif | ||
1181 | |||
1182 | #if XFS_WANT_FUNCS_C || (XFS_WANT_SPACE_C && XFSSO_XFS_DIR2_DB_TO_FDINDEX) | ||
1183 | int | ||
1184 | xfs_dir2_db_to_fdindex(xfs_mount_t *mp, xfs_dir2_db_t db) | ||
1185 | { | ||
1186 | return XFS_DIR2_DB_TO_FDINDEX(mp, db); | ||
1187 | } | ||
1188 | #endif | ||
1189 | |||
1190 | #if XFS_WANT_FUNCS_C || (XFS_WANT_SPACE_C && XFSSO_XFS_DIR2_LEAF_BESTS_P) | ||
1191 | xfs_dir2_data_off_t * | ||
1192 | xfs_dir2_leaf_bests_p(xfs_dir2_leaf_tail_t *ltp) | ||
1193 | { | ||
1194 | return XFS_DIR2_LEAF_BESTS_P(ltp); | ||
1195 | } | ||
1196 | #endif | ||
1197 | |||
1198 | #if XFS_WANT_FUNCS_C || (XFS_WANT_SPACE_C && XFSSO_XFS_DIR2_LEAF_TAIL_P) | ||
1199 | xfs_dir2_leaf_tail_t * | ||
1200 | xfs_dir2_leaf_tail_p(xfs_mount_t *mp, xfs_dir2_leaf_t *lp) | ||
1201 | { | ||
1202 | return XFS_DIR2_LEAF_TAIL_P(mp, lp); | ||
1203 | } | ||
1204 | #endif | ||
1205 | |||
1206 | #if XFS_WANT_FUNCS_C || (XFS_WANT_SPACE_C && XFSSO_XFS_DIR2_MAX_LEAF_ENTS) | ||
1207 | int | ||
1208 | xfs_dir2_max_leaf_ents(xfs_mount_t *mp) | ||
1209 | { | ||
1210 | return XFS_DIR2_MAX_LEAF_ENTS(mp); | ||
1211 | } | ||
1212 | #endif | ||
1213 | |||
1214 | #if XFS_WANT_FUNCS_C || (XFS_WANT_SPACE_C && XFSSO_XFS_DIR2_SF_ENTSIZE_BYENTRY) | ||
1215 | int | ||
1216 | xfs_dir2_sf_entsize_byentry(xfs_dir2_sf_t *sfp, xfs_dir2_sf_entry_t *sfep) | ||
1217 | { | ||
1218 | return XFS_DIR2_SF_ENTSIZE_BYENTRY(sfp, sfep); | ||
1219 | } | ||
1220 | #endif | ||
1221 | |||
1222 | #if XFS_WANT_FUNCS_C || (XFS_WANT_SPACE_C && XFSSO_XFS_DIR2_SF_FIRSTENTRY) | ||
1223 | xfs_dir2_sf_entry_t * | ||
1224 | xfs_dir2_sf_firstentry(xfs_dir2_sf_t *sfp) | ||
1225 | { | ||
1226 | return XFS_DIR2_SF_FIRSTENTRY(sfp); | ||
1227 | } | ||
1228 | #endif | ||
1229 | |||
1230 | #if XFS_WANT_FUNCS_C || (XFS_WANT_SPACE_C && XFSSO_XFS_DIR2_SF_ENTSIZE_BYNAME) | ||
1231 | int | ||
1232 | xfs_dir2_sf_entsize_byname(xfs_dir2_sf_t *sfp, int len) | ||
1233 | { | ||
1234 | return XFS_DIR2_SF_ENTSIZE_BYNAME(sfp, len); | ||
1235 | } | ||
1236 | #endif | ||
1237 | |||
1238 | #if XFS_WANT_FUNCS_C || (XFS_WANT_SPACE_C && XFSSO_XFS_DIR2_SF_GET_INUMBER) | ||
1239 | xfs_intino_t | ||
1240 | xfs_dir2_sf_get_inumber(xfs_dir2_sf_t *sfp, xfs_dir2_inou_t *from) | ||
1241 | { | ||
1242 | return XFS_DIR2_SF_GET_INUMBER(sfp, from); | ||
1243 | } | ||
1244 | #endif | ||
1245 | |||
1246 | #if XFS_WANT_FUNCS_C || (XFS_WANT_SPACE_C && XFSSO_XFS_DIR2_SF_GET_OFFSET) | ||
1247 | xfs_dir2_data_aoff_t | ||
1248 | xfs_dir2_sf_get_offset(xfs_dir2_sf_entry_t *sfep) | ||
1249 | { | ||
1250 | return XFS_DIR2_SF_GET_OFFSET(sfep); | ||
1251 | } | ||
1252 | #endif | ||
1253 | |||
1254 | #if XFS_WANT_FUNCS_C || (XFS_WANT_SPACE_C && XFSSO_XFS_DIR2_SF_HDR_SIZE) | ||
1255 | int | ||
1256 | xfs_dir2_sf_hdr_size(int i8count) | ||
1257 | { | ||
1258 | return XFS_DIR2_SF_HDR_SIZE(i8count); | ||
1259 | } | ||
1260 | #endif | ||
1261 | |||
1262 | #if XFS_WANT_FUNCS_C || (XFS_WANT_SPACE_C && XFSSO_XFS_DIR2_SF_INUMBERP) | ||
1263 | xfs_dir2_inou_t * | ||
1264 | xfs_dir2_sf_inumberp(xfs_dir2_sf_entry_t *sfep) | ||
1265 | { | ||
1266 | return XFS_DIR2_SF_INUMBERP(sfep); | ||
1267 | } | ||
1268 | #endif | ||
1269 | |||
1270 | #if XFS_WANT_FUNCS_C || (XFS_WANT_SPACE_C && XFSSO_XFS_DIR2_SF_NEXTENTRY) | ||
1271 | xfs_dir2_sf_entry_t * | ||
1272 | xfs_dir2_sf_nextentry(xfs_dir2_sf_t *sfp, xfs_dir2_sf_entry_t *sfep) | ||
1273 | { | ||
1274 | return XFS_DIR2_SF_NEXTENTRY(sfp, sfep); | ||
1275 | } | ||
1276 | #endif | ||
1277 | |||
1278 | #if XFS_WANT_FUNCS_C || (XFS_WANT_SPACE_C && XFSSO_XFS_DIR2_SF_PUT_INUMBER) | ||
1279 | void | ||
1280 | xfs_dir2_sf_put_inumber(xfs_dir2_sf_t *sfp, xfs_ino_t *from, xfs_dir2_inou_t *to) | ||
1281 | { | ||
1282 | XFS_DIR2_SF_PUT_INUMBER(sfp, from, to); | ||
1283 | } | ||
1284 | #endif | ||
1285 | |||
1286 | #if XFS_WANT_FUNCS_C || (XFS_WANT_SPACE_C && XFSSO_XFS_DIR2_SF_PUT_OFFSET) | ||
1287 | void | ||
1288 | xfs_dir2_sf_put_offset(xfs_dir2_sf_entry_t *sfep, xfs_dir2_data_aoff_t off) | ||
1289 | { | ||
1290 | XFS_DIR2_SF_PUT_OFFSET(sfep, off); | ||
1291 | } | ||
1292 | #endif | ||
1293 | |||
1294 | #if XFS_WANT_FUNCS_C || (XFS_WANT_SPACE_C && XFSSO_XFS_EXTFMT_INODE ) | ||
1295 | xfs_exntfmt_t | ||
1296 | xfs_extfmt_inode(struct xfs_inode *ip) | ||
1297 | { | ||
1298 | return XFS_EXTFMT_INODE(ip); | ||
1299 | } | ||
1300 | #endif | ||
1301 | |||
1302 | #if XFS_WANT_FUNCS_C || (XFS_WANT_SPACE_C && XFSSO_XFS_EXTLEN_MAX) | ||
1303 | xfs_extlen_t | ||
1304 | xfs_extlen_max(xfs_extlen_t a, xfs_extlen_t b) | ||
1305 | { | ||
1306 | return XFS_EXTLEN_MAX(a, b); | ||
1307 | } | ||
1308 | #endif | ||
1309 | |||
1310 | #if XFS_WANT_FUNCS_C || (XFS_WANT_SPACE_C && XFSSO_XFS_EXTLEN_MIN) | ||
1311 | xfs_extlen_t | ||
1312 | xfs_extlen_min(xfs_extlen_t a, xfs_extlen_t b) | ||
1313 | { | ||
1314 | return XFS_EXTLEN_MIN(a, b); | ||
1315 | } | ||
1316 | #endif | ||
1317 | |||
1318 | #if XFS_WANT_FUNCS_C || (XFS_WANT_SPACE_C && XFSSO_XFS_FILBLKS_MAX) | ||
1319 | xfs_filblks_t | ||
1320 | xfs_filblks_max(xfs_filblks_t a, xfs_filblks_t b) | ||
1321 | { | ||
1322 | return XFS_FILBLKS_MAX(a, b); | ||
1323 | } | ||
1324 | #endif | ||
1325 | |||
1326 | #if XFS_WANT_FUNCS_C || (XFS_WANT_SPACE_C && XFSSO_XFS_FILBLKS_MIN) | ||
1327 | xfs_filblks_t | ||
1328 | xfs_filblks_min(xfs_filblks_t a, xfs_filblks_t b) | ||
1329 | { | ||
1330 | return XFS_FILBLKS_MIN(a, b); | ||
1331 | } | ||
1332 | #endif | ||
1333 | |||
1334 | #if XFS_WANT_FUNCS_C || (XFS_WANT_SPACE_C && XFSSO_XFS_FILEOFF_MAX) | ||
1335 | xfs_fileoff_t | ||
1336 | xfs_fileoff_max(xfs_fileoff_t a, xfs_fileoff_t b) | ||
1337 | { | ||
1338 | return XFS_FILEOFF_MAX(a, b); | ||
1339 | } | ||
1340 | #endif | ||
1341 | |||
1342 | #if XFS_WANT_FUNCS_C || (XFS_WANT_SPACE_C && XFSSO_XFS_FILEOFF_MIN) | ||
1343 | xfs_fileoff_t | ||
1344 | xfs_fileoff_min(xfs_fileoff_t a, xfs_fileoff_t b) | ||
1345 | { | ||
1346 | return XFS_FILEOFF_MIN(a, b); | ||
1347 | } | ||
1348 | #endif | ||
1349 | |||
1350 | #if XFS_WANT_FUNCS_C || (XFS_WANT_SPACE_C && XFSSO_XFS_FSB_SANITY_CHECK) | ||
1351 | int | ||
1352 | xfs_fsb_sanity_check(xfs_mount_t *mp, xfs_fsblock_t fsbno) | ||
1353 | { | ||
1354 | return XFS_FSB_SANITY_CHECK(mp, fsbno); | ||
1355 | } | ||
1356 | #endif | ||
1357 | |||
1358 | #if XFS_WANT_FUNCS_C || (XFS_WANT_SPACE_C && XFSSO_XFS_FSB_TO_AGBNO) | ||
1359 | xfs_agblock_t | ||
1360 | xfs_fsb_to_agbno(xfs_mount_t *mp, xfs_fsblock_t fsbno) | ||
1361 | { | ||
1362 | return XFS_FSB_TO_AGBNO(mp, fsbno); | ||
1363 | } | ||
1364 | #endif | ||
1365 | |||
1366 | #if XFS_WANT_FUNCS_C || (XFS_WANT_SPACE_C && XFSSO_XFS_FSB_TO_AGNO) | ||
1367 | xfs_agnumber_t | ||
1368 | xfs_fsb_to_agno(xfs_mount_t *mp, xfs_fsblock_t fsbno) | ||
1369 | { | ||
1370 | return XFS_FSB_TO_AGNO(mp, fsbno); | ||
1371 | } | ||
1372 | #endif | ||
1373 | |||
1374 | #if XFS_WANT_FUNCS_C || (XFS_WANT_SPACE_C && XFSSO_XFS_FSB_TO_DADDR) | ||
1375 | xfs_daddr_t | ||
1376 | xfs_fsb_to_daddr(xfs_mount_t *mp, xfs_fsblock_t fsbno) | ||
1377 | { | ||
1378 | return XFS_FSB_TO_DADDR(mp, fsbno); | ||
1379 | } | ||
1380 | #endif | ||
1381 | |||
1382 | #if XFS_WANT_FUNCS_C || (XFS_WANT_SPACE_C && XFSSO_XFS_FSB_TO_DB) | ||
1383 | xfs_daddr_t | ||
1384 | xfs_fsb_to_db(xfs_inode_t *ip, xfs_fsblock_t fsb) | ||
1385 | { | ||
1386 | return XFS_FSB_TO_DB(ip, fsb); | ||
1387 | } | ||
1388 | #endif | ||
1389 | |||
1390 | #if XFS_WANT_FUNCS_C || (XFS_WANT_SPACE_C && XFSSO_XFS_HDR_BLOCK) | ||
1391 | xfs_agblock_t | ||
1392 | xfs_hdr_block(xfs_mount_t *mp, xfs_daddr_t d) | ||
1393 | { | ||
1394 | return XFS_HDR_BLOCK(mp, d); | ||
1395 | } | ||
1396 | #endif | ||
1397 | |||
1398 | #if XFS_WANT_FUNCS_C || (XFS_WANT_SPACE_C && XFSSO_XFS_IALLOC_BLOCKS) | ||
1399 | xfs_extlen_t | ||
1400 | xfs_ialloc_blocks(xfs_mount_t *mp) | ||
1401 | { | ||
1402 | return XFS_IALLOC_BLOCKS(mp); | ||
1403 | } | ||
1404 | #endif | ||
1405 | |||
1406 | #if XFS_WANT_FUNCS_C || (XFS_WANT_SPACE_C && XFSSO_XFS_IALLOC_FIND_FREE) | ||
1407 | int | ||
1408 | xfs_ialloc_find_free(xfs_inofree_t *fp) | ||
1409 | { | ||
1410 | return XFS_IALLOC_FIND_FREE(fp); | ||
1411 | } | ||
1412 | #endif | ||
1413 | |||
1414 | #if XFS_WANT_FUNCS_C || (XFS_WANT_SPACE_C && XFSSO_XFS_IALLOC_INODES) | ||
1415 | int | ||
1416 | xfs_ialloc_inodes(xfs_mount_t *mp) | ||
1417 | { | ||
1418 | return XFS_IALLOC_INODES(mp); | ||
1419 | } | ||
1420 | #endif | ||
1421 | |||
1422 | #if XFS_WANT_FUNCS_C || (XFS_WANT_SPACE_C && XFSSO_XFS_IBT_BLOCK) | ||
1423 | xfs_agblock_t | ||
1424 | xfs_ibt_block(xfs_mount_t *mp) | ||
1425 | { | ||
1426 | return XFS_IBT_BLOCK(mp); | ||
1427 | } | ||
1428 | #endif | ||
1429 | |||
1430 | #if XFS_WANT_FUNCS_C || (XFS_WANT_SPACE_C && XFSSO_XFS_IFORK_ASIZE) | ||
1431 | int | ||
1432 | xfs_ifork_asize(xfs_inode_t *ip) | ||
1433 | { | ||
1434 | return XFS_IFORK_ASIZE(ip); | ||
1435 | } | ||
1436 | #endif | ||
1437 | |||
1438 | #if XFS_WANT_FUNCS_C || (XFS_WANT_SPACE_C && XFSSO_XFS_IFORK_DSIZE) | ||
1439 | int | ||
1440 | xfs_ifork_dsize(xfs_inode_t *ip) | ||
1441 | { | ||
1442 | return XFS_IFORK_DSIZE(ip); | ||
1443 | } | ||
1444 | #endif | ||
1445 | |||
1446 | #if XFS_WANT_FUNCS_C || (XFS_WANT_SPACE_C && XFSSO_XFS_IFORK_FMT_SET) | ||
1447 | void | ||
1448 | xfs_ifork_fmt_set(xfs_inode_t *ip, int w, int n) | ||
1449 | { | ||
1450 | XFS_IFORK_FMT_SET(ip, w, n); | ||
1451 | } | ||
1452 | #endif | ||
1453 | |||
1454 | #if XFS_WANT_FUNCS_C || (XFS_WANT_SPACE_C && XFSSO_XFS_IFORK_FORMAT) | ||
1455 | int | ||
1456 | xfs_ifork_format(xfs_inode_t *ip, int w) | ||
1457 | { | ||
1458 | return XFS_IFORK_FORMAT(ip, w); | ||
1459 | } | ||
1460 | #endif | ||
1461 | |||
1462 | #if XFS_WANT_FUNCS_C || (XFS_WANT_SPACE_C && XFSSO_XFS_IFORK_NEXT_SET) | ||
1463 | void | ||
1464 | xfs_ifork_next_set(xfs_inode_t *ip, int w, int n) | ||
1465 | { | ||
1466 | XFS_IFORK_NEXT_SET(ip, w, n); | ||
1467 | } | ||
1468 | #endif | ||
1469 | |||
1470 | #if XFS_WANT_FUNCS_C || (XFS_WANT_SPACE_C && XFSSO_XFS_IFORK_NEXTENTS) | ||
1471 | int | ||
1472 | xfs_ifork_nextents(xfs_inode_t *ip, int w) | ||
1473 | { | ||
1474 | return XFS_IFORK_NEXTENTS(ip, w); | ||
1475 | } | ||
1476 | #endif | ||
1477 | |||
1478 | #if XFS_WANT_FUNCS_C || (XFS_WANT_SPACE_C && XFSSO_XFS_IFORK_PTR) | ||
1479 | xfs_ifork_t * | ||
1480 | xfs_ifork_ptr(xfs_inode_t *ip, int w) | ||
1481 | { | ||
1482 | return XFS_IFORK_PTR(ip, w); | ||
1483 | } | ||
1484 | #endif | ||
1485 | |||
1486 | #if XFS_WANT_FUNCS_C || (XFS_WANT_SPACE_C && XFSSO_XFS_IFORK_Q) | ||
1487 | int | ||
1488 | xfs_ifork_q(xfs_inode_t *ip) | ||
1489 | { | ||
1490 | return XFS_IFORK_Q(ip); | ||
1491 | } | ||
1492 | #endif | ||
1493 | |||
1494 | #if XFS_WANT_FUNCS_C || (XFS_WANT_SPACE_C && XFSSO_XFS_IFORK_SIZE) | ||
1495 | int | ||
1496 | xfs_ifork_size(xfs_inode_t *ip, int w) | ||
1497 | { | ||
1498 | return XFS_IFORK_SIZE(ip, w); | ||
1499 | } | ||
1500 | #endif | ||
1501 | |||
1502 | #if XFS_WANT_FUNCS_C || (XFS_WANT_SPACE_C && XFSSO_XFS_ILOG_FBROOT) | ||
1503 | int | ||
1504 | xfs_ilog_fbroot(int w) | ||
1505 | { | ||
1506 | return XFS_ILOG_FBROOT(w); | ||
1507 | } | ||
1508 | #endif | ||
1509 | |||
1510 | #if XFS_WANT_FUNCS_C || (XFS_WANT_SPACE_C && XFSSO_XFS_ILOG_FDATA) | ||
1511 | int | ||
1512 | xfs_ilog_fdata(int w) | ||
1513 | { | ||
1514 | return XFS_ILOG_FDATA(w); | ||
1515 | } | ||
1516 | #endif | ||
1517 | |||
1518 | #if XFS_WANT_FUNCS_C || (XFS_WANT_SPACE_C && XFSSO_XFS_ILOG_FEXT) | ||
1519 | int | ||
1520 | xfs_ilog_fext(int w) | ||
1521 | { | ||
1522 | return XFS_ILOG_FEXT(w); | ||
1523 | } | ||
1524 | #endif | ||
1525 | |||
1526 | #if XFS_WANT_FUNCS_C || (XFS_WANT_SPACE_C && XFSSO_XFS_IN_MAXLEVELS) | ||
1527 | int | ||
1528 | xfs_in_maxlevels(xfs_mount_t *mp) | ||
1529 | { | ||
1530 | return XFS_IN_MAXLEVELS(mp); | ||
1531 | } | ||
1532 | #endif | ||
1533 | |||
1534 | #if XFS_WANT_FUNCS_C || (XFS_WANT_SPACE_C && XFSSO_XFS_INO_AGBNO_BITS) | ||
1535 | int | ||
1536 | xfs_ino_agbno_bits(xfs_mount_t *mp) | ||
1537 | { | ||
1538 | return XFS_INO_AGBNO_BITS(mp); | ||
1539 | } | ||
1540 | #endif | ||
1541 | |||
1542 | #if XFS_WANT_FUNCS_C || (XFS_WANT_SPACE_C && XFSSO_XFS_INO_AGINO_BITS) | ||
1543 | int | ||
1544 | xfs_ino_agino_bits(xfs_mount_t *mp) | ||
1545 | { | ||
1546 | return XFS_INO_AGINO_BITS(mp); | ||
1547 | } | ||
1548 | #endif | ||
1549 | |||
1550 | #if XFS_WANT_FUNCS_C || (XFS_WANT_SPACE_C && XFSSO_XFS_INO_AGNO_BITS) | ||
1551 | int | ||
1552 | xfs_ino_agno_bits(xfs_mount_t *mp) | ||
1553 | { | ||
1554 | return XFS_INO_AGNO_BITS(mp); | ||
1555 | } | ||
1556 | #endif | ||
1557 | |||
1558 | #if XFS_WANT_FUNCS_C || (XFS_WANT_SPACE_C && XFSSO_XFS_INO_BITS) | ||
1559 | int | ||
1560 | xfs_ino_bits(xfs_mount_t *mp) | ||
1561 | { | ||
1562 | return XFS_INO_BITS(mp); | ||
1563 | } | ||
1564 | #endif | ||
1565 | |||
1566 | #if XFS_WANT_FUNCS_C || (XFS_WANT_SPACE_C && XFSSO_XFS_INO_MASK) | ||
1567 | __uint32_t | ||
1568 | xfs_ino_mask(int k) | ||
1569 | { | ||
1570 | return XFS_INO_MASK(k); | ||
1571 | } | ||
1572 | #endif | ||
1573 | |||
1574 | #if XFS_WANT_FUNCS_C || (XFS_WANT_SPACE_C && XFSSO_XFS_INO_OFFSET_BITS) | ||
1575 | int | ||
1576 | xfs_ino_offset_bits(xfs_mount_t *mp) | ||
1577 | { | ||
1578 | return XFS_INO_OFFSET_BITS(mp); | ||
1579 | } | ||
1580 | #endif | ||
1581 | |||
1582 | #if XFS_WANT_FUNCS_C || (XFS_WANT_SPACE_C && XFSSO_XFS_INO_TO_AGBNO) | ||
1583 | xfs_agblock_t | ||
1584 | xfs_ino_to_agbno(xfs_mount_t *mp, xfs_ino_t i) | ||
1585 | { | ||
1586 | return XFS_INO_TO_AGBNO(mp, i); | ||
1587 | } | ||
1588 | #endif | ||
1589 | |||
1590 | #if XFS_WANT_FUNCS_C || (XFS_WANT_SPACE_C && XFSSO_XFS_INO_TO_AGINO) | ||
1591 | xfs_agino_t | ||
1592 | xfs_ino_to_agino(xfs_mount_t *mp, xfs_ino_t i) | ||
1593 | { | ||
1594 | return XFS_INO_TO_AGINO(mp, i); | ||
1595 | } | ||
1596 | #endif | ||
1597 | |||
1598 | #if XFS_WANT_FUNCS_C || (XFS_WANT_SPACE_C && XFSSO_XFS_INO_TO_AGNO) | ||
1599 | xfs_agnumber_t | ||
1600 | xfs_ino_to_agno(xfs_mount_t *mp, xfs_ino_t i) | ||
1601 | { | ||
1602 | return XFS_INO_TO_AGNO(mp, i); | ||
1603 | } | ||
1604 | #endif | ||
1605 | |||
1606 | #if XFS_WANT_FUNCS_C || (XFS_WANT_SPACE_C && XFSSO_XFS_INO_TO_FSB) | ||
1607 | xfs_fsblock_t | ||
1608 | xfs_ino_to_fsb(xfs_mount_t *mp, xfs_ino_t i) | ||
1609 | { | ||
1610 | return XFS_INO_TO_FSB(mp, i); | ||
1611 | } | ||
1612 | #endif | ||
1613 | |||
1614 | #if XFS_WANT_FUNCS_C || (XFS_WANT_SPACE_C && XFSSO_XFS_INO_TO_OFFSET) | ||
1615 | int | ||
1616 | xfs_ino_to_offset(xfs_mount_t *mp, xfs_ino_t i) | ||
1617 | { | ||
1618 | return XFS_INO_TO_OFFSET(mp, i); | ||
1619 | } | ||
1620 | #endif | ||
1621 | |||
1622 | #if XFS_WANT_FUNCS_C || (XFS_WANT_SPACE_C && XFSSO_XFS_INOBT_BLOCK_MAXRECS) | ||
1623 | int | ||
1624 | xfs_inobt_block_maxrecs(int lev, xfs_btree_cur_t *cur) | ||
1625 | { | ||
1626 | return XFS_INOBT_BLOCK_MAXRECS(lev, cur); | ||
1627 | } | ||
1628 | #endif | ||
1629 | |||
1630 | #if XFS_WANT_FUNCS_C || (XFS_WANT_SPACE_C && XFSSO_XFS_INOBT_BLOCK_MINRECS) | ||
1631 | int | ||
1632 | xfs_inobt_block_minrecs(int lev, xfs_btree_cur_t *cur) | ||
1633 | { | ||
1634 | return XFS_INOBT_BLOCK_MINRECS(lev, cur); | ||
1635 | } | ||
1636 | #endif | ||
1637 | |||
1638 | #if XFS_WANT_FUNCS_C || (XFS_WANT_SPACE_C && XFSSO_XFS_INOBT_BLOCK_SIZE) | ||
1639 | /*ARGSUSED1*/ | ||
1640 | int | ||
1641 | xfs_inobt_block_size(int lev, xfs_btree_cur_t *cur) | ||
1642 | { | ||
1643 | return XFS_INOBT_BLOCK_SIZE(lev, cur); | ||
1644 | } | ||
1645 | #endif | ||
1646 | |||
1647 | #if XFS_WANT_FUNCS_C || (XFS_WANT_SPACE_C && XFSSO_XFS_INOBT_CLR_FREE) | ||
1648 | void | ||
1649 | xfs_inobt_clr_free(xfs_inobt_rec_t *rp, int i) | ||
1650 | { | ||
1651 | XFS_INOBT_CLR_FREE(rp, i); | ||
1652 | } | ||
1653 | #endif | ||
1654 | |||
1655 | #if XFS_WANT_FUNCS_C || (XFS_WANT_SPACE_C && XFSSO_XFS_INOBT_IS_FREE) | ||
1656 | int | ||
1657 | xfs_inobt_is_free(xfs_inobt_rec_t *rp, int i) | ||
1658 | { | ||
1659 | return XFS_INOBT_IS_FREE(rp, i); | ||
1660 | } | ||
1661 | int | ||
1662 | xfs_inobt_is_free_disk(xfs_inobt_rec_t *rp, int i) | ||
1663 | { | ||
1664 | return XFS_INOBT_IS_FREE_DISK(rp, i); | ||
1665 | } | ||
1666 | #endif | ||
1667 | |||
1668 | #if XFS_WANT_FUNCS_C || (XFS_WANT_SPACE_C && XFSSO_XFS_INOBT_IS_LAST_REC) | ||
1669 | int | ||
1670 | xfs_inobt_is_last_rec(xfs_btree_cur_t *cur) | ||
1671 | { | ||
1672 | return XFS_INOBT_IS_LAST_REC(cur); | ||
1673 | } | ||
1674 | #endif | ||
1675 | |||
1676 | #if XFS_WANT_FUNCS_C || (XFS_WANT_SPACE_C && XFSSO_XFS_INOBT_KEY_ADDR) | ||
1677 | /*ARGSUSED3*/ | ||
1678 | xfs_inobt_key_t * | ||
1679 | xfs_inobt_key_addr(xfs_inobt_block_t *bb, int i, xfs_btree_cur_t *cur) | ||
1680 | { | ||
1681 | return XFS_INOBT_KEY_ADDR(bb, i, cur); | ||
1682 | } | ||
1683 | #endif | ||
1684 | |||
1685 | #if XFS_WANT_FUNCS_C || (XFS_WANT_SPACE_C && XFSSO_XFS_INOBT_MASK) | ||
1686 | xfs_inofree_t | ||
1687 | xfs_inobt_mask(int i) | ||
1688 | { | ||
1689 | return XFS_INOBT_MASK(i); | ||
1690 | } | ||
1691 | #endif | ||
1692 | |||
1693 | #if XFS_WANT_FUNCS_C || (XFS_WANT_SPACE_C && XFSSO_XFS_INOBT_MASKN) | ||
1694 | xfs_inofree_t | ||
1695 | xfs_inobt_maskn(int i, int n) | ||
1696 | { | ||
1697 | return XFS_INOBT_MASKN(i, n); | ||
1698 | } | ||
1699 | #endif | ||
1700 | |||
1701 | #if XFS_WANT_FUNCS_C || (XFS_WANT_SPACE_C && XFSSO_XFS_INOBT_PTR_ADDR) | ||
1702 | xfs_inobt_ptr_t * | ||
1703 | xfs_inobt_ptr_addr(xfs_inobt_block_t *bb, int i, xfs_btree_cur_t *cur) | ||
1704 | { | ||
1705 | return XFS_INOBT_PTR_ADDR(bb, i, cur); | ||
1706 | } | ||
1707 | #endif | ||
1708 | |||
1709 | #if XFS_WANT_FUNCS_C || (XFS_WANT_SPACE_C && XFSSO_XFS_INOBT_REC_ADDR) | ||
1710 | /*ARGSUSED3*/ | ||
1711 | xfs_inobt_rec_t * | ||
1712 | xfs_inobt_rec_addr(xfs_inobt_block_t *bb, int i, xfs_btree_cur_t *cur) | ||
1713 | { | ||
1714 | return XFS_INOBT_REC_ADDR(bb, i, cur); | ||
1715 | } | ||
1716 | #endif | ||
1717 | |||
1718 | #if XFS_WANT_FUNCS_C || (XFS_WANT_SPACE_C && XFSSO_XFS_INOBT_SET_FREE) | ||
1719 | void | ||
1720 | xfs_inobt_set_free(xfs_inobt_rec_t *rp, int i) | ||
1721 | { | ||
1722 | XFS_INOBT_SET_FREE(rp, i); | ||
1723 | } | ||
1724 | #endif | ||
1725 | |||
1726 | #if XFS_WANT_FUNCS_C || (XFS_WANT_SPACE_C && XFSSO_XFS_ITOBHV) | ||
1727 | bhv_desc_t * | ||
1728 | xfs_itobhv(xfs_inode_t *ip) | ||
1729 | { | ||
1730 | return XFS_ITOBHV(ip); | ||
1731 | } | ||
1732 | #endif | ||
1733 | |||
1734 | #if XFS_WANT_FUNCS_C || (XFS_WANT_SPACE_C && XFSSO_XFS_ITOV) | ||
1735 | vnode_t * | ||
1736 | xfs_itov(xfs_inode_t *ip) | ||
1737 | { | ||
1738 | return XFS_ITOV(ip); | ||
1739 | } | ||
1740 | #endif | ||
1741 | |||
1742 | #if XFS_WANT_FUNCS_C || (XFS_WANT_SPACE_C && XFSSO_XFS_LBLOG) | ||
1743 | int | ||
1744 | xfs_lblog(xfs_mount_t *mp) | ||
1745 | { | ||
1746 | return XFS_LBLOG(mp); | ||
1747 | } | ||
1748 | #endif | ||
1749 | |||
1750 | #if XFS_WANT_FUNCS_C || (XFS_WANT_SPACE_C && XFSSO_XFS_LBSIZE) | ||
1751 | int | ||
1752 | xfs_lbsize(xfs_mount_t *mp) | ||
1753 | { | ||
1754 | return XFS_LBSIZE(mp); | ||
1755 | } | ||
1756 | #endif | ||
1757 | |||
1758 | #if XFS_WANT_FUNCS_C || (XFS_WANT_SPACE_C && XFSSO_XFS_LIC_ALL_FREE) | ||
1759 | void | ||
1760 | xfs_lic_all_free(xfs_log_item_chunk_t *cp) | ||
1761 | { | ||
1762 | XFS_LIC_ALL_FREE(cp); | ||
1763 | } | ||
1764 | #endif | ||
1765 | |||
1766 | #if XFS_WANT_FUNCS_C || (XFS_WANT_SPACE_C && XFSSO_XFS_LIC_ARE_ALL_FREE) | ||
1767 | int | ||
1768 | xfs_lic_are_all_free(xfs_log_item_chunk_t *cp) | ||
1769 | { | ||
1770 | return XFS_LIC_ARE_ALL_FREE(cp); | ||
1771 | } | ||
1772 | #endif | ||
1773 | |||
1774 | #if XFS_WANT_FUNCS_C || (XFS_WANT_SPACE_C && XFSSO_XFS_LIC_CLAIM) | ||
1775 | void | ||
1776 | xfs_lic_claim(xfs_log_item_chunk_t *cp, int slot) | ||
1777 | { | ||
1778 | XFS_LIC_CLAIM(cp, slot); | ||
1779 | } | ||
1780 | #endif | ||
1781 | |||
1782 | #if XFS_WANT_FUNCS_C || (XFS_WANT_SPACE_C && XFSSO_XFS_LIC_DESC_TO_CHUNK) | ||
1783 | xfs_log_item_chunk_t * | ||
1784 | xfs_lic_desc_to_chunk(xfs_log_item_desc_t *dp) | ||
1785 | { | ||
1786 | return XFS_LIC_DESC_TO_CHUNK(dp); | ||
1787 | } | ||
1788 | #endif | ||
1789 | |||
1790 | #if XFS_WANT_FUNCS_C || (XFS_WANT_SPACE_C && XFSSO_XFS_LIC_DESC_TO_SLOT) | ||
1791 | int | ||
1792 | xfs_lic_desc_to_slot(xfs_log_item_desc_t *dp) | ||
1793 | { | ||
1794 | return XFS_LIC_DESC_TO_SLOT(dp); | ||
1795 | } | ||
1796 | #endif | ||
1797 | |||
1798 | #if XFS_WANT_FUNCS_C || (XFS_WANT_SPACE_C && XFSSO_XFS_LIC_INIT) | ||
1799 | void | ||
1800 | xfs_lic_init(xfs_log_item_chunk_t *cp) | ||
1801 | { | ||
1802 | XFS_LIC_INIT(cp); | ||
1803 | } | ||
1804 | #endif | ||
1805 | |||
1806 | #if XFS_WANT_FUNCS_C || (XFS_WANT_SPACE_C && XFSSO_XFS_LIC_INIT_SLOT) | ||
1807 | void | ||
1808 | xfs_lic_init_slot(xfs_log_item_chunk_t *cp, int slot) | ||
1809 | { | ||
1810 | XFS_LIC_INIT_SLOT(cp, slot); | ||
1811 | } | ||
1812 | #endif | ||
1813 | |||
1814 | #if XFS_WANT_FUNCS_C || (XFS_WANT_SPACE_C && XFSSO_XFS_LIC_ISFREE) | ||
1815 | int | ||
1816 | xfs_lic_isfree(xfs_log_item_chunk_t *cp, int slot) | ||
1817 | { | ||
1818 | return XFS_LIC_ISFREE(cp, slot); | ||
1819 | } | ||
1820 | #endif | ||
1821 | |||
1822 | #if XFS_WANT_FUNCS_C || (XFS_WANT_SPACE_C && XFSSO_XFS_LIC_RELSE) | ||
1823 | void | ||
1824 | xfs_lic_relse(xfs_log_item_chunk_t *cp, int slot) | ||
1825 | { | ||
1826 | XFS_LIC_RELSE(cp, slot); | ||
1827 | } | ||
1828 | #endif | ||
1829 | |||
1830 | #if XFS_WANT_FUNCS_C || (XFS_WANT_SPACE_C && XFSSO_XFS_LIC_SLOT) | ||
1831 | xfs_log_item_desc_t * | ||
1832 | xfs_lic_slot(xfs_log_item_chunk_t *cp, int slot) | ||
1833 | { | ||
1834 | return XFS_LIC_SLOT(cp, slot); | ||
1835 | } | ||
1836 | #endif | ||
1837 | |||
1838 | #if XFS_WANT_FUNCS_C || (XFS_WANT_SPACE_C && XFSSO_XFS_LIC_VACANCY) | ||
1839 | int | ||
1840 | xfs_lic_vacancy(xfs_log_item_chunk_t *cp) | ||
1841 | { | ||
1842 | return XFS_LIC_VACANCY(cp); | ||
1843 | } | ||
1844 | #endif | ||
1845 | |||
1846 | #if XFS_WANT_FUNCS_C || (XFS_WANT_SPACE_C && XFSSO_XFS_LITINO) | ||
1847 | int | ||
1848 | xfs_litino(xfs_mount_t *mp) | ||
1849 | { | ||
1850 | return XFS_LITINO(mp); | ||
1851 | } | ||
1852 | #endif | ||
1853 | |||
1854 | #if XFS_WANT_FUNCS_C || (XFS_WANT_SPACE_C && XFSSO_XFS_MAKE_IPTR) | ||
1855 | xfs_dinode_t * | ||
1856 | xfs_make_iptr(xfs_mount_t *mp, xfs_buf_t *b, int o) | ||
1857 | { | ||
1858 | return XFS_MAKE_IPTR(mp, b, o); | ||
1859 | } | ||
1860 | #endif | ||
1861 | |||
1862 | #if XFS_WANT_FUNCS_C || (XFS_WANT_SPACE_C && XFSSO_XFS_MASK32HI) | ||
1863 | __uint32_t | ||
1864 | xfs_mask32hi(int n) | ||
1865 | { | ||
1866 | return XFS_MASK32HI(n); | ||
1867 | } | ||
1868 | #endif | ||
1869 | |||
1870 | #if XFS_WANT_FUNCS_C || (XFS_WANT_SPACE_C && XFSSO_XFS_MASK32LO) | ||
1871 | __uint32_t | ||
1872 | xfs_mask32lo(int n) | ||
1873 | { | ||
1874 | return XFS_MASK32LO(n); | ||
1875 | } | ||
1876 | #endif | ||
1877 | |||
1878 | #if XFS_WANT_FUNCS_C || (XFS_WANT_SPACE_C && XFSSO_XFS_MASK64HI) | ||
1879 | __uint64_t | ||
1880 | xfs_mask64hi(int n) | ||
1881 | { | ||
1882 | return XFS_MASK64HI(n); | ||
1883 | } | ||
1884 | #endif | ||
1885 | |||
1886 | #if XFS_WANT_FUNCS_C || (XFS_WANT_SPACE_C && XFSSO_XFS_MASK64LO) | ||
1887 | __uint64_t | ||
1888 | xfs_mask64lo(int n) | ||
1889 | { | ||
1890 | return XFS_MASK64LO(n); | ||
1891 | } | ||
1892 | #endif | ||
1893 | |||
1894 | #if XFS_WANT_FUNCS_C || (XFS_WANT_SPACE_C && XFSSO_XFS_MIN_FREELIST) | ||
1895 | int | ||
1896 | xfs_min_freelist(xfs_agf_t *a, xfs_mount_t *mp) | ||
1897 | { | ||
1898 | return XFS_MIN_FREELIST(a, mp); | ||
1899 | } | ||
1900 | #endif | ||
1901 | |||
1902 | #if XFS_WANT_FUNCS_C || (XFS_WANT_SPACE_C && XFSSO_XFS_MIN_FREELIST_PAG) | ||
1903 | int | ||
1904 | xfs_min_freelist_pag(xfs_perag_t *pag, xfs_mount_t *mp) | ||
1905 | { | ||
1906 | return XFS_MIN_FREELIST_PAG(pag, mp); | ||
1907 | } | ||
1908 | #endif | ||
1909 | |||
1910 | #if XFS_WANT_FUNCS_C || (XFS_WANT_SPACE_C && XFSSO_XFS_MIN_FREELIST_RAW) | ||
1911 | int | ||
1912 | xfs_min_freelist_raw(uint bl, uint cl, xfs_mount_t *mp) | ||
1913 | { | ||
1914 | return XFS_MIN_FREELIST_RAW(bl, cl, mp); | ||
1915 | } | ||
1916 | #endif | ||
1917 | |||
1918 | #if XFS_WANT_FUNCS_C || (XFS_WANT_SPACE_C && XFSSO_XFS_MTOVFS) | ||
1919 | vfs_t * | ||
1920 | xfs_mtovfs(xfs_mount_t *mp) | ||
1921 | { | ||
1922 | return XFS_MTOVFS(mp); | ||
1923 | } | ||
1924 | #endif | ||
1925 | |||
1926 | #if XFS_WANT_FUNCS_C || (XFS_WANT_SPACE_C && XFSSO_XFS_OFFBNO_TO_AGINO) | ||
1927 | xfs_agino_t | ||
1928 | xfs_offbno_to_agino(xfs_mount_t *mp, xfs_agblock_t b, int o) | ||
1929 | { | ||
1930 | return XFS_OFFBNO_TO_AGINO(mp, b, o); | ||
1931 | } | ||
1932 | #endif | ||
1933 | |||
1934 | #if XFS_WANT_FUNCS_C || (XFS_WANT_SPACE_C && XFSSO_XFS_PREALLOC_BLOCKS) | ||
1935 | xfs_agblock_t | ||
1936 | xfs_prealloc_blocks(xfs_mount_t *mp) | ||
1937 | { | ||
1938 | return XFS_PREALLOC_BLOCKS(mp); | ||
1939 | } | ||
1940 | #endif | ||
1941 | |||
1942 | #if XFS_WANT_FUNCS_C || (XFS_WANT_SPACE_C && XFSSO_XFS_SB_BLOCK) | ||
1943 | xfs_agblock_t | ||
1944 | xfs_sb_block(xfs_mount_t *mp) | ||
1945 | { | ||
1946 | return XFS_SB_BLOCK(mp); | ||
1947 | } | ||
1948 | #endif | ||
1949 | |||
1950 | #if XFS_WANT_FUNCS_C || (XFS_WANT_SPACE_C && XFSSO_XFS_SB_GOOD_VERSION) | ||
1951 | int | ||
1952 | xfs_sb_good_version(xfs_sb_t *sbp) | ||
1953 | { | ||
1954 | return XFS_SB_GOOD_VERSION(sbp); | ||
1955 | } | ||
1956 | #endif | ||
1957 | |||
1958 | #if XFS_WANT_FUNCS_C || (XFS_WANT_SPACE_C && XFSSO_XFS_SB_VERSION_ADDATTR) | ||
1959 | void | ||
1960 | xfs_sb_version_addattr(xfs_sb_t *sbp) | ||
1961 | { | ||
1962 | XFS_SB_VERSION_ADDATTR(sbp); | ||
1963 | } | ||
1964 | #endif | ||
1965 | |||
1966 | #if XFS_WANT_FUNCS_C || (XFS_WANT_SPACE_C && XFSSO_XFS_SB_VERSION_ADDDALIGN) | ||
1967 | void | ||
1968 | xfs_sb_version_adddalign(xfs_sb_t *sbp) | ||
1969 | { | ||
1970 | XFS_SB_VERSION_ADDDALIGN(sbp); | ||
1971 | } | ||
1972 | #endif | ||
1973 | |||
1974 | #if XFS_WANT_FUNCS_C || (XFS_WANT_SPACE_C && XFSSO_XFS_SB_VERSION_ADDNLINK) | ||
1975 | void | ||
1976 | xfs_sb_version_addnlink(xfs_sb_t *sbp) | ||
1977 | { | ||
1978 | XFS_SB_VERSION_ADDNLINK(sbp); | ||
1979 | } | ||
1980 | #endif | ||
1981 | |||
1982 | #if XFS_WANT_FUNCS_C || (XFS_WANT_SPACE_C && XFSSO_XFS_SB_VERSION_ADDQUOTA) | ||
1983 | void | ||
1984 | xfs_sb_version_addquota(xfs_sb_t *sbp) | ||
1985 | { | ||
1986 | XFS_SB_VERSION_ADDQUOTA(sbp); | ||
1987 | } | ||
1988 | #endif | ||
1989 | |||
1990 | #if XFS_WANT_FUNCS_C || (XFS_WANT_SPACE_C && XFSSO_XFS_SB_VERSION_ADDSHARED) | ||
1991 | void | ||
1992 | xfs_sb_version_addshared(xfs_sb_t *sbp) | ||
1993 | { | ||
1994 | XFS_SB_VERSION_ADDSHARED(sbp); | ||
1995 | } | ||
1996 | #endif | ||
1997 | |||
1998 | #if XFS_WANT_FUNCS_C || (XFS_WANT_SPACE_C && XFSSO_XFS_SB_VERSION_HASALIGN) | ||
1999 | int | ||
2000 | xfs_sb_version_hasalign(xfs_sb_t *sbp) | ||
2001 | { | ||
2002 | return XFS_SB_VERSION_HASALIGN(sbp); | ||
2003 | } | ||
2004 | #endif | ||
2005 | |||
2006 | #if XFS_WANT_FUNCS_C || (XFS_WANT_SPACE_C && XFSSO_XFS_SB_VERSION_HASATTR) | ||
2007 | int | ||
2008 | xfs_sb_version_hasattr(xfs_sb_t *sbp) | ||
2009 | { | ||
2010 | return XFS_SB_VERSION_HASATTR(sbp); | ||
2011 | } | ||
2012 | #endif | ||
2013 | |||
2014 | #if XFS_WANT_FUNCS_C || (XFS_WANT_SPACE_C && XFSSO_XFS_SB_VERSION_HASDALIGN) | ||
2015 | int | ||
2016 | xfs_sb_version_hasdalign(xfs_sb_t *sbp) | ||
2017 | { | ||
2018 | return XFS_SB_VERSION_HASDALIGN(sbp); | ||
2019 | } | ||
2020 | #endif | ||
2021 | |||
2022 | #if XFS_WANT_FUNCS_C || (XFS_WANT_SPACE_C && XFSSO_XFS_SB_VERSION_HASDIRV2) | ||
2023 | int | ||
2024 | xfs_sb_version_hasdirv2(xfs_sb_t *sbp) | ||
2025 | { | ||
2026 | return XFS_SB_VERSION_HASDIRV2(sbp); | ||
2027 | } | ||
2028 | #endif | ||
2029 | |||
2030 | #if XFS_WANT_FUNCS_C || (XFS_WANT_SPACE_C && XFSSO_XFS_SB_VERSION_HASEXTFLGBIT) | ||
2031 | int | ||
2032 | xfs_sb_version_hasextflgbit(xfs_sb_t *sbp) | ||
2033 | { | ||
2034 | return XFS_SB_VERSION_HASEXTFLGBIT(sbp); | ||
2035 | } | ||
2036 | #endif | ||
2037 | |||
2038 | #if XFS_WANT_FUNCS_C || (XFS_WANT_SPACE_C && XFSSO_XFS_SB_VERSION_HASNLINK) | ||
2039 | int | ||
2040 | xfs_sb_version_hasnlink(xfs_sb_t *sbp) | ||
2041 | { | ||
2042 | return XFS_SB_VERSION_HASNLINK(sbp); | ||
2043 | } | ||
2044 | #endif | ||
2045 | |||
2046 | #if XFS_WANT_FUNCS_C || (XFS_WANT_SPACE_C && XFSSO_XFS_SB_VERSION_HASQUOTA) | ||
2047 | int | ||
2048 | xfs_sb_version_hasquota(xfs_sb_t *sbp) | ||
2049 | { | ||
2050 | return XFS_SB_VERSION_HASQUOTA(sbp); | ||
2051 | } | ||
2052 | #endif | ||
2053 | |||
2054 | #if XFS_WANT_FUNCS_C || (XFS_WANT_SPACE_C && XFSSO_XFS_SB_VERSION_HASSHARED) | ||
2055 | int | ||
2056 | xfs_sb_version_hasshared(xfs_sb_t *sbp) | ||
2057 | { | ||
2058 | return XFS_SB_VERSION_HASSHARED(sbp); | ||
2059 | } | ||
2060 | #endif | ||
2061 | |||
2062 | #if XFS_WANT_FUNCS_C || (XFS_WANT_SPACE_C && XFSSO_XFS_SB_VERSION_NUM) | ||
2063 | int | ||
2064 | xfs_sb_version_num(xfs_sb_t *sbp) | ||
2065 | { | ||
2066 | return XFS_SB_VERSION_NUM(sbp); | ||
2067 | } | ||
2068 | #endif | ||
2069 | |||
2070 | #if XFS_WANT_FUNCS_C || (XFS_WANT_SPACE_C && XFSSO_XFS_SB_VERSION_SUBALIGN) | ||
2071 | void | ||
2072 | xfs_sb_version_subalign(xfs_sb_t *sbp) | ||
2073 | { | ||
2074 | XFS_SB_VERSION_SUBALIGN(sbp); | ||
2075 | } | ||
2076 | #endif | ||
2077 | |||
2078 | #if XFS_WANT_FUNCS_C || (XFS_WANT_SPACE_C && XFSSO_XFS_SB_VERSION_SUBSHARED) | ||
2079 | void | ||
2080 | xfs_sb_version_subshared(xfs_sb_t *sbp) | ||
2081 | { | ||
2082 | XFS_SB_VERSION_SUBSHARED(sbp); | ||
2083 | } | ||
2084 | #endif | ||
2085 | |||
2086 | #if XFS_WANT_FUNCS_C || (XFS_WANT_SPACE_C && XFSSO_XFS_SB_VERSION_HASLOGV2) | ||
2087 | int | ||
2088 | xfs_sb_version_haslogv2(xfs_sb_t *sbp) | ||
2089 | { | ||
2090 | return XFS_SB_VERSION_HASLOGV2(sbp); | ||
2091 | } | ||
2092 | #endif | ||
2093 | |||
2094 | #if XFS_WANT_FUNCS_C || (XFS_WANT_SPACE_C && XFSSO_XFS_SB_VERSION_HASSECTOR) | ||
2095 | int | ||
2096 | xfs_sb_version_hassector(xfs_sb_t *sbp) | ||
2097 | { | ||
2098 | return XFS_SB_VERSION_HASSECTOR(sbp); | ||
2099 | } | ||
2100 | #endif | ||
2101 | |||
2102 | #if XFS_WANT_FUNCS_C || (XFS_WANT_SPACE_C && XFSSO_XFS_SB_VERSION_TONEW) | ||
2103 | unsigned | ||
2104 | xfs_sb_version_tonew(unsigned v) | ||
2105 | { | ||
2106 | return XFS_SB_VERSION_TONEW(v); | ||
2107 | } | ||
2108 | #endif | ||
2109 | |||
2110 | #if XFS_WANT_FUNCS_C || (XFS_WANT_SPACE_C && XFSSO_XFS_SB_VERSION_TOOLD) | ||
2111 | unsigned | ||
2112 | xfs_sb_version_toold(unsigned v) | ||
2113 | { | ||
2114 | return XFS_SB_VERSION_TOOLD(v); | ||
2115 | } | ||
2116 | #endif | ||
2117 | |||
2118 | #if XFS_WANT_FUNCS_C || (XFS_WANT_SPACE_C && XFSSO_XLOG_GRANT_ADD_SPACE) | ||
2119 | void | ||
2120 | xlog_grant_add_space(xlog_t *log, int bytes, int type) | ||
2121 | { | ||
2122 | XLOG_GRANT_ADD_SPACE(log, bytes, type); | ||
2123 | } | ||
2124 | #endif | ||
2125 | |||
2126 | #if XFS_WANT_FUNCS_C || (XFS_WANT_SPACE_C && XFSSO_XLOG_GRANT_SUB_SPACE) | ||
2127 | void | ||
2128 | xlog_grant_sub_space(xlog_t *log, int bytes, int type) | ||
2129 | { | ||
2130 | XLOG_GRANT_SUB_SPACE(log, bytes, type); | ||
2131 | } | ||
2132 | #endif | ||
2133 | |||
2134 | #if XFS_WANT_FUNCS_C || (XFS_WANT_SPACE_C && XFSSO_XFS_SB_VERSION_HASMOREBITS) | ||
2135 | int | ||
2136 | xfs_sb_version_hasmorebits(xfs_sb_t *sbp) | ||
2137 | { | ||
2138 | return XFS_SB_VERSION_HASMOREBITS(sbp); | ||
2139 | } | ||
2140 | #endif | ||
2141 | |||
diff --git a/fs/xfs/xfs_macros.h b/fs/xfs/xfs_macros.h deleted file mode 100644 index 0a9307514a48..000000000000 --- a/fs/xfs/xfs_macros.h +++ /dev/null | |||
@@ -1,104 +0,0 @@ | |||
1 | /* | ||
2 | * Copyright (c) 2000 Silicon Graphics, Inc. All Rights Reserved. | ||
3 | * | ||
4 | * This program is free software; you can redistribute it and/or modify it | ||
5 | * under the terms of version 2 of the GNU General Public License as | ||
6 | * published by the Free Software Foundation. | ||
7 | * | ||
8 | * This program is distributed in the hope that it would be useful, but | ||
9 | * WITHOUT ANY WARRANTY; without even the implied warranty of | ||
10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | ||
11 | * | ||
12 | * Further, this software is distributed without any warranty that it is | ||
13 | * free of the rightful claim of any third person regarding infringement | ||
14 | * or the like. Any license provided herein, whether implied or | ||
15 | * otherwise, applies only to this software file. Patent licenses, if | ||
16 | * any, provided herein do not apply to combinations of this program with | ||
17 | * other software, or any other product whatsoever. | ||
18 | * | ||
19 | * You should have received a copy of the GNU General Public License along | ||
20 | * with this program; if not, write the Free Software Foundation, Inc., 59 | ||
21 | * Temple Place - Suite 330, Boston MA 02111-1307, USA. | ||
22 | * | ||
23 | * Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy, | ||
24 | * Mountain View, CA 94043, or: | ||
25 | * | ||
26 | * http://www.sgi.com | ||
27 | * | ||
28 | * For further information regarding this notice, see: | ||
29 | * | ||
30 | * http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/ | ||
31 | */ | ||
32 | #ifndef __XFS_MACROS_H__ | ||
33 | #define __XFS_MACROS_H__ | ||
34 | |||
35 | /* | ||
36 | * Set for debug kernels and simulation | ||
37 | * These replacements save space. | ||
38 | * Used in xfs_macros.c. | ||
39 | */ | ||
40 | #define XFS_WANT_SPACE_C \ | ||
41 | (!defined(_STANDALONE) && defined(DEBUG)) | ||
42 | |||
43 | /* | ||
44 | * Set for debug simulation and kernel builds, but not for standalone. | ||
45 | * These replacements do not save space. | ||
46 | * Used in xfs_macros.c. | ||
47 | */ | ||
48 | #define XFS_WANT_FUNCS_C \ | ||
49 | (!defined(_STANDALONE) && defined(DEBUG)) | ||
50 | |||
51 | /* | ||
52 | * Corresponding names used in .h files. | ||
53 | */ | ||
54 | #define XFS_WANT_SPACE (XFS_WANT_SPACE_C && !defined(XFS_MACRO_C)) | ||
55 | #define XFS_WANT_FUNCS (XFS_WANT_FUNCS_C && !defined(XFS_MACRO_C)) | ||
56 | |||
57 | /* | ||
58 | * These are the macros that get turned into functions to save space. | ||
59 | */ | ||
60 | #define XFSSO_NULLSTARTBLOCK 1 | ||
61 | #define XFSSO_XFS_AGB_TO_DADDR 1 | ||
62 | #define XFSSO_XFS_AGB_TO_FSB 1 | ||
63 | #define XFSSO_XFS_AGINO_TO_INO 1 | ||
64 | #define XFSSO_XFS_ALLOC_BLOCK_MINRECS 1 | ||
65 | #define XFSSO_XFS_ATTR_SF_NEXTENTRY 1 | ||
66 | #define XFSSO_XFS_BMAP_BLOCK_DMAXRECS 1 | ||
67 | #define XFSSO_XFS_BMAP_BLOCK_IMAXRECS 1 | ||
68 | #define XFSSO_XFS_BMAP_BLOCK_IMINRECS 1 | ||
69 | #define XFSSO_XFS_BMAP_INIT 1 | ||
70 | #define XFSSO_XFS_BMAP_PTR_IADDR 1 | ||
71 | #define XFSSO_XFS_BMAP_SANITY_CHECK 1 | ||
72 | #define XFSSO_XFS_BMAPI_AFLAG 1 | ||
73 | #define XFSSO_XFS_CFORK_SIZE 1 | ||
74 | #define XFSSO_XFS_DA_COOKIE_BNO 1 | ||
75 | #define XFSSO_XFS_DA_COOKIE_ENTRY 1 | ||
76 | #define XFSSO_XFS_DADDR_TO_AGBNO 1 | ||
77 | #define XFSSO_XFS_DADDR_TO_FSB 1 | ||
78 | #define XFSSO_XFS_DFORK_PTR 1 | ||
79 | #define XFSSO_XFS_DIR_SF_GET_DIRINO 1 | ||
80 | #define XFSSO_XFS_DIR_SF_NEXTENTRY 1 | ||
81 | #define XFSSO_XFS_DIR_SF_PUT_DIRINO 1 | ||
82 | #define XFSSO_XFS_FILBLKS_MIN 1 | ||
83 | #define XFSSO_XFS_FSB_SANITY_CHECK 1 | ||
84 | #define XFSSO_XFS_FSB_TO_DADDR 1 | ||
85 | #define XFSSO_XFS_FSB_TO_DB 1 | ||
86 | #define XFSSO_XFS_IALLOC_INODES 1 | ||
87 | #define XFSSO_XFS_IFORK_ASIZE 1 | ||
88 | #define XFSSO_XFS_IFORK_DSIZE 1 | ||
89 | #define XFSSO_XFS_IFORK_FORMAT 1 | ||
90 | #define XFSSO_XFS_IFORK_NEXT_SET 1 | ||
91 | #define XFSSO_XFS_IFORK_NEXTENTS 1 | ||
92 | #define XFSSO_XFS_IFORK_PTR 1 | ||
93 | #define XFSSO_XFS_ILOG_FBROOT 1 | ||
94 | #define XFSSO_XFS_ILOG_FEXT 1 | ||
95 | #define XFSSO_XFS_INO_MASK 1 | ||
96 | #define XFSSO_XFS_INO_TO_FSB 1 | ||
97 | #define XFSSO_XFS_INODE_CLEAR_READ_AHEAD 1 | ||
98 | #define XFSSO_XFS_MIN_FREELIST 1 | ||
99 | #define XFSSO_XFS_SB_GOOD_VERSION 1 | ||
100 | #define XFSSO_XFS_SB_VERSION_HASNLINK 1 | ||
101 | #define XFSSO_XLOG_GRANT_ADD_SPACE 1 | ||
102 | #define XFSSO_XLOG_GRANT_SUB_SPACE 1 | ||
103 | |||
104 | #endif /* __XFS_MACROS_H__ */ | ||
diff --git a/fs/xfs/xfs_mount.c b/fs/xfs/xfs_mount.c index 82e1646e6243..541d5dd474be 100644 --- a/fs/xfs/xfs_mount.c +++ b/fs/xfs/xfs_mount.c | |||
@@ -1,40 +1,26 @@ | |||
1 | /* | 1 | /* |
2 | * Copyright (c) 2000-2004 Silicon Graphics, Inc. All Rights Reserved. | 2 | * Copyright (c) 2000-2005 Silicon Graphics, Inc. |
3 | * All Rights Reserved. | ||
3 | * | 4 | * |
4 | * This program is free software; you can redistribute it and/or modify it | 5 | * This program is free software; you can redistribute it and/or |
5 | * under the terms of version 2 of the GNU General Public License as | 6 | * modify it under the terms of the GNU General Public License as |
6 | * published by the Free Software Foundation. | 7 | * published by the Free Software Foundation. |
7 | * | 8 | * |
8 | * This program is distributed in the hope that it would be useful, but | 9 | * This program is distributed in the hope that it would be useful, |
9 | * WITHOUT ANY WARRANTY; without even the implied warranty of | 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
12 | * GNU General Public License for more details. | ||
11 | * | 13 | * |
12 | * Further, this software is distributed without any warranty that it is | 14 | * You should have received a copy of the GNU General Public License |
13 | * free of the rightful claim of any third person regarding infringement | 15 | * along with this program; if not, write the Free Software Foundation, |
14 | * or the like. Any license provided herein, whether implied or | 16 | * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
15 | * otherwise, applies only to this software file. Patent licenses, if | ||
16 | * any, provided herein do not apply to combinations of this program with | ||
17 | * other software, or any other product whatsoever. | ||
18 | * | ||
19 | * You should have received a copy of the GNU General Public License along | ||
20 | * with this program; if not, write the Free Software Foundation, Inc., 59 | ||
21 | * Temple Place - Suite 330, Boston MA 02111-1307, USA. | ||
22 | * | ||
23 | * Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy, | ||
24 | * Mountain View, CA 94043, or: | ||
25 | * | ||
26 | * http://www.sgi.com | ||
27 | * | ||
28 | * For further information regarding this notice, see: | ||
29 | * | ||
30 | * http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/ | ||
31 | */ | 17 | */ |
32 | |||
33 | #include "xfs.h" | 18 | #include "xfs.h" |
34 | #include "xfs_macros.h" | 19 | #include "xfs_fs.h" |
35 | #include "xfs_types.h" | 20 | #include "xfs_types.h" |
36 | #include "xfs_inum.h" | 21 | #include "xfs_bit.h" |
37 | #include "xfs_log.h" | 22 | #include "xfs_log.h" |
23 | #include "xfs_inum.h" | ||
38 | #include "xfs_trans.h" | 24 | #include "xfs_trans.h" |
39 | #include "xfs_sb.h" | 25 | #include "xfs_sb.h" |
40 | #include "xfs_ag.h" | 26 | #include "xfs_ag.h" |
@@ -42,21 +28,20 @@ | |||
42 | #include "xfs_dir2.h" | 28 | #include "xfs_dir2.h" |
43 | #include "xfs_dmapi.h" | 29 | #include "xfs_dmapi.h" |
44 | #include "xfs_mount.h" | 30 | #include "xfs_mount.h" |
45 | #include "xfs_alloc_btree.h" | ||
46 | #include "xfs_bmap_btree.h" | 31 | #include "xfs_bmap_btree.h" |
32 | #include "xfs_alloc_btree.h" | ||
47 | #include "xfs_ialloc_btree.h" | 33 | #include "xfs_ialloc_btree.h" |
48 | #include "xfs_btree.h" | ||
49 | #include "xfs_ialloc.h" | ||
50 | #include "xfs_attr_sf.h" | ||
51 | #include "xfs_dir_sf.h" | 34 | #include "xfs_dir_sf.h" |
52 | #include "xfs_dir2_sf.h" | 35 | #include "xfs_dir2_sf.h" |
36 | #include "xfs_attr_sf.h" | ||
53 | #include "xfs_dinode.h" | 37 | #include "xfs_dinode.h" |
54 | #include "xfs_inode.h" | 38 | #include "xfs_inode.h" |
39 | #include "xfs_btree.h" | ||
40 | #include "xfs_ialloc.h" | ||
55 | #include "xfs_alloc.h" | 41 | #include "xfs_alloc.h" |
56 | #include "xfs_rtalloc.h" | 42 | #include "xfs_rtalloc.h" |
57 | #include "xfs_bmap.h" | 43 | #include "xfs_bmap.h" |
58 | #include "xfs_error.h" | 44 | #include "xfs_error.h" |
59 | #include "xfs_bit.h" | ||
60 | #include "xfs_rw.h" | 45 | #include "xfs_rw.h" |
61 | #include "xfs_quota.h" | 46 | #include "xfs_quota.h" |
62 | #include "xfs_fsops.h" | 47 | #include "xfs_fsops.h" |
@@ -180,6 +165,10 @@ xfs_mount_free( | |||
180 | 165 | ||
181 | if (mp->m_fsname != NULL) | 166 | if (mp->m_fsname != NULL) |
182 | kmem_free(mp->m_fsname, mp->m_fsname_len); | 167 | kmem_free(mp->m_fsname, mp->m_fsname_len); |
168 | if (mp->m_rtname != NULL) | ||
169 | kmem_free(mp->m_rtname, strlen(mp->m_rtname) + 1); | ||
170 | if (mp->m_logname != NULL) | ||
171 | kmem_free(mp->m_logname, strlen(mp->m_logname) + 1); | ||
183 | 172 | ||
184 | if (remove_bhv) { | 173 | if (remove_bhv) { |
185 | struct vfs *vfsp = XFS_MTOVFS(mp); | 174 | struct vfs *vfsp = XFS_MTOVFS(mp); |
@@ -318,7 +307,7 @@ xfs_mount_validate_sb( | |||
318 | "XFS: Attempted to mount file system with blocksize %d bytes", | 307 | "XFS: Attempted to mount file system with blocksize %d bytes", |
319 | sbp->sb_blocksize); | 308 | sbp->sb_blocksize); |
320 | cmn_err(CE_WARN, | 309 | cmn_err(CE_WARN, |
321 | "XFS: Only page-sized (%d) or less blocksizes currently work.", | 310 | "XFS: Only page-sized (%ld) or less blocksizes currently work.", |
322 | PAGE_SIZE); | 311 | PAGE_SIZE); |
323 | return XFS_ERROR(ENOSYS); | 312 | return XFS_ERROR(ENOSYS); |
324 | } | 313 | } |
@@ -327,7 +316,10 @@ xfs_mount_validate_sb( | |||
327 | } | 316 | } |
328 | 317 | ||
329 | xfs_agnumber_t | 318 | xfs_agnumber_t |
330 | xfs_initialize_perag(xfs_mount_t *mp, xfs_agnumber_t agcount) | 319 | xfs_initialize_perag( |
320 | struct vfs *vfs, | ||
321 | xfs_mount_t *mp, | ||
322 | xfs_agnumber_t agcount) | ||
331 | { | 323 | { |
332 | xfs_agnumber_t index, max_metadata; | 324 | xfs_agnumber_t index, max_metadata; |
333 | xfs_perag_t *pag; | 325 | xfs_perag_t *pag; |
@@ -343,7 +335,7 @@ xfs_initialize_perag(xfs_mount_t *mp, xfs_agnumber_t agcount) | |||
343 | /* Clear the mount flag if no inode can overflow 32 bits | 335 | /* Clear the mount flag if no inode can overflow 32 bits |
344 | * on this filesystem, or if specifically requested.. | 336 | * on this filesystem, or if specifically requested.. |
345 | */ | 337 | */ |
346 | if ((mp->m_flags & XFS_MOUNT_32BITINOOPT) && ino > max_inum) { | 338 | if ((vfs->vfs_flag & VFS_32BITINODES) && ino > max_inum) { |
347 | mp->m_flags |= XFS_MOUNT_32BITINODES; | 339 | mp->m_flags |= XFS_MOUNT_32BITINODES; |
348 | } else { | 340 | } else { |
349 | mp->m_flags &= ~XFS_MOUNT_32BITINODES; | 341 | mp->m_flags &= ~XFS_MOUNT_32BITINODES; |
@@ -360,7 +352,7 @@ xfs_initialize_perag(xfs_mount_t *mp, xfs_agnumber_t agcount) | |||
360 | icount = sbp->sb_dblocks * sbp->sb_imax_pct; | 352 | icount = sbp->sb_dblocks * sbp->sb_imax_pct; |
361 | do_div(icount, 100); | 353 | do_div(icount, 100); |
362 | icount += sbp->sb_agblocks - 1; | 354 | icount += sbp->sb_agblocks - 1; |
363 | do_div(icount, mp->m_ialloc_blks); | 355 | do_div(icount, sbp->sb_agblocks); |
364 | max_metadata = icount; | 356 | max_metadata = icount; |
365 | } else { | 357 | } else { |
366 | max_metadata = agcount; | 358 | max_metadata = agcount; |
@@ -584,12 +576,13 @@ xfs_mount_common(xfs_mount_t *mp, xfs_sb_t *sbp) | |||
584 | ASSERT(sbp->sb_inodesize >= 256 && sbp->sb_inodesize <= 2048); | 576 | ASSERT(sbp->sb_inodesize >= 256 && sbp->sb_inodesize <= 2048); |
585 | switch (sbp->sb_inodesize) { | 577 | switch (sbp->sb_inodesize) { |
586 | case 256: | 578 | case 256: |
587 | mp->m_attroffset = XFS_LITINO(mp) - XFS_BMDR_SPACE_CALC(2); | 579 | mp->m_attroffset = XFS_LITINO(mp) - |
580 | XFS_BMDR_SPACE_CALC(MINABTPTRS); | ||
588 | break; | 581 | break; |
589 | case 512: | 582 | case 512: |
590 | case 1024: | 583 | case 1024: |
591 | case 2048: | 584 | case 2048: |
592 | mp->m_attroffset = XFS_BMDR_SPACE_CALC(12); | 585 | mp->m_attroffset = XFS_BMDR_SPACE_CALC(6 * MINABTPTRS); |
593 | break; | 586 | break; |
594 | default: | 587 | default: |
595 | ASSERT(0); | 588 | ASSERT(0); |
@@ -954,7 +947,7 @@ xfs_mountfs( | |||
954 | mp->m_perag = | 947 | mp->m_perag = |
955 | kmem_zalloc(sbp->sb_agcount * sizeof(xfs_perag_t), KM_SLEEP); | 948 | kmem_zalloc(sbp->sb_agcount * sizeof(xfs_perag_t), KM_SLEEP); |
956 | 949 | ||
957 | mp->m_maxagi = xfs_initialize_perag(mp, sbp->sb_agcount); | 950 | mp->m_maxagi = xfs_initialize_perag(vfsp, mp, sbp->sb_agcount); |
958 | 951 | ||
959 | /* | 952 | /* |
960 | * log's mount-time initialization. Perform 1st part recovery if needed | 953 | * log's mount-time initialization. Perform 1st part recovery if needed |
diff --git a/fs/xfs/xfs_mount.h b/fs/xfs/xfs_mount.h index 5affba38a577..08b2e0a5d807 100644 --- a/fs/xfs/xfs_mount.h +++ b/fs/xfs/xfs_mount.h | |||
@@ -1,38 +1,23 @@ | |||
1 | /* | 1 | /* |
2 | * Copyright (c) 2000-2005 Silicon Graphics, Inc. All Rights Reserved. | 2 | * Copyright (c) 2000-2005 Silicon Graphics, Inc. |
3 | * All Rights Reserved. | ||
3 | * | 4 | * |
4 | * This program is free software; you can redistribute it and/or modify it | 5 | * This program is free software; you can redistribute it and/or |
5 | * under the terms of version 2 of the GNU General Public License as | 6 | * modify it under the terms of the GNU General Public License as |
6 | * published by the Free Software Foundation. | 7 | * published by the Free Software Foundation. |
7 | * | 8 | * |
8 | * This program is distributed in the hope that it would be useful, but | 9 | * This program is distributed in the hope that it would be useful, |
9 | * WITHOUT ANY WARRANTY; without even the implied warranty of | 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
12 | * GNU General Public License for more details. | ||
11 | * | 13 | * |
12 | * Further, this software is distributed without any warranty that it is | 14 | * You should have received a copy of the GNU General Public License |
13 | * free of the rightful claim of any third person regarding infringement | 15 | * along with this program; if not, write the Free Software Foundation, |
14 | * or the like. Any license provided herein, whether implied or | 16 | * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
15 | * otherwise, applies only to this software file. Patent licenses, if | ||
16 | * any, provided herein do not apply to combinations of this program with | ||
17 | * other software, or any other product whatsoever. | ||
18 | * | ||
19 | * You should have received a copy of the GNU General Public License along | ||
20 | * with this program; if not, write the Free Software Foundation, Inc., 59 | ||
21 | * Temple Place - Suite 330, Boston MA 02111-1307, USA. | ||
22 | * | ||
23 | * Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy, | ||
24 | * Mountain View, CA 94043, or: | ||
25 | * | ||
26 | * http://www.sgi.com | ||
27 | * | ||
28 | * For further information regarding this notice, see: | ||
29 | * | ||
30 | * http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/ | ||
31 | */ | 17 | */ |
32 | #ifndef __XFS_MOUNT_H__ | 18 | #ifndef __XFS_MOUNT_H__ |
33 | #define __XFS_MOUNT_H__ | 19 | #define __XFS_MOUNT_H__ |
34 | 20 | ||
35 | |||
36 | typedef struct xfs_trans_reservations { | 21 | typedef struct xfs_trans_reservations { |
37 | uint tr_write; /* extent alloc trans */ | 22 | uint tr_write; /* extent alloc trans */ |
38 | uint tr_itruncate; /* truncate trans */ | 23 | uint tr_itruncate; /* truncate trans */ |
@@ -57,7 +42,6 @@ typedef struct xfs_trans_reservations { | |||
57 | uint tr_growrtfree; /* grow realtime freeing */ | 42 | uint tr_growrtfree; /* grow realtime freeing */ |
58 | } xfs_trans_reservations_t; | 43 | } xfs_trans_reservations_t; |
59 | 44 | ||
60 | |||
61 | #ifndef __KERNEL__ | 45 | #ifndef __KERNEL__ |
62 | /* | 46 | /* |
63 | * Moved here from xfs_ag.h to avoid reordering header files | 47 | * Moved here from xfs_ag.h to avoid reordering header files |
@@ -80,6 +64,9 @@ struct xfs_iocore; | |||
80 | struct xfs_bmbt_irec; | 64 | struct xfs_bmbt_irec; |
81 | struct xfs_bmap_free; | 65 | struct xfs_bmap_free; |
82 | 66 | ||
67 | extern struct vfsops xfs_vfsops; | ||
68 | extern struct vnodeops xfs_vnodeops; | ||
69 | |||
83 | #define AIL_LOCK_T lock_t | 70 | #define AIL_LOCK_T lock_t |
84 | #define AIL_LOCKINIT(x,y) spinlock_init(x,y) | 71 | #define AIL_LOCKINIT(x,y) spinlock_init(x,y) |
85 | #define AIL_LOCK_DESTROY(x) spinlock_destroy(x) | 72 | #define AIL_LOCK_DESTROY(x) spinlock_destroy(x) |
@@ -292,6 +279,8 @@ typedef struct xfs_mount { | |||
292 | struct xfs_buf *m_sb_bp; /* buffer for superblock */ | 279 | struct xfs_buf *m_sb_bp; /* buffer for superblock */ |
293 | char *m_fsname; /* filesystem name */ | 280 | char *m_fsname; /* filesystem name */ |
294 | int m_fsname_len; /* strlen of fs name */ | 281 | int m_fsname_len; /* strlen of fs name */ |
282 | char *m_rtname; /* realtime device name */ | ||
283 | char *m_logname; /* external log device name */ | ||
295 | int m_bsize; /* fs logical block size */ | 284 | int m_bsize; /* fs logical block size */ |
296 | xfs_agnumber_t m_agfrotor; /* last ag where space found */ | 285 | xfs_agnumber_t m_agfrotor; /* last ag where space found */ |
297 | xfs_agnumber_t m_agirotor; /* last ag dir inode alloced */ | 286 | xfs_agnumber_t m_agirotor; /* last ag dir inode alloced */ |
@@ -344,7 +333,7 @@ typedef struct xfs_mount { | |||
344 | sema_t m_growlock; /* growfs mutex */ | 333 | sema_t m_growlock; /* growfs mutex */ |
345 | int m_fixedfsid[2]; /* unchanged for life of FS */ | 334 | int m_fixedfsid[2]; /* unchanged for life of FS */ |
346 | uint m_dmevmask; /* DMI events for this FS */ | 335 | uint m_dmevmask; /* DMI events for this FS */ |
347 | uint m_flags; /* global mount flags */ | 336 | __uint64_t m_flags; /* global mount flags */ |
348 | uint m_attroffset; /* inode attribute offset */ | 337 | uint m_attroffset; /* inode attribute offset */ |
349 | uint m_dir_node_ents; /* #entries in a dir danode */ | 338 | uint m_dir_node_ents; /* #entries in a dir danode */ |
350 | uint m_attr_node_ents; /* #entries in attr danode */ | 339 | uint m_attr_node_ents; /* #entries in attr danode */ |
@@ -389,38 +378,41 @@ typedef struct xfs_mount { | |||
389 | /* | 378 | /* |
390 | * Flags for m_flags. | 379 | * Flags for m_flags. |
391 | */ | 380 | */ |
392 | #define XFS_MOUNT_WSYNC 0x00000001 /* for nfs - all metadata ops | 381 | #define XFS_MOUNT_WSYNC (1ULL << 0) /* for nfs - all metadata ops |
393 | must be synchronous except | 382 | must be synchronous except |
394 | for space allocations */ | 383 | for space allocations */ |
395 | #define XFS_MOUNT_INO64 0x00000002 | 384 | #define XFS_MOUNT_INO64 (1ULL << 1) |
396 | /* 0x00000004 -- currently unused */ | 385 | /* (1ULL << 2) -- currently unused */ |
397 | /* 0x00000008 -- currently unused */ | 386 | /* (1ULL << 3) -- currently unused */ |
398 | #define XFS_MOUNT_FS_SHUTDOWN 0x00000010 /* atomic stop of all filesystem | 387 | #define XFS_MOUNT_FS_SHUTDOWN (1ULL << 4) /* atomic stop of all filesystem |
399 | operations, typically for | 388 | operations, typically for |
400 | disk errors in metadata */ | 389 | disk errors in metadata */ |
401 | #define XFS_MOUNT_NOATIME 0x00000020 /* don't modify inode access | 390 | #define XFS_MOUNT_NOATIME (1ULL << 5) /* don't modify inode access |
402 | times on reads */ | 391 | times on reads */ |
403 | #define XFS_MOUNT_RETERR 0x00000040 /* return alignment errors to | 392 | #define XFS_MOUNT_RETERR (1ULL << 6) /* return alignment errors to |
404 | user */ | 393 | user */ |
405 | #define XFS_MOUNT_NOALIGN 0x00000080 /* turn off stripe alignment | 394 | #define XFS_MOUNT_NOALIGN (1ULL << 7) /* turn off stripe alignment |
406 | allocations */ | 395 | allocations */ |
407 | /* 0x00000100 -- currently unused */ | 396 | #define XFS_MOUNT_COMPAT_ATTR (1ULL << 8) /* do not use attr2 format */ |
408 | /* 0x00000200 -- currently unused */ | 397 | /* (1ULL << 9) -- currently unused */ |
409 | #define XFS_MOUNT_NORECOVERY 0x00000400 /* no recovery - dirty fs */ | 398 | #define XFS_MOUNT_NORECOVERY (1ULL << 10) /* no recovery - dirty fs */ |
410 | #define XFS_MOUNT_SHARED 0x00000800 /* shared mount */ | 399 | #define XFS_MOUNT_SHARED (1ULL << 11) /* shared mount */ |
411 | #define XFS_MOUNT_DFLT_IOSIZE 0x00001000 /* set default i/o size */ | 400 | #define XFS_MOUNT_DFLT_IOSIZE (1ULL << 12) /* set default i/o size */ |
412 | #define XFS_MOUNT_OSYNCISOSYNC 0x00002000 /* o_sync is REALLY o_sync */ | 401 | #define XFS_MOUNT_OSYNCISOSYNC (1ULL << 13) /* o_sync is REALLY o_sync */ |
413 | /* osyncisdsync is now default*/ | 402 | /* osyncisdsync is now default*/ |
414 | #define XFS_MOUNT_32BITINODES 0x00004000 /* do not create inodes above | 403 | #define XFS_MOUNT_32BITINODES (1ULL << 14) /* do not create inodes above |
415 | * 32 bits in size */ | 404 | * 32 bits in size */ |
416 | #define XFS_MOUNT_32BITINOOPT 0x00008000 /* saved mount option state */ | 405 | /* (1ULL << 15) -- currently unused */ |
417 | #define XFS_MOUNT_NOUUID 0x00010000 /* ignore uuid during mount */ | 406 | #define XFS_MOUNT_NOUUID (1ULL << 16) /* ignore uuid during mount */ |
418 | #define XFS_MOUNT_NOLOGFLUSH 0x00020000 | 407 | #define XFS_MOUNT_BARRIER (1ULL << 17) |
419 | #define XFS_MOUNT_IDELETE 0x00040000 /* delete empty inode clusters*/ | 408 | #define XFS_MOUNT_IDELETE (1ULL << 18) /* delete empty inode clusters*/ |
420 | #define XFS_MOUNT_SWALLOC 0x00080000 /* turn on stripe width | 409 | #define XFS_MOUNT_SWALLOC (1ULL << 19) /* turn on stripe width |
421 | * allocation */ | 410 | * allocation */ |
422 | #define XFS_MOUNT_IHASHSIZE 0x00100000 /* inode hash table size */ | 411 | #define XFS_MOUNT_IHASHSIZE (1ULL << 20) /* inode hash table size */ |
423 | #define XFS_MOUNT_DIRSYNC 0x00200000 /* synchronous directory ops */ | 412 | #define XFS_MOUNT_DIRSYNC (1ULL << 21) /* synchronous directory ops */ |
413 | #define XFS_MOUNT_COMPAT_IOSIZE (1ULL << 22) /* don't report large preferred | ||
414 | * I/O size in stat() */ | ||
415 | |||
424 | 416 | ||
425 | /* | 417 | /* |
426 | * Default minimum read and write sizes. | 418 | * Default minimum read and write sizes. |
@@ -442,6 +434,30 @@ typedef struct xfs_mount { | |||
442 | #define XFS_WSYNC_READIO_LOG 15 /* 32K */ | 434 | #define XFS_WSYNC_READIO_LOG 15 /* 32K */ |
443 | #define XFS_WSYNC_WRITEIO_LOG 14 /* 16K */ | 435 | #define XFS_WSYNC_WRITEIO_LOG 14 /* 16K */ |
444 | 436 | ||
437 | /* | ||
438 | * Allow large block sizes to be reported to userspace programs if the | ||
439 | * "largeio" mount option is used. | ||
440 | * | ||
441 | * If compatibility mode is specified, simply return the basic unit of caching | ||
442 | * so that we don't get inefficient read/modify/write I/O from user apps. | ||
443 | * Otherwise.... | ||
444 | * | ||
445 | * If the underlying volume is a stripe, then return the stripe width in bytes | ||
446 | * as the recommended I/O size. It is not a stripe and we've set a default | ||
447 | * buffered I/O size, return that, otherwise return the compat default. | ||
448 | */ | ||
449 | static inline unsigned long | ||
450 | xfs_preferred_iosize(xfs_mount_t *mp) | ||
451 | { | ||
452 | if (mp->m_flags & XFS_MOUNT_COMPAT_IOSIZE) | ||
453 | return PAGE_CACHE_SIZE; | ||
454 | return (mp->m_swidth ? | ||
455 | (mp->m_swidth << mp->m_sb.sb_blocklog) : | ||
456 | ((mp->m_flags & XFS_MOUNT_DFLT_IOSIZE) ? | ||
457 | (1 << (int)MAX(mp->m_readio_log, mp->m_writeio_log)) : | ||
458 | PAGE_CACHE_SIZE)); | ||
459 | } | ||
460 | |||
445 | #define XFS_MAXIOFFSET(mp) ((mp)->m_maxioffset) | 461 | #define XFS_MAXIOFFSET(mp) ((mp)->m_maxioffset) |
446 | 462 | ||
447 | #define XFS_FORCED_SHUTDOWN(mp) ((mp)->m_flags & XFS_MOUNT_FS_SHUTDOWN) | 463 | #define XFS_FORCED_SHUTDOWN(mp) ((mp)->m_flags & XFS_MOUNT_FS_SHUTDOWN) |
@@ -474,57 +490,41 @@ typedef struct xfs_mount { | |||
474 | /* | 490 | /* |
475 | * Macros for getting from mount to vfs and back. | 491 | * Macros for getting from mount to vfs and back. |
476 | */ | 492 | */ |
477 | #if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_MTOVFS) | ||
478 | struct vfs *xfs_mtovfs(xfs_mount_t *mp); | ||
479 | #define XFS_MTOVFS(mp) xfs_mtovfs(mp) | 493 | #define XFS_MTOVFS(mp) xfs_mtovfs(mp) |
480 | #else | 494 | static inline struct vfs *xfs_mtovfs(xfs_mount_t *mp) |
481 | #define XFS_MTOVFS(mp) (bhvtovfs(&(mp)->m_bhv)) | 495 | { |
482 | #endif | 496 | return bhvtovfs(&mp->m_bhv); |
483 | #if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_BHVTOM) | 497 | } |
484 | xfs_mount_t *xfs_bhvtom(bhv_desc_t *bdp); | ||
485 | #define XFS_BHVTOM(bdp) xfs_bhvtom(bdp) | ||
486 | #else | ||
487 | #define XFS_BHVTOM(bdp) ((xfs_mount_t *)BHV_PDATA(bdp)) | ||
488 | #endif | ||
489 | #if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_VFSTOM) | ||
490 | xfs_mount_t *xfs_vfstom(vfs_t *vfs); | ||
491 | #define XFS_VFSTOM(vfs) xfs_vfstom(vfs) | ||
492 | #else | ||
493 | #define XFS_VFSTOM(vfs) \ | ||
494 | (XFS_BHVTOM(bhv_lookup(VFS_BHVHEAD(vfs), &xfs_vfsops))) | ||
495 | #endif | ||
496 | 498 | ||
499 | #define XFS_BHVTOM(bdp) xfs_bhvtom(bdp) | ||
500 | static inline xfs_mount_t *xfs_bhvtom(bhv_desc_t *bdp) | ||
501 | { | ||
502 | return (xfs_mount_t *)BHV_PDATA(bdp); | ||
503 | } | ||
497 | 504 | ||
498 | /* | 505 | #define XFS_VFSTOM(vfs) xfs_vfstom(vfs) |
499 | * Moved here from xfs_ag.h to avoid reordering header files | 506 | static inline xfs_mount_t *xfs_vfstom(vfs_t *vfs) |
500 | */ | 507 | { |
508 | return XFS_BHVTOM(bhv_lookup(VFS_BHVHEAD(vfs), &xfs_vfsops)); | ||
509 | } | ||
501 | 510 | ||
502 | #if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_DADDR_TO_AGNO) | ||
503 | xfs_agnumber_t xfs_daddr_to_agno(struct xfs_mount *mp, xfs_daddr_t d); | ||
504 | #define XFS_DADDR_TO_AGNO(mp,d) xfs_daddr_to_agno(mp,d) | 511 | #define XFS_DADDR_TO_AGNO(mp,d) xfs_daddr_to_agno(mp,d) |
505 | #else | 512 | static inline xfs_agnumber_t |
506 | 513 | xfs_daddr_to_agno(struct xfs_mount *mp, xfs_daddr_t d) | |
507 | static inline xfs_agnumber_t XFS_DADDR_TO_AGNO(xfs_mount_t *mp, xfs_daddr_t d) | ||
508 | { | 514 | { |
509 | d = XFS_BB_TO_FSBT(mp, d); | 515 | xfs_daddr_t ld = XFS_BB_TO_FSBT(mp, d); |
510 | do_div(d, mp->m_sb.sb_agblocks); | 516 | do_div(ld, mp->m_sb.sb_agblocks); |
511 | return (xfs_agnumber_t) d; | 517 | return (xfs_agnumber_t) ld; |
512 | } | 518 | } |
513 | 519 | ||
514 | #endif | ||
515 | #if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_DADDR_TO_AGBNO) | ||
516 | xfs_agblock_t xfs_daddr_to_agbno(struct xfs_mount *mp, xfs_daddr_t d); | ||
517 | #define XFS_DADDR_TO_AGBNO(mp,d) xfs_daddr_to_agbno(mp,d) | 520 | #define XFS_DADDR_TO_AGBNO(mp,d) xfs_daddr_to_agbno(mp,d) |
518 | #else | 521 | static inline xfs_agblock_t |
519 | 522 | xfs_daddr_to_agbno(struct xfs_mount *mp, xfs_daddr_t d) | |
520 | static inline xfs_agblock_t XFS_DADDR_TO_AGBNO(xfs_mount_t *mp, xfs_daddr_t d) | ||
521 | { | 523 | { |
522 | d = XFS_BB_TO_FSBT(mp, d); | 524 | xfs_daddr_t ld = XFS_BB_TO_FSBT(mp, d); |
523 | return (xfs_agblock_t) do_div(d, mp->m_sb.sb_agblocks); | 525 | return (xfs_agblock_t) do_div(ld, mp->m_sb.sb_agblocks); |
524 | } | 526 | } |
525 | 527 | ||
526 | #endif | ||
527 | |||
528 | /* | 528 | /* |
529 | * This structure is for use by the xfs_mod_incore_sb_batch() routine. | 529 | * This structure is for use by the xfs_mod_incore_sb_batch() routine. |
530 | */ | 530 | */ |
@@ -542,6 +542,7 @@ extern xfs_mount_t *xfs_mount_init(void); | |||
542 | extern void xfs_mod_sb(xfs_trans_t *, __int64_t); | 542 | extern void xfs_mod_sb(xfs_trans_t *, __int64_t); |
543 | extern void xfs_mount_free(xfs_mount_t *mp, int remove_bhv); | 543 | extern void xfs_mount_free(xfs_mount_t *mp, int remove_bhv); |
544 | extern int xfs_mountfs(struct vfs *, xfs_mount_t *mp, int); | 544 | extern int xfs_mountfs(struct vfs *, xfs_mount_t *mp, int); |
545 | extern void xfs_mountfs_check_barriers(xfs_mount_t *mp); | ||
545 | 546 | ||
546 | extern int xfs_unmountfs(xfs_mount_t *, struct cred *); | 547 | extern int xfs_unmountfs(xfs_mount_t *, struct cred *); |
547 | extern void xfs_unmountfs_close(xfs_mount_t *, struct cred *); | 548 | extern void xfs_unmountfs_close(xfs_mount_t *, struct cred *); |
@@ -555,12 +556,11 @@ extern int xfs_readsb(xfs_mount_t *mp); | |||
555 | extern void xfs_freesb(xfs_mount_t *); | 556 | extern void xfs_freesb(xfs_mount_t *); |
556 | extern void xfs_do_force_shutdown(bhv_desc_t *, int, char *, int); | 557 | extern void xfs_do_force_shutdown(bhv_desc_t *, int, char *, int); |
557 | extern int xfs_syncsub(xfs_mount_t *, int, int, int *); | 558 | extern int xfs_syncsub(xfs_mount_t *, int, int, int *); |
558 | extern xfs_agnumber_t xfs_initialize_perag(xfs_mount_t *, xfs_agnumber_t); | 559 | extern int xfs_sync_inodes(xfs_mount_t *, int, int, int *); |
560 | extern xfs_agnumber_t xfs_initialize_perag(struct vfs *, xfs_mount_t *, | ||
561 | xfs_agnumber_t); | ||
559 | extern void xfs_xlatesb(void *, struct xfs_sb *, int, __int64_t); | 562 | extern void xfs_xlatesb(void *, struct xfs_sb *, int, __int64_t); |
560 | 563 | ||
561 | extern struct vfsops xfs_vfsops; | ||
562 | extern struct vnodeops xfs_vnodeops; | ||
563 | |||
564 | extern struct xfs_dmops xfs_dmcore_stub; | 564 | extern struct xfs_dmops xfs_dmcore_stub; |
565 | extern struct xfs_qmops xfs_qmcore_stub; | 565 | extern struct xfs_qmops xfs_qmcore_stub; |
566 | extern struct xfs_ioops xfs_iocore_xfs; | 566 | extern struct xfs_ioops xfs_iocore_xfs; |
diff --git a/fs/xfs/xfs_qmops.c b/fs/xfs/xfs_qmops.c index a6cd6324e946..1408a32eef88 100644 --- a/fs/xfs/xfs_qmops.c +++ b/fs/xfs/xfs_qmops.c | |||
@@ -1,40 +1,25 @@ | |||
1 | /* | 1 | /* |
2 | * Copyright (c) 2000-2005 Silicon Graphics, Inc. All Rights Reserved. | 2 | * Copyright (c) 2000-2005 Silicon Graphics, Inc. |
3 | * All Rights Reserved. | ||
3 | * | 4 | * |
4 | * This program is free software; you can redistribute it and/or modify it | 5 | * This program is free software; you can redistribute it and/or |
5 | * under the terms of version 2 of the GNU General Public License as | 6 | * modify it under the terms of the GNU General Public License as |
6 | * published by the Free Software Foundation. | 7 | * published by the Free Software Foundation. |
7 | * | 8 | * |
8 | * This program is distributed in the hope that it would be useful, but | 9 | * This program is distributed in the hope that it would be useful, |
9 | * WITHOUT ANY WARRANTY; without even the implied warranty of | 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
12 | * GNU General Public License for more details. | ||
11 | * | 13 | * |
12 | * Further, this software is distributed without any warranty that it is | 14 | * You should have received a copy of the GNU General Public License |
13 | * free of the rightful claim of any third person regarding infringement | 15 | * along with this program; if not, write the Free Software Foundation, |
14 | * or the like. Any license provided herein, whether implied or | 16 | * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
15 | * otherwise, applies only to this software file. Patent licenses, if | ||
16 | * any, provided herein do not apply to combinations of this program with | ||
17 | * other software, or any other product whatsoever. | ||
18 | * | ||
19 | * You should have received a copy of the GNU General Public License along | ||
20 | * with this program; if not, write the Free Software Foundation, Inc., 59 | ||
21 | * Temple Place - Suite 330, Boston MA 02111-1307, USA. | ||
22 | * | ||
23 | * Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy, | ||
24 | * Mountain View, CA 94043, or: | ||
25 | * | ||
26 | * http://www.sgi.com | ||
27 | * | ||
28 | * For further information regarding this notice, see: | ||
29 | * | ||
30 | * http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/ | ||
31 | */ | 17 | */ |
32 | #include "xfs.h" | 18 | #include "xfs.h" |
33 | 19 | #include "xfs_fs.h" | |
34 | #include "xfs_macros.h" | ||
35 | #include "xfs_types.h" | 20 | #include "xfs_types.h" |
36 | #include "xfs_inum.h" | ||
37 | #include "xfs_log.h" | 21 | #include "xfs_log.h" |
22 | #include "xfs_inum.h" | ||
38 | #include "xfs_trans.h" | 23 | #include "xfs_trans.h" |
39 | #include "xfs_sb.h" | 24 | #include "xfs_sb.h" |
40 | #include "xfs_ag.h" | 25 | #include "xfs_ag.h" |
diff --git a/fs/xfs/xfs_quota.h b/fs/xfs/xfs_quota.h index 32cb79752d5d..82a08baf437b 100644 --- a/fs/xfs/xfs_quota.h +++ b/fs/xfs/xfs_quota.h | |||
@@ -1,33 +1,19 @@ | |||
1 | /* | 1 | /* |
2 | * Copyright (c) 2000-2005 Silicon Graphics, Inc. All Rights Reserved. | 2 | * Copyright (c) 2000-2005 Silicon Graphics, Inc. |
3 | * All Rights Reserved. | ||
3 | * | 4 | * |
4 | * This program is free software; you can redistribute it and/or modify it | 5 | * This program is free software; you can redistribute it and/or |
5 | * under the terms of version 2 of the GNU General Public License as | 6 | * modify it under the terms of the GNU General Public License as |
6 | * published by the Free Software Foundation. | 7 | * published by the Free Software Foundation. |
7 | * | 8 | * |
8 | * This program is distributed in the hope that it would be useful, but | 9 | * This program is distributed in the hope that it would be useful, |
9 | * WITHOUT ANY WARRANTY; without even the implied warranty of | 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
12 | * GNU General Public License for more details. | ||
11 | * | 13 | * |
12 | * Further, this software is distributed without any warranty that it is | 14 | * You should have received a copy of the GNU General Public License |
13 | * free of the rightful claim of any third person regarding infringement | 15 | * along with this program; if not, write the Free Software Foundation, |
14 | * or the like. Any license provided herein, whether implied or | 16 | * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
15 | * otherwise, applies only to this software file. Patent licenses, if | ||
16 | * any, provided herein do not apply to combinations of this program with | ||
17 | * other software, or any other product whatsoever. | ||
18 | * | ||
19 | * You should have received a copy of the GNU General Public License along | ||
20 | * with this program; if not, write the Free Software Foundation, Inc., 59 | ||
21 | * Temple Place - Suite 330, Boston MA 02111-1307, USA. | ||
22 | * | ||
23 | * Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy, | ||
24 | * Mountain View, CA 94043, or: | ||
25 | * | ||
26 | * http://www.sgi.com | ||
27 | * | ||
28 | * For further information regarding this notice, see: | ||
29 | * | ||
30 | * http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/ | ||
31 | */ | 17 | */ |
32 | #ifndef __XFS_QUOTA_H__ | 18 | #ifndef __XFS_QUOTA_H__ |
33 | #define __XFS_QUOTA_H__ | 19 | #define __XFS_QUOTA_H__ |
@@ -42,7 +28,7 @@ | |||
42 | * uid_t and gid_t are hard-coded to 32 bits in the inode. | 28 | * uid_t and gid_t are hard-coded to 32 bits in the inode. |
43 | * Hence, an 'id' in a dquot is 32 bits.. | 29 | * Hence, an 'id' in a dquot is 32 bits.. |
44 | */ | 30 | */ |
45 | typedef __int32_t xfs_dqid_t; | 31 | typedef __uint32_t xfs_dqid_t; |
46 | 32 | ||
47 | /* | 33 | /* |
48 | * Eventhough users may not have quota limits occupying all 64-bits, | 34 | * Eventhough users may not have quota limits occupying all 64-bits, |
@@ -59,28 +45,28 @@ typedef __uint16_t xfs_qwarncnt_t; | |||
59 | * to construct the on disk structure. | 45 | * to construct the on disk structure. |
60 | */ | 46 | */ |
61 | typedef struct xfs_disk_dquot { | 47 | typedef struct xfs_disk_dquot { |
62 | /*16*/ u_int16_t d_magic; /* dquot magic = XFS_DQUOT_MAGIC */ | 48 | __be16 d_magic; /* dquot magic = XFS_DQUOT_MAGIC */ |
63 | /*8 */ u_int8_t d_version; /* dquot version */ | 49 | __u8 d_version; /* dquot version */ |
64 | /*8 */ u_int8_t d_flags; /* XFS_DQ_USER/PROJ/GROUP */ | 50 | __u8 d_flags; /* XFS_DQ_USER/PROJ/GROUP */ |
65 | /*32*/ xfs_dqid_t d_id; /* user,project,group id */ | 51 | __be32 d_id; /* user,project,group id */ |
66 | /*64*/ xfs_qcnt_t d_blk_hardlimit;/* absolute limit on disk blks */ | 52 | __be64 d_blk_hardlimit;/* absolute limit on disk blks */ |
67 | /*64*/ xfs_qcnt_t d_blk_softlimit;/* preferred limit on disk blks */ | 53 | __be64 d_blk_softlimit;/* preferred limit on disk blks */ |
68 | /*64*/ xfs_qcnt_t d_ino_hardlimit;/* maximum # allocated inodes */ | 54 | __be64 d_ino_hardlimit;/* maximum # allocated inodes */ |
69 | /*64*/ xfs_qcnt_t d_ino_softlimit;/* preferred inode limit */ | 55 | __be64 d_ino_softlimit;/* preferred inode limit */ |
70 | /*64*/ xfs_qcnt_t d_bcount; /* disk blocks owned by the user */ | 56 | __be64 d_bcount; /* disk blocks owned by the user */ |
71 | /*64*/ xfs_qcnt_t d_icount; /* inodes owned by the user */ | 57 | __be64 d_icount; /* inodes owned by the user */ |
72 | /*32*/ __int32_t d_itimer; /* zero if within inode limits if not, | 58 | __be32 d_itimer; /* zero if within inode limits if not, |
73 | this is when we refuse service */ | 59 | this is when we refuse service */ |
74 | /*32*/ __int32_t d_btimer; /* similar to above; for disk blocks */ | 60 | __be32 d_btimer; /* similar to above; for disk blocks */ |
75 | /*16*/ xfs_qwarncnt_t d_iwarns; /* warnings issued wrt num inodes */ | 61 | __be16 d_iwarns; /* warnings issued wrt num inodes */ |
76 | /*16*/ xfs_qwarncnt_t d_bwarns; /* warnings issued wrt disk blocks */ | 62 | __be16 d_bwarns; /* warnings issued wrt disk blocks */ |
77 | /*32*/ __int32_t d_pad0; /* 64 bit align */ | 63 | __be32 d_pad0; /* 64 bit align */ |
78 | /*64*/ xfs_qcnt_t d_rtb_hardlimit;/* absolute limit on realtime blks */ | 64 | __be64 d_rtb_hardlimit;/* absolute limit on realtime blks */ |
79 | /*64*/ xfs_qcnt_t d_rtb_softlimit;/* preferred limit on RT disk blks */ | 65 | __be64 d_rtb_softlimit;/* preferred limit on RT disk blks */ |
80 | /*64*/ xfs_qcnt_t d_rtbcount; /* realtime blocks owned */ | 66 | __be64 d_rtbcount; /* realtime blocks owned */ |
81 | /*32*/ __int32_t d_rtbtimer; /* similar to above; for RT disk blocks */ | 67 | __be32 d_rtbtimer; /* similar to above; for RT disk blocks */ |
82 | /*16*/ xfs_qwarncnt_t d_rtbwarns; /* warnings issued wrt RT disk blocks */ | 68 | __be16 d_rtbwarns; /* warnings issued wrt RT disk blocks */ |
83 | /*16*/ __uint16_t d_pad; | 69 | __be16 d_pad; |
84 | } xfs_disk_dquot_t; | 70 | } xfs_disk_dquot_t; |
85 | 71 | ||
86 | /* | 72 | /* |
diff --git a/fs/xfs/xfs_refcache.h b/fs/xfs/xfs_refcache.h index cd8ddfd35d69..2dec79edb510 100644 --- a/fs/xfs/xfs_refcache.h +++ b/fs/xfs/xfs_refcache.h | |||
@@ -1,33 +1,19 @@ | |||
1 | /* | 1 | /* |
2 | * Copyright (c) 2000-2003 Silicon Graphics, Inc. All Rights Reserved. | 2 | * Copyright (c) 2000-2003,2005 Silicon Graphics, Inc. |
3 | * All Rights Reserved. | ||
3 | * | 4 | * |
4 | * This program is free software; you can redistribute it and/or modify it | 5 | * This program is free software; you can redistribute it and/or |
5 | * under the terms of version 2 of the GNU General Public License as | 6 | * modify it under the terms of the GNU General Public License as |
6 | * published by the Free Software Foundation. | 7 | * published by the Free Software Foundation. |
7 | * | 8 | * |
8 | * This program is distributed in the hope that it would be useful, but | 9 | * This program is distributed in the hope that it would be useful, |
9 | * WITHOUT ANY WARRANTY; without even the implied warranty of | 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
12 | * GNU General Public License for more details. | ||
11 | * | 13 | * |
12 | * Further, this software is distributed without any warranty that it is | 14 | * You should have received a copy of the GNU General Public License |
13 | * free of the rightful claim of any third person regarding infringement | 15 | * along with this program; if not, write the Free Software Foundation, |
14 | * or the like. Any license provided herein, whether implied or | 16 | * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
15 | * otherwise, applies only to this software file. Patent licenses, if | ||
16 | * any, provided herein do not apply to combinations of this program with | ||
17 | * other software, or any other product whatsoever. | ||
18 | * | ||
19 | * You should have received a copy of the GNU General Public License along | ||
20 | * with this program; if not, write the Free Software Foundation, Inc., 59 | ||
21 | * Temple Place - Suite 330, Boston MA 02111-1307, USA. | ||
22 | * | ||
23 | * Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy, | ||
24 | * Mountain View, CA 94043, or: | ||
25 | * | ||
26 | * http://www.sgi.com | ||
27 | * | ||
28 | * For further information regarding this notice, see: | ||
29 | * | ||
30 | * http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/ | ||
31 | */ | 17 | */ |
32 | #ifndef __XFS_REFCACHE_H__ | 18 | #ifndef __XFS_REFCACHE_H__ |
33 | #define __XFS_REFCACHE_H__ | 19 | #define __XFS_REFCACHE_H__ |
diff --git a/fs/xfs/xfs_rename.c b/fs/xfs/xfs_rename.c index 23b48ac1cb7e..4d4e8f4e768e 100644 --- a/fs/xfs/xfs_rename.c +++ b/fs/xfs/xfs_rename.c | |||
@@ -1,60 +1,45 @@ | |||
1 | /* | 1 | /* |
2 | * Copyright (c) 2000-2003 Silicon Graphics, Inc. All Rights Reserved. | 2 | * Copyright (c) 2000-2003,2005 Silicon Graphics, Inc. |
3 | * All Rights Reserved. | ||
3 | * | 4 | * |
4 | * This program is free software; you can redistribute it and/or modify it | 5 | * This program is free software; you can redistribute it and/or |
5 | * under the terms of version 2 of the GNU General Public License as | 6 | * modify it under the terms of the GNU General Public License as |
6 | * published by the Free Software Foundation. | 7 | * published by the Free Software Foundation. |
7 | * | 8 | * |
8 | * This program is distributed in the hope that it would be useful, but | 9 | * This program is distributed in the hope that it would be useful, |
9 | * WITHOUT ANY WARRANTY; without even the implied warranty of | 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
12 | * GNU General Public License for more details. | ||
11 | * | 13 | * |
12 | * Further, this software is distributed without any warranty that it is | 14 | * You should have received a copy of the GNU General Public License |
13 | * free of the rightful claim of any third person regarding infringement | 15 | * along with this program; if not, write the Free Software Foundation, |
14 | * or the like. Any license provided herein, whether implied or | 16 | * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
15 | * otherwise, applies only to this software file. Patent licenses, if | ||
16 | * any, provided herein do not apply to combinations of this program with | ||
17 | * other software, or any other product whatsoever. | ||
18 | * | ||
19 | * You should have received a copy of the GNU General Public License along | ||
20 | * with this program; if not, write the Free Software Foundation, Inc., 59 | ||
21 | * Temple Place - Suite 330, Boston MA 02111-1307, USA. | ||
22 | * | ||
23 | * Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy, | ||
24 | * Mountain View, CA 94043, or: | ||
25 | * | ||
26 | * http://www.sgi.com | ||
27 | * | ||
28 | * For further information regarding this notice, see: | ||
29 | * | ||
30 | * http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/ | ||
31 | */ | 17 | */ |
32 | |||
33 | #include "xfs.h" | 18 | #include "xfs.h" |
34 | #include "xfs_macros.h" | 19 | #include "xfs_fs.h" |
35 | #include "xfs_types.h" | 20 | #include "xfs_types.h" |
36 | #include "xfs_inum.h" | ||
37 | #include "xfs_log.h" | 21 | #include "xfs_log.h" |
22 | #include "xfs_inum.h" | ||
38 | #include "xfs_trans.h" | 23 | #include "xfs_trans.h" |
39 | #include "xfs_sb.h" | 24 | #include "xfs_sb.h" |
40 | #include "xfs_dir.h" | 25 | #include "xfs_dir.h" |
41 | #include "xfs_dir2.h" | 26 | #include "xfs_dir2.h" |
42 | #include "xfs_dmapi.h" | 27 | #include "xfs_dmapi.h" |
43 | #include "xfs_mount.h" | 28 | #include "xfs_mount.h" |
29 | #include "xfs_da_btree.h" | ||
44 | #include "xfs_bmap_btree.h" | 30 | #include "xfs_bmap_btree.h" |
45 | #include "xfs_attr_sf.h" | ||
46 | #include "xfs_dir_sf.h" | 31 | #include "xfs_dir_sf.h" |
47 | #include "xfs_dir2_sf.h" | 32 | #include "xfs_dir2_sf.h" |
33 | #include "xfs_attr_sf.h" | ||
48 | #include "xfs_dinode.h" | 34 | #include "xfs_dinode.h" |
49 | #include "xfs_inode_item.h" | ||
50 | #include "xfs_inode.h" | 35 | #include "xfs_inode.h" |
36 | #include "xfs_inode_item.h" | ||
51 | #include "xfs_bmap.h" | 37 | #include "xfs_bmap.h" |
52 | #include "xfs_error.h" | 38 | #include "xfs_error.h" |
53 | #include "xfs_quota.h" | 39 | #include "xfs_quota.h" |
54 | #include "xfs_refcache.h" | 40 | #include "xfs_refcache.h" |
55 | #include "xfs_utils.h" | 41 | #include "xfs_utils.h" |
56 | #include "xfs_trans_space.h" | 42 | #include "xfs_trans_space.h" |
57 | #include "xfs_da_btree.h" | ||
58 | #include "xfs_dir_leaf.h" | 43 | #include "xfs_dir_leaf.h" |
59 | 44 | ||
60 | 45 | ||
@@ -620,8 +605,6 @@ xfs_rename( | |||
620 | IRELE(target_ip); | 605 | IRELE(target_ip); |
621 | } | 606 | } |
622 | 607 | ||
623 | FSC_NOTIFY_NAME_CHANGED(XFS_ITOV(src_ip)); | ||
624 | |||
625 | IRELE(src_ip); | 608 | IRELE(src_ip); |
626 | 609 | ||
627 | /* Fall through to std_return with error = 0 or errno from | 610 | /* Fall through to std_return with error = 0 or errno from |
diff --git a/fs/xfs/xfs_rtalloc.c b/fs/xfs/xfs_rtalloc.c index 2c37822d1012..06fc061c50fc 100644 --- a/fs/xfs/xfs_rtalloc.c +++ b/fs/xfs/xfs_rtalloc.c | |||
@@ -1,44 +1,26 @@ | |||
1 | /* | 1 | /* |
2 | * Copyright (c) 2000-2004 Silicon Graphics, Inc. All Rights Reserved. | 2 | * Copyright (c) 2000-2005 Silicon Graphics, Inc. |
3 | * All Rights Reserved. | ||
3 | * | 4 | * |
4 | * This program is free software; you can redistribute it and/or modify it | 5 | * This program is free software; you can redistribute it and/or |
5 | * under the terms of version 2 of the GNU General Public License as | 6 | * modify it under the terms of the GNU General Public License as |
6 | * published by the Free Software Foundation. | 7 | * published by the Free Software Foundation. |
7 | * | 8 | * |
8 | * This program is distributed in the hope that it would be useful, but | 9 | * This program is distributed in the hope that it would be useful, |
9 | * WITHOUT ANY WARRANTY; without even the implied warranty of | 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
12 | * GNU General Public License for more details. | ||
11 | * | 13 | * |
12 | * Further, this software is distributed without any warranty that it is | 14 | * You should have received a copy of the GNU General Public License |
13 | * free of the rightful claim of any third person regarding infringement | 15 | * along with this program; if not, write the Free Software Foundation, |
14 | * or the like. Any license provided herein, whether implied or | 16 | * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
15 | * otherwise, applies only to this software file. Patent licenses, if | ||
16 | * any, provided herein do not apply to combinations of this program with | ||
17 | * other software, or any other product whatsoever. | ||
18 | * | ||
19 | * You should have received a copy of the GNU General Public License along | ||
20 | * with this program; if not, write the Free Software Foundation, Inc., 59 | ||
21 | * Temple Place - Suite 330, Boston MA 02111-1307, USA. | ||
22 | * | ||
23 | * Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy, | ||
24 | * Mountain View, CA 94043, or: | ||
25 | * | ||
26 | * http://www.sgi.com | ||
27 | * | ||
28 | * For further information regarding this notice, see: | ||
29 | * | ||
30 | * http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/ | ||
31 | */ | 17 | */ |
32 | |||
33 | /* | ||
34 | * Free realtime space allocation for XFS. | ||
35 | */ | ||
36 | |||
37 | #include "xfs.h" | 18 | #include "xfs.h" |
38 | #include "xfs_macros.h" | 19 | #include "xfs_fs.h" |
39 | #include "xfs_types.h" | 20 | #include "xfs_types.h" |
40 | #include "xfs_inum.h" | 21 | #include "xfs_bit.h" |
41 | #include "xfs_log.h" | 22 | #include "xfs_log.h" |
23 | #include "xfs_inum.h" | ||
42 | #include "xfs_trans.h" | 24 | #include "xfs_trans.h" |
43 | #include "xfs_sb.h" | 25 | #include "xfs_sb.h" |
44 | #include "xfs_ag.h" | 26 | #include "xfs_ag.h" |
@@ -46,19 +28,18 @@ | |||
46 | #include "xfs_dir2.h" | 28 | #include "xfs_dir2.h" |
47 | #include "xfs_dmapi.h" | 29 | #include "xfs_dmapi.h" |
48 | #include "xfs_mount.h" | 30 | #include "xfs_mount.h" |
49 | #include "xfs_alloc_btree.h" | ||
50 | #include "xfs_bmap_btree.h" | 31 | #include "xfs_bmap_btree.h" |
32 | #include "xfs_alloc_btree.h" | ||
51 | #include "xfs_ialloc_btree.h" | 33 | #include "xfs_ialloc_btree.h" |
52 | #include "xfs_btree.h" | ||
53 | #include "xfs_ialloc.h" | ||
54 | #include "xfs_attr_sf.h" | ||
55 | #include "xfs_dir_sf.h" | 34 | #include "xfs_dir_sf.h" |
56 | #include "xfs_dir2_sf.h" | 35 | #include "xfs_dir2_sf.h" |
36 | #include "xfs_attr_sf.h" | ||
57 | #include "xfs_dinode.h" | 37 | #include "xfs_dinode.h" |
58 | #include "xfs_inode.h" | 38 | #include "xfs_inode.h" |
39 | #include "xfs_btree.h" | ||
40 | #include "xfs_ialloc.h" | ||
59 | #include "xfs_alloc.h" | 41 | #include "xfs_alloc.h" |
60 | #include "xfs_bmap.h" | 42 | #include "xfs_bmap.h" |
61 | #include "xfs_bit.h" | ||
62 | #include "xfs_rtalloc.h" | 43 | #include "xfs_rtalloc.h" |
63 | #include "xfs_fsops.h" | 44 | #include "xfs_fsops.h" |
64 | #include "xfs_error.h" | 45 | #include "xfs_error.h" |
diff --git a/fs/xfs/xfs_rtalloc.h b/fs/xfs/xfs_rtalloc.h index e2710264c054..0e0b4d2ec202 100644 --- a/fs/xfs/xfs_rtalloc.h +++ b/fs/xfs/xfs_rtalloc.h | |||
@@ -1,33 +1,19 @@ | |||
1 | /* | 1 | /* |
2 | * Copyright (c) 2000-2003 Silicon Graphics, Inc. All Rights Reserved. | 2 | * Copyright (c) 2000-2003,2005 Silicon Graphics, Inc. |
3 | * All Rights Reserved. | ||
3 | * | 4 | * |
4 | * This program is free software; you can redistribute it and/or modify it | 5 | * This program is free software; you can redistribute it and/or |
5 | * under the terms of version 2 of the GNU General Public License as | 6 | * modify it under the terms of the GNU General Public License as |
6 | * published by the Free Software Foundation. | 7 | * published by the Free Software Foundation. |
7 | * | 8 | * |
8 | * This program is distributed in the hope that it would be useful, but | 9 | * This program is distributed in the hope that it would be useful, |
9 | * WITHOUT ANY WARRANTY; without even the implied warranty of | 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
12 | * GNU General Public License for more details. | ||
11 | * | 13 | * |
12 | * Further, this software is distributed without any warranty that it is | 14 | * You should have received a copy of the GNU General Public License |
13 | * free of the rightful claim of any third person regarding infringement | 15 | * along with this program; if not, write the Free Software Foundation, |
14 | * or the like. Any license provided herein, whether implied or | 16 | * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
15 | * otherwise, applies only to this software file. Patent licenses, if | ||
16 | * any, provided herein do not apply to combinations of this program with | ||
17 | * other software, or any other product whatsoever. | ||
18 | * | ||
19 | * You should have received a copy of the GNU General Public License along | ||
20 | * with this program; if not, write the Free Software Foundation, Inc., 59 | ||
21 | * Temple Place - Suite 330, Boston MA 02111-1307, USA. | ||
22 | * | ||
23 | * Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy, | ||
24 | * Mountain View, CA 94043, or: | ||
25 | * | ||
26 | * http://www.sgi.com | ||
27 | * | ||
28 | * For further information regarding this notice, see: | ||
29 | * | ||
30 | * http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/ | ||
31 | */ | 17 | */ |
32 | #ifndef __XFS_RTALLOC_H__ | 18 | #ifndef __XFS_RTALLOC_H__ |
33 | #define __XFS_RTALLOC_H__ | 19 | #define __XFS_RTALLOC_H__ |
diff --git a/fs/xfs/xfs_rw.c b/fs/xfs/xfs_rw.c index d3ff7aef33ba..c4b20872f07d 100644 --- a/fs/xfs/xfs_rw.c +++ b/fs/xfs/xfs_rw.c | |||
@@ -1,40 +1,26 @@ | |||
1 | /* | 1 | /* |
2 | * Copyright (c) 2000-2003 Silicon Graphics, Inc. All Rights Reserved. | 2 | * Copyright (c) 2000-2003,2005 Silicon Graphics, Inc. |
3 | * All Rights Reserved. | ||
3 | * | 4 | * |
4 | * This program is free software; you can redistribute it and/or modify it | 5 | * This program is free software; you can redistribute it and/or |
5 | * under the terms of version 2 of the GNU General Public License as | 6 | * modify it under the terms of the GNU General Public License as |
6 | * published by the Free Software Foundation. | 7 | * published by the Free Software Foundation. |
7 | * | 8 | * |
8 | * This program is distributed in the hope that it would be useful, but | 9 | * This program is distributed in the hope that it would be useful, |
9 | * WITHOUT ANY WARRANTY; without even the implied warranty of | 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
12 | * GNU General Public License for more details. | ||
11 | * | 13 | * |
12 | * Further, this software is distributed without any warranty that it is | 14 | * You should have received a copy of the GNU General Public License |
13 | * free of the rightful claim of any third person regarding infringement | 15 | * along with this program; if not, write the Free Software Foundation, |
14 | * or the like. Any license provided herein, whether implied or | 16 | * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
15 | * otherwise, applies only to this software file. Patent licenses, if | ||
16 | * any, provided herein do not apply to combinations of this program with | ||
17 | * other software, or any other product whatsoever. | ||
18 | * | ||
19 | * You should have received a copy of the GNU General Public License along | ||
20 | * with this program; if not, write the Free Software Foundation, Inc., 59 | ||
21 | * Temple Place - Suite 330, Boston MA 02111-1307, USA. | ||
22 | * | ||
23 | * Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy, | ||
24 | * Mountain View, CA 94043, or: | ||
25 | * | ||
26 | * http://www.sgi.com | ||
27 | * | ||
28 | * For further information regarding this notice, see: | ||
29 | * | ||
30 | * http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/ | ||
31 | */ | 17 | */ |
32 | |||
33 | #include "xfs.h" | 18 | #include "xfs.h" |
34 | #include "xfs_macros.h" | 19 | #include "xfs_fs.h" |
35 | #include "xfs_types.h" | 20 | #include "xfs_types.h" |
36 | #include "xfs_inum.h" | 21 | #include "xfs_bit.h" |
37 | #include "xfs_log.h" | 22 | #include "xfs_log.h" |
23 | #include "xfs_inum.h" | ||
38 | #include "xfs_trans.h" | 24 | #include "xfs_trans.h" |
39 | #include "xfs_sb.h" | 25 | #include "xfs_sb.h" |
40 | #include "xfs_ag.h" | 26 | #include "xfs_ag.h" |
@@ -42,20 +28,20 @@ | |||
42 | #include "xfs_dir2.h" | 28 | #include "xfs_dir2.h" |
43 | #include "xfs_dmapi.h" | 29 | #include "xfs_dmapi.h" |
44 | #include "xfs_mount.h" | 30 | #include "xfs_mount.h" |
45 | #include "xfs_alloc_btree.h" | ||
46 | #include "xfs_bmap_btree.h" | 31 | #include "xfs_bmap_btree.h" |
32 | #include "xfs_alloc_btree.h" | ||
47 | #include "xfs_ialloc_btree.h" | 33 | #include "xfs_ialloc_btree.h" |
34 | #include "xfs_dir_sf.h" | ||
35 | #include "xfs_dir2_sf.h" | ||
36 | #include "xfs_attr_sf.h" | ||
37 | #include "xfs_dinode.h" | ||
38 | #include "xfs_inode.h" | ||
39 | #include "xfs_inode_item.h" | ||
48 | #include "xfs_itable.h" | 40 | #include "xfs_itable.h" |
49 | #include "xfs_btree.h" | 41 | #include "xfs_btree.h" |
50 | #include "xfs_alloc.h" | 42 | #include "xfs_alloc.h" |
51 | #include "xfs_ialloc.h" | 43 | #include "xfs_ialloc.h" |
52 | #include "xfs_attr.h" | 44 | #include "xfs_attr.h" |
53 | #include "xfs_attr_sf.h" | ||
54 | #include "xfs_dir_sf.h" | ||
55 | #include "xfs_dir2_sf.h" | ||
56 | #include "xfs_dinode.h" | ||
57 | #include "xfs_inode_item.h" | ||
58 | #include "xfs_inode.h" | ||
59 | #include "xfs_bmap.h" | 45 | #include "xfs_bmap.h" |
60 | #include "xfs_acl.h" | 46 | #include "xfs_acl.h" |
61 | #include "xfs_mac.h" | 47 | #include "xfs_mac.h" |
@@ -264,7 +250,7 @@ xfs_ioerror_alert( | |||
264 | { | 250 | { |
265 | cmn_err(CE_ALERT, | 251 | cmn_err(CE_ALERT, |
266 | "I/O error in filesystem (\"%s\") meta-data dev %s block 0x%llx" | 252 | "I/O error in filesystem (\"%s\") meta-data dev %s block 0x%llx" |
267 | " (\"%s\") error %d buf count %u", | 253 | " (\"%s\") error %d buf count %zd", |
268 | (!mp || !mp->m_fsname) ? "(fs name not set)" : mp->m_fsname, | 254 | (!mp || !mp->m_fsname) ? "(fs name not set)" : mp->m_fsname, |
269 | XFS_BUFTARG_NAME(bp->pb_target), | 255 | XFS_BUFTARG_NAME(bp->pb_target), |
270 | (__uint64_t)blkno, | 256 | (__uint64_t)blkno, |
diff --git a/fs/xfs/xfs_rw.h b/fs/xfs/xfs_rw.h index c8b10bf8f530..de85eefb7966 100644 --- a/fs/xfs/xfs_rw.h +++ b/fs/xfs/xfs_rw.h | |||
@@ -1,33 +1,19 @@ | |||
1 | /* | 1 | /* |
2 | * Copyright (c) 2000-2003 Silicon Graphics, Inc. All Rights Reserved. | 2 | * Copyright (c) 2000-2003,2005 Silicon Graphics, Inc. |
3 | * All Rights Reserved. | ||
3 | * | 4 | * |
4 | * This program is free software; you can redistribute it and/or modify it | 5 | * This program is free software; you can redistribute it and/or |
5 | * under the terms of version 2 of the GNU General Public License as | 6 | * modify it under the terms of the GNU General Public License as |
6 | * published by the Free Software Foundation. | 7 | * published by the Free Software Foundation. |
7 | * | 8 | * |
8 | * This program is distributed in the hope that it would be useful, but | 9 | * This program is distributed in the hope that it would be useful, |
9 | * WITHOUT ANY WARRANTY; without even the implied warranty of | 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
12 | * GNU General Public License for more details. | ||
11 | * | 13 | * |
12 | * Further, this software is distributed without any warranty that it is | 14 | * You should have received a copy of the GNU General Public License |
13 | * free of the rightful claim of any third person regarding infringement | 15 | * along with this program; if not, write the Free Software Foundation, |
14 | * or the like. Any license provided herein, whether implied or | 16 | * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
15 | * otherwise, applies only to this software file. Patent licenses, if | ||
16 | * any, provided herein do not apply to combinations of this program with | ||
17 | * other software, or any other product whatsoever. | ||
18 | * | ||
19 | * You should have received a copy of the GNU General Public License along | ||
20 | * with this program; if not, write the Free Software Foundation, Inc., 59 | ||
21 | * Temple Place - Suite 330, Boston MA 02111-1307, USA. | ||
22 | * | ||
23 | * Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy, | ||
24 | * Mountain View, CA 94043, or: | ||
25 | * | ||
26 | * http://www.sgi.com | ||
27 | * | ||
28 | * For further information regarding this notice, see: | ||
29 | * | ||
30 | * http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/ | ||
31 | */ | 17 | */ |
32 | #ifndef __XFS_RW_H__ | 18 | #ifndef __XFS_RW_H__ |
33 | #define __XFS_RW_H__ | 19 | #define __XFS_RW_H__ |
@@ -68,87 +54,44 @@ struct xfs_mount; | |||
68 | * file is a real time file or not, because the bmap code | 54 | * file is a real time file or not, because the bmap code |
69 | * does. | 55 | * does. |
70 | */ | 56 | */ |
71 | #if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_FSB_TO_DB) | ||
72 | xfs_daddr_t xfs_fsb_to_db(struct xfs_inode *ip, xfs_fsblock_t fsb); | ||
73 | #define XFS_FSB_TO_DB(ip,fsb) xfs_fsb_to_db(ip,fsb) | 57 | #define XFS_FSB_TO_DB(ip,fsb) xfs_fsb_to_db(ip,fsb) |
74 | #else | 58 | static inline xfs_daddr_t |
75 | #define XFS_FSB_TO_DB(ip,fsb) \ | 59 | xfs_fsb_to_db(struct xfs_inode *ip, xfs_fsblock_t fsb) |
76 | (((ip)->i_d.di_flags & XFS_DIFLAG_REALTIME) ? \ | 60 | { |
61 | return (((ip)->i_d.di_flags & XFS_DIFLAG_REALTIME) ? \ | ||
77 | (xfs_daddr_t)XFS_FSB_TO_BB((ip)->i_mount, (fsb)) : \ | 62 | (xfs_daddr_t)XFS_FSB_TO_BB((ip)->i_mount, (fsb)) : \ |
78 | XFS_FSB_TO_DADDR((ip)->i_mount, (fsb))) | 63 | XFS_FSB_TO_DADDR((ip)->i_mount, (fsb))); |
79 | #endif | 64 | } |
80 | 65 | #define XFS_FSB_TO_DB_IO(io,fsb) xfs_fsb_to_db_io(io,fsb) | |
81 | #define XFS_FSB_TO_DB_IO(io,fsb) \ | 66 | static inline xfs_daddr_t |
82 | (((io)->io_flags & XFS_IOCORE_RT) ? \ | 67 | xfs_fsb_to_db_io(struct xfs_iocore *io, xfs_fsblock_t fsb) |
68 | { | ||
69 | return (((io)->io_flags & XFS_IOCORE_RT) ? \ | ||
83 | XFS_FSB_TO_BB((io)->io_mount, (fsb)) : \ | 70 | XFS_FSB_TO_BB((io)->io_mount, (fsb)) : \ |
84 | XFS_FSB_TO_DADDR((io)->io_mount, (fsb))) | 71 | XFS_FSB_TO_DADDR((io)->io_mount, (fsb))); |
72 | } | ||
85 | 73 | ||
86 | /* | 74 | /* |
87 | * Prototypes for functions in xfs_rw.c. | 75 | * Prototypes for functions in xfs_rw.c. |
88 | */ | 76 | */ |
89 | 77 | extern int xfs_write_clear_setuid(struct xfs_inode *ip); | |
90 | int | 78 | extern int xfs_bwrite(struct xfs_mount *mp, struct xfs_buf *bp); |
91 | xfs_write_clear_setuid( | 79 | extern int xfs_bioerror(struct xfs_buf *bp); |
92 | struct xfs_inode *ip); | 80 | extern int xfs_bioerror_relse(struct xfs_buf *bp); |
93 | 81 | extern int xfs_read_buf(struct xfs_mount *mp, xfs_buftarg_t *btp, | |
94 | int | 82 | xfs_daddr_t blkno, int len, uint flags, |
95 | xfs_bwrite( | 83 | struct xfs_buf **bpp); |
96 | struct xfs_mount *mp, | 84 | extern void xfs_ioerror_alert(char *func, struct xfs_mount *mp, |
97 | struct xfs_buf *bp); | 85 | xfs_buf_t *bp, xfs_daddr_t blkno); |
98 | |||
99 | int | ||
100 | xfs_bioerror( | ||
101 | struct xfs_buf *b); | ||
102 | |||
103 | int | ||
104 | xfs_bioerror_relse( | ||
105 | struct xfs_buf *b); | ||
106 | |||
107 | int | ||
108 | xfs_read_buf( | ||
109 | struct xfs_mount *mp, | ||
110 | xfs_buftarg_t *target, | ||
111 | xfs_daddr_t blkno, | ||
112 | int len, | ||
113 | uint flags, | ||
114 | struct xfs_buf **bpp); | ||
115 | |||
116 | void | ||
117 | xfs_ioerror_alert( | ||
118 | char *func, | ||
119 | struct xfs_mount *mp, | ||
120 | xfs_buf_t *bp, | ||
121 | xfs_daddr_t blkno); | ||
122 | |||
123 | 86 | ||
124 | /* | 87 | /* |
125 | * Prototypes for functions in xfs_vnodeops.c. | 88 | * Prototypes for functions in xfs_vnodeops.c. |
126 | */ | 89 | */ |
127 | 90 | extern int xfs_rwlock(bhv_desc_t *bdp, vrwlock_t write_lock); | |
128 | int | 91 | extern void xfs_rwunlock(bhv_desc_t *bdp, vrwlock_t write_lock); |
129 | xfs_rwlock( | 92 | extern int xfs_change_file_space(bhv_desc_t *bdp, int cmd, xfs_flock64_t *bf, |
130 | bhv_desc_t *bdp, | 93 | xfs_off_t offset, cred_t *credp, int flags); |
131 | vrwlock_t write_lock); | 94 | extern int xfs_set_dmattrs(bhv_desc_t *bdp, u_int evmask, u_int16_t state, |
132 | 95 | cred_t *credp); | |
133 | void | ||
134 | xfs_rwunlock( | ||
135 | bhv_desc_t *bdp, | ||
136 | vrwlock_t write_lock); | ||
137 | |||
138 | int | ||
139 | xfs_change_file_space( | ||
140 | bhv_desc_t *bdp, | ||
141 | int cmd, | ||
142 | xfs_flock64_t *bf, | ||
143 | xfs_off_t offset, | ||
144 | cred_t *credp, | ||
145 | int flags); | ||
146 | |||
147 | int | ||
148 | xfs_set_dmattrs( | ||
149 | bhv_desc_t *bdp, | ||
150 | u_int evmask, | ||
151 | u_int16_t state, | ||
152 | cred_t *credp); | ||
153 | 96 | ||
154 | #endif /* __XFS_RW_H__ */ | 97 | #endif /* __XFS_RW_H__ */ |
diff --git a/fs/xfs/xfs_sb.h b/fs/xfs/xfs_sb.h index ad090a834ced..4a17d335f897 100644 --- a/fs/xfs/xfs_sb.h +++ b/fs/xfs/xfs_sb.h | |||
@@ -1,33 +1,19 @@ | |||
1 | /* | 1 | /* |
2 | * Copyright (c) 2000-2001 Silicon Graphics, Inc. All Rights Reserved. | 2 | * Copyright (c) 2000-2005 Silicon Graphics, Inc. |
3 | * All Rights Reserved. | ||
3 | * | 4 | * |
4 | * This program is free software; you can redistribute it and/or modify it | 5 | * This program is free software; you can redistribute it and/or |
5 | * under the terms of version 2 of the GNU General Public License as | 6 | * modify it under the terms of the GNU General Public License as |
6 | * published by the Free Software Foundation. | 7 | * published by the Free Software Foundation. |
7 | * | 8 | * |
8 | * This program is distributed in the hope that it would be useful, but | 9 | * This program is distributed in the hope that it would be useful, |
9 | * WITHOUT ANY WARRANTY; without even the implied warranty of | 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
12 | * GNU General Public License for more details. | ||
11 | * | 13 | * |
12 | * Further, this software is distributed without any warranty that it is | 14 | * You should have received a copy of the GNU General Public License |
13 | * free of the rightful claim of any third person regarding infringement | 15 | * along with this program; if not, write the Free Software Foundation, |
14 | * or the like. Any license provided herein, whether implied or | 16 | * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
15 | * otherwise, applies only to this software file. Patent licenses, if | ||
16 | * any, provided herein do not apply to combinations of this program with | ||
17 | * other software, or any other product whatsoever. | ||
18 | * | ||
19 | * You should have received a copy of the GNU General Public License along | ||
20 | * with this program; if not, write the Free Software Foundation, Inc., 59 | ||
21 | * Temple Place - Suite 330, Boston MA 02111-1307, USA. | ||
22 | * | ||
23 | * Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy, | ||
24 | * Mountain View, CA 94043, or: | ||
25 | * | ||
26 | * http://www.sgi.com | ||
27 | * | ||
28 | * For further information regarding this notice, see: | ||
29 | * | ||
30 | * http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/ | ||
31 | */ | 17 | */ |
32 | #ifndef __XFS_SB_H__ | 18 | #ifndef __XFS_SB_H__ |
33 | #define __XFS_SB_H__ | 19 | #define __XFS_SB_H__ |
@@ -72,7 +58,8 @@ struct xfs_mount; | |||
72 | XFS_SB_VERSION_DALIGNBIT | \ | 58 | XFS_SB_VERSION_DALIGNBIT | \ |
73 | XFS_SB_VERSION_SHAREDBIT | \ | 59 | XFS_SB_VERSION_SHAREDBIT | \ |
74 | XFS_SB_VERSION_LOGV2BIT | \ | 60 | XFS_SB_VERSION_LOGV2BIT | \ |
75 | XFS_SB_VERSION_SECTORBIT) | 61 | XFS_SB_VERSION_SECTORBIT | \ |
62 | XFS_SB_VERSION_MOREBITSBIT) | ||
76 | #define XFS_SB_VERSION_OKSASHBITS \ | 63 | #define XFS_SB_VERSION_OKSASHBITS \ |
77 | (XFS_SB_VERSION_NUMBITS | \ | 64 | (XFS_SB_VERSION_NUMBITS | \ |
78 | XFS_SB_VERSION_REALFBITS | \ | 65 | XFS_SB_VERSION_REALFBITS | \ |
@@ -103,12 +90,15 @@ struct xfs_mount; | |||
103 | */ | 90 | */ |
104 | #define XFS_SB_VERSION2_REALFBITS 0x00ffffff /* Mask: features */ | 91 | #define XFS_SB_VERSION2_REALFBITS 0x00ffffff /* Mask: features */ |
105 | #define XFS_SB_VERSION2_RESERVED1BIT 0x00000001 | 92 | #define XFS_SB_VERSION2_RESERVED1BIT 0x00000001 |
93 | #define XFS_SB_VERSION2_RESERVED2BIT 0x00000002 | ||
94 | #define XFS_SB_VERSION2_RESERVED4BIT 0x00000004 | ||
95 | #define XFS_SB_VERSION2_ATTR2BIT 0x00000008 /* Inline attr rework */ | ||
106 | #define XFS_SB_VERSION2_SASHFBITS 0xff000000 /* Mask: features that | 96 | #define XFS_SB_VERSION2_SASHFBITS 0xff000000 /* Mask: features that |
107 | require changing | 97 | require changing |
108 | PROM and SASH */ | 98 | PROM and SASH */ |
109 | 99 | ||
110 | #define XFS_SB_VERSION2_OKREALFBITS \ | 100 | #define XFS_SB_VERSION2_OKREALFBITS \ |
111 | (0) | 101 | (XFS_SB_VERSION2_ATTR2BIT) |
112 | #define XFS_SB_VERSION2_OKSASHFBITS \ | 102 | #define XFS_SB_VERSION2_OKSASHFBITS \ |
113 | (0) | 103 | (0) |
114 | #define XFS_SB_VERSION2_OKREALBITS \ | 104 | #define XFS_SB_VERSION2_OKREALBITS \ |
@@ -118,8 +108,7 @@ struct xfs_mount; | |||
118 | /* | 108 | /* |
119 | * mkfs macro to set up sb_features2 word | 109 | * mkfs macro to set up sb_features2 word |
120 | */ | 110 | */ |
121 | #define XFS_SB_VERSION2_MKFS(xyz) \ | 111 | #define XFS_SB_VERSION2_MKFS(resvd1, sbcntr) 0 |
122 | ((xyz) ? 0 : 0) | ||
123 | 112 | ||
124 | typedef struct xfs_sb | 113 | typedef struct xfs_sb |
125 | { | 114 | { |
@@ -176,7 +165,7 @@ typedef struct xfs_sb | |||
176 | __uint8_t sb_logsectlog; /* log2 of the log sector size */ | 165 | __uint8_t sb_logsectlog; /* log2 of the log sector size */ |
177 | __uint16_t sb_logsectsize; /* sector size for the log, bytes */ | 166 | __uint16_t sb_logsectsize; /* sector size for the log, bytes */ |
178 | __uint32_t sb_logsunit; /* stripe unit size for the log */ | 167 | __uint32_t sb_logsunit; /* stripe unit size for the log */ |
179 | __uint32_t sb_features2; /* additonal feature bits */ | 168 | __uint32_t sb_features2; /* additional feature bits */ |
180 | } xfs_sb_t; | 169 | } xfs_sb_t; |
181 | 170 | ||
182 | /* | 171 | /* |
@@ -216,12 +205,15 @@ typedef enum { | |||
216 | #define XFS_SB_SHARED_VN XFS_SB_MVAL(SHARED_VN) | 205 | #define XFS_SB_SHARED_VN XFS_SB_MVAL(SHARED_VN) |
217 | #define XFS_SB_UNIT XFS_SB_MVAL(UNIT) | 206 | #define XFS_SB_UNIT XFS_SB_MVAL(UNIT) |
218 | #define XFS_SB_WIDTH XFS_SB_MVAL(WIDTH) | 207 | #define XFS_SB_WIDTH XFS_SB_MVAL(WIDTH) |
208 | #define XFS_SB_FEATURES2 XFS_SB_MVAL(FEATURES2) | ||
219 | #define XFS_SB_NUM_BITS ((int)XFS_SBS_FIELDCOUNT) | 209 | #define XFS_SB_NUM_BITS ((int)XFS_SBS_FIELDCOUNT) |
220 | #define XFS_SB_ALL_BITS ((1LL << XFS_SB_NUM_BITS) - 1) | 210 | #define XFS_SB_ALL_BITS ((1LL << XFS_SB_NUM_BITS) - 1) |
221 | #define XFS_SB_MOD_BITS \ | 211 | #define XFS_SB_MOD_BITS \ |
222 | (XFS_SB_UUID | XFS_SB_ROOTINO | XFS_SB_RBMINO | XFS_SB_RSUMINO | \ | 212 | (XFS_SB_UUID | XFS_SB_ROOTINO | XFS_SB_RBMINO | XFS_SB_RSUMINO | \ |
223 | XFS_SB_VERSIONNUM | XFS_SB_UQUOTINO | XFS_SB_GQUOTINO | \ | 213 | XFS_SB_VERSIONNUM | XFS_SB_UQUOTINO | XFS_SB_GQUOTINO | \ |
224 | XFS_SB_QFLAGS | XFS_SB_SHARED_VN | XFS_SB_UNIT | XFS_SB_WIDTH) | 214 | XFS_SB_QFLAGS | XFS_SB_SHARED_VN | XFS_SB_UNIT | XFS_SB_WIDTH | \ |
215 | XFS_SB_FEATURES2) | ||
216 | |||
225 | 217 | ||
226 | /* | 218 | /* |
227 | * Misc. Flags - warning - these will be cleared by xfs_repair unless | 219 | * Misc. Flags - warning - these will be cleared by xfs_repair unless |
@@ -235,42 +227,33 @@ typedef enum { | |||
235 | */ | 227 | */ |
236 | #define XFS_SB_MAX_SHARED_VN 0 | 228 | #define XFS_SB_MAX_SHARED_VN 0 |
237 | 229 | ||
238 | #if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_SB_VERSION_NUM) | ||
239 | int xfs_sb_version_num(xfs_sb_t *sbp); | ||
240 | #define XFS_SB_VERSION_NUM(sbp) xfs_sb_version_num(sbp) | ||
241 | #else | ||
242 | #define XFS_SB_VERSION_NUM(sbp) ((sbp)->sb_versionnum & XFS_SB_VERSION_NUMBITS) | 230 | #define XFS_SB_VERSION_NUM(sbp) ((sbp)->sb_versionnum & XFS_SB_VERSION_NUMBITS) |
243 | #endif | ||
244 | 231 | ||
245 | #if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_SB_GOOD_VERSION) | ||
246 | int xfs_sb_good_version(xfs_sb_t *sbp); | ||
247 | #define XFS_SB_GOOD_VERSION(sbp) xfs_sb_good_version(sbp) | 232 | #define XFS_SB_GOOD_VERSION(sbp) xfs_sb_good_version(sbp) |
248 | #else | ||
249 | #define XFS_SB_GOOD_VERSION_INT(sbp) \ | ||
250 | ((((sbp)->sb_versionnum >= XFS_SB_VERSION_1) && \ | ||
251 | ((sbp)->sb_versionnum <= XFS_SB_VERSION_3)) || \ | ||
252 | ((XFS_SB_VERSION_NUM(sbp) == XFS_SB_VERSION_4) && \ | ||
253 | !(((sbp)->sb_versionnum & ~XFS_SB_VERSION_OKREALBITS) || \ | ||
254 | (((sbp)->sb_versionnum & XFS_SB_VERSION_MOREBITSBIT) && \ | ||
255 | ((sbp)->sb_features2 & ~XFS_SB_VERSION2_OKREALBITS))) | ||
256 | |||
257 | #ifdef __KERNEL__ | 233 | #ifdef __KERNEL__ |
258 | #define XFS_SB_GOOD_VERSION(sbp) \ | 234 | static inline int xfs_sb_good_version(xfs_sb_t *sbp) |
259 | (XFS_SB_GOOD_VERSION_INT(sbp) && \ | 235 | { |
260 | (sbp)->sb_shared_vn <= XFS_SB_MAX_SHARED_VN) )) | 236 | return (((sbp->sb_versionnum >= XFS_SB_VERSION_1) && \ |
237 | (sbp->sb_versionnum <= XFS_SB_VERSION_3)) || \ | ||
238 | ((XFS_SB_VERSION_NUM(sbp) == XFS_SB_VERSION_4) && \ | ||
239 | !((sbp->sb_versionnum & ~XFS_SB_VERSION_OKREALBITS) || \ | ||
240 | ((sbp->sb_versionnum & XFS_SB_VERSION_MOREBITSBIT) && \ | ||
241 | (sbp->sb_features2 & ~XFS_SB_VERSION2_OKREALBITS))) && \ | ||
242 | (sbp->sb_shared_vn <= XFS_SB_MAX_SHARED_VN))); | ||
243 | } | ||
261 | #else | 244 | #else |
262 | /* | 245 | static inline int xfs_sb_good_version(xfs_sb_t *sbp) |
263 | * extra 2 paren's here (( to unconfuse paren-matching editors | 246 | { |
264 | * like vi because XFS_SB_GOOD_VERSION_INT is a partial expression | 247 | return (((sbp->sb_versionnum >= XFS_SB_VERSION_1) && \ |
265 | * and the two XFS_SB_GOOD_VERSION's each 2 more close paren's to | 248 | (sbp->sb_versionnum <= XFS_SB_VERSION_3)) || \ |
266 | * complete the expression. | 249 | ((XFS_SB_VERSION_NUM(sbp) == XFS_SB_VERSION_4) && \ |
267 | */ | 250 | !((sbp->sb_versionnum & ~XFS_SB_VERSION_OKREALBITS) || \ |
268 | #define XFS_SB_GOOD_VERSION(sbp) \ | 251 | ((sbp->sb_versionnum & XFS_SB_VERSION_MOREBITSBIT) && \ |
269 | (XFS_SB_GOOD_VERSION_INT(sbp) && \ | 252 | (sbp->sb_features2 & ~XFS_SB_VERSION2_OKREALBITS))) && \ |
270 | (!((sbp)->sb_versionnum & XFS_SB_VERSION_SHAREDBIT) || \ | 253 | (!(sbp->sb_versionnum & XFS_SB_VERSION_SHAREDBIT) || \ |
271 | (sbp)->sb_shared_vn <= XFS_SB_MAX_SHARED_VN)) )) | 254 | (sbp->sb_shared_vn <= XFS_SB_MAX_SHARED_VN)))); |
255 | } | ||
272 | #endif /* __KERNEL__ */ | 256 | #endif /* __KERNEL__ */ |
273 | #endif | ||
274 | 257 | ||
275 | #define XFS_SB_GOOD_SASH_VERSION(sbp) \ | 258 | #define XFS_SB_GOOD_SASH_VERSION(sbp) \ |
276 | ((((sbp)->sb_versionnum >= XFS_SB_VERSION_1) && \ | 259 | ((((sbp)->sb_versionnum >= XFS_SB_VERSION_1) && \ |
@@ -278,275 +261,218 @@ int xfs_sb_good_version(xfs_sb_t *sbp); | |||
278 | ((XFS_SB_VERSION_NUM(sbp) == XFS_SB_VERSION_4) && \ | 261 | ((XFS_SB_VERSION_NUM(sbp) == XFS_SB_VERSION_4) && \ |
279 | !((sbp)->sb_versionnum & ~XFS_SB_VERSION_OKSASHBITS))) | 262 | !((sbp)->sb_versionnum & ~XFS_SB_VERSION_OKSASHBITS))) |
280 | 263 | ||
281 | #if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_SB_VERSION_TONEW) | ||
282 | unsigned xfs_sb_version_tonew(unsigned v); | ||
283 | #define XFS_SB_VERSION_TONEW(v) xfs_sb_version_tonew(v) | 264 | #define XFS_SB_VERSION_TONEW(v) xfs_sb_version_tonew(v) |
284 | #else | 265 | static inline unsigned xfs_sb_version_tonew(unsigned v) |
285 | #define XFS_SB_VERSION_TONEW(v) \ | 266 | { |
286 | ((((v) == XFS_SB_VERSION_1) ? \ | 267 | return ((((v) == XFS_SB_VERSION_1) ? \ |
287 | 0 : \ | 268 | 0 : \ |
288 | (((v) == XFS_SB_VERSION_2) ? \ | 269 | (((v) == XFS_SB_VERSION_2) ? \ |
289 | XFS_SB_VERSION_ATTRBIT : \ | 270 | XFS_SB_VERSION_ATTRBIT : \ |
290 | (XFS_SB_VERSION_ATTRBIT | XFS_SB_VERSION_NLINKBIT))) | \ | 271 | (XFS_SB_VERSION_ATTRBIT | XFS_SB_VERSION_NLINKBIT))) | \ |
291 | XFS_SB_VERSION_4) | 272 | XFS_SB_VERSION_4); |
292 | #endif | 273 | } |
293 | 274 | ||
294 | #if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_SB_VERSION_TOOLD) | ||
295 | unsigned xfs_sb_version_toold(unsigned v); | ||
296 | #define XFS_SB_VERSION_TOOLD(v) xfs_sb_version_toold(v) | 275 | #define XFS_SB_VERSION_TOOLD(v) xfs_sb_version_toold(v) |
297 | #else | 276 | static inline unsigned xfs_sb_version_toold(unsigned v) |
298 | #define XFS_SB_VERSION_TOOLD(v) \ | 277 | { |
299 | (((v) & (XFS_SB_VERSION_QUOTABIT | XFS_SB_VERSION_ALIGNBIT)) ? \ | 278 | return (((v) & (XFS_SB_VERSION_QUOTABIT | XFS_SB_VERSION_ALIGNBIT)) ? \ |
300 | 0 : \ | 279 | 0 : \ |
301 | (((v) & XFS_SB_VERSION_NLINKBIT) ? \ | 280 | (((v) & XFS_SB_VERSION_NLINKBIT) ? \ |
302 | XFS_SB_VERSION_3 : \ | 281 | XFS_SB_VERSION_3 : \ |
303 | (((v) & XFS_SB_VERSION_ATTRBIT) ? \ | 282 | (((v) & XFS_SB_VERSION_ATTRBIT) ? \ |
304 | XFS_SB_VERSION_2 : \ | 283 | XFS_SB_VERSION_2 : \ |
305 | XFS_SB_VERSION_1))) | 284 | XFS_SB_VERSION_1))); |
306 | #endif | 285 | } |
307 | 286 | ||
308 | #if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_SB_VERSION_HASATTR) | ||
309 | int xfs_sb_version_hasattr(xfs_sb_t *sbp); | ||
310 | #define XFS_SB_VERSION_HASATTR(sbp) xfs_sb_version_hasattr(sbp) | 287 | #define XFS_SB_VERSION_HASATTR(sbp) xfs_sb_version_hasattr(sbp) |
311 | #else | 288 | static inline int xfs_sb_version_hasattr(xfs_sb_t *sbp) |
312 | #define XFS_SB_VERSION_HASATTR(sbp) \ | 289 | { |
313 | (((sbp)->sb_versionnum == XFS_SB_VERSION_2) || \ | 290 | return ((sbp)->sb_versionnum == XFS_SB_VERSION_2) || \ |
314 | ((sbp)->sb_versionnum == XFS_SB_VERSION_3) || \ | 291 | ((sbp)->sb_versionnum == XFS_SB_VERSION_3) || \ |
315 | ((XFS_SB_VERSION_NUM(sbp) == XFS_SB_VERSION_4) && \ | 292 | ((XFS_SB_VERSION_NUM(sbp) == XFS_SB_VERSION_4) && \ |
316 | ((sbp)->sb_versionnum & XFS_SB_VERSION_ATTRBIT))) | 293 | ((sbp)->sb_versionnum & XFS_SB_VERSION_ATTRBIT)); |
317 | #endif | 294 | } |
318 | 295 | ||
319 | #if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_SB_VERSION_ADDATTR) | ||
320 | void xfs_sb_version_addattr(xfs_sb_t *sbp); | ||
321 | #define XFS_SB_VERSION_ADDATTR(sbp) xfs_sb_version_addattr(sbp) | 296 | #define XFS_SB_VERSION_ADDATTR(sbp) xfs_sb_version_addattr(sbp) |
322 | #else | 297 | static inline void xfs_sb_version_addattr(xfs_sb_t *sbp) |
323 | #define XFS_SB_VERSION_ADDATTR(sbp) \ | 298 | { |
324 | ((sbp)->sb_versionnum = \ | 299 | (sbp)->sb_versionnum = (((sbp)->sb_versionnum == XFS_SB_VERSION_1) ? \ |
325 | (((sbp)->sb_versionnum == XFS_SB_VERSION_1) ? \ | ||
326 | XFS_SB_VERSION_2 : \ | 300 | XFS_SB_VERSION_2 : \ |
327 | ((XFS_SB_VERSION_NUM(sbp) == XFS_SB_VERSION_4) ? \ | 301 | ((XFS_SB_VERSION_NUM(sbp) == XFS_SB_VERSION_4) ? \ |
328 | ((sbp)->sb_versionnum | XFS_SB_VERSION_ATTRBIT) : \ | 302 | ((sbp)->sb_versionnum | XFS_SB_VERSION_ATTRBIT) : \ |
329 | (XFS_SB_VERSION_4 | XFS_SB_VERSION_ATTRBIT)))) | 303 | (XFS_SB_VERSION_4 | XFS_SB_VERSION_ATTRBIT))); |
330 | #endif | 304 | } |
331 | 305 | ||
332 | #if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_SB_VERSION_HASNLINK) | ||
333 | int xfs_sb_version_hasnlink(xfs_sb_t *sbp); | ||
334 | #define XFS_SB_VERSION_HASNLINK(sbp) xfs_sb_version_hasnlink(sbp) | 306 | #define XFS_SB_VERSION_HASNLINK(sbp) xfs_sb_version_hasnlink(sbp) |
335 | #else | 307 | static inline int xfs_sb_version_hasnlink(xfs_sb_t *sbp) |
336 | #define XFS_SB_VERSION_HASNLINK(sbp) \ | 308 | { |
337 | (((sbp)->sb_versionnum == XFS_SB_VERSION_3) || \ | 309 | return ((sbp)->sb_versionnum == XFS_SB_VERSION_3) || \ |
338 | ((XFS_SB_VERSION_NUM(sbp) == XFS_SB_VERSION_4) && \ | 310 | ((XFS_SB_VERSION_NUM(sbp) == XFS_SB_VERSION_4) && \ |
339 | ((sbp)->sb_versionnum & XFS_SB_VERSION_NLINKBIT))) | 311 | ((sbp)->sb_versionnum & XFS_SB_VERSION_NLINKBIT)); |
340 | #endif | 312 | } |
341 | 313 | ||
342 | #if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_SB_VERSION_ADDNLINK) | ||
343 | void xfs_sb_version_addnlink(xfs_sb_t *sbp); | ||
344 | #define XFS_SB_VERSION_ADDNLINK(sbp) xfs_sb_version_addnlink(sbp) | 314 | #define XFS_SB_VERSION_ADDNLINK(sbp) xfs_sb_version_addnlink(sbp) |
345 | #else | 315 | static inline void xfs_sb_version_addnlink(xfs_sb_t *sbp) |
346 | #define XFS_SB_VERSION_ADDNLINK(sbp) \ | 316 | { |
347 | ((sbp)->sb_versionnum = \ | 317 | (sbp)->sb_versionnum = ((sbp)->sb_versionnum <= XFS_SB_VERSION_2 ? \ |
348 | ((sbp)->sb_versionnum <= XFS_SB_VERSION_2 ? \ | ||
349 | XFS_SB_VERSION_3 : \ | 318 | XFS_SB_VERSION_3 : \ |
350 | ((sbp)->sb_versionnum | XFS_SB_VERSION_NLINKBIT))) | 319 | ((sbp)->sb_versionnum | XFS_SB_VERSION_NLINKBIT)); |
351 | #endif | 320 | } |
352 | 321 | ||
353 | #if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_SB_VERSION_HASQUOTA) | ||
354 | int xfs_sb_version_hasquota(xfs_sb_t *sbp); | ||
355 | #define XFS_SB_VERSION_HASQUOTA(sbp) xfs_sb_version_hasquota(sbp) | 322 | #define XFS_SB_VERSION_HASQUOTA(sbp) xfs_sb_version_hasquota(sbp) |
356 | #else | 323 | static inline int xfs_sb_version_hasquota(xfs_sb_t *sbp) |
357 | #define XFS_SB_VERSION_HASQUOTA(sbp) \ | 324 | { |
358 | ((XFS_SB_VERSION_NUM(sbp) == XFS_SB_VERSION_4) && \ | 325 | return (XFS_SB_VERSION_NUM(sbp) == XFS_SB_VERSION_4) && \ |
359 | ((sbp)->sb_versionnum & XFS_SB_VERSION_QUOTABIT)) | 326 | ((sbp)->sb_versionnum & XFS_SB_VERSION_QUOTABIT); |
360 | #endif | 327 | } |
361 | 328 | ||
362 | #if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_SB_VERSION_ADDQUOTA) | ||
363 | void xfs_sb_version_addquota(xfs_sb_t *sbp); | ||
364 | #define XFS_SB_VERSION_ADDQUOTA(sbp) xfs_sb_version_addquota(sbp) | 329 | #define XFS_SB_VERSION_ADDQUOTA(sbp) xfs_sb_version_addquota(sbp) |
365 | #else | 330 | static inline void xfs_sb_version_addquota(xfs_sb_t *sbp) |
366 | #define XFS_SB_VERSION_ADDQUOTA(sbp) \ | 331 | { |
367 | ((sbp)->sb_versionnum = \ | 332 | (sbp)->sb_versionnum = \ |
368 | (XFS_SB_VERSION_NUM(sbp) == XFS_SB_VERSION_4 ? \ | 333 | (XFS_SB_VERSION_NUM(sbp) == XFS_SB_VERSION_4 ? \ |
369 | ((sbp)->sb_versionnum | XFS_SB_VERSION_QUOTABIT) : \ | 334 | ((sbp)->sb_versionnum | XFS_SB_VERSION_QUOTABIT) : \ |
370 | (XFS_SB_VERSION_TONEW((sbp)->sb_versionnum) | \ | 335 | (XFS_SB_VERSION_TONEW((sbp)->sb_versionnum) | \ |
371 | XFS_SB_VERSION_QUOTABIT))) | 336 | XFS_SB_VERSION_QUOTABIT)); |
372 | #endif | 337 | } |
373 | 338 | ||
374 | #if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_SB_VERSION_HASALIGN) | ||
375 | int xfs_sb_version_hasalign(xfs_sb_t *sbp); | ||
376 | #define XFS_SB_VERSION_HASALIGN(sbp) xfs_sb_version_hasalign(sbp) | 339 | #define XFS_SB_VERSION_HASALIGN(sbp) xfs_sb_version_hasalign(sbp) |
377 | #else | 340 | static inline int xfs_sb_version_hasalign(xfs_sb_t *sbp) |
378 | #define XFS_SB_VERSION_HASALIGN(sbp) \ | 341 | { |
379 | ((XFS_SB_VERSION_NUM(sbp) == XFS_SB_VERSION_4) && \ | 342 | return (XFS_SB_VERSION_NUM(sbp) == XFS_SB_VERSION_4) && \ |
380 | ((sbp)->sb_versionnum & XFS_SB_VERSION_ALIGNBIT)) | 343 | ((sbp)->sb_versionnum & XFS_SB_VERSION_ALIGNBIT); |
381 | #endif | 344 | } |
382 | 345 | ||
383 | #if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_SB_VERSION_SUBALIGN) | ||
384 | void xfs_sb_version_subalign(xfs_sb_t *sbp); | ||
385 | #define XFS_SB_VERSION_SUBALIGN(sbp) xfs_sb_version_subalign(sbp) | 346 | #define XFS_SB_VERSION_SUBALIGN(sbp) xfs_sb_version_subalign(sbp) |
386 | #else | 347 | static inline void xfs_sb_version_subalign(xfs_sb_t *sbp) |
387 | #define XFS_SB_VERSION_SUBALIGN(sbp) \ | 348 | { |
388 | ((sbp)->sb_versionnum = \ | 349 | (sbp)->sb_versionnum = \ |
389 | XFS_SB_VERSION_TOOLD((sbp)->sb_versionnum & ~XFS_SB_VERSION_ALIGNBIT)) | 350 | XFS_SB_VERSION_TOOLD((sbp)->sb_versionnum & ~XFS_SB_VERSION_ALIGNBIT); |
390 | #endif | 351 | } |
391 | 352 | ||
392 | #if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_SB_VERSION_HASDALIGN) | ||
393 | int xfs_sb_version_hasdalign(xfs_sb_t *sbp); | ||
394 | #define XFS_SB_VERSION_HASDALIGN(sbp) xfs_sb_version_hasdalign(sbp) | 353 | #define XFS_SB_VERSION_HASDALIGN(sbp) xfs_sb_version_hasdalign(sbp) |
395 | #else | 354 | static inline int xfs_sb_version_hasdalign(xfs_sb_t *sbp) |
396 | #define XFS_SB_VERSION_HASDALIGN(sbp) \ | 355 | { |
397 | ((XFS_SB_VERSION_NUM(sbp) == XFS_SB_VERSION_4) && \ | 356 | return (XFS_SB_VERSION_NUM(sbp) == XFS_SB_VERSION_4) && \ |
398 | ((sbp)->sb_versionnum & XFS_SB_VERSION_DALIGNBIT)) | 357 | ((sbp)->sb_versionnum & XFS_SB_VERSION_DALIGNBIT); |
399 | #endif | 358 | } |
400 | 359 | ||
401 | #if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_SB_VERSION_ADDDALIGN) | ||
402 | int xfs_sb_version_adddalign(xfs_sb_t *sbp); | ||
403 | #define XFS_SB_VERSION_ADDDALIGN(sbp) xfs_sb_version_adddalign(sbp) | 360 | #define XFS_SB_VERSION_ADDDALIGN(sbp) xfs_sb_version_adddalign(sbp) |
404 | #else | 361 | static inline int xfs_sb_version_adddalign(xfs_sb_t *sbp) |
405 | #define XFS_SB_VERSION_ADDDALIGN(sbp) \ | 362 | { |
406 | ((sbp)->sb_versionnum = \ | 363 | return (sbp)->sb_versionnum = \ |
407 | ((sbp)->sb_versionnum | XFS_SB_VERSION_DALIGNBIT)) | 364 | ((sbp)->sb_versionnum | XFS_SB_VERSION_DALIGNBIT); |
408 | #endif | 365 | } |
409 | 366 | ||
410 | #if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_SB_VERSION_HASSHARED) | ||
411 | int xfs_sb_version_hasshared(xfs_sb_t *sbp); | ||
412 | #define XFS_SB_VERSION_HASSHARED(sbp) xfs_sb_version_hasshared(sbp) | 367 | #define XFS_SB_VERSION_HASSHARED(sbp) xfs_sb_version_hasshared(sbp) |
413 | #else | 368 | static inline int xfs_sb_version_hasshared(xfs_sb_t *sbp) |
414 | #define XFS_SB_VERSION_HASSHARED(sbp) \ | 369 | { |
415 | ((XFS_SB_VERSION_NUM(sbp) == XFS_SB_VERSION_4) && \ | 370 | return (XFS_SB_VERSION_NUM(sbp) == XFS_SB_VERSION_4) && \ |
416 | ((sbp)->sb_versionnum & XFS_SB_VERSION_SHAREDBIT)) | 371 | ((sbp)->sb_versionnum & XFS_SB_VERSION_SHAREDBIT); |
417 | #endif | 372 | } |
418 | 373 | ||
419 | #if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_SB_VERSION_ADDSHARED) | ||
420 | int xfs_sb_version_addshared(xfs_sb_t *sbp); | ||
421 | #define XFS_SB_VERSION_ADDSHARED(sbp) xfs_sb_version_addshared(sbp) | 374 | #define XFS_SB_VERSION_ADDSHARED(sbp) xfs_sb_version_addshared(sbp) |
422 | #else | 375 | static inline int xfs_sb_version_addshared(xfs_sb_t *sbp) |
423 | #define XFS_SB_VERSION_ADDSHARED(sbp) \ | 376 | { |
424 | ((sbp)->sb_versionnum = \ | 377 | return (sbp)->sb_versionnum = \ |
425 | ((sbp)->sb_versionnum | XFS_SB_VERSION_SHAREDBIT)) | 378 | ((sbp)->sb_versionnum | XFS_SB_VERSION_SHAREDBIT); |
426 | #endif | 379 | } |
427 | 380 | ||
428 | #if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_SB_VERSION_SUBSHARED) | ||
429 | int xfs_sb_version_subshared(xfs_sb_t *sbp); | ||
430 | #define XFS_SB_VERSION_SUBSHARED(sbp) xfs_sb_version_subshared(sbp) | 381 | #define XFS_SB_VERSION_SUBSHARED(sbp) xfs_sb_version_subshared(sbp) |
431 | #else | 382 | static inline int xfs_sb_version_subshared(xfs_sb_t *sbp) |
432 | #define XFS_SB_VERSION_SUBSHARED(sbp) \ | 383 | { |
433 | ((sbp)->sb_versionnum = \ | 384 | return (sbp)->sb_versionnum = \ |
434 | ((sbp)->sb_versionnum & ~XFS_SB_VERSION_SHAREDBIT)) | 385 | ((sbp)->sb_versionnum & ~XFS_SB_VERSION_SHAREDBIT); |
435 | #endif | 386 | } |
436 | 387 | ||
437 | #if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_SB_VERSION_HASDIRV2) | ||
438 | int xfs_sb_version_hasdirv2(xfs_sb_t *sbp); | ||
439 | #define XFS_SB_VERSION_HASDIRV2(sbp) xfs_sb_version_hasdirv2(sbp) | 388 | #define XFS_SB_VERSION_HASDIRV2(sbp) xfs_sb_version_hasdirv2(sbp) |
440 | #else | 389 | static inline int xfs_sb_version_hasdirv2(xfs_sb_t *sbp) |
441 | #define XFS_SB_VERSION_HASDIRV2(sbp) \ | 390 | { |
442 | ((XFS_SB_VERSION_NUM(sbp) == XFS_SB_VERSION_4) && \ | 391 | return (XFS_SB_VERSION_NUM(sbp) == XFS_SB_VERSION_4) && \ |
443 | ((sbp)->sb_versionnum & XFS_SB_VERSION_DIRV2BIT)) | 392 | ((sbp)->sb_versionnum & XFS_SB_VERSION_DIRV2BIT); |
444 | #endif | 393 | } |
445 | 394 | ||
446 | #if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_SB_VERSION_HASLOGV2) | ||
447 | int xfs_sb_version_haslogv2(xfs_sb_t *sbp); | ||
448 | #define XFS_SB_VERSION_HASLOGV2(sbp) xfs_sb_version_haslogv2(sbp) | 395 | #define XFS_SB_VERSION_HASLOGV2(sbp) xfs_sb_version_haslogv2(sbp) |
449 | #else | 396 | static inline int xfs_sb_version_haslogv2(xfs_sb_t *sbp) |
450 | #define XFS_SB_VERSION_HASLOGV2(sbp) \ | 397 | { |
451 | ((XFS_SB_VERSION_NUM(sbp) == XFS_SB_VERSION_4) && \ | 398 | return (XFS_SB_VERSION_NUM(sbp) == XFS_SB_VERSION_4) && \ |
452 | ((sbp)->sb_versionnum & XFS_SB_VERSION_LOGV2BIT)) | 399 | ((sbp)->sb_versionnum & XFS_SB_VERSION_LOGV2BIT); |
453 | #endif | 400 | } |
454 | 401 | ||
455 | #if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_SB_VERSION_HASEXTFLGBIT) | ||
456 | int xfs_sb_version_hasextflgbit(xfs_sb_t *sbp); | ||
457 | #define XFS_SB_VERSION_HASEXTFLGBIT(sbp) xfs_sb_version_hasextflgbit(sbp) | 402 | #define XFS_SB_VERSION_HASEXTFLGBIT(sbp) xfs_sb_version_hasextflgbit(sbp) |
458 | #else | 403 | static inline int xfs_sb_version_hasextflgbit(xfs_sb_t *sbp) |
459 | #define XFS_SB_VERSION_HASEXTFLGBIT(sbp) \ | 404 | { |
460 | ((XFS_SB_VERSION_NUM(sbp) == XFS_SB_VERSION_4) && \ | 405 | return (XFS_SB_VERSION_NUM(sbp) == XFS_SB_VERSION_4) && \ |
461 | ((sbp)->sb_versionnum & XFS_SB_VERSION_EXTFLGBIT)) | 406 | ((sbp)->sb_versionnum & XFS_SB_VERSION_EXTFLGBIT); |
462 | #endif | 407 | } |
463 | 408 | ||
464 | #if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_SB_VERSION_ADDEXTFLGBIT) | ||
465 | int xfs_sb_version_addextflgbit(xfs_sb_t *sbp); | ||
466 | #define XFS_SB_VERSION_ADDEXTFLGBIT(sbp) xfs_sb_version_addextflgbit(sbp) | 409 | #define XFS_SB_VERSION_ADDEXTFLGBIT(sbp) xfs_sb_version_addextflgbit(sbp) |
467 | #else | 410 | static inline int xfs_sb_version_addextflgbit(xfs_sb_t *sbp) |
468 | #define XFS_SB_VERSION_ADDEXTFLGBIT(sbp) \ | 411 | { |
469 | ((sbp)->sb_versionnum = \ | 412 | return (sbp)->sb_versionnum = \ |
470 | ((sbp)->sb_versionnum | XFS_SB_VERSION_EXTFLGBIT)) | 413 | ((sbp)->sb_versionnum | XFS_SB_VERSION_EXTFLGBIT); |
471 | #endif | 414 | } |
472 | 415 | ||
473 | #if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_SB_VERSION_SUBEXTFLGBIT) | ||
474 | int xfs_sb_version_subextflgbit(xfs_sb_t *sbp); | ||
475 | #define XFS_SB_VERSION_SUBEXTFLGBIT(sbp) xfs_sb_version_subextflgbit(sbp) | 416 | #define XFS_SB_VERSION_SUBEXTFLGBIT(sbp) xfs_sb_version_subextflgbit(sbp) |
476 | #else | 417 | static inline int xfs_sb_version_subextflgbit(xfs_sb_t *sbp) |
477 | #define XFS_SB_VERSION_SUBEXTFLGBIT(sbp) \ | 418 | { |
478 | ((sbp)->sb_versionnum = \ | 419 | return (sbp)->sb_versionnum = \ |
479 | ((sbp)->sb_versionnum & ~XFS_SB_VERSION_EXTFLGBIT)) | 420 | ((sbp)->sb_versionnum & ~XFS_SB_VERSION_EXTFLGBIT); |
480 | #endif | 421 | } |
481 | 422 | ||
482 | #if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_SB_VERSION_HASSECTOR) | ||
483 | int xfs_sb_version_hassector(xfs_sb_t *sbp); | ||
484 | #define XFS_SB_VERSION_HASSECTOR(sbp) xfs_sb_version_hassector(sbp) | 423 | #define XFS_SB_VERSION_HASSECTOR(sbp) xfs_sb_version_hassector(sbp) |
485 | #else | 424 | static inline int xfs_sb_version_hassector(xfs_sb_t *sbp) |
486 | #define XFS_SB_VERSION_HASSECTOR(sbp) \ | 425 | { |
487 | ((XFS_SB_VERSION_NUM(sbp) == XFS_SB_VERSION_4) && \ | 426 | return (XFS_SB_VERSION_NUM(sbp) == XFS_SB_VERSION_4) && \ |
488 | ((sbp)->sb_versionnum & XFS_SB_VERSION_SECTORBIT)) | 427 | ((sbp)->sb_versionnum & XFS_SB_VERSION_SECTORBIT); |
489 | #endif | 428 | } |
490 | 429 | ||
491 | #if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_SB_VERSION_HASMOREBITSBIT) | ||
492 | int xfs_sb_version_hasmorebits(xfs_sb_t *sbp); | ||
493 | #define XFS_SB_VERSION_HASMOREBITS(sbp) xfs_sb_version_hasmorebits(sbp) | 430 | #define XFS_SB_VERSION_HASMOREBITS(sbp) xfs_sb_version_hasmorebits(sbp) |
494 | #else | 431 | static inline int xfs_sb_version_hasmorebits(xfs_sb_t *sbp) |
495 | #define XFS_SB_VERSION_HASMOREBITS(sbp) \ | 432 | { |
496 | ((XFS_SB_VERSION_NUM(sbp) == XFS_SB_VERSION_4) && \ | 433 | return (XFS_SB_VERSION_NUM(sbp) == XFS_SB_VERSION_4) && \ |
497 | ((sbp)->sb_versionnum & XFS_SB_VERSION_MOREBITSBIT)) | 434 | ((sbp)->sb_versionnum & XFS_SB_VERSION_MOREBITSBIT); |
498 | #endif | 435 | } |
499 | 436 | ||
500 | /* | 437 | /* |
501 | * sb_features2 bit version macros. | 438 | * sb_features2 bit version macros. |
502 | * | 439 | * |
503 | * For example, for a bit defined as XFS_SB_VERSION2_YBIT, has a macro: | 440 | * For example, for a bit defined as XFS_SB_VERSION2_FUNBIT, has a macro: |
504 | * | 441 | * |
505 | * SB_VERSION_HASYBIT(xfs_sb_t *sbp) | 442 | * SB_VERSION_HASFUNBIT(xfs_sb_t *sbp) |
506 | * ((XFS_SB_VERSION_HASMOREBITS(sbp) && | 443 | * ((XFS_SB_VERSION_HASMOREBITS(sbp) && |
507 | * ((sbp)->sb_versionnum & XFS_SB_VERSION2_YBIT) | 444 | * ((sbp)->sb_features2 & XFS_SB_VERSION2_FUNBIT) |
508 | */ | 445 | */ |
509 | 446 | ||
447 | #define XFS_SB_VERSION_HASATTR2(sbp) xfs_sb_version_hasattr2(sbp) | ||
448 | static inline int xfs_sb_version_hasattr2(xfs_sb_t *sbp) | ||
449 | { | ||
450 | return (XFS_SB_VERSION_HASMOREBITS(sbp)) && \ | ||
451 | ((sbp)->sb_features2 & XFS_SB_VERSION2_ATTR2BIT); | ||
452 | } | ||
453 | |||
454 | #define XFS_SB_VERSION_ADDATTR2(sbp) xfs_sb_version_addattr2(sbp) | ||
455 | static inline void xfs_sb_version_addattr2(xfs_sb_t *sbp) | ||
456 | { | ||
457 | ((sbp)->sb_versionnum = \ | ||
458 | ((sbp)->sb_versionnum | XFS_SB_VERSION_MOREBITSBIT), \ | ||
459 | ((sbp)->sb_features2 = \ | ||
460 | ((sbp)->sb_features2 | XFS_SB_VERSION2_ATTR2BIT))); | ||
461 | } | ||
462 | |||
510 | /* | 463 | /* |
511 | * end of superblock version macros | 464 | * end of superblock version macros |
512 | */ | 465 | */ |
513 | 466 | ||
514 | #define XFS_SB_DADDR ((xfs_daddr_t)0) /* daddr in filesystem/ag */ | 467 | #define XFS_SB_DADDR ((xfs_daddr_t)0) /* daddr in filesystem/ag */ |
515 | #if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_SB_BLOCK) | ||
516 | xfs_agblock_t xfs_sb_block(struct xfs_mount *mp); | ||
517 | #define XFS_SB_BLOCK(mp) xfs_sb_block(mp) | ||
518 | #else | ||
519 | #define XFS_SB_BLOCK(mp) XFS_HDR_BLOCK(mp, XFS_SB_DADDR) | 468 | #define XFS_SB_BLOCK(mp) XFS_HDR_BLOCK(mp, XFS_SB_DADDR) |
520 | #endif | ||
521 | |||
522 | #if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_HDR_BLOCK) | ||
523 | xfs_agblock_t xfs_hdr_block(struct xfs_mount *mp, xfs_daddr_t d); | ||
524 | #define XFS_HDR_BLOCK(mp,d) xfs_hdr_block(mp,d) | ||
525 | #else | ||
526 | #define XFS_HDR_BLOCK(mp,d) ((xfs_agblock_t)(XFS_BB_TO_FSBT(mp,d))) | ||
527 | #endif | ||
528 | #if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_DADDR_TO_FSB) | ||
529 | xfs_fsblock_t xfs_daddr_to_fsb(struct xfs_mount *mp, xfs_daddr_t d); | ||
530 | #define XFS_DADDR_TO_FSB(mp,d) xfs_daddr_to_fsb(mp,d) | ||
531 | #else | ||
532 | #define XFS_DADDR_TO_FSB(mp,d) \ | ||
533 | XFS_AGB_TO_FSB(mp, XFS_DADDR_TO_AGNO(mp,d), XFS_DADDR_TO_AGBNO(mp,d)) | ||
534 | #endif | ||
535 | #if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_FSB_TO_DADDR) | ||
536 | xfs_daddr_t xfs_fsb_to_daddr(struct xfs_mount *mp, xfs_fsblock_t fsbno); | ||
537 | #define XFS_FSB_TO_DADDR(mp,fsbno) xfs_fsb_to_daddr(mp,fsbno) | ||
538 | #else | ||
539 | #define XFS_FSB_TO_DADDR(mp,fsbno) \ | ||
540 | XFS_AGB_TO_DADDR(mp, XFS_FSB_TO_AGNO(mp,fsbno), \ | ||
541 | XFS_FSB_TO_AGBNO(mp,fsbno)) | ||
542 | #endif | ||
543 | |||
544 | #if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_BUF_TO_SBP) | ||
545 | xfs_sb_t *xfs_buf_to_sbp(struct xfs_buf *bp); | ||
546 | #define XFS_BUF_TO_SBP(bp) xfs_buf_to_sbp(bp) | ||
547 | #else | ||
548 | #define XFS_BUF_TO_SBP(bp) ((xfs_sb_t *)XFS_BUF_PTR(bp)) | 469 | #define XFS_BUF_TO_SBP(bp) ((xfs_sb_t *)XFS_BUF_PTR(bp)) |
549 | #endif | 470 | |
471 | #define XFS_HDR_BLOCK(mp,d) ((xfs_agblock_t)XFS_BB_TO_FSBT(mp,d)) | ||
472 | #define XFS_DADDR_TO_FSB(mp,d) XFS_AGB_TO_FSB(mp, \ | ||
473 | XFS_DADDR_TO_AGNO(mp,d), XFS_DADDR_TO_AGBNO(mp,d)) | ||
474 | #define XFS_FSB_TO_DADDR(mp,fsbno) XFS_AGB_TO_DADDR(mp, \ | ||
475 | XFS_FSB_TO_AGNO(mp,fsbno), XFS_FSB_TO_AGBNO(mp,fsbno)) | ||
550 | 476 | ||
551 | /* | 477 | /* |
552 | * File system sector to basic block conversions. | 478 | * File system sector to basic block conversions. |
diff --git a/fs/xfs/xfs_trans.c b/fs/xfs/xfs_trans.c index 92efe272b83d..279e043d7323 100644 --- a/fs/xfs/xfs_trans.c +++ b/fs/xfs/xfs_trans.c | |||
@@ -1,40 +1,26 @@ | |||
1 | /* | 1 | /* |
2 | * Copyright (c) 2000-2003 Silicon Graphics, Inc. All Rights Reserved. | 2 | * Copyright (c) 2000-2003,2005 Silicon Graphics, Inc. |
3 | * All Rights Reserved. | ||
3 | * | 4 | * |
4 | * This program is free software; you can redistribute it and/or modify it | 5 | * This program is free software; you can redistribute it and/or |
5 | * under the terms of version 2 of the GNU General Public License as | 6 | * modify it under the terms of the GNU General Public License as |
6 | * published by the Free Software Foundation. | 7 | * published by the Free Software Foundation. |
7 | * | 8 | * |
8 | * This program is distributed in the hope that it would be useful, but | 9 | * This program is distributed in the hope that it would be useful, |
9 | * WITHOUT ANY WARRANTY; without even the implied warranty of | 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
12 | * GNU General Public License for more details. | ||
11 | * | 13 | * |
12 | * Further, this software is distributed without any warranty that it is | 14 | * You should have received a copy of the GNU General Public License |
13 | * free of the rightful claim of any third person regarding infringement | 15 | * along with this program; if not, write the Free Software Foundation, |
14 | * or the like. Any license provided herein, whether implied or | 16 | * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
15 | * otherwise, applies only to this software file. Patent licenses, if | ||
16 | * any, provided herein do not apply to combinations of this program with | ||
17 | * other software, or any other product whatsoever. | ||
18 | * | ||
19 | * You should have received a copy of the GNU General Public License along | ||
20 | * with this program; if not, write the Free Software Foundation, Inc., 59 | ||
21 | * Temple Place - Suite 330, Boston MA 02111-1307, USA. | ||
22 | * | ||
23 | * Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy, | ||
24 | * Mountain View, CA 94043, or: | ||
25 | * | ||
26 | * http://www.sgi.com | ||
27 | * | ||
28 | * For further information regarding this notice, see: | ||
29 | * | ||
30 | * http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/ | ||
31 | */ | 17 | */ |
32 | |||
33 | #include "xfs.h" | 18 | #include "xfs.h" |
34 | #include "xfs_macros.h" | 19 | #include "xfs_fs.h" |
35 | #include "xfs_types.h" | 20 | #include "xfs_types.h" |
36 | #include "xfs_inum.h" | 21 | #include "xfs_bit.h" |
37 | #include "xfs_log.h" | 22 | #include "xfs_log.h" |
23 | #include "xfs_inum.h" | ||
38 | #include "xfs_trans.h" | 24 | #include "xfs_trans.h" |
39 | #include "xfs_sb.h" | 25 | #include "xfs_sb.h" |
40 | #include "xfs_ag.h" | 26 | #include "xfs_ag.h" |
@@ -43,21 +29,21 @@ | |||
43 | #include "xfs_dmapi.h" | 29 | #include "xfs_dmapi.h" |
44 | #include "xfs_mount.h" | 30 | #include "xfs_mount.h" |
45 | #include "xfs_error.h" | 31 | #include "xfs_error.h" |
46 | #include "xfs_trans_priv.h" | 32 | #include "xfs_da_btree.h" |
47 | #include "xfs_alloc_btree.h" | ||
48 | #include "xfs_bmap_btree.h" | 33 | #include "xfs_bmap_btree.h" |
34 | #include "xfs_alloc_btree.h" | ||
49 | #include "xfs_ialloc_btree.h" | 35 | #include "xfs_ialloc_btree.h" |
50 | #include "xfs_btree.h" | ||
51 | #include "xfs_ialloc.h" | ||
52 | #include "xfs_alloc.h" | ||
53 | #include "xfs_attr_sf.h" | ||
54 | #include "xfs_dir_sf.h" | 36 | #include "xfs_dir_sf.h" |
55 | #include "xfs_dir2_sf.h" | 37 | #include "xfs_dir2_sf.h" |
38 | #include "xfs_attr_sf.h" | ||
56 | #include "xfs_dinode.h" | 39 | #include "xfs_dinode.h" |
57 | #include "xfs_inode.h" | 40 | #include "xfs_inode.h" |
41 | #include "xfs_btree.h" | ||
42 | #include "xfs_ialloc.h" | ||
43 | #include "xfs_alloc.h" | ||
58 | #include "xfs_bmap.h" | 44 | #include "xfs_bmap.h" |
59 | #include "xfs_da_btree.h" | ||
60 | #include "xfs_quota.h" | 45 | #include "xfs_quota.h" |
46 | #include "xfs_trans_priv.h" | ||
61 | #include "xfs_trans_space.h" | 47 | #include "xfs_trans_space.h" |
62 | 48 | ||
63 | 49 | ||
@@ -190,12 +176,8 @@ xfs_trans_dup( | |||
190 | XFS_LBC_INIT(&(ntp->t_busy)); | 176 | XFS_LBC_INIT(&(ntp->t_busy)); |
191 | 177 | ||
192 | ASSERT(tp->t_flags & XFS_TRANS_PERM_LOG_RES); | 178 | ASSERT(tp->t_flags & XFS_TRANS_PERM_LOG_RES); |
193 | |||
194 | #if defined(XLOG_NOLOG) || defined(DEBUG) | ||
195 | ASSERT(!xlog_debug || tp->t_ticket != NULL); | ||
196 | #else | ||
197 | ASSERT(tp->t_ticket != NULL); | 179 | ASSERT(tp->t_ticket != NULL); |
198 | #endif | 180 | |
199 | ntp->t_flags = XFS_TRANS_PERM_LOG_RES | (tp->t_flags & XFS_TRANS_RESERVE); | 181 | ntp->t_flags = XFS_TRANS_PERM_LOG_RES | (tp->t_flags & XFS_TRANS_RESERVE); |
200 | ntp->t_ticket = tp->t_ticket; | 182 | ntp->t_ticket = tp->t_ticket; |
201 | ntp->t_blk_res = tp->t_blk_res - tp->t_blk_res_used; | 183 | ntp->t_blk_res = tp->t_blk_res - tp->t_blk_res_used; |
@@ -661,10 +643,11 @@ xfs_trans_unreserve_and_mod_sb( | |||
661 | */ | 643 | */ |
662 | /*ARGSUSED*/ | 644 | /*ARGSUSED*/ |
663 | int | 645 | int |
664 | xfs_trans_commit( | 646 | _xfs_trans_commit( |
665 | xfs_trans_t *tp, | 647 | xfs_trans_t *tp, |
666 | uint flags, | 648 | uint flags, |
667 | xfs_lsn_t *commit_lsn_p) | 649 | xfs_lsn_t *commit_lsn_p, |
650 | int *log_flushed) | ||
668 | { | 651 | { |
669 | xfs_log_iovec_t *log_vector; | 652 | xfs_log_iovec_t *log_vector; |
670 | int nvec; | 653 | int nvec; |
@@ -676,9 +659,6 @@ xfs_trans_commit( | |||
676 | int sync; | 659 | int sync; |
677 | #define XFS_TRANS_LOGVEC_COUNT 16 | 660 | #define XFS_TRANS_LOGVEC_COUNT 16 |
678 | xfs_log_iovec_t log_vector_fast[XFS_TRANS_LOGVEC_COUNT]; | 661 | xfs_log_iovec_t log_vector_fast[XFS_TRANS_LOGVEC_COUNT]; |
679 | #if defined(XLOG_NOLOG) || defined(DEBUG) | ||
680 | static xfs_lsn_t trans_lsn = 1; | ||
681 | #endif | ||
682 | void *commit_iclog; | 662 | void *commit_iclog; |
683 | int shutdown; | 663 | int shutdown; |
684 | 664 | ||
@@ -729,11 +709,7 @@ shut_us_down: | |||
729 | *commit_lsn_p = commit_lsn; | 709 | *commit_lsn_p = commit_lsn; |
730 | return (shutdown); | 710 | return (shutdown); |
731 | } | 711 | } |
732 | #if defined(XLOG_NOLOG) || defined(DEBUG) | ||
733 | ASSERT(!xlog_debug || tp->t_ticket != NULL); | ||
734 | #else | ||
735 | ASSERT(tp->t_ticket != NULL); | 712 | ASSERT(tp->t_ticket != NULL); |
736 | #endif | ||
737 | 713 | ||
738 | /* | 714 | /* |
739 | * If we need to update the superblock, then do it now. | 715 | * If we need to update the superblock, then do it now. |
@@ -750,14 +726,10 @@ shut_us_down: | |||
750 | * by using a vector from the stack when it fits. | 726 | * by using a vector from the stack when it fits. |
751 | */ | 727 | */ |
752 | nvec = xfs_trans_count_vecs(tp); | 728 | nvec = xfs_trans_count_vecs(tp); |
753 | |||
754 | if (nvec == 0) { | 729 | if (nvec == 0) { |
755 | xfs_force_shutdown(mp, XFS_LOG_IO_ERROR); | 730 | xfs_force_shutdown(mp, XFS_LOG_IO_ERROR); |
756 | goto shut_us_down; | 731 | goto shut_us_down; |
757 | } | 732 | } else if (nvec <= XFS_TRANS_LOGVEC_COUNT) { |
758 | |||
759 | |||
760 | if (nvec <= XFS_TRANS_LOGVEC_COUNT) { | ||
761 | log_vector = log_vector_fast; | 733 | log_vector = log_vector_fast; |
762 | } else { | 734 | } else { |
763 | log_vector = (xfs_log_iovec_t *)kmem_alloc(nvec * | 735 | log_vector = (xfs_log_iovec_t *)kmem_alloc(nvec * |
@@ -771,30 +743,14 @@ shut_us_down: | |||
771 | */ | 743 | */ |
772 | xfs_trans_fill_vecs(tp, log_vector); | 744 | xfs_trans_fill_vecs(tp, log_vector); |
773 | 745 | ||
774 | /* | 746 | error = xfs_log_write(mp, log_vector, nvec, tp->t_ticket, &(tp->t_lsn)); |
775 | * Ignore errors here. xfs_log_done would do the right thing. | ||
776 | * We need to put the ticket, etc. away. | ||
777 | */ | ||
778 | error = xfs_log_write(mp, log_vector, nvec, tp->t_ticket, | ||
779 | &(tp->t_lsn)); | ||
780 | 747 | ||
781 | #if defined(XLOG_NOLOG) || defined(DEBUG) | ||
782 | if (xlog_debug) { | ||
783 | commit_lsn = xfs_log_done(mp, tp->t_ticket, | ||
784 | &commit_iclog, log_flags); | ||
785 | } else { | ||
786 | commit_lsn = 0; | ||
787 | tp->t_lsn = trans_lsn++; | ||
788 | } | ||
789 | #else | ||
790 | /* | 748 | /* |
791 | * This is the regular case. At this point (after the call finishes), | 749 | * The transaction is committed incore here, and can go out to disk |
792 | * the transaction is committed incore and could go out to disk at | 750 | * at any time after this call. However, all the items associated |
793 | * any time. However, all the items associated with the transaction | 751 | * with the transaction are still locked and pinned in memory. |
794 | * are still locked and pinned in memory. | ||
795 | */ | 752 | */ |
796 | commit_lsn = xfs_log_done(mp, tp->t_ticket, &commit_iclog, log_flags); | 753 | commit_lsn = xfs_log_done(mp, tp->t_ticket, &commit_iclog, log_flags); |
797 | #endif | ||
798 | 754 | ||
799 | tp->t_commit_lsn = commit_lsn; | 755 | tp->t_commit_lsn = commit_lsn; |
800 | if (nvec > XFS_TRANS_LOGVEC_COUNT) { | 756 | if (nvec > XFS_TRANS_LOGVEC_COUNT) { |
@@ -893,9 +849,11 @@ shut_us_down: | |||
893 | * log out now and wait for it. | 849 | * log out now and wait for it. |
894 | */ | 850 | */ |
895 | if (sync) { | 851 | if (sync) { |
896 | if (!error) | 852 | if (!error) { |
897 | error = xfs_log_force(mp, commit_lsn, | 853 | error = _xfs_log_force(mp, commit_lsn, |
898 | XFS_LOG_FORCE | XFS_LOG_SYNC); | 854 | XFS_LOG_FORCE | XFS_LOG_SYNC, |
855 | log_flushed); | ||
856 | } | ||
899 | XFS_STATS_INC(xs_trans_sync); | 857 | XFS_STATS_INC(xs_trans_sync); |
900 | } else { | 858 | } else { |
901 | XFS_STATS_INC(xs_trans_async); | 859 | XFS_STATS_INC(xs_trans_async); |
diff --git a/fs/xfs/xfs_trans.h b/fs/xfs/xfs_trans.h index a263aec8b3a6..a889963fdd14 100644 --- a/fs/xfs/xfs_trans.h +++ b/fs/xfs/xfs_trans.h | |||
@@ -1,33 +1,19 @@ | |||
1 | /* | 1 | /* |
2 | * Copyright (c) 2000-2002 Silicon Graphics, Inc. All Rights Reserved. | 2 | * Copyright (c) 2000-2002,2005 Silicon Graphics, Inc. |
3 | * All Rights Reserved. | ||
3 | * | 4 | * |
4 | * This program is free software; you can redistribute it and/or modify it | 5 | * This program is free software; you can redistribute it and/or |
5 | * under the terms of version 2 of the GNU General Public License as | 6 | * modify it under the terms of the GNU General Public License as |
6 | * published by the Free Software Foundation. | 7 | * published by the Free Software Foundation. |
7 | * | 8 | * |
8 | * This program is distributed in the hope that it would be useful, but | 9 | * This program is distributed in the hope that it would be useful, |
9 | * WITHOUT ANY WARRANTY; without even the implied warranty of | 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
12 | * GNU General Public License for more details. | ||
11 | * | 13 | * |
12 | * Further, this software is distributed without any warranty that it is | 14 | * You should have received a copy of the GNU General Public License |
13 | * free of the rightful claim of any third person regarding infringement | 15 | * along with this program; if not, write the Free Software Foundation, |
14 | * or the like. Any license provided herein, whether implied or | 16 | * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
15 | * otherwise, applies only to this software file. Patent licenses, if | ||
16 | * any, provided herein do not apply to combinations of this program with | ||
17 | * other software, or any other product whatsoever. | ||
18 | * | ||
19 | * You should have received a copy of the GNU General Public License along | ||
20 | * with this program; if not, write the Free Software Foundation, Inc., 59 | ||
21 | * Temple Place - Suite 330, Boston MA 02111-1307, USA. | ||
22 | * | ||
23 | * Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy, | ||
24 | * Mountain View, CA 94043, or: | ||
25 | * | ||
26 | * http://www.sgi.com | ||
27 | * | ||
28 | * For further information regarding this notice, see: | ||
29 | * | ||
30 | * http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/ | ||
31 | */ | 17 | */ |
32 | #ifndef __XFS_TRANS_H__ | 18 | #ifndef __XFS_TRANS_H__ |
33 | #define __XFS_TRANS_H__ | 19 | #define __XFS_TRANS_H__ |
@@ -135,19 +121,6 @@ typedef struct xfs_ail_entry { | |||
135 | struct xfs_log_item *ail_back; /* AIL back pointer */ | 121 | struct xfs_log_item *ail_back; /* AIL back pointer */ |
136 | } xfs_ail_entry_t; | 122 | } xfs_ail_entry_t; |
137 | 123 | ||
138 | /* | ||
139 | * This structure is passed as a parameter to xfs_trans_push_ail() | ||
140 | * and is used to track the what LSN the waiting processes are | ||
141 | * waiting to become unused. | ||
142 | */ | ||
143 | typedef struct xfs_ail_ticket { | ||
144 | xfs_lsn_t at_lsn; /* lsn waitin for */ | ||
145 | struct xfs_ail_ticket *at_forw; /* wait list ptr */ | ||
146 | struct xfs_ail_ticket *at_back; /* wait list ptr */ | ||
147 | sv_t at_sema; /* wait sema */ | ||
148 | } xfs_ail_ticket_t; | ||
149 | |||
150 | |||
151 | typedef struct xfs_log_item { | 124 | typedef struct xfs_log_item { |
152 | xfs_ail_entry_t li_ail; /* AIL pointers */ | 125 | xfs_ail_entry_t li_ail; /* AIL pointers */ |
153 | xfs_lsn_t li_lsn; /* last on-disk lsn */ | 126 | xfs_lsn_t li_lsn; /* last on-disk lsn */ |
@@ -247,68 +220,67 @@ typedef struct xfs_log_item_chunk { | |||
247 | * lic_unused to the right value (0 matches all free). The | 220 | * lic_unused to the right value (0 matches all free). The |
248 | * lic_descs.lid_index values are set up as each desc is allocated. | 221 | * lic_descs.lid_index values are set up as each desc is allocated. |
249 | */ | 222 | */ |
250 | #if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_LIC_INIT) | ||
251 | void xfs_lic_init(xfs_log_item_chunk_t *cp); | ||
252 | #define XFS_LIC_INIT(cp) xfs_lic_init(cp) | 223 | #define XFS_LIC_INIT(cp) xfs_lic_init(cp) |
253 | #else | 224 | static inline void xfs_lic_init(xfs_log_item_chunk_t *cp) |
254 | #define XFS_LIC_INIT(cp) ((cp)->lic_free = XFS_LIC_FREEMASK) | 225 | { |
255 | #endif | 226 | cp->lic_free = XFS_LIC_FREEMASK; |
256 | #if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_LIC_INIT_SLOT) | 227 | } |
257 | void xfs_lic_init_slot(xfs_log_item_chunk_t *cp, int slot); | 228 | |
258 | #define XFS_LIC_INIT_SLOT(cp,slot) xfs_lic_init_slot(cp, slot) | 229 | #define XFS_LIC_INIT_SLOT(cp,slot) xfs_lic_init_slot(cp, slot) |
259 | #else | 230 | static inline void xfs_lic_init_slot(xfs_log_item_chunk_t *cp, int slot) |
260 | #define XFS_LIC_INIT_SLOT(cp,slot) \ | 231 | { |
261 | ((cp)->lic_descs[slot].lid_index = (unsigned char)(slot)) | 232 | cp->lic_descs[slot].lid_index = (unsigned char)(slot); |
262 | #endif | 233 | } |
263 | #if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_LIC_VACANCY) | 234 | |
264 | int xfs_lic_vacancy(xfs_log_item_chunk_t *cp); | ||
265 | #define XFS_LIC_VACANCY(cp) xfs_lic_vacancy(cp) | 235 | #define XFS_LIC_VACANCY(cp) xfs_lic_vacancy(cp) |
266 | #else | 236 | static inline int xfs_lic_vacancy(xfs_log_item_chunk_t *cp) |
267 | #define XFS_LIC_VACANCY(cp) (((cp)->lic_free) & XFS_LIC_FREEMASK) | 237 | { |
268 | #endif | 238 | return cp->lic_free & XFS_LIC_FREEMASK; |
269 | #if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_LIC_ALL_FREE) | 239 | } |
270 | void xfs_lic_all_free(xfs_log_item_chunk_t *cp); | 240 | |
271 | #define XFS_LIC_ALL_FREE(cp) xfs_lic_all_free(cp) | 241 | #define XFS_LIC_ALL_FREE(cp) xfs_lic_all_free(cp) |
272 | #else | 242 | static inline void xfs_lic_all_free(xfs_log_item_chunk_t *cp) |
273 | #define XFS_LIC_ALL_FREE(cp) ((cp)->lic_free = XFS_LIC_FREEMASK) | 243 | { |
274 | #endif | 244 | cp->lic_free = XFS_LIC_FREEMASK; |
275 | #if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_LIC_ARE_ALL_FREE) | 245 | } |
276 | int xfs_lic_are_all_free(xfs_log_item_chunk_t *cp); | 246 | |
277 | #define XFS_LIC_ARE_ALL_FREE(cp) xfs_lic_are_all_free(cp) | 247 | #define XFS_LIC_ARE_ALL_FREE(cp) xfs_lic_are_all_free(cp) |
278 | #else | 248 | static inline int xfs_lic_are_all_free(xfs_log_item_chunk_t *cp) |
279 | #define XFS_LIC_ARE_ALL_FREE(cp) (((cp)->lic_free & XFS_LIC_FREEMASK) ==\ | 249 | { |
280 | XFS_LIC_FREEMASK) | 250 | return ((cp->lic_free & XFS_LIC_FREEMASK) == XFS_LIC_FREEMASK); |
281 | #endif | 251 | } |
282 | #if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_LIC_ISFREE) | 252 | |
283 | int xfs_lic_isfree(xfs_log_item_chunk_t *cp, int slot); | ||
284 | #define XFS_LIC_ISFREE(cp,slot) xfs_lic_isfree(cp,slot) | 253 | #define XFS_LIC_ISFREE(cp,slot) xfs_lic_isfree(cp,slot) |
285 | #else | 254 | static inline int xfs_lic_isfree(xfs_log_item_chunk_t *cp, int slot) |
286 | #define XFS_LIC_ISFREE(cp,slot) ((cp)->lic_free & (1 << (slot))) | 255 | { |
287 | #endif | 256 | return (cp->lic_free & (1 << slot)); |
288 | #if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_LIC_CLAIM) | 257 | } |
289 | void xfs_lic_claim(xfs_log_item_chunk_t *cp, int slot); | 258 | |
290 | #define XFS_LIC_CLAIM(cp,slot) xfs_lic_claim(cp,slot) | 259 | #define XFS_LIC_CLAIM(cp,slot) xfs_lic_claim(cp,slot) |
291 | #else | 260 | static inline void xfs_lic_claim(xfs_log_item_chunk_t *cp, int slot) |
292 | #define XFS_LIC_CLAIM(cp,slot) ((cp)->lic_free &= ~(1 << (slot))) | 261 | { |
293 | #endif | 262 | cp->lic_free &= ~(1 << slot); |
294 | #if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_LIC_RELSE) | 263 | } |
295 | void xfs_lic_relse(xfs_log_item_chunk_t *cp, int slot); | 264 | |
296 | #define XFS_LIC_RELSE(cp,slot) xfs_lic_relse(cp,slot) | 265 | #define XFS_LIC_RELSE(cp,slot) xfs_lic_relse(cp,slot) |
297 | #else | 266 | static inline void xfs_lic_relse(xfs_log_item_chunk_t *cp, int slot) |
298 | #define XFS_LIC_RELSE(cp,slot) ((cp)->lic_free |= 1 << (slot)) | 267 | { |
299 | #endif | 268 | cp->lic_free |= 1 << slot; |
300 | #if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_LIC_SLOT) | 269 | } |
301 | xfs_log_item_desc_t *xfs_lic_slot(xfs_log_item_chunk_t *cp, int slot); | 270 | |
302 | #define XFS_LIC_SLOT(cp,slot) xfs_lic_slot(cp,slot) | 271 | #define XFS_LIC_SLOT(cp,slot) xfs_lic_slot(cp,slot) |
303 | #else | 272 | static inline xfs_log_item_desc_t * |
304 | #define XFS_LIC_SLOT(cp,slot) (&((cp)->lic_descs[slot])) | 273 | xfs_lic_slot(xfs_log_item_chunk_t *cp, int slot) |
305 | #endif | 274 | { |
306 | #if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_LIC_DESC_TO_SLOT) | 275 | return &(cp->lic_descs[slot]); |
307 | int xfs_lic_desc_to_slot(xfs_log_item_desc_t *dp); | 276 | } |
277 | |||
308 | #define XFS_LIC_DESC_TO_SLOT(dp) xfs_lic_desc_to_slot(dp) | 278 | #define XFS_LIC_DESC_TO_SLOT(dp) xfs_lic_desc_to_slot(dp) |
309 | #else | 279 | static inline int xfs_lic_desc_to_slot(xfs_log_item_desc_t *dp) |
310 | #define XFS_LIC_DESC_TO_SLOT(dp) ((uint)((dp)->lid_index)) | 280 | { |
311 | #endif | 281 | return (uint)dp->lid_index; |
282 | } | ||
283 | |||
312 | /* | 284 | /* |
313 | * Calculate the address of a chunk given a descriptor pointer: | 285 | * Calculate the address of a chunk given a descriptor pointer: |
314 | * dp - dp->lid_index give the address of the start of the lic_descs array. | 286 | * dp - dp->lid_index give the address of the start of the lic_descs array. |
@@ -316,15 +288,14 @@ int xfs_lic_desc_to_slot(xfs_log_item_desc_t *dp); | |||
316 | * All of this yields the address of the chunk, which is | 288 | * All of this yields the address of the chunk, which is |
317 | * cast to a chunk pointer. | 289 | * cast to a chunk pointer. |
318 | */ | 290 | */ |
319 | #if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_LIC_DESC_TO_CHUNK) | ||
320 | xfs_log_item_chunk_t *xfs_lic_desc_to_chunk(xfs_log_item_desc_t *dp); | ||
321 | #define XFS_LIC_DESC_TO_CHUNK(dp) xfs_lic_desc_to_chunk(dp) | 291 | #define XFS_LIC_DESC_TO_CHUNK(dp) xfs_lic_desc_to_chunk(dp) |
322 | #else | 292 | static inline xfs_log_item_chunk_t * |
323 | #define XFS_LIC_DESC_TO_CHUNK(dp) ((xfs_log_item_chunk_t*) \ | 293 | xfs_lic_desc_to_chunk(xfs_log_item_desc_t *dp) |
324 | (((xfs_caddr_t)((dp) - (dp)->lid_index)) -\ | 294 | { |
325 | (xfs_caddr_t)(((xfs_log_item_chunk_t*) \ | 295 | return (xfs_log_item_chunk_t*) \ |
326 | 0)->lic_descs))) | 296 | (((xfs_caddr_t)((dp) - (dp)->lid_index)) - \ |
327 | #endif | 297 | (xfs_caddr_t)(((xfs_log_item_chunk_t*)0)->lic_descs)); |
298 | } | ||
328 | 299 | ||
329 | #ifdef __KERNEL__ | 300 | #ifdef __KERNEL__ |
330 | /* | 301 | /* |
@@ -341,7 +312,7 @@ typedef struct xfs_log_busy_slot { | |||
341 | #define XFS_LBC_NUM_SLOTS 31 | 312 | #define XFS_LBC_NUM_SLOTS 31 |
342 | typedef struct xfs_log_busy_chunk { | 313 | typedef struct xfs_log_busy_chunk { |
343 | struct xfs_log_busy_chunk *lbc_next; | 314 | struct xfs_log_busy_chunk *lbc_next; |
344 | uint lbc_free; /* bitmask of free slots */ | 315 | uint lbc_free; /* free slots bitmask */ |
345 | ushort lbc_unused; /* first unused */ | 316 | ushort lbc_unused; /* first unused */ |
346 | xfs_log_busy_slot_t lbc_busy[XFS_LBC_NUM_SLOTS]; | 317 | xfs_log_busy_slot_t lbc_busy[XFS_LBC_NUM_SLOTS]; |
347 | } xfs_log_busy_chunk_t; | 318 | } xfs_log_busy_chunk_t; |
@@ -1025,7 +996,12 @@ void xfs_trans_log_efd_extent(xfs_trans_t *, | |||
1025 | struct xfs_efd_log_item *, | 996 | struct xfs_efd_log_item *, |
1026 | xfs_fsblock_t, | 997 | xfs_fsblock_t, |
1027 | xfs_extlen_t); | 998 | xfs_extlen_t); |
1028 | int xfs_trans_commit(xfs_trans_t *, uint flags, xfs_lsn_t *); | 999 | int _xfs_trans_commit(xfs_trans_t *, |
1000 | uint flags, | ||
1001 | xfs_lsn_t *, | ||
1002 | int *); | ||
1003 | #define xfs_trans_commit(tp, flags, lsn) \ | ||
1004 | _xfs_trans_commit(tp, flags, lsn, NULL) | ||
1029 | void xfs_trans_cancel(xfs_trans_t *, int); | 1005 | void xfs_trans_cancel(xfs_trans_t *, int); |
1030 | void xfs_trans_ail_init(struct xfs_mount *); | 1006 | void xfs_trans_ail_init(struct xfs_mount *); |
1031 | xfs_lsn_t xfs_trans_push_ail(struct xfs_mount *, xfs_lsn_t); | 1007 | xfs_lsn_t xfs_trans_push_ail(struct xfs_mount *, xfs_lsn_t); |
diff --git a/fs/xfs/xfs_trans_ail.c b/fs/xfs/xfs_trans_ail.c index 2a71b4f91bfa..19ab24af1c1c 100644 --- a/fs/xfs/xfs_trans_ail.c +++ b/fs/xfs/xfs_trans_ail.c | |||
@@ -1,40 +1,25 @@ | |||
1 | /* | 1 | /* |
2 | * Copyright (c) 2000-2002 Silicon Graphics, Inc. All Rights Reserved. | 2 | * Copyright (c) 2000-2002,2005 Silicon Graphics, Inc. |
3 | * All Rights Reserved. | ||
3 | * | 4 | * |
4 | * This program is free software; you can redistribute it and/or modify it | 5 | * This program is free software; you can redistribute it and/or |
5 | * under the terms of version 2 of the GNU General Public License as | 6 | * modify it under the terms of the GNU General Public License as |
6 | * published by the Free Software Foundation. | 7 | * published by the Free Software Foundation. |
7 | * | 8 | * |
8 | * This program is distributed in the hope that it would be useful, but | 9 | * This program is distributed in the hope that it would be useful, |
9 | * WITHOUT ANY WARRANTY; without even the implied warranty of | 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
12 | * GNU General Public License for more details. | ||
11 | * | 13 | * |
12 | * Further, this software is distributed without any warranty that it is | 14 | * You should have received a copy of the GNU General Public License |
13 | * free of the rightful claim of any third person regarding infringement | 15 | * along with this program; if not, write the Free Software Foundation, |
14 | * or the like. Any license provided herein, whether implied or | 16 | * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
15 | * otherwise, applies only to this software file. Patent licenses, if | ||
16 | * any, provided herein do not apply to combinations of this program with | ||
17 | * other software, or any other product whatsoever. | ||
18 | * | ||
19 | * You should have received a copy of the GNU General Public License along | ||
20 | * with this program; if not, write the Free Software Foundation, Inc., 59 | ||
21 | * Temple Place - Suite 330, Boston MA 02111-1307, USA. | ||
22 | * | ||
23 | * Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy, | ||
24 | * Mountain View, CA 94043, or: | ||
25 | * | ||
26 | * http://www.sgi.com | ||
27 | * | ||
28 | * For further information regarding this notice, see: | ||
29 | * | ||
30 | * http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/ | ||
31 | */ | 17 | */ |
32 | |||
33 | #include "xfs.h" | 18 | #include "xfs.h" |
34 | #include "xfs_macros.h" | 19 | #include "xfs_fs.h" |
35 | #include "xfs_types.h" | 20 | #include "xfs_types.h" |
36 | #include "xfs_inum.h" | ||
37 | #include "xfs_log.h" | 21 | #include "xfs_log.h" |
22 | #include "xfs_inum.h" | ||
38 | #include "xfs_trans.h" | 23 | #include "xfs_trans.h" |
39 | #include "xfs_sb.h" | 24 | #include "xfs_sb.h" |
40 | #include "xfs_dir.h" | 25 | #include "xfs_dir.h" |
diff --git a/fs/xfs/xfs_trans_buf.c b/fs/xfs/xfs_trans_buf.c index e733293dd7f4..c74c31ebc81c 100644 --- a/fs/xfs/xfs_trans_buf.c +++ b/fs/xfs/xfs_trans_buf.c | |||
@@ -1,47 +1,42 @@ | |||
1 | /* | 1 | /* |
2 | * Copyright (c) 2000-2002 Silicon Graphics, Inc. All Rights Reserved. | 2 | * Copyright (c) 2000-2002,2005 Silicon Graphics, Inc. |
3 | * All Rights Reserved. | ||
3 | * | 4 | * |
4 | * This program is free software; you can redistribute it and/or modify it | 5 | * This program is free software; you can redistribute it and/or |
5 | * under the terms of version 2 of the GNU General Public License as | 6 | * modify it under the terms of the GNU General Public License as |
6 | * published by the Free Software Foundation. | 7 | * published by the Free Software Foundation. |
7 | * | 8 | * |
8 | * This program is distributed in the hope that it would be useful, but | 9 | * This program is distributed in the hope that it would be useful, |
9 | * WITHOUT ANY WARRANTY; without even the implied warranty of | 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
12 | * GNU General Public License for more details. | ||
11 | * | 13 | * |
12 | * Further, this software is distributed without any warranty that it is | 14 | * You should have received a copy of the GNU General Public License |
13 | * free of the rightful claim of any third person regarding infringement | 15 | * along with this program; if not, write the Free Software Foundation, |
14 | * or the like. Any license provided herein, whether implied or | 16 | * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
15 | * otherwise, applies only to this software file. Patent licenses, if | ||
16 | * any, provided herein do not apply to combinations of this program with | ||
17 | * other software, or any other product whatsoever. | ||
18 | * | ||
19 | * You should have received a copy of the GNU General Public License along | ||
20 | * with this program; if not, write the Free Software Foundation, Inc., 59 | ||
21 | * Temple Place - Suite 330, Boston MA 02111-1307, USA. | ||
22 | * | ||
23 | * Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy, | ||
24 | * Mountain View, CA 94043, or: | ||
25 | * | ||
26 | * http://www.sgi.com | ||
27 | * | ||
28 | * For further information regarding this notice, see: | ||
29 | * | ||
30 | * http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/ | ||
31 | */ | 17 | */ |
32 | |||
33 | #include "xfs.h" | 18 | #include "xfs.h" |
34 | #include "xfs_macros.h" | 19 | #include "xfs_fs.h" |
35 | #include "xfs_types.h" | 20 | #include "xfs_types.h" |
36 | #include "xfs_inum.h" | 21 | #include "xfs_bit.h" |
37 | #include "xfs_log.h" | 22 | #include "xfs_log.h" |
23 | #include "xfs_inum.h" | ||
38 | #include "xfs_trans.h" | 24 | #include "xfs_trans.h" |
39 | #include "xfs_buf_item.h" | ||
40 | #include "xfs_sb.h" | 25 | #include "xfs_sb.h" |
41 | #include "xfs_ag.h" | 26 | #include "xfs_ag.h" |
42 | #include "xfs_dir.h" | 27 | #include "xfs_dir.h" |
28 | #include "xfs_dir2.h" | ||
43 | #include "xfs_dmapi.h" | 29 | #include "xfs_dmapi.h" |
44 | #include "xfs_mount.h" | 30 | #include "xfs_mount.h" |
31 | #include "xfs_bmap_btree.h" | ||
32 | #include "xfs_alloc_btree.h" | ||
33 | #include "xfs_ialloc_btree.h" | ||
34 | #include "xfs_dir_sf.h" | ||
35 | #include "xfs_dir2_sf.h" | ||
36 | #include "xfs_attr_sf.h" | ||
37 | #include "xfs_dinode.h" | ||
38 | #include "xfs_inode.h" | ||
39 | #include "xfs_buf_item.h" | ||
45 | #include "xfs_trans_priv.h" | 40 | #include "xfs_trans_priv.h" |
46 | #include "xfs_error.h" | 41 | #include "xfs_error.h" |
47 | #include "xfs_rw.h" | 42 | #include "xfs_rw.h" |
diff --git a/fs/xfs/xfs_trans_extfree.c b/fs/xfs/xfs_trans_extfree.c index 93259a15f983..7d7d627f25df 100644 --- a/fs/xfs/xfs_trans_extfree.c +++ b/fs/xfs/xfs_trans_extfree.c | |||
@@ -1,40 +1,25 @@ | |||
1 | /* | 1 | /* |
2 | * Copyright (c) 2000 Silicon Graphics, Inc. All Rights Reserved. | 2 | * Copyright (c) 2000,2005 Silicon Graphics, Inc. |
3 | * All Rights Reserved. | ||
3 | * | 4 | * |
4 | * This program is free software; you can redistribute it and/or modify it | 5 | * This program is free software; you can redistribute it and/or |
5 | * under the terms of version 2 of the GNU General Public License as | 6 | * modify it under the terms of the GNU General Public License as |
6 | * published by the Free Software Foundation. | 7 | * published by the Free Software Foundation. |
7 | * | 8 | * |
8 | * This program is distributed in the hope that it would be useful, but | 9 | * This program is distributed in the hope that it would be useful, |
9 | * WITHOUT ANY WARRANTY; without even the implied warranty of | 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
12 | * GNU General Public License for more details. | ||
11 | * | 13 | * |
12 | * Further, this software is distributed without any warranty that it is | 14 | * You should have received a copy of the GNU General Public License |
13 | * free of the rightful claim of any third person regarding infringement | 15 | * along with this program; if not, write the Free Software Foundation, |
14 | * or the like. Any license provided herein, whether implied or | 16 | * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
15 | * otherwise, applies only to this software file. Patent licenses, if | ||
16 | * any, provided herein do not apply to combinations of this program with | ||
17 | * other software, or any other product whatsoever. | ||
18 | * | ||
19 | * You should have received a copy of the GNU General Public License along | ||
20 | * with this program; if not, write the Free Software Foundation, Inc., 59 | ||
21 | * Temple Place - Suite 330, Boston MA 02111-1307, USA. | ||
22 | * | ||
23 | * Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy, | ||
24 | * Mountain View, CA 94043, or: | ||
25 | * | ||
26 | * http://www.sgi.com | ||
27 | * | ||
28 | * For further information regarding this notice, see: | ||
29 | * | ||
30 | * http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/ | ||
31 | */ | 17 | */ |
32 | |||
33 | #include "xfs.h" | 18 | #include "xfs.h" |
34 | #include "xfs_macros.h" | 19 | #include "xfs_fs.h" |
35 | #include "xfs_types.h" | 20 | #include "xfs_types.h" |
36 | #include "xfs_inum.h" | ||
37 | #include "xfs_log.h" | 21 | #include "xfs_log.h" |
22 | #include "xfs_inum.h" | ||
38 | #include "xfs_trans.h" | 23 | #include "xfs_trans.h" |
39 | #include "xfs_sb.h" | 24 | #include "xfs_sb.h" |
40 | #include "xfs_dir.h" | 25 | #include "xfs_dir.h" |
diff --git a/fs/xfs/xfs_trans_inode.c b/fs/xfs/xfs_trans_inode.c index 7e7631ca4979..e341409172d2 100644 --- a/fs/xfs/xfs_trans_inode.c +++ b/fs/xfs/xfs_trans_inode.c | |||
@@ -1,40 +1,26 @@ | |||
1 | /* | 1 | /* |
2 | * Copyright (c) 2000 Silicon Graphics, Inc. All Rights Reserved. | 2 | * Copyright (c) 2000,2005 Silicon Graphics, Inc. |
3 | * All Rights Reserved. | ||
3 | * | 4 | * |
4 | * This program is free software; you can redistribute it and/or modify it | 5 | * This program is free software; you can redistribute it and/or |
5 | * under the terms of version 2 of the GNU General Public License as | 6 | * modify it under the terms of the GNU General Public License as |
6 | * published by the Free Software Foundation. | 7 | * published by the Free Software Foundation. |
7 | * | 8 | * |
8 | * This program is distributed in the hope that it would be useful, but | 9 | * This program is distributed in the hope that it would be useful, |
9 | * WITHOUT ANY WARRANTY; without even the implied warranty of | 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
12 | * GNU General Public License for more details. | ||
11 | * | 13 | * |
12 | * Further, this software is distributed without any warranty that it is | 14 | * You should have received a copy of the GNU General Public License |
13 | * free of the rightful claim of any third person regarding infringement | 15 | * along with this program; if not, write the Free Software Foundation, |
14 | * or the like. Any license provided herein, whether implied or | 16 | * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
15 | * otherwise, applies only to this software file. Patent licenses, if | ||
16 | * any, provided herein do not apply to combinations of this program with | ||
17 | * other software, or any other product whatsoever. | ||
18 | * | ||
19 | * You should have received a copy of the GNU General Public License along | ||
20 | * with this program; if not, write the Free Software Foundation, Inc., 59 | ||
21 | * Temple Place - Suite 330, Boston MA 02111-1307, USA. | ||
22 | * | ||
23 | * Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy, | ||
24 | * Mountain View, CA 94043, or: | ||
25 | * | ||
26 | * http://www.sgi.com | ||
27 | * | ||
28 | * For further information regarding this notice, see: | ||
29 | * | ||
30 | * http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/ | ||
31 | */ | 17 | */ |
32 | |||
33 | #include "xfs.h" | 18 | #include "xfs.h" |
34 | #include "xfs_macros.h" | 19 | #include "xfs_fs.h" |
35 | #include "xfs_types.h" | 20 | #include "xfs_types.h" |
36 | #include "xfs_inum.h" | 21 | #include "xfs_bit.h" |
37 | #include "xfs_log.h" | 22 | #include "xfs_log.h" |
23 | #include "xfs_inum.h" | ||
38 | #include "xfs_trans.h" | 24 | #include "xfs_trans.h" |
39 | #include "xfs_sb.h" | 25 | #include "xfs_sb.h" |
40 | #include "xfs_ag.h" | 26 | #include "xfs_ag.h" |
@@ -42,18 +28,18 @@ | |||
42 | #include "xfs_dir2.h" | 28 | #include "xfs_dir2.h" |
43 | #include "xfs_dmapi.h" | 29 | #include "xfs_dmapi.h" |
44 | #include "xfs_mount.h" | 30 | #include "xfs_mount.h" |
45 | #include "xfs_trans_priv.h" | ||
46 | #include "xfs_alloc_btree.h" | ||
47 | #include "xfs_bmap_btree.h" | 31 | #include "xfs_bmap_btree.h" |
32 | #include "xfs_alloc_btree.h" | ||
48 | #include "xfs_ialloc_btree.h" | 33 | #include "xfs_ialloc_btree.h" |
49 | #include "xfs_btree.h" | ||
50 | #include "xfs_ialloc.h" | ||
51 | #include "xfs_attr_sf.h" | ||
52 | #include "xfs_dir_sf.h" | 34 | #include "xfs_dir_sf.h" |
53 | #include "xfs_dir2_sf.h" | 35 | #include "xfs_dir2_sf.h" |
36 | #include "xfs_attr_sf.h" | ||
54 | #include "xfs_dinode.h" | 37 | #include "xfs_dinode.h" |
55 | #include "xfs_inode_item.h" | ||
56 | #include "xfs_inode.h" | 38 | #include "xfs_inode.h" |
39 | #include "xfs_btree.h" | ||
40 | #include "xfs_ialloc.h" | ||
41 | #include "xfs_trans_priv.h" | ||
42 | #include "xfs_inode_item.h" | ||
57 | 43 | ||
58 | #ifdef XFS_TRANS_DEBUG | 44 | #ifdef XFS_TRANS_DEBUG |
59 | STATIC void | 45 | STATIC void |
diff --git a/fs/xfs/xfs_trans_item.c b/fs/xfs/xfs_trans_item.c index 1b8a756d80ed..486147ef0e3d 100644 --- a/fs/xfs/xfs_trans_item.c +++ b/fs/xfs/xfs_trans_item.c | |||
@@ -1,40 +1,25 @@ | |||
1 | /* | 1 | /* |
2 | * Copyright (c) 2000-2002 Silicon Graphics, Inc. All Rights Reserved. | 2 | * Copyright (c) 2000-2002,2005 Silicon Graphics, Inc. |
3 | * All Rights Reserved. | ||
3 | * | 4 | * |
4 | * This program is free software; you can redistribute it and/or modify it | 5 | * This program is free software; you can redistribute it and/or |
5 | * under the terms of version 2 of the GNU General Public License as | 6 | * modify it under the terms of the GNU General Public License as |
6 | * published by the Free Software Foundation. | 7 | * published by the Free Software Foundation. |
7 | * | 8 | * |
8 | * This program is distributed in the hope that it would be useful, but | 9 | * This program is distributed in the hope that it would be useful, |
9 | * WITHOUT ANY WARRANTY; without even the implied warranty of | 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
12 | * GNU General Public License for more details. | ||
11 | * | 13 | * |
12 | * Further, this software is distributed without any warranty that it is | 14 | * You should have received a copy of the GNU General Public License |
13 | * free of the rightful claim of any third person regarding infringement | 15 | * along with this program; if not, write the Free Software Foundation, |
14 | * or the like. Any license provided herein, whether implied or | 16 | * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
15 | * otherwise, applies only to this software file. Patent licenses, if | ||
16 | * any, provided herein do not apply to combinations of this program with | ||
17 | * other software, or any other product whatsoever. | ||
18 | * | ||
19 | * You should have received a copy of the GNU General Public License along | ||
20 | * with this program; if not, write the Free Software Foundation, Inc., 59 | ||
21 | * Temple Place - Suite 330, Boston MA 02111-1307, USA. | ||
22 | * | ||
23 | * Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy, | ||
24 | * Mountain View, CA 94043, or: | ||
25 | * | ||
26 | * http://www.sgi.com | ||
27 | * | ||
28 | * For further information regarding this notice, see: | ||
29 | * | ||
30 | * http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/ | ||
31 | */ | 17 | */ |
32 | |||
33 | #include "xfs.h" | 18 | #include "xfs.h" |
34 | #include "xfs_macros.h" | 19 | #include "xfs_fs.h" |
35 | #include "xfs_types.h" | 20 | #include "xfs_types.h" |
36 | #include "xfs_inum.h" | ||
37 | #include "xfs_log.h" | 21 | #include "xfs_log.h" |
22 | #include "xfs_inum.h" | ||
38 | #include "xfs_trans.h" | 23 | #include "xfs_trans.h" |
39 | 24 | ||
40 | STATIC int xfs_trans_unlock_chunk(xfs_log_item_chunk_t *, | 25 | STATIC int xfs_trans_unlock_chunk(xfs_log_item_chunk_t *, |
diff --git a/fs/xfs/xfs_trans_priv.h b/fs/xfs/xfs_trans_priv.h index d4dae7d06afc..13edab8a9e94 100644 --- a/fs/xfs/xfs_trans_priv.h +++ b/fs/xfs/xfs_trans_priv.h | |||
@@ -1,33 +1,19 @@ | |||
1 | /* | 1 | /* |
2 | * Copyright (c) 2000, 2002 Silicon Graphics, Inc. All Rights Reserved. | 2 | * Copyright (c) 2000,2002,2005 Silicon Graphics, Inc. |
3 | * All Rights Reserved. | ||
3 | * | 4 | * |
4 | * This program is free software; you can redistribute it and/or modify it | 5 | * This program is free software; you can redistribute it and/or |
5 | * under the terms of version 2 of the GNU General Public License as | 6 | * modify it under the terms of the GNU General Public License as |
6 | * published by the Free Software Foundation. | 7 | * published by the Free Software Foundation. |
7 | * | 8 | * |
8 | * This program is distributed in the hope that it would be useful, but | 9 | * This program is distributed in the hope that it would be useful, |
9 | * WITHOUT ANY WARRANTY; without even the implied warranty of | 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
12 | * GNU General Public License for more details. | ||
11 | * | 13 | * |
12 | * Further, this software is distributed without any warranty that it is | 14 | * You should have received a copy of the GNU General Public License |
13 | * free of the rightful claim of any third person regarding infringement | 15 | * along with this program; if not, write the Free Software Foundation, |
14 | * or the like. Any license provided herein, whether implied or | 16 | * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
15 | * otherwise, applies only to this software file. Patent licenses, if | ||
16 | * any, provided herein do not apply to combinations of this program with | ||
17 | * other software, or any other product whatsoever. | ||
18 | * | ||
19 | * You should have received a copy of the GNU General Public License along | ||
20 | * with this program; if not, write the Free Software Foundation, Inc., 59 | ||
21 | * Temple Place - Suite 330, Boston MA 02111-1307, USA. | ||
22 | * | ||
23 | * Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy, | ||
24 | * Mountain View, CA 94043, or: | ||
25 | * | ||
26 | * http://www.sgi.com | ||
27 | * | ||
28 | * For further information regarding this notice, see: | ||
29 | * | ||
30 | * http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/ | ||
31 | */ | 17 | */ |
32 | #ifndef __XFS_TRANS_PRIV_H__ | 18 | #ifndef __XFS_TRANS_PRIV_H__ |
33 | #define __XFS_TRANS_PRIV_H__ | 19 | #define __XFS_TRANS_PRIV_H__ |
diff --git a/fs/xfs/xfs_trans_space.h b/fs/xfs/xfs_trans_space.h index e91d173f4ed3..7fe3792b18df 100644 --- a/fs/xfs/xfs_trans_space.h +++ b/fs/xfs/xfs_trans_space.h | |||
@@ -1,33 +1,19 @@ | |||
1 | /* | 1 | /* |
2 | * Copyright (c) 2000 Silicon Graphics, Inc. All Rights Reserved. | 2 | * Copyright (c) 2000,2005 Silicon Graphics, Inc. |
3 | * All Rights Reserved. | ||
3 | * | 4 | * |
4 | * This program is free software; you can redistribute it and/or modify it | 5 | * This program is free software; you can redistribute it and/or |
5 | * under the terms of version 2 of the GNU General Public License as | 6 | * modify it under the terms of the GNU General Public License as |
6 | * published by the Free Software Foundation. | 7 | * published by the Free Software Foundation. |
7 | * | 8 | * |
8 | * This program is distributed in the hope that it would be useful, but | 9 | * This program is distributed in the hope that it would be useful, |
9 | * WITHOUT ANY WARRANTY; without even the implied warranty of | 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
12 | * GNU General Public License for more details. | ||
11 | * | 13 | * |
12 | * Further, this software is distributed without any warranty that it is | 14 | * You should have received a copy of the GNU General Public License |
13 | * free of the rightful claim of any third person regarding infringement | 15 | * along with this program; if not, write the Free Software Foundation, |
14 | * or the like. Any license provided herein, whether implied or | 16 | * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
15 | * otherwise, applies only to this software file. Patent licenses, if | ||
16 | * any, provided herein do not apply to combinations of this program with | ||
17 | * other software, or any other product whatsoever. | ||
18 | * | ||
19 | * You should have received a copy of the GNU General Public License along | ||
20 | * with this program; if not, write the Free Software Foundation, Inc., 59 | ||
21 | * Temple Place - Suite 330, Boston MA 02111-1307, USA. | ||
22 | * | ||
23 | * Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy, | ||
24 | * Mountain View, CA 94043, or: | ||
25 | * | ||
26 | * http://www.sgi.com | ||
27 | * | ||
28 | * For further information regarding this notice, see: | ||
29 | * | ||
30 | * http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/ | ||
31 | */ | 17 | */ |
32 | #ifndef __XFS_TRANS_SPACE_H__ | 18 | #ifndef __XFS_TRANS_SPACE_H__ |
33 | #define __XFS_TRANS_SPACE_H__ | 19 | #define __XFS_TRANS_SPACE_H__ |
diff --git a/fs/xfs/xfs_types.h b/fs/xfs/xfs_types.h index 16f5371ce102..104f64a98790 100644 --- a/fs/xfs/xfs_types.h +++ b/fs/xfs/xfs_types.h | |||
@@ -1,33 +1,19 @@ | |||
1 | /* | 1 | /* |
2 | * Copyright (c) 2000-2003 Silicon Graphics, Inc. All Rights Reserved. | 2 | * Copyright (c) 2000-2005 Silicon Graphics, Inc. |
3 | * All Rights Reserved. | ||
3 | * | 4 | * |
4 | * This program is free software; you can redistribute it and/or modify it | 5 | * This program is free software; you can redistribute it and/or |
5 | * under the terms of version 2 of the GNU General Public License as | 6 | * modify it under the terms of the GNU General Public License as |
6 | * published by the Free Software Foundation. | 7 | * published by the Free Software Foundation. |
7 | * | 8 | * |
8 | * This program is distributed in the hope that it would be useful, but | 9 | * This program is distributed in the hope that it would be useful, |
9 | * WITHOUT ANY WARRANTY; without even the implied warranty of | 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
12 | * GNU General Public License for more details. | ||
11 | * | 13 | * |
12 | * Further, this software is distributed without any warranty that it is | 14 | * You should have received a copy of the GNU General Public License |
13 | * free of the rightful claim of any third person regarding infringement | 15 | * along with this program; if not, write the Free Software Foundation, |
14 | * or the like. Any license provided herein, whether implied or | 16 | * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
15 | * otherwise, applies only to this software file. Patent licenses, if | ||
16 | * any, provided herein do not apply to combinations of this program with | ||
17 | * other software, or any other product whatsoever. | ||
18 | * | ||
19 | * You should have received a copy of the GNU General Public License along | ||
20 | * with this program; if not, write the Free Software Foundation, Inc., 59 | ||
21 | * Temple Place - Suite 330, Boston MA 02111-1307, USA. | ||
22 | * | ||
23 | * Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy, | ||
24 | * Mountain View, CA 94043, or: | ||
25 | * | ||
26 | * http://www.sgi.com | ||
27 | * | ||
28 | * For further information regarding this notice, see: | ||
29 | * | ||
30 | * http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/ | ||
31 | */ | 17 | */ |
32 | #ifndef __XFS_TYPES_H__ | 18 | #ifndef __XFS_TYPES_H__ |
33 | #define __XFS_TYPES_H__ | 19 | #define __XFS_TYPES_H__ |
@@ -154,6 +140,12 @@ typedef __uint8_t xfs_arch_t; /* architecture of an xfs fs */ | |||
154 | #define MAXAEXTNUM ((xfs_aextnum_t)0x7fff) /* signed short */ | 140 | #define MAXAEXTNUM ((xfs_aextnum_t)0x7fff) /* signed short */ |
155 | 141 | ||
156 | /* | 142 | /* |
143 | * Min numbers of data/attr fork btree root pointers. | ||
144 | */ | ||
145 | #define MINDBTPTRS 3 | ||
146 | #define MINABTPTRS 2 | ||
147 | |||
148 | /* | ||
157 | * MAXNAMELEN is the length (including the terminating null) of | 149 | * MAXNAMELEN is the length (including the terminating null) of |
158 | * the longest permissible file (component) name. | 150 | * the longest permissible file (component) name. |
159 | */ | 151 | */ |
diff --git a/fs/xfs/xfs_utils.c b/fs/xfs/xfs_utils.c index 11351f08d438..fefe1d60377f 100644 --- a/fs/xfs/xfs_utils.c +++ b/fs/xfs/xfs_utils.c | |||
@@ -1,53 +1,40 @@ | |||
1 | /* | 1 | /* |
2 | * Copyright (c) 2000-2002 Silicon Graphics, Inc. All Rights Reserved. | 2 | * Copyright (c) 2000-2002,2005 Silicon Graphics, Inc. |
3 | * All Rights Reserved. | ||
3 | * | 4 | * |
4 | * This program is free software; you can redistribute it and/or modify it | 5 | * This program is free software; you can redistribute it and/or |
5 | * under the terms of version 2 of the GNU General Public License as | 6 | * modify it under the terms of the GNU General Public License as |
6 | * published by the Free Software Foundation. | 7 | * published by the Free Software Foundation. |
7 | * | 8 | * |
8 | * This program is distributed in the hope that it would be useful, but | 9 | * This program is distributed in the hope that it would be useful, |
9 | * WITHOUT ANY WARRANTY; without even the implied warranty of | 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
12 | * GNU General Public License for more details. | ||
11 | * | 13 | * |
12 | * Further, this software is distributed without any warranty that it is | 14 | * You should have received a copy of the GNU General Public License |
13 | * free of the rightful claim of any third person regarding infringement | 15 | * along with this program; if not, write the Free Software Foundation, |
14 | * or the like. Any license provided herein, whether implied or | 16 | * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
15 | * otherwise, applies only to this software file. Patent licenses, if | ||
16 | * any, provided herein do not apply to combinations of this program with | ||
17 | * other software, or any other product whatsoever. | ||
18 | * | ||
19 | * You should have received a copy of the GNU General Public License along | ||
20 | * with this program; if not, write the Free Software Foundation, Inc., 59 | ||
21 | * Temple Place - Suite 330, Boston MA 02111-1307, USA. | ||
22 | * | ||
23 | * Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy, | ||
24 | * Mountain View, CA 94043, or: | ||
25 | * | ||
26 | * http://www.sgi.com | ||
27 | * | ||
28 | * For further information regarding this notice, see: | ||
29 | * | ||
30 | * http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/ | ||
31 | */ | 17 | */ |
32 | |||
33 | #include "xfs.h" | 18 | #include "xfs.h" |
34 | #include "xfs_macros.h" | 19 | #include "xfs_fs.h" |
35 | #include "xfs_types.h" | 20 | #include "xfs_types.h" |
36 | #include "xfs_inum.h" | 21 | #include "xfs_bit.h" |
37 | #include "xfs_log.h" | 22 | #include "xfs_log.h" |
23 | #include "xfs_inum.h" | ||
38 | #include "xfs_trans.h" | 24 | #include "xfs_trans.h" |
39 | #include "xfs_sb.h" | 25 | #include "xfs_sb.h" |
26 | #include "xfs_ag.h" | ||
40 | #include "xfs_dir.h" | 27 | #include "xfs_dir.h" |
41 | #include "xfs_dir2.h" | 28 | #include "xfs_dir2.h" |
42 | #include "xfs_dmapi.h" | 29 | #include "xfs_dmapi.h" |
43 | #include "xfs_mount.h" | 30 | #include "xfs_mount.h" |
44 | #include "xfs_bmap_btree.h" | 31 | #include "xfs_bmap_btree.h" |
45 | #include "xfs_attr_sf.h" | ||
46 | #include "xfs_dir_sf.h" | 32 | #include "xfs_dir_sf.h" |
47 | #include "xfs_dir2_sf.h" | 33 | #include "xfs_dir2_sf.h" |
34 | #include "xfs_attr_sf.h" | ||
48 | #include "xfs_dinode.h" | 35 | #include "xfs_dinode.h" |
49 | #include "xfs_inode_item.h" | ||
50 | #include "xfs_inode.h" | 36 | #include "xfs_inode.h" |
37 | #include "xfs_inode_item.h" | ||
51 | #include "xfs_bmap.h" | 38 | #include "xfs_bmap.h" |
52 | #include "xfs_error.h" | 39 | #include "xfs_error.h" |
53 | #include "xfs_quota.h" | 40 | #include "xfs_quota.h" |
diff --git a/fs/xfs/xfs_utils.h b/fs/xfs/xfs_utils.h index 01d98b4b7af7..472661a3b6d8 100644 --- a/fs/xfs/xfs_utils.h +++ b/fs/xfs/xfs_utils.h | |||
@@ -1,33 +1,19 @@ | |||
1 | /* | 1 | /* |
2 | * Copyright (c) 2000-2002 Silicon Graphics, Inc. All Rights Reserved. | 2 | * Copyright (c) 2000-2002,2005 Silicon Graphics, Inc. |
3 | * All Rights Reserved. | ||
3 | * | 4 | * |
4 | * This program is free software; you can redistribute it and/or modify it | 5 | * This program is free software; you can redistribute it and/or |
5 | * under the terms of version 2 of the GNU General Public License as | 6 | * modify it under the terms of the GNU General Public License as |
6 | * published by the Free Software Foundation. | 7 | * published by the Free Software Foundation. |
7 | * | 8 | * |
8 | * This program is distributed in the hope that it would be useful, but | 9 | * This program is distributed in the hope that it would be useful, |
9 | * WITHOUT ANY WARRANTY; without even the implied warranty of | 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
12 | * GNU General Public License for more details. | ||
11 | * | 13 | * |
12 | * Further, this software is distributed without any warranty that it is | 14 | * You should have received a copy of the GNU General Public License |
13 | * free of the rightful claim of any third person regarding infringement | 15 | * along with this program; if not, write the Free Software Foundation, |
14 | * or the like. Any license provided herein, whether implied or | 16 | * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
15 | * otherwise, applies only to this software file. Patent licenses, if | ||
16 | * any, provided herein do not apply to combinations of this program with | ||
17 | * other software, or any other product whatsoever. | ||
18 | * | ||
19 | * You should have received a copy of the GNU General Public License along | ||
20 | * with this program; if not, write the Free Software Foundation, Inc., 59 | ||
21 | * Temple Place - Suite 330, Boston MA 02111-1307, USA. | ||
22 | * | ||
23 | * Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy, | ||
24 | * Mountain View, CA 94043, or: | ||
25 | * | ||
26 | * http://www.sgi.com | ||
27 | * | ||
28 | * For further information regarding this notice, see: | ||
29 | * | ||
30 | * http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/ | ||
31 | */ | 17 | */ |
32 | #ifndef __XFS_UTILS_H__ | 18 | #ifndef __XFS_UTILS_H__ |
33 | #define __XFS_UTILS_H__ | 19 | #define __XFS_UTILS_H__ |
diff --git a/fs/xfs/xfs_vfsops.c b/fs/xfs/xfs_vfsops.c index f1a904e23ade..7bdbd991ab1c 100644 --- a/fs/xfs/xfs_vfsops.c +++ b/fs/xfs/xfs_vfsops.c | |||
@@ -1,74 +1,58 @@ | |||
1 | /* | 1 | /* |
2 | * XFS filesystem operations. | 2 | * Copyright (c) 2000-2005 Silicon Graphics, Inc. |
3 | * All Rights Reserved. | ||
3 | * | 4 | * |
4 | * Copyright (c) 2000-2005 Silicon Graphics, Inc. All Rights Reserved. | 5 | * This program is free software; you can redistribute it and/or |
5 | * | 6 | * modify it under the terms of the GNU General Public License as |
6 | * This program is free software; you can redistribute it and/or modify it | ||
7 | * under the terms of version 2 of the GNU General Public License as | ||
8 | * published by the Free Software Foundation. | 7 | * published by the Free Software Foundation. |
9 | * | 8 | * |
10 | * This program is distributed in the hope that it would be useful, but | 9 | * This program is distributed in the hope that it would be useful, |
11 | * WITHOUT ANY WARRANTY; without even the implied warranty of | 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
13 | * | 12 | * GNU General Public License for more details. |
14 | * Further, this software is distributed without any warranty that it is | ||
15 | * free of the rightful claim of any third person regarding infringement | ||
16 | * or the like. Any license provided herein, whether implied or | ||
17 | * otherwise, applies only to this software file. Patent licenses, if | ||
18 | * any, provided herein do not apply to combinations of this program with | ||
19 | * other software, or any other product whatsoever. | ||
20 | * | ||
21 | * You should have received a copy of the GNU General Public License along | ||
22 | * with this program; if not, write the Free Software Foundation, Inc., 59 | ||
23 | * Temple Place - Suite 330, Boston MA 02111-1307, USA. | ||
24 | * | ||
25 | * Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy, | ||
26 | * Mountain View, CA 94043, or: | ||
27 | * | 13 | * |
28 | * http://www.sgi.com | 14 | * You should have received a copy of the GNU General Public License |
29 | * | 15 | * along with this program; if not, write the Free Software Foundation, |
30 | * For further information regarding this notice, see: | 16 | * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
31 | * | ||
32 | * http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/ | ||
33 | */ | 17 | */ |
34 | |||
35 | #include "xfs.h" | 18 | #include "xfs.h" |
36 | #include "xfs_macros.h" | 19 | #include "xfs_fs.h" |
37 | #include "xfs_types.h" | 20 | #include "xfs_types.h" |
38 | #include "xfs_inum.h" | 21 | #include "xfs_bit.h" |
39 | #include "xfs_log.h" | 22 | #include "xfs_log.h" |
23 | #include "xfs_inum.h" | ||
40 | #include "xfs_trans.h" | 24 | #include "xfs_trans.h" |
41 | #include "xfs_sb.h" | 25 | #include "xfs_sb.h" |
26 | #include "xfs_ag.h" | ||
42 | #include "xfs_dir.h" | 27 | #include "xfs_dir.h" |
43 | #include "xfs_dir2.h" | 28 | #include "xfs_dir2.h" |
44 | #include "xfs_dmapi.h" | 29 | #include "xfs_dmapi.h" |
45 | #include "xfs_mount.h" | 30 | #include "xfs_mount.h" |
31 | #include "xfs_da_btree.h" | ||
46 | #include "xfs_bmap_btree.h" | 32 | #include "xfs_bmap_btree.h" |
47 | #include "xfs_ialloc_btree.h" | 33 | #include "xfs_ialloc_btree.h" |
48 | #include "xfs_alloc_btree.h" | 34 | #include "xfs_alloc_btree.h" |
49 | #include "xfs_btree.h" | ||
50 | #include "xfs_alloc.h" | ||
51 | #include "xfs_ialloc.h" | ||
52 | #include "xfs_attr_sf.h" | ||
53 | #include "xfs_dir_sf.h" | 35 | #include "xfs_dir_sf.h" |
54 | #include "xfs_dir2_sf.h" | 36 | #include "xfs_dir2_sf.h" |
37 | #include "xfs_attr_sf.h" | ||
55 | #include "xfs_dinode.h" | 38 | #include "xfs_dinode.h" |
56 | #include "xfs_inode_item.h" | ||
57 | #include "xfs_inode.h" | 39 | #include "xfs_inode.h" |
58 | #include "xfs_ag.h" | 40 | #include "xfs_inode_item.h" |
41 | #include "xfs_btree.h" | ||
42 | #include "xfs_alloc.h" | ||
43 | #include "xfs_ialloc.h" | ||
44 | #include "xfs_quota.h" | ||
59 | #include "xfs_error.h" | 45 | #include "xfs_error.h" |
60 | #include "xfs_bmap.h" | 46 | #include "xfs_bmap.h" |
61 | #include "xfs_da_btree.h" | ||
62 | #include "xfs_rw.h" | 47 | #include "xfs_rw.h" |
63 | #include "xfs_refcache.h" | 48 | #include "xfs_refcache.h" |
64 | #include "xfs_buf_item.h" | 49 | #include "xfs_buf_item.h" |
65 | #include "xfs_extfree_item.h" | 50 | #include "xfs_log_priv.h" |
66 | #include "xfs_quota.h" | ||
67 | #include "xfs_dir2_trace.h" | 51 | #include "xfs_dir2_trace.h" |
52 | #include "xfs_extfree_item.h" | ||
68 | #include "xfs_acl.h" | 53 | #include "xfs_acl.h" |
69 | #include "xfs_attr.h" | 54 | #include "xfs_attr.h" |
70 | #include "xfs_clnt.h" | 55 | #include "xfs_clnt.h" |
71 | #include "xfs_log_priv.h" | ||
72 | 56 | ||
73 | STATIC int xfs_sync(bhv_desc_t *, int, cred_t *); | 57 | STATIC int xfs_sync(bhv_desc_t *, int, cred_t *); |
74 | 58 | ||
@@ -230,9 +214,7 @@ xfs_start_flags( | |||
230 | } | 214 | } |
231 | 215 | ||
232 | if (ap->logbufs != -1 && | 216 | if (ap->logbufs != -1 && |
233 | #if defined(DEBUG) || defined(XLOG_NOLOG) | ||
234 | ap->logbufs != 0 && | 217 | ap->logbufs != 0 && |
235 | #endif | ||
236 | (ap->logbufs < XLOG_MIN_ICLOGS || | 218 | (ap->logbufs < XLOG_MIN_ICLOGS || |
237 | ap->logbufs > XLOG_MAX_ICLOGS)) { | 219 | ap->logbufs > XLOG_MAX_ICLOGS)) { |
238 | cmn_err(CE_WARN, | 220 | cmn_err(CE_WARN, |
@@ -242,6 +224,7 @@ xfs_start_flags( | |||
242 | } | 224 | } |
243 | mp->m_logbufs = ap->logbufs; | 225 | mp->m_logbufs = ap->logbufs; |
244 | if (ap->logbufsize != -1 && | 226 | if (ap->logbufsize != -1 && |
227 | ap->logbufsize != 0 && | ||
245 | ap->logbufsize != 16 * 1024 && | 228 | ap->logbufsize != 16 * 1024 && |
246 | ap->logbufsize != 32 * 1024 && | 229 | ap->logbufsize != 32 * 1024 && |
247 | ap->logbufsize != 64 * 1024 && | 230 | ap->logbufsize != 64 * 1024 && |
@@ -257,6 +240,14 @@ xfs_start_flags( | |||
257 | mp->m_fsname_len = strlen(ap->fsname) + 1; | 240 | mp->m_fsname_len = strlen(ap->fsname) + 1; |
258 | mp->m_fsname = kmem_alloc(mp->m_fsname_len, KM_SLEEP); | 241 | mp->m_fsname = kmem_alloc(mp->m_fsname_len, KM_SLEEP); |
259 | strcpy(mp->m_fsname, ap->fsname); | 242 | strcpy(mp->m_fsname, ap->fsname); |
243 | if (ap->rtname[0]) { | ||
244 | mp->m_rtname = kmem_alloc(strlen(ap->rtname) + 1, KM_SLEEP); | ||
245 | strcpy(mp->m_rtname, ap->rtname); | ||
246 | } | ||
247 | if (ap->logname[0]) { | ||
248 | mp->m_logname = kmem_alloc(strlen(ap->logname) + 1, KM_SLEEP); | ||
249 | strcpy(mp->m_logname, ap->logname); | ||
250 | } | ||
260 | 251 | ||
261 | if (ap->flags & XFSMNT_WSYNC) | 252 | if (ap->flags & XFSMNT_WSYNC) |
262 | mp->m_flags |= XFS_MOUNT_WSYNC; | 253 | mp->m_flags |= XFS_MOUNT_WSYNC; |
@@ -268,21 +259,16 @@ xfs_start_flags( | |||
268 | #endif | 259 | #endif |
269 | if (ap->flags & XFSMNT_NOATIME) | 260 | if (ap->flags & XFSMNT_NOATIME) |
270 | mp->m_flags |= XFS_MOUNT_NOATIME; | 261 | mp->m_flags |= XFS_MOUNT_NOATIME; |
271 | |||
272 | if (ap->flags & XFSMNT_RETERR) | 262 | if (ap->flags & XFSMNT_RETERR) |
273 | mp->m_flags |= XFS_MOUNT_RETERR; | 263 | mp->m_flags |= XFS_MOUNT_RETERR; |
274 | |||
275 | if (ap->flags & XFSMNT_NOALIGN) | 264 | if (ap->flags & XFSMNT_NOALIGN) |
276 | mp->m_flags |= XFS_MOUNT_NOALIGN; | 265 | mp->m_flags |= XFS_MOUNT_NOALIGN; |
277 | |||
278 | if (ap->flags & XFSMNT_SWALLOC) | 266 | if (ap->flags & XFSMNT_SWALLOC) |
279 | mp->m_flags |= XFS_MOUNT_SWALLOC; | 267 | mp->m_flags |= XFS_MOUNT_SWALLOC; |
280 | |||
281 | if (ap->flags & XFSMNT_OSYNCISOSYNC) | 268 | if (ap->flags & XFSMNT_OSYNCISOSYNC) |
282 | mp->m_flags |= XFS_MOUNT_OSYNCISOSYNC; | 269 | mp->m_flags |= XFS_MOUNT_OSYNCISOSYNC; |
283 | |||
284 | if (ap->flags & XFSMNT_32BITINODES) | 270 | if (ap->flags & XFSMNT_32BITINODES) |
285 | mp->m_flags |= (XFS_MOUNT_32BITINODES | XFS_MOUNT_32BITINOOPT); | 271 | mp->m_flags |= XFS_MOUNT_32BITINODES; |
286 | 272 | ||
287 | if (ap->flags & XFSMNT_IOSIZE) { | 273 | if (ap->flags & XFSMNT_IOSIZE) { |
288 | if (ap->iosizelog > XFS_MAX_IO_LOG || | 274 | if (ap->iosizelog > XFS_MAX_IO_LOG || |
@@ -300,12 +286,15 @@ xfs_start_flags( | |||
300 | 286 | ||
301 | if (ap->flags & XFSMNT_IHASHSIZE) | 287 | if (ap->flags & XFSMNT_IHASHSIZE) |
302 | mp->m_flags |= XFS_MOUNT_IHASHSIZE; | 288 | mp->m_flags |= XFS_MOUNT_IHASHSIZE; |
303 | |||
304 | if (ap->flags & XFSMNT_IDELETE) | 289 | if (ap->flags & XFSMNT_IDELETE) |
305 | mp->m_flags |= XFS_MOUNT_IDELETE; | 290 | mp->m_flags |= XFS_MOUNT_IDELETE; |
306 | |||
307 | if (ap->flags & XFSMNT_DIRSYNC) | 291 | if (ap->flags & XFSMNT_DIRSYNC) |
308 | mp->m_flags |= XFS_MOUNT_DIRSYNC; | 292 | mp->m_flags |= XFS_MOUNT_DIRSYNC; |
293 | if (ap->flags & XFSMNT_COMPAT_ATTR) | ||
294 | mp->m_flags |= XFS_MOUNT_COMPAT_ATTR; | ||
295 | |||
296 | if (ap->flags2 & XFSMNT2_COMPAT_IOSIZE) | ||
297 | mp->m_flags |= XFS_MOUNT_COMPAT_IOSIZE; | ||
309 | 298 | ||
310 | /* | 299 | /* |
311 | * no recovery flag requires a read-only mount | 300 | * no recovery flag requires a read-only mount |
@@ -321,8 +310,8 @@ xfs_start_flags( | |||
321 | 310 | ||
322 | if (ap->flags & XFSMNT_NOUUID) | 311 | if (ap->flags & XFSMNT_NOUUID) |
323 | mp->m_flags |= XFS_MOUNT_NOUUID; | 312 | mp->m_flags |= XFS_MOUNT_NOUUID; |
324 | if (ap->flags & XFSMNT_NOLOGFLUSH) | 313 | if (ap->flags & XFSMNT_BARRIER) |
325 | mp->m_flags |= XFS_MOUNT_NOLOGFLUSH; | 314 | mp->m_flags |= XFS_MOUNT_BARRIER; |
326 | 315 | ||
327 | return 0; | 316 | return 0; |
328 | } | 317 | } |
@@ -393,6 +382,10 @@ xfs_finish_flags( | |||
393 | return XFS_ERROR(EINVAL); | 382 | return XFS_ERROR(EINVAL); |
394 | } | 383 | } |
395 | 384 | ||
385 | if (XFS_SB_VERSION_HASATTR2(&mp->m_sb)) { | ||
386 | mp->m_flags &= ~XFS_MOUNT_COMPAT_ATTR; | ||
387 | } | ||
388 | |||
396 | return 0; | 389 | return 0; |
397 | } | 390 | } |
398 | 391 | ||
@@ -512,8 +505,14 @@ xfs_mount( | |||
512 | goto error2; | 505 | goto error2; |
513 | 506 | ||
514 | error = XFS_IOINIT(vfsp, args, flags); | 507 | error = XFS_IOINIT(vfsp, args, flags); |
515 | if (!error) | 508 | if (error) |
516 | return 0; | 509 | goto error2; |
510 | |||
511 | if ((args->flags & XFSMNT_BARRIER) && | ||
512 | !(XFS_MTOVFS(mp)->vfs_flag & VFS_RDONLY)) | ||
513 | xfs_mountfs_check_barriers(mp); | ||
514 | return 0; | ||
515 | |||
517 | error2: | 516 | error2: |
518 | if (mp->m_sb_bp) | 517 | if (mp->m_sb_bp) |
519 | xfs_freesb(mp); | 518 | xfs_freesb(mp); |
@@ -656,19 +655,24 @@ xfs_mntupdate( | |||
656 | else | 655 | else |
657 | mp->m_flags &= ~XFS_MOUNT_NOATIME; | 656 | mp->m_flags &= ~XFS_MOUNT_NOATIME; |
658 | 657 | ||
659 | if (!(vfsp->vfs_flag & VFS_RDONLY)) { | 658 | if ((vfsp->vfs_flag & VFS_RDONLY) && |
660 | VFS_SYNC(vfsp, SYNC_FSDATA|SYNC_BDFLUSH|SYNC_ATTR, NULL, error); | 659 | !(*flags & MS_RDONLY)) { |
660 | vfsp->vfs_flag &= ~VFS_RDONLY; | ||
661 | |||
662 | if (args->flags & XFSMNT_BARRIER) | ||
663 | xfs_mountfs_check_barriers(mp); | ||
661 | } | 664 | } |
662 | 665 | ||
663 | if (*flags & MS_RDONLY) { | 666 | if (!(vfsp->vfs_flag & VFS_RDONLY) && |
667 | (*flags & MS_RDONLY)) { | ||
668 | VFS_SYNC(vfsp, SYNC_FSDATA|SYNC_BDFLUSH|SYNC_ATTR, NULL, error); | ||
669 | |||
664 | xfs_quiesce_fs(mp); | 670 | xfs_quiesce_fs(mp); |
665 | 671 | ||
666 | /* Ok now write out an unmount record */ | 672 | /* Ok now write out an unmount record */ |
667 | xfs_log_unmount_write(mp); | 673 | xfs_log_unmount_write(mp); |
668 | xfs_unmountfs_writesb(mp); | 674 | xfs_unmountfs_writesb(mp); |
669 | vfsp->vfs_flag |= VFS_RDONLY; | 675 | vfsp->vfs_flag |= VFS_RDONLY; |
670 | } else { | ||
671 | vfsp->vfs_flag &= ~VFS_RDONLY; | ||
672 | } | 676 | } |
673 | 677 | ||
674 | return 0; | 678 | return 0; |
@@ -892,7 +896,7 @@ xfs_sync( | |||
892 | * only available by calling this routine. | 896 | * only available by calling this routine. |
893 | * | 897 | * |
894 | */ | 898 | */ |
895 | STATIC int | 899 | int |
896 | xfs_sync_inodes( | 900 | xfs_sync_inodes( |
897 | xfs_mount_t *mp, | 901 | xfs_mount_t *mp, |
898 | int flags, | 902 | int flags, |
@@ -976,7 +980,7 @@ xfs_sync_inodes( | |||
976 | ipointer = (xfs_iptr_t *)kmem_zalloc(sizeof(xfs_iptr_t), KM_SLEEP); | 980 | ipointer = (xfs_iptr_t *)kmem_zalloc(sizeof(xfs_iptr_t), KM_SLEEP); |
977 | 981 | ||
978 | fflag = XFS_B_ASYNC; /* default is don't wait */ | 982 | fflag = XFS_B_ASYNC; /* default is don't wait */ |
979 | if (flags & SYNC_BDFLUSH) | 983 | if (flags & (SYNC_BDFLUSH | SYNC_DELWRI)) |
980 | fflag = XFS_B_DELWRI; | 984 | fflag = XFS_B_DELWRI; |
981 | if (flags & SYNC_WAIT) | 985 | if (flags & SYNC_WAIT) |
982 | fflag = 0; /* synchronous overrides all */ | 986 | fflag = 0; /* synchronous overrides all */ |
@@ -1628,11 +1632,17 @@ xfs_vget( | |||
1628 | #define MNTOPT_ALLOCSIZE "allocsize" /* preferred allocation size */ | 1632 | #define MNTOPT_ALLOCSIZE "allocsize" /* preferred allocation size */ |
1629 | #define MNTOPT_IHASHSIZE "ihashsize" /* size of inode hash table */ | 1633 | #define MNTOPT_IHASHSIZE "ihashsize" /* size of inode hash table */ |
1630 | #define MNTOPT_NORECOVERY "norecovery" /* don't run XFS recovery */ | 1634 | #define MNTOPT_NORECOVERY "norecovery" /* don't run XFS recovery */ |
1631 | #define MNTOPT_NOLOGFLUSH "nologflush" /* don't hard flush on log writes */ | 1635 | #define MNTOPT_BARRIER "barrier" /* use writer barriers for log write and |
1636 | * unwritten extent conversion */ | ||
1632 | #define MNTOPT_OSYNCISOSYNC "osyncisosync" /* o_sync is REALLY o_sync */ | 1637 | #define MNTOPT_OSYNCISOSYNC "osyncisosync" /* o_sync is REALLY o_sync */ |
1633 | #define MNTOPT_64BITINODE "inode64" /* inodes can be allocated anywhere */ | 1638 | #define MNTOPT_64BITINODE "inode64" /* inodes can be allocated anywhere */ |
1634 | #define MNTOPT_IKEEP "ikeep" /* do not free empty inode clusters */ | 1639 | #define MNTOPT_IKEEP "ikeep" /* do not free empty inode clusters */ |
1635 | #define MNTOPT_NOIKEEP "noikeep" /* free empty inode clusters */ | 1640 | #define MNTOPT_NOIKEEP "noikeep" /* free empty inode clusters */ |
1641 | #define MNTOPT_LARGEIO "largeio" /* report large I/O sizes in stat() */ | ||
1642 | #define MNTOPT_NOLARGEIO "nolargeio" /* do not report large I/O sizes | ||
1643 | * in stat(). */ | ||
1644 | #define MNTOPT_ATTR2 "attr2" /* do use attr2 attribute format */ | ||
1645 | #define MNTOPT_NOATTR2 "noattr2" /* do not use attr2 attribute format */ | ||
1636 | 1646 | ||
1637 | STATIC unsigned long | 1647 | STATIC unsigned long |
1638 | suffix_strtoul(const char *cp, char **endp, unsigned int base) | 1648 | suffix_strtoul(const char *cp, char **endp, unsigned int base) |
@@ -1669,12 +1679,15 @@ xfs_parseargs( | |||
1669 | int dsunit, dswidth, vol_dsunit, vol_dswidth; | 1679 | int dsunit, dswidth, vol_dsunit, vol_dswidth; |
1670 | int iosize; | 1680 | int iosize; |
1671 | 1681 | ||
1682 | args->flags2 |= XFSMNT2_COMPAT_IOSIZE; | ||
1683 | args->flags |= XFSMNT_COMPAT_ATTR; | ||
1684 | |||
1672 | #if 0 /* XXX: off by default, until some remaining issues ironed out */ | 1685 | #if 0 /* XXX: off by default, until some remaining issues ironed out */ |
1673 | args->flags |= XFSMNT_IDELETE; /* default to on */ | 1686 | args->flags |= XFSMNT_IDELETE; /* default to on */ |
1674 | #endif | 1687 | #endif |
1675 | 1688 | ||
1676 | if (!options) | 1689 | if (!options) |
1677 | return 0; | 1690 | goto done; |
1678 | 1691 | ||
1679 | iosize = dsunit = dswidth = vol_dsunit = vol_dswidth = 0; | 1692 | iosize = dsunit = dswidth = vol_dsunit = vol_dswidth = 0; |
1680 | 1693 | ||
@@ -1791,12 +1804,20 @@ xfs_parseargs( | |||
1791 | #endif | 1804 | #endif |
1792 | } else if (!strcmp(this_char, MNTOPT_NOUUID)) { | 1805 | } else if (!strcmp(this_char, MNTOPT_NOUUID)) { |
1793 | args->flags |= XFSMNT_NOUUID; | 1806 | args->flags |= XFSMNT_NOUUID; |
1794 | } else if (!strcmp(this_char, MNTOPT_NOLOGFLUSH)) { | 1807 | } else if (!strcmp(this_char, MNTOPT_BARRIER)) { |
1795 | args->flags |= XFSMNT_NOLOGFLUSH; | 1808 | args->flags |= XFSMNT_BARRIER; |
1796 | } else if (!strcmp(this_char, MNTOPT_IKEEP)) { | 1809 | } else if (!strcmp(this_char, MNTOPT_IKEEP)) { |
1797 | args->flags &= ~XFSMNT_IDELETE; | 1810 | args->flags &= ~XFSMNT_IDELETE; |
1798 | } else if (!strcmp(this_char, MNTOPT_NOIKEEP)) { | 1811 | } else if (!strcmp(this_char, MNTOPT_NOIKEEP)) { |
1799 | args->flags |= XFSMNT_IDELETE; | 1812 | args->flags |= XFSMNT_IDELETE; |
1813 | } else if (!strcmp(this_char, MNTOPT_LARGEIO)) { | ||
1814 | args->flags2 &= ~XFSMNT2_COMPAT_IOSIZE; | ||
1815 | } else if (!strcmp(this_char, MNTOPT_NOLARGEIO)) { | ||
1816 | args->flags2 |= XFSMNT2_COMPAT_IOSIZE; | ||
1817 | } else if (!strcmp(this_char, MNTOPT_ATTR2)) { | ||
1818 | args->flags &= ~XFSMNT_COMPAT_ATTR; | ||
1819 | } else if (!strcmp(this_char, MNTOPT_NOATTR2)) { | ||
1820 | args->flags |= XFSMNT_COMPAT_ATTR; | ||
1800 | } else if (!strcmp(this_char, "osyncisdsync")) { | 1821 | } else if (!strcmp(this_char, "osyncisdsync")) { |
1801 | /* no-op, this is now the default */ | 1822 | /* no-op, this is now the default */ |
1802 | printk("XFS: osyncisdsync is now the default, option is deprecated.\n"); | 1823 | printk("XFS: osyncisdsync is now the default, option is deprecated.\n"); |
@@ -1846,6 +1867,11 @@ printk("XFS: irixsgid is now a sysctl(2) variable, option is deprecated.\n"); | |||
1846 | args->sunit = args->swidth = 0; | 1867 | args->sunit = args->swidth = 0; |
1847 | } | 1868 | } |
1848 | 1869 | ||
1870 | done: | ||
1871 | if (args->flags & XFSMNT_32BITINODES) | ||
1872 | vfsp->vfs_flag |= VFS_32BITINODES; | ||
1873 | if (args->flags2) | ||
1874 | args->flags |= XFSMNT_FLAGS2; | ||
1849 | return 0; | 1875 | return 0; |
1850 | } | 1876 | } |
1851 | 1877 | ||
@@ -1866,7 +1892,7 @@ xfs_showargs( | |||
1866 | { XFS_MOUNT_NOUUID, "," MNTOPT_NOUUID }, | 1892 | { XFS_MOUNT_NOUUID, "," MNTOPT_NOUUID }, |
1867 | { XFS_MOUNT_NORECOVERY, "," MNTOPT_NORECOVERY }, | 1893 | { XFS_MOUNT_NORECOVERY, "," MNTOPT_NORECOVERY }, |
1868 | { XFS_MOUNT_OSYNCISOSYNC, "," MNTOPT_OSYNCISOSYNC }, | 1894 | { XFS_MOUNT_OSYNCISOSYNC, "," MNTOPT_OSYNCISOSYNC }, |
1869 | { XFS_MOUNT_NOLOGFLUSH, "," MNTOPT_NOLOGFLUSH }, | 1895 | { XFS_MOUNT_BARRIER, "," MNTOPT_BARRIER }, |
1870 | { XFS_MOUNT_IDELETE, "," MNTOPT_NOIKEEP }, | 1896 | { XFS_MOUNT_IDELETE, "," MNTOPT_NOIKEEP }, |
1871 | { 0, NULL } | 1897 | { 0, NULL } |
1872 | }; | 1898 | }; |
@@ -1883,21 +1909,20 @@ xfs_showargs( | |||
1883 | seq_printf(m, "," MNTOPT_IHASHSIZE "=%d", mp->m_ihsize); | 1909 | seq_printf(m, "," MNTOPT_IHASHSIZE "=%d", mp->m_ihsize); |
1884 | 1910 | ||
1885 | if (mp->m_flags & XFS_MOUNT_DFLT_IOSIZE) | 1911 | if (mp->m_flags & XFS_MOUNT_DFLT_IOSIZE) |
1886 | seq_printf(m, "," MNTOPT_ALLOCSIZE "=%d", 1<<mp->m_writeio_log); | 1912 | seq_printf(m, "," MNTOPT_ALLOCSIZE "=%dk", |
1913 | (int)(1 << mp->m_writeio_log) >> 10); | ||
1887 | 1914 | ||
1888 | if (mp->m_logbufs > 0) | 1915 | if (mp->m_logbufs > 0) |
1889 | seq_printf(m, "," MNTOPT_LOGBUFS "=%d", mp->m_logbufs); | 1916 | seq_printf(m, "," MNTOPT_LOGBUFS "=%d", mp->m_logbufs); |
1890 | 1917 | ||
1891 | if (mp->m_logbsize > 0) | 1918 | if (mp->m_logbsize > 0) |
1892 | seq_printf(m, "," MNTOPT_LOGBSIZE "=%d", mp->m_logbsize); | 1919 | seq_printf(m, "," MNTOPT_LOGBSIZE "=%dk", mp->m_logbsize >> 10); |
1893 | 1920 | ||
1894 | if (mp->m_ddev_targp != mp->m_logdev_targp) | 1921 | if (mp->m_logname) |
1895 | seq_printf(m, "," MNTOPT_LOGDEV "=%s", | 1922 | seq_printf(m, "," MNTOPT_LOGDEV "=%s", mp->m_logname); |
1896 | XFS_BUFTARG_NAME(mp->m_logdev_targp)); | ||
1897 | 1923 | ||
1898 | if (mp->m_rtdev_targp && mp->m_ddev_targp != mp->m_rtdev_targp) | 1924 | if (mp->m_rtname) |
1899 | seq_printf(m, "," MNTOPT_RTDEV "=%s", | 1925 | seq_printf(m, "," MNTOPT_RTDEV "=%s", mp->m_rtname); |
1900 | XFS_BUFTARG_NAME(mp->m_rtdev_targp)); | ||
1901 | 1926 | ||
1902 | if (mp->m_dalign > 0) | 1927 | if (mp->m_dalign > 0) |
1903 | seq_printf(m, "," MNTOPT_SUNIT "=%d", | 1928 | seq_printf(m, "," MNTOPT_SUNIT "=%d", |
@@ -1907,7 +1932,13 @@ xfs_showargs( | |||
1907 | seq_printf(m, "," MNTOPT_SWIDTH "=%d", | 1932 | seq_printf(m, "," MNTOPT_SWIDTH "=%d", |
1908 | (int)XFS_FSB_TO_BB(mp, mp->m_swidth)); | 1933 | (int)XFS_FSB_TO_BB(mp, mp->m_swidth)); |
1909 | 1934 | ||
1910 | if (!(mp->m_flags & XFS_MOUNT_32BITINOOPT)) | 1935 | if (!(mp->m_flags & XFS_MOUNT_COMPAT_ATTR)) |
1936 | seq_printf(m, "," MNTOPT_ATTR2); | ||
1937 | |||
1938 | if (!(mp->m_flags & XFS_MOUNT_COMPAT_IOSIZE)) | ||
1939 | seq_printf(m, "," MNTOPT_LARGEIO); | ||
1940 | |||
1941 | if (!(vfsp->vfs_flag & VFS_32BITINODES)) | ||
1911 | seq_printf(m, "," MNTOPT_64BITINODE); | 1942 | seq_printf(m, "," MNTOPT_64BITINODE); |
1912 | 1943 | ||
1913 | if (vfsp->vfs_flag & VFS_GRPID) | 1944 | if (vfsp->vfs_flag & VFS_GRPID) |
diff --git a/fs/xfs/xfs_vnodeops.c b/fs/xfs/xfs_vnodeops.c index 58bfe629b933..7c1f74531463 100644 --- a/fs/xfs/xfs_vnodeops.c +++ b/fs/xfs/xfs_vnodeops.c | |||
@@ -1,40 +1,26 @@ | |||
1 | /* | 1 | /* |
2 | * Copyright (c) 2000-2005 Silicon Graphics, Inc. All Rights Reserved. | 2 | * Copyright (c) 2000-2005 Silicon Graphics, Inc. |
3 | * All Rights Reserved. | ||
3 | * | 4 | * |
4 | * This program is free software; you can redistribute it and/or modify it | 5 | * This program is free software; you can redistribute it and/or |
5 | * under the terms of version 2 of the GNU General Public License as | 6 | * modify it under the terms of the GNU General Public License as |
6 | * published by the Free Software Foundation. | 7 | * published by the Free Software Foundation. |
7 | * | 8 | * |
8 | * This program is distributed in the hope that it would be useful, but | 9 | * This program is distributed in the hope that it would be useful, |
9 | * WITHOUT ANY WARRANTY; without even the implied warranty of | 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
12 | * GNU General Public License for more details. | ||
11 | * | 13 | * |
12 | * Further, this software is distributed without any warranty that it is | 14 | * You should have received a copy of the GNU General Public License |
13 | * free of the rightful claim of any third person regarding infringement | 15 | * along with this program; if not, write the Free Software Foundation, |
14 | * or the like. Any license provided herein, whether implied or | 16 | * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
15 | * otherwise, applies only to this software file. Patent licenses, if | ||
16 | * any, provided herein do not apply to combinations of this program with | ||
17 | * other software, or any other product whatsoever. | ||
18 | * | ||
19 | * You should have received a copy of the GNU General Public License along | ||
20 | * with this program; if not, write the Free Software Foundation, Inc., 59 | ||
21 | * Temple Place - Suite 330, Boston MA 02111-1307, USA. | ||
22 | * | ||
23 | * Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy, | ||
24 | * Mountain View, CA 94043, or: | ||
25 | * | ||
26 | * http://www.sgi.com | ||
27 | * | ||
28 | * For further information regarding this notice, see: | ||
29 | * | ||
30 | * http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/ | ||
31 | */ | 17 | */ |
32 | |||
33 | #include "xfs.h" | 18 | #include "xfs.h" |
34 | #include "xfs_macros.h" | 19 | #include "xfs_fs.h" |
35 | #include "xfs_types.h" | 20 | #include "xfs_types.h" |
36 | #include "xfs_inum.h" | 21 | #include "xfs_bit.h" |
37 | #include "xfs_log.h" | 22 | #include "xfs_log.h" |
23 | #include "xfs_inum.h" | ||
38 | #include "xfs_trans.h" | 24 | #include "xfs_trans.h" |
39 | #include "xfs_sb.h" | 25 | #include "xfs_sb.h" |
40 | #include "xfs_ag.h" | 26 | #include "xfs_ag.h" |
@@ -42,33 +28,32 @@ | |||
42 | #include "xfs_dir2.h" | 28 | #include "xfs_dir2.h" |
43 | #include "xfs_dmapi.h" | 29 | #include "xfs_dmapi.h" |
44 | #include "xfs_mount.h" | 30 | #include "xfs_mount.h" |
45 | #include "xfs_alloc_btree.h" | 31 | #include "xfs_da_btree.h" |
46 | #include "xfs_bmap_btree.h" | 32 | #include "xfs_bmap_btree.h" |
33 | #include "xfs_alloc_btree.h" | ||
47 | #include "xfs_ialloc_btree.h" | 34 | #include "xfs_ialloc_btree.h" |
48 | #include "xfs_itable.h" | ||
49 | #include "xfs_btree.h" | ||
50 | #include "xfs_ialloc.h" | ||
51 | #include "xfs_alloc.h" | ||
52 | #include "xfs_attr_sf.h" | ||
53 | #include "xfs_dir_sf.h" | 35 | #include "xfs_dir_sf.h" |
54 | #include "xfs_dir2_sf.h" | 36 | #include "xfs_dir2_sf.h" |
37 | #include "xfs_attr_sf.h" | ||
55 | #include "xfs_dinode.h" | 38 | #include "xfs_dinode.h" |
56 | #include "xfs_inode_item.h" | ||
57 | #include "xfs_inode.h" | 39 | #include "xfs_inode.h" |
40 | #include "xfs_inode_item.h" | ||
41 | #include "xfs_dir_leaf.h" | ||
42 | #include "xfs_itable.h" | ||
43 | #include "xfs_btree.h" | ||
44 | #include "xfs_ialloc.h" | ||
45 | #include "xfs_alloc.h" | ||
58 | #include "xfs_bmap.h" | 46 | #include "xfs_bmap.h" |
59 | #include "xfs_da_btree.h" | ||
60 | #include "xfs_attr.h" | 47 | #include "xfs_attr.h" |
61 | #include "xfs_rw.h" | 48 | #include "xfs_rw.h" |
62 | #include "xfs_refcache.h" | ||
63 | #include "xfs_error.h" | 49 | #include "xfs_error.h" |
64 | #include "xfs_bit.h" | ||
65 | #include "xfs_rtalloc.h" | ||
66 | #include "xfs_quota.h" | 50 | #include "xfs_quota.h" |
67 | #include "xfs_utils.h" | 51 | #include "xfs_utils.h" |
52 | #include "xfs_rtalloc.h" | ||
53 | #include "xfs_refcache.h" | ||
68 | #include "xfs_trans_space.h" | 54 | #include "xfs_trans_space.h" |
69 | #include "xfs_dir_leaf.h" | ||
70 | #include "xfs_mac.h" | ||
71 | #include "xfs_log_priv.h" | 55 | #include "xfs_log_priv.h" |
56 | #include "xfs_mac.h" | ||
72 | 57 | ||
73 | 58 | ||
74 | /* | 59 | /* |
@@ -181,40 +166,7 @@ xfs_getattr( | |||
181 | vap->va_rdev = 0; | 166 | vap->va_rdev = 0; |
182 | 167 | ||
183 | if (!(ip->i_d.di_flags & XFS_DIFLAG_REALTIME)) { | 168 | if (!(ip->i_d.di_flags & XFS_DIFLAG_REALTIME)) { |
184 | 169 | vap->va_blocksize = xfs_preferred_iosize(mp); | |
185 | #if 0 | ||
186 | /* Large block sizes confuse various | ||
187 | * user space programs, so letting the | ||
188 | * stripe size through is not a good | ||
189 | * idea for now. | ||
190 | */ | ||
191 | vap->va_blocksize = mp->m_swidth ? | ||
192 | /* | ||
193 | * If the underlying volume is a stripe, then | ||
194 | * return the stripe width in bytes as the | ||
195 | * recommended I/O size. | ||
196 | */ | ||
197 | (mp->m_swidth << mp->m_sb.sb_blocklog) : | ||
198 | /* | ||
199 | * Return the largest of the preferred buffer | ||
200 | * sizes since doing small I/Os into larger | ||
201 | * buffers causes buffers to be decommissioned. | ||
202 | * The value returned is in bytes. | ||
203 | */ | ||
204 | (1 << (int)MAX(mp->m_readio_log, | ||
205 | mp->m_writeio_log)); | ||
206 | |||
207 | #else | ||
208 | vap->va_blocksize = | ||
209 | /* | ||
210 | * Return the largest of the preferred buffer | ||
211 | * sizes since doing small I/Os into larger | ||
212 | * buffers causes buffers to be decommissioned. | ||
213 | * The value returned is in bytes. | ||
214 | */ | ||
215 | 1 << (int)MAX(mp->m_readio_log, | ||
216 | mp->m_writeio_log); | ||
217 | #endif | ||
218 | } else { | 170 | } else { |
219 | 171 | ||
220 | /* | 172 | /* |
@@ -581,8 +533,7 @@ xfs_setattr( | |||
581 | /* | 533 | /* |
582 | * Can't change extent size if any extents are allocated. | 534 | * Can't change extent size if any extents are allocated. |
583 | */ | 535 | */ |
584 | if ((ip->i_d.di_nextents || ip->i_delayed_blks) && | 536 | if (ip->i_d.di_nextents && (mask & XFS_AT_EXTSIZE) && |
585 | (mask & XFS_AT_EXTSIZE) && | ||
586 | ((ip->i_d.di_extsize << mp->m_sb.sb_blocklog) != | 537 | ((ip->i_d.di_extsize << mp->m_sb.sb_blocklog) != |
587 | vap->va_extsize) ) { | 538 | vap->va_extsize) ) { |
588 | code = XFS_ERROR(EINVAL); /* EFBIG? */ | 539 | code = XFS_ERROR(EINVAL); /* EFBIG? */ |
@@ -610,7 +561,8 @@ xfs_setattr( | |||
610 | /* | 561 | /* |
611 | * Can't change realtime flag if any extents are allocated. | 562 | * Can't change realtime flag if any extents are allocated. |
612 | */ | 563 | */ |
613 | if (ip->i_d.di_nextents && (mask & XFS_AT_XFLAGS) && | 564 | if ((ip->i_d.di_nextents || ip->i_delayed_blks) && |
565 | (mask & XFS_AT_XFLAGS) && | ||
614 | (ip->i_d.di_flags & XFS_DIFLAG_REALTIME) != | 566 | (ip->i_d.di_flags & XFS_DIFLAG_REALTIME) != |
615 | (vap->va_xflags & XFS_XFLAG_REALTIME)) { | 567 | (vap->va_xflags & XFS_XFLAG_REALTIME)) { |
616 | code = XFS_ERROR(EINVAL); /* EFBIG? */ | 568 | code = XFS_ERROR(EINVAL); /* EFBIG? */ |
@@ -674,8 +626,10 @@ xfs_setattr( | |||
674 | */ | 626 | */ |
675 | if (mask & XFS_AT_SIZE) { | 627 | if (mask & XFS_AT_SIZE) { |
676 | code = 0; | 628 | code = 0; |
677 | if (vap->va_size > ip->i_d.di_size) | 629 | if ((vap->va_size > ip->i_d.di_size) && |
630 | (flags & ATTR_NOSIZETOK) == 0) { | ||
678 | code = xfs_igrow_start(ip, vap->va_size, credp); | 631 | code = xfs_igrow_start(ip, vap->va_size, credp); |
632 | } | ||
679 | xfs_iunlock(ip, XFS_ILOCK_EXCL); | 633 | xfs_iunlock(ip, XFS_ILOCK_EXCL); |
680 | if (!code) | 634 | if (!code) |
681 | code = xfs_itruncate_data(ip, vap->va_size); | 635 | code = xfs_itruncate_data(ip, vap->va_size); |
@@ -1118,6 +1072,7 @@ xfs_fsync( | |||
1118 | xfs_inode_t *ip; | 1072 | xfs_inode_t *ip; |
1119 | xfs_trans_t *tp; | 1073 | xfs_trans_t *tp; |
1120 | int error; | 1074 | int error; |
1075 | int log_flushed = 0, changed = 1; | ||
1121 | 1076 | ||
1122 | vn_trace_entry(BHV_TO_VNODE(bdp), | 1077 | vn_trace_entry(BHV_TO_VNODE(bdp), |
1123 | __FUNCTION__, (inst_t *)__return_address); | 1078 | __FUNCTION__, (inst_t *)__return_address); |
@@ -1171,10 +1126,18 @@ xfs_fsync( | |||
1171 | xfs_iunlock(ip, XFS_ILOCK_SHARED); | 1126 | xfs_iunlock(ip, XFS_ILOCK_SHARED); |
1172 | 1127 | ||
1173 | if (xfs_ipincount(ip)) { | 1128 | if (xfs_ipincount(ip)) { |
1174 | xfs_log_force(ip->i_mount, (xfs_lsn_t)0, | 1129 | _xfs_log_force(ip->i_mount, (xfs_lsn_t)0, |
1175 | XFS_LOG_FORCE | | 1130 | XFS_LOG_FORCE | |
1176 | ((flag & FSYNC_WAIT) | 1131 | ((flag & FSYNC_WAIT) |
1177 | ? XFS_LOG_SYNC : 0)); | 1132 | ? XFS_LOG_SYNC : 0), |
1133 | &log_flushed); | ||
1134 | } else { | ||
1135 | /* | ||
1136 | * If the inode is not pinned and nothing | ||
1137 | * has changed we don't need to flush the | ||
1138 | * cache. | ||
1139 | */ | ||
1140 | changed = 0; | ||
1178 | } | 1141 | } |
1179 | error = 0; | 1142 | error = 0; |
1180 | } else { | 1143 | } else { |
@@ -1210,10 +1173,27 @@ xfs_fsync( | |||
1210 | xfs_trans_log_inode(tp, ip, XFS_ILOG_CORE); | 1173 | xfs_trans_log_inode(tp, ip, XFS_ILOG_CORE); |
1211 | if (flag & FSYNC_WAIT) | 1174 | if (flag & FSYNC_WAIT) |
1212 | xfs_trans_set_sync(tp); | 1175 | xfs_trans_set_sync(tp); |
1213 | error = xfs_trans_commit(tp, 0, NULL); | 1176 | error = _xfs_trans_commit(tp, 0, NULL, &log_flushed); |
1214 | 1177 | ||
1215 | xfs_iunlock(ip, XFS_ILOCK_EXCL); | 1178 | xfs_iunlock(ip, XFS_ILOCK_EXCL); |
1216 | } | 1179 | } |
1180 | |||
1181 | if ((ip->i_mount->m_flags & XFS_MOUNT_BARRIER) && changed) { | ||
1182 | /* | ||
1183 | * If the log write didn't issue an ordered tag we need | ||
1184 | * to flush the disk cache for the data device now. | ||
1185 | */ | ||
1186 | if (!log_flushed) | ||
1187 | xfs_blkdev_issue_flush(ip->i_mount->m_ddev_targp); | ||
1188 | |||
1189 | /* | ||
1190 | * If this inode is on the RT dev we need to flush that | ||
1191 | * cache aswell. | ||
1192 | */ | ||
1193 | if (ip->i_d.di_flags & XFS_DIFLAG_REALTIME) | ||
1194 | xfs_blkdev_issue_flush(ip->i_mount->m_rtdev_targp); | ||
1195 | } | ||
1196 | |||
1217 | return error; | 1197 | return error; |
1218 | } | 1198 | } |
1219 | 1199 | ||