diff options
Diffstat (limited to 'fs')
225 files changed, 4035 insertions, 3011 deletions
diff --git a/fs/9p/acl.c b/fs/9p/acl.c index 515455296378..535ab6eccb1a 100644 --- a/fs/9p/acl.c +++ b/fs/9p/acl.c | |||
@@ -262,7 +262,7 @@ static int v9fs_xattr_get_acl(struct dentry *dentry, const char *name, | |||
262 | if (strcmp(name, "") != 0) | 262 | if (strcmp(name, "") != 0) |
263 | return -EINVAL; | 263 | return -EINVAL; |
264 | 264 | ||
265 | v9ses = v9fs_inode2v9ses(dentry->d_inode); | 265 | v9ses = v9fs_dentry2v9ses(dentry); |
266 | /* | 266 | /* |
267 | * We allow set/get/list of acl when access=client is not specified | 267 | * We allow set/get/list of acl when access=client is not specified |
268 | */ | 268 | */ |
@@ -312,7 +312,7 @@ static int v9fs_xattr_set_acl(struct dentry *dentry, const char *name, | |||
312 | if (strcmp(name, "") != 0) | 312 | if (strcmp(name, "") != 0) |
313 | return -EINVAL; | 313 | return -EINVAL; |
314 | 314 | ||
315 | v9ses = v9fs_inode2v9ses(dentry->d_inode); | 315 | v9ses = v9fs_dentry2v9ses(dentry); |
316 | /* | 316 | /* |
317 | * set the attribute on the remote. Without even looking at the | 317 | * set the attribute on the remote. Without even looking at the |
318 | * xattr value. We leave it to the server to validate | 318 | * xattr value. We leave it to the server to validate |
@@ -323,7 +323,7 @@ static int v9fs_xattr_set_acl(struct dentry *dentry, const char *name, | |||
323 | 323 | ||
324 | if (S_ISLNK(inode->i_mode)) | 324 | if (S_ISLNK(inode->i_mode)) |
325 | return -EOPNOTSUPP; | 325 | return -EOPNOTSUPP; |
326 | if (!is_owner_or_cap(inode)) | 326 | if (!inode_owner_or_capable(inode)) |
327 | return -EPERM; | 327 | return -EPERM; |
328 | if (value) { | 328 | if (value) { |
329 | /* update the cached acl value */ | 329 | /* update the cached acl value */ |
diff --git a/fs/9p/fid.c b/fs/9p/fid.c index cd63e002d826..0ee594569dcc 100644 --- a/fs/9p/fid.c +++ b/fs/9p/fid.c | |||
@@ -134,7 +134,7 @@ static struct p9_fid *v9fs_fid_lookup_with_uid(struct dentry *dentry, | |||
134 | struct v9fs_session_info *v9ses; | 134 | struct v9fs_session_info *v9ses; |
135 | struct p9_fid *fid, *old_fid = NULL; | 135 | struct p9_fid *fid, *old_fid = NULL; |
136 | 136 | ||
137 | v9ses = v9fs_inode2v9ses(dentry->d_inode); | 137 | v9ses = v9fs_dentry2v9ses(dentry); |
138 | access = v9ses->flags & V9FS_ACCESS_MASK; | 138 | access = v9ses->flags & V9FS_ACCESS_MASK; |
139 | fid = v9fs_fid_find(dentry, uid, any); | 139 | fid = v9fs_fid_find(dentry, uid, any); |
140 | if (fid) | 140 | if (fid) |
@@ -237,7 +237,7 @@ struct p9_fid *v9fs_fid_lookup(struct dentry *dentry) | |||
237 | int any, access; | 237 | int any, access; |
238 | struct v9fs_session_info *v9ses; | 238 | struct v9fs_session_info *v9ses; |
239 | 239 | ||
240 | v9ses = v9fs_inode2v9ses(dentry->d_inode); | 240 | v9ses = v9fs_dentry2v9ses(dentry); |
241 | access = v9ses->flags & V9FS_ACCESS_MASK; | 241 | access = v9ses->flags & V9FS_ACCESS_MASK; |
242 | switch (access) { | 242 | switch (access) { |
243 | case V9FS_ACCESS_SINGLE: | 243 | case V9FS_ACCESS_SINGLE: |
@@ -286,9 +286,11 @@ static struct p9_fid *v9fs_fid_clone_with_uid(struct dentry *dentry, uid_t uid) | |||
286 | 286 | ||
287 | struct p9_fid *v9fs_writeback_fid(struct dentry *dentry) | 287 | struct p9_fid *v9fs_writeback_fid(struct dentry *dentry) |
288 | { | 288 | { |
289 | int err; | 289 | int err, flags; |
290 | struct p9_fid *fid; | 290 | struct p9_fid *fid; |
291 | struct v9fs_session_info *v9ses; | ||
291 | 292 | ||
293 | v9ses = v9fs_dentry2v9ses(dentry); | ||
292 | fid = v9fs_fid_clone_with_uid(dentry, 0); | 294 | fid = v9fs_fid_clone_with_uid(dentry, 0); |
293 | if (IS_ERR(fid)) | 295 | if (IS_ERR(fid)) |
294 | goto error_out; | 296 | goto error_out; |
@@ -297,8 +299,17 @@ struct p9_fid *v9fs_writeback_fid(struct dentry *dentry) | |||
297 | * dirty pages. We always request for the open fid in read-write | 299 | * dirty pages. We always request for the open fid in read-write |
298 | * mode so that a partial page write which result in page | 300 | * mode so that a partial page write which result in page |
299 | * read can work. | 301 | * read can work. |
302 | * | ||
303 | * we don't have a tsyncfs operation for older version | ||
304 | * of protocol. So make sure the write back fid is | ||
305 | * opened in O_SYNC mode. | ||
300 | */ | 306 | */ |
301 | err = p9_client_open(fid, O_RDWR); | 307 | if (!v9fs_proto_dotl(v9ses)) |
308 | flags = O_RDWR | O_SYNC; | ||
309 | else | ||
310 | flags = O_RDWR; | ||
311 | |||
312 | err = p9_client_open(fid, flags); | ||
302 | if (err < 0) { | 313 | if (err < 0) { |
303 | p9_client_clunk(fid); | 314 | p9_client_clunk(fid); |
304 | fid = ERR_PTR(err); | 315 | fid = ERR_PTR(err); |
diff --git a/fs/9p/v9fs.h b/fs/9p/v9fs.h index bd8496db135b..9665c2b840e6 100644 --- a/fs/9p/v9fs.h +++ b/fs/9p/v9fs.h | |||
@@ -130,6 +130,7 @@ struct v9fs_inode { | |||
130 | #endif | 130 | #endif |
131 | unsigned int cache_validity; | 131 | unsigned int cache_validity; |
132 | struct p9_fid *writeback_fid; | 132 | struct p9_fid *writeback_fid; |
133 | struct mutex v_mutex; | ||
133 | struct inode vfs_inode; | 134 | struct inode vfs_inode; |
134 | }; | 135 | }; |
135 | 136 | ||
@@ -173,6 +174,11 @@ static inline struct v9fs_session_info *v9fs_inode2v9ses(struct inode *inode) | |||
173 | return (inode->i_sb->s_fs_info); | 174 | return (inode->i_sb->s_fs_info); |
174 | } | 175 | } |
175 | 176 | ||
177 | static inline struct v9fs_session_info *v9fs_dentry2v9ses(struct dentry *dentry) | ||
178 | { | ||
179 | return dentry->d_sb->s_fs_info; | ||
180 | } | ||
181 | |||
176 | static inline int v9fs_proto_dotu(struct v9fs_session_info *v9ses) | 182 | static inline int v9fs_proto_dotu(struct v9fs_session_info *v9ses) |
177 | { | 183 | { |
178 | return v9ses->flags & V9FS_PROTO_2000U; | 184 | return v9ses->flags & V9FS_PROTO_2000U; |
diff --git a/fs/9p/vfs_file.c b/fs/9p/vfs_file.c index 78bcb97c3425..ffed55817f0c 100644 --- a/fs/9p/vfs_file.c +++ b/fs/9p/vfs_file.c | |||
@@ -90,7 +90,9 @@ int v9fs_file_open(struct inode *inode, struct file *file) | |||
90 | } | 90 | } |
91 | 91 | ||
92 | file->private_data = fid; | 92 | file->private_data = fid; |
93 | if (v9ses->cache && !v9inode->writeback_fid) { | 93 | mutex_lock(&v9inode->v_mutex); |
94 | if (v9ses->cache && !v9inode->writeback_fid && | ||
95 | ((file->f_flags & O_ACCMODE) != O_RDONLY)) { | ||
94 | /* | 96 | /* |
95 | * clone a fid and add it to writeback_fid | 97 | * clone a fid and add it to writeback_fid |
96 | * we do it during open time instead of | 98 | * we do it during open time instead of |
@@ -101,10 +103,12 @@ int v9fs_file_open(struct inode *inode, struct file *file) | |||
101 | fid = v9fs_writeback_fid(file->f_path.dentry); | 103 | fid = v9fs_writeback_fid(file->f_path.dentry); |
102 | if (IS_ERR(fid)) { | 104 | if (IS_ERR(fid)) { |
103 | err = PTR_ERR(fid); | 105 | err = PTR_ERR(fid); |
106 | mutex_unlock(&v9inode->v_mutex); | ||
104 | goto out_error; | 107 | goto out_error; |
105 | } | 108 | } |
106 | v9inode->writeback_fid = (void *) fid; | 109 | v9inode->writeback_fid = (void *) fid; |
107 | } | 110 | } |
111 | mutex_unlock(&v9inode->v_mutex); | ||
108 | #ifdef CONFIG_9P_FSCACHE | 112 | #ifdef CONFIG_9P_FSCACHE |
109 | if (v9ses->cache) | 113 | if (v9ses->cache) |
110 | v9fs_cache_inode_set_cookie(inode, file); | 114 | v9fs_cache_inode_set_cookie(inode, file); |
@@ -504,9 +508,12 @@ v9fs_file_write(struct file *filp, const char __user * data, | |||
504 | if (!count) | 508 | if (!count) |
505 | goto out; | 509 | goto out; |
506 | 510 | ||
507 | return v9fs_file_write_internal(filp->f_path.dentry->d_inode, | 511 | retval = v9fs_file_write_internal(filp->f_path.dentry->d_inode, |
508 | filp->private_data, | 512 | filp->private_data, |
509 | data, count, offset, 1); | 513 | data, count, &origin, 1); |
514 | /* update offset on successful write */ | ||
515 | if (retval > 0) | ||
516 | *offset = origin; | ||
510 | out: | 517 | out: |
511 | return retval; | 518 | return retval; |
512 | } | 519 | } |
diff --git a/fs/9p/vfs_inode.c b/fs/9p/vfs_inode.c index 8a2c232f708a..7f6c67703195 100644 --- a/fs/9p/vfs_inode.c +++ b/fs/9p/vfs_inode.c | |||
@@ -221,6 +221,7 @@ struct inode *v9fs_alloc_inode(struct super_block *sb) | |||
221 | #endif | 221 | #endif |
222 | v9inode->writeback_fid = NULL; | 222 | v9inode->writeback_fid = NULL; |
223 | v9inode->cache_validity = 0; | 223 | v9inode->cache_validity = 0; |
224 | mutex_init(&v9inode->v_mutex); | ||
224 | return &v9inode->vfs_inode; | 225 | return &v9inode->vfs_inode; |
225 | } | 226 | } |
226 | 227 | ||
@@ -650,7 +651,9 @@ v9fs_vfs_create(struct inode *dir, struct dentry *dentry, int mode, | |||
650 | /* if we are opening a file, assign the open fid to the file */ | 651 | /* if we are opening a file, assign the open fid to the file */ |
651 | if (nd && nd->flags & LOOKUP_OPEN) { | 652 | if (nd && nd->flags & LOOKUP_OPEN) { |
652 | v9inode = V9FS_I(dentry->d_inode); | 653 | v9inode = V9FS_I(dentry->d_inode); |
653 | if (v9ses->cache && !v9inode->writeback_fid) { | 654 | mutex_lock(&v9inode->v_mutex); |
655 | if (v9ses->cache && !v9inode->writeback_fid && | ||
656 | ((flags & O_ACCMODE) != O_RDONLY)) { | ||
654 | /* | 657 | /* |
655 | * clone a fid and add it to writeback_fid | 658 | * clone a fid and add it to writeback_fid |
656 | * we do it during open time instead of | 659 | * we do it during open time instead of |
@@ -661,10 +664,12 @@ v9fs_vfs_create(struct inode *dir, struct dentry *dentry, int mode, | |||
661 | inode_fid = v9fs_writeback_fid(dentry); | 664 | inode_fid = v9fs_writeback_fid(dentry); |
662 | if (IS_ERR(inode_fid)) { | 665 | if (IS_ERR(inode_fid)) { |
663 | err = PTR_ERR(inode_fid); | 666 | err = PTR_ERR(inode_fid); |
667 | mutex_unlock(&v9inode->v_mutex); | ||
664 | goto error; | 668 | goto error; |
665 | } | 669 | } |
666 | v9inode->writeback_fid = (void *) inode_fid; | 670 | v9inode->writeback_fid = (void *) inode_fid; |
667 | } | 671 | } |
672 | mutex_unlock(&v9inode->v_mutex); | ||
668 | filp = lookup_instantiate_filp(nd, dentry, generic_file_open); | 673 | filp = lookup_instantiate_filp(nd, dentry, generic_file_open); |
669 | if (IS_ERR(filp)) { | 674 | if (IS_ERR(filp)) { |
670 | err = PTR_ERR(filp); | 675 | err = PTR_ERR(filp); |
@@ -931,7 +936,7 @@ v9fs_vfs_getattr(struct vfsmount *mnt, struct dentry *dentry, | |||
931 | 936 | ||
932 | P9_DPRINTK(P9_DEBUG_VFS, "dentry: %p\n", dentry); | 937 | P9_DPRINTK(P9_DEBUG_VFS, "dentry: %p\n", dentry); |
933 | err = -EPERM; | 938 | err = -EPERM; |
934 | v9ses = v9fs_inode2v9ses(dentry->d_inode); | 939 | v9ses = v9fs_dentry2v9ses(dentry); |
935 | if (v9ses->cache == CACHE_LOOSE || v9ses->cache == CACHE_FSCACHE) { | 940 | if (v9ses->cache == CACHE_LOOSE || v9ses->cache == CACHE_FSCACHE) { |
936 | generic_fillattr(dentry->d_inode, stat); | 941 | generic_fillattr(dentry->d_inode, stat); |
937 | return 0; | 942 | return 0; |
@@ -967,8 +972,12 @@ static int v9fs_vfs_setattr(struct dentry *dentry, struct iattr *iattr) | |||
967 | struct p9_wstat wstat; | 972 | struct p9_wstat wstat; |
968 | 973 | ||
969 | P9_DPRINTK(P9_DEBUG_VFS, "\n"); | 974 | P9_DPRINTK(P9_DEBUG_VFS, "\n"); |
975 | retval = inode_change_ok(dentry->d_inode, iattr); | ||
976 | if (retval) | ||
977 | return retval; | ||
978 | |||
970 | retval = -EPERM; | 979 | retval = -EPERM; |
971 | v9ses = v9fs_inode2v9ses(dentry->d_inode); | 980 | v9ses = v9fs_dentry2v9ses(dentry); |
972 | fid = v9fs_fid_lookup(dentry); | 981 | fid = v9fs_fid_lookup(dentry); |
973 | if(IS_ERR(fid)) | 982 | if(IS_ERR(fid)) |
974 | return PTR_ERR(fid); | 983 | return PTR_ERR(fid); |
@@ -993,12 +1002,7 @@ static int v9fs_vfs_setattr(struct dentry *dentry, struct iattr *iattr) | |||
993 | if (iattr->ia_valid & ATTR_GID) | 1002 | if (iattr->ia_valid & ATTR_GID) |
994 | wstat.n_gid = iattr->ia_gid; | 1003 | wstat.n_gid = iattr->ia_gid; |
995 | } | 1004 | } |
996 | if ((iattr->ia_valid & ATTR_SIZE) && | 1005 | |
997 | iattr->ia_size != i_size_read(dentry->d_inode)) { | ||
998 | retval = vmtruncate(dentry->d_inode, iattr->ia_size); | ||
999 | if (retval) | ||
1000 | return retval; | ||
1001 | } | ||
1002 | /* Write all dirty data */ | 1006 | /* Write all dirty data */ |
1003 | if (S_ISREG(dentry->d_inode->i_mode)) | 1007 | if (S_ISREG(dentry->d_inode->i_mode)) |
1004 | filemap_write_and_wait(dentry->d_inode->i_mapping); | 1008 | filemap_write_and_wait(dentry->d_inode->i_mapping); |
@@ -1006,6 +1010,11 @@ static int v9fs_vfs_setattr(struct dentry *dentry, struct iattr *iattr) | |||
1006 | retval = p9_client_wstat(fid, &wstat); | 1010 | retval = p9_client_wstat(fid, &wstat); |
1007 | if (retval < 0) | 1011 | if (retval < 0) |
1008 | return retval; | 1012 | return retval; |
1013 | |||
1014 | if ((iattr->ia_valid & ATTR_SIZE) && | ||
1015 | iattr->ia_size != i_size_read(dentry->d_inode)) | ||
1016 | truncate_setsize(dentry->d_inode, iattr->ia_size); | ||
1017 | |||
1009 | v9fs_invalidate_inode_attr(dentry->d_inode); | 1018 | v9fs_invalidate_inode_attr(dentry->d_inode); |
1010 | 1019 | ||
1011 | setattr_copy(dentry->d_inode, iattr); | 1020 | setattr_copy(dentry->d_inode, iattr); |
@@ -1130,7 +1139,7 @@ static int v9fs_readlink(struct dentry *dentry, char *buffer, int buflen) | |||
1130 | 1139 | ||
1131 | P9_DPRINTK(P9_DEBUG_VFS, " %s\n", dentry->d_name.name); | 1140 | P9_DPRINTK(P9_DEBUG_VFS, " %s\n", dentry->d_name.name); |
1132 | retval = -EPERM; | 1141 | retval = -EPERM; |
1133 | v9ses = v9fs_inode2v9ses(dentry->d_inode); | 1142 | v9ses = v9fs_dentry2v9ses(dentry); |
1134 | fid = v9fs_fid_lookup(dentry); | 1143 | fid = v9fs_fid_lookup(dentry); |
1135 | if (IS_ERR(fid)) | 1144 | if (IS_ERR(fid)) |
1136 | return PTR_ERR(fid); | 1145 | return PTR_ERR(fid); |
diff --git a/fs/9p/vfs_inode_dotl.c b/fs/9p/vfs_inode_dotl.c index 67c138e94feb..ffbb113d5f33 100644 --- a/fs/9p/vfs_inode_dotl.c +++ b/fs/9p/vfs_inode_dotl.c | |||
@@ -245,7 +245,9 @@ v9fs_vfs_create_dotl(struct inode *dir, struct dentry *dentry, int omode, | |||
245 | v9fs_set_create_acl(dentry, dacl, pacl); | 245 | v9fs_set_create_acl(dentry, dacl, pacl); |
246 | 246 | ||
247 | v9inode = V9FS_I(inode); | 247 | v9inode = V9FS_I(inode); |
248 | if (v9ses->cache && !v9inode->writeback_fid) { | 248 | mutex_lock(&v9inode->v_mutex); |
249 | if (v9ses->cache && !v9inode->writeback_fid && | ||
250 | ((flags & O_ACCMODE) != O_RDONLY)) { | ||
249 | /* | 251 | /* |
250 | * clone a fid and add it to writeback_fid | 252 | * clone a fid and add it to writeback_fid |
251 | * we do it during open time instead of | 253 | * we do it during open time instead of |
@@ -256,10 +258,12 @@ v9fs_vfs_create_dotl(struct inode *dir, struct dentry *dentry, int omode, | |||
256 | inode_fid = v9fs_writeback_fid(dentry); | 258 | inode_fid = v9fs_writeback_fid(dentry); |
257 | if (IS_ERR(inode_fid)) { | 259 | if (IS_ERR(inode_fid)) { |
258 | err = PTR_ERR(inode_fid); | 260 | err = PTR_ERR(inode_fid); |
261 | mutex_unlock(&v9inode->v_mutex); | ||
259 | goto error; | 262 | goto error; |
260 | } | 263 | } |
261 | v9inode->writeback_fid = (void *) inode_fid; | 264 | v9inode->writeback_fid = (void *) inode_fid; |
262 | } | 265 | } |
266 | mutex_unlock(&v9inode->v_mutex); | ||
263 | /* Since we are opening a file, assign the open fid to the file */ | 267 | /* Since we are opening a file, assign the open fid to the file */ |
264 | filp = lookup_instantiate_filp(nd, dentry, generic_file_open); | 268 | filp = lookup_instantiate_filp(nd, dentry, generic_file_open); |
265 | if (IS_ERR(filp)) { | 269 | if (IS_ERR(filp)) { |
@@ -391,7 +395,7 @@ v9fs_vfs_getattr_dotl(struct vfsmount *mnt, struct dentry *dentry, | |||
391 | 395 | ||
392 | P9_DPRINTK(P9_DEBUG_VFS, "dentry: %p\n", dentry); | 396 | P9_DPRINTK(P9_DEBUG_VFS, "dentry: %p\n", dentry); |
393 | err = -EPERM; | 397 | err = -EPERM; |
394 | v9ses = v9fs_inode2v9ses(dentry->d_inode); | 398 | v9ses = v9fs_dentry2v9ses(dentry); |
395 | if (v9ses->cache == CACHE_LOOSE || v9ses->cache == CACHE_FSCACHE) { | 399 | if (v9ses->cache == CACHE_LOOSE || v9ses->cache == CACHE_FSCACHE) { |
396 | generic_fillattr(dentry->d_inode, stat); | 400 | generic_fillattr(dentry->d_inode, stat); |
397 | return 0; | 401 | return 0; |
@@ -448,17 +452,11 @@ int v9fs_vfs_setattr_dotl(struct dentry *dentry, struct iattr *iattr) | |||
448 | p9attr.mtime_nsec = iattr->ia_mtime.tv_nsec; | 452 | p9attr.mtime_nsec = iattr->ia_mtime.tv_nsec; |
449 | 453 | ||
450 | retval = -EPERM; | 454 | retval = -EPERM; |
451 | v9ses = v9fs_inode2v9ses(dentry->d_inode); | 455 | v9ses = v9fs_dentry2v9ses(dentry); |
452 | fid = v9fs_fid_lookup(dentry); | 456 | fid = v9fs_fid_lookup(dentry); |
453 | if (IS_ERR(fid)) | 457 | if (IS_ERR(fid)) |
454 | return PTR_ERR(fid); | 458 | return PTR_ERR(fid); |
455 | 459 | ||
456 | if ((iattr->ia_valid & ATTR_SIZE) && | ||
457 | iattr->ia_size != i_size_read(dentry->d_inode)) { | ||
458 | retval = vmtruncate(dentry->d_inode, iattr->ia_size); | ||
459 | if (retval) | ||
460 | return retval; | ||
461 | } | ||
462 | /* Write all dirty data */ | 460 | /* Write all dirty data */ |
463 | if (S_ISREG(dentry->d_inode->i_mode)) | 461 | if (S_ISREG(dentry->d_inode->i_mode)) |
464 | filemap_write_and_wait(dentry->d_inode->i_mapping); | 462 | filemap_write_and_wait(dentry->d_inode->i_mapping); |
@@ -466,8 +464,12 @@ int v9fs_vfs_setattr_dotl(struct dentry *dentry, struct iattr *iattr) | |||
466 | retval = p9_client_setattr(fid, &p9attr); | 464 | retval = p9_client_setattr(fid, &p9attr); |
467 | if (retval < 0) | 465 | if (retval < 0) |
468 | return retval; | 466 | return retval; |
469 | v9fs_invalidate_inode_attr(dentry->d_inode); | ||
470 | 467 | ||
468 | if ((iattr->ia_valid & ATTR_SIZE) && | ||
469 | iattr->ia_size != i_size_read(dentry->d_inode)) | ||
470 | truncate_setsize(dentry->d_inode, iattr->ia_size); | ||
471 | |||
472 | v9fs_invalidate_inode_attr(dentry->d_inode); | ||
471 | setattr_copy(dentry->d_inode, iattr); | 473 | setattr_copy(dentry->d_inode, iattr); |
472 | mark_inode_dirty(dentry->d_inode); | 474 | mark_inode_dirty(dentry->d_inode); |
473 | if (iattr->ia_valid & ATTR_MODE) { | 475 | if (iattr->ia_valid & ATTR_MODE) { |
diff --git a/fs/9p/vfs_super.c b/fs/9p/vfs_super.c index 09fd08d1606f..f3eed3383e4f 100644 --- a/fs/9p/vfs_super.c +++ b/fs/9p/vfs_super.c | |||
@@ -262,7 +262,7 @@ static int v9fs_statfs(struct dentry *dentry, struct kstatfs *buf) | |||
262 | goto done; | 262 | goto done; |
263 | } | 263 | } |
264 | 264 | ||
265 | v9ses = v9fs_inode2v9ses(dentry->d_inode); | 265 | v9ses = v9fs_dentry2v9ses(dentry); |
266 | if (v9fs_proto_dotl(v9ses)) { | 266 | if (v9fs_proto_dotl(v9ses)) { |
267 | res = p9_client_statfs(fid, &rs); | 267 | res = p9_client_statfs(fid, &rs); |
268 | if (res == 0) { | 268 | if (res == 0) { |
diff --git a/fs/adfs/adfs.h b/fs/adfs/adfs.h index 2ff622f6f547..718ac1f440c6 100644 --- a/fs/adfs/adfs.h +++ b/fs/adfs/adfs.h | |||
@@ -50,6 +50,7 @@ struct adfs_sb_info { | |||
50 | gid_t s_gid; /* owner gid */ | 50 | gid_t s_gid; /* owner gid */ |
51 | umode_t s_owner_mask; /* ADFS owner perm -> unix perm */ | 51 | umode_t s_owner_mask; /* ADFS owner perm -> unix perm */ |
52 | umode_t s_other_mask; /* ADFS other perm -> unix perm */ | 52 | umode_t s_other_mask; /* ADFS other perm -> unix perm */ |
53 | int s_ftsuffix; /* ,xyz hex filetype suffix option */ | ||
53 | 54 | ||
54 | __u32 s_ids_per_zone; /* max. no ids in one zone */ | 55 | __u32 s_ids_per_zone; /* max. no ids in one zone */ |
55 | __u32 s_idlen; /* length of ID in map */ | 56 | __u32 s_idlen; /* length of ID in map */ |
@@ -79,6 +80,10 @@ struct adfs_dir { | |||
79 | 80 | ||
80 | int nr_buffers; | 81 | int nr_buffers; |
81 | struct buffer_head *bh[4]; | 82 | struct buffer_head *bh[4]; |
83 | |||
84 | /* big directories need allocated buffers */ | ||
85 | struct buffer_head **bh_fplus; | ||
86 | |||
82 | unsigned int pos; | 87 | unsigned int pos; |
83 | unsigned int parent_id; | 88 | unsigned int parent_id; |
84 | 89 | ||
@@ -89,7 +94,7 @@ struct adfs_dir { | |||
89 | /* | 94 | /* |
90 | * This is the overall maximum name length | 95 | * This is the overall maximum name length |
91 | */ | 96 | */ |
92 | #define ADFS_MAX_NAME_LEN 256 | 97 | #define ADFS_MAX_NAME_LEN (256 + 4) /* +4 for ,xyz hex filetype suffix */ |
93 | struct object_info { | 98 | struct object_info { |
94 | __u32 parent_id; /* parent object id */ | 99 | __u32 parent_id; /* parent object id */ |
95 | __u32 file_id; /* object id */ | 100 | __u32 file_id; /* object id */ |
@@ -97,10 +102,26 @@ struct object_info { | |||
97 | __u32 execaddr; /* execution address */ | 102 | __u32 execaddr; /* execution address */ |
98 | __u32 size; /* size */ | 103 | __u32 size; /* size */ |
99 | __u8 attr; /* RISC OS attributes */ | 104 | __u8 attr; /* RISC OS attributes */ |
100 | unsigned char name_len; /* name length */ | 105 | unsigned int name_len; /* name length */ |
101 | char name[ADFS_MAX_NAME_LEN];/* file name */ | 106 | char name[ADFS_MAX_NAME_LEN];/* file name */ |
107 | |||
108 | /* RISC OS file type (12-bit: derived from loadaddr) */ | ||
109 | __u16 filetype; | ||
102 | }; | 110 | }; |
103 | 111 | ||
112 | /* RISC OS 12-bit filetype converts to ,xyz hex filename suffix */ | ||
113 | static inline int append_filetype_suffix(char *buf, __u16 filetype) | ||
114 | { | ||
115 | if (filetype == 0xffff) /* no explicit 12-bit file type was set */ | ||
116 | return 0; | ||
117 | |||
118 | *buf++ = ','; | ||
119 | *buf++ = hex_asc_lo(filetype >> 8); | ||
120 | *buf++ = hex_asc_lo(filetype >> 4); | ||
121 | *buf++ = hex_asc_lo(filetype >> 0); | ||
122 | return 4; | ||
123 | } | ||
124 | |||
104 | struct adfs_dir_ops { | 125 | struct adfs_dir_ops { |
105 | int (*read)(struct super_block *sb, unsigned int id, unsigned int sz, struct adfs_dir *dir); | 126 | int (*read)(struct super_block *sb, unsigned int id, unsigned int sz, struct adfs_dir *dir); |
106 | int (*setpos)(struct adfs_dir *dir, unsigned int fpos); | 127 | int (*setpos)(struct adfs_dir *dir, unsigned int fpos); |
diff --git a/fs/adfs/dir_f.c b/fs/adfs/dir_f.c index bafc71222e25..4bbe853ee50a 100644 --- a/fs/adfs/dir_f.c +++ b/fs/adfs/dir_f.c | |||
@@ -52,7 +52,6 @@ static inline int adfs_readname(char *buf, char *ptr, int maxlen) | |||
52 | *buf++ = *ptr; | 52 | *buf++ = *ptr; |
53 | ptr++; | 53 | ptr++; |
54 | } | 54 | } |
55 | *buf = '\0'; | ||
56 | 55 | ||
57 | return buf - old_buf; | 56 | return buf - old_buf; |
58 | } | 57 | } |
@@ -208,7 +207,8 @@ release_buffers: | |||
208 | * convert a disk-based directory entry to a Linux ADFS directory entry | 207 | * convert a disk-based directory entry to a Linux ADFS directory entry |
209 | */ | 208 | */ |
210 | static inline void | 209 | static inline void |
211 | adfs_dir2obj(struct object_info *obj, struct adfs_direntry *de) | 210 | adfs_dir2obj(struct adfs_dir *dir, struct object_info *obj, |
211 | struct adfs_direntry *de) | ||
212 | { | 212 | { |
213 | obj->name_len = adfs_readname(obj->name, de->dirobname, ADFS_F_NAME_LEN); | 213 | obj->name_len = adfs_readname(obj->name, de->dirobname, ADFS_F_NAME_LEN); |
214 | obj->file_id = adfs_readval(de->dirinddiscadd, 3); | 214 | obj->file_id = adfs_readval(de->dirinddiscadd, 3); |
@@ -216,6 +216,23 @@ adfs_dir2obj(struct object_info *obj, struct adfs_direntry *de) | |||
216 | obj->execaddr = adfs_readval(de->direxec, 4); | 216 | obj->execaddr = adfs_readval(de->direxec, 4); |
217 | obj->size = adfs_readval(de->dirlen, 4); | 217 | obj->size = adfs_readval(de->dirlen, 4); |
218 | obj->attr = de->newdiratts; | 218 | obj->attr = de->newdiratts; |
219 | obj->filetype = -1; | ||
220 | |||
221 | /* | ||
222 | * object is a file and is filetyped and timestamped? | ||
223 | * RISC OS 12-bit filetype is stored in load_address[19:8] | ||
224 | */ | ||
225 | if ((0 == (obj->attr & ADFS_NDA_DIRECTORY)) && | ||
226 | (0xfff00000 == (0xfff00000 & obj->loadaddr))) { | ||
227 | obj->filetype = (__u16) ((0x000fff00 & obj->loadaddr) >> 8); | ||
228 | |||
229 | /* optionally append the ,xyz hex filetype suffix */ | ||
230 | if (ADFS_SB(dir->sb)->s_ftsuffix) | ||
231 | obj->name_len += | ||
232 | append_filetype_suffix( | ||
233 | &obj->name[obj->name_len], | ||
234 | obj->filetype); | ||
235 | } | ||
219 | } | 236 | } |
220 | 237 | ||
221 | /* | 238 | /* |
@@ -260,7 +277,7 @@ __adfs_dir_get(struct adfs_dir *dir, int pos, struct object_info *obj) | |||
260 | if (!de.dirobname[0]) | 277 | if (!de.dirobname[0]) |
261 | return -ENOENT; | 278 | return -ENOENT; |
262 | 279 | ||
263 | adfs_dir2obj(obj, &de); | 280 | adfs_dir2obj(dir, obj, &de); |
264 | 281 | ||
265 | return 0; | 282 | return 0; |
266 | } | 283 | } |
diff --git a/fs/adfs/dir_fplus.c b/fs/adfs/dir_fplus.c index 1796bb352d05..d9e3bee4e653 100644 --- a/fs/adfs/dir_fplus.c +++ b/fs/adfs/dir_fplus.c | |||
@@ -8,6 +8,7 @@ | |||
8 | * published by the Free Software Foundation. | 8 | * published by the Free Software Foundation. |
9 | */ | 9 | */ |
10 | #include <linux/buffer_head.h> | 10 | #include <linux/buffer_head.h> |
11 | #include <linux/slab.h> | ||
11 | #include "adfs.h" | 12 | #include "adfs.h" |
12 | #include "dir_fplus.h" | 13 | #include "dir_fplus.h" |
13 | 14 | ||
@@ -22,30 +23,53 @@ adfs_fplus_read(struct super_block *sb, unsigned int id, unsigned int sz, struct | |||
22 | 23 | ||
23 | dir->nr_buffers = 0; | 24 | dir->nr_buffers = 0; |
24 | 25 | ||
26 | /* start off using fixed bh set - only alloc for big dirs */ | ||
27 | dir->bh_fplus = &dir->bh[0]; | ||
28 | |||
25 | block = __adfs_block_map(sb, id, 0); | 29 | block = __adfs_block_map(sb, id, 0); |
26 | if (!block) { | 30 | if (!block) { |
27 | adfs_error(sb, "dir object %X has a hole at offset 0", id); | 31 | adfs_error(sb, "dir object %X has a hole at offset 0", id); |
28 | goto out; | 32 | goto out; |
29 | } | 33 | } |
30 | 34 | ||
31 | dir->bh[0] = sb_bread(sb, block); | 35 | dir->bh_fplus[0] = sb_bread(sb, block); |
32 | if (!dir->bh[0]) | 36 | if (!dir->bh_fplus[0]) |
33 | goto out; | 37 | goto out; |
34 | dir->nr_buffers += 1; | 38 | dir->nr_buffers += 1; |
35 | 39 | ||
36 | h = (struct adfs_bigdirheader *)dir->bh[0]->b_data; | 40 | h = (struct adfs_bigdirheader *)dir->bh_fplus[0]->b_data; |
37 | size = le32_to_cpu(h->bigdirsize); | 41 | size = le32_to_cpu(h->bigdirsize); |
38 | if (size != sz) { | 42 | if (size != sz) { |
39 | printk(KERN_WARNING "adfs: adfs_fplus_read: directory header size\n" | 43 | printk(KERN_WARNING "adfs: adfs_fplus_read:" |
40 | " does not match directory size\n"); | 44 | " directory header size %X\n" |
45 | " does not match directory size %X\n", | ||
46 | size, sz); | ||
41 | } | 47 | } |
42 | 48 | ||
43 | if (h->bigdirversion[0] != 0 || h->bigdirversion[1] != 0 || | 49 | if (h->bigdirversion[0] != 0 || h->bigdirversion[1] != 0 || |
44 | h->bigdirversion[2] != 0 || size & 2047 || | 50 | h->bigdirversion[2] != 0 || size & 2047 || |
45 | h->bigdirstartname != cpu_to_le32(BIGDIRSTARTNAME)) | 51 | h->bigdirstartname != cpu_to_le32(BIGDIRSTARTNAME)) { |
52 | printk(KERN_WARNING "adfs: dir object %X has" | ||
53 | " malformed dir header\n", id); | ||
46 | goto out; | 54 | goto out; |
55 | } | ||
47 | 56 | ||
48 | size >>= sb->s_blocksize_bits; | 57 | size >>= sb->s_blocksize_bits; |
58 | if (size > sizeof(dir->bh)/sizeof(dir->bh[0])) { | ||
59 | /* this directory is too big for fixed bh set, must allocate */ | ||
60 | struct buffer_head **bh_fplus = | ||
61 | kzalloc(size * sizeof(struct buffer_head *), | ||
62 | GFP_KERNEL); | ||
63 | if (!bh_fplus) { | ||
64 | adfs_error(sb, "not enough memory for" | ||
65 | " dir object %X (%d blocks)", id, size); | ||
66 | goto out; | ||
67 | } | ||
68 | dir->bh_fplus = bh_fplus; | ||
69 | /* copy over the pointer to the block that we've already read */ | ||
70 | dir->bh_fplus[0] = dir->bh[0]; | ||
71 | } | ||
72 | |||
49 | for (blk = 1; blk < size; blk++) { | 73 | for (blk = 1; blk < size; blk++) { |
50 | block = __adfs_block_map(sb, id, blk); | 74 | block = __adfs_block_map(sb, id, blk); |
51 | if (!block) { | 75 | if (!block) { |
@@ -53,25 +77,44 @@ adfs_fplus_read(struct super_block *sb, unsigned int id, unsigned int sz, struct | |||
53 | goto out; | 77 | goto out; |
54 | } | 78 | } |
55 | 79 | ||
56 | dir->bh[blk] = sb_bread(sb, block); | 80 | dir->bh_fplus[blk] = sb_bread(sb, block); |
57 | if (!dir->bh[blk]) | 81 | if (!dir->bh_fplus[blk]) { |
82 | adfs_error(sb, "dir object %X failed read for" | ||
83 | " offset %d, mapped block %X", | ||
84 | id, blk, block); | ||
58 | goto out; | 85 | goto out; |
59 | dir->nr_buffers = blk; | 86 | } |
87 | |||
88 | dir->nr_buffers += 1; | ||
60 | } | 89 | } |
61 | 90 | ||
62 | t = (struct adfs_bigdirtail *)(dir->bh[size - 1]->b_data + (sb->s_blocksize - 8)); | 91 | t = (struct adfs_bigdirtail *) |
92 | (dir->bh_fplus[size - 1]->b_data + (sb->s_blocksize - 8)); | ||
63 | 93 | ||
64 | if (t->bigdirendname != cpu_to_le32(BIGDIRENDNAME) || | 94 | if (t->bigdirendname != cpu_to_le32(BIGDIRENDNAME) || |
65 | t->bigdirendmasseq != h->startmasseq || | 95 | t->bigdirendmasseq != h->startmasseq || |
66 | t->reserved[0] != 0 || t->reserved[1] != 0) | 96 | t->reserved[0] != 0 || t->reserved[1] != 0) { |
97 | printk(KERN_WARNING "adfs: dir object %X has " | ||
98 | "malformed dir end\n", id); | ||
67 | goto out; | 99 | goto out; |
100 | } | ||
68 | 101 | ||
69 | dir->parent_id = le32_to_cpu(h->bigdirparent); | 102 | dir->parent_id = le32_to_cpu(h->bigdirparent); |
70 | dir->sb = sb; | 103 | dir->sb = sb; |
71 | return 0; | 104 | return 0; |
105 | |||
72 | out: | 106 | out: |
73 | for (i = 0; i < dir->nr_buffers; i++) | 107 | if (dir->bh_fplus) { |
74 | brelse(dir->bh[i]); | 108 | for (i = 0; i < dir->nr_buffers; i++) |
109 | brelse(dir->bh_fplus[i]); | ||
110 | |||
111 | if (&dir->bh[0] != dir->bh_fplus) | ||
112 | kfree(dir->bh_fplus); | ||
113 | |||
114 | dir->bh_fplus = NULL; | ||
115 | } | ||
116 | |||
117 | dir->nr_buffers = 0; | ||
75 | dir->sb = NULL; | 118 | dir->sb = NULL; |
76 | return ret; | 119 | return ret; |
77 | } | 120 | } |
@@ -79,7 +122,8 @@ out: | |||
79 | static int | 122 | static int |
80 | adfs_fplus_setpos(struct adfs_dir *dir, unsigned int fpos) | 123 | adfs_fplus_setpos(struct adfs_dir *dir, unsigned int fpos) |
81 | { | 124 | { |
82 | struct adfs_bigdirheader *h = (struct adfs_bigdirheader *)dir->bh[0]->b_data; | 125 | struct adfs_bigdirheader *h = |
126 | (struct adfs_bigdirheader *) dir->bh_fplus[0]->b_data; | ||
83 | int ret = -ENOENT; | 127 | int ret = -ENOENT; |
84 | 128 | ||
85 | if (fpos <= le32_to_cpu(h->bigdirentries)) { | 129 | if (fpos <= le32_to_cpu(h->bigdirentries)) { |
@@ -102,21 +146,27 @@ dir_memcpy(struct adfs_dir *dir, unsigned int offset, void *to, int len) | |||
102 | partial = sb->s_blocksize - offset; | 146 | partial = sb->s_blocksize - offset; |
103 | 147 | ||
104 | if (partial >= len) | 148 | if (partial >= len) |
105 | memcpy(to, dir->bh[buffer]->b_data + offset, len); | 149 | memcpy(to, dir->bh_fplus[buffer]->b_data + offset, len); |
106 | else { | 150 | else { |
107 | char *c = (char *)to; | 151 | char *c = (char *)to; |
108 | 152 | ||
109 | remainder = len - partial; | 153 | remainder = len - partial; |
110 | 154 | ||
111 | memcpy(c, dir->bh[buffer]->b_data + offset, partial); | 155 | memcpy(c, |
112 | memcpy(c + partial, dir->bh[buffer + 1]->b_data, remainder); | 156 | dir->bh_fplus[buffer]->b_data + offset, |
157 | partial); | ||
158 | |||
159 | memcpy(c + partial, | ||
160 | dir->bh_fplus[buffer + 1]->b_data, | ||
161 | remainder); | ||
113 | } | 162 | } |
114 | } | 163 | } |
115 | 164 | ||
116 | static int | 165 | static int |
117 | adfs_fplus_getnext(struct adfs_dir *dir, struct object_info *obj) | 166 | adfs_fplus_getnext(struct adfs_dir *dir, struct object_info *obj) |
118 | { | 167 | { |
119 | struct adfs_bigdirheader *h = (struct adfs_bigdirheader *)dir->bh[0]->b_data; | 168 | struct adfs_bigdirheader *h = |
169 | (struct adfs_bigdirheader *) dir->bh_fplus[0]->b_data; | ||
120 | struct adfs_bigdirentry bde; | 170 | struct adfs_bigdirentry bde; |
121 | unsigned int offset; | 171 | unsigned int offset; |
122 | int i, ret = -ENOENT; | 172 | int i, ret = -ENOENT; |
@@ -147,6 +197,24 @@ adfs_fplus_getnext(struct adfs_dir *dir, struct object_info *obj) | |||
147 | if (obj->name[i] == '/') | 197 | if (obj->name[i] == '/') |
148 | obj->name[i] = '.'; | 198 | obj->name[i] = '.'; |
149 | 199 | ||
200 | obj->filetype = -1; | ||
201 | |||
202 | /* | ||
203 | * object is a file and is filetyped and timestamped? | ||
204 | * RISC OS 12-bit filetype is stored in load_address[19:8] | ||
205 | */ | ||
206 | if ((0 == (obj->attr & ADFS_NDA_DIRECTORY)) && | ||
207 | (0xfff00000 == (0xfff00000 & obj->loadaddr))) { | ||
208 | obj->filetype = (__u16) ((0x000fff00 & obj->loadaddr) >> 8); | ||
209 | |||
210 | /* optionally append the ,xyz hex filetype suffix */ | ||
211 | if (ADFS_SB(dir->sb)->s_ftsuffix) | ||
212 | obj->name_len += | ||
213 | append_filetype_suffix( | ||
214 | &obj->name[obj->name_len], | ||
215 | obj->filetype); | ||
216 | } | ||
217 | |||
150 | dir->pos += 1; | 218 | dir->pos += 1; |
151 | ret = 0; | 219 | ret = 0; |
152 | out: | 220 | out: |
@@ -160,7 +228,7 @@ adfs_fplus_sync(struct adfs_dir *dir) | |||
160 | int i; | 228 | int i; |
161 | 229 | ||
162 | for (i = dir->nr_buffers - 1; i >= 0; i--) { | 230 | for (i = dir->nr_buffers - 1; i >= 0; i--) { |
163 | struct buffer_head *bh = dir->bh[i]; | 231 | struct buffer_head *bh = dir->bh_fplus[i]; |
164 | sync_dirty_buffer(bh); | 232 | sync_dirty_buffer(bh); |
165 | if (buffer_req(bh) && !buffer_uptodate(bh)) | 233 | if (buffer_req(bh) && !buffer_uptodate(bh)) |
166 | err = -EIO; | 234 | err = -EIO; |
@@ -174,8 +242,17 @@ adfs_fplus_free(struct adfs_dir *dir) | |||
174 | { | 242 | { |
175 | int i; | 243 | int i; |
176 | 244 | ||
177 | for (i = 0; i < dir->nr_buffers; i++) | 245 | if (dir->bh_fplus) { |
178 | brelse(dir->bh[i]); | 246 | for (i = 0; i < dir->nr_buffers; i++) |
247 | brelse(dir->bh_fplus[i]); | ||
248 | |||
249 | if (&dir->bh[0] != dir->bh_fplus) | ||
250 | kfree(dir->bh_fplus); | ||
251 | |||
252 | dir->bh_fplus = NULL; | ||
253 | } | ||
254 | |||
255 | dir->nr_buffers = 0; | ||
179 | dir->sb = NULL; | 256 | dir->sb = NULL; |
180 | } | 257 | } |
181 | 258 | ||
diff --git a/fs/adfs/inode.c b/fs/adfs/inode.c index 09fe40198d1c..92444e94f842 100644 --- a/fs/adfs/inode.c +++ b/fs/adfs/inode.c | |||
@@ -78,26 +78,13 @@ static const struct address_space_operations adfs_aops = { | |||
78 | .bmap = _adfs_bmap | 78 | .bmap = _adfs_bmap |
79 | }; | 79 | }; |
80 | 80 | ||
81 | static inline unsigned int | ||
82 | adfs_filetype(struct inode *inode) | ||
83 | { | ||
84 | unsigned int type; | ||
85 | |||
86 | if (ADFS_I(inode)->stamped) | ||
87 | type = (ADFS_I(inode)->loadaddr >> 8) & 0xfff; | ||
88 | else | ||
89 | type = (unsigned int) -1; | ||
90 | |||
91 | return type; | ||
92 | } | ||
93 | |||
94 | /* | 81 | /* |
95 | * Convert ADFS attributes and filetype to Linux permission. | 82 | * Convert ADFS attributes and filetype to Linux permission. |
96 | */ | 83 | */ |
97 | static umode_t | 84 | static umode_t |
98 | adfs_atts2mode(struct super_block *sb, struct inode *inode) | 85 | adfs_atts2mode(struct super_block *sb, struct inode *inode) |
99 | { | 86 | { |
100 | unsigned int filetype, attr = ADFS_I(inode)->attr; | 87 | unsigned int attr = ADFS_I(inode)->attr; |
101 | umode_t mode, rmask; | 88 | umode_t mode, rmask; |
102 | struct adfs_sb_info *asb = ADFS_SB(sb); | 89 | struct adfs_sb_info *asb = ADFS_SB(sb); |
103 | 90 | ||
@@ -106,9 +93,7 @@ adfs_atts2mode(struct super_block *sb, struct inode *inode) | |||
106 | return S_IFDIR | S_IXUGO | mode; | 93 | return S_IFDIR | S_IXUGO | mode; |
107 | } | 94 | } |
108 | 95 | ||
109 | filetype = adfs_filetype(inode); | 96 | switch (ADFS_I(inode)->filetype) { |
110 | |||
111 | switch (filetype) { | ||
112 | case 0xfc0: /* LinkFS */ | 97 | case 0xfc0: /* LinkFS */ |
113 | return S_IFLNK|S_IRWXUGO; | 98 | return S_IFLNK|S_IRWXUGO; |
114 | 99 | ||
@@ -174,50 +159,48 @@ adfs_mode2atts(struct super_block *sb, struct inode *inode) | |||
174 | 159 | ||
175 | /* | 160 | /* |
176 | * Convert an ADFS time to Unix time. ADFS has a 40-bit centi-second time | 161 | * Convert an ADFS time to Unix time. ADFS has a 40-bit centi-second time |
177 | * referenced to 1 Jan 1900 (til 2248) | 162 | * referenced to 1 Jan 1900 (til 2248) so we need to discard 2208988800 seconds |
163 | * of time to convert from RISC OS epoch to Unix epoch. | ||
178 | */ | 164 | */ |
179 | static void | 165 | static void |
180 | adfs_adfs2unix_time(struct timespec *tv, struct inode *inode) | 166 | adfs_adfs2unix_time(struct timespec *tv, struct inode *inode) |
181 | { | 167 | { |
182 | unsigned int high, low; | 168 | unsigned int high, low; |
169 | /* 01 Jan 1970 00:00:00 (Unix epoch) as nanoseconds since | ||
170 | * 01 Jan 1900 00:00:00 (RISC OS epoch) | ||
171 | */ | ||
172 | static const s64 nsec_unix_epoch_diff_risc_os_epoch = | ||
173 | 2208988800000000000LL; | ||
174 | s64 nsec; | ||
183 | 175 | ||
184 | if (ADFS_I(inode)->stamped == 0) | 176 | if (ADFS_I(inode)->stamped == 0) |
185 | goto cur_time; | 177 | goto cur_time; |
186 | 178 | ||
187 | high = ADFS_I(inode)->loadaddr << 24; | 179 | high = ADFS_I(inode)->loadaddr & 0xFF; /* top 8 bits of timestamp */ |
188 | low = ADFS_I(inode)->execaddr; | 180 | low = ADFS_I(inode)->execaddr; /* bottom 32 bits of timestamp */ |
189 | 181 | ||
190 | high |= low >> 8; | 182 | /* convert 40-bit centi-seconds to 32-bit seconds |
191 | low &= 255; | 183 | * going via nanoseconds to retain precision |
184 | */ | ||
185 | nsec = (((s64) high << 32) | (s64) low) * 10000000; /* cs to ns */ | ||
192 | 186 | ||
193 | /* Files dated pre 01 Jan 1970 00:00:00. */ | 187 | /* Files dated pre 01 Jan 1970 00:00:00. */ |
194 | if (high < 0x336e996a) | 188 | if (nsec < nsec_unix_epoch_diff_risc_os_epoch) |
195 | goto too_early; | 189 | goto too_early; |
196 | 190 | ||
197 | /* Files dated post 18 Jan 2038 03:14:05. */ | 191 | /* convert from RISC OS to Unix epoch */ |
198 | if (high >= 0x656e9969) | 192 | nsec -= nsec_unix_epoch_diff_risc_os_epoch; |
199 | goto too_late; | ||
200 | 193 | ||
201 | /* discard 2208988800 (0x336e996a00) seconds of time */ | 194 | *tv = ns_to_timespec(nsec); |
202 | high -= 0x336e996a; | ||
203 | |||
204 | /* convert 40-bit centi-seconds to 32-bit seconds */ | ||
205 | tv->tv_sec = (((high % 100) << 8) + low) / 100 + (high / 100 << 8); | ||
206 | tv->tv_nsec = 0; | ||
207 | return; | 195 | return; |
208 | 196 | ||
209 | cur_time: | 197 | cur_time: |
210 | *tv = CURRENT_TIME_SEC; | 198 | *tv = CURRENT_TIME; |
211 | return; | 199 | return; |
212 | 200 | ||
213 | too_early: | 201 | too_early: |
214 | tv->tv_sec = tv->tv_nsec = 0; | 202 | tv->tv_sec = tv->tv_nsec = 0; |
215 | return; | 203 | return; |
216 | |||
217 | too_late: | ||
218 | tv->tv_sec = 0x7ffffffd; | ||
219 | tv->tv_nsec = 0; | ||
220 | return; | ||
221 | } | 204 | } |
222 | 205 | ||
223 | /* | 206 | /* |
@@ -279,7 +262,8 @@ adfs_iget(struct super_block *sb, struct object_info *obj) | |||
279 | ADFS_I(inode)->loadaddr = obj->loadaddr; | 262 | ADFS_I(inode)->loadaddr = obj->loadaddr; |
280 | ADFS_I(inode)->execaddr = obj->execaddr; | 263 | ADFS_I(inode)->execaddr = obj->execaddr; |
281 | ADFS_I(inode)->attr = obj->attr; | 264 | ADFS_I(inode)->attr = obj->attr; |
282 | ADFS_I(inode)->stamped = ((obj->loadaddr & 0xfff00000) == 0xfff00000); | 265 | ADFS_I(inode)->filetype = obj->filetype; |
266 | ADFS_I(inode)->stamped = ((obj->loadaddr & 0xfff00000) == 0xfff00000); | ||
283 | 267 | ||
284 | inode->i_mode = adfs_atts2mode(sb, inode); | 268 | inode->i_mode = adfs_atts2mode(sb, inode); |
285 | adfs_adfs2unix_time(&inode->i_mtime, inode); | 269 | adfs_adfs2unix_time(&inode->i_mtime, inode); |
diff --git a/fs/adfs/super.c b/fs/adfs/super.c index 06d7388b477b..c8bf36a1996a 100644 --- a/fs/adfs/super.c +++ b/fs/adfs/super.c | |||
@@ -138,17 +138,20 @@ static int adfs_show_options(struct seq_file *seq, struct vfsmount *mnt) | |||
138 | seq_printf(seq, ",ownmask=%o", asb->s_owner_mask); | 138 | seq_printf(seq, ",ownmask=%o", asb->s_owner_mask); |
139 | if (asb->s_other_mask != ADFS_DEFAULT_OTHER_MASK) | 139 | if (asb->s_other_mask != ADFS_DEFAULT_OTHER_MASK) |
140 | seq_printf(seq, ",othmask=%o", asb->s_other_mask); | 140 | seq_printf(seq, ",othmask=%o", asb->s_other_mask); |
141 | if (asb->s_ftsuffix != 0) | ||
142 | seq_printf(seq, ",ftsuffix=%u", asb->s_ftsuffix); | ||
141 | 143 | ||
142 | return 0; | 144 | return 0; |
143 | } | 145 | } |
144 | 146 | ||
145 | enum {Opt_uid, Opt_gid, Opt_ownmask, Opt_othmask, Opt_err}; | 147 | enum {Opt_uid, Opt_gid, Opt_ownmask, Opt_othmask, Opt_ftsuffix, Opt_err}; |
146 | 148 | ||
147 | static const match_table_t tokens = { | 149 | static const match_table_t tokens = { |
148 | {Opt_uid, "uid=%u"}, | 150 | {Opt_uid, "uid=%u"}, |
149 | {Opt_gid, "gid=%u"}, | 151 | {Opt_gid, "gid=%u"}, |
150 | {Opt_ownmask, "ownmask=%o"}, | 152 | {Opt_ownmask, "ownmask=%o"}, |
151 | {Opt_othmask, "othmask=%o"}, | 153 | {Opt_othmask, "othmask=%o"}, |
154 | {Opt_ftsuffix, "ftsuffix=%u"}, | ||
152 | {Opt_err, NULL} | 155 | {Opt_err, NULL} |
153 | }; | 156 | }; |
154 | 157 | ||
@@ -189,6 +192,11 @@ static int parse_options(struct super_block *sb, char *options) | |||
189 | return -EINVAL; | 192 | return -EINVAL; |
190 | asb->s_other_mask = option; | 193 | asb->s_other_mask = option; |
191 | break; | 194 | break; |
195 | case Opt_ftsuffix: | ||
196 | if (match_int(args, &option)) | ||
197 | return -EINVAL; | ||
198 | asb->s_ftsuffix = option; | ||
199 | break; | ||
192 | default: | 200 | default: |
193 | printk("ADFS-fs: unrecognised mount option \"%s\" " | 201 | printk("ADFS-fs: unrecognised mount option \"%s\" " |
194 | "or missing value\n", p); | 202 | "or missing value\n", p); |
@@ -366,6 +374,7 @@ static int adfs_fill_super(struct super_block *sb, void *data, int silent) | |||
366 | asb->s_gid = 0; | 374 | asb->s_gid = 0; |
367 | asb->s_owner_mask = ADFS_DEFAULT_OWNER_MASK; | 375 | asb->s_owner_mask = ADFS_DEFAULT_OWNER_MASK; |
368 | asb->s_other_mask = ADFS_DEFAULT_OTHER_MASK; | 376 | asb->s_other_mask = ADFS_DEFAULT_OTHER_MASK; |
377 | asb->s_ftsuffix = 0; | ||
369 | 378 | ||
370 | if (parse_options(sb, data)) | 379 | if (parse_options(sb, data)) |
371 | goto error; | 380 | goto error; |
@@ -445,11 +454,13 @@ static int adfs_fill_super(struct super_block *sb, void *data, int silent) | |||
445 | 454 | ||
446 | root_obj.parent_id = root_obj.file_id = le32_to_cpu(dr->root); | 455 | root_obj.parent_id = root_obj.file_id = le32_to_cpu(dr->root); |
447 | root_obj.name_len = 0; | 456 | root_obj.name_len = 0; |
448 | root_obj.loadaddr = 0; | 457 | /* Set root object date as 01 Jan 1987 00:00:00 */ |
449 | root_obj.execaddr = 0; | 458 | root_obj.loadaddr = 0xfff0003f; |
459 | root_obj.execaddr = 0xec22c000; | ||
450 | root_obj.size = ADFS_NEWDIR_SIZE; | 460 | root_obj.size = ADFS_NEWDIR_SIZE; |
451 | root_obj.attr = ADFS_NDA_DIRECTORY | ADFS_NDA_OWNER_READ | | 461 | root_obj.attr = ADFS_NDA_DIRECTORY | ADFS_NDA_OWNER_READ | |
452 | ADFS_NDA_OWNER_WRITE | ADFS_NDA_PUBLIC_READ; | 462 | ADFS_NDA_OWNER_WRITE | ADFS_NDA_PUBLIC_READ; |
463 | root_obj.filetype = -1; | ||
453 | 464 | ||
454 | /* | 465 | /* |
455 | * If this is a F+ disk with variable length directories, | 466 | * If this is a F+ disk with variable length directories, |
@@ -463,6 +474,12 @@ static int adfs_fill_super(struct super_block *sb, void *data, int silent) | |||
463 | asb->s_dir = &adfs_f_dir_ops; | 474 | asb->s_dir = &adfs_f_dir_ops; |
464 | asb->s_namelen = ADFS_F_NAME_LEN; | 475 | asb->s_namelen = ADFS_F_NAME_LEN; |
465 | } | 476 | } |
477 | /* | ||
478 | * ,xyz hex filetype suffix may be added by driver | ||
479 | * to files that have valid RISC OS filetype | ||
480 | */ | ||
481 | if (asb->s_ftsuffix) | ||
482 | asb->s_namelen += 4; | ||
466 | 483 | ||
467 | sb->s_d_op = &adfs_dentry_operations; | 484 | sb->s_d_op = &adfs_dentry_operations; |
468 | root = adfs_iget(sb, &root_obj); | 485 | root = adfs_iget(sb, &root_obj); |
diff --git a/fs/affs/Makefile b/fs/affs/Makefile index b2c4f54446f3..3988b4a78339 100644 --- a/fs/affs/Makefile +++ b/fs/affs/Makefile | |||
@@ -2,7 +2,7 @@ | |||
2 | # Makefile for the Linux affs filesystem routines. | 2 | # Makefile for the Linux affs filesystem routines. |
3 | # | 3 | # |
4 | 4 | ||
5 | #EXTRA_CFLAGS=-DDEBUG=1 | 5 | #ccflags-y := -DDEBUG=1 |
6 | 6 | ||
7 | obj-$(CONFIG_AFFS_FS) += affs.o | 7 | obj-$(CONFIG_AFFS_FS) += affs.o |
8 | 8 | ||
@@ -520,7 +520,7 @@ static inline void really_put_req(struct kioctx *ctx, struct kiocb *req) | |||
520 | ctx->reqs_active--; | 520 | ctx->reqs_active--; |
521 | 521 | ||
522 | if (unlikely(!ctx->reqs_active && ctx->dead)) | 522 | if (unlikely(!ctx->reqs_active && ctx->dead)) |
523 | wake_up(&ctx->wait); | 523 | wake_up_all(&ctx->wait); |
524 | } | 524 | } |
525 | 525 | ||
526 | static void aio_fput_routine(struct work_struct *data) | 526 | static void aio_fput_routine(struct work_struct *data) |
@@ -1229,7 +1229,7 @@ static void io_destroy(struct kioctx *ioctx) | |||
1229 | * by other CPUs at this point. Right now, we rely on the | 1229 | * by other CPUs at this point. Right now, we rely on the |
1230 | * locking done by the above calls to ensure this consistency. | 1230 | * locking done by the above calls to ensure this consistency. |
1231 | */ | 1231 | */ |
1232 | wake_up(&ioctx->wait); | 1232 | wake_up_all(&ioctx->wait); |
1233 | put_ioctx(ioctx); /* once for the lookup */ | 1233 | put_ioctx(ioctx); /* once for the lookup */ |
1234 | } | 1234 | } |
1235 | 1235 | ||
@@ -59,7 +59,7 @@ int inode_change_ok(const struct inode *inode, struct iattr *attr) | |||
59 | 59 | ||
60 | /* Make sure a caller can chmod. */ | 60 | /* Make sure a caller can chmod. */ |
61 | if (ia_valid & ATTR_MODE) { | 61 | if (ia_valid & ATTR_MODE) { |
62 | if (!is_owner_or_cap(inode)) | 62 | if (!inode_owner_or_capable(inode)) |
63 | return -EPERM; | 63 | return -EPERM; |
64 | /* Also check the setgid bit! */ | 64 | /* Also check the setgid bit! */ |
65 | if (!in_group_p((ia_valid & ATTR_GID) ? attr->ia_gid : | 65 | if (!in_group_p((ia_valid & ATTR_GID) ? attr->ia_gid : |
@@ -69,7 +69,7 @@ int inode_change_ok(const struct inode *inode, struct iattr *attr) | |||
69 | 69 | ||
70 | /* Check for setting the inode time. */ | 70 | /* Check for setting the inode time. */ |
71 | if (ia_valid & (ATTR_MTIME_SET | ATTR_ATIME_SET | ATTR_TIMES_SET)) { | 71 | if (ia_valid & (ATTR_MTIME_SET | ATTR_ATIME_SET | ATTR_TIMES_SET)) { |
72 | if (!is_owner_or_cap(inode)) | 72 | if (!inode_owner_or_capable(inode)) |
73 | return -EPERM; | 73 | return -EPERM; |
74 | } | 74 | } |
75 | 75 | ||
diff --git a/fs/autofs4/root.c b/fs/autofs4/root.c index 014e7aba3b08..e6f84d26f4cf 100644 --- a/fs/autofs4/root.c +++ b/fs/autofs4/root.c | |||
@@ -36,7 +36,7 @@ static long autofs4_root_compat_ioctl(struct file *,unsigned int,unsigned long); | |||
36 | static int autofs4_dir_open(struct inode *inode, struct file *file); | 36 | static int autofs4_dir_open(struct inode *inode, struct file *file); |
37 | static struct dentry *autofs4_lookup(struct inode *,struct dentry *, struct nameidata *); | 37 | static struct dentry *autofs4_lookup(struct inode *,struct dentry *, struct nameidata *); |
38 | static struct vfsmount *autofs4_d_automount(struct path *); | 38 | static struct vfsmount *autofs4_d_automount(struct path *); |
39 | static int autofs4_d_manage(struct dentry *, bool, bool); | 39 | static int autofs4_d_manage(struct dentry *, bool); |
40 | static void autofs4_dentry_release(struct dentry *); | 40 | static void autofs4_dentry_release(struct dentry *); |
41 | 41 | ||
42 | const struct file_operations autofs4_root_operations = { | 42 | const struct file_operations autofs4_root_operations = { |
@@ -446,7 +446,7 @@ done: | |||
446 | return NULL; | 446 | return NULL; |
447 | } | 447 | } |
448 | 448 | ||
449 | int autofs4_d_manage(struct dentry *dentry, bool mounting_here, bool rcu_walk) | 449 | int autofs4_d_manage(struct dentry *dentry, bool rcu_walk) |
450 | { | 450 | { |
451 | struct autofs_sb_info *sbi = autofs4_sbi(dentry->d_sb); | 451 | struct autofs_sb_info *sbi = autofs4_sbi(dentry->d_sb); |
452 | 452 | ||
@@ -454,7 +454,7 @@ int autofs4_d_manage(struct dentry *dentry, bool mounting_here, bool rcu_walk) | |||
454 | dentry, dentry->d_name.len, dentry->d_name.name); | 454 | dentry, dentry->d_name.len, dentry->d_name.name); |
455 | 455 | ||
456 | /* The daemon never waits. */ | 456 | /* The daemon never waits. */ |
457 | if (autofs4_oz_mode(sbi) || mounting_here) { | 457 | if (autofs4_oz_mode(sbi)) { |
458 | if (!d_mountpoint(dentry)) | 458 | if (!d_mountpoint(dentry)) |
459 | return -EISDIR; | 459 | return -EISDIR; |
460 | return 0; | 460 | return 0; |
diff --git a/fs/bfs/dir.c b/fs/bfs/dir.c index 685ecff3ab31..b14cebfd9047 100644 --- a/fs/bfs/dir.c +++ b/fs/bfs/dir.c | |||
@@ -97,7 +97,7 @@ static int bfs_create(struct inode *dir, struct dentry *dentry, int mode, | |||
97 | if (!inode) | 97 | if (!inode) |
98 | return -ENOSPC; | 98 | return -ENOSPC; |
99 | mutex_lock(&info->bfs_lock); | 99 | mutex_lock(&info->bfs_lock); |
100 | ino = find_first_zero_bit(info->si_imap, info->si_lasti); | 100 | ino = find_first_zero_bit(info->si_imap, info->si_lasti + 1); |
101 | if (ino > info->si_lasti) { | 101 | if (ino > info->si_lasti) { |
102 | mutex_unlock(&info->bfs_lock); | 102 | mutex_unlock(&info->bfs_lock); |
103 | iput(inode); | 103 | iput(inode); |
diff --git a/fs/binfmt_elf.c b/fs/binfmt_elf.c index d5b640ba6cb1..f34078d702d3 100644 --- a/fs/binfmt_elf.c +++ b/fs/binfmt_elf.c | |||
@@ -570,7 +570,7 @@ static int load_elf_binary(struct linux_binprm *bprm, struct pt_regs *regs) | |||
570 | unsigned long elf_entry; | 570 | unsigned long elf_entry; |
571 | unsigned long interp_load_addr = 0; | 571 | unsigned long interp_load_addr = 0; |
572 | unsigned long start_code, end_code, start_data, end_data; | 572 | unsigned long start_code, end_code, start_data, end_data; |
573 | unsigned long reloc_func_desc = 0; | 573 | unsigned long reloc_func_desc __maybe_unused = 0; |
574 | int executable_stack = EXSTACK_DEFAULT; | 574 | int executable_stack = EXSTACK_DEFAULT; |
575 | unsigned long def_flags = 0; | 575 | unsigned long def_flags = 0; |
576 | struct { | 576 | struct { |
@@ -1906,7 +1906,7 @@ static int elf_core_dump(struct coredump_params *cprm) | |||
1906 | segs = current->mm->map_count; | 1906 | segs = current->mm->map_count; |
1907 | segs += elf_core_extra_phdrs(); | 1907 | segs += elf_core_extra_phdrs(); |
1908 | 1908 | ||
1909 | gate_vma = get_gate_vma(current); | 1909 | gate_vma = get_gate_vma(current->mm); |
1910 | if (gate_vma != NULL) | 1910 | if (gate_vma != NULL) |
1911 | segs++; | 1911 | segs++; |
1912 | 1912 | ||
@@ -111,7 +111,7 @@ static struct kmem_cache *bio_find_or_create_slab(unsigned int extra_size) | |||
111 | if (!slab) | 111 | if (!slab) |
112 | goto out_unlock; | 112 | goto out_unlock; |
113 | 113 | ||
114 | printk("bio: create slab <%s> at %d\n", bslab->name, entry); | 114 | printk(KERN_INFO "bio: create slab <%s> at %d\n", bslab->name, entry); |
115 | bslab->slab = slab; | 115 | bslab->slab = slab; |
116 | bslab->slab_ref = 1; | 116 | bslab->slab_ref = 1; |
117 | bslab->slab_size = sz; | 117 | bslab->slab_size = sz; |
diff --git a/fs/btrfs/acl.c b/fs/btrfs/acl.c index 9c949348510b..de34bfad9ec3 100644 --- a/fs/btrfs/acl.c +++ b/fs/btrfs/acl.c | |||
@@ -170,7 +170,7 @@ static int btrfs_xattr_acl_set(struct dentry *dentry, const char *name, | |||
170 | int ret; | 170 | int ret; |
171 | struct posix_acl *acl = NULL; | 171 | struct posix_acl *acl = NULL; |
172 | 172 | ||
173 | if (!is_owner_or_cap(dentry->d_inode)) | 173 | if (!inode_owner_or_capable(dentry->d_inode)) |
174 | return -EPERM; | 174 | return -EPERM; |
175 | 175 | ||
176 | if (!IS_POSIXACL(dentry->d_inode)) | 176 | if (!IS_POSIXACL(dentry->d_inode)) |
diff --git a/fs/btrfs/disk-io.c b/fs/btrfs/disk-io.c index e1aa8d607bc7..100b07f021b4 100644 --- a/fs/btrfs/disk-io.c +++ b/fs/btrfs/disk-io.c | |||
@@ -2493,7 +2493,7 @@ int close_ctree(struct btrfs_root *root) | |||
2493 | * ERROR state on disk. | 2493 | * ERROR state on disk. |
2494 | * | 2494 | * |
2495 | * 2. when btrfs flips readonly just in btrfs_commit_super, | 2495 | * 2. when btrfs flips readonly just in btrfs_commit_super, |
2496 | * and in such case, btrfs cannnot write sb via btrfs_commit_super, | 2496 | * and in such case, btrfs cannot write sb via btrfs_commit_super, |
2497 | * and since fs_state has been set BTRFS_SUPER_FLAG_ERROR flag, | 2497 | * and since fs_state has been set BTRFS_SUPER_FLAG_ERROR flag, |
2498 | * btrfs will cleanup all FS resources first and write sb then. | 2498 | * btrfs will cleanup all FS resources first and write sb then. |
2499 | */ | 2499 | */ |
diff --git a/fs/btrfs/ioctl.c b/fs/btrfs/ioctl.c index 5fdb2abc4fa7..d1bace3df9b6 100644 --- a/fs/btrfs/ioctl.c +++ b/fs/btrfs/ioctl.c | |||
@@ -158,7 +158,7 @@ static int btrfs_ioctl_setflags(struct file *file, void __user *arg) | |||
158 | FS_SYNC_FL | FS_DIRSYNC_FL)) | 158 | FS_SYNC_FL | FS_DIRSYNC_FL)) |
159 | return -EOPNOTSUPP; | 159 | return -EOPNOTSUPP; |
160 | 160 | ||
161 | if (!is_owner_or_cap(inode)) | 161 | if (!inode_owner_or_capable(inode)) |
162 | return -EACCES; | 162 | return -EACCES; |
163 | 163 | ||
164 | mutex_lock(&inode->i_mutex); | 164 | mutex_lock(&inode->i_mutex); |
@@ -1077,7 +1077,7 @@ static noinline int btrfs_ioctl_subvol_setflags(struct file *file, | |||
1077 | if (flags & ~BTRFS_SUBVOL_RDONLY) | 1077 | if (flags & ~BTRFS_SUBVOL_RDONLY) |
1078 | return -EOPNOTSUPP; | 1078 | return -EOPNOTSUPP; |
1079 | 1079 | ||
1080 | if (!is_owner_or_cap(inode)) | 1080 | if (!inode_owner_or_capable(inode)) |
1081 | return -EACCES; | 1081 | return -EACCES; |
1082 | 1082 | ||
1083 | down_write(&root->fs_info->subvol_sem); | 1083 | down_write(&root->fs_info->subvol_sem); |
diff --git a/fs/btrfs/zlib.c b/fs/btrfs/zlib.c index f5ec2d44150d..faccd47c6c46 100644 --- a/fs/btrfs/zlib.c +++ b/fs/btrfs/zlib.c | |||
@@ -57,7 +57,8 @@ static struct list_head *zlib_alloc_workspace(void) | |||
57 | if (!workspace) | 57 | if (!workspace) |
58 | return ERR_PTR(-ENOMEM); | 58 | return ERR_PTR(-ENOMEM); |
59 | 59 | ||
60 | workspace->def_strm.workspace = vmalloc(zlib_deflate_workspacesize()); | 60 | workspace->def_strm.workspace = vmalloc(zlib_deflate_workspacesize( |
61 | MAX_WBITS, MAX_MEM_LEVEL)); | ||
61 | workspace->inf_strm.workspace = vmalloc(zlib_inflate_workspacesize()); | 62 | workspace->inf_strm.workspace = vmalloc(zlib_inflate_workspacesize()); |
62 | workspace->buf = kmalloc(PAGE_CACHE_SIZE, GFP_NOFS); | 63 | workspace->buf = kmalloc(PAGE_CACHE_SIZE, GFP_NOFS); |
63 | if (!workspace->def_strm.workspace || | 64 | if (!workspace->def_strm.workspace || |
diff --git a/fs/ceph/debugfs.c b/fs/ceph/debugfs.c index 08f65faac112..0dba6915712b 100644 --- a/fs/ceph/debugfs.c +++ b/fs/ceph/debugfs.c | |||
@@ -210,8 +210,6 @@ int ceph_fs_debugfs_init(struct ceph_fs_client *fsc) | |||
210 | if (!fsc->debugfs_congestion_kb) | 210 | if (!fsc->debugfs_congestion_kb) |
211 | goto out; | 211 | goto out; |
212 | 212 | ||
213 | dout("a\n"); | ||
214 | |||
215 | snprintf(name, sizeof(name), "../../bdi/%s", | 213 | snprintf(name, sizeof(name), "../../bdi/%s", |
216 | dev_name(fsc->backing_dev_info.dev)); | 214 | dev_name(fsc->backing_dev_info.dev)); |
217 | fsc->debugfs_bdi = | 215 | fsc->debugfs_bdi = |
@@ -221,7 +219,6 @@ int ceph_fs_debugfs_init(struct ceph_fs_client *fsc) | |||
221 | if (!fsc->debugfs_bdi) | 219 | if (!fsc->debugfs_bdi) |
222 | goto out; | 220 | goto out; |
223 | 221 | ||
224 | dout("b\n"); | ||
225 | fsc->debugfs_mdsmap = debugfs_create_file("mdsmap", | 222 | fsc->debugfs_mdsmap = debugfs_create_file("mdsmap", |
226 | 0600, | 223 | 0600, |
227 | fsc->client->debugfs_dir, | 224 | fsc->client->debugfs_dir, |
@@ -230,7 +227,6 @@ int ceph_fs_debugfs_init(struct ceph_fs_client *fsc) | |||
230 | if (!fsc->debugfs_mdsmap) | 227 | if (!fsc->debugfs_mdsmap) |
231 | goto out; | 228 | goto out; |
232 | 229 | ||
233 | dout("ca\n"); | ||
234 | fsc->debugfs_mdsc = debugfs_create_file("mdsc", | 230 | fsc->debugfs_mdsc = debugfs_create_file("mdsc", |
235 | 0600, | 231 | 0600, |
236 | fsc->client->debugfs_dir, | 232 | fsc->client->debugfs_dir, |
@@ -239,7 +235,6 @@ int ceph_fs_debugfs_init(struct ceph_fs_client *fsc) | |||
239 | if (!fsc->debugfs_mdsc) | 235 | if (!fsc->debugfs_mdsc) |
240 | goto out; | 236 | goto out; |
241 | 237 | ||
242 | dout("da\n"); | ||
243 | fsc->debugfs_caps = debugfs_create_file("caps", | 238 | fsc->debugfs_caps = debugfs_create_file("caps", |
244 | 0400, | 239 | 0400, |
245 | fsc->client->debugfs_dir, | 240 | fsc->client->debugfs_dir, |
@@ -248,7 +243,6 @@ int ceph_fs_debugfs_init(struct ceph_fs_client *fsc) | |||
248 | if (!fsc->debugfs_caps) | 243 | if (!fsc->debugfs_caps) |
249 | goto out; | 244 | goto out; |
250 | 245 | ||
251 | dout("ea\n"); | ||
252 | fsc->debugfs_dentry_lru = debugfs_create_file("dentry_lru", | 246 | fsc->debugfs_dentry_lru = debugfs_create_file("dentry_lru", |
253 | 0600, | 247 | 0600, |
254 | fsc->client->debugfs_dir, | 248 | fsc->client->debugfs_dir, |
diff --git a/fs/ceph/dir.c b/fs/ceph/dir.c index ebafa65a29b6..1a867a3601ae 100644 --- a/fs/ceph/dir.c +++ b/fs/ceph/dir.c | |||
@@ -161,7 +161,7 @@ more: | |||
161 | filp->f_pos = di->offset; | 161 | filp->f_pos = di->offset; |
162 | err = filldir(dirent, dentry->d_name.name, | 162 | err = filldir(dirent, dentry->d_name.name, |
163 | dentry->d_name.len, di->offset, | 163 | dentry->d_name.len, di->offset, |
164 | dentry->d_inode->i_ino, | 164 | ceph_translate_ino(dentry->d_sb, dentry->d_inode->i_ino), |
165 | dentry->d_inode->i_mode >> 12); | 165 | dentry->d_inode->i_mode >> 12); |
166 | 166 | ||
167 | if (last) { | 167 | if (last) { |
@@ -245,15 +245,17 @@ static int ceph_readdir(struct file *filp, void *dirent, filldir_t filldir) | |||
245 | 245 | ||
246 | dout("readdir off 0 -> '.'\n"); | 246 | dout("readdir off 0 -> '.'\n"); |
247 | if (filldir(dirent, ".", 1, ceph_make_fpos(0, 0), | 247 | if (filldir(dirent, ".", 1, ceph_make_fpos(0, 0), |
248 | inode->i_ino, inode->i_mode >> 12) < 0) | 248 | ceph_translate_ino(inode->i_sb, inode->i_ino), |
249 | inode->i_mode >> 12) < 0) | ||
249 | return 0; | 250 | return 0; |
250 | filp->f_pos = 1; | 251 | filp->f_pos = 1; |
251 | off = 1; | 252 | off = 1; |
252 | } | 253 | } |
253 | if (filp->f_pos == 1) { | 254 | if (filp->f_pos == 1) { |
255 | ino_t ino = filp->f_dentry->d_parent->d_inode->i_ino; | ||
254 | dout("readdir off 1 -> '..'\n"); | 256 | dout("readdir off 1 -> '..'\n"); |
255 | if (filldir(dirent, "..", 2, ceph_make_fpos(0, 1), | 257 | if (filldir(dirent, "..", 2, ceph_make_fpos(0, 1), |
256 | filp->f_dentry->d_parent->d_inode->i_ino, | 258 | ceph_translate_ino(inode->i_sb, ino), |
257 | inode->i_mode >> 12) < 0) | 259 | inode->i_mode >> 12) < 0) |
258 | return 0; | 260 | return 0; |
259 | filp->f_pos = 2; | 261 | filp->f_pos = 2; |
@@ -377,7 +379,8 @@ more: | |||
377 | if (filldir(dirent, | 379 | if (filldir(dirent, |
378 | rinfo->dir_dname[off - fi->offset], | 380 | rinfo->dir_dname[off - fi->offset], |
379 | rinfo->dir_dname_len[off - fi->offset], | 381 | rinfo->dir_dname_len[off - fi->offset], |
380 | pos, ino, ftype) < 0) { | 382 | pos, |
383 | ceph_translate_ino(inode->i_sb, ino), ftype) < 0) { | ||
381 | dout("filldir stopping us...\n"); | 384 | dout("filldir stopping us...\n"); |
382 | return 0; | 385 | return 0; |
383 | } | 386 | } |
@@ -1024,14 +1027,13 @@ out_touch: | |||
1024 | } | 1027 | } |
1025 | 1028 | ||
1026 | /* | 1029 | /* |
1027 | * When a dentry is released, clear the dir I_COMPLETE if it was part | 1030 | * Release our ceph_dentry_info. |
1028 | * of the current dir gen or if this is in the snapshot namespace. | ||
1029 | */ | 1031 | */ |
1030 | static void ceph_dentry_release(struct dentry *dentry) | 1032 | static void ceph_d_release(struct dentry *dentry) |
1031 | { | 1033 | { |
1032 | struct ceph_dentry_info *di = ceph_dentry(dentry); | 1034 | struct ceph_dentry_info *di = ceph_dentry(dentry); |
1033 | 1035 | ||
1034 | dout("dentry_release %p\n", dentry); | 1036 | dout("d_release %p\n", dentry); |
1035 | if (di) { | 1037 | if (di) { |
1036 | ceph_dentry_lru_del(dentry); | 1038 | ceph_dentry_lru_del(dentry); |
1037 | if (di->lease_session) | 1039 | if (di->lease_session) |
@@ -1256,14 +1258,14 @@ const struct inode_operations ceph_dir_iops = { | |||
1256 | 1258 | ||
1257 | const struct dentry_operations ceph_dentry_ops = { | 1259 | const struct dentry_operations ceph_dentry_ops = { |
1258 | .d_revalidate = ceph_d_revalidate, | 1260 | .d_revalidate = ceph_d_revalidate, |
1259 | .d_release = ceph_dentry_release, | 1261 | .d_release = ceph_d_release, |
1260 | }; | 1262 | }; |
1261 | 1263 | ||
1262 | const struct dentry_operations ceph_snapdir_dentry_ops = { | 1264 | const struct dentry_operations ceph_snapdir_dentry_ops = { |
1263 | .d_revalidate = ceph_snapdir_d_revalidate, | 1265 | .d_revalidate = ceph_snapdir_d_revalidate, |
1264 | .d_release = ceph_dentry_release, | 1266 | .d_release = ceph_d_release, |
1265 | }; | 1267 | }; |
1266 | 1268 | ||
1267 | const struct dentry_operations ceph_snap_dentry_ops = { | 1269 | const struct dentry_operations ceph_snap_dentry_ops = { |
1268 | .d_release = ceph_dentry_release, | 1270 | .d_release = ceph_d_release, |
1269 | }; | 1271 | }; |
diff --git a/fs/ceph/file.c b/fs/ceph/file.c index 7d0e4a82d898..159b512d5a27 100644 --- a/fs/ceph/file.c +++ b/fs/ceph/file.c | |||
@@ -564,11 +564,19 @@ more: | |||
564 | * start_request so that a tid has been assigned. | 564 | * start_request so that a tid has been assigned. |
565 | */ | 565 | */ |
566 | spin_lock(&ci->i_unsafe_lock); | 566 | spin_lock(&ci->i_unsafe_lock); |
567 | list_add(&req->r_unsafe_item, &ci->i_unsafe_writes); | 567 | list_add_tail(&req->r_unsafe_item, |
568 | &ci->i_unsafe_writes); | ||
568 | spin_unlock(&ci->i_unsafe_lock); | 569 | spin_unlock(&ci->i_unsafe_lock); |
569 | ceph_get_cap_refs(ci, CEPH_CAP_FILE_WR); | 570 | ceph_get_cap_refs(ci, CEPH_CAP_FILE_WR); |
570 | } | 571 | } |
572 | |||
571 | ret = ceph_osdc_wait_request(&fsc->client->osdc, req); | 573 | ret = ceph_osdc_wait_request(&fsc->client->osdc, req); |
574 | if (ret < 0 && req->r_safe_callback) { | ||
575 | spin_lock(&ci->i_unsafe_lock); | ||
576 | list_del_init(&req->r_unsafe_item); | ||
577 | spin_unlock(&ci->i_unsafe_lock); | ||
578 | ceph_put_cap_refs(ci, CEPH_CAP_FILE_WR); | ||
579 | } | ||
572 | } | 580 | } |
573 | 581 | ||
574 | if (file->f_flags & O_DIRECT) | 582 | if (file->f_flags & O_DIRECT) |
diff --git a/fs/ceph/inode.c b/fs/ceph/inode.c index 193bfa5e9cbd..b54c97da1c43 100644 --- a/fs/ceph/inode.c +++ b/fs/ceph/inode.c | |||
@@ -36,6 +36,13 @@ static void ceph_vmtruncate_work(struct work_struct *work); | |||
36 | /* | 36 | /* |
37 | * find or create an inode, given the ceph ino number | 37 | * find or create an inode, given the ceph ino number |
38 | */ | 38 | */ |
39 | static int ceph_set_ino_cb(struct inode *inode, void *data) | ||
40 | { | ||
41 | ceph_inode(inode)->i_vino = *(struct ceph_vino *)data; | ||
42 | inode->i_ino = ceph_vino_to_ino(*(struct ceph_vino *)data); | ||
43 | return 0; | ||
44 | } | ||
45 | |||
39 | struct inode *ceph_get_inode(struct super_block *sb, struct ceph_vino vino) | 46 | struct inode *ceph_get_inode(struct super_block *sb, struct ceph_vino vino) |
40 | { | 47 | { |
41 | struct inode *inode; | 48 | struct inode *inode; |
@@ -1030,9 +1037,6 @@ int ceph_fill_trace(struct super_block *sb, struct ceph_mds_request *req, | |||
1030 | dout("fill_trace doing d_move %p -> %p\n", | 1037 | dout("fill_trace doing d_move %p -> %p\n", |
1031 | req->r_old_dentry, dn); | 1038 | req->r_old_dentry, dn); |
1032 | 1039 | ||
1033 | /* d_move screws up d_subdirs order */ | ||
1034 | ceph_i_clear(dir, CEPH_I_COMPLETE); | ||
1035 | |||
1036 | d_move(req->r_old_dentry, dn); | 1040 | d_move(req->r_old_dentry, dn); |
1037 | dout(" src %p '%.*s' dst %p '%.*s'\n", | 1041 | dout(" src %p '%.*s' dst %p '%.*s'\n", |
1038 | req->r_old_dentry, | 1042 | req->r_old_dentry, |
@@ -1044,12 +1048,15 @@ int ceph_fill_trace(struct super_block *sb, struct ceph_mds_request *req, | |||
1044 | rehashing bug in vfs_rename_dir */ | 1048 | rehashing bug in vfs_rename_dir */ |
1045 | ceph_invalidate_dentry_lease(dn); | 1049 | ceph_invalidate_dentry_lease(dn); |
1046 | 1050 | ||
1047 | /* take overwritten dentry's readdir offset */ | 1051 | /* |
1048 | dout("dn %p gets %p offset %lld (old offset %lld)\n", | 1052 | * d_move() puts the renamed dentry at the end of |
1049 | req->r_old_dentry, dn, ceph_dentry(dn)->offset, | 1053 | * d_subdirs. We need to assign it an appropriate |
1054 | * directory offset so we can behave when holding | ||
1055 | * I_COMPLETE. | ||
1056 | */ | ||
1057 | ceph_set_dentry_offset(req->r_old_dentry); | ||
1058 | dout("dn %p gets new offset %lld\n", req->r_old_dentry, | ||
1050 | ceph_dentry(req->r_old_dentry)->offset); | 1059 | ceph_dentry(req->r_old_dentry)->offset); |
1051 | ceph_dentry(req->r_old_dentry)->offset = | ||
1052 | ceph_dentry(dn)->offset; | ||
1053 | 1060 | ||
1054 | dn = req->r_old_dentry; /* use old_dentry */ | 1061 | dn = req->r_old_dentry; /* use old_dentry */ |
1055 | in = dn->d_inode; | 1062 | in = dn->d_inode; |
@@ -1809,7 +1816,7 @@ int ceph_getattr(struct vfsmount *mnt, struct dentry *dentry, | |||
1809 | err = ceph_do_getattr(inode, CEPH_STAT_CAP_INODE_ALL); | 1816 | err = ceph_do_getattr(inode, CEPH_STAT_CAP_INODE_ALL); |
1810 | if (!err) { | 1817 | if (!err) { |
1811 | generic_fillattr(inode, stat); | 1818 | generic_fillattr(inode, stat); |
1812 | stat->ino = inode->i_ino; | 1819 | stat->ino = ceph_translate_ino(inode->i_sb, inode->i_ino); |
1813 | if (ceph_snap(inode) != CEPH_NOSNAP) | 1820 | if (ceph_snap(inode) != CEPH_NOSNAP) |
1814 | stat->dev = ceph_snap(inode); | 1821 | stat->dev = ceph_snap(inode); |
1815 | else | 1822 | else |
diff --git a/fs/ceph/super.c b/fs/ceph/super.c index 9c5085465a63..a9e78b4a258c 100644 --- a/fs/ceph/super.c +++ b/fs/ceph/super.c | |||
@@ -131,6 +131,7 @@ enum { | |||
131 | Opt_rbytes, | 131 | Opt_rbytes, |
132 | Opt_norbytes, | 132 | Opt_norbytes, |
133 | Opt_noasyncreaddir, | 133 | Opt_noasyncreaddir, |
134 | Opt_ino32, | ||
134 | }; | 135 | }; |
135 | 136 | ||
136 | static match_table_t fsopt_tokens = { | 137 | static match_table_t fsopt_tokens = { |
@@ -150,6 +151,7 @@ static match_table_t fsopt_tokens = { | |||
150 | {Opt_rbytes, "rbytes"}, | 151 | {Opt_rbytes, "rbytes"}, |
151 | {Opt_norbytes, "norbytes"}, | 152 | {Opt_norbytes, "norbytes"}, |
152 | {Opt_noasyncreaddir, "noasyncreaddir"}, | 153 | {Opt_noasyncreaddir, "noasyncreaddir"}, |
154 | {Opt_ino32, "ino32"}, | ||
153 | {-1, NULL} | 155 | {-1, NULL} |
154 | }; | 156 | }; |
155 | 157 | ||
@@ -225,6 +227,9 @@ static int parse_fsopt_token(char *c, void *private) | |||
225 | case Opt_noasyncreaddir: | 227 | case Opt_noasyncreaddir: |
226 | fsopt->flags |= CEPH_MOUNT_OPT_NOASYNCREADDIR; | 228 | fsopt->flags |= CEPH_MOUNT_OPT_NOASYNCREADDIR; |
227 | break; | 229 | break; |
230 | case Opt_ino32: | ||
231 | fsopt->flags |= CEPH_MOUNT_OPT_INO32; | ||
232 | break; | ||
228 | default: | 233 | default: |
229 | BUG_ON(token); | 234 | BUG_ON(token); |
230 | } | 235 | } |
@@ -288,7 +293,7 @@ static int parse_mount_options(struct ceph_mount_options **pfsopt, | |||
288 | fsopt->sb_flags = flags; | 293 | fsopt->sb_flags = flags; |
289 | fsopt->flags = CEPH_MOUNT_OPT_DEFAULT; | 294 | fsopt->flags = CEPH_MOUNT_OPT_DEFAULT; |
290 | 295 | ||
291 | fsopt->rsize = CEPH_MOUNT_RSIZE_DEFAULT; | 296 | fsopt->rsize = CEPH_RSIZE_DEFAULT; |
292 | fsopt->snapdir_name = kstrdup(CEPH_SNAPDIRNAME_DEFAULT, GFP_KERNEL); | 297 | fsopt->snapdir_name = kstrdup(CEPH_SNAPDIRNAME_DEFAULT, GFP_KERNEL); |
293 | fsopt->caps_wanted_delay_min = CEPH_CAPS_WANTED_DELAY_MIN_DEFAULT; | 298 | fsopt->caps_wanted_delay_min = CEPH_CAPS_WANTED_DELAY_MIN_DEFAULT; |
294 | fsopt->caps_wanted_delay_max = CEPH_CAPS_WANTED_DELAY_MAX_DEFAULT; | 299 | fsopt->caps_wanted_delay_max = CEPH_CAPS_WANTED_DELAY_MAX_DEFAULT; |
@@ -370,7 +375,7 @@ static int ceph_show_options(struct seq_file *m, struct vfsmount *mnt) | |||
370 | 375 | ||
371 | if (fsopt->wsize) | 376 | if (fsopt->wsize) |
372 | seq_printf(m, ",wsize=%d", fsopt->wsize); | 377 | seq_printf(m, ",wsize=%d", fsopt->wsize); |
373 | if (fsopt->rsize != CEPH_MOUNT_RSIZE_DEFAULT) | 378 | if (fsopt->rsize != CEPH_RSIZE_DEFAULT) |
374 | seq_printf(m, ",rsize=%d", fsopt->rsize); | 379 | seq_printf(m, ",rsize=%d", fsopt->rsize); |
375 | if (fsopt->congestion_kb != default_congestion_kb()) | 380 | if (fsopt->congestion_kb != default_congestion_kb()) |
376 | seq_printf(m, ",write_congestion_kb=%d", fsopt->congestion_kb); | 381 | seq_printf(m, ",write_congestion_kb=%d", fsopt->congestion_kb); |
diff --git a/fs/ceph/super.h b/fs/ceph/super.h index 20b907d76ae2..619fe719968f 100644 --- a/fs/ceph/super.h +++ b/fs/ceph/super.h | |||
@@ -27,6 +27,7 @@ | |||
27 | #define CEPH_MOUNT_OPT_DIRSTAT (1<<4) /* `cat dirname` for stats */ | 27 | #define CEPH_MOUNT_OPT_DIRSTAT (1<<4) /* `cat dirname` for stats */ |
28 | #define CEPH_MOUNT_OPT_RBYTES (1<<5) /* dir st_bytes = rbytes */ | 28 | #define CEPH_MOUNT_OPT_RBYTES (1<<5) /* dir st_bytes = rbytes */ |
29 | #define CEPH_MOUNT_OPT_NOASYNCREADDIR (1<<7) /* no dcache readdir */ | 29 | #define CEPH_MOUNT_OPT_NOASYNCREADDIR (1<<7) /* no dcache readdir */ |
30 | #define CEPH_MOUNT_OPT_INO32 (1<<8) /* 32 bit inos */ | ||
30 | 31 | ||
31 | #define CEPH_MOUNT_OPT_DEFAULT (CEPH_MOUNT_OPT_RBYTES) | 32 | #define CEPH_MOUNT_OPT_DEFAULT (CEPH_MOUNT_OPT_RBYTES) |
32 | 33 | ||
@@ -35,6 +36,7 @@ | |||
35 | #define ceph_test_mount_opt(fsc, opt) \ | 36 | #define ceph_test_mount_opt(fsc, opt) \ |
36 | (!!((fsc)->mount_options->flags & CEPH_MOUNT_OPT_##opt)) | 37 | (!!((fsc)->mount_options->flags & CEPH_MOUNT_OPT_##opt)) |
37 | 38 | ||
39 | #define CEPH_RSIZE_DEFAULT (512*1024) /* readahead */ | ||
38 | #define CEPH_MAX_READDIR_DEFAULT 1024 | 40 | #define CEPH_MAX_READDIR_DEFAULT 1024 |
39 | #define CEPH_MAX_READDIR_BYTES_DEFAULT (512*1024) | 41 | #define CEPH_MAX_READDIR_BYTES_DEFAULT (512*1024) |
40 | #define CEPH_SNAPDIRNAME_DEFAULT ".snap" | 42 | #define CEPH_SNAPDIRNAME_DEFAULT ".snap" |
@@ -319,6 +321,16 @@ static inline struct ceph_inode_info *ceph_inode(struct inode *inode) | |||
319 | return container_of(inode, struct ceph_inode_info, vfs_inode); | 321 | return container_of(inode, struct ceph_inode_info, vfs_inode); |
320 | } | 322 | } |
321 | 323 | ||
324 | static inline struct ceph_fs_client *ceph_inode_to_client(struct inode *inode) | ||
325 | { | ||
326 | return (struct ceph_fs_client *)inode->i_sb->s_fs_info; | ||
327 | } | ||
328 | |||
329 | static inline struct ceph_fs_client *ceph_sb_to_client(struct super_block *sb) | ||
330 | { | ||
331 | return (struct ceph_fs_client *)sb->s_fs_info; | ||
332 | } | ||
333 | |||
322 | static inline struct ceph_vino ceph_vino(struct inode *inode) | 334 | static inline struct ceph_vino ceph_vino(struct inode *inode) |
323 | { | 335 | { |
324 | return ceph_inode(inode)->i_vino; | 336 | return ceph_inode(inode)->i_vino; |
@@ -327,19 +339,49 @@ static inline struct ceph_vino ceph_vino(struct inode *inode) | |||
327 | /* | 339 | /* |
328 | * ino_t is <64 bits on many architectures, blech. | 340 | * ino_t is <64 bits on many architectures, blech. |
329 | * | 341 | * |
330 | * don't include snap in ino hash, at least for now. | 342 | * i_ino (kernel inode) st_ino (userspace) |
343 | * i386 32 32 | ||
344 | * x86_64+ino32 64 32 | ||
345 | * x86_64 64 64 | ||
346 | */ | ||
347 | static inline u32 ceph_ino_to_ino32(ino_t ino) | ||
348 | { | ||
349 | ino ^= ino >> (sizeof(ino) * 8 - 32); | ||
350 | if (!ino) | ||
351 | ino = 1; | ||
352 | return ino; | ||
353 | } | ||
354 | |||
355 | /* | ||
356 | * kernel i_ino value | ||
331 | */ | 357 | */ |
332 | static inline ino_t ceph_vino_to_ino(struct ceph_vino vino) | 358 | static inline ino_t ceph_vino_to_ino(struct ceph_vino vino) |
333 | { | 359 | { |
334 | ino_t ino = (ino_t)vino.ino; /* ^ (vino.snap << 20); */ | 360 | ino_t ino = (ino_t)vino.ino; /* ^ (vino.snap << 20); */ |
335 | #if BITS_PER_LONG == 32 | 361 | #if BITS_PER_LONG == 32 |
336 | ino ^= vino.ino >> (sizeof(u64)-sizeof(ino_t)) * 8; | 362 | ino = ceph_ino_to_ino32(ino); |
337 | if (!ino) | ||
338 | ino = 1; | ||
339 | #endif | 363 | #endif |
340 | return ino; | 364 | return ino; |
341 | } | 365 | } |
342 | 366 | ||
367 | /* | ||
368 | * user-visible ino (stat, filldir) | ||
369 | */ | ||
370 | #if BITS_PER_LONG == 32 | ||
371 | static inline ino_t ceph_translate_ino(struct super_block *sb, ino_t ino) | ||
372 | { | ||
373 | return ino; | ||
374 | } | ||
375 | #else | ||
376 | static inline ino_t ceph_translate_ino(struct super_block *sb, ino_t ino) | ||
377 | { | ||
378 | if (ceph_test_mount_opt(ceph_sb_to_client(sb), INO32)) | ||
379 | ino = ceph_ino_to_ino32(ino); | ||
380 | return ino; | ||
381 | } | ||
382 | #endif | ||
383 | |||
384 | |||
343 | /* for printf-style formatting */ | 385 | /* for printf-style formatting */ |
344 | #define ceph_vinop(i) ceph_inode(i)->i_vino.ino, ceph_inode(i)->i_vino.snap | 386 | #define ceph_vinop(i) ceph_inode(i)->i_vino.ino, ceph_inode(i)->i_vino.snap |
345 | 387 | ||
@@ -428,13 +470,6 @@ static inline loff_t ceph_make_fpos(unsigned frag, unsigned off) | |||
428 | return ((loff_t)frag << 32) | (loff_t)off; | 470 | return ((loff_t)frag << 32) | (loff_t)off; |
429 | } | 471 | } |
430 | 472 | ||
431 | static inline int ceph_set_ino_cb(struct inode *inode, void *data) | ||
432 | { | ||
433 | ceph_inode(inode)->i_vino = *(struct ceph_vino *)data; | ||
434 | inode->i_ino = ceph_vino_to_ino(*(struct ceph_vino *)data); | ||
435 | return 0; | ||
436 | } | ||
437 | |||
438 | /* | 473 | /* |
439 | * caps helpers | 474 | * caps helpers |
440 | */ | 475 | */ |
@@ -503,15 +538,6 @@ extern void ceph_reservation_status(struct ceph_fs_client *client, | |||
503 | int *total, int *avail, int *used, | 538 | int *total, int *avail, int *used, |
504 | int *reserved, int *min); | 539 | int *reserved, int *min); |
505 | 540 | ||
506 | static inline struct ceph_fs_client *ceph_inode_to_client(struct inode *inode) | ||
507 | { | ||
508 | return (struct ceph_fs_client *)inode->i_sb->s_fs_info; | ||
509 | } | ||
510 | |||
511 | static inline struct ceph_fs_client *ceph_sb_to_client(struct super_block *sb) | ||
512 | { | ||
513 | return (struct ceph_fs_client *)sb->s_fs_info; | ||
514 | } | ||
515 | 541 | ||
516 | 542 | ||
517 | /* | 543 | /* |
diff --git a/fs/coda/Makefile b/fs/coda/Makefile index 6c22e61da397..1bab69a0d347 100644 --- a/fs/coda/Makefile +++ b/fs/coda/Makefile | |||
@@ -9,4 +9,4 @@ coda-objs := psdev.o cache.o cnode.o inode.o dir.o file.o upcall.o \ | |||
9 | 9 | ||
10 | # If you want debugging output, please uncomment the following line. | 10 | # If you want debugging output, please uncomment the following line. |
11 | 11 | ||
12 | # EXTRA_CFLAGS += -DDEBUG -DDEBUG_SMB_MALLOC=1 | 12 | # ccflags-y := -DDEBUG -DDEBUG_SMB_MALLOC=1 |
diff --git a/fs/coda/sysctl.c b/fs/coda/sysctl.c index c6405ce3c50e..06d27a41807f 100644 --- a/fs/coda/sysctl.c +++ b/fs/coda/sysctl.c | |||
@@ -13,7 +13,6 @@ | |||
13 | 13 | ||
14 | #ifdef CONFIG_SYSCTL | 14 | #ifdef CONFIG_SYSCTL |
15 | static struct ctl_table_header *fs_table_header; | 15 | static struct ctl_table_header *fs_table_header; |
16 | #endif | ||
17 | 16 | ||
18 | static ctl_table coda_table[] = { | 17 | static ctl_table coda_table[] = { |
19 | { | 18 | { |
@@ -40,7 +39,6 @@ static ctl_table coda_table[] = { | |||
40 | {} | 39 | {} |
41 | }; | 40 | }; |
42 | 41 | ||
43 | #ifdef CONFIG_SYSCTL | ||
44 | static ctl_table fs_table[] = { | 42 | static ctl_table fs_table[] = { |
45 | { | 43 | { |
46 | .procname = "coda", | 44 | .procname = "coda", |
@@ -49,22 +47,18 @@ static ctl_table fs_table[] = { | |||
49 | }, | 47 | }, |
50 | {} | 48 | {} |
51 | }; | 49 | }; |
52 | #endif | ||
53 | 50 | ||
54 | void coda_sysctl_init(void) | 51 | void coda_sysctl_init(void) |
55 | { | 52 | { |
56 | #ifdef CONFIG_SYSCTL | ||
57 | if ( !fs_table_header ) | 53 | if ( !fs_table_header ) |
58 | fs_table_header = register_sysctl_table(fs_table); | 54 | fs_table_header = register_sysctl_table(fs_table); |
59 | #endif | ||
60 | } | 55 | } |
61 | 56 | ||
62 | void coda_sysctl_clean(void) | 57 | void coda_sysctl_clean(void) |
63 | { | 58 | { |
64 | #ifdef CONFIG_SYSCTL | ||
65 | if ( fs_table_header ) { | 59 | if ( fs_table_header ) { |
66 | unregister_sysctl_table(fs_table_header); | 60 | unregister_sysctl_table(fs_table_header); |
67 | fs_table_header = NULL; | 61 | fs_table_header = NULL; |
68 | } | 62 | } |
69 | #endif | ||
70 | } | 63 | } |
64 | #endif | ||
diff --git a/fs/compat.c b/fs/compat.c index c6d31a3bab88..72fe6cda9108 100644 --- a/fs/compat.c +++ b/fs/compat.c | |||
@@ -1671,9 +1671,6 @@ int compat_set_fd_set(unsigned long nr, compat_ulong_t __user *ufdset, | |||
1671 | * Update: ERESTARTSYS breaks at least the xview clock binary, so | 1671 | * Update: ERESTARTSYS breaks at least the xview clock binary, so |
1672 | * I'm trying ERESTARTNOHAND which restart only when you want to. | 1672 | * I'm trying ERESTARTNOHAND which restart only when you want to. |
1673 | */ | 1673 | */ |
1674 | #define MAX_SELECT_SECONDS \ | ||
1675 | ((unsigned long) (MAX_SCHEDULE_TIMEOUT / HZ)-1) | ||
1676 | |||
1677 | int compat_core_sys_select(int n, compat_ulong_t __user *inp, | 1674 | int compat_core_sys_select(int n, compat_ulong_t __user *inp, |
1678 | compat_ulong_t __user *outp, compat_ulong_t __user *exp, | 1675 | compat_ulong_t __user *outp, compat_ulong_t __user *exp, |
1679 | struct timespec *end_time) | 1676 | struct timespec *end_time) |
diff --git a/fs/dcache.c b/fs/dcache.c index a39fe47c466f..ad25c4cec7d5 100644 --- a/fs/dcache.c +++ b/fs/dcache.c | |||
@@ -1612,10 +1612,13 @@ struct dentry *d_obtain_alias(struct inode *inode) | |||
1612 | __bit_spin_unlock(0, (unsigned long *)&tmp->d_sb->s_anon.first); | 1612 | __bit_spin_unlock(0, (unsigned long *)&tmp->d_sb->s_anon.first); |
1613 | spin_unlock(&tmp->d_lock); | 1613 | spin_unlock(&tmp->d_lock); |
1614 | spin_unlock(&inode->i_lock); | 1614 | spin_unlock(&inode->i_lock); |
1615 | security_d_instantiate(tmp, inode); | ||
1615 | 1616 | ||
1616 | return tmp; | 1617 | return tmp; |
1617 | 1618 | ||
1618 | out_iput: | 1619 | out_iput: |
1620 | if (res && !IS_ERR(res)) | ||
1621 | security_d_instantiate(res, inode); | ||
1619 | iput(inode); | 1622 | iput(inode); |
1620 | return res; | 1623 | return res; |
1621 | } | 1624 | } |
@@ -1808,7 +1811,7 @@ struct dentry *__d_lookup_rcu(struct dentry *parent, struct qstr *name, | |||
1808 | * false-negative result. d_lookup() protects against concurrent | 1811 | * false-negative result. d_lookup() protects against concurrent |
1809 | * renames using rename_lock seqlock. | 1812 | * renames using rename_lock seqlock. |
1810 | * | 1813 | * |
1811 | * See Documentation/vfs/dcache-locking.txt for more details. | 1814 | * See Documentation/filesystems/path-lookup.txt for more details. |
1812 | */ | 1815 | */ |
1813 | hlist_bl_for_each_entry_rcu(dentry, node, &b->head, d_hash) { | 1816 | hlist_bl_for_each_entry_rcu(dentry, node, &b->head, d_hash) { |
1814 | struct inode *i; | 1817 | struct inode *i; |
@@ -1928,7 +1931,7 @@ struct dentry *__d_lookup(struct dentry *parent, struct qstr *name) | |||
1928 | * false-negative result. d_lookup() protects against concurrent | 1931 | * false-negative result. d_lookup() protects against concurrent |
1929 | * renames using rename_lock seqlock. | 1932 | * renames using rename_lock seqlock. |
1930 | * | 1933 | * |
1931 | * See Documentation/vfs/dcache-locking.txt for more details. | 1934 | * See Documentation/filesystems/path-lookup.txt for more details. |
1932 | */ | 1935 | */ |
1933 | rcu_read_lock(); | 1936 | rcu_read_lock(); |
1934 | 1937 | ||
diff --git a/fs/devpts/inode.c b/fs/devpts/inode.c index 1bb547c9cad6..2f27e578d466 100644 --- a/fs/devpts/inode.c +++ b/fs/devpts/inode.c | |||
@@ -479,6 +479,7 @@ int devpts_pty_new(struct inode *ptmx_inode, struct tty_struct *tty) | |||
479 | struct dentry *root = sb->s_root; | 479 | struct dentry *root = sb->s_root; |
480 | struct pts_fs_info *fsi = DEVPTS_SB(sb); | 480 | struct pts_fs_info *fsi = DEVPTS_SB(sb); |
481 | struct pts_mount_opts *opts = &fsi->mount_opts; | 481 | struct pts_mount_opts *opts = &fsi->mount_opts; |
482 | int ret = 0; | ||
482 | char s[12]; | 483 | char s[12]; |
483 | 484 | ||
484 | /* We're supposed to be given the slave end of a pty */ | 485 | /* We're supposed to be given the slave end of a pty */ |
@@ -501,14 +502,17 @@ int devpts_pty_new(struct inode *ptmx_inode, struct tty_struct *tty) | |||
501 | mutex_lock(&root->d_inode->i_mutex); | 502 | mutex_lock(&root->d_inode->i_mutex); |
502 | 503 | ||
503 | dentry = d_alloc_name(root, s); | 504 | dentry = d_alloc_name(root, s); |
504 | if (!IS_ERR(dentry)) { | 505 | if (dentry) { |
505 | d_add(dentry, inode); | 506 | d_add(dentry, inode); |
506 | fsnotify_create(root->d_inode, dentry); | 507 | fsnotify_create(root->d_inode, dentry); |
508 | } else { | ||
509 | iput(inode); | ||
510 | ret = -ENOMEM; | ||
507 | } | 511 | } |
508 | 512 | ||
509 | mutex_unlock(&root->d_inode->i_mutex); | 513 | mutex_unlock(&root->d_inode->i_mutex); |
510 | 514 | ||
511 | return 0; | 515 | return ret; |
512 | } | 516 | } |
513 | 517 | ||
514 | struct tty_struct *devpts_get_tty(struct inode *pts_inode, int number) | 518 | struct tty_struct *devpts_get_tty(struct inode *pts_inode, int number) |
@@ -544,17 +548,12 @@ void devpts_pty_kill(struct tty_struct *tty) | |||
544 | mutex_lock(&root->d_inode->i_mutex); | 548 | mutex_lock(&root->d_inode->i_mutex); |
545 | 549 | ||
546 | dentry = d_find_alias(inode); | 550 | dentry = d_find_alias(inode); |
547 | if (IS_ERR(dentry)) | ||
548 | goto out; | ||
549 | |||
550 | if (dentry) { | ||
551 | inode->i_nlink--; | ||
552 | d_delete(dentry); | ||
553 | dput(dentry); /* d_alloc_name() in devpts_pty_new() */ | ||
554 | } | ||
555 | 551 | ||
552 | inode->i_nlink--; | ||
553 | d_delete(dentry); | ||
554 | dput(dentry); /* d_alloc_name() in devpts_pty_new() */ | ||
556 | dput(dentry); /* d_find_alias above */ | 555 | dput(dentry); /* d_find_alias above */ |
557 | out: | 556 | |
558 | mutex_unlock(&root->d_inode->i_mutex); | 557 | mutex_unlock(&root->d_inode->i_mutex); |
559 | } | 558 | } |
560 | 559 | ||
diff --git a/fs/direct-io.c b/fs/direct-io.c index b044705eedd4..dcb5577cde1d 100644 --- a/fs/direct-io.c +++ b/fs/direct-io.c | |||
@@ -645,11 +645,11 @@ static int dio_send_cur_page(struct dio *dio) | |||
645 | /* | 645 | /* |
646 | * See whether this new request is contiguous with the old. | 646 | * See whether this new request is contiguous with the old. |
647 | * | 647 | * |
648 | * Btrfs cannot handl having logically non-contiguous requests | 648 | * Btrfs cannot handle having logically non-contiguous requests |
649 | * submitted. For exmple if you have | 649 | * submitted. For example if you have |
650 | * | 650 | * |
651 | * Logical: [0-4095][HOLE][8192-12287] | 651 | * Logical: [0-4095][HOLE][8192-12287] |
652 | * Phyiscal: [0-4095] [4096-8181] | 652 | * Physical: [0-4095] [4096-8191] |
653 | * | 653 | * |
654 | * We cannot submit those pages together as one BIO. So if our | 654 | * We cannot submit those pages together as one BIO. So if our |
655 | * current logical offset in the file does not equal what would | 655 | * current logical offset in the file does not equal what would |
diff --git a/fs/dlm/ast.c b/fs/dlm/ast.c index 4314f0d48d85..abc49f292454 100644 --- a/fs/dlm/ast.c +++ b/fs/dlm/ast.c | |||
@@ -18,6 +18,7 @@ | |||
18 | 18 | ||
19 | #define WAKE_ASTS 0 | 19 | #define WAKE_ASTS 0 |
20 | 20 | ||
21 | static uint64_t ast_seq_count; | ||
21 | static struct list_head ast_queue; | 22 | static struct list_head ast_queue; |
22 | static spinlock_t ast_queue_lock; | 23 | static spinlock_t ast_queue_lock; |
23 | static struct task_struct * astd_task; | 24 | static struct task_struct * astd_task; |
@@ -25,40 +26,186 @@ static unsigned long astd_wakeflags; | |||
25 | static struct mutex astd_running; | 26 | static struct mutex astd_running; |
26 | 27 | ||
27 | 28 | ||
29 | static void dlm_dump_lkb_callbacks(struct dlm_lkb *lkb) | ||
30 | { | ||
31 | int i; | ||
32 | |||
33 | log_print("last_bast %x %llu flags %x mode %d sb %d %x", | ||
34 | lkb->lkb_id, | ||
35 | (unsigned long long)lkb->lkb_last_bast.seq, | ||
36 | lkb->lkb_last_bast.flags, | ||
37 | lkb->lkb_last_bast.mode, | ||
38 | lkb->lkb_last_bast.sb_status, | ||
39 | lkb->lkb_last_bast.sb_flags); | ||
40 | |||
41 | log_print("last_cast %x %llu flags %x mode %d sb %d %x", | ||
42 | lkb->lkb_id, | ||
43 | (unsigned long long)lkb->lkb_last_cast.seq, | ||
44 | lkb->lkb_last_cast.flags, | ||
45 | lkb->lkb_last_cast.mode, | ||
46 | lkb->lkb_last_cast.sb_status, | ||
47 | lkb->lkb_last_cast.sb_flags); | ||
48 | |||
49 | for (i = 0; i < DLM_CALLBACKS_SIZE; i++) { | ||
50 | log_print("cb %x %llu flags %x mode %d sb %d %x", | ||
51 | lkb->lkb_id, | ||
52 | (unsigned long long)lkb->lkb_callbacks[i].seq, | ||
53 | lkb->lkb_callbacks[i].flags, | ||
54 | lkb->lkb_callbacks[i].mode, | ||
55 | lkb->lkb_callbacks[i].sb_status, | ||
56 | lkb->lkb_callbacks[i].sb_flags); | ||
57 | } | ||
58 | } | ||
59 | |||
28 | void dlm_del_ast(struct dlm_lkb *lkb) | 60 | void dlm_del_ast(struct dlm_lkb *lkb) |
29 | { | 61 | { |
30 | spin_lock(&ast_queue_lock); | 62 | spin_lock(&ast_queue_lock); |
31 | if (lkb->lkb_ast_type & (AST_COMP | AST_BAST)) | 63 | if (!list_empty(&lkb->lkb_astqueue)) |
32 | list_del(&lkb->lkb_astqueue); | 64 | list_del_init(&lkb->lkb_astqueue); |
33 | spin_unlock(&ast_queue_lock); | 65 | spin_unlock(&ast_queue_lock); |
34 | } | 66 | } |
35 | 67 | ||
36 | void dlm_add_ast(struct dlm_lkb *lkb, int type, int mode) | 68 | int dlm_add_lkb_callback(struct dlm_lkb *lkb, uint32_t flags, int mode, |
69 | int status, uint32_t sbflags, uint64_t seq) | ||
37 | { | 70 | { |
71 | struct dlm_ls *ls = lkb->lkb_resource->res_ls; | ||
72 | uint64_t prev_seq; | ||
73 | int prev_mode; | ||
74 | int i; | ||
75 | |||
76 | for (i = 0; i < DLM_CALLBACKS_SIZE; i++) { | ||
77 | if (lkb->lkb_callbacks[i].seq) | ||
78 | continue; | ||
79 | |||
80 | /* | ||
81 | * Suppress some redundant basts here, do more on removal. | ||
82 | * Don't even add a bast if the callback just before it | ||
83 | * is a bast for the same mode or a more restrictive mode. | ||
84 | * (the addional > PR check is needed for PR/CW inversion) | ||
85 | */ | ||
86 | |||
87 | if ((i > 0) && (flags & DLM_CB_BAST) && | ||
88 | (lkb->lkb_callbacks[i-1].flags & DLM_CB_BAST)) { | ||
89 | |||
90 | prev_seq = lkb->lkb_callbacks[i-1].seq; | ||
91 | prev_mode = lkb->lkb_callbacks[i-1].mode; | ||
92 | |||
93 | if ((prev_mode == mode) || | ||
94 | (prev_mode > mode && prev_mode > DLM_LOCK_PR)) { | ||
95 | |||
96 | log_debug(ls, "skip %x add bast %llu mode %d " | ||
97 | "for bast %llu mode %d", | ||
98 | lkb->lkb_id, | ||
99 | (unsigned long long)seq, | ||
100 | mode, | ||
101 | (unsigned long long)prev_seq, | ||
102 | prev_mode); | ||
103 | return 0; | ||
104 | } | ||
105 | } | ||
106 | |||
107 | lkb->lkb_callbacks[i].seq = seq; | ||
108 | lkb->lkb_callbacks[i].flags = flags; | ||
109 | lkb->lkb_callbacks[i].mode = mode; | ||
110 | lkb->lkb_callbacks[i].sb_status = status; | ||
111 | lkb->lkb_callbacks[i].sb_flags = (sbflags & 0x000000FF); | ||
112 | break; | ||
113 | } | ||
114 | |||
115 | if (i == DLM_CALLBACKS_SIZE) { | ||
116 | log_error(ls, "no callbacks %x %llu flags %x mode %d sb %d %x", | ||
117 | lkb->lkb_id, (unsigned long long)seq, | ||
118 | flags, mode, status, sbflags); | ||
119 | dlm_dump_lkb_callbacks(lkb); | ||
120 | return -1; | ||
121 | } | ||
122 | |||
123 | return 0; | ||
124 | } | ||
125 | |||
126 | int dlm_rem_lkb_callback(struct dlm_ls *ls, struct dlm_lkb *lkb, | ||
127 | struct dlm_callback *cb, int *resid) | ||
128 | { | ||
129 | int i; | ||
130 | |||
131 | *resid = 0; | ||
132 | |||
133 | if (!lkb->lkb_callbacks[0].seq) | ||
134 | return -ENOENT; | ||
135 | |||
136 | /* oldest undelivered cb is callbacks[0] */ | ||
137 | |||
138 | memcpy(cb, &lkb->lkb_callbacks[0], sizeof(struct dlm_callback)); | ||
139 | memset(&lkb->lkb_callbacks[0], 0, sizeof(struct dlm_callback)); | ||
140 | |||
141 | /* shift others down */ | ||
142 | |||
143 | for (i = 1; i < DLM_CALLBACKS_SIZE; i++) { | ||
144 | if (!lkb->lkb_callbacks[i].seq) | ||
145 | break; | ||
146 | memcpy(&lkb->lkb_callbacks[i-1], &lkb->lkb_callbacks[i], | ||
147 | sizeof(struct dlm_callback)); | ||
148 | memset(&lkb->lkb_callbacks[i], 0, sizeof(struct dlm_callback)); | ||
149 | (*resid)++; | ||
150 | } | ||
151 | |||
152 | /* if cb is a bast, it should be skipped if the blocking mode is | ||
153 | compatible with the last granted mode */ | ||
154 | |||
155 | if ((cb->flags & DLM_CB_BAST) && lkb->lkb_last_cast.seq) { | ||
156 | if (dlm_modes_compat(cb->mode, lkb->lkb_last_cast.mode)) { | ||
157 | cb->flags |= DLM_CB_SKIP; | ||
158 | |||
159 | log_debug(ls, "skip %x bast %llu mode %d " | ||
160 | "for cast %llu mode %d", | ||
161 | lkb->lkb_id, | ||
162 | (unsigned long long)cb->seq, | ||
163 | cb->mode, | ||
164 | (unsigned long long)lkb->lkb_last_cast.seq, | ||
165 | lkb->lkb_last_cast.mode); | ||
166 | return 0; | ||
167 | } | ||
168 | } | ||
169 | |||
170 | if (cb->flags & DLM_CB_CAST) { | ||
171 | memcpy(&lkb->lkb_last_cast, cb, sizeof(struct dlm_callback)); | ||
172 | lkb->lkb_last_cast_time = ktime_get(); | ||
173 | } | ||
174 | |||
175 | if (cb->flags & DLM_CB_BAST) { | ||
176 | memcpy(&lkb->lkb_last_bast, cb, sizeof(struct dlm_callback)); | ||
177 | lkb->lkb_last_bast_time = ktime_get(); | ||
178 | } | ||
179 | |||
180 | return 0; | ||
181 | } | ||
182 | |||
183 | void dlm_add_ast(struct dlm_lkb *lkb, uint32_t flags, int mode, int status, | ||
184 | uint32_t sbflags) | ||
185 | { | ||
186 | uint64_t seq; | ||
187 | int rv; | ||
188 | |||
189 | spin_lock(&ast_queue_lock); | ||
190 | |||
191 | seq = ++ast_seq_count; | ||
192 | |||
38 | if (lkb->lkb_flags & DLM_IFL_USER) { | 193 | if (lkb->lkb_flags & DLM_IFL_USER) { |
39 | dlm_user_add_ast(lkb, type, mode); | 194 | spin_unlock(&ast_queue_lock); |
195 | dlm_user_add_ast(lkb, flags, mode, status, sbflags, seq); | ||
40 | return; | 196 | return; |
41 | } | 197 | } |
42 | 198 | ||
43 | spin_lock(&ast_queue_lock); | 199 | rv = dlm_add_lkb_callback(lkb, flags, mode, status, sbflags, seq); |
44 | if (!(lkb->lkb_ast_type & (AST_COMP | AST_BAST))) { | 200 | if (rv < 0) { |
201 | spin_unlock(&ast_queue_lock); | ||
202 | return; | ||
203 | } | ||
204 | |||
205 | if (list_empty(&lkb->lkb_astqueue)) { | ||
45 | kref_get(&lkb->lkb_ref); | 206 | kref_get(&lkb->lkb_ref); |
46 | list_add_tail(&lkb->lkb_astqueue, &ast_queue); | 207 | list_add_tail(&lkb->lkb_astqueue, &ast_queue); |
47 | lkb->lkb_ast_first = type; | ||
48 | } | 208 | } |
49 | |||
50 | /* sanity check, this should not happen */ | ||
51 | |||
52 | if ((type == AST_COMP) && (lkb->lkb_ast_type & AST_COMP)) | ||
53 | log_print("repeat cast %d castmode %d lock %x %s", | ||
54 | mode, lkb->lkb_castmode, | ||
55 | lkb->lkb_id, lkb->lkb_resource->res_name); | ||
56 | |||
57 | lkb->lkb_ast_type |= type; | ||
58 | if (type == AST_BAST) | ||
59 | lkb->lkb_bastmode = mode; | ||
60 | else | ||
61 | lkb->lkb_castmode = mode; | ||
62 | spin_unlock(&ast_queue_lock); | 209 | spin_unlock(&ast_queue_lock); |
63 | 210 | ||
64 | set_bit(WAKE_ASTS, &astd_wakeflags); | 211 | set_bit(WAKE_ASTS, &astd_wakeflags); |
@@ -72,7 +219,8 @@ static void process_asts(void) | |||
72 | struct dlm_lkb *lkb; | 219 | struct dlm_lkb *lkb; |
73 | void (*castfn) (void *astparam); | 220 | void (*castfn) (void *astparam); |
74 | void (*bastfn) (void *astparam, int mode); | 221 | void (*bastfn) (void *astparam, int mode); |
75 | int type, first, bastmode, castmode, do_bast, do_cast, last_castmode; | 222 | struct dlm_callback callbacks[DLM_CALLBACKS_SIZE]; |
223 | int i, rv, resid; | ||
76 | 224 | ||
77 | repeat: | 225 | repeat: |
78 | spin_lock(&ast_queue_lock); | 226 | spin_lock(&ast_queue_lock); |
@@ -83,54 +231,45 @@ repeat: | |||
83 | if (dlm_locking_stopped(ls)) | 231 | if (dlm_locking_stopped(ls)) |
84 | continue; | 232 | continue; |
85 | 233 | ||
86 | list_del(&lkb->lkb_astqueue); | 234 | /* we remove from astqueue list and remove everything in |
87 | type = lkb->lkb_ast_type; | 235 | lkb_callbacks before releasing the spinlock so empty |
88 | lkb->lkb_ast_type = 0; | 236 | lkb_astqueue is always consistent with empty lkb_callbacks */ |
89 | first = lkb->lkb_ast_first; | 237 | |
90 | lkb->lkb_ast_first = 0; | 238 | list_del_init(&lkb->lkb_astqueue); |
91 | bastmode = lkb->lkb_bastmode; | 239 | |
92 | castmode = lkb->lkb_castmode; | ||
93 | castfn = lkb->lkb_astfn; | 240 | castfn = lkb->lkb_astfn; |
94 | bastfn = lkb->lkb_bastfn; | 241 | bastfn = lkb->lkb_bastfn; |
95 | spin_unlock(&ast_queue_lock); | ||
96 | 242 | ||
97 | do_cast = (type & AST_COMP) && castfn; | 243 | memset(&callbacks, 0, sizeof(callbacks)); |
98 | do_bast = (type & AST_BAST) && bastfn; | ||
99 | 244 | ||
100 | /* Skip a bast if its blocking mode is compatible with the | 245 | for (i = 0; i < DLM_CALLBACKS_SIZE; i++) { |
101 | granted mode of the preceding cast. */ | 246 | rv = dlm_rem_lkb_callback(ls, lkb, &callbacks[i], &resid); |
247 | if (rv < 0) | ||
248 | break; | ||
249 | } | ||
250 | spin_unlock(&ast_queue_lock); | ||
102 | 251 | ||
103 | if (do_bast) { | 252 | if (resid) { |
104 | if (first == AST_COMP) | 253 | /* shouldn't happen, for loop should have removed all */ |
105 | last_castmode = castmode; | 254 | log_error(ls, "callback resid %d lkb %x", |
106 | else | 255 | resid, lkb->lkb_id); |
107 | last_castmode = lkb->lkb_castmode_done; | ||
108 | if (dlm_modes_compat(bastmode, last_castmode)) | ||
109 | do_bast = 0; | ||
110 | } | 256 | } |
111 | 257 | ||
112 | if (first == AST_COMP) { | 258 | for (i = 0; i < DLM_CALLBACKS_SIZE; i++) { |
113 | if (do_cast) | 259 | if (!callbacks[i].seq) |
114 | castfn(lkb->lkb_astparam); | 260 | break; |
115 | if (do_bast) | 261 | if (callbacks[i].flags & DLM_CB_SKIP) { |
116 | bastfn(lkb->lkb_astparam, bastmode); | 262 | continue; |
117 | } else if (first == AST_BAST) { | 263 | } else if (callbacks[i].flags & DLM_CB_BAST) { |
118 | if (do_bast) | 264 | bastfn(lkb->lkb_astparam, callbacks[i].mode); |
119 | bastfn(lkb->lkb_astparam, bastmode); | 265 | } else if (callbacks[i].flags & DLM_CB_CAST) { |
120 | if (do_cast) | 266 | lkb->lkb_lksb->sb_status = callbacks[i].sb_status; |
267 | lkb->lkb_lksb->sb_flags = callbacks[i].sb_flags; | ||
121 | castfn(lkb->lkb_astparam); | 268 | castfn(lkb->lkb_astparam); |
122 | } else { | 269 | } |
123 | log_error(ls, "bad ast_first %d ast_type %d", | ||
124 | first, type); | ||
125 | } | 270 | } |
126 | 271 | ||
127 | if (do_cast) | 272 | /* removes ref for ast_queue, may cause lkb to be freed */ |
128 | lkb->lkb_castmode_done = castmode; | ||
129 | if (do_bast) | ||
130 | lkb->lkb_bastmode_done = bastmode; | ||
131 | |||
132 | /* this removes the reference added by dlm_add_ast | ||
133 | and may result in the lkb being freed */ | ||
134 | dlm_put_lkb(lkb); | 273 | dlm_put_lkb(lkb); |
135 | 274 | ||
136 | cond_resched(); | 275 | cond_resched(); |
diff --git a/fs/dlm/ast.h b/fs/dlm/ast.h index bcb1aaba519d..8aa89c9b5611 100644 --- a/fs/dlm/ast.h +++ b/fs/dlm/ast.h | |||
@@ -13,8 +13,13 @@ | |||
13 | #ifndef __ASTD_DOT_H__ | 13 | #ifndef __ASTD_DOT_H__ |
14 | #define __ASTD_DOT_H__ | 14 | #define __ASTD_DOT_H__ |
15 | 15 | ||
16 | void dlm_add_ast(struct dlm_lkb *lkb, int type, int mode); | ||
17 | void dlm_del_ast(struct dlm_lkb *lkb); | 16 | void dlm_del_ast(struct dlm_lkb *lkb); |
17 | int dlm_add_lkb_callback(struct dlm_lkb *lkb, uint32_t flags, int mode, | ||
18 | int status, uint32_t sbflags, uint64_t seq); | ||
19 | int dlm_rem_lkb_callback(struct dlm_ls *ls, struct dlm_lkb *lkb, | ||
20 | struct dlm_callback *cb, int *resid); | ||
21 | void dlm_add_ast(struct dlm_lkb *lkb, uint32_t flags, int mode, int status, | ||
22 | uint32_t sbflags); | ||
18 | 23 | ||
19 | void dlm_astd_wake(void); | 24 | void dlm_astd_wake(void); |
20 | int dlm_astd_start(void); | 25 | int dlm_astd_start(void); |
diff --git a/fs/dlm/config.c b/fs/dlm/config.c index b54bca03d92f..0d329ff8ed4c 100644 --- a/fs/dlm/config.c +++ b/fs/dlm/config.c | |||
@@ -977,9 +977,9 @@ int dlm_our_addr(struct sockaddr_storage *addr, int num) | |||
977 | /* Config file defaults */ | 977 | /* Config file defaults */ |
978 | #define DEFAULT_TCP_PORT 21064 | 978 | #define DEFAULT_TCP_PORT 21064 |
979 | #define DEFAULT_BUFFER_SIZE 4096 | 979 | #define DEFAULT_BUFFER_SIZE 4096 |
980 | #define DEFAULT_RSBTBL_SIZE 256 | 980 | #define DEFAULT_RSBTBL_SIZE 1024 |
981 | #define DEFAULT_LKBTBL_SIZE 1024 | 981 | #define DEFAULT_LKBTBL_SIZE 1024 |
982 | #define DEFAULT_DIRTBL_SIZE 512 | 982 | #define DEFAULT_DIRTBL_SIZE 1024 |
983 | #define DEFAULT_RECOVER_TIMER 5 | 983 | #define DEFAULT_RECOVER_TIMER 5 |
984 | #define DEFAULT_TOSS_SECS 10 | 984 | #define DEFAULT_TOSS_SECS 10 |
985 | #define DEFAULT_SCAN_SECS 5 | 985 | #define DEFAULT_SCAN_SECS 5 |
diff --git a/fs/dlm/debug_fs.c b/fs/dlm/debug_fs.c index 6b42ba807dfd..59779237e2b4 100644 --- a/fs/dlm/debug_fs.c +++ b/fs/dlm/debug_fs.c | |||
@@ -257,12 +257,12 @@ static int print_format3_lock(struct seq_file *s, struct dlm_lkb *lkb, | |||
257 | lkb->lkb_status, | 257 | lkb->lkb_status, |
258 | lkb->lkb_grmode, | 258 | lkb->lkb_grmode, |
259 | lkb->lkb_rqmode, | 259 | lkb->lkb_rqmode, |
260 | lkb->lkb_bastmode, | 260 | lkb->lkb_last_bast.mode, |
261 | rsb_lookup, | 261 | rsb_lookup, |
262 | lkb->lkb_wait_type, | 262 | lkb->lkb_wait_type, |
263 | lkb->lkb_lvbseq, | 263 | lkb->lkb_lvbseq, |
264 | (unsigned long long)ktime_to_ns(lkb->lkb_timestamp), | 264 | (unsigned long long)ktime_to_ns(lkb->lkb_timestamp), |
265 | (unsigned long long)ktime_to_ns(lkb->lkb_time_bast)); | 265 | (unsigned long long)ktime_to_ns(lkb->lkb_last_bast_time)); |
266 | return rv; | 266 | return rv; |
267 | } | 267 | } |
268 | 268 | ||
diff --git a/fs/dlm/dlm_internal.h b/fs/dlm/dlm_internal.h index f632b58cd222..b94204913011 100644 --- a/fs/dlm/dlm_internal.h +++ b/fs/dlm/dlm_internal.h | |||
@@ -192,11 +192,6 @@ struct dlm_args { | |||
192 | * lkb is a process copy, the nodeid specifies the lock master. | 192 | * lkb is a process copy, the nodeid specifies the lock master. |
193 | */ | 193 | */ |
194 | 194 | ||
195 | /* lkb_ast_type */ | ||
196 | |||
197 | #define AST_COMP 1 | ||
198 | #define AST_BAST 2 | ||
199 | |||
200 | /* lkb_status */ | 195 | /* lkb_status */ |
201 | 196 | ||
202 | #define DLM_LKSTS_WAITING 1 | 197 | #define DLM_LKSTS_WAITING 1 |
@@ -217,6 +212,20 @@ struct dlm_args { | |||
217 | #define DLM_IFL_USER 0x00000001 | 212 | #define DLM_IFL_USER 0x00000001 |
218 | #define DLM_IFL_ORPHAN 0x00000002 | 213 | #define DLM_IFL_ORPHAN 0x00000002 |
219 | 214 | ||
215 | #define DLM_CALLBACKS_SIZE 6 | ||
216 | |||
217 | #define DLM_CB_CAST 0x00000001 | ||
218 | #define DLM_CB_BAST 0x00000002 | ||
219 | #define DLM_CB_SKIP 0x00000004 | ||
220 | |||
221 | struct dlm_callback { | ||
222 | uint64_t seq; | ||
223 | uint32_t flags; /* DLM_CBF_ */ | ||
224 | int sb_status; /* copy to lksb status */ | ||
225 | uint8_t sb_flags; /* copy to lksb flags */ | ||
226 | int8_t mode; /* rq mode of bast, gr mode of cast */ | ||
227 | }; | ||
228 | |||
220 | struct dlm_lkb { | 229 | struct dlm_lkb { |
221 | struct dlm_rsb *lkb_resource; /* the rsb */ | 230 | struct dlm_rsb *lkb_resource; /* the rsb */ |
222 | struct kref lkb_ref; | 231 | struct kref lkb_ref; |
@@ -236,13 +245,6 @@ struct dlm_lkb { | |||
236 | 245 | ||
237 | int8_t lkb_wait_type; /* type of reply waiting for */ | 246 | int8_t lkb_wait_type; /* type of reply waiting for */ |
238 | int8_t lkb_wait_count; | 247 | int8_t lkb_wait_count; |
239 | int8_t lkb_ast_type; /* type of ast queued for */ | ||
240 | int8_t lkb_ast_first; /* type of first ast queued */ | ||
241 | |||
242 | int8_t lkb_bastmode; /* req mode of queued bast */ | ||
243 | int8_t lkb_castmode; /* gr mode of queued cast */ | ||
244 | int8_t lkb_bastmode_done; /* last delivered bastmode */ | ||
245 | int8_t lkb_castmode_done; /* last delivered castmode */ | ||
246 | 248 | ||
247 | struct list_head lkb_idtbl_list; /* lockspace lkbtbl */ | 249 | struct list_head lkb_idtbl_list; /* lockspace lkbtbl */ |
248 | struct list_head lkb_statequeue; /* rsb g/c/w list */ | 250 | struct list_head lkb_statequeue; /* rsb g/c/w list */ |
@@ -251,10 +253,15 @@ struct dlm_lkb { | |||
251 | struct list_head lkb_astqueue; /* need ast to be sent */ | 253 | struct list_head lkb_astqueue; /* need ast to be sent */ |
252 | struct list_head lkb_ownqueue; /* list of locks for a process */ | 254 | struct list_head lkb_ownqueue; /* list of locks for a process */ |
253 | struct list_head lkb_time_list; | 255 | struct list_head lkb_time_list; |
254 | ktime_t lkb_time_bast; /* for debugging */ | ||
255 | ktime_t lkb_timestamp; | 256 | ktime_t lkb_timestamp; |
256 | unsigned long lkb_timeout_cs; | 257 | unsigned long lkb_timeout_cs; |
257 | 258 | ||
259 | struct dlm_callback lkb_callbacks[DLM_CALLBACKS_SIZE]; | ||
260 | struct dlm_callback lkb_last_cast; | ||
261 | struct dlm_callback lkb_last_bast; | ||
262 | ktime_t lkb_last_cast_time; /* for debugging */ | ||
263 | ktime_t lkb_last_bast_time; /* for debugging */ | ||
264 | |||
258 | char *lkb_lvbptr; | 265 | char *lkb_lvbptr; |
259 | struct dlm_lksb *lkb_lksb; /* caller's status block */ | 266 | struct dlm_lksb *lkb_lksb; /* caller's status block */ |
260 | void (*lkb_astfn) (void *astparam); | 267 | void (*lkb_astfn) (void *astparam); |
@@ -544,8 +551,6 @@ struct dlm_user_args { | |||
544 | (dlm_user_proc) on the struct file, | 551 | (dlm_user_proc) on the struct file, |
545 | the process's locks point back to it*/ | 552 | the process's locks point back to it*/ |
546 | struct dlm_lksb lksb; | 553 | struct dlm_lksb lksb; |
547 | int old_mode; | ||
548 | int update_user_lvb; | ||
549 | struct dlm_lksb __user *user_lksb; | 554 | struct dlm_lksb __user *user_lksb; |
550 | void __user *castparam; | 555 | void __user *castparam; |
551 | void __user *castaddr; | 556 | void __user *castaddr; |
diff --git a/fs/dlm/lock.c b/fs/dlm/lock.c index 64e5f3efdd81..04b8c449303f 100644 --- a/fs/dlm/lock.c +++ b/fs/dlm/lock.c | |||
@@ -160,10 +160,10 @@ static const int __quecvt_compat_matrix[8][8] = { | |||
160 | void dlm_print_lkb(struct dlm_lkb *lkb) | 160 | void dlm_print_lkb(struct dlm_lkb *lkb) |
161 | { | 161 | { |
162 | printk(KERN_ERR "lkb: nodeid %d id %x remid %x exflags %x flags %x\n" | 162 | printk(KERN_ERR "lkb: nodeid %d id %x remid %x exflags %x flags %x\n" |
163 | " status %d rqmode %d grmode %d wait_type %d ast_type %d\n", | 163 | " status %d rqmode %d grmode %d wait_type %d\n", |
164 | lkb->lkb_nodeid, lkb->lkb_id, lkb->lkb_remid, lkb->lkb_exflags, | 164 | lkb->lkb_nodeid, lkb->lkb_id, lkb->lkb_remid, lkb->lkb_exflags, |
165 | lkb->lkb_flags, lkb->lkb_status, lkb->lkb_rqmode, | 165 | lkb->lkb_flags, lkb->lkb_status, lkb->lkb_rqmode, |
166 | lkb->lkb_grmode, lkb->lkb_wait_type, lkb->lkb_ast_type); | 166 | lkb->lkb_grmode, lkb->lkb_wait_type); |
167 | } | 167 | } |
168 | 168 | ||
169 | static void dlm_print_rsb(struct dlm_rsb *r) | 169 | static void dlm_print_rsb(struct dlm_rsb *r) |
@@ -305,10 +305,7 @@ static void queue_cast(struct dlm_rsb *r, struct dlm_lkb *lkb, int rv) | |||
305 | rv = -EDEADLK; | 305 | rv = -EDEADLK; |
306 | } | 306 | } |
307 | 307 | ||
308 | lkb->lkb_lksb->sb_status = rv; | 308 | dlm_add_ast(lkb, DLM_CB_CAST, lkb->lkb_grmode, rv, lkb->lkb_sbflags); |
309 | lkb->lkb_lksb->sb_flags = lkb->lkb_sbflags; | ||
310 | |||
311 | dlm_add_ast(lkb, AST_COMP, lkb->lkb_grmode); | ||
312 | } | 309 | } |
313 | 310 | ||
314 | static inline void queue_cast_overlap(struct dlm_rsb *r, struct dlm_lkb *lkb) | 311 | static inline void queue_cast_overlap(struct dlm_rsb *r, struct dlm_lkb *lkb) |
@@ -319,13 +316,10 @@ static inline void queue_cast_overlap(struct dlm_rsb *r, struct dlm_lkb *lkb) | |||
319 | 316 | ||
320 | static void queue_bast(struct dlm_rsb *r, struct dlm_lkb *lkb, int rqmode) | 317 | static void queue_bast(struct dlm_rsb *r, struct dlm_lkb *lkb, int rqmode) |
321 | { | 318 | { |
322 | lkb->lkb_time_bast = ktime_get(); | ||
323 | |||
324 | if (is_master_copy(lkb)) { | 319 | if (is_master_copy(lkb)) { |
325 | lkb->lkb_bastmode = rqmode; /* printed by debugfs */ | ||
326 | send_bast(r, lkb, rqmode); | 320 | send_bast(r, lkb, rqmode); |
327 | } else { | 321 | } else { |
328 | dlm_add_ast(lkb, AST_BAST, rqmode); | 322 | dlm_add_ast(lkb, DLM_CB_BAST, rqmode, 0, 0); |
329 | } | 323 | } |
330 | } | 324 | } |
331 | 325 | ||
@@ -600,6 +594,7 @@ static int create_lkb(struct dlm_ls *ls, struct dlm_lkb **lkb_ret) | |||
600 | INIT_LIST_HEAD(&lkb->lkb_ownqueue); | 594 | INIT_LIST_HEAD(&lkb->lkb_ownqueue); |
601 | INIT_LIST_HEAD(&lkb->lkb_rsb_lookup); | 595 | INIT_LIST_HEAD(&lkb->lkb_rsb_lookup); |
602 | INIT_LIST_HEAD(&lkb->lkb_time_list); | 596 | INIT_LIST_HEAD(&lkb->lkb_time_list); |
597 | INIT_LIST_HEAD(&lkb->lkb_astqueue); | ||
603 | 598 | ||
604 | get_random_bytes(&bucket, sizeof(bucket)); | 599 | get_random_bytes(&bucket, sizeof(bucket)); |
605 | bucket &= (ls->ls_lkbtbl_size - 1); | 600 | bucket &= (ls->ls_lkbtbl_size - 1); |
@@ -2819,9 +2814,9 @@ static void send_args(struct dlm_rsb *r, struct dlm_lkb *lkb, | |||
2819 | not from lkb fields */ | 2814 | not from lkb fields */ |
2820 | 2815 | ||
2821 | if (lkb->lkb_bastfn) | 2816 | if (lkb->lkb_bastfn) |
2822 | ms->m_asts |= AST_BAST; | 2817 | ms->m_asts |= DLM_CB_BAST; |
2823 | if (lkb->lkb_astfn) | 2818 | if (lkb->lkb_astfn) |
2824 | ms->m_asts |= AST_COMP; | 2819 | ms->m_asts |= DLM_CB_CAST; |
2825 | 2820 | ||
2826 | /* compare with switch in create_message; send_remove() doesn't | 2821 | /* compare with switch in create_message; send_remove() doesn't |
2827 | use send_args() */ | 2822 | use send_args() */ |
@@ -3122,8 +3117,8 @@ static int receive_request_args(struct dlm_ls *ls, struct dlm_lkb *lkb, | |||
3122 | lkb->lkb_grmode = DLM_LOCK_IV; | 3117 | lkb->lkb_grmode = DLM_LOCK_IV; |
3123 | lkb->lkb_rqmode = ms->m_rqmode; | 3118 | lkb->lkb_rqmode = ms->m_rqmode; |
3124 | 3119 | ||
3125 | lkb->lkb_bastfn = (ms->m_asts & AST_BAST) ? &fake_bastfn : NULL; | 3120 | lkb->lkb_bastfn = (ms->m_asts & DLM_CB_BAST) ? &fake_bastfn : NULL; |
3126 | lkb->lkb_astfn = (ms->m_asts & AST_COMP) ? &fake_astfn : NULL; | 3121 | lkb->lkb_astfn = (ms->m_asts & DLM_CB_CAST) ? &fake_astfn : NULL; |
3127 | 3122 | ||
3128 | if (lkb->lkb_exflags & DLM_LKF_VALBLK) { | 3123 | if (lkb->lkb_exflags & DLM_LKF_VALBLK) { |
3129 | /* lkb was just created so there won't be an lvb yet */ | 3124 | /* lkb was just created so there won't be an lvb yet */ |
@@ -4412,8 +4407,8 @@ static int receive_rcom_lock_args(struct dlm_ls *ls, struct dlm_lkb *lkb, | |||
4412 | lkb->lkb_grmode = rl->rl_grmode; | 4407 | lkb->lkb_grmode = rl->rl_grmode; |
4413 | /* don't set lkb_status because add_lkb wants to itself */ | 4408 | /* don't set lkb_status because add_lkb wants to itself */ |
4414 | 4409 | ||
4415 | lkb->lkb_bastfn = (rl->rl_asts & AST_BAST) ? &fake_bastfn : NULL; | 4410 | lkb->lkb_bastfn = (rl->rl_asts & DLM_CB_BAST) ? &fake_bastfn : NULL; |
4416 | lkb->lkb_astfn = (rl->rl_asts & AST_COMP) ? &fake_astfn : NULL; | 4411 | lkb->lkb_astfn = (rl->rl_asts & DLM_CB_CAST) ? &fake_astfn : NULL; |
4417 | 4412 | ||
4418 | if (lkb->lkb_exflags & DLM_LKF_VALBLK) { | 4413 | if (lkb->lkb_exflags & DLM_LKF_VALBLK) { |
4419 | int lvblen = rc->rc_header.h_length - sizeof(struct dlm_rcom) - | 4414 | int lvblen = rc->rc_header.h_length - sizeof(struct dlm_rcom) - |
@@ -4589,7 +4584,6 @@ int dlm_user_request(struct dlm_ls *ls, struct dlm_user_args *ua, | |||
4589 | error = set_lock_args(mode, &ua->lksb, flags, namelen, timeout_cs, | 4584 | error = set_lock_args(mode, &ua->lksb, flags, namelen, timeout_cs, |
4590 | fake_astfn, ua, fake_bastfn, &args); | 4585 | fake_astfn, ua, fake_bastfn, &args); |
4591 | lkb->lkb_flags |= DLM_IFL_USER; | 4586 | lkb->lkb_flags |= DLM_IFL_USER; |
4592 | ua->old_mode = DLM_LOCK_IV; | ||
4593 | 4587 | ||
4594 | if (error) { | 4588 | if (error) { |
4595 | __put_lkb(ls, lkb); | 4589 | __put_lkb(ls, lkb); |
@@ -4658,7 +4652,6 @@ int dlm_user_convert(struct dlm_ls *ls, struct dlm_user_args *ua_tmp, | |||
4658 | ua->bastparam = ua_tmp->bastparam; | 4652 | ua->bastparam = ua_tmp->bastparam; |
4659 | ua->bastaddr = ua_tmp->bastaddr; | 4653 | ua->bastaddr = ua_tmp->bastaddr; |
4660 | ua->user_lksb = ua_tmp->user_lksb; | 4654 | ua->user_lksb = ua_tmp->user_lksb; |
4661 | ua->old_mode = lkb->lkb_grmode; | ||
4662 | 4655 | ||
4663 | error = set_lock_args(mode, &ua->lksb, flags, 0, timeout_cs, | 4656 | error = set_lock_args(mode, &ua->lksb, flags, 0, timeout_cs, |
4664 | fake_astfn, ua, fake_bastfn, &args); | 4657 | fake_astfn, ua, fake_bastfn, &args); |
@@ -4917,8 +4910,9 @@ void dlm_clear_proc_locks(struct dlm_ls *ls, struct dlm_user_proc *proc) | |||
4917 | } | 4910 | } |
4918 | 4911 | ||
4919 | list_for_each_entry_safe(lkb, safe, &proc->asts, lkb_astqueue) { | 4912 | list_for_each_entry_safe(lkb, safe, &proc->asts, lkb_astqueue) { |
4920 | lkb->lkb_ast_type = 0; | 4913 | memset(&lkb->lkb_callbacks, 0, |
4921 | list_del(&lkb->lkb_astqueue); | 4914 | sizeof(struct dlm_callback) * DLM_CALLBACKS_SIZE); |
4915 | list_del_init(&lkb->lkb_astqueue); | ||
4922 | dlm_put_lkb(lkb); | 4916 | dlm_put_lkb(lkb); |
4923 | } | 4917 | } |
4924 | 4918 | ||
@@ -4958,7 +4952,9 @@ static void purge_proc_locks(struct dlm_ls *ls, struct dlm_user_proc *proc) | |||
4958 | 4952 | ||
4959 | spin_lock(&proc->asts_spin); | 4953 | spin_lock(&proc->asts_spin); |
4960 | list_for_each_entry_safe(lkb, safe, &proc->asts, lkb_astqueue) { | 4954 | list_for_each_entry_safe(lkb, safe, &proc->asts, lkb_astqueue) { |
4961 | list_del(&lkb->lkb_astqueue); | 4955 | memset(&lkb->lkb_callbacks, 0, |
4956 | sizeof(struct dlm_callback) * DLM_CALLBACKS_SIZE); | ||
4957 | list_del_init(&lkb->lkb_astqueue); | ||
4962 | dlm_put_lkb(lkb); | 4958 | dlm_put_lkb(lkb); |
4963 | } | 4959 | } |
4964 | spin_unlock(&proc->asts_spin); | 4960 | spin_unlock(&proc->asts_spin); |
diff --git a/fs/dlm/lowcomms.c b/fs/dlm/lowcomms.c index 2d8c87b951c2..bffa1e73b9a9 100644 --- a/fs/dlm/lowcomms.c +++ b/fs/dlm/lowcomms.c | |||
@@ -1468,13 +1468,15 @@ static void work_stop(void) | |||
1468 | 1468 | ||
1469 | static int work_start(void) | 1469 | static int work_start(void) |
1470 | { | 1470 | { |
1471 | recv_workqueue = create_singlethread_workqueue("dlm_recv"); | 1471 | recv_workqueue = alloc_workqueue("dlm_recv", |
1472 | WQ_UNBOUND | WQ_MEM_RECLAIM, 1); | ||
1472 | if (!recv_workqueue) { | 1473 | if (!recv_workqueue) { |
1473 | log_print("can't start dlm_recv"); | 1474 | log_print("can't start dlm_recv"); |
1474 | return -ENOMEM; | 1475 | return -ENOMEM; |
1475 | } | 1476 | } |
1476 | 1477 | ||
1477 | send_workqueue = create_singlethread_workqueue("dlm_send"); | 1478 | send_workqueue = alloc_workqueue("dlm_send", |
1479 | WQ_UNBOUND | WQ_MEM_RECLAIM, 1); | ||
1478 | if (!send_workqueue) { | 1480 | if (!send_workqueue) { |
1479 | log_print("can't start dlm_send"); | 1481 | log_print("can't start dlm_send"); |
1480 | destroy_workqueue(recv_workqueue); | 1482 | destroy_workqueue(recv_workqueue); |
diff --git a/fs/dlm/rcom.c b/fs/dlm/rcom.c index 3c83a49a48a3..f10a50f24e8f 100644 --- a/fs/dlm/rcom.c +++ b/fs/dlm/rcom.c | |||
@@ -321,9 +321,9 @@ static void pack_rcom_lock(struct dlm_rsb *r, struct dlm_lkb *lkb, | |||
321 | rl->rl_wait_type = cpu_to_le16(lkb->lkb_wait_type); | 321 | rl->rl_wait_type = cpu_to_le16(lkb->lkb_wait_type); |
322 | 322 | ||
323 | if (lkb->lkb_bastfn) | 323 | if (lkb->lkb_bastfn) |
324 | rl->rl_asts |= AST_BAST; | 324 | rl->rl_asts |= DLM_CB_BAST; |
325 | if (lkb->lkb_astfn) | 325 | if (lkb->lkb_astfn) |
326 | rl->rl_asts |= AST_COMP; | 326 | rl->rl_asts |= DLM_CB_CAST; |
327 | 327 | ||
328 | rl->rl_namelen = cpu_to_le16(r->res_length); | 328 | rl->rl_namelen = cpu_to_le16(r->res_length); |
329 | memcpy(rl->rl_name, r->res_name, r->res_length); | 329 | memcpy(rl->rl_name, r->res_name, r->res_length); |
diff --git a/fs/dlm/user.c b/fs/dlm/user.c index 66d6c16bf440..d5ab3fe7c198 100644 --- a/fs/dlm/user.c +++ b/fs/dlm/user.c | |||
@@ -24,6 +24,7 @@ | |||
24 | #include "lock.h" | 24 | #include "lock.h" |
25 | #include "lvb_table.h" | 25 | #include "lvb_table.h" |
26 | #include "user.h" | 26 | #include "user.h" |
27 | #include "ast.h" | ||
27 | 28 | ||
28 | static const char name_prefix[] = "dlm"; | 29 | static const char name_prefix[] = "dlm"; |
29 | static const struct file_operations device_fops; | 30 | static const struct file_operations device_fops; |
@@ -152,19 +153,16 @@ static void compat_output(struct dlm_lock_result *res, | |||
152 | not related to the lifetime of the lkb struct which is managed | 153 | not related to the lifetime of the lkb struct which is managed |
153 | entirely by refcount. */ | 154 | entirely by refcount. */ |
154 | 155 | ||
155 | static int lkb_is_endoflife(struct dlm_lkb *lkb, int sb_status, int type) | 156 | static int lkb_is_endoflife(int mode, int status) |
156 | { | 157 | { |
157 | switch (sb_status) { | 158 | switch (status) { |
158 | case -DLM_EUNLOCK: | 159 | case -DLM_EUNLOCK: |
159 | return 1; | 160 | return 1; |
160 | case -DLM_ECANCEL: | 161 | case -DLM_ECANCEL: |
161 | case -ETIMEDOUT: | 162 | case -ETIMEDOUT: |
162 | case -EDEADLK: | 163 | case -EDEADLK: |
163 | if (lkb->lkb_grmode == DLM_LOCK_IV) | ||
164 | return 1; | ||
165 | break; | ||
166 | case -EAGAIN: | 164 | case -EAGAIN: |
167 | if (type == AST_COMP && lkb->lkb_grmode == DLM_LOCK_IV) | 165 | if (mode == DLM_LOCK_IV) |
168 | return 1; | 166 | return 1; |
169 | break; | 167 | break; |
170 | } | 168 | } |
@@ -174,12 +172,13 @@ static int lkb_is_endoflife(struct dlm_lkb *lkb, int sb_status, int type) | |||
174 | /* we could possibly check if the cancel of an orphan has resulted in the lkb | 172 | /* we could possibly check if the cancel of an orphan has resulted in the lkb |
175 | being removed and then remove that lkb from the orphans list and free it */ | 173 | being removed and then remove that lkb from the orphans list and free it */ |
176 | 174 | ||
177 | void dlm_user_add_ast(struct dlm_lkb *lkb, int type, int mode) | 175 | void dlm_user_add_ast(struct dlm_lkb *lkb, uint32_t flags, int mode, |
176 | int status, uint32_t sbflags, uint64_t seq) | ||
178 | { | 177 | { |
179 | struct dlm_ls *ls; | 178 | struct dlm_ls *ls; |
180 | struct dlm_user_args *ua; | 179 | struct dlm_user_args *ua; |
181 | struct dlm_user_proc *proc; | 180 | struct dlm_user_proc *proc; |
182 | int eol = 0, ast_type; | 181 | int rv; |
183 | 182 | ||
184 | if (lkb->lkb_flags & (DLM_IFL_ORPHAN | DLM_IFL_DEAD)) | 183 | if (lkb->lkb_flags & (DLM_IFL_ORPHAN | DLM_IFL_DEAD)) |
185 | return; | 184 | return; |
@@ -200,49 +199,29 @@ void dlm_user_add_ast(struct dlm_lkb *lkb, int type, int mode) | |||
200 | ua = lkb->lkb_ua; | 199 | ua = lkb->lkb_ua; |
201 | proc = ua->proc; | 200 | proc = ua->proc; |
202 | 201 | ||
203 | if (type == AST_BAST && ua->bastaddr == NULL) | 202 | if ((flags & DLM_CB_BAST) && ua->bastaddr == NULL) |
204 | goto out; | 203 | goto out; |
205 | 204 | ||
205 | if ((flags & DLM_CB_CAST) && lkb_is_endoflife(mode, status)) | ||
206 | lkb->lkb_flags |= DLM_IFL_ENDOFLIFE; | ||
207 | |||
206 | spin_lock(&proc->asts_spin); | 208 | spin_lock(&proc->asts_spin); |
207 | 209 | ||
208 | ast_type = lkb->lkb_ast_type; | 210 | rv = dlm_add_lkb_callback(lkb, flags, mode, status, sbflags, seq); |
209 | lkb->lkb_ast_type |= type; | 211 | if (rv < 0) { |
210 | if (type == AST_BAST) | 212 | spin_unlock(&proc->asts_spin); |
211 | lkb->lkb_bastmode = mode; | 213 | goto out; |
212 | else | 214 | } |
213 | lkb->lkb_castmode = mode; | ||
214 | 215 | ||
215 | if (!ast_type) { | 216 | if (list_empty(&lkb->lkb_astqueue)) { |
216 | kref_get(&lkb->lkb_ref); | 217 | kref_get(&lkb->lkb_ref); |
217 | list_add_tail(&lkb->lkb_astqueue, &proc->asts); | 218 | list_add_tail(&lkb->lkb_astqueue, &proc->asts); |
218 | lkb->lkb_ast_first = type; | ||
219 | wake_up_interruptible(&proc->wait); | 219 | wake_up_interruptible(&proc->wait); |
220 | } | 220 | } |
221 | if (type == AST_COMP && (ast_type & AST_COMP)) | ||
222 | log_debug(ls, "ast overlap %x status %x %x", | ||
223 | lkb->lkb_id, ua->lksb.sb_status, lkb->lkb_flags); | ||
224 | |||
225 | eol = lkb_is_endoflife(lkb, ua->lksb.sb_status, type); | ||
226 | if (eol) { | ||
227 | lkb->lkb_flags |= DLM_IFL_ENDOFLIFE; | ||
228 | } | ||
229 | |||
230 | /* We want to copy the lvb to userspace when the completion | ||
231 | ast is read if the status is 0, the lock has an lvb and | ||
232 | lvb_ops says we should. We could probably have set_lvb_lock() | ||
233 | set update_user_lvb instead and not need old_mode */ | ||
234 | |||
235 | if ((lkb->lkb_ast_type & AST_COMP) && | ||
236 | (lkb->lkb_lksb->sb_status == 0) && | ||
237 | lkb->lkb_lksb->sb_lvbptr && | ||
238 | dlm_lvb_operations[ua->old_mode + 1][lkb->lkb_grmode + 1]) | ||
239 | ua->update_user_lvb = 1; | ||
240 | else | ||
241 | ua->update_user_lvb = 0; | ||
242 | |||
243 | spin_unlock(&proc->asts_spin); | 221 | spin_unlock(&proc->asts_spin); |
244 | 222 | ||
245 | if (eol) { | 223 | if (lkb->lkb_flags & DLM_IFL_ENDOFLIFE) { |
224 | /* N.B. spin_lock locks_spin, not asts_spin */ | ||
246 | spin_lock(&proc->locks_spin); | 225 | spin_lock(&proc->locks_spin); |
247 | if (!list_empty(&lkb->lkb_ownqueue)) { | 226 | if (!list_empty(&lkb->lkb_ownqueue)) { |
248 | list_del_init(&lkb->lkb_ownqueue); | 227 | list_del_init(&lkb->lkb_ownqueue); |
@@ -705,8 +684,9 @@ static int device_close(struct inode *inode, struct file *file) | |||
705 | return 0; | 684 | return 0; |
706 | } | 685 | } |
707 | 686 | ||
708 | static int copy_result_to_user(struct dlm_user_args *ua, int compat, int type, | 687 | static int copy_result_to_user(struct dlm_user_args *ua, int compat, |
709 | int mode, char __user *buf, size_t count) | 688 | uint32_t flags, int mode, int copy_lvb, |
689 | char __user *buf, size_t count) | ||
710 | { | 690 | { |
711 | #ifdef CONFIG_COMPAT | 691 | #ifdef CONFIG_COMPAT |
712 | struct dlm_lock_result32 result32; | 692 | struct dlm_lock_result32 result32; |
@@ -730,7 +710,7 @@ static int copy_result_to_user(struct dlm_user_args *ua, int compat, int type, | |||
730 | notes that a new blocking AST address and parameter are set even if | 710 | notes that a new blocking AST address and parameter are set even if |
731 | the conversion fails, so maybe we should just do that. */ | 711 | the conversion fails, so maybe we should just do that. */ |
732 | 712 | ||
733 | if (type == AST_BAST) { | 713 | if (flags & DLM_CB_BAST) { |
734 | result.user_astaddr = ua->bastaddr; | 714 | result.user_astaddr = ua->bastaddr; |
735 | result.user_astparam = ua->bastparam; | 715 | result.user_astparam = ua->bastparam; |
736 | result.bast_mode = mode; | 716 | result.bast_mode = mode; |
@@ -750,8 +730,7 @@ static int copy_result_to_user(struct dlm_user_args *ua, int compat, int type, | |||
750 | /* copy lvb to userspace if there is one, it's been updated, and | 730 | /* copy lvb to userspace if there is one, it's been updated, and |
751 | the user buffer has space for it */ | 731 | the user buffer has space for it */ |
752 | 732 | ||
753 | if (ua->update_user_lvb && ua->lksb.sb_lvbptr && | 733 | if (copy_lvb && ua->lksb.sb_lvbptr && count >= len + DLM_USER_LVB_LEN) { |
754 | count >= len + DLM_USER_LVB_LEN) { | ||
755 | if (copy_to_user(buf+len, ua->lksb.sb_lvbptr, | 734 | if (copy_to_user(buf+len, ua->lksb.sb_lvbptr, |
756 | DLM_USER_LVB_LEN)) { | 735 | DLM_USER_LVB_LEN)) { |
757 | error = -EFAULT; | 736 | error = -EFAULT; |
@@ -801,13 +780,12 @@ static ssize_t device_read(struct file *file, char __user *buf, size_t count, | |||
801 | struct dlm_user_proc *proc = file->private_data; | 780 | struct dlm_user_proc *proc = file->private_data; |
802 | struct dlm_lkb *lkb; | 781 | struct dlm_lkb *lkb; |
803 | DECLARE_WAITQUEUE(wait, current); | 782 | DECLARE_WAITQUEUE(wait, current); |
804 | int error = 0, removed; | 783 | struct dlm_callback cb; |
805 | int ret_type, ret_mode; | 784 | int rv, resid, copy_lvb = 0; |
806 | int bastmode, castmode, do_bast, do_cast; | ||
807 | 785 | ||
808 | if (count == sizeof(struct dlm_device_version)) { | 786 | if (count == sizeof(struct dlm_device_version)) { |
809 | error = copy_version_to_user(buf, count); | 787 | rv = copy_version_to_user(buf, count); |
810 | return error; | 788 | return rv; |
811 | } | 789 | } |
812 | 790 | ||
813 | if (!proc) { | 791 | if (!proc) { |
@@ -854,92 +832,57 @@ static ssize_t device_read(struct file *file, char __user *buf, size_t count, | |||
854 | } | 832 | } |
855 | } | 833 | } |
856 | 834 | ||
857 | /* there may be both completion and blocking asts to return for | 835 | /* if we empty lkb_callbacks, we don't want to unlock the spinlock |
858 | the lkb, don't remove lkb from asts list unless no asts remain */ | 836 | without removing lkb_astqueue; so empty lkb_astqueue is always |
837 | consistent with empty lkb_callbacks */ | ||
859 | 838 | ||
860 | lkb = list_entry(proc->asts.next, struct dlm_lkb, lkb_astqueue); | 839 | lkb = list_entry(proc->asts.next, struct dlm_lkb, lkb_astqueue); |
861 | 840 | ||
862 | removed = 0; | 841 | rv = dlm_rem_lkb_callback(lkb->lkb_resource->res_ls, lkb, &cb, &resid); |
863 | ret_type = 0; | 842 | if (rv < 0) { |
864 | ret_mode = 0; | 843 | /* this shouldn't happen; lkb should have been removed from |
865 | do_bast = lkb->lkb_ast_type & AST_BAST; | 844 | list when resid was zero */ |
866 | do_cast = lkb->lkb_ast_type & AST_COMP; | 845 | log_print("dlm_rem_lkb_callback empty %x", lkb->lkb_id); |
867 | bastmode = lkb->lkb_bastmode; | 846 | list_del_init(&lkb->lkb_astqueue); |
868 | castmode = lkb->lkb_castmode; | 847 | spin_unlock(&proc->asts_spin); |
869 | 848 | /* removes ref for proc->asts, may cause lkb to be freed */ | |
870 | /* when both are queued figure out which to do first and | 849 | dlm_put_lkb(lkb); |
871 | switch first so the other goes in the next read */ | 850 | goto try_another; |
872 | |||
873 | if (do_cast && do_bast) { | ||
874 | if (lkb->lkb_ast_first == AST_COMP) { | ||
875 | ret_type = AST_COMP; | ||
876 | ret_mode = castmode; | ||
877 | lkb->lkb_ast_type &= ~AST_COMP; | ||
878 | lkb->lkb_ast_first = AST_BAST; | ||
879 | } else { | ||
880 | ret_type = AST_BAST; | ||
881 | ret_mode = bastmode; | ||
882 | lkb->lkb_ast_type &= ~AST_BAST; | ||
883 | lkb->lkb_ast_first = AST_COMP; | ||
884 | } | ||
885 | } else { | ||
886 | ret_type = lkb->lkb_ast_first; | ||
887 | ret_mode = (ret_type == AST_COMP) ? castmode : bastmode; | ||
888 | lkb->lkb_ast_type &= ~ret_type; | ||
889 | lkb->lkb_ast_first = 0; | ||
890 | } | 851 | } |
852 | if (!resid) | ||
853 | list_del_init(&lkb->lkb_astqueue); | ||
854 | spin_unlock(&proc->asts_spin); | ||
891 | 855 | ||
892 | /* if we're doing a bast but the bast is unnecessary, then | 856 | if (cb.flags & DLM_CB_SKIP) { |
893 | switch to do nothing or do a cast if that was needed next */ | 857 | /* removes ref for proc->asts, may cause lkb to be freed */ |
894 | 858 | if (!resid) | |
895 | if ((ret_type == AST_BAST) && | 859 | dlm_put_lkb(lkb); |
896 | dlm_modes_compat(bastmode, lkb->lkb_castmode_done)) { | 860 | goto try_another; |
897 | ret_type = 0; | ||
898 | ret_mode = 0; | ||
899 | |||
900 | if (do_cast) { | ||
901 | ret_type = AST_COMP; | ||
902 | ret_mode = castmode; | ||
903 | lkb->lkb_ast_type &= ~AST_COMP; | ||
904 | lkb->lkb_ast_first = 0; | ||
905 | } | ||
906 | } | 861 | } |
907 | 862 | ||
908 | if (lkb->lkb_ast_first != lkb->lkb_ast_type) { | 863 | if (cb.flags & DLM_CB_CAST) { |
909 | log_print("device_read %x ast_first %x ast_type %x", | 864 | int old_mode, new_mode; |
910 | lkb->lkb_id, lkb->lkb_ast_first, lkb->lkb_ast_type); | ||
911 | } | ||
912 | 865 | ||
913 | if (!lkb->lkb_ast_type) { | 866 | old_mode = lkb->lkb_last_cast.mode; |
914 | list_del(&lkb->lkb_astqueue); | 867 | new_mode = cb.mode; |
915 | removed = 1; | ||
916 | } | ||
917 | spin_unlock(&proc->asts_spin); | ||
918 | 868 | ||
919 | if (ret_type) { | 869 | if (!cb.sb_status && lkb->lkb_lksb->sb_lvbptr && |
920 | error = copy_result_to_user(lkb->lkb_ua, | 870 | dlm_lvb_operations[old_mode + 1][new_mode + 1]) |
921 | test_bit(DLM_PROC_FLAGS_COMPAT, &proc->flags), | 871 | copy_lvb = 1; |
922 | ret_type, ret_mode, buf, count); | ||
923 | 872 | ||
924 | if (ret_type == AST_COMP) | 873 | lkb->lkb_lksb->sb_status = cb.sb_status; |
925 | lkb->lkb_castmode_done = castmode; | 874 | lkb->lkb_lksb->sb_flags = cb.sb_flags; |
926 | if (ret_type == AST_BAST) | ||
927 | lkb->lkb_bastmode_done = bastmode; | ||
928 | } | 875 | } |
929 | 876 | ||
930 | /* removes reference for the proc->asts lists added by | 877 | rv = copy_result_to_user(lkb->lkb_ua, |
931 | dlm_user_add_ast() and may result in the lkb being freed */ | 878 | test_bit(DLM_PROC_FLAGS_COMPAT, &proc->flags), |
879 | cb.flags, cb.mode, copy_lvb, buf, count); | ||
932 | 880 | ||
933 | if (removed) | 881 | /* removes ref for proc->asts, may cause lkb to be freed */ |
882 | if (!resid) | ||
934 | dlm_put_lkb(lkb); | 883 | dlm_put_lkb(lkb); |
935 | 884 | ||
936 | /* the bast that was queued was eliminated (see unnecessary above), | 885 | return rv; |
937 | leaving nothing to return */ | ||
938 | |||
939 | if (!ret_type) | ||
940 | goto try_another; | ||
941 | |||
942 | return error; | ||
943 | } | 886 | } |
944 | 887 | ||
945 | static unsigned int device_poll(struct file *file, poll_table *wait) | 888 | static unsigned int device_poll(struct file *file, poll_table *wait) |
diff --git a/fs/dlm/user.h b/fs/dlm/user.h index f196091dd7ff..00499ab8835f 100644 --- a/fs/dlm/user.h +++ b/fs/dlm/user.h | |||
@@ -9,7 +9,8 @@ | |||
9 | #ifndef __USER_DOT_H__ | 9 | #ifndef __USER_DOT_H__ |
10 | #define __USER_DOT_H__ | 10 | #define __USER_DOT_H__ |
11 | 11 | ||
12 | void dlm_user_add_ast(struct dlm_lkb *lkb, int type, int mode); | 12 | void dlm_user_add_ast(struct dlm_lkb *lkb, uint32_t flags, int mode, |
13 | int status, uint32_t sbflags, uint64_t seq); | ||
13 | int dlm_user_init(void); | 14 | int dlm_user_init(void); |
14 | void dlm_user_exit(void); | 15 | void dlm_user_exit(void); |
15 | int dlm_device_deregister(struct dlm_ls *ls); | 16 | int dlm_device_deregister(struct dlm_ls *ls); |
diff --git a/fs/drop_caches.c b/fs/drop_caches.c index 2195c213ab2f..816f88e6b9ce 100644 --- a/fs/drop_caches.c +++ b/fs/drop_caches.c | |||
@@ -45,7 +45,11 @@ static void drop_slab(void) | |||
45 | int drop_caches_sysctl_handler(ctl_table *table, int write, | 45 | int drop_caches_sysctl_handler(ctl_table *table, int write, |
46 | void __user *buffer, size_t *length, loff_t *ppos) | 46 | void __user *buffer, size_t *length, loff_t *ppos) |
47 | { | 47 | { |
48 | proc_dointvec_minmax(table, write, buffer, length, ppos); | 48 | int ret; |
49 | |||
50 | ret = proc_dointvec_minmax(table, write, buffer, length, ppos); | ||
51 | if (ret) | ||
52 | return ret; | ||
49 | if (write) { | 53 | if (write) { |
50 | if (sysctl_drop_caches & 1) | 54 | if (sysctl_drop_caches & 1) |
51 | iterate_supers(drop_pagecache_sb, NULL); | 55 | iterate_supers(drop_pagecache_sb, NULL); |
diff --git a/fs/eventpoll.c b/fs/eventpoll.c index 4a09af9e9a63..ed38801b57a7 100644 --- a/fs/eventpoll.c +++ b/fs/eventpoll.c | |||
@@ -62,7 +62,7 @@ | |||
62 | * This mutex is acquired by ep_free() during the epoll file | 62 | * This mutex is acquired by ep_free() during the epoll file |
63 | * cleanup path and it is also acquired by eventpoll_release_file() | 63 | * cleanup path and it is also acquired by eventpoll_release_file() |
64 | * if a file has been pushed inside an epoll set and it is then | 64 | * if a file has been pushed inside an epoll set and it is then |
65 | * close()d without a previous call toepoll_ctl(EPOLL_CTL_DEL). | 65 | * close()d without a previous call to epoll_ctl(EPOLL_CTL_DEL). |
66 | * It is also acquired when inserting an epoll fd onto another epoll | 66 | * It is also acquired when inserting an epoll fd onto another epoll |
67 | * fd. We do this so that we walk the epoll tree and ensure that this | 67 | * fd. We do this so that we walk the epoll tree and ensure that this |
68 | * insertion does not create a cycle of epoll file descriptors, which | 68 | * insertion does not create a cycle of epoll file descriptors, which |
@@ -152,11 +152,11 @@ struct epitem { | |||
152 | 152 | ||
153 | /* | 153 | /* |
154 | * This structure is stored inside the "private_data" member of the file | 154 | * This structure is stored inside the "private_data" member of the file |
155 | * structure and rapresent the main data sructure for the eventpoll | 155 | * structure and represents the main data structure for the eventpoll |
156 | * interface. | 156 | * interface. |
157 | */ | 157 | */ |
158 | struct eventpoll { | 158 | struct eventpoll { |
159 | /* Protect the this structure access */ | 159 | /* Protect the access to this structure */ |
160 | spinlock_t lock; | 160 | spinlock_t lock; |
161 | 161 | ||
162 | /* | 162 | /* |
@@ -316,6 +316,19 @@ static void ep_nested_calls_init(struct nested_calls *ncalls) | |||
316 | } | 316 | } |
317 | 317 | ||
318 | /** | 318 | /** |
319 | * ep_events_available - Checks if ready events might be available. | ||
320 | * | ||
321 | * @ep: Pointer to the eventpoll context. | ||
322 | * | ||
323 | * Returns: Returns a value different than zero if ready events are available, | ||
324 | * or zero otherwise. | ||
325 | */ | ||
326 | static inline int ep_events_available(struct eventpoll *ep) | ||
327 | { | ||
328 | return !list_empty(&ep->rdllist) || ep->ovflist != EP_UNACTIVE_PTR; | ||
329 | } | ||
330 | |||
331 | /** | ||
319 | * ep_call_nested - Perform a bound (possibly) nested call, by checking | 332 | * ep_call_nested - Perform a bound (possibly) nested call, by checking |
320 | * that the recursion limit is not exceeded, and that | 333 | * that the recursion limit is not exceeded, and that |
321 | * the same nested call (by the meaning of same cookie) is | 334 | * the same nested call (by the meaning of same cookie) is |
@@ -793,7 +806,7 @@ static struct epitem *ep_find(struct eventpoll *ep, struct file *file, int fd) | |||
793 | 806 | ||
794 | /* | 807 | /* |
795 | * This is the callback that is passed to the wait queue wakeup | 808 | * This is the callback that is passed to the wait queue wakeup |
796 | * machanism. It is called by the stored file descriptors when they | 809 | * mechanism. It is called by the stored file descriptors when they |
797 | * have events to report. | 810 | * have events to report. |
798 | */ | 811 | */ |
799 | static int ep_poll_callback(wait_queue_t *wait, unsigned mode, int sync, void *key) | 812 | static int ep_poll_callback(wait_queue_t *wait, unsigned mode, int sync, void *key) |
@@ -824,9 +837,9 @@ static int ep_poll_callback(wait_queue_t *wait, unsigned mode, int sync, void *k | |||
824 | goto out_unlock; | 837 | goto out_unlock; |
825 | 838 | ||
826 | /* | 839 | /* |
827 | * If we are trasfering events to userspace, we can hold no locks | 840 | * If we are transferring events to userspace, we can hold no locks |
828 | * (because we're accessing user memory, and because of linux f_op->poll() | 841 | * (because we're accessing user memory, and because of linux f_op->poll() |
829 | * semantics). All the events that happens during that period of time are | 842 | * semantics). All the events that happen during that period of time are |
830 | * chained in ep->ovflist and requeued later on. | 843 | * chained in ep->ovflist and requeued later on. |
831 | */ | 844 | */ |
832 | if (unlikely(ep->ovflist != EP_UNACTIVE_PTR)) { | 845 | if (unlikely(ep->ovflist != EP_UNACTIVE_PTR)) { |
@@ -1135,12 +1148,29 @@ static inline struct timespec ep_set_mstimeout(long ms) | |||
1135 | return timespec_add_safe(now, ts); | 1148 | return timespec_add_safe(now, ts); |
1136 | } | 1149 | } |
1137 | 1150 | ||
1151 | /** | ||
1152 | * ep_poll - Retrieves ready events, and delivers them to the caller supplied | ||
1153 | * event buffer. | ||
1154 | * | ||
1155 | * @ep: Pointer to the eventpoll context. | ||
1156 | * @events: Pointer to the userspace buffer where the ready events should be | ||
1157 | * stored. | ||
1158 | * @maxevents: Size (in terms of number of events) of the caller event buffer. | ||
1159 | * @timeout: Maximum timeout for the ready events fetch operation, in | ||
1160 | * milliseconds. If the @timeout is zero, the function will not block, | ||
1161 | * while if the @timeout is less than zero, the function will block | ||
1162 | * until at least one event has been retrieved (or an error | ||
1163 | * occurred). | ||
1164 | * | ||
1165 | * Returns: Returns the number of ready events which have been fetched, or an | ||
1166 | * error code, in case of error. | ||
1167 | */ | ||
1138 | static int ep_poll(struct eventpoll *ep, struct epoll_event __user *events, | 1168 | static int ep_poll(struct eventpoll *ep, struct epoll_event __user *events, |
1139 | int maxevents, long timeout) | 1169 | int maxevents, long timeout) |
1140 | { | 1170 | { |
1141 | int res, eavail, timed_out = 0; | 1171 | int res = 0, eavail, timed_out = 0; |
1142 | unsigned long flags; | 1172 | unsigned long flags; |
1143 | long slack; | 1173 | long slack = 0; |
1144 | wait_queue_t wait; | 1174 | wait_queue_t wait; |
1145 | ktime_t expires, *to = NULL; | 1175 | ktime_t expires, *to = NULL; |
1146 | 1176 | ||
@@ -1151,14 +1181,19 @@ static int ep_poll(struct eventpoll *ep, struct epoll_event __user *events, | |||
1151 | to = &expires; | 1181 | to = &expires; |
1152 | *to = timespec_to_ktime(end_time); | 1182 | *to = timespec_to_ktime(end_time); |
1153 | } else if (timeout == 0) { | 1183 | } else if (timeout == 0) { |
1184 | /* | ||
1185 | * Avoid the unnecessary trip to the wait queue loop, if the | ||
1186 | * caller specified a non blocking operation. | ||
1187 | */ | ||
1154 | timed_out = 1; | 1188 | timed_out = 1; |
1189 | spin_lock_irqsave(&ep->lock, flags); | ||
1190 | goto check_events; | ||
1155 | } | 1191 | } |
1156 | 1192 | ||
1157 | retry: | 1193 | fetch_events: |
1158 | spin_lock_irqsave(&ep->lock, flags); | 1194 | spin_lock_irqsave(&ep->lock, flags); |
1159 | 1195 | ||
1160 | res = 0; | 1196 | if (!ep_events_available(ep)) { |
1161 | if (list_empty(&ep->rdllist)) { | ||
1162 | /* | 1197 | /* |
1163 | * We don't have any available event to return to the caller. | 1198 | * We don't have any available event to return to the caller. |
1164 | * We need to sleep here, and we will be wake up by | 1199 | * We need to sleep here, and we will be wake up by |
@@ -1174,7 +1209,7 @@ retry: | |||
1174 | * to TASK_INTERRUPTIBLE before doing the checks. | 1209 | * to TASK_INTERRUPTIBLE before doing the checks. |
1175 | */ | 1210 | */ |
1176 | set_current_state(TASK_INTERRUPTIBLE); | 1211 | set_current_state(TASK_INTERRUPTIBLE); |
1177 | if (!list_empty(&ep->rdllist) || timed_out) | 1212 | if (ep_events_available(ep) || timed_out) |
1178 | break; | 1213 | break; |
1179 | if (signal_pending(current)) { | 1214 | if (signal_pending(current)) { |
1180 | res = -EINTR; | 1215 | res = -EINTR; |
@@ -1191,8 +1226,9 @@ retry: | |||
1191 | 1226 | ||
1192 | set_current_state(TASK_RUNNING); | 1227 | set_current_state(TASK_RUNNING); |
1193 | } | 1228 | } |
1229 | check_events: | ||
1194 | /* Is it worth to try to dig for events ? */ | 1230 | /* Is it worth to try to dig for events ? */ |
1195 | eavail = !list_empty(&ep->rdllist) || ep->ovflist != EP_UNACTIVE_PTR; | 1231 | eavail = ep_events_available(ep); |
1196 | 1232 | ||
1197 | spin_unlock_irqrestore(&ep->lock, flags); | 1233 | spin_unlock_irqrestore(&ep->lock, flags); |
1198 | 1234 | ||
@@ -1203,7 +1239,7 @@ retry: | |||
1203 | */ | 1239 | */ |
1204 | if (!res && eavail && | 1240 | if (!res && eavail && |
1205 | !(res = ep_send_events(ep, events, maxevents)) && !timed_out) | 1241 | !(res = ep_send_events(ep, events, maxevents)) && !timed_out) |
1206 | goto retry; | 1242 | goto fetch_events; |
1207 | 1243 | ||
1208 | return res; | 1244 | return res; |
1209 | } | 1245 | } |
@@ -1875,7 +1875,7 @@ static void wait_for_dump_helpers(struct file *file) | |||
1875 | 1875 | ||
1876 | 1876 | ||
1877 | /* | 1877 | /* |
1878 | * uhm_pipe_setup | 1878 | * umh_pipe_setup |
1879 | * helper function to customize the process used | 1879 | * helper function to customize the process used |
1880 | * to collect the core in userspace. Specifically | 1880 | * to collect the core in userspace. Specifically |
1881 | * it sets up a pipe and installs it as fd 0 (stdin) | 1881 | * it sets up a pipe and installs it as fd 0 (stdin) |
diff --git a/fs/exofs/common.h b/fs/exofs/common.h index f0d520312d8b..5e74ad3d4009 100644 --- a/fs/exofs/common.h +++ b/fs/exofs/common.h | |||
@@ -53,10 +53,14 @@ | |||
53 | #define EXOFS_ROOT_ID 0x10002 /* object ID for root directory */ | 53 | #define EXOFS_ROOT_ID 0x10002 /* object ID for root directory */ |
54 | 54 | ||
55 | /* exofs Application specific page/attribute */ | 55 | /* exofs Application specific page/attribute */ |
56 | /* Inode attrs */ | ||
56 | # define EXOFS_APAGE_FS_DATA (OSD_APAGE_APP_DEFINED_FIRST + 3) | 57 | # define EXOFS_APAGE_FS_DATA (OSD_APAGE_APP_DEFINED_FIRST + 3) |
57 | # define EXOFS_ATTR_INODE_DATA 1 | 58 | # define EXOFS_ATTR_INODE_DATA 1 |
58 | # define EXOFS_ATTR_INODE_FILE_LAYOUT 2 | 59 | # define EXOFS_ATTR_INODE_FILE_LAYOUT 2 |
59 | # define EXOFS_ATTR_INODE_DIR_LAYOUT 3 | 60 | # define EXOFS_ATTR_INODE_DIR_LAYOUT 3 |
61 | /* Partition attrs */ | ||
62 | # define EXOFS_APAGE_SB_DATA (0xF0000000U + 3) | ||
63 | # define EXOFS_ATTR_SB_STATS 1 | ||
60 | 64 | ||
61 | /* | 65 | /* |
62 | * The maximum number of files we can have is limited by the size of the | 66 | * The maximum number of files we can have is limited by the size of the |
@@ -86,8 +90,8 @@ enum { | |||
86 | */ | 90 | */ |
87 | enum {EXOFS_FSCB_VER = 1, EXOFS_DT_VER = 1}; | 91 | enum {EXOFS_FSCB_VER = 1, EXOFS_DT_VER = 1}; |
88 | struct exofs_fscb { | 92 | struct exofs_fscb { |
89 | __le64 s_nextid; /* Highest object ID used */ | 93 | __le64 s_nextid; /* Only used after mkfs */ |
90 | __le64 s_numfiles; /* Number of files on fs */ | 94 | __le64 s_numfiles; /* Only used after mkfs */ |
91 | __le32 s_version; /* == EXOFS_FSCB_VER */ | 95 | __le32 s_version; /* == EXOFS_FSCB_VER */ |
92 | __le16 s_magic; /* Magic signature */ | 96 | __le16 s_magic; /* Magic signature */ |
93 | __le16 s_newfs; /* Non-zero if this is a new fs */ | 97 | __le16 s_newfs; /* Non-zero if this is a new fs */ |
@@ -98,6 +102,16 @@ struct exofs_fscb { | |||
98 | } __packed; | 102 | } __packed; |
99 | 103 | ||
100 | /* | 104 | /* |
105 | * This struct is set on the FS partition's attributes. | ||
106 | * [EXOFS_APAGE_SB_DATA, EXOFS_ATTR_SB_STATS] and is written together | ||
107 | * with the create command, to atomically persist the sb writeable information. | ||
108 | */ | ||
109 | struct exofs_sb_stats { | ||
110 | __le64 s_nextid; /* Highest object ID used */ | ||
111 | __le64 s_numfiles; /* Number of files on fs */ | ||
112 | } __packed; | ||
113 | |||
114 | /* | ||
101 | * Describes the raid used in the FS. It is part of the device table. | 115 | * Describes the raid used in the FS. It is part of the device table. |
102 | * This here is taken from the pNFS-objects definition. In exofs we | 116 | * This here is taken from the pNFS-objects definition. In exofs we |
103 | * use one raid policy through-out the filesystem. (NOTE: the funny | 117 | * use one raid policy through-out the filesystem. (NOTE: the funny |
diff --git a/fs/exofs/dir.c b/fs/exofs/dir.c index dcc941d82d67..d0941c6a1f72 100644 --- a/fs/exofs/dir.c +++ b/fs/exofs/dir.c | |||
@@ -124,7 +124,7 @@ out: | |||
124 | 124 | ||
125 | Ebadsize: | 125 | Ebadsize: |
126 | EXOFS_ERR("ERROR [exofs_check_page]: " | 126 | EXOFS_ERR("ERROR [exofs_check_page]: " |
127 | "size of directory #%lu is not a multiple of chunk size", | 127 | "size of directory(0x%lx) is not a multiple of chunk size\n", |
128 | dir->i_ino | 128 | dir->i_ino |
129 | ); | 129 | ); |
130 | goto fail; | 130 | goto fail; |
@@ -142,8 +142,8 @@ Espan: | |||
142 | goto bad_entry; | 142 | goto bad_entry; |
143 | bad_entry: | 143 | bad_entry: |
144 | EXOFS_ERR( | 144 | EXOFS_ERR( |
145 | "ERROR [exofs_check_page]: bad entry in directory #%lu: %s - " | 145 | "ERROR [exofs_check_page]: bad entry in directory(0x%lx): %s - " |
146 | "offset=%lu, inode=%llu, rec_len=%d, name_len=%d", | 146 | "offset=%lu, inode=0x%llu, rec_len=%d, name_len=%d\n", |
147 | dir->i_ino, error, (page->index<<PAGE_CACHE_SHIFT)+offs, | 147 | dir->i_ino, error, (page->index<<PAGE_CACHE_SHIFT)+offs, |
148 | _LLU(le64_to_cpu(p->inode_no)), | 148 | _LLU(le64_to_cpu(p->inode_no)), |
149 | rec_len, p->name_len); | 149 | rec_len, p->name_len); |
@@ -151,8 +151,8 @@ bad_entry: | |||
151 | Eend: | 151 | Eend: |
152 | p = (struct exofs_dir_entry *)(kaddr + offs); | 152 | p = (struct exofs_dir_entry *)(kaddr + offs); |
153 | EXOFS_ERR("ERROR [exofs_check_page]: " | 153 | EXOFS_ERR("ERROR [exofs_check_page]: " |
154 | "entry in directory #%lu spans the page boundary" | 154 | "entry in directory(0x%lx) spans the page boundary" |
155 | "offset=%lu, inode=%llu", | 155 | "offset=%lu, inode=0x%llx\n", |
156 | dir->i_ino, (page->index<<PAGE_CACHE_SHIFT)+offs, | 156 | dir->i_ino, (page->index<<PAGE_CACHE_SHIFT)+offs, |
157 | _LLU(le64_to_cpu(p->inode_no))); | 157 | _LLU(le64_to_cpu(p->inode_no))); |
158 | fail: | 158 | fail: |
@@ -261,9 +261,8 @@ exofs_readdir(struct file *filp, void *dirent, filldir_t filldir) | |||
261 | struct page *page = exofs_get_page(inode, n); | 261 | struct page *page = exofs_get_page(inode, n); |
262 | 262 | ||
263 | if (IS_ERR(page)) { | 263 | if (IS_ERR(page)) { |
264 | EXOFS_ERR("ERROR: " | 264 | EXOFS_ERR("ERROR: bad page in directory(0x%lx)\n", |
265 | "bad page in #%lu", | 265 | inode->i_ino); |
266 | inode->i_ino); | ||
267 | filp->f_pos += PAGE_CACHE_SIZE - offset; | 266 | filp->f_pos += PAGE_CACHE_SIZE - offset; |
268 | return PTR_ERR(page); | 267 | return PTR_ERR(page); |
269 | } | 268 | } |
@@ -283,7 +282,8 @@ exofs_readdir(struct file *filp, void *dirent, filldir_t filldir) | |||
283 | for (; (char *)de <= limit; de = exofs_next_entry(de)) { | 282 | for (; (char *)de <= limit; de = exofs_next_entry(de)) { |
284 | if (de->rec_len == 0) { | 283 | if (de->rec_len == 0) { |
285 | EXOFS_ERR("ERROR: " | 284 | EXOFS_ERR("ERROR: " |
286 | "zero-length directory entry"); | 285 | "zero-length entry in directory(0x%lx)\n", |
286 | inode->i_ino); | ||
287 | exofs_put_page(page); | 287 | exofs_put_page(page); |
288 | return -EIO; | 288 | return -EIO; |
289 | } | 289 | } |
@@ -342,9 +342,9 @@ struct exofs_dir_entry *exofs_find_entry(struct inode *dir, | |||
342 | kaddr += exofs_last_byte(dir, n) - reclen; | 342 | kaddr += exofs_last_byte(dir, n) - reclen; |
343 | while ((char *) de <= kaddr) { | 343 | while ((char *) de <= kaddr) { |
344 | if (de->rec_len == 0) { | 344 | if (de->rec_len == 0) { |
345 | EXOFS_ERR( | 345 | EXOFS_ERR("ERROR: zero-length entry in " |
346 | "ERROR: exofs_find_entry: " | 346 | "directory(0x%lx)\n", |
347 | "zero-length directory entry"); | 347 | dir->i_ino); |
348 | exofs_put_page(page); | 348 | exofs_put_page(page); |
349 | goto out; | 349 | goto out; |
350 | } | 350 | } |
@@ -472,7 +472,8 @@ int exofs_add_link(struct dentry *dentry, struct inode *inode) | |||
472 | } | 472 | } |
473 | if (de->rec_len == 0) { | 473 | if (de->rec_len == 0) { |
474 | EXOFS_ERR("ERROR: exofs_add_link: " | 474 | EXOFS_ERR("ERROR: exofs_add_link: " |
475 | "zero-length directory entry"); | 475 | "zero-length entry in directory(0x%lx)\n", |
476 | inode->i_ino); | ||
476 | err = -EIO; | 477 | err = -EIO; |
477 | goto out_unlock; | 478 | goto out_unlock; |
478 | } | 479 | } |
@@ -491,7 +492,8 @@ int exofs_add_link(struct dentry *dentry, struct inode *inode) | |||
491 | exofs_put_page(page); | 492 | exofs_put_page(page); |
492 | } | 493 | } |
493 | 494 | ||
494 | EXOFS_ERR("exofs_add_link: BAD dentry=%p or inode=%p", dentry, inode); | 495 | EXOFS_ERR("exofs_add_link: BAD dentry=%p or inode=0x%lx\n", |
496 | dentry, inode->i_ino); | ||
495 | return -EINVAL; | 497 | return -EINVAL; |
496 | 498 | ||
497 | got_it: | 499 | got_it: |
@@ -542,7 +544,8 @@ int exofs_delete_entry(struct exofs_dir_entry *dir, struct page *page) | |||
542 | while (de < dir) { | 544 | while (de < dir) { |
543 | if (de->rec_len == 0) { | 545 | if (de->rec_len == 0) { |
544 | EXOFS_ERR("ERROR: exofs_delete_entry:" | 546 | EXOFS_ERR("ERROR: exofs_delete_entry:" |
545 | "zero-length directory entry"); | 547 | "zero-length entry in directory(0x%lx)\n", |
548 | inode->i_ino); | ||
546 | err = -EIO; | 549 | err = -EIO; |
547 | goto out; | 550 | goto out; |
548 | } | 551 | } |
diff --git a/fs/exofs/exofs.h b/fs/exofs/exofs.h index 2dc925fa1010..c965806c2821 100644 --- a/fs/exofs/exofs.h +++ b/fs/exofs/exofs.h | |||
@@ -77,7 +77,7 @@ struct exofs_layout { | |||
77 | * our extension to the in-memory superblock | 77 | * our extension to the in-memory superblock |
78 | */ | 78 | */ |
79 | struct exofs_sb_info { | 79 | struct exofs_sb_info { |
80 | struct exofs_fscb s_fscb; /* Written often, pre-allocate*/ | 80 | struct exofs_sb_stats s_ess; /* Written often, pre-allocate*/ |
81 | int s_timeout; /* timeout for OSD operations */ | 81 | int s_timeout; /* timeout for OSD operations */ |
82 | uint64_t s_nextid; /* highest object ID used */ | 82 | uint64_t s_nextid; /* highest object ID used */ |
83 | uint32_t s_numfiles; /* number of files on fs */ | 83 | uint32_t s_numfiles; /* number of files on fs */ |
@@ -256,6 +256,8 @@ static inline int exofs_oi_read(struct exofs_i_info *oi, | |||
256 | } | 256 | } |
257 | 257 | ||
258 | /* inode.c */ | 258 | /* inode.c */ |
259 | unsigned exofs_max_io_pages(struct exofs_layout *layout, | ||
260 | unsigned expected_pages); | ||
259 | int exofs_setattr(struct dentry *, struct iattr *); | 261 | int exofs_setattr(struct dentry *, struct iattr *); |
260 | int exofs_write_begin(struct file *file, struct address_space *mapping, | 262 | int exofs_write_begin(struct file *file, struct address_space *mapping, |
261 | loff_t pos, unsigned len, unsigned flags, | 263 | loff_t pos, unsigned len, unsigned flags, |
@@ -279,7 +281,7 @@ int exofs_set_link(struct inode *, struct exofs_dir_entry *, struct page *, | |||
279 | struct inode *); | 281 | struct inode *); |
280 | 282 | ||
281 | /* super.c */ | 283 | /* super.c */ |
282 | int exofs_sync_fs(struct super_block *sb, int wait); | 284 | int exofs_sbi_write_stats(struct exofs_sb_info *sbi); |
283 | 285 | ||
284 | /********************* | 286 | /********************* |
285 | * operation vectors * | 287 | * operation vectors * |
diff --git a/fs/exofs/file.c b/fs/exofs/file.c index b905c79b4f0a..45ca323d8363 100644 --- a/fs/exofs/file.c +++ b/fs/exofs/file.c | |||
@@ -45,22 +45,8 @@ static int exofs_release_file(struct inode *inode, struct file *filp) | |||
45 | static int exofs_file_fsync(struct file *filp, int datasync) | 45 | static int exofs_file_fsync(struct file *filp, int datasync) |
46 | { | 46 | { |
47 | int ret; | 47 | int ret; |
48 | struct inode *inode = filp->f_mapping->host; | ||
49 | struct super_block *sb; | ||
50 | |||
51 | if (!(inode->i_state & I_DIRTY)) | ||
52 | return 0; | ||
53 | if (datasync && !(inode->i_state & I_DIRTY_DATASYNC)) | ||
54 | return 0; | ||
55 | |||
56 | ret = sync_inode_metadata(inode, 1); | ||
57 | |||
58 | /* This is a good place to write the sb */ | ||
59 | /* TODO: Sechedule an sb-sync on create */ | ||
60 | sb = inode->i_sb; | ||
61 | if (sb->s_dirt) | ||
62 | exofs_sync_fs(sb, 1); | ||
63 | 48 | ||
49 | ret = sync_inode_metadata(filp->f_mapping->host, 1); | ||
64 | return ret; | 50 | return ret; |
65 | } | 51 | } |
66 | 52 | ||
diff --git a/fs/exofs/inode.c b/fs/exofs/inode.c index a7555238c41a..0c713cfbebf0 100644 --- a/fs/exofs/inode.c +++ b/fs/exofs/inode.c | |||
@@ -43,6 +43,17 @@ enum { BIO_MAX_PAGES_KMALLOC = | |||
43 | PAGE_SIZE / sizeof(struct page *), | 43 | PAGE_SIZE / sizeof(struct page *), |
44 | }; | 44 | }; |
45 | 45 | ||
46 | unsigned exofs_max_io_pages(struct exofs_layout *layout, | ||
47 | unsigned expected_pages) | ||
48 | { | ||
49 | unsigned pages = min_t(unsigned, expected_pages, MAX_PAGES_KMALLOC); | ||
50 | |||
51 | /* TODO: easily support bio chaining */ | ||
52 | pages = min_t(unsigned, pages, | ||
53 | layout->group_width * BIO_MAX_PAGES_KMALLOC); | ||
54 | return pages; | ||
55 | } | ||
56 | |||
46 | struct page_collect { | 57 | struct page_collect { |
47 | struct exofs_sb_info *sbi; | 58 | struct exofs_sb_info *sbi; |
48 | struct inode *inode; | 59 | struct inode *inode; |
@@ -97,8 +108,7 @@ static void _pcol_reset(struct page_collect *pcol) | |||
97 | 108 | ||
98 | static int pcol_try_alloc(struct page_collect *pcol) | 109 | static int pcol_try_alloc(struct page_collect *pcol) |
99 | { | 110 | { |
100 | unsigned pages = min_t(unsigned, pcol->expected_pages, | 111 | unsigned pages; |
101 | MAX_PAGES_KMALLOC); | ||
102 | 112 | ||
103 | if (!pcol->ios) { /* First time allocate io_state */ | 113 | if (!pcol->ios) { /* First time allocate io_state */ |
104 | int ret = exofs_get_io_state(&pcol->sbi->layout, &pcol->ios); | 114 | int ret = exofs_get_io_state(&pcol->sbi->layout, &pcol->ios); |
@@ -108,8 +118,7 @@ static int pcol_try_alloc(struct page_collect *pcol) | |||
108 | } | 118 | } |
109 | 119 | ||
110 | /* TODO: easily support bio chaining */ | 120 | /* TODO: easily support bio chaining */ |
111 | pages = min_t(unsigned, pages, | 121 | pages = exofs_max_io_pages(&pcol->sbi->layout, pcol->expected_pages); |
112 | pcol->sbi->layout.group_width * BIO_MAX_PAGES_KMALLOC); | ||
113 | 122 | ||
114 | for (; pages; pages >>= 1) { | 123 | for (; pages; pages >>= 1) { |
115 | pcol->pages = kmalloc(pages * sizeof(struct page *), | 124 | pcol->pages = kmalloc(pages * sizeof(struct page *), |
@@ -350,8 +359,10 @@ static int readpage_strip(void *data, struct page *page) | |||
350 | 359 | ||
351 | if (!pcol->read_4_write) | 360 | if (!pcol->read_4_write) |
352 | unlock_page(page); | 361 | unlock_page(page); |
353 | EXOFS_DBGMSG("readpage_strip(0x%lx, 0x%lx) empty page," | 362 | EXOFS_DBGMSG("readpage_strip(0x%lx) empty page len=%zx " |
354 | " splitting\n", inode->i_ino, page->index); | 363 | "read_4_write=%d index=0x%lx end_index=0x%lx " |
364 | "splitting\n", inode->i_ino, len, | ||
365 | pcol->read_4_write, page->index, end_index); | ||
355 | 366 | ||
356 | return read_exec(pcol); | 367 | return read_exec(pcol); |
357 | } | 368 | } |
@@ -722,11 +733,28 @@ int exofs_write_begin(struct file *file, struct address_space *mapping, | |||
722 | 733 | ||
723 | /* read modify write */ | 734 | /* read modify write */ |
724 | if (!PageUptodate(page) && (len != PAGE_CACHE_SIZE)) { | 735 | if (!PageUptodate(page) && (len != PAGE_CACHE_SIZE)) { |
736 | loff_t i_size = i_size_read(mapping->host); | ||
737 | pgoff_t end_index = i_size >> PAGE_CACHE_SHIFT; | ||
738 | size_t rlen; | ||
739 | |||
740 | if (page->index < end_index) | ||
741 | rlen = PAGE_CACHE_SIZE; | ||
742 | else if (page->index == end_index) | ||
743 | rlen = i_size & ~PAGE_CACHE_MASK; | ||
744 | else | ||
745 | rlen = 0; | ||
746 | |||
747 | if (!rlen) { | ||
748 | clear_highpage(page); | ||
749 | SetPageUptodate(page); | ||
750 | goto out; | ||
751 | } | ||
752 | |||
725 | ret = _readpage(page, true); | 753 | ret = _readpage(page, true); |
726 | if (ret) { | 754 | if (ret) { |
727 | /*SetPageError was done by _readpage. Is it ok?*/ | 755 | /*SetPageError was done by _readpage. Is it ok?*/ |
728 | unlock_page(page); | 756 | unlock_page(page); |
729 | EXOFS_DBGMSG("__readpage_filler failed\n"); | 757 | EXOFS_DBGMSG("__readpage failed\n"); |
730 | } | 758 | } |
731 | } | 759 | } |
732 | out: | 760 | out: |
@@ -1030,6 +1058,7 @@ struct inode *exofs_iget(struct super_block *sb, unsigned long ino) | |||
1030 | memcpy(oi->i_data, fcb.i_data, sizeof(fcb.i_data)); | 1058 | memcpy(oi->i_data, fcb.i_data, sizeof(fcb.i_data)); |
1031 | } | 1059 | } |
1032 | 1060 | ||
1061 | inode->i_mapping->backing_dev_info = sb->s_bdi; | ||
1033 | if (S_ISREG(inode->i_mode)) { | 1062 | if (S_ISREG(inode->i_mode)) { |
1034 | inode->i_op = &exofs_file_inode_operations; | 1063 | inode->i_op = &exofs_file_inode_operations; |
1035 | inode->i_fop = &exofs_file_operations; | 1064 | inode->i_fop = &exofs_file_operations; |
@@ -1073,6 +1102,7 @@ int __exofs_wait_obj_created(struct exofs_i_info *oi) | |||
1073 | } | 1102 | } |
1074 | return unlikely(is_bad_inode(&oi->vfs_inode)) ? -EIO : 0; | 1103 | return unlikely(is_bad_inode(&oi->vfs_inode)) ? -EIO : 0; |
1075 | } | 1104 | } |
1105 | |||
1076 | /* | 1106 | /* |
1077 | * Callback function from exofs_new_inode(). The important thing is that we | 1107 | * Callback function from exofs_new_inode(). The important thing is that we |
1078 | * set the obj_created flag so that other methods know that the object exists on | 1108 | * set the obj_created flag so that other methods know that the object exists on |
@@ -1130,7 +1160,7 @@ struct inode *exofs_new_inode(struct inode *dir, int mode) | |||
1130 | 1160 | ||
1131 | sbi = sb->s_fs_info; | 1161 | sbi = sb->s_fs_info; |
1132 | 1162 | ||
1133 | sb->s_dirt = 1; | 1163 | inode->i_mapping->backing_dev_info = sb->s_bdi; |
1134 | inode_init_owner(inode, dir, mode); | 1164 | inode_init_owner(inode, dir, mode); |
1135 | inode->i_ino = sbi->s_nextid++; | 1165 | inode->i_ino = sbi->s_nextid++; |
1136 | inode->i_blkbits = EXOFS_BLKSHIFT; | 1166 | inode->i_blkbits = EXOFS_BLKSHIFT; |
@@ -1141,6 +1171,8 @@ struct inode *exofs_new_inode(struct inode *dir, int mode) | |||
1141 | spin_unlock(&sbi->s_next_gen_lock); | 1171 | spin_unlock(&sbi->s_next_gen_lock); |
1142 | insert_inode_hash(inode); | 1172 | insert_inode_hash(inode); |
1143 | 1173 | ||
1174 | exofs_sbi_write_stats(sbi); /* Make sure new sbi->s_nextid is on disk */ | ||
1175 | |||
1144 | mark_inode_dirty(inode); | 1176 | mark_inode_dirty(inode); |
1145 | 1177 | ||
1146 | ret = exofs_get_io_state(&sbi->layout, &ios); | 1178 | ret = exofs_get_io_state(&sbi->layout, &ios); |
@@ -1271,7 +1303,8 @@ out: | |||
1271 | 1303 | ||
1272 | int exofs_write_inode(struct inode *inode, struct writeback_control *wbc) | 1304 | int exofs_write_inode(struct inode *inode, struct writeback_control *wbc) |
1273 | { | 1305 | { |
1274 | return exofs_update_inode(inode, wbc->sync_mode == WB_SYNC_ALL); | 1306 | /* FIXME: fix fsync and use wbc->sync_mode == WB_SYNC_ALL */ |
1307 | return exofs_update_inode(inode, 1); | ||
1275 | } | 1308 | } |
1276 | 1309 | ||
1277 | /* | 1310 | /* |
diff --git a/fs/exofs/super.c b/fs/exofs/super.c index 8c6c4669b381..06065bd37fc3 100644 --- a/fs/exofs/super.c +++ b/fs/exofs/super.c | |||
@@ -48,6 +48,7 @@ | |||
48 | * struct to hold what we get from mount options | 48 | * struct to hold what we get from mount options |
49 | */ | 49 | */ |
50 | struct exofs_mountopt { | 50 | struct exofs_mountopt { |
51 | bool is_osdname; | ||
51 | const char *dev_name; | 52 | const char *dev_name; |
52 | uint64_t pid; | 53 | uint64_t pid; |
53 | int timeout; | 54 | int timeout; |
@@ -56,7 +57,7 @@ struct exofs_mountopt { | |||
56 | /* | 57 | /* |
57 | * exofs-specific mount-time options. | 58 | * exofs-specific mount-time options. |
58 | */ | 59 | */ |
59 | enum { Opt_pid, Opt_to, Opt_mkfs, Opt_format, Opt_err }; | 60 | enum { Opt_name, Opt_pid, Opt_to, Opt_err }; |
60 | 61 | ||
61 | /* | 62 | /* |
62 | * Our mount-time options. These should ideally be 64-bit unsigned, but the | 63 | * Our mount-time options. These should ideally be 64-bit unsigned, but the |
@@ -64,6 +65,7 @@ enum { Opt_pid, Opt_to, Opt_mkfs, Opt_format, Opt_err }; | |||
64 | * sufficient for most applications now. | 65 | * sufficient for most applications now. |
65 | */ | 66 | */ |
66 | static match_table_t tokens = { | 67 | static match_table_t tokens = { |
68 | {Opt_name, "osdname=%s"}, | ||
67 | {Opt_pid, "pid=%u"}, | 69 | {Opt_pid, "pid=%u"}, |
68 | {Opt_to, "to=%u"}, | 70 | {Opt_to, "to=%u"}, |
69 | {Opt_err, NULL} | 71 | {Opt_err, NULL} |
@@ -94,6 +96,14 @@ static int parse_options(char *options, struct exofs_mountopt *opts) | |||
94 | 96 | ||
95 | token = match_token(p, tokens, args); | 97 | token = match_token(p, tokens, args); |
96 | switch (token) { | 98 | switch (token) { |
99 | case Opt_name: | ||
100 | opts->dev_name = match_strdup(&args[0]); | ||
101 | if (unlikely(!opts->dev_name)) { | ||
102 | EXOFS_ERR("Error allocating dev_name"); | ||
103 | return -ENOMEM; | ||
104 | } | ||
105 | opts->is_osdname = true; | ||
106 | break; | ||
97 | case Opt_pid: | 107 | case Opt_pid: |
98 | if (0 == match_strlcpy(str, &args[0], sizeof(str))) | 108 | if (0 == match_strlcpy(str, &args[0], sizeof(str))) |
99 | return -EINVAL; | 109 | return -EINVAL; |
@@ -203,6 +213,101 @@ static void destroy_inodecache(void) | |||
203 | static const struct super_operations exofs_sops; | 213 | static const struct super_operations exofs_sops; |
204 | static const struct export_operations exofs_export_ops; | 214 | static const struct export_operations exofs_export_ops; |
205 | 215 | ||
216 | static const struct osd_attr g_attr_sb_stats = ATTR_DEF( | ||
217 | EXOFS_APAGE_SB_DATA, | ||
218 | EXOFS_ATTR_SB_STATS, | ||
219 | sizeof(struct exofs_sb_stats)); | ||
220 | |||
221 | static int __sbi_read_stats(struct exofs_sb_info *sbi) | ||
222 | { | ||
223 | struct osd_attr attrs[] = { | ||
224 | [0] = g_attr_sb_stats, | ||
225 | }; | ||
226 | struct exofs_io_state *ios; | ||
227 | int ret; | ||
228 | |||
229 | ret = exofs_get_io_state(&sbi->layout, &ios); | ||
230 | if (unlikely(ret)) { | ||
231 | EXOFS_ERR("%s: exofs_get_io_state failed.\n", __func__); | ||
232 | return ret; | ||
233 | } | ||
234 | |||
235 | ios->cred = sbi->s_cred; | ||
236 | |||
237 | ios->in_attr = attrs; | ||
238 | ios->in_attr_len = ARRAY_SIZE(attrs); | ||
239 | |||
240 | ret = exofs_sbi_read(ios); | ||
241 | if (unlikely(ret)) { | ||
242 | EXOFS_ERR("Error reading super_block stats => %d\n", ret); | ||
243 | goto out; | ||
244 | } | ||
245 | |||
246 | ret = extract_attr_from_ios(ios, &attrs[0]); | ||
247 | if (ret) { | ||
248 | EXOFS_ERR("%s: extract_attr of sb_stats failed\n", __func__); | ||
249 | goto out; | ||
250 | } | ||
251 | if (attrs[0].len) { | ||
252 | struct exofs_sb_stats *ess; | ||
253 | |||
254 | if (unlikely(attrs[0].len != sizeof(*ess))) { | ||
255 | EXOFS_ERR("%s: Wrong version of exofs_sb_stats " | ||
256 | "size(%d) != expected(%zd)\n", | ||
257 | __func__, attrs[0].len, sizeof(*ess)); | ||
258 | goto out; | ||
259 | } | ||
260 | |||
261 | ess = attrs[0].val_ptr; | ||
262 | sbi->s_nextid = le64_to_cpu(ess->s_nextid); | ||
263 | sbi->s_numfiles = le32_to_cpu(ess->s_numfiles); | ||
264 | } | ||
265 | |||
266 | out: | ||
267 | exofs_put_io_state(ios); | ||
268 | return ret; | ||
269 | } | ||
270 | |||
271 | static void stats_done(struct exofs_io_state *ios, void *p) | ||
272 | { | ||
273 | exofs_put_io_state(ios); | ||
274 | /* Good thanks nothing to do anymore */ | ||
275 | } | ||
276 | |||
277 | /* Asynchronously write the stats attribute */ | ||
278 | int exofs_sbi_write_stats(struct exofs_sb_info *sbi) | ||
279 | { | ||
280 | struct osd_attr attrs[] = { | ||
281 | [0] = g_attr_sb_stats, | ||
282 | }; | ||
283 | struct exofs_io_state *ios; | ||
284 | int ret; | ||
285 | |||
286 | ret = exofs_get_io_state(&sbi->layout, &ios); | ||
287 | if (unlikely(ret)) { | ||
288 | EXOFS_ERR("%s: exofs_get_io_state failed.\n", __func__); | ||
289 | return ret; | ||
290 | } | ||
291 | |||
292 | sbi->s_ess.s_nextid = cpu_to_le64(sbi->s_nextid); | ||
293 | sbi->s_ess.s_numfiles = cpu_to_le64(sbi->s_numfiles); | ||
294 | attrs[0].val_ptr = &sbi->s_ess; | ||
295 | |||
296 | ios->cred = sbi->s_cred; | ||
297 | ios->done = stats_done; | ||
298 | ios->private = sbi; | ||
299 | ios->out_attr = attrs; | ||
300 | ios->out_attr_len = ARRAY_SIZE(attrs); | ||
301 | |||
302 | ret = exofs_sbi_write(ios); | ||
303 | if (unlikely(ret)) { | ||
304 | EXOFS_ERR("%s: exofs_sbi_write failed.\n", __func__); | ||
305 | exofs_put_io_state(ios); | ||
306 | } | ||
307 | |||
308 | return ret; | ||
309 | } | ||
310 | |||
206 | /* | 311 | /* |
207 | * Write the superblock to the OSD | 312 | * Write the superblock to the OSD |
208 | */ | 313 | */ |
@@ -213,18 +318,25 @@ int exofs_sync_fs(struct super_block *sb, int wait) | |||
213 | struct exofs_io_state *ios; | 318 | struct exofs_io_state *ios; |
214 | int ret = -ENOMEM; | 319 | int ret = -ENOMEM; |
215 | 320 | ||
216 | lock_super(sb); | 321 | fscb = kmalloc(sizeof(*fscb), GFP_KERNEL); |
322 | if (unlikely(!fscb)) | ||
323 | return -ENOMEM; | ||
324 | |||
217 | sbi = sb->s_fs_info; | 325 | sbi = sb->s_fs_info; |
218 | fscb = &sbi->s_fscb; | ||
219 | 326 | ||
327 | /* NOTE: We no longer dirty the super_block anywhere in exofs. The | ||
328 | * reason we write the fscb here on unmount is so we can stay backwards | ||
329 | * compatible with fscb->s_version == 1. (What we are not compatible | ||
330 | * with is if a new version FS crashed and then we try to mount an old | ||
331 | * version). Otherwise the exofs_fscb is read-only from mkfs time. All | ||
332 | * the writeable info is set in exofs_sbi_write_stats() above. | ||
333 | */ | ||
220 | ret = exofs_get_io_state(&sbi->layout, &ios); | 334 | ret = exofs_get_io_state(&sbi->layout, &ios); |
221 | if (ret) | 335 | if (unlikely(ret)) |
222 | goto out; | 336 | goto out; |
223 | 337 | ||
224 | /* Note: We only write the changing part of the fscb. .i.e upto the | 338 | lock_super(sb); |
225 | * the fscb->s_dev_table_oid member. There is no read-modify-write | 339 | |
226 | * here. | ||
227 | */ | ||
228 | ios->length = offsetof(struct exofs_fscb, s_dev_table_oid); | 340 | ios->length = offsetof(struct exofs_fscb, s_dev_table_oid); |
229 | memset(fscb, 0, ios->length); | 341 | memset(fscb, 0, ios->length); |
230 | fscb->s_nextid = cpu_to_le64(sbi->s_nextid); | 342 | fscb->s_nextid = cpu_to_le64(sbi->s_nextid); |
@@ -239,16 +351,17 @@ int exofs_sync_fs(struct super_block *sb, int wait) | |||
239 | ios->cred = sbi->s_cred; | 351 | ios->cred = sbi->s_cred; |
240 | 352 | ||
241 | ret = exofs_sbi_write(ios); | 353 | ret = exofs_sbi_write(ios); |
242 | if (unlikely(ret)) { | 354 | if (unlikely(ret)) |
243 | EXOFS_ERR("%s: exofs_sbi_write failed.\n", __func__); | 355 | EXOFS_ERR("%s: exofs_sbi_write failed.\n", __func__); |
244 | goto out; | 356 | else |
245 | } | 357 | sb->s_dirt = 0; |
246 | sb->s_dirt = 0; | 358 | |
247 | 359 | ||
360 | unlock_super(sb); | ||
248 | out: | 361 | out: |
249 | EXOFS_DBGMSG("s_nextid=0x%llx ret=%d\n", _LLU(sbi->s_nextid), ret); | 362 | EXOFS_DBGMSG("s_nextid=0x%llx ret=%d\n", _LLU(sbi->s_nextid), ret); |
250 | exofs_put_io_state(ios); | 363 | exofs_put_io_state(ios); |
251 | unlock_super(sb); | 364 | kfree(fscb); |
252 | return ret; | 365 | return ret; |
253 | } | 366 | } |
254 | 367 | ||
@@ -292,13 +405,14 @@ static void exofs_put_super(struct super_block *sb) | |||
292 | int num_pend; | 405 | int num_pend; |
293 | struct exofs_sb_info *sbi = sb->s_fs_info; | 406 | struct exofs_sb_info *sbi = sb->s_fs_info; |
294 | 407 | ||
295 | if (sb->s_dirt) | ||
296 | exofs_write_super(sb); | ||
297 | |||
298 | /* make sure there are no pending commands */ | 408 | /* make sure there are no pending commands */ |
299 | for (num_pend = atomic_read(&sbi->s_curr_pending); num_pend > 0; | 409 | for (num_pend = atomic_read(&sbi->s_curr_pending); num_pend > 0; |
300 | num_pend = atomic_read(&sbi->s_curr_pending)) { | 410 | num_pend = atomic_read(&sbi->s_curr_pending)) { |
301 | wait_queue_head_t wq; | 411 | wait_queue_head_t wq; |
412 | |||
413 | printk(KERN_NOTICE "%s: !!Pending operations in flight. " | ||
414 | "This is a BUG. please report to osd-dev@open-osd.org\n", | ||
415 | __func__); | ||
302 | init_waitqueue_head(&wq); | 416 | init_waitqueue_head(&wq); |
303 | wait_event_timeout(wq, | 417 | wait_event_timeout(wq, |
304 | (atomic_read(&sbi->s_curr_pending) == 0), | 418 | (atomic_read(&sbi->s_curr_pending) == 0), |
@@ -390,6 +504,23 @@ static int _read_and_match_data_map(struct exofs_sb_info *sbi, unsigned numdevs, | |||
390 | return 0; | 504 | return 0; |
391 | } | 505 | } |
392 | 506 | ||
507 | static unsigned __ra_pages(struct exofs_layout *layout) | ||
508 | { | ||
509 | const unsigned _MIN_RA = 32; /* min 128K read-ahead */ | ||
510 | unsigned ra_pages = layout->group_width * layout->stripe_unit / | ||
511 | PAGE_SIZE; | ||
512 | unsigned max_io_pages = exofs_max_io_pages(layout, ~0); | ||
513 | |||
514 | ra_pages *= 2; /* two stripes */ | ||
515 | if (ra_pages < _MIN_RA) | ||
516 | ra_pages = roundup(_MIN_RA, ra_pages / 2); | ||
517 | |||
518 | if (ra_pages > max_io_pages) | ||
519 | ra_pages = max_io_pages; | ||
520 | |||
521 | return ra_pages; | ||
522 | } | ||
523 | |||
393 | /* @odi is valid only as long as @fscb_dev is valid */ | 524 | /* @odi is valid only as long as @fscb_dev is valid */ |
394 | static int exofs_devs_2_odi(struct exofs_dt_device_info *dt_dev, | 525 | static int exofs_devs_2_odi(struct exofs_dt_device_info *dt_dev, |
395 | struct osd_dev_info *odi) | 526 | struct osd_dev_info *odi) |
@@ -495,7 +626,7 @@ static int exofs_read_lookup_dev_table(struct exofs_sb_info **psbi, | |||
495 | } | 626 | } |
496 | 627 | ||
497 | od = osduld_info_lookup(&odi); | 628 | od = osduld_info_lookup(&odi); |
498 | if (unlikely(IS_ERR(od))) { | 629 | if (IS_ERR(od)) { |
499 | ret = PTR_ERR(od); | 630 | ret = PTR_ERR(od); |
500 | EXOFS_ERR("ERROR: device requested is not found " | 631 | EXOFS_ERR("ERROR: device requested is not found " |
501 | "osd_name-%s =>%d\n", odi.osdname, ret); | 632 | "osd_name-%s =>%d\n", odi.osdname, ret); |
@@ -558,9 +689,17 @@ static int exofs_fill_super(struct super_block *sb, void *data, int silent) | |||
558 | goto free_bdi; | 689 | goto free_bdi; |
559 | 690 | ||
560 | /* use mount options to fill superblock */ | 691 | /* use mount options to fill superblock */ |
561 | od = osduld_path_lookup(opts->dev_name); | 692 | if (opts->is_osdname) { |
693 | struct osd_dev_info odi = {.systemid_len = 0}; | ||
694 | |||
695 | odi.osdname_len = strlen(opts->dev_name); | ||
696 | odi.osdname = (u8 *)opts->dev_name; | ||
697 | od = osduld_info_lookup(&odi); | ||
698 | } else { | ||
699 | od = osduld_path_lookup(opts->dev_name); | ||
700 | } | ||
562 | if (IS_ERR(od)) { | 701 | if (IS_ERR(od)) { |
563 | ret = PTR_ERR(od); | 702 | ret = -EINVAL; |
564 | goto free_sbi; | 703 | goto free_sbi; |
565 | } | 704 | } |
566 | 705 | ||
@@ -594,6 +733,7 @@ static int exofs_fill_super(struct super_block *sb, void *data, int silent) | |||
594 | goto free_sbi; | 733 | goto free_sbi; |
595 | 734 | ||
596 | sb->s_magic = le16_to_cpu(fscb.s_magic); | 735 | sb->s_magic = le16_to_cpu(fscb.s_magic); |
736 | /* NOTE: we read below to be backward compatible with old versions */ | ||
597 | sbi->s_nextid = le64_to_cpu(fscb.s_nextid); | 737 | sbi->s_nextid = le64_to_cpu(fscb.s_nextid); |
598 | sbi->s_numfiles = le32_to_cpu(fscb.s_numfiles); | 738 | sbi->s_numfiles = le32_to_cpu(fscb.s_numfiles); |
599 | 739 | ||
@@ -604,7 +744,7 @@ static int exofs_fill_super(struct super_block *sb, void *data, int silent) | |||
604 | ret = -EINVAL; | 744 | ret = -EINVAL; |
605 | goto free_sbi; | 745 | goto free_sbi; |
606 | } | 746 | } |
607 | if (le32_to_cpu(fscb.s_version) != EXOFS_FSCB_VER) { | 747 | if (le32_to_cpu(fscb.s_version) > EXOFS_FSCB_VER) { |
608 | EXOFS_ERR("ERROR: Bad FSCB version expected-%d got-%d\n", | 748 | EXOFS_ERR("ERROR: Bad FSCB version expected-%d got-%d\n", |
609 | EXOFS_FSCB_VER, le32_to_cpu(fscb.s_version)); | 749 | EXOFS_FSCB_VER, le32_to_cpu(fscb.s_version)); |
610 | ret = -EINVAL; | 750 | ret = -EINVAL; |
@@ -622,7 +762,10 @@ static int exofs_fill_super(struct super_block *sb, void *data, int silent) | |||
622 | goto free_sbi; | 762 | goto free_sbi; |
623 | } | 763 | } |
624 | 764 | ||
765 | __sbi_read_stats(sbi); | ||
766 | |||
625 | /* set up operation vectors */ | 767 | /* set up operation vectors */ |
768 | sbi->bdi.ra_pages = __ra_pages(&sbi->layout); | ||
626 | sb->s_bdi = &sbi->bdi; | 769 | sb->s_bdi = &sbi->bdi; |
627 | sb->s_fs_info = sbi; | 770 | sb->s_fs_info = sbi; |
628 | sb->s_op = &exofs_sops; | 771 | sb->s_op = &exofs_sops; |
@@ -652,6 +795,8 @@ static int exofs_fill_super(struct super_block *sb, void *data, int silent) | |||
652 | 795 | ||
653 | _exofs_print_device("Mounting", opts->dev_name, sbi->layout.s_ods[0], | 796 | _exofs_print_device("Mounting", opts->dev_name, sbi->layout.s_ods[0], |
654 | sbi->layout.s_pid); | 797 | sbi->layout.s_pid); |
798 | if (opts->is_osdname) | ||
799 | kfree(opts->dev_name); | ||
655 | return 0; | 800 | return 0; |
656 | 801 | ||
657 | free_sbi: | 802 | free_sbi: |
@@ -660,6 +805,8 @@ free_bdi: | |||
660 | EXOFS_ERR("Unable to mount exofs on %s pid=0x%llx err=%d\n", | 805 | EXOFS_ERR("Unable to mount exofs on %s pid=0x%llx err=%d\n", |
661 | opts->dev_name, sbi->layout.s_pid, ret); | 806 | opts->dev_name, sbi->layout.s_pid, ret); |
662 | exofs_free_sbi(sbi); | 807 | exofs_free_sbi(sbi); |
808 | if (opts->is_osdname) | ||
809 | kfree(opts->dev_name); | ||
663 | return ret; | 810 | return ret; |
664 | } | 811 | } |
665 | 812 | ||
@@ -677,7 +824,8 @@ static struct dentry *exofs_mount(struct file_system_type *type, | |||
677 | if (ret) | 824 | if (ret) |
678 | return ERR_PTR(ret); | 825 | return ERR_PTR(ret); |
679 | 826 | ||
680 | opts.dev_name = dev_name; | 827 | if (!opts.dev_name) |
828 | opts.dev_name = dev_name; | ||
681 | return mount_nodev(type, flags, &opts, exofs_fill_super); | 829 | return mount_nodev(type, flags, &opts, exofs_fill_super); |
682 | } | 830 | } |
683 | 831 | ||
diff --git a/fs/ext2/acl.c b/fs/ext2/acl.c index 7b4180554a62..abea5a17c764 100644 --- a/fs/ext2/acl.c +++ b/fs/ext2/acl.c | |||
@@ -406,7 +406,7 @@ ext2_xattr_set_acl(struct dentry *dentry, const char *name, const void *value, | |||
406 | return -EINVAL; | 406 | return -EINVAL; |
407 | if (!test_opt(dentry->d_sb, POSIX_ACL)) | 407 | if (!test_opt(dentry->d_sb, POSIX_ACL)) |
408 | return -EOPNOTSUPP; | 408 | return -EOPNOTSUPP; |
409 | if (!is_owner_or_cap(dentry->d_inode)) | 409 | if (!inode_owner_or_capable(dentry->d_inode)) |
410 | return -EPERM; | 410 | return -EPERM; |
411 | 411 | ||
412 | if (value) { | 412 | if (value) { |
diff --git a/fs/ext2/ext2.h b/fs/ext2/ext2.h index 1b48c3370872..645be9e7ee47 100644 --- a/fs/ext2/ext2.h +++ b/fs/ext2/ext2.h | |||
@@ -174,3 +174,9 @@ ext2_group_first_block_no(struct super_block *sb, unsigned long group_no) | |||
174 | return group_no * (ext2_fsblk_t)EXT2_BLOCKS_PER_GROUP(sb) + | 174 | return group_no * (ext2_fsblk_t)EXT2_BLOCKS_PER_GROUP(sb) + |
175 | le32_to_cpu(EXT2_SB(sb)->s_es->s_first_data_block); | 175 | le32_to_cpu(EXT2_SB(sb)->s_es->s_first_data_block); |
176 | } | 176 | } |
177 | |||
178 | #define ext2_set_bit __test_and_set_bit_le | ||
179 | #define ext2_clear_bit __test_and_clear_bit_le | ||
180 | #define ext2_test_bit test_bit_le | ||
181 | #define ext2_find_first_zero_bit find_first_zero_bit_le | ||
182 | #define ext2_find_next_zero_bit find_next_zero_bit_le | ||
diff --git a/fs/ext2/ioctl.c b/fs/ext2/ioctl.c index e7431309bdca..f81e250ac5c4 100644 --- a/fs/ext2/ioctl.c +++ b/fs/ext2/ioctl.c | |||
@@ -39,7 +39,7 @@ long ext2_ioctl(struct file *filp, unsigned int cmd, unsigned long arg) | |||
39 | if (ret) | 39 | if (ret) |
40 | return ret; | 40 | return ret; |
41 | 41 | ||
42 | if (!is_owner_or_cap(inode)) { | 42 | if (!inode_owner_or_capable(inode)) { |
43 | ret = -EACCES; | 43 | ret = -EACCES; |
44 | goto setflags_out; | 44 | goto setflags_out; |
45 | } | 45 | } |
@@ -89,7 +89,7 @@ setflags_out: | |||
89 | case EXT2_IOC_GETVERSION: | 89 | case EXT2_IOC_GETVERSION: |
90 | return put_user(inode->i_generation, (int __user *) arg); | 90 | return put_user(inode->i_generation, (int __user *) arg); |
91 | case EXT2_IOC_SETVERSION: | 91 | case EXT2_IOC_SETVERSION: |
92 | if (!is_owner_or_cap(inode)) | 92 | if (!inode_owner_or_capable(inode)) |
93 | return -EPERM; | 93 | return -EPERM; |
94 | ret = mnt_want_write(filp->f_path.mnt); | 94 | ret = mnt_want_write(filp->f_path.mnt); |
95 | if (ret) | 95 | if (ret) |
@@ -115,7 +115,7 @@ setflags_out: | |||
115 | if (!test_opt(inode->i_sb, RESERVATION) ||!S_ISREG(inode->i_mode)) | 115 | if (!test_opt(inode->i_sb, RESERVATION) ||!S_ISREG(inode->i_mode)) |
116 | return -ENOTTY; | 116 | return -ENOTTY; |
117 | 117 | ||
118 | if (!is_owner_or_cap(inode)) | 118 | if (!inode_owner_or_capable(inode)) |
119 | return -EACCES; | 119 | return -EACCES; |
120 | 120 | ||
121 | if (get_user(rsv_window_size, (int __user *)arg)) | 121 | if (get_user(rsv_window_size, (int __user *)arg)) |
diff --git a/fs/ext3/acl.c b/fs/ext3/acl.c index e4fa49e6c539..9d021c0d472a 100644 --- a/fs/ext3/acl.c +++ b/fs/ext3/acl.c | |||
@@ -435,7 +435,7 @@ ext3_xattr_set_acl(struct dentry *dentry, const char *name, const void *value, | |||
435 | return -EINVAL; | 435 | return -EINVAL; |
436 | if (!test_opt(inode->i_sb, POSIX_ACL)) | 436 | if (!test_opt(inode->i_sb, POSIX_ACL)) |
437 | return -EOPNOTSUPP; | 437 | return -EOPNOTSUPP; |
438 | if (!is_owner_or_cap(inode)) | 438 | if (!inode_owner_or_capable(inode)) |
439 | return -EPERM; | 439 | return -EPERM; |
440 | 440 | ||
441 | if (value) { | 441 | if (value) { |
diff --git a/fs/ext3/ioctl.c b/fs/ext3/ioctl.c index fc080dd561f7..f4090bd2f345 100644 --- a/fs/ext3/ioctl.c +++ b/fs/ext3/ioctl.c | |||
@@ -38,7 +38,7 @@ long ext3_ioctl(struct file *filp, unsigned int cmd, unsigned long arg) | |||
38 | unsigned int oldflags; | 38 | unsigned int oldflags; |
39 | unsigned int jflag; | 39 | unsigned int jflag; |
40 | 40 | ||
41 | if (!is_owner_or_cap(inode)) | 41 | if (!inode_owner_or_capable(inode)) |
42 | return -EACCES; | 42 | return -EACCES; |
43 | 43 | ||
44 | if (get_user(flags, (int __user *) arg)) | 44 | if (get_user(flags, (int __user *) arg)) |
@@ -123,7 +123,7 @@ flags_out: | |||
123 | __u32 generation; | 123 | __u32 generation; |
124 | int err; | 124 | int err; |
125 | 125 | ||
126 | if (!is_owner_or_cap(inode)) | 126 | if (!inode_owner_or_capable(inode)) |
127 | return -EPERM; | 127 | return -EPERM; |
128 | 128 | ||
129 | err = mnt_want_write(filp->f_path.mnt); | 129 | err = mnt_want_write(filp->f_path.mnt); |
@@ -192,7 +192,7 @@ setversion_out: | |||
192 | if (err) | 192 | if (err) |
193 | return err; | 193 | return err; |
194 | 194 | ||
195 | if (!is_owner_or_cap(inode)) { | 195 | if (!inode_owner_or_capable(inode)) { |
196 | err = -EACCES; | 196 | err = -EACCES; |
197 | goto setrsvsz_out; | 197 | goto setrsvsz_out; |
198 | } | 198 | } |
diff --git a/fs/ext4/acl.c b/fs/ext4/acl.c index e0270d1f8d82..21eacd7b7d79 100644 --- a/fs/ext4/acl.c +++ b/fs/ext4/acl.c | |||
@@ -433,7 +433,7 @@ ext4_xattr_set_acl(struct dentry *dentry, const char *name, const void *value, | |||
433 | return -EINVAL; | 433 | return -EINVAL; |
434 | if (!test_opt(inode->i_sb, POSIX_ACL)) | 434 | if (!test_opt(inode->i_sb, POSIX_ACL)) |
435 | return -EOPNOTSUPP; | 435 | return -EOPNOTSUPP; |
436 | if (!is_owner_or_cap(inode)) | 436 | if (!inode_owner_or_capable(inode)) |
437 | return -EPERM; | 437 | return -EPERM; |
438 | 438 | ||
439 | if (value) { | 439 | if (value) { |
diff --git a/fs/ext4/ext4.h b/fs/ext4/ext4.h index 3aa0b72b3b94..4daaf2b753f4 100644 --- a/fs/ext4/ext4.h +++ b/fs/ext4/ext4.h | |||
@@ -923,14 +923,14 @@ struct ext4_inode_info { | |||
923 | #define test_opt2(sb, opt) (EXT4_SB(sb)->s_mount_opt2 & \ | 923 | #define test_opt2(sb, opt) (EXT4_SB(sb)->s_mount_opt2 & \ |
924 | EXT4_MOUNT2_##opt) | 924 | EXT4_MOUNT2_##opt) |
925 | 925 | ||
926 | #define ext4_set_bit ext2_set_bit | 926 | #define ext4_set_bit __test_and_set_bit_le |
927 | #define ext4_set_bit_atomic ext2_set_bit_atomic | 927 | #define ext4_set_bit_atomic ext2_set_bit_atomic |
928 | #define ext4_clear_bit ext2_clear_bit | 928 | #define ext4_clear_bit __test_and_clear_bit_le |
929 | #define ext4_clear_bit_atomic ext2_clear_bit_atomic | 929 | #define ext4_clear_bit_atomic ext2_clear_bit_atomic |
930 | #define ext4_test_bit ext2_test_bit | 930 | #define ext4_test_bit test_bit_le |
931 | #define ext4_find_first_zero_bit ext2_find_first_zero_bit | 931 | #define ext4_find_first_zero_bit find_first_zero_bit_le |
932 | #define ext4_find_next_zero_bit ext2_find_next_zero_bit | 932 | #define ext4_find_next_zero_bit find_next_zero_bit_le |
933 | #define ext4_find_next_bit ext2_find_next_bit | 933 | #define ext4_find_next_bit find_next_bit_le |
934 | 934 | ||
935 | /* | 935 | /* |
936 | * Maximal mount counts between two filesystem checks | 936 | * Maximal mount counts between two filesystem checks |
diff --git a/fs/ext4/extents.c b/fs/ext4/extents.c index ccce8a7e94ed..7516fb9c0bd5 100644 --- a/fs/ext4/extents.c +++ b/fs/ext4/extents.c | |||
@@ -131,7 +131,7 @@ static ext4_fsblk_t ext4_ext_find_goal(struct inode *inode, | |||
131 | * fragmenting the file system's free space. Maybe we | 131 | * fragmenting the file system's free space. Maybe we |
132 | * should have some hueristics or some way to allow | 132 | * should have some hueristics or some way to allow |
133 | * userspace to pass a hint to file system, | 133 | * userspace to pass a hint to file system, |
134 | * especiially if the latter case turns out to be | 134 | * especially if the latter case turns out to be |
135 | * common. | 135 | * common. |
136 | */ | 136 | */ |
137 | ex = path[depth].p_ext; | 137 | ex = path[depth].p_ext; |
@@ -2844,7 +2844,7 @@ fix_extent_len: | |||
2844 | * ext4_get_blocks_dio_write() when DIO to write | 2844 | * ext4_get_blocks_dio_write() when DIO to write |
2845 | * to an uninitialized extent. | 2845 | * to an uninitialized extent. |
2846 | * | 2846 | * |
2847 | * Writing to an uninitized extent may result in splitting the uninitialized | 2847 | * Writing to an uninitialized extent may result in splitting the uninitialized |
2848 | * extent into multiple /initialized uninitialized extents (up to three) | 2848 | * extent into multiple /initialized uninitialized extents (up to three) |
2849 | * There are three possibilities: | 2849 | * There are three possibilities: |
2850 | * a> There is no split required: Entire extent should be uninitialized | 2850 | * a> There is no split required: Entire extent should be uninitialized |
diff --git a/fs/ext4/ioctl.c b/fs/ext4/ioctl.c index eb3bc2fe647e..a84faa110bcd 100644 --- a/fs/ext4/ioctl.c +++ b/fs/ext4/ioctl.c | |||
@@ -38,7 +38,7 @@ long ext4_ioctl(struct file *filp, unsigned int cmd, unsigned long arg) | |||
38 | unsigned int oldflags; | 38 | unsigned int oldflags; |
39 | unsigned int jflag; | 39 | unsigned int jflag; |
40 | 40 | ||
41 | if (!is_owner_or_cap(inode)) | 41 | if (!inode_owner_or_capable(inode)) |
42 | return -EACCES; | 42 | return -EACCES; |
43 | 43 | ||
44 | if (get_user(flags, (int __user *) arg)) | 44 | if (get_user(flags, (int __user *) arg)) |
@@ -146,7 +146,7 @@ flags_out: | |||
146 | __u32 generation; | 146 | __u32 generation; |
147 | int err; | 147 | int err; |
148 | 148 | ||
149 | if (!is_owner_or_cap(inode)) | 149 | if (!inode_owner_or_capable(inode)) |
150 | return -EPERM; | 150 | return -EPERM; |
151 | 151 | ||
152 | err = mnt_want_write(filp->f_path.mnt); | 152 | err = mnt_want_write(filp->f_path.mnt); |
@@ -298,7 +298,7 @@ mext_out: | |||
298 | case EXT4_IOC_MIGRATE: | 298 | case EXT4_IOC_MIGRATE: |
299 | { | 299 | { |
300 | int err; | 300 | int err; |
301 | if (!is_owner_or_cap(inode)) | 301 | if (!inode_owner_or_capable(inode)) |
302 | return -EACCES; | 302 | return -EACCES; |
303 | 303 | ||
304 | err = mnt_want_write(filp->f_path.mnt); | 304 | err = mnt_want_write(filp->f_path.mnt); |
@@ -320,7 +320,7 @@ mext_out: | |||
320 | case EXT4_IOC_ALLOC_DA_BLKS: | 320 | case EXT4_IOC_ALLOC_DA_BLKS: |
321 | { | 321 | { |
322 | int err; | 322 | int err; |
323 | if (!is_owner_or_cap(inode)) | 323 | if (!inode_owner_or_capable(inode)) |
324 | return -EACCES; | 324 | return -EACCES; |
325 | 325 | ||
326 | err = mnt_want_write(filp->f_path.mnt); | 326 | err = mnt_want_write(filp->f_path.mnt); |
diff --git a/fs/fcntl.c b/fs/fcntl.c index 6c82e5bac039..22764c7c8382 100644 --- a/fs/fcntl.c +++ b/fs/fcntl.c | |||
@@ -159,7 +159,7 @@ static int setfl(int fd, struct file * filp, unsigned long arg) | |||
159 | 159 | ||
160 | /* O_NOATIME can only be set by the owner or superuser */ | 160 | /* O_NOATIME can only be set by the owner or superuser */ |
161 | if ((arg & O_NOATIME) && !(filp->f_flags & O_NOATIME)) | 161 | if ((arg & O_NOATIME) && !(filp->f_flags & O_NOATIME)) |
162 | if (!is_owner_or_cap(inode)) | 162 | if (!inode_owner_or_capable(inode)) |
163 | return -EPERM; | 163 | return -EPERM; |
164 | 164 | ||
165 | /* required for strict SunOS emulation */ | 165 | /* required for strict SunOS emulation */ |
@@ -66,8 +66,7 @@ static int fifo_open(struct inode *inode, struct file *filp) | |||
66 | /* suppress POLLHUP until we have | 66 | /* suppress POLLHUP until we have |
67 | * seen a writer */ | 67 | * seen a writer */ |
68 | filp->f_version = pipe->w_counter; | 68 | filp->f_version = pipe->w_counter; |
69 | } else | 69 | } else { |
70 | { | ||
71 | wait_for_partner(inode, &pipe->w_counter); | 70 | wait_for_partner(inode, &pipe->w_counter); |
72 | if(signal_pending(current)) | 71 | if(signal_pending(current)) |
73 | goto err_rd; | 72 | goto err_rd; |
diff --git a/fs/fuse/cuse.c b/fs/fuse/cuse.c index 3e87cce5837d..b6cca47f7b07 100644 --- a/fs/fuse/cuse.c +++ b/fs/fuse/cuse.c | |||
@@ -305,7 +305,7 @@ static void cuse_gendev_release(struct device *dev) | |||
305 | static void cuse_process_init_reply(struct fuse_conn *fc, struct fuse_req *req) | 305 | static void cuse_process_init_reply(struct fuse_conn *fc, struct fuse_req *req) |
306 | { | 306 | { |
307 | struct cuse_conn *cc = fc_to_cc(fc); | 307 | struct cuse_conn *cc = fc_to_cc(fc); |
308 | struct cuse_init_out *arg = &req->misc.cuse_init_out; | 308 | struct cuse_init_out *arg = req->out.args[0].value; |
309 | struct page *page = req->pages[0]; | 309 | struct page *page = req->pages[0]; |
310 | struct cuse_devinfo devinfo = { }; | 310 | struct cuse_devinfo devinfo = { }; |
311 | struct device *dev; | 311 | struct device *dev; |
@@ -384,6 +384,7 @@ static void cuse_process_init_reply(struct fuse_conn *fc, struct fuse_req *req) | |||
384 | dev_set_uevent_suppress(dev, 0); | 384 | dev_set_uevent_suppress(dev, 0); |
385 | kobject_uevent(&dev->kobj, KOBJ_ADD); | 385 | kobject_uevent(&dev->kobj, KOBJ_ADD); |
386 | out: | 386 | out: |
387 | kfree(arg); | ||
387 | __free_page(page); | 388 | __free_page(page); |
388 | return; | 389 | return; |
389 | 390 | ||
@@ -405,6 +406,7 @@ static int cuse_send_init(struct cuse_conn *cc) | |||
405 | struct page *page; | 406 | struct page *page; |
406 | struct fuse_conn *fc = &cc->fc; | 407 | struct fuse_conn *fc = &cc->fc; |
407 | struct cuse_init_in *arg; | 408 | struct cuse_init_in *arg; |
409 | void *outarg; | ||
408 | 410 | ||
409 | BUILD_BUG_ON(CUSE_INIT_INFO_MAX > PAGE_SIZE); | 411 | BUILD_BUG_ON(CUSE_INIT_INFO_MAX > PAGE_SIZE); |
410 | 412 | ||
@@ -419,6 +421,10 @@ static int cuse_send_init(struct cuse_conn *cc) | |||
419 | if (!page) | 421 | if (!page) |
420 | goto err_put_req; | 422 | goto err_put_req; |
421 | 423 | ||
424 | outarg = kzalloc(sizeof(struct cuse_init_out), GFP_KERNEL); | ||
425 | if (!outarg) | ||
426 | goto err_free_page; | ||
427 | |||
422 | arg = &req->misc.cuse_init_in; | 428 | arg = &req->misc.cuse_init_in; |
423 | arg->major = FUSE_KERNEL_VERSION; | 429 | arg->major = FUSE_KERNEL_VERSION; |
424 | arg->minor = FUSE_KERNEL_MINOR_VERSION; | 430 | arg->minor = FUSE_KERNEL_MINOR_VERSION; |
@@ -429,7 +435,7 @@ static int cuse_send_init(struct cuse_conn *cc) | |||
429 | req->in.args[0].value = arg; | 435 | req->in.args[0].value = arg; |
430 | req->out.numargs = 2; | 436 | req->out.numargs = 2; |
431 | req->out.args[0].size = sizeof(struct cuse_init_out); | 437 | req->out.args[0].size = sizeof(struct cuse_init_out); |
432 | req->out.args[0].value = &req->misc.cuse_init_out; | 438 | req->out.args[0].value = outarg; |
433 | req->out.args[1].size = CUSE_INIT_INFO_MAX; | 439 | req->out.args[1].size = CUSE_INIT_INFO_MAX; |
434 | req->out.argvar = 1; | 440 | req->out.argvar = 1; |
435 | req->out.argpages = 1; | 441 | req->out.argpages = 1; |
@@ -440,6 +446,8 @@ static int cuse_send_init(struct cuse_conn *cc) | |||
440 | 446 | ||
441 | return 0; | 447 | return 0; |
442 | 448 | ||
449 | err_free_page: | ||
450 | __free_page(page); | ||
443 | err_put_req: | 451 | err_put_req: |
444 | fuse_put_request(fc, req); | 452 | fuse_put_request(fc, req); |
445 | err: | 453 | err: |
@@ -458,7 +466,7 @@ static void cuse_fc_release(struct fuse_conn *fc) | |||
458 | * @file: file struct being opened | 466 | * @file: file struct being opened |
459 | * | 467 | * |
460 | * Userland CUSE server can create a CUSE device by opening /dev/cuse | 468 | * Userland CUSE server can create a CUSE device by opening /dev/cuse |
461 | * and replying to the initilaization request kernel sends. This | 469 | * and replying to the initialization request kernel sends. This |
462 | * function is responsible for handling CUSE device initialization. | 470 | * function is responsible for handling CUSE device initialization. |
463 | * Because the fd opened by this function is used during | 471 | * Because the fd opened by this function is used during |
464 | * initialization, this function only creates cuse_conn and sends | 472 | * initialization, this function only creates cuse_conn and sends |
diff --git a/fs/fuse/dev.c b/fs/fuse/dev.c index cf8d28d1fbad..640fc229df10 100644 --- a/fs/fuse/dev.c +++ b/fs/fuse/dev.c | |||
@@ -737,14 +737,12 @@ static int fuse_try_move_page(struct fuse_copy_state *cs, struct page **pagep) | |||
737 | if (WARN_ON(PageMlocked(oldpage))) | 737 | if (WARN_ON(PageMlocked(oldpage))) |
738 | goto out_fallback_unlock; | 738 | goto out_fallback_unlock; |
739 | 739 | ||
740 | remove_from_page_cache(oldpage); | 740 | err = replace_page_cache_page(oldpage, newpage, GFP_KERNEL); |
741 | page_cache_release(oldpage); | ||
742 | |||
743 | err = add_to_page_cache_locked(newpage, mapping, index, GFP_KERNEL); | ||
744 | if (err) { | 741 | if (err) { |
745 | printk(KERN_WARNING "fuse_try_move_page: failed to add page"); | 742 | unlock_page(newpage); |
746 | goto out_fallback_unlock; | 743 | return err; |
747 | } | 744 | } |
745 | |||
748 | page_cache_get(newpage); | 746 | page_cache_get(newpage); |
749 | 747 | ||
750 | if (!(buf->flags & PIPE_BUF_FLAG_LRU)) | 748 | if (!(buf->flags & PIPE_BUF_FLAG_LRU)) |
@@ -1910,6 +1908,21 @@ __acquires(fc->lock) | |||
1910 | kfree(dequeue_forget(fc, 1, NULL)); | 1908 | kfree(dequeue_forget(fc, 1, NULL)); |
1911 | } | 1909 | } |
1912 | 1910 | ||
1911 | static void end_polls(struct fuse_conn *fc) | ||
1912 | { | ||
1913 | struct rb_node *p; | ||
1914 | |||
1915 | p = rb_first(&fc->polled_files); | ||
1916 | |||
1917 | while (p) { | ||
1918 | struct fuse_file *ff; | ||
1919 | ff = rb_entry(p, struct fuse_file, polled_node); | ||
1920 | wake_up_interruptible_all(&ff->poll_wait); | ||
1921 | |||
1922 | p = rb_next(p); | ||
1923 | } | ||
1924 | } | ||
1925 | |||
1913 | /* | 1926 | /* |
1914 | * Abort all requests. | 1927 | * Abort all requests. |
1915 | * | 1928 | * |
@@ -1937,6 +1950,7 @@ void fuse_abort_conn(struct fuse_conn *fc) | |||
1937 | fc->blocked = 0; | 1950 | fc->blocked = 0; |
1938 | end_io_requests(fc); | 1951 | end_io_requests(fc); |
1939 | end_queued_requests(fc); | 1952 | end_queued_requests(fc); |
1953 | end_polls(fc); | ||
1940 | wake_up_all(&fc->waitq); | 1954 | wake_up_all(&fc->waitq); |
1941 | wake_up_all(&fc->blocked_waitq); | 1955 | wake_up_all(&fc->blocked_waitq); |
1942 | kill_fasync(&fc->fasync, SIGIO, POLL_IN); | 1956 | kill_fasync(&fc->fasync, SIGIO, POLL_IN); |
@@ -1953,6 +1967,7 @@ int fuse_dev_release(struct inode *inode, struct file *file) | |||
1953 | fc->connected = 0; | 1967 | fc->connected = 0; |
1954 | fc->blocked = 0; | 1968 | fc->blocked = 0; |
1955 | end_queued_requests(fc); | 1969 | end_queued_requests(fc); |
1970 | end_polls(fc); | ||
1956 | wake_up_all(&fc->blocked_waitq); | 1971 | wake_up_all(&fc->blocked_waitq); |
1957 | spin_unlock(&fc->lock); | 1972 | spin_unlock(&fc->lock); |
1958 | fuse_conn_put(fc); | 1973 | fuse_conn_put(fc); |
diff --git a/fs/fuse/dir.c b/fs/fuse/dir.c index 8bd0ef9286c3..c6ba49bd95b3 100644 --- a/fs/fuse/dir.c +++ b/fs/fuse/dir.c | |||
@@ -158,10 +158,7 @@ static int fuse_dentry_revalidate(struct dentry *entry, struct nameidata *nd) | |||
158 | { | 158 | { |
159 | struct inode *inode; | 159 | struct inode *inode; |
160 | 160 | ||
161 | if (nd && nd->flags & LOOKUP_RCU) | 161 | inode = ACCESS_ONCE(entry->d_inode); |
162 | return -ECHILD; | ||
163 | |||
164 | inode = entry->d_inode; | ||
165 | if (inode && is_bad_inode(inode)) | 162 | if (inode && is_bad_inode(inode)) |
166 | return 0; | 163 | return 0; |
167 | else if (fuse_dentry_time(entry) < get_jiffies_64()) { | 164 | else if (fuse_dentry_time(entry) < get_jiffies_64()) { |
@@ -177,6 +174,9 @@ static int fuse_dentry_revalidate(struct dentry *entry, struct nameidata *nd) | |||
177 | if (!inode) | 174 | if (!inode) |
178 | return 0; | 175 | return 0; |
179 | 176 | ||
177 | if (nd->flags & LOOKUP_RCU) | ||
178 | return -ECHILD; | ||
179 | |||
180 | fc = get_fuse_conn(inode); | 180 | fc = get_fuse_conn(inode); |
181 | req = fuse_get_req(fc); | 181 | req = fuse_get_req(fc); |
182 | if (IS_ERR(req)) | 182 | if (IS_ERR(req)) |
@@ -970,6 +970,14 @@ static int fuse_access(struct inode *inode, int mask) | |||
970 | return err; | 970 | return err; |
971 | } | 971 | } |
972 | 972 | ||
973 | static int fuse_perm_getattr(struct inode *inode, int flags) | ||
974 | { | ||
975 | if (flags & IPERM_FLAG_RCU) | ||
976 | return -ECHILD; | ||
977 | |||
978 | return fuse_do_getattr(inode, NULL, NULL); | ||
979 | } | ||
980 | |||
973 | /* | 981 | /* |
974 | * Check permission. The two basic access models of FUSE are: | 982 | * Check permission. The two basic access models of FUSE are: |
975 | * | 983 | * |
@@ -989,9 +997,6 @@ static int fuse_permission(struct inode *inode, int mask, unsigned int flags) | |||
989 | bool refreshed = false; | 997 | bool refreshed = false; |
990 | int err = 0; | 998 | int err = 0; |
991 | 999 | ||
992 | if (flags & IPERM_FLAG_RCU) | ||
993 | return -ECHILD; | ||
994 | |||
995 | if (!fuse_allow_task(fc, current)) | 1000 | if (!fuse_allow_task(fc, current)) |
996 | return -EACCES; | 1001 | return -EACCES; |
997 | 1002 | ||
@@ -1000,9 +1005,15 @@ static int fuse_permission(struct inode *inode, int mask, unsigned int flags) | |||
1000 | */ | 1005 | */ |
1001 | if ((fc->flags & FUSE_DEFAULT_PERMISSIONS) || | 1006 | if ((fc->flags & FUSE_DEFAULT_PERMISSIONS) || |
1002 | ((mask & MAY_EXEC) && S_ISREG(inode->i_mode))) { | 1007 | ((mask & MAY_EXEC) && S_ISREG(inode->i_mode))) { |
1003 | err = fuse_update_attributes(inode, NULL, NULL, &refreshed); | 1008 | struct fuse_inode *fi = get_fuse_inode(inode); |
1004 | if (err) | 1009 | |
1005 | return err; | 1010 | if (fi->i_time < get_jiffies_64()) { |
1011 | refreshed = true; | ||
1012 | |||
1013 | err = fuse_perm_getattr(inode, flags); | ||
1014 | if (err) | ||
1015 | return err; | ||
1016 | } | ||
1006 | } | 1017 | } |
1007 | 1018 | ||
1008 | if (fc->flags & FUSE_DEFAULT_PERMISSIONS) { | 1019 | if (fc->flags & FUSE_DEFAULT_PERMISSIONS) { |
@@ -1012,7 +1023,7 @@ static int fuse_permission(struct inode *inode, int mask, unsigned int flags) | |||
1012 | attributes. This is also needed, because the root | 1023 | attributes. This is also needed, because the root |
1013 | node will at first have no permissions */ | 1024 | node will at first have no permissions */ |
1014 | if (err == -EACCES && !refreshed) { | 1025 | if (err == -EACCES && !refreshed) { |
1015 | err = fuse_do_getattr(inode, NULL, NULL); | 1026 | err = fuse_perm_getattr(inode, flags); |
1016 | if (!err) | 1027 | if (!err) |
1017 | err = generic_permission(inode, mask, | 1028 | err = generic_permission(inode, mask, |
1018 | flags, NULL); | 1029 | flags, NULL); |
@@ -1023,13 +1034,16 @@ static int fuse_permission(struct inode *inode, int mask, unsigned int flags) | |||
1023 | noticed immediately, only after the attribute | 1034 | noticed immediately, only after the attribute |
1024 | timeout has expired */ | 1035 | timeout has expired */ |
1025 | } else if (mask & (MAY_ACCESS | MAY_CHDIR)) { | 1036 | } else if (mask & (MAY_ACCESS | MAY_CHDIR)) { |
1037 | if (flags & IPERM_FLAG_RCU) | ||
1038 | return -ECHILD; | ||
1039 | |||
1026 | err = fuse_access(inode, mask); | 1040 | err = fuse_access(inode, mask); |
1027 | } else if ((mask & MAY_EXEC) && S_ISREG(inode->i_mode)) { | 1041 | } else if ((mask & MAY_EXEC) && S_ISREG(inode->i_mode)) { |
1028 | if (!(inode->i_mode & S_IXUGO)) { | 1042 | if (!(inode->i_mode & S_IXUGO)) { |
1029 | if (refreshed) | 1043 | if (refreshed) |
1030 | return -EACCES; | 1044 | return -EACCES; |
1031 | 1045 | ||
1032 | err = fuse_do_getattr(inode, NULL, NULL); | 1046 | err = fuse_perm_getattr(inode, flags); |
1033 | if (!err && !(inode->i_mode & S_IXUGO)) | 1047 | if (!err && !(inode->i_mode & S_IXUGO)) |
1034 | return -EACCES; | 1048 | return -EACCES; |
1035 | } | 1049 | } |
diff --git a/fs/fuse/file.c b/fs/fuse/file.c index 9e0832dbb1e3..6ea00734984e 100644 --- a/fs/fuse/file.c +++ b/fs/fuse/file.c | |||
@@ -222,7 +222,7 @@ static void fuse_prepare_release(struct fuse_file *ff, int flags, int opcode) | |||
222 | rb_erase(&ff->polled_node, &fc->polled_files); | 222 | rb_erase(&ff->polled_node, &fc->polled_files); |
223 | spin_unlock(&fc->lock); | 223 | spin_unlock(&fc->lock); |
224 | 224 | ||
225 | wake_up_interruptible_sync(&ff->poll_wait); | 225 | wake_up_interruptible_all(&ff->poll_wait); |
226 | 226 | ||
227 | inarg->fh = ff->fh; | 227 | inarg->fh = ff->fh; |
228 | inarg->flags = flags; | 228 | inarg->flags = flags; |
diff --git a/fs/fuse/fuse_i.h b/fs/fuse/fuse_i.h index d4286947bc2c..b788becada76 100644 --- a/fs/fuse/fuse_i.h +++ b/fs/fuse/fuse_i.h | |||
@@ -272,7 +272,6 @@ struct fuse_req { | |||
272 | struct fuse_init_in init_in; | 272 | struct fuse_init_in init_in; |
273 | struct fuse_init_out init_out; | 273 | struct fuse_init_out init_out; |
274 | struct cuse_init_in cuse_init_in; | 274 | struct cuse_init_in cuse_init_in; |
275 | struct cuse_init_out cuse_init_out; | ||
276 | struct { | 275 | struct { |
277 | struct fuse_read_in in; | 276 | struct fuse_read_in in; |
278 | u64 attr_ver; | 277 | u64 attr_ver; |
diff --git a/fs/generic_acl.c b/fs/generic_acl.c index 06c48a891832..8f26d1a58912 100644 --- a/fs/generic_acl.c +++ b/fs/generic_acl.c | |||
@@ -74,7 +74,7 @@ generic_acl_set(struct dentry *dentry, const char *name, const void *value, | |||
74 | return -EINVAL; | 74 | return -EINVAL; |
75 | if (S_ISLNK(inode->i_mode)) | 75 | if (S_ISLNK(inode->i_mode)) |
76 | return -EOPNOTSUPP; | 76 | return -EOPNOTSUPP; |
77 | if (!is_owner_or_cap(inode)) | 77 | if (!inode_owner_or_capable(inode)) |
78 | return -EPERM; | 78 | return -EPERM; |
79 | if (value) { | 79 | if (value) { |
80 | acl = posix_acl_from_xattr(value, size); | 80 | acl = posix_acl_from_xattr(value, size); |
diff --git a/fs/gfs2/Makefile b/fs/gfs2/Makefile index 21f7e46da4c0..f3d23ef4e876 100644 --- a/fs/gfs2/Makefile +++ b/fs/gfs2/Makefile | |||
@@ -1,4 +1,4 @@ | |||
1 | EXTRA_CFLAGS := -I$(src) | 1 | ccflags-y := -I$(src) |
2 | obj-$(CONFIG_GFS2_FS) += gfs2.o | 2 | obj-$(CONFIG_GFS2_FS) += gfs2.o |
3 | gfs2-y := acl.o bmap.o dir.o xattr.o glock.o \ | 3 | gfs2-y := acl.o bmap.o dir.o xattr.o glock.o \ |
4 | glops.o inode.o log.o lops.o main.o meta_io.o \ | 4 | glops.o inode.o log.o lops.o main.o meta_io.o \ |
diff --git a/fs/gfs2/file.c b/fs/gfs2/file.c index 4074b952b059..b2682e073eee 100644 --- a/fs/gfs2/file.c +++ b/fs/gfs2/file.c | |||
@@ -221,7 +221,7 @@ static int do_gfs2_set_flags(struct file *filp, u32 reqflags, u32 mask) | |||
221 | goto out_drop_write; | 221 | goto out_drop_write; |
222 | 222 | ||
223 | error = -EACCES; | 223 | error = -EACCES; |
224 | if (!is_owner_or_cap(inode)) | 224 | if (!inode_owner_or_capable(inode)) |
225 | goto out; | 225 | goto out; |
226 | 226 | ||
227 | error = 0; | 227 | error = 0; |
diff --git a/fs/hfsplus/ioctl.c b/fs/hfsplus/ioctl.c index 508ce662ce12..fbaa6690c8e0 100644 --- a/fs/hfsplus/ioctl.c +++ b/fs/hfsplus/ioctl.c | |||
@@ -47,7 +47,7 @@ static int hfsplus_ioctl_setflags(struct file *file, int __user *user_flags) | |||
47 | if (err) | 47 | if (err) |
48 | goto out; | 48 | goto out; |
49 | 49 | ||
50 | if (!is_owner_or_cap(inode)) { | 50 | if (!inode_owner_or_capable(inode)) { |
51 | err = -EACCES; | 51 | err = -EACCES; |
52 | goto out_drop_write; | 52 | goto out_drop_write; |
53 | } | 53 | } |
diff --git a/fs/hugetlbfs/inode.c b/fs/hugetlbfs/inode.c index 9885082b470f..b9eeb1cd03ff 100644 --- a/fs/hugetlbfs/inode.c +++ b/fs/hugetlbfs/inode.c | |||
@@ -332,8 +332,7 @@ static void truncate_huge_page(struct page *page) | |||
332 | { | 332 | { |
333 | cancel_dirty_page(page, /* No IO accounting for huge pages? */0); | 333 | cancel_dirty_page(page, /* No IO accounting for huge pages? */0); |
334 | ClearPageUptodate(page); | 334 | ClearPageUptodate(page); |
335 | remove_from_page_cache(page); | 335 | delete_from_page_cache(page); |
336 | put_page(page); | ||
337 | } | 336 | } |
338 | 337 | ||
339 | static void truncate_hugepages(struct inode *inode, loff_t lstart) | 338 | static void truncate_hugepages(struct inode *inode, loff_t lstart) |
diff --git a/fs/inode.c b/fs/inode.c index 9910c039f026..0b3da4a77704 100644 --- a/fs/inode.c +++ b/fs/inode.c | |||
@@ -25,6 +25,7 @@ | |||
25 | #include <linux/async.h> | 25 | #include <linux/async.h> |
26 | #include <linux/posix_acl.h> | 26 | #include <linux/posix_acl.h> |
27 | #include <linux/ima.h> | 27 | #include <linux/ima.h> |
28 | #include <linux/cred.h> | ||
28 | 29 | ||
29 | /* | 30 | /* |
30 | * This is needed for the following functions: | 31 | * This is needed for the following functions: |
@@ -1715,7 +1716,7 @@ void init_special_inode(struct inode *inode, umode_t mode, dev_t rdev) | |||
1715 | EXPORT_SYMBOL(init_special_inode); | 1716 | EXPORT_SYMBOL(init_special_inode); |
1716 | 1717 | ||
1717 | /** | 1718 | /** |
1718 | * Init uid,gid,mode for new inode according to posix standards | 1719 | * inode_init_owner - Init uid,gid,mode for new inode according to posix standards |
1719 | * @inode: New inode | 1720 | * @inode: New inode |
1720 | * @dir: Directory inode | 1721 | * @dir: Directory inode |
1721 | * @mode: mode of the new inode | 1722 | * @mode: mode of the new inode |
@@ -1733,3 +1734,22 @@ void inode_init_owner(struct inode *inode, const struct inode *dir, | |||
1733 | inode->i_mode = mode; | 1734 | inode->i_mode = mode; |
1734 | } | 1735 | } |
1735 | EXPORT_SYMBOL(inode_init_owner); | 1736 | EXPORT_SYMBOL(inode_init_owner); |
1737 | |||
1738 | /** | ||
1739 | * inode_owner_or_capable - check current task permissions to inode | ||
1740 | * @inode: inode being checked | ||
1741 | * | ||
1742 | * Return true if current either has CAP_FOWNER to the inode, or | ||
1743 | * owns the file. | ||
1744 | */ | ||
1745 | bool inode_owner_or_capable(const struct inode *inode) | ||
1746 | { | ||
1747 | struct user_namespace *ns = inode_userns(inode); | ||
1748 | |||
1749 | if (current_user_ns() == ns && current_fsuid() == inode->i_uid) | ||
1750 | return true; | ||
1751 | if (ns_capable(ns, CAP_FOWNER)) | ||
1752 | return true; | ||
1753 | return false; | ||
1754 | } | ||
1755 | EXPORT_SYMBOL(inode_owner_or_capable); | ||
diff --git a/fs/internal.h b/fs/internal.h index f3d15de44b15..8318059b42c6 100644 --- a/fs/internal.h +++ b/fs/internal.h | |||
@@ -12,6 +12,7 @@ | |||
12 | #include <linux/lglock.h> | 12 | #include <linux/lglock.h> |
13 | 13 | ||
14 | struct super_block; | 14 | struct super_block; |
15 | struct file_system_type; | ||
15 | struct linux_binprm; | 16 | struct linux_binprm; |
16 | struct path; | 17 | struct path; |
17 | 18 | ||
@@ -61,10 +62,9 @@ extern int check_unsafe_exec(struct linux_binprm *); | |||
61 | extern int copy_mount_options(const void __user *, unsigned long *); | 62 | extern int copy_mount_options(const void __user *, unsigned long *); |
62 | extern int copy_mount_string(const void __user *, char **); | 63 | extern int copy_mount_string(const void __user *, char **); |
63 | 64 | ||
64 | extern void free_vfsmnt(struct vfsmount *); | ||
65 | extern struct vfsmount *alloc_vfsmnt(const char *); | ||
66 | extern unsigned int mnt_get_count(struct vfsmount *mnt); | 65 | extern unsigned int mnt_get_count(struct vfsmount *mnt); |
67 | extern struct vfsmount *__lookup_mnt(struct vfsmount *, struct dentry *, int); | 66 | extern struct vfsmount *__lookup_mnt(struct vfsmount *, struct dentry *, int); |
67 | extern struct vfsmount *lookup_mnt(struct path *); | ||
68 | extern void mnt_set_mountpoint(struct vfsmount *, struct dentry *, | 68 | extern void mnt_set_mountpoint(struct vfsmount *, struct dentry *, |
69 | struct vfsmount *); | 69 | struct vfsmount *); |
70 | extern void release_mounts(struct list_head *); | 70 | extern void release_mounts(struct list_head *); |
@@ -99,6 +99,8 @@ extern struct file *get_empty_filp(void); | |||
99 | extern int do_remount_sb(struct super_block *, int, void *, int); | 99 | extern int do_remount_sb(struct super_block *, int, void *, int); |
100 | extern void __put_super(struct super_block *sb); | 100 | extern void __put_super(struct super_block *sb); |
101 | extern void put_super(struct super_block *sb); | 101 | extern void put_super(struct super_block *sb); |
102 | extern struct dentry *mount_fs(struct file_system_type *, | ||
103 | int, const char *, void *); | ||
102 | 104 | ||
103 | /* | 105 | /* |
104 | * open.c | 106 | * open.c |
diff --git a/fs/ioctl.c b/fs/ioctl.c index 1eebeb72b202..1d9b9fcb2db4 100644 --- a/fs/ioctl.c +++ b/fs/ioctl.c | |||
@@ -548,6 +548,7 @@ int do_vfs_ioctl(struct file *filp, unsigned int fd, unsigned int cmd, | |||
548 | { | 548 | { |
549 | int error = 0; | 549 | int error = 0; |
550 | int __user *argp = (int __user *)arg; | 550 | int __user *argp = (int __user *)arg; |
551 | struct inode *inode = filp->f_path.dentry->d_inode; | ||
551 | 552 | ||
552 | switch (cmd) { | 553 | switch (cmd) { |
553 | case FIOCLEX: | 554 | case FIOCLEX: |
@@ -567,13 +568,11 @@ int do_vfs_ioctl(struct file *filp, unsigned int fd, unsigned int cmd, | |||
567 | break; | 568 | break; |
568 | 569 | ||
569 | case FIOQSIZE: | 570 | case FIOQSIZE: |
570 | if (S_ISDIR(filp->f_path.dentry->d_inode->i_mode) || | 571 | if (S_ISDIR(inode->i_mode) || S_ISREG(inode->i_mode) || |
571 | S_ISREG(filp->f_path.dentry->d_inode->i_mode) || | 572 | S_ISLNK(inode->i_mode)) { |
572 | S_ISLNK(filp->f_path.dentry->d_inode->i_mode)) { | 573 | loff_t res = inode_get_bytes(inode); |
573 | loff_t res = | 574 | error = copy_to_user(argp, &res, sizeof(res)) ? |
574 | inode_get_bytes(filp->f_path.dentry->d_inode); | 575 | -EFAULT : 0; |
575 | error = copy_to_user((loff_t __user *)arg, &res, | ||
576 | sizeof(res)) ? -EFAULT : 0; | ||
577 | } else | 576 | } else |
578 | error = -ENOTTY; | 577 | error = -ENOTTY; |
579 | break; | 578 | break; |
@@ -590,14 +589,10 @@ int do_vfs_ioctl(struct file *filp, unsigned int fd, unsigned int cmd, | |||
590 | return ioctl_fiemap(filp, arg); | 589 | return ioctl_fiemap(filp, arg); |
591 | 590 | ||
592 | case FIGETBSZ: | 591 | case FIGETBSZ: |
593 | { | 592 | return put_user(inode->i_sb->s_blocksize, argp); |
594 | struct inode *inode = filp->f_path.dentry->d_inode; | ||
595 | int __user *p = (int __user *)arg; | ||
596 | return put_user(inode->i_sb->s_blocksize, p); | ||
597 | } | ||
598 | 593 | ||
599 | default: | 594 | default: |
600 | if (S_ISREG(filp->f_path.dentry->d_inode->i_mode)) | 595 | if (S_ISREG(inode->i_mode)) |
601 | error = file_ioctl(filp, cmd, arg); | 596 | error = file_ioctl(filp, cmd, arg); |
602 | else | 597 | else |
603 | error = vfs_ioctl(filp, cmd, arg); | 598 | error = vfs_ioctl(filp, cmd, arg); |
diff --git a/fs/jffs2/acl.c b/fs/jffs2/acl.c index 95b79672150a..828a0e1ea438 100644 --- a/fs/jffs2/acl.c +++ b/fs/jffs2/acl.c | |||
@@ -402,7 +402,7 @@ static int jffs2_acl_setxattr(struct dentry *dentry, const char *name, | |||
402 | 402 | ||
403 | if (name[0] != '\0') | 403 | if (name[0] != '\0') |
404 | return -EINVAL; | 404 | return -EINVAL; |
405 | if (!is_owner_or_cap(dentry->d_inode)) | 405 | if (!inode_owner_or_capable(dentry->d_inode)) |
406 | return -EPERM; | 406 | return -EPERM; |
407 | 407 | ||
408 | if (value) { | 408 | if (value) { |
diff --git a/fs/jffs2/compr_zlib.c b/fs/jffs2/compr_zlib.c index fd05a0b9431d..5a001020c542 100644 --- a/fs/jffs2/compr_zlib.c +++ b/fs/jffs2/compr_zlib.c | |||
@@ -40,12 +40,13 @@ static z_stream inf_strm, def_strm; | |||
40 | 40 | ||
41 | static int __init alloc_workspaces(void) | 41 | static int __init alloc_workspaces(void) |
42 | { | 42 | { |
43 | def_strm.workspace = vmalloc(zlib_deflate_workspacesize()); | 43 | def_strm.workspace = vmalloc(zlib_deflate_workspacesize(MAX_WBITS, |
44 | MAX_MEM_LEVEL)); | ||
44 | if (!def_strm.workspace) { | 45 | if (!def_strm.workspace) { |
45 | printk(KERN_WARNING "Failed to allocate %d bytes for deflate workspace\n", zlib_deflate_workspacesize()); | 46 | printk(KERN_WARNING "Failed to allocate %d bytes for deflate workspace\n", zlib_deflate_workspacesize(MAX_WBITS, MAX_MEM_LEVEL)); |
46 | return -ENOMEM; | 47 | return -ENOMEM; |
47 | } | 48 | } |
48 | D1(printk(KERN_DEBUG "Allocated %d bytes for deflate workspace\n", zlib_deflate_workspacesize())); | 49 | D1(printk(KERN_DEBUG "Allocated %d bytes for deflate workspace\n", zlib_deflate_workspacesize(MAX_WBITS, MAX_MEM_LEVEL))); |
49 | inf_strm.workspace = vmalloc(zlib_inflate_workspacesize()); | 50 | inf_strm.workspace = vmalloc(zlib_inflate_workspacesize()); |
50 | if (!inf_strm.workspace) { | 51 | if (!inf_strm.workspace) { |
51 | printk(KERN_WARNING "Failed to allocate %d bytes for inflate workspace\n", zlib_inflate_workspacesize()); | 52 | printk(KERN_WARNING "Failed to allocate %d bytes for inflate workspace\n", zlib_inflate_workspacesize()); |
diff --git a/fs/jfs/Makefile b/fs/jfs/Makefile index 3adb6395e42d..a58fa72d7e59 100644 --- a/fs/jfs/Makefile +++ b/fs/jfs/Makefile | |||
@@ -13,4 +13,4 @@ jfs-y := super.o file.o inode.o namei.o jfs_mount.o jfs_umount.o \ | |||
13 | 13 | ||
14 | jfs-$(CONFIG_JFS_POSIX_ACL) += acl.o | 14 | jfs-$(CONFIG_JFS_POSIX_ACL) += acl.o |
15 | 15 | ||
16 | EXTRA_CFLAGS += -D_JFS_4K | 16 | ccflags-y := -D_JFS_4K |
diff --git a/fs/jfs/ioctl.c b/fs/jfs/ioctl.c index afe222bf300f..6f98a1866776 100644 --- a/fs/jfs/ioctl.c +++ b/fs/jfs/ioctl.c | |||
@@ -72,7 +72,7 @@ long jfs_ioctl(struct file *filp, unsigned int cmd, unsigned long arg) | |||
72 | if (err) | 72 | if (err) |
73 | return err; | 73 | return err; |
74 | 74 | ||
75 | if (!is_owner_or_cap(inode)) { | 75 | if (!inode_owner_or_capable(inode)) { |
76 | err = -EACCES; | 76 | err = -EACCES; |
77 | goto setflags_out; | 77 | goto setflags_out; |
78 | } | 78 | } |
diff --git a/fs/jfs/xattr.c b/fs/jfs/xattr.c index 3fa4c32272df..24838f1eeee5 100644 --- a/fs/jfs/xattr.c +++ b/fs/jfs/xattr.c | |||
@@ -678,7 +678,7 @@ static int can_set_system_xattr(struct inode *inode, const char *name, | |||
678 | struct posix_acl *acl; | 678 | struct posix_acl *acl; |
679 | int rc; | 679 | int rc; |
680 | 680 | ||
681 | if (!is_owner_or_cap(inode)) | 681 | if (!inode_owner_or_capable(inode)) |
682 | return -EPERM; | 682 | return -EPERM; |
683 | 683 | ||
684 | /* | 684 | /* |
diff --git a/fs/locks.c b/fs/locks.c index 822c3d1843af..0a4f50dfadfb 100644 --- a/fs/locks.c +++ b/fs/locks.c | |||
@@ -414,17 +414,7 @@ static int flock64_to_posix_lock(struct file *filp, struct file_lock *fl, | |||
414 | fl->fl_ops = NULL; | 414 | fl->fl_ops = NULL; |
415 | fl->fl_lmops = NULL; | 415 | fl->fl_lmops = NULL; |
416 | 416 | ||
417 | switch (l->l_type) { | 417 | return assign_type(fl, l->l_type); |
418 | case F_RDLCK: | ||
419 | case F_WRLCK: | ||
420 | case F_UNLCK: | ||
421 | fl->fl_type = l->l_type; | ||
422 | break; | ||
423 | default: | ||
424 | return -EINVAL; | ||
425 | } | ||
426 | |||
427 | return (0); | ||
428 | } | 418 | } |
429 | #endif | 419 | #endif |
430 | 420 | ||
diff --git a/fs/logfs/compr.c b/fs/logfs/compr.c index 44bbfd249abc..961f02b86d97 100644 --- a/fs/logfs/compr.c +++ b/fs/logfs/compr.c | |||
@@ -81,7 +81,7 @@ error: | |||
81 | 81 | ||
82 | int __init logfs_compr_init(void) | 82 | int __init logfs_compr_init(void) |
83 | { | 83 | { |
84 | size_t size = max(zlib_deflate_workspacesize(), | 84 | size_t size = max(zlib_deflate_workspacesize(MAX_WBITS, MAX_MEM_LEVEL), |
85 | zlib_inflate_workspacesize()); | 85 | zlib_inflate_workspacesize()); |
86 | stream.workspace = vmalloc(size); | 86 | stream.workspace = vmalloc(size); |
87 | if (!stream.workspace) | 87 | if (!stream.workspace) |
diff --git a/fs/logfs/file.c b/fs/logfs/file.c index e86376b87af1..c2ad7028def4 100644 --- a/fs/logfs/file.c +++ b/fs/logfs/file.c | |||
@@ -196,7 +196,7 @@ long logfs_ioctl(struct file *file, unsigned int cmd, unsigned long arg) | |||
196 | if (IS_RDONLY(inode)) | 196 | if (IS_RDONLY(inode)) |
197 | return -EROFS; | 197 | return -EROFS; |
198 | 198 | ||
199 | if (!is_owner_or_cap(inode)) | 199 | if (!inode_owner_or_capable(inode)) |
200 | return -EACCES; | 200 | return -EACCES; |
201 | 201 | ||
202 | err = get_user(flags, (int __user *)arg); | 202 | err = get_user(flags, (int __user *)arg); |
diff --git a/fs/minix/Kconfig b/fs/minix/Kconfig index 0fd7ca994264..6624684dd5de 100644 --- a/fs/minix/Kconfig +++ b/fs/minix/Kconfig | |||
@@ -15,3 +15,11 @@ config MINIX_FS | |||
15 | module will be called minix. Note that the file system of your root | 15 | module will be called minix. Note that the file system of your root |
16 | partition (the one containing the directory /) cannot be compiled as | 16 | partition (the one containing the directory /) cannot be compiled as |
17 | a module. | 17 | a module. |
18 | |||
19 | config MINIX_FS_NATIVE_ENDIAN | ||
20 | def_bool MINIX_FS | ||
21 | depends on H8300 || M32R || MICROBLAZE || MIPS || S390 || SUPERH || SPARC || XTENSA || (M68K && !MMU) | ||
22 | |||
23 | config MINIX_FS_BIG_ENDIAN_16BIT_INDEXED | ||
24 | def_bool MINIX_FS | ||
25 | depends on M68K && MMU | ||
diff --git a/fs/minix/minix.h b/fs/minix/minix.h index 407b1c84911e..341e2122879a 100644 --- a/fs/minix/minix.h +++ b/fs/minix/minix.h | |||
@@ -88,4 +88,78 @@ static inline struct minix_inode_info *minix_i(struct inode *inode) | |||
88 | return list_entry(inode, struct minix_inode_info, vfs_inode); | 88 | return list_entry(inode, struct minix_inode_info, vfs_inode); |
89 | } | 89 | } |
90 | 90 | ||
91 | #if defined(CONFIG_MINIX_FS_NATIVE_ENDIAN) && \ | ||
92 | defined(CONFIG_MINIX_FS_BIG_ENDIAN_16BIT_INDEXED) | ||
93 | |||
94 | #error Minix file system byte order broken | ||
95 | |||
96 | #elif defined(CONFIG_MINIX_FS_NATIVE_ENDIAN) | ||
97 | |||
98 | /* | ||
99 | * big-endian 32 or 64 bit indexed bitmaps on big-endian system or | ||
100 | * little-endian bitmaps on little-endian system | ||
101 | */ | ||
102 | |||
103 | #define minix_test_and_set_bit(nr, addr) \ | ||
104 | __test_and_set_bit((nr), (unsigned long *)(addr)) | ||
105 | #define minix_set_bit(nr, addr) \ | ||
106 | __set_bit((nr), (unsigned long *)(addr)) | ||
107 | #define minix_test_and_clear_bit(nr, addr) \ | ||
108 | __test_and_clear_bit((nr), (unsigned long *)(addr)) | ||
109 | #define minix_test_bit(nr, addr) \ | ||
110 | test_bit((nr), (unsigned long *)(addr)) | ||
111 | #define minix_find_first_zero_bit(addr, size) \ | ||
112 | find_first_zero_bit((unsigned long *)(addr), (size)) | ||
113 | |||
114 | #elif defined(CONFIG_MINIX_FS_BIG_ENDIAN_16BIT_INDEXED) | ||
115 | |||
116 | /* | ||
117 | * big-endian 16bit indexed bitmaps | ||
118 | */ | ||
119 | |||
120 | static inline int minix_find_first_zero_bit(const void *vaddr, unsigned size) | ||
121 | { | ||
122 | const unsigned short *p = vaddr, *addr = vaddr; | ||
123 | unsigned short num; | ||
124 | |||
125 | if (!size) | ||
126 | return 0; | ||
127 | |||
128 | size = (size >> 4) + ((size & 15) > 0); | ||
129 | while (*p++ == 0xffff) { | ||
130 | if (--size == 0) | ||
131 | return (p - addr) << 4; | ||
132 | } | ||
133 | |||
134 | num = *--p; | ||
135 | return ((p - addr) << 4) + ffz(num); | ||
136 | } | ||
137 | |||
138 | #define minix_test_and_set_bit(nr, addr) \ | ||
139 | __test_and_set_bit((nr) ^ 16, (unsigned long *)(addr)) | ||
140 | #define minix_set_bit(nr, addr) \ | ||
141 | __set_bit((nr) ^ 16, (unsigned long *)(addr)) | ||
142 | #define minix_test_and_clear_bit(nr, addr) \ | ||
143 | __test_and_clear_bit((nr) ^ 16, (unsigned long *)(addr)) | ||
144 | |||
145 | static inline int minix_test_bit(int nr, const void *vaddr) | ||
146 | { | ||
147 | const unsigned short *p = vaddr; | ||
148 | return (p[nr >> 4] & (1U << (nr & 15))) != 0; | ||
149 | } | ||
150 | |||
151 | #else | ||
152 | |||
153 | /* | ||
154 | * little-endian bitmaps | ||
155 | */ | ||
156 | |||
157 | #define minix_test_and_set_bit __test_and_set_bit_le | ||
158 | #define minix_set_bit __set_bit_le | ||
159 | #define minix_test_and_clear_bit __test_and_clear_bit_le | ||
160 | #define minix_test_bit test_bit_le | ||
161 | #define minix_find_first_zero_bit find_first_zero_bit_le | ||
162 | |||
163 | #endif | ||
164 | |||
91 | #endif /* FS_MINIX_H */ | 165 | #endif /* FS_MINIX_H */ |
diff --git a/fs/namei.c b/fs/namei.c index b912b7abe747..d0066e17d45d 100644 --- a/fs/namei.c +++ b/fs/namei.c | |||
@@ -183,6 +183,9 @@ static int acl_permission_check(struct inode *inode, int mask, unsigned int flag | |||
183 | 183 | ||
184 | mask &= MAY_READ | MAY_WRITE | MAY_EXEC; | 184 | mask &= MAY_READ | MAY_WRITE | MAY_EXEC; |
185 | 185 | ||
186 | if (current_user_ns() != inode_userns(inode)) | ||
187 | goto other_perms; | ||
188 | |||
186 | if (current_fsuid() == inode->i_uid) | 189 | if (current_fsuid() == inode->i_uid) |
187 | mode >>= 6; | 190 | mode >>= 6; |
188 | else { | 191 | else { |
@@ -196,6 +199,7 @@ static int acl_permission_check(struct inode *inode, int mask, unsigned int flag | |||
196 | mode >>= 3; | 199 | mode >>= 3; |
197 | } | 200 | } |
198 | 201 | ||
202 | other_perms: | ||
199 | /* | 203 | /* |
200 | * If the DACs are ok we don't need any capability check. | 204 | * If the DACs are ok we don't need any capability check. |
201 | */ | 205 | */ |
@@ -237,7 +241,7 @@ int generic_permission(struct inode *inode, int mask, unsigned int flags, | |||
237 | * Executable DACs are overridable if at least one exec bit is set. | 241 | * Executable DACs are overridable if at least one exec bit is set. |
238 | */ | 242 | */ |
239 | if (!(mask & MAY_EXEC) || execute_ok(inode)) | 243 | if (!(mask & MAY_EXEC) || execute_ok(inode)) |
240 | if (capable(CAP_DAC_OVERRIDE)) | 244 | if (ns_capable(inode_userns(inode), CAP_DAC_OVERRIDE)) |
241 | return 0; | 245 | return 0; |
242 | 246 | ||
243 | /* | 247 | /* |
@@ -245,7 +249,7 @@ int generic_permission(struct inode *inode, int mask, unsigned int flags, | |||
245 | */ | 249 | */ |
246 | mask &= MAY_READ | MAY_WRITE | MAY_EXEC; | 250 | mask &= MAY_READ | MAY_WRITE | MAY_EXEC; |
247 | if (mask == MAY_READ || (S_ISDIR(inode->i_mode) && !(mask & MAY_WRITE))) | 251 | if (mask == MAY_READ || (S_ISDIR(inode->i_mode) && !(mask & MAY_WRITE))) |
248 | if (capable(CAP_DAC_READ_SEARCH)) | 252 | if (ns_capable(inode_userns(inode), CAP_DAC_READ_SEARCH)) |
249 | return 0; | 253 | return 0; |
250 | 254 | ||
251 | return -EACCES; | 255 | return -EACCES; |
@@ -654,6 +658,7 @@ static inline int handle_reval_path(struct nameidata *nd) | |||
654 | static inline int exec_permission(struct inode *inode, unsigned int flags) | 658 | static inline int exec_permission(struct inode *inode, unsigned int flags) |
655 | { | 659 | { |
656 | int ret; | 660 | int ret; |
661 | struct user_namespace *ns = inode_userns(inode); | ||
657 | 662 | ||
658 | if (inode->i_op->permission) { | 663 | if (inode->i_op->permission) { |
659 | ret = inode->i_op->permission(inode, MAY_EXEC, flags); | 664 | ret = inode->i_op->permission(inode, MAY_EXEC, flags); |
@@ -666,7 +671,8 @@ static inline int exec_permission(struct inode *inode, unsigned int flags) | |||
666 | if (ret == -ECHILD) | 671 | if (ret == -ECHILD) |
667 | return ret; | 672 | return ret; |
668 | 673 | ||
669 | if (capable(CAP_DAC_OVERRIDE) || capable(CAP_DAC_READ_SEARCH)) | 674 | if (ns_capable(ns, CAP_DAC_OVERRIDE) || |
675 | ns_capable(ns, CAP_DAC_READ_SEARCH)) | ||
670 | goto ok; | 676 | goto ok; |
671 | 677 | ||
672 | return ret; | 678 | return ret; |
@@ -933,8 +939,7 @@ static int follow_managed(struct path *path, unsigned flags) | |||
933 | if (managed & DCACHE_MANAGE_TRANSIT) { | 939 | if (managed & DCACHE_MANAGE_TRANSIT) { |
934 | BUG_ON(!path->dentry->d_op); | 940 | BUG_ON(!path->dentry->d_op); |
935 | BUG_ON(!path->dentry->d_op->d_manage); | 941 | BUG_ON(!path->dentry->d_op->d_manage); |
936 | ret = path->dentry->d_op->d_manage(path->dentry, | 942 | ret = path->dentry->d_op->d_manage(path->dentry, false); |
937 | false, false); | ||
938 | if (ret < 0) | 943 | if (ret < 0) |
939 | return ret == -EISDIR ? 0 : ret; | 944 | return ret == -EISDIR ? 0 : ret; |
940 | } | 945 | } |
@@ -999,7 +1004,7 @@ static bool __follow_mount_rcu(struct nameidata *nd, struct path *path, | |||
999 | struct vfsmount *mounted; | 1004 | struct vfsmount *mounted; |
1000 | if (unlikely(path->dentry->d_flags & DCACHE_MANAGE_TRANSIT) && | 1005 | if (unlikely(path->dentry->d_flags & DCACHE_MANAGE_TRANSIT) && |
1001 | !reverse_transit && | 1006 | !reverse_transit && |
1002 | path->dentry->d_op->d_manage(path->dentry, false, true) < 0) | 1007 | path->dentry->d_op->d_manage(path->dentry, true) < 0) |
1003 | return false; | 1008 | return false; |
1004 | mounted = __lookup_mnt(path->mnt, path->dentry, 1); | 1009 | mounted = __lookup_mnt(path->mnt, path->dentry, 1); |
1005 | if (!mounted) | 1010 | if (!mounted) |
@@ -1065,7 +1070,7 @@ failed: | |||
1065 | * Care must be taken as namespace_sem may be held (indicated by mounting_here | 1070 | * Care must be taken as namespace_sem may be held (indicated by mounting_here |
1066 | * being true). | 1071 | * being true). |
1067 | */ | 1072 | */ |
1068 | int follow_down(struct path *path, bool mounting_here) | 1073 | int follow_down(struct path *path) |
1069 | { | 1074 | { |
1070 | unsigned managed; | 1075 | unsigned managed; |
1071 | int ret; | 1076 | int ret; |
@@ -1086,7 +1091,7 @@ int follow_down(struct path *path, bool mounting_here) | |||
1086 | BUG_ON(!path->dentry->d_op); | 1091 | BUG_ON(!path->dentry->d_op); |
1087 | BUG_ON(!path->dentry->d_op->d_manage); | 1092 | BUG_ON(!path->dentry->d_op->d_manage); |
1088 | ret = path->dentry->d_op->d_manage( | 1093 | ret = path->dentry->d_op->d_manage( |
1089 | path->dentry, mounting_here, false); | 1094 | path->dentry, false); |
1090 | if (ret < 0) | 1095 | if (ret < 0) |
1091 | return ret == -EISDIR ? 0 : ret; | 1096 | return ret == -EISDIR ? 0 : ret; |
1092 | } | 1097 | } |
@@ -1645,13 +1650,16 @@ static int path_lookupat(int dfd, const char *name, | |||
1645 | err = -ECHILD; | 1650 | err = -ECHILD; |
1646 | } | 1651 | } |
1647 | 1652 | ||
1648 | if (!err) | 1653 | if (!err) { |
1649 | err = handle_reval_path(nd); | 1654 | err = handle_reval_path(nd); |
1655 | if (err) | ||
1656 | path_put(&nd->path); | ||
1657 | } | ||
1650 | 1658 | ||
1651 | if (!err && nd->flags & LOOKUP_DIRECTORY) { | 1659 | if (!err && nd->flags & LOOKUP_DIRECTORY) { |
1652 | if (!nd->inode->i_op->lookup) { | 1660 | if (!nd->inode->i_op->lookup) { |
1653 | path_put(&nd->path); | 1661 | path_put(&nd->path); |
1654 | return -ENOTDIR; | 1662 | err = -ENOTDIR; |
1655 | } | 1663 | } |
1656 | } | 1664 | } |
1657 | 1665 | ||
@@ -1843,11 +1851,15 @@ static inline int check_sticky(struct inode *dir, struct inode *inode) | |||
1843 | 1851 | ||
1844 | if (!(dir->i_mode & S_ISVTX)) | 1852 | if (!(dir->i_mode & S_ISVTX)) |
1845 | return 0; | 1853 | return 0; |
1854 | if (current_user_ns() != inode_userns(inode)) | ||
1855 | goto other_userns; | ||
1846 | if (inode->i_uid == fsuid) | 1856 | if (inode->i_uid == fsuid) |
1847 | return 0; | 1857 | return 0; |
1848 | if (dir->i_uid == fsuid) | 1858 | if (dir->i_uid == fsuid) |
1849 | return 0; | 1859 | return 0; |
1850 | return !capable(CAP_FOWNER); | 1860 | |
1861 | other_userns: | ||
1862 | return !ns_capable(inode_userns(inode), CAP_FOWNER); | ||
1851 | } | 1863 | } |
1852 | 1864 | ||
1853 | /* | 1865 | /* |
@@ -2027,7 +2039,7 @@ static int may_open(struct path *path, int acc_mode, int flag) | |||
2027 | } | 2039 | } |
2028 | 2040 | ||
2029 | /* O_NOATIME can only be set by the owner or superuser */ | 2041 | /* O_NOATIME can only be set by the owner or superuser */ |
2030 | if (flag & O_NOATIME && !is_owner_or_cap(inode)) | 2042 | if (flag & O_NOATIME && !inode_owner_or_capable(inode)) |
2031 | return -EPERM; | 2043 | return -EPERM; |
2032 | 2044 | ||
2033 | /* | 2045 | /* |
@@ -2441,7 +2453,8 @@ int vfs_mknod(struct inode *dir, struct dentry *dentry, int mode, dev_t dev) | |||
2441 | if (error) | 2453 | if (error) |
2442 | return error; | 2454 | return error; |
2443 | 2455 | ||
2444 | if ((S_ISCHR(mode) || S_ISBLK(mode)) && !capable(CAP_MKNOD)) | 2456 | if ((S_ISCHR(mode) || S_ISBLK(mode)) && |
2457 | !ns_capable(inode_userns(dir), CAP_MKNOD)) | ||
2445 | return -EPERM; | 2458 | return -EPERM; |
2446 | 2459 | ||
2447 | if (!dir->i_op->mknod) | 2460 | if (!dir->i_op->mknod) |
diff --git a/fs/namespace.c b/fs/namespace.c index d7513485c1f3..7dba2ed03429 100644 --- a/fs/namespace.c +++ b/fs/namespace.c | |||
@@ -196,7 +196,7 @@ unsigned int mnt_get_count(struct vfsmount *mnt) | |||
196 | #endif | 196 | #endif |
197 | } | 197 | } |
198 | 198 | ||
199 | struct vfsmount *alloc_vfsmnt(const char *name) | 199 | static struct vfsmount *alloc_vfsmnt(const char *name) |
200 | { | 200 | { |
201 | struct vfsmount *mnt = kmem_cache_zalloc(mnt_cache, GFP_KERNEL); | 201 | struct vfsmount *mnt = kmem_cache_zalloc(mnt_cache, GFP_KERNEL); |
202 | if (mnt) { | 202 | if (mnt) { |
@@ -466,15 +466,7 @@ static void __mnt_unmake_readonly(struct vfsmount *mnt) | |||
466 | br_write_unlock(vfsmount_lock); | 466 | br_write_unlock(vfsmount_lock); |
467 | } | 467 | } |
468 | 468 | ||
469 | void simple_set_mnt(struct vfsmount *mnt, struct super_block *sb) | 469 | static void free_vfsmnt(struct vfsmount *mnt) |
470 | { | ||
471 | mnt->mnt_sb = sb; | ||
472 | mnt->mnt_root = dget(sb->s_root); | ||
473 | } | ||
474 | |||
475 | EXPORT_SYMBOL(simple_set_mnt); | ||
476 | |||
477 | void free_vfsmnt(struct vfsmount *mnt) | ||
478 | { | 470 | { |
479 | kfree(mnt->mnt_devname); | 471 | kfree(mnt->mnt_devname); |
480 | mnt_free_id(mnt); | 472 | mnt_free_id(mnt); |
@@ -678,6 +670,36 @@ static struct vfsmount *skip_mnt_tree(struct vfsmount *p) | |||
678 | return p; | 670 | return p; |
679 | } | 671 | } |
680 | 672 | ||
673 | struct vfsmount * | ||
674 | vfs_kern_mount(struct file_system_type *type, int flags, const char *name, void *data) | ||
675 | { | ||
676 | struct vfsmount *mnt; | ||
677 | struct dentry *root; | ||
678 | |||
679 | if (!type) | ||
680 | return ERR_PTR(-ENODEV); | ||
681 | |||
682 | mnt = alloc_vfsmnt(name); | ||
683 | if (!mnt) | ||
684 | return ERR_PTR(-ENOMEM); | ||
685 | |||
686 | if (flags & MS_KERNMOUNT) | ||
687 | mnt->mnt_flags = MNT_INTERNAL; | ||
688 | |||
689 | root = mount_fs(type, flags, name, data); | ||
690 | if (IS_ERR(root)) { | ||
691 | free_vfsmnt(mnt); | ||
692 | return ERR_CAST(root); | ||
693 | } | ||
694 | |||
695 | mnt->mnt_root = root; | ||
696 | mnt->mnt_sb = root->d_sb; | ||
697 | mnt->mnt_mountpoint = mnt->mnt_root; | ||
698 | mnt->mnt_parent = mnt; | ||
699 | return mnt; | ||
700 | } | ||
701 | EXPORT_SYMBOL_GPL(vfs_kern_mount); | ||
702 | |||
681 | static struct vfsmount *clone_mnt(struct vfsmount *old, struct dentry *root, | 703 | static struct vfsmount *clone_mnt(struct vfsmount *old, struct dentry *root, |
682 | int flag) | 704 | int flag) |
683 | { | 705 | { |
@@ -1641,9 +1663,35 @@ static int attach_recursive_mnt(struct vfsmount *source_mnt, | |||
1641 | return err; | 1663 | return err; |
1642 | } | 1664 | } |
1643 | 1665 | ||
1666 | static int lock_mount(struct path *path) | ||
1667 | { | ||
1668 | struct vfsmount *mnt; | ||
1669 | retry: | ||
1670 | mutex_lock(&path->dentry->d_inode->i_mutex); | ||
1671 | if (unlikely(cant_mount(path->dentry))) { | ||
1672 | mutex_unlock(&path->dentry->d_inode->i_mutex); | ||
1673 | return -ENOENT; | ||
1674 | } | ||
1675 | down_write(&namespace_sem); | ||
1676 | mnt = lookup_mnt(path); | ||
1677 | if (likely(!mnt)) | ||
1678 | return 0; | ||
1679 | up_write(&namespace_sem); | ||
1680 | mutex_unlock(&path->dentry->d_inode->i_mutex); | ||
1681 | path_put(path); | ||
1682 | path->mnt = mnt; | ||
1683 | path->dentry = dget(mnt->mnt_root); | ||
1684 | goto retry; | ||
1685 | } | ||
1686 | |||
1687 | static void unlock_mount(struct path *path) | ||
1688 | { | ||
1689 | up_write(&namespace_sem); | ||
1690 | mutex_unlock(&path->dentry->d_inode->i_mutex); | ||
1691 | } | ||
1692 | |||
1644 | static int graft_tree(struct vfsmount *mnt, struct path *path) | 1693 | static int graft_tree(struct vfsmount *mnt, struct path *path) |
1645 | { | 1694 | { |
1646 | int err; | ||
1647 | if (mnt->mnt_sb->s_flags & MS_NOUSER) | 1695 | if (mnt->mnt_sb->s_flags & MS_NOUSER) |
1648 | return -EINVAL; | 1696 | return -EINVAL; |
1649 | 1697 | ||
@@ -1651,16 +1699,10 @@ static int graft_tree(struct vfsmount *mnt, struct path *path) | |||
1651 | S_ISDIR(mnt->mnt_root->d_inode->i_mode)) | 1699 | S_ISDIR(mnt->mnt_root->d_inode->i_mode)) |
1652 | return -ENOTDIR; | 1700 | return -ENOTDIR; |
1653 | 1701 | ||
1654 | err = -ENOENT; | 1702 | if (d_unlinked(path->dentry)) |
1655 | mutex_lock(&path->dentry->d_inode->i_mutex); | 1703 | return -ENOENT; |
1656 | if (cant_mount(path->dentry)) | ||
1657 | goto out_unlock; | ||
1658 | 1704 | ||
1659 | if (!d_unlinked(path->dentry)) | 1705 | return attach_recursive_mnt(mnt, path, NULL); |
1660 | err = attach_recursive_mnt(mnt, path, NULL); | ||
1661 | out_unlock: | ||
1662 | mutex_unlock(&path->dentry->d_inode->i_mutex); | ||
1663 | return err; | ||
1664 | } | 1706 | } |
1665 | 1707 | ||
1666 | /* | 1708 | /* |
@@ -1723,6 +1765,7 @@ static int do_change_type(struct path *path, int flag) | |||
1723 | static int do_loopback(struct path *path, char *old_name, | 1765 | static int do_loopback(struct path *path, char *old_name, |
1724 | int recurse) | 1766 | int recurse) |
1725 | { | 1767 | { |
1768 | LIST_HEAD(umount_list); | ||
1726 | struct path old_path; | 1769 | struct path old_path; |
1727 | struct vfsmount *mnt = NULL; | 1770 | struct vfsmount *mnt = NULL; |
1728 | int err = mount_is_safe(path); | 1771 | int err = mount_is_safe(path); |
@@ -1734,13 +1777,16 @@ static int do_loopback(struct path *path, char *old_name, | |||
1734 | if (err) | 1777 | if (err) |
1735 | return err; | 1778 | return err; |
1736 | 1779 | ||
1737 | down_write(&namespace_sem); | 1780 | err = lock_mount(path); |
1781 | if (err) | ||
1782 | goto out; | ||
1783 | |||
1738 | err = -EINVAL; | 1784 | err = -EINVAL; |
1739 | if (IS_MNT_UNBINDABLE(old_path.mnt)) | 1785 | if (IS_MNT_UNBINDABLE(old_path.mnt)) |
1740 | goto out; | 1786 | goto out2; |
1741 | 1787 | ||
1742 | if (!check_mnt(path->mnt) || !check_mnt(old_path.mnt)) | 1788 | if (!check_mnt(path->mnt) || !check_mnt(old_path.mnt)) |
1743 | goto out; | 1789 | goto out2; |
1744 | 1790 | ||
1745 | err = -ENOMEM; | 1791 | err = -ENOMEM; |
1746 | if (recurse) | 1792 | if (recurse) |
@@ -1749,20 +1795,18 @@ static int do_loopback(struct path *path, char *old_name, | |||
1749 | mnt = clone_mnt(old_path.mnt, old_path.dentry, 0); | 1795 | mnt = clone_mnt(old_path.mnt, old_path.dentry, 0); |
1750 | 1796 | ||
1751 | if (!mnt) | 1797 | if (!mnt) |
1752 | goto out; | 1798 | goto out2; |
1753 | 1799 | ||
1754 | err = graft_tree(mnt, path); | 1800 | err = graft_tree(mnt, path); |
1755 | if (err) { | 1801 | if (err) { |
1756 | LIST_HEAD(umount_list); | ||
1757 | |||
1758 | br_write_lock(vfsmount_lock); | 1802 | br_write_lock(vfsmount_lock); |
1759 | umount_tree(mnt, 0, &umount_list); | 1803 | umount_tree(mnt, 0, &umount_list); |
1760 | br_write_unlock(vfsmount_lock); | 1804 | br_write_unlock(vfsmount_lock); |
1761 | release_mounts(&umount_list); | ||
1762 | } | 1805 | } |
1763 | 1806 | out2: | |
1807 | unlock_mount(path); | ||
1808 | release_mounts(&umount_list); | ||
1764 | out: | 1809 | out: |
1765 | up_write(&namespace_sem); | ||
1766 | path_put(&old_path); | 1810 | path_put(&old_path); |
1767 | return err; | 1811 | return err; |
1768 | } | 1812 | } |
@@ -1851,18 +1895,12 @@ static int do_move_mount(struct path *path, char *old_name) | |||
1851 | if (err) | 1895 | if (err) |
1852 | return err; | 1896 | return err; |
1853 | 1897 | ||
1854 | down_write(&namespace_sem); | 1898 | err = lock_mount(path); |
1855 | err = follow_down(path, true); | ||
1856 | if (err < 0) | 1899 | if (err < 0) |
1857 | goto out; | 1900 | goto out; |
1858 | 1901 | ||
1859 | err = -EINVAL; | 1902 | err = -EINVAL; |
1860 | if (!check_mnt(path->mnt) || !check_mnt(old_path.mnt)) | 1903 | if (!check_mnt(path->mnt) || !check_mnt(old_path.mnt)) |
1861 | goto out; | ||
1862 | |||
1863 | err = -ENOENT; | ||
1864 | mutex_lock(&path->dentry->d_inode->i_mutex); | ||
1865 | if (cant_mount(path->dentry)) | ||
1866 | goto out1; | 1904 | goto out1; |
1867 | 1905 | ||
1868 | if (d_unlinked(path->dentry)) | 1906 | if (d_unlinked(path->dentry)) |
@@ -1904,16 +1942,87 @@ static int do_move_mount(struct path *path, char *old_name) | |||
1904 | * automatically */ | 1942 | * automatically */ |
1905 | list_del_init(&old_path.mnt->mnt_expire); | 1943 | list_del_init(&old_path.mnt->mnt_expire); |
1906 | out1: | 1944 | out1: |
1907 | mutex_unlock(&path->dentry->d_inode->i_mutex); | 1945 | unlock_mount(path); |
1908 | out: | 1946 | out: |
1909 | up_write(&namespace_sem); | ||
1910 | if (!err) | 1947 | if (!err) |
1911 | path_put(&parent_path); | 1948 | path_put(&parent_path); |
1912 | path_put(&old_path); | 1949 | path_put(&old_path); |
1913 | return err; | 1950 | return err; |
1914 | } | 1951 | } |
1915 | 1952 | ||
1916 | static int do_add_mount(struct vfsmount *, struct path *, int); | 1953 | static struct vfsmount *fs_set_subtype(struct vfsmount *mnt, const char *fstype) |
1954 | { | ||
1955 | int err; | ||
1956 | const char *subtype = strchr(fstype, '.'); | ||
1957 | if (subtype) { | ||
1958 | subtype++; | ||
1959 | err = -EINVAL; | ||
1960 | if (!subtype[0]) | ||
1961 | goto err; | ||
1962 | } else | ||
1963 | subtype = ""; | ||
1964 | |||
1965 | mnt->mnt_sb->s_subtype = kstrdup(subtype, GFP_KERNEL); | ||
1966 | err = -ENOMEM; | ||
1967 | if (!mnt->mnt_sb->s_subtype) | ||
1968 | goto err; | ||
1969 | return mnt; | ||
1970 | |||
1971 | err: | ||
1972 | mntput(mnt); | ||
1973 | return ERR_PTR(err); | ||
1974 | } | ||
1975 | |||
1976 | struct vfsmount * | ||
1977 | do_kern_mount(const char *fstype, int flags, const char *name, void *data) | ||
1978 | { | ||
1979 | struct file_system_type *type = get_fs_type(fstype); | ||
1980 | struct vfsmount *mnt; | ||
1981 | if (!type) | ||
1982 | return ERR_PTR(-ENODEV); | ||
1983 | mnt = vfs_kern_mount(type, flags, name, data); | ||
1984 | if (!IS_ERR(mnt) && (type->fs_flags & FS_HAS_SUBTYPE) && | ||
1985 | !mnt->mnt_sb->s_subtype) | ||
1986 | mnt = fs_set_subtype(mnt, fstype); | ||
1987 | put_filesystem(type); | ||
1988 | return mnt; | ||
1989 | } | ||
1990 | EXPORT_SYMBOL_GPL(do_kern_mount); | ||
1991 | |||
1992 | /* | ||
1993 | * add a mount into a namespace's mount tree | ||
1994 | */ | ||
1995 | static int do_add_mount(struct vfsmount *newmnt, struct path *path, int mnt_flags) | ||
1996 | { | ||
1997 | int err; | ||
1998 | |||
1999 | mnt_flags &= ~(MNT_SHARED | MNT_WRITE_HOLD | MNT_INTERNAL); | ||
2000 | |||
2001 | err = lock_mount(path); | ||
2002 | if (err) | ||
2003 | return err; | ||
2004 | |||
2005 | err = -EINVAL; | ||
2006 | if (!(mnt_flags & MNT_SHRINKABLE) && !check_mnt(path->mnt)) | ||
2007 | goto unlock; | ||
2008 | |||
2009 | /* Refuse the same filesystem on the same mount point */ | ||
2010 | err = -EBUSY; | ||
2011 | if (path->mnt->mnt_sb == newmnt->mnt_sb && | ||
2012 | path->mnt->mnt_root == path->dentry) | ||
2013 | goto unlock; | ||
2014 | |||
2015 | err = -EINVAL; | ||
2016 | if (S_ISLNK(newmnt->mnt_root->d_inode->i_mode)) | ||
2017 | goto unlock; | ||
2018 | |||
2019 | newmnt->mnt_flags = mnt_flags; | ||
2020 | err = graft_tree(newmnt, path); | ||
2021 | |||
2022 | unlock: | ||
2023 | unlock_mount(path); | ||
2024 | return err; | ||
2025 | } | ||
1917 | 2026 | ||
1918 | /* | 2027 | /* |
1919 | * create a new mount for userspace and request it to be added into the | 2028 | * create a new mount for userspace and request it to be added into the |
@@ -1973,43 +2082,6 @@ fail: | |||
1973 | return err; | 2082 | return err; |
1974 | } | 2083 | } |
1975 | 2084 | ||
1976 | /* | ||
1977 | * add a mount into a namespace's mount tree | ||
1978 | */ | ||
1979 | static int do_add_mount(struct vfsmount *newmnt, struct path *path, int mnt_flags) | ||
1980 | { | ||
1981 | int err; | ||
1982 | |||
1983 | mnt_flags &= ~(MNT_SHARED | MNT_WRITE_HOLD | MNT_INTERNAL); | ||
1984 | |||
1985 | down_write(&namespace_sem); | ||
1986 | /* Something was mounted here while we slept */ | ||
1987 | err = follow_down(path, true); | ||
1988 | if (err < 0) | ||
1989 | goto unlock; | ||
1990 | |||
1991 | err = -EINVAL; | ||
1992 | if (!(mnt_flags & MNT_SHRINKABLE) && !check_mnt(path->mnt)) | ||
1993 | goto unlock; | ||
1994 | |||
1995 | /* Refuse the same filesystem on the same mount point */ | ||
1996 | err = -EBUSY; | ||
1997 | if (path->mnt->mnt_sb == newmnt->mnt_sb && | ||
1998 | path->mnt->mnt_root == path->dentry) | ||
1999 | goto unlock; | ||
2000 | |||
2001 | err = -EINVAL; | ||
2002 | if (S_ISLNK(newmnt->mnt_root->d_inode->i_mode)) | ||
2003 | goto unlock; | ||
2004 | |||
2005 | newmnt->mnt_flags = mnt_flags; | ||
2006 | err = graft_tree(newmnt, path); | ||
2007 | |||
2008 | unlock: | ||
2009 | up_write(&namespace_sem); | ||
2010 | return err; | ||
2011 | } | ||
2012 | |||
2013 | /** | 2085 | /** |
2014 | * mnt_set_expiry - Put a mount on an expiration list | 2086 | * mnt_set_expiry - Put a mount on an expiration list |
2015 | * @mnt: The mount to list. | 2087 | * @mnt: The mount to list. |
@@ -2510,65 +2582,60 @@ SYSCALL_DEFINE2(pivot_root, const char __user *, new_root, | |||
2510 | error = user_path_dir(new_root, &new); | 2582 | error = user_path_dir(new_root, &new); |
2511 | if (error) | 2583 | if (error) |
2512 | goto out0; | 2584 | goto out0; |
2513 | error = -EINVAL; | ||
2514 | if (!check_mnt(new.mnt)) | ||
2515 | goto out1; | ||
2516 | 2585 | ||
2517 | error = user_path_dir(put_old, &old); | 2586 | error = user_path_dir(put_old, &old); |
2518 | if (error) | 2587 | if (error) |
2519 | goto out1; | 2588 | goto out1; |
2520 | 2589 | ||
2521 | error = security_sb_pivotroot(&old, &new); | 2590 | error = security_sb_pivotroot(&old, &new); |
2522 | if (error) { | 2591 | if (error) |
2523 | path_put(&old); | 2592 | goto out2; |
2524 | goto out1; | ||
2525 | } | ||
2526 | 2593 | ||
2527 | get_fs_root(current->fs, &root); | 2594 | get_fs_root(current->fs, &root); |
2528 | down_write(&namespace_sem); | 2595 | error = lock_mount(&old); |
2529 | mutex_lock(&old.dentry->d_inode->i_mutex); | 2596 | if (error) |
2597 | goto out3; | ||
2598 | |||
2530 | error = -EINVAL; | 2599 | error = -EINVAL; |
2531 | if (IS_MNT_SHARED(old.mnt) || | 2600 | if (IS_MNT_SHARED(old.mnt) || |
2532 | IS_MNT_SHARED(new.mnt->mnt_parent) || | 2601 | IS_MNT_SHARED(new.mnt->mnt_parent) || |
2533 | IS_MNT_SHARED(root.mnt->mnt_parent)) | 2602 | IS_MNT_SHARED(root.mnt->mnt_parent)) |
2534 | goto out2; | 2603 | goto out4; |
2535 | if (!check_mnt(root.mnt)) | 2604 | if (!check_mnt(root.mnt) || !check_mnt(new.mnt)) |
2536 | goto out2; | 2605 | goto out4; |
2537 | error = -ENOENT; | 2606 | error = -ENOENT; |
2538 | if (cant_mount(old.dentry)) | ||
2539 | goto out2; | ||
2540 | if (d_unlinked(new.dentry)) | 2607 | if (d_unlinked(new.dentry)) |
2541 | goto out2; | 2608 | goto out4; |
2542 | if (d_unlinked(old.dentry)) | 2609 | if (d_unlinked(old.dentry)) |
2543 | goto out2; | 2610 | goto out4; |
2544 | error = -EBUSY; | 2611 | error = -EBUSY; |
2545 | if (new.mnt == root.mnt || | 2612 | if (new.mnt == root.mnt || |
2546 | old.mnt == root.mnt) | 2613 | old.mnt == root.mnt) |
2547 | goto out2; /* loop, on the same file system */ | 2614 | goto out4; /* loop, on the same file system */ |
2548 | error = -EINVAL; | 2615 | error = -EINVAL; |
2549 | if (root.mnt->mnt_root != root.dentry) | 2616 | if (root.mnt->mnt_root != root.dentry) |
2550 | goto out2; /* not a mountpoint */ | 2617 | goto out4; /* not a mountpoint */ |
2551 | if (root.mnt->mnt_parent == root.mnt) | 2618 | if (root.mnt->mnt_parent == root.mnt) |
2552 | goto out2; /* not attached */ | 2619 | goto out4; /* not attached */ |
2553 | if (new.mnt->mnt_root != new.dentry) | 2620 | if (new.mnt->mnt_root != new.dentry) |
2554 | goto out2; /* not a mountpoint */ | 2621 | goto out4; /* not a mountpoint */ |
2555 | if (new.mnt->mnt_parent == new.mnt) | 2622 | if (new.mnt->mnt_parent == new.mnt) |
2556 | goto out2; /* not attached */ | 2623 | goto out4; /* not attached */ |
2557 | /* make sure we can reach put_old from new_root */ | 2624 | /* make sure we can reach put_old from new_root */ |
2558 | tmp = old.mnt; | 2625 | tmp = old.mnt; |
2559 | br_write_lock(vfsmount_lock); | ||
2560 | if (tmp != new.mnt) { | 2626 | if (tmp != new.mnt) { |
2561 | for (;;) { | 2627 | for (;;) { |
2562 | if (tmp->mnt_parent == tmp) | 2628 | if (tmp->mnt_parent == tmp) |
2563 | goto out3; /* already mounted on put_old */ | 2629 | goto out4; /* already mounted on put_old */ |
2564 | if (tmp->mnt_parent == new.mnt) | 2630 | if (tmp->mnt_parent == new.mnt) |
2565 | break; | 2631 | break; |
2566 | tmp = tmp->mnt_parent; | 2632 | tmp = tmp->mnt_parent; |
2567 | } | 2633 | } |
2568 | if (!is_subdir(tmp->mnt_mountpoint, new.dentry)) | 2634 | if (!is_subdir(tmp->mnt_mountpoint, new.dentry)) |
2569 | goto out3; | 2635 | goto out4; |
2570 | } else if (!is_subdir(old.dentry, new.dentry)) | 2636 | } else if (!is_subdir(old.dentry, new.dentry)) |
2571 | goto out3; | 2637 | goto out4; |
2638 | br_write_lock(vfsmount_lock); | ||
2572 | detach_mnt(new.mnt, &parent_path); | 2639 | detach_mnt(new.mnt, &parent_path); |
2573 | detach_mnt(root.mnt, &root_parent); | 2640 | detach_mnt(root.mnt, &root_parent); |
2574 | /* mount old root on put_old */ | 2641 | /* mount old root on put_old */ |
@@ -2578,22 +2645,21 @@ SYSCALL_DEFINE2(pivot_root, const char __user *, new_root, | |||
2578 | touch_mnt_namespace(current->nsproxy->mnt_ns); | 2645 | touch_mnt_namespace(current->nsproxy->mnt_ns); |
2579 | br_write_unlock(vfsmount_lock); | 2646 | br_write_unlock(vfsmount_lock); |
2580 | chroot_fs_refs(&root, &new); | 2647 | chroot_fs_refs(&root, &new); |
2581 | |||
2582 | error = 0; | 2648 | error = 0; |
2583 | path_put(&root_parent); | 2649 | out4: |
2584 | path_put(&parent_path); | 2650 | unlock_mount(&old); |
2585 | out2: | 2651 | if (!error) { |
2586 | mutex_unlock(&old.dentry->d_inode->i_mutex); | 2652 | path_put(&root_parent); |
2587 | up_write(&namespace_sem); | 2653 | path_put(&parent_path); |
2654 | } | ||
2655 | out3: | ||
2588 | path_put(&root); | 2656 | path_put(&root); |
2657 | out2: | ||
2589 | path_put(&old); | 2658 | path_put(&old); |
2590 | out1: | 2659 | out1: |
2591 | path_put(&new); | 2660 | path_put(&new); |
2592 | out0: | 2661 | out0: |
2593 | return error; | 2662 | return error; |
2594 | out3: | ||
2595 | br_write_unlock(vfsmount_lock); | ||
2596 | goto out2; | ||
2597 | } | 2663 | } |
2598 | 2664 | ||
2599 | static void __init init_mount_tree(void) | 2665 | static void __init init_mount_tree(void) |
@@ -2635,7 +2701,7 @@ void __init mnt_init(void) | |||
2635 | if (!mount_hashtable) | 2701 | if (!mount_hashtable) |
2636 | panic("Failed to allocate mount hash table\n"); | 2702 | panic("Failed to allocate mount hash table\n"); |
2637 | 2703 | ||
2638 | printk("Mount-cache hash table entries: %lu\n", HASH_SIZE); | 2704 | printk(KERN_INFO "Mount-cache hash table entries: %lu\n", HASH_SIZE); |
2639 | 2705 | ||
2640 | for (u = 0; u < HASH_SIZE; u++) | 2706 | for (u = 0; u < HASH_SIZE; u++) |
2641 | INIT_LIST_HEAD(&mount_hashtable[u]); | 2707 | INIT_LIST_HEAD(&mount_hashtable[u]); |
@@ -2668,3 +2734,9 @@ void put_mnt_ns(struct mnt_namespace *ns) | |||
2668 | kfree(ns); | 2734 | kfree(ns); |
2669 | } | 2735 | } |
2670 | EXPORT_SYMBOL(put_mnt_ns); | 2736 | EXPORT_SYMBOL(put_mnt_ns); |
2737 | |||
2738 | struct vfsmount *kern_mount_data(struct file_system_type *type, void *data) | ||
2739 | { | ||
2740 | return vfs_kern_mount(type, MS_KERNMOUNT, type->name, data); | ||
2741 | } | ||
2742 | EXPORT_SYMBOL_GPL(kern_mount_data); | ||
diff --git a/fs/ncpfs/Makefile b/fs/ncpfs/Makefile index 68ea095100a8..c66af563f2ce 100644 --- a/fs/ncpfs/Makefile +++ b/fs/ncpfs/Makefile | |||
@@ -11,6 +11,6 @@ ncpfs-$(CONFIG_NCPFS_EXTRAS) += symlink.o | |||
11 | ncpfs-$(CONFIG_NCPFS_NFS_NS) += symlink.o | 11 | ncpfs-$(CONFIG_NCPFS_NFS_NS) += symlink.o |
12 | 12 | ||
13 | # If you want debugging output, please uncomment the following line | 13 | # If you want debugging output, please uncomment the following line |
14 | # EXTRA_CFLAGS += -DDEBUG_NCP=1 | 14 | # ccflags-y := -DDEBUG_NCP=1 |
15 | 15 | ||
16 | CFLAGS_ncplib_kernel.o := -finline-functions | 16 | CFLAGS_ncplib_kernel.o := -finline-functions |
diff --git a/fs/nfs/namespace.c b/fs/nfs/namespace.c index c0b8344db0c6..bf1c68009ffd 100644 --- a/fs/nfs/namespace.c +++ b/fs/nfs/namespace.c | |||
@@ -98,7 +98,7 @@ rename_retry: | |||
98 | namelen--; | 98 | namelen--; |
99 | buflen -= namelen; | 99 | buflen -= namelen; |
100 | if (buflen < 0) { | 100 | if (buflen < 0) { |
101 | spin_lock(&dentry->d_lock); | 101 | spin_unlock(&dentry->d_lock); |
102 | rcu_read_unlock(); | 102 | rcu_read_unlock(); |
103 | goto Elong; | 103 | goto Elong; |
104 | } | 104 | } |
@@ -108,7 +108,7 @@ rename_retry: | |||
108 | rcu_read_unlock(); | 108 | rcu_read_unlock(); |
109 | return end; | 109 | return end; |
110 | Elong_unlock: | 110 | Elong_unlock: |
111 | spin_lock(&dentry->d_lock); | 111 | spin_unlock(&dentry->d_lock); |
112 | rcu_read_unlock(); | 112 | rcu_read_unlock(); |
113 | if (read_seqretry(&rename_lock, seq)) | 113 | if (read_seqretry(&rename_lock, seq)) |
114 | goto rename_retry; | 114 | goto rename_retry; |
diff --git a/fs/nfsd/export.c b/fs/nfsd/export.c index 8b31e5f8795d..ad000aeb21a2 100644 --- a/fs/nfsd/export.c +++ b/fs/nfsd/export.c | |||
@@ -299,7 +299,6 @@ svc_expkey_update(struct svc_expkey *new, struct svc_expkey *old) | |||
299 | 299 | ||
300 | #define EXPORT_HASHBITS 8 | 300 | #define EXPORT_HASHBITS 8 |
301 | #define EXPORT_HASHMAX (1<< EXPORT_HASHBITS) | 301 | #define EXPORT_HASHMAX (1<< EXPORT_HASHBITS) |
302 | #define EXPORT_HASHMASK (EXPORT_HASHMAX -1) | ||
303 | 302 | ||
304 | static struct cache_head *export_table[EXPORT_HASHMAX]; | 303 | static struct cache_head *export_table[EXPORT_HASHMAX]; |
305 | 304 | ||
diff --git a/fs/nfsd/nfs4idmap.c b/fs/nfsd/nfs4idmap.c index 6d2c397d458b..55780a22fdbd 100644 --- a/fs/nfsd/nfs4idmap.c +++ b/fs/nfsd/nfs4idmap.c | |||
@@ -63,7 +63,6 @@ struct ent { | |||
63 | 63 | ||
64 | #define ENT_HASHBITS 8 | 64 | #define ENT_HASHBITS 8 |
65 | #define ENT_HASHMAX (1 << ENT_HASHBITS) | 65 | #define ENT_HASHMAX (1 << ENT_HASHBITS) |
66 | #define ENT_HASHMASK (ENT_HASHMAX - 1) | ||
67 | 66 | ||
68 | static void | 67 | static void |
69 | ent_init(struct cache_head *cnew, struct cache_head *citm) | 68 | ent_init(struct cache_head *cnew, struct cache_head *citm) |
diff --git a/fs/nfsd/nfs4proc.c b/fs/nfsd/nfs4proc.c index db52546143d1..5fcb1396a7e3 100644 --- a/fs/nfsd/nfs4proc.c +++ b/fs/nfsd/nfs4proc.c | |||
@@ -984,8 +984,8 @@ typedef __be32(*nfsd4op_func)(struct svc_rqst *, struct nfsd4_compound_state *, | |||
984 | void *); | 984 | void *); |
985 | enum nfsd4_op_flags { | 985 | enum nfsd4_op_flags { |
986 | ALLOWED_WITHOUT_FH = 1 << 0, /* No current filehandle required */ | 986 | ALLOWED_WITHOUT_FH = 1 << 0, /* No current filehandle required */ |
987 | ALLOWED_ON_ABSENT_FS = 2 << 0, /* ops processed on absent fs */ | 987 | ALLOWED_ON_ABSENT_FS = 1 << 1, /* ops processed on absent fs */ |
988 | ALLOWED_AS_FIRST_OP = 3 << 0, /* ops reqired first in compound */ | 988 | ALLOWED_AS_FIRST_OP = 1 << 2, /* ops reqired first in compound */ |
989 | }; | 989 | }; |
990 | 990 | ||
991 | struct nfsd4_operation { | 991 | struct nfsd4_operation { |
diff --git a/fs/nfsd/nfs4state.c b/fs/nfsd/nfs4state.c index 7b566ec14e18..fbde6f79922e 100644 --- a/fs/nfsd/nfs4state.c +++ b/fs/nfsd/nfs4state.c | |||
@@ -148,7 +148,7 @@ static struct list_head ownerstr_hashtbl[OWNER_HASH_SIZE]; | |||
148 | /* hash table for nfs4_file */ | 148 | /* hash table for nfs4_file */ |
149 | #define FILE_HASH_BITS 8 | 149 | #define FILE_HASH_BITS 8 |
150 | #define FILE_HASH_SIZE (1 << FILE_HASH_BITS) | 150 | #define FILE_HASH_SIZE (1 << FILE_HASH_BITS) |
151 | #define FILE_HASH_MASK (FILE_HASH_SIZE - 1) | 151 | |
152 | /* hash table for (open)nfs4_stateid */ | 152 | /* hash table for (open)nfs4_stateid */ |
153 | #define STATEID_HASH_BITS 10 | 153 | #define STATEID_HASH_BITS 10 |
154 | #define STATEID_HASH_SIZE (1 << STATEID_HASH_BITS) | 154 | #define STATEID_HASH_SIZE (1 << STATEID_HASH_BITS) |
@@ -316,64 +316,6 @@ static struct list_head unconf_id_hashtbl[CLIENT_HASH_SIZE]; | |||
316 | static struct list_head client_lru; | 316 | static struct list_head client_lru; |
317 | static struct list_head close_lru; | 317 | static struct list_head close_lru; |
318 | 318 | ||
319 | static void unhash_generic_stateid(struct nfs4_stateid *stp) | ||
320 | { | ||
321 | list_del(&stp->st_hash); | ||
322 | list_del(&stp->st_perfile); | ||
323 | list_del(&stp->st_perstateowner); | ||
324 | } | ||
325 | |||
326 | static void free_generic_stateid(struct nfs4_stateid *stp) | ||
327 | { | ||
328 | put_nfs4_file(stp->st_file); | ||
329 | kmem_cache_free(stateid_slab, stp); | ||
330 | } | ||
331 | |||
332 | static void release_lock_stateid(struct nfs4_stateid *stp) | ||
333 | { | ||
334 | struct file *file; | ||
335 | |||
336 | unhash_generic_stateid(stp); | ||
337 | file = find_any_file(stp->st_file); | ||
338 | if (file) | ||
339 | locks_remove_posix(file, (fl_owner_t)stp->st_stateowner); | ||
340 | free_generic_stateid(stp); | ||
341 | } | ||
342 | |||
343 | static void unhash_lockowner(struct nfs4_stateowner *sop) | ||
344 | { | ||
345 | struct nfs4_stateid *stp; | ||
346 | |||
347 | list_del(&sop->so_idhash); | ||
348 | list_del(&sop->so_strhash); | ||
349 | list_del(&sop->so_perstateid); | ||
350 | while (!list_empty(&sop->so_stateids)) { | ||
351 | stp = list_first_entry(&sop->so_stateids, | ||
352 | struct nfs4_stateid, st_perstateowner); | ||
353 | release_lock_stateid(stp); | ||
354 | } | ||
355 | } | ||
356 | |||
357 | static void release_lockowner(struct nfs4_stateowner *sop) | ||
358 | { | ||
359 | unhash_lockowner(sop); | ||
360 | nfs4_put_stateowner(sop); | ||
361 | } | ||
362 | |||
363 | static void | ||
364 | release_stateid_lockowners(struct nfs4_stateid *open_stp) | ||
365 | { | ||
366 | struct nfs4_stateowner *lock_sop; | ||
367 | |||
368 | while (!list_empty(&open_stp->st_lockowners)) { | ||
369 | lock_sop = list_entry(open_stp->st_lockowners.next, | ||
370 | struct nfs4_stateowner, so_perstateid); | ||
371 | /* list_del(&open_stp->st_lockowners); */ | ||
372 | BUG_ON(lock_sop->so_is_open_owner); | ||
373 | release_lockowner(lock_sop); | ||
374 | } | ||
375 | } | ||
376 | |||
377 | /* | 319 | /* |
378 | * We store the NONE, READ, WRITE, and BOTH bits separately in the | 320 | * We store the NONE, READ, WRITE, and BOTH bits separately in the |
379 | * st_{access,deny}_bmap field of the stateid, in order to track not | 321 | * st_{access,deny}_bmap field of the stateid, in order to track not |
@@ -446,13 +388,71 @@ static int nfs4_access_bmap_to_omode(struct nfs4_stateid *stp) | |||
446 | return nfs4_access_to_omode(access); | 388 | return nfs4_access_to_omode(access); |
447 | } | 389 | } |
448 | 390 | ||
449 | static void release_open_stateid(struct nfs4_stateid *stp) | 391 | static void unhash_generic_stateid(struct nfs4_stateid *stp) |
392 | { | ||
393 | list_del(&stp->st_hash); | ||
394 | list_del(&stp->st_perfile); | ||
395 | list_del(&stp->st_perstateowner); | ||
396 | } | ||
397 | |||
398 | static void free_generic_stateid(struct nfs4_stateid *stp) | ||
450 | { | 399 | { |
451 | int oflag = nfs4_access_bmap_to_omode(stp); | 400 | int oflag = nfs4_access_bmap_to_omode(stp); |
452 | 401 | ||
402 | nfs4_file_put_access(stp->st_file, oflag); | ||
403 | put_nfs4_file(stp->st_file); | ||
404 | kmem_cache_free(stateid_slab, stp); | ||
405 | } | ||
406 | |||
407 | static void release_lock_stateid(struct nfs4_stateid *stp) | ||
408 | { | ||
409 | struct file *file; | ||
410 | |||
411 | unhash_generic_stateid(stp); | ||
412 | file = find_any_file(stp->st_file); | ||
413 | if (file) | ||
414 | locks_remove_posix(file, (fl_owner_t)stp->st_stateowner); | ||
415 | free_generic_stateid(stp); | ||
416 | } | ||
417 | |||
418 | static void unhash_lockowner(struct nfs4_stateowner *sop) | ||
419 | { | ||
420 | struct nfs4_stateid *stp; | ||
421 | |||
422 | list_del(&sop->so_idhash); | ||
423 | list_del(&sop->so_strhash); | ||
424 | list_del(&sop->so_perstateid); | ||
425 | while (!list_empty(&sop->so_stateids)) { | ||
426 | stp = list_first_entry(&sop->so_stateids, | ||
427 | struct nfs4_stateid, st_perstateowner); | ||
428 | release_lock_stateid(stp); | ||
429 | } | ||
430 | } | ||
431 | |||
432 | static void release_lockowner(struct nfs4_stateowner *sop) | ||
433 | { | ||
434 | unhash_lockowner(sop); | ||
435 | nfs4_put_stateowner(sop); | ||
436 | } | ||
437 | |||
438 | static void | ||
439 | release_stateid_lockowners(struct nfs4_stateid *open_stp) | ||
440 | { | ||
441 | struct nfs4_stateowner *lock_sop; | ||
442 | |||
443 | while (!list_empty(&open_stp->st_lockowners)) { | ||
444 | lock_sop = list_entry(open_stp->st_lockowners.next, | ||
445 | struct nfs4_stateowner, so_perstateid); | ||
446 | /* list_del(&open_stp->st_lockowners); */ | ||
447 | BUG_ON(lock_sop->so_is_open_owner); | ||
448 | release_lockowner(lock_sop); | ||
449 | } | ||
450 | } | ||
451 | |||
452 | static void release_open_stateid(struct nfs4_stateid *stp) | ||
453 | { | ||
453 | unhash_generic_stateid(stp); | 454 | unhash_generic_stateid(stp); |
454 | release_stateid_lockowners(stp); | 455 | release_stateid_lockowners(stp); |
455 | nfs4_file_put_access(stp->st_file, oflag); | ||
456 | free_generic_stateid(stp); | 456 | free_generic_stateid(stp); |
457 | } | 457 | } |
458 | 458 | ||
@@ -608,7 +608,8 @@ static void init_forechannel_attrs(struct nfsd4_channel_attrs *new, struct nfsd4 | |||
608 | u32 maxrpc = nfsd_serv->sv_max_mesg; | 608 | u32 maxrpc = nfsd_serv->sv_max_mesg; |
609 | 609 | ||
610 | new->maxreqs = numslots; | 610 | new->maxreqs = numslots; |
611 | new->maxresp_cached = slotsize + NFSD_MIN_HDR_SEQ_SZ; | 611 | new->maxresp_cached = min_t(u32, req->maxresp_cached, |
612 | slotsize + NFSD_MIN_HDR_SEQ_SZ); | ||
612 | new->maxreq_sz = min_t(u32, req->maxreq_sz, maxrpc); | 613 | new->maxreq_sz = min_t(u32, req->maxreq_sz, maxrpc); |
613 | new->maxresp_sz = min_t(u32, req->maxresp_sz, maxrpc); | 614 | new->maxresp_sz = min_t(u32, req->maxresp_sz, maxrpc); |
614 | new->maxops = min_t(u32, req->maxops, NFSD_MAX_OPS_PER_COMPOUND); | 615 | new->maxops = min_t(u32, req->maxops, NFSD_MAX_OPS_PER_COMPOUND); |
@@ -3735,6 +3736,7 @@ alloc_init_lock_stateid(struct nfs4_stateowner *sop, struct nfs4_file *fp, struc | |||
3735 | stp->st_stateid.si_stateownerid = sop->so_id; | 3736 | stp->st_stateid.si_stateownerid = sop->so_id; |
3736 | stp->st_stateid.si_fileid = fp->fi_id; | 3737 | stp->st_stateid.si_fileid = fp->fi_id; |
3737 | stp->st_stateid.si_generation = 0; | 3738 | stp->st_stateid.si_generation = 0; |
3739 | stp->st_access_bmap = 0; | ||
3738 | stp->st_deny_bmap = open_stp->st_deny_bmap; | 3740 | stp->st_deny_bmap = open_stp->st_deny_bmap; |
3739 | stp->st_openstp = open_stp; | 3741 | stp->st_openstp = open_stp; |
3740 | 3742 | ||
@@ -3749,6 +3751,17 @@ check_lock_length(u64 offset, u64 length) | |||
3749 | LOFF_OVERFLOW(offset, length))); | 3751 | LOFF_OVERFLOW(offset, length))); |
3750 | } | 3752 | } |
3751 | 3753 | ||
3754 | static void get_lock_access(struct nfs4_stateid *lock_stp, u32 access) | ||
3755 | { | ||
3756 | struct nfs4_file *fp = lock_stp->st_file; | ||
3757 | int oflag = nfs4_access_to_omode(access); | ||
3758 | |||
3759 | if (test_bit(access, &lock_stp->st_access_bmap)) | ||
3760 | return; | ||
3761 | nfs4_file_get_access(fp, oflag); | ||
3762 | __set_bit(access, &lock_stp->st_access_bmap); | ||
3763 | } | ||
3764 | |||
3752 | /* | 3765 | /* |
3753 | * LOCK operation | 3766 | * LOCK operation |
3754 | */ | 3767 | */ |
@@ -3765,7 +3778,6 @@ nfsd4_lock(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate, | |||
3765 | struct file_lock conflock; | 3778 | struct file_lock conflock; |
3766 | __be32 status = 0; | 3779 | __be32 status = 0; |
3767 | unsigned int strhashval; | 3780 | unsigned int strhashval; |
3768 | unsigned int cmd; | ||
3769 | int err; | 3781 | int err; |
3770 | 3782 | ||
3771 | dprintk("NFSD: nfsd4_lock: start=%Ld length=%Ld\n", | 3783 | dprintk("NFSD: nfsd4_lock: start=%Ld length=%Ld\n", |
@@ -3847,22 +3859,18 @@ nfsd4_lock(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate, | |||
3847 | switch (lock->lk_type) { | 3859 | switch (lock->lk_type) { |
3848 | case NFS4_READ_LT: | 3860 | case NFS4_READ_LT: |
3849 | case NFS4_READW_LT: | 3861 | case NFS4_READW_LT: |
3850 | if (find_readable_file(lock_stp->st_file)) { | 3862 | filp = find_readable_file(lock_stp->st_file); |
3851 | nfs4_get_vfs_file(rqstp, fp, &cstate->current_fh, NFS4_SHARE_ACCESS_READ); | 3863 | if (filp) |
3852 | filp = find_readable_file(lock_stp->st_file); | 3864 | get_lock_access(lock_stp, NFS4_SHARE_ACCESS_READ); |
3853 | } | ||
3854 | file_lock.fl_type = F_RDLCK; | 3865 | file_lock.fl_type = F_RDLCK; |
3855 | cmd = F_SETLK; | 3866 | break; |
3856 | break; | ||
3857 | case NFS4_WRITE_LT: | 3867 | case NFS4_WRITE_LT: |
3858 | case NFS4_WRITEW_LT: | 3868 | case NFS4_WRITEW_LT: |
3859 | if (find_writeable_file(lock_stp->st_file)) { | 3869 | filp = find_writeable_file(lock_stp->st_file); |
3860 | nfs4_get_vfs_file(rqstp, fp, &cstate->current_fh, NFS4_SHARE_ACCESS_WRITE); | 3870 | if (filp) |
3861 | filp = find_writeable_file(lock_stp->st_file); | 3871 | get_lock_access(lock_stp, NFS4_SHARE_ACCESS_WRITE); |
3862 | } | ||
3863 | file_lock.fl_type = F_WRLCK; | 3872 | file_lock.fl_type = F_WRLCK; |
3864 | cmd = F_SETLK; | 3873 | break; |
3865 | break; | ||
3866 | default: | 3874 | default: |
3867 | status = nfserr_inval; | 3875 | status = nfserr_inval; |
3868 | goto out; | 3876 | goto out; |
@@ -3886,7 +3894,7 @@ nfsd4_lock(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate, | |||
3886 | * Note: locks.c uses the BKL to protect the inode's lock list. | 3894 | * Note: locks.c uses the BKL to protect the inode's lock list. |
3887 | */ | 3895 | */ |
3888 | 3896 | ||
3889 | err = vfs_lock_file(filp, cmd, &file_lock, &conflock); | 3897 | err = vfs_lock_file(filp, F_SETLK, &file_lock, &conflock); |
3890 | switch (-err) { | 3898 | switch (-err) { |
3891 | case 0: /* success! */ | 3899 | case 0: /* success! */ |
3892 | update_stateid(&lock_stp->st_stateid); | 3900 | update_stateid(&lock_stp->st_stateid); |
diff --git a/fs/nfsd/nfs4xdr.c b/fs/nfsd/nfs4xdr.c index 615f0a9f0600..c6766af00d98 100644 --- a/fs/nfsd/nfs4xdr.c +++ b/fs/nfsd/nfs4xdr.c | |||
@@ -1142,7 +1142,7 @@ nfsd4_decode_create_session(struct nfsd4_compoundargs *argp, | |||
1142 | 1142 | ||
1143 | u32 dummy; | 1143 | u32 dummy; |
1144 | char *machine_name; | 1144 | char *machine_name; |
1145 | int i, j; | 1145 | int i; |
1146 | int nr_secflavs; | 1146 | int nr_secflavs; |
1147 | 1147 | ||
1148 | READ_BUF(16); | 1148 | READ_BUF(16); |
@@ -1215,8 +1215,6 @@ nfsd4_decode_create_session(struct nfsd4_compoundargs *argp, | |||
1215 | READ_BUF(4); | 1215 | READ_BUF(4); |
1216 | READ32(dummy); | 1216 | READ32(dummy); |
1217 | READ_BUF(dummy * 4); | 1217 | READ_BUF(dummy * 4); |
1218 | for (j = 0; j < dummy; ++j) | ||
1219 | READ32(dummy); | ||
1220 | break; | 1218 | break; |
1221 | case RPC_AUTH_GSS: | 1219 | case RPC_AUTH_GSS: |
1222 | dprintk("RPC_AUTH_GSS callback secflavor " | 1220 | dprintk("RPC_AUTH_GSS callback secflavor " |
@@ -1232,7 +1230,6 @@ nfsd4_decode_create_session(struct nfsd4_compoundargs *argp, | |||
1232 | READ_BUF(4); | 1230 | READ_BUF(4); |
1233 | READ32(dummy); | 1231 | READ32(dummy); |
1234 | READ_BUF(dummy); | 1232 | READ_BUF(dummy); |
1235 | p += XDR_QUADLEN(dummy); | ||
1236 | break; | 1233 | break; |
1237 | default: | 1234 | default: |
1238 | dprintk("Illegal callback secflavor\n"); | 1235 | dprintk("Illegal callback secflavor\n"); |
diff --git a/fs/nfsd/nfsctl.c b/fs/nfsd/nfsctl.c index 33b3e2b06779..1f5eae40f34e 100644 --- a/fs/nfsd/nfsctl.c +++ b/fs/nfsd/nfsctl.c | |||
@@ -12,13 +12,14 @@ | |||
12 | #include <linux/nfsd/syscall.h> | 12 | #include <linux/nfsd/syscall.h> |
13 | #include <linux/lockd/lockd.h> | 13 | #include <linux/lockd/lockd.h> |
14 | #include <linux/sunrpc/clnt.h> | 14 | #include <linux/sunrpc/clnt.h> |
15 | #include <linux/sunrpc/gss_api.h> | ||
15 | 16 | ||
16 | #include "idmap.h" | 17 | #include "idmap.h" |
17 | #include "nfsd.h" | 18 | #include "nfsd.h" |
18 | #include "cache.h" | 19 | #include "cache.h" |
19 | 20 | ||
20 | /* | 21 | /* |
21 | * We have a single directory with 9 nodes in it. | 22 | * We have a single directory with several nodes in it. |
22 | */ | 23 | */ |
23 | enum { | 24 | enum { |
24 | NFSD_Root = 1, | 25 | NFSD_Root = 1, |
@@ -42,6 +43,7 @@ enum { | |||
42 | NFSD_Versions, | 43 | NFSD_Versions, |
43 | NFSD_Ports, | 44 | NFSD_Ports, |
44 | NFSD_MaxBlkSize, | 45 | NFSD_MaxBlkSize, |
46 | NFSD_SupportedEnctypes, | ||
45 | /* | 47 | /* |
46 | * The below MUST come last. Otherwise we leave a hole in nfsd_files[] | 48 | * The below MUST come last. Otherwise we leave a hole in nfsd_files[] |
47 | * with !CONFIG_NFSD_V4 and simple_fill_super() goes oops | 49 | * with !CONFIG_NFSD_V4 and simple_fill_super() goes oops |
@@ -187,6 +189,34 @@ static struct file_operations export_features_operations = { | |||
187 | .release = single_release, | 189 | .release = single_release, |
188 | }; | 190 | }; |
189 | 191 | ||
192 | #ifdef CONFIG_SUNRPC_GSS | ||
193 | static int supported_enctypes_show(struct seq_file *m, void *v) | ||
194 | { | ||
195 | struct gss_api_mech *k5mech; | ||
196 | |||
197 | k5mech = gss_mech_get_by_name("krb5"); | ||
198 | if (k5mech == NULL) | ||
199 | goto out; | ||
200 | if (k5mech->gm_upcall_enctypes != NULL) | ||
201 | seq_printf(m, k5mech->gm_upcall_enctypes); | ||
202 | gss_mech_put(k5mech); | ||
203 | out: | ||
204 | return 0; | ||
205 | } | ||
206 | |||
207 | static int supported_enctypes_open(struct inode *inode, struct file *file) | ||
208 | { | ||
209 | return single_open(file, supported_enctypes_show, NULL); | ||
210 | } | ||
211 | |||
212 | static struct file_operations supported_enctypes_ops = { | ||
213 | .open = supported_enctypes_open, | ||
214 | .read = seq_read, | ||
215 | .llseek = seq_lseek, | ||
216 | .release = single_release, | ||
217 | }; | ||
218 | #endif /* CONFIG_SUNRPC_GSS */ | ||
219 | |||
190 | extern int nfsd_pool_stats_open(struct inode *inode, struct file *file); | 220 | extern int nfsd_pool_stats_open(struct inode *inode, struct file *file); |
191 | extern int nfsd_pool_stats_release(struct inode *inode, struct file *file); | 221 | extern int nfsd_pool_stats_release(struct inode *inode, struct file *file); |
192 | 222 | ||
@@ -1397,6 +1427,9 @@ static int nfsd_fill_super(struct super_block * sb, void * data, int silent) | |||
1397 | [NFSD_Versions] = {"versions", &transaction_ops, S_IWUSR|S_IRUSR}, | 1427 | [NFSD_Versions] = {"versions", &transaction_ops, S_IWUSR|S_IRUSR}, |
1398 | [NFSD_Ports] = {"portlist", &transaction_ops, S_IWUSR|S_IRUGO}, | 1428 | [NFSD_Ports] = {"portlist", &transaction_ops, S_IWUSR|S_IRUGO}, |
1399 | [NFSD_MaxBlkSize] = {"max_block_size", &transaction_ops, S_IWUSR|S_IRUGO}, | 1429 | [NFSD_MaxBlkSize] = {"max_block_size", &transaction_ops, S_IWUSR|S_IRUGO}, |
1430 | #ifdef CONFIG_SUNRPC_GSS | ||
1431 | [NFSD_SupportedEnctypes] = {"supported_krb5_enctypes", &supported_enctypes_ops, S_IRUGO}, | ||
1432 | #endif /* CONFIG_SUNRPC_GSS */ | ||
1400 | #ifdef CONFIG_NFSD_V4 | 1433 | #ifdef CONFIG_NFSD_V4 |
1401 | [NFSD_Leasetime] = {"nfsv4leasetime", &transaction_ops, S_IWUSR|S_IRUSR}, | 1434 | [NFSD_Leasetime] = {"nfsv4leasetime", &transaction_ops, S_IWUSR|S_IRUSR}, |
1402 | [NFSD_Gracetime] = {"nfsv4gracetime", &transaction_ops, S_IWUSR|S_IRUSR}, | 1435 | [NFSD_Gracetime] = {"nfsv4gracetime", &transaction_ops, S_IWUSR|S_IRUSR}, |
diff --git a/fs/nfsd/state.h b/fs/nfsd/state.h index 2d31224b07bf..6bd2f3c21f2b 100644 --- a/fs/nfsd/state.h +++ b/fs/nfsd/state.h | |||
@@ -367,16 +367,12 @@ struct nfs4_file { | |||
367 | struct list_head fi_delegations; | 367 | struct list_head fi_delegations; |
368 | /* One each for O_RDONLY, O_WRONLY, O_RDWR: */ | 368 | /* One each for O_RDONLY, O_WRONLY, O_RDWR: */ |
369 | struct file * fi_fds[3]; | 369 | struct file * fi_fds[3]; |
370 | /* One each for O_RDONLY, O_WRONLY: */ | ||
371 | atomic_t fi_access[2]; | ||
372 | /* | 370 | /* |
373 | * Each open stateid contributes 1 to either fi_readers or | 371 | * Each open or lock stateid contributes 1 to either |
374 | * fi_writers, or both, depending on the open mode. A | 372 | * fi_access[O_RDONLY], fi_access[O_WRONLY], or both, depending |
375 | * delegation also takes an fi_readers reference. Lock | 373 | * on open or lock mode: |
376 | * stateid's take none. | ||
377 | */ | 374 | */ |
378 | atomic_t fi_readers; | 375 | atomic_t fi_access[2]; |
379 | atomic_t fi_writers; | ||
380 | struct file *fi_deleg_file; | 376 | struct file *fi_deleg_file; |
381 | struct file_lock *fi_lease; | 377 | struct file_lock *fi_lease; |
382 | atomic_t fi_delegees; | 378 | atomic_t fi_delegees; |
diff --git a/fs/nfsd/vfs.c b/fs/nfsd/vfs.c index da1d9701f8e4..2e1cebde90df 100644 --- a/fs/nfsd/vfs.c +++ b/fs/nfsd/vfs.c | |||
@@ -87,7 +87,7 @@ nfsd_cross_mnt(struct svc_rqst *rqstp, struct dentry **dpp, | |||
87 | .dentry = dget(dentry)}; | 87 | .dentry = dget(dentry)}; |
88 | int err = 0; | 88 | int err = 0; |
89 | 89 | ||
90 | err = follow_down(&path, false); | 90 | err = follow_down(&path); |
91 | if (err < 0) | 91 | if (err < 0) |
92 | goto out; | 92 | goto out; |
93 | 93 | ||
@@ -1749,8 +1749,6 @@ nfsd_rename(struct svc_rqst *rqstp, struct svc_fh *ffhp, char *fname, int flen, | |||
1749 | if (host_err) | 1749 | if (host_err) |
1750 | goto out_drop_write; | 1750 | goto out_drop_write; |
1751 | } | 1751 | } |
1752 | if (host_err) | ||
1753 | goto out_drop_write; | ||
1754 | host_err = vfs_rename(fdir, odentry, tdir, ndentry); | 1752 | host_err = vfs_rename(fdir, odentry, tdir, ndentry); |
1755 | if (!host_err) { | 1753 | if (!host_err) { |
1756 | host_err = commit_metadata(tfhp); | 1754 | host_err = commit_metadata(tfhp); |
diff --git a/fs/nilfs2/alloc.c b/fs/nilfs2/alloc.c index d7fd696e595c..0a0a66d98cce 100644 --- a/fs/nilfs2/alloc.c +++ b/fs/nilfs2/alloc.c | |||
@@ -521,8 +521,8 @@ void nilfs_palloc_commit_free_entry(struct inode *inode, | |||
521 | group_offset, bitmap)) | 521 | group_offset, bitmap)) |
522 | printk(KERN_WARNING "%s: entry number %llu already freed\n", | 522 | printk(KERN_WARNING "%s: entry number %llu already freed\n", |
523 | __func__, (unsigned long long)req->pr_entry_nr); | 523 | __func__, (unsigned long long)req->pr_entry_nr); |
524 | 524 | else | |
525 | nilfs_palloc_group_desc_add_entries(inode, group, desc, 1); | 525 | nilfs_palloc_group_desc_add_entries(inode, group, desc, 1); |
526 | 526 | ||
527 | kunmap(req->pr_bitmap_bh->b_page); | 527 | kunmap(req->pr_bitmap_bh->b_page); |
528 | kunmap(req->pr_desc_bh->b_page); | 528 | kunmap(req->pr_desc_bh->b_page); |
@@ -558,8 +558,8 @@ void nilfs_palloc_abort_alloc_entry(struct inode *inode, | |||
558 | group_offset, bitmap)) | 558 | group_offset, bitmap)) |
559 | printk(KERN_WARNING "%s: entry number %llu already freed\n", | 559 | printk(KERN_WARNING "%s: entry number %llu already freed\n", |
560 | __func__, (unsigned long long)req->pr_entry_nr); | 560 | __func__, (unsigned long long)req->pr_entry_nr); |
561 | 561 | else | |
562 | nilfs_palloc_group_desc_add_entries(inode, group, desc, 1); | 562 | nilfs_palloc_group_desc_add_entries(inode, group, desc, 1); |
563 | 563 | ||
564 | kunmap(req->pr_bitmap_bh->b_page); | 564 | kunmap(req->pr_bitmap_bh->b_page); |
565 | kunmap(req->pr_desc_bh->b_page); | 565 | kunmap(req->pr_desc_bh->b_page); |
@@ -665,7 +665,7 @@ int nilfs_palloc_freev(struct inode *inode, __u64 *entry_nrs, size_t nitems) | |||
665 | for (j = i, n = 0; | 665 | for (j = i, n = 0; |
666 | (j < nitems) && nilfs_palloc_group_is_in(inode, group, | 666 | (j < nitems) && nilfs_palloc_group_is_in(inode, group, |
667 | entry_nrs[j]); | 667 | entry_nrs[j]); |
668 | j++, n++) { | 668 | j++) { |
669 | nilfs_palloc_group(inode, entry_nrs[j], &group_offset); | 669 | nilfs_palloc_group(inode, entry_nrs[j], &group_offset); |
670 | if (!nilfs_clear_bit_atomic( | 670 | if (!nilfs_clear_bit_atomic( |
671 | nilfs_mdt_bgl_lock(inode, group), | 671 | nilfs_mdt_bgl_lock(inode, group), |
@@ -674,6 +674,8 @@ int nilfs_palloc_freev(struct inode *inode, __u64 *entry_nrs, size_t nitems) | |||
674 | "%s: entry number %llu already freed\n", | 674 | "%s: entry number %llu already freed\n", |
675 | __func__, | 675 | __func__, |
676 | (unsigned long long)entry_nrs[j]); | 676 | (unsigned long long)entry_nrs[j]); |
677 | } else { | ||
678 | n++; | ||
677 | } | 679 | } |
678 | } | 680 | } |
679 | nilfs_palloc_group_desc_add_entries(inode, group, desc, n); | 681 | nilfs_palloc_group_desc_add_entries(inode, group, desc, n); |
diff --git a/fs/nilfs2/alloc.h b/fs/nilfs2/alloc.h index 9af34a7e6e13..f5fde36b9e28 100644 --- a/fs/nilfs2/alloc.h +++ b/fs/nilfs2/alloc.h | |||
@@ -74,7 +74,7 @@ int nilfs_palloc_freev(struct inode *, __u64 *, size_t); | |||
74 | 74 | ||
75 | #define nilfs_set_bit_atomic ext2_set_bit_atomic | 75 | #define nilfs_set_bit_atomic ext2_set_bit_atomic |
76 | #define nilfs_clear_bit_atomic ext2_clear_bit_atomic | 76 | #define nilfs_clear_bit_atomic ext2_clear_bit_atomic |
77 | #define nilfs_find_next_zero_bit ext2_find_next_zero_bit | 77 | #define nilfs_find_next_zero_bit find_next_zero_bit_le |
78 | 78 | ||
79 | /* | 79 | /* |
80 | * persistent object allocator cache | 80 | * persistent object allocator cache |
diff --git a/fs/nilfs2/bmap.c b/fs/nilfs2/bmap.c index 3ee67c67cc52..4723f04e9b12 100644 --- a/fs/nilfs2/bmap.c +++ b/fs/nilfs2/bmap.c | |||
@@ -25,7 +25,6 @@ | |||
25 | #include <linux/errno.h> | 25 | #include <linux/errno.h> |
26 | #include "nilfs.h" | 26 | #include "nilfs.h" |
27 | #include "bmap.h" | 27 | #include "bmap.h" |
28 | #include "sb.h" | ||
29 | #include "btree.h" | 28 | #include "btree.h" |
30 | #include "direct.h" | 29 | #include "direct.h" |
31 | #include "btnode.h" | 30 | #include "btnode.h" |
@@ -425,17 +424,6 @@ int nilfs_bmap_test_and_clear_dirty(struct nilfs_bmap *bmap) | |||
425 | /* | 424 | /* |
426 | * Internal use only | 425 | * Internal use only |
427 | */ | 426 | */ |
428 | |||
429 | void nilfs_bmap_add_blocks(const struct nilfs_bmap *bmap, int n) | ||
430 | { | ||
431 | inode_add_bytes(bmap->b_inode, (1 << bmap->b_inode->i_blkbits) * n); | ||
432 | } | ||
433 | |||
434 | void nilfs_bmap_sub_blocks(const struct nilfs_bmap *bmap, int n) | ||
435 | { | ||
436 | inode_sub_bytes(bmap->b_inode, (1 << bmap->b_inode->i_blkbits) * n); | ||
437 | } | ||
438 | |||
439 | __u64 nilfs_bmap_data_get_key(const struct nilfs_bmap *bmap, | 427 | __u64 nilfs_bmap_data_get_key(const struct nilfs_bmap *bmap, |
440 | const struct buffer_head *bh) | 428 | const struct buffer_head *bh) |
441 | { | 429 | { |
diff --git a/fs/nilfs2/bmap.h b/fs/nilfs2/bmap.h index bde1c0aa2e15..40d9f453d31c 100644 --- a/fs/nilfs2/bmap.h +++ b/fs/nilfs2/bmap.h | |||
@@ -240,9 +240,6 @@ __u64 nilfs_bmap_data_get_key(const struct nilfs_bmap *, | |||
240 | __u64 nilfs_bmap_find_target_seq(const struct nilfs_bmap *, __u64); | 240 | __u64 nilfs_bmap_find_target_seq(const struct nilfs_bmap *, __u64); |
241 | __u64 nilfs_bmap_find_target_in_group(const struct nilfs_bmap *); | 241 | __u64 nilfs_bmap_find_target_in_group(const struct nilfs_bmap *); |
242 | 242 | ||
243 | void nilfs_bmap_add_blocks(const struct nilfs_bmap *, int); | ||
244 | void nilfs_bmap_sub_blocks(const struct nilfs_bmap *, int); | ||
245 | |||
246 | 243 | ||
247 | /* Assume that bmap semaphore is locked. */ | 244 | /* Assume that bmap semaphore is locked. */ |
248 | static inline int nilfs_bmap_dirty(const struct nilfs_bmap *bmap) | 245 | static inline int nilfs_bmap_dirty(const struct nilfs_bmap *bmap) |
diff --git a/fs/nilfs2/btree.c b/fs/nilfs2/btree.c index 300c2bc00c3f..d451ae0e0bf3 100644 --- a/fs/nilfs2/btree.c +++ b/fs/nilfs2/btree.c | |||
@@ -1174,7 +1174,7 @@ static int nilfs_btree_insert(struct nilfs_bmap *btree, __u64 key, __u64 ptr) | |||
1174 | if (ret < 0) | 1174 | if (ret < 0) |
1175 | goto out; | 1175 | goto out; |
1176 | nilfs_btree_commit_insert(btree, path, level, key, ptr); | 1176 | nilfs_btree_commit_insert(btree, path, level, key, ptr); |
1177 | nilfs_bmap_add_blocks(btree, stats.bs_nblocks); | 1177 | nilfs_inode_add_blocks(btree->b_inode, stats.bs_nblocks); |
1178 | 1178 | ||
1179 | out: | 1179 | out: |
1180 | nilfs_btree_free_path(path); | 1180 | nilfs_btree_free_path(path); |
@@ -1511,7 +1511,7 @@ static int nilfs_btree_delete(struct nilfs_bmap *btree, __u64 key) | |||
1511 | if (ret < 0) | 1511 | if (ret < 0) |
1512 | goto out; | 1512 | goto out; |
1513 | nilfs_btree_commit_delete(btree, path, level, dat); | 1513 | nilfs_btree_commit_delete(btree, path, level, dat); |
1514 | nilfs_bmap_sub_blocks(btree, stats.bs_nblocks); | 1514 | nilfs_inode_sub_blocks(btree->b_inode, stats.bs_nblocks); |
1515 | 1515 | ||
1516 | out: | 1516 | out: |
1517 | nilfs_btree_free_path(path); | 1517 | nilfs_btree_free_path(path); |
@@ -1776,7 +1776,7 @@ int nilfs_btree_convert_and_insert(struct nilfs_bmap *btree, | |||
1776 | return ret; | 1776 | return ret; |
1777 | nilfs_btree_commit_convert_and_insert(btree, key, ptr, keys, ptrs, n, | 1777 | nilfs_btree_commit_convert_and_insert(btree, key, ptr, keys, ptrs, n, |
1778 | di, ni, bh); | 1778 | di, ni, bh); |
1779 | nilfs_bmap_add_blocks(btree, stats.bs_nblocks); | 1779 | nilfs_inode_add_blocks(btree->b_inode, stats.bs_nblocks); |
1780 | return 0; | 1780 | return 0; |
1781 | } | 1781 | } |
1782 | 1782 | ||
diff --git a/fs/nilfs2/dir.c b/fs/nilfs2/dir.c index 9d45773b79e6..3a1923943b14 100644 --- a/fs/nilfs2/dir.c +++ b/fs/nilfs2/dir.c | |||
@@ -440,7 +440,6 @@ void nilfs_set_link(struct inode *dir, struct nilfs_dir_entry *de, | |||
440 | nilfs_commit_chunk(page, mapping, from, to); | 440 | nilfs_commit_chunk(page, mapping, from, to); |
441 | nilfs_put_page(page); | 441 | nilfs_put_page(page); |
442 | dir->i_mtime = dir->i_ctime = CURRENT_TIME; | 442 | dir->i_mtime = dir->i_ctime = CURRENT_TIME; |
443 | /* NILFS_I(dir)->i_flags &= ~NILFS_BTREE_FL; */ | ||
444 | } | 443 | } |
445 | 444 | ||
446 | /* | 445 | /* |
@@ -531,7 +530,6 @@ got_it: | |||
531 | nilfs_set_de_type(de, inode); | 530 | nilfs_set_de_type(de, inode); |
532 | nilfs_commit_chunk(page, page->mapping, from, to); | 531 | nilfs_commit_chunk(page, page->mapping, from, to); |
533 | dir->i_mtime = dir->i_ctime = CURRENT_TIME; | 532 | dir->i_mtime = dir->i_ctime = CURRENT_TIME; |
534 | /* NILFS_I(dir)->i_flags &= ~NILFS_BTREE_FL; */ | ||
535 | nilfs_mark_inode_dirty(dir); | 533 | nilfs_mark_inode_dirty(dir); |
536 | /* OFFSET_CACHE */ | 534 | /* OFFSET_CACHE */ |
537 | out_put: | 535 | out_put: |
@@ -579,7 +577,6 @@ int nilfs_delete_entry(struct nilfs_dir_entry *dir, struct page *page) | |||
579 | dir->inode = 0; | 577 | dir->inode = 0; |
580 | nilfs_commit_chunk(page, mapping, from, to); | 578 | nilfs_commit_chunk(page, mapping, from, to); |
581 | inode->i_ctime = inode->i_mtime = CURRENT_TIME; | 579 | inode->i_ctime = inode->i_mtime = CURRENT_TIME; |
582 | /* NILFS_I(inode)->i_flags &= ~NILFS_BTREE_FL; */ | ||
583 | out: | 580 | out: |
584 | nilfs_put_page(page); | 581 | nilfs_put_page(page); |
585 | return err; | 582 | return err; |
@@ -684,7 +681,7 @@ const struct file_operations nilfs_dir_operations = { | |||
684 | .readdir = nilfs_readdir, | 681 | .readdir = nilfs_readdir, |
685 | .unlocked_ioctl = nilfs_ioctl, | 682 | .unlocked_ioctl = nilfs_ioctl, |
686 | #ifdef CONFIG_COMPAT | 683 | #ifdef CONFIG_COMPAT |
687 | .compat_ioctl = nilfs_ioctl, | 684 | .compat_ioctl = nilfs_compat_ioctl, |
688 | #endif /* CONFIG_COMPAT */ | 685 | #endif /* CONFIG_COMPAT */ |
689 | .fsync = nilfs_sync_file, | 686 | .fsync = nilfs_sync_file, |
690 | 687 | ||
diff --git a/fs/nilfs2/direct.c b/fs/nilfs2/direct.c index 324d80c57518..82f4865e86dd 100644 --- a/fs/nilfs2/direct.c +++ b/fs/nilfs2/direct.c | |||
@@ -146,7 +146,7 @@ static int nilfs_direct_insert(struct nilfs_bmap *bmap, __u64 key, __u64 ptr) | |||
146 | if (NILFS_BMAP_USE_VBN(bmap)) | 146 | if (NILFS_BMAP_USE_VBN(bmap)) |
147 | nilfs_bmap_set_target_v(bmap, key, req.bpr_ptr); | 147 | nilfs_bmap_set_target_v(bmap, key, req.bpr_ptr); |
148 | 148 | ||
149 | nilfs_bmap_add_blocks(bmap, 1); | 149 | nilfs_inode_add_blocks(bmap->b_inode, 1); |
150 | } | 150 | } |
151 | return ret; | 151 | return ret; |
152 | } | 152 | } |
@@ -168,7 +168,7 @@ static int nilfs_direct_delete(struct nilfs_bmap *bmap, __u64 key) | |||
168 | if (!ret) { | 168 | if (!ret) { |
169 | nilfs_bmap_commit_end_ptr(bmap, &req, dat); | 169 | nilfs_bmap_commit_end_ptr(bmap, &req, dat); |
170 | nilfs_direct_set_ptr(bmap, key, NILFS_BMAP_INVALID_PTR); | 170 | nilfs_direct_set_ptr(bmap, key, NILFS_BMAP_INVALID_PTR); |
171 | nilfs_bmap_sub_blocks(bmap, 1); | 171 | nilfs_inode_sub_blocks(bmap->b_inode, 1); |
172 | } | 172 | } |
173 | return ret; | 173 | return ret; |
174 | } | 174 | } |
diff --git a/fs/nilfs2/file.c b/fs/nilfs2/file.c index 2f560c9fb808..93589fccdd97 100644 --- a/fs/nilfs2/file.c +++ b/fs/nilfs2/file.c | |||
@@ -59,7 +59,7 @@ static int nilfs_page_mkwrite(struct vm_area_struct *vma, struct vm_fault *vmf) | |||
59 | struct nilfs_transaction_info ti; | 59 | struct nilfs_transaction_info ti; |
60 | int ret; | 60 | int ret; |
61 | 61 | ||
62 | if (unlikely(nilfs_near_disk_full(NILFS_SB(inode->i_sb)->s_nilfs))) | 62 | if (unlikely(nilfs_near_disk_full(inode->i_sb->s_fs_info))) |
63 | return VM_FAULT_SIGBUS; /* -ENOSPC */ | 63 | return VM_FAULT_SIGBUS; /* -ENOSPC */ |
64 | 64 | ||
65 | lock_page(page); | 65 | lock_page(page); |
@@ -142,7 +142,7 @@ const struct file_operations nilfs_file_operations = { | |||
142 | .aio_write = generic_file_aio_write, | 142 | .aio_write = generic_file_aio_write, |
143 | .unlocked_ioctl = nilfs_ioctl, | 143 | .unlocked_ioctl = nilfs_ioctl, |
144 | #ifdef CONFIG_COMPAT | 144 | #ifdef CONFIG_COMPAT |
145 | .compat_ioctl = nilfs_ioctl, | 145 | .compat_ioctl = nilfs_compat_ioctl, |
146 | #endif /* CONFIG_COMPAT */ | 146 | #endif /* CONFIG_COMPAT */ |
147 | .mmap = nilfs_file_mmap, | 147 | .mmap = nilfs_file_mmap, |
148 | .open = generic_file_open, | 148 | .open = generic_file_open, |
diff --git a/fs/nilfs2/inode.c b/fs/nilfs2/inode.c index 2fd440d8d6b8..d5625be236a8 100644 --- a/fs/nilfs2/inode.c +++ b/fs/nilfs2/inode.c | |||
@@ -41,6 +41,24 @@ struct nilfs_iget_args { | |||
41 | int for_gc; | 41 | int for_gc; |
42 | }; | 42 | }; |
43 | 43 | ||
44 | void nilfs_inode_add_blocks(struct inode *inode, int n) | ||
45 | { | ||
46 | struct nilfs_root *root = NILFS_I(inode)->i_root; | ||
47 | |||
48 | inode_add_bytes(inode, (1 << inode->i_blkbits) * n); | ||
49 | if (root) | ||
50 | atomic_add(n, &root->blocks_count); | ||
51 | } | ||
52 | |||
53 | void nilfs_inode_sub_blocks(struct inode *inode, int n) | ||
54 | { | ||
55 | struct nilfs_root *root = NILFS_I(inode)->i_root; | ||
56 | |||
57 | inode_sub_bytes(inode, (1 << inode->i_blkbits) * n); | ||
58 | if (root) | ||
59 | atomic_sub(n, &root->blocks_count); | ||
60 | } | ||
61 | |||
44 | /** | 62 | /** |
45 | * nilfs_get_block() - get a file block on the filesystem (callback function) | 63 | * nilfs_get_block() - get a file block on the filesystem (callback function) |
46 | * @inode - inode struct of the target file | 64 | * @inode - inode struct of the target file |
@@ -277,7 +295,7 @@ const struct address_space_operations nilfs_aops = { | |||
277 | struct inode *nilfs_new_inode(struct inode *dir, int mode) | 295 | struct inode *nilfs_new_inode(struct inode *dir, int mode) |
278 | { | 296 | { |
279 | struct super_block *sb = dir->i_sb; | 297 | struct super_block *sb = dir->i_sb; |
280 | struct nilfs_sb_info *sbi = NILFS_SB(sb); | 298 | struct the_nilfs *nilfs = sb->s_fs_info; |
281 | struct inode *inode; | 299 | struct inode *inode; |
282 | struct nilfs_inode_info *ii; | 300 | struct nilfs_inode_info *ii; |
283 | struct nilfs_root *root; | 301 | struct nilfs_root *root; |
@@ -315,19 +333,16 @@ struct inode *nilfs_new_inode(struct inode *dir, int mode) | |||
315 | /* No lock is needed; iget() ensures it. */ | 333 | /* No lock is needed; iget() ensures it. */ |
316 | } | 334 | } |
317 | 335 | ||
318 | ii->i_flags = NILFS_I(dir)->i_flags; | 336 | ii->i_flags = nilfs_mask_flags( |
319 | if (S_ISLNK(mode)) | 337 | mode, NILFS_I(dir)->i_flags & NILFS_FL_INHERITED); |
320 | ii->i_flags &= ~(NILFS_IMMUTABLE_FL | NILFS_APPEND_FL); | ||
321 | if (!S_ISDIR(mode)) | ||
322 | ii->i_flags &= ~NILFS_DIRSYNC_FL; | ||
323 | 338 | ||
324 | /* ii->i_file_acl = 0; */ | 339 | /* ii->i_file_acl = 0; */ |
325 | /* ii->i_dir_acl = 0; */ | 340 | /* ii->i_dir_acl = 0; */ |
326 | ii->i_dir_start_lookup = 0; | 341 | ii->i_dir_start_lookup = 0; |
327 | nilfs_set_inode_flags(inode); | 342 | nilfs_set_inode_flags(inode); |
328 | spin_lock(&sbi->s_next_gen_lock); | 343 | spin_lock(&nilfs->ns_next_gen_lock); |
329 | inode->i_generation = sbi->s_next_generation++; | 344 | inode->i_generation = nilfs->ns_next_generation++; |
330 | spin_unlock(&sbi->s_next_gen_lock); | 345 | spin_unlock(&nilfs->ns_next_gen_lock); |
331 | insert_inode_hash(inode); | 346 | insert_inode_hash(inode); |
332 | 347 | ||
333 | err = nilfs_init_acl(inode, dir); | 348 | err = nilfs_init_acl(inode, dir); |
@@ -359,17 +374,15 @@ void nilfs_set_inode_flags(struct inode *inode) | |||
359 | 374 | ||
360 | inode->i_flags &= ~(S_SYNC | S_APPEND | S_IMMUTABLE | S_NOATIME | | 375 | inode->i_flags &= ~(S_SYNC | S_APPEND | S_IMMUTABLE | S_NOATIME | |
361 | S_DIRSYNC); | 376 | S_DIRSYNC); |
362 | if (flags & NILFS_SYNC_FL) | 377 | if (flags & FS_SYNC_FL) |
363 | inode->i_flags |= S_SYNC; | 378 | inode->i_flags |= S_SYNC; |
364 | if (flags & NILFS_APPEND_FL) | 379 | if (flags & FS_APPEND_FL) |
365 | inode->i_flags |= S_APPEND; | 380 | inode->i_flags |= S_APPEND; |
366 | if (flags & NILFS_IMMUTABLE_FL) | 381 | if (flags & FS_IMMUTABLE_FL) |
367 | inode->i_flags |= S_IMMUTABLE; | 382 | inode->i_flags |= S_IMMUTABLE; |
368 | #ifndef NILFS_ATIME_DISABLE | 383 | if (flags & FS_NOATIME_FL) |
369 | if (flags & NILFS_NOATIME_FL) | ||
370 | #endif | ||
371 | inode->i_flags |= S_NOATIME; | 384 | inode->i_flags |= S_NOATIME; |
372 | if (flags & NILFS_DIRSYNC_FL) | 385 | if (flags & FS_DIRSYNC_FL) |
373 | inode->i_flags |= S_DIRSYNC; | 386 | inode->i_flags |= S_DIRSYNC; |
374 | mapping_set_gfp_mask(inode->i_mapping, | 387 | mapping_set_gfp_mask(inode->i_mapping, |
375 | mapping_gfp_mask(inode->i_mapping) & ~__GFP_FS); | 388 | mapping_gfp_mask(inode->i_mapping) & ~__GFP_FS); |
@@ -420,7 +433,7 @@ static int __nilfs_read_inode(struct super_block *sb, | |||
420 | struct nilfs_root *root, unsigned long ino, | 433 | struct nilfs_root *root, unsigned long ino, |
421 | struct inode *inode) | 434 | struct inode *inode) |
422 | { | 435 | { |
423 | struct the_nilfs *nilfs = NILFS_SB(sb)->s_nilfs; | 436 | struct the_nilfs *nilfs = sb->s_fs_info; |
424 | struct buffer_head *bh; | 437 | struct buffer_head *bh; |
425 | struct nilfs_inode *raw_inode; | 438 | struct nilfs_inode *raw_inode; |
426 | int err; | 439 | int err; |
@@ -707,6 +720,7 @@ void nilfs_evict_inode(struct inode *inode) | |||
707 | struct nilfs_transaction_info ti; | 720 | struct nilfs_transaction_info ti; |
708 | struct super_block *sb = inode->i_sb; | 721 | struct super_block *sb = inode->i_sb; |
709 | struct nilfs_inode_info *ii = NILFS_I(inode); | 722 | struct nilfs_inode_info *ii = NILFS_I(inode); |
723 | int ret; | ||
710 | 724 | ||
711 | if (inode->i_nlink || !ii->i_root || unlikely(is_bad_inode(inode))) { | 725 | if (inode->i_nlink || !ii->i_root || unlikely(is_bad_inode(inode))) { |
712 | if (inode->i_data.nrpages) | 726 | if (inode->i_data.nrpages) |
@@ -725,8 +739,9 @@ void nilfs_evict_inode(struct inode *inode) | |||
725 | nilfs_mark_inode_dirty(inode); | 739 | nilfs_mark_inode_dirty(inode); |
726 | end_writeback(inode); | 740 | end_writeback(inode); |
727 | 741 | ||
728 | nilfs_ifile_delete_inode(ii->i_root->ifile, inode->i_ino); | 742 | ret = nilfs_ifile_delete_inode(ii->i_root->ifile, inode->i_ino); |
729 | atomic_dec(&ii->i_root->inodes_count); | 743 | if (!ret) |
744 | atomic_dec(&ii->i_root->inodes_count); | ||
730 | 745 | ||
731 | nilfs_clear_inode(inode); | 746 | nilfs_clear_inode(inode); |
732 | 747 | ||
@@ -792,18 +807,18 @@ int nilfs_permission(struct inode *inode, int mask, unsigned int flags) | |||
792 | 807 | ||
793 | int nilfs_load_inode_block(struct inode *inode, struct buffer_head **pbh) | 808 | int nilfs_load_inode_block(struct inode *inode, struct buffer_head **pbh) |
794 | { | 809 | { |
795 | struct nilfs_sb_info *sbi = NILFS_SB(inode->i_sb); | 810 | struct the_nilfs *nilfs = inode->i_sb->s_fs_info; |
796 | struct nilfs_inode_info *ii = NILFS_I(inode); | 811 | struct nilfs_inode_info *ii = NILFS_I(inode); |
797 | int err; | 812 | int err; |
798 | 813 | ||
799 | spin_lock(&sbi->s_inode_lock); | 814 | spin_lock(&nilfs->ns_inode_lock); |
800 | if (ii->i_bh == NULL) { | 815 | if (ii->i_bh == NULL) { |
801 | spin_unlock(&sbi->s_inode_lock); | 816 | spin_unlock(&nilfs->ns_inode_lock); |
802 | err = nilfs_ifile_get_inode_block(ii->i_root->ifile, | 817 | err = nilfs_ifile_get_inode_block(ii->i_root->ifile, |
803 | inode->i_ino, pbh); | 818 | inode->i_ino, pbh); |
804 | if (unlikely(err)) | 819 | if (unlikely(err)) |
805 | return err; | 820 | return err; |
806 | spin_lock(&sbi->s_inode_lock); | 821 | spin_lock(&nilfs->ns_inode_lock); |
807 | if (ii->i_bh == NULL) | 822 | if (ii->i_bh == NULL) |
808 | ii->i_bh = *pbh; | 823 | ii->i_bh = *pbh; |
809 | else { | 824 | else { |
@@ -814,36 +829,36 @@ int nilfs_load_inode_block(struct inode *inode, struct buffer_head **pbh) | |||
814 | *pbh = ii->i_bh; | 829 | *pbh = ii->i_bh; |
815 | 830 | ||
816 | get_bh(*pbh); | 831 | get_bh(*pbh); |
817 | spin_unlock(&sbi->s_inode_lock); | 832 | spin_unlock(&nilfs->ns_inode_lock); |
818 | return 0; | 833 | return 0; |
819 | } | 834 | } |
820 | 835 | ||
821 | int nilfs_inode_dirty(struct inode *inode) | 836 | int nilfs_inode_dirty(struct inode *inode) |
822 | { | 837 | { |
823 | struct nilfs_inode_info *ii = NILFS_I(inode); | 838 | struct nilfs_inode_info *ii = NILFS_I(inode); |
824 | struct nilfs_sb_info *sbi = NILFS_SB(inode->i_sb); | 839 | struct the_nilfs *nilfs = inode->i_sb->s_fs_info; |
825 | int ret = 0; | 840 | int ret = 0; |
826 | 841 | ||
827 | if (!list_empty(&ii->i_dirty)) { | 842 | if (!list_empty(&ii->i_dirty)) { |
828 | spin_lock(&sbi->s_inode_lock); | 843 | spin_lock(&nilfs->ns_inode_lock); |
829 | ret = test_bit(NILFS_I_DIRTY, &ii->i_state) || | 844 | ret = test_bit(NILFS_I_DIRTY, &ii->i_state) || |
830 | test_bit(NILFS_I_BUSY, &ii->i_state); | 845 | test_bit(NILFS_I_BUSY, &ii->i_state); |
831 | spin_unlock(&sbi->s_inode_lock); | 846 | spin_unlock(&nilfs->ns_inode_lock); |
832 | } | 847 | } |
833 | return ret; | 848 | return ret; |
834 | } | 849 | } |
835 | 850 | ||
836 | int nilfs_set_file_dirty(struct inode *inode, unsigned nr_dirty) | 851 | int nilfs_set_file_dirty(struct inode *inode, unsigned nr_dirty) |
837 | { | 852 | { |
838 | struct nilfs_sb_info *sbi = NILFS_SB(inode->i_sb); | ||
839 | struct nilfs_inode_info *ii = NILFS_I(inode); | 853 | struct nilfs_inode_info *ii = NILFS_I(inode); |
854 | struct the_nilfs *nilfs = inode->i_sb->s_fs_info; | ||
840 | 855 | ||
841 | atomic_add(nr_dirty, &sbi->s_nilfs->ns_ndirtyblks); | 856 | atomic_add(nr_dirty, &nilfs->ns_ndirtyblks); |
842 | 857 | ||
843 | if (test_and_set_bit(NILFS_I_DIRTY, &ii->i_state)) | 858 | if (test_and_set_bit(NILFS_I_DIRTY, &ii->i_state)) |
844 | return 0; | 859 | return 0; |
845 | 860 | ||
846 | spin_lock(&sbi->s_inode_lock); | 861 | spin_lock(&nilfs->ns_inode_lock); |
847 | if (!test_bit(NILFS_I_QUEUED, &ii->i_state) && | 862 | if (!test_bit(NILFS_I_QUEUED, &ii->i_state) && |
848 | !test_bit(NILFS_I_BUSY, &ii->i_state)) { | 863 | !test_bit(NILFS_I_BUSY, &ii->i_state)) { |
849 | /* Because this routine may race with nilfs_dispose_list(), | 864 | /* Because this routine may race with nilfs_dispose_list(), |
@@ -851,18 +866,18 @@ int nilfs_set_file_dirty(struct inode *inode, unsigned nr_dirty) | |||
851 | if (list_empty(&ii->i_dirty) && igrab(inode) == NULL) { | 866 | if (list_empty(&ii->i_dirty) && igrab(inode) == NULL) { |
852 | /* This will happen when somebody is freeing | 867 | /* This will happen when somebody is freeing |
853 | this inode. */ | 868 | this inode. */ |
854 | nilfs_warning(sbi->s_super, __func__, | 869 | nilfs_warning(inode->i_sb, __func__, |
855 | "cannot get inode (ino=%lu)\n", | 870 | "cannot get inode (ino=%lu)\n", |
856 | inode->i_ino); | 871 | inode->i_ino); |
857 | spin_unlock(&sbi->s_inode_lock); | 872 | spin_unlock(&nilfs->ns_inode_lock); |
858 | return -EINVAL; /* NILFS_I_DIRTY may remain for | 873 | return -EINVAL; /* NILFS_I_DIRTY may remain for |
859 | freeing inode */ | 874 | freeing inode */ |
860 | } | 875 | } |
861 | list_del(&ii->i_dirty); | 876 | list_del(&ii->i_dirty); |
862 | list_add_tail(&ii->i_dirty, &sbi->s_dirty_files); | 877 | list_add_tail(&ii->i_dirty, &nilfs->ns_dirty_files); |
863 | set_bit(NILFS_I_QUEUED, &ii->i_state); | 878 | set_bit(NILFS_I_QUEUED, &ii->i_state); |
864 | } | 879 | } |
865 | spin_unlock(&sbi->s_inode_lock); | 880 | spin_unlock(&nilfs->ns_inode_lock); |
866 | return 0; | 881 | return 0; |
867 | } | 882 | } |
868 | 883 | ||
diff --git a/fs/nilfs2/ioctl.c b/fs/nilfs2/ioctl.c index 496738963fdb..f2469ba6246b 100644 --- a/fs/nilfs2/ioctl.c +++ b/fs/nilfs2/ioctl.c | |||
@@ -26,7 +26,9 @@ | |||
26 | #include <linux/capability.h> /* capable() */ | 26 | #include <linux/capability.h> /* capable() */ |
27 | #include <linux/uaccess.h> /* copy_from_user(), copy_to_user() */ | 27 | #include <linux/uaccess.h> /* copy_from_user(), copy_to_user() */ |
28 | #include <linux/vmalloc.h> | 28 | #include <linux/vmalloc.h> |
29 | #include <linux/compat.h> /* compat_ptr() */ | ||
29 | #include <linux/mount.h> /* mnt_want_write(), mnt_drop_write() */ | 30 | #include <linux/mount.h> /* mnt_want_write(), mnt_drop_write() */ |
31 | #include <linux/buffer_head.h> | ||
30 | #include <linux/nilfs2_fs.h> | 32 | #include <linux/nilfs2_fs.h> |
31 | #include "nilfs.h" | 33 | #include "nilfs.h" |
32 | #include "segment.h" | 34 | #include "segment.h" |
@@ -97,11 +99,74 @@ static int nilfs_ioctl_wrap_copy(struct the_nilfs *nilfs, | |||
97 | return ret; | 99 | return ret; |
98 | } | 100 | } |
99 | 101 | ||
102 | static int nilfs_ioctl_getflags(struct inode *inode, void __user *argp) | ||
103 | { | ||
104 | unsigned int flags = NILFS_I(inode)->i_flags & FS_FL_USER_VISIBLE; | ||
105 | |||
106 | return put_user(flags, (int __user *)argp); | ||
107 | } | ||
108 | |||
109 | static int nilfs_ioctl_setflags(struct inode *inode, struct file *filp, | ||
110 | void __user *argp) | ||
111 | { | ||
112 | struct nilfs_transaction_info ti; | ||
113 | unsigned int flags, oldflags; | ||
114 | int ret; | ||
115 | |||
116 | if (!inode_owner_or_capable(inode)) | ||
117 | return -EACCES; | ||
118 | |||
119 | if (get_user(flags, (int __user *)argp)) | ||
120 | return -EFAULT; | ||
121 | |||
122 | ret = mnt_want_write(filp->f_path.mnt); | ||
123 | if (ret) | ||
124 | return ret; | ||
125 | |||
126 | flags = nilfs_mask_flags(inode->i_mode, flags); | ||
127 | |||
128 | mutex_lock(&inode->i_mutex); | ||
129 | |||
130 | oldflags = NILFS_I(inode)->i_flags; | ||
131 | |||
132 | /* | ||
133 | * The IMMUTABLE and APPEND_ONLY flags can only be changed by the | ||
134 | * relevant capability. | ||
135 | */ | ||
136 | ret = -EPERM; | ||
137 | if (((flags ^ oldflags) & (FS_APPEND_FL | FS_IMMUTABLE_FL)) && | ||
138 | !capable(CAP_LINUX_IMMUTABLE)) | ||
139 | goto out; | ||
140 | |||
141 | ret = nilfs_transaction_begin(inode->i_sb, &ti, 0); | ||
142 | if (ret) | ||
143 | goto out; | ||
144 | |||
145 | NILFS_I(inode)->i_flags = (oldflags & ~FS_FL_USER_MODIFIABLE) | | ||
146 | (flags & FS_FL_USER_MODIFIABLE); | ||
147 | |||
148 | nilfs_set_inode_flags(inode); | ||
149 | inode->i_ctime = CURRENT_TIME; | ||
150 | if (IS_SYNC(inode)) | ||
151 | nilfs_set_transaction_flag(NILFS_TI_SYNC); | ||
152 | |||
153 | nilfs_mark_inode_dirty(inode); | ||
154 | ret = nilfs_transaction_commit(inode->i_sb); | ||
155 | out: | ||
156 | mutex_unlock(&inode->i_mutex); | ||
157 | mnt_drop_write(filp->f_path.mnt); | ||
158 | return ret; | ||
159 | } | ||
160 | |||
161 | static int nilfs_ioctl_getversion(struct inode *inode, void __user *argp) | ||
162 | { | ||
163 | return put_user(inode->i_generation, (int __user *)argp); | ||
164 | } | ||
165 | |||
100 | static int nilfs_ioctl_change_cpmode(struct inode *inode, struct file *filp, | 166 | static int nilfs_ioctl_change_cpmode(struct inode *inode, struct file *filp, |
101 | unsigned int cmd, void __user *argp) | 167 | unsigned int cmd, void __user *argp) |
102 | { | 168 | { |
103 | struct the_nilfs *nilfs = NILFS_SB(inode->i_sb)->s_nilfs; | 169 | struct the_nilfs *nilfs = inode->i_sb->s_fs_info; |
104 | struct inode *cpfile = nilfs->ns_cpfile; | ||
105 | struct nilfs_transaction_info ti; | 170 | struct nilfs_transaction_info ti; |
106 | struct nilfs_cpmode cpmode; | 171 | struct nilfs_cpmode cpmode; |
107 | int ret; | 172 | int ret; |
@@ -121,7 +186,7 @@ static int nilfs_ioctl_change_cpmode(struct inode *inode, struct file *filp, | |||
121 | 186 | ||
122 | nilfs_transaction_begin(inode->i_sb, &ti, 0); | 187 | nilfs_transaction_begin(inode->i_sb, &ti, 0); |
123 | ret = nilfs_cpfile_change_cpmode( | 188 | ret = nilfs_cpfile_change_cpmode( |
124 | cpfile, cpmode.cm_cno, cpmode.cm_mode); | 189 | nilfs->ns_cpfile, cpmode.cm_cno, cpmode.cm_mode); |
125 | if (unlikely(ret < 0)) | 190 | if (unlikely(ret < 0)) |
126 | nilfs_transaction_abort(inode->i_sb); | 191 | nilfs_transaction_abort(inode->i_sb); |
127 | else | 192 | else |
@@ -137,7 +202,7 @@ static int | |||
137 | nilfs_ioctl_delete_checkpoint(struct inode *inode, struct file *filp, | 202 | nilfs_ioctl_delete_checkpoint(struct inode *inode, struct file *filp, |
138 | unsigned int cmd, void __user *argp) | 203 | unsigned int cmd, void __user *argp) |
139 | { | 204 | { |
140 | struct inode *cpfile = NILFS_SB(inode->i_sb)->s_nilfs->ns_cpfile; | 205 | struct the_nilfs *nilfs = inode->i_sb->s_fs_info; |
141 | struct nilfs_transaction_info ti; | 206 | struct nilfs_transaction_info ti; |
142 | __u64 cno; | 207 | __u64 cno; |
143 | int ret; | 208 | int ret; |
@@ -154,7 +219,7 @@ nilfs_ioctl_delete_checkpoint(struct inode *inode, struct file *filp, | |||
154 | goto out; | 219 | goto out; |
155 | 220 | ||
156 | nilfs_transaction_begin(inode->i_sb, &ti, 0); | 221 | nilfs_transaction_begin(inode->i_sb, &ti, 0); |
157 | ret = nilfs_cpfile_delete_checkpoint(cpfile, cno); | 222 | ret = nilfs_cpfile_delete_checkpoint(nilfs->ns_cpfile, cno); |
158 | if (unlikely(ret < 0)) | 223 | if (unlikely(ret < 0)) |
159 | nilfs_transaction_abort(inode->i_sb); | 224 | nilfs_transaction_abort(inode->i_sb); |
160 | else | 225 | else |
@@ -180,7 +245,7 @@ nilfs_ioctl_do_get_cpinfo(struct the_nilfs *nilfs, __u64 *posp, int flags, | |||
180 | static int nilfs_ioctl_get_cpstat(struct inode *inode, struct file *filp, | 245 | static int nilfs_ioctl_get_cpstat(struct inode *inode, struct file *filp, |
181 | unsigned int cmd, void __user *argp) | 246 | unsigned int cmd, void __user *argp) |
182 | { | 247 | { |
183 | struct the_nilfs *nilfs = NILFS_SB(inode->i_sb)->s_nilfs; | 248 | struct the_nilfs *nilfs = inode->i_sb->s_fs_info; |
184 | struct nilfs_cpstat cpstat; | 249 | struct nilfs_cpstat cpstat; |
185 | int ret; | 250 | int ret; |
186 | 251 | ||
@@ -211,7 +276,7 @@ nilfs_ioctl_do_get_suinfo(struct the_nilfs *nilfs, __u64 *posp, int flags, | |||
211 | static int nilfs_ioctl_get_sustat(struct inode *inode, struct file *filp, | 276 | static int nilfs_ioctl_get_sustat(struct inode *inode, struct file *filp, |
212 | unsigned int cmd, void __user *argp) | 277 | unsigned int cmd, void __user *argp) |
213 | { | 278 | { |
214 | struct the_nilfs *nilfs = NILFS_SB(inode->i_sb)->s_nilfs; | 279 | struct the_nilfs *nilfs = inode->i_sb->s_fs_info; |
215 | struct nilfs_sustat sustat; | 280 | struct nilfs_sustat sustat; |
216 | int ret; | 281 | int ret; |
217 | 282 | ||
@@ -267,7 +332,7 @@ nilfs_ioctl_do_get_bdescs(struct the_nilfs *nilfs, __u64 *posp, int flags, | |||
267 | static int nilfs_ioctl_get_bdescs(struct inode *inode, struct file *filp, | 332 | static int nilfs_ioctl_get_bdescs(struct inode *inode, struct file *filp, |
268 | unsigned int cmd, void __user *argp) | 333 | unsigned int cmd, void __user *argp) |
269 | { | 334 | { |
270 | struct the_nilfs *nilfs = NILFS_SB(inode->i_sb)->s_nilfs; | 335 | struct the_nilfs *nilfs = inode->i_sb->s_fs_info; |
271 | struct nilfs_argv argv; | 336 | struct nilfs_argv argv; |
272 | int ret; | 337 | int ret; |
273 | 338 | ||
@@ -336,7 +401,7 @@ static int nilfs_ioctl_move_blocks(struct super_block *sb, | |||
336 | struct nilfs_argv *argv, void *buf) | 401 | struct nilfs_argv *argv, void *buf) |
337 | { | 402 | { |
338 | size_t nmembs = argv->v_nmembs; | 403 | size_t nmembs = argv->v_nmembs; |
339 | struct the_nilfs *nilfs = NILFS_SB(sb)->s_nilfs; | 404 | struct the_nilfs *nilfs = sb->s_fs_info; |
340 | struct inode *inode; | 405 | struct inode *inode; |
341 | struct nilfs_vdesc *vdesc; | 406 | struct nilfs_vdesc *vdesc; |
342 | struct buffer_head *bh, *n; | 407 | struct buffer_head *bh, *n; |
@@ -550,7 +615,7 @@ static int nilfs_ioctl_clean_segments(struct inode *inode, struct file *filp, | |||
550 | ret = PTR_ERR(kbufs[4]); | 615 | ret = PTR_ERR(kbufs[4]); |
551 | goto out; | 616 | goto out; |
552 | } | 617 | } |
553 | nilfs = NILFS_SB(inode->i_sb)->s_nilfs; | 618 | nilfs = inode->i_sb->s_fs_info; |
554 | 619 | ||
555 | for (n = 0; n < 4; n++) { | 620 | for (n = 0; n < 4; n++) { |
556 | ret = -EINVAL; | 621 | ret = -EINVAL; |
@@ -623,7 +688,7 @@ static int nilfs_ioctl_sync(struct inode *inode, struct file *filp, | |||
623 | return ret; | 688 | return ret; |
624 | 689 | ||
625 | if (argp != NULL) { | 690 | if (argp != NULL) { |
626 | nilfs = NILFS_SB(inode->i_sb)->s_nilfs; | 691 | nilfs = inode->i_sb->s_fs_info; |
627 | down_read(&nilfs->ns_segctor_sem); | 692 | down_read(&nilfs->ns_segctor_sem); |
628 | cno = nilfs->ns_cno - 1; | 693 | cno = nilfs->ns_cno - 1; |
629 | up_read(&nilfs->ns_segctor_sem); | 694 | up_read(&nilfs->ns_segctor_sem); |
@@ -641,7 +706,7 @@ static int nilfs_ioctl_get_info(struct inode *inode, struct file *filp, | |||
641 | void *, size_t, size_t)) | 706 | void *, size_t, size_t)) |
642 | 707 | ||
643 | { | 708 | { |
644 | struct the_nilfs *nilfs = NILFS_SB(inode->i_sb)->s_nilfs; | 709 | struct the_nilfs *nilfs = inode->i_sb->s_fs_info; |
645 | struct nilfs_argv argv; | 710 | struct nilfs_argv argv; |
646 | int ret; | 711 | int ret; |
647 | 712 | ||
@@ -666,6 +731,12 @@ long nilfs_ioctl(struct file *filp, unsigned int cmd, unsigned long arg) | |||
666 | void __user *argp = (void __user *)arg; | 731 | void __user *argp = (void __user *)arg; |
667 | 732 | ||
668 | switch (cmd) { | 733 | switch (cmd) { |
734 | case FS_IOC_GETFLAGS: | ||
735 | return nilfs_ioctl_getflags(inode, argp); | ||
736 | case FS_IOC_SETFLAGS: | ||
737 | return nilfs_ioctl_setflags(inode, filp, argp); | ||
738 | case FS_IOC_GETVERSION: | ||
739 | return nilfs_ioctl_getversion(inode, argp); | ||
669 | case NILFS_IOCTL_CHANGE_CPMODE: | 740 | case NILFS_IOCTL_CHANGE_CPMODE: |
670 | return nilfs_ioctl_change_cpmode(inode, filp, cmd, argp); | 741 | return nilfs_ioctl_change_cpmode(inode, filp, cmd, argp); |
671 | case NILFS_IOCTL_DELETE_CHECKPOINT: | 742 | case NILFS_IOCTL_DELETE_CHECKPOINT: |
@@ -696,3 +767,23 @@ long nilfs_ioctl(struct file *filp, unsigned int cmd, unsigned long arg) | |||
696 | return -ENOTTY; | 767 | return -ENOTTY; |
697 | } | 768 | } |
698 | } | 769 | } |
770 | |||
771 | #ifdef CONFIG_COMPAT | ||
772 | long nilfs_compat_ioctl(struct file *filp, unsigned int cmd, unsigned long arg) | ||
773 | { | ||
774 | switch (cmd) { | ||
775 | case FS_IOC32_GETFLAGS: | ||
776 | cmd = FS_IOC_GETFLAGS; | ||
777 | break; | ||
778 | case FS_IOC32_SETFLAGS: | ||
779 | cmd = FS_IOC_SETFLAGS; | ||
780 | break; | ||
781 | case FS_IOC32_GETVERSION: | ||
782 | cmd = FS_IOC_GETVERSION; | ||
783 | break; | ||
784 | default: | ||
785 | return -ENOIOCTLCMD; | ||
786 | } | ||
787 | return nilfs_ioctl(filp, cmd, (unsigned long)compat_ptr(arg)); | ||
788 | } | ||
789 | #endif | ||
diff --git a/fs/nilfs2/mdt.h b/fs/nilfs2/mdt.h index b13734bf3521..ed68563ec708 100644 --- a/fs/nilfs2/mdt.h +++ b/fs/nilfs2/mdt.h | |||
@@ -66,7 +66,7 @@ static inline struct nilfs_mdt_info *NILFS_MDT(const struct inode *inode) | |||
66 | 66 | ||
67 | static inline struct the_nilfs *NILFS_I_NILFS(struct inode *inode) | 67 | static inline struct the_nilfs *NILFS_I_NILFS(struct inode *inode) |
68 | { | 68 | { |
69 | return NILFS_SB(inode->i_sb)->s_nilfs; | 69 | return inode->i_sb->s_fs_info; |
70 | } | 70 | } |
71 | 71 | ||
72 | /* Default GFP flags using highmem */ | 72 | /* Default GFP flags using highmem */ |
diff --git a/fs/nilfs2/namei.c b/fs/nilfs2/namei.c index 161791d26458..546849b3e88f 100644 --- a/fs/nilfs2/namei.c +++ b/fs/nilfs2/namei.c | |||
@@ -482,7 +482,7 @@ static struct dentry *nilfs_get_dentry(struct super_block *sb, u64 cno, | |||
482 | if (ino < NILFS_FIRST_INO(sb) && ino != NILFS_ROOT_INO) | 482 | if (ino < NILFS_FIRST_INO(sb) && ino != NILFS_ROOT_INO) |
483 | return ERR_PTR(-ESTALE); | 483 | return ERR_PTR(-ESTALE); |
484 | 484 | ||
485 | root = nilfs_lookup_root(NILFS_SB(sb)->s_nilfs, cno); | 485 | root = nilfs_lookup_root(sb->s_fs_info, cno); |
486 | if (!root) | 486 | if (!root) |
487 | return ERR_PTR(-ESTALE); | 487 | return ERR_PTR(-ESTALE); |
488 | 488 | ||
diff --git a/fs/nilfs2/nilfs.h b/fs/nilfs2/nilfs.h index 777e8fd04304..856e8e4e0b74 100644 --- a/fs/nilfs2/nilfs.h +++ b/fs/nilfs2/nilfs.h | |||
@@ -30,7 +30,6 @@ | |||
30 | #include <linux/blkdev.h> | 30 | #include <linux/blkdev.h> |
31 | #include <linux/nilfs2_fs.h> | 31 | #include <linux/nilfs2_fs.h> |
32 | #include "the_nilfs.h" | 32 | #include "the_nilfs.h" |
33 | #include "sb.h" | ||
34 | #include "bmap.h" | 33 | #include "bmap.h" |
35 | 34 | ||
36 | /* | 35 | /* |
@@ -122,7 +121,7 @@ enum { | |||
122 | #define NILFS_SYS_INO_BITS \ | 121 | #define NILFS_SYS_INO_BITS \ |
123 | ((unsigned int)(1 << NILFS_ROOT_INO) | NILFS_MDT_INO_BITS) | 122 | ((unsigned int)(1 << NILFS_ROOT_INO) | NILFS_MDT_INO_BITS) |
124 | 123 | ||
125 | #define NILFS_FIRST_INO(sb) (NILFS_SB(sb)->s_nilfs->ns_first_ino) | 124 | #define NILFS_FIRST_INO(sb) (((struct the_nilfs *)sb->s_fs_info)->ns_first_ino) |
126 | 125 | ||
127 | #define NILFS_MDT_INODE(sb, ino) \ | 126 | #define NILFS_MDT_INODE(sb, ino) \ |
128 | ((ino) < NILFS_FIRST_INO(sb) && (NILFS_MDT_INO_BITS & (1 << (ino)))) | 127 | ((ino) < NILFS_FIRST_INO(sb) && (NILFS_MDT_INO_BITS & (1 << (ino)))) |
@@ -212,6 +211,23 @@ static inline int nilfs_init_acl(struct inode *inode, struct inode *dir) | |||
212 | 211 | ||
213 | #define NILFS_ATIME_DISABLE | 212 | #define NILFS_ATIME_DISABLE |
214 | 213 | ||
214 | /* Flags that should be inherited by new inodes from their parent. */ | ||
215 | #define NILFS_FL_INHERITED \ | ||
216 | (FS_SECRM_FL | FS_UNRM_FL | FS_COMPR_FL | FS_SYNC_FL | \ | ||
217 | FS_IMMUTABLE_FL | FS_APPEND_FL | FS_NODUMP_FL | FS_NOATIME_FL |\ | ||
218 | FS_COMPRBLK_FL | FS_NOCOMP_FL | FS_NOTAIL_FL | FS_DIRSYNC_FL) | ||
219 | |||
220 | /* Mask out flags that are inappropriate for the given type of inode. */ | ||
221 | static inline __u32 nilfs_mask_flags(umode_t mode, __u32 flags) | ||
222 | { | ||
223 | if (S_ISDIR(mode)) | ||
224 | return flags; | ||
225 | else if (S_ISREG(mode)) | ||
226 | return flags & ~(FS_DIRSYNC_FL | FS_TOPDIR_FL); | ||
227 | else | ||
228 | return flags & (FS_NODUMP_FL | FS_NOATIME_FL); | ||
229 | } | ||
230 | |||
215 | /* dir.c */ | 231 | /* dir.c */ |
216 | extern int nilfs_add_link(struct dentry *, struct inode *); | 232 | extern int nilfs_add_link(struct dentry *, struct inode *); |
217 | extern ino_t nilfs_inode_by_name(struct inode *, const struct qstr *); | 233 | extern ino_t nilfs_inode_by_name(struct inode *, const struct qstr *); |
@@ -229,10 +245,13 @@ extern int nilfs_sync_file(struct file *, int); | |||
229 | 245 | ||
230 | /* ioctl.c */ | 246 | /* ioctl.c */ |
231 | long nilfs_ioctl(struct file *, unsigned int, unsigned long); | 247 | long nilfs_ioctl(struct file *, unsigned int, unsigned long); |
248 | long nilfs_compat_ioctl(struct file *file, unsigned int cmd, unsigned long arg); | ||
232 | int nilfs_ioctl_prepare_clean_segments(struct the_nilfs *, struct nilfs_argv *, | 249 | int nilfs_ioctl_prepare_clean_segments(struct the_nilfs *, struct nilfs_argv *, |
233 | void **); | 250 | void **); |
234 | 251 | ||
235 | /* inode.c */ | 252 | /* inode.c */ |
253 | void nilfs_inode_add_blocks(struct inode *inode, int n); | ||
254 | void nilfs_inode_sub_blocks(struct inode *inode, int n); | ||
236 | extern struct inode *nilfs_new_inode(struct inode *, int); | 255 | extern struct inode *nilfs_new_inode(struct inode *, int); |
237 | extern void nilfs_free_inode(struct inode *); | 256 | extern void nilfs_free_inode(struct inode *); |
238 | extern int nilfs_get_block(struct inode *, sector_t, struct buffer_head *, int); | 257 | extern int nilfs_get_block(struct inode *, sector_t, struct buffer_head *, int); |
@@ -275,11 +294,11 @@ extern int nilfs_check_feature_compatibility(struct super_block *, | |||
275 | struct nilfs_super_block *); | 294 | struct nilfs_super_block *); |
276 | extern void nilfs_set_log_cursor(struct nilfs_super_block *, | 295 | extern void nilfs_set_log_cursor(struct nilfs_super_block *, |
277 | struct the_nilfs *); | 296 | struct the_nilfs *); |
278 | extern struct nilfs_super_block **nilfs_prepare_super(struct nilfs_sb_info *, | 297 | struct nilfs_super_block **nilfs_prepare_super(struct super_block *sb, |
279 | int flip); | 298 | int flip); |
280 | extern int nilfs_commit_super(struct nilfs_sb_info *, int); | 299 | int nilfs_commit_super(struct super_block *sb, int flag); |
281 | extern int nilfs_cleanup_super(struct nilfs_sb_info *); | 300 | int nilfs_cleanup_super(struct super_block *sb); |
282 | int nilfs_attach_checkpoint(struct nilfs_sb_info *sbi, __u64 cno, int curr_mnt, | 301 | int nilfs_attach_checkpoint(struct super_block *sb, __u64 cno, int curr_mnt, |
283 | struct nilfs_root **root); | 302 | struct nilfs_root **root); |
284 | int nilfs_checkpoint_is_mounted(struct super_block *sb, __u64 cno); | 303 | int nilfs_checkpoint_is_mounted(struct super_block *sb, __u64 cno); |
285 | 304 | ||
diff --git a/fs/nilfs2/recovery.c b/fs/nilfs2/recovery.c index 3dfcd3b7d389..ba4a64518f38 100644 --- a/fs/nilfs2/recovery.c +++ b/fs/nilfs2/recovery.c | |||
@@ -425,7 +425,7 @@ void nilfs_dispose_segment_list(struct list_head *head) | |||
425 | } | 425 | } |
426 | 426 | ||
427 | static int nilfs_prepare_segment_for_recovery(struct the_nilfs *nilfs, | 427 | static int nilfs_prepare_segment_for_recovery(struct the_nilfs *nilfs, |
428 | struct nilfs_sb_info *sbi, | 428 | struct super_block *sb, |
429 | struct nilfs_recovery_info *ri) | 429 | struct nilfs_recovery_info *ri) |
430 | { | 430 | { |
431 | struct list_head *head = &ri->ri_used_segments; | 431 | struct list_head *head = &ri->ri_used_segments; |
@@ -501,7 +501,7 @@ static int nilfs_recovery_copy_block(struct the_nilfs *nilfs, | |||
501 | } | 501 | } |
502 | 502 | ||
503 | static int nilfs_recover_dsync_blocks(struct the_nilfs *nilfs, | 503 | static int nilfs_recover_dsync_blocks(struct the_nilfs *nilfs, |
504 | struct nilfs_sb_info *sbi, | 504 | struct super_block *sb, |
505 | struct nilfs_root *root, | 505 | struct nilfs_root *root, |
506 | struct list_head *head, | 506 | struct list_head *head, |
507 | unsigned long *nr_salvaged_blocks) | 507 | unsigned long *nr_salvaged_blocks) |
@@ -514,7 +514,7 @@ static int nilfs_recover_dsync_blocks(struct the_nilfs *nilfs, | |||
514 | int err = 0, err2 = 0; | 514 | int err = 0, err2 = 0; |
515 | 515 | ||
516 | list_for_each_entry_safe(rb, n, head, list) { | 516 | list_for_each_entry_safe(rb, n, head, list) { |
517 | inode = nilfs_iget(sbi->s_super, root, rb->ino); | 517 | inode = nilfs_iget(sb, root, rb->ino); |
518 | if (IS_ERR(inode)) { | 518 | if (IS_ERR(inode)) { |
519 | err = PTR_ERR(inode); | 519 | err = PTR_ERR(inode); |
520 | inode = NULL; | 520 | inode = NULL; |
@@ -572,11 +572,11 @@ static int nilfs_recover_dsync_blocks(struct the_nilfs *nilfs, | |||
572 | * nilfs_do_roll_forward - salvage logical segments newer than the latest | 572 | * nilfs_do_roll_forward - salvage logical segments newer than the latest |
573 | * checkpoint | 573 | * checkpoint |
574 | * @nilfs: nilfs object | 574 | * @nilfs: nilfs object |
575 | * @sbi: nilfs_sb_info | 575 | * @sb: super block instance |
576 | * @ri: pointer to a nilfs_recovery_info | 576 | * @ri: pointer to a nilfs_recovery_info |
577 | */ | 577 | */ |
578 | static int nilfs_do_roll_forward(struct the_nilfs *nilfs, | 578 | static int nilfs_do_roll_forward(struct the_nilfs *nilfs, |
579 | struct nilfs_sb_info *sbi, | 579 | struct super_block *sb, |
580 | struct nilfs_root *root, | 580 | struct nilfs_root *root, |
581 | struct nilfs_recovery_info *ri) | 581 | struct nilfs_recovery_info *ri) |
582 | { | 582 | { |
@@ -648,7 +648,7 @@ static int nilfs_do_roll_forward(struct the_nilfs *nilfs, | |||
648 | goto failed; | 648 | goto failed; |
649 | if (flags & NILFS_SS_LOGEND) { | 649 | if (flags & NILFS_SS_LOGEND) { |
650 | err = nilfs_recover_dsync_blocks( | 650 | err = nilfs_recover_dsync_blocks( |
651 | nilfs, sbi, root, &dsync_blocks, | 651 | nilfs, sb, root, &dsync_blocks, |
652 | &nsalvaged_blocks); | 652 | &nsalvaged_blocks); |
653 | if (unlikely(err)) | 653 | if (unlikely(err)) |
654 | goto failed; | 654 | goto failed; |
@@ -681,7 +681,7 @@ static int nilfs_do_roll_forward(struct the_nilfs *nilfs, | |||
681 | 681 | ||
682 | if (nsalvaged_blocks) { | 682 | if (nsalvaged_blocks) { |
683 | printk(KERN_INFO "NILFS (device %s): salvaged %lu blocks\n", | 683 | printk(KERN_INFO "NILFS (device %s): salvaged %lu blocks\n", |
684 | sbi->s_super->s_id, nsalvaged_blocks); | 684 | sb->s_id, nsalvaged_blocks); |
685 | ri->ri_need_recovery = NILFS_RECOVERY_ROLLFORWARD_DONE; | 685 | ri->ri_need_recovery = NILFS_RECOVERY_ROLLFORWARD_DONE; |
686 | } | 686 | } |
687 | out: | 687 | out: |
@@ -695,7 +695,7 @@ static int nilfs_do_roll_forward(struct the_nilfs *nilfs, | |||
695 | printk(KERN_ERR | 695 | printk(KERN_ERR |
696 | "NILFS (device %s): Error roll-forwarding " | 696 | "NILFS (device %s): Error roll-forwarding " |
697 | "(err=%d, pseg block=%llu). ", | 697 | "(err=%d, pseg block=%llu). ", |
698 | sbi->s_super->s_id, err, (unsigned long long)pseg_start); | 698 | sb->s_id, err, (unsigned long long)pseg_start); |
699 | goto out; | 699 | goto out; |
700 | } | 700 | } |
701 | 701 | ||
@@ -724,7 +724,7 @@ static void nilfs_finish_roll_forward(struct the_nilfs *nilfs, | |||
724 | /** | 724 | /** |
725 | * nilfs_salvage_orphan_logs - salvage logs written after the latest checkpoint | 725 | * nilfs_salvage_orphan_logs - salvage logs written after the latest checkpoint |
726 | * @nilfs: nilfs object | 726 | * @nilfs: nilfs object |
727 | * @sbi: nilfs_sb_info | 727 | * @sb: super block instance |
728 | * @ri: pointer to a nilfs_recovery_info struct to store search results. | 728 | * @ri: pointer to a nilfs_recovery_info struct to store search results. |
729 | * | 729 | * |
730 | * Return Value: On success, 0 is returned. On error, one of the following | 730 | * Return Value: On success, 0 is returned. On error, one of the following |
@@ -741,7 +741,7 @@ static void nilfs_finish_roll_forward(struct the_nilfs *nilfs, | |||
741 | * %-ENOMEM - Insufficient memory available. | 741 | * %-ENOMEM - Insufficient memory available. |
742 | */ | 742 | */ |
743 | int nilfs_salvage_orphan_logs(struct the_nilfs *nilfs, | 743 | int nilfs_salvage_orphan_logs(struct the_nilfs *nilfs, |
744 | struct nilfs_sb_info *sbi, | 744 | struct super_block *sb, |
745 | struct nilfs_recovery_info *ri) | 745 | struct nilfs_recovery_info *ri) |
746 | { | 746 | { |
747 | struct nilfs_root *root; | 747 | struct nilfs_root *root; |
@@ -750,32 +750,32 @@ int nilfs_salvage_orphan_logs(struct the_nilfs *nilfs, | |||
750 | if (ri->ri_lsegs_start == 0 || ri->ri_lsegs_end == 0) | 750 | if (ri->ri_lsegs_start == 0 || ri->ri_lsegs_end == 0) |
751 | return 0; | 751 | return 0; |
752 | 752 | ||
753 | err = nilfs_attach_checkpoint(sbi, ri->ri_cno, true, &root); | 753 | err = nilfs_attach_checkpoint(sb, ri->ri_cno, true, &root); |
754 | if (unlikely(err)) { | 754 | if (unlikely(err)) { |
755 | printk(KERN_ERR | 755 | printk(KERN_ERR |
756 | "NILFS: error loading the latest checkpoint.\n"); | 756 | "NILFS: error loading the latest checkpoint.\n"); |
757 | return err; | 757 | return err; |
758 | } | 758 | } |
759 | 759 | ||
760 | err = nilfs_do_roll_forward(nilfs, sbi, root, ri); | 760 | err = nilfs_do_roll_forward(nilfs, sb, root, ri); |
761 | if (unlikely(err)) | 761 | if (unlikely(err)) |
762 | goto failed; | 762 | goto failed; |
763 | 763 | ||
764 | if (ri->ri_need_recovery == NILFS_RECOVERY_ROLLFORWARD_DONE) { | 764 | if (ri->ri_need_recovery == NILFS_RECOVERY_ROLLFORWARD_DONE) { |
765 | err = nilfs_prepare_segment_for_recovery(nilfs, sbi, ri); | 765 | err = nilfs_prepare_segment_for_recovery(nilfs, sb, ri); |
766 | if (unlikely(err)) { | 766 | if (unlikely(err)) { |
767 | printk(KERN_ERR "NILFS: Error preparing segments for " | 767 | printk(KERN_ERR "NILFS: Error preparing segments for " |
768 | "recovery.\n"); | 768 | "recovery.\n"); |
769 | goto failed; | 769 | goto failed; |
770 | } | 770 | } |
771 | 771 | ||
772 | err = nilfs_attach_segment_constructor(sbi, root); | 772 | err = nilfs_attach_log_writer(sb, root); |
773 | if (unlikely(err)) | 773 | if (unlikely(err)) |
774 | goto failed; | 774 | goto failed; |
775 | 775 | ||
776 | set_nilfs_discontinued(nilfs); | 776 | set_nilfs_discontinued(nilfs); |
777 | err = nilfs_construct_segment(sbi->s_super); | 777 | err = nilfs_construct_segment(sb); |
778 | nilfs_detach_segment_constructor(sbi); | 778 | nilfs_detach_log_writer(sb); |
779 | 779 | ||
780 | if (unlikely(err)) { | 780 | if (unlikely(err)) { |
781 | printk(KERN_ERR "NILFS: Oops! recovery failed. " | 781 | printk(KERN_ERR "NILFS: Oops! recovery failed. " |
diff --git a/fs/nilfs2/sb.h b/fs/nilfs2/sb.h deleted file mode 100644 index 7a17715f215f..000000000000 --- a/fs/nilfs2/sb.h +++ /dev/null | |||
@@ -1,85 +0,0 @@ | |||
1 | /* | ||
2 | * sb.h - NILFS on-memory super block structure. | ||
3 | * | ||
4 | * Copyright (C) 2005-2008 Nippon Telegraph and Telephone Corporation. | ||
5 | * | ||
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 | ||
8 | * the Free Software Foundation; either version 2 of the License, or | ||
9 | * (at your option) any later version. | ||
10 | * | ||
11 | * This program is distributed in the hope that it will be useful, | ||
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
14 | * GNU General Public License for more details. | ||
15 | * | ||
16 | * You should have received a copy of the GNU General Public License | ||
17 | * along with this program; if not, write to the Free Software | ||
18 | * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA | ||
19 | * | ||
20 | * Written by Ryusuke Konishi <ryusuke@osrg.net> | ||
21 | * | ||
22 | */ | ||
23 | |||
24 | #ifndef _NILFS_SB | ||
25 | #define _NILFS_SB | ||
26 | |||
27 | #include <linux/types.h> | ||
28 | #include <linux/fs.h> | ||
29 | |||
30 | struct the_nilfs; | ||
31 | struct nilfs_sc_info; | ||
32 | |||
33 | /* | ||
34 | * NILFS super-block data in memory | ||
35 | */ | ||
36 | struct nilfs_sb_info { | ||
37 | /* Mount options */ | ||
38 | unsigned long s_mount_opt; | ||
39 | uid_t s_resuid; | ||
40 | gid_t s_resgid; | ||
41 | |||
42 | unsigned long s_interval; /* construction interval */ | ||
43 | unsigned long s_watermark; /* threshold of data amount | ||
44 | for the segment construction */ | ||
45 | |||
46 | /* Fundamental members */ | ||
47 | struct super_block *s_super; /* reverse pointer to super_block */ | ||
48 | struct the_nilfs *s_nilfs; | ||
49 | |||
50 | /* Segment constructor */ | ||
51 | struct list_head s_dirty_files; /* dirty files list */ | ||
52 | struct nilfs_sc_info *s_sc_info; /* segment constructor info */ | ||
53 | spinlock_t s_inode_lock; /* Lock for the nilfs inode. | ||
54 | It covers s_dirty_files list */ | ||
55 | |||
56 | /* Inode allocator */ | ||
57 | spinlock_t s_next_gen_lock; | ||
58 | u32 s_next_generation; | ||
59 | }; | ||
60 | |||
61 | static inline struct nilfs_sb_info *NILFS_SB(struct super_block *sb) | ||
62 | { | ||
63 | return sb->s_fs_info; | ||
64 | } | ||
65 | |||
66 | static inline struct nilfs_sc_info *NILFS_SC(struct nilfs_sb_info *sbi) | ||
67 | { | ||
68 | return sbi->s_sc_info; | ||
69 | } | ||
70 | |||
71 | /* | ||
72 | * Bit operations for the mount option | ||
73 | */ | ||
74 | #define nilfs_clear_opt(sbi, opt) \ | ||
75 | do { (sbi)->s_mount_opt &= ~NILFS_MOUNT_##opt; } while (0) | ||
76 | #define nilfs_set_opt(sbi, opt) \ | ||
77 | do { (sbi)->s_mount_opt |= NILFS_MOUNT_##opt; } while (0) | ||
78 | #define nilfs_test_opt(sbi, opt) ((sbi)->s_mount_opt & NILFS_MOUNT_##opt) | ||
79 | #define nilfs_write_opt(sbi, mask, opt) \ | ||
80 | do { (sbi)->s_mount_opt = \ | ||
81 | (((sbi)->s_mount_opt & ~NILFS_MOUNT_##mask) | \ | ||
82 | NILFS_MOUNT_##opt); \ | ||
83 | } while (0) | ||
84 | |||
85 | #endif /* _NILFS_SB */ | ||
diff --git a/fs/nilfs2/segment.c b/fs/nilfs2/segment.c index 2de9f636792a..afe4f2183454 100644 --- a/fs/nilfs2/segment.c +++ b/fs/nilfs2/segment.c | |||
@@ -104,8 +104,7 @@ struct nilfs_sc_operations { | |||
104 | static void nilfs_segctor_start_timer(struct nilfs_sc_info *); | 104 | static void nilfs_segctor_start_timer(struct nilfs_sc_info *); |
105 | static void nilfs_segctor_do_flush(struct nilfs_sc_info *, int); | 105 | static void nilfs_segctor_do_flush(struct nilfs_sc_info *, int); |
106 | static void nilfs_segctor_do_immediate_flush(struct nilfs_sc_info *); | 106 | static void nilfs_segctor_do_immediate_flush(struct nilfs_sc_info *); |
107 | static void nilfs_dispose_list(struct nilfs_sb_info *, struct list_head *, | 107 | static void nilfs_dispose_list(struct the_nilfs *, struct list_head *, int); |
108 | int); | ||
109 | 108 | ||
110 | #define nilfs_cnt32_gt(a, b) \ | 109 | #define nilfs_cnt32_gt(a, b) \ |
111 | (typecheck(__u32, a) && typecheck(__u32, b) && \ | 110 | (typecheck(__u32, a) && typecheck(__u32, b) && \ |
@@ -182,7 +181,6 @@ int nilfs_transaction_begin(struct super_block *sb, | |||
182 | struct nilfs_transaction_info *ti, | 181 | struct nilfs_transaction_info *ti, |
183 | int vacancy_check) | 182 | int vacancy_check) |
184 | { | 183 | { |
185 | struct nilfs_sb_info *sbi; | ||
186 | struct the_nilfs *nilfs; | 184 | struct the_nilfs *nilfs; |
187 | int ret = nilfs_prepare_segment_lock(ti); | 185 | int ret = nilfs_prepare_segment_lock(ti); |
188 | 186 | ||
@@ -193,8 +191,7 @@ int nilfs_transaction_begin(struct super_block *sb, | |||
193 | 191 | ||
194 | vfs_check_frozen(sb, SB_FREEZE_WRITE); | 192 | vfs_check_frozen(sb, SB_FREEZE_WRITE); |
195 | 193 | ||
196 | sbi = NILFS_SB(sb); | 194 | nilfs = sb->s_fs_info; |
197 | nilfs = sbi->s_nilfs; | ||
198 | down_read(&nilfs->ns_segctor_sem); | 195 | down_read(&nilfs->ns_segctor_sem); |
199 | if (vacancy_check && nilfs_near_disk_full(nilfs)) { | 196 | if (vacancy_check && nilfs_near_disk_full(nilfs)) { |
200 | up_read(&nilfs->ns_segctor_sem); | 197 | up_read(&nilfs->ns_segctor_sem); |
@@ -225,8 +222,7 @@ int nilfs_transaction_begin(struct super_block *sb, | |||
225 | int nilfs_transaction_commit(struct super_block *sb) | 222 | int nilfs_transaction_commit(struct super_block *sb) |
226 | { | 223 | { |
227 | struct nilfs_transaction_info *ti = current->journal_info; | 224 | struct nilfs_transaction_info *ti = current->journal_info; |
228 | struct nilfs_sb_info *sbi; | 225 | struct the_nilfs *nilfs = sb->s_fs_info; |
229 | struct nilfs_sc_info *sci; | ||
230 | int err = 0; | 226 | int err = 0; |
231 | 227 | ||
232 | BUG_ON(ti == NULL || ti->ti_magic != NILFS_TI_MAGIC); | 228 | BUG_ON(ti == NULL || ti->ti_magic != NILFS_TI_MAGIC); |
@@ -235,16 +231,15 @@ int nilfs_transaction_commit(struct super_block *sb) | |||
235 | ti->ti_count--; | 231 | ti->ti_count--; |
236 | return 0; | 232 | return 0; |
237 | } | 233 | } |
238 | sbi = NILFS_SB(sb); | 234 | if (nilfs->ns_writer) { |
239 | sci = NILFS_SC(sbi); | 235 | struct nilfs_sc_info *sci = nilfs->ns_writer; |
240 | if (sci != NULL) { | 236 | |
241 | if (ti->ti_flags & NILFS_TI_COMMIT) | 237 | if (ti->ti_flags & NILFS_TI_COMMIT) |
242 | nilfs_segctor_start_timer(sci); | 238 | nilfs_segctor_start_timer(sci); |
243 | if (atomic_read(&sbi->s_nilfs->ns_ndirtyblks) > | 239 | if (atomic_read(&nilfs->ns_ndirtyblks) > sci->sc_watermark) |
244 | sci->sc_watermark) | ||
245 | nilfs_segctor_do_flush(sci, 0); | 240 | nilfs_segctor_do_flush(sci, 0); |
246 | } | 241 | } |
247 | up_read(&sbi->s_nilfs->ns_segctor_sem); | 242 | up_read(&nilfs->ns_segctor_sem); |
248 | current->journal_info = ti->ti_save; | 243 | current->journal_info = ti->ti_save; |
249 | 244 | ||
250 | if (ti->ti_flags & NILFS_TI_SYNC) | 245 | if (ti->ti_flags & NILFS_TI_SYNC) |
@@ -257,13 +252,14 @@ int nilfs_transaction_commit(struct super_block *sb) | |||
257 | void nilfs_transaction_abort(struct super_block *sb) | 252 | void nilfs_transaction_abort(struct super_block *sb) |
258 | { | 253 | { |
259 | struct nilfs_transaction_info *ti = current->journal_info; | 254 | struct nilfs_transaction_info *ti = current->journal_info; |
255 | struct the_nilfs *nilfs = sb->s_fs_info; | ||
260 | 256 | ||
261 | BUG_ON(ti == NULL || ti->ti_magic != NILFS_TI_MAGIC); | 257 | BUG_ON(ti == NULL || ti->ti_magic != NILFS_TI_MAGIC); |
262 | if (ti->ti_count > 0) { | 258 | if (ti->ti_count > 0) { |
263 | ti->ti_count--; | 259 | ti->ti_count--; |
264 | return; | 260 | return; |
265 | } | 261 | } |
266 | up_read(&NILFS_SB(sb)->s_nilfs->ns_segctor_sem); | 262 | up_read(&nilfs->ns_segctor_sem); |
267 | 263 | ||
268 | current->journal_info = ti->ti_save; | 264 | current->journal_info = ti->ti_save; |
269 | if (ti->ti_flags & NILFS_TI_DYNAMIC_ALLOC) | 265 | if (ti->ti_flags & NILFS_TI_DYNAMIC_ALLOC) |
@@ -272,9 +268,8 @@ void nilfs_transaction_abort(struct super_block *sb) | |||
272 | 268 | ||
273 | void nilfs_relax_pressure_in_lock(struct super_block *sb) | 269 | void nilfs_relax_pressure_in_lock(struct super_block *sb) |
274 | { | 270 | { |
275 | struct nilfs_sb_info *sbi = NILFS_SB(sb); | 271 | struct the_nilfs *nilfs = sb->s_fs_info; |
276 | struct nilfs_sc_info *sci = NILFS_SC(sbi); | 272 | struct nilfs_sc_info *sci = nilfs->ns_writer; |
277 | struct the_nilfs *nilfs = sbi->s_nilfs; | ||
278 | 273 | ||
279 | if (!sci || !sci->sc_flush_request) | 274 | if (!sci || !sci->sc_flush_request) |
280 | return; | 275 | return; |
@@ -294,11 +289,13 @@ void nilfs_relax_pressure_in_lock(struct super_block *sb) | |||
294 | downgrade_write(&nilfs->ns_segctor_sem); | 289 | downgrade_write(&nilfs->ns_segctor_sem); |
295 | } | 290 | } |
296 | 291 | ||
297 | static void nilfs_transaction_lock(struct nilfs_sb_info *sbi, | 292 | static void nilfs_transaction_lock(struct super_block *sb, |
298 | struct nilfs_transaction_info *ti, | 293 | struct nilfs_transaction_info *ti, |
299 | int gcflag) | 294 | int gcflag) |
300 | { | 295 | { |
301 | struct nilfs_transaction_info *cur_ti = current->journal_info; | 296 | struct nilfs_transaction_info *cur_ti = current->journal_info; |
297 | struct the_nilfs *nilfs = sb->s_fs_info; | ||
298 | struct nilfs_sc_info *sci = nilfs->ns_writer; | ||
302 | 299 | ||
303 | WARN_ON(cur_ti); | 300 | WARN_ON(cur_ti); |
304 | ti->ti_flags = NILFS_TI_WRITER; | 301 | ti->ti_flags = NILFS_TI_WRITER; |
@@ -309,30 +306,31 @@ static void nilfs_transaction_lock(struct nilfs_sb_info *sbi, | |||
309 | current->journal_info = ti; | 306 | current->journal_info = ti; |
310 | 307 | ||
311 | for (;;) { | 308 | for (;;) { |
312 | down_write(&sbi->s_nilfs->ns_segctor_sem); | 309 | down_write(&nilfs->ns_segctor_sem); |
313 | if (!test_bit(NILFS_SC_PRIOR_FLUSH, &NILFS_SC(sbi)->sc_flags)) | 310 | if (!test_bit(NILFS_SC_PRIOR_FLUSH, &sci->sc_flags)) |
314 | break; | 311 | break; |
315 | 312 | ||
316 | nilfs_segctor_do_immediate_flush(NILFS_SC(sbi)); | 313 | nilfs_segctor_do_immediate_flush(sci); |
317 | 314 | ||
318 | up_write(&sbi->s_nilfs->ns_segctor_sem); | 315 | up_write(&nilfs->ns_segctor_sem); |
319 | yield(); | 316 | yield(); |
320 | } | 317 | } |
321 | if (gcflag) | 318 | if (gcflag) |
322 | ti->ti_flags |= NILFS_TI_GC; | 319 | ti->ti_flags |= NILFS_TI_GC; |
323 | } | 320 | } |
324 | 321 | ||
325 | static void nilfs_transaction_unlock(struct nilfs_sb_info *sbi) | 322 | static void nilfs_transaction_unlock(struct super_block *sb) |
326 | { | 323 | { |
327 | struct nilfs_transaction_info *ti = current->journal_info; | 324 | struct nilfs_transaction_info *ti = current->journal_info; |
325 | struct the_nilfs *nilfs = sb->s_fs_info; | ||
328 | 326 | ||
329 | BUG_ON(ti == NULL || ti->ti_magic != NILFS_TI_MAGIC); | 327 | BUG_ON(ti == NULL || ti->ti_magic != NILFS_TI_MAGIC); |
330 | BUG_ON(ti->ti_count > 0); | 328 | BUG_ON(ti->ti_count > 0); |
331 | 329 | ||
332 | up_write(&sbi->s_nilfs->ns_segctor_sem); | 330 | up_write(&nilfs->ns_segctor_sem); |
333 | current->journal_info = ti->ti_save; | 331 | current->journal_info = ti->ti_save; |
334 | if (!list_empty(&ti->ti_garbage)) | 332 | if (!list_empty(&ti->ti_garbage)) |
335 | nilfs_dispose_list(sbi, &ti->ti_garbage, 0); | 333 | nilfs_dispose_list(nilfs, &ti->ti_garbage, 0); |
336 | } | 334 | } |
337 | 335 | ||
338 | static void *nilfs_segctor_map_segsum_entry(struct nilfs_sc_info *sci, | 336 | static void *nilfs_segctor_map_segsum_entry(struct nilfs_sc_info *sci, |
@@ -714,7 +712,7 @@ static void nilfs_lookup_dirty_node_buffers(struct inode *inode, | |||
714 | } | 712 | } |
715 | } | 713 | } |
716 | 714 | ||
717 | static void nilfs_dispose_list(struct nilfs_sb_info *sbi, | 715 | static void nilfs_dispose_list(struct the_nilfs *nilfs, |
718 | struct list_head *head, int force) | 716 | struct list_head *head, int force) |
719 | { | 717 | { |
720 | struct nilfs_inode_info *ii, *n; | 718 | struct nilfs_inode_info *ii, *n; |
@@ -722,7 +720,7 @@ static void nilfs_dispose_list(struct nilfs_sb_info *sbi, | |||
722 | unsigned nv = 0; | 720 | unsigned nv = 0; |
723 | 721 | ||
724 | while (!list_empty(head)) { | 722 | while (!list_empty(head)) { |
725 | spin_lock(&sbi->s_inode_lock); | 723 | spin_lock(&nilfs->ns_inode_lock); |
726 | list_for_each_entry_safe(ii, n, head, i_dirty) { | 724 | list_for_each_entry_safe(ii, n, head, i_dirty) { |
727 | list_del_init(&ii->i_dirty); | 725 | list_del_init(&ii->i_dirty); |
728 | if (force) { | 726 | if (force) { |
@@ -733,14 +731,14 @@ static void nilfs_dispose_list(struct nilfs_sb_info *sbi, | |||
733 | } else if (test_bit(NILFS_I_DIRTY, &ii->i_state)) { | 731 | } else if (test_bit(NILFS_I_DIRTY, &ii->i_state)) { |
734 | set_bit(NILFS_I_QUEUED, &ii->i_state); | 732 | set_bit(NILFS_I_QUEUED, &ii->i_state); |
735 | list_add_tail(&ii->i_dirty, | 733 | list_add_tail(&ii->i_dirty, |
736 | &sbi->s_dirty_files); | 734 | &nilfs->ns_dirty_files); |
737 | continue; | 735 | continue; |
738 | } | 736 | } |
739 | ivec[nv++] = ii; | 737 | ivec[nv++] = ii; |
740 | if (nv == SC_N_INODEVEC) | 738 | if (nv == SC_N_INODEVEC) |
741 | break; | 739 | break; |
742 | } | 740 | } |
743 | spin_unlock(&sbi->s_inode_lock); | 741 | spin_unlock(&nilfs->ns_inode_lock); |
744 | 742 | ||
745 | for (pii = ivec; nv > 0; pii++, nv--) | 743 | for (pii = ivec; nv > 0; pii++, nv--) |
746 | iput(&(*pii)->vfs_inode); | 744 | iput(&(*pii)->vfs_inode); |
@@ -773,24 +771,23 @@ static int nilfs_segctor_clean(struct nilfs_sc_info *sci) | |||
773 | 771 | ||
774 | static int nilfs_segctor_confirm(struct nilfs_sc_info *sci) | 772 | static int nilfs_segctor_confirm(struct nilfs_sc_info *sci) |
775 | { | 773 | { |
776 | struct nilfs_sb_info *sbi = sci->sc_sbi; | 774 | struct the_nilfs *nilfs = sci->sc_super->s_fs_info; |
777 | int ret = 0; | 775 | int ret = 0; |
778 | 776 | ||
779 | if (nilfs_test_metadata_dirty(sbi->s_nilfs, sci->sc_root)) | 777 | if (nilfs_test_metadata_dirty(nilfs, sci->sc_root)) |
780 | set_bit(NILFS_SC_DIRTY, &sci->sc_flags); | 778 | set_bit(NILFS_SC_DIRTY, &sci->sc_flags); |
781 | 779 | ||
782 | spin_lock(&sbi->s_inode_lock); | 780 | spin_lock(&nilfs->ns_inode_lock); |
783 | if (list_empty(&sbi->s_dirty_files) && nilfs_segctor_clean(sci)) | 781 | if (list_empty(&nilfs->ns_dirty_files) && nilfs_segctor_clean(sci)) |
784 | ret++; | 782 | ret++; |
785 | 783 | ||
786 | spin_unlock(&sbi->s_inode_lock); | 784 | spin_unlock(&nilfs->ns_inode_lock); |
787 | return ret; | 785 | return ret; |
788 | } | 786 | } |
789 | 787 | ||
790 | static void nilfs_segctor_clear_metadata_dirty(struct nilfs_sc_info *sci) | 788 | static void nilfs_segctor_clear_metadata_dirty(struct nilfs_sc_info *sci) |
791 | { | 789 | { |
792 | struct nilfs_sb_info *sbi = sci->sc_sbi; | 790 | struct the_nilfs *nilfs = sci->sc_super->s_fs_info; |
793 | struct the_nilfs *nilfs = sbi->s_nilfs; | ||
794 | 791 | ||
795 | nilfs_mdt_clear_dirty(sci->sc_root->ifile); | 792 | nilfs_mdt_clear_dirty(sci->sc_root->ifile); |
796 | nilfs_mdt_clear_dirty(nilfs->ns_cpfile); | 793 | nilfs_mdt_clear_dirty(nilfs->ns_cpfile); |
@@ -800,7 +797,7 @@ static void nilfs_segctor_clear_metadata_dirty(struct nilfs_sc_info *sci) | |||
800 | 797 | ||
801 | static int nilfs_segctor_create_checkpoint(struct nilfs_sc_info *sci) | 798 | static int nilfs_segctor_create_checkpoint(struct nilfs_sc_info *sci) |
802 | { | 799 | { |
803 | struct the_nilfs *nilfs = sci->sc_sbi->s_nilfs; | 800 | struct the_nilfs *nilfs = sci->sc_super->s_fs_info; |
804 | struct buffer_head *bh_cp; | 801 | struct buffer_head *bh_cp; |
805 | struct nilfs_checkpoint *raw_cp; | 802 | struct nilfs_checkpoint *raw_cp; |
806 | int err; | 803 | int err; |
@@ -824,8 +821,7 @@ static int nilfs_segctor_create_checkpoint(struct nilfs_sc_info *sci) | |||
824 | 821 | ||
825 | static int nilfs_segctor_fill_in_checkpoint(struct nilfs_sc_info *sci) | 822 | static int nilfs_segctor_fill_in_checkpoint(struct nilfs_sc_info *sci) |
826 | { | 823 | { |
827 | struct nilfs_sb_info *sbi = sci->sc_sbi; | 824 | struct the_nilfs *nilfs = sci->sc_super->s_fs_info; |
828 | struct the_nilfs *nilfs = sbi->s_nilfs; | ||
829 | struct buffer_head *bh_cp; | 825 | struct buffer_head *bh_cp; |
830 | struct nilfs_checkpoint *raw_cp; | 826 | struct nilfs_checkpoint *raw_cp; |
831 | int err; | 827 | int err; |
@@ -1049,8 +1045,7 @@ static int nilfs_segctor_scan_file_dsync(struct nilfs_sc_info *sci, | |||
1049 | 1045 | ||
1050 | static int nilfs_segctor_collect_blocks(struct nilfs_sc_info *sci, int mode) | 1046 | static int nilfs_segctor_collect_blocks(struct nilfs_sc_info *sci, int mode) |
1051 | { | 1047 | { |
1052 | struct nilfs_sb_info *sbi = sci->sc_sbi; | 1048 | struct the_nilfs *nilfs = sci->sc_super->s_fs_info; |
1053 | struct the_nilfs *nilfs = sbi->s_nilfs; | ||
1054 | struct list_head *head; | 1049 | struct list_head *head; |
1055 | struct nilfs_inode_info *ii; | 1050 | struct nilfs_inode_info *ii; |
1056 | size_t ndone; | 1051 | size_t ndone; |
@@ -1859,7 +1854,7 @@ static void nilfs_segctor_complete_write(struct nilfs_sc_info *sci) | |||
1859 | { | 1854 | { |
1860 | struct nilfs_segment_buffer *segbuf; | 1855 | struct nilfs_segment_buffer *segbuf; |
1861 | struct page *bd_page = NULL, *fs_page = NULL; | 1856 | struct page *bd_page = NULL, *fs_page = NULL; |
1862 | struct the_nilfs *nilfs = sci->sc_sbi->s_nilfs; | 1857 | struct the_nilfs *nilfs = sci->sc_super->s_fs_info; |
1863 | int update_sr = false; | 1858 | int update_sr = false; |
1864 | 1859 | ||
1865 | list_for_each_entry(segbuf, &sci->sc_write_logs, sb_list) { | 1860 | list_for_each_entry(segbuf, &sci->sc_write_logs, sb_list) { |
@@ -1963,30 +1958,30 @@ static int nilfs_segctor_wait(struct nilfs_sc_info *sci) | |||
1963 | return ret; | 1958 | return ret; |
1964 | } | 1959 | } |
1965 | 1960 | ||
1966 | static int nilfs_segctor_check_in_files(struct nilfs_sc_info *sci, | 1961 | static int nilfs_segctor_collect_dirty_files(struct nilfs_sc_info *sci, |
1967 | struct nilfs_sb_info *sbi) | 1962 | struct the_nilfs *nilfs) |
1968 | { | 1963 | { |
1969 | struct nilfs_inode_info *ii, *n; | 1964 | struct nilfs_inode_info *ii, *n; |
1970 | struct inode *ifile = sci->sc_root->ifile; | 1965 | struct inode *ifile = sci->sc_root->ifile; |
1971 | 1966 | ||
1972 | spin_lock(&sbi->s_inode_lock); | 1967 | spin_lock(&nilfs->ns_inode_lock); |
1973 | retry: | 1968 | retry: |
1974 | list_for_each_entry_safe(ii, n, &sbi->s_dirty_files, i_dirty) { | 1969 | list_for_each_entry_safe(ii, n, &nilfs->ns_dirty_files, i_dirty) { |
1975 | if (!ii->i_bh) { | 1970 | if (!ii->i_bh) { |
1976 | struct buffer_head *ibh; | 1971 | struct buffer_head *ibh; |
1977 | int err; | 1972 | int err; |
1978 | 1973 | ||
1979 | spin_unlock(&sbi->s_inode_lock); | 1974 | spin_unlock(&nilfs->ns_inode_lock); |
1980 | err = nilfs_ifile_get_inode_block( | 1975 | err = nilfs_ifile_get_inode_block( |
1981 | ifile, ii->vfs_inode.i_ino, &ibh); | 1976 | ifile, ii->vfs_inode.i_ino, &ibh); |
1982 | if (unlikely(err)) { | 1977 | if (unlikely(err)) { |
1983 | nilfs_warning(sbi->s_super, __func__, | 1978 | nilfs_warning(sci->sc_super, __func__, |
1984 | "failed to get inode block.\n"); | 1979 | "failed to get inode block.\n"); |
1985 | return err; | 1980 | return err; |
1986 | } | 1981 | } |
1987 | nilfs_mdt_mark_buffer_dirty(ibh); | 1982 | nilfs_mdt_mark_buffer_dirty(ibh); |
1988 | nilfs_mdt_mark_dirty(ifile); | 1983 | nilfs_mdt_mark_dirty(ifile); |
1989 | spin_lock(&sbi->s_inode_lock); | 1984 | spin_lock(&nilfs->ns_inode_lock); |
1990 | if (likely(!ii->i_bh)) | 1985 | if (likely(!ii->i_bh)) |
1991 | ii->i_bh = ibh; | 1986 | ii->i_bh = ibh; |
1992 | else | 1987 | else |
@@ -1999,18 +1994,18 @@ static int nilfs_segctor_check_in_files(struct nilfs_sc_info *sci, | |||
1999 | list_del(&ii->i_dirty); | 1994 | list_del(&ii->i_dirty); |
2000 | list_add_tail(&ii->i_dirty, &sci->sc_dirty_files); | 1995 | list_add_tail(&ii->i_dirty, &sci->sc_dirty_files); |
2001 | } | 1996 | } |
2002 | spin_unlock(&sbi->s_inode_lock); | 1997 | spin_unlock(&nilfs->ns_inode_lock); |
2003 | 1998 | ||
2004 | return 0; | 1999 | return 0; |
2005 | } | 2000 | } |
2006 | 2001 | ||
2007 | static void nilfs_segctor_check_out_files(struct nilfs_sc_info *sci, | 2002 | static void nilfs_segctor_drop_written_files(struct nilfs_sc_info *sci, |
2008 | struct nilfs_sb_info *sbi) | 2003 | struct the_nilfs *nilfs) |
2009 | { | 2004 | { |
2010 | struct nilfs_transaction_info *ti = current->journal_info; | 2005 | struct nilfs_transaction_info *ti = current->journal_info; |
2011 | struct nilfs_inode_info *ii, *n; | 2006 | struct nilfs_inode_info *ii, *n; |
2012 | 2007 | ||
2013 | spin_lock(&sbi->s_inode_lock); | 2008 | spin_lock(&nilfs->ns_inode_lock); |
2014 | list_for_each_entry_safe(ii, n, &sci->sc_dirty_files, i_dirty) { | 2009 | list_for_each_entry_safe(ii, n, &sci->sc_dirty_files, i_dirty) { |
2015 | if (!test_and_clear_bit(NILFS_I_UPDATED, &ii->i_state) || | 2010 | if (!test_and_clear_bit(NILFS_I_UPDATED, &ii->i_state) || |
2016 | test_bit(NILFS_I_DIRTY, &ii->i_state)) | 2011 | test_bit(NILFS_I_DIRTY, &ii->i_state)) |
@@ -2022,7 +2017,7 @@ static void nilfs_segctor_check_out_files(struct nilfs_sc_info *sci, | |||
2022 | list_del(&ii->i_dirty); | 2017 | list_del(&ii->i_dirty); |
2023 | list_add_tail(&ii->i_dirty, &ti->ti_garbage); | 2018 | list_add_tail(&ii->i_dirty, &ti->ti_garbage); |
2024 | } | 2019 | } |
2025 | spin_unlock(&sbi->s_inode_lock); | 2020 | spin_unlock(&nilfs->ns_inode_lock); |
2026 | } | 2021 | } |
2027 | 2022 | ||
2028 | /* | 2023 | /* |
@@ -2030,15 +2025,14 @@ static void nilfs_segctor_check_out_files(struct nilfs_sc_info *sci, | |||
2030 | */ | 2025 | */ |
2031 | static int nilfs_segctor_do_construct(struct nilfs_sc_info *sci, int mode) | 2026 | static int nilfs_segctor_do_construct(struct nilfs_sc_info *sci, int mode) |
2032 | { | 2027 | { |
2033 | struct nilfs_sb_info *sbi = sci->sc_sbi; | 2028 | struct the_nilfs *nilfs = sci->sc_super->s_fs_info; |
2034 | struct the_nilfs *nilfs = sbi->s_nilfs; | ||
2035 | struct page *failed_page; | 2029 | struct page *failed_page; |
2036 | int err; | 2030 | int err; |
2037 | 2031 | ||
2038 | sci->sc_stage.scnt = NILFS_ST_INIT; | 2032 | sci->sc_stage.scnt = NILFS_ST_INIT; |
2039 | sci->sc_cno = nilfs->ns_cno; | 2033 | sci->sc_cno = nilfs->ns_cno; |
2040 | 2034 | ||
2041 | err = nilfs_segctor_check_in_files(sci, sbi); | 2035 | err = nilfs_segctor_collect_dirty_files(sci, nilfs); |
2042 | if (unlikely(err)) | 2036 | if (unlikely(err)) |
2043 | goto out; | 2037 | goto out; |
2044 | 2038 | ||
@@ -2116,7 +2110,7 @@ static int nilfs_segctor_do_construct(struct nilfs_sc_info *sci, int mode) | |||
2116 | } while (sci->sc_stage.scnt != NILFS_ST_DONE); | 2110 | } while (sci->sc_stage.scnt != NILFS_ST_DONE); |
2117 | 2111 | ||
2118 | out: | 2112 | out: |
2119 | nilfs_segctor_check_out_files(sci, sbi); | 2113 | nilfs_segctor_drop_written_files(sci, nilfs); |
2120 | return err; | 2114 | return err; |
2121 | 2115 | ||
2122 | failed_to_write: | 2116 | failed_to_write: |
@@ -2169,8 +2163,8 @@ static void nilfs_segctor_do_flush(struct nilfs_sc_info *sci, int bn) | |||
2169 | */ | 2163 | */ |
2170 | void nilfs_flush_segment(struct super_block *sb, ino_t ino) | 2164 | void nilfs_flush_segment(struct super_block *sb, ino_t ino) |
2171 | { | 2165 | { |
2172 | struct nilfs_sb_info *sbi = NILFS_SB(sb); | 2166 | struct the_nilfs *nilfs = sb->s_fs_info; |
2173 | struct nilfs_sc_info *sci = NILFS_SC(sbi); | 2167 | struct nilfs_sc_info *sci = nilfs->ns_writer; |
2174 | 2168 | ||
2175 | if (!sci || nilfs_doing_construction()) | 2169 | if (!sci || nilfs_doing_construction()) |
2176 | return; | 2170 | return; |
@@ -2259,8 +2253,8 @@ static void nilfs_segctor_wakeup(struct nilfs_sc_info *sci, int err) | |||
2259 | */ | 2253 | */ |
2260 | int nilfs_construct_segment(struct super_block *sb) | 2254 | int nilfs_construct_segment(struct super_block *sb) |
2261 | { | 2255 | { |
2262 | struct nilfs_sb_info *sbi = NILFS_SB(sb); | 2256 | struct the_nilfs *nilfs = sb->s_fs_info; |
2263 | struct nilfs_sc_info *sci = NILFS_SC(sbi); | 2257 | struct nilfs_sc_info *sci = nilfs->ns_writer; |
2264 | struct nilfs_transaction_info *ti; | 2258 | struct nilfs_transaction_info *ti; |
2265 | int err; | 2259 | int err; |
2266 | 2260 | ||
@@ -2297,8 +2291,8 @@ int nilfs_construct_segment(struct super_block *sb) | |||
2297 | int nilfs_construct_dsync_segment(struct super_block *sb, struct inode *inode, | 2291 | int nilfs_construct_dsync_segment(struct super_block *sb, struct inode *inode, |
2298 | loff_t start, loff_t end) | 2292 | loff_t start, loff_t end) |
2299 | { | 2293 | { |
2300 | struct nilfs_sb_info *sbi = NILFS_SB(sb); | 2294 | struct the_nilfs *nilfs = sb->s_fs_info; |
2301 | struct nilfs_sc_info *sci = NILFS_SC(sbi); | 2295 | struct nilfs_sc_info *sci = nilfs->ns_writer; |
2302 | struct nilfs_inode_info *ii; | 2296 | struct nilfs_inode_info *ii; |
2303 | struct nilfs_transaction_info ti; | 2297 | struct nilfs_transaction_info ti; |
2304 | int err = 0; | 2298 | int err = 0; |
@@ -2306,33 +2300,33 @@ int nilfs_construct_dsync_segment(struct super_block *sb, struct inode *inode, | |||
2306 | if (!sci) | 2300 | if (!sci) |
2307 | return -EROFS; | 2301 | return -EROFS; |
2308 | 2302 | ||
2309 | nilfs_transaction_lock(sbi, &ti, 0); | 2303 | nilfs_transaction_lock(sb, &ti, 0); |
2310 | 2304 | ||
2311 | ii = NILFS_I(inode); | 2305 | ii = NILFS_I(inode); |
2312 | if (test_bit(NILFS_I_INODE_DIRTY, &ii->i_state) || | 2306 | if (test_bit(NILFS_I_INODE_DIRTY, &ii->i_state) || |
2313 | nilfs_test_opt(sbi, STRICT_ORDER) || | 2307 | nilfs_test_opt(nilfs, STRICT_ORDER) || |
2314 | test_bit(NILFS_SC_UNCLOSED, &sci->sc_flags) || | 2308 | test_bit(NILFS_SC_UNCLOSED, &sci->sc_flags) || |
2315 | nilfs_discontinued(sbi->s_nilfs)) { | 2309 | nilfs_discontinued(nilfs)) { |
2316 | nilfs_transaction_unlock(sbi); | 2310 | nilfs_transaction_unlock(sb); |
2317 | err = nilfs_segctor_sync(sci); | 2311 | err = nilfs_segctor_sync(sci); |
2318 | return err; | 2312 | return err; |
2319 | } | 2313 | } |
2320 | 2314 | ||
2321 | spin_lock(&sbi->s_inode_lock); | 2315 | spin_lock(&nilfs->ns_inode_lock); |
2322 | if (!test_bit(NILFS_I_QUEUED, &ii->i_state) && | 2316 | if (!test_bit(NILFS_I_QUEUED, &ii->i_state) && |
2323 | !test_bit(NILFS_I_BUSY, &ii->i_state)) { | 2317 | !test_bit(NILFS_I_BUSY, &ii->i_state)) { |
2324 | spin_unlock(&sbi->s_inode_lock); | 2318 | spin_unlock(&nilfs->ns_inode_lock); |
2325 | nilfs_transaction_unlock(sbi); | 2319 | nilfs_transaction_unlock(sb); |
2326 | return 0; | 2320 | return 0; |
2327 | } | 2321 | } |
2328 | spin_unlock(&sbi->s_inode_lock); | 2322 | spin_unlock(&nilfs->ns_inode_lock); |
2329 | sci->sc_dsync_inode = ii; | 2323 | sci->sc_dsync_inode = ii; |
2330 | sci->sc_dsync_start = start; | 2324 | sci->sc_dsync_start = start; |
2331 | sci->sc_dsync_end = end; | 2325 | sci->sc_dsync_end = end; |
2332 | 2326 | ||
2333 | err = nilfs_segctor_do_construct(sci, SC_LSEG_DSYNC); | 2327 | err = nilfs_segctor_do_construct(sci, SC_LSEG_DSYNC); |
2334 | 2328 | ||
2335 | nilfs_transaction_unlock(sbi); | 2329 | nilfs_transaction_unlock(sb); |
2336 | return err; | 2330 | return err; |
2337 | } | 2331 | } |
2338 | 2332 | ||
@@ -2388,8 +2382,7 @@ static void nilfs_segctor_notify(struct nilfs_sc_info *sci, int mode, int err) | |||
2388 | */ | 2382 | */ |
2389 | static int nilfs_segctor_construct(struct nilfs_sc_info *sci, int mode) | 2383 | static int nilfs_segctor_construct(struct nilfs_sc_info *sci, int mode) |
2390 | { | 2384 | { |
2391 | struct nilfs_sb_info *sbi = sci->sc_sbi; | 2385 | struct the_nilfs *nilfs = sci->sc_super->s_fs_info; |
2392 | struct the_nilfs *nilfs = sbi->s_nilfs; | ||
2393 | struct nilfs_super_block **sbp; | 2386 | struct nilfs_super_block **sbp; |
2394 | int err = 0; | 2387 | int err = 0; |
2395 | 2388 | ||
@@ -2407,11 +2400,12 @@ static int nilfs_segctor_construct(struct nilfs_sc_info *sci, int mode) | |||
2407 | nilfs_discontinued(nilfs)) { | 2400 | nilfs_discontinued(nilfs)) { |
2408 | down_write(&nilfs->ns_sem); | 2401 | down_write(&nilfs->ns_sem); |
2409 | err = -EIO; | 2402 | err = -EIO; |
2410 | sbp = nilfs_prepare_super(sbi, | 2403 | sbp = nilfs_prepare_super(sci->sc_super, |
2411 | nilfs_sb_will_flip(nilfs)); | 2404 | nilfs_sb_will_flip(nilfs)); |
2412 | if (likely(sbp)) { | 2405 | if (likely(sbp)) { |
2413 | nilfs_set_log_cursor(sbp[0], nilfs); | 2406 | nilfs_set_log_cursor(sbp[0], nilfs); |
2414 | err = nilfs_commit_super(sbi, NILFS_SB_COMMIT); | 2407 | err = nilfs_commit_super(sci->sc_super, |
2408 | NILFS_SB_COMMIT); | ||
2415 | } | 2409 | } |
2416 | up_write(&nilfs->ns_sem); | 2410 | up_write(&nilfs->ns_sem); |
2417 | } | 2411 | } |
@@ -2443,16 +2437,15 @@ nilfs_remove_written_gcinodes(struct the_nilfs *nilfs, struct list_head *head) | |||
2443 | int nilfs_clean_segments(struct super_block *sb, struct nilfs_argv *argv, | 2437 | int nilfs_clean_segments(struct super_block *sb, struct nilfs_argv *argv, |
2444 | void **kbufs) | 2438 | void **kbufs) |
2445 | { | 2439 | { |
2446 | struct nilfs_sb_info *sbi = NILFS_SB(sb); | 2440 | struct the_nilfs *nilfs = sb->s_fs_info; |
2447 | struct nilfs_sc_info *sci = NILFS_SC(sbi); | 2441 | struct nilfs_sc_info *sci = nilfs->ns_writer; |
2448 | struct the_nilfs *nilfs = sbi->s_nilfs; | ||
2449 | struct nilfs_transaction_info ti; | 2442 | struct nilfs_transaction_info ti; |
2450 | int err; | 2443 | int err; |
2451 | 2444 | ||
2452 | if (unlikely(!sci)) | 2445 | if (unlikely(!sci)) |
2453 | return -EROFS; | 2446 | return -EROFS; |
2454 | 2447 | ||
2455 | nilfs_transaction_lock(sbi, &ti, 1); | 2448 | nilfs_transaction_lock(sb, &ti, 1); |
2456 | 2449 | ||
2457 | err = nilfs_mdt_save_to_shadow_map(nilfs->ns_dat); | 2450 | err = nilfs_mdt_save_to_shadow_map(nilfs->ns_dat); |
2458 | if (unlikely(err)) | 2451 | if (unlikely(err)) |
@@ -2480,14 +2473,14 @@ int nilfs_clean_segments(struct super_block *sb, struct nilfs_argv *argv, | |||
2480 | set_current_state(TASK_INTERRUPTIBLE); | 2473 | set_current_state(TASK_INTERRUPTIBLE); |
2481 | schedule_timeout(sci->sc_interval); | 2474 | schedule_timeout(sci->sc_interval); |
2482 | } | 2475 | } |
2483 | if (nilfs_test_opt(sbi, DISCARD)) { | 2476 | if (nilfs_test_opt(nilfs, DISCARD)) { |
2484 | int ret = nilfs_discard_segments(nilfs, sci->sc_freesegs, | 2477 | int ret = nilfs_discard_segments(nilfs, sci->sc_freesegs, |
2485 | sci->sc_nfreesegs); | 2478 | sci->sc_nfreesegs); |
2486 | if (ret) { | 2479 | if (ret) { |
2487 | printk(KERN_WARNING | 2480 | printk(KERN_WARNING |
2488 | "NILFS warning: error %d on discard request, " | 2481 | "NILFS warning: error %d on discard request, " |
2489 | "turning discards off for the device\n", ret); | 2482 | "turning discards off for the device\n", ret); |
2490 | nilfs_clear_opt(sbi, DISCARD); | 2483 | nilfs_clear_opt(nilfs, DISCARD); |
2491 | } | 2484 | } |
2492 | } | 2485 | } |
2493 | 2486 | ||
@@ -2495,16 +2488,15 @@ int nilfs_clean_segments(struct super_block *sb, struct nilfs_argv *argv, | |||
2495 | sci->sc_freesegs = NULL; | 2488 | sci->sc_freesegs = NULL; |
2496 | sci->sc_nfreesegs = 0; | 2489 | sci->sc_nfreesegs = 0; |
2497 | nilfs_mdt_clear_shadow_map(nilfs->ns_dat); | 2490 | nilfs_mdt_clear_shadow_map(nilfs->ns_dat); |
2498 | nilfs_transaction_unlock(sbi); | 2491 | nilfs_transaction_unlock(sb); |
2499 | return err; | 2492 | return err; |
2500 | } | 2493 | } |
2501 | 2494 | ||
2502 | static void nilfs_segctor_thread_construct(struct nilfs_sc_info *sci, int mode) | 2495 | static void nilfs_segctor_thread_construct(struct nilfs_sc_info *sci, int mode) |
2503 | { | 2496 | { |
2504 | struct nilfs_sb_info *sbi = sci->sc_sbi; | ||
2505 | struct nilfs_transaction_info ti; | 2497 | struct nilfs_transaction_info ti; |
2506 | 2498 | ||
2507 | nilfs_transaction_lock(sbi, &ti, 0); | 2499 | nilfs_transaction_lock(sci->sc_super, &ti, 0); |
2508 | nilfs_segctor_construct(sci, mode); | 2500 | nilfs_segctor_construct(sci, mode); |
2509 | 2501 | ||
2510 | /* | 2502 | /* |
@@ -2515,7 +2507,7 @@ static void nilfs_segctor_thread_construct(struct nilfs_sc_info *sci, int mode) | |||
2515 | if (test_bit(NILFS_SC_UNCLOSED, &sci->sc_flags)) | 2507 | if (test_bit(NILFS_SC_UNCLOSED, &sci->sc_flags)) |
2516 | nilfs_segctor_start_timer(sci); | 2508 | nilfs_segctor_start_timer(sci); |
2517 | 2509 | ||
2518 | nilfs_transaction_unlock(sbi); | 2510 | nilfs_transaction_unlock(sci->sc_super); |
2519 | } | 2511 | } |
2520 | 2512 | ||
2521 | static void nilfs_segctor_do_immediate_flush(struct nilfs_sc_info *sci) | 2513 | static void nilfs_segctor_do_immediate_flush(struct nilfs_sc_info *sci) |
@@ -2561,7 +2553,7 @@ static int nilfs_segctor_flush_mode(struct nilfs_sc_info *sci) | |||
2561 | static int nilfs_segctor_thread(void *arg) | 2553 | static int nilfs_segctor_thread(void *arg) |
2562 | { | 2554 | { |
2563 | struct nilfs_sc_info *sci = (struct nilfs_sc_info *)arg; | 2555 | struct nilfs_sc_info *sci = (struct nilfs_sc_info *)arg; |
2564 | struct the_nilfs *nilfs = sci->sc_sbi->s_nilfs; | 2556 | struct the_nilfs *nilfs = sci->sc_super->s_fs_info; |
2565 | int timeout = 0; | 2557 | int timeout = 0; |
2566 | 2558 | ||
2567 | sci->sc_timer.data = (unsigned long)current; | 2559 | sci->sc_timer.data = (unsigned long)current; |
@@ -2672,17 +2664,17 @@ static void nilfs_segctor_kill_thread(struct nilfs_sc_info *sci) | |||
2672 | /* | 2664 | /* |
2673 | * Setup & clean-up functions | 2665 | * Setup & clean-up functions |
2674 | */ | 2666 | */ |
2675 | static struct nilfs_sc_info *nilfs_segctor_new(struct nilfs_sb_info *sbi, | 2667 | static struct nilfs_sc_info *nilfs_segctor_new(struct super_block *sb, |
2676 | struct nilfs_root *root) | 2668 | struct nilfs_root *root) |
2677 | { | 2669 | { |
2670 | struct the_nilfs *nilfs = sb->s_fs_info; | ||
2678 | struct nilfs_sc_info *sci; | 2671 | struct nilfs_sc_info *sci; |
2679 | 2672 | ||
2680 | sci = kzalloc(sizeof(*sci), GFP_KERNEL); | 2673 | sci = kzalloc(sizeof(*sci), GFP_KERNEL); |
2681 | if (!sci) | 2674 | if (!sci) |
2682 | return NULL; | 2675 | return NULL; |
2683 | 2676 | ||
2684 | sci->sc_sbi = sbi; | 2677 | sci->sc_super = sb; |
2685 | sci->sc_super = sbi->s_super; | ||
2686 | 2678 | ||
2687 | nilfs_get_root(root); | 2679 | nilfs_get_root(root); |
2688 | sci->sc_root = root; | 2680 | sci->sc_root = root; |
@@ -2702,10 +2694,10 @@ static struct nilfs_sc_info *nilfs_segctor_new(struct nilfs_sb_info *sbi, | |||
2702 | sci->sc_mjcp_freq = HZ * NILFS_SC_DEFAULT_SR_FREQ; | 2694 | sci->sc_mjcp_freq = HZ * NILFS_SC_DEFAULT_SR_FREQ; |
2703 | sci->sc_watermark = NILFS_SC_DEFAULT_WATERMARK; | 2695 | sci->sc_watermark = NILFS_SC_DEFAULT_WATERMARK; |
2704 | 2696 | ||
2705 | if (sbi->s_interval) | 2697 | if (nilfs->ns_interval) |
2706 | sci->sc_interval = sbi->s_interval; | 2698 | sci->sc_interval = nilfs->ns_interval; |
2707 | if (sbi->s_watermark) | 2699 | if (nilfs->ns_watermark) |
2708 | sci->sc_watermark = sbi->s_watermark; | 2700 | sci->sc_watermark = nilfs->ns_watermark; |
2709 | return sci; | 2701 | return sci; |
2710 | } | 2702 | } |
2711 | 2703 | ||
@@ -2716,12 +2708,11 @@ static void nilfs_segctor_write_out(struct nilfs_sc_info *sci) | |||
2716 | /* The segctord thread was stopped and its timer was removed. | 2708 | /* The segctord thread was stopped and its timer was removed. |
2717 | But some tasks remain. */ | 2709 | But some tasks remain. */ |
2718 | do { | 2710 | do { |
2719 | struct nilfs_sb_info *sbi = sci->sc_sbi; | ||
2720 | struct nilfs_transaction_info ti; | 2711 | struct nilfs_transaction_info ti; |
2721 | 2712 | ||
2722 | nilfs_transaction_lock(sbi, &ti, 0); | 2713 | nilfs_transaction_lock(sci->sc_super, &ti, 0); |
2723 | ret = nilfs_segctor_construct(sci, SC_LSEG_SR); | 2714 | ret = nilfs_segctor_construct(sci, SC_LSEG_SR); |
2724 | nilfs_transaction_unlock(sbi); | 2715 | nilfs_transaction_unlock(sci->sc_super); |
2725 | 2716 | ||
2726 | } while (ret && retrycount-- > 0); | 2717 | } while (ret && retrycount-- > 0); |
2727 | } | 2718 | } |
@@ -2736,10 +2727,10 @@ static void nilfs_segctor_write_out(struct nilfs_sc_info *sci) | |||
2736 | */ | 2727 | */ |
2737 | static void nilfs_segctor_destroy(struct nilfs_sc_info *sci) | 2728 | static void nilfs_segctor_destroy(struct nilfs_sc_info *sci) |
2738 | { | 2729 | { |
2739 | struct nilfs_sb_info *sbi = sci->sc_sbi; | 2730 | struct the_nilfs *nilfs = sci->sc_super->s_fs_info; |
2740 | int flag; | 2731 | int flag; |
2741 | 2732 | ||
2742 | up_write(&sbi->s_nilfs->ns_segctor_sem); | 2733 | up_write(&nilfs->ns_segctor_sem); |
2743 | 2734 | ||
2744 | spin_lock(&sci->sc_state_lock); | 2735 | spin_lock(&sci->sc_state_lock); |
2745 | nilfs_segctor_kill_thread(sci); | 2736 | nilfs_segctor_kill_thread(sci); |
@@ -2753,9 +2744,9 @@ static void nilfs_segctor_destroy(struct nilfs_sc_info *sci) | |||
2753 | WARN_ON(!list_empty(&sci->sc_copied_buffers)); | 2744 | WARN_ON(!list_empty(&sci->sc_copied_buffers)); |
2754 | 2745 | ||
2755 | if (!list_empty(&sci->sc_dirty_files)) { | 2746 | if (!list_empty(&sci->sc_dirty_files)) { |
2756 | nilfs_warning(sbi->s_super, __func__, | 2747 | nilfs_warning(sci->sc_super, __func__, |
2757 | "dirty file(s) after the final construction\n"); | 2748 | "dirty file(s) after the final construction\n"); |
2758 | nilfs_dispose_list(sbi, &sci->sc_dirty_files, 1); | 2749 | nilfs_dispose_list(nilfs, &sci->sc_dirty_files, 1); |
2759 | } | 2750 | } |
2760 | 2751 | ||
2761 | WARN_ON(!list_empty(&sci->sc_segbufs)); | 2752 | WARN_ON(!list_empty(&sci->sc_segbufs)); |
@@ -2763,79 +2754,78 @@ static void nilfs_segctor_destroy(struct nilfs_sc_info *sci) | |||
2763 | 2754 | ||
2764 | nilfs_put_root(sci->sc_root); | 2755 | nilfs_put_root(sci->sc_root); |
2765 | 2756 | ||
2766 | down_write(&sbi->s_nilfs->ns_segctor_sem); | 2757 | down_write(&nilfs->ns_segctor_sem); |
2767 | 2758 | ||
2768 | del_timer_sync(&sci->sc_timer); | 2759 | del_timer_sync(&sci->sc_timer); |
2769 | kfree(sci); | 2760 | kfree(sci); |
2770 | } | 2761 | } |
2771 | 2762 | ||
2772 | /** | 2763 | /** |
2773 | * nilfs_attach_segment_constructor - attach a segment constructor | 2764 | * nilfs_attach_log_writer - attach log writer |
2774 | * @sbi: nilfs_sb_info | 2765 | * @sb: super block instance |
2775 | * @root: root object of the current filesystem tree | 2766 | * @root: root object of the current filesystem tree |
2776 | * | 2767 | * |
2777 | * nilfs_attach_segment_constructor() allocates a struct nilfs_sc_info, | 2768 | * This allocates a log writer object, initializes it, and starts the |
2778 | * initializes it, and starts the segment constructor. | 2769 | * log writer. |
2779 | * | 2770 | * |
2780 | * Return Value: On success, 0 is returned. On error, one of the following | 2771 | * Return Value: On success, 0 is returned. On error, one of the following |
2781 | * negative error code is returned. | 2772 | * negative error code is returned. |
2782 | * | 2773 | * |
2783 | * %-ENOMEM - Insufficient memory available. | 2774 | * %-ENOMEM - Insufficient memory available. |
2784 | */ | 2775 | */ |
2785 | int nilfs_attach_segment_constructor(struct nilfs_sb_info *sbi, | 2776 | int nilfs_attach_log_writer(struct super_block *sb, struct nilfs_root *root) |
2786 | struct nilfs_root *root) | ||
2787 | { | 2777 | { |
2778 | struct the_nilfs *nilfs = sb->s_fs_info; | ||
2788 | int err; | 2779 | int err; |
2789 | 2780 | ||
2790 | if (NILFS_SC(sbi)) { | 2781 | if (nilfs->ns_writer) { |
2791 | /* | 2782 | /* |
2792 | * This happens if the filesystem was remounted | 2783 | * This happens if the filesystem was remounted |
2793 | * read/write after nilfs_error degenerated it into a | 2784 | * read/write after nilfs_error degenerated it into a |
2794 | * read-only mount. | 2785 | * read-only mount. |
2795 | */ | 2786 | */ |
2796 | nilfs_detach_segment_constructor(sbi); | 2787 | nilfs_detach_log_writer(sb); |
2797 | } | 2788 | } |
2798 | 2789 | ||
2799 | sbi->s_sc_info = nilfs_segctor_new(sbi, root); | 2790 | nilfs->ns_writer = nilfs_segctor_new(sb, root); |
2800 | if (!sbi->s_sc_info) | 2791 | if (!nilfs->ns_writer) |
2801 | return -ENOMEM; | 2792 | return -ENOMEM; |
2802 | 2793 | ||
2803 | err = nilfs_segctor_start_thread(NILFS_SC(sbi)); | 2794 | err = nilfs_segctor_start_thread(nilfs->ns_writer); |
2804 | if (err) { | 2795 | if (err) { |
2805 | kfree(sbi->s_sc_info); | 2796 | kfree(nilfs->ns_writer); |
2806 | sbi->s_sc_info = NULL; | 2797 | nilfs->ns_writer = NULL; |
2807 | } | 2798 | } |
2808 | return err; | 2799 | return err; |
2809 | } | 2800 | } |
2810 | 2801 | ||
2811 | /** | 2802 | /** |
2812 | * nilfs_detach_segment_constructor - destroy the segment constructor | 2803 | * nilfs_detach_log_writer - destroy log writer |
2813 | * @sbi: nilfs_sb_info | 2804 | * @sb: super block instance |
2814 | * | 2805 | * |
2815 | * nilfs_detach_segment_constructor() kills the segment constructor daemon, | 2806 | * This kills log writer daemon, frees the log writer object, and |
2816 | * frees the struct nilfs_sc_info, and destroy the dirty file list. | 2807 | * destroys list of dirty files. |
2817 | */ | 2808 | */ |
2818 | void nilfs_detach_segment_constructor(struct nilfs_sb_info *sbi) | 2809 | void nilfs_detach_log_writer(struct super_block *sb) |
2819 | { | 2810 | { |
2820 | struct the_nilfs *nilfs = sbi->s_nilfs; | 2811 | struct the_nilfs *nilfs = sb->s_fs_info; |
2821 | LIST_HEAD(garbage_list); | 2812 | LIST_HEAD(garbage_list); |
2822 | 2813 | ||
2823 | down_write(&nilfs->ns_segctor_sem); | 2814 | down_write(&nilfs->ns_segctor_sem); |
2824 | if (NILFS_SC(sbi)) { | 2815 | if (nilfs->ns_writer) { |
2825 | nilfs_segctor_destroy(NILFS_SC(sbi)); | 2816 | nilfs_segctor_destroy(nilfs->ns_writer); |
2826 | sbi->s_sc_info = NULL; | 2817 | nilfs->ns_writer = NULL; |
2827 | } | 2818 | } |
2828 | 2819 | ||
2829 | /* Force to free the list of dirty files */ | 2820 | /* Force to free the list of dirty files */ |
2830 | spin_lock(&sbi->s_inode_lock); | 2821 | spin_lock(&nilfs->ns_inode_lock); |
2831 | if (!list_empty(&sbi->s_dirty_files)) { | 2822 | if (!list_empty(&nilfs->ns_dirty_files)) { |
2832 | list_splice_init(&sbi->s_dirty_files, &garbage_list); | 2823 | list_splice_init(&nilfs->ns_dirty_files, &garbage_list); |
2833 | nilfs_warning(sbi->s_super, __func__, | 2824 | nilfs_warning(sb, __func__, |
2834 | "Non empty dirty list after the last " | 2825 | "Hit dirty file after stopped log writer\n"); |
2835 | "segment construction\n"); | 2826 | } |
2836 | } | 2827 | spin_unlock(&nilfs->ns_inode_lock); |
2837 | spin_unlock(&sbi->s_inode_lock); | ||
2838 | up_write(&nilfs->ns_segctor_sem); | 2828 | up_write(&nilfs->ns_segctor_sem); |
2839 | 2829 | ||
2840 | nilfs_dispose_list(sbi, &garbage_list, 1); | 2830 | nilfs_dispose_list(nilfs, &garbage_list, 1); |
2841 | } | 2831 | } |
diff --git a/fs/nilfs2/segment.h b/fs/nilfs2/segment.h index cd8056e7cbed..6c02a86745fb 100644 --- a/fs/nilfs2/segment.h +++ b/fs/nilfs2/segment.h | |||
@@ -27,7 +27,7 @@ | |||
27 | #include <linux/fs.h> | 27 | #include <linux/fs.h> |
28 | #include <linux/buffer_head.h> | 28 | #include <linux/buffer_head.h> |
29 | #include <linux/nilfs2_fs.h> | 29 | #include <linux/nilfs2_fs.h> |
30 | #include "sb.h" | 30 | #include "nilfs.h" |
31 | 31 | ||
32 | struct nilfs_root; | 32 | struct nilfs_root; |
33 | 33 | ||
@@ -88,7 +88,6 @@ struct nilfs_segsum_pointer { | |||
88 | /** | 88 | /** |
89 | * struct nilfs_sc_info - Segment constructor information | 89 | * struct nilfs_sc_info - Segment constructor information |
90 | * @sc_super: Back pointer to super_block struct | 90 | * @sc_super: Back pointer to super_block struct |
91 | * @sc_sbi: Back pointer to nilfs_sb_info struct | ||
92 | * @sc_root: root object of the current filesystem tree | 91 | * @sc_root: root object of the current filesystem tree |
93 | * @sc_nblk_inc: Block count of current generation | 92 | * @sc_nblk_inc: Block count of current generation |
94 | * @sc_dirty_files: List of files to be written | 93 | * @sc_dirty_files: List of files to be written |
@@ -131,7 +130,6 @@ struct nilfs_segsum_pointer { | |||
131 | */ | 130 | */ |
132 | struct nilfs_sc_info { | 131 | struct nilfs_sc_info { |
133 | struct super_block *sc_super; | 132 | struct super_block *sc_super; |
134 | struct nilfs_sb_info *sc_sbi; | ||
135 | struct nilfs_root *sc_root; | 133 | struct nilfs_root *sc_root; |
136 | 134 | ||
137 | unsigned long sc_nblk_inc; | 135 | unsigned long sc_nblk_inc; |
@@ -235,18 +233,16 @@ extern void nilfs_flush_segment(struct super_block *, ino_t); | |||
235 | extern int nilfs_clean_segments(struct super_block *, struct nilfs_argv *, | 233 | extern int nilfs_clean_segments(struct super_block *, struct nilfs_argv *, |
236 | void **); | 234 | void **); |
237 | 235 | ||
238 | int nilfs_attach_segment_constructor(struct nilfs_sb_info *sbi, | 236 | int nilfs_attach_log_writer(struct super_block *sb, struct nilfs_root *root); |
239 | struct nilfs_root *root); | 237 | void nilfs_detach_log_writer(struct super_block *sb); |
240 | extern void nilfs_detach_segment_constructor(struct nilfs_sb_info *); | ||
241 | 238 | ||
242 | /* recovery.c */ | 239 | /* recovery.c */ |
243 | extern int nilfs_read_super_root_block(struct the_nilfs *, sector_t, | 240 | extern int nilfs_read_super_root_block(struct the_nilfs *, sector_t, |
244 | struct buffer_head **, int); | 241 | struct buffer_head **, int); |
245 | extern int nilfs_search_super_root(struct the_nilfs *, | 242 | extern int nilfs_search_super_root(struct the_nilfs *, |
246 | struct nilfs_recovery_info *); | 243 | struct nilfs_recovery_info *); |
247 | extern int nilfs_salvage_orphan_logs(struct the_nilfs *, | 244 | int nilfs_salvage_orphan_logs(struct the_nilfs *nilfs, struct super_block *sb, |
248 | struct nilfs_sb_info *, | 245 | struct nilfs_recovery_info *ri); |
249 | struct nilfs_recovery_info *); | ||
250 | extern void nilfs_dispose_segment_list(struct list_head *); | 246 | extern void nilfs_dispose_segment_list(struct list_head *); |
251 | 247 | ||
252 | #endif /* _NILFS_SEGMENT_H */ | 248 | #endif /* _NILFS_SEGMENT_H */ |
diff --git a/fs/nilfs2/super.c b/fs/nilfs2/super.c index 1673b3d99842..062cca065195 100644 --- a/fs/nilfs2/super.c +++ b/fs/nilfs2/super.c | |||
@@ -43,7 +43,6 @@ | |||
43 | #include <linux/init.h> | 43 | #include <linux/init.h> |
44 | #include <linux/blkdev.h> | 44 | #include <linux/blkdev.h> |
45 | #include <linux/parser.h> | 45 | #include <linux/parser.h> |
46 | #include <linux/random.h> | ||
47 | #include <linux/crc32.h> | 46 | #include <linux/crc32.h> |
48 | #include <linux/vfs.h> | 47 | #include <linux/vfs.h> |
49 | #include <linux/writeback.h> | 48 | #include <linux/writeback.h> |
@@ -72,23 +71,23 @@ struct kmem_cache *nilfs_transaction_cachep; | |||
72 | struct kmem_cache *nilfs_segbuf_cachep; | 71 | struct kmem_cache *nilfs_segbuf_cachep; |
73 | struct kmem_cache *nilfs_btree_path_cache; | 72 | struct kmem_cache *nilfs_btree_path_cache; |
74 | 73 | ||
75 | static int nilfs_setup_super(struct nilfs_sb_info *sbi, int is_mount); | 74 | static int nilfs_setup_super(struct super_block *sb, int is_mount); |
76 | static int nilfs_remount(struct super_block *sb, int *flags, char *data); | 75 | static int nilfs_remount(struct super_block *sb, int *flags, char *data); |
77 | 76 | ||
78 | static void nilfs_set_error(struct nilfs_sb_info *sbi) | 77 | static void nilfs_set_error(struct super_block *sb) |
79 | { | 78 | { |
80 | struct the_nilfs *nilfs = sbi->s_nilfs; | 79 | struct the_nilfs *nilfs = sb->s_fs_info; |
81 | struct nilfs_super_block **sbp; | 80 | struct nilfs_super_block **sbp; |
82 | 81 | ||
83 | down_write(&nilfs->ns_sem); | 82 | down_write(&nilfs->ns_sem); |
84 | if (!(nilfs->ns_mount_state & NILFS_ERROR_FS)) { | 83 | if (!(nilfs->ns_mount_state & NILFS_ERROR_FS)) { |
85 | nilfs->ns_mount_state |= NILFS_ERROR_FS; | 84 | nilfs->ns_mount_state |= NILFS_ERROR_FS; |
86 | sbp = nilfs_prepare_super(sbi, 0); | 85 | sbp = nilfs_prepare_super(sb, 0); |
87 | if (likely(sbp)) { | 86 | if (likely(sbp)) { |
88 | sbp[0]->s_state |= cpu_to_le16(NILFS_ERROR_FS); | 87 | sbp[0]->s_state |= cpu_to_le16(NILFS_ERROR_FS); |
89 | if (sbp[1]) | 88 | if (sbp[1]) |
90 | sbp[1]->s_state |= cpu_to_le16(NILFS_ERROR_FS); | 89 | sbp[1]->s_state |= cpu_to_le16(NILFS_ERROR_FS); |
91 | nilfs_commit_super(sbi, NILFS_SB_COMMIT_ALL); | 90 | nilfs_commit_super(sb, NILFS_SB_COMMIT_ALL); |
92 | } | 91 | } |
93 | } | 92 | } |
94 | up_write(&nilfs->ns_sem); | 93 | up_write(&nilfs->ns_sem); |
@@ -109,7 +108,7 @@ static void nilfs_set_error(struct nilfs_sb_info *sbi) | |||
109 | void nilfs_error(struct super_block *sb, const char *function, | 108 | void nilfs_error(struct super_block *sb, const char *function, |
110 | const char *fmt, ...) | 109 | const char *fmt, ...) |
111 | { | 110 | { |
112 | struct nilfs_sb_info *sbi = NILFS_SB(sb); | 111 | struct the_nilfs *nilfs = sb->s_fs_info; |
113 | struct va_format vaf; | 112 | struct va_format vaf; |
114 | va_list args; | 113 | va_list args; |
115 | 114 | ||
@@ -124,15 +123,15 @@ void nilfs_error(struct super_block *sb, const char *function, | |||
124 | va_end(args); | 123 | va_end(args); |
125 | 124 | ||
126 | if (!(sb->s_flags & MS_RDONLY)) { | 125 | if (!(sb->s_flags & MS_RDONLY)) { |
127 | nilfs_set_error(sbi); | 126 | nilfs_set_error(sb); |
128 | 127 | ||
129 | if (nilfs_test_opt(sbi, ERRORS_RO)) { | 128 | if (nilfs_test_opt(nilfs, ERRORS_RO)) { |
130 | printk(KERN_CRIT "Remounting filesystem read-only\n"); | 129 | printk(KERN_CRIT "Remounting filesystem read-only\n"); |
131 | sb->s_flags |= MS_RDONLY; | 130 | sb->s_flags |= MS_RDONLY; |
132 | } | 131 | } |
133 | } | 132 | } |
134 | 133 | ||
135 | if (nilfs_test_opt(sbi, ERRORS_PANIC)) | 134 | if (nilfs_test_opt(nilfs, ERRORS_PANIC)) |
136 | panic("NILFS (device %s): panic forced after error\n", | 135 | panic("NILFS (device %s): panic forced after error\n", |
137 | sb->s_id); | 136 | sb->s_id); |
138 | } | 137 | } |
@@ -189,14 +188,14 @@ void nilfs_destroy_inode(struct inode *inode) | |||
189 | call_rcu(&inode->i_rcu, nilfs_i_callback); | 188 | call_rcu(&inode->i_rcu, nilfs_i_callback); |
190 | } | 189 | } |
191 | 190 | ||
192 | static int nilfs_sync_super(struct nilfs_sb_info *sbi, int flag) | 191 | static int nilfs_sync_super(struct super_block *sb, int flag) |
193 | { | 192 | { |
194 | struct the_nilfs *nilfs = sbi->s_nilfs; | 193 | struct the_nilfs *nilfs = sb->s_fs_info; |
195 | int err; | 194 | int err; |
196 | 195 | ||
197 | retry: | 196 | retry: |
198 | set_buffer_dirty(nilfs->ns_sbh[0]); | 197 | set_buffer_dirty(nilfs->ns_sbh[0]); |
199 | if (nilfs_test_opt(sbi, BARRIER)) { | 198 | if (nilfs_test_opt(nilfs, BARRIER)) { |
200 | err = __sync_dirty_buffer(nilfs->ns_sbh[0], | 199 | err = __sync_dirty_buffer(nilfs->ns_sbh[0], |
201 | WRITE_SYNC | WRITE_FLUSH_FUA); | 200 | WRITE_SYNC | WRITE_FLUSH_FUA); |
202 | } else { | 201 | } else { |
@@ -263,10 +262,10 @@ void nilfs_set_log_cursor(struct nilfs_super_block *sbp, | |||
263 | spin_unlock(&nilfs->ns_last_segment_lock); | 262 | spin_unlock(&nilfs->ns_last_segment_lock); |
264 | } | 263 | } |
265 | 264 | ||
266 | struct nilfs_super_block **nilfs_prepare_super(struct nilfs_sb_info *sbi, | 265 | struct nilfs_super_block **nilfs_prepare_super(struct super_block *sb, |
267 | int flip) | 266 | int flip) |
268 | { | 267 | { |
269 | struct the_nilfs *nilfs = sbi->s_nilfs; | 268 | struct the_nilfs *nilfs = sb->s_fs_info; |
270 | struct nilfs_super_block **sbp = nilfs->ns_sbp; | 269 | struct nilfs_super_block **sbp = nilfs->ns_sbp; |
271 | 270 | ||
272 | /* nilfs->ns_sem must be locked by the caller. */ | 271 | /* nilfs->ns_sem must be locked by the caller. */ |
@@ -276,7 +275,7 @@ struct nilfs_super_block **nilfs_prepare_super(struct nilfs_sb_info *sbi, | |||
276 | memcpy(sbp[0], sbp[1], nilfs->ns_sbsize); | 275 | memcpy(sbp[0], sbp[1], nilfs->ns_sbsize); |
277 | } else { | 276 | } else { |
278 | printk(KERN_CRIT "NILFS: superblock broke on dev %s\n", | 277 | printk(KERN_CRIT "NILFS: superblock broke on dev %s\n", |
279 | sbi->s_super->s_id); | 278 | sb->s_id); |
280 | return NULL; | 279 | return NULL; |
281 | } | 280 | } |
282 | } else if (sbp[1] && | 281 | } else if (sbp[1] && |
@@ -290,9 +289,9 @@ struct nilfs_super_block **nilfs_prepare_super(struct nilfs_sb_info *sbi, | |||
290 | return sbp; | 289 | return sbp; |
291 | } | 290 | } |
292 | 291 | ||
293 | int nilfs_commit_super(struct nilfs_sb_info *sbi, int flag) | 292 | int nilfs_commit_super(struct super_block *sb, int flag) |
294 | { | 293 | { |
295 | struct the_nilfs *nilfs = sbi->s_nilfs; | 294 | struct the_nilfs *nilfs = sb->s_fs_info; |
296 | struct nilfs_super_block **sbp = nilfs->ns_sbp; | 295 | struct nilfs_super_block **sbp = nilfs->ns_sbp; |
297 | time_t t; | 296 | time_t t; |
298 | 297 | ||
@@ -312,27 +311,28 @@ int nilfs_commit_super(struct nilfs_sb_info *sbi, int flag) | |||
312 | nilfs->ns_sbsize)); | 311 | nilfs->ns_sbsize)); |
313 | } | 312 | } |
314 | clear_nilfs_sb_dirty(nilfs); | 313 | clear_nilfs_sb_dirty(nilfs); |
315 | return nilfs_sync_super(sbi, flag); | 314 | return nilfs_sync_super(sb, flag); |
316 | } | 315 | } |
317 | 316 | ||
318 | /** | 317 | /** |
319 | * nilfs_cleanup_super() - write filesystem state for cleanup | 318 | * nilfs_cleanup_super() - write filesystem state for cleanup |
320 | * @sbi: nilfs_sb_info to be unmounted or degraded to read-only | 319 | * @sb: super block instance to be unmounted or degraded to read-only |
321 | * | 320 | * |
322 | * This function restores state flags in the on-disk super block. | 321 | * This function restores state flags in the on-disk super block. |
323 | * This will set "clean" flag (i.e. NILFS_VALID_FS) unless the | 322 | * This will set "clean" flag (i.e. NILFS_VALID_FS) unless the |
324 | * filesystem was not clean previously. | 323 | * filesystem was not clean previously. |
325 | */ | 324 | */ |
326 | int nilfs_cleanup_super(struct nilfs_sb_info *sbi) | 325 | int nilfs_cleanup_super(struct super_block *sb) |
327 | { | 326 | { |
327 | struct the_nilfs *nilfs = sb->s_fs_info; | ||
328 | struct nilfs_super_block **sbp; | 328 | struct nilfs_super_block **sbp; |
329 | int flag = NILFS_SB_COMMIT; | 329 | int flag = NILFS_SB_COMMIT; |
330 | int ret = -EIO; | 330 | int ret = -EIO; |
331 | 331 | ||
332 | sbp = nilfs_prepare_super(sbi, 0); | 332 | sbp = nilfs_prepare_super(sb, 0); |
333 | if (sbp) { | 333 | if (sbp) { |
334 | sbp[0]->s_state = cpu_to_le16(sbi->s_nilfs->ns_mount_state); | 334 | sbp[0]->s_state = cpu_to_le16(nilfs->ns_mount_state); |
335 | nilfs_set_log_cursor(sbp[0], sbi->s_nilfs); | 335 | nilfs_set_log_cursor(sbp[0], nilfs); |
336 | if (sbp[1] && sbp[0]->s_last_cno == sbp[1]->s_last_cno) { | 336 | if (sbp[1] && sbp[0]->s_last_cno == sbp[1]->s_last_cno) { |
337 | /* | 337 | /* |
338 | * make the "clean" flag also to the opposite | 338 | * make the "clean" flag also to the opposite |
@@ -342,21 +342,20 @@ int nilfs_cleanup_super(struct nilfs_sb_info *sbi) | |||
342 | sbp[1]->s_state = sbp[0]->s_state; | 342 | sbp[1]->s_state = sbp[0]->s_state; |
343 | flag = NILFS_SB_COMMIT_ALL; | 343 | flag = NILFS_SB_COMMIT_ALL; |
344 | } | 344 | } |
345 | ret = nilfs_commit_super(sbi, flag); | 345 | ret = nilfs_commit_super(sb, flag); |
346 | } | 346 | } |
347 | return ret; | 347 | return ret; |
348 | } | 348 | } |
349 | 349 | ||
350 | static void nilfs_put_super(struct super_block *sb) | 350 | static void nilfs_put_super(struct super_block *sb) |
351 | { | 351 | { |
352 | struct nilfs_sb_info *sbi = NILFS_SB(sb); | 352 | struct the_nilfs *nilfs = sb->s_fs_info; |
353 | struct the_nilfs *nilfs = sbi->s_nilfs; | ||
354 | 353 | ||
355 | nilfs_detach_segment_constructor(sbi); | 354 | nilfs_detach_log_writer(sb); |
356 | 355 | ||
357 | if (!(sb->s_flags & MS_RDONLY)) { | 356 | if (!(sb->s_flags & MS_RDONLY)) { |
358 | down_write(&nilfs->ns_sem); | 357 | down_write(&nilfs->ns_sem); |
359 | nilfs_cleanup_super(sbi); | 358 | nilfs_cleanup_super(sb); |
360 | up_write(&nilfs->ns_sem); | 359 | up_write(&nilfs->ns_sem); |
361 | } | 360 | } |
362 | 361 | ||
@@ -365,15 +364,12 @@ static void nilfs_put_super(struct super_block *sb) | |||
365 | iput(nilfs->ns_dat); | 364 | iput(nilfs->ns_dat); |
366 | 365 | ||
367 | destroy_nilfs(nilfs); | 366 | destroy_nilfs(nilfs); |
368 | sbi->s_super = NULL; | ||
369 | sb->s_fs_info = NULL; | 367 | sb->s_fs_info = NULL; |
370 | kfree(sbi); | ||
371 | } | 368 | } |
372 | 369 | ||
373 | static int nilfs_sync_fs(struct super_block *sb, int wait) | 370 | static int nilfs_sync_fs(struct super_block *sb, int wait) |
374 | { | 371 | { |
375 | struct nilfs_sb_info *sbi = NILFS_SB(sb); | 372 | struct the_nilfs *nilfs = sb->s_fs_info; |
376 | struct the_nilfs *nilfs = sbi->s_nilfs; | ||
377 | struct nilfs_super_block **sbp; | 373 | struct nilfs_super_block **sbp; |
378 | int err = 0; | 374 | int err = 0; |
379 | 375 | ||
@@ -383,10 +379,10 @@ static int nilfs_sync_fs(struct super_block *sb, int wait) | |||
383 | 379 | ||
384 | down_write(&nilfs->ns_sem); | 380 | down_write(&nilfs->ns_sem); |
385 | if (nilfs_sb_dirty(nilfs)) { | 381 | if (nilfs_sb_dirty(nilfs)) { |
386 | sbp = nilfs_prepare_super(sbi, nilfs_sb_will_flip(nilfs)); | 382 | sbp = nilfs_prepare_super(sb, nilfs_sb_will_flip(nilfs)); |
387 | if (likely(sbp)) { | 383 | if (likely(sbp)) { |
388 | nilfs_set_log_cursor(sbp[0], nilfs); | 384 | nilfs_set_log_cursor(sbp[0], nilfs); |
389 | nilfs_commit_super(sbi, NILFS_SB_COMMIT); | 385 | nilfs_commit_super(sb, NILFS_SB_COMMIT); |
390 | } | 386 | } |
391 | } | 387 | } |
392 | up_write(&nilfs->ns_sem); | 388 | up_write(&nilfs->ns_sem); |
@@ -394,10 +390,10 @@ static int nilfs_sync_fs(struct super_block *sb, int wait) | |||
394 | return err; | 390 | return err; |
395 | } | 391 | } |
396 | 392 | ||
397 | int nilfs_attach_checkpoint(struct nilfs_sb_info *sbi, __u64 cno, int curr_mnt, | 393 | int nilfs_attach_checkpoint(struct super_block *sb, __u64 cno, int curr_mnt, |
398 | struct nilfs_root **rootp) | 394 | struct nilfs_root **rootp) |
399 | { | 395 | { |
400 | struct the_nilfs *nilfs = sbi->s_nilfs; | 396 | struct the_nilfs *nilfs = sb->s_fs_info; |
401 | struct nilfs_root *root; | 397 | struct nilfs_root *root; |
402 | struct nilfs_checkpoint *raw_cp; | 398 | struct nilfs_checkpoint *raw_cp; |
403 | struct buffer_head *bh_cp; | 399 | struct buffer_head *bh_cp; |
@@ -426,7 +422,7 @@ int nilfs_attach_checkpoint(struct nilfs_sb_info *sbi, __u64 cno, int curr_mnt, | |||
426 | goto failed; | 422 | goto failed; |
427 | } | 423 | } |
428 | 424 | ||
429 | err = nilfs_ifile_read(sbi->s_super, root, nilfs->ns_inode_size, | 425 | err = nilfs_ifile_read(sb, root, nilfs->ns_inode_size, |
430 | &raw_cp->cp_ifile_inode, &root->ifile); | 426 | &raw_cp->cp_ifile_inode, &root->ifile); |
431 | if (err) | 427 | if (err) |
432 | goto failed_bh; | 428 | goto failed_bh; |
@@ -450,8 +446,7 @@ int nilfs_attach_checkpoint(struct nilfs_sb_info *sbi, __u64 cno, int curr_mnt, | |||
450 | 446 | ||
451 | static int nilfs_freeze(struct super_block *sb) | 447 | static int nilfs_freeze(struct super_block *sb) |
452 | { | 448 | { |
453 | struct nilfs_sb_info *sbi = NILFS_SB(sb); | 449 | struct the_nilfs *nilfs = sb->s_fs_info; |
454 | struct the_nilfs *nilfs = sbi->s_nilfs; | ||
455 | int err; | 450 | int err; |
456 | 451 | ||
457 | if (sb->s_flags & MS_RDONLY) | 452 | if (sb->s_flags & MS_RDONLY) |
@@ -459,21 +454,20 @@ static int nilfs_freeze(struct super_block *sb) | |||
459 | 454 | ||
460 | /* Mark super block clean */ | 455 | /* Mark super block clean */ |
461 | down_write(&nilfs->ns_sem); | 456 | down_write(&nilfs->ns_sem); |
462 | err = nilfs_cleanup_super(sbi); | 457 | err = nilfs_cleanup_super(sb); |
463 | up_write(&nilfs->ns_sem); | 458 | up_write(&nilfs->ns_sem); |
464 | return err; | 459 | return err; |
465 | } | 460 | } |
466 | 461 | ||
467 | static int nilfs_unfreeze(struct super_block *sb) | 462 | static int nilfs_unfreeze(struct super_block *sb) |
468 | { | 463 | { |
469 | struct nilfs_sb_info *sbi = NILFS_SB(sb); | 464 | struct the_nilfs *nilfs = sb->s_fs_info; |
470 | struct the_nilfs *nilfs = sbi->s_nilfs; | ||
471 | 465 | ||
472 | if (sb->s_flags & MS_RDONLY) | 466 | if (sb->s_flags & MS_RDONLY) |
473 | return 0; | 467 | return 0; |
474 | 468 | ||
475 | down_write(&nilfs->ns_sem); | 469 | down_write(&nilfs->ns_sem); |
476 | nilfs_setup_super(sbi, false); | 470 | nilfs_setup_super(sb, false); |
477 | up_write(&nilfs->ns_sem); | 471 | up_write(&nilfs->ns_sem); |
478 | return 0; | 472 | return 0; |
479 | } | 473 | } |
@@ -530,22 +524,22 @@ static int nilfs_statfs(struct dentry *dentry, struct kstatfs *buf) | |||
530 | static int nilfs_show_options(struct seq_file *seq, struct vfsmount *vfs) | 524 | static int nilfs_show_options(struct seq_file *seq, struct vfsmount *vfs) |
531 | { | 525 | { |
532 | struct super_block *sb = vfs->mnt_sb; | 526 | struct super_block *sb = vfs->mnt_sb; |
533 | struct nilfs_sb_info *sbi = NILFS_SB(sb); | 527 | struct the_nilfs *nilfs = sb->s_fs_info; |
534 | struct nilfs_root *root = NILFS_I(vfs->mnt_root->d_inode)->i_root; | 528 | struct nilfs_root *root = NILFS_I(vfs->mnt_root->d_inode)->i_root; |
535 | 529 | ||
536 | if (!nilfs_test_opt(sbi, BARRIER)) | 530 | if (!nilfs_test_opt(nilfs, BARRIER)) |
537 | seq_puts(seq, ",nobarrier"); | 531 | seq_puts(seq, ",nobarrier"); |
538 | if (root->cno != NILFS_CPTREE_CURRENT_CNO) | 532 | if (root->cno != NILFS_CPTREE_CURRENT_CNO) |
539 | seq_printf(seq, ",cp=%llu", (unsigned long long)root->cno); | 533 | seq_printf(seq, ",cp=%llu", (unsigned long long)root->cno); |
540 | if (nilfs_test_opt(sbi, ERRORS_PANIC)) | 534 | if (nilfs_test_opt(nilfs, ERRORS_PANIC)) |
541 | seq_puts(seq, ",errors=panic"); | 535 | seq_puts(seq, ",errors=panic"); |
542 | if (nilfs_test_opt(sbi, ERRORS_CONT)) | 536 | if (nilfs_test_opt(nilfs, ERRORS_CONT)) |
543 | seq_puts(seq, ",errors=continue"); | 537 | seq_puts(seq, ",errors=continue"); |
544 | if (nilfs_test_opt(sbi, STRICT_ORDER)) | 538 | if (nilfs_test_opt(nilfs, STRICT_ORDER)) |
545 | seq_puts(seq, ",order=strict"); | 539 | seq_puts(seq, ",order=strict"); |
546 | if (nilfs_test_opt(sbi, NORECOVERY)) | 540 | if (nilfs_test_opt(nilfs, NORECOVERY)) |
547 | seq_puts(seq, ",norecovery"); | 541 | seq_puts(seq, ",norecovery"); |
548 | if (nilfs_test_opt(sbi, DISCARD)) | 542 | if (nilfs_test_opt(nilfs, DISCARD)) |
549 | seq_puts(seq, ",discard"); | 543 | seq_puts(seq, ",discard"); |
550 | 544 | ||
551 | return 0; | 545 | return 0; |
@@ -594,7 +588,7 @@ static match_table_t tokens = { | |||
594 | 588 | ||
595 | static int parse_options(char *options, struct super_block *sb, int is_remount) | 589 | static int parse_options(char *options, struct super_block *sb, int is_remount) |
596 | { | 590 | { |
597 | struct nilfs_sb_info *sbi = NILFS_SB(sb); | 591 | struct the_nilfs *nilfs = sb->s_fs_info; |
598 | char *p; | 592 | char *p; |
599 | substring_t args[MAX_OPT_ARGS]; | 593 | substring_t args[MAX_OPT_ARGS]; |
600 | 594 | ||
@@ -609,29 +603,29 @@ static int parse_options(char *options, struct super_block *sb, int is_remount) | |||
609 | token = match_token(p, tokens, args); | 603 | token = match_token(p, tokens, args); |
610 | switch (token) { | 604 | switch (token) { |
611 | case Opt_barrier: | 605 | case Opt_barrier: |
612 | nilfs_set_opt(sbi, BARRIER); | 606 | nilfs_set_opt(nilfs, BARRIER); |
613 | break; | 607 | break; |
614 | case Opt_nobarrier: | 608 | case Opt_nobarrier: |
615 | nilfs_clear_opt(sbi, BARRIER); | 609 | nilfs_clear_opt(nilfs, BARRIER); |
616 | break; | 610 | break; |
617 | case Opt_order: | 611 | case Opt_order: |
618 | if (strcmp(args[0].from, "relaxed") == 0) | 612 | if (strcmp(args[0].from, "relaxed") == 0) |
619 | /* Ordered data semantics */ | 613 | /* Ordered data semantics */ |
620 | nilfs_clear_opt(sbi, STRICT_ORDER); | 614 | nilfs_clear_opt(nilfs, STRICT_ORDER); |
621 | else if (strcmp(args[0].from, "strict") == 0) | 615 | else if (strcmp(args[0].from, "strict") == 0) |
622 | /* Strict in-order semantics */ | 616 | /* Strict in-order semantics */ |
623 | nilfs_set_opt(sbi, STRICT_ORDER); | 617 | nilfs_set_opt(nilfs, STRICT_ORDER); |
624 | else | 618 | else |
625 | return 0; | 619 | return 0; |
626 | break; | 620 | break; |
627 | case Opt_err_panic: | 621 | case Opt_err_panic: |
628 | nilfs_write_opt(sbi, ERROR_MODE, ERRORS_PANIC); | 622 | nilfs_write_opt(nilfs, ERROR_MODE, ERRORS_PANIC); |
629 | break; | 623 | break; |
630 | case Opt_err_ro: | 624 | case Opt_err_ro: |
631 | nilfs_write_opt(sbi, ERROR_MODE, ERRORS_RO); | 625 | nilfs_write_opt(nilfs, ERROR_MODE, ERRORS_RO); |
632 | break; | 626 | break; |
633 | case Opt_err_cont: | 627 | case Opt_err_cont: |
634 | nilfs_write_opt(sbi, ERROR_MODE, ERRORS_CONT); | 628 | nilfs_write_opt(nilfs, ERROR_MODE, ERRORS_CONT); |
635 | break; | 629 | break; |
636 | case Opt_snapshot: | 630 | case Opt_snapshot: |
637 | if (is_remount) { | 631 | if (is_remount) { |
@@ -642,13 +636,13 @@ static int parse_options(char *options, struct super_block *sb, int is_remount) | |||
642 | } | 636 | } |
643 | break; | 637 | break; |
644 | case Opt_norecovery: | 638 | case Opt_norecovery: |
645 | nilfs_set_opt(sbi, NORECOVERY); | 639 | nilfs_set_opt(nilfs, NORECOVERY); |
646 | break; | 640 | break; |
647 | case Opt_discard: | 641 | case Opt_discard: |
648 | nilfs_set_opt(sbi, DISCARD); | 642 | nilfs_set_opt(nilfs, DISCARD); |
649 | break; | 643 | break; |
650 | case Opt_nodiscard: | 644 | case Opt_nodiscard: |
651 | nilfs_clear_opt(sbi, DISCARD); | 645 | nilfs_clear_opt(nilfs, DISCARD); |
652 | break; | 646 | break; |
653 | default: | 647 | default: |
654 | printk(KERN_ERR | 648 | printk(KERN_ERR |
@@ -660,22 +654,24 @@ static int parse_options(char *options, struct super_block *sb, int is_remount) | |||
660 | } | 654 | } |
661 | 655 | ||
662 | static inline void | 656 | static inline void |
663 | nilfs_set_default_options(struct nilfs_sb_info *sbi, | 657 | nilfs_set_default_options(struct super_block *sb, |
664 | struct nilfs_super_block *sbp) | 658 | struct nilfs_super_block *sbp) |
665 | { | 659 | { |
666 | sbi->s_mount_opt = | 660 | struct the_nilfs *nilfs = sb->s_fs_info; |
661 | |||
662 | nilfs->ns_mount_opt = | ||
667 | NILFS_MOUNT_ERRORS_RO | NILFS_MOUNT_BARRIER; | 663 | NILFS_MOUNT_ERRORS_RO | NILFS_MOUNT_BARRIER; |
668 | } | 664 | } |
669 | 665 | ||
670 | static int nilfs_setup_super(struct nilfs_sb_info *sbi, int is_mount) | 666 | static int nilfs_setup_super(struct super_block *sb, int is_mount) |
671 | { | 667 | { |
672 | struct the_nilfs *nilfs = sbi->s_nilfs; | 668 | struct the_nilfs *nilfs = sb->s_fs_info; |
673 | struct nilfs_super_block **sbp; | 669 | struct nilfs_super_block **sbp; |
674 | int max_mnt_count; | 670 | int max_mnt_count; |
675 | int mnt_count; | 671 | int mnt_count; |
676 | 672 | ||
677 | /* nilfs->ns_sem must be locked by the caller. */ | 673 | /* nilfs->ns_sem must be locked by the caller. */ |
678 | sbp = nilfs_prepare_super(sbi, 0); | 674 | sbp = nilfs_prepare_super(sb, 0); |
679 | if (!sbp) | 675 | if (!sbp) |
680 | return -EIO; | 676 | return -EIO; |
681 | 677 | ||
@@ -706,7 +702,7 @@ skip_mount_setup: | |||
706 | /* synchronize sbp[1] with sbp[0] */ | 702 | /* synchronize sbp[1] with sbp[0] */ |
707 | if (sbp[1]) | 703 | if (sbp[1]) |
708 | memcpy(sbp[1], sbp[0], nilfs->ns_sbsize); | 704 | memcpy(sbp[1], sbp[0], nilfs->ns_sbsize); |
709 | return nilfs_commit_super(sbi, NILFS_SB_COMMIT_ALL); | 705 | return nilfs_commit_super(sb, NILFS_SB_COMMIT_ALL); |
710 | } | 706 | } |
711 | 707 | ||
712 | struct nilfs_super_block *nilfs_read_super_block(struct super_block *sb, | 708 | struct nilfs_super_block *nilfs_read_super_block(struct super_block *sb, |
@@ -727,7 +723,7 @@ int nilfs_store_magic_and_option(struct super_block *sb, | |||
727 | struct nilfs_super_block *sbp, | 723 | struct nilfs_super_block *sbp, |
728 | char *data) | 724 | char *data) |
729 | { | 725 | { |
730 | struct nilfs_sb_info *sbi = NILFS_SB(sb); | 726 | struct the_nilfs *nilfs = sb->s_fs_info; |
731 | 727 | ||
732 | sb->s_magic = le16_to_cpu(sbp->s_magic); | 728 | sb->s_magic = le16_to_cpu(sbp->s_magic); |
733 | 729 | ||
@@ -736,12 +732,12 @@ int nilfs_store_magic_and_option(struct super_block *sb, | |||
736 | sb->s_flags |= MS_NOATIME; | 732 | sb->s_flags |= MS_NOATIME; |
737 | #endif | 733 | #endif |
738 | 734 | ||
739 | nilfs_set_default_options(sbi, sbp); | 735 | nilfs_set_default_options(sb, sbp); |
740 | 736 | ||
741 | sbi->s_resuid = le16_to_cpu(sbp->s_def_resuid); | 737 | nilfs->ns_resuid = le16_to_cpu(sbp->s_def_resuid); |
742 | sbi->s_resgid = le16_to_cpu(sbp->s_def_resgid); | 738 | nilfs->ns_resgid = le16_to_cpu(sbp->s_def_resgid); |
743 | sbi->s_interval = le32_to_cpu(sbp->s_c_interval); | 739 | nilfs->ns_interval = le32_to_cpu(sbp->s_c_interval); |
744 | sbi->s_watermark = le32_to_cpu(sbp->s_c_block_max); | 740 | nilfs->ns_watermark = le32_to_cpu(sbp->s_c_block_max); |
745 | 741 | ||
746 | return !parse_options(data, sb, 0) ? -EINVAL : 0 ; | 742 | return !parse_options(data, sb, 0) ? -EINVAL : 0 ; |
747 | } | 743 | } |
@@ -822,7 +818,7 @@ static int nilfs_get_root_dentry(struct super_block *sb, | |||
822 | static int nilfs_attach_snapshot(struct super_block *s, __u64 cno, | 818 | static int nilfs_attach_snapshot(struct super_block *s, __u64 cno, |
823 | struct dentry **root_dentry) | 819 | struct dentry **root_dentry) |
824 | { | 820 | { |
825 | struct the_nilfs *nilfs = NILFS_SB(s)->s_nilfs; | 821 | struct the_nilfs *nilfs = s->s_fs_info; |
826 | struct nilfs_root *root; | 822 | struct nilfs_root *root; |
827 | int ret; | 823 | int ret; |
828 | 824 | ||
@@ -840,7 +836,7 @@ static int nilfs_attach_snapshot(struct super_block *s, __u64 cno, | |||
840 | goto out; | 836 | goto out; |
841 | } | 837 | } |
842 | 838 | ||
843 | ret = nilfs_attach_checkpoint(NILFS_SB(s), cno, false, &root); | 839 | ret = nilfs_attach_checkpoint(s, cno, false, &root); |
844 | if (ret) { | 840 | if (ret) { |
845 | printk(KERN_ERR "NILFS: error loading snapshot " | 841 | printk(KERN_ERR "NILFS: error loading snapshot " |
846 | "(checkpoint number=%llu).\n", | 842 | "(checkpoint number=%llu).\n", |
@@ -874,7 +870,7 @@ static int nilfs_try_to_shrink_tree(struct dentry *root_dentry) | |||
874 | 870 | ||
875 | int nilfs_checkpoint_is_mounted(struct super_block *sb, __u64 cno) | 871 | int nilfs_checkpoint_is_mounted(struct super_block *sb, __u64 cno) |
876 | { | 872 | { |
877 | struct the_nilfs *nilfs = NILFS_SB(sb)->s_nilfs; | 873 | struct the_nilfs *nilfs = sb->s_fs_info; |
878 | struct nilfs_root *root; | 874 | struct nilfs_root *root; |
879 | struct inode *inode; | 875 | struct inode *inode; |
880 | struct dentry *dentry; | 876 | struct dentry *dentry; |
@@ -887,7 +883,7 @@ int nilfs_checkpoint_is_mounted(struct super_block *sb, __u64 cno) | |||
887 | return true; /* protect recent checkpoints */ | 883 | return true; /* protect recent checkpoints */ |
888 | 884 | ||
889 | ret = false; | 885 | ret = false; |
890 | root = nilfs_lookup_root(NILFS_SB(sb)->s_nilfs, cno); | 886 | root = nilfs_lookup_root(nilfs, cno); |
891 | if (root) { | 887 | if (root) { |
892 | inode = nilfs_ilookup(sb, root, NILFS_ROOT_INO); | 888 | inode = nilfs_ilookup(sb, root, NILFS_ROOT_INO); |
893 | if (inode) { | 889 | if (inode) { |
@@ -917,43 +913,21 @@ static int | |||
917 | nilfs_fill_super(struct super_block *sb, void *data, int silent) | 913 | nilfs_fill_super(struct super_block *sb, void *data, int silent) |
918 | { | 914 | { |
919 | struct the_nilfs *nilfs; | 915 | struct the_nilfs *nilfs; |
920 | struct nilfs_sb_info *sbi; | ||
921 | struct nilfs_root *fsroot; | 916 | struct nilfs_root *fsroot; |
922 | struct backing_dev_info *bdi; | 917 | struct backing_dev_info *bdi; |
923 | __u64 cno; | 918 | __u64 cno; |
924 | int err; | 919 | int err; |
925 | 920 | ||
926 | sbi = kzalloc(sizeof(*sbi), GFP_KERNEL); | 921 | nilfs = alloc_nilfs(sb->s_bdev); |
927 | if (!sbi) | 922 | if (!nilfs) |
928 | return -ENOMEM; | 923 | return -ENOMEM; |
929 | 924 | ||
930 | sb->s_fs_info = sbi; | 925 | sb->s_fs_info = nilfs; |
931 | sbi->s_super = sb; | ||
932 | |||
933 | nilfs = alloc_nilfs(sb->s_bdev); | ||
934 | if (!nilfs) { | ||
935 | err = -ENOMEM; | ||
936 | goto failed_sbi; | ||
937 | } | ||
938 | sbi->s_nilfs = nilfs; | ||
939 | 926 | ||
940 | err = init_nilfs(nilfs, sbi, (char *)data); | 927 | err = init_nilfs(nilfs, sb, (char *)data); |
941 | if (err) | 928 | if (err) |
942 | goto failed_nilfs; | 929 | goto failed_nilfs; |
943 | 930 | ||
944 | spin_lock_init(&sbi->s_inode_lock); | ||
945 | INIT_LIST_HEAD(&sbi->s_dirty_files); | ||
946 | |||
947 | /* | ||
948 | * Following initialization is overlapped because | ||
949 | * nilfs_sb_info structure has been cleared at the beginning. | ||
950 | * But we reserve them to keep our interest and make ready | ||
951 | * for the future change. | ||
952 | */ | ||
953 | get_random_bytes(&sbi->s_next_generation, | ||
954 | sizeof(sbi->s_next_generation)); | ||
955 | spin_lock_init(&sbi->s_next_gen_lock); | ||
956 | |||
957 | sb->s_op = &nilfs_sops; | 931 | sb->s_op = &nilfs_sops; |
958 | sb->s_export_op = &nilfs_export_ops; | 932 | sb->s_export_op = &nilfs_export_ops; |
959 | sb->s_root = NULL; | 933 | sb->s_root = NULL; |
@@ -962,12 +936,12 @@ nilfs_fill_super(struct super_block *sb, void *data, int silent) | |||
962 | bdi = sb->s_bdev->bd_inode->i_mapping->backing_dev_info; | 936 | bdi = sb->s_bdev->bd_inode->i_mapping->backing_dev_info; |
963 | sb->s_bdi = bdi ? : &default_backing_dev_info; | 937 | sb->s_bdi = bdi ? : &default_backing_dev_info; |
964 | 938 | ||
965 | err = load_nilfs(nilfs, sbi); | 939 | err = load_nilfs(nilfs, sb); |
966 | if (err) | 940 | if (err) |
967 | goto failed_nilfs; | 941 | goto failed_nilfs; |
968 | 942 | ||
969 | cno = nilfs_last_cno(nilfs); | 943 | cno = nilfs_last_cno(nilfs); |
970 | err = nilfs_attach_checkpoint(sbi, cno, true, &fsroot); | 944 | err = nilfs_attach_checkpoint(sb, cno, true, &fsroot); |
971 | if (err) { | 945 | if (err) { |
972 | printk(KERN_ERR "NILFS: error loading last checkpoint " | 946 | printk(KERN_ERR "NILFS: error loading last checkpoint " |
973 | "(checkpoint number=%llu).\n", (unsigned long long)cno); | 947 | "(checkpoint number=%llu).\n", (unsigned long long)cno); |
@@ -975,7 +949,7 @@ nilfs_fill_super(struct super_block *sb, void *data, int silent) | |||
975 | } | 949 | } |
976 | 950 | ||
977 | if (!(sb->s_flags & MS_RDONLY)) { | 951 | if (!(sb->s_flags & MS_RDONLY)) { |
978 | err = nilfs_attach_segment_constructor(sbi, fsroot); | 952 | err = nilfs_attach_log_writer(sb, fsroot); |
979 | if (err) | 953 | if (err) |
980 | goto failed_checkpoint; | 954 | goto failed_checkpoint; |
981 | } | 955 | } |
@@ -988,14 +962,14 @@ nilfs_fill_super(struct super_block *sb, void *data, int silent) | |||
988 | 962 | ||
989 | if (!(sb->s_flags & MS_RDONLY)) { | 963 | if (!(sb->s_flags & MS_RDONLY)) { |
990 | down_write(&nilfs->ns_sem); | 964 | down_write(&nilfs->ns_sem); |
991 | nilfs_setup_super(sbi, true); | 965 | nilfs_setup_super(sb, true); |
992 | up_write(&nilfs->ns_sem); | 966 | up_write(&nilfs->ns_sem); |
993 | } | 967 | } |
994 | 968 | ||
995 | return 0; | 969 | return 0; |
996 | 970 | ||
997 | failed_segctor: | 971 | failed_segctor: |
998 | nilfs_detach_segment_constructor(sbi); | 972 | nilfs_detach_log_writer(sb); |
999 | 973 | ||
1000 | failed_checkpoint: | 974 | failed_checkpoint: |
1001 | nilfs_put_root(fsroot); | 975 | nilfs_put_root(fsroot); |
@@ -1007,23 +981,18 @@ nilfs_fill_super(struct super_block *sb, void *data, int silent) | |||
1007 | 981 | ||
1008 | failed_nilfs: | 982 | failed_nilfs: |
1009 | destroy_nilfs(nilfs); | 983 | destroy_nilfs(nilfs); |
1010 | |||
1011 | failed_sbi: | ||
1012 | sb->s_fs_info = NULL; | ||
1013 | kfree(sbi); | ||
1014 | return err; | 984 | return err; |
1015 | } | 985 | } |
1016 | 986 | ||
1017 | static int nilfs_remount(struct super_block *sb, int *flags, char *data) | 987 | static int nilfs_remount(struct super_block *sb, int *flags, char *data) |
1018 | { | 988 | { |
1019 | struct nilfs_sb_info *sbi = NILFS_SB(sb); | 989 | struct the_nilfs *nilfs = sb->s_fs_info; |
1020 | struct the_nilfs *nilfs = sbi->s_nilfs; | ||
1021 | unsigned long old_sb_flags; | 990 | unsigned long old_sb_flags; |
1022 | unsigned long old_mount_opt; | 991 | unsigned long old_mount_opt; |
1023 | int err; | 992 | int err; |
1024 | 993 | ||
1025 | old_sb_flags = sb->s_flags; | 994 | old_sb_flags = sb->s_flags; |
1026 | old_mount_opt = sbi->s_mount_opt; | 995 | old_mount_opt = nilfs->ns_mount_opt; |
1027 | 996 | ||
1028 | if (!parse_options(data, sb, 1)) { | 997 | if (!parse_options(data, sb, 1)) { |
1029 | err = -EINVAL; | 998 | err = -EINVAL; |
@@ -1043,8 +1012,8 @@ static int nilfs_remount(struct super_block *sb, int *flags, char *data) | |||
1043 | if ((*flags & MS_RDONLY) == (sb->s_flags & MS_RDONLY)) | 1012 | if ((*flags & MS_RDONLY) == (sb->s_flags & MS_RDONLY)) |
1044 | goto out; | 1013 | goto out; |
1045 | if (*flags & MS_RDONLY) { | 1014 | if (*flags & MS_RDONLY) { |
1046 | /* Shutting down the segment constructor */ | 1015 | /* Shutting down log writer */ |
1047 | nilfs_detach_segment_constructor(sbi); | 1016 | nilfs_detach_log_writer(sb); |
1048 | sb->s_flags |= MS_RDONLY; | 1017 | sb->s_flags |= MS_RDONLY; |
1049 | 1018 | ||
1050 | /* | 1019 | /* |
@@ -1052,7 +1021,7 @@ static int nilfs_remount(struct super_block *sb, int *flags, char *data) | |||
1052 | * the RDONLY flag and then mark the partition as valid again. | 1021 | * the RDONLY flag and then mark the partition as valid again. |
1053 | */ | 1022 | */ |
1054 | down_write(&nilfs->ns_sem); | 1023 | down_write(&nilfs->ns_sem); |
1055 | nilfs_cleanup_super(sbi); | 1024 | nilfs_cleanup_super(sb); |
1056 | up_write(&nilfs->ns_sem); | 1025 | up_write(&nilfs->ns_sem); |
1057 | } else { | 1026 | } else { |
1058 | __u64 features; | 1027 | __u64 features; |
@@ -1079,12 +1048,12 @@ static int nilfs_remount(struct super_block *sb, int *flags, char *data) | |||
1079 | sb->s_flags &= ~MS_RDONLY; | 1048 | sb->s_flags &= ~MS_RDONLY; |
1080 | 1049 | ||
1081 | root = NILFS_I(sb->s_root->d_inode)->i_root; | 1050 | root = NILFS_I(sb->s_root->d_inode)->i_root; |
1082 | err = nilfs_attach_segment_constructor(sbi, root); | 1051 | err = nilfs_attach_log_writer(sb, root); |
1083 | if (err) | 1052 | if (err) |
1084 | goto restore_opts; | 1053 | goto restore_opts; |
1085 | 1054 | ||
1086 | down_write(&nilfs->ns_sem); | 1055 | down_write(&nilfs->ns_sem); |
1087 | nilfs_setup_super(sbi, true); | 1056 | nilfs_setup_super(sb, true); |
1088 | up_write(&nilfs->ns_sem); | 1057 | up_write(&nilfs->ns_sem); |
1089 | } | 1058 | } |
1090 | out: | 1059 | out: |
@@ -1092,13 +1061,12 @@ static int nilfs_remount(struct super_block *sb, int *flags, char *data) | |||
1092 | 1061 | ||
1093 | restore_opts: | 1062 | restore_opts: |
1094 | sb->s_flags = old_sb_flags; | 1063 | sb->s_flags = old_sb_flags; |
1095 | sbi->s_mount_opt = old_mount_opt; | 1064 | nilfs->ns_mount_opt = old_mount_opt; |
1096 | return err; | 1065 | return err; |
1097 | } | 1066 | } |
1098 | 1067 | ||
1099 | struct nilfs_super_data { | 1068 | struct nilfs_super_data { |
1100 | struct block_device *bdev; | 1069 | struct block_device *bdev; |
1101 | struct nilfs_sb_info *sbi; | ||
1102 | __u64 cno; | 1070 | __u64 cno; |
1103 | int flags; | 1071 | int flags; |
1104 | }; | 1072 | }; |
diff --git a/fs/nilfs2/the_nilfs.c b/fs/nilfs2/the_nilfs.c index ad4ac607cf57..d2acd1a651f3 100644 --- a/fs/nilfs2/the_nilfs.c +++ b/fs/nilfs2/the_nilfs.c | |||
@@ -25,6 +25,7 @@ | |||
25 | #include <linux/slab.h> | 25 | #include <linux/slab.h> |
26 | #include <linux/blkdev.h> | 26 | #include <linux/blkdev.h> |
27 | #include <linux/backing-dev.h> | 27 | #include <linux/backing-dev.h> |
28 | #include <linux/random.h> | ||
28 | #include <linux/crc32.h> | 29 | #include <linux/crc32.h> |
29 | #include "nilfs.h" | 30 | #include "nilfs.h" |
30 | #include "segment.h" | 31 | #include "segment.h" |
@@ -75,7 +76,10 @@ struct the_nilfs *alloc_nilfs(struct block_device *bdev) | |||
75 | nilfs->ns_bdev = bdev; | 76 | nilfs->ns_bdev = bdev; |
76 | atomic_set(&nilfs->ns_ndirtyblks, 0); | 77 | atomic_set(&nilfs->ns_ndirtyblks, 0); |
77 | init_rwsem(&nilfs->ns_sem); | 78 | init_rwsem(&nilfs->ns_sem); |
79 | INIT_LIST_HEAD(&nilfs->ns_dirty_files); | ||
78 | INIT_LIST_HEAD(&nilfs->ns_gc_inodes); | 80 | INIT_LIST_HEAD(&nilfs->ns_gc_inodes); |
81 | spin_lock_init(&nilfs->ns_inode_lock); | ||
82 | spin_lock_init(&nilfs->ns_next_gen_lock); | ||
79 | spin_lock_init(&nilfs->ns_last_segment_lock); | 83 | spin_lock_init(&nilfs->ns_last_segment_lock); |
80 | nilfs->ns_cptree = RB_ROOT; | 84 | nilfs->ns_cptree = RB_ROOT; |
81 | spin_lock_init(&nilfs->ns_cptree_lock); | 85 | spin_lock_init(&nilfs->ns_cptree_lock); |
@@ -197,16 +201,16 @@ static int nilfs_store_log_cursor(struct the_nilfs *nilfs, | |||
197 | /** | 201 | /** |
198 | * load_nilfs - load and recover the nilfs | 202 | * load_nilfs - load and recover the nilfs |
199 | * @nilfs: the_nilfs structure to be released | 203 | * @nilfs: the_nilfs structure to be released |
200 | * @sbi: nilfs_sb_info used to recover past segment | 204 | * @sb: super block isntance used to recover past segment |
201 | * | 205 | * |
202 | * load_nilfs() searches and load the latest super root, | 206 | * load_nilfs() searches and load the latest super root, |
203 | * attaches the last segment, and does recovery if needed. | 207 | * attaches the last segment, and does recovery if needed. |
204 | * The caller must call this exclusively for simultaneous mounts. | 208 | * The caller must call this exclusively for simultaneous mounts. |
205 | */ | 209 | */ |
206 | int load_nilfs(struct the_nilfs *nilfs, struct nilfs_sb_info *sbi) | 210 | int load_nilfs(struct the_nilfs *nilfs, struct super_block *sb) |
207 | { | 211 | { |
208 | struct nilfs_recovery_info ri; | 212 | struct nilfs_recovery_info ri; |
209 | unsigned int s_flags = sbi->s_super->s_flags; | 213 | unsigned int s_flags = sb->s_flags; |
210 | int really_read_only = bdev_read_only(nilfs->ns_bdev); | 214 | int really_read_only = bdev_read_only(nilfs->ns_bdev); |
211 | int valid_fs = nilfs_valid_fs(nilfs); | 215 | int valid_fs = nilfs_valid_fs(nilfs); |
212 | int err; | 216 | int err; |
@@ -271,7 +275,7 @@ int load_nilfs(struct the_nilfs *nilfs, struct nilfs_sb_info *sbi) | |||
271 | goto scan_error; | 275 | goto scan_error; |
272 | } | 276 | } |
273 | 277 | ||
274 | err = nilfs_load_super_root(nilfs, sbi->s_super, ri.ri_super_root); | 278 | err = nilfs_load_super_root(nilfs, sb, ri.ri_super_root); |
275 | if (unlikely(err)) { | 279 | if (unlikely(err)) { |
276 | printk(KERN_ERR "NILFS: error loading super root.\n"); | 280 | printk(KERN_ERR "NILFS: error loading super root.\n"); |
277 | goto failed; | 281 | goto failed; |
@@ -283,7 +287,7 @@ int load_nilfs(struct the_nilfs *nilfs, struct nilfs_sb_info *sbi) | |||
283 | if (s_flags & MS_RDONLY) { | 287 | if (s_flags & MS_RDONLY) { |
284 | __u64 features; | 288 | __u64 features; |
285 | 289 | ||
286 | if (nilfs_test_opt(sbi, NORECOVERY)) { | 290 | if (nilfs_test_opt(nilfs, NORECOVERY)) { |
287 | printk(KERN_INFO "NILFS: norecovery option specified. " | 291 | printk(KERN_INFO "NILFS: norecovery option specified. " |
288 | "skipping roll-forward recovery\n"); | 292 | "skipping roll-forward recovery\n"); |
289 | goto skip_recovery; | 293 | goto skip_recovery; |
@@ -304,21 +308,21 @@ int load_nilfs(struct the_nilfs *nilfs, struct nilfs_sb_info *sbi) | |||
304 | err = -EROFS; | 308 | err = -EROFS; |
305 | goto failed_unload; | 309 | goto failed_unload; |
306 | } | 310 | } |
307 | sbi->s_super->s_flags &= ~MS_RDONLY; | 311 | sb->s_flags &= ~MS_RDONLY; |
308 | } else if (nilfs_test_opt(sbi, NORECOVERY)) { | 312 | } else if (nilfs_test_opt(nilfs, NORECOVERY)) { |
309 | printk(KERN_ERR "NILFS: recovery cancelled because norecovery " | 313 | printk(KERN_ERR "NILFS: recovery cancelled because norecovery " |
310 | "option was specified for a read/write mount\n"); | 314 | "option was specified for a read/write mount\n"); |
311 | err = -EINVAL; | 315 | err = -EINVAL; |
312 | goto failed_unload; | 316 | goto failed_unload; |
313 | } | 317 | } |
314 | 318 | ||
315 | err = nilfs_salvage_orphan_logs(nilfs, sbi, &ri); | 319 | err = nilfs_salvage_orphan_logs(nilfs, sb, &ri); |
316 | if (err) | 320 | if (err) |
317 | goto failed_unload; | 321 | goto failed_unload; |
318 | 322 | ||
319 | down_write(&nilfs->ns_sem); | 323 | down_write(&nilfs->ns_sem); |
320 | nilfs->ns_mount_state |= NILFS_VALID_FS; /* set "clean" flag */ | 324 | nilfs->ns_mount_state |= NILFS_VALID_FS; /* set "clean" flag */ |
321 | err = nilfs_cleanup_super(sbi); | 325 | err = nilfs_cleanup_super(sb); |
322 | up_write(&nilfs->ns_sem); | 326 | up_write(&nilfs->ns_sem); |
323 | 327 | ||
324 | if (err) { | 328 | if (err) { |
@@ -330,7 +334,7 @@ int load_nilfs(struct the_nilfs *nilfs, struct nilfs_sb_info *sbi) | |||
330 | 334 | ||
331 | skip_recovery: | 335 | skip_recovery: |
332 | nilfs_clear_recovery_info(&ri); | 336 | nilfs_clear_recovery_info(&ri); |
333 | sbi->s_super->s_flags = s_flags; | 337 | sb->s_flags = s_flags; |
334 | return 0; | 338 | return 0; |
335 | 339 | ||
336 | scan_error: | 340 | scan_error: |
@@ -344,7 +348,7 @@ int load_nilfs(struct the_nilfs *nilfs, struct nilfs_sb_info *sbi) | |||
344 | 348 | ||
345 | failed: | 349 | failed: |
346 | nilfs_clear_recovery_info(&ri); | 350 | nilfs_clear_recovery_info(&ri); |
347 | sbi->s_super->s_flags = s_flags; | 351 | sb->s_flags = s_flags; |
348 | return err; | 352 | return err; |
349 | } | 353 | } |
350 | 354 | ||
@@ -475,10 +479,13 @@ static int nilfs_load_super_block(struct the_nilfs *nilfs, | |||
475 | return -EIO; | 479 | return -EIO; |
476 | } | 480 | } |
477 | printk(KERN_WARNING | 481 | printk(KERN_WARNING |
478 | "NILFS warning: unable to read primary superblock\n"); | 482 | "NILFS warning: unable to read primary superblock " |
479 | } else if (!sbp[1]) | 483 | "(blocksize = %d)\n", blocksize); |
484 | } else if (!sbp[1]) { | ||
480 | printk(KERN_WARNING | 485 | printk(KERN_WARNING |
481 | "NILFS warning: unable to read secondary superblock\n"); | 486 | "NILFS warning: unable to read secondary superblock " |
487 | "(blocksize = %d)\n", blocksize); | ||
488 | } | ||
482 | 489 | ||
483 | /* | 490 | /* |
484 | * Compare two super blocks and set 1 in swp if the secondary | 491 | * Compare two super blocks and set 1 in swp if the secondary |
@@ -505,7 +512,7 @@ static int nilfs_load_super_block(struct the_nilfs *nilfs, | |||
505 | 512 | ||
506 | if (!valid[!swp]) | 513 | if (!valid[!swp]) |
507 | printk(KERN_WARNING "NILFS warning: broken superblock. " | 514 | printk(KERN_WARNING "NILFS warning: broken superblock. " |
508 | "using spare superblock.\n"); | 515 | "using spare superblock (blocksize = %d).\n", blocksize); |
509 | if (swp) | 516 | if (swp) |
510 | nilfs_swap_super_block(nilfs); | 517 | nilfs_swap_super_block(nilfs); |
511 | 518 | ||
@@ -519,7 +526,6 @@ static int nilfs_load_super_block(struct the_nilfs *nilfs, | |||
519 | /** | 526 | /** |
520 | * init_nilfs - initialize a NILFS instance. | 527 | * init_nilfs - initialize a NILFS instance. |
521 | * @nilfs: the_nilfs structure | 528 | * @nilfs: the_nilfs structure |
522 | * @sbi: nilfs_sb_info | ||
523 | * @sb: super block | 529 | * @sb: super block |
524 | * @data: mount options | 530 | * @data: mount options |
525 | * | 531 | * |
@@ -530,9 +536,8 @@ static int nilfs_load_super_block(struct the_nilfs *nilfs, | |||
530 | * Return Value: On success, 0 is returned. On error, a negative error | 536 | * Return Value: On success, 0 is returned. On error, a negative error |
531 | * code is returned. | 537 | * code is returned. |
532 | */ | 538 | */ |
533 | int init_nilfs(struct the_nilfs *nilfs, struct nilfs_sb_info *sbi, char *data) | 539 | int init_nilfs(struct the_nilfs *nilfs, struct super_block *sb, char *data) |
534 | { | 540 | { |
535 | struct super_block *sb = sbi->s_super; | ||
536 | struct nilfs_super_block *sbp; | 541 | struct nilfs_super_block *sbp; |
537 | int blocksize; | 542 | int blocksize; |
538 | int err; | 543 | int err; |
@@ -588,6 +593,9 @@ int init_nilfs(struct the_nilfs *nilfs, struct nilfs_sb_info *sbi, char *data) | |||
588 | nilfs->ns_blocksize_bits = sb->s_blocksize_bits; | 593 | nilfs->ns_blocksize_bits = sb->s_blocksize_bits; |
589 | nilfs->ns_blocksize = blocksize; | 594 | nilfs->ns_blocksize = blocksize; |
590 | 595 | ||
596 | get_random_bytes(&nilfs->ns_next_generation, | ||
597 | sizeof(nilfs->ns_next_generation)); | ||
598 | |||
591 | err = nilfs_store_disk_layout(nilfs, sbp); | 599 | err = nilfs_store_disk_layout(nilfs, sbp); |
592 | if (err) | 600 | if (err) |
593 | goto failed_sbh; | 601 | goto failed_sbh; |
diff --git a/fs/nilfs2/the_nilfs.h b/fs/nilfs2/the_nilfs.h index fd85e4c05c6b..f4968145c2a3 100644 --- a/fs/nilfs2/the_nilfs.h +++ b/fs/nilfs2/the_nilfs.h | |||
@@ -31,7 +31,8 @@ | |||
31 | #include <linux/blkdev.h> | 31 | #include <linux/blkdev.h> |
32 | #include <linux/backing-dev.h> | 32 | #include <linux/backing-dev.h> |
33 | #include <linux/slab.h> | 33 | #include <linux/slab.h> |
34 | #include "sb.h" | 34 | |
35 | struct nilfs_sc_info; | ||
35 | 36 | ||
36 | /* the_nilfs struct */ | 37 | /* the_nilfs struct */ |
37 | enum { | 38 | enum { |
@@ -65,13 +66,23 @@ enum { | |||
65 | * @ns_last_cno: checkpoint number of the latest segment | 66 | * @ns_last_cno: checkpoint number of the latest segment |
66 | * @ns_prot_seq: least sequence number of segments which must not be reclaimed | 67 | * @ns_prot_seq: least sequence number of segments which must not be reclaimed |
67 | * @ns_prev_seq: base sequence number used to decide if advance log cursor | 68 | * @ns_prev_seq: base sequence number used to decide if advance log cursor |
68 | * @ns_segctor_sem: segment constructor semaphore | 69 | * @ns_writer: log writer |
70 | * @ns_segctor_sem: semaphore protecting log write | ||
69 | * @ns_dat: DAT file inode | 71 | * @ns_dat: DAT file inode |
70 | * @ns_cpfile: checkpoint file inode | 72 | * @ns_cpfile: checkpoint file inode |
71 | * @ns_sufile: segusage file inode | 73 | * @ns_sufile: segusage file inode |
72 | * @ns_cptree: rb-tree of all mounted checkpoints (nilfs_root) | 74 | * @ns_cptree: rb-tree of all mounted checkpoints (nilfs_root) |
73 | * @ns_cptree_lock: lock protecting @ns_cptree | 75 | * @ns_cptree_lock: lock protecting @ns_cptree |
76 | * @ns_dirty_files: list of dirty files | ||
77 | * @ns_inode_lock: lock protecting @ns_dirty_files | ||
74 | * @ns_gc_inodes: dummy inodes to keep live blocks | 78 | * @ns_gc_inodes: dummy inodes to keep live blocks |
79 | * @ns_next_generation: next generation number for inodes | ||
80 | * @ns_next_gen_lock: lock protecting @ns_next_generation | ||
81 | * @ns_mount_opt: mount options | ||
82 | * @ns_resuid: uid for reserved blocks | ||
83 | * @ns_resgid: gid for reserved blocks | ||
84 | * @ns_interval: checkpoint creation interval | ||
85 | * @ns_watermark: watermark for the number of dirty buffers | ||
75 | * @ns_blocksize_bits: bit length of block size | 86 | * @ns_blocksize_bits: bit length of block size |
76 | * @ns_blocksize: block size | 87 | * @ns_blocksize: block size |
77 | * @ns_nsegments: number of segments in filesystem | 88 | * @ns_nsegments: number of segments in filesystem |
@@ -131,6 +142,7 @@ struct the_nilfs { | |||
131 | u64 ns_prot_seq; | 142 | u64 ns_prot_seq; |
132 | u64 ns_prev_seq; | 143 | u64 ns_prev_seq; |
133 | 144 | ||
145 | struct nilfs_sc_info *ns_writer; | ||
134 | struct rw_semaphore ns_segctor_sem; | 146 | struct rw_semaphore ns_segctor_sem; |
135 | 147 | ||
136 | /* | 148 | /* |
@@ -145,9 +157,25 @@ struct the_nilfs { | |||
145 | struct rb_root ns_cptree; | 157 | struct rb_root ns_cptree; |
146 | spinlock_t ns_cptree_lock; | 158 | spinlock_t ns_cptree_lock; |
147 | 159 | ||
160 | /* Dirty inode list */ | ||
161 | struct list_head ns_dirty_files; | ||
162 | spinlock_t ns_inode_lock; | ||
163 | |||
148 | /* GC inode list */ | 164 | /* GC inode list */ |
149 | struct list_head ns_gc_inodes; | 165 | struct list_head ns_gc_inodes; |
150 | 166 | ||
167 | /* Inode allocator */ | ||
168 | u32 ns_next_generation; | ||
169 | spinlock_t ns_next_gen_lock; | ||
170 | |||
171 | /* Mount options */ | ||
172 | unsigned long ns_mount_opt; | ||
173 | |||
174 | uid_t ns_resuid; | ||
175 | gid_t ns_resgid; | ||
176 | unsigned long ns_interval; | ||
177 | unsigned long ns_watermark; | ||
178 | |||
151 | /* Disk layout information (static) */ | 179 | /* Disk layout information (static) */ |
152 | unsigned int ns_blocksize_bits; | 180 | unsigned int ns_blocksize_bits; |
153 | unsigned int ns_blocksize; | 181 | unsigned int ns_blocksize; |
@@ -180,6 +208,20 @@ THE_NILFS_FNS(DISCONTINUED, discontinued) | |||
180 | THE_NILFS_FNS(GC_RUNNING, gc_running) | 208 | THE_NILFS_FNS(GC_RUNNING, gc_running) |
181 | THE_NILFS_FNS(SB_DIRTY, sb_dirty) | 209 | THE_NILFS_FNS(SB_DIRTY, sb_dirty) |
182 | 210 | ||
211 | /* | ||
212 | * Mount option operations | ||
213 | */ | ||
214 | #define nilfs_clear_opt(nilfs, opt) \ | ||
215 | do { (nilfs)->ns_mount_opt &= ~NILFS_MOUNT_##opt; } while (0) | ||
216 | #define nilfs_set_opt(nilfs, opt) \ | ||
217 | do { (nilfs)->ns_mount_opt |= NILFS_MOUNT_##opt; } while (0) | ||
218 | #define nilfs_test_opt(nilfs, opt) ((nilfs)->ns_mount_opt & NILFS_MOUNT_##opt) | ||
219 | #define nilfs_write_opt(nilfs, mask, opt) \ | ||
220 | do { (nilfs)->ns_mount_opt = \ | ||
221 | (((nilfs)->ns_mount_opt & ~NILFS_MOUNT_##mask) | \ | ||
222 | NILFS_MOUNT_##opt); \ | ||
223 | } while (0) | ||
224 | |||
183 | /** | 225 | /** |
184 | * struct nilfs_root - nilfs root object | 226 | * struct nilfs_root - nilfs root object |
185 | * @cno: checkpoint number | 227 | * @cno: checkpoint number |
@@ -224,15 +266,14 @@ static inline int nilfs_sb_will_flip(struct the_nilfs *nilfs) | |||
224 | void nilfs_set_last_segment(struct the_nilfs *, sector_t, u64, __u64); | 266 | void nilfs_set_last_segment(struct the_nilfs *, sector_t, u64, __u64); |
225 | struct the_nilfs *alloc_nilfs(struct block_device *bdev); | 267 | struct the_nilfs *alloc_nilfs(struct block_device *bdev); |
226 | void destroy_nilfs(struct the_nilfs *nilfs); | 268 | void destroy_nilfs(struct the_nilfs *nilfs); |
227 | int init_nilfs(struct the_nilfs *, struct nilfs_sb_info *, char *); | 269 | int init_nilfs(struct the_nilfs *nilfs, struct super_block *sb, char *data); |
228 | int load_nilfs(struct the_nilfs *, struct nilfs_sb_info *); | 270 | int load_nilfs(struct the_nilfs *nilfs, struct super_block *sb); |
229 | int nilfs_discard_segments(struct the_nilfs *, __u64 *, size_t); | 271 | int nilfs_discard_segments(struct the_nilfs *, __u64 *, size_t); |
230 | int nilfs_count_free_blocks(struct the_nilfs *, sector_t *); | 272 | int nilfs_count_free_blocks(struct the_nilfs *, sector_t *); |
231 | struct nilfs_root *nilfs_lookup_root(struct the_nilfs *nilfs, __u64 cno); | 273 | struct nilfs_root *nilfs_lookup_root(struct the_nilfs *nilfs, __u64 cno); |
232 | struct nilfs_root *nilfs_find_or_create_root(struct the_nilfs *nilfs, | 274 | struct nilfs_root *nilfs_find_or_create_root(struct the_nilfs *nilfs, |
233 | __u64 cno); | 275 | __u64 cno); |
234 | void nilfs_put_root(struct nilfs_root *root); | 276 | void nilfs_put_root(struct nilfs_root *root); |
235 | struct nilfs_sb_info *nilfs_find_sbinfo(struct the_nilfs *, int, __u64); | ||
236 | int nilfs_near_disk_full(struct the_nilfs *); | 277 | int nilfs_near_disk_full(struct the_nilfs *); |
237 | void nilfs_fall_back_super_block(struct the_nilfs *); | 278 | void nilfs_fall_back_super_block(struct the_nilfs *); |
238 | void nilfs_swap_super_block(struct the_nilfs *); | 279 | void nilfs_swap_super_block(struct the_nilfs *); |
diff --git a/fs/notify/fanotify/fanotify_user.c b/fs/notify/fanotify/fanotify_user.c index 8b61220cffc5..6b1305dc26c0 100644 --- a/fs/notify/fanotify/fanotify_user.c +++ b/fs/notify/fanotify/fanotify_user.c | |||
@@ -876,7 +876,7 @@ SYSCALL_ALIAS(sys_fanotify_mark, SyS_fanotify_mark); | |||
876 | #endif | 876 | #endif |
877 | 877 | ||
878 | /* | 878 | /* |
879 | * fanotify_user_setup - Our initialization function. Note that we cannnot return | 879 | * fanotify_user_setup - Our initialization function. Note that we cannot return |
880 | * error because we have compiled-in VFS hooks. So an (unlikely) failure here | 880 | * error because we have compiled-in VFS hooks. So an (unlikely) failure here |
881 | * must result in panic(). | 881 | * must result in panic(). |
882 | */ | 882 | */ |
diff --git a/fs/notify/inotify/inotify_user.c b/fs/notify/inotify/inotify_user.c index 4cd5d5d78f9f..bd46e7c8a0ef 100644 --- a/fs/notify/inotify/inotify_user.c +++ b/fs/notify/inotify/inotify_user.c | |||
@@ -841,7 +841,7 @@ out: | |||
841 | } | 841 | } |
842 | 842 | ||
843 | /* | 843 | /* |
844 | * inotify_user_setup - Our initialization function. Note that we cannnot return | 844 | * inotify_user_setup - Our initialization function. Note that we cannot return |
845 | * error because we have compiled-in VFS hooks. So an (unlikely) failure here | 845 | * error because we have compiled-in VFS hooks. So an (unlikely) failure here |
846 | * must result in panic(). | 846 | * must result in panic(). |
847 | */ | 847 | */ |
diff --git a/fs/ntfs/Makefile b/fs/ntfs/Makefile index 4ff028fcfd6e..30206b238433 100644 --- a/fs/ntfs/Makefile +++ b/fs/ntfs/Makefile | |||
@@ -2,18 +2,13 @@ | |||
2 | 2 | ||
3 | obj-$(CONFIG_NTFS_FS) += ntfs.o | 3 | obj-$(CONFIG_NTFS_FS) += ntfs.o |
4 | 4 | ||
5 | ntfs-objs := aops.o attrib.o collate.o compress.o debug.o dir.o file.o \ | 5 | ntfs-y := 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.30\" | 9 | ntfs-$(CONFIG_NTFS_RW) += bitmap.o lcnalloc.o logfile.o quota.o usnjrnl.o |
10 | 10 | ||
11 | ifeq ($(CONFIG_NTFS_DEBUG),y) | 11 | ccflags-y := -DNTFS_VERSION=\"2.1.30\" |
12 | EXTRA_CFLAGS += -DDEBUG | 12 | ccflags-$(CONFIG_NTFS_DEBUG) += -DDEBUG |
13 | endif | 13 | ccflags-$(CONFIG_NTFS_RW) += -DNTFS_RW |
14 | 14 | ||
15 | ifeq ($(CONFIG_NTFS_RW),y) | ||
16 | EXTRA_CFLAGS += -DNTFS_RW | ||
17 | |||
18 | ntfs-objs += bitmap.o lcnalloc.o logfile.o quota.o usnjrnl.o | ||
19 | endif | ||
diff --git a/fs/ocfs2/Makefile b/fs/ocfs2/Makefile index 07d9fd854350..d8a0313e99e6 100644 --- a/fs/ocfs2/Makefile +++ b/fs/ocfs2/Makefile | |||
@@ -1,6 +1,6 @@ | |||
1 | EXTRA_CFLAGS += -Ifs/ocfs2 | 1 | ccflags-y := -Ifs/ocfs2 |
2 | 2 | ||
3 | EXTRA_CFLAGS += -DCATCH_BH_JBD_RACES | 3 | ccflags-y += -DCATCH_BH_JBD_RACES |
4 | 4 | ||
5 | obj-$(CONFIG_OCFS2_FS) += \ | 5 | obj-$(CONFIG_OCFS2_FS) += \ |
6 | ocfs2.o \ | 6 | ocfs2.o \ |
diff --git a/fs/ocfs2/acl.c b/fs/ocfs2/acl.c index 704f6b1742f3..90f2729b7a5b 100644 --- a/fs/ocfs2/acl.c +++ b/fs/ocfs2/acl.c | |||
@@ -497,7 +497,7 @@ static int ocfs2_xattr_set_acl(struct dentry *dentry, const char *name, | |||
497 | if (!(osb->s_mount_opt & OCFS2_MOUNT_POSIX_ACL)) | 497 | if (!(osb->s_mount_opt & OCFS2_MOUNT_POSIX_ACL)) |
498 | return -EOPNOTSUPP; | 498 | return -EOPNOTSUPP; |
499 | 499 | ||
500 | if (!is_owner_or_cap(inode)) | 500 | if (!inode_owner_or_capable(inode)) |
501 | return -EPERM; | 501 | return -EPERM; |
502 | 502 | ||
503 | if (value) { | 503 | if (value) { |
diff --git a/fs/ocfs2/dir.c b/fs/ocfs2/dir.c index d417b3f9b0c7..f97b6f1c61dd 100644 --- a/fs/ocfs2/dir.c +++ b/fs/ocfs2/dir.c | |||
@@ -354,7 +354,7 @@ static inline int ocfs2_match(int len, | |||
354 | /* | 354 | /* |
355 | * Returns 0 if not found, -1 on failure, and 1 on success | 355 | * Returns 0 if not found, -1 on failure, and 1 on success |
356 | */ | 356 | */ |
357 | static int inline ocfs2_search_dirblock(struct buffer_head *bh, | 357 | static inline int ocfs2_search_dirblock(struct buffer_head *bh, |
358 | struct inode *dir, | 358 | struct inode *dir, |
359 | const char *name, int namelen, | 359 | const char *name, int namelen, |
360 | unsigned long offset, | 360 | unsigned long offset, |
diff --git a/fs/ocfs2/dlm/Makefile b/fs/ocfs2/dlm/Makefile index dcebf0d920fa..c8a044efbb15 100644 --- a/fs/ocfs2/dlm/Makefile +++ b/fs/ocfs2/dlm/Makefile | |||
@@ -1,4 +1,4 @@ | |||
1 | EXTRA_CFLAGS += -Ifs/ocfs2 | 1 | ccflags-y := -Ifs/ocfs2 |
2 | 2 | ||
3 | obj-$(CONFIG_OCFS2_FS_O2CB) += ocfs2_dlm.o | 3 | obj-$(CONFIG_OCFS2_FS_O2CB) += ocfs2_dlm.o |
4 | 4 | ||
diff --git a/fs/ocfs2/dlmfs/Makefile b/fs/ocfs2/dlmfs/Makefile index df69b4856d0d..f14be89a6701 100644 --- a/fs/ocfs2/dlmfs/Makefile +++ b/fs/ocfs2/dlmfs/Makefile | |||
@@ -1,4 +1,4 @@ | |||
1 | EXTRA_CFLAGS += -Ifs/ocfs2 | 1 | ccflags-y := -Ifs/ocfs2 |
2 | 2 | ||
3 | obj-$(CONFIG_OCFS2_FS) += ocfs2_dlmfs.o | 3 | obj-$(CONFIG_OCFS2_FS) += ocfs2_dlmfs.o |
4 | 4 | ||
diff --git a/fs/ocfs2/ioctl.c b/fs/ocfs2/ioctl.c index 7a4868196152..09de77ce002a 100644 --- a/fs/ocfs2/ioctl.c +++ b/fs/ocfs2/ioctl.c | |||
@@ -82,7 +82,7 @@ static int ocfs2_set_inode_attr(struct inode *inode, unsigned flags, | |||
82 | } | 82 | } |
83 | 83 | ||
84 | status = -EACCES; | 84 | status = -EACCES; |
85 | if (!is_owner_or_cap(inode)) | 85 | if (!inode_owner_or_capable(inode)) |
86 | goto bail_unlock; | 86 | goto bail_unlock; |
87 | 87 | ||
88 | if (!S_ISDIR(inode->i_mode)) | 88 | if (!S_ISDIR(inode->i_mode)) |
diff --git a/fs/ocfs2/ocfs2.h b/fs/ocfs2/ocfs2.h index 51cd6898e7f1..1a97ba1ec3fc 100644 --- a/fs/ocfs2/ocfs2.h +++ b/fs/ocfs2/ocfs2.h | |||
@@ -831,18 +831,18 @@ static inline unsigned int ocfs2_clusters_to_megabytes(struct super_block *sb, | |||
831 | 831 | ||
832 | static inline void _ocfs2_set_bit(unsigned int bit, unsigned long *bitmap) | 832 | static inline void _ocfs2_set_bit(unsigned int bit, unsigned long *bitmap) |
833 | { | 833 | { |
834 | ext2_set_bit(bit, bitmap); | 834 | __test_and_set_bit_le(bit, bitmap); |
835 | } | 835 | } |
836 | #define ocfs2_set_bit(bit, addr) _ocfs2_set_bit((bit), (unsigned long *)(addr)) | 836 | #define ocfs2_set_bit(bit, addr) _ocfs2_set_bit((bit), (unsigned long *)(addr)) |
837 | 837 | ||
838 | static inline void _ocfs2_clear_bit(unsigned int bit, unsigned long *bitmap) | 838 | static inline void _ocfs2_clear_bit(unsigned int bit, unsigned long *bitmap) |
839 | { | 839 | { |
840 | ext2_clear_bit(bit, bitmap); | 840 | __test_and_clear_bit_le(bit, bitmap); |
841 | } | 841 | } |
842 | #define ocfs2_clear_bit(bit, addr) _ocfs2_clear_bit((bit), (unsigned long *)(addr)) | 842 | #define ocfs2_clear_bit(bit, addr) _ocfs2_clear_bit((bit), (unsigned long *)(addr)) |
843 | 843 | ||
844 | #define ocfs2_test_bit ext2_test_bit | 844 | #define ocfs2_test_bit test_bit_le |
845 | #define ocfs2_find_next_zero_bit ext2_find_next_zero_bit | 845 | #define ocfs2_find_next_zero_bit find_next_zero_bit_le |
846 | #define ocfs2_find_next_bit ext2_find_next_bit | 846 | #define ocfs2_find_next_bit find_next_bit_le |
847 | #endif /* OCFS2_H */ | 847 | #endif /* OCFS2_H */ |
848 | 848 | ||
diff --git a/fs/omfs/dir.c b/fs/omfs/dir.c index 393f3f659da7..de4ff29f1e05 100644 --- a/fs/omfs/dir.c +++ b/fs/omfs/dir.c | |||
@@ -235,33 +235,22 @@ static int omfs_dir_is_empty(struct inode *inode) | |||
235 | return *ptr != ~0; | 235 | return *ptr != ~0; |
236 | } | 236 | } |
237 | 237 | ||
238 | static int omfs_unlink(struct inode *dir, struct dentry *dentry) | 238 | static int omfs_remove(struct inode *dir, struct dentry *dentry) |
239 | { | 239 | { |
240 | int ret; | ||
241 | struct inode *inode = dentry->d_inode; | 240 | struct inode *inode = dentry->d_inode; |
241 | int ret; | ||
242 | |||
243 | if (S_ISDIR(inode->i_mode) && !omfs_dir_is_empty(inode)) | ||
244 | return -ENOTEMPTY; | ||
242 | 245 | ||
243 | ret = omfs_delete_entry(dentry); | 246 | ret = omfs_delete_entry(dentry); |
244 | if (ret) | 247 | if (ret) |
245 | goto end_unlink; | 248 | return ret; |
246 | 249 | ||
247 | inode_dec_link_count(inode); | 250 | clear_nlink(inode); |
251 | mark_inode_dirty(inode); | ||
248 | mark_inode_dirty(dir); | 252 | mark_inode_dirty(dir); |
249 | 253 | return 0; | |
250 | end_unlink: | ||
251 | return ret; | ||
252 | } | ||
253 | |||
254 | static int omfs_rmdir(struct inode *dir, struct dentry *dentry) | ||
255 | { | ||
256 | int err = -ENOTEMPTY; | ||
257 | struct inode *inode = dentry->d_inode; | ||
258 | |||
259 | if (omfs_dir_is_empty(inode)) { | ||
260 | err = omfs_unlink(dir, dentry); | ||
261 | if (!err) | ||
262 | inode_dec_link_count(inode); | ||
263 | } | ||
264 | return err; | ||
265 | } | 254 | } |
266 | 255 | ||
267 | static int omfs_add_node(struct inode *dir, struct dentry *dentry, int mode) | 256 | static int omfs_add_node(struct inode *dir, struct dentry *dentry, int mode) |
@@ -372,9 +361,10 @@ static int omfs_fill_chain(struct file *filp, void *dirent, filldir_t filldir, | |||
372 | 361 | ||
373 | res = filldir(dirent, oi->i_name, strnlen(oi->i_name, | 362 | res = filldir(dirent, oi->i_name, strnlen(oi->i_name, |
374 | OMFS_NAMELEN), filp->f_pos, self, d_type); | 363 | OMFS_NAMELEN), filp->f_pos, self, d_type); |
375 | if (res == 0) | ||
376 | filp->f_pos++; | ||
377 | brelse(bh); | 364 | brelse(bh); |
365 | if (res < 0) | ||
366 | break; | ||
367 | filp->f_pos++; | ||
378 | } | 368 | } |
379 | out: | 369 | out: |
380 | return res; | 370 | return res; |
@@ -385,44 +375,28 @@ static int omfs_rename(struct inode *old_dir, struct dentry *old_dentry, | |||
385 | { | 375 | { |
386 | struct inode *new_inode = new_dentry->d_inode; | 376 | struct inode *new_inode = new_dentry->d_inode; |
387 | struct inode *old_inode = old_dentry->d_inode; | 377 | struct inode *old_inode = old_dentry->d_inode; |
388 | struct buffer_head *bh; | ||
389 | int is_dir; | ||
390 | int err; | 378 | int err; |
391 | 379 | ||
392 | is_dir = S_ISDIR(old_inode->i_mode); | ||
393 | |||
394 | if (new_inode) { | 380 | if (new_inode) { |
395 | /* overwriting existing file/dir */ | 381 | /* overwriting existing file/dir */ |
396 | err = -ENOTEMPTY; | 382 | err = omfs_remove(new_dir, new_dentry); |
397 | if (is_dir && !omfs_dir_is_empty(new_inode)) | ||
398 | goto out; | ||
399 | |||
400 | err = -ENOENT; | ||
401 | bh = omfs_find_entry(new_dir, new_dentry->d_name.name, | ||
402 | new_dentry->d_name.len); | ||
403 | if (IS_ERR(bh)) | ||
404 | goto out; | ||
405 | brelse(bh); | ||
406 | |||
407 | err = omfs_unlink(new_dir, new_dentry); | ||
408 | if (err) | 383 | if (err) |
409 | goto out; | 384 | goto out; |
410 | } | 385 | } |
411 | 386 | ||
412 | /* since omfs locates files by name, we need to unlink _before_ | 387 | /* since omfs locates files by name, we need to unlink _before_ |
413 | * adding the new link or we won't find the old one */ | 388 | * adding the new link or we won't find the old one */ |
414 | inode_inc_link_count(old_inode); | 389 | err = omfs_delete_entry(old_dentry); |
415 | err = omfs_unlink(old_dir, old_dentry); | 390 | if (err) |
416 | if (err) { | ||
417 | inode_dec_link_count(old_inode); | ||
418 | goto out; | 391 | goto out; |
419 | } | ||
420 | 392 | ||
393 | mark_inode_dirty(old_dir); | ||
421 | err = omfs_add_link(new_dentry, old_inode); | 394 | err = omfs_add_link(new_dentry, old_inode); |
422 | if (err) | 395 | if (err) |
423 | goto out; | 396 | goto out; |
424 | 397 | ||
425 | old_inode->i_ctime = CURRENT_TIME_SEC; | 398 | old_inode->i_ctime = CURRENT_TIME_SEC; |
399 | mark_inode_dirty(old_inode); | ||
426 | out: | 400 | out: |
427 | return err; | 401 | return err; |
428 | } | 402 | } |
@@ -488,8 +462,8 @@ const struct inode_operations omfs_dir_inops = { | |||
488 | .mkdir = omfs_mkdir, | 462 | .mkdir = omfs_mkdir, |
489 | .rename = omfs_rename, | 463 | .rename = omfs_rename, |
490 | .create = omfs_create, | 464 | .create = omfs_create, |
491 | .unlink = omfs_unlink, | 465 | .unlink = omfs_remove, |
492 | .rmdir = omfs_rmdir, | 466 | .rmdir = omfs_remove, |
493 | }; | 467 | }; |
494 | 468 | ||
495 | const struct file_operations omfs_dir_operations = { | 469 | const struct file_operations omfs_dir_operations = { |
@@ -835,17 +835,8 @@ struct file *dentry_open(struct dentry *dentry, struct vfsmount *mnt, int flags, | |||
835 | 835 | ||
836 | validate_creds(cred); | 836 | validate_creds(cred); |
837 | 837 | ||
838 | /* | 838 | /* We must always pass in a valid mount pointer. */ |
839 | * We must always pass in a valid mount pointer. Historically | 839 | BUG_ON(!mnt); |
840 | * callers got away with not passing it, but we must enforce this at | ||
841 | * the earliest possible point now to avoid strange problems deep in the | ||
842 | * filesystem stack. | ||
843 | */ | ||
844 | if (!mnt) { | ||
845 | printk(KERN_WARNING "%s called with NULL vfsmount\n", __func__); | ||
846 | dump_stack(); | ||
847 | return ERR_PTR(-EINVAL); | ||
848 | } | ||
849 | 840 | ||
850 | error = -ENFILE; | 841 | error = -ENFILE; |
851 | f = get_empty_filp(); | 842 | f = get_empty_filp(); |
diff --git a/fs/proc/array.c b/fs/proc/array.c index 7c99c1cf7e5c..5e4f776b0917 100644 --- a/fs/proc/array.c +++ b/fs/proc/array.c | |||
@@ -489,8 +489,8 @@ static int do_task_stat(struct seq_file *m, struct pid_namespace *ns, | |||
489 | vsize, | 489 | vsize, |
490 | mm ? get_mm_rss(mm) : 0, | 490 | mm ? get_mm_rss(mm) : 0, |
491 | rsslim, | 491 | rsslim, |
492 | mm ? mm->start_code : 0, | 492 | mm ? (permitted ? mm->start_code : 1) : 0, |
493 | mm ? mm->end_code : 0, | 493 | mm ? (permitted ? mm->end_code : 1) : 0, |
494 | (permitted && mm) ? mm->start_stack : 0, | 494 | (permitted && mm) ? mm->start_stack : 0, |
495 | esp, | 495 | esp, |
496 | eip, | 496 | eip, |
diff --git a/fs/proc/base.c b/fs/proc/base.c index d49c4b5d2c3e..5a670c11aeac 100644 --- a/fs/proc/base.c +++ b/fs/proc/base.c | |||
@@ -191,17 +191,20 @@ static int proc_root_link(struct inode *inode, struct path *path) | |||
191 | return result; | 191 | return result; |
192 | } | 192 | } |
193 | 193 | ||
194 | /* | 194 | static struct mm_struct *__check_mem_permission(struct task_struct *task) |
195 | * Return zero if current may access user memory in @task, -error if not. | ||
196 | */ | ||
197 | static int check_mem_permission(struct task_struct *task) | ||
198 | { | 195 | { |
196 | struct mm_struct *mm; | ||
197 | |||
198 | mm = get_task_mm(task); | ||
199 | if (!mm) | ||
200 | return ERR_PTR(-EINVAL); | ||
201 | |||
199 | /* | 202 | /* |
200 | * A task can always look at itself, in case it chooses | 203 | * A task can always look at itself, in case it chooses |
201 | * to use system calls instead of load instructions. | 204 | * to use system calls instead of load instructions. |
202 | */ | 205 | */ |
203 | if (task == current) | 206 | if (task == current) |
204 | return 0; | 207 | return mm; |
205 | 208 | ||
206 | /* | 209 | /* |
207 | * If current is actively ptrace'ing, and would also be | 210 | * If current is actively ptrace'ing, and would also be |
@@ -213,27 +216,53 @@ static int check_mem_permission(struct task_struct *task) | |||
213 | match = (tracehook_tracer_task(task) == current); | 216 | match = (tracehook_tracer_task(task) == current); |
214 | rcu_read_unlock(); | 217 | rcu_read_unlock(); |
215 | if (match && ptrace_may_access(task, PTRACE_MODE_ATTACH)) | 218 | if (match && ptrace_may_access(task, PTRACE_MODE_ATTACH)) |
216 | return 0; | 219 | return mm; |
217 | } | 220 | } |
218 | 221 | ||
219 | /* | 222 | /* |
220 | * Noone else is allowed. | 223 | * Noone else is allowed. |
221 | */ | 224 | */ |
222 | return -EPERM; | 225 | mmput(mm); |
226 | return ERR_PTR(-EPERM); | ||
227 | } | ||
228 | |||
229 | /* | ||
230 | * If current may access user memory in @task return a reference to the | ||
231 | * corresponding mm, otherwise ERR_PTR. | ||
232 | */ | ||
233 | static struct mm_struct *check_mem_permission(struct task_struct *task) | ||
234 | { | ||
235 | struct mm_struct *mm; | ||
236 | int err; | ||
237 | |||
238 | /* | ||
239 | * Avoid racing if task exec's as we might get a new mm but validate | ||
240 | * against old credentials. | ||
241 | */ | ||
242 | err = mutex_lock_killable(&task->signal->cred_guard_mutex); | ||
243 | if (err) | ||
244 | return ERR_PTR(err); | ||
245 | |||
246 | mm = __check_mem_permission(task); | ||
247 | mutex_unlock(&task->signal->cred_guard_mutex); | ||
248 | |||
249 | return mm; | ||
223 | } | 250 | } |
224 | 251 | ||
225 | struct mm_struct *mm_for_maps(struct task_struct *task) | 252 | struct mm_struct *mm_for_maps(struct task_struct *task) |
226 | { | 253 | { |
227 | struct mm_struct *mm; | 254 | struct mm_struct *mm; |
255 | int err; | ||
228 | 256 | ||
229 | if (mutex_lock_killable(&task->signal->cred_guard_mutex)) | 257 | err = mutex_lock_killable(&task->signal->cred_guard_mutex); |
230 | return NULL; | 258 | if (err) |
259 | return ERR_PTR(err); | ||
231 | 260 | ||
232 | mm = get_task_mm(task); | 261 | mm = get_task_mm(task); |
233 | if (mm && mm != current->mm && | 262 | if (mm && mm != current->mm && |
234 | !ptrace_may_access(task, PTRACE_MODE_READ)) { | 263 | !ptrace_may_access(task, PTRACE_MODE_READ)) { |
235 | mmput(mm); | 264 | mmput(mm); |
236 | mm = NULL; | 265 | mm = ERR_PTR(-EACCES); |
237 | } | 266 | } |
238 | mutex_unlock(&task->signal->cred_guard_mutex); | 267 | mutex_unlock(&task->signal->cred_guard_mutex); |
239 | 268 | ||
@@ -279,9 +308,9 @@ out: | |||
279 | 308 | ||
280 | static int proc_pid_auxv(struct task_struct *task, char *buffer) | 309 | static int proc_pid_auxv(struct task_struct *task, char *buffer) |
281 | { | 310 | { |
282 | int res = 0; | 311 | struct mm_struct *mm = mm_for_maps(task); |
283 | struct mm_struct *mm = get_task_mm(task); | 312 | int res = PTR_ERR(mm); |
284 | if (mm) { | 313 | if (mm && !IS_ERR(mm)) { |
285 | unsigned int nwords = 0; | 314 | unsigned int nwords = 0; |
286 | do { | 315 | do { |
287 | nwords += 2; | 316 | nwords += 2; |
@@ -318,6 +347,23 @@ static int proc_pid_wchan(struct task_struct *task, char *buffer) | |||
318 | } | 347 | } |
319 | #endif /* CONFIG_KALLSYMS */ | 348 | #endif /* CONFIG_KALLSYMS */ |
320 | 349 | ||
350 | static int lock_trace(struct task_struct *task) | ||
351 | { | ||
352 | int err = mutex_lock_killable(&task->signal->cred_guard_mutex); | ||
353 | if (err) | ||
354 | return err; | ||
355 | if (!ptrace_may_access(task, PTRACE_MODE_ATTACH)) { | ||
356 | mutex_unlock(&task->signal->cred_guard_mutex); | ||
357 | return -EPERM; | ||
358 | } | ||
359 | return 0; | ||
360 | } | ||
361 | |||
362 | static void unlock_trace(struct task_struct *task) | ||
363 | { | ||
364 | mutex_unlock(&task->signal->cred_guard_mutex); | ||
365 | } | ||
366 | |||
321 | #ifdef CONFIG_STACKTRACE | 367 | #ifdef CONFIG_STACKTRACE |
322 | 368 | ||
323 | #define MAX_STACK_TRACE_DEPTH 64 | 369 | #define MAX_STACK_TRACE_DEPTH 64 |
@@ -327,6 +373,7 @@ static int proc_pid_stack(struct seq_file *m, struct pid_namespace *ns, | |||
327 | { | 373 | { |
328 | struct stack_trace trace; | 374 | struct stack_trace trace; |
329 | unsigned long *entries; | 375 | unsigned long *entries; |
376 | int err; | ||
330 | int i; | 377 | int i; |
331 | 378 | ||
332 | entries = kmalloc(MAX_STACK_TRACE_DEPTH * sizeof(*entries), GFP_KERNEL); | 379 | entries = kmalloc(MAX_STACK_TRACE_DEPTH * sizeof(*entries), GFP_KERNEL); |
@@ -337,15 +384,20 @@ static int proc_pid_stack(struct seq_file *m, struct pid_namespace *ns, | |||
337 | trace.max_entries = MAX_STACK_TRACE_DEPTH; | 384 | trace.max_entries = MAX_STACK_TRACE_DEPTH; |
338 | trace.entries = entries; | 385 | trace.entries = entries; |
339 | trace.skip = 0; | 386 | trace.skip = 0; |
340 | save_stack_trace_tsk(task, &trace); | ||
341 | 387 | ||
342 | for (i = 0; i < trace.nr_entries; i++) { | 388 | err = lock_trace(task); |
343 | seq_printf(m, "[<%p>] %pS\n", | 389 | if (!err) { |
344 | (void *)entries[i], (void *)entries[i]); | 390 | save_stack_trace_tsk(task, &trace); |
391 | |||
392 | for (i = 0; i < trace.nr_entries; i++) { | ||
393 | seq_printf(m, "[<%pK>] %pS\n", | ||
394 | (void *)entries[i], (void *)entries[i]); | ||
395 | } | ||
396 | unlock_trace(task); | ||
345 | } | 397 | } |
346 | kfree(entries); | 398 | kfree(entries); |
347 | 399 | ||
348 | return 0; | 400 | return err; |
349 | } | 401 | } |
350 | #endif | 402 | #endif |
351 | 403 | ||
@@ -508,18 +560,22 @@ static int proc_pid_syscall(struct task_struct *task, char *buffer) | |||
508 | { | 560 | { |
509 | long nr; | 561 | long nr; |
510 | unsigned long args[6], sp, pc; | 562 | unsigned long args[6], sp, pc; |
563 | int res = lock_trace(task); | ||
564 | if (res) | ||
565 | return res; | ||
511 | 566 | ||
512 | if (task_current_syscall(task, &nr, args, 6, &sp, &pc)) | 567 | if (task_current_syscall(task, &nr, args, 6, &sp, &pc)) |
513 | return sprintf(buffer, "running\n"); | 568 | res = sprintf(buffer, "running\n"); |
514 | 569 | else if (nr < 0) | |
515 | if (nr < 0) | 570 | res = sprintf(buffer, "%ld 0x%lx 0x%lx\n", nr, sp, pc); |
516 | return sprintf(buffer, "%ld 0x%lx 0x%lx\n", nr, sp, pc); | 571 | else |
517 | 572 | res = sprintf(buffer, | |
518 | return sprintf(buffer, | ||
519 | "%ld 0x%lx 0x%lx 0x%lx 0x%lx 0x%lx 0x%lx 0x%lx 0x%lx\n", | 573 | "%ld 0x%lx 0x%lx 0x%lx 0x%lx 0x%lx 0x%lx 0x%lx 0x%lx\n", |
520 | nr, | 574 | nr, |
521 | args[0], args[1], args[2], args[3], args[4], args[5], | 575 | args[0], args[1], args[2], args[3], args[4], args[5], |
522 | sp, pc); | 576 | sp, pc); |
577 | unlock_trace(task); | ||
578 | return res; | ||
523 | } | 579 | } |
524 | #endif /* CONFIG_HAVE_ARCH_TRACEHOOK */ | 580 | #endif /* CONFIG_HAVE_ARCH_TRACEHOOK */ |
525 | 581 | ||
@@ -775,18 +831,14 @@ static ssize_t mem_read(struct file * file, char __user * buf, | |||
775 | if (!task) | 831 | if (!task) |
776 | goto out_no_task; | 832 | goto out_no_task; |
777 | 833 | ||
778 | if (check_mem_permission(task)) | ||
779 | goto out; | ||
780 | |||
781 | ret = -ENOMEM; | 834 | ret = -ENOMEM; |
782 | page = (char *)__get_free_page(GFP_TEMPORARY); | 835 | page = (char *)__get_free_page(GFP_TEMPORARY); |
783 | if (!page) | 836 | if (!page) |
784 | goto out; | 837 | goto out; |
785 | 838 | ||
786 | ret = 0; | 839 | mm = check_mem_permission(task); |
787 | 840 | ret = PTR_ERR(mm); | |
788 | mm = get_task_mm(task); | 841 | if (IS_ERR(mm)) |
789 | if (!mm) | ||
790 | goto out_free; | 842 | goto out_free; |
791 | 843 | ||
792 | ret = -EIO; | 844 | ret = -EIO; |
@@ -800,8 +852,8 @@ static ssize_t mem_read(struct file * file, char __user * buf, | |||
800 | int this_len, retval; | 852 | int this_len, retval; |
801 | 853 | ||
802 | this_len = (count > PAGE_SIZE) ? PAGE_SIZE : count; | 854 | this_len = (count > PAGE_SIZE) ? PAGE_SIZE : count; |
803 | retval = access_process_vm(task, src, page, this_len, 0); | 855 | retval = access_remote_vm(mm, src, page, this_len, 0); |
804 | if (!retval || check_mem_permission(task)) { | 856 | if (!retval) { |
805 | if (!ret) | 857 | if (!ret) |
806 | ret = -EIO; | 858 | ret = -EIO; |
807 | break; | 859 | break; |
@@ -829,10 +881,6 @@ out_no_task: | |||
829 | return ret; | 881 | return ret; |
830 | } | 882 | } |
831 | 883 | ||
832 | #define mem_write NULL | ||
833 | |||
834 | #ifndef mem_write | ||
835 | /* This is a security hazard */ | ||
836 | static ssize_t mem_write(struct file * file, const char __user *buf, | 884 | static ssize_t mem_write(struct file * file, const char __user *buf, |
837 | size_t count, loff_t *ppos) | 885 | size_t count, loff_t *ppos) |
838 | { | 886 | { |
@@ -840,18 +888,25 @@ static ssize_t mem_write(struct file * file, const char __user *buf, | |||
840 | char *page; | 888 | char *page; |
841 | struct task_struct *task = get_proc_task(file->f_path.dentry->d_inode); | 889 | struct task_struct *task = get_proc_task(file->f_path.dentry->d_inode); |
842 | unsigned long dst = *ppos; | 890 | unsigned long dst = *ppos; |
891 | struct mm_struct *mm; | ||
843 | 892 | ||
844 | copied = -ESRCH; | 893 | copied = -ESRCH; |
845 | if (!task) | 894 | if (!task) |
846 | goto out_no_task; | 895 | goto out_no_task; |
847 | 896 | ||
848 | if (check_mem_permission(task)) | 897 | mm = check_mem_permission(task); |
849 | goto out; | 898 | copied = PTR_ERR(mm); |
899 | if (IS_ERR(mm)) | ||
900 | goto out_task; | ||
901 | |||
902 | copied = -EIO; | ||
903 | if (file->private_data != (void *)((long)current->self_exec_id)) | ||
904 | goto out_mm; | ||
850 | 905 | ||
851 | copied = -ENOMEM; | 906 | copied = -ENOMEM; |
852 | page = (char *)__get_free_page(GFP_TEMPORARY); | 907 | page = (char *)__get_free_page(GFP_TEMPORARY); |
853 | if (!page) | 908 | if (!page) |
854 | goto out; | 909 | goto out_mm; |
855 | 910 | ||
856 | copied = 0; | 911 | copied = 0; |
857 | while (count > 0) { | 912 | while (count > 0) { |
@@ -862,7 +917,7 @@ static ssize_t mem_write(struct file * file, const char __user *buf, | |||
862 | copied = -EFAULT; | 917 | copied = -EFAULT; |
863 | break; | 918 | break; |
864 | } | 919 | } |
865 | retval = access_process_vm(task, dst, page, this_len, 1); | 920 | retval = access_remote_vm(mm, dst, page, this_len, 1); |
866 | if (!retval) { | 921 | if (!retval) { |
867 | if (!copied) | 922 | if (!copied) |
868 | copied = -EIO; | 923 | copied = -EIO; |
@@ -875,12 +930,13 @@ static ssize_t mem_write(struct file * file, const char __user *buf, | |||
875 | } | 930 | } |
876 | *ppos = dst; | 931 | *ppos = dst; |
877 | free_page((unsigned long) page); | 932 | free_page((unsigned long) page); |
878 | out: | 933 | out_mm: |
934 | mmput(mm); | ||
935 | out_task: | ||
879 | put_task_struct(task); | 936 | put_task_struct(task); |
880 | out_no_task: | 937 | out_no_task: |
881 | return copied; | 938 | return copied; |
882 | } | 939 | } |
883 | #endif | ||
884 | 940 | ||
885 | loff_t mem_lseek(struct file *file, loff_t offset, int orig) | 941 | loff_t mem_lseek(struct file *file, loff_t offset, int orig) |
886 | { | 942 | { |
@@ -917,20 +973,18 @@ static ssize_t environ_read(struct file *file, char __user *buf, | |||
917 | if (!task) | 973 | if (!task) |
918 | goto out_no_task; | 974 | goto out_no_task; |
919 | 975 | ||
920 | if (!ptrace_may_access(task, PTRACE_MODE_READ)) | ||
921 | goto out; | ||
922 | |||
923 | ret = -ENOMEM; | 976 | ret = -ENOMEM; |
924 | page = (char *)__get_free_page(GFP_TEMPORARY); | 977 | page = (char *)__get_free_page(GFP_TEMPORARY); |
925 | if (!page) | 978 | if (!page) |
926 | goto out; | 979 | goto out; |
927 | 980 | ||
928 | ret = 0; | ||
929 | 981 | ||
930 | mm = get_task_mm(task); | 982 | mm = mm_for_maps(task); |
931 | if (!mm) | 983 | ret = PTR_ERR(mm); |
984 | if (!mm || IS_ERR(mm)) | ||
932 | goto out_free; | 985 | goto out_free; |
933 | 986 | ||
987 | ret = 0; | ||
934 | while (count > 0) { | 988 | while (count > 0) { |
935 | int this_len, retval, max_len; | 989 | int this_len, retval, max_len; |
936 | 990 | ||
@@ -2748,8 +2802,12 @@ static int proc_tgid_io_accounting(struct task_struct *task, char *buffer) | |||
2748 | static int proc_pid_personality(struct seq_file *m, struct pid_namespace *ns, | 2802 | static int proc_pid_personality(struct seq_file *m, struct pid_namespace *ns, |
2749 | struct pid *pid, struct task_struct *task) | 2803 | struct pid *pid, struct task_struct *task) |
2750 | { | 2804 | { |
2751 | seq_printf(m, "%08x\n", task->personality); | 2805 | int err = lock_trace(task); |
2752 | return 0; | 2806 | if (!err) { |
2807 | seq_printf(m, "%08x\n", task->personality); | ||
2808 | unlock_trace(task); | ||
2809 | } | ||
2810 | return err; | ||
2753 | } | 2811 | } |
2754 | 2812 | ||
2755 | /* | 2813 | /* |
@@ -2768,7 +2826,7 @@ static const struct pid_entry tgid_base_stuff[] = { | |||
2768 | REG("environ", S_IRUSR, proc_environ_operations), | 2826 | REG("environ", S_IRUSR, proc_environ_operations), |
2769 | INF("auxv", S_IRUSR, proc_pid_auxv), | 2827 | INF("auxv", S_IRUSR, proc_pid_auxv), |
2770 | ONE("status", S_IRUGO, proc_pid_status), | 2828 | ONE("status", S_IRUGO, proc_pid_status), |
2771 | ONE("personality", S_IRUSR, proc_pid_personality), | 2829 | ONE("personality", S_IRUGO, proc_pid_personality), |
2772 | INF("limits", S_IRUGO, proc_pid_limits), | 2830 | INF("limits", S_IRUGO, proc_pid_limits), |
2773 | #ifdef CONFIG_SCHED_DEBUG | 2831 | #ifdef CONFIG_SCHED_DEBUG |
2774 | REG("sched", S_IRUGO|S_IWUSR, proc_pid_sched_operations), | 2832 | REG("sched", S_IRUGO|S_IWUSR, proc_pid_sched_operations), |
@@ -2778,7 +2836,7 @@ static const struct pid_entry tgid_base_stuff[] = { | |||
2778 | #endif | 2836 | #endif |
2779 | REG("comm", S_IRUGO|S_IWUSR, proc_pid_set_comm_operations), | 2837 | REG("comm", S_IRUGO|S_IWUSR, proc_pid_set_comm_operations), |
2780 | #ifdef CONFIG_HAVE_ARCH_TRACEHOOK | 2838 | #ifdef CONFIG_HAVE_ARCH_TRACEHOOK |
2781 | INF("syscall", S_IRUSR, proc_pid_syscall), | 2839 | INF("syscall", S_IRUGO, proc_pid_syscall), |
2782 | #endif | 2840 | #endif |
2783 | INF("cmdline", S_IRUGO, proc_pid_cmdline), | 2841 | INF("cmdline", S_IRUGO, proc_pid_cmdline), |
2784 | ONE("stat", S_IRUGO, proc_tgid_stat), | 2842 | ONE("stat", S_IRUGO, proc_tgid_stat), |
@@ -2797,7 +2855,7 @@ static const struct pid_entry tgid_base_stuff[] = { | |||
2797 | #ifdef CONFIG_PROC_PAGE_MONITOR | 2855 | #ifdef CONFIG_PROC_PAGE_MONITOR |
2798 | REG("clear_refs", S_IWUSR, proc_clear_refs_operations), | 2856 | REG("clear_refs", S_IWUSR, proc_clear_refs_operations), |
2799 | REG("smaps", S_IRUGO, proc_smaps_operations), | 2857 | REG("smaps", S_IRUGO, proc_smaps_operations), |
2800 | REG("pagemap", S_IRUSR, proc_pagemap_operations), | 2858 | REG("pagemap", S_IRUGO, proc_pagemap_operations), |
2801 | #endif | 2859 | #endif |
2802 | #ifdef CONFIG_SECURITY | 2860 | #ifdef CONFIG_SECURITY |
2803 | DIR("attr", S_IRUGO|S_IXUGO, proc_attr_dir_inode_operations, proc_attr_dir_operations), | 2861 | DIR("attr", S_IRUGO|S_IXUGO, proc_attr_dir_inode_operations, proc_attr_dir_operations), |
@@ -2806,7 +2864,7 @@ static const struct pid_entry tgid_base_stuff[] = { | |||
2806 | INF("wchan", S_IRUGO, proc_pid_wchan), | 2864 | INF("wchan", S_IRUGO, proc_pid_wchan), |
2807 | #endif | 2865 | #endif |
2808 | #ifdef CONFIG_STACKTRACE | 2866 | #ifdef CONFIG_STACKTRACE |
2809 | ONE("stack", S_IRUSR, proc_pid_stack), | 2867 | ONE("stack", S_IRUGO, proc_pid_stack), |
2810 | #endif | 2868 | #endif |
2811 | #ifdef CONFIG_SCHEDSTATS | 2869 | #ifdef CONFIG_SCHEDSTATS |
2812 | INF("schedstat", S_IRUGO, proc_pid_schedstat), | 2870 | INF("schedstat", S_IRUGO, proc_pid_schedstat), |
@@ -3108,14 +3166,14 @@ static const struct pid_entry tid_base_stuff[] = { | |||
3108 | REG("environ", S_IRUSR, proc_environ_operations), | 3166 | REG("environ", S_IRUSR, proc_environ_operations), |
3109 | INF("auxv", S_IRUSR, proc_pid_auxv), | 3167 | INF("auxv", S_IRUSR, proc_pid_auxv), |
3110 | ONE("status", S_IRUGO, proc_pid_status), | 3168 | ONE("status", S_IRUGO, proc_pid_status), |
3111 | ONE("personality", S_IRUSR, proc_pid_personality), | 3169 | ONE("personality", S_IRUGO, proc_pid_personality), |
3112 | INF("limits", S_IRUGO, proc_pid_limits), | 3170 | INF("limits", S_IRUGO, proc_pid_limits), |
3113 | #ifdef CONFIG_SCHED_DEBUG | 3171 | #ifdef CONFIG_SCHED_DEBUG |
3114 | REG("sched", S_IRUGO|S_IWUSR, proc_pid_sched_operations), | 3172 | REG("sched", S_IRUGO|S_IWUSR, proc_pid_sched_operations), |
3115 | #endif | 3173 | #endif |
3116 | REG("comm", S_IRUGO|S_IWUSR, proc_pid_set_comm_operations), | 3174 | REG("comm", S_IRUGO|S_IWUSR, proc_pid_set_comm_operations), |
3117 | #ifdef CONFIG_HAVE_ARCH_TRACEHOOK | 3175 | #ifdef CONFIG_HAVE_ARCH_TRACEHOOK |
3118 | INF("syscall", S_IRUSR, proc_pid_syscall), | 3176 | INF("syscall", S_IRUGO, proc_pid_syscall), |
3119 | #endif | 3177 | #endif |
3120 | INF("cmdline", S_IRUGO, proc_pid_cmdline), | 3178 | INF("cmdline", S_IRUGO, proc_pid_cmdline), |
3121 | ONE("stat", S_IRUGO, proc_tid_stat), | 3179 | ONE("stat", S_IRUGO, proc_tid_stat), |
@@ -3133,7 +3191,7 @@ static const struct pid_entry tid_base_stuff[] = { | |||
3133 | #ifdef CONFIG_PROC_PAGE_MONITOR | 3191 | #ifdef CONFIG_PROC_PAGE_MONITOR |
3134 | REG("clear_refs", S_IWUSR, proc_clear_refs_operations), | 3192 | REG("clear_refs", S_IWUSR, proc_clear_refs_operations), |
3135 | REG("smaps", S_IRUGO, proc_smaps_operations), | 3193 | REG("smaps", S_IRUGO, proc_smaps_operations), |
3136 | REG("pagemap", S_IRUSR, proc_pagemap_operations), | 3194 | REG("pagemap", S_IRUGO, proc_pagemap_operations), |
3137 | #endif | 3195 | #endif |
3138 | #ifdef CONFIG_SECURITY | 3196 | #ifdef CONFIG_SECURITY |
3139 | DIR("attr", S_IRUGO|S_IXUGO, proc_attr_dir_inode_operations, proc_attr_dir_operations), | 3197 | DIR("attr", S_IRUGO|S_IXUGO, proc_attr_dir_inode_operations, proc_attr_dir_operations), |
@@ -3142,7 +3200,7 @@ static const struct pid_entry tid_base_stuff[] = { | |||
3142 | INF("wchan", S_IRUGO, proc_pid_wchan), | 3200 | INF("wchan", S_IRUGO, proc_pid_wchan), |
3143 | #endif | 3201 | #endif |
3144 | #ifdef CONFIG_STACKTRACE | 3202 | #ifdef CONFIG_STACKTRACE |
3145 | ONE("stack", S_IRUSR, proc_pid_stack), | 3203 | ONE("stack", S_IRUGO, proc_pid_stack), |
3146 | #endif | 3204 | #endif |
3147 | #ifdef CONFIG_SCHEDSTATS | 3205 | #ifdef CONFIG_SCHEDSTATS |
3148 | INF("schedstat", S_IRUGO, proc_pid_schedstat), | 3206 | INF("schedstat", S_IRUGO, proc_pid_schedstat), |
@@ -3161,7 +3219,7 @@ static const struct pid_entry tid_base_stuff[] = { | |||
3161 | REG("oom_score_adj", S_IRUGO|S_IWUSR, proc_oom_score_adj_operations), | 3219 | REG("oom_score_adj", S_IRUGO|S_IWUSR, proc_oom_score_adj_operations), |
3162 | #ifdef CONFIG_AUDITSYSCALL | 3220 | #ifdef CONFIG_AUDITSYSCALL |
3163 | REG("loginuid", S_IWUSR|S_IRUGO, proc_loginuid_operations), | 3221 | REG("loginuid", S_IWUSR|S_IRUGO, proc_loginuid_operations), |
3164 | REG("sessionid", S_IRUSR, proc_sessionid_operations), | 3222 | REG("sessionid", S_IRUGO, proc_sessionid_operations), |
3165 | #endif | 3223 | #endif |
3166 | #ifdef CONFIG_FAULT_INJECTION | 3224 | #ifdef CONFIG_FAULT_INJECTION |
3167 | REG("make-it-fail", S_IRUGO|S_IWUSR, proc_fault_inject_operations), | 3225 | REG("make-it-fail", S_IRUGO|S_IWUSR, proc_fault_inject_operations), |
diff --git a/fs/proc/generic.c b/fs/proc/generic.c index 01e07f2a188f..f1281339b6fa 100644 --- a/fs/proc/generic.c +++ b/fs/proc/generic.c | |||
@@ -28,7 +28,7 @@ | |||
28 | 28 | ||
29 | DEFINE_SPINLOCK(proc_subdir_lock); | 29 | DEFINE_SPINLOCK(proc_subdir_lock); |
30 | 30 | ||
31 | static int proc_match(int len, const char *name, struct proc_dir_entry *de) | 31 | static int proc_match(unsigned int len, const char *name, struct proc_dir_entry *de) |
32 | { | 32 | { |
33 | if (de->namelen != len) | 33 | if (de->namelen != len) |
34 | return 0; | 34 | return 0; |
@@ -303,7 +303,7 @@ static int __xlate_proc_name(const char *name, struct proc_dir_entry **ret, | |||
303 | { | 303 | { |
304 | const char *cp = name, *next; | 304 | const char *cp = name, *next; |
305 | struct proc_dir_entry *de; | 305 | struct proc_dir_entry *de; |
306 | int len; | 306 | unsigned int len; |
307 | 307 | ||
308 | de = *ret; | 308 | de = *ret; |
309 | if (!de) | 309 | if (!de) |
@@ -602,7 +602,7 @@ static struct proc_dir_entry *__proc_create(struct proc_dir_entry **parent, | |||
602 | { | 602 | { |
603 | struct proc_dir_entry *ent = NULL; | 603 | struct proc_dir_entry *ent = NULL; |
604 | const char *fn = name; | 604 | const char *fn = name; |
605 | int len; | 605 | unsigned int len; |
606 | 606 | ||
607 | /* make sure name is valid */ | 607 | /* make sure name is valid */ |
608 | if (!name || !strlen(name)) goto out; | 608 | if (!name || !strlen(name)) goto out; |
@@ -786,7 +786,7 @@ void remove_proc_entry(const char *name, struct proc_dir_entry *parent) | |||
786 | struct proc_dir_entry **p; | 786 | struct proc_dir_entry **p; |
787 | struct proc_dir_entry *de = NULL; | 787 | struct proc_dir_entry *de = NULL; |
788 | const char *fn = name; | 788 | const char *fn = name; |
789 | int len; | 789 | unsigned int len; |
790 | 790 | ||
791 | spin_lock(&proc_subdir_lock); | 791 | spin_lock(&proc_subdir_lock); |
792 | if (__xlate_proc_name(name, &parent, &fn) != 0) { | 792 | if (__xlate_proc_name(name, &parent, &fn) != 0) { |
diff --git a/fs/proc/inode.c b/fs/proc/inode.c index d6a7ca1fdac5..d15aa1b1cc8f 100644 --- a/fs/proc/inode.c +++ b/fs/proc/inode.c | |||
@@ -46,8 +46,6 @@ static void proc_evict_inode(struct inode *inode) | |||
46 | } | 46 | } |
47 | } | 47 | } |
48 | 48 | ||
49 | struct vfsmount *proc_mnt; | ||
50 | |||
51 | static struct kmem_cache * proc_inode_cachep; | 49 | static struct kmem_cache * proc_inode_cachep; |
52 | 50 | ||
53 | static struct inode *proc_alloc_inode(struct super_block *sb) | 51 | static struct inode *proc_alloc_inode(struct super_block *sb) |
diff --git a/fs/proc/internal.h b/fs/proc/internal.h index 9ad561ded409..c03e8d3a3a5b 100644 --- a/fs/proc/internal.h +++ b/fs/proc/internal.h | |||
@@ -107,7 +107,6 @@ static inline struct proc_dir_entry *pde_get(struct proc_dir_entry *pde) | |||
107 | } | 107 | } |
108 | void pde_put(struct proc_dir_entry *pde); | 108 | void pde_put(struct proc_dir_entry *pde); |
109 | 109 | ||
110 | extern struct vfsmount *proc_mnt; | ||
111 | int proc_fill_super(struct super_block *); | 110 | int proc_fill_super(struct super_block *); |
112 | struct inode *proc_get_inode(struct super_block *, struct proc_dir_entry *); | 111 | struct inode *proc_get_inode(struct super_block *, struct proc_dir_entry *); |
113 | 112 | ||
diff --git a/fs/proc/root.c b/fs/proc/root.c index ef9fa8e24ad6..a9000e9cfee5 100644 --- a/fs/proc/root.c +++ b/fs/proc/root.c | |||
@@ -43,17 +43,6 @@ static struct dentry *proc_mount(struct file_system_type *fs_type, | |||
43 | struct pid_namespace *ns; | 43 | struct pid_namespace *ns; |
44 | struct proc_inode *ei; | 44 | struct proc_inode *ei; |
45 | 45 | ||
46 | if (proc_mnt) { | ||
47 | /* Seed the root directory with a pid so it doesn't need | ||
48 | * to be special in base.c. I would do this earlier but | ||
49 | * the only task alive when /proc is mounted the first time | ||
50 | * is the init_task and it doesn't have any pids. | ||
51 | */ | ||
52 | ei = PROC_I(proc_mnt->mnt_sb->s_root->d_inode); | ||
53 | if (!ei->pid) | ||
54 | ei->pid = find_get_pid(1); | ||
55 | } | ||
56 | |||
57 | if (flags & MS_KERNMOUNT) | 46 | if (flags & MS_KERNMOUNT) |
58 | ns = (struct pid_namespace *)data; | 47 | ns = (struct pid_namespace *)data; |
59 | else | 48 | else |
@@ -71,16 +60,16 @@ static struct dentry *proc_mount(struct file_system_type *fs_type, | |||
71 | return ERR_PTR(err); | 60 | return ERR_PTR(err); |
72 | } | 61 | } |
73 | 62 | ||
74 | ei = PROC_I(sb->s_root->d_inode); | ||
75 | if (!ei->pid) { | ||
76 | rcu_read_lock(); | ||
77 | ei->pid = get_pid(find_pid_ns(1, ns)); | ||
78 | rcu_read_unlock(); | ||
79 | } | ||
80 | |||
81 | sb->s_flags |= MS_ACTIVE; | 63 | sb->s_flags |= MS_ACTIVE; |
82 | } | 64 | } |
83 | 65 | ||
66 | ei = PROC_I(sb->s_root->d_inode); | ||
67 | if (!ei->pid) { | ||
68 | rcu_read_lock(); | ||
69 | ei->pid = get_pid(find_pid_ns(1, ns)); | ||
70 | rcu_read_unlock(); | ||
71 | } | ||
72 | |||
84 | return dget(sb->s_root); | 73 | return dget(sb->s_root); |
85 | } | 74 | } |
86 | 75 | ||
@@ -101,19 +90,20 @@ static struct file_system_type proc_fs_type = { | |||
101 | 90 | ||
102 | void __init proc_root_init(void) | 91 | void __init proc_root_init(void) |
103 | { | 92 | { |
93 | struct vfsmount *mnt; | ||
104 | int err; | 94 | int err; |
105 | 95 | ||
106 | proc_init_inodecache(); | 96 | proc_init_inodecache(); |
107 | err = register_filesystem(&proc_fs_type); | 97 | err = register_filesystem(&proc_fs_type); |
108 | if (err) | 98 | if (err) |
109 | return; | 99 | return; |
110 | proc_mnt = kern_mount_data(&proc_fs_type, &init_pid_ns); | 100 | mnt = kern_mount_data(&proc_fs_type, &init_pid_ns); |
111 | if (IS_ERR(proc_mnt)) { | 101 | if (IS_ERR(mnt)) { |
112 | unregister_filesystem(&proc_fs_type); | 102 | unregister_filesystem(&proc_fs_type); |
113 | return; | 103 | return; |
114 | } | 104 | } |
115 | 105 | ||
116 | init_pid_ns.proc_mnt = proc_mnt; | 106 | init_pid_ns.proc_mnt = mnt; |
117 | proc_symlink("mounts", NULL, "self/mounts"); | 107 | proc_symlink("mounts", NULL, "self/mounts"); |
118 | 108 | ||
119 | proc_net_init(); | 109 | proc_net_init(); |
diff --git a/fs/proc/task_mmu.c b/fs/proc/task_mmu.c index 60b914860f81..7c708a418acc 100644 --- a/fs/proc/task_mmu.c +++ b/fs/proc/task_mmu.c | |||
@@ -1,5 +1,6 @@ | |||
1 | #include <linux/mm.h> | 1 | #include <linux/mm.h> |
2 | #include <linux/hugetlb.h> | 2 | #include <linux/hugetlb.h> |
3 | #include <linux/huge_mm.h> | ||
3 | #include <linux/mount.h> | 4 | #include <linux/mount.h> |
4 | #include <linux/seq_file.h> | 5 | #include <linux/seq_file.h> |
5 | #include <linux/highmem.h> | 6 | #include <linux/highmem.h> |
@@ -7,6 +8,7 @@ | |||
7 | #include <linux/slab.h> | 8 | #include <linux/slab.h> |
8 | #include <linux/pagemap.h> | 9 | #include <linux/pagemap.h> |
9 | #include <linux/mempolicy.h> | 10 | #include <linux/mempolicy.h> |
11 | #include <linux/rmap.h> | ||
10 | #include <linux/swap.h> | 12 | #include <linux/swap.h> |
11 | #include <linux/swapops.h> | 13 | #include <linux/swapops.h> |
12 | 14 | ||
@@ -119,14 +121,14 @@ static void *m_start(struct seq_file *m, loff_t *pos) | |||
119 | 121 | ||
120 | priv->task = get_pid_task(priv->pid, PIDTYPE_PID); | 122 | priv->task = get_pid_task(priv->pid, PIDTYPE_PID); |
121 | if (!priv->task) | 123 | if (!priv->task) |
122 | return NULL; | 124 | return ERR_PTR(-ESRCH); |
123 | 125 | ||
124 | mm = mm_for_maps(priv->task); | 126 | mm = mm_for_maps(priv->task); |
125 | if (!mm) | 127 | if (!mm || IS_ERR(mm)) |
126 | return NULL; | 128 | return mm; |
127 | down_read(&mm->mmap_sem); | 129 | down_read(&mm->mmap_sem); |
128 | 130 | ||
129 | tail_vma = get_gate_vma(priv->task); | 131 | tail_vma = get_gate_vma(priv->task->mm); |
130 | priv->tail_vma = tail_vma; | 132 | priv->tail_vma = tail_vma; |
131 | 133 | ||
132 | /* Start with last addr hint */ | 134 | /* Start with last addr hint */ |
@@ -249,8 +251,8 @@ static void show_map_vma(struct seq_file *m, struct vm_area_struct *vma) | |||
249 | const char *name = arch_vma_name(vma); | 251 | const char *name = arch_vma_name(vma); |
250 | if (!name) { | 252 | if (!name) { |
251 | if (mm) { | 253 | if (mm) { |
252 | if (vma->vm_start <= mm->start_brk && | 254 | if (vma->vm_start <= mm->brk && |
253 | vma->vm_end >= mm->brk) { | 255 | vma->vm_end >= mm->start_brk) { |
254 | name = "[heap]"; | 256 | name = "[heap]"; |
255 | } else if (vma->vm_start <= mm->start_stack && | 257 | } else if (vma->vm_start <= mm->start_stack && |
256 | vma->vm_end >= mm->start_stack) { | 258 | vma->vm_end >= mm->start_stack) { |
@@ -277,7 +279,8 @@ static int show_map(struct seq_file *m, void *v) | |||
277 | show_map_vma(m, vma); | 279 | show_map_vma(m, vma); |
278 | 280 | ||
279 | if (m->count < m->size) /* vma is copied successfully */ | 281 | if (m->count < m->size) /* vma is copied successfully */ |
280 | m->version = (vma != get_gate_vma(task))? vma->vm_start: 0; | 282 | m->version = (vma != get_gate_vma(task->mm)) |
283 | ? vma->vm_start : 0; | ||
281 | return 0; | 284 | return 0; |
282 | } | 285 | } |
283 | 286 | ||
@@ -329,58 +332,86 @@ struct mem_size_stats { | |||
329 | unsigned long private_dirty; | 332 | unsigned long private_dirty; |
330 | unsigned long referenced; | 333 | unsigned long referenced; |
331 | unsigned long anonymous; | 334 | unsigned long anonymous; |
335 | unsigned long anonymous_thp; | ||
332 | unsigned long swap; | 336 | unsigned long swap; |
333 | u64 pss; | 337 | u64 pss; |
334 | }; | 338 | }; |
335 | 339 | ||
336 | static int smaps_pte_range(pmd_t *pmd, unsigned long addr, unsigned long end, | 340 | |
337 | struct mm_walk *walk) | 341 | static void smaps_pte_entry(pte_t ptent, unsigned long addr, |
342 | unsigned long ptent_size, struct mm_walk *walk) | ||
338 | { | 343 | { |
339 | struct mem_size_stats *mss = walk->private; | 344 | struct mem_size_stats *mss = walk->private; |
340 | struct vm_area_struct *vma = mss->vma; | 345 | struct vm_area_struct *vma = mss->vma; |
341 | pte_t *pte, ptent; | ||
342 | spinlock_t *ptl; | ||
343 | struct page *page; | 346 | struct page *page; |
344 | int mapcount; | 347 | int mapcount; |
345 | 348 | ||
346 | pte = pte_offset_map_lock(vma->vm_mm, pmd, addr, &ptl); | 349 | if (is_swap_pte(ptent)) { |
347 | for (; addr != end; pte++, addr += PAGE_SIZE) { | 350 | mss->swap += ptent_size; |
348 | ptent = *pte; | 351 | return; |
349 | 352 | } | |
350 | if (is_swap_pte(ptent)) { | ||
351 | mss->swap += PAGE_SIZE; | ||
352 | continue; | ||
353 | } | ||
354 | 353 | ||
355 | if (!pte_present(ptent)) | 354 | if (!pte_present(ptent)) |
356 | continue; | 355 | return; |
356 | |||
357 | page = vm_normal_page(vma, addr, ptent); | ||
358 | if (!page) | ||
359 | return; | ||
360 | |||
361 | if (PageAnon(page)) | ||
362 | mss->anonymous += ptent_size; | ||
363 | |||
364 | mss->resident += ptent_size; | ||
365 | /* Accumulate the size in pages that have been accessed. */ | ||
366 | if (pte_young(ptent) || PageReferenced(page)) | ||
367 | mss->referenced += ptent_size; | ||
368 | mapcount = page_mapcount(page); | ||
369 | if (mapcount >= 2) { | ||
370 | if (pte_dirty(ptent) || PageDirty(page)) | ||
371 | mss->shared_dirty += ptent_size; | ||
372 | else | ||
373 | mss->shared_clean += ptent_size; | ||
374 | mss->pss += (ptent_size << PSS_SHIFT) / mapcount; | ||
375 | } else { | ||
376 | if (pte_dirty(ptent) || PageDirty(page)) | ||
377 | mss->private_dirty += ptent_size; | ||
378 | else | ||
379 | mss->private_clean += ptent_size; | ||
380 | mss->pss += (ptent_size << PSS_SHIFT); | ||
381 | } | ||
382 | } | ||
357 | 383 | ||
358 | page = vm_normal_page(vma, addr, ptent); | 384 | static int smaps_pte_range(pmd_t *pmd, unsigned long addr, unsigned long end, |
359 | if (!page) | 385 | struct mm_walk *walk) |
360 | continue; | 386 | { |
387 | struct mem_size_stats *mss = walk->private; | ||
388 | struct vm_area_struct *vma = mss->vma; | ||
389 | pte_t *pte; | ||
390 | spinlock_t *ptl; | ||
361 | 391 | ||
362 | if (PageAnon(page)) | 392 | spin_lock(&walk->mm->page_table_lock); |
363 | mss->anonymous += PAGE_SIZE; | 393 | if (pmd_trans_huge(*pmd)) { |
364 | 394 | if (pmd_trans_splitting(*pmd)) { | |
365 | mss->resident += PAGE_SIZE; | 395 | spin_unlock(&walk->mm->page_table_lock); |
366 | /* Accumulate the size in pages that have been accessed. */ | 396 | wait_split_huge_page(vma->anon_vma, pmd); |
367 | if (pte_young(ptent) || PageReferenced(page)) | ||
368 | mss->referenced += PAGE_SIZE; | ||
369 | mapcount = page_mapcount(page); | ||
370 | if (mapcount >= 2) { | ||
371 | if (pte_dirty(ptent) || PageDirty(page)) | ||
372 | mss->shared_dirty += PAGE_SIZE; | ||
373 | else | ||
374 | mss->shared_clean += PAGE_SIZE; | ||
375 | mss->pss += (PAGE_SIZE << PSS_SHIFT) / mapcount; | ||
376 | } else { | 397 | } else { |
377 | if (pte_dirty(ptent) || PageDirty(page)) | 398 | smaps_pte_entry(*(pte_t *)pmd, addr, |
378 | mss->private_dirty += PAGE_SIZE; | 399 | HPAGE_PMD_SIZE, walk); |
379 | else | 400 | spin_unlock(&walk->mm->page_table_lock); |
380 | mss->private_clean += PAGE_SIZE; | 401 | mss->anonymous_thp += HPAGE_PMD_SIZE; |
381 | mss->pss += (PAGE_SIZE << PSS_SHIFT); | 402 | return 0; |
382 | } | 403 | } |
404 | } else { | ||
405 | spin_unlock(&walk->mm->page_table_lock); | ||
383 | } | 406 | } |
407 | /* | ||
408 | * The mmap_sem held all the way back in m_start() is what | ||
409 | * keeps khugepaged out of here and from collapsing things | ||
410 | * in here. | ||
411 | */ | ||
412 | pte = pte_offset_map_lock(vma->vm_mm, pmd, addr, &ptl); | ||
413 | for (; addr != end; pte++, addr += PAGE_SIZE) | ||
414 | smaps_pte_entry(*pte, addr, PAGE_SIZE, walk); | ||
384 | pte_unmap_unlock(pte - 1, ptl); | 415 | pte_unmap_unlock(pte - 1, ptl); |
385 | cond_resched(); | 416 | cond_resched(); |
386 | return 0; | 417 | return 0; |
@@ -416,6 +447,7 @@ static int show_smap(struct seq_file *m, void *v) | |||
416 | "Private_Dirty: %8lu kB\n" | 447 | "Private_Dirty: %8lu kB\n" |
417 | "Referenced: %8lu kB\n" | 448 | "Referenced: %8lu kB\n" |
418 | "Anonymous: %8lu kB\n" | 449 | "Anonymous: %8lu kB\n" |
450 | "AnonHugePages: %8lu kB\n" | ||
419 | "Swap: %8lu kB\n" | 451 | "Swap: %8lu kB\n" |
420 | "KernelPageSize: %8lu kB\n" | 452 | "KernelPageSize: %8lu kB\n" |
421 | "MMUPageSize: %8lu kB\n" | 453 | "MMUPageSize: %8lu kB\n" |
@@ -429,6 +461,7 @@ static int show_smap(struct seq_file *m, void *v) | |||
429 | mss.private_dirty >> 10, | 461 | mss.private_dirty >> 10, |
430 | mss.referenced >> 10, | 462 | mss.referenced >> 10, |
431 | mss.anonymous >> 10, | 463 | mss.anonymous >> 10, |
464 | mss.anonymous_thp >> 10, | ||
432 | mss.swap >> 10, | 465 | mss.swap >> 10, |
433 | vma_kernel_pagesize(vma) >> 10, | 466 | vma_kernel_pagesize(vma) >> 10, |
434 | vma_mmu_pagesize(vma) >> 10, | 467 | vma_mmu_pagesize(vma) >> 10, |
@@ -436,7 +469,8 @@ static int show_smap(struct seq_file *m, void *v) | |||
436 | (unsigned long)(mss.pss >> (10 + PSS_SHIFT)) : 0); | 469 | (unsigned long)(mss.pss >> (10 + PSS_SHIFT)) : 0); |
437 | 470 | ||
438 | if (m->count < m->size) /* vma is copied successfully */ | 471 | if (m->count < m->size) /* vma is copied successfully */ |
439 | m->version = (vma != get_gate_vma(task)) ? vma->vm_start : 0; | 472 | m->version = (vma != get_gate_vma(task->mm)) |
473 | ? vma->vm_start : 0; | ||
440 | return 0; | 474 | return 0; |
441 | } | 475 | } |
442 | 476 | ||
@@ -467,6 +501,8 @@ static int clear_refs_pte_range(pmd_t *pmd, unsigned long addr, | |||
467 | spinlock_t *ptl; | 501 | spinlock_t *ptl; |
468 | struct page *page; | 502 | struct page *page; |
469 | 503 | ||
504 | split_huge_page_pmd(walk->mm, pmd); | ||
505 | |||
470 | pte = pte_offset_map_lock(vma->vm_mm, pmd, addr, &ptl); | 506 | pte = pte_offset_map_lock(vma->vm_mm, pmd, addr, &ptl); |
471 | for (; addr != end; pte++, addr += PAGE_SIZE) { | 507 | for (; addr != end; pte++, addr += PAGE_SIZE) { |
472 | ptent = *pte; | 508 | ptent = *pte; |
@@ -623,6 +659,8 @@ static int pagemap_pte_range(pmd_t *pmd, unsigned long addr, unsigned long end, | |||
623 | pte_t *pte; | 659 | pte_t *pte; |
624 | int err = 0; | 660 | int err = 0; |
625 | 661 | ||
662 | split_huge_page_pmd(walk->mm, pmd); | ||
663 | |||
626 | /* find the first VMA at or above 'addr' */ | 664 | /* find the first VMA at or above 'addr' */ |
627 | vma = find_vma(walk->mm, addr); | 665 | vma = find_vma(walk->mm, addr); |
628 | for (; addr != end; addr += PAGE_SIZE) { | 666 | for (; addr != end; addr += PAGE_SIZE) { |
@@ -728,8 +766,9 @@ static ssize_t pagemap_read(struct file *file, char __user *buf, | |||
728 | if (!task) | 766 | if (!task) |
729 | goto out; | 767 | goto out; |
730 | 768 | ||
731 | ret = -EACCES; | 769 | mm = mm_for_maps(task); |
732 | if (!ptrace_may_access(task, PTRACE_MODE_READ)) | 770 | ret = PTR_ERR(mm); |
771 | if (!mm || IS_ERR(mm)) | ||
733 | goto out_task; | 772 | goto out_task; |
734 | 773 | ||
735 | ret = -EINVAL; | 774 | ret = -EINVAL; |
@@ -742,10 +781,6 @@ static ssize_t pagemap_read(struct file *file, char __user *buf, | |||
742 | if (!count) | 781 | if (!count) |
743 | goto out_task; | 782 | goto out_task; |
744 | 783 | ||
745 | mm = get_task_mm(task); | ||
746 | if (!mm) | ||
747 | goto out_task; | ||
748 | |||
749 | pm.len = PM_ENTRY_BYTES * (PAGEMAP_WALK_SIZE >> PAGE_SHIFT); | 784 | pm.len = PM_ENTRY_BYTES * (PAGEMAP_WALK_SIZE >> PAGE_SHIFT); |
750 | pm.buffer = kmalloc(pm.len, GFP_TEMPORARY); | 785 | pm.buffer = kmalloc(pm.len, GFP_TEMPORARY); |
751 | ret = -ENOMEM; | 786 | ret = -ENOMEM; |
diff --git a/fs/proc/task_nommu.c b/fs/proc/task_nommu.c index b535d3e5d5f1..980de547c070 100644 --- a/fs/proc/task_nommu.c +++ b/fs/proc/task_nommu.c | |||
@@ -199,13 +199,13 @@ static void *m_start(struct seq_file *m, loff_t *pos) | |||
199 | /* pin the task and mm whilst we play with them */ | 199 | /* pin the task and mm whilst we play with them */ |
200 | priv->task = get_pid_task(priv->pid, PIDTYPE_PID); | 200 | priv->task = get_pid_task(priv->pid, PIDTYPE_PID); |
201 | if (!priv->task) | 201 | if (!priv->task) |
202 | return NULL; | 202 | return ERR_PTR(-ESRCH); |
203 | 203 | ||
204 | mm = mm_for_maps(priv->task); | 204 | mm = mm_for_maps(priv->task); |
205 | if (!mm) { | 205 | if (!mm || IS_ERR(mm)) { |
206 | put_task_struct(priv->task); | 206 | put_task_struct(priv->task); |
207 | priv->task = NULL; | 207 | priv->task = NULL; |
208 | return NULL; | 208 | return mm; |
209 | } | 209 | } |
210 | down_read(&mm->mmap_sem); | 210 | down_read(&mm->mmap_sem); |
211 | 211 | ||
diff --git a/fs/pstore/inode.c b/fs/pstore/inode.c index 549d245d0b42..977ed2723845 100644 --- a/fs/pstore/inode.c +++ b/fs/pstore/inode.c | |||
@@ -27,6 +27,7 @@ | |||
27 | #include <linux/string.h> | 27 | #include <linux/string.h> |
28 | #include <linux/mount.h> | 28 | #include <linux/mount.h> |
29 | #include <linux/ramfs.h> | 29 | #include <linux/ramfs.h> |
30 | #include <linux/parser.h> | ||
30 | #include <linux/sched.h> | 31 | #include <linux/sched.h> |
31 | #include <linux/magic.h> | 32 | #include <linux/magic.h> |
32 | #include <linux/pstore.h> | 33 | #include <linux/pstore.h> |
@@ -40,9 +41,29 @@ | |||
40 | struct pstore_private { | 41 | struct pstore_private { |
41 | u64 id; | 42 | u64 id; |
42 | int (*erase)(u64); | 43 | int (*erase)(u64); |
44 | ssize_t size; | ||
45 | char data[]; | ||
43 | }; | 46 | }; |
44 | 47 | ||
45 | #define pstore_get_inode ramfs_get_inode | 48 | static int pstore_file_open(struct inode *inode, struct file *file) |
49 | { | ||
50 | file->private_data = inode->i_private; | ||
51 | return 0; | ||
52 | } | ||
53 | |||
54 | static ssize_t pstore_file_read(struct file *file, char __user *userbuf, | ||
55 | size_t count, loff_t *ppos) | ||
56 | { | ||
57 | struct pstore_private *ps = file->private_data; | ||
58 | |||
59 | return simple_read_from_buffer(userbuf, count, ppos, ps->data, ps->size); | ||
60 | } | ||
61 | |||
62 | static const struct file_operations pstore_file_operations = { | ||
63 | .open = pstore_file_open, | ||
64 | .read = pstore_file_read, | ||
65 | .llseek = default_llseek, | ||
66 | }; | ||
46 | 67 | ||
47 | /* | 68 | /* |
48 | * When a file is unlinked from our file system we call the | 69 | * When a file is unlinked from our file system we call the |
@@ -53,54 +74,99 @@ static int pstore_unlink(struct inode *dir, struct dentry *dentry) | |||
53 | struct pstore_private *p = dentry->d_inode->i_private; | 74 | struct pstore_private *p = dentry->d_inode->i_private; |
54 | 75 | ||
55 | p->erase(p->id); | 76 | p->erase(p->id); |
56 | kfree(p); | ||
57 | 77 | ||
58 | return simple_unlink(dir, dentry); | 78 | return simple_unlink(dir, dentry); |
59 | } | 79 | } |
60 | 80 | ||
81 | static void pstore_evict_inode(struct inode *inode) | ||
82 | { | ||
83 | end_writeback(inode); | ||
84 | kfree(inode->i_private); | ||
85 | } | ||
86 | |||
61 | static const struct inode_operations pstore_dir_inode_operations = { | 87 | static const struct inode_operations pstore_dir_inode_operations = { |
62 | .lookup = simple_lookup, | 88 | .lookup = simple_lookup, |
63 | .unlink = pstore_unlink, | 89 | .unlink = pstore_unlink, |
64 | }; | 90 | }; |
65 | 91 | ||
92 | static struct inode *pstore_get_inode(struct super_block *sb, | ||
93 | const struct inode *dir, int mode, dev_t dev) | ||
94 | { | ||
95 | struct inode *inode = new_inode(sb); | ||
96 | |||
97 | if (inode) { | ||
98 | inode->i_ino = get_next_ino(); | ||
99 | inode->i_uid = inode->i_gid = 0; | ||
100 | inode->i_mode = mode; | ||
101 | inode->i_atime = inode->i_mtime = inode->i_ctime = CURRENT_TIME; | ||
102 | switch (mode & S_IFMT) { | ||
103 | case S_IFREG: | ||
104 | inode->i_fop = &pstore_file_operations; | ||
105 | break; | ||
106 | case S_IFDIR: | ||
107 | inode->i_op = &pstore_dir_inode_operations; | ||
108 | inode->i_fop = &simple_dir_operations; | ||
109 | inc_nlink(inode); | ||
110 | break; | ||
111 | } | ||
112 | } | ||
113 | return inode; | ||
114 | } | ||
115 | |||
116 | enum { | ||
117 | Opt_kmsg_bytes, Opt_err | ||
118 | }; | ||
119 | |||
120 | static const match_table_t tokens = { | ||
121 | {Opt_kmsg_bytes, "kmsg_bytes=%u"}, | ||
122 | {Opt_err, NULL} | ||
123 | }; | ||
124 | |||
125 | static void parse_options(char *options) | ||
126 | { | ||
127 | char *p; | ||
128 | substring_t args[MAX_OPT_ARGS]; | ||
129 | int option; | ||
130 | |||
131 | if (!options) | ||
132 | return; | ||
133 | |||
134 | while ((p = strsep(&options, ",")) != NULL) { | ||
135 | int token; | ||
136 | |||
137 | if (!*p) | ||
138 | continue; | ||
139 | |||
140 | token = match_token(p, tokens, args); | ||
141 | switch (token) { | ||
142 | case Opt_kmsg_bytes: | ||
143 | if (!match_int(&args[0], &option)) | ||
144 | pstore_set_kmsg_bytes(option); | ||
145 | break; | ||
146 | } | ||
147 | } | ||
148 | } | ||
149 | |||
150 | static int pstore_remount(struct super_block *sb, int *flags, char *data) | ||
151 | { | ||
152 | parse_options(data); | ||
153 | |||
154 | return 0; | ||
155 | } | ||
156 | |||
66 | static const struct super_operations pstore_ops = { | 157 | static const struct super_operations pstore_ops = { |
67 | .statfs = simple_statfs, | 158 | .statfs = simple_statfs, |
68 | .drop_inode = generic_delete_inode, | 159 | .drop_inode = generic_delete_inode, |
160 | .evict_inode = pstore_evict_inode, | ||
161 | .remount_fs = pstore_remount, | ||
69 | .show_options = generic_show_options, | 162 | .show_options = generic_show_options, |
70 | }; | 163 | }; |
71 | 164 | ||
72 | static struct super_block *pstore_sb; | 165 | static struct super_block *pstore_sb; |
73 | static struct vfsmount *pstore_mnt; | ||
74 | 166 | ||
75 | int pstore_is_mounted(void) | 167 | int pstore_is_mounted(void) |
76 | { | 168 | { |
77 | return pstore_mnt != NULL; | 169 | return pstore_sb != NULL; |
78 | } | ||
79 | |||
80 | /* | ||
81 | * Set up a file structure as if we had opened this file and | ||
82 | * write our data to it. | ||
83 | */ | ||
84 | static int pstore_writefile(struct inode *inode, struct dentry *dentry, | ||
85 | char *data, size_t size) | ||
86 | { | ||
87 | struct file f; | ||
88 | ssize_t n; | ||
89 | mm_segment_t old_fs = get_fs(); | ||
90 | |||
91 | memset(&f, '0', sizeof f); | ||
92 | f.f_mapping = inode->i_mapping; | ||
93 | f.f_path.dentry = dentry; | ||
94 | f.f_path.mnt = pstore_mnt; | ||
95 | f.f_pos = 0; | ||
96 | f.f_op = inode->i_fop; | ||
97 | set_fs(KERNEL_DS); | ||
98 | n = do_sync_write(&f, data, size, &f.f_pos); | ||
99 | set_fs(old_fs); | ||
100 | |||
101 | fsnotify_modify(&f); | ||
102 | |||
103 | return n == size; | ||
104 | } | 170 | } |
105 | 171 | ||
106 | /* | 172 | /* |
@@ -123,8 +189,7 @@ int pstore_mkfile(enum pstore_type_id type, char *psname, u64 id, | |||
123 | inode = pstore_get_inode(pstore_sb, root->d_inode, S_IFREG | 0444, 0); | 189 | inode = pstore_get_inode(pstore_sb, root->d_inode, S_IFREG | 0444, 0); |
124 | if (!inode) | 190 | if (!inode) |
125 | goto fail; | 191 | goto fail; |
126 | inode->i_uid = inode->i_gid = 0; | 192 | private = kmalloc(sizeof *private + size, GFP_KERNEL); |
127 | private = kmalloc(sizeof *private, GFP_KERNEL); | ||
128 | if (!private) | 193 | if (!private) |
129 | goto fail_alloc; | 194 | goto fail_alloc; |
130 | private->id = id; | 195 | private->id = id; |
@@ -152,28 +217,19 @@ int pstore_mkfile(enum pstore_type_id type, char *psname, u64 id, | |||
152 | if (IS_ERR(dentry)) | 217 | if (IS_ERR(dentry)) |
153 | goto fail_lockedalloc; | 218 | goto fail_lockedalloc; |
154 | 219 | ||
155 | d_add(dentry, inode); | 220 | memcpy(private->data, data, size); |
156 | 221 | inode->i_size = private->size = size; | |
157 | mutex_unlock(&root->d_inode->i_mutex); | ||
158 | |||
159 | if (!pstore_writefile(inode, dentry, data, size)) | ||
160 | goto fail_write; | ||
161 | 222 | ||
162 | inode->i_private = private; | 223 | inode->i_private = private; |
163 | 224 | ||
164 | if (time.tv_sec) | 225 | if (time.tv_sec) |
165 | inode->i_mtime = inode->i_ctime = time; | 226 | inode->i_mtime = inode->i_ctime = time; |
166 | 227 | ||
167 | return 0; | 228 | d_add(dentry, inode); |
168 | 229 | ||
169 | fail_write: | ||
170 | kfree(private); | ||
171 | inode->i_nlink--; | ||
172 | mutex_lock(&root->d_inode->i_mutex); | ||
173 | d_delete(dentry); | ||
174 | dput(dentry); | ||
175 | mutex_unlock(&root->d_inode->i_mutex); | 230 | mutex_unlock(&root->d_inode->i_mutex); |
176 | goto fail; | 231 | |
232 | return 0; | ||
177 | 233 | ||
178 | fail_lockedalloc: | 234 | fail_lockedalloc: |
179 | mutex_unlock(&root->d_inode->i_mutex); | 235 | mutex_unlock(&root->d_inode->i_mutex); |
@@ -202,6 +258,8 @@ int pstore_fill_super(struct super_block *sb, void *data, int silent) | |||
202 | sb->s_op = &pstore_ops; | 258 | sb->s_op = &pstore_ops; |
203 | sb->s_time_gran = 1; | 259 | sb->s_time_gran = 1; |
204 | 260 | ||
261 | parse_options(data); | ||
262 | |||
205 | inode = pstore_get_inode(sb, NULL, S_IFDIR | 0755, 0); | 263 | inode = pstore_get_inode(sb, NULL, S_IFDIR | 0755, 0); |
206 | if (!inode) { | 264 | if (!inode) { |
207 | err = -ENOMEM; | 265 | err = -ENOMEM; |
@@ -225,59 +283,27 @@ fail: | |||
225 | return err; | 283 | return err; |
226 | } | 284 | } |
227 | 285 | ||
228 | static int pstore_get_sb(struct file_system_type *fs_type, | 286 | static struct dentry *pstore_mount(struct file_system_type *fs_type, |
229 | int flags, const char *dev_name, void *data, struct vfsmount *mnt) | 287 | int flags, const char *dev_name, void *data) |
230 | { | 288 | { |
231 | struct dentry *root; | 289 | return mount_single(fs_type, flags, data, pstore_fill_super); |
232 | |||
233 | root = mount_nodev(fs_type, flags, data, pstore_fill_super); | ||
234 | if (IS_ERR(root)) | ||
235 | return -ENOMEM; | ||
236 | |||
237 | mnt->mnt_root = root; | ||
238 | mnt->mnt_sb = root->d_sb; | ||
239 | pstore_mnt = mnt; | ||
240 | |||
241 | return 0; | ||
242 | } | 290 | } |
243 | 291 | ||
244 | static void pstore_kill_sb(struct super_block *sb) | 292 | static void pstore_kill_sb(struct super_block *sb) |
245 | { | 293 | { |
246 | kill_litter_super(sb); | 294 | kill_litter_super(sb); |
247 | pstore_sb = NULL; | 295 | pstore_sb = NULL; |
248 | pstore_mnt = NULL; | ||
249 | } | 296 | } |
250 | 297 | ||
251 | static struct file_system_type pstore_fs_type = { | 298 | static struct file_system_type pstore_fs_type = { |
252 | .name = "pstore", | 299 | .name = "pstore", |
253 | .get_sb = pstore_get_sb, | 300 | .mount = pstore_mount, |
254 | .kill_sb = pstore_kill_sb, | 301 | .kill_sb = pstore_kill_sb, |
255 | }; | 302 | }; |
256 | 303 | ||
257 | static int __init init_pstore_fs(void) | 304 | static int __init init_pstore_fs(void) |
258 | { | 305 | { |
259 | int rc = 0; | 306 | return register_filesystem(&pstore_fs_type); |
260 | struct kobject *pstorefs_kobj; | ||
261 | |||
262 | pstorefs_kobj = kobject_create_and_add("pstore", fs_kobj); | ||
263 | if (!pstorefs_kobj) { | ||
264 | rc = -ENOMEM; | ||
265 | goto done; | ||
266 | } | ||
267 | |||
268 | rc = sysfs_create_file(pstorefs_kobj, &pstore_kmsg_bytes_attr.attr); | ||
269 | if (rc) | ||
270 | goto done1; | ||
271 | |||
272 | rc = register_filesystem(&pstore_fs_type); | ||
273 | if (rc == 0) | ||
274 | goto done; | ||
275 | |||
276 | sysfs_remove_file(pstorefs_kobj, &pstore_kmsg_bytes_attr.attr); | ||
277 | done1: | ||
278 | kobject_put(pstorefs_kobj); | ||
279 | done: | ||
280 | return rc; | ||
281 | } | 307 | } |
282 | module_init(init_pstore_fs) | 308 | module_init(init_pstore_fs) |
283 | 309 | ||
diff --git a/fs/pstore/internal.h b/fs/pstore/internal.h index 76c26d2fab29..8c9f23eb1645 100644 --- a/fs/pstore/internal.h +++ b/fs/pstore/internal.h | |||
@@ -1,7 +1,6 @@ | |||
1 | extern void pstore_set_kmsg_bytes(int); | ||
1 | extern void pstore_get_records(void); | 2 | extern void pstore_get_records(void); |
2 | extern int pstore_mkfile(enum pstore_type_id, char *psname, u64 id, | 3 | extern int pstore_mkfile(enum pstore_type_id, char *psname, u64 id, |
3 | char *data, size_t size, | 4 | char *data, size_t size, |
4 | struct timespec time, int (*erase)(u64)); | 5 | struct timespec time, int (*erase)(u64)); |
5 | extern int pstore_is_mounted(void); | 6 | extern int pstore_is_mounted(void); |
6 | |||
7 | extern struct kobj_attribute pstore_kmsg_bytes_attr; | ||
diff --git a/fs/pstore/platform.c b/fs/pstore/platform.c index 705fdf8abf6e..f835a25625ff 100644 --- a/fs/pstore/platform.c +++ b/fs/pstore/platform.c | |||
@@ -37,27 +37,21 @@ | |||
37 | static DEFINE_SPINLOCK(pstore_lock); | 37 | static DEFINE_SPINLOCK(pstore_lock); |
38 | static struct pstore_info *psinfo; | 38 | static struct pstore_info *psinfo; |
39 | 39 | ||
40 | /* How much of the console log to snapshot. /sys/fs/pstore/kmsg_bytes */ | 40 | /* How much of the console log to snapshot */ |
41 | static unsigned long kmsg_bytes = 10240; | 41 | static unsigned long kmsg_bytes = 10240; |
42 | 42 | ||
43 | static ssize_t b_show(struct kobject *kobj, | 43 | void pstore_set_kmsg_bytes(int bytes) |
44 | struct kobj_attribute *attr, char *buf) | ||
45 | { | 44 | { |
46 | return snprintf(buf, PAGE_SIZE, "%lu\n", kmsg_bytes); | 45 | kmsg_bytes = bytes; |
47 | } | 46 | } |
48 | 47 | ||
49 | static ssize_t b_store(struct kobject *kobj, struct kobj_attribute *attr, | ||
50 | const char *buf, size_t count) | ||
51 | { | ||
52 | return (sscanf(buf, "%lu", &kmsg_bytes) > 0) ? count : 0; | ||
53 | } | ||
54 | |||
55 | struct kobj_attribute pstore_kmsg_bytes_attr = | ||
56 | __ATTR(kmsg_bytes, S_IRUGO | S_IWUSR, b_show, b_store); | ||
57 | |||
58 | /* Tag each group of saved records with a sequence number */ | 48 | /* Tag each group of saved records with a sequence number */ |
59 | static int oopscount; | 49 | static int oopscount; |
60 | 50 | ||
51 | static char *reason_str[] = { | ||
52 | "Oops", "Panic", "Kexec", "Restart", "Halt", "Poweroff", "Emergency" | ||
53 | }; | ||
54 | |||
61 | /* | 55 | /* |
62 | * callback from kmsg_dump. (s2,l2) has the most recently | 56 | * callback from kmsg_dump. (s2,l2) has the most recently |
63 | * written bytes, older bytes are in (s1,l1). Save as much | 57 | * written bytes, older bytes are in (s1,l1). Save as much |
@@ -71,15 +65,20 @@ static void pstore_dump(struct kmsg_dumper *dumper, | |||
71 | unsigned long s1_start, s2_start; | 65 | unsigned long s1_start, s2_start; |
72 | unsigned long l1_cpy, l2_cpy; | 66 | unsigned long l1_cpy, l2_cpy; |
73 | unsigned long size, total = 0; | 67 | unsigned long size, total = 0; |
74 | char *dst; | 68 | char *dst, *why; |
75 | u64 id; | 69 | u64 id; |
76 | int hsize, part = 1; | 70 | int hsize, part = 1; |
77 | 71 | ||
72 | if (reason < ARRAY_SIZE(reason_str)) | ||
73 | why = reason_str[reason]; | ||
74 | else | ||
75 | why = "Unknown"; | ||
76 | |||
78 | mutex_lock(&psinfo->buf_mutex); | 77 | mutex_lock(&psinfo->buf_mutex); |
79 | oopscount++; | 78 | oopscount++; |
80 | while (total < kmsg_bytes) { | 79 | while (total < kmsg_bytes) { |
81 | dst = psinfo->buf; | 80 | dst = psinfo->buf; |
82 | hsize = sprintf(dst, "Oops#%d Part%d\n", oopscount, part++); | 81 | hsize = sprintf(dst, "%s#%d Part%d\n", why, oopscount, part++); |
83 | size = psinfo->bufsize - hsize; | 82 | size = psinfo->bufsize - hsize; |
84 | dst += hsize; | 83 | dst += hsize; |
85 | 84 | ||
@@ -96,7 +95,7 @@ static void pstore_dump(struct kmsg_dumper *dumper, | |||
96 | memcpy(dst + l1_cpy, s2 + s2_start, l2_cpy); | 95 | memcpy(dst + l1_cpy, s2 + s2_start, l2_cpy); |
97 | 96 | ||
98 | id = psinfo->write(PSTORE_TYPE_DMESG, hsize + l1_cpy + l2_cpy); | 97 | id = psinfo->write(PSTORE_TYPE_DMESG, hsize + l1_cpy + l2_cpy); |
99 | if (pstore_is_mounted()) | 98 | if (reason == KMSG_DUMP_OOPS && pstore_is_mounted()) |
100 | pstore_mkfile(PSTORE_TYPE_DMESG, psinfo->name, id, | 99 | pstore_mkfile(PSTORE_TYPE_DMESG, psinfo->name, id, |
101 | psinfo->buf, hsize + l1_cpy + l2_cpy, | 100 | psinfo->buf, hsize + l1_cpy + l2_cpy, |
102 | CURRENT_TIME, psinfo->erase); | 101 | CURRENT_TIME, psinfo->erase); |
diff --git a/fs/reiserfs/Makefile b/fs/reiserfs/Makefile index 792b3cb2cd18..3c3b00165114 100644 --- a/fs/reiserfs/Makefile +++ b/fs/reiserfs/Makefile | |||
@@ -31,9 +31,7 @@ endif | |||
31 | # and causing a panic. Since this behavior only affects ppc32, this ifeq | 31 | # and causing a panic. Since this behavior only affects ppc32, this ifeq |
32 | # will work around it. If any other architecture displays this behavior, | 32 | # will work around it. If any other architecture displays this behavior, |
33 | # add it here. | 33 | # add it here. |
34 | ifeq ($(CONFIG_PPC32),y) | 34 | ccflags-$(CONFIG_PPC32) := $(call cc-ifversion, -lt, 0400, -O1) |
35 | EXTRA_CFLAGS := $(call cc-ifversion, -lt, 0400, -O1) | ||
36 | endif | ||
37 | 35 | ||
38 | TAGS: | 36 | TAGS: |
39 | etags *.c | 37 | etags *.c |
diff --git a/fs/reiserfs/ioctl.c b/fs/reiserfs/ioctl.c index 79265fdc317a..4e153051bc75 100644 --- a/fs/reiserfs/ioctl.c +++ b/fs/reiserfs/ioctl.c | |||
@@ -59,7 +59,7 @@ long reiserfs_ioctl(struct file *filp, unsigned int cmd, unsigned long arg) | |||
59 | if (err) | 59 | if (err) |
60 | break; | 60 | break; |
61 | 61 | ||
62 | if (!is_owner_or_cap(inode)) { | 62 | if (!inode_owner_or_capable(inode)) { |
63 | err = -EPERM; | 63 | err = -EPERM; |
64 | goto setflags_out; | 64 | goto setflags_out; |
65 | } | 65 | } |
@@ -103,7 +103,7 @@ setflags_out: | |||
103 | err = put_user(inode->i_generation, (int __user *)arg); | 103 | err = put_user(inode->i_generation, (int __user *)arg); |
104 | break; | 104 | break; |
105 | case REISERFS_IOC_SETVERSION: | 105 | case REISERFS_IOC_SETVERSION: |
106 | if (!is_owner_or_cap(inode)) { | 106 | if (!inode_owner_or_capable(inode)) { |
107 | err = -EPERM; | 107 | err = -EPERM; |
108 | break; | 108 | break; |
109 | } | 109 | } |
diff --git a/fs/reiserfs/xattr_acl.c b/fs/reiserfs/xattr_acl.c index 90d2fcb67a31..3dc38f1206fc 100644 --- a/fs/reiserfs/xattr_acl.c +++ b/fs/reiserfs/xattr_acl.c | |||
@@ -26,7 +26,7 @@ posix_acl_set(struct dentry *dentry, const char *name, const void *value, | |||
26 | size_t jcreate_blocks; | 26 | size_t jcreate_blocks; |
27 | if (!reiserfs_posixacl(inode->i_sb)) | 27 | if (!reiserfs_posixacl(inode->i_sb)) |
28 | return -EOPNOTSUPP; | 28 | return -EOPNOTSUPP; |
29 | if (!is_owner_or_cap(inode)) | 29 | if (!inode_owner_or_capable(inode)) |
30 | return -EPERM; | 30 | return -EPERM; |
31 | 31 | ||
32 | if (value) { | 32 | if (value) { |
diff --git a/fs/select.c b/fs/select.c index e56560d2b08a..d33418fdc858 100644 --- a/fs/select.c +++ b/fs/select.c | |||
@@ -517,9 +517,6 @@ int do_select(int n, fd_set_bits *fds, struct timespec *end_time) | |||
517 | * Update: ERESTARTSYS breaks at least the xview clock binary, so | 517 | * Update: ERESTARTSYS breaks at least the xview clock binary, so |
518 | * I'm trying ERESTARTNOHAND which restart only when you want to. | 518 | * I'm trying ERESTARTNOHAND which restart only when you want to. |
519 | */ | 519 | */ |
520 | #define MAX_SELECT_SECONDS \ | ||
521 | ((unsigned long) (MAX_SCHEDULE_TIMEOUT / HZ)-1) | ||
522 | |||
523 | int core_sys_select(int n, fd_set __user *inp, fd_set __user *outp, | 520 | int core_sys_select(int n, fd_set __user *inp, fd_set __user *outp, |
524 | fd_set __user *exp, struct timespec *end_time) | 521 | fd_set __user *exp, struct timespec *end_time) |
525 | { | 522 | { |
diff --git a/fs/squashfs/Kconfig b/fs/squashfs/Kconfig index aa68a8a31518..efc309fa3035 100644 --- a/fs/squashfs/Kconfig +++ b/fs/squashfs/Kconfig | |||
@@ -5,12 +5,12 @@ config SQUASHFS | |||
5 | help | 5 | help |
6 | Saying Y here includes support for SquashFS 4.0 (a Compressed | 6 | Saying Y here includes support for SquashFS 4.0 (a Compressed |
7 | Read-Only File System). Squashfs is a highly compressed read-only | 7 | Read-Only File System). Squashfs is a highly compressed read-only |
8 | filesystem for Linux. It uses zlib/lzo compression to compress both | 8 | filesystem for Linux. It uses zlib, lzo or xz compression to |
9 | files, inodes and directories. Inodes in the system are very small | 9 | compress both files, inodes and directories. Inodes in the system |
10 | and all blocks are packed to minimise data overhead. Block sizes | 10 | are very small and all blocks are packed to minimise data overhead. |
11 | greater than 4K are supported up to a maximum of 1 Mbytes (default | 11 | Block sizes greater than 4K are supported up to a maximum of 1 Mbytes |
12 | block size 128K). SquashFS 4.0 supports 64 bit filesystems and files | 12 | (default block size 128K). SquashFS 4.0 supports 64 bit filesystems |
13 | (larger than 4GB), full uid/gid information, hard links and | 13 | and files (larger than 4GB), full uid/gid information, hard links and |
14 | timestamps. | 14 | timestamps. |
15 | 15 | ||
16 | Squashfs is intended for general read-only filesystem use, for | 16 | Squashfs is intended for general read-only filesystem use, for |
diff --git a/fs/squashfs/decompressor.c b/fs/squashfs/decompressor.c index a5940e54c4dd..e921bd213738 100644 --- a/fs/squashfs/decompressor.c +++ b/fs/squashfs/decompressor.c | |||
@@ -23,6 +23,7 @@ | |||
23 | 23 | ||
24 | #include <linux/types.h> | 24 | #include <linux/types.h> |
25 | #include <linux/mutex.h> | 25 | #include <linux/mutex.h> |
26 | #include <linux/slab.h> | ||
26 | #include <linux/buffer_head.h> | 27 | #include <linux/buffer_head.h> |
27 | 28 | ||
28 | #include "squashfs_fs.h" | 29 | #include "squashfs_fs.h" |
@@ -74,3 +75,36 @@ const struct squashfs_decompressor *squashfs_lookup_decompressor(int id) | |||
74 | 75 | ||
75 | return decompressor[i]; | 76 | return decompressor[i]; |
76 | } | 77 | } |
78 | |||
79 | |||
80 | void *squashfs_decompressor_init(struct super_block *sb, unsigned short flags) | ||
81 | { | ||
82 | struct squashfs_sb_info *msblk = sb->s_fs_info; | ||
83 | void *strm, *buffer = NULL; | ||
84 | int length = 0; | ||
85 | |||
86 | /* | ||
87 | * Read decompressor specific options from file system if present | ||
88 | */ | ||
89 | if (SQUASHFS_COMP_OPTS(flags)) { | ||
90 | buffer = kmalloc(PAGE_CACHE_SIZE, GFP_KERNEL); | ||
91 | if (buffer == NULL) | ||
92 | return ERR_PTR(-ENOMEM); | ||
93 | |||
94 | length = squashfs_read_data(sb, &buffer, | ||
95 | sizeof(struct squashfs_super_block), 0, NULL, | ||
96 | PAGE_CACHE_SIZE, 1); | ||
97 | |||
98 | if (length < 0) { | ||
99 | strm = ERR_PTR(length); | ||
100 | goto finished; | ||
101 | } | ||
102 | } | ||
103 | |||
104 | strm = msblk->decompressor->init(msblk, buffer, length); | ||
105 | |||
106 | finished: | ||
107 | kfree(buffer); | ||
108 | |||
109 | return strm; | ||
110 | } | ||
diff --git a/fs/squashfs/decompressor.h b/fs/squashfs/decompressor.h index 3b305a70f7aa..099745ad5691 100644 --- a/fs/squashfs/decompressor.h +++ b/fs/squashfs/decompressor.h | |||
@@ -24,7 +24,7 @@ | |||
24 | */ | 24 | */ |
25 | 25 | ||
26 | struct squashfs_decompressor { | 26 | struct squashfs_decompressor { |
27 | void *(*init)(struct squashfs_sb_info *); | 27 | void *(*init)(struct squashfs_sb_info *, void *, int); |
28 | void (*free)(void *); | 28 | void (*free)(void *); |
29 | int (*decompress)(struct squashfs_sb_info *, void **, | 29 | int (*decompress)(struct squashfs_sb_info *, void **, |
30 | struct buffer_head **, int, int, int, int, int); | 30 | struct buffer_head **, int, int, int, int, int); |
@@ -33,11 +33,6 @@ struct squashfs_decompressor { | |||
33 | int supported; | 33 | int supported; |
34 | }; | 34 | }; |
35 | 35 | ||
36 | static inline void *squashfs_decompressor_init(struct squashfs_sb_info *msblk) | ||
37 | { | ||
38 | return msblk->decompressor->init(msblk); | ||
39 | } | ||
40 | |||
41 | static inline void squashfs_decompressor_free(struct squashfs_sb_info *msblk, | 36 | static inline void squashfs_decompressor_free(struct squashfs_sb_info *msblk, |
42 | void *s) | 37 | void *s) |
43 | { | 38 | { |
diff --git a/fs/squashfs/dir.c b/fs/squashfs/dir.c index 0dc340aa2be9..3f79cd1d0c19 100644 --- a/fs/squashfs/dir.c +++ b/fs/squashfs/dir.c | |||
@@ -172,6 +172,11 @@ static int squashfs_readdir(struct file *file, void *dirent, filldir_t filldir) | |||
172 | length += sizeof(dirh); | 172 | length += sizeof(dirh); |
173 | 173 | ||
174 | dir_count = le32_to_cpu(dirh.count) + 1; | 174 | dir_count = le32_to_cpu(dirh.count) + 1; |
175 | |||
176 | /* dir_count should never be larger than 256 */ | ||
177 | if (dir_count > 256) | ||
178 | goto failed_read; | ||
179 | |||
175 | while (dir_count--) { | 180 | while (dir_count--) { |
176 | /* | 181 | /* |
177 | * Read directory entry. | 182 | * Read directory entry. |
@@ -183,6 +188,10 @@ static int squashfs_readdir(struct file *file, void *dirent, filldir_t filldir) | |||
183 | 188 | ||
184 | size = le16_to_cpu(dire->size) + 1; | 189 | size = le16_to_cpu(dire->size) + 1; |
185 | 190 | ||
191 | /* size should never be larger than SQUASHFS_NAME_LEN */ | ||
192 | if (size > SQUASHFS_NAME_LEN) | ||
193 | goto failed_read; | ||
194 | |||
186 | err = squashfs_read_metadata(inode->i_sb, dire->name, | 195 | err = squashfs_read_metadata(inode->i_sb, dire->name, |
187 | &block, &offset, size); | 196 | &block, &offset, size); |
188 | if (err < 0) | 197 | if (err < 0) |
diff --git a/fs/squashfs/lzo_wrapper.c b/fs/squashfs/lzo_wrapper.c index 7da759e34c52..00f4dfc5f088 100644 --- a/fs/squashfs/lzo_wrapper.c +++ b/fs/squashfs/lzo_wrapper.c | |||
@@ -37,7 +37,7 @@ struct squashfs_lzo { | |||
37 | void *output; | 37 | void *output; |
38 | }; | 38 | }; |
39 | 39 | ||
40 | static void *lzo_init(struct squashfs_sb_info *msblk) | 40 | static void *lzo_init(struct squashfs_sb_info *msblk, void *buff, int len) |
41 | { | 41 | { |
42 | int block_size = max_t(int, msblk->block_size, SQUASHFS_METADATA_SIZE); | 42 | int block_size = max_t(int, msblk->block_size, SQUASHFS_METADATA_SIZE); |
43 | 43 | ||
@@ -58,7 +58,7 @@ failed2: | |||
58 | failed: | 58 | failed: |
59 | ERROR("Failed to allocate lzo workspace\n"); | 59 | ERROR("Failed to allocate lzo workspace\n"); |
60 | kfree(stream); | 60 | kfree(stream); |
61 | return NULL; | 61 | return ERR_PTR(-ENOMEM); |
62 | } | 62 | } |
63 | 63 | ||
64 | 64 | ||
diff --git a/fs/squashfs/namei.c b/fs/squashfs/namei.c index 7a9464d08cf6..5d922a6701ab 100644 --- a/fs/squashfs/namei.c +++ b/fs/squashfs/namei.c | |||
@@ -176,6 +176,11 @@ static struct dentry *squashfs_lookup(struct inode *dir, struct dentry *dentry, | |||
176 | length += sizeof(dirh); | 176 | length += sizeof(dirh); |
177 | 177 | ||
178 | dir_count = le32_to_cpu(dirh.count) + 1; | 178 | dir_count = le32_to_cpu(dirh.count) + 1; |
179 | |||
180 | /* dir_count should never be larger than 256 */ | ||
181 | if (dir_count > 256) | ||
182 | goto data_error; | ||
183 | |||
179 | while (dir_count--) { | 184 | while (dir_count--) { |
180 | /* | 185 | /* |
181 | * Read directory entry. | 186 | * Read directory entry. |
@@ -187,6 +192,10 @@ static struct dentry *squashfs_lookup(struct inode *dir, struct dentry *dentry, | |||
187 | 192 | ||
188 | size = le16_to_cpu(dire->size) + 1; | 193 | size = le16_to_cpu(dire->size) + 1; |
189 | 194 | ||
195 | /* size should never be larger than SQUASHFS_NAME_LEN */ | ||
196 | if (size > SQUASHFS_NAME_LEN) | ||
197 | goto data_error; | ||
198 | |||
190 | err = squashfs_read_metadata(dir->i_sb, dire->name, | 199 | err = squashfs_read_metadata(dir->i_sb, dire->name, |
191 | &block, &offset, size); | 200 | &block, &offset, size); |
192 | if (err < 0) | 201 | if (err < 0) |
@@ -228,6 +237,9 @@ exit_lookup: | |||
228 | d_add(dentry, inode); | 237 | d_add(dentry, inode); |
229 | return ERR_PTR(0); | 238 | return ERR_PTR(0); |
230 | 239 | ||
240 | data_error: | ||
241 | err = -EIO; | ||
242 | |||
231 | read_failure: | 243 | read_failure: |
232 | ERROR("Unable to read directory block [%llx:%x]\n", | 244 | ERROR("Unable to read directory block [%llx:%x]\n", |
233 | squashfs_i(dir)->start + msblk->directory_table, | 245 | squashfs_i(dir)->start + msblk->directory_table, |
diff --git a/fs/squashfs/squashfs.h b/fs/squashfs/squashfs.h index ba729d808876..1f2e608b8785 100644 --- a/fs/squashfs/squashfs.h +++ b/fs/squashfs/squashfs.h | |||
@@ -48,6 +48,7 @@ extern int squashfs_read_table(struct super_block *, void *, u64, int); | |||
48 | 48 | ||
49 | /* decompressor.c */ | 49 | /* decompressor.c */ |
50 | extern const struct squashfs_decompressor *squashfs_lookup_decompressor(int); | 50 | extern const struct squashfs_decompressor *squashfs_lookup_decompressor(int); |
51 | extern void *squashfs_decompressor_init(struct super_block *, unsigned short); | ||
51 | 52 | ||
52 | /* export.c */ | 53 | /* export.c */ |
53 | extern __le64 *squashfs_read_inode_lookup_table(struct super_block *, u64, | 54 | extern __le64 *squashfs_read_inode_lookup_table(struct super_block *, u64, |
diff --git a/fs/squashfs/squashfs_fs.h b/fs/squashfs/squashfs_fs.h index 39533feffd6d..4582c568ef4d 100644 --- a/fs/squashfs/squashfs_fs.h +++ b/fs/squashfs/squashfs_fs.h | |||
@@ -57,6 +57,7 @@ | |||
57 | #define SQUASHFS_ALWAYS_FRAG 5 | 57 | #define SQUASHFS_ALWAYS_FRAG 5 |
58 | #define SQUASHFS_DUPLICATE 6 | 58 | #define SQUASHFS_DUPLICATE 6 |
59 | #define SQUASHFS_EXPORT 7 | 59 | #define SQUASHFS_EXPORT 7 |
60 | #define SQUASHFS_COMP_OPT 10 | ||
60 | 61 | ||
61 | #define SQUASHFS_BIT(flag, bit) ((flag >> bit) & 1) | 62 | #define SQUASHFS_BIT(flag, bit) ((flag >> bit) & 1) |
62 | 63 | ||
@@ -81,6 +82,9 @@ | |||
81 | #define SQUASHFS_EXPORTABLE(flags) SQUASHFS_BIT(flags, \ | 82 | #define SQUASHFS_EXPORTABLE(flags) SQUASHFS_BIT(flags, \ |
82 | SQUASHFS_EXPORT) | 83 | SQUASHFS_EXPORT) |
83 | 84 | ||
85 | #define SQUASHFS_COMP_OPTS(flags) SQUASHFS_BIT(flags, \ | ||
86 | SQUASHFS_COMP_OPT) | ||
87 | |||
84 | /* Max number of types and file types */ | 88 | /* Max number of types and file types */ |
85 | #define SQUASHFS_DIR_TYPE 1 | 89 | #define SQUASHFS_DIR_TYPE 1 |
86 | #define SQUASHFS_REG_TYPE 2 | 90 | #define SQUASHFS_REG_TYPE 2 |
diff --git a/fs/squashfs/super.c b/fs/squashfs/super.c index 20700b9f2b4c..5c8184c061a4 100644 --- a/fs/squashfs/super.c +++ b/fs/squashfs/super.c | |||
@@ -199,10 +199,6 @@ static int squashfs_fill_super(struct super_block *sb, void *data, int silent) | |||
199 | 199 | ||
200 | err = -ENOMEM; | 200 | err = -ENOMEM; |
201 | 201 | ||
202 | msblk->stream = squashfs_decompressor_init(msblk); | ||
203 | if (msblk->stream == NULL) | ||
204 | goto failed_mount; | ||
205 | |||
206 | msblk->block_cache = squashfs_cache_init("metadata", | 202 | msblk->block_cache = squashfs_cache_init("metadata", |
207 | SQUASHFS_CACHED_BLKS, SQUASHFS_METADATA_SIZE); | 203 | SQUASHFS_CACHED_BLKS, SQUASHFS_METADATA_SIZE); |
208 | if (msblk->block_cache == NULL) | 204 | if (msblk->block_cache == NULL) |
@@ -215,6 +211,13 @@ static int squashfs_fill_super(struct super_block *sb, void *data, int silent) | |||
215 | goto failed_mount; | 211 | goto failed_mount; |
216 | } | 212 | } |
217 | 213 | ||
214 | msblk->stream = squashfs_decompressor_init(sb, flags); | ||
215 | if (IS_ERR(msblk->stream)) { | ||
216 | err = PTR_ERR(msblk->stream); | ||
217 | msblk->stream = NULL; | ||
218 | goto failed_mount; | ||
219 | } | ||
220 | |||
218 | /* Allocate and read id index table */ | 221 | /* Allocate and read id index table */ |
219 | msblk->id_table = squashfs_read_id_index_table(sb, | 222 | msblk->id_table = squashfs_read_id_index_table(sb, |
220 | le64_to_cpu(sblk->id_table_start), le16_to_cpu(sblk->no_ids)); | 223 | le64_to_cpu(sblk->id_table_start), le16_to_cpu(sblk->no_ids)); |
@@ -370,8 +373,8 @@ static void squashfs_put_super(struct super_block *sb) | |||
370 | } | 373 | } |
371 | 374 | ||
372 | 375 | ||
373 | static struct dentry *squashfs_mount(struct file_system_type *fs_type, int flags, | 376 | static struct dentry *squashfs_mount(struct file_system_type *fs_type, |
374 | const char *dev_name, void *data) | 377 | int flags, const char *dev_name, void *data) |
375 | { | 378 | { |
376 | return mount_bdev(fs_type, flags, dev_name, data, squashfs_fill_super); | 379 | return mount_bdev(fs_type, flags, dev_name, data, squashfs_fill_super); |
377 | } | 380 | } |
diff --git a/fs/squashfs/xz_wrapper.c b/fs/squashfs/xz_wrapper.c index c4eb40018256..aa47a286d1f8 100644 --- a/fs/squashfs/xz_wrapper.c +++ b/fs/squashfs/xz_wrapper.c | |||
@@ -26,10 +26,10 @@ | |||
26 | #include <linux/buffer_head.h> | 26 | #include <linux/buffer_head.h> |
27 | #include <linux/slab.h> | 27 | #include <linux/slab.h> |
28 | #include <linux/xz.h> | 28 | #include <linux/xz.h> |
29 | #include <linux/bitops.h> | ||
29 | 30 | ||
30 | #include "squashfs_fs.h" | 31 | #include "squashfs_fs.h" |
31 | #include "squashfs_fs_sb.h" | 32 | #include "squashfs_fs_sb.h" |
32 | #include "squashfs_fs_i.h" | ||
33 | #include "squashfs.h" | 33 | #include "squashfs.h" |
34 | #include "decompressor.h" | 34 | #include "decompressor.h" |
35 | 35 | ||
@@ -38,24 +38,57 @@ struct squashfs_xz { | |||
38 | struct xz_buf buf; | 38 | struct xz_buf buf; |
39 | }; | 39 | }; |
40 | 40 | ||
41 | static void *squashfs_xz_init(struct squashfs_sb_info *msblk) | 41 | struct comp_opts { |
42 | __le32 dictionary_size; | ||
43 | __le32 flags; | ||
44 | }; | ||
45 | |||
46 | static void *squashfs_xz_init(struct squashfs_sb_info *msblk, void *buff, | ||
47 | int len) | ||
42 | { | 48 | { |
43 | int block_size = max_t(int, msblk->block_size, SQUASHFS_METADATA_SIZE); | 49 | struct comp_opts *comp_opts = buff; |
50 | struct squashfs_xz *stream; | ||
51 | int dict_size = msblk->block_size; | ||
52 | int err, n; | ||
53 | |||
54 | if (comp_opts) { | ||
55 | /* check compressor options are the expected length */ | ||
56 | if (len < sizeof(*comp_opts)) { | ||
57 | err = -EIO; | ||
58 | goto failed; | ||
59 | } | ||
44 | 60 | ||
45 | struct squashfs_xz *stream = kmalloc(sizeof(*stream), GFP_KERNEL); | 61 | dict_size = le32_to_cpu(comp_opts->dictionary_size); |
46 | if (stream == NULL) | 62 | |
63 | /* the dictionary size should be 2^n or 2^n+2^(n+1) */ | ||
64 | n = ffs(dict_size) - 1; | ||
65 | if (dict_size != (1 << n) && dict_size != (1 << n) + | ||
66 | (1 << (n + 1))) { | ||
67 | err = -EIO; | ||
68 | goto failed; | ||
69 | } | ||
70 | } | ||
71 | |||
72 | dict_size = max_t(int, dict_size, SQUASHFS_METADATA_SIZE); | ||
73 | |||
74 | stream = kmalloc(sizeof(*stream), GFP_KERNEL); | ||
75 | if (stream == NULL) { | ||
76 | err = -ENOMEM; | ||
47 | goto failed; | 77 | goto failed; |
78 | } | ||
48 | 79 | ||
49 | stream->state = xz_dec_init(XZ_PREALLOC, block_size); | 80 | stream->state = xz_dec_init(XZ_PREALLOC, dict_size); |
50 | if (stream->state == NULL) | 81 | if (stream->state == NULL) { |
82 | kfree(stream); | ||
83 | err = -ENOMEM; | ||
51 | goto failed; | 84 | goto failed; |
85 | } | ||
52 | 86 | ||
53 | return stream; | 87 | return stream; |
54 | 88 | ||
55 | failed: | 89 | failed: |
56 | ERROR("Failed to allocate xz workspace\n"); | 90 | ERROR("Failed to initialise xz decompressor\n"); |
57 | kfree(stream); | 91 | return ERR_PTR(err); |
58 | return NULL; | ||
59 | } | 92 | } |
60 | 93 | ||
61 | 94 | ||
diff --git a/fs/squashfs/zlib_wrapper.c b/fs/squashfs/zlib_wrapper.c index 4661ae2b1cec..517688b32ffa 100644 --- a/fs/squashfs/zlib_wrapper.c +++ b/fs/squashfs/zlib_wrapper.c | |||
@@ -26,19 +26,19 @@ | |||
26 | #include <linux/buffer_head.h> | 26 | #include <linux/buffer_head.h> |
27 | #include <linux/slab.h> | 27 | #include <linux/slab.h> |
28 | #include <linux/zlib.h> | 28 | #include <linux/zlib.h> |
29 | #include <linux/vmalloc.h> | ||
29 | 30 | ||
30 | #include "squashfs_fs.h" | 31 | #include "squashfs_fs.h" |
31 | #include "squashfs_fs_sb.h" | 32 | #include "squashfs_fs_sb.h" |
32 | #include "squashfs.h" | 33 | #include "squashfs.h" |
33 | #include "decompressor.h" | 34 | #include "decompressor.h" |
34 | 35 | ||
35 | static void *zlib_init(struct squashfs_sb_info *dummy) | 36 | static void *zlib_init(struct squashfs_sb_info *dummy, void *buff, int len) |
36 | { | 37 | { |
37 | z_stream *stream = kmalloc(sizeof(z_stream), GFP_KERNEL); | 38 | z_stream *stream = kmalloc(sizeof(z_stream), GFP_KERNEL); |
38 | if (stream == NULL) | 39 | if (stream == NULL) |
39 | goto failed; | 40 | goto failed; |
40 | stream->workspace = kmalloc(zlib_inflate_workspacesize(), | 41 | stream->workspace = vmalloc(zlib_inflate_workspacesize()); |
41 | GFP_KERNEL); | ||
42 | if (stream->workspace == NULL) | 42 | if (stream->workspace == NULL) |
43 | goto failed; | 43 | goto failed; |
44 | 44 | ||
@@ -47,7 +47,7 @@ static void *zlib_init(struct squashfs_sb_info *dummy) | |||
47 | failed: | 47 | failed: |
48 | ERROR("Failed to allocate zlib workspace\n"); | 48 | ERROR("Failed to allocate zlib workspace\n"); |
49 | kfree(stream); | 49 | kfree(stream); |
50 | return NULL; | 50 | return ERR_PTR(-ENOMEM); |
51 | } | 51 | } |
52 | 52 | ||
53 | 53 | ||
@@ -56,7 +56,7 @@ static void zlib_free(void *strm) | |||
56 | z_stream *stream = strm; | 56 | z_stream *stream = strm; |
57 | 57 | ||
58 | if (stream) | 58 | if (stream) |
59 | kfree(stream->workspace); | 59 | vfree(stream->workspace); |
60 | kfree(stream); | 60 | kfree(stream); |
61 | } | 61 | } |
62 | 62 | ||
diff --git a/fs/super.c b/fs/super.c index 4bae0ef6110e..e84864908264 100644 --- a/fs/super.c +++ b/fs/super.c | |||
@@ -910,29 +910,18 @@ struct dentry *mount_single(struct file_system_type *fs_type, | |||
910 | } | 910 | } |
911 | EXPORT_SYMBOL(mount_single); | 911 | EXPORT_SYMBOL(mount_single); |
912 | 912 | ||
913 | struct vfsmount * | 913 | struct dentry * |
914 | vfs_kern_mount(struct file_system_type *type, int flags, const char *name, void *data) | 914 | mount_fs(struct file_system_type *type, int flags, const char *name, void *data) |
915 | { | 915 | { |
916 | struct vfsmount *mnt; | ||
917 | struct dentry *root; | 916 | struct dentry *root; |
917 | struct super_block *sb; | ||
918 | char *secdata = NULL; | 918 | char *secdata = NULL; |
919 | int error; | 919 | int error = -ENOMEM; |
920 | |||
921 | if (!type) | ||
922 | return ERR_PTR(-ENODEV); | ||
923 | |||
924 | error = -ENOMEM; | ||
925 | mnt = alloc_vfsmnt(name); | ||
926 | if (!mnt) | ||
927 | goto out; | ||
928 | |||
929 | if (flags & MS_KERNMOUNT) | ||
930 | mnt->mnt_flags = MNT_INTERNAL; | ||
931 | 920 | ||
932 | if (data && !(type->fs_flags & FS_BINARY_MOUNTDATA)) { | 921 | if (data && !(type->fs_flags & FS_BINARY_MOUNTDATA)) { |
933 | secdata = alloc_secdata(); | 922 | secdata = alloc_secdata(); |
934 | if (!secdata) | 923 | if (!secdata) |
935 | goto out_mnt; | 924 | goto out; |
936 | 925 | ||
937 | error = security_sb_copy_data(data, secdata); | 926 | error = security_sb_copy_data(data, secdata); |
938 | if (error) | 927 | if (error) |
@@ -944,13 +933,12 @@ vfs_kern_mount(struct file_system_type *type, int flags, const char *name, void | |||
944 | error = PTR_ERR(root); | 933 | error = PTR_ERR(root); |
945 | goto out_free_secdata; | 934 | goto out_free_secdata; |
946 | } | 935 | } |
947 | mnt->mnt_root = root; | 936 | sb = root->d_sb; |
948 | mnt->mnt_sb = root->d_sb; | 937 | BUG_ON(!sb); |
949 | BUG_ON(!mnt->mnt_sb); | 938 | WARN_ON(!sb->s_bdi); |
950 | WARN_ON(!mnt->mnt_sb->s_bdi); | 939 | sb->s_flags |= MS_BORN; |
951 | mnt->mnt_sb->s_flags |= MS_BORN; | ||
952 | 940 | ||
953 | error = security_sb_kern_mount(mnt->mnt_sb, flags, secdata); | 941 | error = security_sb_kern_mount(sb, flags, secdata); |
954 | if (error) | 942 | if (error) |
955 | goto out_sb; | 943 | goto out_sb; |
956 | 944 | ||
@@ -961,27 +949,21 @@ vfs_kern_mount(struct file_system_type *type, int flags, const char *name, void | |||
961 | * violate this rule. This warning should be either removed or | 949 | * violate this rule. This warning should be either removed or |
962 | * converted to a BUG() in 2.6.34. | 950 | * converted to a BUG() in 2.6.34. |
963 | */ | 951 | */ |
964 | WARN((mnt->mnt_sb->s_maxbytes < 0), "%s set sb->s_maxbytes to " | 952 | WARN((sb->s_maxbytes < 0), "%s set sb->s_maxbytes to " |
965 | "negative value (%lld)\n", type->name, mnt->mnt_sb->s_maxbytes); | 953 | "negative value (%lld)\n", type->name, sb->s_maxbytes); |
966 | 954 | ||
967 | mnt->mnt_mountpoint = mnt->mnt_root; | 955 | up_write(&sb->s_umount); |
968 | mnt->mnt_parent = mnt; | ||
969 | up_write(&mnt->mnt_sb->s_umount); | ||
970 | free_secdata(secdata); | 956 | free_secdata(secdata); |
971 | return mnt; | 957 | return root; |
972 | out_sb: | 958 | out_sb: |
973 | dput(mnt->mnt_root); | 959 | dput(root); |
974 | deactivate_locked_super(mnt->mnt_sb); | 960 | deactivate_locked_super(sb); |
975 | out_free_secdata: | 961 | out_free_secdata: |
976 | free_secdata(secdata); | 962 | free_secdata(secdata); |
977 | out_mnt: | ||
978 | free_vfsmnt(mnt); | ||
979 | out: | 963 | out: |
980 | return ERR_PTR(error); | 964 | return ERR_PTR(error); |
981 | } | 965 | } |
982 | 966 | ||
983 | EXPORT_SYMBOL_GPL(vfs_kern_mount); | ||
984 | |||
985 | /** | 967 | /** |
986 | * freeze_super - lock the filesystem and force it into a consistent state | 968 | * freeze_super - lock the filesystem and force it into a consistent state |
987 | * @sb: the super to lock | 969 | * @sb: the super to lock |
@@ -1071,49 +1053,3 @@ out: | |||
1071 | return 0; | 1053 | return 0; |
1072 | } | 1054 | } |
1073 | EXPORT_SYMBOL(thaw_super); | 1055 | EXPORT_SYMBOL(thaw_super); |
1074 | |||
1075 | static struct vfsmount *fs_set_subtype(struct vfsmount *mnt, const char *fstype) | ||
1076 | { | ||
1077 | int err; | ||
1078 | const char *subtype = strchr(fstype, '.'); | ||
1079 | if (subtype) { | ||
1080 | subtype++; | ||
1081 | err = -EINVAL; | ||
1082 | if (!subtype[0]) | ||
1083 | goto err; | ||
1084 | } else | ||
1085 | subtype = ""; | ||
1086 | |||
1087 | mnt->mnt_sb->s_subtype = kstrdup(subtype, GFP_KERNEL); | ||
1088 | err = -ENOMEM; | ||
1089 | if (!mnt->mnt_sb->s_subtype) | ||
1090 | goto err; | ||
1091 | return mnt; | ||
1092 | |||
1093 | err: | ||
1094 | mntput(mnt); | ||
1095 | return ERR_PTR(err); | ||
1096 | } | ||
1097 | |||
1098 | struct vfsmount * | ||
1099 | do_kern_mount(const char *fstype, int flags, const char *name, void *data) | ||
1100 | { | ||
1101 | struct file_system_type *type = get_fs_type(fstype); | ||
1102 | struct vfsmount *mnt; | ||
1103 | if (!type) | ||
1104 | return ERR_PTR(-ENODEV); | ||
1105 | mnt = vfs_kern_mount(type, flags, name, data); | ||
1106 | if (!IS_ERR(mnt) && (type->fs_flags & FS_HAS_SUBTYPE) && | ||
1107 | !mnt->mnt_sb->s_subtype) | ||
1108 | mnt = fs_set_subtype(mnt, fstype); | ||
1109 | put_filesystem(type); | ||
1110 | return mnt; | ||
1111 | } | ||
1112 | EXPORT_SYMBOL_GPL(do_kern_mount); | ||
1113 | |||
1114 | struct vfsmount *kern_mount_data(struct file_system_type *type, void *data) | ||
1115 | { | ||
1116 | return vfs_kern_mount(type, MS_KERNMOUNT, type->name, data); | ||
1117 | } | ||
1118 | |||
1119 | EXPORT_SYMBOL_GPL(kern_mount_data); | ||
@@ -7,6 +7,7 @@ | |||
7 | #include <linux/fs.h> | 7 | #include <linux/fs.h> |
8 | #include <linux/slab.h> | 8 | #include <linux/slab.h> |
9 | #include <linux/module.h> | 9 | #include <linux/module.h> |
10 | #include <linux/namei.h> | ||
10 | #include <linux/sched.h> | 11 | #include <linux/sched.h> |
11 | #include <linux/writeback.h> | 12 | #include <linux/writeback.h> |
12 | #include <linux/syscalls.h> | 13 | #include <linux/syscalls.h> |
@@ -128,6 +129,29 @@ void emergency_sync(void) | |||
128 | } | 129 | } |
129 | } | 130 | } |
130 | 131 | ||
132 | /* | ||
133 | * sync a single super | ||
134 | */ | ||
135 | SYSCALL_DEFINE1(syncfs, int, fd) | ||
136 | { | ||
137 | struct file *file; | ||
138 | struct super_block *sb; | ||
139 | int ret; | ||
140 | int fput_needed; | ||
141 | |||
142 | file = fget_light(fd, &fput_needed); | ||
143 | if (!file) | ||
144 | return -EBADF; | ||
145 | sb = file->f_dentry->d_sb; | ||
146 | |||
147 | down_read(&sb->s_umount); | ||
148 | ret = sync_filesystem(sb); | ||
149 | up_read(&sb->s_umount); | ||
150 | |||
151 | fput_light(file, fput_needed); | ||
152 | return ret; | ||
153 | } | ||
154 | |||
131 | /** | 155 | /** |
132 | * vfs_fsync_range - helper to sync a range of data & metadata to disk | 156 | * vfs_fsync_range - helper to sync a range of data & metadata to disk |
133 | * @file: file to sync | 157 | * @file: file to sync |
diff --git a/fs/ubifs/Kconfig b/fs/ubifs/Kconfig index 830e3f76f442..d7440904be17 100644 --- a/fs/ubifs/Kconfig +++ b/fs/ubifs/Kconfig | |||
@@ -44,29 +44,17 @@ config UBIFS_FS_ZLIB | |||
44 | 44 | ||
45 | # Debugging-related stuff | 45 | # Debugging-related stuff |
46 | config UBIFS_FS_DEBUG | 46 | config UBIFS_FS_DEBUG |
47 | bool "Enable debugging" | 47 | bool "Enable debugging support" |
48 | depends on UBIFS_FS | 48 | depends on UBIFS_FS |
49 | select DEBUG_FS | 49 | select DEBUG_FS |
50 | select KALLSYMS_ALL | 50 | select KALLSYMS_ALL |
51 | help | 51 | help |
52 | This option enables UBIFS debugging. | 52 | This option enables UBIFS debugging support. It makes sure various |
53 | 53 | assertions, self-checks, debugging messages and test modes are compiled | |
54 | config UBIFS_FS_DEBUG_MSG_LVL | 54 | in (this all is compiled out otherwise). Assertions are light-weight |
55 | int "Default message level (0 = no extra messages, 3 = lots)" | 55 | and this option also enables them. Self-checks, debugging messages and |
56 | depends on UBIFS_FS_DEBUG | 56 | test modes are switched off by default. Thus, it is safe and actually |
57 | default "0" | 57 | recommended to have debugging support enabled, and it should not slow |
58 | help | 58 | down UBIFS. You can then further enable / disable individual debugging |
59 | This controls the amount of debugging messages produced by UBIFS. | 59 | features using UBIFS module parameters and the corresponding sysfs |
60 | If reporting bugs, please try to have available a full dump of the | 60 | interfaces. |
61 | messages at level 1 while the misbehaviour was occurring. Level 2 | ||
62 | may become necessary if level 1 messages were not enough to find the | ||
63 | bug. Generally Level 3 should be avoided. | ||
64 | |||
65 | config UBIFS_FS_DEBUG_CHKS | ||
66 | bool "Enable extra checks" | ||
67 | depends on UBIFS_FS_DEBUG | ||
68 | help | ||
69 | If extra checks are enabled UBIFS will check the consistency of its | ||
70 | internal data structures during operation. However, UBIFS performance | ||
71 | is dramatically slower when this option is selected especially if the | ||
72 | file system is large. | ||
diff --git a/fs/ubifs/commit.c b/fs/ubifs/commit.c index 02429d81ca33..b148fbc80f8d 100644 --- a/fs/ubifs/commit.c +++ b/fs/ubifs/commit.c | |||
@@ -48,6 +48,56 @@ | |||
48 | #include <linux/slab.h> | 48 | #include <linux/slab.h> |
49 | #include "ubifs.h" | 49 | #include "ubifs.h" |
50 | 50 | ||
51 | /* | ||
52 | * nothing_to_commit - check if there is nothing to commit. | ||
53 | * @c: UBIFS file-system description object | ||
54 | * | ||
55 | * This is a helper function which checks if there is anything to commit. It is | ||
56 | * used as an optimization to avoid starting the commit if it is not really | ||
57 | * necessary. Indeed, the commit operation always assumes flash I/O (e.g., | ||
58 | * writing the commit start node to the log), and it is better to avoid doing | ||
59 | * this unnecessarily. E.g., 'ubifs_sync_fs()' runs the commit, but if there is | ||
60 | * nothing to commit, it is more optimal to avoid any flash I/O. | ||
61 | * | ||
62 | * This function has to be called with @c->commit_sem locked for writing - | ||
63 | * this function does not take LPT/TNC locks because the @c->commit_sem | ||
64 | * guarantees that we have exclusive access to the TNC and LPT data structures. | ||
65 | * | ||
66 | * This function returns %1 if there is nothing to commit and %0 otherwise. | ||
67 | */ | ||
68 | static int nothing_to_commit(struct ubifs_info *c) | ||
69 | { | ||
70 | /* | ||
71 | * During mounting or remounting from R/O mode to R/W mode we may | ||
72 | * commit for various recovery-related reasons. | ||
73 | */ | ||
74 | if (c->mounting || c->remounting_rw) | ||
75 | return 0; | ||
76 | |||
77 | /* | ||
78 | * If the root TNC node is dirty, we definitely have something to | ||
79 | * commit. | ||
80 | */ | ||
81 | if (c->zroot.znode && test_bit(DIRTY_ZNODE, &c->zroot.znode->flags)) | ||
82 | return 0; | ||
83 | |||
84 | /* | ||
85 | * Even though the TNC is clean, the LPT tree may have dirty nodes. For | ||
86 | * example, this may happen if the budgeting subsystem invoked GC to | ||
87 | * make some free space, and the GC found an LEB with only dirty and | ||
88 | * free space. In this case GC would just change the lprops of this | ||
89 | * LEB (by turning all space into free space) and unmap it. | ||
90 | */ | ||
91 | if (c->nroot && test_bit(DIRTY_CNODE, &c->nroot->flags)) | ||
92 | return 0; | ||
93 | |||
94 | ubifs_assert(atomic_long_read(&c->dirty_zn_cnt) == 0); | ||
95 | ubifs_assert(c->dirty_pn_cnt == 0); | ||
96 | ubifs_assert(c->dirty_nn_cnt == 0); | ||
97 | |||
98 | return 1; | ||
99 | } | ||
100 | |||
51 | /** | 101 | /** |
52 | * do_commit - commit the journal. | 102 | * do_commit - commit the journal. |
53 | * @c: UBIFS file-system description object | 103 | * @c: UBIFS file-system description object |
@@ -70,6 +120,12 @@ static int do_commit(struct ubifs_info *c) | |||
70 | goto out_up; | 120 | goto out_up; |
71 | } | 121 | } |
72 | 122 | ||
123 | if (nothing_to_commit(c)) { | ||
124 | up_write(&c->commit_sem); | ||
125 | err = 0; | ||
126 | goto out_cancel; | ||
127 | } | ||
128 | |||
73 | /* Sync all write buffers (necessary for recovery) */ | 129 | /* Sync all write buffers (necessary for recovery) */ |
74 | for (i = 0; i < c->jhead_cnt; i++) { | 130 | for (i = 0; i < c->jhead_cnt; i++) { |
75 | err = ubifs_wbuf_sync(&c->jheads[i].wbuf); | 131 | err = ubifs_wbuf_sync(&c->jheads[i].wbuf); |
@@ -162,12 +218,12 @@ static int do_commit(struct ubifs_info *c) | |||
162 | if (err) | 218 | if (err) |
163 | goto out; | 219 | goto out; |
164 | 220 | ||
221 | out_cancel: | ||
165 | spin_lock(&c->cs_lock); | 222 | spin_lock(&c->cs_lock); |
166 | c->cmt_state = COMMIT_RESTING; | 223 | c->cmt_state = COMMIT_RESTING; |
167 | wake_up(&c->cmt_wq); | 224 | wake_up(&c->cmt_wq); |
168 | dbg_cmt("commit end"); | 225 | dbg_cmt("commit end"); |
169 | spin_unlock(&c->cs_lock); | 226 | spin_unlock(&c->cs_lock); |
170 | |||
171 | return 0; | 227 | return 0; |
172 | 228 | ||
173 | out_up: | 229 | out_up: |
diff --git a/fs/ubifs/debug.c b/fs/ubifs/debug.c index 0bee4dbffc31..f25a7339f800 100644 --- a/fs/ubifs/debug.c +++ b/fs/ubifs/debug.c | |||
@@ -43,8 +43,8 @@ DEFINE_SPINLOCK(dbg_lock); | |||
43 | static char dbg_key_buf0[128]; | 43 | static char dbg_key_buf0[128]; |
44 | static char dbg_key_buf1[128]; | 44 | static char dbg_key_buf1[128]; |
45 | 45 | ||
46 | unsigned int ubifs_msg_flags = UBIFS_MSG_FLAGS_DEFAULT; | 46 | unsigned int ubifs_msg_flags; |
47 | unsigned int ubifs_chk_flags = UBIFS_CHK_FLAGS_DEFAULT; | 47 | unsigned int ubifs_chk_flags; |
48 | unsigned int ubifs_tst_flags; | 48 | unsigned int ubifs_tst_flags; |
49 | 49 | ||
50 | module_param_named(debug_msgs, ubifs_msg_flags, uint, S_IRUGO | S_IWUSR); | 50 | module_param_named(debug_msgs, ubifs_msg_flags, uint, S_IRUGO | S_IWUSR); |
@@ -810,16 +810,24 @@ void dbg_dump_leb(const struct ubifs_info *c, int lnum) | |||
810 | { | 810 | { |
811 | struct ubifs_scan_leb *sleb; | 811 | struct ubifs_scan_leb *sleb; |
812 | struct ubifs_scan_node *snod; | 812 | struct ubifs_scan_node *snod; |
813 | void *buf; | ||
813 | 814 | ||
814 | if (dbg_failure_mode) | 815 | if (dbg_failure_mode) |
815 | return; | 816 | return; |
816 | 817 | ||
817 | printk(KERN_DEBUG "(pid %d) start dumping LEB %d\n", | 818 | printk(KERN_DEBUG "(pid %d) start dumping LEB %d\n", |
818 | current->pid, lnum); | 819 | current->pid, lnum); |
819 | sleb = ubifs_scan(c, lnum, 0, c->dbg->buf, 0); | 820 | |
821 | buf = __vmalloc(c->leb_size, GFP_NOFS, PAGE_KERNEL); | ||
822 | if (!buf) { | ||
823 | ubifs_err("cannot allocate memory for dumping LEB %d", lnum); | ||
824 | return; | ||
825 | } | ||
826 | |||
827 | sleb = ubifs_scan(c, lnum, 0, buf, 0); | ||
820 | if (IS_ERR(sleb)) { | 828 | if (IS_ERR(sleb)) { |
821 | ubifs_err("scan error %d", (int)PTR_ERR(sleb)); | 829 | ubifs_err("scan error %d", (int)PTR_ERR(sleb)); |
822 | return; | 830 | goto out; |
823 | } | 831 | } |
824 | 832 | ||
825 | printk(KERN_DEBUG "LEB %d has %d nodes ending at %d\n", lnum, | 833 | printk(KERN_DEBUG "LEB %d has %d nodes ending at %d\n", lnum, |
@@ -835,6 +843,9 @@ void dbg_dump_leb(const struct ubifs_info *c, int lnum) | |||
835 | printk(KERN_DEBUG "(pid %d) finish dumping LEB %d\n", | 843 | printk(KERN_DEBUG "(pid %d) finish dumping LEB %d\n", |
836 | current->pid, lnum); | 844 | current->pid, lnum); |
837 | ubifs_scan_destroy(sleb); | 845 | ubifs_scan_destroy(sleb); |
846 | |||
847 | out: | ||
848 | vfree(buf); | ||
838 | return; | 849 | return; |
839 | } | 850 | } |
840 | 851 | ||
@@ -2690,16 +2701,8 @@ int ubifs_debugging_init(struct ubifs_info *c) | |||
2690 | if (!c->dbg) | 2701 | if (!c->dbg) |
2691 | return -ENOMEM; | 2702 | return -ENOMEM; |
2692 | 2703 | ||
2693 | c->dbg->buf = vmalloc(c->leb_size); | ||
2694 | if (!c->dbg->buf) | ||
2695 | goto out; | ||
2696 | |||
2697 | failure_mode_init(c); | 2704 | failure_mode_init(c); |
2698 | return 0; | 2705 | return 0; |
2699 | |||
2700 | out: | ||
2701 | kfree(c->dbg); | ||
2702 | return -ENOMEM; | ||
2703 | } | 2706 | } |
2704 | 2707 | ||
2705 | /** | 2708 | /** |
@@ -2709,7 +2712,6 @@ out: | |||
2709 | void ubifs_debugging_exit(struct ubifs_info *c) | 2712 | void ubifs_debugging_exit(struct ubifs_info *c) |
2710 | { | 2713 | { |
2711 | failure_mode_exit(c); | 2714 | failure_mode_exit(c); |
2712 | vfree(c->dbg->buf); | ||
2713 | kfree(c->dbg); | 2715 | kfree(c->dbg); |
2714 | } | 2716 | } |
2715 | 2717 | ||
@@ -2813,19 +2815,19 @@ int dbg_debugfs_init_fs(struct ubifs_info *c) | |||
2813 | } | 2815 | } |
2814 | 2816 | ||
2815 | fname = "dump_lprops"; | 2817 | fname = "dump_lprops"; |
2816 | dent = debugfs_create_file(fname, S_IWUGO, d->dfs_dir, c, &dfs_fops); | 2818 | dent = debugfs_create_file(fname, S_IWUSR, d->dfs_dir, c, &dfs_fops); |
2817 | if (IS_ERR(dent)) | 2819 | if (IS_ERR(dent)) |
2818 | goto out_remove; | 2820 | goto out_remove; |
2819 | d->dfs_dump_lprops = dent; | 2821 | d->dfs_dump_lprops = dent; |
2820 | 2822 | ||
2821 | fname = "dump_budg"; | 2823 | fname = "dump_budg"; |
2822 | dent = debugfs_create_file(fname, S_IWUGO, d->dfs_dir, c, &dfs_fops); | 2824 | dent = debugfs_create_file(fname, S_IWUSR, d->dfs_dir, c, &dfs_fops); |
2823 | if (IS_ERR(dent)) | 2825 | if (IS_ERR(dent)) |
2824 | goto out_remove; | 2826 | goto out_remove; |
2825 | d->dfs_dump_budg = dent; | 2827 | d->dfs_dump_budg = dent; |
2826 | 2828 | ||
2827 | fname = "dump_tnc"; | 2829 | fname = "dump_tnc"; |
2828 | dent = debugfs_create_file(fname, S_IWUGO, d->dfs_dir, c, &dfs_fops); | 2830 | dent = debugfs_create_file(fname, S_IWUSR, d->dfs_dir, c, &dfs_fops); |
2829 | if (IS_ERR(dent)) | 2831 | if (IS_ERR(dent)) |
2830 | goto out_remove; | 2832 | goto out_remove; |
2831 | d->dfs_dump_tnc = dent; | 2833 | d->dfs_dump_tnc = dent; |
diff --git a/fs/ubifs/debug.h b/fs/ubifs/debug.h index 69ebe4729151..919f0de29d8f 100644 --- a/fs/ubifs/debug.h +++ b/fs/ubifs/debug.h | |||
@@ -27,7 +27,6 @@ | |||
27 | 27 | ||
28 | /** | 28 | /** |
29 | * ubifs_debug_info - per-FS debugging information. | 29 | * ubifs_debug_info - per-FS debugging information. |
30 | * @buf: a buffer of LEB size, used for various purposes | ||
31 | * @old_zroot: old index root - used by 'dbg_check_old_index()' | 30 | * @old_zroot: old index root - used by 'dbg_check_old_index()' |
32 | * @old_zroot_level: old index root level - used by 'dbg_check_old_index()' | 31 | * @old_zroot_level: old index root level - used by 'dbg_check_old_index()' |
33 | * @old_zroot_sqnum: old index root sqnum - used by 'dbg_check_old_index()' | 32 | * @old_zroot_sqnum: old index root sqnum - used by 'dbg_check_old_index()' |
@@ -54,7 +53,6 @@ | |||
54 | * dfs_dump_tnc: "dump TNC" debugfs knob | 53 | * dfs_dump_tnc: "dump TNC" debugfs knob |
55 | */ | 54 | */ |
56 | struct ubifs_debug_info { | 55 | struct ubifs_debug_info { |
57 | void *buf; | ||
58 | struct ubifs_zbranch old_zroot; | 56 | struct ubifs_zbranch old_zroot; |
59 | int old_zroot_level; | 57 | int old_zroot_level; |
60 | unsigned long long old_zroot_sqnum; | 58 | unsigned long long old_zroot_sqnum; |
@@ -173,7 +171,7 @@ const char *dbg_key_str1(const struct ubifs_info *c, | |||
173 | #define dbg_rcvry(fmt, ...) dbg_do_msg(UBIFS_MSG_RCVRY, fmt, ##__VA_ARGS__) | 171 | #define dbg_rcvry(fmt, ...) dbg_do_msg(UBIFS_MSG_RCVRY, fmt, ##__VA_ARGS__) |
174 | 172 | ||
175 | /* | 173 | /* |
176 | * Debugging message type flags (must match msg_type_names in debug.c). | 174 | * Debugging message type flags. |
177 | * | 175 | * |
178 | * UBIFS_MSG_GEN: general messages | 176 | * UBIFS_MSG_GEN: general messages |
179 | * UBIFS_MSG_JNL: journal messages | 177 | * UBIFS_MSG_JNL: journal messages |
@@ -205,14 +203,8 @@ enum { | |||
205 | UBIFS_MSG_RCVRY = 0x1000, | 203 | UBIFS_MSG_RCVRY = 0x1000, |
206 | }; | 204 | }; |
207 | 205 | ||
208 | /* Debugging message type flags for each default debug message level */ | ||
209 | #define UBIFS_MSG_LVL_0 0 | ||
210 | #define UBIFS_MSG_LVL_1 0x1 | ||
211 | #define UBIFS_MSG_LVL_2 0x7f | ||
212 | #define UBIFS_MSG_LVL_3 0xffff | ||
213 | |||
214 | /* | 206 | /* |
215 | * Debugging check flags (must match chk_names in debug.c). | 207 | * Debugging check flags. |
216 | * | 208 | * |
217 | * UBIFS_CHK_GEN: general checks | 209 | * UBIFS_CHK_GEN: general checks |
218 | * UBIFS_CHK_TNC: check TNC | 210 | * UBIFS_CHK_TNC: check TNC |
@@ -233,7 +225,7 @@ enum { | |||
233 | }; | 225 | }; |
234 | 226 | ||
235 | /* | 227 | /* |
236 | * Special testing flags (must match tst_names in debug.c). | 228 | * Special testing flags. |
237 | * | 229 | * |
238 | * UBIFS_TST_FORCE_IN_THE_GAPS: force the use of in-the-gaps method | 230 | * UBIFS_TST_FORCE_IN_THE_GAPS: force the use of in-the-gaps method |
239 | * UBIFS_TST_RCVRY: failure mode for recovery testing | 231 | * UBIFS_TST_RCVRY: failure mode for recovery testing |
@@ -243,22 +235,6 @@ enum { | |||
243 | UBIFS_TST_RCVRY = 0x4, | 235 | UBIFS_TST_RCVRY = 0x4, |
244 | }; | 236 | }; |
245 | 237 | ||
246 | #if CONFIG_UBIFS_FS_DEBUG_MSG_LVL == 1 | ||
247 | #define UBIFS_MSG_FLAGS_DEFAULT UBIFS_MSG_LVL_1 | ||
248 | #elif CONFIG_UBIFS_FS_DEBUG_MSG_LVL == 2 | ||
249 | #define UBIFS_MSG_FLAGS_DEFAULT UBIFS_MSG_LVL_2 | ||
250 | #elif CONFIG_UBIFS_FS_DEBUG_MSG_LVL == 3 | ||
251 | #define UBIFS_MSG_FLAGS_DEFAULT UBIFS_MSG_LVL_3 | ||
252 | #else | ||
253 | #define UBIFS_MSG_FLAGS_DEFAULT UBIFS_MSG_LVL_0 | ||
254 | #endif | ||
255 | |||
256 | #ifdef CONFIG_UBIFS_FS_DEBUG_CHKS | ||
257 | #define UBIFS_CHK_FLAGS_DEFAULT 0xffffffff | ||
258 | #else | ||
259 | #define UBIFS_CHK_FLAGS_DEFAULT 0 | ||
260 | #endif | ||
261 | |||
262 | extern spinlock_t dbg_lock; | 238 | extern spinlock_t dbg_lock; |
263 | 239 | ||
264 | extern unsigned int ubifs_msg_flags; | 240 | extern unsigned int ubifs_msg_flags; |
diff --git a/fs/ubifs/file.c b/fs/ubifs/file.c index d77db7e36484..28be1e6a65e8 100644 --- a/fs/ubifs/file.c +++ b/fs/ubifs/file.c | |||
@@ -448,10 +448,12 @@ static int ubifs_write_begin(struct file *file, struct address_space *mapping, | |||
448 | if (!(pos & ~PAGE_CACHE_MASK) && len == PAGE_CACHE_SIZE) { | 448 | if (!(pos & ~PAGE_CACHE_MASK) && len == PAGE_CACHE_SIZE) { |
449 | /* | 449 | /* |
450 | * We change whole page so no need to load it. But we | 450 | * We change whole page so no need to load it. But we |
451 | * have to set the @PG_checked flag to make the further | 451 | * do not know whether this page exists on the media or |
452 | * code know that the page is new. This might be not | 452 | * not, so we assume the latter because it requires |
453 | * true, but it is better to budget more than to read | 453 | * larger budget. The assumption is that it is better |
454 | * the page from the media. | 454 | * to budget a bit more than to read the page from the |
455 | * media. Thus, we are setting the @PG_checked flag | ||
456 | * here. | ||
455 | */ | 457 | */ |
456 | SetPageChecked(page); | 458 | SetPageChecked(page); |
457 | skipped_read = 1; | 459 | skipped_read = 1; |
@@ -559,6 +561,7 @@ static int ubifs_write_end(struct file *file, struct address_space *mapping, | |||
559 | dbg_gen("copied %d instead of %d, read page and repeat", | 561 | dbg_gen("copied %d instead of %d, read page and repeat", |
560 | copied, len); | 562 | copied, len); |
561 | cancel_budget(c, page, ui, appending); | 563 | cancel_budget(c, page, ui, appending); |
564 | ClearPageChecked(page); | ||
562 | 565 | ||
563 | /* | 566 | /* |
564 | * Return 0 to force VFS to repeat the whole operation, or the | 567 | * Return 0 to force VFS to repeat the whole operation, or the |
diff --git a/fs/ubifs/io.c b/fs/ubifs/io.c index d82173182eeb..dfd168b7807e 100644 --- a/fs/ubifs/io.c +++ b/fs/ubifs/io.c | |||
@@ -31,6 +31,26 @@ | |||
31 | * buffer is full or when it is not used for some time (by timer). This is | 31 | * buffer is full or when it is not used for some time (by timer). This is |
32 | * similar to the mechanism is used by JFFS2. | 32 | * similar to the mechanism is used by JFFS2. |
33 | * | 33 | * |
34 | * UBIFS distinguishes between minimum write size (@c->min_io_size) and maximum | ||
35 | * write size (@c->max_write_size). The latter is the maximum amount of bytes | ||
36 | * the underlying flash is able to program at a time, and writing in | ||
37 | * @c->max_write_size units should presumably be faster. Obviously, | ||
38 | * @c->min_io_size <= @c->max_write_size. Write-buffers are of | ||
39 | * @c->max_write_size bytes in size for maximum performance. However, when a | ||
40 | * write-buffer is flushed, only the portion of it (aligned to @c->min_io_size | ||
41 | * boundary) which contains data is written, not the whole write-buffer, | ||
42 | * because this is more space-efficient. | ||
43 | * | ||
44 | * This optimization adds few complications to the code. Indeed, on the one | ||
45 | * hand, we want to write in optimal @c->max_write_size bytes chunks, which | ||
46 | * also means aligning writes at the @c->max_write_size bytes offsets. On the | ||
47 | * other hand, we do not want to waste space when synchronizing the write | ||
48 | * buffer, so during synchronization we writes in smaller chunks. And this makes | ||
49 | * the next write offset to be not aligned to @c->max_write_size bytes. So the | ||
50 | * have to make sure that the write-buffer offset (@wbuf->offs) becomes aligned | ||
51 | * to @c->max_write_size bytes again. We do this by temporarily shrinking | ||
52 | * write-buffer size (@wbuf->size). | ||
53 | * | ||
34 | * Write-buffers are defined by 'struct ubifs_wbuf' objects and protected by | 54 | * Write-buffers are defined by 'struct ubifs_wbuf' objects and protected by |
35 | * mutexes defined inside these objects. Since sometimes upper-level code | 55 | * mutexes defined inside these objects. Since sometimes upper-level code |
36 | * has to lock the write-buffer (e.g. journal space reservation code), many | 56 | * has to lock the write-buffer (e.g. journal space reservation code), many |
@@ -46,8 +66,8 @@ | |||
46 | * UBIFS uses padding when it pads to the next min. I/O unit. In this case it | 66 | * UBIFS uses padding when it pads to the next min. I/O unit. In this case it |
47 | * uses padding nodes or padding bytes, if the padding node does not fit. | 67 | * uses padding nodes or padding bytes, if the padding node does not fit. |
48 | * | 68 | * |
49 | * All UBIFS nodes are protected by CRC checksums and UBIFS checks all nodes | 69 | * All UBIFS nodes are protected by CRC checksums and UBIFS checks CRC when |
50 | * every time they are read from the flash media. | 70 | * they are read from the flash media. |
51 | */ | 71 | */ |
52 | 72 | ||
53 | #include <linux/crc32.h> | 73 | #include <linux/crc32.h> |
@@ -88,8 +108,12 @@ void ubifs_ro_mode(struct ubifs_info *c, int err) | |||
88 | * This function may skip data nodes CRC checking if @c->no_chk_data_crc is | 108 | * This function may skip data nodes CRC checking if @c->no_chk_data_crc is |
89 | * true, which is controlled by corresponding UBIFS mount option. However, if | 109 | * true, which is controlled by corresponding UBIFS mount option. However, if |
90 | * @must_chk_crc is true, then @c->no_chk_data_crc is ignored and CRC is | 110 | * @must_chk_crc is true, then @c->no_chk_data_crc is ignored and CRC is |
91 | * checked. Similarly, if @c->always_chk_crc is true, @c->no_chk_data_crc is | 111 | * checked. Similarly, if @c->mounting or @c->remounting_rw is true (we are |
92 | * ignored and CRC is checked. | 112 | * mounting or re-mounting to R/W mode), @c->no_chk_data_crc is ignored and CRC |
113 | * is checked. This is because during mounting or re-mounting from R/O mode to | ||
114 | * R/W mode we may read journal nodes (when replying the journal or doing the | ||
115 | * recovery) and the journal nodes may potentially be corrupted, so checking is | ||
116 | * required. | ||
93 | * | 117 | * |
94 | * This function returns zero in case of success and %-EUCLEAN in case of bad | 118 | * This function returns zero in case of success and %-EUCLEAN in case of bad |
95 | * CRC or magic. | 119 | * CRC or magic. |
@@ -131,8 +155,8 @@ int ubifs_check_node(const struct ubifs_info *c, const void *buf, int lnum, | |||
131 | node_len > c->ranges[type].max_len) | 155 | node_len > c->ranges[type].max_len) |
132 | goto out_len; | 156 | goto out_len; |
133 | 157 | ||
134 | if (!must_chk_crc && type == UBIFS_DATA_NODE && !c->always_chk_crc && | 158 | if (!must_chk_crc && type == UBIFS_DATA_NODE && !c->mounting && |
135 | c->no_chk_data_crc) | 159 | !c->remounting_rw && c->no_chk_data_crc) |
136 | return 0; | 160 | return 0; |
137 | 161 | ||
138 | crc = crc32(UBIFS_CRC32_INIT, buf + 8, node_len - 8); | 162 | crc = crc32(UBIFS_CRC32_INIT, buf + 8, node_len - 8); |
@@ -343,11 +367,17 @@ static void cancel_wbuf_timer_nolock(struct ubifs_wbuf *wbuf) | |||
343 | * | 367 | * |
344 | * This function synchronizes write-buffer @buf and returns zero in case of | 368 | * This function synchronizes write-buffer @buf and returns zero in case of |
345 | * success or a negative error code in case of failure. | 369 | * success or a negative error code in case of failure. |
370 | * | ||
371 | * Note, although write-buffers are of @c->max_write_size, this function does | ||
372 | * not necessarily writes all @c->max_write_size bytes to the flash. Instead, | ||
373 | * if the write-buffer is only partially filled with data, only the used part | ||
374 | * of the write-buffer (aligned on @c->min_io_size boundary) is synchronized. | ||
375 | * This way we waste less space. | ||
346 | */ | 376 | */ |
347 | int ubifs_wbuf_sync_nolock(struct ubifs_wbuf *wbuf) | 377 | int ubifs_wbuf_sync_nolock(struct ubifs_wbuf *wbuf) |
348 | { | 378 | { |
349 | struct ubifs_info *c = wbuf->c; | 379 | struct ubifs_info *c = wbuf->c; |
350 | int err, dirt; | 380 | int err, dirt, sync_len; |
351 | 381 | ||
352 | cancel_wbuf_timer_nolock(wbuf); | 382 | cancel_wbuf_timer_nolock(wbuf); |
353 | if (!wbuf->used || wbuf->lnum == -1) | 383 | if (!wbuf->used || wbuf->lnum == -1) |
@@ -357,27 +387,53 @@ int ubifs_wbuf_sync_nolock(struct ubifs_wbuf *wbuf) | |||
357 | dbg_io("LEB %d:%d, %d bytes, jhead %s", | 387 | dbg_io("LEB %d:%d, %d bytes, jhead %s", |
358 | wbuf->lnum, wbuf->offs, wbuf->used, dbg_jhead(wbuf->jhead)); | 388 | wbuf->lnum, wbuf->offs, wbuf->used, dbg_jhead(wbuf->jhead)); |
359 | ubifs_assert(!(wbuf->avail & 7)); | 389 | ubifs_assert(!(wbuf->avail & 7)); |
360 | ubifs_assert(wbuf->offs + c->min_io_size <= c->leb_size); | 390 | ubifs_assert(wbuf->offs + wbuf->size <= c->leb_size); |
391 | ubifs_assert(wbuf->size >= c->min_io_size); | ||
392 | ubifs_assert(wbuf->size <= c->max_write_size); | ||
393 | ubifs_assert(wbuf->size % c->min_io_size == 0); | ||
361 | ubifs_assert(!c->ro_media && !c->ro_mount); | 394 | ubifs_assert(!c->ro_media && !c->ro_mount); |
395 | if (c->leb_size - wbuf->offs >= c->max_write_size) | ||
396 | ubifs_assert(!((wbuf->offs + wbuf->size) % c->max_write_size )); | ||
362 | 397 | ||
363 | if (c->ro_error) | 398 | if (c->ro_error) |
364 | return -EROFS; | 399 | return -EROFS; |
365 | 400 | ||
366 | ubifs_pad(c, wbuf->buf + wbuf->used, wbuf->avail); | 401 | /* |
402 | * Do not write whole write buffer but write only the minimum necessary | ||
403 | * amount of min. I/O units. | ||
404 | */ | ||
405 | sync_len = ALIGN(wbuf->used, c->min_io_size); | ||
406 | dirt = sync_len - wbuf->used; | ||
407 | if (dirt) | ||
408 | ubifs_pad(c, wbuf->buf + wbuf->used, dirt); | ||
367 | err = ubi_leb_write(c->ubi, wbuf->lnum, wbuf->buf, wbuf->offs, | 409 | err = ubi_leb_write(c->ubi, wbuf->lnum, wbuf->buf, wbuf->offs, |
368 | c->min_io_size, wbuf->dtype); | 410 | sync_len, wbuf->dtype); |
369 | if (err) { | 411 | if (err) { |
370 | ubifs_err("cannot write %d bytes to LEB %d:%d", | 412 | ubifs_err("cannot write %d bytes to LEB %d:%d", |
371 | c->min_io_size, wbuf->lnum, wbuf->offs); | 413 | sync_len, wbuf->lnum, wbuf->offs); |
372 | dbg_dump_stack(); | 414 | dbg_dump_stack(); |
373 | return err; | 415 | return err; |
374 | } | 416 | } |
375 | 417 | ||
376 | dirt = wbuf->avail; | ||
377 | |||
378 | spin_lock(&wbuf->lock); | 418 | spin_lock(&wbuf->lock); |
379 | wbuf->offs += c->min_io_size; | 419 | wbuf->offs += sync_len; |
380 | wbuf->avail = c->min_io_size; | 420 | /* |
421 | * Now @wbuf->offs is not necessarily aligned to @c->max_write_size. | ||
422 | * But our goal is to optimize writes and make sure we write in | ||
423 | * @c->max_write_size chunks and to @c->max_write_size-aligned offset. | ||
424 | * Thus, if @wbuf->offs is not aligned to @c->max_write_size now, make | ||
425 | * sure that @wbuf->offs + @wbuf->size is aligned to | ||
426 | * @c->max_write_size. This way we make sure that after next | ||
427 | * write-buffer flush we are again at the optimal offset (aligned to | ||
428 | * @c->max_write_size). | ||
429 | */ | ||
430 | if (c->leb_size - wbuf->offs < c->max_write_size) | ||
431 | wbuf->size = c->leb_size - wbuf->offs; | ||
432 | else if (wbuf->offs & (c->max_write_size - 1)) | ||
433 | wbuf->size = ALIGN(wbuf->offs, c->max_write_size) - wbuf->offs; | ||
434 | else | ||
435 | wbuf->size = c->max_write_size; | ||
436 | wbuf->avail = wbuf->size; | ||
381 | wbuf->used = 0; | 437 | wbuf->used = 0; |
382 | wbuf->next_ino = 0; | 438 | wbuf->next_ino = 0; |
383 | spin_unlock(&wbuf->lock); | 439 | spin_unlock(&wbuf->lock); |
@@ -420,7 +476,13 @@ int ubifs_wbuf_seek_nolock(struct ubifs_wbuf *wbuf, int lnum, int offs, | |||
420 | spin_lock(&wbuf->lock); | 476 | spin_lock(&wbuf->lock); |
421 | wbuf->lnum = lnum; | 477 | wbuf->lnum = lnum; |
422 | wbuf->offs = offs; | 478 | wbuf->offs = offs; |
423 | wbuf->avail = c->min_io_size; | 479 | if (c->leb_size - wbuf->offs < c->max_write_size) |
480 | wbuf->size = c->leb_size - wbuf->offs; | ||
481 | else if (wbuf->offs & (c->max_write_size - 1)) | ||
482 | wbuf->size = ALIGN(wbuf->offs, c->max_write_size) - wbuf->offs; | ||
483 | else | ||
484 | wbuf->size = c->max_write_size; | ||
485 | wbuf->avail = wbuf->size; | ||
424 | wbuf->used = 0; | 486 | wbuf->used = 0; |
425 | spin_unlock(&wbuf->lock); | 487 | spin_unlock(&wbuf->lock); |
426 | wbuf->dtype = dtype; | 488 | wbuf->dtype = dtype; |
@@ -500,8 +562,9 @@ out_timers: | |||
500 | * | 562 | * |
501 | * This function writes data to flash via write-buffer @wbuf. This means that | 563 | * This function writes data to flash via write-buffer @wbuf. This means that |
502 | * the last piece of the node won't reach the flash media immediately if it | 564 | * the last piece of the node won't reach the flash media immediately if it |
503 | * does not take whole minimal I/O unit. Instead, the node will sit in RAM | 565 | * does not take whole max. write unit (@c->max_write_size). Instead, the node |
504 | * until the write-buffer is synchronized (e.g., by timer). | 566 | * will sit in RAM until the write-buffer is synchronized (e.g., by timer, or |
567 | * because more data are appended to the write-buffer). | ||
505 | * | 568 | * |
506 | * This function returns zero in case of success and a negative error code in | 569 | * This function returns zero in case of success and a negative error code in |
507 | * case of failure. If the node cannot be written because there is no more | 570 | * case of failure. If the node cannot be written because there is no more |
@@ -518,9 +581,14 @@ int ubifs_wbuf_write_nolock(struct ubifs_wbuf *wbuf, void *buf, int len) | |||
518 | ubifs_assert(len > 0 && wbuf->lnum >= 0 && wbuf->lnum < c->leb_cnt); | 581 | ubifs_assert(len > 0 && wbuf->lnum >= 0 && wbuf->lnum < c->leb_cnt); |
519 | ubifs_assert(wbuf->offs >= 0 && wbuf->offs % c->min_io_size == 0); | 582 | ubifs_assert(wbuf->offs >= 0 && wbuf->offs % c->min_io_size == 0); |
520 | ubifs_assert(!(wbuf->offs & 7) && wbuf->offs <= c->leb_size); | 583 | ubifs_assert(!(wbuf->offs & 7) && wbuf->offs <= c->leb_size); |
521 | ubifs_assert(wbuf->avail > 0 && wbuf->avail <= c->min_io_size); | 584 | ubifs_assert(wbuf->avail > 0 && wbuf->avail <= wbuf->size); |
585 | ubifs_assert(wbuf->size >= c->min_io_size); | ||
586 | ubifs_assert(wbuf->size <= c->max_write_size); | ||
587 | ubifs_assert(wbuf->size % c->min_io_size == 0); | ||
522 | ubifs_assert(mutex_is_locked(&wbuf->io_mutex)); | 588 | ubifs_assert(mutex_is_locked(&wbuf->io_mutex)); |
523 | ubifs_assert(!c->ro_media && !c->ro_mount); | 589 | ubifs_assert(!c->ro_media && !c->ro_mount); |
590 | if (c->leb_size - wbuf->offs >= c->max_write_size) | ||
591 | ubifs_assert(!((wbuf->offs + wbuf->size) % c->max_write_size )); | ||
524 | 592 | ||
525 | if (c->leb_size - wbuf->offs - wbuf->used < aligned_len) { | 593 | if (c->leb_size - wbuf->offs - wbuf->used < aligned_len) { |
526 | err = -ENOSPC; | 594 | err = -ENOSPC; |
@@ -543,14 +611,18 @@ int ubifs_wbuf_write_nolock(struct ubifs_wbuf *wbuf, void *buf, int len) | |||
543 | dbg_io("flush jhead %s wbuf to LEB %d:%d", | 611 | dbg_io("flush jhead %s wbuf to LEB %d:%d", |
544 | dbg_jhead(wbuf->jhead), wbuf->lnum, wbuf->offs); | 612 | dbg_jhead(wbuf->jhead), wbuf->lnum, wbuf->offs); |
545 | err = ubi_leb_write(c->ubi, wbuf->lnum, wbuf->buf, | 613 | err = ubi_leb_write(c->ubi, wbuf->lnum, wbuf->buf, |
546 | wbuf->offs, c->min_io_size, | 614 | wbuf->offs, wbuf->size, |
547 | wbuf->dtype); | 615 | wbuf->dtype); |
548 | if (err) | 616 | if (err) |
549 | goto out; | 617 | goto out; |
550 | 618 | ||
551 | spin_lock(&wbuf->lock); | 619 | spin_lock(&wbuf->lock); |
552 | wbuf->offs += c->min_io_size; | 620 | wbuf->offs += wbuf->size; |
553 | wbuf->avail = c->min_io_size; | 621 | if (c->leb_size - wbuf->offs >= c->max_write_size) |
622 | wbuf->size = c->max_write_size; | ||
623 | else | ||
624 | wbuf->size = c->leb_size - wbuf->offs; | ||
625 | wbuf->avail = wbuf->size; | ||
554 | wbuf->used = 0; | 626 | wbuf->used = 0; |
555 | wbuf->next_ino = 0; | 627 | wbuf->next_ino = 0; |
556 | spin_unlock(&wbuf->lock); | 628 | spin_unlock(&wbuf->lock); |
@@ -564,33 +636,57 @@ int ubifs_wbuf_write_nolock(struct ubifs_wbuf *wbuf, void *buf, int len) | |||
564 | goto exit; | 636 | goto exit; |
565 | } | 637 | } |
566 | 638 | ||
567 | /* | 639 | offs = wbuf->offs; |
568 | * The node is large enough and does not fit entirely within current | 640 | written = 0; |
569 | * minimal I/O unit. We have to fill and flush write-buffer and switch | ||
570 | * to the next min. I/O unit. | ||
571 | */ | ||
572 | dbg_io("flush jhead %s wbuf to LEB %d:%d", | ||
573 | dbg_jhead(wbuf->jhead), wbuf->lnum, wbuf->offs); | ||
574 | memcpy(wbuf->buf + wbuf->used, buf, wbuf->avail); | ||
575 | err = ubi_leb_write(c->ubi, wbuf->lnum, wbuf->buf, wbuf->offs, | ||
576 | c->min_io_size, wbuf->dtype); | ||
577 | if (err) | ||
578 | goto out; | ||
579 | 641 | ||
580 | offs = wbuf->offs + c->min_io_size; | 642 | if (wbuf->used) { |
581 | len -= wbuf->avail; | 643 | /* |
582 | aligned_len -= wbuf->avail; | 644 | * The node is large enough and does not fit entirely within |
583 | written = wbuf->avail; | 645 | * current available space. We have to fill and flush |
646 | * write-buffer and switch to the next max. write unit. | ||
647 | */ | ||
648 | dbg_io("flush jhead %s wbuf to LEB %d:%d", | ||
649 | dbg_jhead(wbuf->jhead), wbuf->lnum, wbuf->offs); | ||
650 | memcpy(wbuf->buf + wbuf->used, buf, wbuf->avail); | ||
651 | err = ubi_leb_write(c->ubi, wbuf->lnum, wbuf->buf, wbuf->offs, | ||
652 | wbuf->size, wbuf->dtype); | ||
653 | if (err) | ||
654 | goto out; | ||
655 | |||
656 | offs += wbuf->size; | ||
657 | len -= wbuf->avail; | ||
658 | aligned_len -= wbuf->avail; | ||
659 | written += wbuf->avail; | ||
660 | } else if (wbuf->offs & (c->max_write_size - 1)) { | ||
661 | /* | ||
662 | * The write-buffer offset is not aligned to | ||
663 | * @c->max_write_size and @wbuf->size is less than | ||
664 | * @c->max_write_size. Write @wbuf->size bytes to make sure the | ||
665 | * following writes are done in optimal @c->max_write_size | ||
666 | * chunks. | ||
667 | */ | ||
668 | dbg_io("write %d bytes to LEB %d:%d", | ||
669 | wbuf->size, wbuf->lnum, wbuf->offs); | ||
670 | err = ubi_leb_write(c->ubi, wbuf->lnum, buf, wbuf->offs, | ||
671 | wbuf->size, wbuf->dtype); | ||
672 | if (err) | ||
673 | goto out; | ||
674 | |||
675 | offs += wbuf->size; | ||
676 | len -= wbuf->size; | ||
677 | aligned_len -= wbuf->size; | ||
678 | written += wbuf->size; | ||
679 | } | ||
584 | 680 | ||
585 | /* | 681 | /* |
586 | * The remaining data may take more whole min. I/O units, so write the | 682 | * The remaining data may take more whole max. write units, so write the |
587 | * remains multiple to min. I/O unit size directly to the flash media. | 683 | * remains multiple to max. write unit size directly to the flash media. |
588 | * We align node length to 8-byte boundary because we anyway flash wbuf | 684 | * We align node length to 8-byte boundary because we anyway flash wbuf |
589 | * if the remaining space is less than 8 bytes. | 685 | * if the remaining space is less than 8 bytes. |
590 | */ | 686 | */ |
591 | n = aligned_len >> c->min_io_shift; | 687 | n = aligned_len >> c->max_write_shift; |
592 | if (n) { | 688 | if (n) { |
593 | n <<= c->min_io_shift; | 689 | n <<= c->max_write_shift; |
594 | dbg_io("write %d bytes to LEB %d:%d", n, wbuf->lnum, offs); | 690 | dbg_io("write %d bytes to LEB %d:%d", n, wbuf->lnum, offs); |
595 | err = ubi_leb_write(c->ubi, wbuf->lnum, buf + written, offs, n, | 691 | err = ubi_leb_write(c->ubi, wbuf->lnum, buf + written, offs, n, |
596 | wbuf->dtype); | 692 | wbuf->dtype); |
@@ -606,14 +702,18 @@ int ubifs_wbuf_write_nolock(struct ubifs_wbuf *wbuf, void *buf, int len) | |||
606 | if (aligned_len) | 702 | if (aligned_len) |
607 | /* | 703 | /* |
608 | * And now we have what's left and what does not take whole | 704 | * And now we have what's left and what does not take whole |
609 | * min. I/O unit, so write it to the write-buffer and we are | 705 | * max. write unit, so write it to the write-buffer and we are |
610 | * done. | 706 | * done. |
611 | */ | 707 | */ |
612 | memcpy(wbuf->buf, buf + written, len); | 708 | memcpy(wbuf->buf, buf + written, len); |
613 | 709 | ||
614 | wbuf->offs = offs; | 710 | wbuf->offs = offs; |
711 | if (c->leb_size - wbuf->offs >= c->max_write_size) | ||
712 | wbuf->size = c->max_write_size; | ||
713 | else | ||
714 | wbuf->size = c->leb_size - wbuf->offs; | ||
715 | wbuf->avail = wbuf->size - aligned_len; | ||
615 | wbuf->used = aligned_len; | 716 | wbuf->used = aligned_len; |
616 | wbuf->avail = c->min_io_size - aligned_len; | ||
617 | wbuf->next_ino = 0; | 717 | wbuf->next_ino = 0; |
618 | spin_unlock(&wbuf->lock); | 718 | spin_unlock(&wbuf->lock); |
619 | 719 | ||
@@ -837,11 +937,11 @@ int ubifs_wbuf_init(struct ubifs_info *c, struct ubifs_wbuf *wbuf) | |||
837 | { | 937 | { |
838 | size_t size; | 938 | size_t size; |
839 | 939 | ||
840 | wbuf->buf = kmalloc(c->min_io_size, GFP_KERNEL); | 940 | wbuf->buf = kmalloc(c->max_write_size, GFP_KERNEL); |
841 | if (!wbuf->buf) | 941 | if (!wbuf->buf) |
842 | return -ENOMEM; | 942 | return -ENOMEM; |
843 | 943 | ||
844 | size = (c->min_io_size / UBIFS_CH_SZ + 1) * sizeof(ino_t); | 944 | size = (c->max_write_size / UBIFS_CH_SZ + 1) * sizeof(ino_t); |
845 | wbuf->inodes = kmalloc(size, GFP_KERNEL); | 945 | wbuf->inodes = kmalloc(size, GFP_KERNEL); |
846 | if (!wbuf->inodes) { | 946 | if (!wbuf->inodes) { |
847 | kfree(wbuf->buf); | 947 | kfree(wbuf->buf); |
@@ -851,7 +951,14 @@ int ubifs_wbuf_init(struct ubifs_info *c, struct ubifs_wbuf *wbuf) | |||
851 | 951 | ||
852 | wbuf->used = 0; | 952 | wbuf->used = 0; |
853 | wbuf->lnum = wbuf->offs = -1; | 953 | wbuf->lnum = wbuf->offs = -1; |
854 | wbuf->avail = c->min_io_size; | 954 | /* |
955 | * If the LEB starts at the max. write size aligned address, then | ||
956 | * write-buffer size has to be set to @c->max_write_size. Otherwise, | ||
957 | * set it to something smaller so that it ends at the closest max. | ||
958 | * write size boundary. | ||
959 | */ | ||
960 | size = c->max_write_size - (c->leb_start % c->max_write_size); | ||
961 | wbuf->avail = wbuf->size = size; | ||
855 | wbuf->dtype = UBI_UNKNOWN; | 962 | wbuf->dtype = UBI_UNKNOWN; |
856 | wbuf->sync_callback = NULL; | 963 | wbuf->sync_callback = NULL; |
857 | mutex_init(&wbuf->io_mutex); | 964 | mutex_init(&wbuf->io_mutex); |
diff --git a/fs/ubifs/ioctl.c b/fs/ubifs/ioctl.c index 8aacd64957a2..548acf494afd 100644 --- a/fs/ubifs/ioctl.c +++ b/fs/ubifs/ioctl.c | |||
@@ -160,7 +160,7 @@ long ubifs_ioctl(struct file *file, unsigned int cmd, unsigned long arg) | |||
160 | if (IS_RDONLY(inode)) | 160 | if (IS_RDONLY(inode)) |
161 | return -EROFS; | 161 | return -EROFS; |
162 | 162 | ||
163 | if (!is_owner_or_cap(inode)) | 163 | if (!inode_owner_or_capable(inode)) |
164 | return -EACCES; | 164 | return -EACCES; |
165 | 165 | ||
166 | if (get_user(flags, (int __user *) arg)) | 166 | if (get_user(flags, (int __user *) arg)) |
diff --git a/fs/ubifs/journal.c b/fs/ubifs/journal.c index 914f1bd89e57..aed25e864227 100644 --- a/fs/ubifs/journal.c +++ b/fs/ubifs/journal.c | |||
@@ -690,7 +690,7 @@ int ubifs_jnl_write_data(struct ubifs_info *c, const struct inode *inode, | |||
690 | { | 690 | { |
691 | struct ubifs_data_node *data; | 691 | struct ubifs_data_node *data; |
692 | int err, lnum, offs, compr_type, out_len; | 692 | int err, lnum, offs, compr_type, out_len; |
693 | int dlen = UBIFS_DATA_NODE_SZ + UBIFS_BLOCK_SIZE * WORST_COMPR_FACTOR; | 693 | int dlen = COMPRESSED_DATA_NODE_BUF_SZ, allocated = 1; |
694 | struct ubifs_inode *ui = ubifs_inode(inode); | 694 | struct ubifs_inode *ui = ubifs_inode(inode); |
695 | 695 | ||
696 | dbg_jnl("ino %lu, blk %u, len %d, key %s", | 696 | dbg_jnl("ino %lu, blk %u, len %d, key %s", |
@@ -698,9 +698,19 @@ int ubifs_jnl_write_data(struct ubifs_info *c, const struct inode *inode, | |||
698 | DBGKEY(key)); | 698 | DBGKEY(key)); |
699 | ubifs_assert(len <= UBIFS_BLOCK_SIZE); | 699 | ubifs_assert(len <= UBIFS_BLOCK_SIZE); |
700 | 700 | ||
701 | data = kmalloc(dlen, GFP_NOFS); | 701 | data = kmalloc(dlen, GFP_NOFS | __GFP_NOWARN); |
702 | if (!data) | 702 | if (!data) { |
703 | return -ENOMEM; | 703 | /* |
704 | * Fall-back to the write reserve buffer. Note, we might be | ||
705 | * currently on the memory reclaim path, when the kernel is | ||
706 | * trying to free some memory by writing out dirty pages. The | ||
707 | * write reserve buffer helps us to guarantee that we are | ||
708 | * always able to write the data. | ||
709 | */ | ||
710 | allocated = 0; | ||
711 | mutex_lock(&c->write_reserve_mutex); | ||
712 | data = c->write_reserve_buf; | ||
713 | } | ||
704 | 714 | ||
705 | data->ch.node_type = UBIFS_DATA_NODE; | 715 | data->ch.node_type = UBIFS_DATA_NODE; |
706 | key_write(c, key, &data->key); | 716 | key_write(c, key, &data->key); |
@@ -736,7 +746,10 @@ int ubifs_jnl_write_data(struct ubifs_info *c, const struct inode *inode, | |||
736 | goto out_ro; | 746 | goto out_ro; |
737 | 747 | ||
738 | finish_reservation(c); | 748 | finish_reservation(c); |
739 | kfree(data); | 749 | if (!allocated) |
750 | mutex_unlock(&c->write_reserve_mutex); | ||
751 | else | ||
752 | kfree(data); | ||
740 | return 0; | 753 | return 0; |
741 | 754 | ||
742 | out_release: | 755 | out_release: |
@@ -745,7 +758,10 @@ out_ro: | |||
745 | ubifs_ro_mode(c, err); | 758 | ubifs_ro_mode(c, err); |
746 | finish_reservation(c); | 759 | finish_reservation(c); |
747 | out_free: | 760 | out_free: |
748 | kfree(data); | 761 | if (!allocated) |
762 | mutex_unlock(&c->write_reserve_mutex); | ||
763 | else | ||
764 | kfree(data); | ||
749 | return err; | 765 | return err; |
750 | } | 766 | } |
751 | 767 | ||
diff --git a/fs/ubifs/lprops.c b/fs/ubifs/lprops.c index 4d4ca388889b..0ee0847f2421 100644 --- a/fs/ubifs/lprops.c +++ b/fs/ubifs/lprops.c | |||
@@ -1035,7 +1035,8 @@ static int scan_check_cb(struct ubifs_info *c, | |||
1035 | struct ubifs_scan_leb *sleb; | 1035 | struct ubifs_scan_leb *sleb; |
1036 | struct ubifs_scan_node *snod; | 1036 | struct ubifs_scan_node *snod; |
1037 | struct ubifs_lp_stats *lst = &data->lst; | 1037 | struct ubifs_lp_stats *lst = &data->lst; |
1038 | int cat, lnum = lp->lnum, is_idx = 0, used = 0, free, dirty; | 1038 | int cat, lnum = lp->lnum, is_idx = 0, used = 0, free, dirty, ret; |
1039 | void *buf = NULL; | ||
1039 | 1040 | ||
1040 | cat = lp->flags & LPROPS_CAT_MASK; | 1041 | cat = lp->flags & LPROPS_CAT_MASK; |
1041 | if (cat != LPROPS_UNCAT) { | 1042 | if (cat != LPROPS_UNCAT) { |
@@ -1093,7 +1094,13 @@ static int scan_check_cb(struct ubifs_info *c, | |||
1093 | } | 1094 | } |
1094 | } | 1095 | } |
1095 | 1096 | ||
1096 | sleb = ubifs_scan(c, lnum, 0, c->dbg->buf, 0); | 1097 | buf = __vmalloc(c->leb_size, GFP_NOFS, PAGE_KERNEL); |
1098 | if (!buf) { | ||
1099 | ubifs_err("cannot allocate memory to scan LEB %d", lnum); | ||
1100 | goto out; | ||
1101 | } | ||
1102 | |||
1103 | sleb = ubifs_scan(c, lnum, 0, buf, 0); | ||
1097 | if (IS_ERR(sleb)) { | 1104 | if (IS_ERR(sleb)) { |
1098 | /* | 1105 | /* |
1099 | * After an unclean unmount, empty and freeable LEBs | 1106 | * After an unclean unmount, empty and freeable LEBs |
@@ -1105,7 +1112,8 @@ static int scan_check_cb(struct ubifs_info *c, | |||
1105 | lst->empty_lebs += 1; | 1112 | lst->empty_lebs += 1; |
1106 | lst->total_free += c->leb_size; | 1113 | lst->total_free += c->leb_size; |
1107 | lst->total_dark += ubifs_calc_dark(c, c->leb_size); | 1114 | lst->total_dark += ubifs_calc_dark(c, c->leb_size); |
1108 | return LPT_SCAN_CONTINUE; | 1115 | ret = LPT_SCAN_CONTINUE; |
1116 | goto exit; | ||
1109 | } | 1117 | } |
1110 | 1118 | ||
1111 | if (lp->free + lp->dirty == c->leb_size && | 1119 | if (lp->free + lp->dirty == c->leb_size && |
@@ -1115,10 +1123,12 @@ static int scan_check_cb(struct ubifs_info *c, | |||
1115 | lst->total_free += lp->free; | 1123 | lst->total_free += lp->free; |
1116 | lst->total_dirty += lp->dirty; | 1124 | lst->total_dirty += lp->dirty; |
1117 | lst->total_dark += ubifs_calc_dark(c, c->leb_size); | 1125 | lst->total_dark += ubifs_calc_dark(c, c->leb_size); |
1118 | return LPT_SCAN_CONTINUE; | 1126 | ret = LPT_SCAN_CONTINUE; |
1127 | goto exit; | ||
1119 | } | 1128 | } |
1120 | data->err = PTR_ERR(sleb); | 1129 | data->err = PTR_ERR(sleb); |
1121 | return LPT_SCAN_STOP; | 1130 | ret = LPT_SCAN_STOP; |
1131 | goto exit; | ||
1122 | } | 1132 | } |
1123 | 1133 | ||
1124 | is_idx = -1; | 1134 | is_idx = -1; |
@@ -1236,7 +1246,10 @@ static int scan_check_cb(struct ubifs_info *c, | |||
1236 | } | 1246 | } |
1237 | 1247 | ||
1238 | ubifs_scan_destroy(sleb); | 1248 | ubifs_scan_destroy(sleb); |
1239 | return LPT_SCAN_CONTINUE; | 1249 | ret = LPT_SCAN_CONTINUE; |
1250 | exit: | ||
1251 | vfree(buf); | ||
1252 | return ret; | ||
1240 | 1253 | ||
1241 | out_print: | 1254 | out_print: |
1242 | ubifs_err("bad accounting of LEB %d: free %d, dirty %d flags %#x, " | 1255 | ubifs_err("bad accounting of LEB %d: free %d, dirty %d flags %#x, " |
@@ -1246,6 +1259,7 @@ out_print: | |||
1246 | out_destroy: | 1259 | out_destroy: |
1247 | ubifs_scan_destroy(sleb); | 1260 | ubifs_scan_destroy(sleb); |
1248 | out: | 1261 | out: |
1262 | vfree(buf); | ||
1249 | data->err = -EINVAL; | 1263 | data->err = -EINVAL; |
1250 | return LPT_SCAN_STOP; | 1264 | return LPT_SCAN_STOP; |
1251 | } | 1265 | } |
diff --git a/fs/ubifs/lpt_commit.c b/fs/ubifs/lpt_commit.c index 5c90dec5db0b..0c9c69bd983a 100644 --- a/fs/ubifs/lpt_commit.c +++ b/fs/ubifs/lpt_commit.c | |||
@@ -1628,29 +1628,35 @@ static int dbg_check_ltab_lnum(struct ubifs_info *c, int lnum) | |||
1628 | { | 1628 | { |
1629 | int err, len = c->leb_size, dirty = 0, node_type, node_num, node_len; | 1629 | int err, len = c->leb_size, dirty = 0, node_type, node_num, node_len; |
1630 | int ret; | 1630 | int ret; |
1631 | void *buf = c->dbg->buf; | 1631 | void *buf, *p; |
1632 | 1632 | ||
1633 | if (!(ubifs_chk_flags & UBIFS_CHK_LPROPS)) | 1633 | if (!(ubifs_chk_flags & UBIFS_CHK_LPROPS)) |
1634 | return 0; | 1634 | return 0; |
1635 | 1635 | ||
1636 | buf = p = __vmalloc(c->leb_size, GFP_NOFS, PAGE_KERNEL); | ||
1637 | if (!buf) { | ||
1638 | ubifs_err("cannot allocate memory for ltab checking"); | ||
1639 | return 0; | ||
1640 | } | ||
1641 | |||
1636 | dbg_lp("LEB %d", lnum); | 1642 | dbg_lp("LEB %d", lnum); |
1637 | err = ubi_read(c->ubi, lnum, buf, 0, c->leb_size); | 1643 | err = ubi_read(c->ubi, lnum, buf, 0, c->leb_size); |
1638 | if (err) { | 1644 | if (err) { |
1639 | dbg_msg("ubi_read failed, LEB %d, error %d", lnum, err); | 1645 | dbg_msg("ubi_read failed, LEB %d, error %d", lnum, err); |
1640 | return err; | 1646 | goto out; |
1641 | } | 1647 | } |
1642 | while (1) { | 1648 | while (1) { |
1643 | if (!is_a_node(c, buf, len)) { | 1649 | if (!is_a_node(c, p, len)) { |
1644 | int i, pad_len; | 1650 | int i, pad_len; |
1645 | 1651 | ||
1646 | pad_len = get_pad_len(c, buf, len); | 1652 | pad_len = get_pad_len(c, p, len); |
1647 | if (pad_len) { | 1653 | if (pad_len) { |
1648 | buf += pad_len; | 1654 | p += pad_len; |
1649 | len -= pad_len; | 1655 | len -= pad_len; |
1650 | dirty += pad_len; | 1656 | dirty += pad_len; |
1651 | continue; | 1657 | continue; |
1652 | } | 1658 | } |
1653 | if (!dbg_is_all_ff(buf, len)) { | 1659 | if (!dbg_is_all_ff(p, len)) { |
1654 | dbg_msg("invalid empty space in LEB %d at %d", | 1660 | dbg_msg("invalid empty space in LEB %d at %d", |
1655 | lnum, c->leb_size - len); | 1661 | lnum, c->leb_size - len); |
1656 | err = -EINVAL; | 1662 | err = -EINVAL; |
@@ -1668,16 +1674,21 @@ static int dbg_check_ltab_lnum(struct ubifs_info *c, int lnum) | |||
1668 | lnum, dirty, c->ltab[i].dirty); | 1674 | lnum, dirty, c->ltab[i].dirty); |
1669 | err = -EINVAL; | 1675 | err = -EINVAL; |
1670 | } | 1676 | } |
1671 | return err; | 1677 | goto out; |
1672 | } | 1678 | } |
1673 | node_type = get_lpt_node_type(c, buf, &node_num); | 1679 | node_type = get_lpt_node_type(c, p, &node_num); |
1674 | node_len = get_lpt_node_len(c, node_type); | 1680 | node_len = get_lpt_node_len(c, node_type); |
1675 | ret = dbg_is_node_dirty(c, node_type, lnum, c->leb_size - len); | 1681 | ret = dbg_is_node_dirty(c, node_type, lnum, c->leb_size - len); |
1676 | if (ret == 1) | 1682 | if (ret == 1) |
1677 | dirty += node_len; | 1683 | dirty += node_len; |
1678 | buf += node_len; | 1684 | p += node_len; |
1679 | len -= node_len; | 1685 | len -= node_len; |
1680 | } | 1686 | } |
1687 | |||
1688 | err = 0; | ||
1689 | out: | ||
1690 | vfree(buf); | ||
1691 | return err; | ||
1681 | } | 1692 | } |
1682 | 1693 | ||
1683 | /** | 1694 | /** |
@@ -1870,25 +1881,31 @@ int dbg_chk_lpt_sz(struct ubifs_info *c, int action, int len) | |||
1870 | static void dump_lpt_leb(const struct ubifs_info *c, int lnum) | 1881 | static void dump_lpt_leb(const struct ubifs_info *c, int lnum) |
1871 | { | 1882 | { |
1872 | int err, len = c->leb_size, node_type, node_num, node_len, offs; | 1883 | int err, len = c->leb_size, node_type, node_num, node_len, offs; |
1873 | void *buf = c->dbg->buf; | 1884 | void *buf, *p; |
1874 | 1885 | ||
1875 | printk(KERN_DEBUG "(pid %d) start dumping LEB %d\n", | 1886 | printk(KERN_DEBUG "(pid %d) start dumping LEB %d\n", |
1876 | current->pid, lnum); | 1887 | current->pid, lnum); |
1888 | buf = p = __vmalloc(c->leb_size, GFP_NOFS, PAGE_KERNEL); | ||
1889 | if (!buf) { | ||
1890 | ubifs_err("cannot allocate memory to dump LPT"); | ||
1891 | return; | ||
1892 | } | ||
1893 | |||
1877 | err = ubi_read(c->ubi, lnum, buf, 0, c->leb_size); | 1894 | err = ubi_read(c->ubi, lnum, buf, 0, c->leb_size); |
1878 | if (err) { | 1895 | if (err) { |
1879 | ubifs_err("cannot read LEB %d, error %d", lnum, err); | 1896 | ubifs_err("cannot read LEB %d, error %d", lnum, err); |
1880 | return; | 1897 | goto out; |
1881 | } | 1898 | } |
1882 | while (1) { | 1899 | while (1) { |
1883 | offs = c->leb_size - len; | 1900 | offs = c->leb_size - len; |
1884 | if (!is_a_node(c, buf, len)) { | 1901 | if (!is_a_node(c, p, len)) { |
1885 | int pad_len; | 1902 | int pad_len; |
1886 | 1903 | ||
1887 | pad_len = get_pad_len(c, buf, len); | 1904 | pad_len = get_pad_len(c, p, len); |
1888 | if (pad_len) { | 1905 | if (pad_len) { |
1889 | printk(KERN_DEBUG "LEB %d:%d, pad %d bytes\n", | 1906 | printk(KERN_DEBUG "LEB %d:%d, pad %d bytes\n", |
1890 | lnum, offs, pad_len); | 1907 | lnum, offs, pad_len); |
1891 | buf += pad_len; | 1908 | p += pad_len; |
1892 | len -= pad_len; | 1909 | len -= pad_len; |
1893 | continue; | 1910 | continue; |
1894 | } | 1911 | } |
@@ -1898,7 +1915,7 @@ static void dump_lpt_leb(const struct ubifs_info *c, int lnum) | |||
1898 | break; | 1915 | break; |
1899 | } | 1916 | } |
1900 | 1917 | ||
1901 | node_type = get_lpt_node_type(c, buf, &node_num); | 1918 | node_type = get_lpt_node_type(c, p, &node_num); |
1902 | switch (node_type) { | 1919 | switch (node_type) { |
1903 | case UBIFS_LPT_PNODE: | 1920 | case UBIFS_LPT_PNODE: |
1904 | { | 1921 | { |
@@ -1923,7 +1940,7 @@ static void dump_lpt_leb(const struct ubifs_info *c, int lnum) | |||
1923 | else | 1940 | else |
1924 | printk(KERN_DEBUG "LEB %d:%d, nnode, ", | 1941 | printk(KERN_DEBUG "LEB %d:%d, nnode, ", |
1925 | lnum, offs); | 1942 | lnum, offs); |
1926 | err = ubifs_unpack_nnode(c, buf, &nnode); | 1943 | err = ubifs_unpack_nnode(c, p, &nnode); |
1927 | for (i = 0; i < UBIFS_LPT_FANOUT; i++) { | 1944 | for (i = 0; i < UBIFS_LPT_FANOUT; i++) { |
1928 | printk(KERN_CONT "%d:%d", nnode.nbranch[i].lnum, | 1945 | printk(KERN_CONT "%d:%d", nnode.nbranch[i].lnum, |
1929 | nnode.nbranch[i].offs); | 1946 | nnode.nbranch[i].offs); |
@@ -1944,15 +1961,18 @@ static void dump_lpt_leb(const struct ubifs_info *c, int lnum) | |||
1944 | break; | 1961 | break; |
1945 | default: | 1962 | default: |
1946 | ubifs_err("LPT node type %d not recognized", node_type); | 1963 | ubifs_err("LPT node type %d not recognized", node_type); |
1947 | return; | 1964 | goto out; |
1948 | } | 1965 | } |
1949 | 1966 | ||
1950 | buf += node_len; | 1967 | p += node_len; |
1951 | len -= node_len; | 1968 | len -= node_len; |
1952 | } | 1969 | } |
1953 | 1970 | ||
1954 | printk(KERN_DEBUG "(pid %d) finish dumping LEB %d\n", | 1971 | printk(KERN_DEBUG "(pid %d) finish dumping LEB %d\n", |
1955 | current->pid, lnum); | 1972 | current->pid, lnum); |
1973 | out: | ||
1974 | vfree(buf); | ||
1975 | return; | ||
1956 | } | 1976 | } |
1957 | 1977 | ||
1958 | /** | 1978 | /** |
diff --git a/fs/ubifs/orphan.c b/fs/ubifs/orphan.c index 82009c74b6a3..09df318e368f 100644 --- a/fs/ubifs/orphan.c +++ b/fs/ubifs/orphan.c | |||
@@ -892,15 +892,22 @@ static int dbg_read_orphans(struct check_info *ci, struct ubifs_scan_leb *sleb) | |||
892 | static int dbg_scan_orphans(struct ubifs_info *c, struct check_info *ci) | 892 | static int dbg_scan_orphans(struct ubifs_info *c, struct check_info *ci) |
893 | { | 893 | { |
894 | int lnum, err = 0; | 894 | int lnum, err = 0; |
895 | void *buf; | ||
895 | 896 | ||
896 | /* Check no-orphans flag and skip this if no orphans */ | 897 | /* Check no-orphans flag and skip this if no orphans */ |
897 | if (c->no_orphs) | 898 | if (c->no_orphs) |
898 | return 0; | 899 | return 0; |
899 | 900 | ||
901 | buf = __vmalloc(c->leb_size, GFP_NOFS, PAGE_KERNEL); | ||
902 | if (!buf) { | ||
903 | ubifs_err("cannot allocate memory to check orphans"); | ||
904 | return 0; | ||
905 | } | ||
906 | |||
900 | for (lnum = c->orph_first; lnum <= c->orph_last; lnum++) { | 907 | for (lnum = c->orph_first; lnum <= c->orph_last; lnum++) { |
901 | struct ubifs_scan_leb *sleb; | 908 | struct ubifs_scan_leb *sleb; |
902 | 909 | ||
903 | sleb = ubifs_scan(c, lnum, 0, c->dbg->buf, 0); | 910 | sleb = ubifs_scan(c, lnum, 0, buf, 0); |
904 | if (IS_ERR(sleb)) { | 911 | if (IS_ERR(sleb)) { |
905 | err = PTR_ERR(sleb); | 912 | err = PTR_ERR(sleb); |
906 | break; | 913 | break; |
@@ -912,6 +919,7 @@ static int dbg_scan_orphans(struct ubifs_info *c, struct check_info *ci) | |||
912 | break; | 919 | break; |
913 | } | 920 | } |
914 | 921 | ||
922 | vfree(buf); | ||
915 | return err; | 923 | return err; |
916 | } | 924 | } |
917 | 925 | ||
diff --git a/fs/ubifs/recovery.c b/fs/ubifs/recovery.c index 77e9b874b6c2..936f2cbfe6b6 100644 --- a/fs/ubifs/recovery.c +++ b/fs/ubifs/recovery.c | |||
@@ -28,6 +28,23 @@ | |||
28 | * UBIFS always cleans away all remnants of an unclean un-mount, so that | 28 | * UBIFS always cleans away all remnants of an unclean un-mount, so that |
29 | * errors do not accumulate. However UBIFS defers recovery if it is mounted | 29 | * errors do not accumulate. However UBIFS defers recovery if it is mounted |
30 | * read-only, and the flash is not modified in that case. | 30 | * read-only, and the flash is not modified in that case. |
31 | * | ||
32 | * The general UBIFS approach to the recovery is that it recovers from | ||
33 | * corruptions which could be caused by power cuts, but it refuses to recover | ||
34 | * from corruption caused by other reasons. And UBIFS tries to distinguish | ||
35 | * between these 2 reasons of corruptions and silently recover in the former | ||
36 | * case and loudly complain in the latter case. | ||
37 | * | ||
38 | * UBIFS writes only to erased LEBs, so it writes only to the flash space | ||
39 | * containing only 0xFFs. UBIFS also always writes strictly from the beginning | ||
40 | * of the LEB to the end. And UBIFS assumes that the underlying flash media | ||
41 | * writes in @c->max_write_size bytes at a time. | ||
42 | * | ||
43 | * Hence, if UBIFS finds a corrupted node at offset X, it expects only the min. | ||
44 | * I/O unit corresponding to offset X to contain corrupted data, all the | ||
45 | * following min. I/O units have to contain empty space (all 0xFFs). If this is | ||
46 | * not true, the corruption cannot be the result of a power cut, and UBIFS | ||
47 | * refuses to mount. | ||
31 | */ | 48 | */ |
32 | 49 | ||
33 | #include <linux/crc32.h> | 50 | #include <linux/crc32.h> |
@@ -362,8 +379,9 @@ int ubifs_write_rcvrd_mst_node(struct ubifs_info *c) | |||
362 | * @offs: offset to check | 379 | * @offs: offset to check |
363 | * | 380 | * |
364 | * This function returns %1 if @offs was in the last write to the LEB whose data | 381 | * This function returns %1 if @offs was in the last write to the LEB whose data |
365 | * is in @buf, otherwise %0 is returned. The determination is made by checking | 382 | * is in @buf, otherwise %0 is returned. The determination is made by checking |
366 | * for subsequent empty space starting from the next @c->min_io_size boundary. | 383 | * for subsequent empty space starting from the next @c->max_write_size |
384 | * boundary. | ||
367 | */ | 385 | */ |
368 | static int is_last_write(const struct ubifs_info *c, void *buf, int offs) | 386 | static int is_last_write(const struct ubifs_info *c, void *buf, int offs) |
369 | { | 387 | { |
@@ -371,10 +389,10 @@ static int is_last_write(const struct ubifs_info *c, void *buf, int offs) | |||
371 | uint8_t *p; | 389 | uint8_t *p; |
372 | 390 | ||
373 | /* | 391 | /* |
374 | * Round up to the next @c->min_io_size boundary i.e. @offs is in the | 392 | * Round up to the next @c->max_write_size boundary i.e. @offs is in |
375 | * last wbuf written. After that should be empty space. | 393 | * the last wbuf written. After that should be empty space. |
376 | */ | 394 | */ |
377 | empty_offs = ALIGN(offs + 1, c->min_io_size); | 395 | empty_offs = ALIGN(offs + 1, c->max_write_size); |
378 | check_len = c->leb_size - empty_offs; | 396 | check_len = c->leb_size - empty_offs; |
379 | p = buf + empty_offs - offs; | 397 | p = buf + empty_offs - offs; |
380 | return is_empty(p, check_len); | 398 | return is_empty(p, check_len); |
@@ -429,7 +447,7 @@ static int no_more_nodes(const struct ubifs_info *c, void *buf, int len, | |||
429 | int skip, dlen = le32_to_cpu(ch->len); | 447 | int skip, dlen = le32_to_cpu(ch->len); |
430 | 448 | ||
431 | /* Check for empty space after the corrupt node's common header */ | 449 | /* Check for empty space after the corrupt node's common header */ |
432 | skip = ALIGN(offs + UBIFS_CH_SZ, c->min_io_size) - offs; | 450 | skip = ALIGN(offs + UBIFS_CH_SZ, c->max_write_size) - offs; |
433 | if (is_empty(buf + skip, len - skip)) | 451 | if (is_empty(buf + skip, len - skip)) |
434 | return 1; | 452 | return 1; |
435 | /* | 453 | /* |
@@ -441,7 +459,7 @@ static int no_more_nodes(const struct ubifs_info *c, void *buf, int len, | |||
441 | return 0; | 459 | return 0; |
442 | } | 460 | } |
443 | /* Now we know the corrupt node's length we can skip over it */ | 461 | /* Now we know the corrupt node's length we can skip over it */ |
444 | skip = ALIGN(offs + dlen, c->min_io_size) - offs; | 462 | skip = ALIGN(offs + dlen, c->max_write_size) - offs; |
445 | /* After which there should be empty space */ | 463 | /* After which there should be empty space */ |
446 | if (is_empty(buf + skip, len - skip)) | 464 | if (is_empty(buf + skip, len - skip)) |
447 | return 1; | 465 | return 1; |
@@ -671,10 +689,14 @@ struct ubifs_scan_leb *ubifs_recover_leb(struct ubifs_info *c, int lnum, | |||
671 | } else { | 689 | } else { |
672 | int corruption = first_non_ff(buf, len); | 690 | int corruption = first_non_ff(buf, len); |
673 | 691 | ||
692 | /* | ||
693 | * See header comment for this file for more | ||
694 | * explanations about the reasons we have this check. | ||
695 | */ | ||
674 | ubifs_err("corrupt empty space LEB %d:%d, corruption " | 696 | ubifs_err("corrupt empty space LEB %d:%d, corruption " |
675 | "starts at %d", lnum, offs, corruption); | 697 | "starts at %d", lnum, offs, corruption); |
676 | /* Make sure we dump interesting non-0xFF data */ | 698 | /* Make sure we dump interesting non-0xFF data */ |
677 | offs = corruption; | 699 | offs += corruption; |
678 | buf += corruption; | 700 | buf += corruption; |
679 | goto corrupted; | 701 | goto corrupted; |
680 | } | 702 | } |
@@ -836,12 +858,8 @@ struct ubifs_scan_leb *ubifs_recover_log_leb(struct ubifs_info *c, int lnum, | |||
836 | static int recover_head(const struct ubifs_info *c, int lnum, int offs, | 858 | static int recover_head(const struct ubifs_info *c, int lnum, int offs, |
837 | void *sbuf) | 859 | void *sbuf) |
838 | { | 860 | { |
839 | int len, err; | 861 | int len = c->max_write_size, err; |
840 | 862 | ||
841 | if (c->min_io_size > 1) | ||
842 | len = c->min_io_size; | ||
843 | else | ||
844 | len = 512; | ||
845 | if (offs + len > c->leb_size) | 863 | if (offs + len > c->leb_size) |
846 | len = c->leb_size - offs; | 864 | len = c->leb_size - offs; |
847 | 865 | ||
diff --git a/fs/ubifs/scan.c b/fs/ubifs/scan.c index 3e1ee57dbeaa..36216b46f772 100644 --- a/fs/ubifs/scan.c +++ b/fs/ubifs/scan.c | |||
@@ -328,7 +328,7 @@ struct ubifs_scan_leb *ubifs_scan(const struct ubifs_info *c, int lnum, | |||
328 | if (!quiet) | 328 | if (!quiet) |
329 | ubifs_err("empty space starts at non-aligned offset %d", | 329 | ubifs_err("empty space starts at non-aligned offset %d", |
330 | offs); | 330 | offs); |
331 | goto corrupted;; | 331 | goto corrupted; |
332 | } | 332 | } |
333 | 333 | ||
334 | ubifs_end_scan(c, sleb, lnum, offs); | 334 | ubifs_end_scan(c, sleb, lnum, offs); |
diff --git a/fs/ubifs/super.c b/fs/ubifs/super.c index 6e11c2975dcf..e5dc1e120e8d 100644 --- a/fs/ubifs/super.c +++ b/fs/ubifs/super.c | |||
@@ -512,9 +512,12 @@ static int init_constants_early(struct ubifs_info *c) | |||
512 | 512 | ||
513 | c->leb_cnt = c->vi.size; | 513 | c->leb_cnt = c->vi.size; |
514 | c->leb_size = c->vi.usable_leb_size; | 514 | c->leb_size = c->vi.usable_leb_size; |
515 | c->leb_start = c->di.leb_start; | ||
515 | c->half_leb_size = c->leb_size / 2; | 516 | c->half_leb_size = c->leb_size / 2; |
516 | c->min_io_size = c->di.min_io_size; | 517 | c->min_io_size = c->di.min_io_size; |
517 | c->min_io_shift = fls(c->min_io_size) - 1; | 518 | c->min_io_shift = fls(c->min_io_size) - 1; |
519 | c->max_write_size = c->di.max_write_size; | ||
520 | c->max_write_shift = fls(c->max_write_size) - 1; | ||
518 | 521 | ||
519 | if (c->leb_size < UBIFS_MIN_LEB_SZ) { | 522 | if (c->leb_size < UBIFS_MIN_LEB_SZ) { |
520 | ubifs_err("too small LEBs (%d bytes), min. is %d bytes", | 523 | ubifs_err("too small LEBs (%d bytes), min. is %d bytes", |
@@ -534,6 +537,18 @@ static int init_constants_early(struct ubifs_info *c) | |||
534 | } | 537 | } |
535 | 538 | ||
536 | /* | 539 | /* |
540 | * Maximum write size has to be greater or equivalent to min. I/O | ||
541 | * size, and be multiple of min. I/O size. | ||
542 | */ | ||
543 | if (c->max_write_size < c->min_io_size || | ||
544 | c->max_write_size % c->min_io_size || | ||
545 | !is_power_of_2(c->max_write_size)) { | ||
546 | ubifs_err("bad write buffer size %d for %d min. I/O unit", | ||
547 | c->max_write_size, c->min_io_size); | ||
548 | return -EINVAL; | ||
549 | } | ||
550 | |||
551 | /* | ||
537 | * UBIFS aligns all node to 8-byte boundary, so to make function in | 552 | * UBIFS aligns all node to 8-byte boundary, so to make function in |
538 | * io.c simpler, assume minimum I/O unit size to be 8 bytes if it is | 553 | * io.c simpler, assume minimum I/O unit size to be 8 bytes if it is |
539 | * less than 8. | 554 | * less than 8. |
@@ -541,6 +556,10 @@ static int init_constants_early(struct ubifs_info *c) | |||
541 | if (c->min_io_size < 8) { | 556 | if (c->min_io_size < 8) { |
542 | c->min_io_size = 8; | 557 | c->min_io_size = 8; |
543 | c->min_io_shift = 3; | 558 | c->min_io_shift = 3; |
559 | if (c->max_write_size < c->min_io_size) { | ||
560 | c->max_write_size = c->min_io_size; | ||
561 | c->max_write_shift = c->min_io_shift; | ||
562 | } | ||
544 | } | 563 | } |
545 | 564 | ||
546 | c->ref_node_alsz = ALIGN(UBIFS_REF_NODE_SZ, c->min_io_size); | 565 | c->ref_node_alsz = ALIGN(UBIFS_REF_NODE_SZ, c->min_io_size); |
@@ -1202,11 +1221,14 @@ static int mount_ubifs(struct ubifs_info *c) | |||
1202 | if (c->bulk_read == 1) | 1221 | if (c->bulk_read == 1) |
1203 | bu_init(c); | 1222 | bu_init(c); |
1204 | 1223 | ||
1205 | /* | 1224 | if (!c->ro_mount) { |
1206 | * We have to check all CRCs, even for data nodes, when we mount the FS | 1225 | c->write_reserve_buf = kmalloc(COMPRESSED_DATA_NODE_BUF_SZ, |
1207 | * (specifically, when we are replaying). | 1226 | GFP_KERNEL); |
1208 | */ | 1227 | if (!c->write_reserve_buf) |
1209 | c->always_chk_crc = 1; | 1228 | goto out_free; |
1229 | } | ||
1230 | |||
1231 | c->mounting = 1; | ||
1210 | 1232 | ||
1211 | err = ubifs_read_superblock(c); | 1233 | err = ubifs_read_superblock(c); |
1212 | if (err) | 1234 | if (err) |
@@ -1382,7 +1404,7 @@ static int mount_ubifs(struct ubifs_info *c) | |||
1382 | if (err) | 1404 | if (err) |
1383 | goto out_infos; | 1405 | goto out_infos; |
1384 | 1406 | ||
1385 | c->always_chk_crc = 0; | 1407 | c->mounting = 0; |
1386 | 1408 | ||
1387 | ubifs_msg("mounted UBI device %d, volume %d, name \"%s\"", | 1409 | ubifs_msg("mounted UBI device %d, volume %d, name \"%s\"", |
1388 | c->vi.ubi_num, c->vi.vol_id, c->vi.name); | 1410 | c->vi.ubi_num, c->vi.vol_id, c->vi.name); |
@@ -1403,6 +1425,7 @@ static int mount_ubifs(struct ubifs_info *c) | |||
1403 | 1425 | ||
1404 | dbg_msg("compiled on: " __DATE__ " at " __TIME__); | 1426 | dbg_msg("compiled on: " __DATE__ " at " __TIME__); |
1405 | dbg_msg("min. I/O unit size: %d bytes", c->min_io_size); | 1427 | dbg_msg("min. I/O unit size: %d bytes", c->min_io_size); |
1428 | dbg_msg("max. write size: %d bytes", c->max_write_size); | ||
1406 | dbg_msg("LEB size: %d bytes (%d KiB)", | 1429 | dbg_msg("LEB size: %d bytes (%d KiB)", |
1407 | c->leb_size, c->leb_size >> 10); | 1430 | c->leb_size, c->leb_size >> 10); |
1408 | dbg_msg("data journal heads: %d", | 1431 | dbg_msg("data journal heads: %d", |
@@ -1432,9 +1455,9 @@ static int mount_ubifs(struct ubifs_info *c) | |||
1432 | UBIFS_TRUN_NODE_SZ, UBIFS_SB_NODE_SZ, UBIFS_MST_NODE_SZ); | 1455 | UBIFS_TRUN_NODE_SZ, UBIFS_SB_NODE_SZ, UBIFS_MST_NODE_SZ); |
1433 | dbg_msg("node sizes: ref %zu, cmt. start %zu, orph %zu", | 1456 | dbg_msg("node sizes: ref %zu, cmt. start %zu, orph %zu", |
1434 | UBIFS_REF_NODE_SZ, UBIFS_CS_NODE_SZ, UBIFS_ORPH_NODE_SZ); | 1457 | UBIFS_REF_NODE_SZ, UBIFS_CS_NODE_SZ, UBIFS_ORPH_NODE_SZ); |
1435 | dbg_msg("max. node sizes: data %zu, inode %zu dentry %zu", | 1458 | dbg_msg("max. node sizes: data %zu, inode %zu dentry %zu, idx %d", |
1436 | UBIFS_MAX_DATA_NODE_SZ, UBIFS_MAX_INO_NODE_SZ, | 1459 | UBIFS_MAX_DATA_NODE_SZ, UBIFS_MAX_INO_NODE_SZ, |
1437 | UBIFS_MAX_DENT_NODE_SZ); | 1460 | UBIFS_MAX_DENT_NODE_SZ, ubifs_idx_node_sz(c, c->fanout)); |
1438 | dbg_msg("dead watermark: %d", c->dead_wm); | 1461 | dbg_msg("dead watermark: %d", c->dead_wm); |
1439 | dbg_msg("dark watermark: %d", c->dark_wm); | 1462 | dbg_msg("dark watermark: %d", c->dark_wm); |
1440 | dbg_msg("LEB overhead: %d", c->leb_overhead); | 1463 | dbg_msg("LEB overhead: %d", c->leb_overhead); |
@@ -1474,6 +1497,7 @@ out_wbufs: | |||
1474 | out_cbuf: | 1497 | out_cbuf: |
1475 | kfree(c->cbuf); | 1498 | kfree(c->cbuf); |
1476 | out_free: | 1499 | out_free: |
1500 | kfree(c->write_reserve_buf); | ||
1477 | kfree(c->bu.buf); | 1501 | kfree(c->bu.buf); |
1478 | vfree(c->ileb_buf); | 1502 | vfree(c->ileb_buf); |
1479 | vfree(c->sbuf); | 1503 | vfree(c->sbuf); |
@@ -1512,6 +1536,7 @@ static void ubifs_umount(struct ubifs_info *c) | |||
1512 | kfree(c->cbuf); | 1536 | kfree(c->cbuf); |
1513 | kfree(c->rcvrd_mst_node); | 1537 | kfree(c->rcvrd_mst_node); |
1514 | kfree(c->mst_node); | 1538 | kfree(c->mst_node); |
1539 | kfree(c->write_reserve_buf); | ||
1515 | kfree(c->bu.buf); | 1540 | kfree(c->bu.buf); |
1516 | vfree(c->ileb_buf); | 1541 | vfree(c->ileb_buf); |
1517 | vfree(c->sbuf); | 1542 | vfree(c->sbuf); |
@@ -1543,7 +1568,6 @@ static int ubifs_remount_rw(struct ubifs_info *c) | |||
1543 | mutex_lock(&c->umount_mutex); | 1568 | mutex_lock(&c->umount_mutex); |
1544 | dbg_save_space_info(c); | 1569 | dbg_save_space_info(c); |
1545 | c->remounting_rw = 1; | 1570 | c->remounting_rw = 1; |
1546 | c->always_chk_crc = 1; | ||
1547 | 1571 | ||
1548 | err = check_free_space(c); | 1572 | err = check_free_space(c); |
1549 | if (err) | 1573 | if (err) |
@@ -1598,6 +1622,10 @@ static int ubifs_remount_rw(struct ubifs_info *c) | |||
1598 | goto out; | 1622 | goto out; |
1599 | } | 1623 | } |
1600 | 1624 | ||
1625 | c->write_reserve_buf = kmalloc(COMPRESSED_DATA_NODE_BUF_SZ, GFP_KERNEL); | ||
1626 | if (!c->write_reserve_buf) | ||
1627 | goto out; | ||
1628 | |||
1601 | err = ubifs_lpt_init(c, 0, 1); | 1629 | err = ubifs_lpt_init(c, 0, 1); |
1602 | if (err) | 1630 | if (err) |
1603 | goto out; | 1631 | goto out; |
@@ -1650,7 +1678,6 @@ static int ubifs_remount_rw(struct ubifs_info *c) | |||
1650 | dbg_gen("re-mounted read-write"); | 1678 | dbg_gen("re-mounted read-write"); |
1651 | c->ro_mount = 0; | 1679 | c->ro_mount = 0; |
1652 | c->remounting_rw = 0; | 1680 | c->remounting_rw = 0; |
1653 | c->always_chk_crc = 0; | ||
1654 | err = dbg_check_space_info(c); | 1681 | err = dbg_check_space_info(c); |
1655 | mutex_unlock(&c->umount_mutex); | 1682 | mutex_unlock(&c->umount_mutex); |
1656 | return err; | 1683 | return err; |
@@ -1663,11 +1690,12 @@ out: | |||
1663 | c->bgt = NULL; | 1690 | c->bgt = NULL; |
1664 | } | 1691 | } |
1665 | free_wbufs(c); | 1692 | free_wbufs(c); |
1693 | kfree(c->write_reserve_buf); | ||
1694 | c->write_reserve_buf = NULL; | ||
1666 | vfree(c->ileb_buf); | 1695 | vfree(c->ileb_buf); |
1667 | c->ileb_buf = NULL; | 1696 | c->ileb_buf = NULL; |
1668 | ubifs_lpt_free(c, 1); | 1697 | ubifs_lpt_free(c, 1); |
1669 | c->remounting_rw = 0; | 1698 | c->remounting_rw = 0; |
1670 | c->always_chk_crc = 0; | ||
1671 | mutex_unlock(&c->umount_mutex); | 1699 | mutex_unlock(&c->umount_mutex); |
1672 | return err; | 1700 | return err; |
1673 | } | 1701 | } |
@@ -1707,6 +1735,8 @@ static void ubifs_remount_ro(struct ubifs_info *c) | |||
1707 | free_wbufs(c); | 1735 | free_wbufs(c); |
1708 | vfree(c->orph_buf); | 1736 | vfree(c->orph_buf); |
1709 | c->orph_buf = NULL; | 1737 | c->orph_buf = NULL; |
1738 | kfree(c->write_reserve_buf); | ||
1739 | c->write_reserve_buf = NULL; | ||
1710 | vfree(c->ileb_buf); | 1740 | vfree(c->ileb_buf); |
1711 | c->ileb_buf = NULL; | 1741 | c->ileb_buf = NULL; |
1712 | ubifs_lpt_free(c, 1); | 1742 | ubifs_lpt_free(c, 1); |
@@ -1937,6 +1967,7 @@ static int ubifs_fill_super(struct super_block *sb, void *data, int silent) | |||
1937 | mutex_init(&c->mst_mutex); | 1967 | mutex_init(&c->mst_mutex); |
1938 | mutex_init(&c->umount_mutex); | 1968 | mutex_init(&c->umount_mutex); |
1939 | mutex_init(&c->bu_mutex); | 1969 | mutex_init(&c->bu_mutex); |
1970 | mutex_init(&c->write_reserve_mutex); | ||
1940 | init_waitqueue_head(&c->cmt_wq); | 1971 | init_waitqueue_head(&c->cmt_wq); |
1941 | c->buds = RB_ROOT; | 1972 | c->buds = RB_ROOT; |
1942 | c->old_idx = RB_ROOT; | 1973 | c->old_idx = RB_ROOT; |
@@ -1954,6 +1985,7 @@ static int ubifs_fill_super(struct super_block *sb, void *data, int silent) | |||
1954 | INIT_LIST_HEAD(&c->old_buds); | 1985 | INIT_LIST_HEAD(&c->old_buds); |
1955 | INIT_LIST_HEAD(&c->orph_list); | 1986 | INIT_LIST_HEAD(&c->orph_list); |
1956 | INIT_LIST_HEAD(&c->orph_new); | 1987 | INIT_LIST_HEAD(&c->orph_new); |
1988 | c->no_chk_data_crc = 1; | ||
1957 | 1989 | ||
1958 | c->vfs_sb = sb; | 1990 | c->vfs_sb = sb; |
1959 | c->highest_inum = UBIFS_FIRST_INO; | 1991 | c->highest_inum = UBIFS_FIRST_INO; |
diff --git a/fs/ubifs/tnc.c b/fs/ubifs/tnc.c index ad9cf0133622..de485979ca39 100644 --- a/fs/ubifs/tnc.c +++ b/fs/ubifs/tnc.c | |||
@@ -447,8 +447,11 @@ static int tnc_read_node_nm(struct ubifs_info *c, struct ubifs_zbranch *zbr, | |||
447 | * | 447 | * |
448 | * Note, this function does not check CRC of data nodes if @c->no_chk_data_crc | 448 | * Note, this function does not check CRC of data nodes if @c->no_chk_data_crc |
449 | * is true (it is controlled by corresponding mount option). However, if | 449 | * is true (it is controlled by corresponding mount option). However, if |
450 | * @c->always_chk_crc is true, @c->no_chk_data_crc is ignored and CRC is always | 450 | * @c->mounting or @c->remounting_rw is true (we are mounting or re-mounting to |
451 | * checked. | 451 | * R/W mode), @c->no_chk_data_crc is ignored and CRC is checked. This is |
452 | * because during mounting or re-mounting from R/O mode to R/W mode we may read | ||
453 | * journal nodes (when replying the journal or doing the recovery) and the | ||
454 | * journal nodes may potentially be corrupted, so checking is required. | ||
452 | */ | 455 | */ |
453 | static int try_read_node(const struct ubifs_info *c, void *buf, int type, | 456 | static int try_read_node(const struct ubifs_info *c, void *buf, int type, |
454 | int len, int lnum, int offs) | 457 | int len, int lnum, int offs) |
@@ -476,7 +479,8 @@ static int try_read_node(const struct ubifs_info *c, void *buf, int type, | |||
476 | if (node_len != len) | 479 | if (node_len != len) |
477 | return 0; | 480 | return 0; |
478 | 481 | ||
479 | if (type == UBIFS_DATA_NODE && !c->always_chk_crc && c->no_chk_data_crc) | 482 | if (type == UBIFS_DATA_NODE && c->no_chk_data_crc && !c->mounting && |
483 | !c->remounting_rw) | ||
480 | return 1; | 484 | return 1; |
481 | 485 | ||
482 | crc = crc32(UBIFS_CRC32_INIT, buf + 8, node_len - 8); | 486 | crc = crc32(UBIFS_CRC32_INIT, buf + 8, node_len - 8); |
diff --git a/fs/ubifs/ubifs.h b/fs/ubifs/ubifs.h index 381d6b207a52..8c40ad3c6721 100644 --- a/fs/ubifs/ubifs.h +++ b/fs/ubifs/ubifs.h | |||
@@ -151,6 +151,12 @@ | |||
151 | */ | 151 | */ |
152 | #define WORST_COMPR_FACTOR 2 | 152 | #define WORST_COMPR_FACTOR 2 |
153 | 153 | ||
154 | /* | ||
155 | * How much memory is needed for a buffer where we comress a data node. | ||
156 | */ | ||
157 | #define COMPRESSED_DATA_NODE_BUF_SZ \ | ||
158 | (UBIFS_DATA_NODE_SZ + UBIFS_BLOCK_SIZE * WORST_COMPR_FACTOR) | ||
159 | |||
154 | /* Maximum expected tree height for use by bottom_up_buf */ | 160 | /* Maximum expected tree height for use by bottom_up_buf */ |
155 | #define BOTTOM_UP_HEIGHT 64 | 161 | #define BOTTOM_UP_HEIGHT 64 |
156 | 162 | ||
@@ -646,6 +652,7 @@ typedef int (*ubifs_lpt_scan_callback)(struct ubifs_info *c, | |||
646 | * @offs: write-buffer offset in this logical eraseblock | 652 | * @offs: write-buffer offset in this logical eraseblock |
647 | * @avail: number of bytes available in the write-buffer | 653 | * @avail: number of bytes available in the write-buffer |
648 | * @used: number of used bytes in the write-buffer | 654 | * @used: number of used bytes in the write-buffer |
655 | * @size: write-buffer size (in [@c->min_io_size, @c->max_write_size] range) | ||
649 | * @dtype: type of data stored in this LEB (%UBI_LONGTERM, %UBI_SHORTTERM, | 656 | * @dtype: type of data stored in this LEB (%UBI_LONGTERM, %UBI_SHORTTERM, |
650 | * %UBI_UNKNOWN) | 657 | * %UBI_UNKNOWN) |
651 | * @jhead: journal head the mutex belongs to (note, needed only to shut lockdep | 658 | * @jhead: journal head the mutex belongs to (note, needed only to shut lockdep |
@@ -680,6 +687,7 @@ struct ubifs_wbuf { | |||
680 | int offs; | 687 | int offs; |
681 | int avail; | 688 | int avail; |
682 | int used; | 689 | int used; |
690 | int size; | ||
683 | int dtype; | 691 | int dtype; |
684 | int jhead; | 692 | int jhead; |
685 | int (*sync_callback)(struct ubifs_info *c, int lnum, int free, int pad); | 693 | int (*sync_callback)(struct ubifs_info *c, int lnum, int free, int pad); |
@@ -1003,6 +1011,11 @@ struct ubifs_debug_info; | |||
1003 | * @bu_mutex: protects the pre-allocated bulk-read buffer and @c->bu | 1011 | * @bu_mutex: protects the pre-allocated bulk-read buffer and @c->bu |
1004 | * @bu: pre-allocated bulk-read information | 1012 | * @bu: pre-allocated bulk-read information |
1005 | * | 1013 | * |
1014 | * @write_reserve_mutex: protects @write_reserve_buf | ||
1015 | * @write_reserve_buf: on the write path we allocate memory, which might | ||
1016 | * sometimes be unavailable, in which case we use this | ||
1017 | * write reserve buffer | ||
1018 | * | ||
1006 | * @log_lebs: number of logical eraseblocks in the log | 1019 | * @log_lebs: number of logical eraseblocks in the log |
1007 | * @log_bytes: log size in bytes | 1020 | * @log_bytes: log size in bytes |
1008 | * @log_last: last LEB of the log | 1021 | * @log_last: last LEB of the log |
@@ -1024,7 +1037,12 @@ struct ubifs_debug_info; | |||
1024 | * | 1037 | * |
1025 | * @min_io_size: minimal input/output unit size | 1038 | * @min_io_size: minimal input/output unit size |
1026 | * @min_io_shift: number of bits in @min_io_size minus one | 1039 | * @min_io_shift: number of bits in @min_io_size minus one |
1040 | * @max_write_size: maximum amount of bytes the underlying flash can write at a | ||
1041 | * time (MTD write buffer size) | ||
1042 | * @max_write_shift: number of bits in @max_write_size minus one | ||
1027 | * @leb_size: logical eraseblock size in bytes | 1043 | * @leb_size: logical eraseblock size in bytes |
1044 | * @leb_start: starting offset of logical eraseblocks within physical | ||
1045 | * eraseblocks | ||
1028 | * @half_leb_size: half LEB size | 1046 | * @half_leb_size: half LEB size |
1029 | * @idx_leb_size: how many bytes of an LEB are effectively available when it is | 1047 | * @idx_leb_size: how many bytes of an LEB are effectively available when it is |
1030 | * used to store indexing nodes (@leb_size - @max_idx_node_sz) | 1048 | * used to store indexing nodes (@leb_size - @max_idx_node_sz) |
@@ -1166,22 +1184,21 @@ struct ubifs_debug_info; | |||
1166 | * @rp_uid: reserved pool user ID | 1184 | * @rp_uid: reserved pool user ID |
1167 | * @rp_gid: reserved pool group ID | 1185 | * @rp_gid: reserved pool group ID |
1168 | * | 1186 | * |
1169 | * @empty: if the UBI device is empty | 1187 | * @empty: %1 if the UBI device is empty |
1188 | * @need_recovery: %1 if the file-system needs recovery | ||
1189 | * @replaying: %1 during journal replay | ||
1190 | * @mounting: %1 while mounting | ||
1191 | * @remounting_rw: %1 while re-mounting from R/O mode to R/W mode | ||
1170 | * @replay_tree: temporary tree used during journal replay | 1192 | * @replay_tree: temporary tree used during journal replay |
1171 | * @replay_list: temporary list used during journal replay | 1193 | * @replay_list: temporary list used during journal replay |
1172 | * @replay_buds: list of buds to replay | 1194 | * @replay_buds: list of buds to replay |
1173 | * @cs_sqnum: sequence number of first node in the log (commit start node) | 1195 | * @cs_sqnum: sequence number of first node in the log (commit start node) |
1174 | * @replay_sqnum: sequence number of node currently being replayed | 1196 | * @replay_sqnum: sequence number of node currently being replayed |
1175 | * @need_recovery: file-system needs recovery | ||
1176 | * @replaying: set to %1 during journal replay | ||
1177 | * @unclean_leb_list: LEBs to recover when re-mounting R/O mounted FS to R/W | 1197 | * @unclean_leb_list: LEBs to recover when re-mounting R/O mounted FS to R/W |
1178 | * mode | 1198 | * mode |
1179 | * @rcvrd_mst_node: recovered master node to write when re-mounting R/O mounted | 1199 | * @rcvrd_mst_node: recovered master node to write when re-mounting R/O mounted |
1180 | * FS to R/W mode | 1200 | * FS to R/W mode |
1181 | * @size_tree: inode size information for recovery | 1201 | * @size_tree: inode size information for recovery |
1182 | * @remounting_rw: set while re-mounting from R/O mode to R/W mode | ||
1183 | * @always_chk_crc: always check CRCs (while mounting and remounting to R/W | ||
1184 | * mode) | ||
1185 | * @mount_opts: UBIFS-specific mount options | 1202 | * @mount_opts: UBIFS-specific mount options |
1186 | * | 1203 | * |
1187 | * @dbg: debugging-related information | 1204 | * @dbg: debugging-related information |
@@ -1250,6 +1267,9 @@ struct ubifs_info { | |||
1250 | struct mutex bu_mutex; | 1267 | struct mutex bu_mutex; |
1251 | struct bu_info bu; | 1268 | struct bu_info bu; |
1252 | 1269 | ||
1270 | struct mutex write_reserve_mutex; | ||
1271 | void *write_reserve_buf; | ||
1272 | |||
1253 | int log_lebs; | 1273 | int log_lebs; |
1254 | long long log_bytes; | 1274 | long long log_bytes; |
1255 | int log_last; | 1275 | int log_last; |
@@ -1271,7 +1291,10 @@ struct ubifs_info { | |||
1271 | 1291 | ||
1272 | int min_io_size; | 1292 | int min_io_size; |
1273 | int min_io_shift; | 1293 | int min_io_shift; |
1294 | int max_write_size; | ||
1295 | int max_write_shift; | ||
1274 | int leb_size; | 1296 | int leb_size; |
1297 | int leb_start; | ||
1275 | int half_leb_size; | 1298 | int half_leb_size; |
1276 | int idx_leb_size; | 1299 | int idx_leb_size; |
1277 | int leb_cnt; | 1300 | int leb_cnt; |
@@ -1402,19 +1425,19 @@ struct ubifs_info { | |||
1402 | gid_t rp_gid; | 1425 | gid_t rp_gid; |
1403 | 1426 | ||
1404 | /* The below fields are used only during mounting and re-mounting */ | 1427 | /* The below fields are used only during mounting and re-mounting */ |
1405 | int empty; | 1428 | unsigned int empty:1; |
1429 | unsigned int need_recovery:1; | ||
1430 | unsigned int replaying:1; | ||
1431 | unsigned int mounting:1; | ||
1432 | unsigned int remounting_rw:1; | ||
1406 | struct rb_root replay_tree; | 1433 | struct rb_root replay_tree; |
1407 | struct list_head replay_list; | 1434 | struct list_head replay_list; |
1408 | struct list_head replay_buds; | 1435 | struct list_head replay_buds; |
1409 | unsigned long long cs_sqnum; | 1436 | unsigned long long cs_sqnum; |
1410 | unsigned long long replay_sqnum; | 1437 | unsigned long long replay_sqnum; |
1411 | int need_recovery; | ||
1412 | int replaying; | ||
1413 | struct list_head unclean_leb_list; | 1438 | struct list_head unclean_leb_list; |
1414 | struct ubifs_mst_node *rcvrd_mst_node; | 1439 | struct ubifs_mst_node *rcvrd_mst_node; |
1415 | struct rb_root size_tree; | 1440 | struct rb_root size_tree; |
1416 | int remounting_rw; | ||
1417 | int always_chk_crc; | ||
1418 | struct ubifs_mount_opts mount_opts; | 1441 | struct ubifs_mount_opts mount_opts; |
1419 | 1442 | ||
1420 | #ifdef CONFIG_UBIFS_FS_DEBUG | 1443 | #ifdef CONFIG_UBIFS_FS_DEBUG |
diff --git a/fs/udf/balloc.c b/fs/udf/balloc.c index 8994dd041660..95518a9f589e 100644 --- a/fs/udf/balloc.c +++ b/fs/udf/balloc.c | |||
@@ -27,11 +27,10 @@ | |||
27 | #include "udf_i.h" | 27 | #include "udf_i.h" |
28 | #include "udf_sb.h" | 28 | #include "udf_sb.h" |
29 | 29 | ||
30 | #define udf_clear_bit(nr, addr) ext2_clear_bit(nr, addr) | 30 | #define udf_clear_bit __test_and_clear_bit_le |
31 | #define udf_set_bit(nr, addr) ext2_set_bit(nr, addr) | 31 | #define udf_set_bit __test_and_set_bit_le |
32 | #define udf_test_bit(nr, addr) ext2_test_bit(nr, addr) | 32 | #define udf_test_bit test_bit_le |
33 | #define udf_find_next_one_bit(addr, size, offset) \ | 33 | #define udf_find_next_one_bit find_next_bit_le |
34 | ext2_find_next_bit((unsigned long *)(addr), size, offset) | ||
35 | 34 | ||
36 | static int read_block_bitmap(struct super_block *sb, | 35 | static int read_block_bitmap(struct super_block *sb, |
37 | struct udf_bitmap *bitmap, unsigned int block, | 36 | struct udf_bitmap *bitmap, unsigned int block, |
diff --git a/fs/ufs/util.h b/fs/ufs/util.h index 9f8775ce381c..954175928240 100644 --- a/fs/ufs/util.h +++ b/fs/ufs/util.h | |||
@@ -408,7 +408,7 @@ static inline unsigned _ubh_find_next_zero_bit_( | |||
408 | for (;;) { | 408 | for (;;) { |
409 | count = min_t(unsigned int, size + offset, uspi->s_bpf); | 409 | count = min_t(unsigned int, size + offset, uspi->s_bpf); |
410 | size -= count - offset; | 410 | size -= count - offset; |
411 | pos = ext2_find_next_zero_bit (ubh->bh[base]->b_data, count, offset); | 411 | pos = find_next_zero_bit_le(ubh->bh[base]->b_data, count, offset); |
412 | if (pos < count || !size) | 412 | if (pos < count || !size) |
413 | break; | 413 | break; |
414 | base++; | 414 | base++; |
diff --git a/fs/utimes.c b/fs/utimes.c index 179b58690657..ba653f3dc1bc 100644 --- a/fs/utimes.c +++ b/fs/utimes.c | |||
@@ -95,7 +95,7 @@ static int utimes_common(struct path *path, struct timespec *times) | |||
95 | if (IS_IMMUTABLE(inode)) | 95 | if (IS_IMMUTABLE(inode)) |
96 | goto mnt_drop_write_and_out; | 96 | goto mnt_drop_write_and_out; |
97 | 97 | ||
98 | if (!is_owner_or_cap(inode)) { | 98 | if (!inode_owner_or_capable(inode)) { |
99 | error = inode_permission(inode, MAY_WRITE); | 99 | error = inode_permission(inode, MAY_WRITE); |
100 | if (error) | 100 | if (error) |
101 | goto mnt_drop_write_and_out; | 101 | goto mnt_drop_write_and_out; |
diff --git a/fs/xattr.c b/fs/xattr.c index 01bb8135e14a..a19acdb81cd1 100644 --- a/fs/xattr.c +++ b/fs/xattr.c | |||
@@ -59,7 +59,7 @@ xattr_permission(struct inode *inode, const char *name, int mask) | |||
59 | if (!S_ISREG(inode->i_mode) && !S_ISDIR(inode->i_mode)) | 59 | if (!S_ISREG(inode->i_mode) && !S_ISDIR(inode->i_mode)) |
60 | return -EPERM; | 60 | return -EPERM; |
61 | if (S_ISDIR(inode->i_mode) && (inode->i_mode & S_ISVTX) && | 61 | if (S_ISDIR(inode->i_mode) && (inode->i_mode & S_ISVTX) && |
62 | (mask & MAY_WRITE) && !is_owner_or_cap(inode)) | 62 | (mask & MAY_WRITE) && !inode_owner_or_capable(inode)) |
63 | return -EPERM; | 63 | return -EPERM; |
64 | } | 64 | } |
65 | 65 | ||
diff --git a/fs/xfs/Makefile b/fs/xfs/Makefile index faca44997099..284a7c89697e 100644 --- a/fs/xfs/Makefile +++ b/fs/xfs/Makefile | |||
@@ -16,14 +16,11 @@ | |||
16 | # Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA | 16 | # Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
17 | # | 17 | # |
18 | 18 | ||
19 | EXTRA_CFLAGS += -I$(src) -I$(src)/linux-2.6 | 19 | ccflags-y := -I$(src) -I$(src)/linux-2.6 |
20 | ccflags-$(CONFIG_XFS_DEBUG) += -g | ||
20 | 21 | ||
21 | XFS_LINUX := linux-2.6 | 22 | XFS_LINUX := linux-2.6 |
22 | 23 | ||
23 | ifeq ($(CONFIG_XFS_DEBUG),y) | ||
24 | EXTRA_CFLAGS += -g | ||
25 | endif | ||
26 | |||
27 | obj-$(CONFIG_XFS_FS) += xfs.o | 24 | obj-$(CONFIG_XFS_FS) += xfs.o |
28 | 25 | ||
29 | xfs-y += linux-2.6/xfs_trace.o | 26 | xfs-y += linux-2.6/xfs_trace.o |
@@ -105,11 +102,10 @@ xfs-y += $(addprefix $(XFS_LINUX)/, \ | |||
105 | xfs_globals.o \ | 102 | xfs_globals.o \ |
106 | xfs_ioctl.o \ | 103 | xfs_ioctl.o \ |
107 | xfs_iops.o \ | 104 | xfs_iops.o \ |
105 | xfs_message.o \ | ||
108 | xfs_super.o \ | 106 | xfs_super.o \ |
109 | xfs_sync.o \ | 107 | xfs_sync.o \ |
110 | xfs_xattr.o) | 108 | xfs_xattr.o) |
111 | 109 | ||
112 | # Objects in support/ | 110 | # Objects in support/ |
113 | xfs-y += $(addprefix support/, \ | 111 | xfs-y += support/uuid.o |
114 | debug.o \ | ||
115 | uuid.o) | ||
diff --git a/fs/xfs/linux-2.6/kmem.c b/fs/xfs/linux-2.6/kmem.c index 666c9db48eb6..a907de565db3 100644 --- a/fs/xfs/linux-2.6/kmem.c +++ b/fs/xfs/linux-2.6/kmem.c | |||
@@ -23,6 +23,7 @@ | |||
23 | #include <linux/backing-dev.h> | 23 | #include <linux/backing-dev.h> |
24 | #include "time.h" | 24 | #include "time.h" |
25 | #include "kmem.h" | 25 | #include "kmem.h" |
26 | #include "xfs_message.h" | ||
26 | 27 | ||
27 | /* | 28 | /* |
28 | * Greedy allocation. May fail and may return vmalloced memory. | 29 | * Greedy allocation. May fail and may return vmalloced memory. |
@@ -56,8 +57,8 @@ kmem_alloc(size_t size, unsigned int __nocast flags) | |||
56 | if (ptr || (flags & (KM_MAYFAIL|KM_NOSLEEP))) | 57 | if (ptr || (flags & (KM_MAYFAIL|KM_NOSLEEP))) |
57 | return ptr; | 58 | return ptr; |
58 | if (!(++retries % 100)) | 59 | if (!(++retries % 100)) |
59 | printk(KERN_ERR "XFS: possible memory allocation " | 60 | xfs_err(NULL, |
60 | "deadlock in %s (mode:0x%x)\n", | 61 | "possible memory allocation deadlock in %s (mode:0x%x)", |
61 | __func__, lflags); | 62 | __func__, lflags); |
62 | congestion_wait(BLK_RW_ASYNC, HZ/50); | 63 | congestion_wait(BLK_RW_ASYNC, HZ/50); |
63 | } while (1); | 64 | } while (1); |
@@ -112,8 +113,8 @@ kmem_zone_alloc(kmem_zone_t *zone, unsigned int __nocast flags) | |||
112 | if (ptr || (flags & (KM_MAYFAIL|KM_NOSLEEP))) | 113 | if (ptr || (flags & (KM_MAYFAIL|KM_NOSLEEP))) |
113 | return ptr; | 114 | return ptr; |
114 | if (!(++retries % 100)) | 115 | if (!(++retries % 100)) |
115 | printk(KERN_ERR "XFS: possible memory allocation " | 116 | xfs_err(NULL, |
116 | "deadlock in %s (mode:0x%x)\n", | 117 | "possible memory allocation deadlock in %s (mode:0x%x)", |
117 | __func__, lflags); | 118 | __func__, lflags); |
118 | congestion_wait(BLK_RW_ASYNC, HZ/50); | 119 | congestion_wait(BLK_RW_ASYNC, HZ/50); |
119 | } while (1); | 120 | } while (1); |
diff --git a/fs/xfs/linux-2.6/xfs_aops.c b/fs/xfs/linux-2.6/xfs_aops.c index ec7bbb5645b6..8c5c87277456 100644 --- a/fs/xfs/linux-2.6/xfs_aops.c +++ b/fs/xfs/linux-2.6/xfs_aops.c | |||
@@ -854,7 +854,7 @@ xfs_aops_discard_page( | |||
854 | if (XFS_FORCED_SHUTDOWN(ip->i_mount)) | 854 | if (XFS_FORCED_SHUTDOWN(ip->i_mount)) |
855 | goto out_invalidate; | 855 | goto out_invalidate; |
856 | 856 | ||
857 | xfs_fs_cmn_err(CE_ALERT, ip->i_mount, | 857 | xfs_alert(ip->i_mount, |
858 | "page discard on page %p, inode 0x%llx, offset %llu.", | 858 | "page discard on page %p, inode 0x%llx, offset %llu.", |
859 | page, ip->i_ino, offset); | 859 | page, ip->i_ino, offset); |
860 | 860 | ||
@@ -872,7 +872,7 @@ xfs_aops_discard_page( | |||
872 | if (error) { | 872 | if (error) { |
873 | /* something screwed, just bail */ | 873 | /* something screwed, just bail */ |
874 | if (!XFS_FORCED_SHUTDOWN(ip->i_mount)) { | 874 | if (!XFS_FORCED_SHUTDOWN(ip->i_mount)) { |
875 | xfs_fs_cmn_err(CE_ALERT, ip->i_mount, | 875 | xfs_alert(ip->i_mount, |
876 | "page discard unable to remove delalloc mapping."); | 876 | "page discard unable to remove delalloc mapping."); |
877 | } | 877 | } |
878 | break; | 878 | break; |
@@ -1411,7 +1411,7 @@ xfs_vm_write_failed( | |||
1411 | if (error) { | 1411 | if (error) { |
1412 | /* something screwed, just bail */ | 1412 | /* something screwed, just bail */ |
1413 | if (!XFS_FORCED_SHUTDOWN(ip->i_mount)) { | 1413 | if (!XFS_FORCED_SHUTDOWN(ip->i_mount)) { |
1414 | xfs_fs_cmn_err(CE_ALERT, ip->i_mount, | 1414 | xfs_alert(ip->i_mount, |
1415 | "xfs_vm_write_failed: unable to clean up ino %lld", | 1415 | "xfs_vm_write_failed: unable to clean up ino %lld", |
1416 | ip->i_ino); | 1416 | ip->i_ino); |
1417 | } | 1417 | } |
diff --git a/fs/xfs/linux-2.6/xfs_buf.c b/fs/xfs/linux-2.6/xfs_buf.c index f83a4c830a65..5cb230f2cb4f 100644 --- a/fs/xfs/linux-2.6/xfs_buf.c +++ b/fs/xfs/linux-2.6/xfs_buf.c | |||
@@ -401,9 +401,8 @@ _xfs_buf_lookup_pages( | |||
401 | * handle buffer allocation failures we can't do much. | 401 | * handle buffer allocation failures we can't do much. |
402 | */ | 402 | */ |
403 | if (!(++retries % 100)) | 403 | if (!(++retries % 100)) |
404 | printk(KERN_ERR | 404 | xfs_err(NULL, |
405 | "XFS: possible memory allocation " | 405 | "possible memory allocation deadlock in %s (mode:0x%x)", |
406 | "deadlock in %s (mode:0x%x)\n", | ||
407 | __func__, gfp_mask); | 406 | __func__, gfp_mask); |
408 | 407 | ||
409 | XFS_STATS_INC(xb_page_retries); | 408 | XFS_STATS_INC(xb_page_retries); |
@@ -615,8 +614,8 @@ xfs_buf_get( | |||
615 | if (!(bp->b_flags & XBF_MAPPED)) { | 614 | if (!(bp->b_flags & XBF_MAPPED)) { |
616 | error = _xfs_buf_map_pages(bp, flags); | 615 | error = _xfs_buf_map_pages(bp, flags); |
617 | if (unlikely(error)) { | 616 | if (unlikely(error)) { |
618 | printk(KERN_WARNING "%s: failed to map pages\n", | 617 | xfs_warn(target->bt_mount, |
619 | __func__); | 618 | "%s: failed to map pages\n", __func__); |
620 | goto no_buffer; | 619 | goto no_buffer; |
621 | } | 620 | } |
622 | } | 621 | } |
@@ -850,8 +849,8 @@ xfs_buf_get_uncached( | |||
850 | 849 | ||
851 | error = _xfs_buf_map_pages(bp, XBF_MAPPED); | 850 | error = _xfs_buf_map_pages(bp, XBF_MAPPED); |
852 | if (unlikely(error)) { | 851 | if (unlikely(error)) { |
853 | printk(KERN_WARNING "%s: failed to map pages\n", | 852 | xfs_warn(target->bt_mount, |
854 | __func__); | 853 | "%s: failed to map pages\n", __func__); |
855 | goto fail_free_mem; | 854 | goto fail_free_mem; |
856 | } | 855 | } |
857 | 856 | ||
@@ -1617,8 +1616,8 @@ xfs_setsize_buftarg_flags( | |||
1617 | btp->bt_smask = sectorsize - 1; | 1616 | btp->bt_smask = sectorsize - 1; |
1618 | 1617 | ||
1619 | if (set_blocksize(btp->bt_bdev, sectorsize)) { | 1618 | if (set_blocksize(btp->bt_bdev, sectorsize)) { |
1620 | printk(KERN_WARNING | 1619 | xfs_warn(btp->bt_mount, |
1621 | "XFS: Cannot set_blocksize to %u on device %s\n", | 1620 | "Cannot set_blocksize to %u on device %s\n", |
1622 | sectorsize, XFS_BUFTARG_NAME(btp)); | 1621 | sectorsize, XFS_BUFTARG_NAME(btp)); |
1623 | return EINVAL; | 1622 | return EINVAL; |
1624 | } | 1623 | } |
diff --git a/fs/xfs/linux-2.6/xfs_linux.h b/fs/xfs/linux-2.6/xfs_linux.h index 096494997747..244be9cbfe78 100644 --- a/fs/xfs/linux-2.6/xfs_linux.h +++ b/fs/xfs/linux-2.6/xfs_linux.h | |||
@@ -39,7 +39,6 @@ | |||
39 | #include <mrlock.h> | 39 | #include <mrlock.h> |
40 | #include <time.h> | 40 | #include <time.h> |
41 | 41 | ||
42 | #include <support/debug.h> | ||
43 | #include <support/uuid.h> | 42 | #include <support/uuid.h> |
44 | 43 | ||
45 | #include <linux/semaphore.h> | 44 | #include <linux/semaphore.h> |
@@ -86,6 +85,7 @@ | |||
86 | #include <xfs_aops.h> | 85 | #include <xfs_aops.h> |
87 | #include <xfs_super.h> | 86 | #include <xfs_super.h> |
88 | #include <xfs_buf.h> | 87 | #include <xfs_buf.h> |
88 | #include <xfs_message.h> | ||
89 | 89 | ||
90 | /* | 90 | /* |
91 | * Feature macros (disable/enable) | 91 | * Feature macros (disable/enable) |
@@ -280,4 +280,25 @@ static inline __uint64_t howmany_64(__uint64_t x, __uint32_t y) | |||
280 | #define __arch_pack | 280 | #define __arch_pack |
281 | #endif | 281 | #endif |
282 | 282 | ||
283 | #define ASSERT_ALWAYS(expr) \ | ||
284 | (unlikely(expr) ? (void)0 : assfail(#expr, __FILE__, __LINE__)) | ||
285 | |||
286 | #ifndef DEBUG | ||
287 | #define ASSERT(expr) ((void)0) | ||
288 | |||
289 | #ifndef STATIC | ||
290 | # define STATIC static noinline | ||
291 | #endif | ||
292 | |||
293 | #else /* DEBUG */ | ||
294 | |||
295 | #define ASSERT(expr) \ | ||
296 | (unlikely(expr) ? (void)0 : assfail(#expr, __FILE__, __LINE__)) | ||
297 | |||
298 | #ifndef STATIC | ||
299 | # define STATIC noinline | ||
300 | #endif | ||
301 | |||
302 | #endif /* DEBUG */ | ||
303 | |||
283 | #endif /* __XFS_LINUX__ */ | 304 | #endif /* __XFS_LINUX__ */ |
diff --git a/fs/xfs/linux-2.6/xfs_message.c b/fs/xfs/linux-2.6/xfs_message.c new file mode 100644 index 000000000000..508e06fd7d1e --- /dev/null +++ b/fs/xfs/linux-2.6/xfs_message.c | |||
@@ -0,0 +1,133 @@ | |||
1 | /* | ||
2 | * Copyright (c) 2011 Red Hat, Inc. All Rights Reserved. | ||
3 | * | ||
4 | * This program is free software; you can redistribute it and/or | ||
5 | * modify it under the terms of the GNU General Public License as | ||
6 | * published by the Free Software Foundation. | ||
7 | * | ||
8 | * This program is distributed in the hope that it would be useful, | ||
9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
11 | * GNU General Public License for more details. | ||
12 | * | ||
13 | * You should have received a copy of the GNU General Public License | ||
14 | * along with this program; if not, write the Free Software Foundation, | ||
15 | * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA | ||
16 | */ | ||
17 | |||
18 | #include "xfs.h" | ||
19 | #include "xfs_fs.h" | ||
20 | #include "xfs_types.h" | ||
21 | #include "xfs_log.h" | ||
22 | #include "xfs_inum.h" | ||
23 | #include "xfs_trans.h" | ||
24 | #include "xfs_sb.h" | ||
25 | #include "xfs_ag.h" | ||
26 | #include "xfs_mount.h" | ||
27 | |||
28 | /* | ||
29 | * XFS logging functions | ||
30 | */ | ||
31 | static int | ||
32 | __xfs_printk( | ||
33 | const char *level, | ||
34 | const struct xfs_mount *mp, | ||
35 | struct va_format *vaf) | ||
36 | { | ||
37 | if (mp && mp->m_fsname) | ||
38 | return printk("%sXFS (%s): %pV\n", level, mp->m_fsname, vaf); | ||
39 | return printk("%sXFS: %pV\n", level, vaf); | ||
40 | } | ||
41 | |||
42 | int xfs_printk( | ||
43 | const char *level, | ||
44 | const struct xfs_mount *mp, | ||
45 | const char *fmt, ...) | ||
46 | { | ||
47 | struct va_format vaf; | ||
48 | va_list args; | ||
49 | int r; | ||
50 | |||
51 | va_start(args, fmt); | ||
52 | |||
53 | vaf.fmt = fmt; | ||
54 | vaf.va = &args; | ||
55 | |||
56 | r = __xfs_printk(level, mp, &vaf); | ||
57 | va_end(args); | ||
58 | |||
59 | return r; | ||
60 | } | ||
61 | |||
62 | #define define_xfs_printk_level(func, kern_level) \ | ||
63 | int func(const struct xfs_mount *mp, const char *fmt, ...) \ | ||
64 | { \ | ||
65 | struct va_format vaf; \ | ||
66 | va_list args; \ | ||
67 | int r; \ | ||
68 | \ | ||
69 | va_start(args, fmt); \ | ||
70 | \ | ||
71 | vaf.fmt = fmt; \ | ||
72 | vaf.va = &args; \ | ||
73 | \ | ||
74 | r = __xfs_printk(kern_level, mp, &vaf); \ | ||
75 | va_end(args); \ | ||
76 | \ | ||
77 | return r; \ | ||
78 | } \ | ||
79 | |||
80 | define_xfs_printk_level(xfs_emerg, KERN_EMERG); | ||
81 | define_xfs_printk_level(xfs_alert, KERN_ALERT); | ||
82 | define_xfs_printk_level(xfs_crit, KERN_CRIT); | ||
83 | define_xfs_printk_level(xfs_err, KERN_ERR); | ||
84 | define_xfs_printk_level(xfs_warn, KERN_WARNING); | ||
85 | define_xfs_printk_level(xfs_notice, KERN_NOTICE); | ||
86 | define_xfs_printk_level(xfs_info, KERN_INFO); | ||
87 | #ifdef DEBUG | ||
88 | define_xfs_printk_level(xfs_debug, KERN_DEBUG); | ||
89 | #endif | ||
90 | |||
91 | int | ||
92 | xfs_alert_tag( | ||
93 | const struct xfs_mount *mp, | ||
94 | int panic_tag, | ||
95 | const char *fmt, ...) | ||
96 | { | ||
97 | struct va_format vaf; | ||
98 | va_list args; | ||
99 | int do_panic = 0; | ||
100 | int r; | ||
101 | |||
102 | if (xfs_panic_mask && (xfs_panic_mask & panic_tag)) { | ||
103 | xfs_printk(KERN_ALERT, mp, | ||
104 | "XFS: Transforming an alert into a BUG."); | ||
105 | do_panic = 1; | ||
106 | } | ||
107 | |||
108 | va_start(args, fmt); | ||
109 | |||
110 | vaf.fmt = fmt; | ||
111 | vaf.va = &args; | ||
112 | |||
113 | r = __xfs_printk(KERN_ALERT, mp, &vaf); | ||
114 | va_end(args); | ||
115 | |||
116 | BUG_ON(do_panic); | ||
117 | |||
118 | return r; | ||
119 | } | ||
120 | |||
121 | void | ||
122 | assfail(char *expr, char *file, int line) | ||
123 | { | ||
124 | xfs_emerg(NULL, "Assertion failed: %s, file: %s, line: %d", | ||
125 | expr, file, line); | ||
126 | BUG(); | ||
127 | } | ||
128 | |||
129 | void | ||
130 | xfs_hex_dump(void *p, int length) | ||
131 | { | ||
132 | print_hex_dump(KERN_ALERT, "", DUMP_PREFIX_ADDRESS, 16, 1, p, length, 1); | ||
133 | } | ||
diff --git a/fs/xfs/linux-2.6/xfs_message.h b/fs/xfs/linux-2.6/xfs_message.h new file mode 100644 index 000000000000..e77ffa16745b --- /dev/null +++ b/fs/xfs/linux-2.6/xfs_message.h | |||
@@ -0,0 +1,38 @@ | |||
1 | #ifndef __XFS_MESSAGE_H | ||
2 | #define __XFS_MESSAGE_H 1 | ||
3 | |||
4 | struct xfs_mount; | ||
5 | |||
6 | extern int xfs_printk(const char *level, const struct xfs_mount *mp, | ||
7 | const char *fmt, ...) | ||
8 | __attribute__ ((format (printf, 3, 4))); | ||
9 | extern int xfs_emerg(const struct xfs_mount *mp, const char *fmt, ...) | ||
10 | __attribute__ ((format (printf, 2, 3))); | ||
11 | extern int xfs_alert(const struct xfs_mount *mp, const char *fmt, ...) | ||
12 | __attribute__ ((format (printf, 2, 3))); | ||
13 | extern int xfs_alert_tag(const struct xfs_mount *mp, int tag, | ||
14 | const char *fmt, ...) | ||
15 | __attribute__ ((format (printf, 3, 4))); | ||
16 | extern int xfs_crit(const struct xfs_mount *mp, const char *fmt, ...) | ||
17 | __attribute__ ((format (printf, 2, 3))); | ||
18 | extern int xfs_err(const struct xfs_mount *mp, const char *fmt, ...) | ||
19 | __attribute__ ((format (printf, 2, 3))); | ||
20 | extern int xfs_warn(const struct xfs_mount *mp, const char *fmt, ...) | ||
21 | __attribute__ ((format (printf, 2, 3))); | ||
22 | extern int xfs_notice(const struct xfs_mount *mp, const char *fmt, ...) | ||
23 | __attribute__ ((format (printf, 2, 3))); | ||
24 | extern int xfs_info(const struct xfs_mount *mp, const char *fmt, ...) | ||
25 | __attribute__ ((format (printf, 2, 3))); | ||
26 | |||
27 | #ifdef DEBUG | ||
28 | extern int xfs_debug(const struct xfs_mount *mp, const char *fmt, ...) | ||
29 | __attribute__ ((format (printf, 2, 3))); | ||
30 | #else | ||
31 | #define xfs_debug(mp, fmt, ...) (0) | ||
32 | #endif | ||
33 | |||
34 | extern void assfail(char *expr, char *f, int l); | ||
35 | |||
36 | extern void xfs_hex_dump(void *p, int length); | ||
37 | |||
38 | #endif /* __XFS_MESSAGE_H */ | ||
diff --git a/fs/xfs/linux-2.6/xfs_super.c b/fs/xfs/linux-2.6/xfs_super.c index 9731898083ae..818c4cf2de86 100644 --- a/fs/xfs/linux-2.6/xfs_super.c +++ b/fs/xfs/linux-2.6/xfs_super.c | |||
@@ -173,6 +173,15 @@ xfs_parseargs( | |||
173 | __uint8_t iosizelog = 0; | 173 | __uint8_t iosizelog = 0; |
174 | 174 | ||
175 | /* | 175 | /* |
176 | * set up the mount name first so all the errors will refer to the | ||
177 | * correct device. | ||
178 | */ | ||
179 | mp->m_fsname = kstrndup(sb->s_id, MAXNAMELEN, GFP_KERNEL); | ||
180 | if (!mp->m_fsname) | ||
181 | return ENOMEM; | ||
182 | mp->m_fsname_len = strlen(mp->m_fsname) + 1; | ||
183 | |||
184 | /* | ||
176 | * Copy binary VFS mount flags we are interested in. | 185 | * Copy binary VFS mount flags we are interested in. |
177 | */ | 186 | */ |
178 | if (sb->s_flags & MS_RDONLY) | 187 | if (sb->s_flags & MS_RDONLY) |
@@ -189,6 +198,7 @@ xfs_parseargs( | |||
189 | mp->m_flags |= XFS_MOUNT_BARRIER; | 198 | mp->m_flags |= XFS_MOUNT_BARRIER; |
190 | mp->m_flags |= XFS_MOUNT_COMPAT_IOSIZE; | 199 | mp->m_flags |= XFS_MOUNT_COMPAT_IOSIZE; |
191 | mp->m_flags |= XFS_MOUNT_SMALL_INUMS; | 200 | mp->m_flags |= XFS_MOUNT_SMALL_INUMS; |
201 | mp->m_flags |= XFS_MOUNT_DELAYLOG; | ||
192 | 202 | ||
193 | /* | 203 | /* |
194 | * These can be overridden by the mount option parsing. | 204 | * These can be overridden by the mount option parsing. |
@@ -207,24 +217,21 @@ xfs_parseargs( | |||
207 | 217 | ||
208 | if (!strcmp(this_char, MNTOPT_LOGBUFS)) { | 218 | if (!strcmp(this_char, MNTOPT_LOGBUFS)) { |
209 | if (!value || !*value) { | 219 | if (!value || !*value) { |
210 | cmn_err(CE_WARN, | 220 | xfs_warn(mp, "%s option requires an argument", |
211 | "XFS: %s option requires an argument", | ||
212 | this_char); | 221 | this_char); |
213 | return EINVAL; | 222 | return EINVAL; |
214 | } | 223 | } |
215 | mp->m_logbufs = simple_strtoul(value, &eov, 10); | 224 | mp->m_logbufs = simple_strtoul(value, &eov, 10); |
216 | } else if (!strcmp(this_char, MNTOPT_LOGBSIZE)) { | 225 | } else if (!strcmp(this_char, MNTOPT_LOGBSIZE)) { |
217 | if (!value || !*value) { | 226 | if (!value || !*value) { |
218 | cmn_err(CE_WARN, | 227 | xfs_warn(mp, "%s option requires an argument", |
219 | "XFS: %s option requires an argument", | ||
220 | this_char); | 228 | this_char); |
221 | return EINVAL; | 229 | return EINVAL; |
222 | } | 230 | } |
223 | mp->m_logbsize = suffix_strtoul(value, &eov, 10); | 231 | mp->m_logbsize = suffix_strtoul(value, &eov, 10); |
224 | } else if (!strcmp(this_char, MNTOPT_LOGDEV)) { | 232 | } else if (!strcmp(this_char, MNTOPT_LOGDEV)) { |
225 | if (!value || !*value) { | 233 | if (!value || !*value) { |
226 | cmn_err(CE_WARN, | 234 | xfs_warn(mp, "%s option requires an argument", |
227 | "XFS: %s option requires an argument", | ||
228 | this_char); | 235 | this_char); |
229 | return EINVAL; | 236 | return EINVAL; |
230 | } | 237 | } |
@@ -232,14 +239,12 @@ xfs_parseargs( | |||
232 | if (!mp->m_logname) | 239 | if (!mp->m_logname) |
233 | return ENOMEM; | 240 | return ENOMEM; |
234 | } else if (!strcmp(this_char, MNTOPT_MTPT)) { | 241 | } else if (!strcmp(this_char, MNTOPT_MTPT)) { |
235 | cmn_err(CE_WARN, | 242 | xfs_warn(mp, "%s option not allowed on this system", |
236 | "XFS: %s option not allowed on this system", | ||
237 | this_char); | 243 | this_char); |
238 | return EINVAL; | 244 | return EINVAL; |
239 | } else if (!strcmp(this_char, MNTOPT_RTDEV)) { | 245 | } else if (!strcmp(this_char, MNTOPT_RTDEV)) { |
240 | if (!value || !*value) { | 246 | if (!value || !*value) { |
241 | cmn_err(CE_WARN, | 247 | xfs_warn(mp, "%s option requires an argument", |
242 | "XFS: %s option requires an argument", | ||
243 | this_char); | 248 | this_char); |
244 | return EINVAL; | 249 | return EINVAL; |
245 | } | 250 | } |
@@ -248,8 +253,7 @@ xfs_parseargs( | |||
248 | return ENOMEM; | 253 | return ENOMEM; |
249 | } else if (!strcmp(this_char, MNTOPT_BIOSIZE)) { | 254 | } else if (!strcmp(this_char, MNTOPT_BIOSIZE)) { |
250 | if (!value || !*value) { | 255 | if (!value || !*value) { |
251 | cmn_err(CE_WARN, | 256 | xfs_warn(mp, "%s option requires an argument", |
252 | "XFS: %s option requires an argument", | ||
253 | this_char); | 257 | this_char); |
254 | return EINVAL; | 258 | return EINVAL; |
255 | } | 259 | } |
@@ -257,8 +261,7 @@ xfs_parseargs( | |||
257 | iosizelog = ffs(iosize) - 1; | 261 | iosizelog = ffs(iosize) - 1; |
258 | } else if (!strcmp(this_char, MNTOPT_ALLOCSIZE)) { | 262 | } else if (!strcmp(this_char, MNTOPT_ALLOCSIZE)) { |
259 | if (!value || !*value) { | 263 | if (!value || !*value) { |
260 | cmn_err(CE_WARN, | 264 | xfs_warn(mp, "%s option requires an argument", |
261 | "XFS: %s option requires an argument", | ||
262 | this_char); | 265 | this_char); |
263 | return EINVAL; | 266 | return EINVAL; |
264 | } | 267 | } |
@@ -280,16 +283,14 @@ xfs_parseargs( | |||
280 | mp->m_flags |= XFS_MOUNT_SWALLOC; | 283 | mp->m_flags |= XFS_MOUNT_SWALLOC; |
281 | } else if (!strcmp(this_char, MNTOPT_SUNIT)) { | 284 | } else if (!strcmp(this_char, MNTOPT_SUNIT)) { |
282 | if (!value || !*value) { | 285 | if (!value || !*value) { |
283 | cmn_err(CE_WARN, | 286 | xfs_warn(mp, "%s option requires an argument", |
284 | "XFS: %s option requires an argument", | ||
285 | this_char); | 287 | this_char); |
286 | return EINVAL; | 288 | return EINVAL; |
287 | } | 289 | } |
288 | dsunit = simple_strtoul(value, &eov, 10); | 290 | dsunit = simple_strtoul(value, &eov, 10); |
289 | } else if (!strcmp(this_char, MNTOPT_SWIDTH)) { | 291 | } else if (!strcmp(this_char, MNTOPT_SWIDTH)) { |
290 | if (!value || !*value) { | 292 | if (!value || !*value) { |
291 | cmn_err(CE_WARN, | 293 | xfs_warn(mp, "%s option requires an argument", |
292 | "XFS: %s option requires an argument", | ||
293 | this_char); | 294 | this_char); |
294 | return EINVAL; | 295 | return EINVAL; |
295 | } | 296 | } |
@@ -297,8 +298,7 @@ xfs_parseargs( | |||
297 | } else if (!strcmp(this_char, MNTOPT_64BITINODE)) { | 298 | } else if (!strcmp(this_char, MNTOPT_64BITINODE)) { |
298 | mp->m_flags &= ~XFS_MOUNT_SMALL_INUMS; | 299 | mp->m_flags &= ~XFS_MOUNT_SMALL_INUMS; |
299 | #if !XFS_BIG_INUMS | 300 | #if !XFS_BIG_INUMS |
300 | cmn_err(CE_WARN, | 301 | xfs_warn(mp, "%s option not allowed on this system", |
301 | "XFS: %s option not allowed on this system", | ||
302 | this_char); | 302 | this_char); |
303 | return EINVAL; | 303 | return EINVAL; |
304 | #endif | 304 | #endif |
@@ -356,20 +356,19 @@ xfs_parseargs( | |||
356 | } else if (!strcmp(this_char, MNTOPT_NODELAYLOG)) { | 356 | } else if (!strcmp(this_char, MNTOPT_NODELAYLOG)) { |
357 | mp->m_flags &= ~XFS_MOUNT_DELAYLOG; | 357 | mp->m_flags &= ~XFS_MOUNT_DELAYLOG; |
358 | } else if (!strcmp(this_char, "ihashsize")) { | 358 | } else if (!strcmp(this_char, "ihashsize")) { |
359 | cmn_err(CE_WARN, | 359 | xfs_warn(mp, |
360 | "XFS: ihashsize no longer used, option is deprecated."); | 360 | "ihashsize no longer used, option is deprecated."); |
361 | } else if (!strcmp(this_char, "osyncisdsync")) { | 361 | } else if (!strcmp(this_char, "osyncisdsync")) { |
362 | cmn_err(CE_WARN, | 362 | xfs_warn(mp, |
363 | "XFS: osyncisdsync has no effect, option is deprecated."); | 363 | "osyncisdsync has no effect, option is deprecated."); |
364 | } else if (!strcmp(this_char, "osyncisosync")) { | 364 | } else if (!strcmp(this_char, "osyncisosync")) { |
365 | cmn_err(CE_WARN, | 365 | xfs_warn(mp, |
366 | "XFS: osyncisosync has no effect, option is deprecated."); | 366 | "osyncisosync has no effect, option is deprecated."); |
367 | } else if (!strcmp(this_char, "irixsgid")) { | 367 | } else if (!strcmp(this_char, "irixsgid")) { |
368 | cmn_err(CE_WARN, | 368 | xfs_warn(mp, |
369 | "XFS: irixsgid is now a sysctl(2) variable, option is deprecated."); | 369 | "irixsgid is now a sysctl(2) variable, option is deprecated."); |
370 | } else { | 370 | } else { |
371 | cmn_err(CE_WARN, | 371 | xfs_warn(mp, "unknown mount option [%s].", this_char); |
372 | "XFS: unknown mount option [%s].", this_char); | ||
373 | return EINVAL; | 372 | return EINVAL; |
374 | } | 373 | } |
375 | } | 374 | } |
@@ -379,40 +378,37 @@ xfs_parseargs( | |||
379 | */ | 378 | */ |
380 | if ((mp->m_flags & XFS_MOUNT_NORECOVERY) && | 379 | if ((mp->m_flags & XFS_MOUNT_NORECOVERY) && |
381 | !(mp->m_flags & XFS_MOUNT_RDONLY)) { | 380 | !(mp->m_flags & XFS_MOUNT_RDONLY)) { |
382 | cmn_err(CE_WARN, "XFS: no-recovery mounts must be read-only."); | 381 | xfs_warn(mp, "no-recovery mounts must be read-only."); |
383 | return EINVAL; | 382 | return EINVAL; |
384 | } | 383 | } |
385 | 384 | ||
386 | if ((mp->m_flags & XFS_MOUNT_NOALIGN) && (dsunit || dswidth)) { | 385 | if ((mp->m_flags & XFS_MOUNT_NOALIGN) && (dsunit || dswidth)) { |
387 | cmn_err(CE_WARN, | 386 | xfs_warn(mp, |
388 | "XFS: sunit and swidth options incompatible with the noalign option"); | 387 | "sunit and swidth options incompatible with the noalign option"); |
389 | return EINVAL; | 388 | return EINVAL; |
390 | } | 389 | } |
391 | 390 | ||
392 | #ifndef CONFIG_XFS_QUOTA | 391 | #ifndef CONFIG_XFS_QUOTA |
393 | if (XFS_IS_QUOTA_RUNNING(mp)) { | 392 | if (XFS_IS_QUOTA_RUNNING(mp)) { |
394 | cmn_err(CE_WARN, | 393 | xfs_warn(mp, "quota support not available in this kernel."); |
395 | "XFS: quota support not available in this kernel."); | ||
396 | return EINVAL; | 394 | return EINVAL; |
397 | } | 395 | } |
398 | #endif | 396 | #endif |
399 | 397 | ||
400 | if ((mp->m_qflags & (XFS_GQUOTA_ACCT | XFS_GQUOTA_ACTIVE)) && | 398 | if ((mp->m_qflags & (XFS_GQUOTA_ACCT | XFS_GQUOTA_ACTIVE)) && |
401 | (mp->m_qflags & (XFS_PQUOTA_ACCT | XFS_PQUOTA_ACTIVE))) { | 399 | (mp->m_qflags & (XFS_PQUOTA_ACCT | XFS_PQUOTA_ACTIVE))) { |
402 | cmn_err(CE_WARN, | 400 | xfs_warn(mp, "cannot mount with both project and group quota"); |
403 | "XFS: cannot mount with both project and group quota"); | ||
404 | return EINVAL; | 401 | return EINVAL; |
405 | } | 402 | } |
406 | 403 | ||
407 | if ((dsunit && !dswidth) || (!dsunit && dswidth)) { | 404 | if ((dsunit && !dswidth) || (!dsunit && dswidth)) { |
408 | cmn_err(CE_WARN, | 405 | xfs_warn(mp, "sunit and swidth must be specified together"); |
409 | "XFS: sunit and swidth must be specified together"); | ||
410 | return EINVAL; | 406 | return EINVAL; |
411 | } | 407 | } |
412 | 408 | ||
413 | if (dsunit && (dswidth % dsunit != 0)) { | 409 | if (dsunit && (dswidth % dsunit != 0)) { |
414 | cmn_err(CE_WARN, | 410 | xfs_warn(mp, |
415 | "XFS: stripe width (%d) must be a multiple of the stripe unit (%d)", | 411 | "stripe width (%d) must be a multiple of the stripe unit (%d)", |
416 | dswidth, dsunit); | 412 | dswidth, dsunit); |
417 | return EINVAL; | 413 | return EINVAL; |
418 | } | 414 | } |
@@ -438,8 +434,7 @@ done: | |||
438 | mp->m_logbufs != 0 && | 434 | mp->m_logbufs != 0 && |
439 | (mp->m_logbufs < XLOG_MIN_ICLOGS || | 435 | (mp->m_logbufs < XLOG_MIN_ICLOGS || |
440 | mp->m_logbufs > XLOG_MAX_ICLOGS)) { | 436 | mp->m_logbufs > XLOG_MAX_ICLOGS)) { |
441 | cmn_err(CE_WARN, | 437 | xfs_warn(mp, "invalid logbufs value: %d [not %d-%d]", |
442 | "XFS: invalid logbufs value: %d [not %d-%d]", | ||
443 | mp->m_logbufs, XLOG_MIN_ICLOGS, XLOG_MAX_ICLOGS); | 438 | mp->m_logbufs, XLOG_MIN_ICLOGS, XLOG_MAX_ICLOGS); |
444 | return XFS_ERROR(EINVAL); | 439 | return XFS_ERROR(EINVAL); |
445 | } | 440 | } |
@@ -448,22 +443,16 @@ done: | |||
448 | (mp->m_logbsize < XLOG_MIN_RECORD_BSIZE || | 443 | (mp->m_logbsize < XLOG_MIN_RECORD_BSIZE || |
449 | mp->m_logbsize > XLOG_MAX_RECORD_BSIZE || | 444 | mp->m_logbsize > XLOG_MAX_RECORD_BSIZE || |
450 | !is_power_of_2(mp->m_logbsize))) { | 445 | !is_power_of_2(mp->m_logbsize))) { |
451 | cmn_err(CE_WARN, | 446 | xfs_warn(mp, |
452 | "XFS: invalid logbufsize: %d [not 16k,32k,64k,128k or 256k]", | 447 | "invalid logbufsize: %d [not 16k,32k,64k,128k or 256k]", |
453 | mp->m_logbsize); | 448 | mp->m_logbsize); |
454 | return XFS_ERROR(EINVAL); | 449 | return XFS_ERROR(EINVAL); |
455 | } | 450 | } |
456 | 451 | ||
457 | mp->m_fsname = kstrndup(sb->s_id, MAXNAMELEN, GFP_KERNEL); | ||
458 | if (!mp->m_fsname) | ||
459 | return ENOMEM; | ||
460 | mp->m_fsname_len = strlen(mp->m_fsname) + 1; | ||
461 | |||
462 | if (iosizelog) { | 452 | if (iosizelog) { |
463 | if (iosizelog > XFS_MAX_IO_LOG || | 453 | if (iosizelog > XFS_MAX_IO_LOG || |
464 | iosizelog < XFS_MIN_IO_LOG) { | 454 | iosizelog < XFS_MIN_IO_LOG) { |
465 | cmn_err(CE_WARN, | 455 | xfs_warn(mp, "invalid log iosize: %d [not %d-%d]", |
466 | "XFS: invalid log iosize: %d [not %d-%d]", | ||
467 | iosizelog, XFS_MIN_IO_LOG, | 456 | iosizelog, XFS_MIN_IO_LOG, |
468 | XFS_MAX_IO_LOG); | 457 | XFS_MAX_IO_LOG); |
469 | return XFS_ERROR(EINVAL); | 458 | return XFS_ERROR(EINVAL); |
@@ -610,7 +599,7 @@ xfs_blkdev_get( | |||
610 | mp); | 599 | mp); |
611 | if (IS_ERR(*bdevp)) { | 600 | if (IS_ERR(*bdevp)) { |
612 | error = PTR_ERR(*bdevp); | 601 | error = PTR_ERR(*bdevp); |
613 | printk("XFS: Invalid device [%s], error=%d\n", name, error); | 602 | xfs_warn(mp, "Invalid device [%s], error=%d\n", name, error); |
614 | } | 603 | } |
615 | 604 | ||
616 | return -error; | 605 | return -error; |
@@ -664,23 +653,23 @@ xfs_mountfs_check_barriers(xfs_mount_t *mp) | |||
664 | int error; | 653 | int error; |
665 | 654 | ||
666 | if (mp->m_logdev_targp != mp->m_ddev_targp) { | 655 | if (mp->m_logdev_targp != mp->m_ddev_targp) { |
667 | xfs_fs_cmn_err(CE_NOTE, mp, | 656 | xfs_notice(mp, |
668 | "Disabling barriers, not supported with external log device"); | 657 | "Disabling barriers, not supported with external log device"); |
669 | mp->m_flags &= ~XFS_MOUNT_BARRIER; | 658 | mp->m_flags &= ~XFS_MOUNT_BARRIER; |
670 | return; | 659 | return; |
671 | } | 660 | } |
672 | 661 | ||
673 | if (xfs_readonly_buftarg(mp->m_ddev_targp)) { | 662 | if (xfs_readonly_buftarg(mp->m_ddev_targp)) { |
674 | xfs_fs_cmn_err(CE_NOTE, mp, | 663 | xfs_notice(mp, |
675 | "Disabling barriers, underlying device is readonly"); | 664 | "Disabling barriers, underlying device is readonly"); |
676 | mp->m_flags &= ~XFS_MOUNT_BARRIER; | 665 | mp->m_flags &= ~XFS_MOUNT_BARRIER; |
677 | return; | 666 | return; |
678 | } | 667 | } |
679 | 668 | ||
680 | error = xfs_barrier_test(mp); | 669 | error = xfs_barrier_test(mp); |
681 | if (error) { | 670 | if (error) { |
682 | xfs_fs_cmn_err(CE_NOTE, mp, | 671 | xfs_notice(mp, |
683 | "Disabling barriers, trial barrier write failed"); | 672 | "Disabling barriers, trial barrier write failed"); |
684 | mp->m_flags &= ~XFS_MOUNT_BARRIER; | 673 | mp->m_flags &= ~XFS_MOUNT_BARRIER; |
685 | return; | 674 | return; |
686 | } | 675 | } |
@@ -743,8 +732,8 @@ xfs_open_devices( | |||
743 | goto out_close_logdev; | 732 | goto out_close_logdev; |
744 | 733 | ||
745 | if (rtdev == ddev || rtdev == logdev) { | 734 | if (rtdev == ddev || rtdev == logdev) { |
746 | cmn_err(CE_WARN, | 735 | xfs_warn(mp, |
747 | "XFS: Cannot mount filesystem with identical rtdev and ddev/logdev."); | 736 | "Cannot mount filesystem with identical rtdev and ddev/logdev."); |
748 | error = EINVAL; | 737 | error = EINVAL; |
749 | goto out_close_rtdev; | 738 | goto out_close_rtdev; |
750 | } | 739 | } |
@@ -1345,8 +1334,8 @@ xfs_fs_remount( | |||
1345 | * options that we can't actually change. | 1334 | * options that we can't actually change. |
1346 | */ | 1335 | */ |
1347 | #if 0 | 1336 | #if 0 |
1348 | printk(KERN_INFO | 1337 | xfs_info(mp, |
1349 | "XFS: mount option \"%s\" not supported for remount\n", p); | 1338 | "mount option \"%s\" not supported for remount\n", p); |
1350 | return -EINVAL; | 1339 | return -EINVAL; |
1351 | #else | 1340 | #else |
1352 | break; | 1341 | break; |
@@ -1367,8 +1356,7 @@ xfs_fs_remount( | |||
1367 | if (mp->m_update_flags) { | 1356 | if (mp->m_update_flags) { |
1368 | error = xfs_mount_log_sb(mp, mp->m_update_flags); | 1357 | error = xfs_mount_log_sb(mp, mp->m_update_flags); |
1369 | if (error) { | 1358 | if (error) { |
1370 | cmn_err(CE_WARN, | 1359 | xfs_warn(mp, "failed to write sb changes"); |
1371 | "XFS: failed to write sb changes"); | ||
1372 | return error; | 1360 | return error; |
1373 | } | 1361 | } |
1374 | mp->m_update_flags = 0; | 1362 | mp->m_update_flags = 0; |
@@ -1452,15 +1440,15 @@ xfs_finish_flags( | |||
1452 | mp->m_logbsize = mp->m_sb.sb_logsunit; | 1440 | mp->m_logbsize = mp->m_sb.sb_logsunit; |
1453 | } else if (mp->m_logbsize > 0 && | 1441 | } else if (mp->m_logbsize > 0 && |
1454 | mp->m_logbsize < mp->m_sb.sb_logsunit) { | 1442 | mp->m_logbsize < mp->m_sb.sb_logsunit) { |
1455 | cmn_err(CE_WARN, | 1443 | xfs_warn(mp, |
1456 | "XFS: logbuf size must be greater than or equal to log stripe size"); | 1444 | "logbuf size must be greater than or equal to log stripe size"); |
1457 | return XFS_ERROR(EINVAL); | 1445 | return XFS_ERROR(EINVAL); |
1458 | } | 1446 | } |
1459 | } else { | 1447 | } else { |
1460 | /* Fail a mount if the logbuf is larger than 32K */ | 1448 | /* Fail a mount if the logbuf is larger than 32K */ |
1461 | if (mp->m_logbsize > XLOG_BIG_RECORD_BSIZE) { | 1449 | if (mp->m_logbsize > XLOG_BIG_RECORD_BSIZE) { |
1462 | cmn_err(CE_WARN, | 1450 | xfs_warn(mp, |
1463 | "XFS: logbuf size for version 1 logs must be 16K or 32K"); | 1451 | "logbuf size for version 1 logs must be 16K or 32K"); |
1464 | return XFS_ERROR(EINVAL); | 1452 | return XFS_ERROR(EINVAL); |
1465 | } | 1453 | } |
1466 | } | 1454 | } |
@@ -1477,8 +1465,8 @@ xfs_finish_flags( | |||
1477 | * prohibit r/w mounts of read-only filesystems | 1465 | * prohibit r/w mounts of read-only filesystems |
1478 | */ | 1466 | */ |
1479 | if ((mp->m_sb.sb_flags & XFS_SBF_READONLY) && !ronly) { | 1467 | if ((mp->m_sb.sb_flags & XFS_SBF_READONLY) && !ronly) { |
1480 | cmn_err(CE_WARN, | 1468 | xfs_warn(mp, |
1481 | "XFS: cannot mount a read-only filesystem as read-write"); | 1469 | "cannot mount a read-only filesystem as read-write"); |
1482 | return XFS_ERROR(EROFS); | 1470 | return XFS_ERROR(EROFS); |
1483 | } | 1471 | } |
1484 | 1472 | ||
diff --git a/fs/xfs/linux-2.6/xfs_sync.c b/fs/xfs/linux-2.6/xfs_sync.c index e22f0057d21f..6c10f1d2e3d3 100644 --- a/fs/xfs/linux-2.6/xfs_sync.c +++ b/fs/xfs/linux-2.6/xfs_sync.c | |||
@@ -425,8 +425,7 @@ xfs_quiesce_attr( | |||
425 | /* Push the superblock and write an unmount record */ | 425 | /* Push the superblock and write an unmount record */ |
426 | error = xfs_log_sbcount(mp, 1); | 426 | error = xfs_log_sbcount(mp, 1); |
427 | if (error) | 427 | if (error) |
428 | xfs_fs_cmn_err(CE_WARN, mp, | 428 | xfs_warn(mp, "xfs_attr_quiesce: failed to log sb changes. " |
429 | "xfs_attr_quiesce: failed to log sb changes. " | ||
430 | "Frozen image may not be consistent."); | 429 | "Frozen image may not be consistent."); |
431 | xfs_log_unmount_write(mp); | 430 | xfs_log_unmount_write(mp); |
432 | xfs_unmountfs_writesb(mp); | 431 | xfs_unmountfs_writesb(mp); |
@@ -806,7 +805,7 @@ xfs_reclaim_inode( | |||
806 | * pass on the error. | 805 | * pass on the error. |
807 | */ | 806 | */ |
808 | if (error && error != EAGAIN && !XFS_FORCED_SHUTDOWN(ip->i_mount)) { | 807 | if (error && error != EAGAIN && !XFS_FORCED_SHUTDOWN(ip->i_mount)) { |
809 | xfs_fs_cmn_err(CE_WARN, ip->i_mount, | 808 | xfs_warn(ip->i_mount, |
810 | "inode 0x%llx background reclaim flush failed with %d", | 809 | "inode 0x%llx background reclaim flush failed with %d", |
811 | (long long)ip->i_ino, error); | 810 | (long long)ip->i_ino, error); |
812 | } | 811 | } |
diff --git a/fs/xfs/linux-2.6/xfs_sysctl.c b/fs/xfs/linux-2.6/xfs_sysctl.c index ee3cee097e7e..ee2d2adaa438 100644 --- a/fs/xfs/linux-2.6/xfs_sysctl.c +++ b/fs/xfs/linux-2.6/xfs_sysctl.c | |||
@@ -37,7 +37,7 @@ xfs_stats_clear_proc_handler( | |||
37 | ret = proc_dointvec_minmax(ctl, write, buffer, lenp, ppos); | 37 | ret = proc_dointvec_minmax(ctl, write, buffer, lenp, ppos); |
38 | 38 | ||
39 | if (!ret && write && *valp) { | 39 | if (!ret && write && *valp) { |
40 | printk("XFS Clearing xfsstats\n"); | 40 | xfs_notice(NULL, "Clearing xfsstats"); |
41 | for_each_possible_cpu(c) { | 41 | for_each_possible_cpu(c) { |
42 | preempt_disable(); | 42 | preempt_disable(); |
43 | /* save vn_active, it's a universal truth! */ | 43 | /* save vn_active, it's a universal truth! */ |
diff --git a/fs/xfs/quota/xfs_dquot.c b/fs/xfs/quota/xfs_dquot.c index d22aa3103106..7e2416478503 100644 --- a/fs/xfs/quota/xfs_dquot.c +++ b/fs/xfs/quota/xfs_dquot.c | |||
@@ -544,9 +544,10 @@ xfs_qm_dqtobp( | |||
544 | /* | 544 | /* |
545 | * A simple sanity check in case we got a corrupted dquot... | 545 | * A simple sanity check in case we got a corrupted dquot... |
546 | */ | 546 | */ |
547 | if (xfs_qm_dqcheck(ddq, id, dqp->dq_flags & XFS_DQ_ALLTYPES, | 547 | error = xfs_qm_dqcheck(mp, ddq, id, dqp->dq_flags & XFS_DQ_ALLTYPES, |
548 | flags & (XFS_QMOPT_DQREPAIR|XFS_QMOPT_DOWARN), | 548 | flags & (XFS_QMOPT_DQREPAIR|XFS_QMOPT_DOWARN), |
549 | "dqtobp")) { | 549 | "dqtobp"); |
550 | if (error) { | ||
550 | if (!(flags & XFS_QMOPT_DQREPAIR)) { | 551 | if (!(flags & XFS_QMOPT_DQREPAIR)) { |
551 | xfs_trans_brelse(tp, bp); | 552 | xfs_trans_brelse(tp, bp); |
552 | return XFS_ERROR(EIO); | 553 | return XFS_ERROR(EIO); |
@@ -827,7 +828,7 @@ xfs_qm_dqget( | |||
827 | if (xfs_do_dqerror) { | 828 | if (xfs_do_dqerror) { |
828 | if ((xfs_dqerror_target == mp->m_ddev_targp) && | 829 | if ((xfs_dqerror_target == mp->m_ddev_targp) && |
829 | (xfs_dqreq_num++ % xfs_dqerror_mod) == 0) { | 830 | (xfs_dqreq_num++ % xfs_dqerror_mod) == 0) { |
830 | cmn_err(CE_DEBUG, "Returning error in dqget"); | 831 | xfs_debug(mp, "Returning error in dqget"); |
831 | return (EIO); | 832 | return (EIO); |
832 | } | 833 | } |
833 | } | 834 | } |
@@ -1207,8 +1208,9 @@ xfs_qm_dqflush( | |||
1207 | /* | 1208 | /* |
1208 | * A simple sanity check in case we got a corrupted dquot.. | 1209 | * A simple sanity check in case we got a corrupted dquot.. |
1209 | */ | 1210 | */ |
1210 | if (xfs_qm_dqcheck(&dqp->q_core, be32_to_cpu(ddqp->d_id), 0, | 1211 | error = xfs_qm_dqcheck(mp, &dqp->q_core, be32_to_cpu(ddqp->d_id), 0, |
1211 | XFS_QMOPT_DOWARN, "dqflush (incore copy)")) { | 1212 | XFS_QMOPT_DOWARN, "dqflush (incore copy)"); |
1213 | if (error) { | ||
1212 | xfs_buf_relse(bp); | 1214 | xfs_buf_relse(bp); |
1213 | xfs_dqfunlock(dqp); | 1215 | xfs_dqfunlock(dqp); |
1214 | xfs_force_shutdown(mp, SHUTDOWN_CORRUPT_INCORE); | 1216 | xfs_force_shutdown(mp, SHUTDOWN_CORRUPT_INCORE); |
@@ -1391,8 +1393,8 @@ xfs_qm_dqpurge( | |||
1391 | */ | 1393 | */ |
1392 | error = xfs_qm_dqflush(dqp, SYNC_WAIT); | 1394 | error = xfs_qm_dqflush(dqp, SYNC_WAIT); |
1393 | if (error) | 1395 | if (error) |
1394 | xfs_fs_cmn_err(CE_WARN, mp, | 1396 | xfs_warn(mp, "%s: dquot %p flush failed", |
1395 | "xfs_qm_dqpurge: dquot %p flush failed", dqp); | 1397 | __func__, dqp); |
1396 | xfs_dqflock(dqp); | 1398 | xfs_dqflock(dqp); |
1397 | } | 1399 | } |
1398 | ASSERT(atomic_read(&dqp->q_pincount) == 0); | 1400 | ASSERT(atomic_read(&dqp->q_pincount) == 0); |
@@ -1425,36 +1427,38 @@ xfs_qm_dqpurge( | |||
1425 | void | 1427 | void |
1426 | xfs_qm_dqprint(xfs_dquot_t *dqp) | 1428 | xfs_qm_dqprint(xfs_dquot_t *dqp) |
1427 | { | 1429 | { |
1428 | cmn_err(CE_DEBUG, "-----------KERNEL DQUOT----------------"); | 1430 | struct xfs_mount *mp = dqp->q_mount; |
1429 | cmn_err(CE_DEBUG, "---- dquotID = %d", | 1431 | |
1432 | xfs_debug(mp, "-----------KERNEL DQUOT----------------"); | ||
1433 | xfs_debug(mp, "---- dquotID = %d", | ||
1430 | (int)be32_to_cpu(dqp->q_core.d_id)); | 1434 | (int)be32_to_cpu(dqp->q_core.d_id)); |
1431 | cmn_err(CE_DEBUG, "---- type = %s", DQFLAGTO_TYPESTR(dqp)); | 1435 | xfs_debug(mp, "---- type = %s", DQFLAGTO_TYPESTR(dqp)); |
1432 | cmn_err(CE_DEBUG, "---- fs = 0x%p", dqp->q_mount); | 1436 | xfs_debug(mp, "---- fs = 0x%p", dqp->q_mount); |
1433 | cmn_err(CE_DEBUG, "---- blkno = 0x%x", (int) dqp->q_blkno); | 1437 | xfs_debug(mp, "---- blkno = 0x%x", (int) dqp->q_blkno); |
1434 | cmn_err(CE_DEBUG, "---- boffset = 0x%x", (int) dqp->q_bufoffset); | 1438 | xfs_debug(mp, "---- boffset = 0x%x", (int) dqp->q_bufoffset); |
1435 | cmn_err(CE_DEBUG, "---- blkhlimit = %Lu (0x%x)", | 1439 | xfs_debug(mp, "---- blkhlimit = %Lu (0x%x)", |
1436 | be64_to_cpu(dqp->q_core.d_blk_hardlimit), | 1440 | be64_to_cpu(dqp->q_core.d_blk_hardlimit), |
1437 | (int)be64_to_cpu(dqp->q_core.d_blk_hardlimit)); | 1441 | (int)be64_to_cpu(dqp->q_core.d_blk_hardlimit)); |
1438 | cmn_err(CE_DEBUG, "---- blkslimit = %Lu (0x%x)", | 1442 | xfs_debug(mp, "---- blkslimit = %Lu (0x%x)", |
1439 | be64_to_cpu(dqp->q_core.d_blk_softlimit), | 1443 | be64_to_cpu(dqp->q_core.d_blk_softlimit), |
1440 | (int)be64_to_cpu(dqp->q_core.d_blk_softlimit)); | 1444 | (int)be64_to_cpu(dqp->q_core.d_blk_softlimit)); |
1441 | cmn_err(CE_DEBUG, "---- inohlimit = %Lu (0x%x)", | 1445 | xfs_debug(mp, "---- inohlimit = %Lu (0x%x)", |
1442 | be64_to_cpu(dqp->q_core.d_ino_hardlimit), | 1446 | be64_to_cpu(dqp->q_core.d_ino_hardlimit), |
1443 | (int)be64_to_cpu(dqp->q_core.d_ino_hardlimit)); | 1447 | (int)be64_to_cpu(dqp->q_core.d_ino_hardlimit)); |
1444 | cmn_err(CE_DEBUG, "---- inoslimit = %Lu (0x%x)", | 1448 | xfs_debug(mp, "---- inoslimit = %Lu (0x%x)", |
1445 | be64_to_cpu(dqp->q_core.d_ino_softlimit), | 1449 | be64_to_cpu(dqp->q_core.d_ino_softlimit), |
1446 | (int)be64_to_cpu(dqp->q_core.d_ino_softlimit)); | 1450 | (int)be64_to_cpu(dqp->q_core.d_ino_softlimit)); |
1447 | cmn_err(CE_DEBUG, "---- bcount = %Lu (0x%x)", | 1451 | xfs_debug(mp, "---- bcount = %Lu (0x%x)", |
1448 | be64_to_cpu(dqp->q_core.d_bcount), | 1452 | be64_to_cpu(dqp->q_core.d_bcount), |
1449 | (int)be64_to_cpu(dqp->q_core.d_bcount)); | 1453 | (int)be64_to_cpu(dqp->q_core.d_bcount)); |
1450 | cmn_err(CE_DEBUG, "---- icount = %Lu (0x%x)", | 1454 | xfs_debug(mp, "---- icount = %Lu (0x%x)", |
1451 | be64_to_cpu(dqp->q_core.d_icount), | 1455 | be64_to_cpu(dqp->q_core.d_icount), |
1452 | (int)be64_to_cpu(dqp->q_core.d_icount)); | 1456 | (int)be64_to_cpu(dqp->q_core.d_icount)); |
1453 | cmn_err(CE_DEBUG, "---- btimer = %d", | 1457 | xfs_debug(mp, "---- btimer = %d", |
1454 | (int)be32_to_cpu(dqp->q_core.d_btimer)); | 1458 | (int)be32_to_cpu(dqp->q_core.d_btimer)); |
1455 | cmn_err(CE_DEBUG, "---- itimer = %d", | 1459 | xfs_debug(mp, "---- itimer = %d", |
1456 | (int)be32_to_cpu(dqp->q_core.d_itimer)); | 1460 | (int)be32_to_cpu(dqp->q_core.d_itimer)); |
1457 | cmn_err(CE_DEBUG, "---------------------------"); | 1461 | xfs_debug(mp, "---------------------------"); |
1458 | } | 1462 | } |
1459 | #endif | 1463 | #endif |
1460 | 1464 | ||
diff --git a/fs/xfs/quota/xfs_dquot_item.c b/fs/xfs/quota/xfs_dquot_item.c index 2a1f3dc10a02..9e0e2fa3f2c8 100644 --- a/fs/xfs/quota/xfs_dquot_item.c +++ b/fs/xfs/quota/xfs_dquot_item.c | |||
@@ -136,9 +136,8 @@ xfs_qm_dquot_logitem_push( | |||
136 | */ | 136 | */ |
137 | error = xfs_qm_dqflush(dqp, 0); | 137 | error = xfs_qm_dqflush(dqp, 0); |
138 | if (error) | 138 | if (error) |
139 | xfs_fs_cmn_err(CE_WARN, dqp->q_mount, | 139 | xfs_warn(dqp->q_mount, "%s: push error %d on dqp %p", |
140 | "xfs_qm_dquot_logitem_push: push error %d on dqp %p", | 140 | __func__, error, dqp); |
141 | error, dqp); | ||
142 | xfs_dqunlock(dqp); | 141 | xfs_dqunlock(dqp); |
143 | } | 142 | } |
144 | 143 | ||
diff --git a/fs/xfs/quota/xfs_qm.c b/fs/xfs/quota/xfs_qm.c index 206a2815ced6..254ee062bd7d 100644 --- a/fs/xfs/quota/xfs_qm.c +++ b/fs/xfs/quota/xfs_qm.c | |||
@@ -80,7 +80,7 @@ xfs_qm_dquot_list_print( | |||
80 | int i = 0; | 80 | int i = 0; |
81 | 81 | ||
82 | list_for_each_entry(dqp, &mp->m_quotainfo->qi_dqlist_lock, qi_mplist) { | 82 | list_for_each_entry(dqp, &mp->m_quotainfo->qi_dqlist_lock, qi_mplist) { |
83 | cmn_err(CE_DEBUG, " %d. \"%d (%s)\" " | 83 | xfs_debug(mp, " %d. \"%d (%s)\" " |
84 | "bcnt = %lld, icnt = %lld, refs = %d", | 84 | "bcnt = %lld, icnt = %lld, refs = %d", |
85 | i++, be32_to_cpu(dqp->q_core.d_id), | 85 | i++, be32_to_cpu(dqp->q_core.d_id), |
86 | DQFLAGTO_TYPESTR(dqp), | 86 | DQFLAGTO_TYPESTR(dqp), |
@@ -205,7 +205,7 @@ xfs_qm_destroy( | |||
205 | list_for_each_entry_safe(dqp, n, &xqm->qm_dqfrlist, q_freelist) { | 205 | list_for_each_entry_safe(dqp, n, &xqm->qm_dqfrlist, q_freelist) { |
206 | xfs_dqlock(dqp); | 206 | xfs_dqlock(dqp); |
207 | #ifdef QUOTADEBUG | 207 | #ifdef QUOTADEBUG |
208 | cmn_err(CE_DEBUG, "FREELIST destroy 0x%p", dqp); | 208 | xfs_debug(dqp->q_mount, "FREELIST destroy 0x%p", dqp); |
209 | #endif | 209 | #endif |
210 | list_del_init(&dqp->q_freelist); | 210 | list_del_init(&dqp->q_freelist); |
211 | xfs_Gqm->qm_dqfrlist_cnt--; | 211 | xfs_Gqm->qm_dqfrlist_cnt--; |
@@ -341,9 +341,7 @@ xfs_qm_mount_quotas( | |||
341 | * quotas immediately. | 341 | * quotas immediately. |
342 | */ | 342 | */ |
343 | if (mp->m_sb.sb_rextents) { | 343 | if (mp->m_sb.sb_rextents) { |
344 | cmn_err(CE_NOTE, | 344 | xfs_notice(mp, "Cannot turn on quotas for realtime filesystem"); |
345 | "Cannot turn on quotas for realtime filesystem %s", | ||
346 | mp->m_fsname); | ||
347 | mp->m_qflags = 0; | 345 | mp->m_qflags = 0; |
348 | goto write_changes; | 346 | goto write_changes; |
349 | } | 347 | } |
@@ -402,14 +400,13 @@ xfs_qm_mount_quotas( | |||
402 | * off, but the on disk superblock doesn't know that ! | 400 | * off, but the on disk superblock doesn't know that ! |
403 | */ | 401 | */ |
404 | ASSERT(!(XFS_IS_QUOTA_RUNNING(mp))); | 402 | ASSERT(!(XFS_IS_QUOTA_RUNNING(mp))); |
405 | xfs_fs_cmn_err(CE_ALERT, mp, | 403 | xfs_alert(mp, "%s: Superblock update failed!", |
406 | "XFS mount_quotas: Superblock update failed!"); | 404 | __func__); |
407 | } | 405 | } |
408 | } | 406 | } |
409 | 407 | ||
410 | if (error) { | 408 | if (error) { |
411 | xfs_fs_cmn_err(CE_WARN, mp, | 409 | xfs_warn(mp, "Failed to initialize disk quotas."); |
412 | "Failed to initialize disk quotas."); | ||
413 | return; | 410 | return; |
414 | } | 411 | } |
415 | 412 | ||
@@ -1230,13 +1227,6 @@ xfs_qm_qino_alloc( | |||
1230 | } | 1227 | } |
1231 | 1228 | ||
1232 | /* | 1229 | /* |
1233 | * Keep an extra reference to this quota inode. This inode is | ||
1234 | * locked exclusively and joined to the transaction already. | ||
1235 | */ | ||
1236 | ASSERT(xfs_isilocked(*ip, XFS_ILOCK_EXCL)); | ||
1237 | IHOLD(*ip); | ||
1238 | |||
1239 | /* | ||
1240 | * Make the changes in the superblock, and log those too. | 1230 | * Make the changes in the superblock, and log those too. |
1241 | * sbfields arg may contain fields other than *QUOTINO; | 1231 | * sbfields arg may contain fields other than *QUOTINO; |
1242 | * VERSIONNUM for example. | 1232 | * VERSIONNUM for example. |
@@ -1264,7 +1254,7 @@ xfs_qm_qino_alloc( | |||
1264 | xfs_mod_sb(tp, sbfields); | 1254 | xfs_mod_sb(tp, sbfields); |
1265 | 1255 | ||
1266 | if ((error = xfs_trans_commit(tp, XFS_TRANS_RELEASE_LOG_RES))) { | 1256 | if ((error = xfs_trans_commit(tp, XFS_TRANS_RELEASE_LOG_RES))) { |
1267 | xfs_fs_cmn_err(CE_ALERT, mp, "XFS qino_alloc failed!"); | 1257 | xfs_alert(mp, "%s failed (error %d)!", __func__, error); |
1268 | return error; | 1258 | return error; |
1269 | } | 1259 | } |
1270 | return 0; | 1260 | return 0; |
@@ -1299,7 +1289,7 @@ xfs_qm_reset_dqcounts( | |||
1299 | * output any warnings because it's perfectly possible to | 1289 | * output any warnings because it's perfectly possible to |
1300 | * find uninitialised dquot blks. See comment in xfs_qm_dqcheck. | 1290 | * find uninitialised dquot blks. See comment in xfs_qm_dqcheck. |
1301 | */ | 1291 | */ |
1302 | (void) xfs_qm_dqcheck(ddq, id+j, type, XFS_QMOPT_DQREPAIR, | 1292 | (void) xfs_qm_dqcheck(mp, ddq, id+j, type, XFS_QMOPT_DQREPAIR, |
1303 | "xfs_quotacheck"); | 1293 | "xfs_quotacheck"); |
1304 | ddq->d_bcount = 0; | 1294 | ddq->d_bcount = 0; |
1305 | ddq->d_icount = 0; | 1295 | ddq->d_icount = 0; |
@@ -1676,7 +1666,7 @@ xfs_qm_quotacheck( | |||
1676 | */ | 1666 | */ |
1677 | ASSERT(list_empty(&mp->m_quotainfo->qi_dqlist)); | 1667 | ASSERT(list_empty(&mp->m_quotainfo->qi_dqlist)); |
1678 | 1668 | ||
1679 | cmn_err(CE_NOTE, "XFS quotacheck %s: Please wait.", mp->m_fsname); | 1669 | xfs_notice(mp, "Quotacheck needed: Please wait."); |
1680 | 1670 | ||
1681 | /* | 1671 | /* |
1682 | * First we go thru all the dquots on disk, USR and GRP/PRJ, and reset | 1672 | * First we go thru all the dquots on disk, USR and GRP/PRJ, and reset |
@@ -1754,9 +1744,9 @@ xfs_qm_quotacheck( | |||
1754 | 1744 | ||
1755 | error_return: | 1745 | error_return: |
1756 | if (error) { | 1746 | if (error) { |
1757 | cmn_err(CE_WARN, "XFS quotacheck %s: Unsuccessful (Error %d): " | 1747 | xfs_warn(mp, |
1758 | "Disabling quotas.", | 1748 | "Quotacheck: Unsuccessful (Error %d): Disabling quotas.", |
1759 | mp->m_fsname, error); | 1749 | error); |
1760 | /* | 1750 | /* |
1761 | * We must turn off quotas. | 1751 | * We must turn off quotas. |
1762 | */ | 1752 | */ |
@@ -1764,12 +1754,11 @@ xfs_qm_quotacheck( | |||
1764 | ASSERT(xfs_Gqm != NULL); | 1754 | ASSERT(xfs_Gqm != NULL); |
1765 | xfs_qm_destroy_quotainfo(mp); | 1755 | xfs_qm_destroy_quotainfo(mp); |
1766 | if (xfs_mount_reset_sbqflags(mp)) { | 1756 | if (xfs_mount_reset_sbqflags(mp)) { |
1767 | cmn_err(CE_WARN, "XFS quotacheck %s: " | 1757 | xfs_warn(mp, |
1768 | "Failed to reset quota flags.", mp->m_fsname); | 1758 | "Quotacheck: Failed to reset quota flags."); |
1769 | } | 1759 | } |
1770 | } else { | 1760 | } else |
1771 | cmn_err(CE_NOTE, "XFS quotacheck %s: Done.", mp->m_fsname); | 1761 | xfs_notice(mp, "Quotacheck: Done."); |
1772 | } | ||
1773 | return (error); | 1762 | return (error); |
1774 | } | 1763 | } |
1775 | 1764 | ||
@@ -1937,8 +1926,8 @@ again: | |||
1937 | */ | 1926 | */ |
1938 | error = xfs_qm_dqflush(dqp, 0); | 1927 | error = xfs_qm_dqflush(dqp, 0); |
1939 | if (error) { | 1928 | if (error) { |
1940 | xfs_fs_cmn_err(CE_WARN, mp, | 1929 | xfs_warn(mp, "%s: dquot %p flush failed", |
1941 | "xfs_qm_dqreclaim: dquot %p flush failed", dqp); | 1930 | __func__, dqp); |
1942 | } | 1931 | } |
1943 | goto dqunlock; | 1932 | goto dqunlock; |
1944 | } | 1933 | } |
@@ -2115,7 +2104,7 @@ xfs_qm_write_sb_changes( | |||
2115 | int error; | 2104 | int error; |
2116 | 2105 | ||
2117 | #ifdef QUOTADEBUG | 2106 | #ifdef QUOTADEBUG |
2118 | cmn_err(CE_NOTE, "Writing superblock quota changes :%s", mp->m_fsname); | 2107 | xfs_notice(mp, "Writing superblock quota changes"); |
2119 | #endif | 2108 | #endif |
2120 | tp = xfs_trans_alloc(mp, XFS_TRANS_QM_SBCHANGE); | 2109 | tp = xfs_trans_alloc(mp, XFS_TRANS_QM_SBCHANGE); |
2121 | if ((error = xfs_trans_reserve(tp, 0, | 2110 | if ((error = xfs_trans_reserve(tp, 0, |
diff --git a/fs/xfs/quota/xfs_qm_bhv.c b/fs/xfs/quota/xfs_qm_bhv.c index 45b5cb1788ab..774d7ec6df8e 100644 --- a/fs/xfs/quota/xfs_qm_bhv.c +++ b/fs/xfs/quota/xfs_qm_bhv.c | |||
@@ -119,8 +119,7 @@ xfs_qm_newmount( | |||
119 | (gquotaondisk && !XFS_IS_GQUOTA_ON(mp)) || | 119 | (gquotaondisk && !XFS_IS_GQUOTA_ON(mp)) || |
120 | (!gquotaondisk && XFS_IS_OQUOTA_ON(mp))) && | 120 | (!gquotaondisk && XFS_IS_OQUOTA_ON(mp))) && |
121 | xfs_dev_is_read_only(mp, "changing quota state")) { | 121 | xfs_dev_is_read_only(mp, "changing quota state")) { |
122 | cmn_err(CE_WARN, | 122 | xfs_warn(mp, "please mount with%s%s%s%s.", |
123 | "XFS: please mount with%s%s%s%s.", | ||
124 | (!quotaondisk ? "out quota" : ""), | 123 | (!quotaondisk ? "out quota" : ""), |
125 | (uquotaondisk ? " usrquota" : ""), | 124 | (uquotaondisk ? " usrquota" : ""), |
126 | (pquotaondisk ? " prjquota" : ""), | 125 | (pquotaondisk ? " prjquota" : ""), |
diff --git a/fs/xfs/quota/xfs_qm_syscalls.c b/fs/xfs/quota/xfs_qm_syscalls.c index bdebc183223e..c82f06778a27 100644 --- a/fs/xfs/quota/xfs_qm_syscalls.c +++ b/fs/xfs/quota/xfs_qm_syscalls.c | |||
@@ -41,12 +41,6 @@ | |||
41 | #include "xfs_qm.h" | 41 | #include "xfs_qm.h" |
42 | #include "xfs_trace.h" | 42 | #include "xfs_trace.h" |
43 | 43 | ||
44 | #ifdef DEBUG | ||
45 | # define qdprintk(s, args...) cmn_err(CE_DEBUG, s, ## args) | ||
46 | #else | ||
47 | # define qdprintk(s, args...) do { } while (0) | ||
48 | #endif | ||
49 | |||
50 | STATIC int xfs_qm_log_quotaoff(xfs_mount_t *, xfs_qoff_logitem_t **, uint); | 44 | STATIC int xfs_qm_log_quotaoff(xfs_mount_t *, xfs_qoff_logitem_t **, uint); |
51 | STATIC int xfs_qm_log_quotaoff_end(xfs_mount_t *, xfs_qoff_logitem_t *, | 45 | STATIC int xfs_qm_log_quotaoff_end(xfs_mount_t *, xfs_qoff_logitem_t *, |
52 | uint); | 46 | uint); |
@@ -294,7 +288,8 @@ xfs_qm_scall_trunc_qfiles( | |||
294 | int error = 0, error2 = 0; | 288 | int error = 0, error2 = 0; |
295 | 289 | ||
296 | if (!xfs_sb_version_hasquota(&mp->m_sb) || flags == 0) { | 290 | if (!xfs_sb_version_hasquota(&mp->m_sb) || flags == 0) { |
297 | qdprintk("qtrunc flags=%x m_qflags=%x\n", flags, mp->m_qflags); | 291 | xfs_debug(mp, "%s: flags=%x m_qflags=%x\n", |
292 | __func__, flags, mp->m_qflags); | ||
298 | return XFS_ERROR(EINVAL); | 293 | return XFS_ERROR(EINVAL); |
299 | } | 294 | } |
300 | 295 | ||
@@ -331,7 +326,8 @@ xfs_qm_scall_quotaon( | |||
331 | sbflags = 0; | 326 | sbflags = 0; |
332 | 327 | ||
333 | if (flags == 0) { | 328 | if (flags == 0) { |
334 | qdprintk("quotaon: zero flags, m_qflags=%x\n", mp->m_qflags); | 329 | xfs_debug(mp, "%s: zero flags, m_qflags=%x\n", |
330 | __func__, mp->m_qflags); | ||
335 | return XFS_ERROR(EINVAL); | 331 | return XFS_ERROR(EINVAL); |
336 | } | 332 | } |
337 | 333 | ||
@@ -352,8 +348,9 @@ xfs_qm_scall_quotaon( | |||
352 | (flags & XFS_GQUOTA_ACCT) == 0 && | 348 | (flags & XFS_GQUOTA_ACCT) == 0 && |
353 | (mp->m_sb.sb_qflags & XFS_GQUOTA_ACCT) == 0 && | 349 | (mp->m_sb.sb_qflags & XFS_GQUOTA_ACCT) == 0 && |
354 | (flags & XFS_OQUOTA_ENFD))) { | 350 | (flags & XFS_OQUOTA_ENFD))) { |
355 | qdprintk("Can't enforce without acct, flags=%x sbflags=%x\n", | 351 | xfs_debug(mp, |
356 | flags, mp->m_sb.sb_qflags); | 352 | "%s: Can't enforce without acct, flags=%x sbflags=%x\n", |
353 | __func__, flags, mp->m_sb.sb_qflags); | ||
357 | return XFS_ERROR(EINVAL); | 354 | return XFS_ERROR(EINVAL); |
358 | } | 355 | } |
359 | /* | 356 | /* |
@@ -541,7 +538,7 @@ xfs_qm_scall_setqlim( | |||
541 | q->qi_bsoftlimit = soft; | 538 | q->qi_bsoftlimit = soft; |
542 | } | 539 | } |
543 | } else { | 540 | } else { |
544 | qdprintk("blkhard %Ld < blksoft %Ld\n", hard, soft); | 541 | xfs_debug(mp, "blkhard %Ld < blksoft %Ld\n", hard, soft); |
545 | } | 542 | } |
546 | hard = (newlim->d_fieldmask & FS_DQ_RTBHARD) ? | 543 | hard = (newlim->d_fieldmask & FS_DQ_RTBHARD) ? |
547 | (xfs_qcnt_t) XFS_BB_TO_FSB(mp, newlim->d_rtb_hardlimit) : | 544 | (xfs_qcnt_t) XFS_BB_TO_FSB(mp, newlim->d_rtb_hardlimit) : |
@@ -557,7 +554,7 @@ xfs_qm_scall_setqlim( | |||
557 | q->qi_rtbsoftlimit = soft; | 554 | q->qi_rtbsoftlimit = soft; |
558 | } | 555 | } |
559 | } else { | 556 | } else { |
560 | qdprintk("rtbhard %Ld < rtbsoft %Ld\n", hard, soft); | 557 | xfs_debug(mp, "rtbhard %Ld < rtbsoft %Ld\n", hard, soft); |
561 | } | 558 | } |
562 | 559 | ||
563 | hard = (newlim->d_fieldmask & FS_DQ_IHARD) ? | 560 | hard = (newlim->d_fieldmask & FS_DQ_IHARD) ? |
@@ -574,7 +571,7 @@ xfs_qm_scall_setqlim( | |||
574 | q->qi_isoftlimit = soft; | 571 | q->qi_isoftlimit = soft; |
575 | } | 572 | } |
576 | } else { | 573 | } else { |
577 | qdprintk("ihard %Ld < isoft %Ld\n", hard, soft); | 574 | xfs_debug(mp, "ihard %Ld < isoft %Ld\n", hard, soft); |
578 | } | 575 | } |
579 | 576 | ||
580 | /* | 577 | /* |
@@ -939,10 +936,11 @@ struct mutex qcheck_lock; | |||
939 | #define DQTEST_LIST_PRINT(l, NXT, title) \ | 936 | #define DQTEST_LIST_PRINT(l, NXT, title) \ |
940 | { \ | 937 | { \ |
941 | xfs_dqtest_t *dqp; int i = 0;\ | 938 | xfs_dqtest_t *dqp; int i = 0;\ |
942 | cmn_err(CE_DEBUG, "%s (#%d)", title, (int) (l)->qh_nelems); \ | 939 | xfs_debug(NULL, "%s (#%d)", title, (int) (l)->qh_nelems); \ |
943 | for (dqp = (xfs_dqtest_t *)(l)->qh_next; dqp != NULL; \ | 940 | for (dqp = (xfs_dqtest_t *)(l)->qh_next; dqp != NULL; \ |
944 | dqp = (xfs_dqtest_t *)dqp->NXT) { \ | 941 | dqp = (xfs_dqtest_t *)dqp->NXT) { \ |
945 | cmn_err(CE_DEBUG, " %d. \"%d (%s)\" bcnt = %d, icnt = %d", \ | 942 | xfs_debug(dqp->q_mount, \ |
943 | " %d. \"%d (%s)\" bcnt = %d, icnt = %d", \ | ||
946 | ++i, dqp->d_id, DQFLAGTO_TYPESTR(dqp), \ | 944 | ++i, dqp->d_id, DQFLAGTO_TYPESTR(dqp), \ |
947 | dqp->d_bcount, dqp->d_icount); } \ | 945 | dqp->d_bcount, dqp->d_icount); } \ |
948 | } | 946 | } |
@@ -966,16 +964,17 @@ xfs_qm_hashinsert(xfs_dqhash_t *h, xfs_dqtest_t *dqp) | |||
966 | } | 964 | } |
967 | STATIC void | 965 | STATIC void |
968 | xfs_qm_dqtest_print( | 966 | xfs_qm_dqtest_print( |
969 | xfs_dqtest_t *d) | 967 | struct xfs_mount *mp, |
968 | struct dqtest *d) | ||
970 | { | 969 | { |
971 | cmn_err(CE_DEBUG, "-----------DQTEST DQUOT----------------"); | 970 | xfs_debug(mp, "-----------DQTEST DQUOT----------------"); |
972 | cmn_err(CE_DEBUG, "---- dquot ID = %d", d->d_id); | 971 | xfs_debug(mp, "---- dquot ID = %d", d->d_id); |
973 | cmn_err(CE_DEBUG, "---- fs = 0x%p", d->q_mount); | 972 | xfs_debug(mp, "---- fs = 0x%p", d->q_mount); |
974 | cmn_err(CE_DEBUG, "---- bcount = %Lu (0x%x)", | 973 | xfs_debug(mp, "---- bcount = %Lu (0x%x)", |
975 | d->d_bcount, (int)d->d_bcount); | 974 | d->d_bcount, (int)d->d_bcount); |
976 | cmn_err(CE_DEBUG, "---- icount = %Lu (0x%x)", | 975 | xfs_debug(mp, "---- icount = %Lu (0x%x)", |
977 | d->d_icount, (int)d->d_icount); | 976 | d->d_icount, (int)d->d_icount); |
978 | cmn_err(CE_DEBUG, "---------------------------"); | 977 | xfs_debug(mp, "---------------------------"); |
979 | } | 978 | } |
980 | 979 | ||
981 | STATIC void | 980 | STATIC void |
@@ -989,12 +988,14 @@ xfs_qm_dqtest_failed( | |||
989 | { | 988 | { |
990 | qmtest_nfails++; | 989 | qmtest_nfails++; |
991 | if (error) | 990 | if (error) |
992 | cmn_err(CE_DEBUG, "quotacheck failed id=%d, err=%d\nreason: %s", | 991 | xfs_debug(dqp->q_mount, |
993 | d->d_id, error, reason); | 992 | "quotacheck failed id=%d, err=%d\nreason: %s", |
993 | d->d_id, error, reason); | ||
994 | else | 994 | else |
995 | cmn_err(CE_DEBUG, "quotacheck failed id=%d (%s) [%d != %d]", | 995 | xfs_debug(dqp->q_mount, |
996 | d->d_id, reason, (int)a, (int)b); | 996 | "quotacheck failed id=%d (%s) [%d != %d]", |
997 | xfs_qm_dqtest_print(d); | 997 | d->d_id, reason, (int)a, (int)b); |
998 | xfs_qm_dqtest_print(dqp->q_mount, d); | ||
998 | if (dqp) | 999 | if (dqp) |
999 | xfs_qm_dqprint(dqp); | 1000 | xfs_qm_dqprint(dqp); |
1000 | } | 1001 | } |
@@ -1021,9 +1022,9 @@ xfs_dqtest_cmp2( | |||
1021 | be64_to_cpu(dqp->q_core.d_bcount) >= | 1022 | be64_to_cpu(dqp->q_core.d_bcount) >= |
1022 | be64_to_cpu(dqp->q_core.d_blk_softlimit)) { | 1023 | be64_to_cpu(dqp->q_core.d_blk_softlimit)) { |
1023 | if (!dqp->q_core.d_btimer && dqp->q_core.d_id) { | 1024 | if (!dqp->q_core.d_btimer && dqp->q_core.d_id) { |
1024 | cmn_err(CE_DEBUG, | 1025 | xfs_debug(dqp->q_mount, |
1025 | "%d [%s] [0x%p] BLK TIMER NOT STARTED", | 1026 | "%d [%s] BLK TIMER NOT STARTED", |
1026 | d->d_id, DQFLAGTO_TYPESTR(d), d->q_mount); | 1027 | d->d_id, DQFLAGTO_TYPESTR(d)); |
1027 | err++; | 1028 | err++; |
1028 | } | 1029 | } |
1029 | } | 1030 | } |
@@ -1031,16 +1032,16 @@ xfs_dqtest_cmp2( | |||
1031 | be64_to_cpu(dqp->q_core.d_icount) >= | 1032 | be64_to_cpu(dqp->q_core.d_icount) >= |
1032 | be64_to_cpu(dqp->q_core.d_ino_softlimit)) { | 1033 | be64_to_cpu(dqp->q_core.d_ino_softlimit)) { |
1033 | if (!dqp->q_core.d_itimer && dqp->q_core.d_id) { | 1034 | if (!dqp->q_core.d_itimer && dqp->q_core.d_id) { |
1034 | cmn_err(CE_DEBUG, | 1035 | xfs_debug(dqp->q_mount, |
1035 | "%d [%s] [0x%p] INO TIMER NOT STARTED", | 1036 | "%d [%s] INO TIMER NOT STARTED", |
1036 | d->d_id, DQFLAGTO_TYPESTR(d), d->q_mount); | 1037 | d->d_id, DQFLAGTO_TYPESTR(d)); |
1037 | err++; | 1038 | err++; |
1038 | } | 1039 | } |
1039 | } | 1040 | } |
1040 | #ifdef QUOTADEBUG | 1041 | #ifdef QUOTADEBUG |
1041 | if (!err) { | 1042 | if (!err) { |
1042 | cmn_err(CE_DEBUG, "%d [%s] [0x%p] qchecked", | 1043 | xfs_debug(dqp->q_mount, "%d [%s] qchecked", |
1043 | d->d_id, DQFLAGTO_TYPESTR(d), d->q_mount); | 1044 | d->d_id, DQFLAGTO_TYPESTR(d)); |
1044 | } | 1045 | } |
1045 | #endif | 1046 | #endif |
1046 | return (err); | 1047 | return (err); |
@@ -1137,8 +1138,8 @@ xfs_qm_internalqcheck_adjust( | |||
1137 | 1138 | ||
1138 | if (ino == mp->m_sb.sb_uquotino || ino == mp->m_sb.sb_gquotino) { | 1139 | if (ino == mp->m_sb.sb_uquotino || ino == mp->m_sb.sb_gquotino) { |
1139 | *res = BULKSTAT_RV_NOTHING; | 1140 | *res = BULKSTAT_RV_NOTHING; |
1140 | qdprintk("internalqcheck: ino=%llu, uqino=%llu, gqino=%llu\n", | 1141 | xfs_debug(mp, "%s: ino=%llu, uqino=%llu, gqino=%llu\n", |
1141 | (unsigned long long) ino, | 1142 | __func__, (unsigned long long) ino, |
1142 | (unsigned long long) mp->m_sb.sb_uquotino, | 1143 | (unsigned long long) mp->m_sb.sb_uquotino, |
1143 | (unsigned long long) mp->m_sb.sb_gquotino); | 1144 | (unsigned long long) mp->m_sb.sb_gquotino); |
1144 | return XFS_ERROR(EINVAL); | 1145 | return XFS_ERROR(EINVAL); |
@@ -1223,12 +1224,12 @@ xfs_qm_internalqcheck( | |||
1223 | xfs_qm_internalqcheck_adjust, | 1224 | xfs_qm_internalqcheck_adjust, |
1224 | 0, NULL, &done); | 1225 | 0, NULL, &done); |
1225 | if (error) { | 1226 | if (error) { |
1226 | cmn_err(CE_DEBUG, "Bulkstat returned error 0x%x", error); | 1227 | xfs_debug(mp, "Bulkstat returned error 0x%x", error); |
1227 | break; | 1228 | break; |
1228 | } | 1229 | } |
1229 | } while (!done); | 1230 | } while (!done); |
1230 | 1231 | ||
1231 | cmn_err(CE_DEBUG, "Checking results against system dquots"); | 1232 | xfs_debug(mp, "Checking results against system dquots"); |
1232 | for (i = 0; i < qmtest_hashmask; i++) { | 1233 | for (i = 0; i < qmtest_hashmask; i++) { |
1233 | xfs_dqtest_t *d, *n; | 1234 | xfs_dqtest_t *d, *n; |
1234 | xfs_dqhash_t *h; | 1235 | xfs_dqhash_t *h; |
@@ -1246,10 +1247,10 @@ xfs_qm_internalqcheck( | |||
1246 | } | 1247 | } |
1247 | 1248 | ||
1248 | if (qmtest_nfails) { | 1249 | if (qmtest_nfails) { |
1249 | cmn_err(CE_DEBUG, "******** quotacheck failed ********"); | 1250 | xfs_debug(mp, "******** quotacheck failed ********"); |
1250 | cmn_err(CE_DEBUG, "failures = %d", qmtest_nfails); | 1251 | xfs_debug(mp, "failures = %d", qmtest_nfails); |
1251 | } else { | 1252 | } else { |
1252 | cmn_err(CE_DEBUG, "******** quotacheck successful! ********"); | 1253 | xfs_debug(mp, "******** quotacheck successful! ********"); |
1253 | } | 1254 | } |
1254 | kmem_free(qmtest_udqtab); | 1255 | kmem_free(qmtest_udqtab); |
1255 | kmem_free(qmtest_gdqtab); | 1256 | kmem_free(qmtest_gdqtab); |
diff --git a/fs/xfs/quota/xfs_trans_dquot.c b/fs/xfs/quota/xfs_trans_dquot.c index 7de91d1b75c0..2a3648731331 100644 --- a/fs/xfs/quota/xfs_trans_dquot.c +++ b/fs/xfs/quota/xfs_trans_dquot.c | |||
@@ -643,8 +643,9 @@ xfs_trans_dqresv( | |||
643 | (XFS_IS_OQUOTA_ENFORCED(dqp->q_mount) && | 643 | (XFS_IS_OQUOTA_ENFORCED(dqp->q_mount) && |
644 | (XFS_QM_ISPDQ(dqp) || XFS_QM_ISGDQ(dqp))))) { | 644 | (XFS_QM_ISPDQ(dqp) || XFS_QM_ISGDQ(dqp))))) { |
645 | #ifdef QUOTADEBUG | 645 | #ifdef QUOTADEBUG |
646 | cmn_err(CE_DEBUG, "BLK Res: nblks=%ld + resbcount=%Ld" | 646 | xfs_debug(mp, |
647 | " > hardlimit=%Ld?", nblks, *resbcountp, hardlimit); | 647 | "BLK Res: nblks=%ld + resbcount=%Ld > hardlimit=%Ld?", |
648 | nblks, *resbcountp, hardlimit); | ||
648 | #endif | 649 | #endif |
649 | if (nblks > 0) { | 650 | if (nblks > 0) { |
650 | /* | 651 | /* |
diff --git a/fs/xfs/support/debug.c b/fs/xfs/support/debug.c deleted file mode 100644 index 0df88897ef84..000000000000 --- a/fs/xfs/support/debug.c +++ /dev/null | |||
@@ -1,107 +0,0 @@ | |||
1 | /* | ||
2 | * Copyright (c) 2000-2003,2005 Silicon Graphics, Inc. | ||
3 | * All Rights Reserved. | ||
4 | * | ||
5 | * This program is free software; you can redistribute it and/or | ||
6 | * modify it under the terms of the GNU General Public License as | ||
7 | * published by the Free Software Foundation. | ||
8 | * | ||
9 | * This program is distributed in the hope that it would be useful, | ||
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
12 | * GNU General Public License for more details. | ||
13 | * | ||
14 | * You should have received a copy of the GNU General Public License | ||
15 | * along with this program; if not, write the Free Software Foundation, | ||
16 | * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA | ||
17 | */ | ||
18 | #include <xfs.h> | ||
19 | #include "debug.h" | ||
20 | |||
21 | /* xfs_mount.h drags a lot of crap in, sorry.. */ | ||
22 | #include "xfs_sb.h" | ||
23 | #include "xfs_inum.h" | ||
24 | #include "xfs_ag.h" | ||
25 | #include "xfs_mount.h" | ||
26 | #include "xfs_error.h" | ||
27 | |||
28 | void | ||
29 | cmn_err( | ||
30 | const char *lvl, | ||
31 | const char *fmt, | ||
32 | ...) | ||
33 | { | ||
34 | struct va_format vaf; | ||
35 | va_list args; | ||
36 | |||
37 | va_start(args, fmt); | ||
38 | vaf.fmt = fmt; | ||
39 | vaf.va = &args; | ||
40 | |||
41 | printk("%s%pV", lvl, &vaf); | ||
42 | va_end(args); | ||
43 | |||
44 | BUG_ON(strncmp(lvl, KERN_EMERG, strlen(KERN_EMERG)) == 0); | ||
45 | } | ||
46 | |||
47 | void | ||
48 | xfs_fs_cmn_err( | ||
49 | const char *lvl, | ||
50 | struct xfs_mount *mp, | ||
51 | const char *fmt, | ||
52 | ...) | ||
53 | { | ||
54 | struct va_format vaf; | ||
55 | va_list args; | ||
56 | |||
57 | va_start(args, fmt); | ||
58 | vaf.fmt = fmt; | ||
59 | vaf.va = &args; | ||
60 | |||
61 | printk("%sFilesystem %s: %pV", lvl, mp->m_fsname, &vaf); | ||
62 | va_end(args); | ||
63 | |||
64 | BUG_ON(strncmp(lvl, KERN_EMERG, strlen(KERN_EMERG)) == 0); | ||
65 | } | ||
66 | |||
67 | /* All callers to xfs_cmn_err use CE_ALERT, so don't bother testing lvl */ | ||
68 | void | ||
69 | xfs_cmn_err( | ||
70 | int panic_tag, | ||
71 | const char *lvl, | ||
72 | struct xfs_mount *mp, | ||
73 | const char *fmt, | ||
74 | ...) | ||
75 | { | ||
76 | struct va_format vaf; | ||
77 | va_list args; | ||
78 | int do_panic = 0; | ||
79 | |||
80 | if (xfs_panic_mask && (xfs_panic_mask & panic_tag)) { | ||
81 | printk(KERN_ALERT "XFS: Transforming an alert into a BUG."); | ||
82 | do_panic = 1; | ||
83 | } | ||
84 | |||
85 | va_start(args, fmt); | ||
86 | vaf.fmt = fmt; | ||
87 | vaf.va = &args; | ||
88 | |||
89 | printk(KERN_ALERT "Filesystem %s: %pV", mp->m_fsname, &vaf); | ||
90 | va_end(args); | ||
91 | |||
92 | BUG_ON(do_panic); | ||
93 | } | ||
94 | |||
95 | void | ||
96 | assfail(char *expr, char *file, int line) | ||
97 | { | ||
98 | printk(KERN_CRIT "Assertion failed: %s, file: %s, line: %d\n", expr, | ||
99 | file, line); | ||
100 | BUG(); | ||
101 | } | ||
102 | |||
103 | void | ||
104 | xfs_hex_dump(void *p, int length) | ||
105 | { | ||
106 | print_hex_dump(KERN_ALERT, "", DUMP_PREFIX_ADDRESS, 16, 1, p, length, 1); | ||
107 | } | ||
diff --git a/fs/xfs/support/debug.h b/fs/xfs/support/debug.h deleted file mode 100644 index 05699f67d475..000000000000 --- a/fs/xfs/support/debug.h +++ /dev/null | |||
@@ -1,61 +0,0 @@ | |||
1 | /* | ||
2 | * Copyright (c) 2000-2005 Silicon Graphics, Inc. | ||
3 | * All Rights Reserved. | ||
4 | * | ||
5 | * This program is free software; you can redistribute it and/or | ||
6 | * modify it under the terms of the GNU General Public License as | ||
7 | * published by the Free Software Foundation. | ||
8 | * | ||
9 | * This program is distributed in the hope that it would be useful, | ||
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
12 | * GNU General Public License for more details. | ||
13 | * | ||
14 | * You should have received a copy of the GNU General Public License | ||
15 | * along with this program; if not, write the Free Software Foundation, | ||
16 | * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA | ||
17 | */ | ||
18 | #ifndef __XFS_SUPPORT_DEBUG_H__ | ||
19 | #define __XFS_SUPPORT_DEBUG_H__ | ||
20 | |||
21 | #include <stdarg.h> | ||
22 | |||
23 | struct xfs_mount; | ||
24 | |||
25 | #define CE_DEBUG KERN_DEBUG | ||
26 | #define CE_CONT KERN_INFO | ||
27 | #define CE_NOTE KERN_NOTICE | ||
28 | #define CE_WARN KERN_WARNING | ||
29 | #define CE_ALERT KERN_ALERT | ||
30 | #define CE_PANIC KERN_EMERG | ||
31 | |||
32 | void cmn_err(const char *lvl, const char *fmt, ...) | ||
33 | __attribute__ ((format (printf, 2, 3))); | ||
34 | void xfs_fs_cmn_err( const char *lvl, struct xfs_mount *mp, | ||
35 | const char *fmt, ...) __attribute__ ((format (printf, 3, 4))); | ||
36 | void xfs_cmn_err( int panic_tag, const char *lvl, struct xfs_mount *mp, | ||
37 | const char *fmt, ...) __attribute__ ((format (printf, 4, 5))); | ||
38 | |||
39 | extern void assfail(char *expr, char *f, int l); | ||
40 | |||
41 | #define ASSERT_ALWAYS(expr) \ | ||
42 | (unlikely(expr) ? (void)0 : assfail(#expr, __FILE__, __LINE__)) | ||
43 | |||
44 | #ifndef DEBUG | ||
45 | #define ASSERT(expr) ((void)0) | ||
46 | |||
47 | #ifndef STATIC | ||
48 | # define STATIC static noinline | ||
49 | #endif | ||
50 | |||
51 | #else /* DEBUG */ | ||
52 | |||
53 | #define ASSERT(expr) \ | ||
54 | (unlikely(expr) ? (void)0 : assfail(#expr, __FILE__, __LINE__)) | ||
55 | |||
56 | #ifndef STATIC | ||
57 | # define STATIC noinline | ||
58 | #endif | ||
59 | |||
60 | #endif /* DEBUG */ | ||
61 | #endif /* __XFS_SUPPORT_DEBUG_H__ */ | ||
diff --git a/fs/xfs/xfs_alloc.c b/fs/xfs/xfs_alloc.c index f3227984a9bf..4bc3c649aee4 100644 --- a/fs/xfs/xfs_alloc.c +++ b/fs/xfs/xfs_alloc.c | |||
@@ -147,10 +147,9 @@ xfs_alloc_get_rec( | |||
147 | */ | 147 | */ |
148 | STATIC void | 148 | STATIC void |
149 | xfs_alloc_compute_aligned( | 149 | xfs_alloc_compute_aligned( |
150 | xfs_alloc_arg_t *args, /* allocation argument structure */ | ||
150 | xfs_agblock_t foundbno, /* starting block in found extent */ | 151 | xfs_agblock_t foundbno, /* starting block in found extent */ |
151 | xfs_extlen_t foundlen, /* length in found extent */ | 152 | xfs_extlen_t foundlen, /* length in found extent */ |
152 | xfs_extlen_t alignment, /* alignment for allocation */ | ||
153 | xfs_extlen_t minlen, /* minimum length for allocation */ | ||
154 | xfs_agblock_t *resbno, /* result block number */ | 153 | xfs_agblock_t *resbno, /* result block number */ |
155 | xfs_extlen_t *reslen) /* result length */ | 154 | xfs_extlen_t *reslen) /* result length */ |
156 | { | 155 | { |
@@ -158,8 +157,8 @@ xfs_alloc_compute_aligned( | |||
158 | xfs_extlen_t diff; | 157 | xfs_extlen_t diff; |
159 | xfs_extlen_t len; | 158 | xfs_extlen_t len; |
160 | 159 | ||
161 | if (alignment > 1 && foundlen >= minlen) { | 160 | if (args->alignment > 1 && foundlen >= args->minlen) { |
162 | bno = roundup(foundbno, alignment); | 161 | bno = roundup(foundbno, args->alignment); |
163 | diff = bno - foundbno; | 162 | diff = bno - foundbno; |
164 | len = diff >= foundlen ? 0 : foundlen - diff; | 163 | len = diff >= foundlen ? 0 : foundlen - diff; |
165 | } else { | 164 | } else { |
@@ -464,6 +463,27 @@ xfs_alloc_read_agfl( | |||
464 | return 0; | 463 | return 0; |
465 | } | 464 | } |
466 | 465 | ||
466 | STATIC int | ||
467 | xfs_alloc_update_counters( | ||
468 | struct xfs_trans *tp, | ||
469 | struct xfs_perag *pag, | ||
470 | struct xfs_buf *agbp, | ||
471 | long len) | ||
472 | { | ||
473 | struct xfs_agf *agf = XFS_BUF_TO_AGF(agbp); | ||
474 | |||
475 | pag->pagf_freeblks += len; | ||
476 | be32_add_cpu(&agf->agf_freeblks, len); | ||
477 | |||
478 | xfs_trans_agblocks_delta(tp, len); | ||
479 | if (unlikely(be32_to_cpu(agf->agf_freeblks) > | ||
480 | be32_to_cpu(agf->agf_length))) | ||
481 | return EFSCORRUPTED; | ||
482 | |||
483 | xfs_alloc_log_agf(tp, agbp, XFS_AGF_FREEBLKS); | ||
484 | return 0; | ||
485 | } | ||
486 | |||
467 | /* | 487 | /* |
468 | * Allocation group level functions. | 488 | * Allocation group level functions. |
469 | */ | 489 | */ |
@@ -505,49 +525,44 @@ xfs_alloc_ag_vextent( | |||
505 | ASSERT(0); | 525 | ASSERT(0); |
506 | /* NOTREACHED */ | 526 | /* NOTREACHED */ |
507 | } | 527 | } |
508 | if (error) | 528 | |
529 | if (error || args->agbno == NULLAGBLOCK) | ||
509 | return error; | 530 | return error; |
510 | /* | ||
511 | * If the allocation worked, need to change the agf structure | ||
512 | * (and log it), and the superblock. | ||
513 | */ | ||
514 | if (args->agbno != NULLAGBLOCK) { | ||
515 | xfs_agf_t *agf; /* allocation group freelist header */ | ||
516 | long slen = (long)args->len; | ||
517 | 531 | ||
518 | ASSERT(args->len >= args->minlen && args->len <= args->maxlen); | 532 | ASSERT(args->len >= args->minlen); |
519 | ASSERT(!(args->wasfromfl) || !args->isfl); | 533 | ASSERT(args->len <= args->maxlen); |
520 | ASSERT(args->agbno % args->alignment == 0); | 534 | ASSERT(!args->wasfromfl || !args->isfl); |
521 | if (!(args->wasfromfl)) { | 535 | ASSERT(args->agbno % args->alignment == 0); |
522 | 536 | ||
523 | agf = XFS_BUF_TO_AGF(args->agbp); | 537 | if (!args->wasfromfl) { |
524 | be32_add_cpu(&agf->agf_freeblks, -(args->len)); | 538 | error = xfs_alloc_update_counters(args->tp, args->pag, |
525 | xfs_trans_agblocks_delta(args->tp, | 539 | args->agbp, |
526 | -((long)(args->len))); | 540 | -((long)(args->len))); |
527 | args->pag->pagf_freeblks -= args->len; | 541 | if (error) |
528 | ASSERT(be32_to_cpu(agf->agf_freeblks) <= | 542 | return error; |
529 | be32_to_cpu(agf->agf_length)); | 543 | |
530 | xfs_alloc_log_agf(args->tp, args->agbp, | 544 | /* |
531 | XFS_AGF_FREEBLKS); | 545 | * Search the busylist for these blocks and mark the |
532 | /* | 546 | * transaction as synchronous if blocks are found. This |
533 | * Search the busylist for these blocks and mark the | 547 | * avoids the need to block due to a synchronous log |
534 | * transaction as synchronous if blocks are found. This | 548 | * force to ensure correct ordering as the synchronous |
535 | * avoids the need to block due to a synchronous log | 549 | * transaction will guarantee that for us. |
536 | * force to ensure correct ordering as the synchronous | 550 | */ |
537 | * transaction will guarantee that for us. | 551 | if (xfs_alloc_busy_search(args->mp, args->agno, |
538 | */ | 552 | args->agbno, args->len)) |
539 | if (xfs_alloc_busy_search(args->mp, args->agno, | 553 | xfs_trans_set_sync(args->tp); |
540 | args->agbno, args->len)) | ||
541 | xfs_trans_set_sync(args->tp); | ||
542 | } | ||
543 | if (!args->isfl) | ||
544 | xfs_trans_mod_sb(args->tp, | ||
545 | args->wasdel ? XFS_TRANS_SB_RES_FDBLOCKS : | ||
546 | XFS_TRANS_SB_FDBLOCKS, -slen); | ||
547 | XFS_STATS_INC(xs_allocx); | ||
548 | XFS_STATS_ADD(xs_allocb, args->len); | ||
549 | } | 554 | } |
550 | return 0; | 555 | |
556 | if (!args->isfl) { | ||
557 | xfs_trans_mod_sb(args->tp, args->wasdel ? | ||
558 | XFS_TRANS_SB_RES_FDBLOCKS : | ||
559 | XFS_TRANS_SB_FDBLOCKS, | ||
560 | -((long)(args->len))); | ||
561 | } | ||
562 | |||
563 | XFS_STATS_INC(xs_allocx); | ||
564 | XFS_STATS_ADD(xs_allocb, args->len); | ||
565 | return error; | ||
551 | } | 566 | } |
552 | 567 | ||
553 | /* | 568 | /* |
@@ -693,8 +708,7 @@ xfs_alloc_find_best_extent( | |||
693 | if (error) | 708 | if (error) |
694 | goto error0; | 709 | goto error0; |
695 | XFS_WANT_CORRUPTED_GOTO(i == 1, error0); | 710 | XFS_WANT_CORRUPTED_GOTO(i == 1, error0); |
696 | xfs_alloc_compute_aligned(*sbno, *slen, args->alignment, | 711 | xfs_alloc_compute_aligned(args, *sbno, *slen, &bno, slena); |
697 | args->minlen, &bno, slena); | ||
698 | 712 | ||
699 | /* | 713 | /* |
700 | * The good extent is closer than this one. | 714 | * The good extent is closer than this one. |
@@ -866,8 +880,8 @@ xfs_alloc_ag_vextent_near( | |||
866 | if ((error = xfs_alloc_get_rec(cnt_cur, <bno, <len, &i))) | 880 | if ((error = xfs_alloc_get_rec(cnt_cur, <bno, <len, &i))) |
867 | goto error0; | 881 | goto error0; |
868 | XFS_WANT_CORRUPTED_GOTO(i == 1, error0); | 882 | XFS_WANT_CORRUPTED_GOTO(i == 1, error0); |
869 | xfs_alloc_compute_aligned(ltbno, ltlen, args->alignment, | 883 | xfs_alloc_compute_aligned(args, ltbno, ltlen, |
870 | args->minlen, <bnoa, <lena); | 884 | <bnoa, <lena); |
871 | if (ltlena < args->minlen) | 885 | if (ltlena < args->minlen) |
872 | continue; | 886 | continue; |
873 | args->len = XFS_EXTLEN_MIN(ltlena, args->maxlen); | 887 | args->len = XFS_EXTLEN_MIN(ltlena, args->maxlen); |
@@ -987,8 +1001,8 @@ xfs_alloc_ag_vextent_near( | |||
987 | if ((error = xfs_alloc_get_rec(bno_cur_lt, <bno, <len, &i))) | 1001 | if ((error = xfs_alloc_get_rec(bno_cur_lt, <bno, <len, &i))) |
988 | goto error0; | 1002 | goto error0; |
989 | XFS_WANT_CORRUPTED_GOTO(i == 1, error0); | 1003 | XFS_WANT_CORRUPTED_GOTO(i == 1, error0); |
990 | xfs_alloc_compute_aligned(ltbno, ltlen, args->alignment, | 1004 | xfs_alloc_compute_aligned(args, ltbno, ltlen, |
991 | args->minlen, <bnoa, <lena); | 1005 | <bnoa, <lena); |
992 | if (ltlena >= args->minlen) | 1006 | if (ltlena >= args->minlen) |
993 | break; | 1007 | break; |
994 | if ((error = xfs_btree_decrement(bno_cur_lt, 0, &i))) | 1008 | if ((error = xfs_btree_decrement(bno_cur_lt, 0, &i))) |
@@ -1003,8 +1017,8 @@ xfs_alloc_ag_vextent_near( | |||
1003 | if ((error = xfs_alloc_get_rec(bno_cur_gt, >bno, >len, &i))) | 1017 | if ((error = xfs_alloc_get_rec(bno_cur_gt, >bno, >len, &i))) |
1004 | goto error0; | 1018 | goto error0; |
1005 | XFS_WANT_CORRUPTED_GOTO(i == 1, error0); | 1019 | XFS_WANT_CORRUPTED_GOTO(i == 1, error0); |
1006 | xfs_alloc_compute_aligned(gtbno, gtlen, args->alignment, | 1020 | xfs_alloc_compute_aligned(args, gtbno, gtlen, |
1007 | args->minlen, >bnoa, >lena); | 1021 | >bnoa, >lena); |
1008 | if (gtlena >= args->minlen) | 1022 | if (gtlena >= args->minlen) |
1009 | break; | 1023 | break; |
1010 | if ((error = xfs_btree_increment(bno_cur_gt, 0, &i))) | 1024 | if ((error = xfs_btree_increment(bno_cur_gt, 0, &i))) |
@@ -1183,8 +1197,7 @@ xfs_alloc_ag_vextent_size( | |||
1183 | * once aligned; if not, we search left for something better. | 1197 | * once aligned; if not, we search left for something better. |
1184 | * This can't happen in the second case above. | 1198 | * This can't happen in the second case above. |
1185 | */ | 1199 | */ |
1186 | xfs_alloc_compute_aligned(fbno, flen, args->alignment, args->minlen, | 1200 | xfs_alloc_compute_aligned(args, fbno, flen, &rbno, &rlen); |
1187 | &rbno, &rlen); | ||
1188 | rlen = XFS_EXTLEN_MIN(args->maxlen, rlen); | 1201 | rlen = XFS_EXTLEN_MIN(args->maxlen, rlen); |
1189 | XFS_WANT_CORRUPTED_GOTO(rlen == 0 || | 1202 | XFS_WANT_CORRUPTED_GOTO(rlen == 0 || |
1190 | (rlen <= flen && rbno + rlen <= fbno + flen), error0); | 1203 | (rlen <= flen && rbno + rlen <= fbno + flen), error0); |
@@ -1209,8 +1222,8 @@ xfs_alloc_ag_vextent_size( | |||
1209 | XFS_WANT_CORRUPTED_GOTO(i == 1, error0); | 1222 | XFS_WANT_CORRUPTED_GOTO(i == 1, error0); |
1210 | if (flen < bestrlen) | 1223 | if (flen < bestrlen) |
1211 | break; | 1224 | break; |
1212 | xfs_alloc_compute_aligned(fbno, flen, args->alignment, | 1225 | xfs_alloc_compute_aligned(args, fbno, flen, |
1213 | args->minlen, &rbno, &rlen); | 1226 | &rbno, &rlen); |
1214 | rlen = XFS_EXTLEN_MIN(args->maxlen, rlen); | 1227 | rlen = XFS_EXTLEN_MIN(args->maxlen, rlen); |
1215 | XFS_WANT_CORRUPTED_GOTO(rlen == 0 || | 1228 | XFS_WANT_CORRUPTED_GOTO(rlen == 0 || |
1216 | (rlen <= flen && rbno + rlen <= fbno + flen), | 1229 | (rlen <= flen && rbno + rlen <= fbno + flen), |
@@ -1388,6 +1401,7 @@ xfs_free_ag_extent( | |||
1388 | xfs_mount_t *mp; /* mount point struct for filesystem */ | 1401 | xfs_mount_t *mp; /* mount point struct for filesystem */ |
1389 | xfs_agblock_t nbno; /* new starting block of freespace */ | 1402 | xfs_agblock_t nbno; /* new starting block of freespace */ |
1390 | xfs_extlen_t nlen; /* new length of freespace */ | 1403 | xfs_extlen_t nlen; /* new length of freespace */ |
1404 | xfs_perag_t *pag; /* per allocation group data */ | ||
1391 | 1405 | ||
1392 | mp = tp->t_mountp; | 1406 | mp = tp->t_mountp; |
1393 | /* | 1407 | /* |
@@ -1586,30 +1600,20 @@ xfs_free_ag_extent( | |||
1586 | XFS_WANT_CORRUPTED_GOTO(i == 1, error0); | 1600 | XFS_WANT_CORRUPTED_GOTO(i == 1, error0); |
1587 | xfs_btree_del_cursor(cnt_cur, XFS_BTREE_NOERROR); | 1601 | xfs_btree_del_cursor(cnt_cur, XFS_BTREE_NOERROR); |
1588 | cnt_cur = NULL; | 1602 | cnt_cur = NULL; |
1603 | |||
1589 | /* | 1604 | /* |
1590 | * Update the freespace totals in the ag and superblock. | 1605 | * Update the freespace totals in the ag and superblock. |
1591 | */ | 1606 | */ |
1592 | { | 1607 | pag = xfs_perag_get(mp, agno); |
1593 | xfs_agf_t *agf; | 1608 | error = xfs_alloc_update_counters(tp, pag, agbp, len); |
1594 | xfs_perag_t *pag; /* per allocation group data */ | 1609 | xfs_perag_put(pag); |
1595 | 1610 | if (error) | |
1596 | pag = xfs_perag_get(mp, agno); | 1611 | goto error0; |
1597 | pag->pagf_freeblks += len; | 1612 | |
1598 | xfs_perag_put(pag); | 1613 | if (!isfl) |
1599 | 1614 | xfs_trans_mod_sb(tp, XFS_TRANS_SB_FDBLOCKS, (long)len); | |
1600 | agf = XFS_BUF_TO_AGF(agbp); | 1615 | XFS_STATS_INC(xs_freex); |
1601 | be32_add_cpu(&agf->agf_freeblks, len); | 1616 | XFS_STATS_ADD(xs_freeb, len); |
1602 | xfs_trans_agblocks_delta(tp, len); | ||
1603 | XFS_WANT_CORRUPTED_GOTO( | ||
1604 | be32_to_cpu(agf->agf_freeblks) <= | ||
1605 | be32_to_cpu(agf->agf_length), | ||
1606 | error0); | ||
1607 | xfs_alloc_log_agf(tp, agbp, XFS_AGF_FREEBLKS); | ||
1608 | if (!isfl) | ||
1609 | xfs_trans_mod_sb(tp, XFS_TRANS_SB_FDBLOCKS, (long)len); | ||
1610 | XFS_STATS_INC(xs_freex); | ||
1611 | XFS_STATS_ADD(xs_freeb, len); | ||
1612 | } | ||
1613 | 1617 | ||
1614 | trace_xfs_free_extent(mp, agno, bno, len, isfl, haveleft, haveright); | 1618 | trace_xfs_free_extent(mp, agno, bno, len, isfl, haveleft, haveright); |
1615 | 1619 | ||
diff --git a/fs/xfs/xfs_bmap.c b/fs/xfs/xfs_bmap.c index dc3afd7739ff..fa00788de2f5 100644 --- a/fs/xfs/xfs_bmap.c +++ b/fs/xfs/xfs_bmap.c | |||
@@ -2365,6 +2365,13 @@ xfs_bmap_rtalloc( | |||
2365 | */ | 2365 | */ |
2366 | if (ralen * mp->m_sb.sb_rextsize >= MAXEXTLEN) | 2366 | if (ralen * mp->m_sb.sb_rextsize >= MAXEXTLEN) |
2367 | ralen = MAXEXTLEN / mp->m_sb.sb_rextsize; | 2367 | ralen = MAXEXTLEN / mp->m_sb.sb_rextsize; |
2368 | |||
2369 | /* | ||
2370 | * Lock out other modifications to the RT bitmap inode. | ||
2371 | */ | ||
2372 | xfs_ilock(mp->m_rbmip, XFS_ILOCK_EXCL); | ||
2373 | xfs_trans_ijoin_ref(ap->tp, mp->m_rbmip, XFS_ILOCK_EXCL); | ||
2374 | |||
2368 | /* | 2375 | /* |
2369 | * If it's an allocation to an empty file at offset 0, | 2376 | * If it's an allocation to an empty file at offset 0, |
2370 | * pick an extent that will space things out in the rt area. | 2377 | * pick an extent that will space things out in the rt area. |
@@ -3519,7 +3526,7 @@ xfs_bmap_search_extents( | |||
3519 | 3526 | ||
3520 | if (unlikely(!(gotp->br_startblock) && (*lastxp != NULLEXTNUM) && | 3527 | if (unlikely(!(gotp->br_startblock) && (*lastxp != NULLEXTNUM) && |
3521 | !(XFS_IS_REALTIME_INODE(ip) && fork == XFS_DATA_FORK))) { | 3528 | !(XFS_IS_REALTIME_INODE(ip) && fork == XFS_DATA_FORK))) { |
3522 | xfs_cmn_err(XFS_PTAG_FSBLOCK_ZERO, CE_ALERT, ip->i_mount, | 3529 | xfs_alert_tag(ip->i_mount, XFS_PTAG_FSBLOCK_ZERO, |
3523 | "Access to block zero in inode %llu " | 3530 | "Access to block zero in inode %llu " |
3524 | "start_block: %llx start_off: %llx " | 3531 | "start_block: %llx start_off: %llx " |
3525 | "blkcnt: %llx extent-state: %x lastx: %x\n", | 3532 | "blkcnt: %llx extent-state: %x lastx: %x\n", |
@@ -4193,12 +4200,11 @@ xfs_bmap_read_extents( | |||
4193 | num_recs = xfs_btree_get_numrecs(block); | 4200 | num_recs = xfs_btree_get_numrecs(block); |
4194 | if (unlikely(i + num_recs > room)) { | 4201 | if (unlikely(i + num_recs > room)) { |
4195 | ASSERT(i + num_recs <= room); | 4202 | ASSERT(i + num_recs <= room); |
4196 | xfs_fs_repair_cmn_err(CE_WARN, ip->i_mount, | 4203 | xfs_warn(ip->i_mount, |
4197 | "corrupt dinode %Lu, (btree extents).", | 4204 | "corrupt dinode %Lu, (btree extents).", |
4198 | (unsigned long long) ip->i_ino); | 4205 | (unsigned long long) ip->i_ino); |
4199 | XFS_ERROR_REPORT("xfs_bmap_read_extents(1)", | 4206 | XFS_CORRUPTION_ERROR("xfs_bmap_read_extents(1)", |
4200 | XFS_ERRLEVEL_LOW, | 4207 | XFS_ERRLEVEL_LOW, ip->i_mount, block); |
4201 | ip->i_mount); | ||
4202 | goto error0; | 4208 | goto error0; |
4203 | } | 4209 | } |
4204 | XFS_WANT_CORRUPTED_GOTO( | 4210 | XFS_WANT_CORRUPTED_GOTO( |
@@ -5772,7 +5778,7 @@ xfs_check_block( | |||
5772 | else | 5778 | else |
5773 | thispa = XFS_BMBT_PTR_ADDR(mp, block, j, dmxr); | 5779 | thispa = XFS_BMBT_PTR_ADDR(mp, block, j, dmxr); |
5774 | if (*thispa == *pp) { | 5780 | if (*thispa == *pp) { |
5775 | cmn_err(CE_WARN, "%s: thispa(%d) == pp(%d) %Ld", | 5781 | xfs_warn(mp, "%s: thispa(%d) == pp(%d) %Ld", |
5776 | __func__, j, i, | 5782 | __func__, j, i, |
5777 | (unsigned long long)be64_to_cpu(*thispa)); | 5783 | (unsigned long long)be64_to_cpu(*thispa)); |
5778 | panic("%s: ptrs are equal in node\n", | 5784 | panic("%s: ptrs are equal in node\n", |
@@ -5937,11 +5943,11 @@ xfs_bmap_check_leaf_extents( | |||
5937 | return; | 5943 | return; |
5938 | 5944 | ||
5939 | error0: | 5945 | error0: |
5940 | cmn_err(CE_WARN, "%s: at error0", __func__); | 5946 | xfs_warn(mp, "%s: at error0", __func__); |
5941 | if (bp_release) | 5947 | if (bp_release) |
5942 | xfs_trans_brelse(NULL, bp); | 5948 | xfs_trans_brelse(NULL, bp); |
5943 | error_norelse: | 5949 | error_norelse: |
5944 | cmn_err(CE_WARN, "%s: BAD after btree leaves for %d extents", | 5950 | xfs_warn(mp, "%s: BAD after btree leaves for %d extents", |
5945 | __func__, i); | 5951 | __func__, i); |
5946 | panic("%s: CORRUPTED BTREE OR SOMETHING", __func__); | 5952 | panic("%s: CORRUPTED BTREE OR SOMETHING", __func__); |
5947 | return; | 5953 | return; |
@@ -6144,7 +6150,7 @@ xfs_bmap_punch_delalloc_range( | |||
6144 | if (error) { | 6150 | if (error) { |
6145 | /* something screwed, just bail */ | 6151 | /* something screwed, just bail */ |
6146 | if (!XFS_FORCED_SHUTDOWN(ip->i_mount)) { | 6152 | if (!XFS_FORCED_SHUTDOWN(ip->i_mount)) { |
6147 | xfs_fs_cmn_err(CE_ALERT, ip->i_mount, | 6153 | xfs_alert(ip->i_mount, |
6148 | "Failed delalloc mapping lookup ino %lld fsb %lld.", | 6154 | "Failed delalloc mapping lookup ino %lld fsb %lld.", |
6149 | ip->i_ino, start_fsb); | 6155 | ip->i_ino, start_fsb); |
6150 | } | 6156 | } |
diff --git a/fs/xfs/xfs_buf_item.c b/fs/xfs/xfs_buf_item.c index 6f8c21ce0d6d..e5413d96f1af 100644 --- a/fs/xfs/xfs_buf_item.c +++ b/fs/xfs/xfs_buf_item.c | |||
@@ -130,10 +130,12 @@ xfs_buf_item_log_check( | |||
130 | orig = bip->bli_orig; | 130 | orig = bip->bli_orig; |
131 | buffer = XFS_BUF_PTR(bp); | 131 | buffer = XFS_BUF_PTR(bp); |
132 | for (x = 0; x < XFS_BUF_COUNT(bp); x++) { | 132 | for (x = 0; x < XFS_BUF_COUNT(bp); x++) { |
133 | if (orig[x] != buffer[x] && !btst(bip->bli_logged, x)) | 133 | if (orig[x] != buffer[x] && !btst(bip->bli_logged, x)) { |
134 | cmn_err(CE_PANIC, | 134 | xfs_emerg(bp->b_mount, |
135 | "xfs_buf_item_log_check bip %x buffer %x orig %x index %d", | 135 | "%s: bip %x buffer %x orig %x index %d", |
136 | bip, bp, orig, x); | 136 | __func__, bip, bp, orig, x); |
137 | ASSERT(0); | ||
138 | } | ||
137 | } | 139 | } |
138 | } | 140 | } |
139 | #else | 141 | #else |
@@ -983,10 +985,9 @@ xfs_buf_iodone_callbacks( | |||
983 | if (XFS_BUF_TARGET(bp) != lasttarg || | 985 | if (XFS_BUF_TARGET(bp) != lasttarg || |
984 | time_after(jiffies, (lasttime + 5*HZ))) { | 986 | time_after(jiffies, (lasttime + 5*HZ))) { |
985 | lasttime = jiffies; | 987 | lasttime = jiffies; |
986 | cmn_err(CE_ALERT, "Device %s, XFS metadata write error" | 988 | xfs_alert(mp, "Device %s: metadata write error block 0x%llx", |
987 | " block 0x%llx in %s", | ||
988 | XFS_BUFTARG_NAME(XFS_BUF_TARGET(bp)), | 989 | XFS_BUFTARG_NAME(XFS_BUF_TARGET(bp)), |
989 | (__uint64_t)XFS_BUF_ADDR(bp), mp->m_fsname); | 990 | (__uint64_t)XFS_BUF_ADDR(bp)); |
990 | } | 991 | } |
991 | lasttarg = XFS_BUF_TARGET(bp); | 992 | lasttarg = XFS_BUF_TARGET(bp); |
992 | 993 | ||
diff --git a/fs/xfs/xfs_da_btree.c b/fs/xfs/xfs_da_btree.c index 1c00bedb3175..6102ac6d1dff 100644 --- a/fs/xfs/xfs_da_btree.c +++ b/fs/xfs/xfs_da_btree.c | |||
@@ -1995,13 +1995,12 @@ xfs_da_do_buf( | |||
1995 | error = mappedbno == -2 ? 0 : XFS_ERROR(EFSCORRUPTED); | 1995 | error = mappedbno == -2 ? 0 : XFS_ERROR(EFSCORRUPTED); |
1996 | if (unlikely(error == EFSCORRUPTED)) { | 1996 | if (unlikely(error == EFSCORRUPTED)) { |
1997 | if (xfs_error_level >= XFS_ERRLEVEL_LOW) { | 1997 | if (xfs_error_level >= XFS_ERRLEVEL_LOW) { |
1998 | cmn_err(CE_ALERT, "xfs_da_do_buf: bno %lld\n", | 1998 | xfs_alert(mp, "%s: bno %lld dir: inode %lld", |
1999 | (long long)bno); | 1999 | __func__, (long long)bno, |
2000 | cmn_err(CE_ALERT, "dir: inode %lld\n", | ||
2001 | (long long)dp->i_ino); | 2000 | (long long)dp->i_ino); |
2002 | for (i = 0; i < nmap; i++) { | 2001 | for (i = 0; i < nmap; i++) { |
2003 | cmn_err(CE_ALERT, | 2002 | xfs_alert(mp, |
2004 | "[%02d] br_startoff %lld br_startblock %lld br_blockcount %lld br_state %d\n", | 2003 | "[%02d] br_startoff %lld br_startblock %lld br_blockcount %lld br_state %d", |
2005 | i, | 2004 | i, |
2006 | (long long)mapp[i].br_startoff, | 2005 | (long long)mapp[i].br_startoff, |
2007 | (long long)mapp[i].br_startblock, | 2006 | (long long)mapp[i].br_startblock, |
diff --git a/fs/xfs/xfs_dfrag.c b/fs/xfs/xfs_dfrag.c index e60490bc00a6..be628677c288 100644 --- a/fs/xfs/xfs_dfrag.c +++ b/fs/xfs/xfs_dfrag.c | |||
@@ -270,9 +270,9 @@ xfs_swap_extents( | |||
270 | /* check inode formats now that data is flushed */ | 270 | /* check inode formats now that data is flushed */ |
271 | error = xfs_swap_extents_check_format(ip, tip); | 271 | error = xfs_swap_extents_check_format(ip, tip); |
272 | if (error) { | 272 | if (error) { |
273 | xfs_fs_cmn_err(CE_NOTE, mp, | 273 | xfs_notice(mp, |
274 | "%s: inode 0x%llx format is incompatible for exchanging.", | 274 | "%s: inode 0x%llx format is incompatible for exchanging.", |
275 | __FILE__, ip->i_ino); | 275 | __func__, ip->i_ino); |
276 | goto out_unlock; | 276 | goto out_unlock; |
277 | } | 277 | } |
278 | 278 | ||
diff --git a/fs/xfs/xfs_dir2.c b/fs/xfs/xfs_dir2.c index a1321bc7f192..dba7a71cedf3 100644 --- a/fs/xfs/xfs_dir2.c +++ b/fs/xfs/xfs_dir2.c | |||
@@ -159,7 +159,7 @@ xfs_dir_ino_validate( | |||
159 | XFS_AGINO_TO_INO(mp, agno, agino) == ino; | 159 | XFS_AGINO_TO_INO(mp, agno, agino) == ino; |
160 | if (unlikely(XFS_TEST_ERROR(!ino_ok, mp, XFS_ERRTAG_DIR_INO_VALIDATE, | 160 | if (unlikely(XFS_TEST_ERROR(!ino_ok, mp, XFS_ERRTAG_DIR_INO_VALIDATE, |
161 | XFS_RANDOM_DIR_INO_VALIDATE))) { | 161 | XFS_RANDOM_DIR_INO_VALIDATE))) { |
162 | xfs_fs_cmn_err(CE_WARN, mp, "Invalid inode number 0x%Lx", | 162 | xfs_warn(mp, "Invalid inode number 0x%Lx", |
163 | (unsigned long long) ino); | 163 | (unsigned long long) ino); |
164 | XFS_ERROR_REPORT("xfs_dir_ino_validate", XFS_ERRLEVEL_LOW, mp); | 164 | XFS_ERROR_REPORT("xfs_dir_ino_validate", XFS_ERRLEVEL_LOW, mp); |
165 | return XFS_ERROR(EFSCORRUPTED); | 165 | return XFS_ERROR(EFSCORRUPTED); |
diff --git a/fs/xfs/xfs_dir2_node.c b/fs/xfs/xfs_dir2_node.c index f9a0864b696a..a0aab7d3294f 100644 --- a/fs/xfs/xfs_dir2_node.c +++ b/fs/xfs/xfs_dir2_node.c | |||
@@ -899,10 +899,9 @@ xfs_dir2_leafn_rebalance( | |||
899 | if(blk2->index < 0) { | 899 | if(blk2->index < 0) { |
900 | state->inleaf = 1; | 900 | state->inleaf = 1; |
901 | blk2->index = 0; | 901 | blk2->index = 0; |
902 | cmn_err(CE_ALERT, | 902 | xfs_alert(args->dp->i_mount, |
903 | "xfs_dir2_leafn_rebalance: picked the wrong leaf? reverting original leaf: " | 903 | "%s: picked the wrong leaf? reverting original leaf: blk1->index %d\n", |
904 | "blk1->index %d\n", | 904 | __func__, blk1->index); |
905 | blk1->index); | ||
906 | } | 905 | } |
907 | } | 906 | } |
908 | 907 | ||
@@ -1641,26 +1640,22 @@ xfs_dir2_node_addname_int( | |||
1641 | } | 1640 | } |
1642 | 1641 | ||
1643 | if (unlikely(xfs_dir2_db_to_fdb(mp, dbno) != fbno)) { | 1642 | if (unlikely(xfs_dir2_db_to_fdb(mp, dbno) != fbno)) { |
1644 | cmn_err(CE_ALERT, | 1643 | xfs_alert(mp, |
1645 | "xfs_dir2_node_addname_int: dir ino " | 1644 | "%s: dir ino " "%llu needed freesp block %lld for\n" |
1646 | "%llu needed freesp block %lld for\n" | 1645 | " data block %lld, got %lld ifbno %llu lastfbno %d", |
1647 | " data block %lld, got %lld\n" | 1646 | __func__, (unsigned long long)dp->i_ino, |
1648 | " ifbno %llu lastfbno %d\n", | ||
1649 | (unsigned long long)dp->i_ino, | ||
1650 | (long long)xfs_dir2_db_to_fdb(mp, dbno), | 1647 | (long long)xfs_dir2_db_to_fdb(mp, dbno), |
1651 | (long long)dbno, (long long)fbno, | 1648 | (long long)dbno, (long long)fbno, |
1652 | (unsigned long long)ifbno, lastfbno); | 1649 | (unsigned long long)ifbno, lastfbno); |
1653 | if (fblk) { | 1650 | if (fblk) { |
1654 | cmn_err(CE_ALERT, | 1651 | xfs_alert(mp, |
1655 | " fblk 0x%p blkno %llu " | 1652 | " fblk 0x%p blkno %llu index %d magic 0x%x", |
1656 | "index %d magic 0x%x\n", | ||
1657 | fblk, | 1653 | fblk, |
1658 | (unsigned long long)fblk->blkno, | 1654 | (unsigned long long)fblk->blkno, |
1659 | fblk->index, | 1655 | fblk->index, |
1660 | fblk->magic); | 1656 | fblk->magic); |
1661 | } else { | 1657 | } else { |
1662 | cmn_err(CE_ALERT, | 1658 | xfs_alert(mp, " ... fblk is NULL"); |
1663 | " ... fblk is NULL\n"); | ||
1664 | } | 1659 | } |
1665 | XFS_ERROR_REPORT("xfs_dir2_node_addname_int", | 1660 | XFS_ERROR_REPORT("xfs_dir2_node_addname_int", |
1666 | XFS_ERRLEVEL_LOW, mp); | 1661 | XFS_ERRLEVEL_LOW, mp); |
diff --git a/fs/xfs/xfs_error.c b/fs/xfs/xfs_error.c index 4c7db74a05f7..39f06336b99d 100644 --- a/fs/xfs/xfs_error.c +++ b/fs/xfs/xfs_error.c | |||
@@ -48,7 +48,7 @@ xfs_error_trap(int e) | |||
48 | break; | 48 | break; |
49 | if (e != xfs_etrap[i]) | 49 | if (e != xfs_etrap[i]) |
50 | continue; | 50 | continue; |
51 | cmn_err(CE_NOTE, "xfs_error_trap: error %d", e); | 51 | xfs_notice(NULL, "%s: error %d", __func__, e); |
52 | BUG(); | 52 | BUG(); |
53 | break; | 53 | break; |
54 | } | 54 | } |
@@ -74,7 +74,7 @@ xfs_error_test(int error_tag, int *fsidp, char *expression, | |||
74 | 74 | ||
75 | for (i = 0; i < XFS_NUM_INJECT_ERROR; i++) { | 75 | for (i = 0; i < XFS_NUM_INJECT_ERROR; i++) { |
76 | if (xfs_etest[i] == error_tag && xfs_etest_fsid[i] == fsid) { | 76 | if (xfs_etest[i] == error_tag && xfs_etest_fsid[i] == fsid) { |
77 | cmn_err(CE_WARN, | 77 | xfs_warn(NULL, |
78 | "Injecting error (%s) at file %s, line %d, on filesystem \"%s\"", | 78 | "Injecting error (%s) at file %s, line %d, on filesystem \"%s\"", |
79 | expression, file, line, xfs_etest_fsname[i]); | 79 | expression, file, line, xfs_etest_fsname[i]); |
80 | return 1; | 80 | return 1; |
@@ -95,14 +95,14 @@ xfs_errortag_add(int error_tag, xfs_mount_t *mp) | |||
95 | 95 | ||
96 | for (i = 0; i < XFS_NUM_INJECT_ERROR; i++) { | 96 | for (i = 0; i < XFS_NUM_INJECT_ERROR; i++) { |
97 | if (xfs_etest_fsid[i] == fsid && xfs_etest[i] == error_tag) { | 97 | if (xfs_etest_fsid[i] == fsid && xfs_etest[i] == error_tag) { |
98 | cmn_err(CE_WARN, "XFS error tag #%d on", error_tag); | 98 | xfs_warn(mp, "error tag #%d on", error_tag); |
99 | return 0; | 99 | return 0; |
100 | } | 100 | } |
101 | } | 101 | } |
102 | 102 | ||
103 | for (i = 0; i < XFS_NUM_INJECT_ERROR; i++) { | 103 | for (i = 0; i < XFS_NUM_INJECT_ERROR; i++) { |
104 | if (xfs_etest[i] == 0) { | 104 | if (xfs_etest[i] == 0) { |
105 | cmn_err(CE_WARN, "Turned on XFS error tag #%d", | 105 | xfs_warn(mp, "Turned on XFS error tag #%d", |
106 | error_tag); | 106 | error_tag); |
107 | xfs_etest[i] = error_tag; | 107 | xfs_etest[i] = error_tag; |
108 | xfs_etest_fsid[i] = fsid; | 108 | xfs_etest_fsid[i] = fsid; |
@@ -114,7 +114,7 @@ xfs_errortag_add(int error_tag, xfs_mount_t *mp) | |||
114 | } | 114 | } |
115 | } | 115 | } |
116 | 116 | ||
117 | cmn_err(CE_WARN, "error tag overflow, too many turned on"); | 117 | xfs_warn(mp, "error tag overflow, too many turned on"); |
118 | 118 | ||
119 | return 1; | 119 | return 1; |
120 | } | 120 | } |
@@ -133,7 +133,7 @@ xfs_errortag_clearall(xfs_mount_t *mp, int loud) | |||
133 | if ((fsid == 0LL || xfs_etest_fsid[i] == fsid) && | 133 | if ((fsid == 0LL || xfs_etest_fsid[i] == fsid) && |
134 | xfs_etest[i] != 0) { | 134 | xfs_etest[i] != 0) { |
135 | cleared = 1; | 135 | cleared = 1; |
136 | cmn_err(CE_WARN, "Clearing XFS error tag #%d", | 136 | xfs_warn(mp, "Clearing XFS error tag #%d", |
137 | xfs_etest[i]); | 137 | xfs_etest[i]); |
138 | xfs_etest[i] = 0; | 138 | xfs_etest[i] = 0; |
139 | xfs_etest_fsid[i] = 0LL; | 139 | xfs_etest_fsid[i] = 0LL; |
@@ -144,9 +144,7 @@ xfs_errortag_clearall(xfs_mount_t *mp, int loud) | |||
144 | } | 144 | } |
145 | 145 | ||
146 | if (loud || cleared) | 146 | if (loud || cleared) |
147 | cmn_err(CE_WARN, | 147 | xfs_warn(mp, "Cleared all XFS error tags for filesystem"); |
148 | "Cleared all XFS error tags for filesystem \"%s\"", | ||
149 | mp->m_fsname); | ||
150 | 148 | ||
151 | return 0; | 149 | return 0; |
152 | } | 150 | } |
@@ -162,9 +160,8 @@ xfs_error_report( | |||
162 | inst_t *ra) | 160 | inst_t *ra) |
163 | { | 161 | { |
164 | if (level <= xfs_error_level) { | 162 | if (level <= xfs_error_level) { |
165 | xfs_cmn_err(XFS_PTAG_ERROR_REPORT, | 163 | xfs_alert_tag(mp, XFS_PTAG_ERROR_REPORT, |
166 | CE_ALERT, mp, | 164 | "Internal error %s at line %d of file %s. Caller 0x%p\n", |
167 | "XFS internal error %s at line %d of file %s. Caller 0x%p\n", | ||
168 | tag, linenum, filename, ra); | 165 | tag, linenum, filename, ra); |
169 | 166 | ||
170 | xfs_stack_trace(); | 167 | xfs_stack_trace(); |
@@ -184,4 +181,5 @@ xfs_corruption_error( | |||
184 | if (level <= xfs_error_level) | 181 | if (level <= xfs_error_level) |
185 | xfs_hex_dump(p, 16); | 182 | xfs_hex_dump(p, 16); |
186 | xfs_error_report(tag, level, mp, filename, linenum, ra); | 183 | xfs_error_report(tag, level, mp, filename, linenum, ra); |
184 | xfs_alert(mp, "Corruption detected. Unmount and run xfs_repair"); | ||
187 | } | 185 | } |
diff --git a/fs/xfs/xfs_error.h b/fs/xfs/xfs_error.h index 10dce5475f02..079a367f44ee 100644 --- a/fs/xfs/xfs_error.h +++ b/fs/xfs/xfs_error.h | |||
@@ -145,10 +145,8 @@ extern int xfs_errortag_clearall(struct xfs_mount *mp, int loud); | |||
145 | #endif /* DEBUG */ | 145 | #endif /* DEBUG */ |
146 | 146 | ||
147 | /* | 147 | /* |
148 | * XFS panic tags -- allow a call to xfs_cmn_err() be turned into | 148 | * XFS panic tags -- allow a call to xfs_alert_tag() be turned into |
149 | * a panic by setting xfs_panic_mask in a | 149 | * a panic by setting xfs_panic_mask in a sysctl. |
150 | * sysctl. update xfs_max[XFS_PARAM] if | ||
151 | * more are added. | ||
152 | */ | 150 | */ |
153 | #define XFS_NO_PTAG 0 | 151 | #define XFS_NO_PTAG 0 |
154 | #define XFS_PTAG_IFLUSH 0x00000001 | 152 | #define XFS_PTAG_IFLUSH 0x00000001 |
@@ -160,17 +158,4 @@ extern int xfs_errortag_clearall(struct xfs_mount *mp, int loud); | |||
160 | #define XFS_PTAG_SHUTDOWN_LOGERROR 0x00000040 | 158 | #define XFS_PTAG_SHUTDOWN_LOGERROR 0x00000040 |
161 | #define XFS_PTAG_FSBLOCK_ZERO 0x00000080 | 159 | #define XFS_PTAG_FSBLOCK_ZERO 0x00000080 |
162 | 160 | ||
163 | struct xfs_mount; | ||
164 | |||
165 | extern void xfs_hex_dump(void *p, int length); | ||
166 | |||
167 | #define xfs_fs_repair_cmn_err(level, mp, fmt, args...) \ | ||
168 | xfs_fs_cmn_err(level, mp, fmt " Unmount and run xfs_repair.", ## args) | ||
169 | |||
170 | #define xfs_fs_mount_cmn_err(f, fmt, args...) \ | ||
171 | do { \ | ||
172 | if (!(f & XFS_MFSI_QUIET)) \ | ||
173 | cmn_err(CE_WARN, "XFS: " fmt, ## args); \ | ||
174 | } while (0) | ||
175 | |||
176 | #endif /* __XFS_ERROR_H__ */ | 161 | #endif /* __XFS_ERROR_H__ */ |
diff --git a/fs/xfs/xfs_fsops.c b/fs/xfs/xfs_fsops.c index 85668efb3e3e..9153d2c77caf 100644 --- a/fs/xfs/xfs_fsops.c +++ b/fs/xfs/xfs_fsops.c | |||
@@ -385,8 +385,8 @@ xfs_growfs_data_private( | |||
385 | XFS_AGB_TO_DADDR(mp, agno, XFS_SB_BLOCK(mp)), | 385 | XFS_AGB_TO_DADDR(mp, agno, XFS_SB_BLOCK(mp)), |
386 | XFS_FSS_TO_BB(mp, 1), 0, &bp); | 386 | XFS_FSS_TO_BB(mp, 1), 0, &bp); |
387 | if (error) { | 387 | if (error) { |
388 | xfs_fs_cmn_err(CE_WARN, mp, | 388 | xfs_warn(mp, |
389 | "error %d reading secondary superblock for ag %d", | 389 | "error %d reading secondary superblock for ag %d", |
390 | error, agno); | 390 | error, agno); |
391 | break; | 391 | break; |
392 | } | 392 | } |
@@ -399,7 +399,7 @@ xfs_growfs_data_private( | |||
399 | if (!(error = xfs_bwrite(mp, bp))) { | 399 | if (!(error = xfs_bwrite(mp, bp))) { |
400 | continue; | 400 | continue; |
401 | } else { | 401 | } else { |
402 | xfs_fs_cmn_err(CE_WARN, mp, | 402 | xfs_warn(mp, |
403 | "write error %d updating secondary superblock for ag %d", | 403 | "write error %d updating secondary superblock for ag %d", |
404 | error, agno); | 404 | error, agno); |
405 | break; /* no point in continuing */ | 405 | break; /* no point in continuing */ |
diff --git a/fs/xfs/xfs_ialloc.c b/fs/xfs/xfs_ialloc.c index 0626a32c3447..84ebeec16642 100644 --- a/fs/xfs/xfs_ialloc.c +++ b/fs/xfs/xfs_ialloc.c | |||
@@ -1055,28 +1055,23 @@ xfs_difree( | |||
1055 | */ | 1055 | */ |
1056 | agno = XFS_INO_TO_AGNO(mp, inode); | 1056 | agno = XFS_INO_TO_AGNO(mp, inode); |
1057 | if (agno >= mp->m_sb.sb_agcount) { | 1057 | if (agno >= mp->m_sb.sb_agcount) { |
1058 | cmn_err(CE_WARN, | 1058 | xfs_warn(mp, "%s: agno >= mp->m_sb.sb_agcount (%d >= %d).", |
1059 | "xfs_difree: agno >= mp->m_sb.sb_agcount (%d >= %d) on %s. Returning EINVAL.", | 1059 | __func__, agno, mp->m_sb.sb_agcount); |
1060 | agno, mp->m_sb.sb_agcount, mp->m_fsname); | ||
1061 | ASSERT(0); | 1060 | ASSERT(0); |
1062 | return XFS_ERROR(EINVAL); | 1061 | return XFS_ERROR(EINVAL); |
1063 | } | 1062 | } |
1064 | agino = XFS_INO_TO_AGINO(mp, inode); | 1063 | agino = XFS_INO_TO_AGINO(mp, inode); |
1065 | if (inode != XFS_AGINO_TO_INO(mp, agno, agino)) { | 1064 | if (inode != XFS_AGINO_TO_INO(mp, agno, agino)) { |
1066 | cmn_err(CE_WARN, | 1065 | xfs_warn(mp, "%s: inode != XFS_AGINO_TO_INO() (%llu != %llu).", |
1067 | "xfs_difree: inode != XFS_AGINO_TO_INO() " | 1066 | __func__, (unsigned long long)inode, |
1068 | "(%llu != %llu) on %s. Returning EINVAL.", | 1067 | (unsigned long long)XFS_AGINO_TO_INO(mp, agno, agino)); |
1069 | (unsigned long long)inode, | ||
1070 | (unsigned long long)XFS_AGINO_TO_INO(mp, agno, agino), | ||
1071 | mp->m_fsname); | ||
1072 | ASSERT(0); | 1068 | ASSERT(0); |
1073 | return XFS_ERROR(EINVAL); | 1069 | return XFS_ERROR(EINVAL); |
1074 | } | 1070 | } |
1075 | agbno = XFS_AGINO_TO_AGBNO(mp, agino); | 1071 | agbno = XFS_AGINO_TO_AGBNO(mp, agino); |
1076 | if (agbno >= mp->m_sb.sb_agblocks) { | 1072 | if (agbno >= mp->m_sb.sb_agblocks) { |
1077 | cmn_err(CE_WARN, | 1073 | xfs_warn(mp, "%s: agbno >= mp->m_sb.sb_agblocks (%d >= %d).", |
1078 | "xfs_difree: agbno >= mp->m_sb.sb_agblocks (%d >= %d) on %s. Returning EINVAL.", | 1074 | __func__, agbno, mp->m_sb.sb_agblocks); |
1079 | agbno, mp->m_sb.sb_agblocks, mp->m_fsname); | ||
1080 | ASSERT(0); | 1075 | ASSERT(0); |
1081 | return XFS_ERROR(EINVAL); | 1076 | return XFS_ERROR(EINVAL); |
1082 | } | 1077 | } |
@@ -1085,9 +1080,8 @@ xfs_difree( | |||
1085 | */ | 1080 | */ |
1086 | error = xfs_ialloc_read_agi(mp, tp, agno, &agbp); | 1081 | error = xfs_ialloc_read_agi(mp, tp, agno, &agbp); |
1087 | if (error) { | 1082 | if (error) { |
1088 | cmn_err(CE_WARN, | 1083 | xfs_warn(mp, "%s: xfs_ialloc_read_agi() returned error %d.", |
1089 | "xfs_difree: xfs_ialloc_read_agi() returned an error %d on %s. Returning error.", | 1084 | __func__, error); |
1090 | error, mp->m_fsname); | ||
1091 | return error; | 1085 | return error; |
1092 | } | 1086 | } |
1093 | agi = XFS_BUF_TO_AGI(agbp); | 1087 | agi = XFS_BUF_TO_AGI(agbp); |
@@ -1106,17 +1100,15 @@ xfs_difree( | |||
1106 | * Look for the entry describing this inode. | 1100 | * Look for the entry describing this inode. |
1107 | */ | 1101 | */ |
1108 | if ((error = xfs_inobt_lookup(cur, agino, XFS_LOOKUP_LE, &i))) { | 1102 | if ((error = xfs_inobt_lookup(cur, agino, XFS_LOOKUP_LE, &i))) { |
1109 | cmn_err(CE_WARN, | 1103 | xfs_warn(mp, "%s: xfs_inobt_lookup() returned error %d.", |
1110 | "xfs_difree: xfs_inobt_lookup returned() an error %d on %s. Returning error.", | 1104 | __func__, error); |
1111 | error, mp->m_fsname); | ||
1112 | goto error0; | 1105 | goto error0; |
1113 | } | 1106 | } |
1114 | XFS_WANT_CORRUPTED_GOTO(i == 1, error0); | 1107 | XFS_WANT_CORRUPTED_GOTO(i == 1, error0); |
1115 | error = xfs_inobt_get_rec(cur, &rec, &i); | 1108 | error = xfs_inobt_get_rec(cur, &rec, &i); |
1116 | if (error) { | 1109 | if (error) { |
1117 | cmn_err(CE_WARN, | 1110 | xfs_warn(mp, "%s: xfs_inobt_get_rec() returned error %d.", |
1118 | "xfs_difree: xfs_inobt_get_rec() returned an error %d on %s. Returning error.", | 1111 | __func__, error); |
1119 | error, mp->m_fsname); | ||
1120 | goto error0; | 1112 | goto error0; |
1121 | } | 1113 | } |
1122 | XFS_WANT_CORRUPTED_GOTO(i == 1, error0); | 1114 | XFS_WANT_CORRUPTED_GOTO(i == 1, error0); |
@@ -1157,8 +1149,8 @@ xfs_difree( | |||
1157 | xfs_trans_mod_sb(tp, XFS_TRANS_SB_IFREE, -(ilen - 1)); | 1149 | xfs_trans_mod_sb(tp, XFS_TRANS_SB_IFREE, -(ilen - 1)); |
1158 | 1150 | ||
1159 | if ((error = xfs_btree_delete(cur, &i))) { | 1151 | if ((error = xfs_btree_delete(cur, &i))) { |
1160 | cmn_err(CE_WARN, "xfs_difree: xfs_btree_delete returned an error %d on %s.\n", | 1152 | xfs_warn(mp, "%s: xfs_btree_delete returned error %d.", |
1161 | error, mp->m_fsname); | 1153 | __func__, error); |
1162 | goto error0; | 1154 | goto error0; |
1163 | } | 1155 | } |
1164 | 1156 | ||
@@ -1170,9 +1162,8 @@ xfs_difree( | |||
1170 | 1162 | ||
1171 | error = xfs_inobt_update(cur, &rec); | 1163 | error = xfs_inobt_update(cur, &rec); |
1172 | if (error) { | 1164 | if (error) { |
1173 | cmn_err(CE_WARN, | 1165 | xfs_warn(mp, "%s: xfs_inobt_update returned error %d.", |
1174 | "xfs_difree: xfs_inobt_update returned an error %d on %s.", | 1166 | __func__, error); |
1175 | error, mp->m_fsname); | ||
1176 | goto error0; | 1167 | goto error0; |
1177 | } | 1168 | } |
1178 | 1169 | ||
@@ -1218,10 +1209,9 @@ xfs_imap_lookup( | |||
1218 | 1209 | ||
1219 | error = xfs_ialloc_read_agi(mp, tp, agno, &agbp); | 1210 | error = xfs_ialloc_read_agi(mp, tp, agno, &agbp); |
1220 | if (error) { | 1211 | if (error) { |
1221 | xfs_fs_cmn_err(CE_ALERT, mp, "xfs_imap: " | 1212 | xfs_alert(mp, |
1222 | "xfs_ialloc_read_agi() returned " | 1213 | "%s: xfs_ialloc_read_agi() returned error %d, agno %d", |
1223 | "error %d, agno %d", | 1214 | __func__, error, agno); |
1224 | error, agno); | ||
1225 | return error; | 1215 | return error; |
1226 | } | 1216 | } |
1227 | 1217 | ||
@@ -1299,24 +1289,21 @@ xfs_imap( | |||
1299 | if (flags & XFS_IGET_UNTRUSTED) | 1289 | if (flags & XFS_IGET_UNTRUSTED) |
1300 | return XFS_ERROR(EINVAL); | 1290 | return XFS_ERROR(EINVAL); |
1301 | if (agno >= mp->m_sb.sb_agcount) { | 1291 | if (agno >= mp->m_sb.sb_agcount) { |
1302 | xfs_fs_cmn_err(CE_ALERT, mp, | 1292 | xfs_alert(mp, |
1303 | "xfs_imap: agno (%d) >= " | 1293 | "%s: agno (%d) >= mp->m_sb.sb_agcount (%d)", |
1304 | "mp->m_sb.sb_agcount (%d)", | 1294 | __func__, agno, mp->m_sb.sb_agcount); |
1305 | agno, mp->m_sb.sb_agcount); | ||
1306 | } | 1295 | } |
1307 | if (agbno >= mp->m_sb.sb_agblocks) { | 1296 | if (agbno >= mp->m_sb.sb_agblocks) { |
1308 | xfs_fs_cmn_err(CE_ALERT, mp, | 1297 | xfs_alert(mp, |
1309 | "xfs_imap: agbno (0x%llx) >= " | 1298 | "%s: agbno (0x%llx) >= mp->m_sb.sb_agblocks (0x%lx)", |
1310 | "mp->m_sb.sb_agblocks (0x%lx)", | 1299 | __func__, (unsigned long long)agbno, |
1311 | (unsigned long long) agbno, | 1300 | (unsigned long)mp->m_sb.sb_agblocks); |
1312 | (unsigned long) mp->m_sb.sb_agblocks); | ||
1313 | } | 1301 | } |
1314 | if (ino != XFS_AGINO_TO_INO(mp, agno, agino)) { | 1302 | if (ino != XFS_AGINO_TO_INO(mp, agno, agino)) { |
1315 | xfs_fs_cmn_err(CE_ALERT, mp, | 1303 | xfs_alert(mp, |
1316 | "xfs_imap: ino (0x%llx) != " | 1304 | "%s: ino (0x%llx) != XFS_AGINO_TO_INO() (0x%llx)", |
1317 | "XFS_AGINO_TO_INO(mp, agno, agino) " | 1305 | __func__, ino, |
1318 | "(0x%llx)", | 1306 | XFS_AGINO_TO_INO(mp, agno, agino)); |
1319 | ino, XFS_AGINO_TO_INO(mp, agno, agino)); | ||
1320 | } | 1307 | } |
1321 | xfs_stack_trace(); | 1308 | xfs_stack_trace(); |
1322 | #endif /* DEBUG */ | 1309 | #endif /* DEBUG */ |
@@ -1388,10 +1375,9 @@ out_map: | |||
1388 | */ | 1375 | */ |
1389 | if ((imap->im_blkno + imap->im_len) > | 1376 | if ((imap->im_blkno + imap->im_len) > |
1390 | XFS_FSB_TO_BB(mp, mp->m_sb.sb_dblocks)) { | 1377 | XFS_FSB_TO_BB(mp, mp->m_sb.sb_dblocks)) { |
1391 | xfs_fs_cmn_err(CE_ALERT, mp, "xfs_imap: " | 1378 | xfs_alert(mp, |
1392 | "(imap->im_blkno (0x%llx) + imap->im_len (0x%llx)) > " | 1379 | "%s: (im_blkno (0x%llx) + im_len (0x%llx)) > sb_dblocks (0x%llx)", |
1393 | " XFS_FSB_TO_BB(mp, mp->m_sb.sb_dblocks) (0x%llx)", | 1380 | __func__, (unsigned long long) imap->im_blkno, |
1394 | (unsigned long long) imap->im_blkno, | ||
1395 | (unsigned long long) imap->im_len, | 1381 | (unsigned long long) imap->im_len, |
1396 | XFS_FSB_TO_BB(mp, mp->m_sb.sb_dblocks)); | 1382 | XFS_FSB_TO_BB(mp, mp->m_sb.sb_dblocks)); |
1397 | return XFS_ERROR(EINVAL); | 1383 | return XFS_ERROR(EINVAL); |
diff --git a/fs/xfs/xfs_inode.c b/fs/xfs/xfs_inode.c index be7cf625421f..da871f532236 100644 --- a/fs/xfs/xfs_inode.c +++ b/fs/xfs/xfs_inode.c | |||
@@ -110,8 +110,8 @@ xfs_inobp_check( | |||
110 | dip = (xfs_dinode_t *)xfs_buf_offset(bp, | 110 | dip = (xfs_dinode_t *)xfs_buf_offset(bp, |
111 | i * mp->m_sb.sb_inodesize); | 111 | i * mp->m_sb.sb_inodesize); |
112 | if (!dip->di_next_unlinked) { | 112 | if (!dip->di_next_unlinked) { |
113 | xfs_fs_cmn_err(CE_ALERT, mp, | 113 | xfs_alert(mp, |
114 | "Detected a bogus zero next_unlinked field in incore inode buffer 0x%p. About to pop an ASSERT.", | 114 | "Detected bogus zero next_unlinked field in incore inode buffer 0x%p.", |
115 | bp); | 115 | bp); |
116 | ASSERT(dip->di_next_unlinked); | 116 | ASSERT(dip->di_next_unlinked); |
117 | } | 117 | } |
@@ -142,10 +142,9 @@ xfs_imap_to_bp( | |||
142 | (int)imap->im_len, buf_flags, &bp); | 142 | (int)imap->im_len, buf_flags, &bp); |
143 | if (error) { | 143 | if (error) { |
144 | if (error != EAGAIN) { | 144 | if (error != EAGAIN) { |
145 | cmn_err(CE_WARN, | 145 | xfs_warn(mp, |
146 | "xfs_imap_to_bp: xfs_trans_read_buf()returned " | 146 | "%s: xfs_trans_read_buf() returned error %d.", |
147 | "an error %d on %s. Returning error.", | 147 | __func__, error); |
148 | error, mp->m_fsname); | ||
149 | } else { | 148 | } else { |
150 | ASSERT(buf_flags & XBF_TRYLOCK); | 149 | ASSERT(buf_flags & XBF_TRYLOCK); |
151 | } | 150 | } |
@@ -180,12 +179,11 @@ xfs_imap_to_bp( | |||
180 | XFS_CORRUPTION_ERROR("xfs_imap_to_bp", | 179 | XFS_CORRUPTION_ERROR("xfs_imap_to_bp", |
181 | XFS_ERRLEVEL_HIGH, mp, dip); | 180 | XFS_ERRLEVEL_HIGH, mp, dip); |
182 | #ifdef DEBUG | 181 | #ifdef DEBUG |
183 | cmn_err(CE_PANIC, | 182 | xfs_emerg(mp, |
184 | "Device %s - bad inode magic/vsn " | 183 | "bad inode magic/vsn daddr %lld #%d (magic=%x)", |
185 | "daddr %lld #%d (magic=%x)", | ||
186 | XFS_BUFTARG_NAME(mp->m_ddev_targp), | ||
187 | (unsigned long long)imap->im_blkno, i, | 184 | (unsigned long long)imap->im_blkno, i, |
188 | be16_to_cpu(dip->di_magic)); | 185 | be16_to_cpu(dip->di_magic)); |
186 | ASSERT(0); | ||
189 | #endif | 187 | #endif |
190 | xfs_trans_brelse(tp, bp); | 188 | xfs_trans_brelse(tp, bp); |
191 | return XFS_ERROR(EFSCORRUPTED); | 189 | return XFS_ERROR(EFSCORRUPTED); |
@@ -317,7 +315,7 @@ xfs_iformat( | |||
317 | if (unlikely(be32_to_cpu(dip->di_nextents) + | 315 | if (unlikely(be32_to_cpu(dip->di_nextents) + |
318 | be16_to_cpu(dip->di_anextents) > | 316 | be16_to_cpu(dip->di_anextents) > |
319 | be64_to_cpu(dip->di_nblocks))) { | 317 | be64_to_cpu(dip->di_nblocks))) { |
320 | xfs_fs_repair_cmn_err(CE_WARN, ip->i_mount, | 318 | xfs_warn(ip->i_mount, |
321 | "corrupt dinode %Lu, extent total = %d, nblocks = %Lu.", | 319 | "corrupt dinode %Lu, extent total = %d, nblocks = %Lu.", |
322 | (unsigned long long)ip->i_ino, | 320 | (unsigned long long)ip->i_ino, |
323 | (int)(be32_to_cpu(dip->di_nextents) + | 321 | (int)(be32_to_cpu(dip->di_nextents) + |
@@ -330,8 +328,7 @@ xfs_iformat( | |||
330 | } | 328 | } |
331 | 329 | ||
332 | if (unlikely(dip->di_forkoff > ip->i_mount->m_sb.sb_inodesize)) { | 330 | if (unlikely(dip->di_forkoff > ip->i_mount->m_sb.sb_inodesize)) { |
333 | xfs_fs_repair_cmn_err(CE_WARN, ip->i_mount, | 331 | xfs_warn(ip->i_mount, "corrupt dinode %Lu, forkoff = 0x%x.", |
334 | "corrupt dinode %Lu, forkoff = 0x%x.", | ||
335 | (unsigned long long)ip->i_ino, | 332 | (unsigned long long)ip->i_ino, |
336 | dip->di_forkoff); | 333 | dip->di_forkoff); |
337 | XFS_CORRUPTION_ERROR("xfs_iformat(2)", XFS_ERRLEVEL_LOW, | 334 | XFS_CORRUPTION_ERROR("xfs_iformat(2)", XFS_ERRLEVEL_LOW, |
@@ -341,7 +338,7 @@ xfs_iformat( | |||
341 | 338 | ||
342 | if (unlikely((ip->i_d.di_flags & XFS_DIFLAG_REALTIME) && | 339 | if (unlikely((ip->i_d.di_flags & XFS_DIFLAG_REALTIME) && |
343 | !ip->i_mount->m_rtdev_targp)) { | 340 | !ip->i_mount->m_rtdev_targp)) { |
344 | xfs_fs_repair_cmn_err(CE_WARN, ip->i_mount, | 341 | xfs_warn(ip->i_mount, |
345 | "corrupt dinode %Lu, has realtime flag set.", | 342 | "corrupt dinode %Lu, has realtime flag set.", |
346 | ip->i_ino); | 343 | ip->i_ino); |
347 | XFS_CORRUPTION_ERROR("xfs_iformat(realtime)", | 344 | XFS_CORRUPTION_ERROR("xfs_iformat(realtime)", |
@@ -373,9 +370,8 @@ xfs_iformat( | |||
373 | * no local regular files yet | 370 | * no local regular files yet |
374 | */ | 371 | */ |
375 | if (unlikely((be16_to_cpu(dip->di_mode) & S_IFMT) == S_IFREG)) { | 372 | if (unlikely((be16_to_cpu(dip->di_mode) & S_IFMT) == S_IFREG)) { |
376 | xfs_fs_repair_cmn_err(CE_WARN, ip->i_mount, | 373 | xfs_warn(ip->i_mount, |
377 | "corrupt inode %Lu " | 374 | "corrupt inode %Lu (local format for regular file).", |
378 | "(local format for regular file).", | ||
379 | (unsigned long long) ip->i_ino); | 375 | (unsigned long long) ip->i_ino); |
380 | XFS_CORRUPTION_ERROR("xfs_iformat(4)", | 376 | XFS_CORRUPTION_ERROR("xfs_iformat(4)", |
381 | XFS_ERRLEVEL_LOW, | 377 | XFS_ERRLEVEL_LOW, |
@@ -385,9 +381,8 @@ xfs_iformat( | |||
385 | 381 | ||
386 | di_size = be64_to_cpu(dip->di_size); | 382 | di_size = be64_to_cpu(dip->di_size); |
387 | if (unlikely(di_size > XFS_DFORK_DSIZE(dip, ip->i_mount))) { | 383 | if (unlikely(di_size > XFS_DFORK_DSIZE(dip, ip->i_mount))) { |
388 | xfs_fs_repair_cmn_err(CE_WARN, ip->i_mount, | 384 | xfs_warn(ip->i_mount, |
389 | "corrupt inode %Lu " | 385 | "corrupt inode %Lu (bad size %Ld for local inode).", |
390 | "(bad size %Ld for local inode).", | ||
391 | (unsigned long long) ip->i_ino, | 386 | (unsigned long long) ip->i_ino, |
392 | (long long) di_size); | 387 | (long long) di_size); |
393 | XFS_CORRUPTION_ERROR("xfs_iformat(5)", | 388 | XFS_CORRUPTION_ERROR("xfs_iformat(5)", |
@@ -431,9 +426,8 @@ xfs_iformat( | |||
431 | size = be16_to_cpu(atp->hdr.totsize); | 426 | size = be16_to_cpu(atp->hdr.totsize); |
432 | 427 | ||
433 | if (unlikely(size < sizeof(struct xfs_attr_sf_hdr))) { | 428 | if (unlikely(size < sizeof(struct xfs_attr_sf_hdr))) { |
434 | xfs_fs_repair_cmn_err(CE_WARN, ip->i_mount, | 429 | xfs_warn(ip->i_mount, |
435 | "corrupt inode %Lu " | 430 | "corrupt inode %Lu (bad attr fork size %Ld).", |
436 | "(bad attr fork size %Ld).", | ||
437 | (unsigned long long) ip->i_ino, | 431 | (unsigned long long) ip->i_ino, |
438 | (long long) size); | 432 | (long long) size); |
439 | XFS_CORRUPTION_ERROR("xfs_iformat(8)", | 433 | XFS_CORRUPTION_ERROR("xfs_iformat(8)", |
@@ -488,9 +482,8 @@ xfs_iformat_local( | |||
488 | * kmem_alloc() or memcpy() below. | 482 | * kmem_alloc() or memcpy() below. |
489 | */ | 483 | */ |
490 | if (unlikely(size > XFS_DFORK_SIZE(dip, ip->i_mount, whichfork))) { | 484 | if (unlikely(size > XFS_DFORK_SIZE(dip, ip->i_mount, whichfork))) { |
491 | xfs_fs_repair_cmn_err(CE_WARN, ip->i_mount, | 485 | xfs_warn(ip->i_mount, |
492 | "corrupt inode %Lu " | 486 | "corrupt inode %Lu (bad size %d for local fork, size = %d).", |
493 | "(bad size %d for local fork, size = %d).", | ||
494 | (unsigned long long) ip->i_ino, size, | 487 | (unsigned long long) ip->i_ino, size, |
495 | XFS_DFORK_SIZE(dip, ip->i_mount, whichfork)); | 488 | XFS_DFORK_SIZE(dip, ip->i_mount, whichfork)); |
496 | XFS_CORRUPTION_ERROR("xfs_iformat_local", XFS_ERRLEVEL_LOW, | 489 | XFS_CORRUPTION_ERROR("xfs_iformat_local", XFS_ERRLEVEL_LOW, |
@@ -547,8 +540,7 @@ xfs_iformat_extents( | |||
547 | * kmem_alloc() or memcpy() below. | 540 | * kmem_alloc() or memcpy() below. |
548 | */ | 541 | */ |
549 | if (unlikely(size < 0 || size > XFS_DFORK_SIZE(dip, ip->i_mount, whichfork))) { | 542 | if (unlikely(size < 0 || size > XFS_DFORK_SIZE(dip, ip->i_mount, whichfork))) { |
550 | xfs_fs_repair_cmn_err(CE_WARN, ip->i_mount, | 543 | xfs_warn(ip->i_mount, "corrupt inode %Lu ((a)extents = %d).", |
551 | "corrupt inode %Lu ((a)extents = %d).", | ||
552 | (unsigned long long) ip->i_ino, nex); | 544 | (unsigned long long) ip->i_ino, nex); |
553 | XFS_CORRUPTION_ERROR("xfs_iformat_extents(1)", XFS_ERRLEVEL_LOW, | 545 | XFS_CORRUPTION_ERROR("xfs_iformat_extents(1)", XFS_ERRLEVEL_LOW, |
554 | ip->i_mount, dip); | 546 | ip->i_mount, dip); |
@@ -623,11 +615,10 @@ xfs_iformat_btree( | |||
623 | || XFS_BMDR_SPACE_CALC(nrecs) > | 615 | || XFS_BMDR_SPACE_CALC(nrecs) > |
624 | XFS_DFORK_SIZE(dip, ip->i_mount, whichfork) | 616 | XFS_DFORK_SIZE(dip, ip->i_mount, whichfork) |
625 | || XFS_IFORK_NEXTENTS(ip, whichfork) > ip->i_d.di_nblocks)) { | 617 | || XFS_IFORK_NEXTENTS(ip, whichfork) > ip->i_d.di_nblocks)) { |
626 | xfs_fs_repair_cmn_err(CE_WARN, ip->i_mount, | 618 | xfs_warn(ip->i_mount, "corrupt inode %Lu (btree).", |
627 | "corrupt inode %Lu (btree).", | ||
628 | (unsigned long long) ip->i_ino); | 619 | (unsigned long long) ip->i_ino); |
629 | XFS_ERROR_REPORT("xfs_iformat_btree", XFS_ERRLEVEL_LOW, | 620 | XFS_CORRUPTION_ERROR("xfs_iformat_btree", XFS_ERRLEVEL_LOW, |
630 | ip->i_mount); | 621 | ip->i_mount, dip); |
631 | return XFS_ERROR(EFSCORRUPTED); | 622 | return XFS_ERROR(EFSCORRUPTED); |
632 | } | 623 | } |
633 | 624 | ||
@@ -813,11 +804,9 @@ xfs_iread( | |||
813 | */ | 804 | */ |
814 | if (be16_to_cpu(dip->di_magic) != XFS_DINODE_MAGIC) { | 805 | if (be16_to_cpu(dip->di_magic) != XFS_DINODE_MAGIC) { |
815 | #ifdef DEBUG | 806 | #ifdef DEBUG |
816 | xfs_fs_cmn_err(CE_ALERT, mp, "xfs_iread: " | 807 | xfs_alert(mp, |
817 | "dip->di_magic (0x%x) != " | 808 | "%s: dip->di_magic (0x%x) != XFS_DINODE_MAGIC (0x%x)", |
818 | "XFS_DINODE_MAGIC (0x%x)", | 809 | __func__, be16_to_cpu(dip->di_magic), XFS_DINODE_MAGIC); |
819 | be16_to_cpu(dip->di_magic), | ||
820 | XFS_DINODE_MAGIC); | ||
821 | #endif /* DEBUG */ | 810 | #endif /* DEBUG */ |
822 | error = XFS_ERROR(EINVAL); | 811 | error = XFS_ERROR(EINVAL); |
823 | goto out_brelse; | 812 | goto out_brelse; |
@@ -835,9 +824,8 @@ xfs_iread( | |||
835 | error = xfs_iformat(ip, dip); | 824 | error = xfs_iformat(ip, dip); |
836 | if (error) { | 825 | if (error) { |
837 | #ifdef DEBUG | 826 | #ifdef DEBUG |
838 | xfs_fs_cmn_err(CE_ALERT, mp, "xfs_iread: " | 827 | xfs_alert(mp, "%s: xfs_iformat() returned error %d", |
839 | "xfs_iformat() returned error %d", | 828 | __func__, error); |
840 | error); | ||
841 | #endif /* DEBUG */ | 829 | #endif /* DEBUG */ |
842 | goto out_brelse; | 830 | goto out_brelse; |
843 | } | 831 | } |
@@ -1016,8 +1004,8 @@ xfs_ialloc( | |||
1016 | * This is because we're setting fields here we need | 1004 | * This is because we're setting fields here we need |
1017 | * to prevent others from looking at until we're done. | 1005 | * to prevent others from looking at until we're done. |
1018 | */ | 1006 | */ |
1019 | error = xfs_trans_iget(tp->t_mountp, tp, ino, | 1007 | error = xfs_iget(tp->t_mountp, tp, ino, XFS_IGET_CREATE, |
1020 | XFS_IGET_CREATE, XFS_ILOCK_EXCL, &ip); | 1008 | XFS_ILOCK_EXCL, &ip); |
1021 | if (error) | 1009 | if (error) |
1022 | return error; | 1010 | return error; |
1023 | ASSERT(ip != NULL); | 1011 | ASSERT(ip != NULL); |
@@ -1166,6 +1154,7 @@ xfs_ialloc( | |||
1166 | /* | 1154 | /* |
1167 | * Log the new values stuffed into the inode. | 1155 | * Log the new values stuffed into the inode. |
1168 | */ | 1156 | */ |
1157 | xfs_trans_ijoin_ref(tp, ip, XFS_ILOCK_EXCL); | ||
1169 | xfs_trans_log_inode(tp, ip, flags); | 1158 | xfs_trans_log_inode(tp, ip, flags); |
1170 | 1159 | ||
1171 | /* now that we have an i_mode we can setup inode ops and unlock */ | 1160 | /* now that we have an i_mode we can setup inode ops and unlock */ |
@@ -1820,9 +1809,8 @@ xfs_iunlink_remove( | |||
1820 | */ | 1809 | */ |
1821 | error = xfs_itobp(mp, tp, ip, &dip, &ibp, XBF_LOCK); | 1810 | error = xfs_itobp(mp, tp, ip, &dip, &ibp, XBF_LOCK); |
1822 | if (error) { | 1811 | if (error) { |
1823 | cmn_err(CE_WARN, | 1812 | xfs_warn(mp, "%s: xfs_itobp() returned error %d.", |
1824 | "xfs_iunlink_remove: xfs_itobp() returned an error %d on %s. Returning error.", | 1813 | __func__, error); |
1825 | error, mp->m_fsname); | ||
1826 | return error; | 1814 | return error; |
1827 | } | 1815 | } |
1828 | next_agino = be32_to_cpu(dip->di_next_unlinked); | 1816 | next_agino = be32_to_cpu(dip->di_next_unlinked); |
@@ -1867,9 +1855,9 @@ xfs_iunlink_remove( | |||
1867 | error = xfs_inotobp(mp, tp, next_ino, &last_dip, | 1855 | error = xfs_inotobp(mp, tp, next_ino, &last_dip, |
1868 | &last_ibp, &last_offset, 0); | 1856 | &last_ibp, &last_offset, 0); |
1869 | if (error) { | 1857 | if (error) { |
1870 | cmn_err(CE_WARN, | 1858 | xfs_warn(mp, |
1871 | "xfs_iunlink_remove: xfs_inotobp() returned an error %d on %s. Returning error.", | 1859 | "%s: xfs_inotobp() returned error %d.", |
1872 | error, mp->m_fsname); | 1860 | __func__, error); |
1873 | return error; | 1861 | return error; |
1874 | } | 1862 | } |
1875 | next_agino = be32_to_cpu(last_dip->di_next_unlinked); | 1863 | next_agino = be32_to_cpu(last_dip->di_next_unlinked); |
@@ -1882,9 +1870,8 @@ xfs_iunlink_remove( | |||
1882 | */ | 1870 | */ |
1883 | error = xfs_itobp(mp, tp, ip, &dip, &ibp, XBF_LOCK); | 1871 | error = xfs_itobp(mp, tp, ip, &dip, &ibp, XBF_LOCK); |
1884 | if (error) { | 1872 | if (error) { |
1885 | cmn_err(CE_WARN, | 1873 | xfs_warn(mp, "%s: xfs_itobp(2) returned error %d.", |
1886 | "xfs_iunlink_remove: xfs_itobp() returned an error %d on %s. Returning error.", | 1874 | __func__, error); |
1887 | error, mp->m_fsname); | ||
1888 | return error; | 1875 | return error; |
1889 | } | 1876 | } |
1890 | next_agino = be32_to_cpu(dip->di_next_unlinked); | 1877 | next_agino = be32_to_cpu(dip->di_next_unlinked); |
@@ -2939,16 +2926,16 @@ xfs_iflush_int( | |||
2939 | 2926 | ||
2940 | if (XFS_TEST_ERROR(be16_to_cpu(dip->di_magic) != XFS_DINODE_MAGIC, | 2927 | if (XFS_TEST_ERROR(be16_to_cpu(dip->di_magic) != XFS_DINODE_MAGIC, |
2941 | mp, XFS_ERRTAG_IFLUSH_1, XFS_RANDOM_IFLUSH_1)) { | 2928 | mp, XFS_ERRTAG_IFLUSH_1, XFS_RANDOM_IFLUSH_1)) { |
2942 | xfs_cmn_err(XFS_PTAG_IFLUSH, CE_ALERT, mp, | 2929 | xfs_alert_tag(mp, XFS_PTAG_IFLUSH, |
2943 | "xfs_iflush: Bad inode %Lu magic number 0x%x, ptr 0x%p", | 2930 | "%s: Bad inode %Lu magic number 0x%x, ptr 0x%p", |
2944 | ip->i_ino, be16_to_cpu(dip->di_magic), dip); | 2931 | __func__, ip->i_ino, be16_to_cpu(dip->di_magic), dip); |
2945 | goto corrupt_out; | 2932 | goto corrupt_out; |
2946 | } | 2933 | } |
2947 | if (XFS_TEST_ERROR(ip->i_d.di_magic != XFS_DINODE_MAGIC, | 2934 | if (XFS_TEST_ERROR(ip->i_d.di_magic != XFS_DINODE_MAGIC, |
2948 | mp, XFS_ERRTAG_IFLUSH_2, XFS_RANDOM_IFLUSH_2)) { | 2935 | mp, XFS_ERRTAG_IFLUSH_2, XFS_RANDOM_IFLUSH_2)) { |
2949 | xfs_cmn_err(XFS_PTAG_IFLUSH, CE_ALERT, mp, | 2936 | xfs_alert_tag(mp, XFS_PTAG_IFLUSH, |
2950 | "xfs_iflush: Bad inode %Lu, ptr 0x%p, magic number 0x%x", | 2937 | "%s: Bad inode %Lu, ptr 0x%p, magic number 0x%x", |
2951 | ip->i_ino, ip, ip->i_d.di_magic); | 2938 | __func__, ip->i_ino, ip, ip->i_d.di_magic); |
2952 | goto corrupt_out; | 2939 | goto corrupt_out; |
2953 | } | 2940 | } |
2954 | if ((ip->i_d.di_mode & S_IFMT) == S_IFREG) { | 2941 | if ((ip->i_d.di_mode & S_IFMT) == S_IFREG) { |
@@ -2956,9 +2943,9 @@ xfs_iflush_int( | |||
2956 | (ip->i_d.di_format != XFS_DINODE_FMT_EXTENTS) && | 2943 | (ip->i_d.di_format != XFS_DINODE_FMT_EXTENTS) && |
2957 | (ip->i_d.di_format != XFS_DINODE_FMT_BTREE), | 2944 | (ip->i_d.di_format != XFS_DINODE_FMT_BTREE), |
2958 | mp, XFS_ERRTAG_IFLUSH_3, XFS_RANDOM_IFLUSH_3)) { | 2945 | mp, XFS_ERRTAG_IFLUSH_3, XFS_RANDOM_IFLUSH_3)) { |
2959 | xfs_cmn_err(XFS_PTAG_IFLUSH, CE_ALERT, mp, | 2946 | xfs_alert_tag(mp, XFS_PTAG_IFLUSH, |
2960 | "xfs_iflush: Bad regular inode %Lu, ptr 0x%p", | 2947 | "%s: Bad regular inode %Lu, ptr 0x%p", |
2961 | ip->i_ino, ip); | 2948 | __func__, ip->i_ino, ip); |
2962 | goto corrupt_out; | 2949 | goto corrupt_out; |
2963 | } | 2950 | } |
2964 | } else if ((ip->i_d.di_mode & S_IFMT) == S_IFDIR) { | 2951 | } else if ((ip->i_d.di_mode & S_IFMT) == S_IFDIR) { |
@@ -2967,28 +2954,28 @@ xfs_iflush_int( | |||
2967 | (ip->i_d.di_format != XFS_DINODE_FMT_BTREE) && | 2954 | (ip->i_d.di_format != XFS_DINODE_FMT_BTREE) && |
2968 | (ip->i_d.di_format != XFS_DINODE_FMT_LOCAL), | 2955 | (ip->i_d.di_format != XFS_DINODE_FMT_LOCAL), |
2969 | mp, XFS_ERRTAG_IFLUSH_4, XFS_RANDOM_IFLUSH_4)) { | 2956 | mp, XFS_ERRTAG_IFLUSH_4, XFS_RANDOM_IFLUSH_4)) { |
2970 | xfs_cmn_err(XFS_PTAG_IFLUSH, CE_ALERT, mp, | 2957 | xfs_alert_tag(mp, XFS_PTAG_IFLUSH, |
2971 | "xfs_iflush: Bad directory inode %Lu, ptr 0x%p", | 2958 | "%s: Bad directory inode %Lu, ptr 0x%p", |
2972 | ip->i_ino, ip); | 2959 | __func__, ip->i_ino, ip); |
2973 | goto corrupt_out; | 2960 | goto corrupt_out; |
2974 | } | 2961 | } |
2975 | } | 2962 | } |
2976 | if (XFS_TEST_ERROR(ip->i_d.di_nextents + ip->i_d.di_anextents > | 2963 | if (XFS_TEST_ERROR(ip->i_d.di_nextents + ip->i_d.di_anextents > |
2977 | ip->i_d.di_nblocks, mp, XFS_ERRTAG_IFLUSH_5, | 2964 | ip->i_d.di_nblocks, mp, XFS_ERRTAG_IFLUSH_5, |
2978 | XFS_RANDOM_IFLUSH_5)) { | 2965 | XFS_RANDOM_IFLUSH_5)) { |
2979 | xfs_cmn_err(XFS_PTAG_IFLUSH, CE_ALERT, mp, | 2966 | xfs_alert_tag(mp, XFS_PTAG_IFLUSH, |
2980 | "xfs_iflush: detected corrupt incore inode %Lu, total extents = %d, nblocks = %Ld, ptr 0x%p", | 2967 | "%s: detected corrupt incore inode %Lu, " |
2981 | ip->i_ino, | 2968 | "total extents = %d, nblocks = %Ld, ptr 0x%p", |
2969 | __func__, ip->i_ino, | ||
2982 | ip->i_d.di_nextents + ip->i_d.di_anextents, | 2970 | ip->i_d.di_nextents + ip->i_d.di_anextents, |
2983 | ip->i_d.di_nblocks, | 2971 | ip->i_d.di_nblocks, ip); |
2984 | ip); | ||
2985 | goto corrupt_out; | 2972 | goto corrupt_out; |
2986 | } | 2973 | } |
2987 | if (XFS_TEST_ERROR(ip->i_d.di_forkoff > mp->m_sb.sb_inodesize, | 2974 | if (XFS_TEST_ERROR(ip->i_d.di_forkoff > mp->m_sb.sb_inodesize, |
2988 | mp, XFS_ERRTAG_IFLUSH_6, XFS_RANDOM_IFLUSH_6)) { | 2975 | mp, XFS_ERRTAG_IFLUSH_6, XFS_RANDOM_IFLUSH_6)) { |
2989 | xfs_cmn_err(XFS_PTAG_IFLUSH, CE_ALERT, mp, | 2976 | xfs_alert_tag(mp, XFS_PTAG_IFLUSH, |
2990 | "xfs_iflush: bad inode %Lu, forkoff 0x%x, ptr 0x%p", | 2977 | "%s: bad inode %Lu, forkoff 0x%x, ptr 0x%p", |
2991 | ip->i_ino, ip->i_d.di_forkoff, ip); | 2978 | __func__, ip->i_ino, ip->i_d.di_forkoff, ip); |
2992 | goto corrupt_out; | 2979 | goto corrupt_out; |
2993 | } | 2980 | } |
2994 | /* | 2981 | /* |
diff --git a/fs/xfs/xfs_inode.h b/fs/xfs/xfs_inode.h index 5c95fa8ec11d..f753200cef8d 100644 --- a/fs/xfs/xfs_inode.h +++ b/fs/xfs/xfs_inode.h | |||
@@ -409,28 +409,35 @@ static inline void xfs_ifunlock(xfs_inode_t *ip) | |||
409 | /* | 409 | /* |
410 | * Flags for lockdep annotations. | 410 | * Flags for lockdep annotations. |
411 | * | 411 | * |
412 | * XFS_I[O]LOCK_PARENT - for operations that require locking two inodes | 412 | * XFS_LOCK_PARENT - for directory operations that require locking a |
413 | * (ie directory operations that require locking a directory inode and | 413 | * parent directory inode and a child entry inode. The parent gets locked |
414 | * an entry inode). The first inode gets locked with this flag so it | 414 | * with this flag so it gets a lockdep subclass of 1 and the child entry |
415 | * gets a lockdep subclass of 1 and the second lock will have a lockdep | 415 | * lock will have a lockdep subclass of 0. |
416 | * subclass of 0. | 416 | * |
417 | * XFS_LOCK_RTBITMAP/XFS_LOCK_RTSUM - the realtime device bitmap and summary | ||
418 | * inodes do not participate in the normal lock order, and thus have their | ||
419 | * own subclasses. | ||
417 | * | 420 | * |
418 | * XFS_LOCK_INUMORDER - for locking several inodes at the some time | 421 | * XFS_LOCK_INUMORDER - for locking several inodes at the some time |
419 | * with xfs_lock_inodes(). This flag is used as the starting subclass | 422 | * with xfs_lock_inodes(). This flag is used as the starting subclass |
420 | * and each subsequent lock acquired will increment the subclass by one. | 423 | * and each subsequent lock acquired will increment the subclass by one. |
421 | * So the first lock acquired will have a lockdep subclass of 2, the | 424 | * So the first lock acquired will have a lockdep subclass of 4, the |
422 | * second lock will have a lockdep subclass of 3, and so on. It is | 425 | * second lock will have a lockdep subclass of 5, and so on. It is |
423 | * the responsibility of the class builder to shift this to the correct | 426 | * the responsibility of the class builder to shift this to the correct |
424 | * portion of the lock_mode lockdep mask. | 427 | * portion of the lock_mode lockdep mask. |
425 | */ | 428 | */ |
426 | #define XFS_LOCK_PARENT 1 | 429 | #define XFS_LOCK_PARENT 1 |
427 | #define XFS_LOCK_INUMORDER 2 | 430 | #define XFS_LOCK_RTBITMAP 2 |
431 | #define XFS_LOCK_RTSUM 3 | ||
432 | #define XFS_LOCK_INUMORDER 4 | ||
428 | 433 | ||
429 | #define XFS_IOLOCK_SHIFT 16 | 434 | #define XFS_IOLOCK_SHIFT 16 |
430 | #define XFS_IOLOCK_PARENT (XFS_LOCK_PARENT << XFS_IOLOCK_SHIFT) | 435 | #define XFS_IOLOCK_PARENT (XFS_LOCK_PARENT << XFS_IOLOCK_SHIFT) |
431 | 436 | ||
432 | #define XFS_ILOCK_SHIFT 24 | 437 | #define XFS_ILOCK_SHIFT 24 |
433 | #define XFS_ILOCK_PARENT (XFS_LOCK_PARENT << XFS_ILOCK_SHIFT) | 438 | #define XFS_ILOCK_PARENT (XFS_LOCK_PARENT << XFS_ILOCK_SHIFT) |
439 | #define XFS_ILOCK_RTBITMAP (XFS_LOCK_RTBITMAP << XFS_ILOCK_SHIFT) | ||
440 | #define XFS_ILOCK_RTSUM (XFS_LOCK_RTSUM << XFS_ILOCK_SHIFT) | ||
434 | 441 | ||
435 | #define XFS_IOLOCK_DEP_MASK 0x00ff0000 | 442 | #define XFS_IOLOCK_DEP_MASK 0x00ff0000 |
436 | #define XFS_ILOCK_DEP_MASK 0xff000000 | 443 | #define XFS_ILOCK_DEP_MASK 0xff000000 |
diff --git a/fs/xfs/xfs_iomap.c b/fs/xfs/xfs_iomap.c index 8a0f044750c3..091d82b94c4d 100644 --- a/fs/xfs/xfs_iomap.c +++ b/fs/xfs/xfs_iomap.c | |||
@@ -101,11 +101,11 @@ xfs_iomap_eof_align_last_fsb( | |||
101 | } | 101 | } |
102 | 102 | ||
103 | STATIC int | 103 | STATIC int |
104 | xfs_cmn_err_fsblock_zero( | 104 | xfs_alert_fsblock_zero( |
105 | xfs_inode_t *ip, | 105 | xfs_inode_t *ip, |
106 | xfs_bmbt_irec_t *imap) | 106 | xfs_bmbt_irec_t *imap) |
107 | { | 107 | { |
108 | xfs_cmn_err(XFS_PTAG_FSBLOCK_ZERO, CE_ALERT, ip->i_mount, | 108 | xfs_alert_tag(ip->i_mount, XFS_PTAG_FSBLOCK_ZERO, |
109 | "Access to block zero in inode %llu " | 109 | "Access to block zero in inode %llu " |
110 | "start_block: %llx start_off: %llx " | 110 | "start_block: %llx start_off: %llx " |
111 | "blkcnt: %llx extent-state: %x\n", | 111 | "blkcnt: %llx extent-state: %x\n", |
@@ -246,7 +246,7 @@ xfs_iomap_write_direct( | |||
246 | } | 246 | } |
247 | 247 | ||
248 | if (!(imap->br_startblock || XFS_IS_REALTIME_INODE(ip))) { | 248 | if (!(imap->br_startblock || XFS_IS_REALTIME_INODE(ip))) { |
249 | error = xfs_cmn_err_fsblock_zero(ip, imap); | 249 | error = xfs_alert_fsblock_zero(ip, imap); |
250 | goto error_out; | 250 | goto error_out; |
251 | } | 251 | } |
252 | 252 | ||
@@ -464,7 +464,7 @@ retry: | |||
464 | } | 464 | } |
465 | 465 | ||
466 | if (!(imap[0].br_startblock || XFS_IS_REALTIME_INODE(ip))) | 466 | if (!(imap[0].br_startblock || XFS_IS_REALTIME_INODE(ip))) |
467 | return xfs_cmn_err_fsblock_zero(ip, &imap[0]); | 467 | return xfs_alert_fsblock_zero(ip, &imap[0]); |
468 | 468 | ||
469 | *ret_imap = imap[0]; | 469 | *ret_imap = imap[0]; |
470 | return 0; | 470 | return 0; |
@@ -614,7 +614,7 @@ xfs_iomap_write_allocate( | |||
614 | * covers at least part of the callers request | 614 | * covers at least part of the callers request |
615 | */ | 615 | */ |
616 | if (!(imap->br_startblock || XFS_IS_REALTIME_INODE(ip))) | 616 | if (!(imap->br_startblock || XFS_IS_REALTIME_INODE(ip))) |
617 | return xfs_cmn_err_fsblock_zero(ip, imap); | 617 | return xfs_alert_fsblock_zero(ip, imap); |
618 | 618 | ||
619 | if ((offset_fsb >= imap->br_startoff) && | 619 | if ((offset_fsb >= imap->br_startoff) && |
620 | (offset_fsb < (imap->br_startoff + | 620 | (offset_fsb < (imap->br_startoff + |
@@ -724,7 +724,7 @@ xfs_iomap_write_unwritten( | |||
724 | return XFS_ERROR(error); | 724 | return XFS_ERROR(error); |
725 | 725 | ||
726 | if (!(imap.br_startblock || XFS_IS_REALTIME_INODE(ip))) | 726 | if (!(imap.br_startblock || XFS_IS_REALTIME_INODE(ip))) |
727 | return xfs_cmn_err_fsblock_zero(ip, &imap); | 727 | return xfs_alert_fsblock_zero(ip, &imap); |
728 | 728 | ||
729 | if ((numblks_fsb = imap.br_blockcount) == 0) { | 729 | if ((numblks_fsb = imap.br_blockcount) == 0) { |
730 | /* | 730 | /* |
diff --git a/fs/xfs/xfs_log.c b/fs/xfs/xfs_log.c index ae6fef1ff563..25efa9b8a602 100644 --- a/fs/xfs/xfs_log.c +++ b/fs/xfs/xfs_log.c | |||
@@ -374,11 +374,10 @@ xfs_log_mount( | |||
374 | int error; | 374 | int error; |
375 | 375 | ||
376 | if (!(mp->m_flags & XFS_MOUNT_NORECOVERY)) | 376 | if (!(mp->m_flags & XFS_MOUNT_NORECOVERY)) |
377 | cmn_err(CE_NOTE, "XFS mounting filesystem %s", mp->m_fsname); | 377 | xfs_notice(mp, "Mounting Filesystem"); |
378 | else { | 378 | else { |
379 | cmn_err(CE_NOTE, | 379 | xfs_notice(mp, |
380 | "Mounting filesystem \"%s\" in no-recovery mode. Filesystem will be inconsistent.", | 380 | "Mounting filesystem in no-recovery mode. Filesystem will be inconsistent."); |
381 | mp->m_fsname); | ||
382 | ASSERT(mp->m_flags & XFS_MOUNT_RDONLY); | 381 | ASSERT(mp->m_flags & XFS_MOUNT_RDONLY); |
383 | } | 382 | } |
384 | 383 | ||
@@ -393,7 +392,7 @@ xfs_log_mount( | |||
393 | */ | 392 | */ |
394 | error = xfs_trans_ail_init(mp); | 393 | error = xfs_trans_ail_init(mp); |
395 | if (error) { | 394 | if (error) { |
396 | cmn_err(CE_WARN, "XFS: AIL initialisation failed: error %d", error); | 395 | xfs_warn(mp, "AIL initialisation failed: error %d", error); |
397 | goto out_free_log; | 396 | goto out_free_log; |
398 | } | 397 | } |
399 | mp->m_log->l_ailp = mp->m_ail; | 398 | mp->m_log->l_ailp = mp->m_ail; |
@@ -413,7 +412,8 @@ xfs_log_mount( | |||
413 | if (readonly) | 412 | if (readonly) |
414 | mp->m_flags |= XFS_MOUNT_RDONLY; | 413 | mp->m_flags |= XFS_MOUNT_RDONLY; |
415 | if (error) { | 414 | if (error) { |
416 | cmn_err(CE_WARN, "XFS: log mount/recovery failed: error %d", error); | 415 | xfs_warn(mp, "log mount/recovery failed: error %d", |
416 | error); | ||
417 | goto out_destroy_ail; | 417 | goto out_destroy_ail; |
418 | } | 418 | } |
419 | } | 419 | } |
@@ -542,10 +542,8 @@ xfs_log_unmount_write(xfs_mount_t *mp) | |||
542 | */ | 542 | */ |
543 | } | 543 | } |
544 | 544 | ||
545 | if (error) { | 545 | if (error) |
546 | xfs_fs_cmn_err(CE_ALERT, mp, | 546 | xfs_alert(mp, "%s: unmount record failed", __func__); |
547 | "xfs_log_unmount: unmount record failed"); | ||
548 | } | ||
549 | 547 | ||
550 | 548 | ||
551 | spin_lock(&log->l_icloglock); | 549 | spin_lock(&log->l_icloglock); |
@@ -852,7 +850,7 @@ xlog_space_left( | |||
852 | * In this case we just want to return the size of the | 850 | * In this case we just want to return the size of the |
853 | * log as the amount of space left. | 851 | * log as the amount of space left. |
854 | */ | 852 | */ |
855 | xfs_fs_cmn_err(CE_ALERT, log->l_mp, | 853 | xfs_alert(log->l_mp, |
856 | "xlog_space_left: head behind tail\n" | 854 | "xlog_space_left: head behind tail\n" |
857 | " tail_cycle = %d, tail_bytes = %d\n" | 855 | " tail_cycle = %d, tail_bytes = %d\n" |
858 | " GH cycle = %d, GH bytes = %d", | 856 | " GH cycle = %d, GH bytes = %d", |
@@ -1001,7 +999,7 @@ xlog_alloc_log(xfs_mount_t *mp, | |||
1001 | 999 | ||
1002 | log = kmem_zalloc(sizeof(xlog_t), KM_MAYFAIL); | 1000 | log = kmem_zalloc(sizeof(xlog_t), KM_MAYFAIL); |
1003 | if (!log) { | 1001 | if (!log) { |
1004 | xlog_warn("XFS: Log allocation failed: No memory!"); | 1002 | xfs_warn(mp, "Log allocation failed: No memory!"); |
1005 | goto out; | 1003 | goto out; |
1006 | } | 1004 | } |
1007 | 1005 | ||
@@ -1029,24 +1027,24 @@ xlog_alloc_log(xfs_mount_t *mp, | |||
1029 | if (xfs_sb_version_hassector(&mp->m_sb)) { | 1027 | if (xfs_sb_version_hassector(&mp->m_sb)) { |
1030 | log2_size = mp->m_sb.sb_logsectlog; | 1028 | log2_size = mp->m_sb.sb_logsectlog; |
1031 | if (log2_size < BBSHIFT) { | 1029 | if (log2_size < BBSHIFT) { |
1032 | xlog_warn("XFS: Log sector size too small " | 1030 | xfs_warn(mp, "Log sector size too small (0x%x < 0x%x)", |
1033 | "(0x%x < 0x%x)", log2_size, BBSHIFT); | 1031 | log2_size, BBSHIFT); |
1034 | goto out_free_log; | 1032 | goto out_free_log; |
1035 | } | 1033 | } |
1036 | 1034 | ||
1037 | log2_size -= BBSHIFT; | 1035 | log2_size -= BBSHIFT; |
1038 | if (log2_size > mp->m_sectbb_log) { | 1036 | if (log2_size > mp->m_sectbb_log) { |
1039 | xlog_warn("XFS: Log sector size too large " | 1037 | xfs_warn(mp, "Log sector size too large (0x%x > 0x%x)", |
1040 | "(0x%x > 0x%x)", log2_size, mp->m_sectbb_log); | 1038 | log2_size, mp->m_sectbb_log); |
1041 | goto out_free_log; | 1039 | goto out_free_log; |
1042 | } | 1040 | } |
1043 | 1041 | ||
1044 | /* for larger sector sizes, must have v2 or external log */ | 1042 | /* for larger sector sizes, must have v2 or external log */ |
1045 | if (log2_size && log->l_logBBstart > 0 && | 1043 | if (log2_size && log->l_logBBstart > 0 && |
1046 | !xfs_sb_version_haslogv2(&mp->m_sb)) { | 1044 | !xfs_sb_version_haslogv2(&mp->m_sb)) { |
1047 | 1045 | xfs_warn(mp, | |
1048 | xlog_warn("XFS: log sector size (0x%x) invalid " | 1046 | "log sector size (0x%x) invalid for configuration.", |
1049 | "for configuration.", log2_size); | 1047 | log2_size); |
1050 | goto out_free_log; | 1048 | goto out_free_log; |
1051 | } | 1049 | } |
1052 | } | 1050 | } |
@@ -1563,38 +1561,36 @@ xlog_print_tic_res( | |||
1563 | "SWAPEXT" | 1561 | "SWAPEXT" |
1564 | }; | 1562 | }; |
1565 | 1563 | ||
1566 | xfs_fs_cmn_err(CE_WARN, mp, | 1564 | xfs_warn(mp, |
1567 | "xfs_log_write: reservation summary:\n" | 1565 | "xfs_log_write: reservation summary:\n" |
1568 | " trans type = %s (%u)\n" | 1566 | " trans type = %s (%u)\n" |
1569 | " unit res = %d bytes\n" | 1567 | " unit res = %d bytes\n" |
1570 | " current res = %d bytes\n" | 1568 | " current res = %d bytes\n" |
1571 | " total reg = %u bytes (o/flow = %u bytes)\n" | 1569 | " total reg = %u bytes (o/flow = %u bytes)\n" |
1572 | " ophdrs = %u (ophdr space = %u bytes)\n" | 1570 | " ophdrs = %u (ophdr space = %u bytes)\n" |
1573 | " ophdr + reg = %u bytes\n" | 1571 | " ophdr + reg = %u bytes\n" |
1574 | " num regions = %u\n", | 1572 | " num regions = %u\n", |
1575 | ((ticket->t_trans_type <= 0 || | 1573 | ((ticket->t_trans_type <= 0 || |
1576 | ticket->t_trans_type > XFS_TRANS_TYPE_MAX) ? | 1574 | ticket->t_trans_type > XFS_TRANS_TYPE_MAX) ? |
1577 | "bad-trans-type" : trans_type_str[ticket->t_trans_type-1]), | 1575 | "bad-trans-type" : trans_type_str[ticket->t_trans_type-1]), |
1578 | ticket->t_trans_type, | 1576 | ticket->t_trans_type, |
1579 | ticket->t_unit_res, | 1577 | ticket->t_unit_res, |
1580 | ticket->t_curr_res, | 1578 | ticket->t_curr_res, |
1581 | ticket->t_res_arr_sum, ticket->t_res_o_flow, | 1579 | ticket->t_res_arr_sum, ticket->t_res_o_flow, |
1582 | ticket->t_res_num_ophdrs, ophdr_spc, | 1580 | ticket->t_res_num_ophdrs, ophdr_spc, |
1583 | ticket->t_res_arr_sum + | 1581 | ticket->t_res_arr_sum + |
1584 | ticket->t_res_o_flow + ophdr_spc, | 1582 | ticket->t_res_o_flow + ophdr_spc, |
1585 | ticket->t_res_num); | 1583 | ticket->t_res_num); |
1586 | 1584 | ||
1587 | for (i = 0; i < ticket->t_res_num; i++) { | 1585 | for (i = 0; i < ticket->t_res_num; i++) { |
1588 | uint r_type = ticket->t_res_arr[i].r_type; | 1586 | uint r_type = ticket->t_res_arr[i].r_type; |
1589 | cmn_err(CE_WARN, | 1587 | xfs_warn(mp, "region[%u]: %s - %u bytes\n", i, |
1590 | "region[%u]: %s - %u bytes\n", | ||
1591 | i, | ||
1592 | ((r_type <= 0 || r_type > XLOG_REG_TYPE_MAX) ? | 1588 | ((r_type <= 0 || r_type > XLOG_REG_TYPE_MAX) ? |
1593 | "bad-rtype" : res_type_str[r_type-1]), | 1589 | "bad-rtype" : res_type_str[r_type-1]), |
1594 | ticket->t_res_arr[i].r_len); | 1590 | ticket->t_res_arr[i].r_len); |
1595 | } | 1591 | } |
1596 | 1592 | ||
1597 | xfs_cmn_err(XFS_PTAG_LOGRES, CE_ALERT, mp, | 1593 | xfs_alert_tag(mp, XFS_PTAG_LOGRES, |
1598 | "xfs_log_write: reservation ran out. Need to up reservation"); | 1594 | "xfs_log_write: reservation ran out. Need to up reservation"); |
1599 | xfs_force_shutdown(mp, SHUTDOWN_CORRUPT_INCORE); | 1595 | xfs_force_shutdown(mp, SHUTDOWN_CORRUPT_INCORE); |
1600 | } | 1596 | } |
@@ -1682,7 +1678,7 @@ xlog_write_setup_ophdr( | |||
1682 | case XFS_LOG: | 1678 | case XFS_LOG: |
1683 | break; | 1679 | break; |
1684 | default: | 1680 | default: |
1685 | xfs_fs_cmn_err(CE_WARN, log->l_mp, | 1681 | xfs_warn(log->l_mp, |
1686 | "Bad XFS transaction clientid 0x%x in ticket 0x%p", | 1682 | "Bad XFS transaction clientid 0x%x in ticket 0x%p", |
1687 | ophdr->oh_clientid, ticket); | 1683 | ophdr->oh_clientid, ticket); |
1688 | return NULL; | 1684 | return NULL; |
@@ -2264,7 +2260,7 @@ xlog_state_do_callback( | |||
2264 | if (repeats > 5000) { | 2260 | if (repeats > 5000) { |
2265 | flushcnt += repeats; | 2261 | flushcnt += repeats; |
2266 | repeats = 0; | 2262 | repeats = 0; |
2267 | xfs_fs_cmn_err(CE_WARN, log->l_mp, | 2263 | xfs_warn(log->l_mp, |
2268 | "%s: possible infinite loop (%d iterations)", | 2264 | "%s: possible infinite loop (%d iterations)", |
2269 | __func__, flushcnt); | 2265 | __func__, flushcnt); |
2270 | } | 2266 | } |
@@ -3052,10 +3048,8 @@ xfs_log_force( | |||
3052 | int error; | 3048 | int error; |
3053 | 3049 | ||
3054 | error = _xfs_log_force(mp, flags, NULL); | 3050 | error = _xfs_log_force(mp, flags, NULL); |
3055 | if (error) { | 3051 | if (error) |
3056 | xfs_fs_cmn_err(CE_WARN, mp, "xfs_log_force: " | 3052 | xfs_warn(mp, "%s: error %d returned.", __func__, error); |
3057 | "error %d returned.", error); | ||
3058 | } | ||
3059 | } | 3053 | } |
3060 | 3054 | ||
3061 | /* | 3055 | /* |
@@ -3204,10 +3198,8 @@ xfs_log_force_lsn( | |||
3204 | int error; | 3198 | int error; |
3205 | 3199 | ||
3206 | error = _xfs_log_force_lsn(mp, lsn, flags, NULL); | 3200 | error = _xfs_log_force_lsn(mp, lsn, flags, NULL); |
3207 | if (error) { | 3201 | if (error) |
3208 | xfs_fs_cmn_err(CE_WARN, mp, "xfs_log_force: " | 3202 | xfs_warn(mp, "%s: error %d returned.", __func__, error); |
3209 | "error %d returned.", error); | ||
3210 | } | ||
3211 | } | 3203 | } |
3212 | 3204 | ||
3213 | /* | 3205 | /* |
@@ -3412,7 +3404,7 @@ xlog_verify_dest_ptr( | |||
3412 | } | 3404 | } |
3413 | 3405 | ||
3414 | if (!good_ptr) | 3406 | if (!good_ptr) |
3415 | xlog_panic("xlog_verify_dest_ptr: invalid ptr"); | 3407 | xfs_emerg(log->l_mp, "%s: invalid ptr", __func__); |
3416 | } | 3408 | } |
3417 | 3409 | ||
3418 | STATIC void | 3410 | STATIC void |
@@ -3448,16 +3440,16 @@ xlog_verify_tail_lsn(xlog_t *log, | |||
3448 | blocks = | 3440 | blocks = |
3449 | log->l_logBBsize - (log->l_prev_block - BLOCK_LSN(tail_lsn)); | 3441 | log->l_logBBsize - (log->l_prev_block - BLOCK_LSN(tail_lsn)); |
3450 | if (blocks < BTOBB(iclog->ic_offset)+BTOBB(log->l_iclog_hsize)) | 3442 | if (blocks < BTOBB(iclog->ic_offset)+BTOBB(log->l_iclog_hsize)) |
3451 | xlog_panic("xlog_verify_tail_lsn: ran out of log space"); | 3443 | xfs_emerg(log->l_mp, "%s: ran out of log space", __func__); |
3452 | } else { | 3444 | } else { |
3453 | ASSERT(CYCLE_LSN(tail_lsn)+1 == log->l_prev_cycle); | 3445 | ASSERT(CYCLE_LSN(tail_lsn)+1 == log->l_prev_cycle); |
3454 | 3446 | ||
3455 | if (BLOCK_LSN(tail_lsn) == log->l_prev_block) | 3447 | if (BLOCK_LSN(tail_lsn) == log->l_prev_block) |
3456 | xlog_panic("xlog_verify_tail_lsn: tail wrapped"); | 3448 | xfs_emerg(log->l_mp, "%s: tail wrapped", __func__); |
3457 | 3449 | ||
3458 | blocks = BLOCK_LSN(tail_lsn) - log->l_prev_block; | 3450 | blocks = BLOCK_LSN(tail_lsn) - log->l_prev_block; |
3459 | if (blocks < BTOBB(iclog->ic_offset) + 1) | 3451 | if (blocks < BTOBB(iclog->ic_offset) + 1) |
3460 | xlog_panic("xlog_verify_tail_lsn: ran out of log space"); | 3452 | xfs_emerg(log->l_mp, "%s: ran out of log space", __func__); |
3461 | } | 3453 | } |
3462 | } /* xlog_verify_tail_lsn */ | 3454 | } /* xlog_verify_tail_lsn */ |
3463 | 3455 | ||
@@ -3497,22 +3489,23 @@ xlog_verify_iclog(xlog_t *log, | |||
3497 | icptr = log->l_iclog; | 3489 | icptr = log->l_iclog; |
3498 | for (i=0; i < log->l_iclog_bufs; i++) { | 3490 | for (i=0; i < log->l_iclog_bufs; i++) { |
3499 | if (icptr == NULL) | 3491 | if (icptr == NULL) |
3500 | xlog_panic("xlog_verify_iclog: invalid ptr"); | 3492 | xfs_emerg(log->l_mp, "%s: invalid ptr", __func__); |
3501 | icptr = icptr->ic_next; | 3493 | icptr = icptr->ic_next; |
3502 | } | 3494 | } |
3503 | if (icptr != log->l_iclog) | 3495 | if (icptr != log->l_iclog) |
3504 | xlog_panic("xlog_verify_iclog: corrupt iclog ring"); | 3496 | xfs_emerg(log->l_mp, "%s: corrupt iclog ring", __func__); |
3505 | spin_unlock(&log->l_icloglock); | 3497 | spin_unlock(&log->l_icloglock); |
3506 | 3498 | ||
3507 | /* check log magic numbers */ | 3499 | /* check log magic numbers */ |
3508 | if (be32_to_cpu(iclog->ic_header.h_magicno) != XLOG_HEADER_MAGIC_NUM) | 3500 | if (be32_to_cpu(iclog->ic_header.h_magicno) != XLOG_HEADER_MAGIC_NUM) |
3509 | xlog_panic("xlog_verify_iclog: invalid magic num"); | 3501 | xfs_emerg(log->l_mp, "%s: invalid magic num", __func__); |
3510 | 3502 | ||
3511 | ptr = (xfs_caddr_t) &iclog->ic_header; | 3503 | ptr = (xfs_caddr_t) &iclog->ic_header; |
3512 | for (ptr += BBSIZE; ptr < ((xfs_caddr_t)&iclog->ic_header) + count; | 3504 | for (ptr += BBSIZE; ptr < ((xfs_caddr_t)&iclog->ic_header) + count; |
3513 | ptr += BBSIZE) { | 3505 | ptr += BBSIZE) { |
3514 | if (be32_to_cpu(*(__be32 *)ptr) == XLOG_HEADER_MAGIC_NUM) | 3506 | if (be32_to_cpu(*(__be32 *)ptr) == XLOG_HEADER_MAGIC_NUM) |
3515 | xlog_panic("xlog_verify_iclog: unexpected magic num"); | 3507 | xfs_emerg(log->l_mp, "%s: unexpected magic num", |
3508 | __func__); | ||
3516 | } | 3509 | } |
3517 | 3510 | ||
3518 | /* check fields */ | 3511 | /* check fields */ |
@@ -3542,9 +3535,10 @@ xlog_verify_iclog(xlog_t *log, | |||
3542 | } | 3535 | } |
3543 | } | 3536 | } |
3544 | if (clientid != XFS_TRANSACTION && clientid != XFS_LOG) | 3537 | if (clientid != XFS_TRANSACTION && clientid != XFS_LOG) |
3545 | cmn_err(CE_WARN, "xlog_verify_iclog: " | 3538 | xfs_warn(log->l_mp, |
3546 | "invalid clientid %d op 0x%p offset 0x%lx", | 3539 | "%s: invalid clientid %d op 0x%p offset 0x%lx", |
3547 | clientid, ophead, (unsigned long)field_offset); | 3540 | __func__, clientid, ophead, |
3541 | (unsigned long)field_offset); | ||
3548 | 3542 | ||
3549 | /* check length */ | 3543 | /* check length */ |
3550 | field_offset = (__psint_t) | 3544 | field_offset = (__psint_t) |
diff --git a/fs/xfs/xfs_log_priv.h b/fs/xfs/xfs_log_priv.h index d5f8be8f4bf6..15dbf1f9c2be 100644 --- a/fs/xfs/xfs_log_priv.h +++ b/fs/xfs/xfs_log_priv.h | |||
@@ -87,10 +87,6 @@ static inline uint xlog_get_client_id(__be32 i) | |||
87 | return be32_to_cpu(i) >> 24; | 87 | return be32_to_cpu(i) >> 24; |
88 | } | 88 | } |
89 | 89 | ||
90 | #define xlog_panic(args...) cmn_err(CE_PANIC, ## args) | ||
91 | #define xlog_exit(args...) cmn_err(CE_PANIC, ## args) | ||
92 | #define xlog_warn(args...) cmn_err(CE_WARN, ## args) | ||
93 | |||
94 | /* | 90 | /* |
95 | * In core log state | 91 | * In core log state |
96 | */ | 92 | */ |
diff --git a/fs/xfs/xfs_log_recover.c b/fs/xfs/xfs_log_recover.c index aa0ebb776903..0c4a5618e7af 100644 --- a/fs/xfs/xfs_log_recover.c +++ b/fs/xfs/xfs_log_recover.c | |||
@@ -92,7 +92,7 @@ xlog_get_bp( | |||
92 | int nbblks) | 92 | int nbblks) |
93 | { | 93 | { |
94 | if (!xlog_buf_bbcount_valid(log, nbblks)) { | 94 | if (!xlog_buf_bbcount_valid(log, nbblks)) { |
95 | xlog_warn("XFS: Invalid block length (0x%x) given for buffer", | 95 | xfs_warn(log->l_mp, "Invalid block length (0x%x) for buffer", |
96 | nbblks); | 96 | nbblks); |
97 | XFS_ERROR_REPORT(__func__, XFS_ERRLEVEL_HIGH, log->l_mp); | 97 | XFS_ERROR_REPORT(__func__, XFS_ERRLEVEL_HIGH, log->l_mp); |
98 | return NULL; | 98 | return NULL; |
@@ -160,7 +160,7 @@ xlog_bread_noalign( | |||
160 | int error; | 160 | int error; |
161 | 161 | ||
162 | if (!xlog_buf_bbcount_valid(log, nbblks)) { | 162 | if (!xlog_buf_bbcount_valid(log, nbblks)) { |
163 | xlog_warn("XFS: Invalid block length (0x%x) given for buffer", | 163 | xfs_warn(log->l_mp, "Invalid block length (0x%x) for buffer", |
164 | nbblks); | 164 | nbblks); |
165 | XFS_ERROR_REPORT(__func__, XFS_ERRLEVEL_HIGH, log->l_mp); | 165 | XFS_ERROR_REPORT(__func__, XFS_ERRLEVEL_HIGH, log->l_mp); |
166 | return EFSCORRUPTED; | 166 | return EFSCORRUPTED; |
@@ -219,7 +219,7 @@ xlog_bwrite( | |||
219 | int error; | 219 | int error; |
220 | 220 | ||
221 | if (!xlog_buf_bbcount_valid(log, nbblks)) { | 221 | if (!xlog_buf_bbcount_valid(log, nbblks)) { |
222 | xlog_warn("XFS: Invalid block length (0x%x) given for buffer", | 222 | xfs_warn(log->l_mp, "Invalid block length (0x%x) for buffer", |
223 | nbblks); | 223 | nbblks); |
224 | XFS_ERROR_REPORT(__func__, XFS_ERRLEVEL_HIGH, log->l_mp); | 224 | XFS_ERROR_REPORT(__func__, XFS_ERRLEVEL_HIGH, log->l_mp); |
225 | return EFSCORRUPTED; | 225 | return EFSCORRUPTED; |
@@ -254,9 +254,9 @@ xlog_header_check_dump( | |||
254 | xfs_mount_t *mp, | 254 | xfs_mount_t *mp, |
255 | xlog_rec_header_t *head) | 255 | xlog_rec_header_t *head) |
256 | { | 256 | { |
257 | cmn_err(CE_DEBUG, "%s: SB : uuid = %pU, fmt = %d\n", | 257 | xfs_debug(mp, "%s: SB : uuid = %pU, fmt = %d\n", |
258 | __func__, &mp->m_sb.sb_uuid, XLOG_FMT); | 258 | __func__, &mp->m_sb.sb_uuid, XLOG_FMT); |
259 | cmn_err(CE_DEBUG, " log : uuid = %pU, fmt = %d\n", | 259 | xfs_debug(mp, " log : uuid = %pU, fmt = %d\n", |
260 | &head->h_fs_uuid, be32_to_cpu(head->h_fmt)); | 260 | &head->h_fs_uuid, be32_to_cpu(head->h_fmt)); |
261 | } | 261 | } |
262 | #else | 262 | #else |
@@ -279,15 +279,15 @@ xlog_header_check_recover( | |||
279 | * a dirty log created in IRIX. | 279 | * a dirty log created in IRIX. |
280 | */ | 280 | */ |
281 | if (unlikely(be32_to_cpu(head->h_fmt) != XLOG_FMT)) { | 281 | if (unlikely(be32_to_cpu(head->h_fmt) != XLOG_FMT)) { |
282 | xlog_warn( | 282 | xfs_warn(mp, |
283 | "XFS: dirty log written in incompatible format - can't recover"); | 283 | "dirty log written in incompatible format - can't recover"); |
284 | xlog_header_check_dump(mp, head); | 284 | xlog_header_check_dump(mp, head); |
285 | XFS_ERROR_REPORT("xlog_header_check_recover(1)", | 285 | XFS_ERROR_REPORT("xlog_header_check_recover(1)", |
286 | XFS_ERRLEVEL_HIGH, mp); | 286 | XFS_ERRLEVEL_HIGH, mp); |
287 | return XFS_ERROR(EFSCORRUPTED); | 287 | return XFS_ERROR(EFSCORRUPTED); |
288 | } else if (unlikely(!uuid_equal(&mp->m_sb.sb_uuid, &head->h_fs_uuid))) { | 288 | } else if (unlikely(!uuid_equal(&mp->m_sb.sb_uuid, &head->h_fs_uuid))) { |
289 | xlog_warn( | 289 | xfs_warn(mp, |
290 | "XFS: dirty log entry has mismatched uuid - can't recover"); | 290 | "dirty log entry has mismatched uuid - can't recover"); |
291 | xlog_header_check_dump(mp, head); | 291 | xlog_header_check_dump(mp, head); |
292 | XFS_ERROR_REPORT("xlog_header_check_recover(2)", | 292 | XFS_ERROR_REPORT("xlog_header_check_recover(2)", |
293 | XFS_ERRLEVEL_HIGH, mp); | 293 | XFS_ERRLEVEL_HIGH, mp); |
@@ -312,9 +312,9 @@ xlog_header_check_mount( | |||
312 | * h_fs_uuid is nil, we assume this log was last mounted | 312 | * h_fs_uuid is nil, we assume this log was last mounted |
313 | * by IRIX and continue. | 313 | * by IRIX and continue. |
314 | */ | 314 | */ |
315 | xlog_warn("XFS: nil uuid in log - IRIX style log"); | 315 | xfs_warn(mp, "nil uuid in log - IRIX style log"); |
316 | } else if (unlikely(!uuid_equal(&mp->m_sb.sb_uuid, &head->h_fs_uuid))) { | 316 | } else if (unlikely(!uuid_equal(&mp->m_sb.sb_uuid, &head->h_fs_uuid))) { |
317 | xlog_warn("XFS: log has mismatched uuid - can't recover"); | 317 | xfs_warn(mp, "log has mismatched uuid - can't recover"); |
318 | xlog_header_check_dump(mp, head); | 318 | xlog_header_check_dump(mp, head); |
319 | XFS_ERROR_REPORT("xlog_header_check_mount", | 319 | XFS_ERROR_REPORT("xlog_header_check_mount", |
320 | XFS_ERRLEVEL_HIGH, mp); | 320 | XFS_ERRLEVEL_HIGH, mp); |
@@ -490,8 +490,8 @@ xlog_find_verify_log_record( | |||
490 | for (i = (*last_blk) - 1; i >= 0; i--) { | 490 | for (i = (*last_blk) - 1; i >= 0; i--) { |
491 | if (i < start_blk) { | 491 | if (i < start_blk) { |
492 | /* valid log record not found */ | 492 | /* valid log record not found */ |
493 | xlog_warn( | 493 | xfs_warn(log->l_mp, |
494 | "XFS: Log inconsistent (didn't find previous header)"); | 494 | "Log inconsistent (didn't find previous header)"); |
495 | ASSERT(0); | 495 | ASSERT(0); |
496 | error = XFS_ERROR(EIO); | 496 | error = XFS_ERROR(EIO); |
497 | goto out; | 497 | goto out; |
@@ -591,12 +591,12 @@ xlog_find_head( | |||
591 | * mkfs etc write a dummy unmount record to a fresh | 591 | * mkfs etc write a dummy unmount record to a fresh |
592 | * log so we can store the uuid in there | 592 | * log so we can store the uuid in there |
593 | */ | 593 | */ |
594 | xlog_warn("XFS: totally zeroed log"); | 594 | xfs_warn(log->l_mp, "totally zeroed log"); |
595 | } | 595 | } |
596 | 596 | ||
597 | return 0; | 597 | return 0; |
598 | } else if (error) { | 598 | } else if (error) { |
599 | xlog_warn("XFS: empty log check failed"); | 599 | xfs_warn(log->l_mp, "empty log check failed"); |
600 | return error; | 600 | return error; |
601 | } | 601 | } |
602 | 602 | ||
@@ -819,7 +819,7 @@ validate_head: | |||
819 | xlog_put_bp(bp); | 819 | xlog_put_bp(bp); |
820 | 820 | ||
821 | if (error) | 821 | if (error) |
822 | xlog_warn("XFS: failed to find log head"); | 822 | xfs_warn(log->l_mp, "failed to find log head"); |
823 | return error; | 823 | return error; |
824 | } | 824 | } |
825 | 825 | ||
@@ -912,7 +912,7 @@ xlog_find_tail( | |||
912 | } | 912 | } |
913 | } | 913 | } |
914 | if (!found) { | 914 | if (!found) { |
915 | xlog_warn("XFS: xlog_find_tail: couldn't find sync record"); | 915 | xfs_warn(log->l_mp, "%s: couldn't find sync record", __func__); |
916 | ASSERT(0); | 916 | ASSERT(0); |
917 | return XFS_ERROR(EIO); | 917 | return XFS_ERROR(EIO); |
918 | } | 918 | } |
@@ -1028,7 +1028,7 @@ done: | |||
1028 | xlog_put_bp(bp); | 1028 | xlog_put_bp(bp); |
1029 | 1029 | ||
1030 | if (error) | 1030 | if (error) |
1031 | xlog_warn("XFS: failed to locate log tail"); | 1031 | xfs_warn(log->l_mp, "failed to locate log tail"); |
1032 | return error; | 1032 | return error; |
1033 | } | 1033 | } |
1034 | 1034 | ||
@@ -1092,7 +1092,8 @@ xlog_find_zeroed( | |||
1092 | * the first block must be 1. If it's not, maybe we're | 1092 | * the first block must be 1. If it's not, maybe we're |
1093 | * not looking at a log... Bail out. | 1093 | * not looking at a log... Bail out. |
1094 | */ | 1094 | */ |
1095 | xlog_warn("XFS: Log inconsistent or not a log (last==0, first!=1)"); | 1095 | xfs_warn(log->l_mp, |
1096 | "Log inconsistent or not a log (last==0, first!=1)"); | ||
1096 | return XFS_ERROR(EINVAL); | 1097 | return XFS_ERROR(EINVAL); |
1097 | } | 1098 | } |
1098 | 1099 | ||
@@ -1506,8 +1507,8 @@ xlog_recover_add_to_trans( | |||
1506 | if (list_empty(&trans->r_itemq)) { | 1507 | if (list_empty(&trans->r_itemq)) { |
1507 | /* we need to catch log corruptions here */ | 1508 | /* we need to catch log corruptions here */ |
1508 | if (*(uint *)dp != XFS_TRANS_HEADER_MAGIC) { | 1509 | if (*(uint *)dp != XFS_TRANS_HEADER_MAGIC) { |
1509 | xlog_warn("XFS: xlog_recover_add_to_trans: " | 1510 | xfs_warn(log->l_mp, "%s: bad header magic number", |
1510 | "bad header magic number"); | 1511 | __func__); |
1511 | ASSERT(0); | 1512 | ASSERT(0); |
1512 | return XFS_ERROR(EIO); | 1513 | return XFS_ERROR(EIO); |
1513 | } | 1514 | } |
@@ -1534,8 +1535,8 @@ xlog_recover_add_to_trans( | |||
1534 | if (item->ri_total == 0) { /* first region to be added */ | 1535 | if (item->ri_total == 0) { /* first region to be added */ |
1535 | if (in_f->ilf_size == 0 || | 1536 | if (in_f->ilf_size == 0 || |
1536 | in_f->ilf_size > XLOG_MAX_REGIONS_IN_ITEM) { | 1537 | in_f->ilf_size > XLOG_MAX_REGIONS_IN_ITEM) { |
1537 | xlog_warn( | 1538 | xfs_warn(log->l_mp, |
1538 | "XFS: bad number of regions (%d) in inode log format", | 1539 | "bad number of regions (%d) in inode log format", |
1539 | in_f->ilf_size); | 1540 | in_f->ilf_size); |
1540 | ASSERT(0); | 1541 | ASSERT(0); |
1541 | return XFS_ERROR(EIO); | 1542 | return XFS_ERROR(EIO); |
@@ -1592,8 +1593,9 @@ xlog_recover_reorder_trans( | |||
1592 | list_move_tail(&item->ri_list, &trans->r_itemq); | 1593 | list_move_tail(&item->ri_list, &trans->r_itemq); |
1593 | break; | 1594 | break; |
1594 | default: | 1595 | default: |
1595 | xlog_warn( | 1596 | xfs_warn(log->l_mp, |
1596 | "XFS: xlog_recover_reorder_trans: unrecognized type of log operation"); | 1597 | "%s: unrecognized type of log operation", |
1598 | __func__); | ||
1597 | ASSERT(0); | 1599 | ASSERT(0); |
1598 | return XFS_ERROR(EIO); | 1600 | return XFS_ERROR(EIO); |
1599 | } | 1601 | } |
@@ -1803,8 +1805,9 @@ xlog_recover_do_inode_buffer( | |||
1803 | logged_nextp = item->ri_buf[item_index].i_addr + | 1805 | logged_nextp = item->ri_buf[item_index].i_addr + |
1804 | next_unlinked_offset - reg_buf_offset; | 1806 | next_unlinked_offset - reg_buf_offset; |
1805 | if (unlikely(*logged_nextp == 0)) { | 1807 | if (unlikely(*logged_nextp == 0)) { |
1806 | xfs_fs_cmn_err(CE_ALERT, mp, | 1808 | xfs_alert(mp, |
1807 | "bad inode buffer log record (ptr = 0x%p, bp = 0x%p). XFS trying to replay bad (0) inode di_next_unlinked field", | 1809 | "Bad inode buffer log record (ptr = 0x%p, bp = 0x%p). " |
1810 | "Trying to replay bad (0) inode di_next_unlinked field.", | ||
1808 | item, bp); | 1811 | item, bp); |
1809 | XFS_ERROR_REPORT("xlog_recover_do_inode_buf", | 1812 | XFS_ERROR_REPORT("xlog_recover_do_inode_buf", |
1810 | XFS_ERRLEVEL_LOW, mp); | 1813 | XFS_ERRLEVEL_LOW, mp); |
@@ -1863,17 +1866,17 @@ xlog_recover_do_reg_buffer( | |||
1863 | if (buf_f->blf_flags & | 1866 | if (buf_f->blf_flags & |
1864 | (XFS_BLF_UDQUOT_BUF|XFS_BLF_PDQUOT_BUF|XFS_BLF_GDQUOT_BUF)) { | 1867 | (XFS_BLF_UDQUOT_BUF|XFS_BLF_PDQUOT_BUF|XFS_BLF_GDQUOT_BUF)) { |
1865 | if (item->ri_buf[i].i_addr == NULL) { | 1868 | if (item->ri_buf[i].i_addr == NULL) { |
1866 | cmn_err(CE_ALERT, | 1869 | xfs_alert(mp, |
1867 | "XFS: NULL dquot in %s.", __func__); | 1870 | "XFS: NULL dquot in %s.", __func__); |
1868 | goto next; | 1871 | goto next; |
1869 | } | 1872 | } |
1870 | if (item->ri_buf[i].i_len < sizeof(xfs_disk_dquot_t)) { | 1873 | if (item->ri_buf[i].i_len < sizeof(xfs_disk_dquot_t)) { |
1871 | cmn_err(CE_ALERT, | 1874 | xfs_alert(mp, |
1872 | "XFS: dquot too small (%d) in %s.", | 1875 | "XFS: dquot too small (%d) in %s.", |
1873 | item->ri_buf[i].i_len, __func__); | 1876 | item->ri_buf[i].i_len, __func__); |
1874 | goto next; | 1877 | goto next; |
1875 | } | 1878 | } |
1876 | error = xfs_qm_dqcheck(item->ri_buf[i].i_addr, | 1879 | error = xfs_qm_dqcheck(mp, item->ri_buf[i].i_addr, |
1877 | -1, 0, XFS_QMOPT_DOWARN, | 1880 | -1, 0, XFS_QMOPT_DOWARN, |
1878 | "dquot_buf_recover"); | 1881 | "dquot_buf_recover"); |
1879 | if (error) | 1882 | if (error) |
@@ -1898,6 +1901,7 @@ xlog_recover_do_reg_buffer( | |||
1898 | */ | 1901 | */ |
1899 | int | 1902 | int |
1900 | xfs_qm_dqcheck( | 1903 | xfs_qm_dqcheck( |
1904 | struct xfs_mount *mp, | ||
1901 | xfs_disk_dquot_t *ddq, | 1905 | xfs_disk_dquot_t *ddq, |
1902 | xfs_dqid_t id, | 1906 | xfs_dqid_t id, |
1903 | uint type, /* used only when IO_dorepair is true */ | 1907 | uint type, /* used only when IO_dorepair is true */ |
@@ -1924,14 +1928,14 @@ xfs_qm_dqcheck( | |||
1924 | */ | 1928 | */ |
1925 | if (be16_to_cpu(ddq->d_magic) != XFS_DQUOT_MAGIC) { | 1929 | if (be16_to_cpu(ddq->d_magic) != XFS_DQUOT_MAGIC) { |
1926 | if (flags & XFS_QMOPT_DOWARN) | 1930 | if (flags & XFS_QMOPT_DOWARN) |
1927 | cmn_err(CE_ALERT, | 1931 | xfs_alert(mp, |
1928 | "%s : XFS dquot ID 0x%x, magic 0x%x != 0x%x", | 1932 | "%s : XFS dquot ID 0x%x, magic 0x%x != 0x%x", |
1929 | str, id, be16_to_cpu(ddq->d_magic), XFS_DQUOT_MAGIC); | 1933 | str, id, be16_to_cpu(ddq->d_magic), XFS_DQUOT_MAGIC); |
1930 | errs++; | 1934 | errs++; |
1931 | } | 1935 | } |
1932 | if (ddq->d_version != XFS_DQUOT_VERSION) { | 1936 | if (ddq->d_version != XFS_DQUOT_VERSION) { |
1933 | if (flags & XFS_QMOPT_DOWARN) | 1937 | if (flags & XFS_QMOPT_DOWARN) |
1934 | cmn_err(CE_ALERT, | 1938 | xfs_alert(mp, |
1935 | "%s : XFS dquot ID 0x%x, version 0x%x != 0x%x", | 1939 | "%s : XFS dquot ID 0x%x, version 0x%x != 0x%x", |
1936 | str, id, ddq->d_version, XFS_DQUOT_VERSION); | 1940 | str, id, ddq->d_version, XFS_DQUOT_VERSION); |
1937 | errs++; | 1941 | errs++; |
@@ -1941,7 +1945,7 @@ xfs_qm_dqcheck( | |||
1941 | ddq->d_flags != XFS_DQ_PROJ && | 1945 | ddq->d_flags != XFS_DQ_PROJ && |
1942 | ddq->d_flags != XFS_DQ_GROUP) { | 1946 | ddq->d_flags != XFS_DQ_GROUP) { |
1943 | if (flags & XFS_QMOPT_DOWARN) | 1947 | if (flags & XFS_QMOPT_DOWARN) |
1944 | cmn_err(CE_ALERT, | 1948 | xfs_alert(mp, |
1945 | "%s : XFS dquot ID 0x%x, unknown flags 0x%x", | 1949 | "%s : XFS dquot ID 0x%x, unknown flags 0x%x", |
1946 | str, id, ddq->d_flags); | 1950 | str, id, ddq->d_flags); |
1947 | errs++; | 1951 | errs++; |
@@ -1949,7 +1953,7 @@ xfs_qm_dqcheck( | |||
1949 | 1953 | ||
1950 | if (id != -1 && id != be32_to_cpu(ddq->d_id)) { | 1954 | if (id != -1 && id != be32_to_cpu(ddq->d_id)) { |
1951 | if (flags & XFS_QMOPT_DOWARN) | 1955 | if (flags & XFS_QMOPT_DOWARN) |
1952 | cmn_err(CE_ALERT, | 1956 | xfs_alert(mp, |
1953 | "%s : ondisk-dquot 0x%p, ID mismatch: " | 1957 | "%s : ondisk-dquot 0x%p, ID mismatch: " |
1954 | "0x%x expected, found id 0x%x", | 1958 | "0x%x expected, found id 0x%x", |
1955 | str, ddq, id, be32_to_cpu(ddq->d_id)); | 1959 | str, ddq, id, be32_to_cpu(ddq->d_id)); |
@@ -1962,9 +1966,8 @@ xfs_qm_dqcheck( | |||
1962 | be64_to_cpu(ddq->d_blk_softlimit)) { | 1966 | be64_to_cpu(ddq->d_blk_softlimit)) { |
1963 | if (!ddq->d_btimer) { | 1967 | if (!ddq->d_btimer) { |
1964 | if (flags & XFS_QMOPT_DOWARN) | 1968 | if (flags & XFS_QMOPT_DOWARN) |
1965 | cmn_err(CE_ALERT, | 1969 | xfs_alert(mp, |
1966 | "%s : Dquot ID 0x%x (0x%p) " | 1970 | "%s : Dquot ID 0x%x (0x%p) BLK TIMER NOT STARTED", |
1967 | "BLK TIMER NOT STARTED", | ||
1968 | str, (int)be32_to_cpu(ddq->d_id), ddq); | 1971 | str, (int)be32_to_cpu(ddq->d_id), ddq); |
1969 | errs++; | 1972 | errs++; |
1970 | } | 1973 | } |
@@ -1974,9 +1977,8 @@ xfs_qm_dqcheck( | |||
1974 | be64_to_cpu(ddq->d_ino_softlimit)) { | 1977 | be64_to_cpu(ddq->d_ino_softlimit)) { |
1975 | if (!ddq->d_itimer) { | 1978 | if (!ddq->d_itimer) { |
1976 | if (flags & XFS_QMOPT_DOWARN) | 1979 | if (flags & XFS_QMOPT_DOWARN) |
1977 | cmn_err(CE_ALERT, | 1980 | xfs_alert(mp, |
1978 | "%s : Dquot ID 0x%x (0x%p) " | 1981 | "%s : Dquot ID 0x%x (0x%p) INODE TIMER NOT STARTED", |
1979 | "INODE TIMER NOT STARTED", | ||
1980 | str, (int)be32_to_cpu(ddq->d_id), ddq); | 1982 | str, (int)be32_to_cpu(ddq->d_id), ddq); |
1981 | errs++; | 1983 | errs++; |
1982 | } | 1984 | } |
@@ -1986,9 +1988,8 @@ xfs_qm_dqcheck( | |||
1986 | be64_to_cpu(ddq->d_rtb_softlimit)) { | 1988 | be64_to_cpu(ddq->d_rtb_softlimit)) { |
1987 | if (!ddq->d_rtbtimer) { | 1989 | if (!ddq->d_rtbtimer) { |
1988 | if (flags & XFS_QMOPT_DOWARN) | 1990 | if (flags & XFS_QMOPT_DOWARN) |
1989 | cmn_err(CE_ALERT, | 1991 | xfs_alert(mp, |
1990 | "%s : Dquot ID 0x%x (0x%p) " | 1992 | "%s : Dquot ID 0x%x (0x%p) RTBLK TIMER NOT STARTED", |
1991 | "RTBLK TIMER NOT STARTED", | ||
1992 | str, (int)be32_to_cpu(ddq->d_id), ddq); | 1993 | str, (int)be32_to_cpu(ddq->d_id), ddq); |
1993 | errs++; | 1994 | errs++; |
1994 | } | 1995 | } |
@@ -1999,7 +2000,7 @@ xfs_qm_dqcheck( | |||
1999 | return errs; | 2000 | return errs; |
2000 | 2001 | ||
2001 | if (flags & XFS_QMOPT_DOWARN) | 2002 | if (flags & XFS_QMOPT_DOWARN) |
2002 | cmn_err(CE_NOTE, "Re-initializing dquot ID 0x%x", id); | 2003 | xfs_notice(mp, "Re-initializing dquot ID 0x%x", id); |
2003 | 2004 | ||
2004 | /* | 2005 | /* |
2005 | * Typically, a repair is only requested by quotacheck. | 2006 | * Typically, a repair is only requested by quotacheck. |
@@ -2218,9 +2219,9 @@ xlog_recover_inode_pass2( | |||
2218 | */ | 2219 | */ |
2219 | if (unlikely(be16_to_cpu(dip->di_magic) != XFS_DINODE_MAGIC)) { | 2220 | if (unlikely(be16_to_cpu(dip->di_magic) != XFS_DINODE_MAGIC)) { |
2220 | xfs_buf_relse(bp); | 2221 | xfs_buf_relse(bp); |
2221 | xfs_fs_cmn_err(CE_ALERT, mp, | 2222 | xfs_alert(mp, |
2222 | "xfs_inode_recover: Bad inode magic number, dino ptr = 0x%p, dino bp = 0x%p, ino = %Ld", | 2223 | "%s: Bad inode magic number, dip = 0x%p, dino bp = 0x%p, ino = %Ld", |
2223 | dip, bp, in_f->ilf_ino); | 2224 | __func__, dip, bp, in_f->ilf_ino); |
2224 | XFS_ERROR_REPORT("xlog_recover_inode_pass2(1)", | 2225 | XFS_ERROR_REPORT("xlog_recover_inode_pass2(1)", |
2225 | XFS_ERRLEVEL_LOW, mp); | 2226 | XFS_ERRLEVEL_LOW, mp); |
2226 | error = EFSCORRUPTED; | 2227 | error = EFSCORRUPTED; |
@@ -2229,9 +2230,9 @@ xlog_recover_inode_pass2( | |||
2229 | dicp = item->ri_buf[1].i_addr; | 2230 | dicp = item->ri_buf[1].i_addr; |
2230 | if (unlikely(dicp->di_magic != XFS_DINODE_MAGIC)) { | 2231 | if (unlikely(dicp->di_magic != XFS_DINODE_MAGIC)) { |
2231 | xfs_buf_relse(bp); | 2232 | xfs_buf_relse(bp); |
2232 | xfs_fs_cmn_err(CE_ALERT, mp, | 2233 | xfs_alert(mp, |
2233 | "xfs_inode_recover: Bad inode log record, rec ptr 0x%p, ino %Ld", | 2234 | "%s: Bad inode log record, rec ptr 0x%p, ino %Ld", |
2234 | item, in_f->ilf_ino); | 2235 | __func__, item, in_f->ilf_ino); |
2235 | XFS_ERROR_REPORT("xlog_recover_inode_pass2(2)", | 2236 | XFS_ERROR_REPORT("xlog_recover_inode_pass2(2)", |
2236 | XFS_ERRLEVEL_LOW, mp); | 2237 | XFS_ERRLEVEL_LOW, mp); |
2237 | error = EFSCORRUPTED; | 2238 | error = EFSCORRUPTED; |
@@ -2263,9 +2264,10 @@ xlog_recover_inode_pass2( | |||
2263 | XFS_CORRUPTION_ERROR("xlog_recover_inode_pass2(3)", | 2264 | XFS_CORRUPTION_ERROR("xlog_recover_inode_pass2(3)", |
2264 | XFS_ERRLEVEL_LOW, mp, dicp); | 2265 | XFS_ERRLEVEL_LOW, mp, dicp); |
2265 | xfs_buf_relse(bp); | 2266 | xfs_buf_relse(bp); |
2266 | xfs_fs_cmn_err(CE_ALERT, mp, | 2267 | xfs_alert(mp, |
2267 | "xfs_inode_recover: Bad regular inode log record, rec ptr 0x%p, ino ptr = 0x%p, ino bp = 0x%p, ino %Ld", | 2268 | "%s: Bad regular inode log record, rec ptr 0x%p, " |
2268 | item, dip, bp, in_f->ilf_ino); | 2269 | "ino ptr = 0x%p, ino bp = 0x%p, ino %Ld", |
2270 | __func__, item, dip, bp, in_f->ilf_ino); | ||
2269 | error = EFSCORRUPTED; | 2271 | error = EFSCORRUPTED; |
2270 | goto error; | 2272 | goto error; |
2271 | } | 2273 | } |
@@ -2276,9 +2278,10 @@ xlog_recover_inode_pass2( | |||
2276 | XFS_CORRUPTION_ERROR("xlog_recover_inode_pass2(4)", | 2278 | XFS_CORRUPTION_ERROR("xlog_recover_inode_pass2(4)", |
2277 | XFS_ERRLEVEL_LOW, mp, dicp); | 2279 | XFS_ERRLEVEL_LOW, mp, dicp); |
2278 | xfs_buf_relse(bp); | 2280 | xfs_buf_relse(bp); |
2279 | xfs_fs_cmn_err(CE_ALERT, mp, | 2281 | xfs_alert(mp, |
2280 | "xfs_inode_recover: Bad dir inode log record, rec ptr 0x%p, ino ptr = 0x%p, ino bp = 0x%p, ino %Ld", | 2282 | "%s: Bad dir inode log record, rec ptr 0x%p, " |
2281 | item, dip, bp, in_f->ilf_ino); | 2283 | "ino ptr = 0x%p, ino bp = 0x%p, ino %Ld", |
2284 | __func__, item, dip, bp, in_f->ilf_ino); | ||
2282 | error = EFSCORRUPTED; | 2285 | error = EFSCORRUPTED; |
2283 | goto error; | 2286 | goto error; |
2284 | } | 2287 | } |
@@ -2287,9 +2290,10 @@ xlog_recover_inode_pass2( | |||
2287 | XFS_CORRUPTION_ERROR("xlog_recover_inode_pass2(5)", | 2290 | XFS_CORRUPTION_ERROR("xlog_recover_inode_pass2(5)", |
2288 | XFS_ERRLEVEL_LOW, mp, dicp); | 2291 | XFS_ERRLEVEL_LOW, mp, dicp); |
2289 | xfs_buf_relse(bp); | 2292 | xfs_buf_relse(bp); |
2290 | xfs_fs_cmn_err(CE_ALERT, mp, | 2293 | xfs_alert(mp, |
2291 | "xfs_inode_recover: Bad inode log record, rec ptr 0x%p, dino ptr 0x%p, dino bp 0x%p, ino %Ld, total extents = %d, nblocks = %Ld", | 2294 | "%s: Bad inode log record, rec ptr 0x%p, dino ptr 0x%p, " |
2292 | item, dip, bp, in_f->ilf_ino, | 2295 | "dino bp 0x%p, ino %Ld, total extents = %d, nblocks = %Ld", |
2296 | __func__, item, dip, bp, in_f->ilf_ino, | ||
2293 | dicp->di_nextents + dicp->di_anextents, | 2297 | dicp->di_nextents + dicp->di_anextents, |
2294 | dicp->di_nblocks); | 2298 | dicp->di_nblocks); |
2295 | error = EFSCORRUPTED; | 2299 | error = EFSCORRUPTED; |
@@ -2299,8 +2303,9 @@ xlog_recover_inode_pass2( | |||
2299 | XFS_CORRUPTION_ERROR("xlog_recover_inode_pass2(6)", | 2303 | XFS_CORRUPTION_ERROR("xlog_recover_inode_pass2(6)", |
2300 | XFS_ERRLEVEL_LOW, mp, dicp); | 2304 | XFS_ERRLEVEL_LOW, mp, dicp); |
2301 | xfs_buf_relse(bp); | 2305 | xfs_buf_relse(bp); |
2302 | xfs_fs_cmn_err(CE_ALERT, mp, | 2306 | xfs_alert(mp, |
2303 | "xfs_inode_recover: Bad inode log rec ptr 0x%p, dino ptr 0x%p, dino bp 0x%p, ino %Ld, forkoff 0x%x", | 2307 | "%s: Bad inode log record, rec ptr 0x%p, dino ptr 0x%p, " |
2308 | "dino bp 0x%p, ino %Ld, forkoff 0x%x", __func__, | ||
2304 | item, dip, bp, in_f->ilf_ino, dicp->di_forkoff); | 2309 | item, dip, bp, in_f->ilf_ino, dicp->di_forkoff); |
2305 | error = EFSCORRUPTED; | 2310 | error = EFSCORRUPTED; |
2306 | goto error; | 2311 | goto error; |
@@ -2309,9 +2314,9 @@ xlog_recover_inode_pass2( | |||
2309 | XFS_CORRUPTION_ERROR("xlog_recover_inode_pass2(7)", | 2314 | XFS_CORRUPTION_ERROR("xlog_recover_inode_pass2(7)", |
2310 | XFS_ERRLEVEL_LOW, mp, dicp); | 2315 | XFS_ERRLEVEL_LOW, mp, dicp); |
2311 | xfs_buf_relse(bp); | 2316 | xfs_buf_relse(bp); |
2312 | xfs_fs_cmn_err(CE_ALERT, mp, | 2317 | xfs_alert(mp, |
2313 | "xfs_inode_recover: Bad inode log record length %d, rec ptr 0x%p", | 2318 | "%s: Bad inode log record length %d, rec ptr 0x%p", |
2314 | item->ri_buf[1].i_len, item); | 2319 | __func__, item->ri_buf[1].i_len, item); |
2315 | error = EFSCORRUPTED; | 2320 | error = EFSCORRUPTED; |
2316 | goto error; | 2321 | goto error; |
2317 | } | 2322 | } |
@@ -2398,7 +2403,7 @@ xlog_recover_inode_pass2( | |||
2398 | break; | 2403 | break; |
2399 | 2404 | ||
2400 | default: | 2405 | default: |
2401 | xlog_warn("XFS: xlog_recover_inode_pass2: Invalid flag"); | 2406 | xfs_warn(log->l_mp, "%s: Invalid flag", __func__); |
2402 | ASSERT(0); | 2407 | ASSERT(0); |
2403 | xfs_buf_relse(bp); | 2408 | xfs_buf_relse(bp); |
2404 | error = EIO; | 2409 | error = EIO; |
@@ -2467,13 +2472,11 @@ xlog_recover_dquot_pass2( | |||
2467 | 2472 | ||
2468 | recddq = item->ri_buf[1].i_addr; | 2473 | recddq = item->ri_buf[1].i_addr; |
2469 | if (recddq == NULL) { | 2474 | if (recddq == NULL) { |
2470 | cmn_err(CE_ALERT, | 2475 | xfs_alert(log->l_mp, "NULL dquot in %s.", __func__); |
2471 | "XFS: NULL dquot in %s.", __func__); | ||
2472 | return XFS_ERROR(EIO); | 2476 | return XFS_ERROR(EIO); |
2473 | } | 2477 | } |
2474 | if (item->ri_buf[1].i_len < sizeof(xfs_disk_dquot_t)) { | 2478 | if (item->ri_buf[1].i_len < sizeof(xfs_disk_dquot_t)) { |
2475 | cmn_err(CE_ALERT, | 2479 | xfs_alert(log->l_mp, "dquot too small (%d) in %s.", |
2476 | "XFS: dquot too small (%d) in %s.", | ||
2477 | item->ri_buf[1].i_len, __func__); | 2480 | item->ri_buf[1].i_len, __func__); |
2478 | return XFS_ERROR(EIO); | 2481 | return XFS_ERROR(EIO); |
2479 | } | 2482 | } |
@@ -2498,12 +2501,10 @@ xlog_recover_dquot_pass2( | |||
2498 | */ | 2501 | */ |
2499 | dq_f = item->ri_buf[0].i_addr; | 2502 | dq_f = item->ri_buf[0].i_addr; |
2500 | ASSERT(dq_f); | 2503 | ASSERT(dq_f); |
2501 | if ((error = xfs_qm_dqcheck(recddq, | 2504 | error = xfs_qm_dqcheck(mp, recddq, dq_f->qlf_id, 0, XFS_QMOPT_DOWARN, |
2502 | dq_f->qlf_id, | 2505 | "xlog_recover_dquot_pass2 (log copy)"); |
2503 | 0, XFS_QMOPT_DOWARN, | 2506 | if (error) |
2504 | "xlog_recover_dquot_pass2 (log copy)"))) { | ||
2505 | return XFS_ERROR(EIO); | 2507 | return XFS_ERROR(EIO); |
2506 | } | ||
2507 | ASSERT(dq_f->qlf_len == 1); | 2508 | ASSERT(dq_f->qlf_len == 1); |
2508 | 2509 | ||
2509 | error = xfs_read_buf(mp, mp->m_ddev_targp, | 2510 | error = xfs_read_buf(mp, mp->m_ddev_targp, |
@@ -2523,8 +2524,9 @@ xlog_recover_dquot_pass2( | |||
2523 | * was among a chunk of dquots created earlier, and we did some | 2524 | * was among a chunk of dquots created earlier, and we did some |
2524 | * minimal initialization then. | 2525 | * minimal initialization then. |
2525 | */ | 2526 | */ |
2526 | if (xfs_qm_dqcheck(ddq, dq_f->qlf_id, 0, XFS_QMOPT_DOWARN, | 2527 | error = xfs_qm_dqcheck(mp, ddq, dq_f->qlf_id, 0, XFS_QMOPT_DOWARN, |
2527 | "xlog_recover_dquot_pass2")) { | 2528 | "xlog_recover_dquot_pass2"); |
2529 | if (error) { | ||
2528 | xfs_buf_relse(bp); | 2530 | xfs_buf_relse(bp); |
2529 | return XFS_ERROR(EIO); | 2531 | return XFS_ERROR(EIO); |
2530 | } | 2532 | } |
@@ -2676,9 +2678,8 @@ xlog_recover_commit_pass1( | |||
2676 | /* nothing to do in pass 1 */ | 2678 | /* nothing to do in pass 1 */ |
2677 | return 0; | 2679 | return 0; |
2678 | default: | 2680 | default: |
2679 | xlog_warn( | 2681 | xfs_warn(log->l_mp, "%s: invalid item type (%d)", |
2680 | "XFS: invalid item type (%d) xlog_recover_commit_pass1", | 2682 | __func__, ITEM_TYPE(item)); |
2681 | ITEM_TYPE(item)); | ||
2682 | ASSERT(0); | 2683 | ASSERT(0); |
2683 | return XFS_ERROR(EIO); | 2684 | return XFS_ERROR(EIO); |
2684 | } | 2685 | } |
@@ -2707,9 +2708,8 @@ xlog_recover_commit_pass2( | |||
2707 | /* nothing to do in pass2 */ | 2708 | /* nothing to do in pass2 */ |
2708 | return 0; | 2709 | return 0; |
2709 | default: | 2710 | default: |
2710 | xlog_warn( | 2711 | xfs_warn(log->l_mp, "%s: invalid item type (%d)", |
2711 | "XFS: invalid item type (%d) xlog_recover_commit_pass2", | 2712 | __func__, ITEM_TYPE(item)); |
2712 | ITEM_TYPE(item)); | ||
2713 | ASSERT(0); | 2713 | ASSERT(0); |
2714 | return XFS_ERROR(EIO); | 2714 | return XFS_ERROR(EIO); |
2715 | } | 2715 | } |
@@ -2751,10 +2751,11 @@ xlog_recover_commit_trans( | |||
2751 | 2751 | ||
2752 | STATIC int | 2752 | STATIC int |
2753 | xlog_recover_unmount_trans( | 2753 | xlog_recover_unmount_trans( |
2754 | struct log *log, | ||
2754 | xlog_recover_t *trans) | 2755 | xlog_recover_t *trans) |
2755 | { | 2756 | { |
2756 | /* Do nothing now */ | 2757 | /* Do nothing now */ |
2757 | xlog_warn("XFS: xlog_recover_unmount_trans: Unmount LR"); | 2758 | xfs_warn(log->l_mp, "%s: Unmount LR", __func__); |
2758 | return 0; | 2759 | return 0; |
2759 | } | 2760 | } |
2760 | 2761 | ||
@@ -2797,8 +2798,8 @@ xlog_recover_process_data( | |||
2797 | dp += sizeof(xlog_op_header_t); | 2798 | dp += sizeof(xlog_op_header_t); |
2798 | if (ohead->oh_clientid != XFS_TRANSACTION && | 2799 | if (ohead->oh_clientid != XFS_TRANSACTION && |
2799 | ohead->oh_clientid != XFS_LOG) { | 2800 | ohead->oh_clientid != XFS_LOG) { |
2800 | xlog_warn( | 2801 | xfs_warn(log->l_mp, "%s: bad clientid 0x%x", |
2801 | "XFS: xlog_recover_process_data: bad clientid"); | 2802 | __func__, ohead->oh_clientid); |
2802 | ASSERT(0); | 2803 | ASSERT(0); |
2803 | return (XFS_ERROR(EIO)); | 2804 | return (XFS_ERROR(EIO)); |
2804 | } | 2805 | } |
@@ -2811,8 +2812,8 @@ xlog_recover_process_data( | |||
2811 | be64_to_cpu(rhead->h_lsn)); | 2812 | be64_to_cpu(rhead->h_lsn)); |
2812 | } else { | 2813 | } else { |
2813 | if (dp + be32_to_cpu(ohead->oh_len) > lp) { | 2814 | if (dp + be32_to_cpu(ohead->oh_len) > lp) { |
2814 | xlog_warn( | 2815 | xfs_warn(log->l_mp, "%s: bad length 0x%x", |
2815 | "XFS: xlog_recover_process_data: bad length"); | 2816 | __func__, be32_to_cpu(ohead->oh_len)); |
2816 | WARN_ON(1); | 2817 | WARN_ON(1); |
2817 | return (XFS_ERROR(EIO)); | 2818 | return (XFS_ERROR(EIO)); |
2818 | } | 2819 | } |
@@ -2825,7 +2826,7 @@ xlog_recover_process_data( | |||
2825 | trans, pass); | 2826 | trans, pass); |
2826 | break; | 2827 | break; |
2827 | case XLOG_UNMOUNT_TRANS: | 2828 | case XLOG_UNMOUNT_TRANS: |
2828 | error = xlog_recover_unmount_trans(trans); | 2829 | error = xlog_recover_unmount_trans(log, trans); |
2829 | break; | 2830 | break; |
2830 | case XLOG_WAS_CONT_TRANS: | 2831 | case XLOG_WAS_CONT_TRANS: |
2831 | error = xlog_recover_add_to_cont_trans(log, | 2832 | error = xlog_recover_add_to_cont_trans(log, |
@@ -2833,8 +2834,8 @@ xlog_recover_process_data( | |||
2833 | be32_to_cpu(ohead->oh_len)); | 2834 | be32_to_cpu(ohead->oh_len)); |
2834 | break; | 2835 | break; |
2835 | case XLOG_START_TRANS: | 2836 | case XLOG_START_TRANS: |
2836 | xlog_warn( | 2837 | xfs_warn(log->l_mp, "%s: bad transaction", |
2837 | "XFS: xlog_recover_process_data: bad transaction"); | 2838 | __func__); |
2838 | ASSERT(0); | 2839 | ASSERT(0); |
2839 | error = XFS_ERROR(EIO); | 2840 | error = XFS_ERROR(EIO); |
2840 | break; | 2841 | break; |
@@ -2844,8 +2845,8 @@ xlog_recover_process_data( | |||
2844 | dp, be32_to_cpu(ohead->oh_len)); | 2845 | dp, be32_to_cpu(ohead->oh_len)); |
2845 | break; | 2846 | break; |
2846 | default: | 2847 | default: |
2847 | xlog_warn( | 2848 | xfs_warn(log->l_mp, "%s: bad flag 0x%x", |
2848 | "XFS: xlog_recover_process_data: bad flag"); | 2849 | __func__, flags); |
2849 | ASSERT(0); | 2850 | ASSERT(0); |
2850 | error = XFS_ERROR(EIO); | 2851 | error = XFS_ERROR(EIO); |
2851 | break; | 2852 | break; |
@@ -3030,8 +3031,7 @@ xlog_recover_clear_agi_bucket( | |||
3030 | out_abort: | 3031 | out_abort: |
3031 | xfs_trans_cancel(tp, XFS_TRANS_ABORT); | 3032 | xfs_trans_cancel(tp, XFS_TRANS_ABORT); |
3032 | out_error: | 3033 | out_error: |
3033 | xfs_fs_cmn_err(CE_WARN, mp, "xlog_recover_clear_agi_bucket: " | 3034 | xfs_warn(mp, "%s: failed to clear agi %d. Continuing.", __func__, agno); |
3034 | "failed to clear agi %d. Continuing.", agno); | ||
3035 | return; | 3035 | return; |
3036 | } | 3036 | } |
3037 | 3037 | ||
@@ -3282,7 +3282,7 @@ xlog_valid_rec_header( | |||
3282 | if (unlikely( | 3282 | if (unlikely( |
3283 | (!rhead->h_version || | 3283 | (!rhead->h_version || |
3284 | (be32_to_cpu(rhead->h_version) & (~XLOG_VERSION_OKBITS))))) { | 3284 | (be32_to_cpu(rhead->h_version) & (~XLOG_VERSION_OKBITS))))) { |
3285 | xlog_warn("XFS: %s: unrecognised log version (%d).", | 3285 | xfs_warn(log->l_mp, "%s: unrecognised log version (%d).", |
3286 | __func__, be32_to_cpu(rhead->h_version)); | 3286 | __func__, be32_to_cpu(rhead->h_version)); |
3287 | return XFS_ERROR(EIO); | 3287 | return XFS_ERROR(EIO); |
3288 | } | 3288 | } |
@@ -3740,10 +3740,9 @@ xlog_recover( | |||
3740 | return error; | 3740 | return error; |
3741 | } | 3741 | } |
3742 | 3742 | ||
3743 | cmn_err(CE_NOTE, | 3743 | xfs_notice(log->l_mp, "Starting recovery (logdev: %s)", |
3744 | "Starting XFS recovery on filesystem: %s (logdev: %s)", | 3744 | log->l_mp->m_logname ? log->l_mp->m_logname |
3745 | log->l_mp->m_fsname, log->l_mp->m_logname ? | 3745 | : "internal"); |
3746 | log->l_mp->m_logname : "internal"); | ||
3747 | 3746 | ||
3748 | error = xlog_do_recover(log, head_blk, tail_blk); | 3747 | error = xlog_do_recover(log, head_blk, tail_blk); |
3749 | log->l_flags |= XLOG_RECOVERY_NEEDED; | 3748 | log->l_flags |= XLOG_RECOVERY_NEEDED; |
@@ -3776,9 +3775,7 @@ xlog_recover_finish( | |||
3776 | int error; | 3775 | int error; |
3777 | error = xlog_recover_process_efis(log); | 3776 | error = xlog_recover_process_efis(log); |
3778 | if (error) { | 3777 | if (error) { |
3779 | cmn_err(CE_ALERT, | 3778 | xfs_alert(log->l_mp, "Failed to recover EFIs"); |
3780 | "Failed to recover EFIs on filesystem: %s", | ||
3781 | log->l_mp->m_fsname); | ||
3782 | return error; | 3779 | return error; |
3783 | } | 3780 | } |
3784 | /* | 3781 | /* |
@@ -3793,15 +3790,12 @@ xlog_recover_finish( | |||
3793 | 3790 | ||
3794 | xlog_recover_check_summary(log); | 3791 | xlog_recover_check_summary(log); |
3795 | 3792 | ||
3796 | cmn_err(CE_NOTE, | 3793 | xfs_notice(log->l_mp, "Ending recovery (logdev: %s)", |
3797 | "Ending XFS recovery on filesystem: %s (logdev: %s)", | 3794 | log->l_mp->m_logname ? log->l_mp->m_logname |
3798 | log->l_mp->m_fsname, log->l_mp->m_logname ? | 3795 | : "internal"); |
3799 | log->l_mp->m_logname : "internal"); | ||
3800 | log->l_flags &= ~XLOG_RECOVERY_NEEDED; | 3796 | log->l_flags &= ~XLOG_RECOVERY_NEEDED; |
3801 | } else { | 3797 | } else { |
3802 | cmn_err(CE_DEBUG, | 3798 | xfs_info(log->l_mp, "Ending clean mount"); |
3803 | "Ending clean XFS mount for filesystem: %s\n", | ||
3804 | log->l_mp->m_fsname); | ||
3805 | } | 3799 | } |
3806 | return 0; | 3800 | return 0; |
3807 | } | 3801 | } |
@@ -3834,10 +3828,8 @@ xlog_recover_check_summary( | |||
3834 | for (agno = 0; agno < mp->m_sb.sb_agcount; agno++) { | 3828 | for (agno = 0; agno < mp->m_sb.sb_agcount; agno++) { |
3835 | error = xfs_read_agf(mp, NULL, agno, 0, &agfbp); | 3829 | error = xfs_read_agf(mp, NULL, agno, 0, &agfbp); |
3836 | if (error) { | 3830 | if (error) { |
3837 | xfs_fs_cmn_err(CE_ALERT, mp, | 3831 | xfs_alert(mp, "%s agf read failed agno %d error %d", |
3838 | "xlog_recover_check_summary(agf)" | 3832 | __func__, agno, error); |
3839 | "agf read failed agno %d error %d", | ||
3840 | agno, error); | ||
3841 | } else { | 3833 | } else { |
3842 | agfp = XFS_BUF_TO_AGF(agfbp); | 3834 | agfp = XFS_BUF_TO_AGF(agfbp); |
3843 | freeblks += be32_to_cpu(agfp->agf_freeblks) + | 3835 | freeblks += be32_to_cpu(agfp->agf_freeblks) + |
@@ -3846,7 +3838,10 @@ xlog_recover_check_summary( | |||
3846 | } | 3838 | } |
3847 | 3839 | ||
3848 | error = xfs_read_agi(mp, NULL, agno, &agibp); | 3840 | error = xfs_read_agi(mp, NULL, agno, &agibp); |
3849 | if (!error) { | 3841 | if (error) { |
3842 | xfs_alert(mp, "%s agi read failed agno %d error %d", | ||
3843 | __func__, agno, error); | ||
3844 | } else { | ||
3850 | struct xfs_agi *agi = XFS_BUF_TO_AGI(agibp); | 3845 | struct xfs_agi *agi = XFS_BUF_TO_AGI(agibp); |
3851 | 3846 | ||
3852 | itotal += be32_to_cpu(agi->agi_count); | 3847 | itotal += be32_to_cpu(agi->agi_count); |
diff --git a/fs/xfs/xfs_mount.c b/fs/xfs/xfs_mount.c index d447aef84bc3..bb3f9a7b24ed 100644 --- a/fs/xfs/xfs_mount.c +++ b/fs/xfs/xfs_mount.c | |||
@@ -133,9 +133,7 @@ xfs_uuid_mount( | |||
133 | return 0; | 133 | return 0; |
134 | 134 | ||
135 | if (uuid_is_nil(uuid)) { | 135 | if (uuid_is_nil(uuid)) { |
136 | cmn_err(CE_WARN, | 136 | xfs_warn(mp, "Filesystem has nil UUID - can't mount"); |
137 | "XFS: Filesystem %s has nil UUID - can't mount", | ||
138 | mp->m_fsname); | ||
139 | return XFS_ERROR(EINVAL); | 137 | return XFS_ERROR(EINVAL); |
140 | } | 138 | } |
141 | 139 | ||
@@ -163,8 +161,7 @@ xfs_uuid_mount( | |||
163 | 161 | ||
164 | out_duplicate: | 162 | out_duplicate: |
165 | mutex_unlock(&xfs_uuid_table_mutex); | 163 | mutex_unlock(&xfs_uuid_table_mutex); |
166 | cmn_err(CE_WARN, "XFS: Filesystem %s has duplicate UUID - can't mount", | 164 | xfs_warn(mp, "Filesystem has duplicate UUID - can't mount"); |
167 | mp->m_fsname); | ||
168 | return XFS_ERROR(EINVAL); | 165 | return XFS_ERROR(EINVAL); |
169 | } | 166 | } |
170 | 167 | ||
@@ -311,6 +308,8 @@ xfs_mount_validate_sb( | |||
311 | xfs_sb_t *sbp, | 308 | xfs_sb_t *sbp, |
312 | int flags) | 309 | int flags) |
313 | { | 310 | { |
311 | int loud = !(flags & XFS_MFSI_QUIET); | ||
312 | |||
314 | /* | 313 | /* |
315 | * If the log device and data device have the | 314 | * If the log device and data device have the |
316 | * same device number, the log is internal. | 315 | * same device number, the log is internal. |
@@ -319,28 +318,32 @@ xfs_mount_validate_sb( | |||
319 | * a volume filesystem in a non-volume manner. | 318 | * a volume filesystem in a non-volume manner. |
320 | */ | 319 | */ |
321 | if (sbp->sb_magicnum != XFS_SB_MAGIC) { | 320 | if (sbp->sb_magicnum != XFS_SB_MAGIC) { |
322 | xfs_fs_mount_cmn_err(flags, "bad magic number"); | 321 | if (loud) |
322 | xfs_warn(mp, "bad magic number"); | ||
323 | return XFS_ERROR(EWRONGFS); | 323 | return XFS_ERROR(EWRONGFS); |
324 | } | 324 | } |
325 | 325 | ||
326 | if (!xfs_sb_good_version(sbp)) { | 326 | if (!xfs_sb_good_version(sbp)) { |
327 | xfs_fs_mount_cmn_err(flags, "bad version"); | 327 | if (loud) |
328 | xfs_warn(mp, "bad version"); | ||
328 | return XFS_ERROR(EWRONGFS); | 329 | return XFS_ERROR(EWRONGFS); |
329 | } | 330 | } |
330 | 331 | ||
331 | if (unlikely( | 332 | if (unlikely( |
332 | sbp->sb_logstart == 0 && mp->m_logdev_targp == mp->m_ddev_targp)) { | 333 | sbp->sb_logstart == 0 && mp->m_logdev_targp == mp->m_ddev_targp)) { |
333 | xfs_fs_mount_cmn_err(flags, | 334 | if (loud) |
334 | "filesystem is marked as having an external log; " | 335 | xfs_warn(mp, |
335 | "specify logdev on the\nmount command line."); | 336 | "filesystem is marked as having an external log; " |
337 | "specify logdev on the mount command line."); | ||
336 | return XFS_ERROR(EINVAL); | 338 | return XFS_ERROR(EINVAL); |
337 | } | 339 | } |
338 | 340 | ||
339 | if (unlikely( | 341 | if (unlikely( |
340 | sbp->sb_logstart != 0 && mp->m_logdev_targp != mp->m_ddev_targp)) { | 342 | sbp->sb_logstart != 0 && mp->m_logdev_targp != mp->m_ddev_targp)) { |
341 | xfs_fs_mount_cmn_err(flags, | 343 | if (loud) |
342 | "filesystem is marked as having an internal log; " | 344 | xfs_warn(mp, |
343 | "do not specify logdev on\nthe mount command line."); | 345 | "filesystem is marked as having an internal log; " |
346 | "do not specify logdev on the mount command line."); | ||
344 | return XFS_ERROR(EINVAL); | 347 | return XFS_ERROR(EINVAL); |
345 | } | 348 | } |
346 | 349 | ||
@@ -369,7 +372,8 @@ xfs_mount_validate_sb( | |||
369 | (sbp->sb_rextsize * sbp->sb_blocksize > XFS_MAX_RTEXTSIZE) || | 372 | (sbp->sb_rextsize * sbp->sb_blocksize > XFS_MAX_RTEXTSIZE) || |
370 | (sbp->sb_rextsize * sbp->sb_blocksize < XFS_MIN_RTEXTSIZE) || | 373 | (sbp->sb_rextsize * sbp->sb_blocksize < XFS_MIN_RTEXTSIZE) || |
371 | (sbp->sb_imax_pct > 100 /* zero sb_imax_pct is valid */))) { | 374 | (sbp->sb_imax_pct > 100 /* zero sb_imax_pct is valid */))) { |
372 | xfs_fs_mount_cmn_err(flags, "SB sanity check 1 failed"); | 375 | if (loud) |
376 | xfs_warn(mp, "SB sanity check 1 failed"); | ||
373 | return XFS_ERROR(EFSCORRUPTED); | 377 | return XFS_ERROR(EFSCORRUPTED); |
374 | } | 378 | } |
375 | 379 | ||
@@ -382,7 +386,8 @@ xfs_mount_validate_sb( | |||
382 | (xfs_drfsbno_t)sbp->sb_agcount * sbp->sb_agblocks || | 386 | (xfs_drfsbno_t)sbp->sb_agcount * sbp->sb_agblocks || |
383 | sbp->sb_dblocks < (xfs_drfsbno_t)(sbp->sb_agcount - 1) * | 387 | sbp->sb_dblocks < (xfs_drfsbno_t)(sbp->sb_agcount - 1) * |
384 | sbp->sb_agblocks + XFS_MIN_AG_BLOCKS)) { | 388 | sbp->sb_agblocks + XFS_MIN_AG_BLOCKS)) { |
385 | xfs_fs_mount_cmn_err(flags, "SB sanity check 2 failed"); | 389 | if (loud) |
390 | xfs_warn(mp, "SB sanity check 2 failed"); | ||
386 | return XFS_ERROR(EFSCORRUPTED); | 391 | return XFS_ERROR(EFSCORRUPTED); |
387 | } | 392 | } |
388 | 393 | ||
@@ -390,12 +395,12 @@ xfs_mount_validate_sb( | |||
390 | * Until this is fixed only page-sized or smaller data blocks work. | 395 | * Until this is fixed only page-sized or smaller data blocks work. |
391 | */ | 396 | */ |
392 | if (unlikely(sbp->sb_blocksize > PAGE_SIZE)) { | 397 | if (unlikely(sbp->sb_blocksize > PAGE_SIZE)) { |
393 | xfs_fs_mount_cmn_err(flags, | 398 | if (loud) { |
394 | "file system with blocksize %d bytes", | 399 | xfs_warn(mp, |
395 | sbp->sb_blocksize); | 400 | "File system with blocksize %d bytes. " |
396 | xfs_fs_mount_cmn_err(flags, | 401 | "Only pagesize (%ld) or less will currently work.", |
397 | "only pagesize (%ld) or less will currently work.", | 402 | sbp->sb_blocksize, PAGE_SIZE); |
398 | PAGE_SIZE); | 403 | } |
399 | return XFS_ERROR(ENOSYS); | 404 | return XFS_ERROR(ENOSYS); |
400 | } | 405 | } |
401 | 406 | ||
@@ -409,21 +414,23 @@ xfs_mount_validate_sb( | |||
409 | case 2048: | 414 | case 2048: |
410 | break; | 415 | break; |
411 | default: | 416 | default: |
412 | xfs_fs_mount_cmn_err(flags, | 417 | if (loud) |
413 | "inode size of %d bytes not supported", | 418 | xfs_warn(mp, "inode size of %d bytes not supported", |
414 | sbp->sb_inodesize); | 419 | sbp->sb_inodesize); |
415 | return XFS_ERROR(ENOSYS); | 420 | return XFS_ERROR(ENOSYS); |
416 | } | 421 | } |
417 | 422 | ||
418 | if (xfs_sb_validate_fsb_count(sbp, sbp->sb_dblocks) || | 423 | if (xfs_sb_validate_fsb_count(sbp, sbp->sb_dblocks) || |
419 | xfs_sb_validate_fsb_count(sbp, sbp->sb_rblocks)) { | 424 | xfs_sb_validate_fsb_count(sbp, sbp->sb_rblocks)) { |
420 | xfs_fs_mount_cmn_err(flags, | 425 | if (loud) |
421 | "file system too large to be mounted on this system."); | 426 | xfs_warn(mp, |
427 | "file system too large to be mounted on this system."); | ||
422 | return XFS_ERROR(EFBIG); | 428 | return XFS_ERROR(EFBIG); |
423 | } | 429 | } |
424 | 430 | ||
425 | if (unlikely(sbp->sb_inprogress)) { | 431 | if (unlikely(sbp->sb_inprogress)) { |
426 | xfs_fs_mount_cmn_err(flags, "file system busy"); | 432 | if (loud) |
433 | xfs_warn(mp, "file system busy"); | ||
427 | return XFS_ERROR(EFSCORRUPTED); | 434 | return XFS_ERROR(EFSCORRUPTED); |
428 | } | 435 | } |
429 | 436 | ||
@@ -431,8 +438,9 @@ xfs_mount_validate_sb( | |||
431 | * Version 1 directory format has never worked on Linux. | 438 | * Version 1 directory format has never worked on Linux. |
432 | */ | 439 | */ |
433 | if (unlikely(!xfs_sb_version_hasdirv2(sbp))) { | 440 | if (unlikely(!xfs_sb_version_hasdirv2(sbp))) { |
434 | xfs_fs_mount_cmn_err(flags, | 441 | if (loud) |
435 | "file system using version 1 directory format"); | 442 | xfs_warn(mp, |
443 | "file system using version 1 directory format"); | ||
436 | return XFS_ERROR(ENOSYS); | 444 | return XFS_ERROR(ENOSYS); |
437 | } | 445 | } |
438 | 446 | ||
@@ -673,6 +681,7 @@ xfs_readsb(xfs_mount_t *mp, int flags) | |||
673 | unsigned int sector_size; | 681 | unsigned int sector_size; |
674 | xfs_buf_t *bp; | 682 | xfs_buf_t *bp; |
675 | int error; | 683 | int error; |
684 | int loud = !(flags & XFS_MFSI_QUIET); | ||
676 | 685 | ||
677 | ASSERT(mp->m_sb_bp == NULL); | 686 | ASSERT(mp->m_sb_bp == NULL); |
678 | ASSERT(mp->m_ddev_targp != NULL); | 687 | ASSERT(mp->m_ddev_targp != NULL); |
@@ -688,7 +697,8 @@ reread: | |||
688 | bp = xfs_buf_read_uncached(mp, mp->m_ddev_targp, | 697 | bp = xfs_buf_read_uncached(mp, mp->m_ddev_targp, |
689 | XFS_SB_DADDR, sector_size, 0); | 698 | XFS_SB_DADDR, sector_size, 0); |
690 | if (!bp) { | 699 | if (!bp) { |
691 | xfs_fs_mount_cmn_err(flags, "SB buffer read failed"); | 700 | if (loud) |
701 | xfs_warn(mp, "SB buffer read failed"); | ||
692 | return EIO; | 702 | return EIO; |
693 | } | 703 | } |
694 | 704 | ||
@@ -699,7 +709,8 @@ reread: | |||
699 | xfs_sb_from_disk(&mp->m_sb, XFS_BUF_TO_SBP(bp)); | 709 | xfs_sb_from_disk(&mp->m_sb, XFS_BUF_TO_SBP(bp)); |
700 | error = xfs_mount_validate_sb(mp, &(mp->m_sb), flags); | 710 | error = xfs_mount_validate_sb(mp, &(mp->m_sb), flags); |
701 | if (error) { | 711 | if (error) { |
702 | xfs_fs_mount_cmn_err(flags, "SB validate failed"); | 712 | if (loud) |
713 | xfs_warn(mp, "SB validate failed"); | ||
703 | goto release_buf; | 714 | goto release_buf; |
704 | } | 715 | } |
705 | 716 | ||
@@ -707,9 +718,9 @@ reread: | |||
707 | * We must be able to do sector-sized and sector-aligned IO. | 718 | * We must be able to do sector-sized and sector-aligned IO. |
708 | */ | 719 | */ |
709 | if (sector_size > mp->m_sb.sb_sectsize) { | 720 | if (sector_size > mp->m_sb.sb_sectsize) { |
710 | xfs_fs_mount_cmn_err(flags, | 721 | if (loud) |
711 | "device supports only %u byte sectors (not %u)", | 722 | xfs_warn(mp, "device supports %u byte sectors (not %u)", |
712 | sector_size, mp->m_sb.sb_sectsize); | 723 | sector_size, mp->m_sb.sb_sectsize); |
713 | error = ENOSYS; | 724 | error = ENOSYS; |
714 | goto release_buf; | 725 | goto release_buf; |
715 | } | 726 | } |
@@ -853,8 +864,7 @@ xfs_update_alignment(xfs_mount_t *mp) | |||
853 | if ((BBTOB(mp->m_dalign) & mp->m_blockmask) || | 864 | if ((BBTOB(mp->m_dalign) & mp->m_blockmask) || |
854 | (BBTOB(mp->m_swidth) & mp->m_blockmask)) { | 865 | (BBTOB(mp->m_swidth) & mp->m_blockmask)) { |
855 | if (mp->m_flags & XFS_MOUNT_RETERR) { | 866 | if (mp->m_flags & XFS_MOUNT_RETERR) { |
856 | cmn_err(CE_WARN, | 867 | xfs_warn(mp, "alignment check 1 failed"); |
857 | "XFS: alignment check 1 failed"); | ||
858 | return XFS_ERROR(EINVAL); | 868 | return XFS_ERROR(EINVAL); |
859 | } | 869 | } |
860 | mp->m_dalign = mp->m_swidth = 0; | 870 | mp->m_dalign = mp->m_swidth = 0; |
@@ -867,8 +877,9 @@ xfs_update_alignment(xfs_mount_t *mp) | |||
867 | if (mp->m_flags & XFS_MOUNT_RETERR) { | 877 | if (mp->m_flags & XFS_MOUNT_RETERR) { |
868 | return XFS_ERROR(EINVAL); | 878 | return XFS_ERROR(EINVAL); |
869 | } | 879 | } |
870 | xfs_fs_cmn_err(CE_WARN, mp, | 880 | xfs_warn(mp, |
871 | "stripe alignment turned off: sunit(%d)/swidth(%d) incompatible with agsize(%d)", | 881 | "stripe alignment turned off: sunit(%d)/swidth(%d) " |
882 | "incompatible with agsize(%d)", | ||
872 | mp->m_dalign, mp->m_swidth, | 883 | mp->m_dalign, mp->m_swidth, |
873 | sbp->sb_agblocks); | 884 | sbp->sb_agblocks); |
874 | 885 | ||
@@ -878,9 +889,9 @@ xfs_update_alignment(xfs_mount_t *mp) | |||
878 | mp->m_swidth = XFS_BB_TO_FSBT(mp, mp->m_swidth); | 889 | mp->m_swidth = XFS_BB_TO_FSBT(mp, mp->m_swidth); |
879 | } else { | 890 | } else { |
880 | if (mp->m_flags & XFS_MOUNT_RETERR) { | 891 | if (mp->m_flags & XFS_MOUNT_RETERR) { |
881 | xfs_fs_cmn_err(CE_WARN, mp, | 892 | xfs_warn(mp, |
882 | "stripe alignment turned off: sunit(%d) less than bsize(%d)", | 893 | "stripe alignment turned off: sunit(%d) less than bsize(%d)", |
883 | mp->m_dalign, | 894 | mp->m_dalign, |
884 | mp->m_blockmask +1); | 895 | mp->m_blockmask +1); |
885 | return XFS_ERROR(EINVAL); | 896 | return XFS_ERROR(EINVAL); |
886 | } | 897 | } |
@@ -1026,14 +1037,14 @@ xfs_check_sizes(xfs_mount_t *mp) | |||
1026 | 1037 | ||
1027 | d = (xfs_daddr_t)XFS_FSB_TO_BB(mp, mp->m_sb.sb_dblocks); | 1038 | d = (xfs_daddr_t)XFS_FSB_TO_BB(mp, mp->m_sb.sb_dblocks); |
1028 | if (XFS_BB_TO_FSB(mp, d) != mp->m_sb.sb_dblocks) { | 1039 | if (XFS_BB_TO_FSB(mp, d) != mp->m_sb.sb_dblocks) { |
1029 | cmn_err(CE_WARN, "XFS: filesystem size mismatch detected"); | 1040 | xfs_warn(mp, "filesystem size mismatch detected"); |
1030 | return XFS_ERROR(EFBIG); | 1041 | return XFS_ERROR(EFBIG); |
1031 | } | 1042 | } |
1032 | bp = xfs_buf_read_uncached(mp, mp->m_ddev_targp, | 1043 | bp = xfs_buf_read_uncached(mp, mp->m_ddev_targp, |
1033 | d - XFS_FSS_TO_BB(mp, 1), | 1044 | d - XFS_FSS_TO_BB(mp, 1), |
1034 | BBTOB(XFS_FSS_TO_BB(mp, 1)), 0); | 1045 | BBTOB(XFS_FSS_TO_BB(mp, 1)), 0); |
1035 | if (!bp) { | 1046 | if (!bp) { |
1036 | cmn_err(CE_WARN, "XFS: last sector read failed"); | 1047 | xfs_warn(mp, "last sector read failed"); |
1037 | return EIO; | 1048 | return EIO; |
1038 | } | 1049 | } |
1039 | xfs_buf_relse(bp); | 1050 | xfs_buf_relse(bp); |
@@ -1041,14 +1052,14 @@ xfs_check_sizes(xfs_mount_t *mp) | |||
1041 | if (mp->m_logdev_targp != mp->m_ddev_targp) { | 1052 | if (mp->m_logdev_targp != mp->m_ddev_targp) { |
1042 | d = (xfs_daddr_t)XFS_FSB_TO_BB(mp, mp->m_sb.sb_logblocks); | 1053 | d = (xfs_daddr_t)XFS_FSB_TO_BB(mp, mp->m_sb.sb_logblocks); |
1043 | if (XFS_BB_TO_FSB(mp, d) != mp->m_sb.sb_logblocks) { | 1054 | if (XFS_BB_TO_FSB(mp, d) != mp->m_sb.sb_logblocks) { |
1044 | cmn_err(CE_WARN, "XFS: log size mismatch detected"); | 1055 | xfs_warn(mp, "log size mismatch detected"); |
1045 | return XFS_ERROR(EFBIG); | 1056 | return XFS_ERROR(EFBIG); |
1046 | } | 1057 | } |
1047 | bp = xfs_buf_read_uncached(mp, mp->m_logdev_targp, | 1058 | bp = xfs_buf_read_uncached(mp, mp->m_logdev_targp, |
1048 | d - XFS_FSB_TO_BB(mp, 1), | 1059 | d - XFS_FSB_TO_BB(mp, 1), |
1049 | XFS_FSB_TO_B(mp, 1), 0); | 1060 | XFS_FSB_TO_B(mp, 1), 0); |
1050 | if (!bp) { | 1061 | if (!bp) { |
1051 | cmn_err(CE_WARN, "XFS: log device read failed"); | 1062 | xfs_warn(mp, "log device read failed"); |
1052 | return EIO; | 1063 | return EIO; |
1053 | } | 1064 | } |
1054 | xfs_buf_relse(bp); | 1065 | xfs_buf_relse(bp); |
@@ -1086,7 +1097,7 @@ xfs_mount_reset_sbqflags( | |||
1086 | return 0; | 1097 | return 0; |
1087 | 1098 | ||
1088 | #ifdef QUOTADEBUG | 1099 | #ifdef QUOTADEBUG |
1089 | xfs_fs_cmn_err(CE_NOTE, mp, "Writing superblock quota changes"); | 1100 | xfs_notice(mp, "Writing superblock quota changes"); |
1090 | #endif | 1101 | #endif |
1091 | 1102 | ||
1092 | tp = xfs_trans_alloc(mp, XFS_TRANS_QM_SBCHANGE); | 1103 | tp = xfs_trans_alloc(mp, XFS_TRANS_QM_SBCHANGE); |
@@ -1094,8 +1105,7 @@ xfs_mount_reset_sbqflags( | |||
1094 | XFS_DEFAULT_LOG_COUNT); | 1105 | XFS_DEFAULT_LOG_COUNT); |
1095 | if (error) { | 1106 | if (error) { |
1096 | xfs_trans_cancel(tp, 0); | 1107 | xfs_trans_cancel(tp, 0); |
1097 | xfs_fs_cmn_err(CE_ALERT, mp, | 1108 | xfs_alert(mp, "%s: Superblock update failed!", __func__); |
1098 | "xfs_mount_reset_sbqflags: Superblock update failed!"); | ||
1099 | return error; | 1109 | return error; |
1100 | } | 1110 | } |
1101 | 1111 | ||
@@ -1161,8 +1171,7 @@ xfs_mountfs( | |||
1161 | * transaction subsystem is online. | 1171 | * transaction subsystem is online. |
1162 | */ | 1172 | */ |
1163 | if (xfs_sb_has_mismatched_features2(sbp)) { | 1173 | if (xfs_sb_has_mismatched_features2(sbp)) { |
1164 | cmn_err(CE_WARN, | 1174 | xfs_warn(mp, "correcting sb_features alignment problem"); |
1165 | "XFS: correcting sb_features alignment problem"); | ||
1166 | sbp->sb_features2 |= sbp->sb_bad_features2; | 1175 | sbp->sb_features2 |= sbp->sb_bad_features2; |
1167 | sbp->sb_bad_features2 = sbp->sb_features2; | 1176 | sbp->sb_bad_features2 = sbp->sb_features2; |
1168 | mp->m_update_flags |= XFS_SB_FEATURES2 | XFS_SB_BAD_FEATURES2; | 1177 | mp->m_update_flags |= XFS_SB_FEATURES2 | XFS_SB_BAD_FEATURES2; |
@@ -1241,7 +1250,7 @@ xfs_mountfs( | |||
1241 | */ | 1250 | */ |
1242 | error = xfs_rtmount_init(mp); | 1251 | error = xfs_rtmount_init(mp); |
1243 | if (error) { | 1252 | if (error) { |
1244 | cmn_err(CE_WARN, "XFS: RT mount failed"); | 1253 | xfs_warn(mp, "RT mount failed"); |
1245 | goto out_remove_uuid; | 1254 | goto out_remove_uuid; |
1246 | } | 1255 | } |
1247 | 1256 | ||
@@ -1272,12 +1281,12 @@ xfs_mountfs( | |||
1272 | INIT_RADIX_TREE(&mp->m_perag_tree, GFP_ATOMIC); | 1281 | INIT_RADIX_TREE(&mp->m_perag_tree, GFP_ATOMIC); |
1273 | error = xfs_initialize_perag(mp, sbp->sb_agcount, &mp->m_maxagi); | 1282 | error = xfs_initialize_perag(mp, sbp->sb_agcount, &mp->m_maxagi); |
1274 | if (error) { | 1283 | if (error) { |
1275 | cmn_err(CE_WARN, "XFS: Failed per-ag init: %d", error); | 1284 | xfs_warn(mp, "Failed per-ag init: %d", error); |
1276 | goto out_remove_uuid; | 1285 | goto out_remove_uuid; |
1277 | } | 1286 | } |
1278 | 1287 | ||
1279 | if (!sbp->sb_logblocks) { | 1288 | if (!sbp->sb_logblocks) { |
1280 | cmn_err(CE_WARN, "XFS: no log defined"); | 1289 | xfs_warn(mp, "no log defined"); |
1281 | XFS_ERROR_REPORT("xfs_mountfs", XFS_ERRLEVEL_LOW, mp); | 1290 | XFS_ERROR_REPORT("xfs_mountfs", XFS_ERRLEVEL_LOW, mp); |
1282 | error = XFS_ERROR(EFSCORRUPTED); | 1291 | error = XFS_ERROR(EFSCORRUPTED); |
1283 | goto out_free_perag; | 1292 | goto out_free_perag; |
@@ -1290,7 +1299,7 @@ xfs_mountfs( | |||
1290 | XFS_FSB_TO_DADDR(mp, sbp->sb_logstart), | 1299 | XFS_FSB_TO_DADDR(mp, sbp->sb_logstart), |
1291 | XFS_FSB_TO_BB(mp, sbp->sb_logblocks)); | 1300 | XFS_FSB_TO_BB(mp, sbp->sb_logblocks)); |
1292 | if (error) { | 1301 | if (error) { |
1293 | cmn_err(CE_WARN, "XFS: log mount failed"); | 1302 | xfs_warn(mp, "log mount failed"); |
1294 | goto out_free_perag; | 1303 | goto out_free_perag; |
1295 | } | 1304 | } |
1296 | 1305 | ||
@@ -1327,16 +1336,14 @@ xfs_mountfs( | |||
1327 | */ | 1336 | */ |
1328 | error = xfs_iget(mp, NULL, sbp->sb_rootino, 0, XFS_ILOCK_EXCL, &rip); | 1337 | error = xfs_iget(mp, NULL, sbp->sb_rootino, 0, XFS_ILOCK_EXCL, &rip); |
1329 | if (error) { | 1338 | if (error) { |
1330 | cmn_err(CE_WARN, "XFS: failed to read root inode"); | 1339 | xfs_warn(mp, "failed to read root inode"); |
1331 | goto out_log_dealloc; | 1340 | goto out_log_dealloc; |
1332 | } | 1341 | } |
1333 | 1342 | ||
1334 | ASSERT(rip != NULL); | 1343 | ASSERT(rip != NULL); |
1335 | 1344 | ||
1336 | if (unlikely((rip->i_d.di_mode & S_IFMT) != S_IFDIR)) { | 1345 | if (unlikely((rip->i_d.di_mode & S_IFMT) != S_IFDIR)) { |
1337 | cmn_err(CE_WARN, "XFS: corrupted root inode"); | 1346 | xfs_warn(mp, "corrupted root inode %llu: not a directory", |
1338 | cmn_err(CE_WARN, "Device %s - root %llu is not a directory", | ||
1339 | XFS_BUFTARG_NAME(mp->m_ddev_targp), | ||
1340 | (unsigned long long)rip->i_ino); | 1347 | (unsigned long long)rip->i_ino); |
1341 | xfs_iunlock(rip, XFS_ILOCK_EXCL); | 1348 | xfs_iunlock(rip, XFS_ILOCK_EXCL); |
1342 | XFS_ERROR_REPORT("xfs_mountfs_int(2)", XFS_ERRLEVEL_LOW, | 1349 | XFS_ERROR_REPORT("xfs_mountfs_int(2)", XFS_ERRLEVEL_LOW, |
@@ -1356,7 +1363,7 @@ xfs_mountfs( | |||
1356 | /* | 1363 | /* |
1357 | * Free up the root inode. | 1364 | * Free up the root inode. |
1358 | */ | 1365 | */ |
1359 | cmn_err(CE_WARN, "XFS: failed to read RT inodes"); | 1366 | xfs_warn(mp, "failed to read RT inodes"); |
1360 | goto out_rele_rip; | 1367 | goto out_rele_rip; |
1361 | } | 1368 | } |
1362 | 1369 | ||
@@ -1368,7 +1375,7 @@ xfs_mountfs( | |||
1368 | if (mp->m_update_flags && !(mp->m_flags & XFS_MOUNT_RDONLY)) { | 1375 | if (mp->m_update_flags && !(mp->m_flags & XFS_MOUNT_RDONLY)) { |
1369 | error = xfs_mount_log_sb(mp, mp->m_update_flags); | 1376 | error = xfs_mount_log_sb(mp, mp->m_update_flags); |
1370 | if (error) { | 1377 | if (error) { |
1371 | cmn_err(CE_WARN, "XFS: failed to write sb changes"); | 1378 | xfs_warn(mp, "failed to write sb changes"); |
1372 | goto out_rtunmount; | 1379 | goto out_rtunmount; |
1373 | } | 1380 | } |
1374 | } | 1381 | } |
@@ -1389,10 +1396,7 @@ xfs_mountfs( | |||
1389 | * quotachecked license. | 1396 | * quotachecked license. |
1390 | */ | 1397 | */ |
1391 | if (mp->m_sb.sb_qflags & XFS_ALL_QUOTA_ACCT) { | 1398 | if (mp->m_sb.sb_qflags & XFS_ALL_QUOTA_ACCT) { |
1392 | cmn_err(CE_NOTE, | 1399 | xfs_notice(mp, "resetting quota flags"); |
1393 | "XFS: resetting qflags for filesystem %s", | ||
1394 | mp->m_fsname); | ||
1395 | |||
1396 | error = xfs_mount_reset_sbqflags(mp); | 1400 | error = xfs_mount_reset_sbqflags(mp); |
1397 | if (error) | 1401 | if (error) |
1398 | return error; | 1402 | return error; |
@@ -1406,7 +1410,7 @@ xfs_mountfs( | |||
1406 | */ | 1410 | */ |
1407 | error = xfs_log_mount_finish(mp); | 1411 | error = xfs_log_mount_finish(mp); |
1408 | if (error) { | 1412 | if (error) { |
1409 | cmn_err(CE_WARN, "XFS: log mount finish failed"); | 1413 | xfs_warn(mp, "log mount finish failed"); |
1410 | goto out_rtunmount; | 1414 | goto out_rtunmount; |
1411 | } | 1415 | } |
1412 | 1416 | ||
@@ -1435,8 +1439,8 @@ xfs_mountfs( | |||
1435 | resblks = xfs_default_resblks(mp); | 1439 | resblks = xfs_default_resblks(mp); |
1436 | error = xfs_reserve_blocks(mp, &resblks, NULL); | 1440 | error = xfs_reserve_blocks(mp, &resblks, NULL); |
1437 | if (error) | 1441 | if (error) |
1438 | cmn_err(CE_WARN, "XFS: Unable to allocate reserve " | 1442 | xfs_warn(mp, |
1439 | "blocks. Continuing without a reserve pool."); | 1443 | "Unable to allocate reserve blocks. Continuing without reserve pool."); |
1440 | } | 1444 | } |
1441 | 1445 | ||
1442 | return 0; | 1446 | return 0; |
@@ -1525,12 +1529,12 @@ xfs_unmountfs( | |||
1525 | resblks = 0; | 1529 | resblks = 0; |
1526 | error = xfs_reserve_blocks(mp, &resblks, NULL); | 1530 | error = xfs_reserve_blocks(mp, &resblks, NULL); |
1527 | if (error) | 1531 | if (error) |
1528 | cmn_err(CE_WARN, "XFS: Unable to free reserved block pool. " | 1532 | xfs_warn(mp, "Unable to free reserved block pool. " |
1529 | "Freespace may not be correct on next mount."); | 1533 | "Freespace may not be correct on next mount."); |
1530 | 1534 | ||
1531 | error = xfs_log_sbcount(mp, 1); | 1535 | error = xfs_log_sbcount(mp, 1); |
1532 | if (error) | 1536 | if (error) |
1533 | cmn_err(CE_WARN, "XFS: Unable to update superblock counters. " | 1537 | xfs_warn(mp, "Unable to update superblock counters. " |
1534 | "Freespace may not be correct on next mount."); | 1538 | "Freespace may not be correct on next mount."); |
1535 | xfs_unmountfs_writesb(mp); | 1539 | xfs_unmountfs_writesb(mp); |
1536 | xfs_unmountfs_wait(mp); /* wait for async bufs */ | 1540 | xfs_unmountfs_wait(mp); /* wait for async bufs */ |
@@ -2013,10 +2017,8 @@ xfs_dev_is_read_only( | |||
2013 | if (xfs_readonly_buftarg(mp->m_ddev_targp) || | 2017 | if (xfs_readonly_buftarg(mp->m_ddev_targp) || |
2014 | xfs_readonly_buftarg(mp->m_logdev_targp) || | 2018 | xfs_readonly_buftarg(mp->m_logdev_targp) || |
2015 | (mp->m_rtdev_targp && xfs_readonly_buftarg(mp->m_rtdev_targp))) { | 2019 | (mp->m_rtdev_targp && xfs_readonly_buftarg(mp->m_rtdev_targp))) { |
2016 | cmn_err(CE_NOTE, | 2020 | xfs_notice(mp, "%s required on read-only device.", message); |
2017 | "XFS: %s required on read-only device.", message); | 2021 | xfs_notice(mp, "write access unavailable, cannot proceed."); |
2018 | cmn_err(CE_NOTE, | ||
2019 | "XFS: write access unavailable, cannot proceed."); | ||
2020 | return EROFS; | 2022 | return EROFS; |
2021 | } | 2023 | } |
2022 | return 0; | 2024 | return 0; |
diff --git a/fs/xfs/xfs_quota.h b/fs/xfs/xfs_quota.h index 9bb6eda4cd21..a595f29567fe 100644 --- a/fs/xfs/xfs_quota.h +++ b/fs/xfs/xfs_quota.h | |||
@@ -382,7 +382,8 @@ static inline int xfs_qm_sync(struct xfs_mount *mp, int flags) | |||
382 | xfs_trans_reserve_quota_bydquots(tp, mp, ud, gd, nb, ni, \ | 382 | xfs_trans_reserve_quota_bydquots(tp, mp, ud, gd, nb, ni, \ |
383 | f | XFS_QMOPT_RES_REGBLKS) | 383 | f | XFS_QMOPT_RES_REGBLKS) |
384 | 384 | ||
385 | extern int xfs_qm_dqcheck(xfs_disk_dquot_t *, xfs_dqid_t, uint, uint, char *); | 385 | extern int xfs_qm_dqcheck(struct xfs_mount *, xfs_disk_dquot_t *, |
386 | xfs_dqid_t, uint, uint, char *); | ||
386 | extern int xfs_mount_reset_sbqflags(struct xfs_mount *); | 387 | extern int xfs_mount_reset_sbqflags(struct xfs_mount *); |
387 | 388 | ||
388 | #endif /* __KERNEL__ */ | 389 | #endif /* __KERNEL__ */ |
diff --git a/fs/xfs/xfs_rtalloc.c b/fs/xfs/xfs_rtalloc.c index 12a191385310..8f76fdff4f46 100644 --- a/fs/xfs/xfs_rtalloc.c +++ b/fs/xfs/xfs_rtalloc.c | |||
@@ -76,7 +76,7 @@ xfs_growfs_rt_alloc( | |||
76 | xfs_mount_t *mp, /* file system mount point */ | 76 | xfs_mount_t *mp, /* file system mount point */ |
77 | xfs_extlen_t oblocks, /* old count of blocks */ | 77 | xfs_extlen_t oblocks, /* old count of blocks */ |
78 | xfs_extlen_t nblocks, /* new count of blocks */ | 78 | xfs_extlen_t nblocks, /* new count of blocks */ |
79 | xfs_ino_t ino) /* inode number (bitmap/summary) */ | 79 | xfs_inode_t *ip) /* inode (bitmap/summary) */ |
80 | { | 80 | { |
81 | xfs_fileoff_t bno; /* block number in file */ | 81 | xfs_fileoff_t bno; /* block number in file */ |
82 | xfs_buf_t *bp; /* temporary buffer for zeroing */ | 82 | xfs_buf_t *bp; /* temporary buffer for zeroing */ |
@@ -86,7 +86,6 @@ xfs_growfs_rt_alloc( | |||
86 | xfs_fsblock_t firstblock; /* first block allocated in xaction */ | 86 | xfs_fsblock_t firstblock; /* first block allocated in xaction */ |
87 | xfs_bmap_free_t flist; /* list of freed blocks */ | 87 | xfs_bmap_free_t flist; /* list of freed blocks */ |
88 | xfs_fsblock_t fsbno; /* filesystem block for bno */ | 88 | xfs_fsblock_t fsbno; /* filesystem block for bno */ |
89 | xfs_inode_t *ip; /* pointer to incore inode */ | ||
90 | xfs_bmbt_irec_t map; /* block map output */ | 89 | xfs_bmbt_irec_t map; /* block map output */ |
91 | int nmap; /* number of block maps */ | 90 | int nmap; /* number of block maps */ |
92 | int resblks; /* space reservation */ | 91 | int resblks; /* space reservation */ |
@@ -112,9 +111,9 @@ xfs_growfs_rt_alloc( | |||
112 | /* | 111 | /* |
113 | * Lock the inode. | 112 | * Lock the inode. |
114 | */ | 113 | */ |
115 | if ((error = xfs_trans_iget(mp, tp, ino, 0, | 114 | xfs_ilock(ip, XFS_ILOCK_EXCL); |
116 | XFS_ILOCK_EXCL, &ip))) | 115 | xfs_trans_ijoin_ref(tp, ip, XFS_ILOCK_EXCL); |
117 | goto error_cancel; | 116 | |
118 | xfs_bmap_init(&flist, &firstblock); | 117 | xfs_bmap_init(&flist, &firstblock); |
119 | /* | 118 | /* |
120 | * Allocate blocks to the bitmap file. | 119 | * Allocate blocks to the bitmap file. |
@@ -155,9 +154,8 @@ xfs_growfs_rt_alloc( | |||
155 | /* | 154 | /* |
156 | * Lock the bitmap inode. | 155 | * Lock the bitmap inode. |
157 | */ | 156 | */ |
158 | if ((error = xfs_trans_iget(mp, tp, ino, 0, | 157 | xfs_ilock(ip, XFS_ILOCK_EXCL); |
159 | XFS_ILOCK_EXCL, &ip))) | 158 | xfs_trans_ijoin_ref(tp, ip, XFS_ILOCK_EXCL); |
160 | goto error_cancel; | ||
161 | /* | 159 | /* |
162 | * Get a buffer for the block. | 160 | * Get a buffer for the block. |
163 | */ | 161 | */ |
@@ -1854,7 +1852,6 @@ xfs_growfs_rt( | |||
1854 | xfs_rtblock_t bmbno; /* bitmap block number */ | 1852 | xfs_rtblock_t bmbno; /* bitmap block number */ |
1855 | xfs_buf_t *bp; /* temporary buffer */ | 1853 | xfs_buf_t *bp; /* temporary buffer */ |
1856 | int error; /* error return value */ | 1854 | int error; /* error return value */ |
1857 | xfs_inode_t *ip; /* bitmap inode, used as lock */ | ||
1858 | xfs_mount_t *nmp; /* new (fake) mount structure */ | 1855 | xfs_mount_t *nmp; /* new (fake) mount structure */ |
1859 | xfs_drfsbno_t nrblocks; /* new number of realtime blocks */ | 1856 | xfs_drfsbno_t nrblocks; /* new number of realtime blocks */ |
1860 | xfs_extlen_t nrbmblocks; /* new number of rt bitmap blocks */ | 1857 | xfs_extlen_t nrbmblocks; /* new number of rt bitmap blocks */ |
@@ -1918,11 +1915,11 @@ xfs_growfs_rt( | |||
1918 | /* | 1915 | /* |
1919 | * Allocate space to the bitmap and summary files, as necessary. | 1916 | * Allocate space to the bitmap and summary files, as necessary. |
1920 | */ | 1917 | */ |
1921 | if ((error = xfs_growfs_rt_alloc(mp, rbmblocks, nrbmblocks, | 1918 | error = xfs_growfs_rt_alloc(mp, rbmblocks, nrbmblocks, mp->m_rbmip); |
1922 | mp->m_sb.sb_rbmino))) | 1919 | if (error) |
1923 | return error; | 1920 | return error; |
1924 | if ((error = xfs_growfs_rt_alloc(mp, rsumblocks, nrsumblocks, | 1921 | error = xfs_growfs_rt_alloc(mp, rsumblocks, nrsumblocks, mp->m_rsumip); |
1925 | mp->m_sb.sb_rsumino))) | 1922 | if (error) |
1926 | return error; | 1923 | return error; |
1927 | /* | 1924 | /* |
1928 | * Allocate a new (fake) mount/sb. | 1925 | * Allocate a new (fake) mount/sb. |
@@ -1972,10 +1969,8 @@ xfs_growfs_rt( | |||
1972 | /* | 1969 | /* |
1973 | * Lock out other callers by grabbing the bitmap inode lock. | 1970 | * Lock out other callers by grabbing the bitmap inode lock. |
1974 | */ | 1971 | */ |
1975 | if ((error = xfs_trans_iget(mp, tp, mp->m_sb.sb_rbmino, 0, | 1972 | xfs_ilock(mp->m_rbmip, XFS_ILOCK_EXCL); |
1976 | XFS_ILOCK_EXCL, &ip))) | 1973 | xfs_trans_ijoin_ref(tp, mp->m_rbmip, XFS_ILOCK_EXCL); |
1977 | goto error_cancel; | ||
1978 | ASSERT(ip == mp->m_rbmip); | ||
1979 | /* | 1974 | /* |
1980 | * Update the bitmap inode's size. | 1975 | * Update the bitmap inode's size. |
1981 | */ | 1976 | */ |
@@ -1986,10 +1981,8 @@ xfs_growfs_rt( | |||
1986 | /* | 1981 | /* |
1987 | * Get the summary inode into the transaction. | 1982 | * Get the summary inode into the transaction. |
1988 | */ | 1983 | */ |
1989 | if ((error = xfs_trans_iget(mp, tp, mp->m_sb.sb_rsumino, 0, | 1984 | xfs_ilock(mp->m_rsumip, XFS_ILOCK_EXCL); |
1990 | XFS_ILOCK_EXCL, &ip))) | 1985 | xfs_trans_ijoin_ref(tp, mp->m_rsumip, XFS_ILOCK_EXCL); |
1991 | goto error_cancel; | ||
1992 | ASSERT(ip == mp->m_rsumip); | ||
1993 | /* | 1986 | /* |
1994 | * Update the summary inode's size. | 1987 | * Update the summary inode's size. |
1995 | */ | 1988 | */ |
@@ -2075,15 +2068,15 @@ xfs_rtallocate_extent( | |||
2075 | xfs_extlen_t prod, /* extent product factor */ | 2068 | xfs_extlen_t prod, /* extent product factor */ |
2076 | xfs_rtblock_t *rtblock) /* out: start block allocated */ | 2069 | xfs_rtblock_t *rtblock) /* out: start block allocated */ |
2077 | { | 2070 | { |
2071 | xfs_mount_t *mp = tp->t_mountp; | ||
2078 | int error; /* error value */ | 2072 | int error; /* error value */ |
2079 | xfs_inode_t *ip; /* inode for bitmap file */ | ||
2080 | xfs_mount_t *mp; /* file system mount structure */ | ||
2081 | xfs_rtblock_t r; /* result allocated block */ | 2073 | xfs_rtblock_t r; /* result allocated block */ |
2082 | xfs_fsblock_t sb; /* summary file block number */ | 2074 | xfs_fsblock_t sb; /* summary file block number */ |
2083 | xfs_buf_t *sumbp; /* summary file block buffer */ | 2075 | xfs_buf_t *sumbp; /* summary file block buffer */ |
2084 | 2076 | ||
2077 | ASSERT(xfs_isilocked(mp->m_rbmip, XFS_ILOCK_EXCL)); | ||
2085 | ASSERT(minlen > 0 && minlen <= maxlen); | 2078 | ASSERT(minlen > 0 && minlen <= maxlen); |
2086 | mp = tp->t_mountp; | 2079 | |
2087 | /* | 2080 | /* |
2088 | * If prod is set then figure out what to do to minlen and maxlen. | 2081 | * If prod is set then figure out what to do to minlen and maxlen. |
2089 | */ | 2082 | */ |
@@ -2099,12 +2092,7 @@ xfs_rtallocate_extent( | |||
2099 | return 0; | 2092 | return 0; |
2100 | } | 2093 | } |
2101 | } | 2094 | } |
2102 | /* | 2095 | |
2103 | * Lock out other callers by grabbing the bitmap inode lock. | ||
2104 | */ | ||
2105 | if ((error = xfs_trans_iget(mp, tp, mp->m_sb.sb_rbmino, 0, | ||
2106 | XFS_ILOCK_EXCL, &ip))) | ||
2107 | return error; | ||
2108 | sumbp = NULL; | 2096 | sumbp = NULL; |
2109 | /* | 2097 | /* |
2110 | * Allocate by size, or near another block, or exactly at some block. | 2098 | * Allocate by size, or near another block, or exactly at some block. |
@@ -2123,11 +2111,12 @@ xfs_rtallocate_extent( | |||
2123 | len, &sumbp, &sb, prod, &r); | 2111 | len, &sumbp, &sb, prod, &r); |
2124 | break; | 2112 | break; |
2125 | default: | 2113 | default: |
2114 | error = EIO; | ||
2126 | ASSERT(0); | 2115 | ASSERT(0); |
2127 | } | 2116 | } |
2128 | if (error) { | 2117 | if (error) |
2129 | return error; | 2118 | return error; |
2130 | } | 2119 | |
2131 | /* | 2120 | /* |
2132 | * If it worked, update the superblock. | 2121 | * If it worked, update the superblock. |
2133 | */ | 2122 | */ |
@@ -2155,7 +2144,6 @@ xfs_rtfree_extent( | |||
2155 | xfs_extlen_t len) /* length of extent freed */ | 2144 | xfs_extlen_t len) /* length of extent freed */ |
2156 | { | 2145 | { |
2157 | int error; /* error value */ | 2146 | int error; /* error value */ |
2158 | xfs_inode_t *ip; /* bitmap file inode */ | ||
2159 | xfs_mount_t *mp; /* file system mount structure */ | 2147 | xfs_mount_t *mp; /* file system mount structure */ |
2160 | xfs_fsblock_t sb; /* summary file block number */ | 2148 | xfs_fsblock_t sb; /* summary file block number */ |
2161 | xfs_buf_t *sumbp; /* summary file block buffer */ | 2149 | xfs_buf_t *sumbp; /* summary file block buffer */ |
@@ -2164,9 +2152,9 @@ xfs_rtfree_extent( | |||
2164 | /* | 2152 | /* |
2165 | * Synchronize by locking the bitmap inode. | 2153 | * Synchronize by locking the bitmap inode. |
2166 | */ | 2154 | */ |
2167 | if ((error = xfs_trans_iget(mp, tp, mp->m_sb.sb_rbmino, 0, | 2155 | xfs_ilock(mp->m_rbmip, XFS_ILOCK_EXCL); |
2168 | XFS_ILOCK_EXCL, &ip))) | 2156 | xfs_trans_ijoin_ref(tp, mp->m_rbmip, XFS_ILOCK_EXCL); |
2169 | return error; | 2157 | |
2170 | #if defined(__KERNEL__) && defined(DEBUG) | 2158 | #if defined(__KERNEL__) && defined(DEBUG) |
2171 | /* | 2159 | /* |
2172 | * Check to see that this whole range is currently allocated. | 2160 | * Check to see that this whole range is currently allocated. |
@@ -2199,10 +2187,10 @@ xfs_rtfree_extent( | |||
2199 | */ | 2187 | */ |
2200 | if (tp->t_frextents_delta + mp->m_sb.sb_frextents == | 2188 | if (tp->t_frextents_delta + mp->m_sb.sb_frextents == |
2201 | mp->m_sb.sb_rextents) { | 2189 | mp->m_sb.sb_rextents) { |
2202 | if (!(ip->i_d.di_flags & XFS_DIFLAG_NEWRTBM)) | 2190 | if (!(mp->m_rbmip->i_d.di_flags & XFS_DIFLAG_NEWRTBM)) |
2203 | ip->i_d.di_flags |= XFS_DIFLAG_NEWRTBM; | 2191 | mp->m_rbmip->i_d.di_flags |= XFS_DIFLAG_NEWRTBM; |
2204 | *(__uint64_t *)&ip->i_d.di_atime = 0; | 2192 | *(__uint64_t *)&mp->m_rbmip->i_d.di_atime = 0; |
2205 | xfs_trans_log_inode(tp, ip, XFS_ILOG_CORE); | 2193 | xfs_trans_log_inode(tp, mp->m_rbmip, XFS_ILOG_CORE); |
2206 | } | 2194 | } |
2207 | return 0; | 2195 | return 0; |
2208 | } | 2196 | } |
@@ -2222,8 +2210,8 @@ xfs_rtmount_init( | |||
2222 | if (sbp->sb_rblocks == 0) | 2210 | if (sbp->sb_rblocks == 0) |
2223 | return 0; | 2211 | return 0; |
2224 | if (mp->m_rtdev_targp == NULL) { | 2212 | if (mp->m_rtdev_targp == NULL) { |
2225 | cmn_err(CE_WARN, | 2213 | xfs_warn(mp, |
2226 | "XFS: This filesystem has a realtime volume, use rtdev=device option"); | 2214 | "Filesystem has a realtime volume, use rtdev=device option"); |
2227 | return XFS_ERROR(ENODEV); | 2215 | return XFS_ERROR(ENODEV); |
2228 | } | 2216 | } |
2229 | mp->m_rsumlevels = sbp->sb_rextslog + 1; | 2217 | mp->m_rsumlevels = sbp->sb_rextslog + 1; |
@@ -2237,7 +2225,7 @@ xfs_rtmount_init( | |||
2237 | */ | 2225 | */ |
2238 | d = (xfs_daddr_t)XFS_FSB_TO_BB(mp, mp->m_sb.sb_rblocks); | 2226 | d = (xfs_daddr_t)XFS_FSB_TO_BB(mp, mp->m_sb.sb_rblocks); |
2239 | if (XFS_BB_TO_FSB(mp, d) != mp->m_sb.sb_rblocks) { | 2227 | if (XFS_BB_TO_FSB(mp, d) != mp->m_sb.sb_rblocks) { |
2240 | cmn_err(CE_WARN, "XFS: realtime mount -- %llu != %llu", | 2228 | xfs_warn(mp, "realtime mount -- %llu != %llu", |
2241 | (unsigned long long) XFS_BB_TO_FSB(mp, d), | 2229 | (unsigned long long) XFS_BB_TO_FSB(mp, d), |
2242 | (unsigned long long) mp->m_sb.sb_rblocks); | 2230 | (unsigned long long) mp->m_sb.sb_rblocks); |
2243 | return XFS_ERROR(EFBIG); | 2231 | return XFS_ERROR(EFBIG); |
@@ -2246,7 +2234,7 @@ xfs_rtmount_init( | |||
2246 | d - XFS_FSB_TO_BB(mp, 1), | 2234 | d - XFS_FSB_TO_BB(mp, 1), |
2247 | XFS_FSB_TO_B(mp, 1), 0); | 2235 | XFS_FSB_TO_B(mp, 1), 0); |
2248 | if (!bp) { | 2236 | if (!bp) { |
2249 | cmn_err(CE_WARN, "XFS: realtime device size check failed"); | 2237 | xfs_warn(mp, "realtime device size check failed"); |
2250 | return EIO; | 2238 | return EIO; |
2251 | } | 2239 | } |
2252 | xfs_buf_relse(bp); | 2240 | xfs_buf_relse(bp); |
@@ -2306,20 +2294,16 @@ xfs_rtpick_extent( | |||
2306 | xfs_rtblock_t *pick) /* result rt extent */ | 2294 | xfs_rtblock_t *pick) /* result rt extent */ |
2307 | { | 2295 | { |
2308 | xfs_rtblock_t b; /* result block */ | 2296 | xfs_rtblock_t b; /* result block */ |
2309 | int error; /* error return value */ | ||
2310 | xfs_inode_t *ip; /* bitmap incore inode */ | ||
2311 | int log2; /* log of sequence number */ | 2297 | int log2; /* log of sequence number */ |
2312 | __uint64_t resid; /* residual after log removed */ | 2298 | __uint64_t resid; /* residual after log removed */ |
2313 | __uint64_t seq; /* sequence number of file creation */ | 2299 | __uint64_t seq; /* sequence number of file creation */ |
2314 | __uint64_t *seqp; /* pointer to seqno in inode */ | 2300 | __uint64_t *seqp; /* pointer to seqno in inode */ |
2315 | 2301 | ||
2316 | if ((error = xfs_trans_iget(mp, tp, mp->m_sb.sb_rbmino, 0, | 2302 | ASSERT(xfs_isilocked(mp->m_rbmip, XFS_ILOCK_EXCL)); |
2317 | XFS_ILOCK_EXCL, &ip))) | 2303 | |
2318 | return error; | 2304 | seqp = (__uint64_t *)&mp->m_rbmip->i_d.di_atime; |
2319 | ASSERT(ip == mp->m_rbmip); | 2305 | if (!(mp->m_rbmip->i_d.di_flags & XFS_DIFLAG_NEWRTBM)) { |
2320 | seqp = (__uint64_t *)&ip->i_d.di_atime; | 2306 | mp->m_rbmip->i_d.di_flags |= XFS_DIFLAG_NEWRTBM; |
2321 | if (!(ip->i_d.di_flags & XFS_DIFLAG_NEWRTBM)) { | ||
2322 | ip->i_d.di_flags |= XFS_DIFLAG_NEWRTBM; | ||
2323 | *seqp = 0; | 2307 | *seqp = 0; |
2324 | } | 2308 | } |
2325 | seq = *seqp; | 2309 | seq = *seqp; |
@@ -2335,7 +2319,7 @@ xfs_rtpick_extent( | |||
2335 | b = mp->m_sb.sb_rextents - len; | 2319 | b = mp->m_sb.sb_rextents - len; |
2336 | } | 2320 | } |
2337 | *seqp = seq + 1; | 2321 | *seqp = seq + 1; |
2338 | xfs_trans_log_inode(tp, ip, XFS_ILOG_CORE); | 2322 | xfs_trans_log_inode(tp, mp->m_rbmip, XFS_ILOG_CORE); |
2339 | *pick = b; | 2323 | *pick = b; |
2340 | return 0; | 2324 | return 0; |
2341 | } | 2325 | } |
diff --git a/fs/xfs/xfs_rtalloc.h b/fs/xfs/xfs_rtalloc.h index ff614c29b441..09e1f4f35e97 100644 --- a/fs/xfs/xfs_rtalloc.h +++ b/fs/xfs/xfs_rtalloc.h | |||
@@ -154,7 +154,7 @@ xfs_rtmount_init( | |||
154 | if (mp->m_sb.sb_rblocks == 0) | 154 | if (mp->m_sb.sb_rblocks == 0) |
155 | return 0; | 155 | return 0; |
156 | 156 | ||
157 | cmn_err(CE_WARN, "XFS: Not built with CONFIG_XFS_RT"); | 157 | xfs_warn(mp, "Not built with CONFIG_XFS_RT"); |
158 | return ENOSYS; | 158 | return ENOSYS; |
159 | } | 159 | } |
160 | # define xfs_rtmount_inodes(m) (((mp)->m_sb.sb_rblocks == 0)? 0 : (ENOSYS)) | 160 | # define xfs_rtmount_inodes(m) (((mp)->m_sb.sb_rblocks == 0)? 0 : (ENOSYS)) |
diff --git a/fs/xfs/xfs_rw.c b/fs/xfs/xfs_rw.c index 56861d5daaef..d6d6fdfe9422 100644 --- a/fs/xfs/xfs_rw.c +++ b/fs/xfs/xfs_rw.c | |||
@@ -49,9 +49,9 @@ xfs_do_force_shutdown( | |||
49 | logerror = flags & SHUTDOWN_LOG_IO_ERROR; | 49 | logerror = flags & SHUTDOWN_LOG_IO_ERROR; |
50 | 50 | ||
51 | if (!(flags & SHUTDOWN_FORCE_UMOUNT)) { | 51 | if (!(flags & SHUTDOWN_FORCE_UMOUNT)) { |
52 | cmn_err(CE_NOTE, "xfs_force_shutdown(%s,0x%x) called from " | 52 | xfs_notice(mp, |
53 | "line %d of file %s. Return address = 0x%p", | 53 | "%s(0x%x) called from line %d of file %s. Return address = 0x%p", |
54 | mp->m_fsname, flags, lnnum, fname, __return_address); | 54 | __func__, flags, lnnum, fname, __return_address); |
55 | } | 55 | } |
56 | /* | 56 | /* |
57 | * No need to duplicate efforts. | 57 | * No need to duplicate efforts. |
@@ -69,30 +69,25 @@ xfs_do_force_shutdown( | |||
69 | return; | 69 | return; |
70 | 70 | ||
71 | if (flags & SHUTDOWN_CORRUPT_INCORE) { | 71 | if (flags & SHUTDOWN_CORRUPT_INCORE) { |
72 | xfs_cmn_err(XFS_PTAG_SHUTDOWN_CORRUPT, CE_ALERT, mp, | 72 | xfs_alert_tag(mp, XFS_PTAG_SHUTDOWN_CORRUPT, |
73 | "Corruption of in-memory data detected. Shutting down filesystem: %s", | 73 | "Corruption of in-memory data detected. Shutting down filesystem"); |
74 | mp->m_fsname); | 74 | if (XFS_ERRLEVEL_HIGH <= xfs_error_level) |
75 | if (XFS_ERRLEVEL_HIGH <= xfs_error_level) { | ||
76 | xfs_stack_trace(); | 75 | xfs_stack_trace(); |
77 | } | ||
78 | } else if (!(flags & SHUTDOWN_FORCE_UMOUNT)) { | 76 | } else if (!(flags & SHUTDOWN_FORCE_UMOUNT)) { |
79 | if (logerror) { | 77 | if (logerror) { |
80 | xfs_cmn_err(XFS_PTAG_SHUTDOWN_LOGERROR, CE_ALERT, mp, | 78 | xfs_alert_tag(mp, XFS_PTAG_SHUTDOWN_LOGERROR, |
81 | "Log I/O Error Detected. Shutting down filesystem: %s", | 79 | "Log I/O Error Detected. Shutting down filesystem"); |
82 | mp->m_fsname); | ||
83 | } else if (flags & SHUTDOWN_DEVICE_REQ) { | 80 | } else if (flags & SHUTDOWN_DEVICE_REQ) { |
84 | xfs_cmn_err(XFS_PTAG_SHUTDOWN_IOERROR, CE_ALERT, mp, | 81 | xfs_alert_tag(mp, XFS_PTAG_SHUTDOWN_IOERROR, |
85 | "All device paths lost. Shutting down filesystem: %s", | 82 | "All device paths lost. Shutting down filesystem"); |
86 | mp->m_fsname); | ||
87 | } else if (!(flags & SHUTDOWN_REMOTE_REQ)) { | 83 | } else if (!(flags & SHUTDOWN_REMOTE_REQ)) { |
88 | xfs_cmn_err(XFS_PTAG_SHUTDOWN_IOERROR, CE_ALERT, mp, | 84 | xfs_alert_tag(mp, XFS_PTAG_SHUTDOWN_IOERROR, |
89 | "I/O Error Detected. Shutting down filesystem: %s", | 85 | "I/O Error Detected. Shutting down filesystem"); |
90 | mp->m_fsname); | ||
91 | } | 86 | } |
92 | } | 87 | } |
93 | if (!(flags & SHUTDOWN_FORCE_UMOUNT)) { | 88 | if (!(flags & SHUTDOWN_FORCE_UMOUNT)) { |
94 | cmn_err(CE_ALERT, "Please umount the filesystem, " | 89 | xfs_alert(mp, |
95 | "and rectify the problem(s)"); | 90 | "Please umount the filesystem and rectify the problem(s)"); |
96 | } | 91 | } |
97 | } | 92 | } |
98 | 93 | ||
@@ -106,10 +101,9 @@ xfs_ioerror_alert( | |||
106 | xfs_buf_t *bp, | 101 | xfs_buf_t *bp, |
107 | xfs_daddr_t blkno) | 102 | xfs_daddr_t blkno) |
108 | { | 103 | { |
109 | cmn_err(CE_ALERT, | 104 | xfs_alert(mp, |
110 | "I/O error in filesystem (\"%s\") meta-data dev %s block 0x%llx" | 105 | "I/O error occurred: meta-data dev %s block 0x%llx" |
111 | " (\"%s\") error %d buf count %zd", | 106 | " (\"%s\") error %d buf count %zd", |
112 | (!mp || !mp->m_fsname) ? "(fs name not set)" : mp->m_fsname, | ||
113 | XFS_BUFTARG_NAME(XFS_BUF_TARGET(bp)), | 107 | XFS_BUFTARG_NAME(XFS_BUF_TARGET(bp)), |
114 | (__uint64_t)blkno, func, | 108 | (__uint64_t)blkno, func, |
115 | XFS_BUF_GETERROR(bp), XFS_BUF_COUNT(bp)); | 109 | XFS_BUF_GETERROR(bp), XFS_BUF_COUNT(bp)); |
@@ -173,17 +167,9 @@ xfs_extlen_t | |||
173 | xfs_get_extsz_hint( | 167 | xfs_get_extsz_hint( |
174 | struct xfs_inode *ip) | 168 | struct xfs_inode *ip) |
175 | { | 169 | { |
176 | xfs_extlen_t extsz; | 170 | if ((ip->i_d.di_flags & XFS_DIFLAG_EXTSIZE) && ip->i_d.di_extsize) |
177 | 171 | return ip->i_d.di_extsize; | |
178 | if (unlikely(XFS_IS_REALTIME_INODE(ip))) { | 172 | if (XFS_IS_REALTIME_INODE(ip)) |
179 | extsz = (ip->i_d.di_flags & XFS_DIFLAG_EXTSIZE) | 173 | return ip->i_mount->m_sb.sb_rextsize; |
180 | ? ip->i_d.di_extsize | 174 | return 0; |
181 | : ip->i_mount->m_sb.sb_rextsize; | ||
182 | ASSERT(extsz); | ||
183 | } else { | ||
184 | extsz = (ip->i_d.di_flags & XFS_DIFLAG_EXTSIZE) | ||
185 | ? ip->i_d.di_extsize : 0; | ||
186 | } | ||
187 | |||
188 | return extsz; | ||
189 | } | 175 | } |
diff --git a/fs/xfs/xfs_trans.h b/fs/xfs/xfs_trans.h index c2042b736b81..06a9759b6352 100644 --- a/fs/xfs/xfs_trans.h +++ b/fs/xfs/xfs_trans.h | |||
@@ -469,8 +469,6 @@ void xfs_trans_inode_buf(xfs_trans_t *, struct xfs_buf *); | |||
469 | void xfs_trans_stale_inode_buf(xfs_trans_t *, struct xfs_buf *); | 469 | void xfs_trans_stale_inode_buf(xfs_trans_t *, struct xfs_buf *); |
470 | void xfs_trans_dquot_buf(xfs_trans_t *, struct xfs_buf *, uint); | 470 | void xfs_trans_dquot_buf(xfs_trans_t *, struct xfs_buf *, uint); |
471 | void xfs_trans_inode_alloc_buf(xfs_trans_t *, struct xfs_buf *); | 471 | void xfs_trans_inode_alloc_buf(xfs_trans_t *, struct xfs_buf *); |
472 | int xfs_trans_iget(struct xfs_mount *, xfs_trans_t *, | ||
473 | xfs_ino_t , uint, uint, struct xfs_inode **); | ||
474 | void xfs_trans_ichgtime(struct xfs_trans *, struct xfs_inode *, int); | 472 | void xfs_trans_ichgtime(struct xfs_trans *, struct xfs_inode *, int); |
475 | void xfs_trans_ijoin_ref(struct xfs_trans *, struct xfs_inode *, uint); | 473 | void xfs_trans_ijoin_ref(struct xfs_trans *, struct xfs_inode *, uint); |
476 | void xfs_trans_ijoin(struct xfs_trans *, struct xfs_inode *); | 474 | void xfs_trans_ijoin(struct xfs_trans *, struct xfs_inode *); |
diff --git a/fs/xfs/xfs_trans_ail.c b/fs/xfs/xfs_trans_ail.c index c5bbbc45db91..12aff9584e29 100644 --- a/fs/xfs/xfs_trans_ail.c +++ b/fs/xfs/xfs_trans_ail.c | |||
@@ -563,7 +563,7 @@ xfs_trans_ail_delete_bulk( | |||
563 | 563 | ||
564 | spin_unlock(&ailp->xa_lock); | 564 | spin_unlock(&ailp->xa_lock); |
565 | if (!XFS_FORCED_SHUTDOWN(mp)) { | 565 | if (!XFS_FORCED_SHUTDOWN(mp)) { |
566 | xfs_cmn_err(XFS_PTAG_AILDELETE, CE_ALERT, mp, | 566 | xfs_alert_tag(mp, XFS_PTAG_AILDELETE, |
567 | "%s: attempting to delete a log item that is not in the AIL", | 567 | "%s: attempting to delete a log item that is not in the AIL", |
568 | __func__); | 568 | __func__); |
569 | xfs_force_shutdown(mp, SHUTDOWN_CORRUPT_INCORE); | 569 | xfs_force_shutdown(mp, SHUTDOWN_CORRUPT_INCORE); |
diff --git a/fs/xfs/xfs_trans_buf.c b/fs/xfs/xfs_trans_buf.c index c47918c302a5..3bea66132334 100644 --- a/fs/xfs/xfs_trans_buf.c +++ b/fs/xfs/xfs_trans_buf.c | |||
@@ -305,7 +305,7 @@ xfs_trans_read_buf( | |||
305 | if (xfs_error_target == target) { | 305 | if (xfs_error_target == target) { |
306 | if (((xfs_req_num++) % xfs_error_mod) == 0) { | 306 | if (((xfs_req_num++) % xfs_error_mod) == 0) { |
307 | xfs_buf_relse(bp); | 307 | xfs_buf_relse(bp); |
308 | cmn_err(CE_DEBUG, "Returning error!\n"); | 308 | xfs_debug(mp, "Returning error!"); |
309 | return XFS_ERROR(EIO); | 309 | return XFS_ERROR(EIO); |
310 | } | 310 | } |
311 | } | 311 | } |
@@ -403,7 +403,7 @@ xfs_trans_read_buf( | |||
403 | xfs_force_shutdown(tp->t_mountp, | 403 | xfs_force_shutdown(tp->t_mountp, |
404 | SHUTDOWN_META_IO_ERROR); | 404 | SHUTDOWN_META_IO_ERROR); |
405 | xfs_buf_relse(bp); | 405 | xfs_buf_relse(bp); |
406 | cmn_err(CE_DEBUG, "Returning trans error!\n"); | 406 | xfs_debug(mp, "Returning trans error!"); |
407 | return XFS_ERROR(EIO); | 407 | return XFS_ERROR(EIO); |
408 | } | 408 | } |
409 | } | 409 | } |
@@ -427,7 +427,7 @@ shutdown_abort: | |||
427 | */ | 427 | */ |
428 | #if defined(DEBUG) | 428 | #if defined(DEBUG) |
429 | if (XFS_BUF_ISSTALE(bp) && XFS_BUF_ISDELAYWRITE(bp)) | 429 | if (XFS_BUF_ISSTALE(bp) && XFS_BUF_ISDELAYWRITE(bp)) |
430 | cmn_err(CE_NOTE, "about to pop assert, bp == 0x%p", bp); | 430 | xfs_notice(mp, "about to pop assert, bp == 0x%p", bp); |
431 | #endif | 431 | #endif |
432 | ASSERT((XFS_BUF_BFLAGS(bp) & (XBF_STALE|XBF_DELWRI)) != | 432 | ASSERT((XFS_BUF_BFLAGS(bp) & (XBF_STALE|XBF_DELWRI)) != |
433 | (XBF_STALE|XBF_DELWRI)); | 433 | (XBF_STALE|XBF_DELWRI)); |
diff --git a/fs/xfs/xfs_trans_inode.c b/fs/xfs/xfs_trans_inode.c index ccb34532768b..16084d8ea231 100644 --- a/fs/xfs/xfs_trans_inode.c +++ b/fs/xfs/xfs_trans_inode.c | |||
@@ -44,28 +44,6 @@ xfs_trans_inode_broot_debug( | |||
44 | #endif | 44 | #endif |
45 | 45 | ||
46 | /* | 46 | /* |
47 | * Get an inode and join it to the transaction. | ||
48 | */ | ||
49 | int | ||
50 | xfs_trans_iget( | ||
51 | xfs_mount_t *mp, | ||
52 | xfs_trans_t *tp, | ||
53 | xfs_ino_t ino, | ||
54 | uint flags, | ||
55 | uint lock_flags, | ||
56 | xfs_inode_t **ipp) | ||
57 | { | ||
58 | int error; | ||
59 | |||
60 | error = xfs_iget(mp, tp, ino, flags, lock_flags, ipp); | ||
61 | if (!error && tp) { | ||
62 | xfs_trans_ijoin(tp, *ipp); | ||
63 | (*ipp)->i_itemp->ili_lock_flags = lock_flags; | ||
64 | } | ||
65 | return error; | ||
66 | } | ||
67 | |||
68 | /* | ||
69 | * Add a locked inode to the transaction. | 47 | * Add a locked inode to the transaction. |
70 | * | 48 | * |
71 | * The inode must be locked, and it cannot be associated with any transaction. | 49 | * The inode must be locked, and it cannot be associated with any transaction. |
diff --git a/fs/xfs/xfs_vnodeops.c b/fs/xfs/xfs_vnodeops.c index d8e6f8cd6f0c..37d8146ee15b 100644 --- a/fs/xfs/xfs_vnodeops.c +++ b/fs/xfs/xfs_vnodeops.c | |||
@@ -1189,9 +1189,8 @@ xfs_inactive( | |||
1189 | * inode might be lost for a long time or forever. | 1189 | * inode might be lost for a long time or forever. |
1190 | */ | 1190 | */ |
1191 | if (!XFS_FORCED_SHUTDOWN(mp)) { | 1191 | if (!XFS_FORCED_SHUTDOWN(mp)) { |
1192 | cmn_err(CE_NOTE, | 1192 | xfs_notice(mp, "%s: xfs_ifree returned error %d", |
1193 | "xfs_inactive: xfs_ifree() returned an error = %d on %s", | 1193 | __func__, error); |
1194 | error, mp->m_fsname); | ||
1195 | xfs_force_shutdown(mp, SHUTDOWN_META_IO_ERROR); | 1194 | xfs_force_shutdown(mp, SHUTDOWN_META_IO_ERROR); |
1196 | } | 1195 | } |
1197 | xfs_trans_cancel(tp, XFS_TRANS_RELEASE_LOG_RES|XFS_TRANS_ABORT); | 1196 | xfs_trans_cancel(tp, XFS_TRANS_RELEASE_LOG_RES|XFS_TRANS_ABORT); |
@@ -1208,12 +1207,12 @@ xfs_inactive( | |||
1208 | */ | 1207 | */ |
1209 | error = xfs_bmap_finish(&tp, &free_list, &committed); | 1208 | error = xfs_bmap_finish(&tp, &free_list, &committed); |
1210 | if (error) | 1209 | if (error) |
1211 | xfs_fs_cmn_err(CE_NOTE, mp, "xfs_inactive: " | 1210 | xfs_notice(mp, "%s: xfs_bmap_finish returned error %d", |
1212 | "xfs_bmap_finish() returned error %d", error); | 1211 | __func__, error); |
1213 | error = xfs_trans_commit(tp, XFS_TRANS_RELEASE_LOG_RES); | 1212 | error = xfs_trans_commit(tp, XFS_TRANS_RELEASE_LOG_RES); |
1214 | if (error) | 1213 | if (error) |
1215 | xfs_fs_cmn_err(CE_NOTE, mp, "xfs_inactive: " | 1214 | xfs_notice(mp, "%s: xfs_trans_commit returned error %d", |
1216 | "xfs_trans_commit() returned error %d", error); | 1215 | __func__, error); |
1217 | } | 1216 | } |
1218 | 1217 | ||
1219 | /* | 1218 | /* |
@@ -1310,7 +1309,7 @@ xfs_create( | |||
1310 | error = xfs_qm_vop_dqalloc(dp, current_fsuid(), current_fsgid(), prid, | 1309 | error = xfs_qm_vop_dqalloc(dp, current_fsuid(), current_fsgid(), prid, |
1311 | XFS_QMOPT_QUOTALL | XFS_QMOPT_INHERIT, &udqp, &gdqp); | 1310 | XFS_QMOPT_QUOTALL | XFS_QMOPT_INHERIT, &udqp, &gdqp); |
1312 | if (error) | 1311 | if (error) |
1313 | goto std_return; | 1312 | return error; |
1314 | 1313 | ||
1315 | if (is_dir) { | 1314 | if (is_dir) { |
1316 | rdev = 0; | 1315 | rdev = 0; |
@@ -1390,12 +1389,6 @@ xfs_create( | |||
1390 | } | 1389 | } |
1391 | 1390 | ||
1392 | /* | 1391 | /* |
1393 | * At this point, we've gotten a newly allocated inode. | ||
1394 | * It is locked (and joined to the transaction). | ||
1395 | */ | ||
1396 | ASSERT(xfs_isilocked(ip, XFS_ILOCK_EXCL)); | ||
1397 | |||
1398 | /* | ||
1399 | * Now we join the directory inode to the transaction. We do not do it | 1392 | * Now we join the directory inode to the transaction. We do not do it |
1400 | * earlier because xfs_dir_ialloc might commit the previous transaction | 1393 | * earlier because xfs_dir_ialloc might commit the previous transaction |
1401 | * (and release all the locks). An error from here on will result in | 1394 | * (and release all the locks). An error from here on will result in |
@@ -1440,22 +1433,13 @@ xfs_create( | |||
1440 | */ | 1433 | */ |
1441 | xfs_qm_vop_create_dqattach(tp, ip, udqp, gdqp); | 1434 | xfs_qm_vop_create_dqattach(tp, ip, udqp, gdqp); |
1442 | 1435 | ||
1443 | /* | ||
1444 | * xfs_trans_commit normally decrements the vnode ref count | ||
1445 | * when it unlocks the inode. Since we want to return the | ||
1446 | * vnode to the caller, we bump the vnode ref count now. | ||
1447 | */ | ||
1448 | IHOLD(ip); | ||
1449 | |||
1450 | error = xfs_bmap_finish(&tp, &free_list, &committed); | 1436 | error = xfs_bmap_finish(&tp, &free_list, &committed); |
1451 | if (error) | 1437 | if (error) |
1452 | goto out_abort_rele; | 1438 | goto out_bmap_cancel; |
1453 | 1439 | ||
1454 | error = xfs_trans_commit(tp, XFS_TRANS_RELEASE_LOG_RES); | 1440 | error = xfs_trans_commit(tp, XFS_TRANS_RELEASE_LOG_RES); |
1455 | if (error) { | 1441 | if (error) |
1456 | IRELE(ip); | 1442 | goto out_release_inode; |
1457 | goto out_dqrele; | ||
1458 | } | ||
1459 | 1443 | ||
1460 | xfs_qm_dqrele(udqp); | 1444 | xfs_qm_dqrele(udqp); |
1461 | xfs_qm_dqrele(gdqp); | 1445 | xfs_qm_dqrele(gdqp); |
@@ -1469,27 +1453,21 @@ xfs_create( | |||
1469 | cancel_flags |= XFS_TRANS_ABORT; | 1453 | cancel_flags |= XFS_TRANS_ABORT; |
1470 | out_trans_cancel: | 1454 | out_trans_cancel: |
1471 | xfs_trans_cancel(tp, cancel_flags); | 1455 | xfs_trans_cancel(tp, cancel_flags); |
1472 | out_dqrele: | 1456 | out_release_inode: |
1457 | /* | ||
1458 | * Wait until after the current transaction is aborted to | ||
1459 | * release the inode. This prevents recursive transactions | ||
1460 | * and deadlocks from xfs_inactive. | ||
1461 | */ | ||
1462 | if (ip) | ||
1463 | IRELE(ip); | ||
1464 | |||
1473 | xfs_qm_dqrele(udqp); | 1465 | xfs_qm_dqrele(udqp); |
1474 | xfs_qm_dqrele(gdqp); | 1466 | xfs_qm_dqrele(gdqp); |
1475 | 1467 | ||
1476 | if (unlock_dp_on_error) | 1468 | if (unlock_dp_on_error) |
1477 | xfs_iunlock(dp, XFS_ILOCK_EXCL); | 1469 | xfs_iunlock(dp, XFS_ILOCK_EXCL); |
1478 | std_return: | ||
1479 | return error; | 1470 | return error; |
1480 | |||
1481 | out_abort_rele: | ||
1482 | /* | ||
1483 | * Wait until after the current transaction is aborted to | ||
1484 | * release the inode. This prevents recursive transactions | ||
1485 | * and deadlocks from xfs_inactive. | ||
1486 | */ | ||
1487 | xfs_bmap_cancel(&free_list); | ||
1488 | cancel_flags |= XFS_TRANS_ABORT; | ||
1489 | xfs_trans_cancel(tp, cancel_flags); | ||
1490 | IRELE(ip); | ||
1491 | unlock_dp_on_error = B_FALSE; | ||
1492 | goto out_dqrele; | ||
1493 | } | 1471 | } |
1494 | 1472 | ||
1495 | #ifdef DEBUG | 1473 | #ifdef DEBUG |
@@ -2114,9 +2092,8 @@ xfs_symlink( | |||
2114 | XFS_BMAPI_WRITE | XFS_BMAPI_METADATA, | 2092 | XFS_BMAPI_WRITE | XFS_BMAPI_METADATA, |
2115 | &first_block, resblks, mval, &nmaps, | 2093 | &first_block, resblks, mval, &nmaps, |
2116 | &free_list); | 2094 | &free_list); |
2117 | if (error) { | 2095 | if (error) |
2118 | goto error1; | 2096 | goto error2; |
2119 | } | ||
2120 | 2097 | ||
2121 | if (resblks) | 2098 | if (resblks) |
2122 | resblks -= fs_blocks; | 2099 | resblks -= fs_blocks; |
@@ -2148,7 +2125,7 @@ xfs_symlink( | |||
2148 | error = xfs_dir_createname(tp, dp, link_name, ip->i_ino, | 2125 | error = xfs_dir_createname(tp, dp, link_name, ip->i_ino, |
2149 | &first_block, &free_list, resblks); | 2126 | &first_block, &free_list, resblks); |
2150 | if (error) | 2127 | if (error) |
2151 | goto error1; | 2128 | goto error2; |
2152 | xfs_trans_ichgtime(tp, dp, XFS_ICHGTIME_MOD | XFS_ICHGTIME_CHG); | 2129 | xfs_trans_ichgtime(tp, dp, XFS_ICHGTIME_MOD | XFS_ICHGTIME_CHG); |
2153 | xfs_trans_log_inode(tp, dp, XFS_ILOG_CORE); | 2130 | xfs_trans_log_inode(tp, dp, XFS_ILOG_CORE); |
2154 | 2131 | ||
@@ -2161,13 +2138,6 @@ xfs_symlink( | |||
2161 | xfs_trans_set_sync(tp); | 2138 | xfs_trans_set_sync(tp); |
2162 | } | 2139 | } |
2163 | 2140 | ||
2164 | /* | ||
2165 | * xfs_trans_commit normally decrements the vnode ref count | ||
2166 | * when it unlocks the inode. Since we want to return the | ||
2167 | * vnode to the caller, we bump the vnode ref count now. | ||
2168 | */ | ||
2169 | IHOLD(ip); | ||
2170 | |||
2171 | error = xfs_bmap_finish(&tp, &free_list, &committed); | 2141 | error = xfs_bmap_finish(&tp, &free_list, &committed); |
2172 | if (error) { | 2142 | if (error) { |
2173 | goto error2; | 2143 | goto error2; |