diff options
Diffstat (limited to 'fs')
49 files changed, 948 insertions, 740 deletions
diff --git a/fs/9p/fid.c b/fs/9p/fid.c index eda449778fa5..c4d13bf904d2 100644 --- a/fs/9p/fid.c +++ b/fs/9p/fid.c | |||
@@ -1,7 +1,7 @@ | |||
1 | /* | 1 | /* |
2 | * V9FS FID Management | 2 | * V9FS FID Management |
3 | * | 3 | * |
4 | * Copyright (C) 2005 by Eric Van Hensbergen <ericvh@gmail.com> | 4 | * Copyright (C) 2005, 2006 by Eric Van Hensbergen <ericvh@gmail.com> |
5 | * | 5 | * |
6 | * This program is free software; you can redistribute it and/or modify | 6 | * This program is free software; you can redistribute it and/or modify |
7 | * it under the terms of the GNU General Public License as published by | 7 | * it under the terms of the GNU General Public License as published by |
@@ -40,7 +40,7 @@ | |||
40 | * | 40 | * |
41 | */ | 41 | */ |
42 | 42 | ||
43 | static int v9fs_fid_insert(struct v9fs_fid *fid, struct dentry *dentry) | 43 | int v9fs_fid_insert(struct v9fs_fid *fid, struct dentry *dentry) |
44 | { | 44 | { |
45 | struct list_head *fid_list = (struct list_head *)dentry->d_fsdata; | 45 | struct list_head *fid_list = (struct list_head *)dentry->d_fsdata; |
46 | dprintk(DEBUG_9P, "fid %d (%p) dentry %s (%p)\n", fid->fid, fid, | 46 | dprintk(DEBUG_9P, "fid %d (%p) dentry %s (%p)\n", fid->fid, fid, |
@@ -57,7 +57,6 @@ static int v9fs_fid_insert(struct v9fs_fid *fid, struct dentry *dentry) | |||
57 | } | 57 | } |
58 | 58 | ||
59 | fid->uid = current->uid; | 59 | fid->uid = current->uid; |
60 | fid->pid = current->pid; | ||
61 | list_add(&fid->list, fid_list); | 60 | list_add(&fid->list, fid_list); |
62 | return 0; | 61 | return 0; |
63 | } | 62 | } |
@@ -68,14 +67,11 @@ static int v9fs_fid_insert(struct v9fs_fid *fid, struct dentry *dentry) | |||
68 | * | 67 | * |
69 | */ | 68 | */ |
70 | 69 | ||
71 | struct v9fs_fid *v9fs_fid_create(struct dentry *dentry, | 70 | struct v9fs_fid *v9fs_fid_create(struct v9fs_session_info *v9ses, int fid) |
72 | struct v9fs_session_info *v9ses, int fid, int create) | ||
73 | { | 71 | { |
74 | struct v9fs_fid *new; | 72 | struct v9fs_fid *new; |
75 | 73 | ||
76 | dprintk(DEBUG_9P, "fid create dentry %p, fid %d, create %d\n", | 74 | dprintk(DEBUG_9P, "fid create fid %d\n", fid); |
77 | dentry, fid, create); | ||
78 | |||
79 | new = kmalloc(sizeof(struct v9fs_fid), GFP_KERNEL); | 75 | new = kmalloc(sizeof(struct v9fs_fid), GFP_KERNEL); |
80 | if (new == NULL) { | 76 | if (new == NULL) { |
81 | dprintk(DEBUG_ERROR, "Out of Memory\n"); | 77 | dprintk(DEBUG_ERROR, "Out of Memory\n"); |
@@ -85,19 +81,13 @@ struct v9fs_fid *v9fs_fid_create(struct dentry *dentry, | |||
85 | new->fid = fid; | 81 | new->fid = fid; |
86 | new->v9ses = v9ses; | 82 | new->v9ses = v9ses; |
87 | new->fidopen = 0; | 83 | new->fidopen = 0; |
88 | new->fidcreate = create; | ||
89 | new->fidclunked = 0; | 84 | new->fidclunked = 0; |
90 | new->iounit = 0; | 85 | new->iounit = 0; |
91 | new->rdir_pos = 0; | 86 | new->rdir_pos = 0; |
92 | new->rdir_fcall = NULL; | 87 | new->rdir_fcall = NULL; |
88 | INIT_LIST_HEAD(&new->list); | ||
93 | 89 | ||
94 | if (v9fs_fid_insert(new, dentry) == 0) | 90 | return new; |
95 | return new; | ||
96 | else { | ||
97 | dprintk(DEBUG_ERROR, "Problems inserting to dentry\n"); | ||
98 | kfree(new); | ||
99 | return NULL; | ||
100 | } | ||
101 | } | 91 | } |
102 | 92 | ||
103 | /** | 93 | /** |
@@ -113,140 +103,29 @@ void v9fs_fid_destroy(struct v9fs_fid *fid) | |||
113 | } | 103 | } |
114 | 104 | ||
115 | /** | 105 | /** |
116 | * v9fs_fid_walk_up - walks from the process current directory | ||
117 | * up to the specified dentry. | ||
118 | */ | ||
119 | static struct v9fs_fid *v9fs_fid_walk_up(struct dentry *dentry) | ||
120 | { | ||
121 | int fidnum, cfidnum, err; | ||
122 | struct v9fs_fid *cfid; | ||
123 | struct dentry *cde; | ||
124 | struct v9fs_session_info *v9ses; | ||
125 | |||
126 | v9ses = v9fs_inode2v9ses(current->fs->pwd->d_inode); | ||
127 | cfid = v9fs_fid_lookup(current->fs->pwd); | ||
128 | if (cfid == NULL) { | ||
129 | dprintk(DEBUG_ERROR, "process cwd doesn't have a fid\n"); | ||
130 | return ERR_PTR(-ENOENT); | ||
131 | } | ||
132 | |||
133 | cfidnum = cfid->fid; | ||
134 | cde = current->fs->pwd; | ||
135 | /* TODO: take advantage of multiwalk */ | ||
136 | |||
137 | fidnum = v9fs_get_idpool(&v9ses->fidpool); | ||
138 | if (fidnum < 0) { | ||
139 | dprintk(DEBUG_ERROR, "could not get a new fid num\n"); | ||
140 | err = -ENOENT; | ||
141 | goto clunk_fid; | ||
142 | } | ||
143 | |||
144 | while (cde != dentry) { | ||
145 | if (cde == cde->d_parent) { | ||
146 | dprintk(DEBUG_ERROR, "can't find dentry\n"); | ||
147 | err = -ENOENT; | ||
148 | goto clunk_fid; | ||
149 | } | ||
150 | |||
151 | err = v9fs_t_walk(v9ses, cfidnum, fidnum, "..", NULL); | ||
152 | if (err < 0) { | ||
153 | dprintk(DEBUG_ERROR, "problem walking to parent\n"); | ||
154 | goto clunk_fid; | ||
155 | } | ||
156 | |||
157 | cfidnum = fidnum; | ||
158 | cde = cde->d_parent; | ||
159 | } | ||
160 | |||
161 | return v9fs_fid_create(dentry, v9ses, fidnum, 0); | ||
162 | |||
163 | clunk_fid: | ||
164 | v9fs_t_clunk(v9ses, fidnum); | ||
165 | return ERR_PTR(err); | ||
166 | } | ||
167 | |||
168 | /** | ||
169 | * v9fs_fid_lookup - retrieve the right fid from a particular dentry | 106 | * v9fs_fid_lookup - retrieve the right fid from a particular dentry |
170 | * @dentry: dentry to look for fid in | 107 | * @dentry: dentry to look for fid in |
171 | * @type: intent of lookup (operation or traversal) | 108 | * @type: intent of lookup (operation or traversal) |
172 | * | 109 | * |
173 | * search list of fids associated with a dentry for a fid with a matching | 110 | * find a fid in the dentry |
174 | * thread id or uid. If that fails, look up the dentry's parents to see if you | 111 | * |
175 | * can find a matching fid. | 112 | * TODO: only match fids that have the same uid as current user |
176 | * | 113 | * |
177 | */ | 114 | */ |
178 | 115 | ||
179 | struct v9fs_fid *v9fs_fid_lookup(struct dentry *dentry) | 116 | struct v9fs_fid *v9fs_fid_lookup(struct dentry *dentry) |
180 | { | 117 | { |
181 | struct list_head *fid_list = (struct list_head *)dentry->d_fsdata; | 118 | struct list_head *fid_list = (struct list_head *)dentry->d_fsdata; |
182 | struct v9fs_fid *current_fid = NULL; | ||
183 | struct v9fs_fid *temp = NULL; | ||
184 | struct v9fs_fid *return_fid = NULL; | 119 | struct v9fs_fid *return_fid = NULL; |
185 | 120 | ||
186 | dprintk(DEBUG_9P, " dentry: %s (%p)\n", dentry->d_iname, dentry); | 121 | dprintk(DEBUG_9P, " dentry: %s (%p)\n", dentry->d_iname, dentry); |
187 | 122 | ||
188 | if (fid_list) { | 123 | if (fid_list) |
189 | list_for_each_entry_safe(current_fid, temp, fid_list, list) { | 124 | return_fid = list_entry(fid_list->next, struct v9fs_fid, list); |
190 | if (!current_fid->fidcreate) { | ||
191 | return_fid = current_fid; | ||
192 | break; | ||
193 | } | ||
194 | } | ||
195 | |||
196 | if (!return_fid) | ||
197 | return_fid = current_fid; | ||
198 | } | ||
199 | |||
200 | /* we are at the root but didn't match */ | ||
201 | if ((!return_fid) && (dentry->d_parent == dentry)) { | ||
202 | /* TODO: clone attach with new uid */ | ||
203 | return_fid = current_fid; | ||
204 | } | ||
205 | 125 | ||
206 | if (!return_fid) { | 126 | if (!return_fid) { |
207 | struct dentry *par = current->fs->pwd->d_parent; | 127 | dprintk(DEBUG_ERROR, "Couldn't find a fid in dentry\n"); |
208 | int count = 1; | ||
209 | while (par != NULL) { | ||
210 | if (par == dentry) | ||
211 | break; | ||
212 | count++; | ||
213 | if (par == par->d_parent) { | ||
214 | dprintk(DEBUG_ERROR, | ||
215 | "got to root without finding dentry\n"); | ||
216 | break; | ||
217 | } | ||
218 | par = par->d_parent; | ||
219 | } | ||
220 | |||
221 | /* XXX - there may be some duplication we can get rid of */ | ||
222 | if (par == dentry) { | ||
223 | return_fid = v9fs_fid_walk_up(dentry); | ||
224 | if (IS_ERR(return_fid)) | ||
225 | return_fid = NULL; | ||
226 | } | ||
227 | } | 128 | } |
228 | 129 | ||
229 | return return_fid; | 130 | return return_fid; |
230 | } | 131 | } |
231 | |||
232 | struct v9fs_fid *v9fs_fid_get_created(struct dentry *dentry) | ||
233 | { | ||
234 | struct list_head *fid_list; | ||
235 | struct v9fs_fid *fid, *ftmp, *ret; | ||
236 | |||
237 | dprintk(DEBUG_9P, " dentry: %s (%p)\n", dentry->d_iname, dentry); | ||
238 | fid_list = (struct list_head *)dentry->d_fsdata; | ||
239 | ret = NULL; | ||
240 | if (fid_list) { | ||
241 | list_for_each_entry_safe(fid, ftmp, fid_list, list) { | ||
242 | if (fid->fidcreate && fid->pid == current->pid) { | ||
243 | list_del(&fid->list); | ||
244 | ret = fid; | ||
245 | break; | ||
246 | } | ||
247 | } | ||
248 | } | ||
249 | |||
250 | dprintk(DEBUG_9P, "return %p\n", ret); | ||
251 | return ret; | ||
252 | } | ||
diff --git a/fs/9p/fid.h b/fs/9p/fid.h index 84c673a44c83..1fc2dd08d75a 100644 --- a/fs/9p/fid.h +++ b/fs/9p/fid.h | |||
@@ -33,7 +33,6 @@ struct v9fs_fid { | |||
33 | 33 | ||
34 | u32 fid; | 34 | u32 fid; |
35 | unsigned char fidopen; /* set when fid is opened */ | 35 | unsigned char fidopen; /* set when fid is opened */ |
36 | unsigned char fidcreate; /* set when fid was just created */ | ||
37 | unsigned char fidclunked; /* set when fid has already been clunked */ | 36 | unsigned char fidclunked; /* set when fid has already been clunked */ |
38 | 37 | ||
39 | struct v9fs_qid qid; | 38 | struct v9fs_qid qid; |
@@ -45,7 +44,6 @@ struct v9fs_fid { | |||
45 | struct v9fs_fcall *rdir_fcall; | 44 | struct v9fs_fcall *rdir_fcall; |
46 | 45 | ||
47 | /* management stuff */ | 46 | /* management stuff */ |
48 | pid_t pid; /* thread associated with this fid */ | ||
49 | uid_t uid; /* user associated with this fid */ | 47 | uid_t uid; /* user associated with this fid */ |
50 | 48 | ||
51 | /* private data */ | 49 | /* private data */ |
@@ -56,5 +54,5 @@ struct v9fs_fid { | |||
56 | struct v9fs_fid *v9fs_fid_lookup(struct dentry *dentry); | 54 | struct v9fs_fid *v9fs_fid_lookup(struct dentry *dentry); |
57 | struct v9fs_fid *v9fs_fid_get_created(struct dentry *); | 55 | struct v9fs_fid *v9fs_fid_get_created(struct dentry *); |
58 | void v9fs_fid_destroy(struct v9fs_fid *fid); | 56 | void v9fs_fid_destroy(struct v9fs_fid *fid); |
59 | struct v9fs_fid *v9fs_fid_create(struct dentry *, | 57 | struct v9fs_fid *v9fs_fid_create(struct v9fs_session_info *, int fid); |
60 | struct v9fs_session_info *v9ses, int fid, int create); | 58 | int v9fs_fid_insert(struct v9fs_fid *fid, struct dentry *dentry); |
diff --git a/fs/9p/v9fs.c b/fs/9p/v9fs.c index ef3386549140..61352491ba36 100644 --- a/fs/9p/v9fs.c +++ b/fs/9p/v9fs.c | |||
@@ -397,6 +397,7 @@ v9fs_session_init(struct v9fs_session_info *v9ses, | |||
397 | } | 397 | } |
398 | 398 | ||
399 | if (v9ses->afid != ~0) { | 399 | if (v9ses->afid != ~0) { |
400 | dprintk(DEBUG_ERROR, "afid not equal to ~0\n"); | ||
400 | if (v9fs_t_clunk(v9ses, v9ses->afid)) | 401 | if (v9fs_t_clunk(v9ses, v9ses->afid)) |
401 | dprintk(DEBUG_ERROR, "clunk failed\n"); | 402 | dprintk(DEBUG_ERROR, "clunk failed\n"); |
402 | } | 403 | } |
diff --git a/fs/9p/v9fs_vfs.h b/fs/9p/v9fs_vfs.h index 69cf2905dc90..a759278acaae 100644 --- a/fs/9p/v9fs_vfs.h +++ b/fs/9p/v9fs_vfs.h | |||
@@ -51,3 +51,4 @@ int v9fs_dir_release(struct inode *inode, struct file *filp); | |||
51 | int v9fs_file_open(struct inode *inode, struct file *file); | 51 | int v9fs_file_open(struct inode *inode, struct file *file); |
52 | void v9fs_inode2stat(struct inode *inode, struct v9fs_stat *stat); | 52 | void v9fs_inode2stat(struct inode *inode, struct v9fs_stat *stat); |
53 | void v9fs_dentry_release(struct dentry *); | 53 | void v9fs_dentry_release(struct dentry *); |
54 | int v9fs_uflags2omode(int uflags); | ||
diff --git a/fs/9p/vfs_dentry.c b/fs/9p/vfs_dentry.c index 2dd806dac9f1..12c9cc926b71 100644 --- a/fs/9p/vfs_dentry.c +++ b/fs/9p/vfs_dentry.c | |||
@@ -43,47 +43,18 @@ | |||
43 | #include "fid.h" | 43 | #include "fid.h" |
44 | 44 | ||
45 | /** | 45 | /** |
46 | * v9fs_dentry_validate - VFS dcache hook to validate cache | 46 | * v9fs_dentry_delete - called when dentry refcount equals 0 |
47 | * @dentry: dentry that is being validated | 47 | * @dentry: dentry in question |
48 | * @nd: path data | ||
49 | * | 48 | * |
50 | * dcache really shouldn't be used for 9P2000 as at all due to | 49 | * By returning 1 here we should remove cacheing of unused |
51 | * potential attached semantics to directory traversal (walk). | 50 | * dentry components. |
52 | * | ||
53 | * FUTURE: look into how to use dcache to allow multi-stage | ||
54 | * walks in Plan 9 & potential for better dcache operation which | ||
55 | * would remain valid for Plan 9 semantics. Older versions | ||
56 | * had validation via stat for those interested. However, since | ||
57 | * stat has the same approximate overhead as walk there really | ||
58 | * is no difference. The only improvement would be from a | ||
59 | * time-decay cache like NFS has and that undermines the | ||
60 | * synchronous nature of 9P2000. | ||
61 | * | 51 | * |
62 | */ | 52 | */ |
63 | 53 | ||
64 | static int v9fs_dentry_validate(struct dentry *dentry, struct nameidata *nd) | 54 | int v9fs_dentry_delete(struct dentry *dentry) |
65 | { | 55 | { |
66 | struct dentry *dc = current->fs->pwd; | 56 | dprintk(DEBUG_VFS, " dentry: %s (%p)\n", dentry->d_iname, dentry); |
67 | 57 | return 1; | |
68 | dprintk(DEBUG_VFS, "dentry: %s (%p)\n", dentry->d_iname, dentry); | ||
69 | if (v9fs_fid_lookup(dentry)) { | ||
70 | dprintk(DEBUG_VFS, "VALID\n"); | ||
71 | return 1; | ||
72 | } | ||
73 | |||
74 | while (dc != NULL) { | ||
75 | if (dc == dentry) { | ||
76 | dprintk(DEBUG_VFS, "VALID\n"); | ||
77 | return 1; | ||
78 | } | ||
79 | if (dc == dc->d_parent) | ||
80 | break; | ||
81 | |||
82 | dc = dc->d_parent; | ||
83 | } | ||
84 | |||
85 | dprintk(DEBUG_VFS, "INVALID\n"); | ||
86 | return 0; | ||
87 | } | 58 | } |
88 | 59 | ||
89 | /** | 60 | /** |
@@ -118,6 +89,6 @@ void v9fs_dentry_release(struct dentry *dentry) | |||
118 | } | 89 | } |
119 | 90 | ||
120 | struct dentry_operations v9fs_dentry_operations = { | 91 | struct dentry_operations v9fs_dentry_operations = { |
121 | .d_revalidate = v9fs_dentry_validate, | 92 | .d_delete = v9fs_dentry_delete, |
122 | .d_release = v9fs_dentry_release, | 93 | .d_release = v9fs_dentry_release, |
123 | }; | 94 | }; |
diff --git a/fs/9p/vfs_file.c b/fs/9p/vfs_file.c index c7e14d917215..de3a129698da 100644 --- a/fs/9p/vfs_file.c +++ b/fs/9p/vfs_file.c | |||
@@ -53,94 +53,70 @@ | |||
53 | int v9fs_file_open(struct inode *inode, struct file *file) | 53 | int v9fs_file_open(struct inode *inode, struct file *file) |
54 | { | 54 | { |
55 | struct v9fs_session_info *v9ses = v9fs_inode2v9ses(inode); | 55 | struct v9fs_session_info *v9ses = v9fs_inode2v9ses(inode); |
56 | struct v9fs_fid *v9fid, *fid; | 56 | struct v9fs_fid *vfid; |
57 | struct v9fs_fcall *fcall = NULL; | 57 | struct v9fs_fcall *fcall = NULL; |
58 | int open_mode = 0; | 58 | int omode; |
59 | unsigned int iounit = 0; | 59 | int fid = V9FS_NOFID; |
60 | int newfid = -1; | 60 | int err; |
61 | long result = -1; | ||
62 | 61 | ||
63 | dprintk(DEBUG_VFS, "inode: %p file: %p \n", inode, file); | 62 | dprintk(DEBUG_VFS, "inode: %p file: %p \n", inode, file); |
64 | 63 | ||
65 | v9fid = v9fs_fid_get_created(file->f_dentry); | 64 | vfid = v9fs_fid_lookup(file->f_dentry); |
66 | if (!v9fid) | 65 | if (!vfid) { |
67 | v9fid = v9fs_fid_lookup(file->f_dentry); | ||
68 | |||
69 | if (!v9fid) { | ||
70 | dprintk(DEBUG_ERROR, "Couldn't resolve fid from dentry\n"); | 66 | dprintk(DEBUG_ERROR, "Couldn't resolve fid from dentry\n"); |
71 | return -EBADF; | 67 | return -EBADF; |
72 | } | 68 | } |
73 | 69 | ||
74 | if (!v9fid->fidcreate) { | 70 | fid = v9fs_get_idpool(&v9ses->fidpool); |
75 | fid = kmalloc(sizeof(struct v9fs_fid), GFP_KERNEL); | 71 | if (fid < 0) { |
76 | if (fid == NULL) { | ||
77 | dprintk(DEBUG_ERROR, "Out of Memory\n"); | ||
78 | return -ENOMEM; | ||
79 | } | ||
80 | |||
81 | fid->fidopen = 0; | ||
82 | fid->fidcreate = 0; | ||
83 | fid->fidclunked = 0; | ||
84 | fid->iounit = 0; | ||
85 | fid->v9ses = v9ses; | ||
86 | |||
87 | newfid = v9fs_get_idpool(&v9ses->fidpool); | ||
88 | if (newfid < 0) { | ||
89 | eprintk(KERN_WARNING, "newfid fails!\n"); | 72 | eprintk(KERN_WARNING, "newfid fails!\n"); |
90 | return -ENOSPC; | 73 | return -ENOSPC; |
91 | } | 74 | } |
92 | 75 | ||
93 | result = | 76 | err = v9fs_t_walk(v9ses, vfid->fid, fid, NULL, NULL); |
94 | v9fs_t_walk(v9ses, v9fid->fid, newfid, NULL, NULL); | 77 | if (err < 0) { |
95 | |||
96 | if (result < 0) { | ||
97 | v9fs_put_idpool(newfid, &v9ses->fidpool); | ||
98 | dprintk(DEBUG_ERROR, "rewalk didn't work\n"); | 78 | dprintk(DEBUG_ERROR, "rewalk didn't work\n"); |
99 | return -EBADF; | 79 | goto put_fid; |
80 | } | ||
81 | |||
82 | vfid = kmalloc(sizeof(struct v9fs_fid), GFP_KERNEL); | ||
83 | if (vfid == NULL) { | ||
84 | dprintk(DEBUG_ERROR, "out of memory\n"); | ||
85 | goto clunk_fid; | ||
100 | } | 86 | } |
101 | 87 | ||
102 | fid->fid = newfid; | ||
103 | v9fid = fid; | ||
104 | /* TODO: do special things for O_EXCL, O_NOFOLLOW, O_SYNC */ | 88 | /* TODO: do special things for O_EXCL, O_NOFOLLOW, O_SYNC */ |
105 | /* translate open mode appropriately */ | 89 | /* translate open mode appropriately */ |
106 | open_mode = file->f_flags & 0x3; | 90 | omode = v9fs_uflags2omode(file->f_flags); |
91 | err = v9fs_t_open(v9ses, fid, omode, &fcall); | ||
92 | if (err < 0) { | ||
93 | PRINT_FCALL_ERROR("open failed", fcall); | ||
94 | goto destroy_vfid; | ||
95 | } | ||
107 | 96 | ||
108 | if (file->f_flags & O_EXCL) | 97 | file->private_data = vfid; |
109 | open_mode |= V9FS_OEXCL; | 98 | vfid->fid = fid; |
99 | vfid->fidopen = 1; | ||
100 | vfid->fidclunked = 0; | ||
101 | vfid->iounit = fcall->params.ropen.iounit; | ||
102 | vfid->rdir_pos = 0; | ||
103 | vfid->rdir_fcall = NULL; | ||
104 | vfid->filp = file; | ||
105 | kfree(fcall); | ||
110 | 106 | ||
111 | if (v9ses->extended) { | 107 | return 0; |
112 | if (file->f_flags & O_TRUNC) | ||
113 | open_mode |= V9FS_OTRUNC; | ||
114 | 108 | ||
115 | if (file->f_flags & O_APPEND) | 109 | destroy_vfid: |
116 | open_mode |= V9FS_OAPPEND; | 110 | v9fs_fid_destroy(vfid); |
117 | } | ||
118 | 111 | ||
119 | result = v9fs_t_open(v9ses, newfid, open_mode, &fcall); | 112 | clunk_fid: |
120 | if (result < 0) { | 113 | v9fs_t_clunk(v9ses, fid); |
121 | PRINT_FCALL_ERROR("open failed", fcall); | ||
122 | kfree(fcall); | ||
123 | return result; | ||
124 | } | ||
125 | 114 | ||
126 | iounit = fcall->params.ropen.iounit; | 115 | put_fid: |
116 | v9fs_put_idpool(fid, &v9ses->fidpool); | ||
127 | kfree(fcall); | 117 | kfree(fcall); |
128 | } else { | ||
129 | /* create case */ | ||
130 | newfid = v9fid->fid; | ||
131 | iounit = v9fid->iounit; | ||
132 | v9fid->fidcreate = 0; | ||
133 | } | ||
134 | |||
135 | file->private_data = v9fid; | ||
136 | |||
137 | v9fid->rdir_pos = 0; | ||
138 | v9fid->rdir_fcall = NULL; | ||
139 | v9fid->fidopen = 1; | ||
140 | v9fid->filp = file; | ||
141 | v9fid->iounit = iounit; | ||
142 | 118 | ||
143 | return 0; | 119 | return err; |
144 | } | 120 | } |
145 | 121 | ||
146 | /** | 122 | /** |
@@ -289,9 +265,7 @@ v9fs_file_write(struct file *filp, const char __user * data, | |||
289 | total += result; | 265 | total += result; |
290 | } while (count); | 266 | } while (count); |
291 | 267 | ||
292 | if(inode->i_mapping->nrpages) | ||
293 | invalidate_inode_pages2(inode->i_mapping); | 268 | invalidate_inode_pages2(inode->i_mapping); |
294 | |||
295 | return total; | 269 | return total; |
296 | } | 270 | } |
297 | 271 | ||
diff --git a/fs/9p/vfs_inode.c b/fs/9p/vfs_inode.c index 63e5b0398e8b..dce729d42869 100644 --- a/fs/9p/vfs_inode.c +++ b/fs/9p/vfs_inode.c | |||
@@ -125,6 +125,38 @@ static int p9mode2unixmode(struct v9fs_session_info *v9ses, int mode) | |||
125 | return res; | 125 | return res; |
126 | } | 126 | } |
127 | 127 | ||
128 | int v9fs_uflags2omode(int uflags) | ||
129 | { | ||
130 | int ret; | ||
131 | |||
132 | ret = 0; | ||
133 | switch (uflags&3) { | ||
134 | default: | ||
135 | case O_RDONLY: | ||
136 | ret = V9FS_OREAD; | ||
137 | break; | ||
138 | |||
139 | case O_WRONLY: | ||
140 | ret = V9FS_OWRITE; | ||
141 | break; | ||
142 | |||
143 | case O_RDWR: | ||
144 | ret = V9FS_ORDWR; | ||
145 | break; | ||
146 | } | ||
147 | |||
148 | if (uflags & O_EXCL) | ||
149 | ret |= V9FS_OEXCL; | ||
150 | |||
151 | if (uflags & O_TRUNC) | ||
152 | ret |= V9FS_OTRUNC; | ||
153 | |||
154 | if (uflags & O_APPEND) | ||
155 | ret |= V9FS_OAPPEND; | ||
156 | |||
157 | return ret; | ||
158 | } | ||
159 | |||
128 | /** | 160 | /** |
129 | * v9fs_blank_wstat - helper function to setup a 9P stat structure | 161 | * v9fs_blank_wstat - helper function to setup a 9P stat structure |
130 | * @v9ses: 9P session info (for determining extended mode) | 162 | * @v9ses: 9P session info (for determining extended mode) |
@@ -163,7 +195,7 @@ v9fs_blank_wstat(struct v9fs_wstat *wstat) | |||
163 | 195 | ||
164 | struct inode *v9fs_get_inode(struct super_block *sb, int mode) | 196 | struct inode *v9fs_get_inode(struct super_block *sb, int mode) |
165 | { | 197 | { |
166 | struct inode *inode = NULL; | 198 | struct inode *inode; |
167 | struct v9fs_session_info *v9ses = sb->s_fs_info; | 199 | struct v9fs_session_info *v9ses = sb->s_fs_info; |
168 | 200 | ||
169 | dprintk(DEBUG_VFS, "super block: %p mode: %o\n", sb, mode); | 201 | dprintk(DEBUG_VFS, "super block: %p mode: %o\n", sb, mode); |
@@ -222,171 +254,135 @@ struct inode *v9fs_get_inode(struct super_block *sb, int mode) | |||
222 | return inode; | 254 | return inode; |
223 | } | 255 | } |
224 | 256 | ||
225 | /** | ||
226 | * v9fs_create - helper function to create files and directories | ||
227 | * @dir: directory inode file is being created in | ||
228 | * @file_dentry: dentry file is being created in | ||
229 | * @perm: permissions file is being created with | ||
230 | * @open_mode: resulting open mode for file | ||
231 | * | ||
232 | */ | ||
233 | |||
234 | static int | 257 | static int |
235 | v9fs_create(struct inode *dir, | 258 | v9fs_create(struct v9fs_session_info *v9ses, u32 pfid, char *name, |
236 | struct dentry *file_dentry, | 259 | u32 perm, u8 mode, u32 *fidp, struct v9fs_qid *qid, u32 *iounit) |
237 | unsigned int perm, unsigned int open_mode) | ||
238 | { | 260 | { |
239 | struct v9fs_session_info *v9ses = v9fs_inode2v9ses(dir); | 261 | u32 fid; |
240 | struct super_block *sb = dir->i_sb; | ||
241 | struct v9fs_fid *dirfid = | ||
242 | v9fs_fid_lookup(file_dentry->d_parent); | ||
243 | struct v9fs_fid *fid = NULL; | ||
244 | struct inode *file_inode = NULL; | ||
245 | struct v9fs_fcall *fcall = NULL; | ||
246 | struct v9fs_qid qid; | ||
247 | int dirfidnum = -1; | ||
248 | long newfid = -1; | ||
249 | int result = 0; | ||
250 | unsigned int iounit = 0; | ||
251 | int wfidno = -1; | ||
252 | int err; | 262 | int err; |
263 | struct v9fs_fcall *fcall; | ||
253 | 264 | ||
254 | perm = unixmode2p9mode(v9ses, perm); | 265 | fid = v9fs_get_idpool(&v9ses->fidpool); |
255 | 266 | if (fid < 0) { | |
256 | dprintk(DEBUG_VFS, "dir: %p dentry: %p perm: %o mode: %o\n", dir, | ||
257 | file_dentry, perm, open_mode); | ||
258 | |||
259 | if (!dirfid) | ||
260 | return -EBADF; | ||
261 | |||
262 | dirfidnum = dirfid->fid; | ||
263 | if (dirfidnum < 0) { | ||
264 | dprintk(DEBUG_ERROR, "No fid for the directory #%lu\n", | ||
265 | dir->i_ino); | ||
266 | return -EBADF; | ||
267 | } | ||
268 | |||
269 | if (file_dentry->d_inode) { | ||
270 | dprintk(DEBUG_ERROR, | ||
271 | "Odd. There is an inode for dir %lu, name :%s:\n", | ||
272 | dir->i_ino, file_dentry->d_name.name); | ||
273 | return -EEXIST; | ||
274 | } | ||
275 | |||
276 | newfid = v9fs_get_idpool(&v9ses->fidpool); | ||
277 | if (newfid < 0) { | ||
278 | eprintk(KERN_WARNING, "no free fids available\n"); | 267 | eprintk(KERN_WARNING, "no free fids available\n"); |
279 | return -ENOSPC; | 268 | err = -ENOSPC; |
269 | goto error; | ||
280 | } | 270 | } |
281 | 271 | ||
282 | result = v9fs_t_walk(v9ses, dirfidnum, newfid, NULL, &fcall); | 272 | err = v9fs_t_walk(v9ses, pfid, fid, NULL, &fcall); |
283 | if (result < 0) { | 273 | if (err < 0) { |
284 | PRINT_FCALL_ERROR("clone error", fcall); | 274 | PRINT_FCALL_ERROR("clone error", fcall); |
285 | v9fs_put_idpool(newfid, &v9ses->fidpool); | 275 | goto error; |
286 | newfid = -1; | ||
287 | goto CleanUpFid; | ||
288 | } | 276 | } |
289 | |||
290 | kfree(fcall); | 277 | kfree(fcall); |
291 | fcall = NULL; | ||
292 | 278 | ||
293 | result = v9fs_t_create(v9ses, newfid, (char *)file_dentry->d_name.name, | 279 | err = v9fs_t_create(v9ses, fid, name, perm, mode, &fcall); |
294 | perm, open_mode, &fcall); | 280 | if (err < 0) { |
295 | if (result < 0) { | ||
296 | PRINT_FCALL_ERROR("create fails", fcall); | 281 | PRINT_FCALL_ERROR("create fails", fcall); |
297 | goto CleanUpFid; | 282 | goto error; |
298 | } | 283 | } |
299 | 284 | ||
300 | iounit = fcall->params.rcreate.iounit; | 285 | if (iounit) |
301 | qid = fcall->params.rcreate.qid; | 286 | *iounit = fcall->params.rcreate.iounit; |
287 | |||
288 | if (qid) | ||
289 | *qid = fcall->params.rcreate.qid; | ||
290 | |||
291 | if (fidp) | ||
292 | *fidp = fid; | ||
293 | |||
302 | kfree(fcall); | 294 | kfree(fcall); |
303 | fcall = NULL; | 295 | return 0; |
304 | 296 | ||
305 | if (!(perm&V9FS_DMDIR)) { | 297 | error: |
306 | fid = v9fs_fid_create(file_dentry, v9ses, newfid, 1); | 298 | if (fid >= 0) |
307 | dprintk(DEBUG_VFS, "fid %p %d\n", fid, fid->fidcreate); | 299 | v9fs_put_idpool(fid, &v9ses->fidpool); |
308 | if (!fid) { | ||
309 | result = -ENOMEM; | ||
310 | goto CleanUpFid; | ||
311 | } | ||
312 | 300 | ||
313 | fid->qid = qid; | 301 | kfree(fcall); |
314 | fid->iounit = iounit; | 302 | return err; |
315 | } else { | 303 | } |
316 | err = v9fs_t_clunk(v9ses, newfid); | 304 | |
317 | newfid = -1; | 305 | static struct v9fs_fid* |
318 | if (err < 0) | 306 | v9fs_clone_walk(struct v9fs_session_info *v9ses, u32 fid, struct dentry *dentry) |
319 | dprintk(DEBUG_ERROR, "clunk for mkdir failed: %d\n", err); | 307 | { |
320 | } | 308 | int err; |
309 | u32 nfid; | ||
310 | struct v9fs_fid *ret; | ||
311 | struct v9fs_fcall *fcall; | ||
321 | 312 | ||
322 | /* walk to the newly created file and put the fid in the dentry */ | 313 | nfid = v9fs_get_idpool(&v9ses->fidpool); |
323 | wfidno = v9fs_get_idpool(&v9ses->fidpool); | 314 | if (nfid < 0) { |
324 | if (wfidno < 0) { | ||
325 | eprintk(KERN_WARNING, "no free fids available\n"); | 315 | eprintk(KERN_WARNING, "no free fids available\n"); |
326 | return -ENOSPC; | 316 | err = -ENOSPC; |
317 | goto error; | ||
327 | } | 318 | } |
328 | 319 | ||
329 | result = v9fs_t_walk(v9ses, dirfidnum, wfidno, | 320 | err = v9fs_t_walk(v9ses, fid, nfid, (char *) dentry->d_name.name, |
330 | (char *) file_dentry->d_name.name, &fcall); | 321 | &fcall); |
331 | if (result < 0) { | 322 | |
332 | PRINT_FCALL_ERROR("clone error", fcall); | 323 | if (err < 0) { |
333 | v9fs_put_idpool(wfidno, &v9ses->fidpool); | 324 | PRINT_FCALL_ERROR("walk error", fcall); |
334 | wfidno = -1; | 325 | v9fs_put_idpool(nfid, &v9ses->fidpool); |
335 | goto CleanUpFid; | 326 | goto error; |
336 | } | 327 | } |
328 | |||
337 | kfree(fcall); | 329 | kfree(fcall); |
338 | fcall = NULL; | 330 | fcall = NULL; |
331 | ret = v9fs_fid_create(v9ses, nfid); | ||
332 | if (!ret) { | ||
333 | err = -ENOMEM; | ||
334 | goto clunk_fid; | ||
335 | } | ||
339 | 336 | ||
340 | if (!v9fs_fid_create(file_dentry, v9ses, wfidno, 0)) { | 337 | err = v9fs_fid_insert(ret, dentry); |
341 | v9fs_put_idpool(wfidno, &v9ses->fidpool); | 338 | if (err < 0) { |
342 | 339 | v9fs_fid_destroy(ret); | |
343 | goto CleanUpFid; | 340 | goto clunk_fid; |
344 | } | 341 | } |
345 | 342 | ||
346 | if ((perm & V9FS_DMSYMLINK) || (perm & V9FS_DMLINK) || | 343 | return ret; |
347 | (perm & V9FS_DMNAMEDPIPE) || (perm & V9FS_DMSOCKET) || | ||
348 | (perm & V9FS_DMDEVICE)) | ||
349 | return 0; | ||
350 | 344 | ||
351 | result = v9fs_t_stat(v9ses, wfidno, &fcall); | 345 | clunk_fid: |
352 | if (result < 0) { | 346 | v9fs_t_clunk(v9ses, nfid); |
353 | PRINT_FCALL_ERROR("stat error", fcall); | 347 | |
354 | goto CleanUpFid; | 348 | error: |
355 | } | 349 | kfree(fcall); |
350 | return ERR_PTR(err); | ||
351 | } | ||
356 | 352 | ||
353 | struct inode * | ||
354 | v9fs_inode_from_fid(struct v9fs_session_info *v9ses, u32 fid, | ||
355 | struct super_block *sb) | ||
356 | { | ||
357 | int err, umode; | ||
358 | struct inode *ret; | ||
359 | struct v9fs_fcall *fcall; | ||
357 | 360 | ||
358 | file_inode = v9fs_get_inode(sb, | 361 | ret = NULL; |
359 | p9mode2unixmode(v9ses, fcall->params.rstat.stat.mode)); | 362 | err = v9fs_t_stat(v9ses, fid, &fcall); |
363 | if (err) { | ||
364 | PRINT_FCALL_ERROR("stat error", fcall); | ||
365 | goto error; | ||
366 | } | ||
360 | 367 | ||
361 | if ((!file_inode) || IS_ERR(file_inode)) { | 368 | umode = p9mode2unixmode(v9ses, fcall->params.rstat.stat.mode); |
362 | dprintk(DEBUG_ERROR, "create inode failed\n"); | 369 | ret = v9fs_get_inode(sb, umode); |
363 | result = -EBADF; | 370 | if (IS_ERR(ret)) { |
364 | goto CleanUpFid; | 371 | err = PTR_ERR(ret); |
372 | ret = NULL; | ||
373 | goto error; | ||
365 | } | 374 | } |
366 | 375 | ||
367 | v9fs_stat2inode(&fcall->params.rstat.stat, file_inode, sb); | 376 | v9fs_stat2inode(&fcall->params.rstat.stat, ret, sb); |
368 | kfree(fcall); | 377 | kfree(fcall); |
369 | fcall = NULL; | 378 | return ret; |
370 | file_dentry->d_op = &v9fs_dentry_operations; | ||
371 | d_instantiate(file_dentry, file_inode); | ||
372 | |||
373 | return 0; | ||
374 | 379 | ||
375 | CleanUpFid: | 380 | error: |
376 | kfree(fcall); | 381 | kfree(fcall); |
377 | fcall = NULL; | 382 | if (ret) |
383 | iput(ret); | ||
378 | 384 | ||
379 | if (newfid >= 0) { | 385 | return ERR_PTR(err); |
380 | err = v9fs_t_clunk(v9ses, newfid); | ||
381 | if (err < 0) | ||
382 | dprintk(DEBUG_ERROR, "clunk failed: %d\n", err); | ||
383 | } | ||
384 | if (wfidno >= 0) { | ||
385 | err = v9fs_t_clunk(v9ses, wfidno); | ||
386 | if (err < 0) | ||
387 | dprintk(DEBUG_ERROR, "clunk failed: %d\n", err); | ||
388 | } | ||
389 | return result; | ||
390 | } | 386 | } |
391 | 387 | ||
392 | /** | 388 | /** |
@@ -440,20 +436,97 @@ static int v9fs_remove(struct inode *dir, struct dentry *file, int rmdir) | |||
440 | return result; | 436 | return result; |
441 | } | 437 | } |
442 | 438 | ||
439 | static int | ||
440 | v9fs_open_created(struct inode *inode, struct file *file) | ||
441 | { | ||
442 | return 0; | ||
443 | } | ||
444 | |||
443 | /** | 445 | /** |
444 | * v9fs_vfs_create - VFS hook to create files | 446 | * v9fs_vfs_create - VFS hook to create files |
445 | * @inode: directory inode that is being deleted | 447 | * @inode: directory inode that is being deleted |
446 | * @dentry: dentry that is being deleted | 448 | * @dentry: dentry that is being deleted |
447 | * @perm: create permissions | 449 | * @mode: create permissions |
448 | * @nd: path information | 450 | * @nd: path information |
449 | * | 451 | * |
450 | */ | 452 | */ |
451 | 453 | ||
452 | static int | 454 | static int |
453 | v9fs_vfs_create(struct inode *inode, struct dentry *dentry, int perm, | 455 | v9fs_vfs_create(struct inode *dir, struct dentry *dentry, int mode, |
454 | struct nameidata *nd) | 456 | struct nameidata *nd) |
455 | { | 457 | { |
456 | return v9fs_create(inode, dentry, perm, O_RDWR); | 458 | int err; |
459 | u32 fid, perm, iounit; | ||
460 | int flags; | ||
461 | struct v9fs_session_info *v9ses; | ||
462 | struct v9fs_fid *dfid, *vfid, *ffid; | ||
463 | struct inode *inode; | ||
464 | struct v9fs_qid qid; | ||
465 | struct file *filp; | ||
466 | |||
467 | inode = NULL; | ||
468 | vfid = NULL; | ||
469 | v9ses = v9fs_inode2v9ses(dir); | ||
470 | dfid = v9fs_fid_lookup(dentry->d_parent); | ||
471 | perm = unixmode2p9mode(v9ses, mode); | ||
472 | |||
473 | if (nd && nd->flags & LOOKUP_OPEN) | ||
474 | flags = nd->intent.open.flags - 1; | ||
475 | else | ||
476 | flags = O_RDWR; | ||
477 | |||
478 | err = v9fs_create(v9ses, dfid->fid, (char *) dentry->d_name.name, | ||
479 | perm, v9fs_uflags2omode(flags), &fid, &qid, &iounit); | ||
480 | |||
481 | if (err) | ||
482 | goto error; | ||
483 | |||
484 | vfid = v9fs_clone_walk(v9ses, dfid->fid, dentry); | ||
485 | if (IS_ERR(vfid)) { | ||
486 | err = PTR_ERR(vfid); | ||
487 | vfid = NULL; | ||
488 | goto error; | ||
489 | } | ||
490 | |||
491 | inode = v9fs_inode_from_fid(v9ses, vfid->fid, dir->i_sb); | ||
492 | if (IS_ERR(inode)) { | ||
493 | err = PTR_ERR(inode); | ||
494 | inode = NULL; | ||
495 | goto error; | ||
496 | } | ||
497 | |||
498 | dentry->d_op = &v9fs_dentry_operations; | ||
499 | d_instantiate(dentry, inode); | ||
500 | |||
501 | if (nd && nd->flags & LOOKUP_OPEN) { | ||
502 | ffid = v9fs_fid_create(v9ses, fid); | ||
503 | if (!ffid) | ||
504 | return -ENOMEM; | ||
505 | |||
506 | filp = lookup_instantiate_filp(nd, dentry, v9fs_open_created); | ||
507 | if (IS_ERR(filp)) { | ||
508 | v9fs_fid_destroy(ffid); | ||
509 | return PTR_ERR(filp); | ||
510 | } | ||
511 | |||
512 | ffid->rdir_pos = 0; | ||
513 | ffid->rdir_fcall = NULL; | ||
514 | ffid->fidopen = 1; | ||
515 | ffid->iounit = iounit; | ||
516 | ffid->filp = filp; | ||
517 | filp->private_data = ffid; | ||
518 | } | ||
519 | |||
520 | return 0; | ||
521 | |||
522 | error: | ||
523 | if (vfid) | ||
524 | v9fs_fid_destroy(vfid); | ||
525 | |||
526 | if (inode) | ||
527 | iput(inode); | ||
528 | |||
529 | return err; | ||
457 | } | 530 | } |
458 | 531 | ||
459 | /** | 532 | /** |
@@ -464,9 +537,57 @@ v9fs_vfs_create(struct inode *inode, struct dentry *dentry, int perm, | |||
464 | * | 537 | * |
465 | */ | 538 | */ |
466 | 539 | ||
467 | static int v9fs_vfs_mkdir(struct inode *inode, struct dentry *dentry, int mode) | 540 | static int v9fs_vfs_mkdir(struct inode *dir, struct dentry *dentry, int mode) |
468 | { | 541 | { |
469 | return v9fs_create(inode, dentry, mode | S_IFDIR, O_RDONLY); | 542 | int err; |
543 | u32 fid, perm; | ||
544 | struct v9fs_session_info *v9ses; | ||
545 | struct v9fs_fid *dfid, *vfid; | ||
546 | struct inode *inode; | ||
547 | |||
548 | inode = NULL; | ||
549 | vfid = NULL; | ||
550 | v9ses = v9fs_inode2v9ses(dir); | ||
551 | dfid = v9fs_fid_lookup(dentry->d_parent); | ||
552 | perm = unixmode2p9mode(v9ses, mode | S_IFDIR); | ||
553 | |||
554 | err = v9fs_create(v9ses, dfid->fid, (char *) dentry->d_name.name, | ||
555 | perm, V9FS_OREAD, &fid, NULL, NULL); | ||
556 | |||
557 | if (err) { | ||
558 | dprintk(DEBUG_ERROR, "create error %d\n", err); | ||
559 | goto error; | ||
560 | } | ||
561 | |||
562 | err = v9fs_t_clunk(v9ses, fid); | ||
563 | if (err) { | ||
564 | dprintk(DEBUG_ERROR, "clunk error %d\n", err); | ||
565 | goto error; | ||
566 | } | ||
567 | |||
568 | vfid = v9fs_clone_walk(v9ses, dfid->fid, dentry); | ||
569 | if (IS_ERR(vfid)) { | ||
570 | err = PTR_ERR(vfid); | ||
571 | vfid = NULL; | ||
572 | goto error; | ||
573 | } | ||
574 | |||
575 | inode = v9fs_inode_from_fid(v9ses, vfid->fid, dir->i_sb); | ||
576 | if (IS_ERR(inode)) { | ||
577 | err = PTR_ERR(inode); | ||
578 | inode = NULL; | ||
579 | goto error; | ||
580 | } | ||
581 | |||
582 | dentry->d_op = &v9fs_dentry_operations; | ||
583 | d_instantiate(dentry, inode); | ||
584 | return 0; | ||
585 | |||
586 | error: | ||
587 | if (vfid) | ||
588 | v9fs_fid_destroy(vfid); | ||
589 | |||
590 | return err; | ||
470 | } | 591 | } |
471 | 592 | ||
472 | /** | 593 | /** |
@@ -516,9 +637,8 @@ static struct dentry *v9fs_vfs_lookup(struct inode *dir, struct dentry *dentry, | |||
516 | return ERR_PTR(-ENOSPC); | 637 | return ERR_PTR(-ENOSPC); |
517 | } | 638 | } |
518 | 639 | ||
519 | result = | 640 | result = v9fs_t_walk(v9ses, dirfidnum, newfid, |
520 | v9fs_t_walk(v9ses, dirfidnum, newfid, (char *)dentry->d_name.name, | 641 | (char *)dentry->d_name.name, NULL); |
521 | NULL); | ||
522 | if (result < 0) { | 642 | if (result < 0) { |
523 | v9fs_put_idpool(newfid, &v9ses->fidpool); | 643 | v9fs_put_idpool(newfid, &v9ses->fidpool); |
524 | if (result == -ENOENT) { | 644 | if (result == -ENOENT) { |
@@ -551,13 +671,17 @@ static struct dentry *v9fs_vfs_lookup(struct inode *dir, struct dentry *dentry, | |||
551 | 671 | ||
552 | inode->i_ino = v9fs_qid2ino(&fcall->params.rstat.stat.qid); | 672 | inode->i_ino = v9fs_qid2ino(&fcall->params.rstat.stat.qid); |
553 | 673 | ||
554 | fid = v9fs_fid_create(dentry, v9ses, newfid, 0); | 674 | fid = v9fs_fid_create(v9ses, newfid); |
555 | if (fid == NULL) { | 675 | if (fid == NULL) { |
556 | dprintk(DEBUG_ERROR, "couldn't insert\n"); | 676 | dprintk(DEBUG_ERROR, "couldn't insert\n"); |
557 | result = -ENOMEM; | 677 | result = -ENOMEM; |
558 | goto FreeFcall; | 678 | goto FreeFcall; |
559 | } | 679 | } |
560 | 680 | ||
681 | result = v9fs_fid_insert(fid, dentry); | ||
682 | if (result < 0) | ||
683 | goto FreeFcall; | ||
684 | |||
561 | fid->qid = fcall->params.rstat.stat.qid; | 685 | fid->qid = fcall->params.rstat.stat.qid; |
562 | 686 | ||
563 | dentry->d_op = &v9fs_dentry_operations; | 687 | dentry->d_op = &v9fs_dentry_operations; |
@@ -886,8 +1010,8 @@ static int v9fs_readlink(struct dentry *dentry, char *buffer, int buflen) | |||
886 | } | 1010 | } |
887 | 1011 | ||
888 | /* copy extension buffer into buffer */ | 1012 | /* copy extension buffer into buffer */ |
889 | if (fcall->params.rstat.stat.extension.len+1 < buflen) | 1013 | if (fcall->params.rstat.stat.extension.len < buflen) |
890 | buflen = fcall->params.rstat.stat.extension.len + 1; | 1014 | buflen = fcall->params.rstat.stat.extension.len; |
891 | 1015 | ||
892 | memcpy(buffer, fcall->params.rstat.stat.extension.str, buflen - 1); | 1016 | memcpy(buffer, fcall->params.rstat.stat.extension.str, buflen - 1); |
893 | buffer[buflen-1] = 0; | 1017 | buffer[buflen-1] = 0; |
@@ -951,7 +1075,7 @@ static void *v9fs_vfs_follow_link(struct dentry *dentry, struct nameidata *nd) | |||
951 | if (!link) | 1075 | if (!link) |
952 | link = ERR_PTR(-ENOMEM); | 1076 | link = ERR_PTR(-ENOMEM); |
953 | else { | 1077 | else { |
954 | len = v9fs_readlink(dentry, link, PATH_MAX); | 1078 | len = v9fs_readlink(dentry, link, strlen(link)); |
955 | 1079 | ||
956 | if (len < 0) { | 1080 | if (len < 0) { |
957 | __putname(link); | 1081 | __putname(link); |
@@ -983,53 +1107,75 @@ static void v9fs_vfs_put_link(struct dentry *dentry, struct nameidata *nd, void | |||
983 | static int v9fs_vfs_mkspecial(struct inode *dir, struct dentry *dentry, | 1107 | static int v9fs_vfs_mkspecial(struct inode *dir, struct dentry *dentry, |
984 | int mode, const char *extension) | 1108 | int mode, const char *extension) |
985 | { | 1109 | { |
986 | int err, retval; | 1110 | int err; |
1111 | u32 fid, perm; | ||
987 | struct v9fs_session_info *v9ses; | 1112 | struct v9fs_session_info *v9ses; |
1113 | struct v9fs_fid *dfid, *vfid; | ||
1114 | struct inode *inode; | ||
988 | struct v9fs_fcall *fcall; | 1115 | struct v9fs_fcall *fcall; |
989 | struct v9fs_fid *fid; | ||
990 | struct v9fs_wstat wstat; | 1116 | struct v9fs_wstat wstat; |
991 | 1117 | ||
992 | v9ses = v9fs_inode2v9ses(dir); | ||
993 | retval = -EPERM; | ||
994 | fcall = NULL; | 1118 | fcall = NULL; |
1119 | inode = NULL; | ||
1120 | vfid = NULL; | ||
1121 | v9ses = v9fs_inode2v9ses(dir); | ||
1122 | dfid = v9fs_fid_lookup(dentry->d_parent); | ||
1123 | perm = unixmode2p9mode(v9ses, mode); | ||
995 | 1124 | ||
996 | if (!v9ses->extended) { | 1125 | if (!v9ses->extended) { |
997 | dprintk(DEBUG_ERROR, "not extended\n"); | 1126 | dprintk(DEBUG_ERROR, "not extended\n"); |
998 | goto free_mem; | 1127 | return -EPERM; |
999 | } | 1128 | } |
1000 | 1129 | ||
1001 | /* issue a create */ | 1130 | err = v9fs_create(v9ses, dfid->fid, (char *) dentry->d_name.name, |
1002 | retval = v9fs_create(dir, dentry, mode, 0); | 1131 | perm, V9FS_OREAD, &fid, NULL, NULL); |
1003 | if (retval != 0) | ||
1004 | goto free_mem; | ||
1005 | 1132 | ||
1006 | fid = v9fs_fid_get_created(dentry); | 1133 | if (err) |
1007 | if (!fid) { | 1134 | goto error; |
1008 | dprintk(DEBUG_ERROR, "couldn't resolve fid from dentry\n"); | 1135 | |
1009 | goto free_mem; | 1136 | err = v9fs_t_clunk(v9ses, fid); |
1137 | if (err) | ||
1138 | goto error; | ||
1139 | |||
1140 | vfid = v9fs_clone_walk(v9ses, dfid->fid, dentry); | ||
1141 | if (IS_ERR(vfid)) { | ||
1142 | err = PTR_ERR(vfid); | ||
1143 | vfid = NULL; | ||
1144 | goto error; | ||
1145 | } | ||
1146 | |||
1147 | inode = v9fs_inode_from_fid(v9ses, vfid->fid, dir->i_sb); | ||
1148 | if (IS_ERR(inode)) { | ||
1149 | err = PTR_ERR(inode); | ||
1150 | inode = NULL; | ||
1151 | goto error; | ||
1010 | } | 1152 | } |
1011 | 1153 | ||
1012 | /* issue a Twstat */ | 1154 | /* issue a Twstat */ |
1013 | v9fs_blank_wstat(&wstat); | 1155 | v9fs_blank_wstat(&wstat); |
1014 | wstat.muid = v9ses->name; | 1156 | wstat.muid = v9ses->name; |
1015 | wstat.extension = (char *) extension; | 1157 | wstat.extension = (char *) extension; |
1016 | retval = v9fs_t_wstat(v9ses, fid->fid, &wstat, &fcall); | 1158 | err = v9fs_t_wstat(v9ses, vfid->fid, &wstat, &fcall); |
1017 | if (retval < 0) { | ||
1018 | PRINT_FCALL_ERROR("wstat error", fcall); | ||
1019 | goto free_mem; | ||
1020 | } | ||
1021 | |||
1022 | err = v9fs_t_clunk(v9ses, fid->fid); | ||
1023 | if (err < 0) { | 1159 | if (err < 0) { |
1024 | dprintk(DEBUG_ERROR, "clunk failed: %d\n", err); | 1160 | PRINT_FCALL_ERROR("wstat error", fcall); |
1025 | goto free_mem; | 1161 | goto error; |
1026 | } | 1162 | } |
1027 | 1163 | ||
1028 | d_drop(dentry); /* FID - will this also clunk? */ | 1164 | kfree(fcall); |
1165 | dentry->d_op = &v9fs_dentry_operations; | ||
1166 | d_instantiate(dentry, inode); | ||
1167 | return 0; | ||
1029 | 1168 | ||
1030 | free_mem: | 1169 | error: |
1031 | kfree(fcall); | 1170 | kfree(fcall); |
1032 | return retval; | 1171 | if (vfid) |
1172 | v9fs_fid_destroy(vfid); | ||
1173 | |||
1174 | if (inode) | ||
1175 | iput(inode); | ||
1176 | |||
1177 | return err; | ||
1178 | |||
1033 | } | 1179 | } |
1034 | 1180 | ||
1035 | /** | 1181 | /** |
diff --git a/fs/9p/vfs_super.c b/fs/9p/vfs_super.c index 2c4fa75be025..cdf787ee08de 100644 --- a/fs/9p/vfs_super.c +++ b/fs/9p/vfs_super.c | |||
@@ -146,7 +146,6 @@ static struct super_block *v9fs_get_sb(struct file_system_type | |||
146 | inode->i_gid = gid; | 146 | inode->i_gid = gid; |
147 | 147 | ||
148 | root = d_alloc_root(inode); | 148 | root = d_alloc_root(inode); |
149 | |||
150 | if (!root) { | 149 | if (!root) { |
151 | retval = -ENOMEM; | 150 | retval = -ENOMEM; |
152 | goto put_back_sb; | 151 | goto put_back_sb; |
@@ -157,16 +156,22 @@ static struct super_block *v9fs_get_sb(struct file_system_type | |||
157 | stat_result = v9fs_t_stat(v9ses, newfid, &fcall); | 156 | stat_result = v9fs_t_stat(v9ses, newfid, &fcall); |
158 | if (stat_result < 0) { | 157 | if (stat_result < 0) { |
159 | dprintk(DEBUG_ERROR, "stat error\n"); | 158 | dprintk(DEBUG_ERROR, "stat error\n"); |
159 | kfree(fcall); | ||
160 | v9fs_t_clunk(v9ses, newfid); | 160 | v9fs_t_clunk(v9ses, newfid); |
161 | v9fs_put_idpool(newfid, &v9ses->fidpool); | ||
162 | } else { | 161 | } else { |
163 | /* Setup the Root Inode */ | 162 | /* Setup the Root Inode */ |
164 | root_fid = v9fs_fid_create(root, v9ses, newfid, 0); | 163 | root_fid = v9fs_fid_create(v9ses, newfid); |
165 | if (root_fid == NULL) { | 164 | if (root_fid == NULL) { |
166 | retval = -ENOMEM; | 165 | retval = -ENOMEM; |
167 | goto put_back_sb; | 166 | goto put_back_sb; |
168 | } | 167 | } |
169 | 168 | ||
169 | retval = v9fs_fid_insert(root_fid, root); | ||
170 | if (retval < 0) { | ||
171 | kfree(fcall); | ||
172 | goto put_back_sb; | ||
173 | } | ||
174 | |||
170 | root_fid->qid = fcall->params.rstat.stat.qid; | 175 | root_fid->qid = fcall->params.rstat.stat.qid; |
171 | root->d_inode->i_ino = | 176 | root->d_inode->i_ino = |
172 | v9fs_qid2ino(&fcall->params.rstat.stat.qid); | 177 | v9fs_qid2ino(&fcall->params.rstat.stat.qid); |
diff --git a/fs/binfmt_elf.c b/fs/binfmt_elf.c index 1b117a441298..c2eac2a50bd2 100644 --- a/fs/binfmt_elf.c +++ b/fs/binfmt_elf.c | |||
@@ -938,6 +938,11 @@ static int load_elf_binary(struct linux_binprm * bprm, struct pt_regs * regs) | |||
938 | kfree(elf_interpreter); | 938 | kfree(elf_interpreter); |
939 | } else { | 939 | } else { |
940 | elf_entry = loc->elf_ex.e_entry; | 940 | elf_entry = loc->elf_ex.e_entry; |
941 | if (BAD_ADDR(elf_entry)) { | ||
942 | send_sig(SIGSEGV, current, 0); | ||
943 | retval = -ENOEXEC; /* Nobody gets to see this, but.. */ | ||
944 | goto out_free_dentry; | ||
945 | } | ||
941 | } | 946 | } |
942 | 947 | ||
943 | kfree(elf_phdata); | 948 | kfree(elf_phdata); |
diff --git a/fs/compat_ioctl.c b/fs/compat_ioctl.c index 057e60217fc5..537ac70edfe5 100644 --- a/fs/compat_ioctl.c +++ b/fs/compat_ioctl.c | |||
@@ -2531,18 +2531,9 @@ static int rtc_ioctl(unsigned fd, unsigned cmd, unsigned long arg) | |||
2531 | val32 = kval; | 2531 | val32 = kval; |
2532 | return put_user(val32, (unsigned int __user *)arg); | 2532 | return put_user(val32, (unsigned int __user *)arg); |
2533 | case RTC_IRQP_SET32: | 2533 | case RTC_IRQP_SET32: |
2534 | return sys_ioctl(fd, RTC_IRQP_SET, arg); | ||
2534 | case RTC_EPOCH_SET32: | 2535 | case RTC_EPOCH_SET32: |
2535 | ret = get_user(val32, (unsigned int __user *)arg); | 2536 | return sys_ioctl(fd, RTC_EPOCH_SET, arg); |
2536 | if (ret) | ||
2537 | return ret; | ||
2538 | kval = val32; | ||
2539 | |||
2540 | set_fs(KERNEL_DS); | ||
2541 | ret = sys_ioctl(fd, (cmd == RTC_IRQP_SET32) ? | ||
2542 | RTC_IRQP_SET : RTC_EPOCH_SET, | ||
2543 | (unsigned long)&kval); | ||
2544 | set_fs(oldfs); | ||
2545 | return ret; | ||
2546 | default: | 2537 | default: |
2547 | /* unreached */ | 2538 | /* unreached */ |
2548 | return -ENOIOCTLCMD; | 2539 | return -ENOIOCTLCMD; |
@@ -885,6 +885,12 @@ int flush_old_exec(struct linux_binprm * bprm) | |||
885 | current->flags &= ~PF_RANDOMIZE; | 885 | current->flags &= ~PF_RANDOMIZE; |
886 | flush_thread(); | 886 | flush_thread(); |
887 | 887 | ||
888 | /* Set the new mm task size. We have to do that late because it may | ||
889 | * depend on TIF_32BIT which is only updated in flush_thread() on | ||
890 | * some architectures like powerpc | ||
891 | */ | ||
892 | current->mm->task_size = TASK_SIZE; | ||
893 | |||
888 | if (bprm->e_uid != current->euid || bprm->e_gid != current->egid || | 894 | if (bprm->e_uid != current->euid || bprm->e_gid != current->egid || |
889 | file_permission(bprm->file, MAY_READ) || | 895 | file_permission(bprm->file, MAY_READ) || |
890 | (bprm->interp_flags & BINPRM_FLAGS_ENFORCE_NONDUMP)) { | 896 | (bprm->interp_flags & BINPRM_FLAGS_ENFORCE_NONDUMP)) { |
diff --git a/fs/fuse/dir.c b/fs/fuse/dir.c index 21fd59c7bc24..c72a8a97935c 100644 --- a/fs/fuse/dir.c +++ b/fs/fuse/dir.c | |||
@@ -111,6 +111,8 @@ static int fuse_dentry_revalidate(struct dentry *entry, struct nameidata *nd) | |||
111 | 111 | ||
112 | /* Doesn't hurt to "reset" the validity timeout */ | 112 | /* Doesn't hurt to "reset" the validity timeout */ |
113 | fuse_invalidate_entry_cache(entry); | 113 | fuse_invalidate_entry_cache(entry); |
114 | |||
115 | /* For negative dentries, always do a fresh lookup */ | ||
114 | if (!inode) | 116 | if (!inode) |
115 | return 0; | 117 | return 0; |
116 | 118 | ||
@@ -122,6 +124,9 @@ static int fuse_dentry_revalidate(struct dentry *entry, struct nameidata *nd) | |||
122 | fuse_lookup_init(req, entry->d_parent->d_inode, entry, &outarg); | 124 | fuse_lookup_init(req, entry->d_parent->d_inode, entry, &outarg); |
123 | request_send(fc, req); | 125 | request_send(fc, req); |
124 | err = req->out.h.error; | 126 | err = req->out.h.error; |
127 | /* Zero nodeid is same as -ENOENT */ | ||
128 | if (!err && !outarg.nodeid) | ||
129 | err = -ENOENT; | ||
125 | if (!err) { | 130 | if (!err) { |
126 | struct fuse_inode *fi = get_fuse_inode(inode); | 131 | struct fuse_inode *fi = get_fuse_inode(inode); |
127 | if (outarg.nodeid != get_node_id(inode)) { | 132 | if (outarg.nodeid != get_node_id(inode)) { |
@@ -190,8 +195,9 @@ static struct dentry *fuse_lookup(struct inode *dir, struct dentry *entry, | |||
190 | fuse_lookup_init(req, dir, entry, &outarg); | 195 | fuse_lookup_init(req, dir, entry, &outarg); |
191 | request_send(fc, req); | 196 | request_send(fc, req); |
192 | err = req->out.h.error; | 197 | err = req->out.h.error; |
193 | if (!err && ((outarg.nodeid && invalid_nodeid(outarg.nodeid)) || | 198 | /* Zero nodeid is same as -ENOENT, but with valid timeout */ |
194 | !valid_mode(outarg.attr.mode))) | 199 | if (!err && outarg.nodeid && |
200 | (invalid_nodeid(outarg.nodeid) || !valid_mode(outarg.attr.mode))) | ||
195 | err = -EIO; | 201 | err = -EIO; |
196 | if (!err && outarg.nodeid) { | 202 | if (!err && outarg.nodeid) { |
197 | inode = fuse_iget(dir->i_sb, outarg.nodeid, outarg.generation, | 203 | inode = fuse_iget(dir->i_sb, outarg.nodeid, outarg.generation, |
diff --git a/fs/namei.c b/fs/namei.c index e28de846c591..557dcf395ca1 100644 --- a/fs/namei.c +++ b/fs/namei.c | |||
@@ -2224,13 +2224,17 @@ int vfs_link(struct dentry *old_dentry, struct inode *dir, struct dentry *new_de | |||
2224 | * and other special files. --ADM | 2224 | * and other special files. --ADM |
2225 | */ | 2225 | */ |
2226 | asmlinkage long sys_linkat(int olddfd, const char __user *oldname, | 2226 | asmlinkage long sys_linkat(int olddfd, const char __user *oldname, |
2227 | int newdfd, const char __user *newname) | 2227 | int newdfd, const char __user *newname, |
2228 | int flags) | ||
2228 | { | 2229 | { |
2229 | struct dentry *new_dentry; | 2230 | struct dentry *new_dentry; |
2230 | struct nameidata nd, old_nd; | 2231 | struct nameidata nd, old_nd; |
2231 | int error; | 2232 | int error; |
2232 | char * to; | 2233 | char * to; |
2233 | 2234 | ||
2235 | if (flags != 0) | ||
2236 | return -EINVAL; | ||
2237 | |||
2234 | to = getname(newname); | 2238 | to = getname(newname); |
2235 | if (IS_ERR(to)) | 2239 | if (IS_ERR(to)) |
2236 | return PTR_ERR(to); | 2240 | return PTR_ERR(to); |
@@ -2263,7 +2267,7 @@ exit: | |||
2263 | 2267 | ||
2264 | asmlinkage long sys_link(const char __user *oldname, const char __user *newname) | 2268 | asmlinkage long sys_link(const char __user *oldname, const char __user *newname) |
2265 | { | 2269 | { |
2266 | return sys_linkat(AT_FDCWD, oldname, AT_FDCWD, newname); | 2270 | return sys_linkat(AT_FDCWD, oldname, AT_FDCWD, newname, 0); |
2267 | } | 2271 | } |
2268 | 2272 | ||
2269 | /* | 2273 | /* |
diff --git a/fs/ntfs/ChangeLog b/fs/ntfs/ChangeLog index 02f44094bda9..9d8ffa89e2c2 100644 --- a/fs/ntfs/ChangeLog +++ b/fs/ntfs/ChangeLog | |||
@@ -1,9 +1,9 @@ | |||
1 | ToDo/Notes: | 1 | ToDo/Notes: |
2 | - Find and fix bugs. | 2 | - Find and fix bugs. |
3 | - The only places in the kernel where a file is resized are | 3 | - The only places in the kernel where a file is resized are |
4 | ntfs_file_write*() and ntfs_truncate() for both of which i_sem is | 4 | ntfs_file_write*() and ntfs_truncate() for both of which i_mutex is |
5 | held. Just have to be careful in read-/writepage and other helpers | 5 | held. Just have to be careful in read-/writepage and other helpers |
6 | not running under i_sem that we play nice... Also need to be careful | 6 | not running under i_mutex that we play nice. Also need to be careful |
7 | with initialized_size extension in ntfs_file_write*() and writepage. | 7 | with initialized_size extension in ntfs_file_write*() and writepage. |
8 | UPDATE: The only things that need to be checked are the compressed | 8 | UPDATE: The only things that need to be checked are the compressed |
9 | write and the other attribute resize/write cases like index | 9 | write and the other attribute resize/write cases like index |
@@ -19,6 +19,24 @@ ToDo/Notes: | |||
19 | - Enable the code for setting the NT4 compatibility flag when we start | 19 | - Enable the code for setting the NT4 compatibility flag when we start |
20 | making NTFS 1.2 specific modifications. | 20 | making NTFS 1.2 specific modifications. |
21 | 21 | ||
22 | 2.1.26 - Minor bug fixes and updates. | ||
23 | |||
24 | - Fix a potential overflow in file.c where a cast to s64 was missing in | ||
25 | a left shift of a page index. | ||
26 | - The struct inode has had its i_sem semaphore changed to a mutex named | ||
27 | i_mutex. | ||
28 | - We have struct kmem_cache now so use it instead of the typedef | ||
29 | kmem_cache_t. (Pekka Enberg) | ||
30 | - Implement support for sector sizes above 512 bytes (up to the maximum | ||
31 | supported by NTFS which is 4096 bytes). | ||
32 | - Do more detailed reporting of why we cannot mount read-write by | ||
33 | special casing the VOLUME_MODIFIED_BY_CHKDSK flag. | ||
34 | - Miscellaneous updates to layout.h. | ||
35 | - Cope with attribute list attribute having invalid flags. Windows | ||
36 | copes with this and even chkdsk does not detect or fix this so we | ||
37 | have to cope with it, too. Thanks to Pawel Kot for reporting the | ||
38 | problem. | ||
39 | |||
22 | 2.1.25 - (Almost) fully implement write(2) and truncate(2). | 40 | 2.1.25 - (Almost) fully implement write(2) and truncate(2). |
23 | 41 | ||
24 | - Change ntfs_map_runlist_nolock(), ntfs_attr_find_vcn_nolock() and | 42 | - Change ntfs_map_runlist_nolock(), ntfs_attr_find_vcn_nolock() and |
@@ -373,7 +391,7 @@ ToDo/Notes: | |||
373 | single one of them had an mst error. (Thanks to Ken MacFerrin for | 391 | single one of them had an mst error. (Thanks to Ken MacFerrin for |
374 | the bug report.) | 392 | the bug report.) |
375 | - Fix error handling in fs/ntfs/quota.c::ntfs_mark_quotas_out_of_date() | 393 | - Fix error handling in fs/ntfs/quota.c::ntfs_mark_quotas_out_of_date() |
376 | where we failed to release i_sem on the $Quota/$Q attribute inode. | 394 | where we failed to release i_mutex on the $Quota/$Q attribute inode. |
377 | - Fix bug in handling of bad inodes in fs/ntfs/namei.c::ntfs_lookup(). | 395 | - Fix bug in handling of bad inodes in fs/ntfs/namei.c::ntfs_lookup(). |
378 | - Add mapping of unmapped buffers to all remaining code paths, i.e. | 396 | - Add mapping of unmapped buffers to all remaining code paths, i.e. |
379 | fs/ntfs/aops.c::ntfs_write_mst_block(), mft.c::ntfs_sync_mft_mirror(), | 397 | fs/ntfs/aops.c::ntfs_write_mst_block(), mft.c::ntfs_sync_mft_mirror(), |
@@ -874,7 +892,7 @@ ToDo/Notes: | |||
874 | clusters. (Philipp Thomas) | 892 | clusters. (Philipp Thomas) |
875 | - attrib.c::load_attribute_list(): Fix bug when initialized_size is a | 893 | - attrib.c::load_attribute_list(): Fix bug when initialized_size is a |
876 | multiple of the block_size but not the cluster size. (Szabolcs | 894 | multiple of the block_size but not the cluster size. (Szabolcs |
877 | Szakacsits <szaka@sienet.hu>) | 895 | Szakacsits) |
878 | 896 | ||
879 | 2.1.2 - Important bug fixes aleviating the hangs in statfs. | 897 | 2.1.2 - Important bug fixes aleviating the hangs in statfs. |
880 | 898 | ||
@@ -884,7 +902,7 @@ ToDo/Notes: | |||
884 | 902 | ||
885 | - Add handling for initialized_size != data_size in compressed files. | 903 | - Add handling for initialized_size != data_size in compressed files. |
886 | - Reduce function local stack usage from 0x3d4 bytes to just noise in | 904 | - Reduce function local stack usage from 0x3d4 bytes to just noise in |
887 | fs/ntfs/upcase.c. (Randy Dunlap <rdunlap@xenotime.net>) | 905 | fs/ntfs/upcase.c. (Randy Dunlap) |
888 | - Remove compiler warnings for newer gcc. | 906 | - Remove compiler warnings for newer gcc. |
889 | - Pages are no longer kmapped by mm/filemap.c::generic_file_write() | 907 | - Pages are no longer kmapped by mm/filemap.c::generic_file_write() |
890 | around calls to ->{prepare,commit}_write. Adapt NTFS appropriately | 908 | around calls to ->{prepare,commit}_write. Adapt NTFS appropriately |
@@ -1201,11 +1219,11 @@ ToDo/Notes: | |||
1201 | the kernel. We probably want a kernel generic init_address_space() | 1219 | the kernel. We probably want a kernel generic init_address_space() |
1202 | function... | 1220 | function... |
1203 | - Drop BKL from ntfs_readdir() after consultation with Al Viro. The | 1221 | - Drop BKL from ntfs_readdir() after consultation with Al Viro. The |
1204 | only caller of ->readdir() is vfs_readdir() which holds i_sem during | 1222 | only caller of ->readdir() is vfs_readdir() which holds i_mutex |
1205 | the call, and i_sem is sufficient protection against changes in the | 1223 | during the call, and i_mutex is sufficient protection against changes |
1206 | directory inode (including ->i_size). | 1224 | in the directory inode (including ->i_size). |
1207 | - Use generic_file_llseek() for directories (as opposed to | 1225 | - Use generic_file_llseek() for directories (as opposed to |
1208 | default_llseek()) as this downs i_sem instead of the BKL which is | 1226 | default_llseek()) as this downs i_mutex instead of the BKL which is |
1209 | what we now need for exclusion against ->f_pos changes considering we | 1227 | what we now need for exclusion against ->f_pos changes considering we |
1210 | no longer take the BKL in ntfs_readdir(). | 1228 | no longer take the BKL in ntfs_readdir(). |
1211 | 1229 | ||
diff --git a/fs/ntfs/Makefile b/fs/ntfs/Makefile index d0d45d1c853a..d95fac7fdeb6 100644 --- a/fs/ntfs/Makefile +++ b/fs/ntfs/Makefile | |||
@@ -6,7 +6,7 @@ ntfs-objs := aops.o attrib.o collate.o compress.o debug.o dir.o file.o \ | |||
6 | index.o inode.o mft.o mst.o namei.o runlist.o super.o sysctl.o \ | 6 | index.o inode.o mft.o mst.o namei.o runlist.o super.o sysctl.o \ |
7 | unistr.o upcase.o | 7 | unistr.o upcase.o |
8 | 8 | ||
9 | EXTRA_CFLAGS = -DNTFS_VERSION=\"2.1.25\" | 9 | EXTRA_CFLAGS = -DNTFS_VERSION=\"2.1.26\" |
10 | 10 | ||
11 | ifeq ($(CONFIG_NTFS_DEBUG),y) | 11 | ifeq ($(CONFIG_NTFS_DEBUG),y) |
12 | EXTRA_CFLAGS += -DDEBUG | 12 | EXTRA_CFLAGS += -DDEBUG |
diff --git a/fs/ntfs/aops.c b/fs/ntfs/aops.c index 1c0a4315876a..7e361da770b3 100644 --- a/fs/ntfs/aops.c +++ b/fs/ntfs/aops.c | |||
@@ -2,7 +2,7 @@ | |||
2 | * aops.c - NTFS kernel address space operations and page cache handling. | 2 | * aops.c - NTFS kernel address space operations and page cache handling. |
3 | * Part of the Linux-NTFS project. | 3 | * Part of the Linux-NTFS project. |
4 | * | 4 | * |
5 | * Copyright (c) 2001-2005 Anton Altaparmakov | 5 | * Copyright (c) 2001-2006 Anton Altaparmakov |
6 | * Copyright (c) 2002 Richard Russon | 6 | * Copyright (c) 2002 Richard Russon |
7 | * | 7 | * |
8 | * This program/include file is free software; you can redistribute it and/or | 8 | * This program/include file is free software; you can redistribute it and/or |
@@ -200,8 +200,8 @@ static int ntfs_read_block(struct page *page) | |||
200 | /* $MFT/$DATA must have its complete runlist in memory at all times. */ | 200 | /* $MFT/$DATA must have its complete runlist in memory at all times. */ |
201 | BUG_ON(!ni->runlist.rl && !ni->mft_no && !NInoAttr(ni)); | 201 | BUG_ON(!ni->runlist.rl && !ni->mft_no && !NInoAttr(ni)); |
202 | 202 | ||
203 | blocksize_bits = VFS_I(ni)->i_blkbits; | 203 | blocksize = vol->sb->s_blocksize; |
204 | blocksize = 1 << blocksize_bits; | 204 | blocksize_bits = vol->sb->s_blocksize_bits; |
205 | 205 | ||
206 | if (!page_has_buffers(page)) { | 206 | if (!page_has_buffers(page)) { |
207 | create_empty_buffers(page, blocksize, 0); | 207 | create_empty_buffers(page, blocksize, 0); |
@@ -569,10 +569,8 @@ static int ntfs_write_block(struct page *page, struct writeback_control *wbc) | |||
569 | 569 | ||
570 | BUG_ON(!NInoNonResident(ni)); | 570 | BUG_ON(!NInoNonResident(ni)); |
571 | BUG_ON(NInoMstProtected(ni)); | 571 | BUG_ON(NInoMstProtected(ni)); |
572 | 572 | blocksize = vol->sb->s_blocksize; | |
573 | blocksize_bits = vi->i_blkbits; | 573 | blocksize_bits = vol->sb->s_blocksize_bits; |
574 | blocksize = 1 << blocksize_bits; | ||
575 | |||
576 | if (!page_has_buffers(page)) { | 574 | if (!page_has_buffers(page)) { |
577 | BUG_ON(!PageUptodate(page)); | 575 | BUG_ON(!PageUptodate(page)); |
578 | create_empty_buffers(page, blocksize, | 576 | create_empty_buffers(page, blocksize, |
@@ -949,8 +947,8 @@ static int ntfs_write_mst_block(struct page *page, | |||
949 | */ | 947 | */ |
950 | BUG_ON(!(is_mft || S_ISDIR(vi->i_mode) || | 948 | BUG_ON(!(is_mft || S_ISDIR(vi->i_mode) || |
951 | (NInoAttr(ni) && ni->type == AT_INDEX_ALLOCATION))); | 949 | (NInoAttr(ni) && ni->type == AT_INDEX_ALLOCATION))); |
952 | bh_size_bits = vi->i_blkbits; | 950 | bh_size = vol->sb->s_blocksize; |
953 | bh_size = 1 << bh_size_bits; | 951 | bh_size_bits = vol->sb->s_blocksize_bits; |
954 | max_bhs = PAGE_CACHE_SIZE / bh_size; | 952 | max_bhs = PAGE_CACHE_SIZE / bh_size; |
955 | BUG_ON(!max_bhs); | 953 | BUG_ON(!max_bhs); |
956 | BUG_ON(max_bhs > MAX_BUF_PER_PAGE); | 954 | BUG_ON(max_bhs > MAX_BUF_PER_PAGE); |
@@ -1596,7 +1594,7 @@ void mark_ntfs_record_dirty(struct page *page, const unsigned int ofs) { | |||
1596 | 1594 | ||
1597 | BUG_ON(!PageUptodate(page)); | 1595 | BUG_ON(!PageUptodate(page)); |
1598 | end = ofs + ni->itype.index.block_size; | 1596 | end = ofs + ni->itype.index.block_size; |
1599 | bh_size = 1 << VFS_I(ni)->i_blkbits; | 1597 | bh_size = VFS_I(ni)->i_sb->s_blocksize; |
1600 | spin_lock(&mapping->private_lock); | 1598 | spin_lock(&mapping->private_lock); |
1601 | if (unlikely(!page_has_buffers(page))) { | 1599 | if (unlikely(!page_has_buffers(page))) { |
1602 | spin_unlock(&mapping->private_lock); | 1600 | spin_unlock(&mapping->private_lock); |
diff --git a/fs/ntfs/file.c b/fs/ntfs/file.c index fb413d3d8618..5027d3d1b3fe 100644 --- a/fs/ntfs/file.c +++ b/fs/ntfs/file.c | |||
@@ -1,7 +1,7 @@ | |||
1 | /* | 1 | /* |
2 | * file.c - NTFS kernel file operations. Part of the Linux-NTFS project. | 2 | * file.c - NTFS kernel file operations. Part of the Linux-NTFS project. |
3 | * | 3 | * |
4 | * Copyright (c) 2001-2005 Anton Altaparmakov | 4 | * Copyright (c) 2001-2006 Anton Altaparmakov |
5 | * | 5 | * |
6 | * This program/include file is free software; you can redistribute it and/or | 6 | * This program/include file is free software; you can redistribute it and/or |
7 | * modify it under the terms of the GNU General Public License as published | 7 | * modify it under the terms of the GNU General Public License as published |
@@ -248,7 +248,7 @@ do_non_resident_extend: | |||
248 | * enough to make ntfs_writepage() work. | 248 | * enough to make ntfs_writepage() work. |
249 | */ | 249 | */ |
250 | write_lock_irqsave(&ni->size_lock, flags); | 250 | write_lock_irqsave(&ni->size_lock, flags); |
251 | ni->initialized_size = (index + 1) << PAGE_CACHE_SHIFT; | 251 | ni->initialized_size = (s64)(index + 1) << PAGE_CACHE_SHIFT; |
252 | if (ni->initialized_size > new_init_size) | 252 | if (ni->initialized_size > new_init_size) |
253 | ni->initialized_size = new_init_size; | 253 | ni->initialized_size = new_init_size; |
254 | write_unlock_irqrestore(&ni->size_lock, flags); | 254 | write_unlock_irqrestore(&ni->size_lock, flags); |
@@ -529,8 +529,8 @@ static int ntfs_prepare_pages_for_non_resident_write(struct page **pages, | |||
529 | "index 0x%lx, nr_pages 0x%x, pos 0x%llx, bytes 0x%zx.", | 529 | "index 0x%lx, nr_pages 0x%x, pos 0x%llx, bytes 0x%zx.", |
530 | vi->i_ino, ni->type, pages[0]->index, nr_pages, | 530 | vi->i_ino, ni->type, pages[0]->index, nr_pages, |
531 | (long long)pos, bytes); | 531 | (long long)pos, bytes); |
532 | blocksize_bits = vi->i_blkbits; | 532 | blocksize = vol->sb->s_blocksize; |
533 | blocksize = 1 << blocksize_bits; | 533 | blocksize_bits = vol->sb->s_blocksize_bits; |
534 | u = 0; | 534 | u = 0; |
535 | do { | 535 | do { |
536 | struct page *page = pages[u]; | 536 | struct page *page = pages[u]; |
@@ -1525,7 +1525,7 @@ static inline int ntfs_commit_pages_after_non_resident_write( | |||
1525 | 1525 | ||
1526 | vi = pages[0]->mapping->host; | 1526 | vi = pages[0]->mapping->host; |
1527 | ni = NTFS_I(vi); | 1527 | ni = NTFS_I(vi); |
1528 | blocksize = 1 << vi->i_blkbits; | 1528 | blocksize = vi->i_sb->s_blocksize; |
1529 | end = pos + bytes; | 1529 | end = pos + bytes; |
1530 | u = 0; | 1530 | u = 0; |
1531 | do { | 1531 | do { |
diff --git a/fs/ntfs/inode.c b/fs/ntfs/inode.c index ea1bd3feea1b..55263b7de9c0 100644 --- a/fs/ntfs/inode.c +++ b/fs/ntfs/inode.c | |||
@@ -677,13 +677,28 @@ static int ntfs_read_locked_inode(struct inode *vi) | |||
677 | ntfs_debug("Attribute list found in inode 0x%lx.", vi->i_ino); | 677 | ntfs_debug("Attribute list found in inode 0x%lx.", vi->i_ino); |
678 | NInoSetAttrList(ni); | 678 | NInoSetAttrList(ni); |
679 | a = ctx->attr; | 679 | a = ctx->attr; |
680 | if (a->flags & ATTR_IS_ENCRYPTED || | 680 | if (a->flags & ATTR_COMPRESSION_MASK) { |
681 | a->flags & ATTR_COMPRESSION_MASK || | ||
682 | a->flags & ATTR_IS_SPARSE) { | ||
683 | ntfs_error(vi->i_sb, "Attribute list attribute is " | 681 | ntfs_error(vi->i_sb, "Attribute list attribute is " |
684 | "compressed/encrypted/sparse."); | 682 | "compressed."); |
685 | goto unm_err_out; | 683 | goto unm_err_out; |
686 | } | 684 | } |
685 | if (a->flags & ATTR_IS_ENCRYPTED || | ||
686 | a->flags & ATTR_IS_SPARSE) { | ||
687 | if (a->non_resident) { | ||
688 | ntfs_error(vi->i_sb, "Non-resident attribute " | ||
689 | "list attribute is encrypted/" | ||
690 | "sparse."); | ||
691 | goto unm_err_out; | ||
692 | } | ||
693 | ntfs_warning(vi->i_sb, "Resident attribute list " | ||
694 | "attribute in inode 0x%lx is marked " | ||
695 | "encrypted/sparse which is not true. " | ||
696 | "However, Windows allows this and " | ||
697 | "chkdsk does not detect or correct it " | ||
698 | "so we will just ignore the invalid " | ||
699 | "flags and pretend they are not set.", | ||
700 | vi->i_ino); | ||
701 | } | ||
687 | /* Now allocate memory for the attribute list. */ | 702 | /* Now allocate memory for the attribute list. */ |
688 | ni->attr_list_size = (u32)ntfs_attr_size(a); | 703 | ni->attr_list_size = (u32)ntfs_attr_size(a); |
689 | ni->attr_list = ntfs_malloc_nofs(ni->attr_list_size); | 704 | ni->attr_list = ntfs_malloc_nofs(ni->attr_list_size); |
@@ -1809,19 +1824,33 @@ int ntfs_read_inode_mount(struct inode *vi) | |||
1809 | } else /* if (!err) */ { | 1824 | } else /* if (!err) */ { |
1810 | ATTR_LIST_ENTRY *al_entry, *next_al_entry; | 1825 | ATTR_LIST_ENTRY *al_entry, *next_al_entry; |
1811 | u8 *al_end; | 1826 | u8 *al_end; |
1827 | static const char *es = " Not allowed. $MFT is corrupt. " | ||
1828 | "You should run chkdsk."; | ||
1812 | 1829 | ||
1813 | ntfs_debug("Attribute list attribute found in $MFT."); | 1830 | ntfs_debug("Attribute list attribute found in $MFT."); |
1814 | NInoSetAttrList(ni); | 1831 | NInoSetAttrList(ni); |
1815 | a = ctx->attr; | 1832 | a = ctx->attr; |
1816 | if (a->flags & ATTR_IS_ENCRYPTED || | 1833 | if (a->flags & ATTR_COMPRESSION_MASK) { |
1817 | a->flags & ATTR_COMPRESSION_MASK || | ||
1818 | a->flags & ATTR_IS_SPARSE) { | ||
1819 | ntfs_error(sb, "Attribute list attribute is " | 1834 | ntfs_error(sb, "Attribute list attribute is " |
1820 | "compressed/encrypted/sparse. Not " | 1835 | "compressed.%s", es); |
1821 | "allowed. $MFT is corrupt. You should " | ||
1822 | "run chkdsk."); | ||
1823 | goto put_err_out; | 1836 | goto put_err_out; |
1824 | } | 1837 | } |
1838 | if (a->flags & ATTR_IS_ENCRYPTED || | ||
1839 | a->flags & ATTR_IS_SPARSE) { | ||
1840 | if (a->non_resident) { | ||
1841 | ntfs_error(sb, "Non-resident attribute list " | ||
1842 | "attribute is encrypted/" | ||
1843 | "sparse.%s", es); | ||
1844 | goto put_err_out; | ||
1845 | } | ||
1846 | ntfs_warning(sb, "Resident attribute list attribute " | ||
1847 | "in $MFT system file is marked " | ||
1848 | "encrypted/sparse which is not true. " | ||
1849 | "However, Windows allows this and " | ||
1850 | "chkdsk does not detect or correct it " | ||
1851 | "so we will just ignore the invalid " | ||
1852 | "flags and pretend they are not set."); | ||
1853 | } | ||
1825 | /* Now allocate memory for the attribute list. */ | 1854 | /* Now allocate memory for the attribute list. */ |
1826 | ni->attr_list_size = (u32)ntfs_attr_size(a); | 1855 | ni->attr_list_size = (u32)ntfs_attr_size(a); |
1827 | ni->attr_list = ntfs_malloc_nofs(ni->attr_list_size); | 1856 | ni->attr_list = ntfs_malloc_nofs(ni->attr_list_size); |
diff --git a/fs/ntfs/layout.h b/fs/ntfs/layout.h index f5678d5d7919..bb408d4dcbb0 100644 --- a/fs/ntfs/layout.h +++ b/fs/ntfs/layout.h | |||
@@ -838,15 +838,19 @@ enum { | |||
838 | F_A_DEVICE, F_A_DIRECTORY, F_A_SPARSE_FILE, F_A_REPARSE_POINT, | 838 | F_A_DEVICE, F_A_DIRECTORY, F_A_SPARSE_FILE, F_A_REPARSE_POINT, |
839 | F_A_COMPRESSED, and F_A_ENCRYPTED and preserves the rest. This mask | 839 | F_A_COMPRESSED, and F_A_ENCRYPTED and preserves the rest. This mask |
840 | is used to to obtain all flags that are valid for setting. */ | 840 | is used to to obtain all flags that are valid for setting. */ |
841 | |||
842 | /* | 841 | /* |
843 | * The following flags are only present in the FILE_NAME attribute (in | 842 | * The following flag is only present in the FILE_NAME attribute (in |
844 | * the field file_attributes). | 843 | * the field file_attributes). |
845 | */ | 844 | */ |
846 | FILE_ATTR_DUP_FILE_NAME_INDEX_PRESENT = const_cpu_to_le32(0x10000000), | 845 | FILE_ATTR_DUP_FILE_NAME_INDEX_PRESENT = const_cpu_to_le32(0x10000000), |
847 | /* Note, this is a copy of the corresponding bit from the mft record, | 846 | /* Note, this is a copy of the corresponding bit from the mft record, |
848 | telling us whether this is a directory or not, i.e. whether it has | 847 | telling us whether this is a directory or not, i.e. whether it has |
849 | an index root attribute or not. */ | 848 | an index root attribute or not. */ |
849 | /* | ||
850 | * The following flag is present both in the STANDARD_INFORMATION | ||
851 | * attribute and in the FILE_NAME attribute (in the field | ||
852 | * file_attributes). | ||
853 | */ | ||
850 | FILE_ATTR_DUP_VIEW_INDEX_PRESENT = const_cpu_to_le32(0x20000000), | 854 | FILE_ATTR_DUP_VIEW_INDEX_PRESENT = const_cpu_to_le32(0x20000000), |
851 | /* Note, this is a copy of the corresponding bit from the mft record, | 855 | /* Note, this is a copy of the corresponding bit from the mft record, |
852 | telling us whether this file has a view index present (eg. object id | 856 | telling us whether this file has a view index present (eg. object id |
@@ -1071,9 +1075,15 @@ typedef struct { | |||
1071 | modified. */ | 1075 | modified. */ |
1072 | /* 20*/ sle64 last_access_time; /* Time this mft record was last | 1076 | /* 20*/ sle64 last_access_time; /* Time this mft record was last |
1073 | accessed. */ | 1077 | accessed. */ |
1074 | /* 28*/ sle64 allocated_size; /* Byte size of allocated space for the | 1078 | /* 28*/ sle64 allocated_size; /* Byte size of on-disk allocated space |
1075 | data attribute. NOTE: Is a multiple | 1079 | for the data attribute. So for |
1076 | of the cluster size. */ | 1080 | normal $DATA, this is the |
1081 | allocated_size from the unnamed | ||
1082 | $DATA attribute and for compressed | ||
1083 | and/or sparse $DATA, this is the | ||
1084 | compressed_size from the unnamed | ||
1085 | $DATA attribute. NOTE: This is a | ||
1086 | multiple of the cluster size. */ | ||
1077 | /* 30*/ sle64 data_size; /* Byte size of actual data in data | 1087 | /* 30*/ sle64 data_size; /* Byte size of actual data in data |
1078 | attribute. */ | 1088 | attribute. */ |
1079 | /* 38*/ FILE_ATTR_FLAGS file_attributes; /* Flags describing the file. */ | 1089 | /* 38*/ FILE_ATTR_FLAGS file_attributes; /* Flags describing the file. */ |
@@ -1904,12 +1914,13 @@ enum { | |||
1904 | VOLUME_DELETE_USN_UNDERWAY = const_cpu_to_le16(0x0010), | 1914 | VOLUME_DELETE_USN_UNDERWAY = const_cpu_to_le16(0x0010), |
1905 | VOLUME_REPAIR_OBJECT_ID = const_cpu_to_le16(0x0020), | 1915 | VOLUME_REPAIR_OBJECT_ID = const_cpu_to_le16(0x0020), |
1906 | 1916 | ||
1917 | VOLUME_CHKDSK_UNDERWAY = const_cpu_to_le16(0x4000), | ||
1907 | VOLUME_MODIFIED_BY_CHKDSK = const_cpu_to_le16(0x8000), | 1918 | VOLUME_MODIFIED_BY_CHKDSK = const_cpu_to_le16(0x8000), |
1908 | 1919 | ||
1909 | VOLUME_FLAGS_MASK = const_cpu_to_le16(0x803f), | 1920 | VOLUME_FLAGS_MASK = const_cpu_to_le16(0xc03f), |
1910 | 1921 | ||
1911 | /* To make our life easier when checking if we must mount read-only. */ | 1922 | /* To make our life easier when checking if we must mount read-only. */ |
1912 | VOLUME_MUST_MOUNT_RO_MASK = const_cpu_to_le16(0x8027), | 1923 | VOLUME_MUST_MOUNT_RO_MASK = const_cpu_to_le16(0xc027), |
1913 | } __attribute__ ((__packed__)); | 1924 | } __attribute__ ((__packed__)); |
1914 | 1925 | ||
1915 | typedef le16 VOLUME_FLAGS; | 1926 | typedef le16 VOLUME_FLAGS; |
diff --git a/fs/ntfs/mft.c b/fs/ntfs/mft.c index 0c65cbb8c5cf..6499aafc2258 100644 --- a/fs/ntfs/mft.c +++ b/fs/ntfs/mft.c | |||
@@ -1,7 +1,7 @@ | |||
1 | /** | 1 | /** |
2 | * mft.c - NTFS kernel mft record operations. Part of the Linux-NTFS project. | 2 | * mft.c - NTFS kernel mft record operations. Part of the Linux-NTFS project. |
3 | * | 3 | * |
4 | * Copyright (c) 2001-2005 Anton Altaparmakov | 4 | * Copyright (c) 2001-2006 Anton Altaparmakov |
5 | * Copyright (c) 2002 Richard Russon | 5 | * Copyright (c) 2002 Richard Russon |
6 | * | 6 | * |
7 | * This program/include file is free software; you can redistribute it and/or | 7 | * This program/include file is free software; you can redistribute it and/or |
@@ -473,7 +473,7 @@ int ntfs_sync_mft_mirror(ntfs_volume *vol, const unsigned long mft_no, | |||
473 | runlist_element *rl; | 473 | runlist_element *rl; |
474 | unsigned int block_start, block_end, m_start, m_end, page_ofs; | 474 | unsigned int block_start, block_end, m_start, m_end, page_ofs; |
475 | int i_bhs, nr_bhs, err = 0; | 475 | int i_bhs, nr_bhs, err = 0; |
476 | unsigned char blocksize_bits = vol->mftmirr_ino->i_blkbits; | 476 | unsigned char blocksize_bits = vol->sb->s_blocksize_bits; |
477 | 477 | ||
478 | ntfs_debug("Entering for inode 0x%lx.", mft_no); | 478 | ntfs_debug("Entering for inode 0x%lx.", mft_no); |
479 | BUG_ON(!max_bhs); | 479 | BUG_ON(!max_bhs); |
@@ -672,8 +672,8 @@ int write_mft_record_nolock(ntfs_inode *ni, MFT_RECORD *m, int sync) | |||
672 | { | 672 | { |
673 | ntfs_volume *vol = ni->vol; | 673 | ntfs_volume *vol = ni->vol; |
674 | struct page *page = ni->page; | 674 | struct page *page = ni->page; |
675 | unsigned char blocksize_bits = vol->mft_ino->i_blkbits; | 675 | unsigned int blocksize = vol->sb->s_blocksize; |
676 | unsigned int blocksize = 1 << blocksize_bits; | 676 | unsigned char blocksize_bits = vol->sb->s_blocksize_bits; |
677 | int max_bhs = vol->mft_record_size / blocksize; | 677 | int max_bhs = vol->mft_record_size / blocksize; |
678 | struct buffer_head *bhs[max_bhs]; | 678 | struct buffer_head *bhs[max_bhs]; |
679 | struct buffer_head *bh, *head; | 679 | struct buffer_head *bh, *head; |
diff --git a/fs/ntfs/ntfs.h b/fs/ntfs/ntfs.h index 446b5014115c..653d2a5c4899 100644 --- a/fs/ntfs/ntfs.h +++ b/fs/ntfs/ntfs.h | |||
@@ -50,11 +50,11 @@ typedef enum { | |||
50 | /* Global variables. */ | 50 | /* Global variables. */ |
51 | 51 | ||
52 | /* Slab caches (from super.c). */ | 52 | /* Slab caches (from super.c). */ |
53 | extern kmem_cache_t *ntfs_name_cache; | 53 | extern struct kmem_cache *ntfs_name_cache; |
54 | extern kmem_cache_t *ntfs_inode_cache; | 54 | extern struct kmem_cache *ntfs_inode_cache; |
55 | extern kmem_cache_t *ntfs_big_inode_cache; | 55 | extern struct kmem_cache *ntfs_big_inode_cache; |
56 | extern kmem_cache_t *ntfs_attr_ctx_cache; | 56 | extern struct kmem_cache *ntfs_attr_ctx_cache; |
57 | extern kmem_cache_t *ntfs_index_ctx_cache; | 57 | extern struct kmem_cache *ntfs_index_ctx_cache; |
58 | 58 | ||
59 | /* The various operations structs defined throughout the driver files. */ | 59 | /* The various operations structs defined throughout the driver files. */ |
60 | extern struct address_space_operations ntfs_aops; | 60 | extern struct address_space_operations ntfs_aops; |
diff --git a/fs/ntfs/super.c b/fs/ntfs/super.c index c3a3f1a8310b..368a8ec10668 100644 --- a/fs/ntfs/super.c +++ b/fs/ntfs/super.c | |||
@@ -1,7 +1,7 @@ | |||
1 | /* | 1 | /* |
2 | * super.c - NTFS kernel super block handling. Part of the Linux-NTFS project. | 2 | * super.c - NTFS kernel super block handling. Part of the Linux-NTFS project. |
3 | * | 3 | * |
4 | * Copyright (c) 2001-2005 Anton Altaparmakov | 4 | * Copyright (c) 2001-2006 Anton Altaparmakov |
5 | * Copyright (c) 2001,2002 Richard Russon | 5 | * Copyright (c) 2001,2002 Richard Russon |
6 | * | 6 | * |
7 | * This program/include file is free software; you can redistribute it and/or | 7 | * This program/include file is free software; you can redistribute it and/or |
@@ -22,6 +22,7 @@ | |||
22 | 22 | ||
23 | #include <linux/stddef.h> | 23 | #include <linux/stddef.h> |
24 | #include <linux/init.h> | 24 | #include <linux/init.h> |
25 | #include <linux/slab.h> | ||
25 | #include <linux/string.h> | 26 | #include <linux/string.h> |
26 | #include <linux/spinlock.h> | 27 | #include <linux/spinlock.h> |
27 | #include <linux/blkdev.h> /* For bdev_hardsect_size(). */ | 28 | #include <linux/blkdev.h> /* For bdev_hardsect_size(). */ |
@@ -471,9 +472,16 @@ static int ntfs_remount(struct super_block *sb, int *flags, char *opt) | |||
471 | ntfs_error(sb, "Volume is dirty and read-only%s", es); | 472 | ntfs_error(sb, "Volume is dirty and read-only%s", es); |
472 | return -EROFS; | 473 | return -EROFS; |
473 | } | 474 | } |
475 | if (vol->vol_flags & VOLUME_MODIFIED_BY_CHKDSK) { | ||
476 | ntfs_error(sb, "Volume has been modified by chkdsk " | ||
477 | "and is read-only%s", es); | ||
478 | return -EROFS; | ||
479 | } | ||
474 | if (vol->vol_flags & VOLUME_MUST_MOUNT_RO_MASK) { | 480 | if (vol->vol_flags & VOLUME_MUST_MOUNT_RO_MASK) { |
475 | ntfs_error(sb, "Volume has unsupported flags set and " | 481 | ntfs_error(sb, "Volume has unsupported flags set " |
476 | "is read-only%s", es); | 482 | "(0x%x) and is read-only%s", |
483 | (unsigned)le16_to_cpu(vol->vol_flags), | ||
484 | es); | ||
477 | return -EROFS; | 485 | return -EROFS; |
478 | } | 486 | } |
479 | if (ntfs_set_volume_flags(vol, VOLUME_IS_DIRTY)) { | 487 | if (ntfs_set_volume_flags(vol, VOLUME_IS_DIRTY)) { |
@@ -641,7 +649,7 @@ static struct buffer_head *read_ntfs_boot_sector(struct super_block *sb, | |||
641 | { | 649 | { |
642 | const char *read_err_str = "Unable to read %s boot sector."; | 650 | const char *read_err_str = "Unable to read %s boot sector."; |
643 | struct buffer_head *bh_primary, *bh_backup; | 651 | struct buffer_head *bh_primary, *bh_backup; |
644 | long nr_blocks = NTFS_SB(sb)->nr_blocks; | 652 | sector_t nr_blocks = NTFS_SB(sb)->nr_blocks; |
645 | 653 | ||
646 | /* Try to read primary boot sector. */ | 654 | /* Try to read primary boot sector. */ |
647 | if ((bh_primary = sb_bread(sb, 0))) { | 655 | if ((bh_primary = sb_bread(sb, 0))) { |
@@ -688,13 +696,18 @@ hotfix_primary_boot_sector: | |||
688 | /* | 696 | /* |
689 | * If we managed to read sector zero and the volume is not | 697 | * If we managed to read sector zero and the volume is not |
690 | * read-only, copy the found, valid backup boot sector to the | 698 | * read-only, copy the found, valid backup boot sector to the |
691 | * primary boot sector. | 699 | * primary boot sector. Note we only copy the actual boot |
700 | * sector structure, not the actual whole device sector as that | ||
701 | * may be bigger and would potentially damage the $Boot system | ||
702 | * file (FIXME: Would be nice to know if the backup boot sector | ||
703 | * on a large sector device contains the whole boot loader or | ||
704 | * just the first 512 bytes). | ||
692 | */ | 705 | */ |
693 | if (!(sb->s_flags & MS_RDONLY)) { | 706 | if (!(sb->s_flags & MS_RDONLY)) { |
694 | ntfs_warning(sb, "Hot-fix: Recovering invalid primary " | 707 | ntfs_warning(sb, "Hot-fix: Recovering invalid primary " |
695 | "boot sector from backup copy."); | 708 | "boot sector from backup copy."); |
696 | memcpy(bh_primary->b_data, bh_backup->b_data, | 709 | memcpy(bh_primary->b_data, bh_backup->b_data, |
697 | sb->s_blocksize); | 710 | NTFS_BLOCK_SIZE); |
698 | mark_buffer_dirty(bh_primary); | 711 | mark_buffer_dirty(bh_primary); |
699 | sync_dirty_buffer(bh_primary); | 712 | sync_dirty_buffer(bh_primary); |
700 | if (buffer_uptodate(bh_primary)) { | 713 | if (buffer_uptodate(bh_primary)) { |
@@ -733,9 +746,13 @@ static BOOL parse_ntfs_boot_sector(ntfs_volume *vol, const NTFS_BOOT_SECTOR *b) | |||
733 | vol->sector_size); | 746 | vol->sector_size); |
734 | ntfs_debug("vol->sector_size_bits = %i (0x%x)", vol->sector_size_bits, | 747 | ntfs_debug("vol->sector_size_bits = %i (0x%x)", vol->sector_size_bits, |
735 | vol->sector_size_bits); | 748 | vol->sector_size_bits); |
736 | if (vol->sector_size != vol->sb->s_blocksize) | 749 | if (vol->sector_size < vol->sb->s_blocksize) { |
737 | ntfs_warning(vol->sb, "The boot sector indicates a sector size " | 750 | ntfs_error(vol->sb, "Sector size (%i) is smaller than the " |
738 | "different from the device sector size."); | 751 | "device block size (%lu). This is not " |
752 | "supported. Sorry.", vol->sector_size, | ||
753 | vol->sb->s_blocksize); | ||
754 | return FALSE; | ||
755 | } | ||
739 | ntfs_debug("sectors_per_cluster = 0x%x", b->bpb.sectors_per_cluster); | 756 | ntfs_debug("sectors_per_cluster = 0x%x", b->bpb.sectors_per_cluster); |
740 | sectors_per_cluster_bits = ffs(b->bpb.sectors_per_cluster) - 1; | 757 | sectors_per_cluster_bits = ffs(b->bpb.sectors_per_cluster) - 1; |
741 | ntfs_debug("sectors_per_cluster_bits = 0x%x", | 758 | ntfs_debug("sectors_per_cluster_bits = 0x%x", |
@@ -748,16 +765,11 @@ static BOOL parse_ntfs_boot_sector(ntfs_volume *vol, const NTFS_BOOT_SECTOR *b) | |||
748 | ntfs_debug("vol->cluster_size = %i (0x%x)", vol->cluster_size, | 765 | ntfs_debug("vol->cluster_size = %i (0x%x)", vol->cluster_size, |
749 | vol->cluster_size); | 766 | vol->cluster_size); |
750 | ntfs_debug("vol->cluster_size_mask = 0x%x", vol->cluster_size_mask); | 767 | ntfs_debug("vol->cluster_size_mask = 0x%x", vol->cluster_size_mask); |
751 | ntfs_debug("vol->cluster_size_bits = %i (0x%x)", | 768 | ntfs_debug("vol->cluster_size_bits = %i", vol->cluster_size_bits); |
752 | vol->cluster_size_bits, vol->cluster_size_bits); | 769 | if (vol->cluster_size < vol->sector_size) { |
753 | if (vol->sector_size > vol->cluster_size) { | 770 | ntfs_error(vol->sb, "Cluster size (%i) is smaller than the " |
754 | ntfs_error(vol->sb, "Sector sizes above the cluster size are " | 771 | "sector size (%i). This is not supported. " |
755 | "not supported. Sorry."); | 772 | "Sorry.", vol->cluster_size, vol->sector_size); |
756 | return FALSE; | ||
757 | } | ||
758 | if (vol->sb->s_blocksize > vol->cluster_size) { | ||
759 | ntfs_error(vol->sb, "Cluster sizes smaller than the device " | ||
760 | "sector size are not supported. Sorry."); | ||
761 | return FALSE; | 773 | return FALSE; |
762 | } | 774 | } |
763 | clusters_per_mft_record = b->clusters_per_mft_record; | 775 | clusters_per_mft_record = b->clusters_per_mft_record; |
@@ -786,11 +798,18 @@ static BOOL parse_ntfs_boot_sector(ntfs_volume *vol, const NTFS_BOOT_SECTOR *b) | |||
786 | * we store $MFT/$DATA, the table of mft records in the page cache. | 798 | * we store $MFT/$DATA, the table of mft records in the page cache. |
787 | */ | 799 | */ |
788 | if (vol->mft_record_size > PAGE_CACHE_SIZE) { | 800 | if (vol->mft_record_size > PAGE_CACHE_SIZE) { |
789 | ntfs_error(vol->sb, "Mft record size %i (0x%x) exceeds the " | 801 | ntfs_error(vol->sb, "Mft record size (%i) exceeds the " |
790 | "page cache size on your system %lu (0x%lx). " | 802 | "PAGE_CACHE_SIZE on your system (%lu). " |
791 | "This is not supported. Sorry.", | 803 | "This is not supported. Sorry.", |
792 | vol->mft_record_size, vol->mft_record_size, | 804 | vol->mft_record_size, PAGE_CACHE_SIZE); |
793 | PAGE_CACHE_SIZE, PAGE_CACHE_SIZE); | 805 | return FALSE; |
806 | } | ||
807 | /* We cannot support mft record sizes below the sector size. */ | ||
808 | if (vol->mft_record_size < vol->sector_size) { | ||
809 | ntfs_error(vol->sb, "Mft record size (%i) is smaller than the " | ||
810 | "sector size (%i). This is not supported. " | ||
811 | "Sorry.", vol->mft_record_size, | ||
812 | vol->sector_size); | ||
794 | return FALSE; | 813 | return FALSE; |
795 | } | 814 | } |
796 | clusters_per_index_record = b->clusters_per_index_record; | 815 | clusters_per_index_record = b->clusters_per_index_record; |
@@ -816,6 +835,14 @@ static BOOL parse_ntfs_boot_sector(ntfs_volume *vol, const NTFS_BOOT_SECTOR *b) | |||
816 | ntfs_debug("vol->index_record_size_bits = %i (0x%x)", | 835 | ntfs_debug("vol->index_record_size_bits = %i (0x%x)", |
817 | vol->index_record_size_bits, | 836 | vol->index_record_size_bits, |
818 | vol->index_record_size_bits); | 837 | vol->index_record_size_bits); |
838 | /* We cannot support index record sizes below the sector size. */ | ||
839 | if (vol->index_record_size < vol->sector_size) { | ||
840 | ntfs_error(vol->sb, "Index record size (%i) is smaller than " | ||
841 | "the sector size (%i). This is not " | ||
842 | "supported. Sorry.", vol->index_record_size, | ||
843 | vol->sector_size); | ||
844 | return FALSE; | ||
845 | } | ||
819 | /* | 846 | /* |
820 | * Get the size of the volume in clusters and check for 64-bit-ness. | 847 | * Get the size of the volume in clusters and check for 64-bit-ness. |
821 | * Windows currently only uses 32 bits to save the clusters so we do | 848 | * Windows currently only uses 32 bits to save the clusters so we do |
@@ -845,15 +872,18 @@ static BOOL parse_ntfs_boot_sector(ntfs_volume *vol, const NTFS_BOOT_SECTOR *b) | |||
845 | } | 872 | } |
846 | ll = sle64_to_cpu(b->mft_lcn); | 873 | ll = sle64_to_cpu(b->mft_lcn); |
847 | if (ll >= vol->nr_clusters) { | 874 | if (ll >= vol->nr_clusters) { |
848 | ntfs_error(vol->sb, "MFT LCN is beyond end of volume. Weird."); | 875 | ntfs_error(vol->sb, "MFT LCN (%lli, 0x%llx) is beyond end of " |
876 | "volume. Weird.", (unsigned long long)ll, | ||
877 | (unsigned long long)ll); | ||
849 | return FALSE; | 878 | return FALSE; |
850 | } | 879 | } |
851 | vol->mft_lcn = ll; | 880 | vol->mft_lcn = ll; |
852 | ntfs_debug("vol->mft_lcn = 0x%llx", (long long)vol->mft_lcn); | 881 | ntfs_debug("vol->mft_lcn = 0x%llx", (long long)vol->mft_lcn); |
853 | ll = sle64_to_cpu(b->mftmirr_lcn); | 882 | ll = sle64_to_cpu(b->mftmirr_lcn); |
854 | if (ll >= vol->nr_clusters) { | 883 | if (ll >= vol->nr_clusters) { |
855 | ntfs_error(vol->sb, "MFTMirr LCN is beyond end of volume. " | 884 | ntfs_error(vol->sb, "MFTMirr LCN (%lli, 0x%llx) is beyond end " |
856 | "Weird."); | 885 | "of volume. Weird.", (unsigned long long)ll, |
886 | (unsigned long long)ll); | ||
857 | return FALSE; | 887 | return FALSE; |
858 | } | 888 | } |
859 | vol->mftmirr_lcn = ll; | 889 | vol->mftmirr_lcn = ll; |
@@ -1822,11 +1852,24 @@ get_ctx_vol_failed: | |||
1822 | /* Make sure that no unsupported volume flags are set. */ | 1852 | /* Make sure that no unsupported volume flags are set. */ |
1823 | if (vol->vol_flags & VOLUME_MUST_MOUNT_RO_MASK) { | 1853 | if (vol->vol_flags & VOLUME_MUST_MOUNT_RO_MASK) { |
1824 | static const char *es1a = "Volume is dirty"; | 1854 | static const char *es1a = "Volume is dirty"; |
1825 | static const char *es1b = "Volume has unsupported flags set"; | 1855 | static const char *es1b = "Volume has been modified by chkdsk"; |
1826 | static const char *es2 = ". Run chkdsk and mount in Windows."; | 1856 | static const char *es1c = "Volume has unsupported flags set"; |
1827 | const char *es1; | 1857 | static const char *es2a = ". Run chkdsk and mount in Windows."; |
1828 | 1858 | static const char *es2b = ". Mount in Windows."; | |
1829 | es1 = vol->vol_flags & VOLUME_IS_DIRTY ? es1a : es1b; | 1859 | const char *es1, *es2; |
1860 | |||
1861 | es2 = es2a; | ||
1862 | if (vol->vol_flags & VOLUME_IS_DIRTY) | ||
1863 | es1 = es1a; | ||
1864 | else if (vol->vol_flags & VOLUME_MODIFIED_BY_CHKDSK) { | ||
1865 | es1 = es1b; | ||
1866 | es2 = es2b; | ||
1867 | } else { | ||
1868 | es1 = es1c; | ||
1869 | ntfs_warning(sb, "Unsupported volume flags 0x%x " | ||
1870 | "encountered.", | ||
1871 | (unsigned)le16_to_cpu(vol->vol_flags)); | ||
1872 | } | ||
1830 | /* If a read-write mount, convert it to a read-only mount. */ | 1873 | /* If a read-write mount, convert it to a read-only mount. */ |
1831 | if (!(sb->s_flags & MS_RDONLY)) { | 1874 | if (!(sb->s_flags & MS_RDONLY)) { |
1832 | if (!(vol->on_errors & (ON_ERRORS_REMOUNT_RO | | 1875 | if (!(vol->on_errors & (ON_ERRORS_REMOUNT_RO | |
@@ -2685,7 +2728,7 @@ static int ntfs_fill_super(struct super_block *sb, void *opt, const int silent) | |||
2685 | ntfs_volume *vol; | 2728 | ntfs_volume *vol; |
2686 | struct buffer_head *bh; | 2729 | struct buffer_head *bh; |
2687 | struct inode *tmp_ino; | 2730 | struct inode *tmp_ino; |
2688 | int result; | 2731 | int blocksize, result; |
2689 | 2732 | ||
2690 | ntfs_debug("Entering."); | 2733 | ntfs_debug("Entering."); |
2691 | #ifndef NTFS_RW | 2734 | #ifndef NTFS_RW |
@@ -2724,60 +2767,85 @@ static int ntfs_fill_super(struct super_block *sb, void *opt, const int silent) | |||
2724 | if (!parse_options(vol, (char*)opt)) | 2767 | if (!parse_options(vol, (char*)opt)) |
2725 | goto err_out_now; | 2768 | goto err_out_now; |
2726 | 2769 | ||
2770 | /* We support sector sizes up to the PAGE_CACHE_SIZE. */ | ||
2771 | if (bdev_hardsect_size(sb->s_bdev) > PAGE_CACHE_SIZE) { | ||
2772 | if (!silent) | ||
2773 | ntfs_error(sb, "Device has unsupported sector size " | ||
2774 | "(%i). The maximum supported sector " | ||
2775 | "size on this architecture is %lu " | ||
2776 | "bytes.", | ||
2777 | bdev_hardsect_size(sb->s_bdev), | ||
2778 | PAGE_CACHE_SIZE); | ||
2779 | goto err_out_now; | ||
2780 | } | ||
2727 | /* | 2781 | /* |
2728 | * TODO: Fail safety check. In the future we should really be able to | 2782 | * Setup the device access block size to NTFS_BLOCK_SIZE or the hard |
2729 | * cope with this being the case, but for now just bail out. | 2783 | * sector size, whichever is bigger. |
2730 | */ | 2784 | */ |
2731 | if (bdev_hardsect_size(sb->s_bdev) > NTFS_BLOCK_SIZE) { | 2785 | blocksize = sb_min_blocksize(sb, NTFS_BLOCK_SIZE); |
2786 | if (blocksize < NTFS_BLOCK_SIZE) { | ||
2732 | if (!silent) | 2787 | if (!silent) |
2733 | ntfs_error(sb, "Device has unsupported hardsect_size."); | 2788 | ntfs_error(sb, "Unable to set device block size."); |
2734 | goto err_out_now; | 2789 | goto err_out_now; |
2735 | } | 2790 | } |
2736 | 2791 | BUG_ON(blocksize != sb->s_blocksize); | |
2737 | /* Setup the device access block size to NTFS_BLOCK_SIZE. */ | 2792 | ntfs_debug("Set device block size to %i bytes (block size bits %i).", |
2738 | if (sb_set_blocksize(sb, NTFS_BLOCK_SIZE) != NTFS_BLOCK_SIZE) { | 2793 | blocksize, sb->s_blocksize_bits); |
2794 | /* Determine the size of the device in units of block_size bytes. */ | ||
2795 | if (!i_size_read(sb->s_bdev->bd_inode)) { | ||
2739 | if (!silent) | 2796 | if (!silent) |
2740 | ntfs_error(sb, "Unable to set block size."); | 2797 | ntfs_error(sb, "Unable to determine device size."); |
2741 | goto err_out_now; | 2798 | goto err_out_now; |
2742 | } | 2799 | } |
2743 | |||
2744 | /* Get the size of the device in units of NTFS_BLOCK_SIZE bytes. */ | ||
2745 | vol->nr_blocks = i_size_read(sb->s_bdev->bd_inode) >> | 2800 | vol->nr_blocks = i_size_read(sb->s_bdev->bd_inode) >> |
2746 | NTFS_BLOCK_SIZE_BITS; | 2801 | sb->s_blocksize_bits; |
2747 | |||
2748 | /* Read the boot sector and return unlocked buffer head to it. */ | 2802 | /* Read the boot sector and return unlocked buffer head to it. */ |
2749 | if (!(bh = read_ntfs_boot_sector(sb, silent))) { | 2803 | if (!(bh = read_ntfs_boot_sector(sb, silent))) { |
2750 | if (!silent) | 2804 | if (!silent) |
2751 | ntfs_error(sb, "Not an NTFS volume."); | 2805 | ntfs_error(sb, "Not an NTFS volume."); |
2752 | goto err_out_now; | 2806 | goto err_out_now; |
2753 | } | 2807 | } |
2754 | |||
2755 | /* | 2808 | /* |
2756 | * Extract the data from the boot sector and setup the ntfs super block | 2809 | * Extract the data from the boot sector and setup the ntfs volume |
2757 | * using it. | 2810 | * using it. |
2758 | */ | 2811 | */ |
2759 | result = parse_ntfs_boot_sector(vol, (NTFS_BOOT_SECTOR*)bh->b_data); | 2812 | result = parse_ntfs_boot_sector(vol, (NTFS_BOOT_SECTOR*)bh->b_data); |
2760 | |||
2761 | /* Initialize the cluster and mft allocators. */ | ||
2762 | ntfs_setup_allocators(vol); | ||
2763 | |||
2764 | brelse(bh); | 2813 | brelse(bh); |
2765 | |||
2766 | if (!result) { | 2814 | if (!result) { |
2767 | if (!silent) | 2815 | if (!silent) |
2768 | ntfs_error(sb, "Unsupported NTFS filesystem."); | 2816 | ntfs_error(sb, "Unsupported NTFS filesystem."); |
2769 | goto err_out_now; | 2817 | goto err_out_now; |
2770 | } | 2818 | } |
2771 | |||
2772 | /* | 2819 | /* |
2773 | * TODO: When we start coping with sector sizes different from | 2820 | * If the boot sector indicates a sector size bigger than the current |
2774 | * NTFS_BLOCK_SIZE, we now probably need to set the blocksize of the | 2821 | * device block size, switch the device block size to the sector size. |
2775 | * device (probably to NTFS_BLOCK_SIZE). | 2822 | * TODO: It may be possible to support this case even when the set |
2823 | * below fails, we would just be breaking up the i/o for each sector | ||
2824 | * into multiple blocks for i/o purposes but otherwise it should just | ||
2825 | * work. However it is safer to leave disabled until someone hits this | ||
2826 | * error message and then we can get them to try it without the setting | ||
2827 | * so we know for sure that it works. | ||
2776 | */ | 2828 | */ |
2777 | 2829 | if (vol->sector_size > blocksize) { | |
2830 | blocksize = sb_set_blocksize(sb, vol->sector_size); | ||
2831 | if (blocksize != vol->sector_size) { | ||
2832 | if (!silent) | ||
2833 | ntfs_error(sb, "Unable to set device block " | ||
2834 | "size to sector size (%i).", | ||
2835 | vol->sector_size); | ||
2836 | goto err_out_now; | ||
2837 | } | ||
2838 | BUG_ON(blocksize != sb->s_blocksize); | ||
2839 | vol->nr_blocks = i_size_read(sb->s_bdev->bd_inode) >> | ||
2840 | sb->s_blocksize_bits; | ||
2841 | ntfs_debug("Changed device block size to %i bytes (block size " | ||
2842 | "bits %i) to match volume sector size.", | ||
2843 | blocksize, sb->s_blocksize_bits); | ||
2844 | } | ||
2845 | /* Initialize the cluster and mft allocators. */ | ||
2846 | ntfs_setup_allocators(vol); | ||
2778 | /* Setup remaining fields in the super block. */ | 2847 | /* Setup remaining fields in the super block. */ |
2779 | sb->s_magic = NTFS_SB_MAGIC; | 2848 | sb->s_magic = NTFS_SB_MAGIC; |
2780 | |||
2781 | /* | 2849 | /* |
2782 | * Ntfs allows 63 bits for the file size, i.e. correct would be: | 2850 | * Ntfs allows 63 bits for the file size, i.e. correct would be: |
2783 | * sb->s_maxbytes = ~0ULL >> 1; | 2851 | * sb->s_maxbytes = ~0ULL >> 1; |
@@ -2787,9 +2855,8 @@ static int ntfs_fill_super(struct super_block *sb, void *opt, const int silent) | |||
2787 | * without overflowing the index or to 2^63 - 1, whichever is smaller. | 2855 | * without overflowing the index or to 2^63 - 1, whichever is smaller. |
2788 | */ | 2856 | */ |
2789 | sb->s_maxbytes = MAX_LFS_FILESIZE; | 2857 | sb->s_maxbytes = MAX_LFS_FILESIZE; |
2790 | 2858 | /* Ntfs measures time in 100ns intervals. */ | |
2791 | sb->s_time_gran = 100; | 2859 | sb->s_time_gran = 100; |
2792 | |||
2793 | /* | 2860 | /* |
2794 | * Now load the metadata required for the page cache and our address | 2861 | * Now load the metadata required for the page cache and our address |
2795 | * space operations to function. We do this by setting up a specialised | 2862 | * space operations to function. We do this by setting up a specialised |
@@ -2987,14 +3054,14 @@ err_out_now: | |||
2987 | * strings of the maximum length allowed by NTFS, which is NTFS_MAX_NAME_LEN | 3054 | * strings of the maximum length allowed by NTFS, which is NTFS_MAX_NAME_LEN |
2988 | * (255) Unicode characters + a terminating NULL Unicode character. | 3055 | * (255) Unicode characters + a terminating NULL Unicode character. |
2989 | */ | 3056 | */ |
2990 | kmem_cache_t *ntfs_name_cache; | 3057 | struct kmem_cache *ntfs_name_cache; |
2991 | 3058 | ||
2992 | /* Slab caches for efficient allocation/deallocation of inodes. */ | 3059 | /* Slab caches for efficient allocation/deallocation of inodes. */ |
2993 | kmem_cache_t *ntfs_inode_cache; | 3060 | struct kmem_cache *ntfs_inode_cache; |
2994 | kmem_cache_t *ntfs_big_inode_cache; | 3061 | struct kmem_cache *ntfs_big_inode_cache; |
2995 | 3062 | ||
2996 | /* Init once constructor for the inode slab cache. */ | 3063 | /* Init once constructor for the inode slab cache. */ |
2997 | static void ntfs_big_inode_init_once(void *foo, kmem_cache_t *cachep, | 3064 | static void ntfs_big_inode_init_once(void *foo, struct kmem_cache *cachep, |
2998 | unsigned long flags) | 3065 | unsigned long flags) |
2999 | { | 3066 | { |
3000 | ntfs_inode *ni = (ntfs_inode *)foo; | 3067 | ntfs_inode *ni = (ntfs_inode *)foo; |
@@ -3008,8 +3075,8 @@ static void ntfs_big_inode_init_once(void *foo, kmem_cache_t *cachep, | |||
3008 | * Slab caches to optimize allocations and deallocations of attribute search | 3075 | * Slab caches to optimize allocations and deallocations of attribute search |
3009 | * contexts and index contexts, respectively. | 3076 | * contexts and index contexts, respectively. |
3010 | */ | 3077 | */ |
3011 | kmem_cache_t *ntfs_attr_ctx_cache; | 3078 | struct kmem_cache *ntfs_attr_ctx_cache; |
3012 | kmem_cache_t *ntfs_index_ctx_cache; | 3079 | struct kmem_cache *ntfs_index_ctx_cache; |
3013 | 3080 | ||
3014 | /* Driver wide semaphore. */ | 3081 | /* Driver wide semaphore. */ |
3015 | DECLARE_MUTEX(ntfs_lock); | 3082 | DECLARE_MUTEX(ntfs_lock); |
diff --git a/fs/ntfs/upcase.c b/fs/ntfs/upcase.c index 879cdf1d5bd3..9101807dc81a 100644 --- a/fs/ntfs/upcase.c +++ b/fs/ntfs/upcase.c | |||
@@ -3,10 +3,7 @@ | |||
3 | * Part of the Linux-NTFS project. | 3 | * Part of the Linux-NTFS project. |
4 | * | 4 | * |
5 | * Copyright (c) 2001 Richard Russon <ntfs@flatcap.org> | 5 | * Copyright (c) 2001 Richard Russon <ntfs@flatcap.org> |
6 | * Copyright (c) 2001-2004 Anton Altaparmakov | 6 | * Copyright (c) 2001-2006 Anton Altaparmakov |
7 | * | ||
8 | * Modified for mkntfs inclusion 9 June 2001 by Anton Altaparmakov. | ||
9 | * Modified for kernel inclusion 10 September 2001 by Anton Altparmakov. | ||
10 | * | 7 | * |
11 | * This program is free software; you can redistribute it and/or modify it | 8 | * This program is free software; you can redistribute it and/or modify it |
12 | * under the terms of the GNU General Public License as published by the Free | 9 | * under the terms of the GNU General Public License as published by the Free |
@@ -75,12 +72,13 @@ ntfschar *generate_default_upcase(void) | |||
75 | if (!uc) | 72 | if (!uc) |
76 | return uc; | 73 | return uc; |
77 | memset(uc, 0, default_upcase_len * sizeof(ntfschar)); | 74 | memset(uc, 0, default_upcase_len * sizeof(ntfschar)); |
75 | /* Generate the little endian Unicode upcase table used by ntfs. */ | ||
78 | for (i = 0; i < default_upcase_len; i++) | 76 | for (i = 0; i < default_upcase_len; i++) |
79 | uc[i] = cpu_to_le16(i); | 77 | uc[i] = cpu_to_le16(i); |
80 | for (r = 0; uc_run_table[r][0]; r++) | 78 | for (r = 0; uc_run_table[r][0]; r++) |
81 | for (i = uc_run_table[r][0]; i < uc_run_table[r][1]; i++) | 79 | for (i = uc_run_table[r][0]; i < uc_run_table[r][1]; i++) |
82 | uc[i] = cpu_to_le16((le16_to_cpu(uc[i]) + | 80 | uc[i] = cpu_to_le16(le16_to_cpu(uc[i]) + |
83 | uc_run_table[r][2])); | 81 | uc_run_table[r][2]); |
84 | for (r = 0; uc_dup_table[r][0]; r++) | 82 | for (r = 0; uc_dup_table[r][0]; r++) |
85 | for (i = uc_dup_table[r][0]; i < uc_dup_table[r][1]; i += 2) | 83 | for (i = uc_dup_table[r][0]; i < uc_dup_table[r][1]; i += 2) |
86 | uc[i + 1] = cpu_to_le16(le16_to_cpu(uc[i + 1]) - 1); | 84 | uc[i + 1] = cpu_to_le16(le16_to_cpu(uc[i + 1]) - 1); |
diff --git a/fs/ntfs/volume.h b/fs/ntfs/volume.h index 375cd20a9f61..406ab55dfb32 100644 --- a/fs/ntfs/volume.h +++ b/fs/ntfs/volume.h | |||
@@ -2,7 +2,7 @@ | |||
2 | * volume.h - Defines for volume structures in NTFS Linux kernel driver. Part | 2 | * volume.h - Defines for volume structures in NTFS Linux kernel driver. Part |
3 | * of the Linux-NTFS project. | 3 | * of the Linux-NTFS project. |
4 | * | 4 | * |
5 | * Copyright (c) 2001-2005 Anton Altaparmakov | 5 | * Copyright (c) 2001-2006 Anton Altaparmakov |
6 | * Copyright (c) 2002 Richard Russon | 6 | * Copyright (c) 2002 Richard Russon |
7 | * | 7 | * |
8 | * This program/include file is free software; you can redistribute it and/or | 8 | * This program/include file is free software; you can redistribute it and/or |
@@ -41,10 +41,8 @@ typedef struct { | |||
41 | * structure has stabilized... (AIA) | 41 | * structure has stabilized... (AIA) |
42 | */ | 42 | */ |
43 | /* Device specifics. */ | 43 | /* Device specifics. */ |
44 | struct super_block *sb; /* Pointer back to the super_block, | 44 | struct super_block *sb; /* Pointer back to the super_block. */ |
45 | so we don't have to get the offset | 45 | LCN nr_blocks; /* Number of sb->s_blocksize bytes |
46 | every time. */ | ||
47 | LCN nr_blocks; /* Number of NTFS_BLOCK_SIZE bytes | ||
48 | sized blocks on the device. */ | 46 | sized blocks on the device. */ |
49 | /* Configuration provided by user at mount time. */ | 47 | /* Configuration provided by user at mount time. */ |
50 | unsigned long flags; /* Miscellaneous flags, see below. */ | 48 | unsigned long flags; /* Miscellaneous flags, see below. */ |
@@ -141,8 +139,8 @@ typedef enum { | |||
141 | NV_ShowSystemFiles, /* 1: Return system files in ntfs_readdir(). */ | 139 | NV_ShowSystemFiles, /* 1: Return system files in ntfs_readdir(). */ |
142 | NV_CaseSensitive, /* 1: Treat file names as case sensitive and | 140 | NV_CaseSensitive, /* 1: Treat file names as case sensitive and |
143 | create filenames in the POSIX namespace. | 141 | create filenames in the POSIX namespace. |
144 | Otherwise be case insensitive and create | 142 | Otherwise be case insensitive but still |
145 | file names in WIN32 namespace. */ | 143 | create file names in POSIX namespace. */ |
146 | NV_LogFileEmpty, /* 1: $LogFile journal is empty. */ | 144 | NV_LogFileEmpty, /* 1: $LogFile journal is empty. */ |
147 | NV_QuotaOutOfDate, /* 1: $Quota is out of date. */ | 145 | NV_QuotaOutOfDate, /* 1: $Quota is out of date. */ |
148 | NV_UsnJrnlStamped, /* 1: $UsnJrnl has been stamped. */ | 146 | NV_UsnJrnlStamped, /* 1: $UsnJrnl has been stamped. */ |
@@ -153,7 +151,7 @@ typedef enum { | |||
153 | * Macro tricks to expand the NVolFoo(), NVolSetFoo(), and NVolClearFoo() | 151 | * Macro tricks to expand the NVolFoo(), NVolSetFoo(), and NVolClearFoo() |
154 | * functions. | 152 | * functions. |
155 | */ | 153 | */ |
156 | #define NVOL_FNS(flag) \ | 154 | #define DEFINE_NVOL_BIT_OPS(flag) \ |
157 | static inline int NVol##flag(ntfs_volume *vol) \ | 155 | static inline int NVol##flag(ntfs_volume *vol) \ |
158 | { \ | 156 | { \ |
159 | return test_bit(NV_##flag, &(vol)->flags); \ | 157 | return test_bit(NV_##flag, &(vol)->flags); \ |
@@ -168,12 +166,12 @@ static inline void NVolClear##flag(ntfs_volume *vol) \ | |||
168 | } | 166 | } |
169 | 167 | ||
170 | /* Emit the ntfs volume bitops functions. */ | 168 | /* Emit the ntfs volume bitops functions. */ |
171 | NVOL_FNS(Errors) | 169 | DEFINE_NVOL_BIT_OPS(Errors) |
172 | NVOL_FNS(ShowSystemFiles) | 170 | DEFINE_NVOL_BIT_OPS(ShowSystemFiles) |
173 | NVOL_FNS(CaseSensitive) | 171 | DEFINE_NVOL_BIT_OPS(CaseSensitive) |
174 | NVOL_FNS(LogFileEmpty) | 172 | DEFINE_NVOL_BIT_OPS(LogFileEmpty) |
175 | NVOL_FNS(QuotaOutOfDate) | 173 | DEFINE_NVOL_BIT_OPS(QuotaOutOfDate) |
176 | NVOL_FNS(UsnJrnlStamped) | 174 | DEFINE_NVOL_BIT_OPS(UsnJrnlStamped) |
177 | NVOL_FNS(SparseEnabled) | 175 | DEFINE_NVOL_BIT_OPS(SparseEnabled) |
178 | 176 | ||
179 | #endif /* _LINUX_NTFS_VOLUME_H */ | 177 | #endif /* _LINUX_NTFS_VOLUME_H */ |
diff --git a/fs/ocfs2/cluster/masklog.c b/fs/ocfs2/cluster/masklog.c index fd741cea5705..636593bf4d17 100644 --- a/fs/ocfs2/cluster/masklog.c +++ b/fs/ocfs2/cluster/masklog.c | |||
@@ -74,6 +74,7 @@ struct mlog_attribute { | |||
74 | #define define_mask(_name) { \ | 74 | #define define_mask(_name) { \ |
75 | .attr = { \ | 75 | .attr = { \ |
76 | .name = #_name, \ | 76 | .name = #_name, \ |
77 | .owner = THIS_MODULE, \ | ||
77 | .mode = S_IRUGO | S_IWUSR, \ | 78 | .mode = S_IRUGO | S_IWUSR, \ |
78 | }, \ | 79 | }, \ |
79 | .mask = ML_##_name, \ | 80 | .mask = ML_##_name, \ |
diff --git a/fs/ocfs2/cluster/masklog.h b/fs/ocfs2/cluster/masklog.h index e8c56a3d9c64..2cadc3009c83 100644 --- a/fs/ocfs2/cluster/masklog.h +++ b/fs/ocfs2/cluster/masklog.h | |||
@@ -256,7 +256,7 @@ extern struct mlog_bits mlog_and_bits, mlog_not_bits; | |||
256 | } \ | 256 | } \ |
257 | } while (0) | 257 | } while (0) |
258 | 258 | ||
259 | #if (BITS_PER_LONG == 32) || defined(CONFIG_X86_64) | 259 | #if (BITS_PER_LONG == 32) || defined(CONFIG_X86_64) || (defined(CONFIG_UML_X86) && defined(CONFIG_64BIT)) |
260 | #define MLFi64 "lld" | 260 | #define MLFi64 "lld" |
261 | #define MLFu64 "llu" | 261 | #define MLFu64 "llu" |
262 | #define MLFx64 "llx" | 262 | #define MLFx64 "llx" |
diff --git a/fs/ocfs2/cluster/nodemanager.c b/fs/ocfs2/cluster/nodemanager.c index cf7828f23361..e1fceb8aa32d 100644 --- a/fs/ocfs2/cluster/nodemanager.c +++ b/fs/ocfs2/cluster/nodemanager.c | |||
@@ -756,7 +756,7 @@ static int __init init_o2nm(void) | |||
756 | if (!ocfs2_table_header) { | 756 | if (!ocfs2_table_header) { |
757 | printk(KERN_ERR "nodemanager: unable to register sysctl\n"); | 757 | printk(KERN_ERR "nodemanager: unable to register sysctl\n"); |
758 | ret = -ENOMEM; /* or something. */ | 758 | ret = -ENOMEM; /* or something. */ |
759 | goto out; | 759 | goto out_o2net; |
760 | } | 760 | } |
761 | 761 | ||
762 | ret = o2net_register_hb_callbacks(); | 762 | ret = o2net_register_hb_callbacks(); |
@@ -780,6 +780,8 @@ out_callbacks: | |||
780 | o2net_unregister_hb_callbacks(); | 780 | o2net_unregister_hb_callbacks(); |
781 | out_sysctl: | 781 | out_sysctl: |
782 | unregister_sysctl_table(ocfs2_table_header); | 782 | unregister_sysctl_table(ocfs2_table_header); |
783 | out_o2net: | ||
784 | o2net_exit(); | ||
783 | out: | 785 | out: |
784 | return ret; | 786 | return ret; |
785 | } | 787 | } |
diff --git a/fs/ocfs2/cluster/tcp.c b/fs/ocfs2/cluster/tcp.c index d22d4cf08db1..0f60cc0d3985 100644 --- a/fs/ocfs2/cluster/tcp.c +++ b/fs/ocfs2/cluster/tcp.c | |||
@@ -1318,7 +1318,7 @@ static void o2net_start_connect(void *arg) | |||
1318 | { | 1318 | { |
1319 | struct o2net_node *nn = arg; | 1319 | struct o2net_node *nn = arg; |
1320 | struct o2net_sock_container *sc = NULL; | 1320 | struct o2net_sock_container *sc = NULL; |
1321 | struct o2nm_node *node = NULL; | 1321 | struct o2nm_node *node = NULL, *mynode = NULL; |
1322 | struct socket *sock = NULL; | 1322 | struct socket *sock = NULL; |
1323 | struct sockaddr_in myaddr = {0, }, remoteaddr = {0, }; | 1323 | struct sockaddr_in myaddr = {0, }, remoteaddr = {0, }; |
1324 | int ret = 0; | 1324 | int ret = 0; |
@@ -1334,6 +1334,12 @@ static void o2net_start_connect(void *arg) | |||
1334 | goto out; | 1334 | goto out; |
1335 | } | 1335 | } |
1336 | 1336 | ||
1337 | mynode = o2nm_get_node_by_num(o2nm_this_node()); | ||
1338 | if (mynode == NULL) { | ||
1339 | ret = 0; | ||
1340 | goto out; | ||
1341 | } | ||
1342 | |||
1337 | spin_lock(&nn->nn_lock); | 1343 | spin_lock(&nn->nn_lock); |
1338 | /* see if we already have one pending or have given up */ | 1344 | /* see if we already have one pending or have given up */ |
1339 | if (nn->nn_sc || nn->nn_persistent_error) | 1345 | if (nn->nn_sc || nn->nn_persistent_error) |
@@ -1361,12 +1367,14 @@ static void o2net_start_connect(void *arg) | |||
1361 | sock->sk->sk_allocation = GFP_ATOMIC; | 1367 | sock->sk->sk_allocation = GFP_ATOMIC; |
1362 | 1368 | ||
1363 | myaddr.sin_family = AF_INET; | 1369 | myaddr.sin_family = AF_INET; |
1370 | myaddr.sin_addr.s_addr = (__force u32)mynode->nd_ipv4_address; | ||
1364 | myaddr.sin_port = (__force u16)htons(0); /* any port */ | 1371 | myaddr.sin_port = (__force u16)htons(0); /* any port */ |
1365 | 1372 | ||
1366 | ret = sock->ops->bind(sock, (struct sockaddr *)&myaddr, | 1373 | ret = sock->ops->bind(sock, (struct sockaddr *)&myaddr, |
1367 | sizeof(myaddr)); | 1374 | sizeof(myaddr)); |
1368 | if (ret) { | 1375 | if (ret) { |
1369 | mlog(0, "bind failed: %d\n", ret); | 1376 | mlog(ML_ERROR, "bind failed with %d at address %u.%u.%u.%u\n", |
1377 | ret, NIPQUAD(mynode->nd_ipv4_address)); | ||
1370 | goto out; | 1378 | goto out; |
1371 | } | 1379 | } |
1372 | 1380 | ||
@@ -1407,6 +1415,8 @@ out: | |||
1407 | sc_put(sc); | 1415 | sc_put(sc); |
1408 | if (node) | 1416 | if (node) |
1409 | o2nm_node_put(node); | 1417 | o2nm_node_put(node); |
1418 | if (mynode) | ||
1419 | o2nm_node_put(mynode); | ||
1410 | 1420 | ||
1411 | return; | 1421 | return; |
1412 | } | 1422 | } |
diff --git a/fs/ocfs2/cluster/tcp.h b/fs/ocfs2/cluster/tcp.h index a6f4585501c8..616ff2b8434a 100644 --- a/fs/ocfs2/cluster/tcp.h +++ b/fs/ocfs2/cluster/tcp.h | |||
@@ -85,13 +85,10 @@ enum { | |||
85 | O2NET_DRIVER_READY, | 85 | O2NET_DRIVER_READY, |
86 | }; | 86 | }; |
87 | 87 | ||
88 | int o2net_init_tcp_sock(struct inode *inode); | ||
89 | int o2net_send_message(u32 msg_type, u32 key, void *data, u32 len, | 88 | int o2net_send_message(u32 msg_type, u32 key, void *data, u32 len, |
90 | u8 target_node, int *status); | 89 | u8 target_node, int *status); |
91 | int o2net_send_message_vec(u32 msg_type, u32 key, struct kvec *vec, | 90 | int o2net_send_message_vec(u32 msg_type, u32 key, struct kvec *vec, |
92 | size_t veclen, u8 target_node, int *status); | 91 | size_t veclen, u8 target_node, int *status); |
93 | int o2net_broadcast_message(u32 msg_type, u32 key, void *data, u32 len, | ||
94 | struct inode *group); | ||
95 | 92 | ||
96 | int o2net_register_handler(u32 msg_type, u32 key, u32 max_len, | 93 | int o2net_register_handler(u32 msg_type, u32 key, u32 max_len, |
97 | o2net_msg_handler_func *func, void *data, | 94 | o2net_msg_handler_func *func, void *data, |
@@ -107,7 +104,5 @@ void o2net_disconnect_node(struct o2nm_node *node); | |||
107 | 104 | ||
108 | int o2net_init(void); | 105 | int o2net_init(void); |
109 | void o2net_exit(void); | 106 | void o2net_exit(void); |
110 | int o2net_proc_init(struct proc_dir_entry *parent); | ||
111 | void o2net_proc_exit(struct proc_dir_entry *parent); | ||
112 | 107 | ||
113 | #endif /* O2CLUSTER_TCP_H */ | 108 | #endif /* O2CLUSTER_TCP_H */ |
diff --git a/fs/ocfs2/dlm/dlmcommon.h b/fs/ocfs2/dlm/dlmcommon.h index 23ceaa7127b4..9c772583744a 100644 --- a/fs/ocfs2/dlm/dlmcommon.h +++ b/fs/ocfs2/dlm/dlmcommon.h | |||
@@ -37,9 +37,7 @@ | |||
37 | #define DLM_THREAD_SHUFFLE_INTERVAL 5 // flush everything every 5 passes | 37 | #define DLM_THREAD_SHUFFLE_INTERVAL 5 // flush everything every 5 passes |
38 | #define DLM_THREAD_MS 200 // flush at least every 200 ms | 38 | #define DLM_THREAD_MS 200 // flush at least every 200 ms |
39 | 39 | ||
40 | #define DLM_HASH_BITS 7 | 40 | #define DLM_HASH_BUCKETS (PAGE_SIZE / sizeof(struct hlist_head)) |
41 | #define DLM_HASH_SIZE (1 << DLM_HASH_BITS) | ||
42 | #define DLM_HASH_MASK (DLM_HASH_SIZE - 1) | ||
43 | 41 | ||
44 | enum dlm_ast_type { | 42 | enum dlm_ast_type { |
45 | DLM_AST = 0, | 43 | DLM_AST = 0, |
@@ -87,7 +85,7 @@ enum dlm_ctxt_state { | |||
87 | struct dlm_ctxt | 85 | struct dlm_ctxt |
88 | { | 86 | { |
89 | struct list_head list; | 87 | struct list_head list; |
90 | struct list_head *resources; | 88 | struct hlist_head *lockres_hash; |
91 | struct list_head dirty_list; | 89 | struct list_head dirty_list; |
92 | struct list_head purge_list; | 90 | struct list_head purge_list; |
93 | struct list_head pending_asts; | 91 | struct list_head pending_asts; |
@@ -217,7 +215,7 @@ struct dlm_lock_resource | |||
217 | { | 215 | { |
218 | /* WARNING: Please see the comment in dlm_init_lockres before | 216 | /* WARNING: Please see the comment in dlm_init_lockres before |
219 | * adding fields here. */ | 217 | * adding fields here. */ |
220 | struct list_head list; | 218 | struct hlist_node hash_node; |
221 | struct kref refs; | 219 | struct kref refs; |
222 | 220 | ||
223 | /* please keep these next 3 in this order | 221 | /* please keep these next 3 in this order |
diff --git a/fs/ocfs2/dlm/dlmdebug.c b/fs/ocfs2/dlm/dlmdebug.c index f339fe27975a..54f61b76ab51 100644 --- a/fs/ocfs2/dlm/dlmdebug.c +++ b/fs/ocfs2/dlm/dlmdebug.c | |||
@@ -117,8 +117,8 @@ EXPORT_SYMBOL_GPL(dlm_print_one_lock); | |||
117 | void dlm_dump_lock_resources(struct dlm_ctxt *dlm) | 117 | void dlm_dump_lock_resources(struct dlm_ctxt *dlm) |
118 | { | 118 | { |
119 | struct dlm_lock_resource *res; | 119 | struct dlm_lock_resource *res; |
120 | struct list_head *iter; | 120 | struct hlist_node *iter; |
121 | struct list_head *bucket; | 121 | struct hlist_head *bucket; |
122 | int i; | 122 | int i; |
123 | 123 | ||
124 | mlog(ML_NOTICE, "struct dlm_ctxt: %s, node=%u, key=%u\n", | 124 | mlog(ML_NOTICE, "struct dlm_ctxt: %s, node=%u, key=%u\n", |
@@ -129,12 +129,10 @@ void dlm_dump_lock_resources(struct dlm_ctxt *dlm) | |||
129 | } | 129 | } |
130 | 130 | ||
131 | spin_lock(&dlm->spinlock); | 131 | spin_lock(&dlm->spinlock); |
132 | for (i=0; i<DLM_HASH_SIZE; i++) { | 132 | for (i=0; i<DLM_HASH_BUCKETS; i++) { |
133 | bucket = &(dlm->resources[i]); | 133 | bucket = &(dlm->lockres_hash[i]); |
134 | list_for_each(iter, bucket) { | 134 | hlist_for_each_entry(res, iter, bucket, hash_node) |
135 | res = list_entry(iter, struct dlm_lock_resource, list); | ||
136 | dlm_print_one_lock_resource(res); | 135 | dlm_print_one_lock_resource(res); |
137 | } | ||
138 | } | 136 | } |
139 | spin_unlock(&dlm->spinlock); | 137 | spin_unlock(&dlm->spinlock); |
140 | } | 138 | } |
diff --git a/fs/ocfs2/dlm/dlmdomain.c b/fs/ocfs2/dlm/dlmdomain.c index 6ee30837389c..8f3a9e3106fd 100644 --- a/fs/ocfs2/dlm/dlmdomain.c +++ b/fs/ocfs2/dlm/dlmdomain.c | |||
@@ -77,26 +77,26 @@ static void dlm_unregister_domain_handlers(struct dlm_ctxt *dlm); | |||
77 | 77 | ||
78 | void __dlm_unhash_lockres(struct dlm_lock_resource *lockres) | 78 | void __dlm_unhash_lockres(struct dlm_lock_resource *lockres) |
79 | { | 79 | { |
80 | list_del_init(&lockres->list); | 80 | hlist_del_init(&lockres->hash_node); |
81 | dlm_lockres_put(lockres); | 81 | dlm_lockres_put(lockres); |
82 | } | 82 | } |
83 | 83 | ||
84 | void __dlm_insert_lockres(struct dlm_ctxt *dlm, | 84 | void __dlm_insert_lockres(struct dlm_ctxt *dlm, |
85 | struct dlm_lock_resource *res) | 85 | struct dlm_lock_resource *res) |
86 | { | 86 | { |
87 | struct list_head *bucket; | 87 | struct hlist_head *bucket; |
88 | struct qstr *q; | 88 | struct qstr *q; |
89 | 89 | ||
90 | assert_spin_locked(&dlm->spinlock); | 90 | assert_spin_locked(&dlm->spinlock); |
91 | 91 | ||
92 | q = &res->lockname; | 92 | q = &res->lockname; |
93 | q->hash = full_name_hash(q->name, q->len); | 93 | q->hash = full_name_hash(q->name, q->len); |
94 | bucket = &(dlm->resources[q->hash & DLM_HASH_MASK]); | 94 | bucket = &(dlm->lockres_hash[q->hash % DLM_HASH_BUCKETS]); |
95 | 95 | ||
96 | /* get a reference for our hashtable */ | 96 | /* get a reference for our hashtable */ |
97 | dlm_lockres_get(res); | 97 | dlm_lockres_get(res); |
98 | 98 | ||
99 | list_add_tail(&res->list, bucket); | 99 | hlist_add_head(&res->hash_node, bucket); |
100 | } | 100 | } |
101 | 101 | ||
102 | struct dlm_lock_resource * __dlm_lookup_lockres(struct dlm_ctxt *dlm, | 102 | struct dlm_lock_resource * __dlm_lookup_lockres(struct dlm_ctxt *dlm, |
@@ -104,9 +104,9 @@ struct dlm_lock_resource * __dlm_lookup_lockres(struct dlm_ctxt *dlm, | |||
104 | unsigned int len) | 104 | unsigned int len) |
105 | { | 105 | { |
106 | unsigned int hash; | 106 | unsigned int hash; |
107 | struct list_head *iter; | 107 | struct hlist_node *iter; |
108 | struct dlm_lock_resource *tmpres=NULL; | 108 | struct dlm_lock_resource *tmpres=NULL; |
109 | struct list_head *bucket; | 109 | struct hlist_head *bucket; |
110 | 110 | ||
111 | mlog_entry("%.*s\n", len, name); | 111 | mlog_entry("%.*s\n", len, name); |
112 | 112 | ||
@@ -114,11 +114,11 @@ struct dlm_lock_resource * __dlm_lookup_lockres(struct dlm_ctxt *dlm, | |||
114 | 114 | ||
115 | hash = full_name_hash(name, len); | 115 | hash = full_name_hash(name, len); |
116 | 116 | ||
117 | bucket = &(dlm->resources[hash & DLM_HASH_MASK]); | 117 | bucket = &(dlm->lockres_hash[hash % DLM_HASH_BUCKETS]); |
118 | 118 | ||
119 | /* check for pre-existing lock */ | 119 | /* check for pre-existing lock */ |
120 | list_for_each(iter, bucket) { | 120 | hlist_for_each(iter, bucket) { |
121 | tmpres = list_entry(iter, struct dlm_lock_resource, list); | 121 | tmpres = hlist_entry(iter, struct dlm_lock_resource, hash_node); |
122 | if (tmpres->lockname.len == len && | 122 | if (tmpres->lockname.len == len && |
123 | memcmp(tmpres->lockname.name, name, len) == 0) { | 123 | memcmp(tmpres->lockname.name, name, len) == 0) { |
124 | dlm_lockres_get(tmpres); | 124 | dlm_lockres_get(tmpres); |
@@ -193,8 +193,8 @@ static int dlm_wait_on_domain_helper(const char *domain) | |||
193 | 193 | ||
194 | static void dlm_free_ctxt_mem(struct dlm_ctxt *dlm) | 194 | static void dlm_free_ctxt_mem(struct dlm_ctxt *dlm) |
195 | { | 195 | { |
196 | if (dlm->resources) | 196 | if (dlm->lockres_hash) |
197 | free_page((unsigned long) dlm->resources); | 197 | free_page((unsigned long) dlm->lockres_hash); |
198 | 198 | ||
199 | if (dlm->name) | 199 | if (dlm->name) |
200 | kfree(dlm->name); | 200 | kfree(dlm->name); |
@@ -303,10 +303,10 @@ static void dlm_migrate_all_locks(struct dlm_ctxt *dlm) | |||
303 | mlog(0, "Migrating locks from domain %s\n", dlm->name); | 303 | mlog(0, "Migrating locks from domain %s\n", dlm->name); |
304 | restart: | 304 | restart: |
305 | spin_lock(&dlm->spinlock); | 305 | spin_lock(&dlm->spinlock); |
306 | for (i=0; i<DLM_HASH_SIZE; i++) { | 306 | for (i = 0; i < DLM_HASH_BUCKETS; i++) { |
307 | while (!list_empty(&dlm->resources[i])) { | 307 | while (!hlist_empty(&dlm->lockres_hash[i])) { |
308 | res = list_entry(dlm->resources[i].next, | 308 | res = hlist_entry(dlm->lockres_hash[i].first, |
309 | struct dlm_lock_resource, list); | 309 | struct dlm_lock_resource, hash_node); |
310 | /* need reference when manually grabbing lockres */ | 310 | /* need reference when manually grabbing lockres */ |
311 | dlm_lockres_get(res); | 311 | dlm_lockres_get(res); |
312 | /* this should unhash the lockres | 312 | /* this should unhash the lockres |
@@ -1191,18 +1191,17 @@ static struct dlm_ctxt *dlm_alloc_ctxt(const char *domain, | |||
1191 | goto leave; | 1191 | goto leave; |
1192 | } | 1192 | } |
1193 | 1193 | ||
1194 | dlm->resources = (struct list_head *) __get_free_page(GFP_KERNEL); | 1194 | dlm->lockres_hash = (struct hlist_head *) __get_free_page(GFP_KERNEL); |
1195 | if (!dlm->resources) { | 1195 | if (!dlm->lockres_hash) { |
1196 | mlog_errno(-ENOMEM); | 1196 | mlog_errno(-ENOMEM); |
1197 | kfree(dlm->name); | 1197 | kfree(dlm->name); |
1198 | kfree(dlm); | 1198 | kfree(dlm); |
1199 | dlm = NULL; | 1199 | dlm = NULL; |
1200 | goto leave; | 1200 | goto leave; |
1201 | } | 1201 | } |
1202 | memset(dlm->resources, 0, PAGE_SIZE); | ||
1203 | 1202 | ||
1204 | for (i=0; i<DLM_HASH_SIZE; i++) | 1203 | for (i=0; i<DLM_HASH_BUCKETS; i++) |
1205 | INIT_LIST_HEAD(&dlm->resources[i]); | 1204 | INIT_HLIST_HEAD(&dlm->lockres_hash[i]); |
1206 | 1205 | ||
1207 | strcpy(dlm->name, domain); | 1206 | strcpy(dlm->name, domain); |
1208 | dlm->key = key; | 1207 | dlm->key = key; |
diff --git a/fs/ocfs2/dlm/dlmmaster.c b/fs/ocfs2/dlm/dlmmaster.c index 2e2e95e69499..847dd3cc4cf5 100644 --- a/fs/ocfs2/dlm/dlmmaster.c +++ b/fs/ocfs2/dlm/dlmmaster.c | |||
@@ -564,7 +564,7 @@ static void dlm_lockres_release(struct kref *kref) | |||
564 | 564 | ||
565 | /* By the time we're ready to blow this guy away, we shouldn't | 565 | /* By the time we're ready to blow this guy away, we shouldn't |
566 | * be on any lists. */ | 566 | * be on any lists. */ |
567 | BUG_ON(!list_empty(&res->list)); | 567 | BUG_ON(!hlist_unhashed(&res->hash_node)); |
568 | BUG_ON(!list_empty(&res->granted)); | 568 | BUG_ON(!list_empty(&res->granted)); |
569 | BUG_ON(!list_empty(&res->converting)); | 569 | BUG_ON(!list_empty(&res->converting)); |
570 | BUG_ON(!list_empty(&res->blocked)); | 570 | BUG_ON(!list_empty(&res->blocked)); |
@@ -605,7 +605,7 @@ static void dlm_init_lockres(struct dlm_ctxt *dlm, | |||
605 | 605 | ||
606 | init_waitqueue_head(&res->wq); | 606 | init_waitqueue_head(&res->wq); |
607 | spin_lock_init(&res->spinlock); | 607 | spin_lock_init(&res->spinlock); |
608 | INIT_LIST_HEAD(&res->list); | 608 | INIT_HLIST_NODE(&res->hash_node); |
609 | INIT_LIST_HEAD(&res->granted); | 609 | INIT_LIST_HEAD(&res->granted); |
610 | INIT_LIST_HEAD(&res->converting); | 610 | INIT_LIST_HEAD(&res->converting); |
611 | INIT_LIST_HEAD(&res->blocked); | 611 | INIT_LIST_HEAD(&res->blocked); |
diff --git a/fs/ocfs2/dlm/dlmrecovery.c b/fs/ocfs2/dlm/dlmrecovery.c index ed76bda1a534..1e232000f3f7 100644 --- a/fs/ocfs2/dlm/dlmrecovery.c +++ b/fs/ocfs2/dlm/dlmrecovery.c | |||
@@ -1693,7 +1693,10 @@ static void dlm_finish_local_lockres_recovery(struct dlm_ctxt *dlm, | |||
1693 | u8 dead_node, u8 new_master) | 1693 | u8 dead_node, u8 new_master) |
1694 | { | 1694 | { |
1695 | int i; | 1695 | int i; |
1696 | struct list_head *iter, *iter2, *bucket; | 1696 | struct list_head *iter, *iter2; |
1697 | struct hlist_node *hash_iter; | ||
1698 | struct hlist_head *bucket; | ||
1699 | |||
1697 | struct dlm_lock_resource *res; | 1700 | struct dlm_lock_resource *res; |
1698 | 1701 | ||
1699 | mlog_entry_void(); | 1702 | mlog_entry_void(); |
@@ -1717,10 +1720,9 @@ static void dlm_finish_local_lockres_recovery(struct dlm_ctxt *dlm, | |||
1717 | * for now we need to run the whole hash, clear | 1720 | * for now we need to run the whole hash, clear |
1718 | * the RECOVERING state and set the owner | 1721 | * the RECOVERING state and set the owner |
1719 | * if necessary */ | 1722 | * if necessary */ |
1720 | for (i=0; i<DLM_HASH_SIZE; i++) { | 1723 | for (i = 0; i < DLM_HASH_BUCKETS; i++) { |
1721 | bucket = &(dlm->resources[i]); | 1724 | bucket = &(dlm->lockres_hash[i]); |
1722 | list_for_each(iter, bucket) { | 1725 | hlist_for_each_entry(res, hash_iter, bucket, hash_node) { |
1723 | res = list_entry (iter, struct dlm_lock_resource, list); | ||
1724 | if (res->state & DLM_LOCK_RES_RECOVERING) { | 1726 | if (res->state & DLM_LOCK_RES_RECOVERING) { |
1725 | if (res->owner == dead_node) { | 1727 | if (res->owner == dead_node) { |
1726 | mlog(0, "(this=%u) res %.*s owner=%u " | 1728 | mlog(0, "(this=%u) res %.*s owner=%u " |
@@ -1852,10 +1854,10 @@ static void dlm_free_dead_locks(struct dlm_ctxt *dlm, | |||
1852 | 1854 | ||
1853 | static void dlm_do_local_recovery_cleanup(struct dlm_ctxt *dlm, u8 dead_node) | 1855 | static void dlm_do_local_recovery_cleanup(struct dlm_ctxt *dlm, u8 dead_node) |
1854 | { | 1856 | { |
1855 | struct list_head *iter; | 1857 | struct hlist_node *iter; |
1856 | struct dlm_lock_resource *res; | 1858 | struct dlm_lock_resource *res; |
1857 | int i; | 1859 | int i; |
1858 | struct list_head *bucket; | 1860 | struct hlist_head *bucket; |
1859 | struct dlm_lock *lock; | 1861 | struct dlm_lock *lock; |
1860 | 1862 | ||
1861 | 1863 | ||
@@ -1876,10 +1878,9 @@ static void dlm_do_local_recovery_cleanup(struct dlm_ctxt *dlm, u8 dead_node) | |||
1876 | * can be kicked again to see if any ASTs or BASTs | 1878 | * can be kicked again to see if any ASTs or BASTs |
1877 | * need to be fired as a result. | 1879 | * need to be fired as a result. |
1878 | */ | 1880 | */ |
1879 | for (i=0; i<DLM_HASH_SIZE; i++) { | 1881 | for (i = 0; i < DLM_HASH_BUCKETS; i++) { |
1880 | bucket = &(dlm->resources[i]); | 1882 | bucket = &(dlm->lockres_hash[i]); |
1881 | list_for_each(iter, bucket) { | 1883 | hlist_for_each_entry(res, iter, bucket, hash_node) { |
1882 | res = list_entry (iter, struct dlm_lock_resource, list); | ||
1883 | /* always prune any $RECOVERY entries for dead nodes, | 1884 | /* always prune any $RECOVERY entries for dead nodes, |
1884 | * otherwise hangs can occur during later recovery */ | 1885 | * otherwise hangs can occur during later recovery */ |
1885 | if (dlm_is_recovery_lock(res->lockname.name, | 1886 | if (dlm_is_recovery_lock(res->lockname.name, |
diff --git a/fs/ocfs2/extent_map.c b/fs/ocfs2/extent_map.c index b6ba292e9544..e6f207eebab4 100644 --- a/fs/ocfs2/extent_map.c +++ b/fs/ocfs2/extent_map.c | |||
@@ -181,6 +181,12 @@ static int ocfs2_extent_map_find_leaf(struct inode *inode, | |||
181 | ret = -EBADR; | 181 | ret = -EBADR; |
182 | if (rec_end > OCFS2_I(inode)->ip_clusters) { | 182 | if (rec_end > OCFS2_I(inode)->ip_clusters) { |
183 | mlog_errno(ret); | 183 | mlog_errno(ret); |
184 | ocfs2_error(inode->i_sb, | ||
185 | "Extent %d at e_blkno %"MLFu64" of inode %"MLFu64" goes past ip_clusters of %u\n", | ||
186 | i, | ||
187 | le64_to_cpu(rec->e_blkno), | ||
188 | OCFS2_I(inode)->ip_blkno, | ||
189 | OCFS2_I(inode)->ip_clusters); | ||
184 | goto out_free; | 190 | goto out_free; |
185 | } | 191 | } |
186 | 192 | ||
@@ -226,6 +232,12 @@ static int ocfs2_extent_map_find_leaf(struct inode *inode, | |||
226 | ret = -EBADR; | 232 | ret = -EBADR; |
227 | if (blkno) { | 233 | if (blkno) { |
228 | mlog_errno(ret); | 234 | mlog_errno(ret); |
235 | ocfs2_error(inode->i_sb, | ||
236 | "Multiple extents for (cpos = %u, clusters = %u) on inode %"MLFu64"; e_blkno %"MLFu64" and rec %d at e_blkno %"MLFu64"\n", | ||
237 | cpos, clusters, | ||
238 | OCFS2_I(inode)->ip_blkno, | ||
239 | blkno, i, | ||
240 | le64_to_cpu(rec->e_blkno)); | ||
229 | goto out_free; | 241 | goto out_free; |
230 | } | 242 | } |
231 | 243 | ||
@@ -238,6 +250,10 @@ static int ocfs2_extent_map_find_leaf(struct inode *inode, | |||
238 | */ | 250 | */ |
239 | ret = -EBADR; | 251 | ret = -EBADR; |
240 | if (!blkno) { | 252 | if (!blkno) { |
253 | ocfs2_error(inode->i_sb, | ||
254 | "No record found for (cpos = %u, clusters = %u) on inode %"MLFu64"\n", | ||
255 | cpos, clusters, | ||
256 | OCFS2_I(inode)->ip_blkno); | ||
241 | mlog_errno(ret); | 257 | mlog_errno(ret); |
242 | goto out_free; | 258 | goto out_free; |
243 | } | 259 | } |
@@ -266,6 +282,20 @@ static int ocfs2_extent_map_find_leaf(struct inode *inode, | |||
266 | 282 | ||
267 | for (i = 0; i < le16_to_cpu(el->l_next_free_rec); i++) { | 283 | for (i = 0; i < le16_to_cpu(el->l_next_free_rec); i++) { |
268 | rec = &el->l_recs[i]; | 284 | rec = &el->l_recs[i]; |
285 | |||
286 | if ((le32_to_cpu(rec->e_cpos) + le32_to_cpu(rec->e_clusters)) > | ||
287 | OCFS2_I(inode)->ip_clusters) { | ||
288 | ret = -EBADR; | ||
289 | mlog_errno(ret); | ||
290 | ocfs2_error(inode->i_sb, | ||
291 | "Extent %d at e_blkno %"MLFu64" of inode %"MLFu64" goes past ip_clusters of %u\n", | ||
292 | i, | ||
293 | le64_to_cpu(rec->e_blkno), | ||
294 | OCFS2_I(inode)->ip_blkno, | ||
295 | OCFS2_I(inode)->ip_clusters); | ||
296 | return ret; | ||
297 | } | ||
298 | |||
269 | ret = ocfs2_extent_map_insert(inode, rec, | 299 | ret = ocfs2_extent_map_insert(inode, rec, |
270 | le16_to_cpu(el->l_tree_depth)); | 300 | le16_to_cpu(el->l_tree_depth)); |
271 | if (ret) { | 301 | if (ret) { |
@@ -526,6 +556,10 @@ static int ocfs2_extent_map_insert(struct inode *inode, | |||
526 | OCFS2_I(inode)->ip_map.em_clusters) { | 556 | OCFS2_I(inode)->ip_map.em_clusters) { |
527 | ret = -EBADR; | 557 | ret = -EBADR; |
528 | mlog_errno(ret); | 558 | mlog_errno(ret); |
559 | ocfs2_error(inode->i_sb, | ||
560 | "Zero e_clusters on non-tail extent record at e_blkno %"MLFu64" on inode %"MLFu64"\n", | ||
561 | le64_to_cpu(rec->e_blkno), | ||
562 | OCFS2_I(inode)->ip_blkno); | ||
529 | return ret; | 563 | return ret; |
530 | } | 564 | } |
531 | 565 | ||
@@ -588,12 +622,12 @@ static int ocfs2_extent_map_insert(struct inode *inode, | |||
588 | * Existing record in the extent map: | 622 | * Existing record in the extent map: |
589 | * | 623 | * |
590 | * cpos = 10, len = 10 | 624 | * cpos = 10, len = 10 |
591 | * |---------| | 625 | * |---------| |
592 | * | 626 | * |
593 | * New Record: | 627 | * New Record: |
594 | * | 628 | * |
595 | * cpos = 10, len = 20 | 629 | * cpos = 10, len = 20 |
596 | * |------------------| | 630 | * |------------------| |
597 | * | 631 | * |
598 | * The passed record is the new on-disk record. The new_clusters value | 632 | * The passed record is the new on-disk record. The new_clusters value |
599 | * is how many clusters were added to the file. If the append is a | 633 | * is how many clusters were added to the file. If the append is a |
diff --git a/fs/ocfs2/file.c b/fs/ocfs2/file.c index 1715bc90e705..8a4048b55fdc 100644 --- a/fs/ocfs2/file.c +++ b/fs/ocfs2/file.c | |||
@@ -933,9 +933,6 @@ static ssize_t ocfs2_file_aio_write(struct kiocb *iocb, | |||
933 | struct file *filp = iocb->ki_filp; | 933 | struct file *filp = iocb->ki_filp; |
934 | struct inode *inode = filp->f_dentry->d_inode; | 934 | struct inode *inode = filp->f_dentry->d_inode; |
935 | loff_t newsize, saved_pos; | 935 | loff_t newsize, saved_pos; |
936 | #ifdef OCFS2_ORACORE_WORKAROUNDS | ||
937 | struct ocfs2_super *osb = OCFS2_SB(inode->i_sb); | ||
938 | #endif | ||
939 | 936 | ||
940 | mlog_entry("(0x%p, 0x%p, %u, '%.*s')\n", filp, buf, | 937 | mlog_entry("(0x%p, 0x%p, %u, '%.*s')\n", filp, buf, |
941 | (unsigned int)count, | 938 | (unsigned int)count, |
@@ -951,14 +948,6 @@ static ssize_t ocfs2_file_aio_write(struct kiocb *iocb, | |||
951 | return -EIO; | 948 | return -EIO; |
952 | } | 949 | } |
953 | 950 | ||
954 | #ifdef OCFS2_ORACORE_WORKAROUNDS | ||
955 | /* ugh, work around some applications which open everything O_DIRECT + | ||
956 | * O_APPEND and really don't mean to use O_DIRECT. */ | ||
957 | if (osb->s_mount_opt & OCFS2_MOUNT_COMPAT_OCFS && | ||
958 | (filp->f_flags & O_APPEND) && (filp->f_flags & O_DIRECT)) | ||
959 | filp->f_flags &= ~O_DIRECT; | ||
960 | #endif | ||
961 | |||
962 | mutex_lock(&inode->i_mutex); | 951 | mutex_lock(&inode->i_mutex); |
963 | /* to match setattr's i_mutex -> i_alloc_sem -> rw_lock ordering */ | 952 | /* to match setattr's i_mutex -> i_alloc_sem -> rw_lock ordering */ |
964 | if (filp->f_flags & O_DIRECT) { | 953 | if (filp->f_flags & O_DIRECT) { |
@@ -1079,27 +1068,7 @@ static ssize_t ocfs2_file_aio_write(struct kiocb *iocb, | |||
1079 | /* communicate with ocfs2_dio_end_io */ | 1068 | /* communicate with ocfs2_dio_end_io */ |
1080 | ocfs2_iocb_set_rw_locked(iocb); | 1069 | ocfs2_iocb_set_rw_locked(iocb); |
1081 | 1070 | ||
1082 | #ifdef OCFS2_ORACORE_WORKAROUNDS | 1071 | ret = generic_file_aio_write_nolock(iocb, &local_iov, 1, &iocb->ki_pos); |
1083 | if (osb->s_mount_opt & OCFS2_MOUNT_COMPAT_OCFS && | ||
1084 | filp->f_flags & O_DIRECT) { | ||
1085 | unsigned int saved_flags = filp->f_flags; | ||
1086 | int sector_size = 1 << osb->s_sectsize_bits; | ||
1087 | |||
1088 | if ((saved_pos & (sector_size - 1)) || | ||
1089 | (count & (sector_size - 1)) || | ||
1090 | ((unsigned long)buf & (sector_size - 1))) { | ||
1091 | filp->f_flags |= O_SYNC; | ||
1092 | filp->f_flags &= ~O_DIRECT; | ||
1093 | } | ||
1094 | |||
1095 | ret = generic_file_aio_write_nolock(iocb, &local_iov, 1, | ||
1096 | &iocb->ki_pos); | ||
1097 | |||
1098 | filp->f_flags = saved_flags; | ||
1099 | } else | ||
1100 | #endif | ||
1101 | ret = generic_file_aio_write_nolock(iocb, &local_iov, 1, | ||
1102 | &iocb->ki_pos); | ||
1103 | 1072 | ||
1104 | /* buffered aio wouldn't have proper lock coverage today */ | 1073 | /* buffered aio wouldn't have proper lock coverage today */ |
1105 | BUG_ON(ret == -EIOCBQUEUED && !(filp->f_flags & O_DIRECT)); | 1074 | BUG_ON(ret == -EIOCBQUEUED && !(filp->f_flags & O_DIRECT)); |
@@ -1140,9 +1109,6 @@ static ssize_t ocfs2_file_aio_read(struct kiocb *iocb, | |||
1140 | int ret = 0, rw_level = -1, have_alloc_sem = 0; | 1109 | int ret = 0, rw_level = -1, have_alloc_sem = 0; |
1141 | struct file *filp = iocb->ki_filp; | 1110 | struct file *filp = iocb->ki_filp; |
1142 | struct inode *inode = filp->f_dentry->d_inode; | 1111 | struct inode *inode = filp->f_dentry->d_inode; |
1143 | #ifdef OCFS2_ORACORE_WORKAROUNDS | ||
1144 | struct ocfs2_super *osb = OCFS2_SB(inode->i_sb); | ||
1145 | #endif | ||
1146 | 1112 | ||
1147 | mlog_entry("(0x%p, 0x%p, %u, '%.*s')\n", filp, buf, | 1113 | mlog_entry("(0x%p, 0x%p, %u, '%.*s')\n", filp, buf, |
1148 | (unsigned int)count, | 1114 | (unsigned int)count, |
@@ -1155,21 +1121,6 @@ static ssize_t ocfs2_file_aio_read(struct kiocb *iocb, | |||
1155 | goto bail; | 1121 | goto bail; |
1156 | } | 1122 | } |
1157 | 1123 | ||
1158 | #ifdef OCFS2_ORACORE_WORKAROUNDS | ||
1159 | if (osb->s_mount_opt & OCFS2_MOUNT_COMPAT_OCFS) { | ||
1160 | if (filp->f_flags & O_DIRECT) { | ||
1161 | int sector_size = 1 << osb->s_sectsize_bits; | ||
1162 | |||
1163 | if ((pos & (sector_size - 1)) || | ||
1164 | (count & (sector_size - 1)) || | ||
1165 | ((unsigned long)buf & (sector_size - 1)) || | ||
1166 | (i_size_read(inode) & (sector_size -1))) { | ||
1167 | filp->f_flags &= ~O_DIRECT; | ||
1168 | } | ||
1169 | } | ||
1170 | } | ||
1171 | #endif | ||
1172 | |||
1173 | /* | 1124 | /* |
1174 | * buffered reads protect themselves in ->readpage(). O_DIRECT reads | 1125 | * buffered reads protect themselves in ->readpage(). O_DIRECT reads |
1175 | * need locks to protect pending reads from racing with truncate. | 1126 | * need locks to protect pending reads from racing with truncate. |
diff --git a/fs/ocfs2/heartbeat.c b/fs/ocfs2/heartbeat.c index 0bbd22f46c80..cbfd45a97a63 100644 --- a/fs/ocfs2/heartbeat.c +++ b/fs/ocfs2/heartbeat.c | |||
@@ -67,6 +67,7 @@ void ocfs2_init_node_maps(struct ocfs2_super *osb) | |||
67 | ocfs2_node_map_init(&osb->mounted_map); | 67 | ocfs2_node_map_init(&osb->mounted_map); |
68 | ocfs2_node_map_init(&osb->recovery_map); | 68 | ocfs2_node_map_init(&osb->recovery_map); |
69 | ocfs2_node_map_init(&osb->umount_map); | 69 | ocfs2_node_map_init(&osb->umount_map); |
70 | ocfs2_node_map_init(&osb->osb_recovering_orphan_dirs); | ||
70 | } | 71 | } |
71 | 72 | ||
72 | static void ocfs2_do_node_down(int node_num, | 73 | static void ocfs2_do_node_down(int node_num, |
diff --git a/fs/ocfs2/inode.c b/fs/ocfs2/inode.c index 8122489c5762..315472a5c192 100644 --- a/fs/ocfs2/inode.c +++ b/fs/ocfs2/inode.c | |||
@@ -41,6 +41,7 @@ | |||
41 | #include "dlmglue.h" | 41 | #include "dlmglue.h" |
42 | #include "extent_map.h" | 42 | #include "extent_map.h" |
43 | #include "file.h" | 43 | #include "file.h" |
44 | #include "heartbeat.h" | ||
44 | #include "inode.h" | 45 | #include "inode.h" |
45 | #include "journal.h" | 46 | #include "journal.h" |
46 | #include "namei.h" | 47 | #include "namei.h" |
@@ -544,6 +545,42 @@ bail: | |||
544 | return status; | 545 | return status; |
545 | } | 546 | } |
546 | 547 | ||
548 | /* | ||
549 | * Serialize with orphan dir recovery. If the process doing | ||
550 | * recovery on this orphan dir does an iget() with the dir | ||
551 | * i_mutex held, we'll deadlock here. Instead we detect this | ||
552 | * and exit early - recovery will wipe this inode for us. | ||
553 | */ | ||
554 | static int ocfs2_check_orphan_recovery_state(struct ocfs2_super *osb, | ||
555 | int slot) | ||
556 | { | ||
557 | int ret = 0; | ||
558 | |||
559 | spin_lock(&osb->osb_lock); | ||
560 | if (ocfs2_node_map_test_bit(osb, &osb->osb_recovering_orphan_dirs, slot)) { | ||
561 | mlog(0, "Recovery is happening on orphan dir %d, will skip " | ||
562 | "this inode\n", slot); | ||
563 | ret = -EDEADLK; | ||
564 | goto out; | ||
565 | } | ||
566 | /* This signals to the orphan recovery process that it should | ||
567 | * wait for us to handle the wipe. */ | ||
568 | osb->osb_orphan_wipes[slot]++; | ||
569 | out: | ||
570 | spin_unlock(&osb->osb_lock); | ||
571 | return ret; | ||
572 | } | ||
573 | |||
574 | static void ocfs2_signal_wipe_completion(struct ocfs2_super *osb, | ||
575 | int slot) | ||
576 | { | ||
577 | spin_lock(&osb->osb_lock); | ||
578 | osb->osb_orphan_wipes[slot]--; | ||
579 | spin_unlock(&osb->osb_lock); | ||
580 | |||
581 | wake_up(&osb->osb_wipe_event); | ||
582 | } | ||
583 | |||
547 | static int ocfs2_wipe_inode(struct inode *inode, | 584 | static int ocfs2_wipe_inode(struct inode *inode, |
548 | struct buffer_head *di_bh) | 585 | struct buffer_head *di_bh) |
549 | { | 586 | { |
@@ -555,6 +592,11 @@ static int ocfs2_wipe_inode(struct inode *inode, | |||
555 | /* We've already voted on this so it should be readonly - no | 592 | /* We've already voted on this so it should be readonly - no |
556 | * spinlock needed. */ | 593 | * spinlock needed. */ |
557 | orphaned_slot = OCFS2_I(inode)->ip_orphaned_slot; | 594 | orphaned_slot = OCFS2_I(inode)->ip_orphaned_slot; |
595 | |||
596 | status = ocfs2_check_orphan_recovery_state(osb, orphaned_slot); | ||
597 | if (status) | ||
598 | return status; | ||
599 | |||
558 | orphan_dir_inode = ocfs2_get_system_file_inode(osb, | 600 | orphan_dir_inode = ocfs2_get_system_file_inode(osb, |
559 | ORPHAN_DIR_SYSTEM_INODE, | 601 | ORPHAN_DIR_SYSTEM_INODE, |
560 | orphaned_slot); | 602 | orphaned_slot); |
@@ -597,6 +639,7 @@ bail_unlock_dir: | |||
597 | brelse(orphan_dir_bh); | 639 | brelse(orphan_dir_bh); |
598 | bail: | 640 | bail: |
599 | iput(orphan_dir_inode); | 641 | iput(orphan_dir_inode); |
642 | ocfs2_signal_wipe_completion(osb, orphaned_slot); | ||
600 | 643 | ||
601 | return status; | 644 | return status; |
602 | } | 645 | } |
@@ -822,7 +865,8 @@ void ocfs2_delete_inode(struct inode *inode) | |||
822 | 865 | ||
823 | status = ocfs2_wipe_inode(inode, di_bh); | 866 | status = ocfs2_wipe_inode(inode, di_bh); |
824 | if (status < 0) { | 867 | if (status < 0) { |
825 | mlog_errno(status); | 868 | if (status != -EDEADLK) |
869 | mlog_errno(status); | ||
826 | goto bail_unlock_inode; | 870 | goto bail_unlock_inode; |
827 | } | 871 | } |
828 | 872 | ||
diff --git a/fs/ocfs2/journal.c b/fs/ocfs2/journal.c index d329c9df90ae..4be801f4559b 100644 --- a/fs/ocfs2/journal.c +++ b/fs/ocfs2/journal.c | |||
@@ -1408,21 +1408,17 @@ bail: | |||
1408 | return status; | 1408 | return status; |
1409 | } | 1409 | } |
1410 | 1410 | ||
1411 | static int ocfs2_recover_orphans(struct ocfs2_super *osb, | 1411 | static int ocfs2_queue_orphans(struct ocfs2_super *osb, |
1412 | int slot) | 1412 | int slot, |
1413 | struct inode **head) | ||
1413 | { | 1414 | { |
1414 | int status = 0; | 1415 | int status; |
1415 | int have_disk_lock = 0; | ||
1416 | struct inode *inode = NULL; | ||
1417 | struct inode *iter; | ||
1418 | struct inode *orphan_dir_inode = NULL; | 1416 | struct inode *orphan_dir_inode = NULL; |
1417 | struct inode *iter; | ||
1419 | unsigned long offset, blk, local; | 1418 | unsigned long offset, blk, local; |
1420 | struct buffer_head *bh = NULL; | 1419 | struct buffer_head *bh = NULL; |
1421 | struct ocfs2_dir_entry *de; | 1420 | struct ocfs2_dir_entry *de; |
1422 | struct super_block *sb = osb->sb; | 1421 | struct super_block *sb = osb->sb; |
1423 | struct ocfs2_inode_info *oi; | ||
1424 | |||
1425 | mlog(0, "Recover inodes from orphan dir in slot %d\n", slot); | ||
1426 | 1422 | ||
1427 | orphan_dir_inode = ocfs2_get_system_file_inode(osb, | 1423 | orphan_dir_inode = ocfs2_get_system_file_inode(osb, |
1428 | ORPHAN_DIR_SYSTEM_INODE, | 1424 | ORPHAN_DIR_SYSTEM_INODE, |
@@ -1430,17 +1426,15 @@ static int ocfs2_recover_orphans(struct ocfs2_super *osb, | |||
1430 | if (!orphan_dir_inode) { | 1426 | if (!orphan_dir_inode) { |
1431 | status = -ENOENT; | 1427 | status = -ENOENT; |
1432 | mlog_errno(status); | 1428 | mlog_errno(status); |
1433 | goto out; | 1429 | return status; |
1434 | } | 1430 | } |
1435 | 1431 | ||
1436 | mutex_lock(&orphan_dir_inode->i_mutex); | 1432 | mutex_lock(&orphan_dir_inode->i_mutex); |
1437 | status = ocfs2_meta_lock(orphan_dir_inode, NULL, NULL, 0); | 1433 | status = ocfs2_meta_lock(orphan_dir_inode, NULL, NULL, 0); |
1438 | if (status < 0) { | 1434 | if (status < 0) { |
1439 | mutex_unlock(&orphan_dir_inode->i_mutex); | ||
1440 | mlog_errno(status); | 1435 | mlog_errno(status); |
1441 | goto out; | 1436 | goto out; |
1442 | } | 1437 | } |
1443 | have_disk_lock = 1; | ||
1444 | 1438 | ||
1445 | offset = 0; | 1439 | offset = 0; |
1446 | iter = NULL; | 1440 | iter = NULL; |
@@ -1451,11 +1445,10 @@ static int ocfs2_recover_orphans(struct ocfs2_super *osb, | |||
1451 | if (!bh) | 1445 | if (!bh) |
1452 | status = -EINVAL; | 1446 | status = -EINVAL; |
1453 | if (status < 0) { | 1447 | if (status < 0) { |
1454 | mutex_unlock(&orphan_dir_inode->i_mutex); | ||
1455 | if (bh) | 1448 | if (bh) |
1456 | brelse(bh); | 1449 | brelse(bh); |
1457 | mlog_errno(status); | 1450 | mlog_errno(status); |
1458 | goto out; | 1451 | goto out_unlock; |
1459 | } | 1452 | } |
1460 | 1453 | ||
1461 | local = 0; | 1454 | local = 0; |
@@ -1465,11 +1458,10 @@ static int ocfs2_recover_orphans(struct ocfs2_super *osb, | |||
1465 | 1458 | ||
1466 | if (!ocfs2_check_dir_entry(orphan_dir_inode, | 1459 | if (!ocfs2_check_dir_entry(orphan_dir_inode, |
1467 | de, bh, local)) { | 1460 | de, bh, local)) { |
1468 | mutex_unlock(&orphan_dir_inode->i_mutex); | ||
1469 | status = -EINVAL; | 1461 | status = -EINVAL; |
1470 | mlog_errno(status); | 1462 | mlog_errno(status); |
1471 | brelse(bh); | 1463 | brelse(bh); |
1472 | goto out; | 1464 | goto out_unlock; |
1473 | } | 1465 | } |
1474 | 1466 | ||
1475 | local += le16_to_cpu(de->rec_len); | 1467 | local += le16_to_cpu(de->rec_len); |
@@ -1504,18 +1496,95 @@ static int ocfs2_recover_orphans(struct ocfs2_super *osb, | |||
1504 | 1496 | ||
1505 | mlog(0, "queue orphan %"MLFu64"\n", | 1497 | mlog(0, "queue orphan %"MLFu64"\n", |
1506 | OCFS2_I(iter)->ip_blkno); | 1498 | OCFS2_I(iter)->ip_blkno); |
1507 | OCFS2_I(iter)->ip_next_orphan = inode; | 1499 | /* No locking is required for the next_orphan |
1508 | inode = iter; | 1500 | * queue as there is only ever a single |
1501 | * process doing orphan recovery. */ | ||
1502 | OCFS2_I(iter)->ip_next_orphan = *head; | ||
1503 | *head = iter; | ||
1509 | } | 1504 | } |
1510 | brelse(bh); | 1505 | brelse(bh); |
1511 | } | 1506 | } |
1512 | mutex_unlock(&orphan_dir_inode->i_mutex); | ||
1513 | 1507 | ||
1508 | out_unlock: | ||
1514 | ocfs2_meta_unlock(orphan_dir_inode, 0); | 1509 | ocfs2_meta_unlock(orphan_dir_inode, 0); |
1515 | have_disk_lock = 0; | 1510 | out: |
1516 | 1511 | mutex_unlock(&orphan_dir_inode->i_mutex); | |
1517 | iput(orphan_dir_inode); | 1512 | iput(orphan_dir_inode); |
1518 | orphan_dir_inode = NULL; | 1513 | return status; |
1514 | } | ||
1515 | |||
1516 | static int ocfs2_orphan_recovery_can_continue(struct ocfs2_super *osb, | ||
1517 | int slot) | ||
1518 | { | ||
1519 | int ret; | ||
1520 | |||
1521 | spin_lock(&osb->osb_lock); | ||
1522 | ret = !osb->osb_orphan_wipes[slot]; | ||
1523 | spin_unlock(&osb->osb_lock); | ||
1524 | return ret; | ||
1525 | } | ||
1526 | |||
1527 | static void ocfs2_mark_recovering_orphan_dir(struct ocfs2_super *osb, | ||
1528 | int slot) | ||
1529 | { | ||
1530 | spin_lock(&osb->osb_lock); | ||
1531 | /* Mark ourselves such that new processes in delete_inode() | ||
1532 | * know to quit early. */ | ||
1533 | ocfs2_node_map_set_bit(osb, &osb->osb_recovering_orphan_dirs, slot); | ||
1534 | while (osb->osb_orphan_wipes[slot]) { | ||
1535 | /* If any processes are already in the middle of an | ||
1536 | * orphan wipe on this dir, then we need to wait for | ||
1537 | * them. */ | ||
1538 | spin_unlock(&osb->osb_lock); | ||
1539 | wait_event_interruptible(osb->osb_wipe_event, | ||
1540 | ocfs2_orphan_recovery_can_continue(osb, slot)); | ||
1541 | spin_lock(&osb->osb_lock); | ||
1542 | } | ||
1543 | spin_unlock(&osb->osb_lock); | ||
1544 | } | ||
1545 | |||
1546 | static void ocfs2_clear_recovering_orphan_dir(struct ocfs2_super *osb, | ||
1547 | int slot) | ||
1548 | { | ||
1549 | ocfs2_node_map_clear_bit(osb, &osb->osb_recovering_orphan_dirs, slot); | ||
1550 | } | ||
1551 | |||
1552 | /* | ||
1553 | * Orphan recovery. Each mounted node has it's own orphan dir which we | ||
1554 | * must run during recovery. Our strategy here is to build a list of | ||
1555 | * the inodes in the orphan dir and iget/iput them. The VFS does | ||
1556 | * (most) of the rest of the work. | ||
1557 | * | ||
1558 | * Orphan recovery can happen at any time, not just mount so we have a | ||
1559 | * couple of extra considerations. | ||
1560 | * | ||
1561 | * - We grab as many inodes as we can under the orphan dir lock - | ||
1562 | * doing iget() outside the orphan dir risks getting a reference on | ||
1563 | * an invalid inode. | ||
1564 | * - We must be sure not to deadlock with other processes on the | ||
1565 | * system wanting to run delete_inode(). This can happen when they go | ||
1566 | * to lock the orphan dir and the orphan recovery process attempts to | ||
1567 | * iget() inside the orphan dir lock. This can be avoided by | ||
1568 | * advertising our state to ocfs2_delete_inode(). | ||
1569 | */ | ||
1570 | static int ocfs2_recover_orphans(struct ocfs2_super *osb, | ||
1571 | int slot) | ||
1572 | { | ||
1573 | int ret = 0; | ||
1574 | struct inode *inode = NULL; | ||
1575 | struct inode *iter; | ||
1576 | struct ocfs2_inode_info *oi; | ||
1577 | |||
1578 | mlog(0, "Recover inodes from orphan dir in slot %d\n", slot); | ||
1579 | |||
1580 | ocfs2_mark_recovering_orphan_dir(osb, slot); | ||
1581 | ret = ocfs2_queue_orphans(osb, slot, &inode); | ||
1582 | ocfs2_clear_recovering_orphan_dir(osb, slot); | ||
1583 | |||
1584 | /* Error here should be noted, but we want to continue with as | ||
1585 | * many queued inodes as we've got. */ | ||
1586 | if (ret) | ||
1587 | mlog_errno(ret); | ||
1519 | 1588 | ||
1520 | while (inode) { | 1589 | while (inode) { |
1521 | oi = OCFS2_I(inode); | 1590 | oi = OCFS2_I(inode); |
@@ -1541,14 +1610,7 @@ static int ocfs2_recover_orphans(struct ocfs2_super *osb, | |||
1541 | inode = iter; | 1610 | inode = iter; |
1542 | } | 1611 | } |
1543 | 1612 | ||
1544 | out: | 1613 | return ret; |
1545 | if (have_disk_lock) | ||
1546 | ocfs2_meta_unlock(orphan_dir_inode, 0); | ||
1547 | |||
1548 | if (orphan_dir_inode) | ||
1549 | iput(orphan_dir_inode); | ||
1550 | |||
1551 | return status; | ||
1552 | } | 1614 | } |
1553 | 1615 | ||
1554 | static int ocfs2_wait_on_mount(struct ocfs2_super *osb) | 1616 | static int ocfs2_wait_on_mount(struct ocfs2_super *osb) |
diff --git a/fs/ocfs2/ocfs2.h b/fs/ocfs2/ocfs2.h index 8d8e4779df92..e89de9b6e491 100644 --- a/fs/ocfs2/ocfs2.h +++ b/fs/ocfs2/ocfs2.h | |||
@@ -174,9 +174,6 @@ enum ocfs2_mount_options | |||
174 | OCFS2_MOUNT_NOINTR = 1 << 2, /* Don't catch signals */ | 174 | OCFS2_MOUNT_NOINTR = 1 << 2, /* Don't catch signals */ |
175 | OCFS2_MOUNT_ERRORS_PANIC = 1 << 3, /* Panic on errors */ | 175 | OCFS2_MOUNT_ERRORS_PANIC = 1 << 3, /* Panic on errors */ |
176 | OCFS2_MOUNT_DATA_WRITEBACK = 1 << 4, /* No data ordering */ | 176 | OCFS2_MOUNT_DATA_WRITEBACK = 1 << 4, /* No data ordering */ |
177 | #ifdef OCFS2_ORACORE_WORKAROUNDS | ||
178 | OCFS2_MOUNT_COMPAT_OCFS = 1 << 30, /* ocfs1 compatibility mode */ | ||
179 | #endif | ||
180 | }; | 177 | }; |
181 | 178 | ||
182 | #define OCFS2_OSB_SOFT_RO 0x0001 | 179 | #define OCFS2_OSB_SOFT_RO 0x0001 |
@@ -290,6 +287,10 @@ struct ocfs2_super | |||
290 | struct inode *osb_tl_inode; | 287 | struct inode *osb_tl_inode; |
291 | struct buffer_head *osb_tl_bh; | 288 | struct buffer_head *osb_tl_bh; |
292 | struct work_struct osb_truncate_log_wq; | 289 | struct work_struct osb_truncate_log_wq; |
290 | |||
291 | struct ocfs2_node_map osb_recovering_orphan_dirs; | ||
292 | unsigned int *osb_orphan_wipes; | ||
293 | wait_queue_head_t osb_wipe_event; | ||
293 | }; | 294 | }; |
294 | 295 | ||
295 | #define OCFS2_SB(sb) ((struct ocfs2_super *)(sb)->s_fs_info) | 296 | #define OCFS2_SB(sb) ((struct ocfs2_super *)(sb)->s_fs_info) |
diff --git a/fs/ocfs2/ocfs2_fs.h b/fs/ocfs2/ocfs2_fs.h index dfb8a5bedfc8..c5b1ac547c15 100644 --- a/fs/ocfs2/ocfs2_fs.h +++ b/fs/ocfs2/ocfs2_fs.h | |||
@@ -138,7 +138,6 @@ | |||
138 | 138 | ||
139 | /* Journal limits (in bytes) */ | 139 | /* Journal limits (in bytes) */ |
140 | #define OCFS2_MIN_JOURNAL_SIZE (4 * 1024 * 1024) | 140 | #define OCFS2_MIN_JOURNAL_SIZE (4 * 1024 * 1024) |
141 | #define OCFS2_MAX_JOURNAL_SIZE (500 * 1024 * 1024) | ||
142 | 141 | ||
143 | struct ocfs2_system_inode_info { | 142 | struct ocfs2_system_inode_info { |
144 | char *si_name; | 143 | char *si_name; |
diff --git a/fs/ocfs2/super.c b/fs/ocfs2/super.c index 046824b6b625..8dd3aafec499 100644 --- a/fs/ocfs2/super.c +++ b/fs/ocfs2/super.c | |||
@@ -1325,6 +1325,16 @@ static int ocfs2_initialize_super(struct super_block *sb, | |||
1325 | } | 1325 | } |
1326 | mlog(ML_NOTICE, "max_slots for this device: %u\n", osb->max_slots); | 1326 | mlog(ML_NOTICE, "max_slots for this device: %u\n", osb->max_slots); |
1327 | 1327 | ||
1328 | init_waitqueue_head(&osb->osb_wipe_event); | ||
1329 | osb->osb_orphan_wipes = kcalloc(osb->max_slots, | ||
1330 | sizeof(*osb->osb_orphan_wipes), | ||
1331 | GFP_KERNEL); | ||
1332 | if (!osb->osb_orphan_wipes) { | ||
1333 | status = -ENOMEM; | ||
1334 | mlog_errno(status); | ||
1335 | goto bail; | ||
1336 | } | ||
1337 | |||
1328 | osb->s_feature_compat = | 1338 | osb->s_feature_compat = |
1329 | le32_to_cpu(OCFS2_RAW_SB(di)->s_feature_compat); | 1339 | le32_to_cpu(OCFS2_RAW_SB(di)->s_feature_compat); |
1330 | osb->s_feature_ro_compat = | 1340 | osb->s_feature_ro_compat = |
@@ -1638,6 +1648,7 @@ static void ocfs2_delete_osb(struct ocfs2_super *osb) | |||
1638 | if (osb->slot_info) | 1648 | if (osb->slot_info) |
1639 | ocfs2_free_slot_info(osb->slot_info); | 1649 | ocfs2_free_slot_info(osb->slot_info); |
1640 | 1650 | ||
1651 | kfree(osb->osb_orphan_wipes); | ||
1641 | /* FIXME | 1652 | /* FIXME |
1642 | * This belongs in journal shutdown, but because we have to | 1653 | * This belongs in journal shutdown, but because we have to |
1643 | * allocate osb->journal at the start of ocfs2_initalize_osb(), | 1654 | * allocate osb->journal at the start of ocfs2_initalize_osb(), |
diff --git a/fs/ramfs/inode.c b/fs/ramfs/inode.c index c66bd5e4c05c..cde5d48994ae 100644 --- a/fs/ramfs/inode.c +++ b/fs/ramfs/inode.c | |||
@@ -27,6 +27,7 @@ | |||
27 | #include <linux/fs.h> | 27 | #include <linux/fs.h> |
28 | #include <linux/pagemap.h> | 28 | #include <linux/pagemap.h> |
29 | #include <linux/highmem.h> | 29 | #include <linux/highmem.h> |
30 | #include <linux/time.h> | ||
30 | #include <linux/init.h> | 31 | #include <linux/init.h> |
31 | #include <linux/string.h> | 32 | #include <linux/string.h> |
32 | #include <linux/smp_lock.h> | 33 | #include <linux/smp_lock.h> |
@@ -104,6 +105,7 @@ ramfs_mknod(struct inode *dir, struct dentry *dentry, int mode, dev_t dev) | |||
104 | d_instantiate(dentry, inode); | 105 | d_instantiate(dentry, inode); |
105 | dget(dentry); /* Extra count - pin the dentry in core */ | 106 | dget(dentry); /* Extra count - pin the dentry in core */ |
106 | error = 0; | 107 | error = 0; |
108 | dir->i_mtime = dir->i_ctime = CURRENT_TIME; | ||
107 | } | 109 | } |
108 | return error; | 110 | return error; |
109 | } | 111 | } |
diff --git a/fs/reiserfs/file.c b/fs/reiserfs/file.c index f3473176c83a..be12879bb179 100644 --- a/fs/reiserfs/file.c +++ b/fs/reiserfs/file.c | |||
@@ -1464,13 +1464,11 @@ static ssize_t reiserfs_file_write(struct file *file, /* the file we are going t | |||
1464 | partially overwritten pages, if needed. And lock the pages, | 1464 | partially overwritten pages, if needed. And lock the pages, |
1465 | so that nobody else can access these until we are done. | 1465 | so that nobody else can access these until we are done. |
1466 | We get number of actual blocks needed as a result. */ | 1466 | We get number of actual blocks needed as a result. */ |
1467 | blocks_to_allocate = | 1467 | res = reiserfs_prepare_file_region_for_write(inode, pos, |
1468 | reiserfs_prepare_file_region_for_write(inode, pos, | 1468 | num_pages, |
1469 | num_pages, | 1469 | write_bytes, |
1470 | write_bytes, | 1470 | prepared_pages); |
1471 | prepared_pages); | 1471 | if (res < 0) { |
1472 | if (blocks_to_allocate < 0) { | ||
1473 | res = blocks_to_allocate; | ||
1474 | reiserfs_release_claimed_blocks(inode->i_sb, | 1472 | reiserfs_release_claimed_blocks(inode->i_sb, |
1475 | num_pages << | 1473 | num_pages << |
1476 | (PAGE_CACHE_SHIFT - | 1474 | (PAGE_CACHE_SHIFT - |
@@ -1478,6 +1476,8 @@ static ssize_t reiserfs_file_write(struct file *file, /* the file we are going t | |||
1478 | break; | 1476 | break; |
1479 | } | 1477 | } |
1480 | 1478 | ||
1479 | blocks_to_allocate = res; | ||
1480 | |||
1481 | /* First we correct our estimate of how many blocks we need */ | 1481 | /* First we correct our estimate of how many blocks we need */ |
1482 | reiserfs_release_claimed_blocks(inode->i_sb, | 1482 | reiserfs_release_claimed_blocks(inode->i_sb, |
1483 | (num_pages << | 1483 | (num_pages << |
diff --git a/fs/reiserfs/inode.c b/fs/reiserfs/inode.c index b33d67bba2fd..d60f6238c66a 100644 --- a/fs/reiserfs/inode.c +++ b/fs/reiserfs/inode.c | |||
@@ -627,11 +627,6 @@ int reiserfs_get_block(struct inode *inode, sector_t block, | |||
627 | reiserfs_write_lock(inode->i_sb); | 627 | reiserfs_write_lock(inode->i_sb); |
628 | version = get_inode_item_key_version(inode); | 628 | version = get_inode_item_key_version(inode); |
629 | 629 | ||
630 | if (block < 0) { | ||
631 | reiserfs_write_unlock(inode->i_sb); | ||
632 | return -EIO; | ||
633 | } | ||
634 | |||
635 | if (!file_capable(inode, block)) { | 630 | if (!file_capable(inode, block)) { |
636 | reiserfs_write_unlock(inode->i_sb); | 631 | reiserfs_write_unlock(inode->i_sb); |
637 | return -EFBIG; | 632 | return -EFBIG; |
@@ -934,12 +929,13 @@ int reiserfs_get_block(struct inode *inode, sector_t block, | |||
934 | //pos_in_item * inode->i_sb->s_blocksize, | 929 | //pos_in_item * inode->i_sb->s_blocksize, |
935 | TYPE_INDIRECT, 3); // key type is unimportant | 930 | TYPE_INDIRECT, 3); // key type is unimportant |
936 | 931 | ||
932 | RFALSE(cpu_key_k_offset(&tmp_key) > cpu_key_k_offset(&key), | ||
933 | "green-805: invalid offset"); | ||
937 | blocks_needed = | 934 | blocks_needed = |
938 | 1 + | 935 | 1 + |
939 | ((cpu_key_k_offset(&key) - | 936 | ((cpu_key_k_offset(&key) - |
940 | cpu_key_k_offset(&tmp_key)) >> inode->i_sb-> | 937 | cpu_key_k_offset(&tmp_key)) >> inode->i_sb-> |
941 | s_blocksize_bits); | 938 | s_blocksize_bits); |
942 | RFALSE(blocks_needed < 0, "green-805: invalid offset"); | ||
943 | 939 | ||
944 | if (blocks_needed == 1) { | 940 | if (blocks_needed == 1) { |
945 | un = &unf_single; | 941 | un = &unf_single; |
diff --git a/fs/reiserfs/journal.c b/fs/reiserfs/journal.c index b7a179560ab4..5a9d2722fa0a 100644 --- a/fs/reiserfs/journal.c +++ b/fs/reiserfs/journal.c | |||
@@ -2319,8 +2319,7 @@ static int journal_read(struct super_block *p_s_sb) | |||
2319 | return 1; | 2319 | return 1; |
2320 | } | 2320 | } |
2321 | jh = (struct reiserfs_journal_header *)(journal->j_header_bh->b_data); | 2321 | jh = (struct reiserfs_journal_header *)(journal->j_header_bh->b_data); |
2322 | if (le32_to_cpu(jh->j_first_unflushed_offset) >= 0 && | 2322 | if (le32_to_cpu(jh->j_first_unflushed_offset) < |
2323 | le32_to_cpu(jh->j_first_unflushed_offset) < | ||
2324 | SB_ONDISK_JOURNAL_SIZE(p_s_sb) | 2323 | SB_ONDISK_JOURNAL_SIZE(p_s_sb) |
2325 | && le32_to_cpu(jh->j_last_flush_trans_id) > 0) { | 2324 | && le32_to_cpu(jh->j_last_flush_trans_id) > 0) { |
2326 | oldest_start = | 2325 | oldest_start = |
diff --git a/fs/xfs/linux-2.6/xfs_aops.c b/fs/xfs/linux-2.6/xfs_aops.c index 8f2beec526cf..74d8be87f983 100644 --- a/fs/xfs/linux-2.6/xfs_aops.c +++ b/fs/xfs/linux-2.6/xfs_aops.c | |||
@@ -540,7 +540,7 @@ xfs_probe_cluster( | |||
540 | 540 | ||
541 | /* First sum forwards in this page */ | 541 | /* First sum forwards in this page */ |
542 | do { | 542 | do { |
543 | if (mapped != buffer_mapped(bh)) | 543 | if (!buffer_uptodate(bh) || (mapped != buffer_mapped(bh))) |
544 | return total; | 544 | return total; |
545 | total += bh->b_size; | 545 | total += bh->b_size; |
546 | } while ((bh = bh->b_this_page) != head); | 546 | } while ((bh = bh->b_this_page) != head); |
diff --git a/fs/xfs/quota/xfs_qm.c b/fs/xfs/quota/xfs_qm.c index 53a00fb217fa..7c0e39dc6189 100644 --- a/fs/xfs/quota/xfs_qm.c +++ b/fs/xfs/quota/xfs_qm.c | |||
@@ -68,6 +68,9 @@ kmem_zone_t *qm_dqzone; | |||
68 | kmem_zone_t *qm_dqtrxzone; | 68 | kmem_zone_t *qm_dqtrxzone; |
69 | STATIC kmem_shaker_t xfs_qm_shaker; | 69 | STATIC kmem_shaker_t xfs_qm_shaker; |
70 | 70 | ||
71 | STATIC cred_t xfs_zerocr; | ||
72 | STATIC xfs_inode_t xfs_zeroino; | ||
73 | |||
71 | STATIC void xfs_qm_list_init(xfs_dqlist_t *, char *, int); | 74 | STATIC void xfs_qm_list_init(xfs_dqlist_t *, char *, int); |
72 | STATIC void xfs_qm_list_destroy(xfs_dqlist_t *); | 75 | STATIC void xfs_qm_list_destroy(xfs_dqlist_t *); |
73 | 76 | ||
@@ -1393,8 +1396,6 @@ xfs_qm_qino_alloc( | |||
1393 | xfs_trans_t *tp; | 1396 | xfs_trans_t *tp; |
1394 | int error; | 1397 | int error; |
1395 | unsigned long s; | 1398 | unsigned long s; |
1396 | cred_t zerocr; | ||
1397 | xfs_inode_t zeroino; | ||
1398 | int committed; | 1399 | int committed; |
1399 | 1400 | ||
1400 | tp = xfs_trans_alloc(mp, XFS_TRANS_QM_QINOCREATE); | 1401 | tp = xfs_trans_alloc(mp, XFS_TRANS_QM_QINOCREATE); |
@@ -1406,11 +1407,9 @@ xfs_qm_qino_alloc( | |||
1406 | xfs_trans_cancel(tp, 0); | 1407 | xfs_trans_cancel(tp, 0); |
1407 | return error; | 1408 | return error; |
1408 | } | 1409 | } |
1409 | memset(&zerocr, 0, sizeof(zerocr)); | ||
1410 | memset(&zeroino, 0, sizeof(zeroino)); | ||
1411 | 1410 | ||
1412 | if ((error = xfs_dir_ialloc(&tp, &zeroino, S_IFREG, 1, 0, | 1411 | if ((error = xfs_dir_ialloc(&tp, &xfs_zeroino, S_IFREG, 1, 0, |
1413 | &zerocr, 0, 1, ip, &committed))) { | 1412 | &xfs_zerocr, 0, 1, ip, &committed))) { |
1414 | xfs_trans_cancel(tp, XFS_TRANS_RELEASE_LOG_RES | | 1413 | xfs_trans_cancel(tp, XFS_TRANS_RELEASE_LOG_RES | |
1415 | XFS_TRANS_ABORT); | 1414 | XFS_TRANS_ABORT); |
1416 | return error; | 1415 | return error; |
diff --git a/fs/xfs/xfs_rtalloc.c b/fs/xfs/xfs_rtalloc.c index 06fc061c50fc..5b413946b1c5 100644 --- a/fs/xfs/xfs_rtalloc.c +++ b/fs/xfs/xfs_rtalloc.c | |||
@@ -130,7 +130,8 @@ xfs_growfs_rt_alloc( | |||
130 | /* | 130 | /* |
131 | * Lock the inode. | 131 | * Lock the inode. |
132 | */ | 132 | */ |
133 | if ((error = xfs_trans_iget(mp, tp, ino, 0, XFS_ILOCK_EXCL, &ip))) | 133 | if ((error = xfs_trans_iget(mp, tp, ino, 0, |
134 | XFS_ILOCK_EXCL, &ip))) | ||
134 | goto error_exit; | 135 | goto error_exit; |
135 | XFS_BMAP_INIT(&flist, &firstblock); | 136 | XFS_BMAP_INIT(&flist, &firstblock); |
136 | /* | 137 | /* |
@@ -170,8 +171,8 @@ xfs_growfs_rt_alloc( | |||
170 | /* | 171 | /* |
171 | * Lock the bitmap inode. | 172 | * Lock the bitmap inode. |
172 | */ | 173 | */ |
173 | if ((error = xfs_trans_iget(mp, tp, ino, 0, XFS_ILOCK_EXCL, | 174 | if ((error = xfs_trans_iget(mp, tp, ino, 0, |
174 | &ip))) | 175 | XFS_ILOCK_EXCL, &ip))) |
175 | goto error_exit; | 176 | goto error_exit; |
176 | /* | 177 | /* |
177 | * Get a buffer for the block. | 178 | * Get a buffer for the block. |
@@ -2023,8 +2024,8 @@ xfs_growfs_rt( | |||
2023 | /* | 2024 | /* |
2024 | * Lock out other callers by grabbing the bitmap inode lock. | 2025 | * Lock out other callers by grabbing the bitmap inode lock. |
2025 | */ | 2026 | */ |
2026 | if ((error = xfs_trans_iget(mp, tp, 0, mp->m_sb.sb_rbmino, | 2027 | if ((error = xfs_trans_iget(mp, tp, mp->m_sb.sb_rbmino, 0, |
2027 | XFS_ILOCK_EXCL, &ip))) | 2028 | XFS_ILOCK_EXCL, &ip))) |
2028 | goto error_exit; | 2029 | goto error_exit; |
2029 | ASSERT(ip == mp->m_rbmip); | 2030 | ASSERT(ip == mp->m_rbmip); |
2030 | /* | 2031 | /* |
@@ -2037,8 +2038,8 @@ xfs_growfs_rt( | |||
2037 | /* | 2038 | /* |
2038 | * Get the summary inode into the transaction. | 2039 | * Get the summary inode into the transaction. |
2039 | */ | 2040 | */ |
2040 | if ((error = xfs_trans_iget(mp, tp, mp->m_sb.sb_rsumino, | 2041 | if ((error = xfs_trans_iget(mp, tp, mp->m_sb.sb_rsumino, 0, |
2041 | 0, XFS_ILOCK_EXCL, &ip))) | 2042 | XFS_ILOCK_EXCL, &ip))) |
2042 | goto error_exit; | 2043 | goto error_exit; |
2043 | ASSERT(ip == mp->m_rsumip); | 2044 | ASSERT(ip == mp->m_rsumip); |
2044 | /* | 2045 | /* |
@@ -2158,10 +2159,9 @@ xfs_rtallocate_extent( | |||
2158 | /* | 2159 | /* |
2159 | * Lock out other callers by grabbing the bitmap inode lock. | 2160 | * Lock out other callers by grabbing the bitmap inode lock. |
2160 | */ | 2161 | */ |
2161 | error = xfs_trans_iget(mp, tp, mp->m_sb.sb_rbmino, 0, XFS_ILOCK_EXCL, &ip); | 2162 | if ((error = xfs_trans_iget(mp, tp, mp->m_sb.sb_rbmino, 0, |
2162 | if (error) { | 2163 | XFS_ILOCK_EXCL, &ip))) |
2163 | return error; | 2164 | return error; |
2164 | } | ||
2165 | sumbp = NULL; | 2165 | sumbp = NULL; |
2166 | /* | 2166 | /* |
2167 | * Allocate by size, or near another block, or exactly at some block. | 2167 | * Allocate by size, or near another block, or exactly at some block. |
@@ -2221,10 +2221,9 @@ xfs_rtfree_extent( | |||
2221 | /* | 2221 | /* |
2222 | * Synchronize by locking the bitmap inode. | 2222 | * Synchronize by locking the bitmap inode. |
2223 | */ | 2223 | */ |
2224 | error = xfs_trans_iget(mp, tp, mp->m_sb.sb_rbmino, 0, XFS_ILOCK_EXCL, &ip); | 2224 | if ((error = xfs_trans_iget(mp, tp, mp->m_sb.sb_rbmino, 0, |
2225 | if (error) { | 2225 | XFS_ILOCK_EXCL, &ip))) |
2226 | return error; | 2226 | return error; |
2227 | } | ||
2228 | #if defined(__KERNEL__) && defined(DEBUG) | 2227 | #if defined(__KERNEL__) && defined(DEBUG) |
2229 | /* | 2228 | /* |
2230 | * Check to see that this whole range is currently allocated. | 2229 | * Check to see that this whole range is currently allocated. |
@@ -2365,8 +2364,8 @@ xfs_rtpick_extent( | |||
2365 | __uint64_t seq; /* sequence number of file creation */ | 2364 | __uint64_t seq; /* sequence number of file creation */ |
2366 | __uint64_t *seqp; /* pointer to seqno in inode */ | 2365 | __uint64_t *seqp; /* pointer to seqno in inode */ |
2367 | 2366 | ||
2368 | error = xfs_trans_iget(mp, tp, mp->m_sb.sb_rbmino, 0, XFS_ILOCK_EXCL, &ip); | 2367 | if ((error = xfs_trans_iget(mp, tp, mp->m_sb.sb_rbmino, 0, |
2369 | if (error) | 2368 | XFS_ILOCK_EXCL, &ip))) |
2370 | return error; | 2369 | return error; |
2371 | ASSERT(ip == mp->m_rbmip); | 2370 | ASSERT(ip == mp->m_rbmip); |
2372 | seqp = (__uint64_t *)&ip->i_d.di_atime; | 2371 | seqp = (__uint64_t *)&ip->i_d.di_atime; |