diff options
Diffstat (limited to 'fs')
70 files changed, 2217 insertions, 963 deletions
diff --git a/fs/9p/v9fs.c b/fs/9p/v9fs.c index c061c3f18e7..24eb01087b6 100644 --- a/fs/9p/v9fs.c +++ b/fs/9p/v9fs.c | |||
| @@ -30,8 +30,8 @@ | |||
| 30 | #include <linux/parser.h> | 30 | #include <linux/parser.h> |
| 31 | #include <linux/idr.h> | 31 | #include <linux/idr.h> |
| 32 | #include <net/9p/9p.h> | 32 | #include <net/9p/9p.h> |
| 33 | #include <net/9p/transport.h> | ||
| 34 | #include <net/9p/client.h> | 33 | #include <net/9p/client.h> |
| 34 | #include <net/9p/transport.h> | ||
| 35 | #include "v9fs.h" | 35 | #include "v9fs.h" |
| 36 | #include "v9fs_vfs.h" | 36 | #include "v9fs_vfs.h" |
| 37 | 37 | ||
| @@ -234,7 +234,7 @@ struct p9_fid *v9fs_session_init(struct v9fs_session_info *v9ses, | |||
| 234 | if (!v9ses->clnt->dotu) | 234 | if (!v9ses->clnt->dotu) |
| 235 | v9ses->flags &= ~V9FS_EXTENDED; | 235 | v9ses->flags &= ~V9FS_EXTENDED; |
| 236 | 236 | ||
| 237 | v9ses->maxdata = v9ses->clnt->msize; | 237 | v9ses->maxdata = v9ses->clnt->msize - P9_IOHDRSZ; |
| 238 | 238 | ||
| 239 | /* for legacy mode, fall back to V9FS_ACCESS_ANY */ | 239 | /* for legacy mode, fall back to V9FS_ACCESS_ANY */ |
| 240 | if (!v9fs_extended(v9ses) && | 240 | if (!v9fs_extended(v9ses) && |
diff --git a/fs/9p/v9fs_vfs.h b/fs/9p/v9fs_vfs.h index 57997fa14e6..c295ba786ed 100644 --- a/fs/9p/v9fs_vfs.h +++ b/fs/9p/v9fs_vfs.h | |||
| @@ -46,9 +46,11 @@ extern struct dentry_operations v9fs_cached_dentry_operations; | |||
| 46 | 46 | ||
| 47 | struct inode *v9fs_get_inode(struct super_block *sb, int mode); | 47 | struct inode *v9fs_get_inode(struct super_block *sb, int mode); |
| 48 | ino_t v9fs_qid2ino(struct p9_qid *qid); | 48 | ino_t v9fs_qid2ino(struct p9_qid *qid); |
| 49 | void v9fs_stat2inode(struct p9_stat *, struct inode *, struct super_block *); | 49 | void v9fs_stat2inode(struct p9_wstat *, struct inode *, struct super_block *); |
| 50 | int v9fs_dir_release(struct inode *inode, struct file *filp); | 50 | int v9fs_dir_release(struct inode *inode, struct file *filp); |
| 51 | int v9fs_file_open(struct inode *inode, struct file *file); | 51 | int v9fs_file_open(struct inode *inode, struct file *file); |
| 52 | void v9fs_inode2stat(struct inode *inode, struct p9_stat *stat); | 52 | void v9fs_inode2stat(struct inode *inode, struct p9_wstat *stat); |
| 53 | void v9fs_dentry_release(struct dentry *); | 53 | void v9fs_dentry_release(struct dentry *); |
| 54 | int v9fs_uflags2omode(int uflags, int extended); | 54 | int v9fs_uflags2omode(int uflags, int extended); |
| 55 | |||
| 56 | ssize_t v9fs_file_readn(struct file *, char *, char __user *, u32, u64); | ||
diff --git a/fs/9p/vfs_addr.c b/fs/9p/vfs_addr.c index 97d3aed5798..6fcb1e7095c 100644 --- a/fs/9p/vfs_addr.c +++ b/fs/9p/vfs_addr.c | |||
| @@ -38,7 +38,6 @@ | |||
| 38 | 38 | ||
| 39 | #include "v9fs.h" | 39 | #include "v9fs.h" |
| 40 | #include "v9fs_vfs.h" | 40 | #include "v9fs_vfs.h" |
| 41 | #include "fid.h" | ||
| 42 | 41 | ||
| 43 | /** | 42 | /** |
| 44 | * v9fs_vfs_readpage - read an entire page in from 9P | 43 | * v9fs_vfs_readpage - read an entire page in from 9P |
| @@ -53,14 +52,12 @@ static int v9fs_vfs_readpage(struct file *filp, struct page *page) | |||
| 53 | int retval; | 52 | int retval; |
| 54 | loff_t offset; | 53 | loff_t offset; |
| 55 | char *buffer; | 54 | char *buffer; |
| 56 | struct p9_fid *fid; | ||
| 57 | 55 | ||
| 58 | P9_DPRINTK(P9_DEBUG_VFS, "\n"); | 56 | P9_DPRINTK(P9_DEBUG_VFS, "\n"); |
| 59 | fid = filp->private_data; | ||
| 60 | buffer = kmap(page); | 57 | buffer = kmap(page); |
| 61 | offset = page_offset(page); | 58 | offset = page_offset(page); |
| 62 | 59 | ||
| 63 | retval = p9_client_readn(fid, buffer, offset, PAGE_CACHE_SIZE); | 60 | retval = v9fs_file_readn(filp, buffer, NULL, offset, PAGE_CACHE_SIZE); |
| 64 | if (retval < 0) | 61 | if (retval < 0) |
| 65 | goto done; | 62 | goto done; |
| 66 | 63 | ||
diff --git a/fs/9p/vfs_dir.c b/fs/9p/vfs_dir.c index e298fe19409..873cd31baa4 100644 --- a/fs/9p/vfs_dir.c +++ b/fs/9p/vfs_dir.c | |||
| @@ -45,7 +45,7 @@ | |||
| 45 | * | 45 | * |
| 46 | */ | 46 | */ |
| 47 | 47 | ||
| 48 | static inline int dt_type(struct p9_stat *mistat) | 48 | static inline int dt_type(struct p9_wstat *mistat) |
| 49 | { | 49 | { |
| 50 | unsigned long perm = mistat->mode; | 50 | unsigned long perm = mistat->mode; |
| 51 | int rettype = DT_REG; | 51 | int rettype = DT_REG; |
| @@ -69,32 +69,58 @@ static inline int dt_type(struct p9_stat *mistat) | |||
| 69 | static int v9fs_dir_readdir(struct file *filp, void *dirent, filldir_t filldir) | 69 | static int v9fs_dir_readdir(struct file *filp, void *dirent, filldir_t filldir) |
| 70 | { | 70 | { |
| 71 | int over; | 71 | int over; |
| 72 | struct p9_wstat st; | ||
| 73 | int err; | ||
| 72 | struct p9_fid *fid; | 74 | struct p9_fid *fid; |
| 73 | struct v9fs_session_info *v9ses; | 75 | int buflen; |
| 74 | struct inode *inode; | 76 | char *statbuf; |
| 75 | struct p9_stat *st; | 77 | int n, i = 0; |
| 76 | 78 | ||
| 77 | P9_DPRINTK(P9_DEBUG_VFS, "name %s\n", filp->f_path.dentry->d_name.name); | 79 | P9_DPRINTK(P9_DEBUG_VFS, "name %s\n", filp->f_path.dentry->d_name.name); |
| 78 | inode = filp->f_path.dentry->d_inode; | ||
| 79 | v9ses = v9fs_inode2v9ses(inode); | ||
| 80 | fid = filp->private_data; | 80 | fid = filp->private_data; |
| 81 | while ((st = p9_client_dirread(fid, filp->f_pos)) != NULL) { | ||
| 82 | if (IS_ERR(st)) | ||
| 83 | return PTR_ERR(st); | ||
| 84 | 81 | ||
| 85 | over = filldir(dirent, st->name.str, st->name.len, filp->f_pos, | 82 | buflen = fid->clnt->msize - P9_IOHDRSZ; |
| 86 | v9fs_qid2ino(&st->qid), dt_type(st)); | 83 | statbuf = kmalloc(buflen, GFP_KERNEL); |
| 84 | if (!statbuf) | ||
| 85 | return -ENOMEM; | ||
| 87 | 86 | ||
| 88 | if (over) | 87 | while (1) { |
| 88 | err = v9fs_file_readn(filp, statbuf, NULL, buflen, | ||
| 89 | fid->rdir_fpos); | ||
| 90 | if (err <= 0) | ||
| 89 | break; | 91 | break; |
| 90 | 92 | ||
| 91 | filp->f_pos += st->size; | 93 | n = err; |
| 92 | kfree(st); | 94 | while (i < n) { |
| 93 | st = NULL; | 95 | err = p9stat_read(statbuf + i, buflen-i, &st, |
| 96 | fid->clnt->dotu); | ||
| 97 | if (err) { | ||
| 98 | P9_DPRINTK(P9_DEBUG_VFS, "returned %d\n", err); | ||
| 99 | err = -EIO; | ||
| 100 | p9stat_free(&st); | ||
| 101 | goto free_and_exit; | ||
| 102 | } | ||
| 103 | |||
| 104 | i += st.size+2; | ||
| 105 | fid->rdir_fpos += st.size+2; | ||
| 106 | |||
| 107 | over = filldir(dirent, st.name, strlen(st.name), | ||
| 108 | filp->f_pos, v9fs_qid2ino(&st.qid), dt_type(&st)); | ||
| 109 | |||
| 110 | filp->f_pos += st.size+2; | ||
| 111 | |||
| 112 | p9stat_free(&st); | ||
| 113 | |||
| 114 | if (over) { | ||
| 115 | err = 0; | ||
| 116 | goto free_and_exit; | ||
| 117 | } | ||
| 118 | } | ||
| 94 | } | 119 | } |
| 95 | 120 | ||
| 96 | kfree(st); | 121 | free_and_exit: |
| 97 | return 0; | 122 | kfree(statbuf); |
| 123 | return err; | ||
| 98 | } | 124 | } |
| 99 | 125 | ||
| 100 | 126 | ||
diff --git a/fs/9p/vfs_file.c b/fs/9p/vfs_file.c index 52944d2249a..041c5269228 100644 --- a/fs/9p/vfs_file.c +++ b/fs/9p/vfs_file.c | |||
| @@ -120,23 +120,72 @@ static int v9fs_file_lock(struct file *filp, int cmd, struct file_lock *fl) | |||
| 120 | } | 120 | } |
| 121 | 121 | ||
| 122 | /** | 122 | /** |
| 123 | * v9fs_file_read - read from a file | 123 | * v9fs_file_readn - read from a file |
| 124 | * @filp: file pointer to read | 124 | * @filp: file pointer to read |
| 125 | * @data: data buffer to read data into | 125 | * @data: data buffer to read data into |
| 126 | * @udata: user data buffer to read data into | ||
| 126 | * @count: size of buffer | 127 | * @count: size of buffer |
| 127 | * @offset: offset at which to read data | 128 | * @offset: offset at which to read data |
| 128 | * | 129 | * |
| 129 | */ | 130 | */ |
| 131 | |||
| 132 | ssize_t | ||
| 133 | v9fs_file_readn(struct file *filp, char *data, char __user *udata, u32 count, | ||
| 134 | u64 offset) | ||
| 135 | { | ||
| 136 | int n, total; | ||
| 137 | struct p9_fid *fid = filp->private_data; | ||
| 138 | |||
| 139 | P9_DPRINTK(P9_DEBUG_VFS, "fid %d offset %llu count %d\n", fid->fid, | ||
| 140 | (long long unsigned) offset, count); | ||
| 141 | |||
| 142 | n = 0; | ||
| 143 | total = 0; | ||
| 144 | do { | ||
| 145 | n = p9_client_read(fid, data, udata, offset, count); | ||
| 146 | if (n <= 0) | ||
| 147 | break; | ||
| 148 | |||
| 149 | if (data) | ||
| 150 | data += n; | ||
| 151 | if (udata) | ||
| 152 | udata += n; | ||
| 153 | |||
| 154 | offset += n; | ||
| 155 | count -= n; | ||
| 156 | total += n; | ||
| 157 | } while (count > 0 && n == (fid->clnt->msize - P9_IOHDRSZ)); | ||
| 158 | |||
| 159 | if (n < 0) | ||
| 160 | total = n; | ||
| 161 | |||
| 162 | return total; | ||
| 163 | } | ||
| 164 | |||
| 165 | /** | ||
| 166 | * v9fs_file_read - read from a file | ||
| 167 | * @filp: file pointer to read | ||
| 168 | * @udata: user data buffer to read data into | ||
| 169 | * @count: size of buffer | ||
| 170 | * @offset: offset at which to read data | ||
| 171 | * | ||
| 172 | */ | ||
| 173 | |||
| 130 | static ssize_t | 174 | static ssize_t |
| 131 | v9fs_file_read(struct file *filp, char __user * data, size_t count, | 175 | v9fs_file_read(struct file *filp, char __user *udata, size_t count, |
| 132 | loff_t * offset) | 176 | loff_t * offset) |
| 133 | { | 177 | { |
| 134 | int ret; | 178 | int ret; |
| 135 | struct p9_fid *fid; | 179 | struct p9_fid *fid; |
| 136 | 180 | ||
| 137 | P9_DPRINTK(P9_DEBUG_VFS, "\n"); | 181 | P9_DPRINTK(P9_DEBUG_VFS, "count %d offset %lld\n", count, *offset); |
| 138 | fid = filp->private_data; | 182 | fid = filp->private_data; |
| 139 | ret = p9_client_uread(fid, data, *offset, count); | 183 | |
| 184 | if (count > (fid->clnt->msize - P9_IOHDRSZ)) | ||
| 185 | ret = v9fs_file_readn(filp, NULL, udata, count, *offset); | ||
| 186 | else | ||
| 187 | ret = p9_client_read(fid, NULL, udata, *offset, count); | ||
| 188 | |||
| 140 | if (ret > 0) | 189 | if (ret > 0) |
| 141 | *offset += ret; | 190 | *offset += ret; |
| 142 | 191 | ||
| @@ -156,19 +205,38 @@ static ssize_t | |||
| 156 | v9fs_file_write(struct file *filp, const char __user * data, | 205 | v9fs_file_write(struct file *filp, const char __user * data, |
| 157 | size_t count, loff_t * offset) | 206 | size_t count, loff_t * offset) |
| 158 | { | 207 | { |
| 159 | int ret; | 208 | int n, rsize, total = 0; |
| 160 | struct p9_fid *fid; | 209 | struct p9_fid *fid; |
| 210 | struct p9_client *clnt; | ||
| 161 | struct inode *inode = filp->f_path.dentry->d_inode; | 211 | struct inode *inode = filp->f_path.dentry->d_inode; |
| 212 | int origin = *offset; | ||
| 162 | 213 | ||
| 163 | P9_DPRINTK(P9_DEBUG_VFS, "data %p count %d offset %x\n", data, | 214 | P9_DPRINTK(P9_DEBUG_VFS, "data %p count %d offset %x\n", data, |
| 164 | (int)count, (int)*offset); | 215 | (int)count, (int)*offset); |
| 165 | 216 | ||
| 166 | fid = filp->private_data; | 217 | fid = filp->private_data; |
| 167 | ret = p9_client_uwrite(fid, data, *offset, count); | 218 | clnt = fid->clnt; |
| 168 | if (ret > 0) { | 219 | |
| 169 | invalidate_inode_pages2_range(inode->i_mapping, *offset, | 220 | rsize = fid->iounit; |
| 170 | *offset+ret); | 221 | if (!rsize || rsize > clnt->msize-P9_IOHDRSZ) |
| 171 | *offset += ret; | 222 | rsize = clnt->msize - P9_IOHDRSZ; |
| 223 | |||
| 224 | do { | ||
| 225 | if (count < rsize) | ||
| 226 | rsize = count; | ||
| 227 | |||
| 228 | n = p9_client_write(fid, NULL, data+total, *offset+total, | ||
| 229 | rsize); | ||
| 230 | if (n <= 0) | ||
| 231 | break; | ||
| 232 | count -= n; | ||
| 233 | total += n; | ||
| 234 | } while (count > 0); | ||
| 235 | |||
| 236 | if (total > 0) { | ||
| 237 | invalidate_inode_pages2_range(inode->i_mapping, origin, | ||
| 238 | origin+total); | ||
| 239 | *offset += total; | ||
| 172 | } | 240 | } |
| 173 | 241 | ||
| 174 | if (*offset > inode->i_size) { | 242 | if (*offset > inode->i_size) { |
| @@ -176,7 +244,10 @@ v9fs_file_write(struct file *filp, const char __user * data, | |||
| 176 | inode->i_blocks = (inode->i_size + 512 - 1) >> 9; | 244 | inode->i_blocks = (inode->i_size + 512 - 1) >> 9; |
| 177 | } | 245 | } |
| 178 | 246 | ||
| 179 | return ret; | 247 | if (n < 0) |
| 248 | return n; | ||
| 249 | |||
| 250 | return total; | ||
| 180 | } | 251 | } |
| 181 | 252 | ||
| 182 | static const struct file_operations v9fs_cached_file_operations = { | 253 | static const struct file_operations v9fs_cached_file_operations = { |
diff --git a/fs/9p/vfs_inode.c b/fs/9p/vfs_inode.c index e83aa5ebe86..8314d3f43b7 100644 --- a/fs/9p/vfs_inode.c +++ b/fs/9p/vfs_inode.c | |||
| @@ -334,7 +334,7 @@ v9fs_inode_from_fid(struct v9fs_session_info *v9ses, struct p9_fid *fid, | |||
| 334 | { | 334 | { |
| 335 | int err, umode; | 335 | int err, umode; |
| 336 | struct inode *ret; | 336 | struct inode *ret; |
| 337 | struct p9_stat *st; | 337 | struct p9_wstat *st; |
| 338 | 338 | ||
| 339 | ret = NULL; | 339 | ret = NULL; |
| 340 | st = p9_client_stat(fid); | 340 | st = p9_client_stat(fid); |
| @@ -417,6 +417,8 @@ v9fs_create(struct v9fs_session_info *v9ses, struct inode *dir, | |||
| 417 | struct p9_fid *dfid, *ofid, *fid; | 417 | struct p9_fid *dfid, *ofid, *fid; |
| 418 | struct inode *inode; | 418 | struct inode *inode; |
| 419 | 419 | ||
| 420 | P9_DPRINTK(P9_DEBUG_VFS, "name %s\n", dentry->d_name.name); | ||
| 421 | |||
| 420 | err = 0; | 422 | err = 0; |
| 421 | ofid = NULL; | 423 | ofid = NULL; |
| 422 | fid = NULL; | 424 | fid = NULL; |
| @@ -424,6 +426,7 @@ v9fs_create(struct v9fs_session_info *v9ses, struct inode *dir, | |||
| 424 | dfid = v9fs_fid_clone(dentry->d_parent); | 426 | dfid = v9fs_fid_clone(dentry->d_parent); |
| 425 | if (IS_ERR(dfid)) { | 427 | if (IS_ERR(dfid)) { |
| 426 | err = PTR_ERR(dfid); | 428 | err = PTR_ERR(dfid); |
| 429 | P9_DPRINTK(P9_DEBUG_VFS, "fid clone failed %d\n", err); | ||
| 427 | dfid = NULL; | 430 | dfid = NULL; |
| 428 | goto error; | 431 | goto error; |
| 429 | } | 432 | } |
| @@ -432,18 +435,22 @@ v9fs_create(struct v9fs_session_info *v9ses, struct inode *dir, | |||
| 432 | ofid = p9_client_walk(dfid, 0, NULL, 1); | 435 | ofid = p9_client_walk(dfid, 0, NULL, 1); |
| 433 | if (IS_ERR(ofid)) { | 436 | if (IS_ERR(ofid)) { |
| 434 | err = PTR_ERR(ofid); | 437 | err = PTR_ERR(ofid); |
| 438 | P9_DPRINTK(P9_DEBUG_VFS, "p9_client_walk failed %d\n", err); | ||
| 435 | ofid = NULL; | 439 | ofid = NULL; |
| 436 | goto error; | 440 | goto error; |
| 437 | } | 441 | } |
| 438 | 442 | ||
| 439 | err = p9_client_fcreate(ofid, name, perm, mode, extension); | 443 | err = p9_client_fcreate(ofid, name, perm, mode, extension); |
| 440 | if (err < 0) | 444 | if (err < 0) { |
| 445 | P9_DPRINTK(P9_DEBUG_VFS, "p9_client_fcreate failed %d\n", err); | ||
| 441 | goto error; | 446 | goto error; |
| 447 | } | ||
| 442 | 448 | ||
| 443 | /* now walk from the parent so we can get unopened fid */ | 449 | /* now walk from the parent so we can get unopened fid */ |
| 444 | fid = p9_client_walk(dfid, 1, &name, 0); | 450 | fid = p9_client_walk(dfid, 1, &name, 0); |
| 445 | if (IS_ERR(fid)) { | 451 | if (IS_ERR(fid)) { |
| 446 | err = PTR_ERR(fid); | 452 | err = PTR_ERR(fid); |
| 453 | P9_DPRINTK(P9_DEBUG_VFS, "p9_client_walk failed %d\n", err); | ||
| 447 | fid = NULL; | 454 | fid = NULL; |
| 448 | goto error; | 455 | goto error; |
| 449 | } else | 456 | } else |
| @@ -453,6 +460,7 @@ v9fs_create(struct v9fs_session_info *v9ses, struct inode *dir, | |||
| 453 | inode = v9fs_inode_from_fid(v9ses, fid, dir->i_sb); | 460 | inode = v9fs_inode_from_fid(v9ses, fid, dir->i_sb); |
| 454 | if (IS_ERR(inode)) { | 461 | if (IS_ERR(inode)) { |
| 455 | err = PTR_ERR(inode); | 462 | err = PTR_ERR(inode); |
| 463 | P9_DPRINTK(P9_DEBUG_VFS, "inode creation failed %d\n", err); | ||
| 456 | goto error; | 464 | goto error; |
| 457 | } | 465 | } |
| 458 | 466 | ||
| @@ -734,7 +742,7 @@ v9fs_vfs_getattr(struct vfsmount *mnt, struct dentry *dentry, | |||
| 734 | int err; | 742 | int err; |
| 735 | struct v9fs_session_info *v9ses; | 743 | struct v9fs_session_info *v9ses; |
| 736 | struct p9_fid *fid; | 744 | struct p9_fid *fid; |
| 737 | struct p9_stat *st; | 745 | struct p9_wstat *st; |
| 738 | 746 | ||
| 739 | P9_DPRINTK(P9_DEBUG_VFS, "dentry: %p\n", dentry); | 747 | P9_DPRINTK(P9_DEBUG_VFS, "dentry: %p\n", dentry); |
| 740 | err = -EPERM; | 748 | err = -EPERM; |
| @@ -815,10 +823,9 @@ static int v9fs_vfs_setattr(struct dentry *dentry, struct iattr *iattr) | |||
| 815 | */ | 823 | */ |
| 816 | 824 | ||
| 817 | void | 825 | void |
| 818 | v9fs_stat2inode(struct p9_stat *stat, struct inode *inode, | 826 | v9fs_stat2inode(struct p9_wstat *stat, struct inode *inode, |
| 819 | struct super_block *sb) | 827 | struct super_block *sb) |
| 820 | { | 828 | { |
| 821 | int n; | ||
| 822 | char ext[32]; | 829 | char ext[32]; |
| 823 | struct v9fs_session_info *v9ses = sb->s_fs_info; | 830 | struct v9fs_session_info *v9ses = sb->s_fs_info; |
| 824 | 831 | ||
| @@ -842,11 +849,7 @@ v9fs_stat2inode(struct p9_stat *stat, struct inode *inode, | |||
| 842 | int major = -1; | 849 | int major = -1; |
| 843 | int minor = -1; | 850 | int minor = -1; |
| 844 | 851 | ||
| 845 | n = stat->extension.len; | 852 | strncpy(ext, stat->extension, sizeof(ext)); |
| 846 | if (n > sizeof(ext)-1) | ||
| 847 | n = sizeof(ext)-1; | ||
| 848 | memmove(ext, stat->extension.str, n); | ||
| 849 | ext[n] = 0; | ||
| 850 | sscanf(ext, "%c %u %u", &type, &major, &minor); | 853 | sscanf(ext, "%c %u %u", &type, &major, &minor); |
| 851 | switch (type) { | 854 | switch (type) { |
| 852 | case 'c': | 855 | case 'c': |
| @@ -857,10 +860,11 @@ v9fs_stat2inode(struct p9_stat *stat, struct inode *inode, | |||
| 857 | break; | 860 | break; |
| 858 | default: | 861 | default: |
| 859 | P9_DPRINTK(P9_DEBUG_ERROR, | 862 | P9_DPRINTK(P9_DEBUG_ERROR, |
| 860 | "Unknown special type %c (%.*s)\n", type, | 863 | "Unknown special type %c %s\n", type, |
| 861 | stat->extension.len, stat->extension.str); | 864 | stat->extension); |
| 862 | }; | 865 | }; |
| 863 | inode->i_rdev = MKDEV(major, minor); | 866 | inode->i_rdev = MKDEV(major, minor); |
| 867 | init_special_inode(inode, inode->i_mode, inode->i_rdev); | ||
| 864 | } else | 868 | } else |
| 865 | inode->i_rdev = 0; | 869 | inode->i_rdev = 0; |
| 866 | 870 | ||
| @@ -904,7 +908,7 @@ static int v9fs_readlink(struct dentry *dentry, char *buffer, int buflen) | |||
| 904 | 908 | ||
| 905 | struct v9fs_session_info *v9ses; | 909 | struct v9fs_session_info *v9ses; |
| 906 | struct p9_fid *fid; | 910 | struct p9_fid *fid; |
| 907 | struct p9_stat *st; | 911 | struct p9_wstat *st; |
| 908 | 912 | ||
| 909 | P9_DPRINTK(P9_DEBUG_VFS, " %s\n", dentry->d_name.name); | 913 | P9_DPRINTK(P9_DEBUG_VFS, " %s\n", dentry->d_name.name); |
| 910 | retval = -EPERM; | 914 | retval = -EPERM; |
| @@ -926,15 +930,10 @@ static int v9fs_readlink(struct dentry *dentry, char *buffer, int buflen) | |||
| 926 | } | 930 | } |
| 927 | 931 | ||
| 928 | /* copy extension buffer into buffer */ | 932 | /* copy extension buffer into buffer */ |
| 929 | if (st->extension.len < buflen) | 933 | strncpy(buffer, st->extension, buflen); |
| 930 | buflen = st->extension.len + 1; | ||
| 931 | |||
| 932 | memmove(buffer, st->extension.str, buflen - 1); | ||
| 933 | buffer[buflen-1] = 0; | ||
| 934 | 934 | ||
| 935 | P9_DPRINTK(P9_DEBUG_VFS, | 935 | P9_DPRINTK(P9_DEBUG_VFS, |
| 936 | "%s -> %.*s (%s)\n", dentry->d_name.name, st->extension.len, | 936 | "%s -> %s (%s)\n", dentry->d_name.name, st->extension, buffer); |
| 937 | st->extension.str, buffer); | ||
| 938 | 937 | ||
| 939 | retval = buflen; | 938 | retval = buflen; |
| 940 | 939 | ||
diff --git a/fs/9p/vfs_super.c b/fs/9p/vfs_super.c index bf59c396049..d6cb1a0ca72 100644 --- a/fs/9p/vfs_super.c +++ b/fs/9p/vfs_super.c | |||
| @@ -111,7 +111,7 @@ static int v9fs_get_sb(struct file_system_type *fs_type, int flags, | |||
| 111 | struct inode *inode = NULL; | 111 | struct inode *inode = NULL; |
| 112 | struct dentry *root = NULL; | 112 | struct dentry *root = NULL; |
| 113 | struct v9fs_session_info *v9ses = NULL; | 113 | struct v9fs_session_info *v9ses = NULL; |
| 114 | struct p9_stat *st = NULL; | 114 | struct p9_wstat *st = NULL; |
| 115 | int mode = S_IRWXUGO | S_ISVTX; | 115 | int mode = S_IRWXUGO | S_ISVTX; |
| 116 | uid_t uid = current->fsuid; | 116 | uid_t uid = current->fsuid; |
| 117 | gid_t gid = current->fsgid; | 117 | gid_t gid = current->fsgid; |
| @@ -161,10 +161,14 @@ static int v9fs_get_sb(struct file_system_type *fs_type, int flags, | |||
| 161 | 161 | ||
| 162 | sb->s_root = root; | 162 | sb->s_root = root; |
| 163 | root->d_inode->i_ino = v9fs_qid2ino(&st->qid); | 163 | root->d_inode->i_ino = v9fs_qid2ino(&st->qid); |
| 164 | |||
| 164 | v9fs_stat2inode(st, root->d_inode, sb); | 165 | v9fs_stat2inode(st, root->d_inode, sb); |
| 166 | |||
| 165 | v9fs_fid_add(root, fid); | 167 | v9fs_fid_add(root, fid); |
| 168 | p9stat_free(st); | ||
| 166 | kfree(st); | 169 | kfree(st); |
| 167 | 170 | ||
| 171 | P9_DPRINTK(P9_DEBUG_VFS, " return simple set mount\n"); | ||
| 168 | return simple_set_mnt(mnt, sb); | 172 | return simple_set_mnt(mnt, sb); |
| 169 | 173 | ||
| 170 | release_sb: | 174 | release_sb: |
diff --git a/fs/Kconfig b/fs/Kconfig index d0a1174fb51..e46297f020c 100644 --- a/fs/Kconfig +++ b/fs/Kconfig | |||
| @@ -6,61 +6,9 @@ menu "File systems" | |||
| 6 | 6 | ||
| 7 | if BLOCK | 7 | if BLOCK |
| 8 | 8 | ||
| 9 | config EXT2_FS | 9 | source "fs/ext2/Kconfig" |
| 10 | tristate "Second extended fs support" | 10 | source "fs/ext3/Kconfig" |
| 11 | help | 11 | source "fs/ext4/Kconfig" |
| 12 | Ext2 is a standard Linux file system for hard disks. | ||
| 13 | |||
| 14 | To compile this file system support as a module, choose M here: the | ||
| 15 | module will be called ext2. | ||
| 16 | |||
| 17 | If unsure, say Y. | ||
| 18 | |||
| 19 | config EXT2_FS_XATTR | ||
| 20 | bool "Ext2 extended attributes" | ||
| 21 | depends on EXT2_FS | ||
| 22 | help | ||
| 23 | Extended attributes are name:value pairs associated with inodes by | ||
| 24 | the kernel or by users (see the attr(5) manual page, or visit | ||
| 25 | <http://acl.bestbits.at/> for details). | ||
| 26 | |||
| 27 | If unsure, say N. | ||
| 28 | |||
| 29 | config EXT2_FS_POSIX_ACL | ||
| 30 | bool "Ext2 POSIX Access Control Lists" | ||
| 31 | depends on EXT2_FS_XATTR | ||
| 32 | select FS_POSIX_ACL | ||
| 33 | help | ||
| 34 | Posix Access Control Lists (ACLs) support permissions for users and | ||
| 35 | groups beyond the owner/group/world scheme. | ||
| 36 | |||
| 37 | To learn more about Access Control Lists, visit the Posix ACLs for | ||
| 38 | Linux website <http://acl.bestbits.at/>. | ||
| 39 | |||
| 40 | If you don't know what Access Control Lists are, say N | ||
| 41 | |||
| 42 | config EXT2_FS_SECURITY | ||
| 43 | bool "Ext2 Security Labels" | ||
| 44 | depends on EXT2_FS_XATTR | ||
| 45 | help | ||
| 46 | Security labels support alternative access control models | ||
| 47 | implemented by security modules like SELinux. This option | ||
| 48 | enables an extended attribute handler for file security | ||
| 49 | labels in the ext2 filesystem. | ||
| 50 | |||
| 51 | If you are not using a security module that requires using | ||
| 52 | extended attributes for file security labels, say N. | ||
| 53 | |||
| 54 | config EXT2_FS_XIP | ||
| 55 | bool "Ext2 execute in place support" | ||
| 56 | depends on EXT2_FS && MMU | ||
| 57 | help | ||
| 58 | Execute in place can be used on memory-backed block devices. If you | ||
| 59 | enable this option, you can select to mount block devices which are | ||
| 60 | capable of this feature without using the page cache. | ||
| 61 | |||
| 62 | If you do not use a block device that is capable of using this, | ||
| 63 | or if unsure, say N. | ||
| 64 | 12 | ||
| 65 | config FS_XIP | 13 | config FS_XIP |
| 66 | # execute in place | 14 | # execute in place |
| @@ -68,218 +16,8 @@ config FS_XIP | |||
| 68 | depends on EXT2_FS_XIP | 16 | depends on EXT2_FS_XIP |
| 69 | default y | 17 | default y |
| 70 | 18 | ||
| 71 | config EXT3_FS | 19 | source "fs/jbd/Kconfig" |
| 72 | tristate "Ext3 journalling file system support" | 20 | source "fs/jbd2/Kconfig" |
| 73 | select JBD | ||
| 74 | help | ||
| 75 | This is the journalling version of the Second extended file system | ||
| 76 | (often called ext3), the de facto standard Linux file system | ||
| 77 | (method to organize files on a storage device) for hard disks. | ||
| 78 | |||
| 79 | The journalling code included in this driver means you do not have | ||
| 80 | to run e2fsck (file system checker) on your file systems after a | ||
| 81 | crash. The journal keeps track of any changes that were being made | ||
| 82 | at the time the system crashed, and can ensure that your file system | ||
| 83 | is consistent without the need for a lengthy check. | ||
| 84 | |||
| 85 | Other than adding the journal to the file system, the on-disk format | ||
| 86 | of ext3 is identical to ext2. It is possible to freely switch | ||
| 87 | between using the ext3 driver and the ext2 driver, as long as the | ||
| 88 | file system has been cleanly unmounted, or e2fsck is run on the file | ||
| 89 | system. | ||
| 90 | |||
| 91 | To add a journal on an existing ext2 file system or change the | ||
| 92 | behavior of ext3 file systems, you can use the tune2fs utility ("man | ||
| 93 | tune2fs"). To modify attributes of files and directories on ext3 | ||
| 94 | file systems, use chattr ("man chattr"). You need to be using | ||
| 95 | e2fsprogs version 1.20 or later in order to create ext3 journals | ||
| 96 | (available at <http://sourceforge.net/projects/e2fsprogs/>). | ||
| 97 | |||
| 98 | To compile this file system support as a module, choose M here: the | ||
| 99 | module will be called ext3. | ||
| 100 | |||
| 101 | config EXT3_FS_XATTR | ||
| 102 | bool "Ext3 extended attributes" | ||
| 103 | depends on EXT3_FS | ||
| 104 | default y | ||
| 105 | help | ||
| 106 | Extended attributes are name:value pairs associated with inodes by | ||
| 107 | the kernel or by users (see the attr(5) manual page, or visit | ||
| 108 | <http://acl.bestbits.at/> for details). | ||
| 109 | |||
| 110 | If unsure, say N. | ||
| 111 | |||
| 112 | You need this for POSIX ACL support on ext3. | ||
| 113 | |||
| 114 | config EXT3_FS_POSIX_ACL | ||
| 115 | bool "Ext3 POSIX Access Control Lists" | ||
| 116 | depends on EXT3_FS_XATTR | ||
| 117 | select FS_POSIX_ACL | ||
| 118 | help | ||
| 119 | Posix Access Control Lists (ACLs) support permissions for users and | ||
| 120 | groups beyond the owner/group/world scheme. | ||
| 121 | |||
| 122 | To learn more about Access Control Lists, visit the Posix ACLs for | ||
| 123 | Linux website <http://acl.bestbits.at/>. | ||
| 124 | |||
| 125 | If you don't know what Access Control Lists are, say N | ||
| 126 | |||
| 127 | config EXT3_FS_SECURITY | ||
| 128 | bool "Ext3 Security Labels" | ||
| 129 | depends on EXT3_FS_XATTR | ||
| 130 | help | ||
| 131 | Security labels support alternative access control models | ||
| 132 | implemented by security modules like SELinux. This option | ||
| 133 | enables an extended attribute handler for file security | ||
| 134 | labels in the ext3 filesystem. | ||
| 135 | |||
| 136 | If you are not using a security module that requires using | ||
| 137 | extended attributes for file security labels, say N. | ||
| 138 | |||
| 139 | config EXT4_FS | ||
| 140 | tristate "The Extended 4 (ext4) filesystem" | ||
| 141 | select JBD2 | ||
| 142 | select CRC16 | ||
| 143 | help | ||
| 144 | This is the next generation of the ext3 filesystem. | ||
| 145 | |||
| 146 | Unlike the change from ext2 filesystem to ext3 filesystem, | ||
| 147 | the on-disk format of ext4 is not forwards compatible with | ||
| 148 | ext3; it is based on extent maps and it supports 48-bit | ||
| 149 | physical block numbers. The ext4 filesystem also supports delayed | ||
| 150 | allocation, persistent preallocation, high resolution time stamps, | ||
| 151 | and a number of other features to improve performance and speed | ||
| 152 | up fsck time. For more information, please see the web pages at | ||
| 153 | http://ext4.wiki.kernel.org. | ||
| 154 | |||
| 155 | The ext4 filesystem will support mounting an ext3 | ||
| 156 | filesystem; while there will be some performance gains from | ||
| 157 | the delayed allocation and inode table readahead, the best | ||
| 158 | performance gains will require enabling ext4 features in the | ||
| 159 | filesystem, or formating a new filesystem as an ext4 | ||
| 160 | filesystem initially. | ||
| 161 | |||
| 162 | To compile this file system support as a module, choose M here. The | ||
| 163 | module will be called ext4. | ||
| 164 | |||
| 165 | If unsure, say N. | ||
| 166 | |||
| 167 | config EXT4DEV_COMPAT | ||
| 168 | bool "Enable ext4dev compatibility" | ||
| 169 | depends on EXT4_FS | ||
| 170 | help | ||
| 171 | Starting with 2.6.28, the name of the ext4 filesystem was | ||
| 172 | renamed from ext4dev to ext4. Unfortunately there are some | ||
| 173 | legacy userspace programs (such as klibc's fstype) have | ||
| 174 | "ext4dev" hardcoded. | ||
| 175 | |||
| 176 | To enable backwards compatibility so that systems that are | ||
| 177 | still expecting to mount ext4 filesystems using ext4dev, | ||
| 178 | chose Y here. This feature will go away by 2.6.31, so | ||
| 179 | please arrange to get your userspace programs fixed! | ||
| 180 | |||
| 181 | config EXT4_FS_XATTR | ||
| 182 | bool "Ext4 extended attributes" | ||
| 183 | depends on EXT4_FS | ||
| 184 | default y | ||
| 185 | help | ||
| 186 | Extended attributes are name:value pairs associated with inodes by | ||
| 187 | the kernel or by users (see the attr(5) manual page, or visit | ||
| 188 | <http://acl.bestbits.at/> for details). | ||
| 189 | |||
| 190 | If unsure, say N. | ||
| 191 | |||
| 192 | You need this for POSIX ACL support on ext4. | ||
| 193 | |||
| 194 | config EXT4_FS_POSIX_ACL | ||
| 195 | bool "Ext4 POSIX Access Control Lists" | ||
| 196 | depends on EXT4_FS_XATTR | ||
| 197 | select FS_POSIX_ACL | ||
| 198 | help | ||
| 199 | POSIX Access Control Lists (ACLs) support permissions for users and | ||
| 200 | groups beyond the owner/group/world scheme. | ||
| 201 | |||
| 202 | To learn more about Access Control Lists, visit the POSIX ACLs for | ||
| 203 | Linux website <http://acl.bestbits.at/>. | ||
| 204 | |||
| 205 | If you don't know what Access Control Lists are, say N | ||
| 206 | |||
| 207 | config EXT4_FS_SECURITY | ||
| 208 | bool "Ext4 Security Labels" | ||
| 209 | depends on EXT4_FS_XATTR | ||
| 210 | help | ||
| 211 | Security labels support alternative access control models | ||
| 212 | implemented by security modules like SELinux. This option | ||
| 213 | enables an extended attribute handler for file security | ||
| 214 | labels in the ext4 filesystem. | ||
| 215 | |||
| 216 | If you are not using a security module that requires using | ||
| 217 | extended attributes for file security labels, say N. | ||
| 218 | |||
| 219 | config JBD | ||
| 220 | tristate | ||
| 221 | help | ||
| 222 | This is a generic journalling layer for block devices. It is | ||
| 223 | currently used by the ext3 file system, but it could also be | ||
| 224 | used to add journal support to other file systems or block | ||
| 225 | devices such as RAID or LVM. | ||
| 226 | |||
| 227 | If you are using the ext3 file system, you need to say Y here. | ||
| 228 | If you are not using ext3 then you will probably want to say N. | ||
| 229 | |||
| 230 | To compile this device as a module, choose M here: the module will be | ||
| 231 | called jbd. If you are compiling ext3 into the kernel, you | ||
| 232 | cannot compile this code as a module. | ||
| 233 | |||
| 234 | config JBD_DEBUG | ||
| 235 | bool "JBD (ext3) debugging support" | ||
| 236 | depends on JBD && DEBUG_FS | ||
| 237 | help | ||
| 238 | If you are using the ext3 journaled file system (or potentially any | ||
| 239 | other file system/device using JBD), this option allows you to | ||
| 240 | enable debugging output while the system is running, in order to | ||
| 241 | help track down any problems you are having. By default the | ||
| 242 | debugging output will be turned off. | ||
| 243 | |||
| 244 | If you select Y here, then you will be able to turn on debugging | ||
| 245 | with "echo N > /sys/kernel/debug/jbd/jbd-debug", where N is a | ||
| 246 | number between 1 and 5, the higher the number, the more debugging | ||
| 247 | output is generated. To turn debugging off again, do | ||
| 248 | "echo 0 > /sys/kernel/debug/jbd/jbd-debug". | ||
| 249 | |||
| 250 | config JBD2 | ||
| 251 | tristate | ||
| 252 | select CRC32 | ||
| 253 | help | ||
| 254 | This is a generic journaling layer for block devices that support | ||
| 255 | both 32-bit and 64-bit block numbers. It is currently used by | ||
| 256 | the ext4 and OCFS2 filesystems, but it could also be used to add | ||
| 257 | journal support to other file systems or block devices such | ||
| 258 | as RAID or LVM. | ||
| 259 | |||
| 260 | If you are using ext4 or OCFS2, you need to say Y here. | ||
| 261 | If you are not using ext4 or OCFS2 then you will | ||
| 262 | probably want to say N. | ||
| 263 | |||
| 264 | To compile this device as a module, choose M here. The module will be | ||
| 265 | called jbd2. If you are compiling ext4 or OCFS2 into the kernel, | ||
| 266 | you cannot compile this code as a module. | ||
| 267 | |||
| 268 | config JBD2_DEBUG | ||
| 269 | bool "JBD2 (ext4) debugging support" | ||
| 270 | depends on JBD2 && DEBUG_FS | ||
| 271 | help | ||
| 272 | If you are using the ext4 journaled file system (or | ||
| 273 | potentially any other filesystem/device using JBD2), this option | ||
| 274 | allows you to enable debugging output while the system is running, | ||
| 275 | in order to help track down any problems you are having. | ||
| 276 | By default, the debugging output will be turned off. | ||
| 277 | |||
| 278 | If you select Y here, then you will be able to turn on debugging | ||
| 279 | with "echo N > /sys/kernel/debug/jbd2/jbd2-debug", where N is a | ||
| 280 | number between 1 and 5. The higher the number, the more debugging | ||
| 281 | output is generated. To turn debugging off again, do | ||
| 282 | "echo 0 > /sys/kernel/debug/jbd2/jbd2-debug". | ||
| 283 | 21 | ||
| 284 | config FS_MBCACHE | 22 | config FS_MBCACHE |
| 285 | # Meta block cache for Extended Attributes (ext2/ext3/ext4) | 23 | # Meta block cache for Extended Attributes (ext2/ext3/ext4) |
| @@ -665,7 +403,7 @@ config AUTOFS4_FS | |||
| 665 | N here. | 403 | N here. |
| 666 | 404 | ||
| 667 | config FUSE_FS | 405 | config FUSE_FS |
| 668 | tristate "Filesystem in Userspace support" | 406 | tristate "FUSE (Filesystem in Userspace) support" |
| 669 | help | 407 | help |
| 670 | With FUSE it is possible to implement a fully functional filesystem | 408 | With FUSE it is possible to implement a fully functional filesystem |
| 671 | in a userspace program. | 409 | in a userspace program. |
| @@ -1168,195 +906,7 @@ config EFS_FS | |||
| 1168 | To compile the EFS file system support as a module, choose M here: the | 906 | To compile the EFS file system support as a module, choose M here: the |
| 1169 | module will be called efs. | 907 | module will be called efs. |
| 1170 | 908 | ||
| 1171 | config JFFS2_FS | 909 | source "fs/jffs2/Kconfig" |
| 1172 | tristate "Journalling Flash File System v2 (JFFS2) support" | ||
| 1173 | select CRC32 | ||
| 1174 | depends on MTD | ||
| 1175 | help | ||
| 1176 | JFFS2 is the second generation of the Journalling Flash File System | ||
| 1177 | for use on diskless embedded devices. It provides improved wear | ||
| 1178 | levelling, compression and support for hard links. You cannot use | ||
| 1179 | this on normal block devices, only on 'MTD' devices. | ||
| 1180 | |||
| 1181 | Further information on the design and implementation of JFFS2 is | ||
| 1182 | available at <http://sources.redhat.com/jffs2/>. | ||
| 1183 | |||
| 1184 | config JFFS2_FS_DEBUG | ||
| 1185 | int "JFFS2 debugging verbosity (0 = quiet, 2 = noisy)" | ||
| 1186 | depends on JFFS2_FS | ||
| 1187 | default "0" | ||
| 1188 | help | ||
| 1189 | This controls the amount of debugging messages produced by the JFFS2 | ||
| 1190 | code. Set it to zero for use in production systems. For evaluation, | ||
| 1191 | testing and debugging, it's advisable to set it to one. This will | ||
| 1192 | enable a few assertions and will print debugging messages at the | ||
| 1193 | KERN_DEBUG loglevel, where they won't normally be visible. Level 2 | ||
| 1194 | is unlikely to be useful - it enables extra debugging in certain | ||
| 1195 | areas which at one point needed debugging, but when the bugs were | ||
| 1196 | located and fixed, the detailed messages were relegated to level 2. | ||
| 1197 | |||
| 1198 | If reporting bugs, please try to have available a full dump of the | ||
| 1199 | messages at debug level 1 while the misbehaviour was occurring. | ||
| 1200 | |||
| 1201 | config JFFS2_FS_WRITEBUFFER | ||
| 1202 | bool "JFFS2 write-buffering support" | ||
| 1203 | depends on JFFS2_FS | ||
| 1204 | default y | ||
| 1205 | help | ||
| 1206 | This enables the write-buffering support in JFFS2. | ||
| 1207 | |||
| 1208 | This functionality is required to support JFFS2 on the following | ||
| 1209 | types of flash devices: | ||
| 1210 | - NAND flash | ||
| 1211 | - NOR flash with transparent ECC | ||
| 1212 | - DataFlash | ||
| 1213 | |||
| 1214 | config JFFS2_FS_WBUF_VERIFY | ||
| 1215 | bool "Verify JFFS2 write-buffer reads" | ||
| 1216 | depends on JFFS2_FS_WRITEBUFFER | ||
| 1217 | default n | ||
| 1218 | help | ||
| 1219 | This causes JFFS2 to read back every page written through the | ||
| 1220 | write-buffer, and check for errors. | ||
| 1221 | |||
| 1222 | config JFFS2_SUMMARY | ||
| 1223 | bool "JFFS2 summary support (EXPERIMENTAL)" | ||
| 1224 | depends on JFFS2_FS && EXPERIMENTAL | ||
| 1225 | default n | ||
| 1226 | help | ||
| 1227 | This feature makes it possible to use summary information | ||
| 1228 | for faster filesystem mount. | ||
| 1229 | |||
| 1230 | The summary information can be inserted into a filesystem image | ||
| 1231 | by the utility 'sumtool'. | ||
| 1232 | |||
| 1233 | If unsure, say 'N'. | ||
| 1234 | |||
| 1235 | config JFFS2_FS_XATTR | ||
| 1236 | bool "JFFS2 XATTR support (EXPERIMENTAL)" | ||
| 1237 | depends on JFFS2_FS && EXPERIMENTAL | ||
| 1238 | default n | ||
| 1239 | help | ||
| 1240 | Extended attributes are name:value pairs associated with inodes by | ||
| 1241 | the kernel or by users (see the attr(5) manual page, or visit | ||
| 1242 | <http://acl.bestbits.at/> for details). | ||
| 1243 | |||
| 1244 | If unsure, say N. | ||
| 1245 | |||
| 1246 | config JFFS2_FS_POSIX_ACL | ||
| 1247 | bool "JFFS2 POSIX Access Control Lists" | ||
| 1248 | depends on JFFS2_FS_XATTR | ||
| 1249 | default y | ||
| 1250 | select FS_POSIX_ACL | ||
| 1251 | help | ||
| 1252 | Posix Access Control Lists (ACLs) support permissions for users and | ||
| 1253 | groups beyond the owner/group/world scheme. | ||
| 1254 | |||
| 1255 | To learn more about Access Control Lists, visit the Posix ACLs for | ||
| 1256 | Linux website <http://acl.bestbits.at/>. | ||
| 1257 | |||
| 1258 | If you don't know what Access Control Lists are, say N | ||
| 1259 | |||
| 1260 | config JFFS2_FS_SECURITY | ||
| 1261 | bool "JFFS2 Security Labels" | ||
| 1262 | depends on JFFS2_FS_XATTR | ||
| 1263 | default y | ||
| 1264 | help | ||
| 1265 | Security labels support alternative access control models | ||
| 1266 | implemented by security modules like SELinux. This option | ||
| 1267 | enables an extended attribute handler for file security | ||
| 1268 | labels in the jffs2 filesystem. | ||
| 1269 | |||
| 1270 | If you are not using a security module that requires using | ||
| 1271 | extended attributes for file security labels, say N. | ||
| 1272 | |||
| 1273 | config JFFS2_COMPRESSION_OPTIONS | ||
| 1274 | bool "Advanced compression options for JFFS2" | ||
| 1275 | depends on JFFS2_FS | ||
| 1276 | default n | ||
| 1277 | help | ||
| 1278 | Enabling this option allows you to explicitly choose which | ||
| 1279 | compression modules, if any, are enabled in JFFS2. Removing | ||
| 1280 | compressors can mean you cannot read existing file systems, | ||
| 1281 | and enabling experimental compressors can mean that you | ||
| 1282 | write a file system which cannot be read by a standard kernel. | ||
| 1283 | |||
| 1284 | If unsure, you should _definitely_ say 'N'. | ||
| 1285 | |||
| 1286 | config JFFS2_ZLIB | ||
| 1287 | bool "JFFS2 ZLIB compression support" if JFFS2_COMPRESSION_OPTIONS | ||
| 1288 | select ZLIB_INFLATE | ||
| 1289 | select ZLIB_DEFLATE | ||
| 1290 | depends on JFFS2_FS | ||
| 1291 | default y | ||
| 1292 | help | ||
| 1293 | Zlib is designed to be a free, general-purpose, legally unencumbered, | ||
| 1294 | lossless data-compression library for use on virtually any computer | ||
| 1295 | hardware and operating system. See <http://www.gzip.org/zlib/> for | ||
| 1296 | further information. | ||
| 1297 | |||
| 1298 | Say 'Y' if unsure. | ||
| 1299 | |||
| 1300 | config JFFS2_LZO | ||
| 1301 | bool "JFFS2 LZO compression support" if JFFS2_COMPRESSION_OPTIONS | ||
| 1302 | select LZO_COMPRESS | ||
| 1303 | select LZO_DECOMPRESS | ||
| 1304 | depends on JFFS2_FS | ||
| 1305 | default n | ||
| 1306 | help | ||
| 1307 | minilzo-based compression. Generally works better than Zlib. | ||
| 1308 | |||
| 1309 | This feature was added in July, 2007. Say 'N' if you need | ||
| 1310 | compatibility with older bootloaders or kernels. | ||
| 1311 | |||
| 1312 | config JFFS2_RTIME | ||
| 1313 | bool "JFFS2 RTIME compression support" if JFFS2_COMPRESSION_OPTIONS | ||
| 1314 | depends on JFFS2_FS | ||
| 1315 | default y | ||
| 1316 | help | ||
| 1317 | Rtime does manage to recompress already-compressed data. Say 'Y' if unsure. | ||
| 1318 | |||
| 1319 | config JFFS2_RUBIN | ||
| 1320 | bool "JFFS2 RUBIN compression support" if JFFS2_COMPRESSION_OPTIONS | ||
| 1321 | depends on JFFS2_FS | ||
| 1322 | default n | ||
| 1323 | help | ||
| 1324 | RUBINMIPS and DYNRUBIN compressors. Say 'N' if unsure. | ||
| 1325 | |||
| 1326 | choice | ||
| 1327 | prompt "JFFS2 default compression mode" if JFFS2_COMPRESSION_OPTIONS | ||
| 1328 | default JFFS2_CMODE_PRIORITY | ||
| 1329 | depends on JFFS2_FS | ||
| 1330 | help | ||
| 1331 | You can set here the default compression mode of JFFS2 from | ||
| 1332 | the available compression modes. Don't touch if unsure. | ||
| 1333 | |||
| 1334 | config JFFS2_CMODE_NONE | ||
| 1335 | bool "no compression" | ||
| 1336 | help | ||
| 1337 | Uses no compression. | ||
| 1338 | |||
| 1339 | config JFFS2_CMODE_PRIORITY | ||
| 1340 | bool "priority" | ||
| 1341 | help | ||
| 1342 | Tries the compressors in a predefined order and chooses the first | ||
| 1343 | successful one. | ||
| 1344 | |||
| 1345 | config JFFS2_CMODE_SIZE | ||
| 1346 | bool "size (EXPERIMENTAL)" | ||
| 1347 | help | ||
| 1348 | Tries all compressors and chooses the one which has the smallest | ||
| 1349 | result. | ||
| 1350 | |||
| 1351 | config JFFS2_CMODE_FAVOURLZO | ||
| 1352 | bool "Favour LZO" | ||
| 1353 | help | ||
| 1354 | Tries all compressors and chooses the one which has the smallest | ||
| 1355 | result but gives some preference to LZO (which has faster | ||
| 1356 | decompression) at the expense of size. | ||
| 1357 | |||
| 1358 | endchoice | ||
| 1359 | |||
| 1360 | # UBIFS File system configuration | 910 | # UBIFS File system configuration |
| 1361 | source "fs/ubifs/Kconfig" | 911 | source "fs/ubifs/Kconfig" |
| 1362 | 912 | ||
| @@ -1913,148 +1463,7 @@ config SMB_NLS_REMOTE | |||
| 1913 | 1463 | ||
| 1914 | smbmount from samba 2.2.0 or later supports this. | 1464 | smbmount from samba 2.2.0 or later supports this. |
| 1915 | 1465 | ||
| 1916 | config CIFS | 1466 | source "fs/cifs/Kconfig" |
| 1917 | tristate "CIFS support (advanced network filesystem, SMBFS successor)" | ||
| 1918 | depends on INET | ||
| 1919 | select NLS | ||
| 1920 | help | ||
| 1921 | This is the client VFS module for the Common Internet File System | ||
| 1922 | (CIFS) protocol which is the successor to the Server Message Block | ||
| 1923 | (SMB) protocol, the native file sharing mechanism for most early | ||
| 1924 | PC operating systems. The CIFS protocol is fully supported by | ||
| 1925 | file servers such as Windows 2000 (including Windows 2003, NT 4 | ||
| 1926 | and Windows XP) as well by Samba (which provides excellent CIFS | ||
| 1927 | server support for Linux and many other operating systems). Limited | ||
| 1928 | support for OS/2 and Windows ME and similar servers is provided as | ||
| 1929 | well. | ||
| 1930 | |||
| 1931 | The cifs module provides an advanced network file system | ||
| 1932 | client for mounting to CIFS compliant servers. It includes | ||
| 1933 | support for DFS (hierarchical name space), secure per-user | ||
| 1934 | session establishment via Kerberos or NTLM or NTLMv2, | ||
| 1935 | safe distributed caching (oplock), optional packet | ||
| 1936 | signing, Unicode and other internationalization improvements. | ||
| 1937 | If you need to mount to Samba or Windows from this machine, say Y. | ||
| 1938 | |||
| 1939 | config CIFS_STATS | ||
| 1940 | bool "CIFS statistics" | ||
| 1941 | depends on CIFS | ||
| 1942 | help | ||
| 1943 | Enabling this option will cause statistics for each server share | ||
| 1944 | mounted by the cifs client to be displayed in /proc/fs/cifs/Stats | ||
| 1945 | |||
| 1946 | config CIFS_STATS2 | ||
| 1947 | bool "Extended statistics" | ||
| 1948 | depends on CIFS_STATS | ||
| 1949 | help | ||
| 1950 | Enabling this option will allow more detailed statistics on SMB | ||
| 1951 | request timing to be displayed in /proc/fs/cifs/DebugData and also | ||
| 1952 | allow optional logging of slow responses to dmesg (depending on the | ||
| 1953 | value of /proc/fs/cifs/cifsFYI, see fs/cifs/README for more details). | ||
| 1954 | These additional statistics may have a minor effect on performance | ||
| 1955 | and memory utilization. | ||
| 1956 | |||
| 1957 | Unless you are a developer or are doing network performance analysis | ||
| 1958 | or tuning, say N. | ||
| 1959 | |||
| 1960 | config CIFS_WEAK_PW_HASH | ||
| 1961 | bool "Support legacy servers which use weaker LANMAN security" | ||
| 1962 | depends on CIFS | ||
| 1963 | help | ||
| 1964 | Modern CIFS servers including Samba and most Windows versions | ||
| 1965 | (since 1997) support stronger NTLM (and even NTLMv2 and Kerberos) | ||
| 1966 | security mechanisms. These hash the password more securely | ||
| 1967 | than the mechanisms used in the older LANMAN version of the | ||
| 1968 | SMB protocol but LANMAN based authentication is needed to | ||
| 1969 | establish sessions with some old SMB servers. | ||
| 1970 | |||
| 1971 | Enabling this option allows the cifs module to mount to older | ||
| 1972 | LANMAN based servers such as OS/2 and Windows 95, but such | ||
| 1973 | mounts may be less secure than mounts using NTLM or more recent | ||
| 1974 | security mechanisms if you are on a public network. Unless you | ||
| 1975 | have a need to access old SMB servers (and are on a private | ||
| 1976 | network) you probably want to say N. Even if this support | ||
| 1977 | is enabled in the kernel build, LANMAN authentication will not be | ||
| 1978 | used automatically. At runtime LANMAN mounts are disabled but | ||
| 1979 | can be set to required (or optional) either in | ||
| 1980 | /proc/fs/cifs (see fs/cifs/README for more detail) or via an | ||
| 1981 | option on the mount command. This support is disabled by | ||
| 1982 | default in order to reduce the possibility of a downgrade | ||
| 1983 | attack. | ||
| 1984 | |||
| 1985 | If unsure, say N. | ||
| 1986 | |||
| 1987 | config CIFS_UPCALL | ||
| 1988 | bool "Kerberos/SPNEGO advanced session setup" | ||
| 1989 | depends on CIFS && KEYS | ||
| 1990 | help | ||
| 1991 | Enables an upcall mechanism for CIFS which accesses | ||
| 1992 | userspace helper utilities to provide SPNEGO packaged (RFC 4178) | ||
| 1993 | Kerberos tickets which are needed to mount to certain secure servers | ||
| 1994 | (for which more secure Kerberos authentication is required). If | ||
| 1995 | unsure, say N. | ||
| 1996 | |||
| 1997 | config CIFS_XATTR | ||
| 1998 | bool "CIFS extended attributes" | ||
| 1999 | depends on CIFS | ||
| 2000 | help | ||
| 2001 | Extended attributes are name:value pairs associated with inodes by | ||
| 2002 | the kernel or by users (see the attr(5) manual page, or visit | ||
| 2003 | <http://acl.bestbits.at/> for details). CIFS maps the name of | ||
| 2004 | extended attributes beginning with the user namespace prefix | ||
| 2005 | to SMB/CIFS EAs. EAs are stored on Windows servers without the | ||
| 2006 | user namespace prefix, but their names are seen by Linux cifs clients | ||
| 2007 | prefaced by the user namespace prefix. The system namespace | ||
| 2008 | (used by some filesystems to store ACLs) is not supported at | ||
| 2009 | this time. | ||
| 2010 | |||
| 2011 | If unsure, say N. | ||
| 2012 | |||
| 2013 | config CIFS_POSIX | ||
| 2014 | bool "CIFS POSIX Extensions" | ||
| 2015 | depends on CIFS_XATTR | ||
| 2016 | help | ||
| 2017 | Enabling this option will cause the cifs client to attempt to | ||
| 2018 | negotiate a newer dialect with servers, such as Samba 3.0.5 | ||
| 2019 | or later, that optionally can handle more POSIX like (rather | ||
| 2020 | than Windows like) file behavior. It also enables | ||
| 2021 | support for POSIX ACLs (getfacl and setfacl) to servers | ||
| 2022 | (such as Samba 3.10 and later) which can negotiate | ||
| 2023 | CIFS POSIX ACL support. If unsure, say N. | ||
| 2024 | |||
| 2025 | config CIFS_DEBUG2 | ||
| 2026 | bool "Enable additional CIFS debugging routines" | ||
| 2027 | depends on CIFS | ||
| 2028 | help | ||
| 2029 | Enabling this option adds a few more debugging routines | ||
| 2030 | to the cifs code which slightly increases the size of | ||
| 2031 | the cifs module and can cause additional logging of debug | ||
| 2032 | messages in some error paths, slowing performance. This | ||
| 2033 | option can be turned off unless you are debugging | ||
| 2034 | cifs problems. If unsure, say N. | ||
| 2035 | |||
| 2036 | config CIFS_EXPERIMENTAL | ||
| 2037 | bool "CIFS Experimental Features (EXPERIMENTAL)" | ||
| 2038 | depends on CIFS && EXPERIMENTAL | ||
| 2039 | help | ||
| 2040 | Enables cifs features under testing. These features are | ||
| 2041 | experimental and currently include DFS support and directory | ||
| 2042 | change notification ie fcntl(F_DNOTIFY), as well as the upcall | ||
| 2043 | mechanism which will be used for Kerberos session negotiation | ||
| 2044 | and uid remapping. Some of these features also may depend on | ||
| 2045 | setting a value of 1 to the pseudo-file /proc/fs/cifs/Experimental | ||
| 2046 | (which is disabled by default). See the file fs/cifs/README | ||
| 2047 | for more details. If unsure, say N. | ||
| 2048 | |||
| 2049 | config CIFS_DFS_UPCALL | ||
| 2050 | bool "DFS feature support (EXPERIMENTAL)" | ||
| 2051 | depends on CIFS_EXPERIMENTAL | ||
| 2052 | depends on KEYS | ||
| 2053 | help | ||
| 2054 | Enables an upcall mechanism for CIFS which contacts userspace | ||
| 2055 | helper utilities to provide server name resolution (host names to | ||
| 2056 | IP addresses) which is needed for implicit mounts of DFS junction | ||
| 2057 | points. If unsure, say N. | ||
| 2058 | 1467 | ||
| 2059 | config NCP_FS | 1468 | config NCP_FS |
| 2060 | tristate "NCP file system support (to mount NetWare volumes)" | 1469 | tristate "NCP file system support (to mount NetWare volumes)" |
diff --git a/fs/Kconfig.binfmt b/fs/Kconfig.binfmt index 801db134181..ce9fb3fbfae 100644 --- a/fs/Kconfig.binfmt +++ b/fs/Kconfig.binfmt | |||
| @@ -40,6 +40,28 @@ config BINFMT_ELF_FDPIC | |||
| 40 | 40 | ||
| 41 | It is also possible to run FDPIC ELF binaries on MMU linux also. | 41 | It is also possible to run FDPIC ELF binaries on MMU linux also. |
| 42 | 42 | ||
| 43 | config CORE_DUMP_DEFAULT_ELF_HEADERS | ||
| 44 | bool "Write ELF core dumps with partial segments" | ||
| 45 | default n | ||
| 46 | depends on BINFMT_ELF | ||
| 47 | help | ||
| 48 | ELF core dump files describe each memory mapping of the crashed | ||
| 49 | process, and can contain or omit the memory contents of each one. | ||
| 50 | The contents of an unmodified text mapping are omitted by default. | ||
| 51 | |||
| 52 | For an unmodified text mapping of an ELF object, including just | ||
| 53 | the first page of the file in a core dump makes it possible to | ||
| 54 | identify the build ID bits in the file, without paying the i/o | ||
| 55 | cost and disk space to dump all the text. However, versions of | ||
| 56 | GDB before 6.7 are confused by ELF core dump files in this format. | ||
| 57 | |||
| 58 | The core dump behavior can be controlled per process using | ||
| 59 | the /proc/PID/coredump_filter pseudo-file; this setting is | ||
| 60 | inherited. See Documentation/filesystems/proc.txt for details. | ||
| 61 | |||
| 62 | This config option changes the default setting of coredump_filter | ||
| 63 | seen at boot time. If unsure, say N. | ||
| 64 | |||
| 43 | config BINFMT_FLAT | 65 | config BINFMT_FLAT |
| 44 | bool "Kernel support for flat binaries" | 66 | bool "Kernel support for flat binaries" |
| 45 | depends on !MMU && (!FRV || BROKEN) | 67 | depends on !MMU && (!FRV || BROKEN) |
diff --git a/fs/binfmt_elf.c b/fs/binfmt_elf.c index c76afa26edf..8fcfa398d35 100644 --- a/fs/binfmt_elf.c +++ b/fs/binfmt_elf.c | |||
| @@ -1156,16 +1156,24 @@ static int dump_seek(struct file *file, loff_t off) | |||
| 1156 | static unsigned long vma_dump_size(struct vm_area_struct *vma, | 1156 | static unsigned long vma_dump_size(struct vm_area_struct *vma, |
| 1157 | unsigned long mm_flags) | 1157 | unsigned long mm_flags) |
| 1158 | { | 1158 | { |
| 1159 | #define FILTER(type) (mm_flags & (1UL << MMF_DUMP_##type)) | ||
| 1160 | |||
| 1159 | /* The vma can be set up to tell us the answer directly. */ | 1161 | /* The vma can be set up to tell us the answer directly. */ |
| 1160 | if (vma->vm_flags & VM_ALWAYSDUMP) | 1162 | if (vma->vm_flags & VM_ALWAYSDUMP) |
| 1161 | goto whole; | 1163 | goto whole; |
| 1162 | 1164 | ||
| 1165 | /* Hugetlb memory check */ | ||
| 1166 | if (vma->vm_flags & VM_HUGETLB) { | ||
| 1167 | if ((vma->vm_flags & VM_SHARED) && FILTER(HUGETLB_SHARED)) | ||
| 1168 | goto whole; | ||
| 1169 | if (!(vma->vm_flags & VM_SHARED) && FILTER(HUGETLB_PRIVATE)) | ||
| 1170 | goto whole; | ||
| 1171 | } | ||
| 1172 | |||
| 1163 | /* Do not dump I/O mapped devices or special mappings */ | 1173 | /* Do not dump I/O mapped devices or special mappings */ |
| 1164 | if (vma->vm_flags & (VM_IO | VM_RESERVED)) | 1174 | if (vma->vm_flags & (VM_IO | VM_RESERVED)) |
| 1165 | return 0; | 1175 | return 0; |
| 1166 | 1176 | ||
| 1167 | #define FILTER(type) (mm_flags & (1UL << MMF_DUMP_##type)) | ||
| 1168 | |||
| 1169 | /* By default, dump shared memory if mapped from an anonymous file. */ | 1177 | /* By default, dump shared memory if mapped from an anonymous file. */ |
| 1170 | if (vma->vm_flags & VM_SHARED) { | 1178 | if (vma->vm_flags & VM_SHARED) { |
| 1171 | if (vma->vm_file->f_path.dentry->d_inode->i_nlink == 0 ? | 1179 | if (vma->vm_file->f_path.dentry->d_inode->i_nlink == 0 ? |
| @@ -1333,20 +1341,15 @@ static void fill_prstatus(struct elf_prstatus *prstatus, | |||
| 1333 | prstatus->pr_pgrp = task_pgrp_vnr(p); | 1341 | prstatus->pr_pgrp = task_pgrp_vnr(p); |
| 1334 | prstatus->pr_sid = task_session_vnr(p); | 1342 | prstatus->pr_sid = task_session_vnr(p); |
| 1335 | if (thread_group_leader(p)) { | 1343 | if (thread_group_leader(p)) { |
| 1344 | struct task_cputime cputime; | ||
| 1345 | |||
| 1336 | /* | 1346 | /* |
| 1337 | * This is the record for the group leader. Add in the | 1347 | * This is the record for the group leader. It shows the |
| 1338 | * cumulative times of previous dead threads. This total | 1348 | * group-wide total, not its individual thread total. |
| 1339 | * won't include the time of each live thread whose state | ||
| 1340 | * is included in the core dump. The final total reported | ||
| 1341 | * to our parent process when it calls wait4 will include | ||
| 1342 | * those sums as well as the little bit more time it takes | ||
| 1343 | * this and each other thread to finish dying after the | ||
| 1344 | * core dump synchronization phase. | ||
| 1345 | */ | 1349 | */ |
| 1346 | cputime_to_timeval(cputime_add(p->utime, p->signal->utime), | 1350 | thread_group_cputime(p, &cputime); |
| 1347 | &prstatus->pr_utime); | 1351 | cputime_to_timeval(cputime.utime, &prstatus->pr_utime); |
| 1348 | cputime_to_timeval(cputime_add(p->stime, p->signal->stime), | 1352 | cputime_to_timeval(cputime.stime, &prstatus->pr_stime); |
| 1349 | &prstatus->pr_stime); | ||
| 1350 | } else { | 1353 | } else { |
| 1351 | cputime_to_timeval(p->utime, &prstatus->pr_utime); | 1354 | cputime_to_timeval(p->utime, &prstatus->pr_utime); |
| 1352 | cputime_to_timeval(p->stime, &prstatus->pr_stime); | 1355 | cputime_to_timeval(p->stime, &prstatus->pr_stime); |
diff --git a/fs/binfmt_elf_fdpic.c b/fs/binfmt_elf_fdpic.c index 0e8367c5462..5b5424cb339 100644 --- a/fs/binfmt_elf_fdpic.c +++ b/fs/binfmt_elf_fdpic.c | |||
| @@ -1390,20 +1390,15 @@ static void fill_prstatus(struct elf_prstatus *prstatus, | |||
| 1390 | prstatus->pr_pgrp = task_pgrp_vnr(p); | 1390 | prstatus->pr_pgrp = task_pgrp_vnr(p); |
| 1391 | prstatus->pr_sid = task_session_vnr(p); | 1391 | prstatus->pr_sid = task_session_vnr(p); |
| 1392 | if (thread_group_leader(p)) { | 1392 | if (thread_group_leader(p)) { |
| 1393 | struct task_cputime cputime; | ||
| 1394 | |||
| 1393 | /* | 1395 | /* |
| 1394 | * This is the record for the group leader. Add in the | 1396 | * This is the record for the group leader. It shows the |
| 1395 | * cumulative times of previous dead threads. This total | 1397 | * group-wide total, not its individual thread total. |
| 1396 | * won't include the time of each live thread whose state | ||
| 1397 | * is included in the core dump. The final total reported | ||
| 1398 | * to our parent process when it calls wait4 will include | ||
| 1399 | * those sums as well as the little bit more time it takes | ||
| 1400 | * this and each other thread to finish dying after the | ||
| 1401 | * core dump synchronization phase. | ||
| 1402 | */ | 1398 | */ |
| 1403 | cputime_to_timeval(cputime_add(p->utime, p->signal->utime), | 1399 | thread_group_cputime(p, &cputime); |
| 1404 | &prstatus->pr_utime); | 1400 | cputime_to_timeval(cputime.utime, &prstatus->pr_utime); |
| 1405 | cputime_to_timeval(cputime_add(p->stime, p->signal->stime), | 1401 | cputime_to_timeval(cputime.stime, &prstatus->pr_stime); |
| 1406 | &prstatus->pr_stime); | ||
| 1407 | } else { | 1402 | } else { |
| 1408 | cputime_to_timeval(p->utime, &prstatus->pr_utime); | 1403 | cputime_to_timeval(p->utime, &prstatus->pr_utime); |
| 1409 | cputime_to_timeval(p->stime, &prstatus->pr_stime); | 1404 | cputime_to_timeval(p->stime, &prstatus->pr_stime); |
diff --git a/fs/buffer.c b/fs/buffer.c index ac78d4c19b3..6569fda5cfe 100644 --- a/fs/buffer.c +++ b/fs/buffer.c | |||
| @@ -76,8 +76,7 @@ EXPORT_SYMBOL(__lock_buffer); | |||
| 76 | 76 | ||
| 77 | void unlock_buffer(struct buffer_head *bh) | 77 | void unlock_buffer(struct buffer_head *bh) |
| 78 | { | 78 | { |
| 79 | smp_mb__before_clear_bit(); | 79 | clear_bit_unlock(BH_Lock, &bh->b_state); |
| 80 | clear_buffer_locked(bh); | ||
| 81 | smp_mb__after_clear_bit(); | 80 | smp_mb__after_clear_bit(); |
| 82 | wake_up_bit(&bh->b_state, BH_Lock); | 81 | wake_up_bit(&bh->b_state, BH_Lock); |
| 83 | } | 82 | } |
diff --git a/fs/cifs/Kconfig b/fs/cifs/Kconfig new file mode 100644 index 00000000000..341a98965bd --- /dev/null +++ b/fs/cifs/Kconfig | |||
| @@ -0,0 +1,142 @@ | |||
| 1 | config CIFS | ||
| 2 | tristate "CIFS support (advanced network filesystem, SMBFS successor)" | ||
| 3 | depends on INET | ||
| 4 | select NLS | ||
| 5 | help | ||
| 6 | This is the client VFS module for the Common Internet File System | ||
| 7 | (CIFS) protocol which is the successor to the Server Message Block | ||
| 8 | (SMB) protocol, the native file sharing mechanism for most early | ||
| 9 | PC operating systems. The CIFS protocol is fully supported by | ||
| 10 | file servers such as Windows 2000 (including Windows 2003, NT 4 | ||
| 11 | and Windows XP) as well by Samba (which provides excellent CIFS | ||
| 12 | server support for Linux and many other operating systems). Limited | ||
| 13 | support for OS/2 and Windows ME and similar servers is provided as | ||
| 14 | well. | ||
| 15 | |||
| 16 | The cifs module provides an advanced network file system | ||
| 17 | client for mounting to CIFS compliant servers. It includes | ||
| 18 | support for DFS (hierarchical name space), secure per-user | ||
| 19 | session establishment via Kerberos or NTLM or NTLMv2, | ||
| 20 | safe distributed caching (oplock), optional packet | ||
| 21 | signing, Unicode and other internationalization improvements. | ||
| 22 | If you need to mount to Samba or Windows from this machine, say Y. | ||
| 23 | |||
| 24 | config CIFS_STATS | ||
| 25 | bool "CIFS statistics" | ||
| 26 | depends on CIFS | ||
| 27 | help | ||
| 28 | Enabling this option will cause statistics for each server share | ||
| 29 | mounted by the cifs client to be displayed in /proc/fs/cifs/Stats | ||
| 30 | |||
| 31 | config CIFS_STATS2 | ||
| 32 | bool "Extended statistics" | ||
| 33 | depends on CIFS_STATS | ||
| 34 | help | ||
| 35 | Enabling this option will allow more detailed statistics on SMB | ||
| 36 | request timing to be displayed in /proc/fs/cifs/DebugData and also | ||
| 37 | allow optional logging of slow responses to dmesg (depending on the | ||
| 38 | value of /proc/fs/cifs/cifsFYI, see fs/cifs/README for more details). | ||
| 39 | These additional statistics may have a minor effect on performance | ||
| 40 | and memory utilization. | ||
| 41 | |||
| 42 | Unless you are a developer or are doing network performance analysis | ||
| 43 | or tuning, say N. | ||
| 44 | |||
| 45 | config CIFS_WEAK_PW_HASH | ||
| 46 | bool "Support legacy servers which use weaker LANMAN security" | ||
| 47 | depends on CIFS | ||
| 48 | help | ||
| 49 | Modern CIFS servers including Samba and most Windows versions | ||
| 50 | (since 1997) support stronger NTLM (and even NTLMv2 and Kerberos) | ||
| 51 | security mechanisms. These hash the password more securely | ||
| 52 | than the mechanisms used in the older LANMAN version of the | ||
| 53 | SMB protocol but LANMAN based authentication is needed to | ||
| 54 | establish sessions with some old SMB servers. | ||
| 55 | |||
| 56 | Enabling this option allows the cifs module to mount to older | ||
| 57 | LANMAN based servers such as OS/2 and Windows 95, but such | ||
| 58 | mounts may be less secure than mounts using NTLM or more recent | ||
| 59 | security mechanisms if you are on a public network. Unless you | ||
| 60 | have a need to access old SMB servers (and are on a private | ||
| 61 | network) you probably want to say N. Even if this support | ||
| 62 | is enabled in the kernel build, LANMAN authentication will not be | ||
| 63 | used automatically. At runtime LANMAN mounts are disabled but | ||
| 64 | can be set to required (or optional) either in | ||
| 65 | /proc/fs/cifs (see fs/cifs/README for more detail) or via an | ||
| 66 | option on the mount command. This support is disabled by | ||
| 67 | default in order to reduce the possibility of a downgrade | ||
| 68 | attack. | ||
| 69 | |||
| 70 | If unsure, say N. | ||
| 71 | |||
| 72 | config CIFS_UPCALL | ||
| 73 | bool "Kerberos/SPNEGO advanced session setup" | ||
| 74 | depends on CIFS && KEYS | ||
| 75 | help | ||
| 76 | Enables an upcall mechanism for CIFS which accesses | ||
| 77 | userspace helper utilities to provide SPNEGO packaged (RFC 4178) | ||
| 78 | Kerberos tickets which are needed to mount to certain secure servers | ||
| 79 | (for which more secure Kerberos authentication is required). If | ||
| 80 | unsure, say N. | ||
| 81 | |||
| 82 | config CIFS_XATTR | ||
| 83 | bool "CIFS extended attributes" | ||
| 84 | depends on CIFS | ||
| 85 | help | ||
| 86 | Extended attributes are name:value pairs associated with inodes by | ||
| 87 | the kernel or by users (see the attr(5) manual page, or visit | ||
| 88 | <http://acl.bestbits.at/> for details). CIFS maps the name of | ||
| 89 | extended attributes beginning with the user namespace prefix | ||
| 90 | to SMB/CIFS EAs. EAs are stored on Windows servers without the | ||
| 91 | user namespace prefix, but their names are seen by Linux cifs clients | ||
| 92 | prefaced by the user namespace prefix. The system namespace | ||
| 93 | (used by some filesystems to store ACLs) is not supported at | ||
| 94 | this time. | ||
| 95 | |||
| 96 | If unsure, say N. | ||
| 97 | |||
| 98 | config CIFS_POSIX | ||
| 99 | bool "CIFS POSIX Extensions" | ||
| 100 | depends on CIFS_XATTR | ||
| 101 | help | ||
| 102 | Enabling this option will cause the cifs client to attempt to | ||
| 103 | negotiate a newer dialect with servers, such as Samba 3.0.5 | ||
| 104 | or later, that optionally can handle more POSIX like (rather | ||
| 105 | than Windows like) file behavior. It also enables | ||
| 106 | support for POSIX ACLs (getfacl and setfacl) to servers | ||
| 107 | (such as Samba 3.10 and later) which can negotiate | ||
| 108 | CIFS POSIX ACL support. If unsure, say N. | ||
| 109 | |||
| 110 | config CIFS_DEBUG2 | ||
| 111 | bool "Enable additional CIFS debugging routines" | ||
| 112 | depends on CIFS | ||
| 113 | help | ||
| 114 | Enabling this option adds a few more debugging routines | ||
| 115 | to the cifs code which slightly increases the size of | ||
| 116 | the cifs module and can cause additional logging of debug | ||
| 117 | messages in some error paths, slowing performance. This | ||
| 118 | option can be turned off unless you are debugging | ||
| 119 | cifs problems. If unsure, say N. | ||
| 120 | |||
| 121 | config CIFS_EXPERIMENTAL | ||
| 122 | bool "CIFS Experimental Features (EXPERIMENTAL)" | ||
| 123 | depends on CIFS && EXPERIMENTAL | ||
| 124 | help | ||
| 125 | Enables cifs features under testing. These features are | ||
| 126 | experimental and currently include DFS support and directory | ||
| 127 | change notification ie fcntl(F_DNOTIFY), as well as the upcall | ||
| 128 | mechanism which will be used for Kerberos session negotiation | ||
| 129 | and uid remapping. Some of these features also may depend on | ||
| 130 | setting a value of 1 to the pseudo-file /proc/fs/cifs/Experimental | ||
| 131 | (which is disabled by default). See the file fs/cifs/README | ||
| 132 | for more details. If unsure, say N. | ||
| 133 | |||
| 134 | config CIFS_DFS_UPCALL | ||
| 135 | bool "DFS feature support (EXPERIMENTAL)" | ||
| 136 | depends on CIFS_EXPERIMENTAL | ||
| 137 | depends on KEYS | ||
| 138 | help | ||
| 139 | Enables an upcall mechanism for CIFS which contacts userspace | ||
| 140 | helper utilities to provide server name resolution (host names to | ||
| 141 | IP addresses) which is needed for implicit mounts of DFS junction | ||
| 142 | points. If unsure, say N. | ||
diff --git a/fs/cifs/file.c b/fs/cifs/file.c index c4a8a060512..62d8bd8f14c 100644 --- a/fs/cifs/file.c +++ b/fs/cifs/file.c | |||
| @@ -1791,7 +1791,7 @@ static void cifs_copy_cache_pages(struct address_space *mapping, | |||
| 1791 | SetPageUptodate(page); | 1791 | SetPageUptodate(page); |
| 1792 | unlock_page(page); | 1792 | unlock_page(page); |
| 1793 | if (!pagevec_add(plru_pvec, page)) | 1793 | if (!pagevec_add(plru_pvec, page)) |
| 1794 | __pagevec_lru_add(plru_pvec); | 1794 | __pagevec_lru_add_file(plru_pvec); |
| 1795 | data += PAGE_CACHE_SIZE; | 1795 | data += PAGE_CACHE_SIZE; |
| 1796 | } | 1796 | } |
| 1797 | return; | 1797 | return; |
| @@ -1925,7 +1925,7 @@ static int cifs_readpages(struct file *file, struct address_space *mapping, | |||
| 1925 | bytes_read = 0; | 1925 | bytes_read = 0; |
| 1926 | } | 1926 | } |
| 1927 | 1927 | ||
| 1928 | pagevec_lru_add(&lru_pvec); | 1928 | pagevec_lru_add_file(&lru_pvec); |
| 1929 | 1929 | ||
| 1930 | /* need to free smb_read_data buf before exit */ | 1930 | /* need to free smb_read_data buf before exit */ |
| 1931 | if (smb_read_data) { | 1931 | if (smb_read_data) { |
| @@ -1386,7 +1386,7 @@ EXPORT_SYMBOL(set_binfmt); | |||
| 1386 | * name into corename, which must have space for at least | 1386 | * name into corename, which must have space for at least |
| 1387 | * CORENAME_MAX_SIZE bytes plus one byte for the zero terminator. | 1387 | * CORENAME_MAX_SIZE bytes plus one byte for the zero terminator. |
| 1388 | */ | 1388 | */ |
| 1389 | static int format_corename(char *corename, int nr_threads, long signr) | 1389 | static int format_corename(char *corename, long signr) |
| 1390 | { | 1390 | { |
| 1391 | const char *pat_ptr = core_pattern; | 1391 | const char *pat_ptr = core_pattern; |
| 1392 | int ispipe = (*pat_ptr == '|'); | 1392 | int ispipe = (*pat_ptr == '|'); |
| @@ -1493,8 +1493,7 @@ static int format_corename(char *corename, int nr_threads, long signr) | |||
| 1493 | * If core_pattern does not include a %p (as is the default) | 1493 | * If core_pattern does not include a %p (as is the default) |
| 1494 | * and core_uses_pid is set, then .%pid will be appended to | 1494 | * and core_uses_pid is set, then .%pid will be appended to |
| 1495 | * the filename. Do not do this for piped commands. */ | 1495 | * the filename. Do not do this for piped commands. */ |
| 1496 | if (!ispipe && !pid_in_pattern | 1496 | if (!ispipe && !pid_in_pattern && core_uses_pid) { |
| 1497 | && (core_uses_pid || nr_threads)) { | ||
| 1498 | rc = snprintf(out_ptr, out_end - out_ptr, | 1497 | rc = snprintf(out_ptr, out_end - out_ptr, |
| 1499 | ".%d", task_tgid_vnr(current)); | 1498 | ".%d", task_tgid_vnr(current)); |
| 1500 | if (rc > out_end - out_ptr) | 1499 | if (rc > out_end - out_ptr) |
| @@ -1757,7 +1756,7 @@ int do_coredump(long signr, int exit_code, struct pt_regs * regs) | |||
| 1757 | * uses lock_kernel() | 1756 | * uses lock_kernel() |
| 1758 | */ | 1757 | */ |
| 1759 | lock_kernel(); | 1758 | lock_kernel(); |
| 1760 | ispipe = format_corename(corename, retval, signr); | 1759 | ispipe = format_corename(corename, signr); |
| 1761 | unlock_kernel(); | 1760 | unlock_kernel(); |
| 1762 | /* | 1761 | /* |
| 1763 | * Don't bother to check the RLIMIT_CORE value if core_pattern points | 1762 | * Don't bother to check the RLIMIT_CORE value if core_pattern points |
diff --git a/fs/ext2/Kconfig b/fs/ext2/Kconfig new file mode 100644 index 00000000000..14a6780fd03 --- /dev/null +++ b/fs/ext2/Kconfig | |||
| @@ -0,0 +1,55 @@ | |||
| 1 | config EXT2_FS | ||
| 2 | tristate "Second extended fs support" | ||
| 3 | help | ||
| 4 | Ext2 is a standard Linux file system for hard disks. | ||
| 5 | |||
| 6 | To compile this file system support as a module, choose M here: the | ||
| 7 | module will be called ext2. | ||
| 8 | |||
| 9 | If unsure, say Y. | ||
| 10 | |||
| 11 | config EXT2_FS_XATTR | ||
| 12 | bool "Ext2 extended attributes" | ||
| 13 | depends on EXT2_FS | ||
| 14 | help | ||
| 15 | Extended attributes are name:value pairs associated with inodes by | ||
| 16 | the kernel or by users (see the attr(5) manual page, or visit | ||
| 17 | <http://acl.bestbits.at/> for details). | ||
| 18 | |||
| 19 | If unsure, say N. | ||
| 20 | |||
| 21 | config EXT2_FS_POSIX_ACL | ||
| 22 | bool "Ext2 POSIX Access Control Lists" | ||
| 23 | depends on EXT2_FS_XATTR | ||
| 24 | select FS_POSIX_ACL | ||
| 25 | help | ||
| 26 | Posix Access Control Lists (ACLs) support permissions for users and | ||
| 27 | groups beyond the owner/group/world scheme. | ||
| 28 | |||
| 29 | To learn more about Access Control Lists, visit the Posix ACLs for | ||
| 30 | Linux website <http://acl.bestbits.at/>. | ||
| 31 | |||
| 32 | If you don't know what Access Control Lists are, say N | ||
| 33 | |||
| 34 | config EXT2_FS_SECURITY | ||
| 35 | bool "Ext2 Security Labels" | ||
| 36 | depends on EXT2_FS_XATTR | ||
| 37 | help | ||
| 38 | Security labels support alternative access control models | ||
| 39 | implemented by security modules like SELinux. This option | ||
| 40 | enables an extended attribute handler for file security | ||
| 41 | labels in the ext2 filesystem. | ||
| 42 | |||
| 43 | If you are not using a security module that requires using | ||
| 44 | extended attributes for file security labels, say N. | ||
| 45 | |||
| 46 | config EXT2_FS_XIP | ||
| 47 | bool "Ext2 execute in place support" | ||
| 48 | depends on EXT2_FS && MMU | ||
| 49 | help | ||
| 50 | Execute in place can be used on memory-backed block devices. If you | ||
| 51 | enable this option, you can select to mount block devices which are | ||
| 52 | capable of this feature without using the page cache. | ||
| 53 | |||
| 54 | If you do not use a block device that is capable of using this, | ||
| 55 | or if unsure, say N. | ||
diff --git a/fs/ext3/Kconfig b/fs/ext3/Kconfig new file mode 100644 index 00000000000..8e0cfe44b0f --- /dev/null +++ b/fs/ext3/Kconfig | |||
| @@ -0,0 +1,67 @@ | |||
| 1 | config EXT3_FS | ||
| 2 | tristate "Ext3 journalling file system support" | ||
| 3 | select JBD | ||
| 4 | help | ||
| 5 | This is the journalling version of the Second extended file system | ||
| 6 | (often called ext3), the de facto standard Linux file system | ||
| 7 | (method to organize files on a storage device) for hard disks. | ||
| 8 | |||
| 9 | The journalling code included in this driver means you do not have | ||
| 10 | to run e2fsck (file system checker) on your file systems after a | ||
| 11 | crash. The journal keeps track of any changes that were being made | ||
| 12 | at the time the system crashed, and can ensure that your file system | ||
| 13 | is consistent without the need for a lengthy check. | ||
| 14 | |||
| 15 | Other than adding the journal to the file system, the on-disk format | ||
| 16 | of ext3 is identical to ext2. It is possible to freely switch | ||
| 17 | between using the ext3 driver and the ext2 driver, as long as the | ||
| 18 | file system has been cleanly unmounted, or e2fsck is run on the file | ||
| 19 | system. | ||
| 20 | |||
| 21 | To add a journal on an existing ext2 file system or change the | ||
| 22 | behavior of ext3 file systems, you can use the tune2fs utility ("man | ||
| 23 | tune2fs"). To modify attributes of files and directories on ext3 | ||
| 24 | file systems, use chattr ("man chattr"). You need to be using | ||
| 25 | e2fsprogs version 1.20 or later in order to create ext3 journals | ||
| 26 | (available at <http://sourceforge.net/projects/e2fsprogs/>). | ||
| 27 | |||
| 28 | To compile this file system support as a module, choose M here: the | ||
| 29 | module will be called ext3. | ||
| 30 | |||
| 31 | config EXT3_FS_XATTR | ||
| 32 | bool "Ext3 extended attributes" | ||
| 33 | depends on EXT3_FS | ||
| 34 | default y | ||
| 35 | help | ||
| 36 | Extended attributes are name:value pairs associated with inodes by | ||
| 37 | the kernel or by users (see the attr(5) manual page, or visit | ||
| 38 | <http://acl.bestbits.at/> for details). | ||
| 39 | |||
| 40 | If unsure, say N. | ||
| 41 | |||
| 42 | You need this for POSIX ACL support on ext3. | ||
| 43 | |||
| 44 | config EXT3_FS_POSIX_ACL | ||
| 45 | bool "Ext3 POSIX Access Control Lists" | ||
| 46 | depends on EXT3_FS_XATTR | ||
| 47 | select FS_POSIX_ACL | ||
| 48 | help | ||
| 49 | Posix Access Control Lists (ACLs) support permissions for users and | ||
| 50 | groups beyond the owner/group/world scheme. | ||
| 51 | |||
| 52 | To learn more about Access Control Lists, visit the Posix ACLs for | ||
| 53 | Linux website <http://acl.bestbits.at/>. | ||
| 54 | |||
| 55 | If you don't know what Access Control Lists are, say N | ||
| 56 | |||
| 57 | config EXT3_FS_SECURITY | ||
| 58 | bool "Ext3 Security Labels" | ||
| 59 | depends on EXT3_FS_XATTR | ||
| 60 | help | ||
| 61 | Security labels support alternative access control models | ||
| 62 | implemented by security modules like SELinux. This option | ||
| 63 | enables an extended attribute handler for file security | ||
| 64 | labels in the ext3 filesystem. | ||
| 65 | |||
| 66 | If you are not using a security module that requires using | ||
| 67 | extended attributes for file security labels, say N. | ||
diff --git a/fs/ext3/balloc.c b/fs/ext3/balloc.c index 92fd0338a6e..f5b57a2ca35 100644 --- a/fs/ext3/balloc.c +++ b/fs/ext3/balloc.c | |||
| @@ -1547,6 +1547,7 @@ retry_alloc: | |||
| 1547 | * turn off reservation for this allocation | 1547 | * turn off reservation for this allocation |
| 1548 | */ | 1548 | */ |
| 1549 | if (my_rsv && (free_blocks < windowsz) | 1549 | if (my_rsv && (free_blocks < windowsz) |
| 1550 | && (free_blocks > 0) | ||
| 1550 | && (rsv_is_empty(&my_rsv->rsv_window))) | 1551 | && (rsv_is_empty(&my_rsv->rsv_window))) |
| 1551 | my_rsv = NULL; | 1552 | my_rsv = NULL; |
| 1552 | 1553 | ||
| @@ -1585,7 +1586,7 @@ retry_alloc: | |||
| 1585 | * free blocks is less than half of the reservation | 1586 | * free blocks is less than half of the reservation |
| 1586 | * window size. | 1587 | * window size. |
| 1587 | */ | 1588 | */ |
| 1588 | if (free_blocks <= (windowsz/2)) | 1589 | if (my_rsv && (free_blocks <= (windowsz/2))) |
| 1589 | continue; | 1590 | continue; |
| 1590 | 1591 | ||
| 1591 | brelse(bitmap_bh); | 1592 | brelse(bitmap_bh); |
diff --git a/fs/ext3/dir.c b/fs/ext3/dir.c index 2eea96ec78e..4c82531ea0a 100644 --- a/fs/ext3/dir.c +++ b/fs/ext3/dir.c | |||
| @@ -102,6 +102,7 @@ static int ext3_readdir(struct file * filp, | |||
| 102 | int err; | 102 | int err; |
| 103 | struct inode *inode = filp->f_path.dentry->d_inode; | 103 | struct inode *inode = filp->f_path.dentry->d_inode; |
| 104 | int ret = 0; | 104 | int ret = 0; |
| 105 | int dir_has_error = 0; | ||
| 105 | 106 | ||
| 106 | sb = inode->i_sb; | 107 | sb = inode->i_sb; |
| 107 | 108 | ||
| @@ -148,9 +149,12 @@ static int ext3_readdir(struct file * filp, | |||
| 148 | * of recovering data when there's a bad sector | 149 | * of recovering data when there's a bad sector |
| 149 | */ | 150 | */ |
| 150 | if (!bh) { | 151 | if (!bh) { |
| 151 | ext3_error (sb, "ext3_readdir", | 152 | if (!dir_has_error) { |
| 152 | "directory #%lu contains a hole at offset %lu", | 153 | ext3_error(sb, __func__, "directory #%lu " |
| 153 | inode->i_ino, (unsigned long)filp->f_pos); | 154 | "contains a hole at offset %lld", |
| 155 | inode->i_ino, filp->f_pos); | ||
| 156 | dir_has_error = 1; | ||
| 157 | } | ||
| 154 | /* corrupt size? Maybe no more blocks to read */ | 158 | /* corrupt size? Maybe no more blocks to read */ |
| 155 | if (filp->f_pos > inode->i_blocks << 9) | 159 | if (filp->f_pos > inode->i_blocks << 9) |
| 156 | break; | 160 | break; |
| @@ -410,7 +414,7 @@ static int call_filldir(struct file * filp, void * dirent, | |||
| 410 | get_dtype(sb, fname->file_type)); | 414 | get_dtype(sb, fname->file_type)); |
| 411 | if (error) { | 415 | if (error) { |
| 412 | filp->f_pos = curr_pos; | 416 | filp->f_pos = curr_pos; |
| 413 | info->extra_fname = fname->next; | 417 | info->extra_fname = fname; |
| 414 | return error; | 418 | return error; |
| 415 | } | 419 | } |
| 416 | fname = fname->next; | 420 | fname = fname->next; |
| @@ -449,11 +453,21 @@ static int ext3_dx_readdir(struct file * filp, | |||
| 449 | * If there are any leftover names on the hash collision | 453 | * If there are any leftover names on the hash collision |
| 450 | * chain, return them first. | 454 | * chain, return them first. |
| 451 | */ | 455 | */ |
| 452 | if (info->extra_fname && | 456 | if (info->extra_fname) { |
| 453 | call_filldir(filp, dirent, filldir, info->extra_fname)) | 457 | if (call_filldir(filp, dirent, filldir, info->extra_fname)) |
| 454 | goto finished; | 458 | goto finished; |
| 455 | 459 | ||
| 456 | if (!info->curr_node) | 460 | info->extra_fname = NULL; |
| 461 | info->curr_node = rb_next(info->curr_node); | ||
| 462 | if (!info->curr_node) { | ||
| 463 | if (info->next_hash == ~0) { | ||
| 464 | filp->f_pos = EXT3_HTREE_EOF; | ||
| 465 | goto finished; | ||
| 466 | } | ||
| 467 | info->curr_hash = info->next_hash; | ||
| 468 | info->curr_minor_hash = 0; | ||
| 469 | } | ||
| 470 | } else if (!info->curr_node) | ||
| 457 | info->curr_node = rb_first(&info->root); | 471 | info->curr_node = rb_first(&info->root); |
| 458 | 472 | ||
| 459 | while (1) { | 473 | while (1) { |
diff --git a/fs/ext3/inode.c b/fs/ext3/inode.c index ebfec4d0148..f8424ad8997 100644 --- a/fs/ext3/inode.c +++ b/fs/ext3/inode.c | |||
| @@ -1186,6 +1186,13 @@ write_begin_failed: | |||
| 1186 | ext3_journal_stop(handle); | 1186 | ext3_journal_stop(handle); |
| 1187 | unlock_page(page); | 1187 | unlock_page(page); |
| 1188 | page_cache_release(page); | 1188 | page_cache_release(page); |
| 1189 | /* | ||
| 1190 | * block_write_begin may have instantiated a few blocks | ||
| 1191 | * outside i_size. Trim these off again. Don't need | ||
| 1192 | * i_size_read because we hold i_mutex. | ||
| 1193 | */ | ||
| 1194 | if (pos + len > inode->i_size) | ||
| 1195 | vmtruncate(inode, inode->i_size); | ||
| 1189 | } | 1196 | } |
| 1190 | if (ret == -ENOSPC && ext3_should_retry_alloc(inode->i_sb, &retries)) | 1197 | if (ret == -ENOSPC && ext3_should_retry_alloc(inode->i_sb, &retries)) |
| 1191 | goto retry; | 1198 | goto retry; |
diff --git a/fs/ext3/resize.c b/fs/ext3/resize.c index 77278e947e9..78fdf383637 100644 --- a/fs/ext3/resize.c +++ b/fs/ext3/resize.c | |||
| @@ -790,7 +790,8 @@ int ext3_group_add(struct super_block *sb, struct ext3_new_group_data *input) | |||
| 790 | 790 | ||
| 791 | if (reserved_gdb || gdb_off == 0) { | 791 | if (reserved_gdb || gdb_off == 0) { |
| 792 | if (!EXT3_HAS_COMPAT_FEATURE(sb, | 792 | if (!EXT3_HAS_COMPAT_FEATURE(sb, |
| 793 | EXT3_FEATURE_COMPAT_RESIZE_INODE)){ | 793 | EXT3_FEATURE_COMPAT_RESIZE_INODE) |
| 794 | || !le16_to_cpu(es->s_reserved_gdt_blocks)) { | ||
| 794 | ext3_warning(sb, __func__, | 795 | ext3_warning(sb, __func__, |
| 795 | "No reserved GDT blocks, can't resize"); | 796 | "No reserved GDT blocks, can't resize"); |
| 796 | return -EPERM; | 797 | return -EPERM; |
diff --git a/fs/ext3/super.c b/fs/ext3/super.c index 399a96a6c55..3a260af5544 100644 --- a/fs/ext3/super.c +++ b/fs/ext3/super.c | |||
| @@ -625,6 +625,9 @@ static int ext3_show_options(struct seq_file *seq, struct vfsmount *vfs) | |||
| 625 | else if (test_opt(sb, DATA_FLAGS) == EXT3_MOUNT_WRITEBACK_DATA) | 625 | else if (test_opt(sb, DATA_FLAGS) == EXT3_MOUNT_WRITEBACK_DATA) |
| 626 | seq_puts(seq, ",data=writeback"); | 626 | seq_puts(seq, ",data=writeback"); |
| 627 | 627 | ||
| 628 | if (test_opt(sb, DATA_ERR_ABORT)) | ||
| 629 | seq_puts(seq, ",data_err=abort"); | ||
| 630 | |||
| 628 | ext3_show_quota_options(seq, sb); | 631 | ext3_show_quota_options(seq, sb); |
| 629 | 632 | ||
| 630 | return 0; | 633 | return 0; |
| @@ -754,6 +757,7 @@ enum { | |||
| 754 | Opt_reservation, Opt_noreservation, Opt_noload, Opt_nobh, Opt_bh, | 757 | Opt_reservation, Opt_noreservation, Opt_noload, Opt_nobh, Opt_bh, |
| 755 | Opt_commit, Opt_journal_update, Opt_journal_inum, Opt_journal_dev, | 758 | Opt_commit, Opt_journal_update, Opt_journal_inum, Opt_journal_dev, |
| 756 | Opt_abort, Opt_data_journal, Opt_data_ordered, Opt_data_writeback, | 759 | Opt_abort, Opt_data_journal, Opt_data_ordered, Opt_data_writeback, |
| 760 | Opt_data_err_abort, Opt_data_err_ignore, | ||
| 757 | Opt_usrjquota, Opt_grpjquota, Opt_offusrjquota, Opt_offgrpjquota, | 761 | Opt_usrjquota, Opt_grpjquota, Opt_offusrjquota, Opt_offgrpjquota, |
| 758 | Opt_jqfmt_vfsold, Opt_jqfmt_vfsv0, Opt_quota, Opt_noquota, | 762 | Opt_jqfmt_vfsold, Opt_jqfmt_vfsv0, Opt_quota, Opt_noquota, |
| 759 | Opt_ignore, Opt_barrier, Opt_err, Opt_resize, Opt_usrquota, | 763 | Opt_ignore, Opt_barrier, Opt_err, Opt_resize, Opt_usrquota, |
| @@ -796,6 +800,8 @@ static const match_table_t tokens = { | |||
| 796 | {Opt_data_journal, "data=journal"}, | 800 | {Opt_data_journal, "data=journal"}, |
| 797 | {Opt_data_ordered, "data=ordered"}, | 801 | {Opt_data_ordered, "data=ordered"}, |
| 798 | {Opt_data_writeback, "data=writeback"}, | 802 | {Opt_data_writeback, "data=writeback"}, |
| 803 | {Opt_data_err_abort, "data_err=abort"}, | ||
| 804 | {Opt_data_err_ignore, "data_err=ignore"}, | ||
| 799 | {Opt_offusrjquota, "usrjquota="}, | 805 | {Opt_offusrjquota, "usrjquota="}, |
| 800 | {Opt_usrjquota, "usrjquota=%s"}, | 806 | {Opt_usrjquota, "usrjquota=%s"}, |
| 801 | {Opt_offgrpjquota, "grpjquota="}, | 807 | {Opt_offgrpjquota, "grpjquota="}, |
| @@ -1011,6 +1017,12 @@ static int parse_options (char *options, struct super_block *sb, | |||
| 1011 | sbi->s_mount_opt |= data_opt; | 1017 | sbi->s_mount_opt |= data_opt; |
| 1012 | } | 1018 | } |
| 1013 | break; | 1019 | break; |
| 1020 | case Opt_data_err_abort: | ||
| 1021 | set_opt(sbi->s_mount_opt, DATA_ERR_ABORT); | ||
| 1022 | break; | ||
| 1023 | case Opt_data_err_ignore: | ||
| 1024 | clear_opt(sbi->s_mount_opt, DATA_ERR_ABORT); | ||
| 1025 | break; | ||
| 1014 | #ifdef CONFIG_QUOTA | 1026 | #ifdef CONFIG_QUOTA |
| 1015 | case Opt_usrjquota: | 1027 | case Opt_usrjquota: |
| 1016 | qtype = USRQUOTA; | 1028 | qtype = USRQUOTA; |
| @@ -1986,6 +1998,10 @@ static void ext3_init_journal_params(struct super_block *sb, journal_t *journal) | |||
| 1986 | journal->j_flags |= JFS_BARRIER; | 1998 | journal->j_flags |= JFS_BARRIER; |
| 1987 | else | 1999 | else |
| 1988 | journal->j_flags &= ~JFS_BARRIER; | 2000 | journal->j_flags &= ~JFS_BARRIER; |
| 2001 | if (test_opt(sb, DATA_ERR_ABORT)) | ||
| 2002 | journal->j_flags |= JFS_ABORT_ON_SYNCDATA_ERR; | ||
| 2003 | else | ||
| 2004 | journal->j_flags &= ~JFS_ABORT_ON_SYNCDATA_ERR; | ||
| 1989 | spin_unlock(&journal->j_state_lock); | 2005 | spin_unlock(&journal->j_state_lock); |
| 1990 | } | 2006 | } |
| 1991 | 2007 | ||
diff --git a/fs/ext4/Kconfig b/fs/ext4/Kconfig new file mode 100644 index 00000000000..7505482a08f --- /dev/null +++ b/fs/ext4/Kconfig | |||
| @@ -0,0 +1,79 @@ | |||
| 1 | config EXT4_FS | ||
| 2 | tristate "The Extended 4 (ext4) filesystem" | ||
| 3 | select JBD2 | ||
| 4 | select CRC16 | ||
| 5 | help | ||
| 6 | This is the next generation of the ext3 filesystem. | ||
| 7 | |||
| 8 | Unlike the change from ext2 filesystem to ext3 filesystem, | ||
| 9 | the on-disk format of ext4 is not forwards compatible with | ||
| 10 | ext3; it is based on extent maps and it supports 48-bit | ||
| 11 | physical block numbers. The ext4 filesystem also supports delayed | ||
| 12 | allocation, persistent preallocation, high resolution time stamps, | ||
| 13 | and a number of other features to improve performance and speed | ||
| 14 | up fsck time. For more information, please see the web pages at | ||
| 15 | http://ext4.wiki.kernel.org. | ||
| 16 | |||
| 17 | The ext4 filesystem will support mounting an ext3 | ||
| 18 | filesystem; while there will be some performance gains from | ||
| 19 | the delayed allocation and inode table readahead, the best | ||
| 20 | performance gains will require enabling ext4 features in the | ||
| 21 | filesystem, or formating a new filesystem as an ext4 | ||
| 22 | filesystem initially. | ||
| 23 | |||
| 24 | To compile this file system support as a module, choose M here. The | ||
| 25 | module will be called ext4. | ||
| 26 | |||
| 27 | If unsure, say N. | ||
| 28 | |||
| 29 | config EXT4DEV_COMPAT | ||
| 30 | bool "Enable ext4dev compatibility" | ||
| 31 | depends on EXT4_FS | ||
| 32 | help | ||
| 33 | Starting with 2.6.28, the name of the ext4 filesystem was | ||
| 34 | renamed from ext4dev to ext4. Unfortunately there are some | ||
| 35 | legacy userspace programs (such as klibc's fstype) have | ||
| 36 | "ext4dev" hardcoded. | ||
| 37 | |||
| 38 | To enable backwards compatibility so that systems that are | ||
| 39 | still expecting to mount ext4 filesystems using ext4dev, | ||
| 40 | chose Y here. This feature will go away by 2.6.31, so | ||
| 41 | please arrange to get your userspace programs fixed! | ||
| 42 | |||
| 43 | config EXT4_FS_XATTR | ||
| 44 | bool "Ext4 extended attributes" | ||
| 45 | depends on EXT4_FS | ||
| 46 | default y | ||
| 47 | help | ||
| 48 | Extended attributes are name:value pairs associated with inodes by | ||
| 49 | the kernel or by users (see the attr(5) manual page, or visit | ||
| 50 | <http://acl.bestbits.at/> for details). | ||
| 51 | |||
| 52 | If unsure, say N. | ||
| 53 | |||
| 54 | You need this for POSIX ACL support on ext4. | ||
| 55 | |||
| 56 | config EXT4_FS_POSIX_ACL | ||
| 57 | bool "Ext4 POSIX Access Control Lists" | ||
| 58 | depends on EXT4_FS_XATTR | ||
| 59 | select FS_POSIX_ACL | ||
| 60 | help | ||
| 61 | POSIX Access Control Lists (ACLs) support permissions for users and | ||
| 62 | groups beyond the owner/group/world scheme. | ||
| 63 | |||
| 64 | To learn more about Access Control Lists, visit the POSIX ACLs for | ||
| 65 | Linux website <http://acl.bestbits.at/>. | ||
| 66 | |||
| 67 | If you don't know what Access Control Lists are, say N | ||
| 68 | |||
| 69 | config EXT4_FS_SECURITY | ||
| 70 | bool "Ext4 Security Labels" | ||
| 71 | depends on EXT4_FS_XATTR | ||
| 72 | help | ||
| 73 | Security labels support alternative access control models | ||
| 74 | implemented by security modules like SELinux. This option | ||
| 75 | enables an extended attribute handler for file security | ||
| 76 | labels in the ext4 filesystem. | ||
| 77 | |||
| 78 | If you are not using a security module that requires using | ||
| 79 | extended attributes for file security labels, say N. | ||
diff --git a/fs/fuse/file.c b/fs/fuse/file.c index 2bada6bbc31..34930a964b8 100644 --- a/fs/fuse/file.c +++ b/fs/fuse/file.c | |||
| @@ -101,6 +101,8 @@ void fuse_finish_open(struct inode *inode, struct file *file, | |||
| 101 | file->f_op = &fuse_direct_io_file_operations; | 101 | file->f_op = &fuse_direct_io_file_operations; |
| 102 | if (!(outarg->open_flags & FOPEN_KEEP_CACHE)) | 102 | if (!(outarg->open_flags & FOPEN_KEEP_CACHE)) |
| 103 | invalidate_inode_pages2(inode->i_mapping); | 103 | invalidate_inode_pages2(inode->i_mapping); |
| 104 | if (outarg->open_flags & FOPEN_NONSEEKABLE) | ||
| 105 | nonseekable_open(inode, file); | ||
| 104 | ff->fh = outarg->fh; | 106 | ff->fh = outarg->fh; |
| 105 | file->private_data = fuse_file_get(ff); | 107 | file->private_data = fuse_file_get(ff); |
| 106 | } | 108 | } |
| @@ -1448,6 +1450,9 @@ static loff_t fuse_file_llseek(struct file *file, loff_t offset, int origin) | |||
| 1448 | mutex_lock(&inode->i_mutex); | 1450 | mutex_lock(&inode->i_mutex); |
| 1449 | switch (origin) { | 1451 | switch (origin) { |
| 1450 | case SEEK_END: | 1452 | case SEEK_END: |
| 1453 | retval = fuse_update_attributes(inode, NULL, file, NULL); | ||
| 1454 | if (retval) | ||
| 1455 | return retval; | ||
| 1451 | offset += i_size_read(inode); | 1456 | offset += i_size_read(inode); |
| 1452 | break; | 1457 | break; |
| 1453 | case SEEK_CUR: | 1458 | case SEEK_CUR: |
diff --git a/fs/fuse/fuse_i.h b/fs/fuse/fuse_i.h index 3a876076bdd..35accfdd747 100644 --- a/fs/fuse/fuse_i.h +++ b/fs/fuse/fuse_i.h | |||
| @@ -6,6 +6,9 @@ | |||
| 6 | See the file COPYING. | 6 | See the file COPYING. |
| 7 | */ | 7 | */ |
| 8 | 8 | ||
| 9 | #ifndef _FS_FUSE_I_H | ||
| 10 | #define _FS_FUSE_I_H | ||
| 11 | |||
| 9 | #include <linux/fuse.h> | 12 | #include <linux/fuse.h> |
| 10 | #include <linux/fs.h> | 13 | #include <linux/fs.h> |
| 11 | #include <linux/mount.h> | 14 | #include <linux/mount.h> |
| @@ -655,3 +658,5 @@ void fuse_set_nowrite(struct inode *inode); | |||
| 655 | void fuse_release_nowrite(struct inode *inode); | 658 | void fuse_release_nowrite(struct inode *inode); |
| 656 | 659 | ||
| 657 | u64 fuse_get_attr_version(struct fuse_conn *fc); | 660 | u64 fuse_get_attr_version(struct fuse_conn *fc); |
| 661 | |||
| 662 | #endif /* _FS_FUSE_I_H */ | ||
diff --git a/fs/fuse/inode.c b/fs/fuse/inode.c index 6a84388cacf..54b1f0e1ef5 100644 --- a/fs/fuse/inode.c +++ b/fs/fuse/inode.c | |||
| @@ -865,7 +865,7 @@ static int fuse_fill_super(struct super_block *sb, void *data, int silent) | |||
| 865 | if (is_bdev) { | 865 | if (is_bdev) { |
| 866 | fc->destroy_req = fuse_request_alloc(); | 866 | fc->destroy_req = fuse_request_alloc(); |
| 867 | if (!fc->destroy_req) | 867 | if (!fc->destroy_req) |
| 868 | goto err_put_root; | 868 | goto err_free_init_req; |
| 869 | } | 869 | } |
| 870 | 870 | ||
| 871 | mutex_lock(&fuse_mutex); | 871 | mutex_lock(&fuse_mutex); |
| @@ -895,6 +895,7 @@ static int fuse_fill_super(struct super_block *sb, void *data, int silent) | |||
| 895 | 895 | ||
| 896 | err_unlock: | 896 | err_unlock: |
| 897 | mutex_unlock(&fuse_mutex); | 897 | mutex_unlock(&fuse_mutex); |
| 898 | err_free_init_req: | ||
| 898 | fuse_request_free(init_req); | 899 | fuse_request_free(init_req); |
| 899 | err_put_root: | 900 | err_put_root: |
| 900 | dput(root_dentry); | 901 | dput(root_dentry); |
diff --git a/fs/hfsplus/extents.c b/fs/hfsplus/extents.c index fec8f61227f..0022eec63cd 100644 --- a/fs/hfsplus/extents.c +++ b/fs/hfsplus/extents.c | |||
| @@ -199,6 +199,9 @@ int hfsplus_get_block(struct inode *inode, sector_t iblock, | |||
| 199 | goto done; | 199 | goto done; |
| 200 | } | 200 | } |
| 201 | 201 | ||
| 202 | if (inode->i_ino == HFSPLUS_EXT_CNID) | ||
| 203 | return -EIO; | ||
| 204 | |||
| 202 | mutex_lock(&HFSPLUS_I(inode).extents_lock); | 205 | mutex_lock(&HFSPLUS_I(inode).extents_lock); |
| 203 | res = hfsplus_ext_read_extent(inode, ablock); | 206 | res = hfsplus_ext_read_extent(inode, ablock); |
| 204 | if (!res) { | 207 | if (!res) { |
diff --git a/fs/hfsplus/inode.c b/fs/hfsplus/inode.c index b085d64a2b6..963be644297 100644 --- a/fs/hfsplus/inode.c +++ b/fs/hfsplus/inode.c | |||
| @@ -254,6 +254,8 @@ static int hfsplus_file_open(struct inode *inode, struct file *file) | |||
| 254 | { | 254 | { |
| 255 | if (HFSPLUS_IS_RSRC(inode)) | 255 | if (HFSPLUS_IS_RSRC(inode)) |
| 256 | inode = HFSPLUS_I(inode).rsrc_inode; | 256 | inode = HFSPLUS_I(inode).rsrc_inode; |
| 257 | if (!(file->f_flags & O_LARGEFILE) && i_size_read(inode) > MAX_NON_LFS) | ||
| 258 | return -EOVERFLOW; | ||
| 257 | atomic_inc(&HFSPLUS_I(inode).opencnt); | 259 | atomic_inc(&HFSPLUS_I(inode).opencnt); |
| 258 | return 0; | 260 | return 0; |
| 259 | } | 261 | } |
diff --git a/fs/jbd/Kconfig b/fs/jbd/Kconfig new file mode 100644 index 00000000000..4e28beeed15 --- /dev/null +++ b/fs/jbd/Kconfig | |||
| @@ -0,0 +1,30 @@ | |||
| 1 | config JBD | ||
| 2 | tristate | ||
| 3 | help | ||
| 4 | This is a generic journalling layer for block devices. It is | ||
| 5 | currently used by the ext3 file system, but it could also be | ||
| 6 | used to add journal support to other file systems or block | ||
| 7 | devices such as RAID or LVM. | ||
| 8 | |||
| 9 | If you are using the ext3 file system, you need to say Y here. | ||
| 10 | If you are not using ext3 then you will probably want to say N. | ||
| 11 | |||
| 12 | To compile this device as a module, choose M here: the module will be | ||
| 13 | called jbd. If you are compiling ext3 into the kernel, you | ||
| 14 | cannot compile this code as a module. | ||
| 15 | |||
| 16 | config JBD_DEBUG | ||
| 17 | bool "JBD (ext3) debugging support" | ||
| 18 | depends on JBD && DEBUG_FS | ||
| 19 | help | ||
| 20 | If you are using the ext3 journaled file system (or potentially any | ||
| 21 | other file system/device using JBD), this option allows you to | ||
| 22 | enable debugging output while the system is running, in order to | ||
| 23 | help track down any problems you are having. By default the | ||
| 24 | debugging output will be turned off. | ||
| 25 | |||
| 26 | If you select Y here, then you will be able to turn on debugging | ||
| 27 | with "echo N > /sys/kernel/debug/jbd/jbd-debug", where N is a | ||
| 28 | number between 1 and 5, the higher the number, the more debugging | ||
| 29 | output is generated. To turn debugging off again, do | ||
| 30 | "echo 0 > /sys/kernel/debug/jbd/jbd-debug". | ||
diff --git a/fs/jbd/commit.c b/fs/jbd/commit.c index ae08c057e75..25719d902c5 100644 --- a/fs/jbd/commit.c +++ b/fs/jbd/commit.c | |||
| @@ -482,6 +482,8 @@ void journal_commit_transaction(journal_t *journal) | |||
| 482 | printk(KERN_WARNING | 482 | printk(KERN_WARNING |
| 483 | "JBD: Detected IO errors while flushing file data " | 483 | "JBD: Detected IO errors while flushing file data " |
| 484 | "on %s\n", bdevname(journal->j_fs_dev, b)); | 484 | "on %s\n", bdevname(journal->j_fs_dev, b)); |
| 485 | if (journal->j_flags & JFS_ABORT_ON_SYNCDATA_ERR) | ||
| 486 | journal_abort(journal, err); | ||
| 485 | err = 0; | 487 | err = 0; |
| 486 | } | 488 | } |
| 487 | 489 | ||
| @@ -518,9 +520,10 @@ void journal_commit_transaction(journal_t *journal) | |||
| 518 | jh = commit_transaction->t_buffers; | 520 | jh = commit_transaction->t_buffers; |
| 519 | 521 | ||
| 520 | /* If we're in abort mode, we just un-journal the buffer and | 522 | /* If we're in abort mode, we just un-journal the buffer and |
| 521 | release it for background writing. */ | 523 | release it. */ |
| 522 | 524 | ||
| 523 | if (is_journal_aborted(journal)) { | 525 | if (is_journal_aborted(journal)) { |
| 526 | clear_buffer_jbddirty(jh2bh(jh)); | ||
| 524 | JBUFFER_TRACE(jh, "journal is aborting: refile"); | 527 | JBUFFER_TRACE(jh, "journal is aborting: refile"); |
| 525 | journal_refile_buffer(journal, jh); | 528 | journal_refile_buffer(journal, jh); |
| 526 | /* If that was the last one, we need to clean up | 529 | /* If that was the last one, we need to clean up |
| @@ -762,6 +765,9 @@ wait_for_iobuf: | |||
| 762 | /* AKPM: bforget here */ | 765 | /* AKPM: bforget here */ |
| 763 | } | 766 | } |
| 764 | 767 | ||
| 768 | if (err) | ||
| 769 | journal_abort(journal, err); | ||
| 770 | |||
| 765 | jbd_debug(3, "JBD: commit phase 6\n"); | 771 | jbd_debug(3, "JBD: commit phase 6\n"); |
| 766 | 772 | ||
| 767 | if (journal_write_commit_record(journal, commit_transaction)) | 773 | if (journal_write_commit_record(journal, commit_transaction)) |
| @@ -852,6 +858,8 @@ restart_loop: | |||
| 852 | if (buffer_jbddirty(bh)) { | 858 | if (buffer_jbddirty(bh)) { |
| 853 | JBUFFER_TRACE(jh, "add to new checkpointing trans"); | 859 | JBUFFER_TRACE(jh, "add to new checkpointing trans"); |
| 854 | __journal_insert_checkpoint(jh, commit_transaction); | 860 | __journal_insert_checkpoint(jh, commit_transaction); |
| 861 | if (is_journal_aborted(journal)) | ||
| 862 | clear_buffer_jbddirty(bh); | ||
| 855 | JBUFFER_TRACE(jh, "refile for checkpoint writeback"); | 863 | JBUFFER_TRACE(jh, "refile for checkpoint writeback"); |
| 856 | __journal_refile_buffer(jh); | 864 | __journal_refile_buffer(jh); |
| 857 | jbd_unlock_bh_state(bh); | 865 | jbd_unlock_bh_state(bh); |
diff --git a/fs/jbd/transaction.c b/fs/jbd/transaction.c index 0540ca27a44..d15cd6e7251 100644 --- a/fs/jbd/transaction.c +++ b/fs/jbd/transaction.c | |||
| @@ -954,9 +954,10 @@ int journal_dirty_data(handle_t *handle, struct buffer_head *bh) | |||
| 954 | journal_t *journal = handle->h_transaction->t_journal; | 954 | journal_t *journal = handle->h_transaction->t_journal; |
| 955 | int need_brelse = 0; | 955 | int need_brelse = 0; |
| 956 | struct journal_head *jh; | 956 | struct journal_head *jh; |
| 957 | int ret = 0; | ||
| 957 | 958 | ||
| 958 | if (is_handle_aborted(handle)) | 959 | if (is_handle_aborted(handle)) |
| 959 | return 0; | 960 | return ret; |
| 960 | 961 | ||
| 961 | jh = journal_add_journal_head(bh); | 962 | jh = journal_add_journal_head(bh); |
| 962 | JBUFFER_TRACE(jh, "entry"); | 963 | JBUFFER_TRACE(jh, "entry"); |
| @@ -1067,7 +1068,16 @@ int journal_dirty_data(handle_t *handle, struct buffer_head *bh) | |||
| 1067 | time if it is redirtied */ | 1068 | time if it is redirtied */ |
| 1068 | } | 1069 | } |
| 1069 | 1070 | ||
| 1070 | /* journal_clean_data_list() may have got there first */ | 1071 | /* |
| 1072 | * We cannot remove the buffer with io error from the | ||
| 1073 | * committing transaction, because otherwise it would | ||
| 1074 | * miss the error and the commit would not abort. | ||
| 1075 | */ | ||
| 1076 | if (unlikely(!buffer_uptodate(bh))) { | ||
| 1077 | ret = -EIO; | ||
| 1078 | goto no_journal; | ||
| 1079 | } | ||
| 1080 | |||
| 1071 | if (jh->b_transaction != NULL) { | 1081 | if (jh->b_transaction != NULL) { |
| 1072 | JBUFFER_TRACE(jh, "unfile from commit"); | 1082 | JBUFFER_TRACE(jh, "unfile from commit"); |
| 1073 | __journal_temp_unlink_buffer(jh); | 1083 | __journal_temp_unlink_buffer(jh); |
| @@ -1108,7 +1118,7 @@ no_journal: | |||
| 1108 | } | 1118 | } |
| 1109 | JBUFFER_TRACE(jh, "exit"); | 1119 | JBUFFER_TRACE(jh, "exit"); |
| 1110 | journal_put_journal_head(jh); | 1120 | journal_put_journal_head(jh); |
| 1111 | return 0; | 1121 | return ret; |
| 1112 | } | 1122 | } |
| 1113 | 1123 | ||
| 1114 | /** | 1124 | /** |
diff --git a/fs/jbd2/Kconfig b/fs/jbd2/Kconfig new file mode 100644 index 00000000000..f32f346f4b0 --- /dev/null +++ b/fs/jbd2/Kconfig | |||
| @@ -0,0 +1,33 @@ | |||
| 1 | config JBD2 | ||
| 2 | tristate | ||
| 3 | select CRC32 | ||
| 4 | help | ||
| 5 | This is a generic journaling layer for block devices that support | ||
| 6 | both 32-bit and 64-bit block numbers. It is currently used by | ||
| 7 | the ext4 and OCFS2 filesystems, but it could also be used to add | ||
| 8 | journal support to other file systems or block devices such | ||
| 9 | as RAID or LVM. | ||
| 10 | |||
| 11 | If you are using ext4 or OCFS2, you need to say Y here. | ||
| 12 | If you are not using ext4 or OCFS2 then you will | ||
| 13 | probably want to say N. | ||
| 14 | |||
| 15 | To compile this device as a module, choose M here. The module will be | ||
| 16 | called jbd2. If you are compiling ext4 or OCFS2 into the kernel, | ||
| 17 | you cannot compile this code as a module. | ||
| 18 | |||
| 19 | config JBD2_DEBUG | ||
| 20 | bool "JBD2 (ext4) debugging support" | ||
| 21 | depends on JBD2 && DEBUG_FS | ||
| 22 | help | ||
| 23 | If you are using the ext4 journaled file system (or | ||
| 24 | potentially any other filesystem/device using JBD2), this option | ||
| 25 | allows you to enable debugging output while the system is running, | ||
| 26 | in order to help track down any problems you are having. | ||
| 27 | By default, the debugging output will be turned off. | ||
| 28 | |||
| 29 | If you select Y here, then you will be able to turn on debugging | ||
| 30 | with "echo N > /sys/kernel/debug/jbd2/jbd2-debug", where N is a | ||
| 31 | number between 1 and 5. The higher the number, the more debugging | ||
| 32 | output is generated. To turn debugging off again, do | ||
| 33 | "echo 0 > /sys/kernel/debug/jbd2/jbd2-debug". | ||
diff --git a/fs/jffs2/Kconfig b/fs/jffs2/Kconfig new file mode 100644 index 00000000000..6ae169cd8fa --- /dev/null +++ b/fs/jffs2/Kconfig | |||
| @@ -0,0 +1,188 @@ | |||
| 1 | config JFFS2_FS | ||
| 2 | tristate "Journalling Flash File System v2 (JFFS2) support" | ||
| 3 | select CRC32 | ||
| 4 | depends on MTD | ||
| 5 | help | ||
| 6 | JFFS2 is the second generation of the Journalling Flash File System | ||
| 7 | for use on diskless embedded devices. It provides improved wear | ||
| 8 | levelling, compression and support for hard links. You cannot use | ||
| 9 | this on normal block devices, only on 'MTD' devices. | ||
| 10 | |||
| 11 | Further information on the design and implementation of JFFS2 is | ||
| 12 | available at <http://sources.redhat.com/jffs2/>. | ||
| 13 | |||
| 14 | config JFFS2_FS_DEBUG | ||
| 15 | int "JFFS2 debugging verbosity (0 = quiet, 2 = noisy)" | ||
| 16 | depends on JFFS2_FS | ||
| 17 | default "0" | ||
| 18 | help | ||
| 19 | This controls the amount of debugging messages produced by the JFFS2 | ||
| 20 | code. Set it to zero for use in production systems. For evaluation, | ||
| 21 | testing and debugging, it's advisable to set it to one. This will | ||
| 22 | enable a few assertions and will print debugging messages at the | ||
| 23 | KERN_DEBUG loglevel, where they won't normally be visible. Level 2 | ||
| 24 | is unlikely to be useful - it enables extra debugging in certain | ||
| 25 | areas which at one point needed debugging, but when the bugs were | ||
| 26 | located and fixed, the detailed messages were relegated to level 2. | ||
| 27 | |||
| 28 | If reporting bugs, please try to have available a full dump of the | ||
| 29 | messages at debug level 1 while the misbehaviour was occurring. | ||
| 30 | |||
| 31 | config JFFS2_FS_WRITEBUFFER | ||
| 32 | bool "JFFS2 write-buffering support" | ||
| 33 | depends on JFFS2_FS | ||
| 34 | default y | ||
| 35 | help | ||
| 36 | This enables the write-buffering support in JFFS2. | ||
| 37 | |||
| 38 | This functionality is required to support JFFS2 on the following | ||
| 39 | types of flash devices: | ||
| 40 | - NAND flash | ||
| 41 | - NOR flash with transparent ECC | ||
| 42 | - DataFlash | ||
| 43 | |||
| 44 | config JFFS2_FS_WBUF_VERIFY | ||
| 45 | bool "Verify JFFS2 write-buffer reads" | ||
| 46 | depends on JFFS2_FS_WRITEBUFFER | ||
| 47 | default n | ||
| 48 | help | ||
| 49 | This causes JFFS2 to read back every page written through the | ||
| 50 | write-buffer, and check for errors. | ||
| 51 | |||
| 52 | config JFFS2_SUMMARY | ||
| 53 | bool "JFFS2 summary support (EXPERIMENTAL)" | ||
| 54 | depends on JFFS2_FS && EXPERIMENTAL | ||
| 55 | default n | ||
| 56 | help | ||
| 57 | This feature makes it possible to use summary information | ||
| 58 | for faster filesystem mount. | ||
| 59 | |||
| 60 | The summary information can be inserted into a filesystem image | ||
| 61 | by the utility 'sumtool'. | ||
| 62 | |||
| 63 | If unsure, say 'N'. | ||
| 64 | |||
| 65 | config JFFS2_FS_XATTR | ||
| 66 | bool "JFFS2 XATTR support (EXPERIMENTAL)" | ||
| 67 | depends on JFFS2_FS && EXPERIMENTAL | ||
| 68 | default n | ||
| 69 | help | ||
| 70 | Extended attributes are name:value pairs associated with inodes by | ||
| 71 | the kernel or by users (see the attr(5) manual page, or visit | ||
| 72 | <http://acl.bestbits.at/> for details). | ||
| 73 | |||
| 74 | If unsure, say N. | ||
| 75 | |||
| 76 | config JFFS2_FS_POSIX_ACL | ||
| 77 | bool "JFFS2 POSIX Access Control Lists" | ||
| 78 | depends on JFFS2_FS_XATTR | ||
| 79 | default y | ||
| 80 | select FS_POSIX_ACL | ||
| 81 | help | ||
| 82 | Posix Access Control Lists (ACLs) support permissions for users and | ||
| 83 | groups beyond the owner/group/world scheme. | ||
| 84 | |||
| 85 | To learn more about Access Control Lists, visit the Posix ACLs for | ||
| 86 | Linux website <http://acl.bestbits.at/>. | ||
| 87 | |||
| 88 | If you don't know what Access Control Lists are, say N | ||
| 89 | |||
| 90 | config JFFS2_FS_SECURITY | ||
| 91 | bool "JFFS2 Security Labels" | ||
| 92 | depends on JFFS2_FS_XATTR | ||
| 93 | default y | ||
| 94 | help | ||
| 95 | Security labels support alternative access control models | ||
| 96 | implemented by security modules like SELinux. This option | ||
| 97 | enables an extended attribute handler for file security | ||
| 98 | labels in the jffs2 filesystem. | ||
| 99 | |||
| 100 | If you are not using a security module that requires using | ||
| 101 | extended attributes for file security labels, say N. | ||
| 102 | |||
| 103 | config JFFS2_COMPRESSION_OPTIONS | ||
| 104 | bool "Advanced compression options for JFFS2" | ||
| 105 | depends on JFFS2_FS | ||
| 106 | default n | ||
| 107 | help | ||
| 108 | Enabling this option allows you to explicitly choose which | ||
| 109 | compression modules, if any, are enabled in JFFS2. Removing | ||
| 110 | compressors can mean you cannot read existing file systems, | ||
| 111 | and enabling experimental compressors can mean that you | ||
| 112 | write a file system which cannot be read by a standard kernel. | ||
| 113 | |||
| 114 | If unsure, you should _definitely_ say 'N'. | ||
| 115 | |||
| 116 | config JFFS2_ZLIB | ||
| 117 | bool "JFFS2 ZLIB compression support" if JFFS2_COMPRESSION_OPTIONS | ||
| 118 | select ZLIB_INFLATE | ||
| 119 | select ZLIB_DEFLATE | ||
| 120 | depends on JFFS2_FS | ||
| 121 | default y | ||
| 122 | help | ||
| 123 | Zlib is designed to be a free, general-purpose, legally unencumbered, | ||
| 124 | lossless data-compression library for use on virtually any computer | ||
| 125 | hardware and operating system. See <http://www.gzip.org/zlib/> for | ||
| 126 | further information. | ||
| 127 | |||
| 128 | Say 'Y' if unsure. | ||
| 129 | |||
| 130 | config JFFS2_LZO | ||
| 131 | bool "JFFS2 LZO compression support" if JFFS2_COMPRESSION_OPTIONS | ||
| 132 | select LZO_COMPRESS | ||
| 133 | select LZO_DECOMPRESS | ||
| 134 | depends on JFFS2_FS | ||
| 135 | default n | ||
| 136 | help | ||
| 137 | minilzo-based compression. Generally works better than Zlib. | ||
| 138 | |||
| 139 | This feature was added in July, 2007. Say 'N' if you need | ||
| 140 | compatibility with older bootloaders or kernels. | ||
| 141 | |||
| 142 | config JFFS2_RTIME | ||
| 143 | bool "JFFS2 RTIME compression support" if JFFS2_COMPRESSION_OPTIONS | ||
| 144 | depends on JFFS2_FS | ||
| 145 | default y | ||
| 146 | help | ||
| 147 | Rtime does manage to recompress already-compressed data. Say 'Y' if unsure. | ||
| 148 | |||
| 149 | config JFFS2_RUBIN | ||
| 150 | bool "JFFS2 RUBIN compression support" if JFFS2_COMPRESSION_OPTIONS | ||
| 151 | depends on JFFS2_FS | ||
| 152 | default n | ||
| 153 | help | ||
| 154 | RUBINMIPS and DYNRUBIN compressors. Say 'N' if unsure. | ||
| 155 | |||
| 156 | choice | ||
| 157 | prompt "JFFS2 default compression mode" if JFFS2_COMPRESSION_OPTIONS | ||
| 158 | default JFFS2_CMODE_PRIORITY | ||
| 159 | depends on JFFS2_FS | ||
| 160 | help | ||
| 161 | You can set here the default compression mode of JFFS2 from | ||
| 162 | the available compression modes. Don't touch if unsure. | ||
| 163 | |||
| 164 | config JFFS2_CMODE_NONE | ||
| 165 | bool "no compression" | ||
| 166 | help | ||
| 167 | Uses no compression. | ||
| 168 | |||
| 169 | config JFFS2_CMODE_PRIORITY | ||
| 170 | bool "priority" | ||
| 171 | help | ||
| 172 | Tries the compressors in a predefined order and chooses the first | ||
| 173 | successful one. | ||
| 174 | |||
| 175 | config JFFS2_CMODE_SIZE | ||
| 176 | bool "size (EXPERIMENTAL)" | ||
| 177 | help | ||
| 178 | Tries all compressors and chooses the one which has the smallest | ||
| 179 | result. | ||
| 180 | |||
| 181 | config JFFS2_CMODE_FAVOURLZO | ||
| 182 | bool "Favour LZO" | ||
| 183 | help | ||
| 184 | Tries all compressors and chooses the one which has the smallest | ||
| 185 | result but gives some preference to LZO (which has faster | ||
| 186 | decompression) at the expense of size. | ||
| 187 | |||
| 188 | endchoice | ||
diff --git a/fs/jffs2/compr.c b/fs/jffs2/compr.c index 86739ee53b3..f25e70c1b51 100644 --- a/fs/jffs2/compr.c +++ b/fs/jffs2/compr.c | |||
| @@ -53,8 +53,8 @@ static int jffs2_is_best_compression(struct jffs2_compressor *this, | |||
| 53 | } | 53 | } |
| 54 | 54 | ||
| 55 | /* jffs2_compress: | 55 | /* jffs2_compress: |
| 56 | * @data: Pointer to uncompressed data | 56 | * @data_in: Pointer to uncompressed data |
| 57 | * @cdata: Pointer to returned pointer to buffer for compressed data | 57 | * @cpage_out: Pointer to returned pointer to buffer for compressed data |
| 58 | * @datalen: On entry, holds the amount of data available for compression. | 58 | * @datalen: On entry, holds the amount of data available for compression. |
| 59 | * On exit, expected to hold the amount of data actually compressed. | 59 | * On exit, expected to hold the amount of data actually compressed. |
| 60 | * @cdatalen: On entry, holds the amount of space available for compressed | 60 | * @cdatalen: On entry, holds the amount of space available for compressed |
diff --git a/fs/jffs2/dir.c b/fs/jffs2/dir.c index cd219ef5525..b1aaae823a5 100644 --- a/fs/jffs2/dir.c +++ b/fs/jffs2/dir.c | |||
| @@ -311,7 +311,7 @@ static int jffs2_symlink (struct inode *dir_i, struct dentry *dentry, const char | |||
| 311 | /* FIXME: If you care. We'd need to use frags for the target | 311 | /* FIXME: If you care. We'd need to use frags for the target |
| 312 | if it grows much more than this */ | 312 | if it grows much more than this */ |
| 313 | if (targetlen > 254) | 313 | if (targetlen > 254) |
| 314 | return -EINVAL; | 314 | return -ENAMETOOLONG; |
| 315 | 315 | ||
| 316 | ri = jffs2_alloc_raw_inode(); | 316 | ri = jffs2_alloc_raw_inode(); |
| 317 | 317 | ||
diff --git a/fs/jffs2/erase.c b/fs/jffs2/erase.c index dddb2a6c9e2..259461b910a 100644 --- a/fs/jffs2/erase.c +++ b/fs/jffs2/erase.c | |||
| @@ -68,7 +68,7 @@ static void jffs2_erase_block(struct jffs2_sb_info *c, | |||
| 68 | instr->len = c->sector_size; | 68 | instr->len = c->sector_size; |
| 69 | instr->callback = jffs2_erase_callback; | 69 | instr->callback = jffs2_erase_callback; |
| 70 | instr->priv = (unsigned long)(&instr[1]); | 70 | instr->priv = (unsigned long)(&instr[1]); |
| 71 | instr->fail_addr = 0xffffffff; | 71 | instr->fail_addr = MTD_FAIL_ADDR_UNKNOWN; |
| 72 | 72 | ||
| 73 | ((struct erase_priv_struct *)instr->priv)->jeb = jeb; | 73 | ((struct erase_priv_struct *)instr->priv)->jeb = jeb; |
| 74 | ((struct erase_priv_struct *)instr->priv)->c = c; | 74 | ((struct erase_priv_struct *)instr->priv)->c = c; |
| @@ -175,7 +175,7 @@ static void jffs2_erase_failed(struct jffs2_sb_info *c, struct jffs2_eraseblock | |||
| 175 | { | 175 | { |
| 176 | /* For NAND, if the failure did not occur at the device level for a | 176 | /* For NAND, if the failure did not occur at the device level for a |
| 177 | specific physical page, don't bother updating the bad block table. */ | 177 | specific physical page, don't bother updating the bad block table. */ |
| 178 | if (jffs2_cleanmarker_oob(c) && (bad_offset != 0xffffffff)) { | 178 | if (jffs2_cleanmarker_oob(c) && (bad_offset != MTD_FAIL_ADDR_UNKNOWN)) { |
| 179 | /* We had a device-level failure to erase. Let's see if we've | 179 | /* We had a device-level failure to erase. Let's see if we've |
| 180 | failed too many times. */ | 180 | failed too many times. */ |
| 181 | if (!jffs2_write_nand_badblock(c, jeb, bad_offset)) { | 181 | if (!jffs2_write_nand_badblock(c, jeb, bad_offset)) { |
diff --git a/fs/jffs2/fs.c b/fs/jffs2/fs.c index 086c4383022..249305d65d5 100644 --- a/fs/jffs2/fs.c +++ b/fs/jffs2/fs.c | |||
| @@ -207,6 +207,8 @@ int jffs2_statfs(struct dentry *dentry, struct kstatfs *buf) | |||
| 207 | buf->f_files = 0; | 207 | buf->f_files = 0; |
| 208 | buf->f_ffree = 0; | 208 | buf->f_ffree = 0; |
| 209 | buf->f_namelen = JFFS2_MAX_NAME_LEN; | 209 | buf->f_namelen = JFFS2_MAX_NAME_LEN; |
| 210 | buf->f_fsid.val[0] = JFFS2_SUPER_MAGIC; | ||
| 211 | buf->f_fsid.val[1] = c->mtd->index; | ||
| 210 | 212 | ||
| 211 | spin_lock(&c->erase_completion_lock); | 213 | spin_lock(&c->erase_completion_lock); |
| 212 | avail = c->dirty_size + c->free_size; | 214 | avail = c->dirty_size + c->free_size; |
| @@ -440,14 +442,14 @@ struct inode *jffs2_new_inode (struct inode *dir_i, int mode, struct jffs2_raw_i | |||
| 440 | 442 | ||
| 441 | memset(ri, 0, sizeof(*ri)); | 443 | memset(ri, 0, sizeof(*ri)); |
| 442 | /* Set OS-specific defaults for new inodes */ | 444 | /* Set OS-specific defaults for new inodes */ |
| 443 | ri->uid = cpu_to_je16(current->fsuid); | 445 | ri->uid = cpu_to_je16(current_fsuid()); |
| 444 | 446 | ||
| 445 | if (dir_i->i_mode & S_ISGID) { | 447 | if (dir_i->i_mode & S_ISGID) { |
| 446 | ri->gid = cpu_to_je16(dir_i->i_gid); | 448 | ri->gid = cpu_to_je16(dir_i->i_gid); |
| 447 | if (S_ISDIR(mode)) | 449 | if (S_ISDIR(mode)) |
| 448 | mode |= S_ISGID; | 450 | mode |= S_ISGID; |
| 449 | } else { | 451 | } else { |
| 450 | ri->gid = cpu_to_je16(current->fsgid); | 452 | ri->gid = cpu_to_je16(current_fsgid()); |
| 451 | } | 453 | } |
| 452 | 454 | ||
| 453 | /* POSIX ACLs have to be processed now, at least partly. | 455 | /* POSIX ACLs have to be processed now, at least partly. |
diff --git a/fs/jffs2/nodemgmt.c b/fs/jffs2/nodemgmt.c index a9bf9603c1b..0875b60b4bf 100644 --- a/fs/jffs2/nodemgmt.c +++ b/fs/jffs2/nodemgmt.c | |||
| @@ -261,6 +261,10 @@ static int jffs2_find_nextblock(struct jffs2_sb_info *c) | |||
| 261 | 261 | ||
| 262 | jffs2_sum_reset_collected(c->summary); /* reset collected summary */ | 262 | jffs2_sum_reset_collected(c->summary); /* reset collected summary */ |
| 263 | 263 | ||
| 264 | /* adjust write buffer offset, else we get a non contiguous write bug */ | ||
| 265 | if (!(c->wbuf_ofs % c->sector_size) && !c->wbuf_len) | ||
| 266 | c->wbuf_ofs = 0xffffffff; | ||
| 267 | |||
| 264 | D1(printk(KERN_DEBUG "jffs2_find_nextblock(): new nextblock = 0x%08x\n", c->nextblock->offset)); | 268 | D1(printk(KERN_DEBUG "jffs2_find_nextblock(): new nextblock = 0x%08x\n", c->nextblock->offset)); |
| 265 | 269 | ||
| 266 | return 0; | 270 | return 0; |
diff --git a/fs/jffs2/wbuf.c b/fs/jffs2/wbuf.c index 0e78b00035e..d9a721e6db7 100644 --- a/fs/jffs2/wbuf.c +++ b/fs/jffs2/wbuf.c | |||
| @@ -679,10 +679,7 @@ static int __jffs2_flush_wbuf(struct jffs2_sb_info *c, int pad) | |||
| 679 | 679 | ||
| 680 | memset(c->wbuf,0xff,c->wbuf_pagesize); | 680 | memset(c->wbuf,0xff,c->wbuf_pagesize); |
| 681 | /* adjust write buffer offset, else we get a non contiguous write bug */ | 681 | /* adjust write buffer offset, else we get a non contiguous write bug */ |
| 682 | if (SECTOR_ADDR(c->wbuf_ofs) == SECTOR_ADDR(c->wbuf_ofs+c->wbuf_pagesize)) | 682 | c->wbuf_ofs += c->wbuf_pagesize; |
| 683 | c->wbuf_ofs += c->wbuf_pagesize; | ||
| 684 | else | ||
| 685 | c->wbuf_ofs = 0xffffffff; | ||
| 686 | c->wbuf_len = 0; | 683 | c->wbuf_len = 0; |
| 687 | return 0; | 684 | return 0; |
| 688 | } | 685 | } |
diff --git a/fs/nfs/callback.c b/fs/nfs/callback.c index 6a09760c596..c2e9cfd9e5a 100644 --- a/fs/nfs/callback.c +++ b/fs/nfs/callback.c | |||
| @@ -40,6 +40,16 @@ unsigned short nfs_callback_tcpport; | |||
| 40 | static const int nfs_set_port_min = 0; | 40 | static const int nfs_set_port_min = 0; |
| 41 | static const int nfs_set_port_max = 65535; | 41 | static const int nfs_set_port_max = 65535; |
| 42 | 42 | ||
| 43 | /* | ||
| 44 | * If the kernel has IPv6 support available, always listen for | ||
| 45 | * both AF_INET and AF_INET6 requests. | ||
| 46 | */ | ||
| 47 | #if defined(CONFIG_IPV6) || defined(CONFIG_IPV6_MODULE) | ||
| 48 | static const sa_family_t nfs_callback_family = AF_INET6; | ||
| 49 | #else | ||
| 50 | static const sa_family_t nfs_callback_family = AF_INET; | ||
| 51 | #endif | ||
| 52 | |||
| 43 | static int param_set_port(const char *val, struct kernel_param *kp) | 53 | static int param_set_port(const char *val, struct kernel_param *kp) |
| 44 | { | 54 | { |
| 45 | char *endp; | 55 | char *endp; |
| @@ -106,7 +116,7 @@ int nfs_callback_up(void) | |||
| 106 | if (nfs_callback_info.users++ || nfs_callback_info.task != NULL) | 116 | if (nfs_callback_info.users++ || nfs_callback_info.task != NULL) |
| 107 | goto out; | 117 | goto out; |
| 108 | serv = svc_create(&nfs4_callback_program, NFS4_CALLBACK_BUFSIZE, | 118 | serv = svc_create(&nfs4_callback_program, NFS4_CALLBACK_BUFSIZE, |
| 109 | AF_INET, NULL); | 119 | nfs_callback_family, NULL); |
| 110 | ret = -ENOMEM; | 120 | ret = -ENOMEM; |
| 111 | if (!serv) | 121 | if (!serv) |
| 112 | goto out_err; | 122 | goto out_err; |
| @@ -116,7 +126,8 @@ int nfs_callback_up(void) | |||
| 116 | if (ret <= 0) | 126 | if (ret <= 0) |
| 117 | goto out_err; | 127 | goto out_err; |
| 118 | nfs_callback_tcpport = ret; | 128 | nfs_callback_tcpport = ret; |
| 119 | dprintk("Callback port = 0x%x\n", nfs_callback_tcpport); | 129 | dprintk("NFS: Callback listener port = %u (af %u)\n", |
| 130 | nfs_callback_tcpport, nfs_callback_family); | ||
| 120 | 131 | ||
| 121 | nfs_callback_info.rqst = svc_prepare_thread(serv, &serv->sv_pools[0]); | 132 | nfs_callback_info.rqst = svc_prepare_thread(serv, &serv->sv_pools[0]); |
| 122 | if (IS_ERR(nfs_callback_info.rqst)) { | 133 | if (IS_ERR(nfs_callback_info.rqst)) { |
| @@ -149,8 +160,8 @@ out: | |||
| 149 | mutex_unlock(&nfs_callback_mutex); | 160 | mutex_unlock(&nfs_callback_mutex); |
| 150 | return ret; | 161 | return ret; |
| 151 | out_err: | 162 | out_err: |
| 152 | dprintk("Couldn't create callback socket or server thread; err = %d\n", | 163 | dprintk("NFS: Couldn't create callback socket or server thread; " |
| 153 | ret); | 164 | "err = %d\n", ret); |
| 154 | nfs_callback_info.users--; | 165 | nfs_callback_info.users--; |
| 155 | goto out; | 166 | goto out; |
| 156 | } | 167 | } |
diff --git a/fs/nfs/dir.c b/fs/nfs/dir.c index 2ab70d46ecb..efdba2e802d 100644 --- a/fs/nfs/dir.c +++ b/fs/nfs/dir.c | |||
| @@ -1517,7 +1517,7 @@ static int nfs_symlink(struct inode *dir, struct dentry *dentry, const char *sym | |||
| 1517 | if (!add_to_page_cache(page, dentry->d_inode->i_mapping, 0, | 1517 | if (!add_to_page_cache(page, dentry->d_inode->i_mapping, 0, |
| 1518 | GFP_KERNEL)) { | 1518 | GFP_KERNEL)) { |
| 1519 | pagevec_add(&lru_pvec, page); | 1519 | pagevec_add(&lru_pvec, page); |
| 1520 | pagevec_lru_add(&lru_pvec); | 1520 | pagevec_lru_add_file(&lru_pvec); |
| 1521 | SetPageUptodate(page); | 1521 | SetPageUptodate(page); |
| 1522 | unlock_page(page); | 1522 | unlock_page(page); |
| 1523 | } else | 1523 | } else |
diff --git a/fs/nfs/nfs4proc.c b/fs/nfs/nfs4proc.c index c910413eaec..83e700a2b0c 100644 --- a/fs/nfs/nfs4proc.c +++ b/fs/nfs/nfs4proc.c | |||
| @@ -1659,8 +1659,10 @@ nfs4_proc_setattr(struct dentry *dentry, struct nfs_fattr *fattr, | |||
| 1659 | struct nfs_open_context *ctx; | 1659 | struct nfs_open_context *ctx; |
| 1660 | 1660 | ||
| 1661 | ctx = nfs_file_open_context(sattr->ia_file); | 1661 | ctx = nfs_file_open_context(sattr->ia_file); |
| 1662 | cred = ctx->cred; | 1662 | if (ctx) { |
| 1663 | state = ctx->state; | 1663 | cred = ctx->cred; |
| 1664 | state = ctx->state; | ||
| 1665 | } | ||
| 1664 | } | 1666 | } |
| 1665 | 1667 | ||
| 1666 | status = nfs4_do_setattr(inode, cred, fattr, sattr, state); | 1668 | status = nfs4_do_setattr(inode, cred, fattr, sattr, state); |
diff --git a/fs/nfs/super.c b/fs/nfs/super.c index 8b28b95c9e4..a3b0061dfd4 100644 --- a/fs/nfs/super.c +++ b/fs/nfs/super.c | |||
| @@ -2459,7 +2459,7 @@ static int nfs4_xdev_get_sb(struct file_system_type *fs_type, int flags, | |||
| 2459 | compare_super = NULL; | 2459 | compare_super = NULL; |
| 2460 | 2460 | ||
| 2461 | /* Get a superblock - note that we may end up sharing one that already exists */ | 2461 | /* Get a superblock - note that we may end up sharing one that already exists */ |
| 2462 | s = sget(&nfs_fs_type, compare_super, nfs_set_super, &sb_mntdata); | 2462 | s = sget(&nfs4_fs_type, compare_super, nfs_set_super, &sb_mntdata); |
| 2463 | if (IS_ERR(s)) { | 2463 | if (IS_ERR(s)) { |
| 2464 | error = PTR_ERR(s); | 2464 | error = PTR_ERR(s); |
| 2465 | goto out_err_nosb; | 2465 | goto out_err_nosb; |
| @@ -2544,7 +2544,7 @@ static int nfs4_referral_get_sb(struct file_system_type *fs_type, int flags, | |||
| 2544 | compare_super = NULL; | 2544 | compare_super = NULL; |
| 2545 | 2545 | ||
| 2546 | /* Get a superblock - note that we may end up sharing one that already exists */ | 2546 | /* Get a superblock - note that we may end up sharing one that already exists */ |
| 2547 | s = sget(&nfs_fs_type, compare_super, nfs_set_super, &sb_mntdata); | 2547 | s = sget(&nfs4_fs_type, compare_super, nfs_set_super, &sb_mntdata); |
| 2548 | if (IS_ERR(s)) { | 2548 | if (IS_ERR(s)) { |
| 2549 | error = PTR_ERR(s); | 2549 | error = PTR_ERR(s); |
| 2550 | goto out_err_nosb; | 2550 | goto out_err_nosb; |
diff --git a/fs/ntfs/file.c b/fs/ntfs/file.c index d020866d423..3140a4429af 100644 --- a/fs/ntfs/file.c +++ b/fs/ntfs/file.c | |||
| @@ -439,7 +439,7 @@ static inline int __ntfs_grab_cache_pages(struct address_space *mapping, | |||
| 439 | pages[nr] = *cached_page; | 439 | pages[nr] = *cached_page; |
| 440 | page_cache_get(*cached_page); | 440 | page_cache_get(*cached_page); |
| 441 | if (unlikely(!pagevec_add(lru_pvec, *cached_page))) | 441 | if (unlikely(!pagevec_add(lru_pvec, *cached_page))) |
| 442 | __pagevec_lru_add(lru_pvec); | 442 | __pagevec_lru_add_file(lru_pvec); |
| 443 | *cached_page = NULL; | 443 | *cached_page = NULL; |
| 444 | } | 444 | } |
| 445 | index++; | 445 | index++; |
| @@ -2084,7 +2084,7 @@ err_out: | |||
| 2084 | OSYNC_METADATA|OSYNC_DATA); | 2084 | OSYNC_METADATA|OSYNC_DATA); |
| 2085 | } | 2085 | } |
| 2086 | } | 2086 | } |
| 2087 | pagevec_lru_add(&lru_pvec); | 2087 | pagevec_lru_add_file(&lru_pvec); |
| 2088 | ntfs_debug("Done. Returning %s (written 0x%lx, status %li).", | 2088 | ntfs_debug("Done. Returning %s (written 0x%lx, status %li).", |
| 2089 | written ? "written" : "status", (unsigned long)written, | 2089 | written ? "written" : "status", (unsigned long)written, |
| 2090 | (long)status); | 2090 | (long)status); |
diff --git a/fs/proc/array.c b/fs/proc/array.c index f4bc0e78953..bb9f4b05703 100644 --- a/fs/proc/array.c +++ b/fs/proc/array.c | |||
| @@ -388,20 +388,20 @@ static int do_task_stat(struct seq_file *m, struct pid_namespace *ns, | |||
| 388 | 388 | ||
| 389 | /* add up live thread stats at the group level */ | 389 | /* add up live thread stats at the group level */ |
| 390 | if (whole) { | 390 | if (whole) { |
| 391 | struct task_cputime cputime; | ||
| 391 | struct task_struct *t = task; | 392 | struct task_struct *t = task; |
| 392 | do { | 393 | do { |
| 393 | min_flt += t->min_flt; | 394 | min_flt += t->min_flt; |
| 394 | maj_flt += t->maj_flt; | 395 | maj_flt += t->maj_flt; |
| 395 | utime = cputime_add(utime, task_utime(t)); | ||
| 396 | stime = cputime_add(stime, task_stime(t)); | ||
| 397 | gtime = cputime_add(gtime, task_gtime(t)); | 396 | gtime = cputime_add(gtime, task_gtime(t)); |
| 398 | t = next_thread(t); | 397 | t = next_thread(t); |
| 399 | } while (t != task); | 398 | } while (t != task); |
| 400 | 399 | ||
| 401 | min_flt += sig->min_flt; | 400 | min_flt += sig->min_flt; |
| 402 | maj_flt += sig->maj_flt; | 401 | maj_flt += sig->maj_flt; |
| 403 | utime = cputime_add(utime, sig->utime); | 402 | thread_group_cputime(task, &cputime); |
| 404 | stime = cputime_add(stime, sig->stime); | 403 | utime = cputime.utime; |
| 404 | stime = cputime.stime; | ||
| 405 | gtime = cputime_add(gtime, sig->gtime); | 405 | gtime = cputime_add(gtime, sig->gtime); |
| 406 | } | 406 | } |
| 407 | 407 | ||
diff --git a/fs/proc/proc_misc.c b/fs/proc/proc_misc.c index 59ea42e1ef0..7ea52c79b2d 100644 --- a/fs/proc/proc_misc.c +++ b/fs/proc/proc_misc.c | |||
| @@ -30,6 +30,7 @@ | |||
| 30 | #include <linux/mm.h> | 30 | #include <linux/mm.h> |
| 31 | #include <linux/mmzone.h> | 31 | #include <linux/mmzone.h> |
| 32 | #include <linux/pagemap.h> | 32 | #include <linux/pagemap.h> |
| 33 | #include <linux/irq.h> | ||
| 33 | #include <linux/interrupt.h> | 34 | #include <linux/interrupt.h> |
| 34 | #include <linux/swap.h> | 35 | #include <linux/swap.h> |
| 35 | #include <linux/slab.h> | 36 | #include <linux/slab.h> |
| @@ -136,6 +137,8 @@ static int meminfo_read_proc(char *page, char **start, off_t off, | |||
| 136 | unsigned long allowed; | 137 | unsigned long allowed; |
| 137 | struct vmalloc_info vmi; | 138 | struct vmalloc_info vmi; |
| 138 | long cached; | 139 | long cached; |
| 140 | unsigned long pages[NR_LRU_LISTS]; | ||
| 141 | int lru; | ||
| 139 | 142 | ||
| 140 | /* | 143 | /* |
| 141 | * display in kilobytes. | 144 | * display in kilobytes. |
| @@ -154,51 +157,70 @@ static int meminfo_read_proc(char *page, char **start, off_t off, | |||
| 154 | 157 | ||
| 155 | get_vmalloc_info(&vmi); | 158 | get_vmalloc_info(&vmi); |
| 156 | 159 | ||
| 160 | for (lru = LRU_BASE; lru < NR_LRU_LISTS; lru++) | ||
| 161 | pages[lru] = global_page_state(NR_LRU_BASE + lru); | ||
| 162 | |||
| 157 | /* | 163 | /* |
| 158 | * Tagged format, for easy grepping and expansion. | 164 | * Tagged format, for easy grepping and expansion. |
| 159 | */ | 165 | */ |
| 160 | len = sprintf(page, | 166 | len = sprintf(page, |
| 161 | "MemTotal: %8lu kB\n" | 167 | "MemTotal: %8lu kB\n" |
| 162 | "MemFree: %8lu kB\n" | 168 | "MemFree: %8lu kB\n" |
| 163 | "Buffers: %8lu kB\n" | 169 | "Buffers: %8lu kB\n" |
| 164 | "Cached: %8lu kB\n" | 170 | "Cached: %8lu kB\n" |
| 165 | "SwapCached: %8lu kB\n" | 171 | "SwapCached: %8lu kB\n" |
| 166 | "Active: %8lu kB\n" | 172 | "Active: %8lu kB\n" |
| 167 | "Inactive: %8lu kB\n" | 173 | "Inactive: %8lu kB\n" |
| 174 | "Active(anon): %8lu kB\n" | ||
| 175 | "Inactive(anon): %8lu kB\n" | ||
| 176 | "Active(file): %8lu kB\n" | ||
| 177 | "Inactive(file): %8lu kB\n" | ||
| 178 | #ifdef CONFIG_UNEVICTABLE_LRU | ||
| 179 | "Unevictable: %8lu kB\n" | ||
| 180 | "Mlocked: %8lu kB\n" | ||
| 181 | #endif | ||
| 168 | #ifdef CONFIG_HIGHMEM | 182 | #ifdef CONFIG_HIGHMEM |
| 169 | "HighTotal: %8lu kB\n" | 183 | "HighTotal: %8lu kB\n" |
| 170 | "HighFree: %8lu kB\n" | 184 | "HighFree: %8lu kB\n" |
| 171 | "LowTotal: %8lu kB\n" | 185 | "LowTotal: %8lu kB\n" |
| 172 | "LowFree: %8lu kB\n" | 186 | "LowFree: %8lu kB\n" |
| 173 | #endif | 187 | #endif |
| 174 | "SwapTotal: %8lu kB\n" | 188 | "SwapTotal: %8lu kB\n" |
| 175 | "SwapFree: %8lu kB\n" | 189 | "SwapFree: %8lu kB\n" |
| 176 | "Dirty: %8lu kB\n" | 190 | "Dirty: %8lu kB\n" |
| 177 | "Writeback: %8lu kB\n" | 191 | "Writeback: %8lu kB\n" |
| 178 | "AnonPages: %8lu kB\n" | 192 | "AnonPages: %8lu kB\n" |
| 179 | "Mapped: %8lu kB\n" | 193 | "Mapped: %8lu kB\n" |
| 180 | "Slab: %8lu kB\n" | 194 | "Slab: %8lu kB\n" |
| 181 | "SReclaimable: %8lu kB\n" | 195 | "SReclaimable: %8lu kB\n" |
| 182 | "SUnreclaim: %8lu kB\n" | 196 | "SUnreclaim: %8lu kB\n" |
| 183 | "PageTables: %8lu kB\n" | 197 | "PageTables: %8lu kB\n" |
| 184 | #ifdef CONFIG_QUICKLIST | 198 | #ifdef CONFIG_QUICKLIST |
| 185 | "Quicklists: %8lu kB\n" | 199 | "Quicklists: %8lu kB\n" |
| 186 | #endif | 200 | #endif |
| 187 | "NFS_Unstable: %8lu kB\n" | 201 | "NFS_Unstable: %8lu kB\n" |
| 188 | "Bounce: %8lu kB\n" | 202 | "Bounce: %8lu kB\n" |
| 189 | "WritebackTmp: %8lu kB\n" | 203 | "WritebackTmp: %8lu kB\n" |
| 190 | "CommitLimit: %8lu kB\n" | 204 | "CommitLimit: %8lu kB\n" |
| 191 | "Committed_AS: %8lu kB\n" | 205 | "Committed_AS: %8lu kB\n" |
| 192 | "VmallocTotal: %8lu kB\n" | 206 | "VmallocTotal: %8lu kB\n" |
| 193 | "VmallocUsed: %8lu kB\n" | 207 | "VmallocUsed: %8lu kB\n" |
| 194 | "VmallocChunk: %8lu kB\n", | 208 | "VmallocChunk: %8lu kB\n", |
| 195 | K(i.totalram), | 209 | K(i.totalram), |
| 196 | K(i.freeram), | 210 | K(i.freeram), |
| 197 | K(i.bufferram), | 211 | K(i.bufferram), |
| 198 | K(cached), | 212 | K(cached), |
| 199 | K(total_swapcache_pages), | 213 | K(total_swapcache_pages), |
| 200 | K(global_page_state(NR_ACTIVE)), | 214 | K(pages[LRU_ACTIVE_ANON] + pages[LRU_ACTIVE_FILE]), |
| 201 | K(global_page_state(NR_INACTIVE)), | 215 | K(pages[LRU_INACTIVE_ANON] + pages[LRU_INACTIVE_FILE]), |
| 216 | K(pages[LRU_ACTIVE_ANON]), | ||
| 217 | K(pages[LRU_INACTIVE_ANON]), | ||
| 218 | K(pages[LRU_ACTIVE_FILE]), | ||
| 219 | K(pages[LRU_INACTIVE_FILE]), | ||
| 220 | #ifdef CONFIG_UNEVICTABLE_LRU | ||
| 221 | K(pages[LRU_UNEVICTABLE]), | ||
| 222 | K(global_page_state(NR_MLOCK)), | ||
| 223 | #endif | ||
| 202 | #ifdef CONFIG_HIGHMEM | 224 | #ifdef CONFIG_HIGHMEM |
| 203 | K(i.totalhigh), | 225 | K(i.totalhigh), |
| 204 | K(i.freehigh), | 226 | K(i.freehigh), |
| @@ -500,17 +522,13 @@ static const struct file_operations proc_vmalloc_operations = { | |||
| 500 | 522 | ||
| 501 | static int show_stat(struct seq_file *p, void *v) | 523 | static int show_stat(struct seq_file *p, void *v) |
| 502 | { | 524 | { |
| 503 | int i; | 525 | int i, j; |
| 504 | unsigned long jif; | 526 | unsigned long jif; |
| 505 | cputime64_t user, nice, system, idle, iowait, irq, softirq, steal; | 527 | cputime64_t user, nice, system, idle, iowait, irq, softirq, steal; |
| 506 | cputime64_t guest; | 528 | cputime64_t guest; |
| 507 | u64 sum = 0; | 529 | u64 sum = 0; |
| 508 | struct timespec boottime; | 530 | struct timespec boottime; |
| 509 | unsigned int *per_irq_sum; | 531 | unsigned int per_irq_sum; |
| 510 | |||
| 511 | per_irq_sum = kzalloc(sizeof(unsigned int)*NR_IRQS, GFP_KERNEL); | ||
| 512 | if (!per_irq_sum) | ||
| 513 | return -ENOMEM; | ||
| 514 | 532 | ||
| 515 | user = nice = system = idle = iowait = | 533 | user = nice = system = idle = iowait = |
| 516 | irq = softirq = steal = cputime64_zero; | 534 | irq = softirq = steal = cputime64_zero; |
| @@ -519,8 +537,6 @@ static int show_stat(struct seq_file *p, void *v) | |||
| 519 | jif = boottime.tv_sec; | 537 | jif = boottime.tv_sec; |
| 520 | 538 | ||
| 521 | for_each_possible_cpu(i) { | 539 | for_each_possible_cpu(i) { |
| 522 | int j; | ||
| 523 | |||
| 524 | user = cputime64_add(user, kstat_cpu(i).cpustat.user); | 540 | user = cputime64_add(user, kstat_cpu(i).cpustat.user); |
| 525 | nice = cputime64_add(nice, kstat_cpu(i).cpustat.nice); | 541 | nice = cputime64_add(nice, kstat_cpu(i).cpustat.nice); |
| 526 | system = cputime64_add(system, kstat_cpu(i).cpustat.system); | 542 | system = cputime64_add(system, kstat_cpu(i).cpustat.system); |
| @@ -530,11 +546,10 @@ static int show_stat(struct seq_file *p, void *v) | |||
| 530 | softirq = cputime64_add(softirq, kstat_cpu(i).cpustat.softirq); | 546 | softirq = cputime64_add(softirq, kstat_cpu(i).cpustat.softirq); |
| 531 | steal = cputime64_add(steal, kstat_cpu(i).cpustat.steal); | 547 | steal = cputime64_add(steal, kstat_cpu(i).cpustat.steal); |
| 532 | guest = cputime64_add(guest, kstat_cpu(i).cpustat.guest); | 548 | guest = cputime64_add(guest, kstat_cpu(i).cpustat.guest); |
| 533 | for (j = 0; j < NR_IRQS; j++) { | 549 | |
| 534 | unsigned int temp = kstat_cpu(i).irqs[j]; | 550 | for_each_irq_nr(j) |
| 535 | sum += temp; | 551 | sum += kstat_irqs_cpu(j, i); |
| 536 | per_irq_sum[j] += temp; | 552 | |
| 537 | } | ||
| 538 | sum += arch_irq_stat_cpu(i); | 553 | sum += arch_irq_stat_cpu(i); |
| 539 | } | 554 | } |
| 540 | sum += arch_irq_stat(); | 555 | sum += arch_irq_stat(); |
| @@ -576,8 +591,15 @@ static int show_stat(struct seq_file *p, void *v) | |||
| 576 | } | 591 | } |
| 577 | seq_printf(p, "intr %llu", (unsigned long long)sum); | 592 | seq_printf(p, "intr %llu", (unsigned long long)sum); |
| 578 | 593 | ||
| 579 | for (i = 0; i < NR_IRQS; i++) | 594 | /* sum again ? it could be updated? */ |
| 580 | seq_printf(p, " %u", per_irq_sum[i]); | 595 | for_each_irq_nr(j) { |
| 596 | per_irq_sum = 0; | ||
| 597 | |||
| 598 | for_each_possible_cpu(i) | ||
| 599 | per_irq_sum += kstat_irqs_cpu(j, i); | ||
| 600 | |||
| 601 | seq_printf(p, " %u", per_irq_sum); | ||
| 602 | } | ||
| 581 | 603 | ||
| 582 | seq_printf(p, | 604 | seq_printf(p, |
| 583 | "\nctxt %llu\n" | 605 | "\nctxt %llu\n" |
| @@ -591,7 +613,6 @@ static int show_stat(struct seq_file *p, void *v) | |||
| 591 | nr_running(), | 613 | nr_running(), |
| 592 | nr_iowait()); | 614 | nr_iowait()); |
| 593 | 615 | ||
| 594 | kfree(per_irq_sum); | ||
| 595 | return 0; | 616 | return 0; |
| 596 | } | 617 | } |
| 597 | 618 | ||
| @@ -630,15 +651,14 @@ static const struct file_operations proc_stat_operations = { | |||
| 630 | */ | 651 | */ |
| 631 | static void *int_seq_start(struct seq_file *f, loff_t *pos) | 652 | static void *int_seq_start(struct seq_file *f, loff_t *pos) |
| 632 | { | 653 | { |
| 633 | return (*pos <= NR_IRQS) ? pos : NULL; | 654 | return (*pos <= nr_irqs) ? pos : NULL; |
| 634 | } | 655 | } |
| 635 | 656 | ||
| 657 | |||
| 636 | static void *int_seq_next(struct seq_file *f, void *v, loff_t *pos) | 658 | static void *int_seq_next(struct seq_file *f, void *v, loff_t *pos) |
| 637 | { | 659 | { |
| 638 | (*pos)++; | 660 | (*pos)++; |
| 639 | if (*pos > NR_IRQS) | 661 | return (*pos <= nr_irqs) ? pos : NULL; |
| 640 | return NULL; | ||
| 641 | return pos; | ||
| 642 | } | 662 | } |
| 643 | 663 | ||
| 644 | static void int_seq_stop(struct seq_file *f, void *v) | 664 | static void int_seq_stop(struct seq_file *f, void *v) |
| @@ -646,7 +666,6 @@ static void int_seq_stop(struct seq_file *f, void *v) | |||
| 646 | /* Nothing to do */ | 666 | /* Nothing to do */ |
| 647 | } | 667 | } |
| 648 | 668 | ||
| 649 | |||
| 650 | static const struct seq_operations int_seq_ops = { | 669 | static const struct seq_operations int_seq_ops = { |
| 651 | .start = int_seq_start, | 670 | .start = int_seq_start, |
| 652 | .next = int_seq_next, | 671 | .next = int_seq_next, |
diff --git a/fs/proc/vmcore.c b/fs/proc/vmcore.c index 841368b87a2..cd9ca67f841 100644 --- a/fs/proc/vmcore.c +++ b/fs/proc/vmcore.c | |||
| @@ -32,9 +32,6 @@ static size_t elfcorebuf_sz; | |||
| 32 | /* Total size of vmcore file. */ | 32 | /* Total size of vmcore file. */ |
| 33 | static u64 vmcore_size; | 33 | static u64 vmcore_size; |
| 34 | 34 | ||
| 35 | /* Stores the physical address of elf header of crash image. */ | ||
| 36 | unsigned long long elfcorehdr_addr = ELFCORE_ADDR_MAX; | ||
| 37 | |||
| 38 | struct proc_dir_entry *proc_vmcore = NULL; | 35 | struct proc_dir_entry *proc_vmcore = NULL; |
| 39 | 36 | ||
| 40 | /* Reads a page from the oldmem device from given offset. */ | 37 | /* Reads a page from the oldmem device from given offset. */ |
| @@ -647,7 +644,7 @@ static int __init vmcore_init(void) | |||
| 647 | int rc = 0; | 644 | int rc = 0; |
| 648 | 645 | ||
| 649 | /* If elfcorehdr= has been passed in cmdline, then capture the dump.*/ | 646 | /* If elfcorehdr= has been passed in cmdline, then capture the dump.*/ |
| 650 | if (!(elfcorehdr_addr < ELFCORE_ADDR_MAX)) | 647 | if (!(is_vmcore_usable())) |
| 651 | return rc; | 648 | return rc; |
| 652 | rc = parse_crash_elf_headers(); | 649 | rc = parse_crash_elf_headers(); |
| 653 | if (rc) { | 650 | if (rc) { |
diff --git a/fs/ramfs/file-nommu.c b/fs/ramfs/file-nommu.c index 5145cb9125a..76acdbc3461 100644 --- a/fs/ramfs/file-nommu.c +++ b/fs/ramfs/file-nommu.c | |||
| @@ -112,12 +112,12 @@ int ramfs_nommu_expand_for_mapping(struct inode *inode, size_t newsize) | |||
| 112 | goto add_error; | 112 | goto add_error; |
| 113 | 113 | ||
| 114 | if (!pagevec_add(&lru_pvec, page)) | 114 | if (!pagevec_add(&lru_pvec, page)) |
| 115 | __pagevec_lru_add(&lru_pvec); | 115 | __pagevec_lru_add_file(&lru_pvec); |
| 116 | 116 | ||
| 117 | unlock_page(page); | 117 | unlock_page(page); |
| 118 | } | 118 | } |
| 119 | 119 | ||
| 120 | pagevec_lru_add(&lru_pvec); | 120 | pagevec_lru_add_file(&lru_pvec); |
| 121 | return 0; | 121 | return 0; |
| 122 | 122 | ||
| 123 | fsize_exceeded: | 123 | fsize_exceeded: |
diff --git a/fs/ramfs/inode.c b/fs/ramfs/inode.c index b13123424e4..f031d1c925f 100644 --- a/fs/ramfs/inode.c +++ b/fs/ramfs/inode.c | |||
| @@ -61,6 +61,7 @@ struct inode *ramfs_get_inode(struct super_block *sb, int mode, dev_t dev) | |||
| 61 | inode->i_mapping->a_ops = &ramfs_aops; | 61 | inode->i_mapping->a_ops = &ramfs_aops; |
| 62 | inode->i_mapping->backing_dev_info = &ramfs_backing_dev_info; | 62 | inode->i_mapping->backing_dev_info = &ramfs_backing_dev_info; |
| 63 | mapping_set_gfp_mask(inode->i_mapping, GFP_HIGHUSER); | 63 | mapping_set_gfp_mask(inode->i_mapping, GFP_HIGHUSER); |
| 64 | mapping_set_unevictable(inode->i_mapping); | ||
| 64 | inode->i_atime = inode->i_mtime = inode->i_ctime = CURRENT_TIME; | 65 | inode->i_atime = inode->i_mtime = inode->i_ctime = CURRENT_TIME; |
| 65 | switch (mode & S_IFMT) { | 66 | switch (mode & S_IFMT) { |
| 66 | default: | 67 | default: |
diff --git a/fs/seq_file.c b/fs/seq_file.c index bd20f7f5a93..eba2eabcd2b 100644 --- a/fs/seq_file.c +++ b/fs/seq_file.c | |||
| @@ -452,17 +452,34 @@ int seq_dentry(struct seq_file *m, struct dentry *dentry, char *esc) | |||
| 452 | 452 | ||
| 453 | int seq_bitmap(struct seq_file *m, unsigned long *bits, unsigned int nr_bits) | 453 | int seq_bitmap(struct seq_file *m, unsigned long *bits, unsigned int nr_bits) |
| 454 | { | 454 | { |
| 455 | size_t len = bitmap_scnprintf_len(nr_bits); | 455 | if (m->count < m->size) { |
| 456 | int len = bitmap_scnprintf(m->buf + m->count, | ||
| 457 | m->size - m->count, bits, nr_bits); | ||
| 458 | if (m->count + len < m->size) { | ||
| 459 | m->count += len; | ||
| 460 | return 0; | ||
| 461 | } | ||
| 462 | } | ||
| 463 | m->count = m->size; | ||
| 464 | return -1; | ||
| 465 | } | ||
| 466 | EXPORT_SYMBOL(seq_bitmap); | ||
| 456 | 467 | ||
| 457 | if (m->count + len < m->size) { | 468 | int seq_bitmap_list(struct seq_file *m, unsigned long *bits, |
| 458 | bitmap_scnprintf(m->buf + m->count, m->size - m->count, | 469 | unsigned int nr_bits) |
| 459 | bits, nr_bits); | 470 | { |
| 460 | m->count += len; | 471 | if (m->count < m->size) { |
| 461 | return 0; | 472 | int len = bitmap_scnlistprintf(m->buf + m->count, |
| 473 | m->size - m->count, bits, nr_bits); | ||
| 474 | if (m->count + len < m->size) { | ||
| 475 | m->count += len; | ||
| 476 | return 0; | ||
| 477 | } | ||
| 462 | } | 478 | } |
| 463 | m->count = m->size; | 479 | m->count = m->size; |
| 464 | return -1; | 480 | return -1; |
| 465 | } | 481 | } |
| 482 | EXPORT_SYMBOL(seq_bitmap_list); | ||
| 466 | 483 | ||
| 467 | static void *single_start(struct seq_file *p, loff_t *pos) | 484 | static void *single_start(struct seq_file *p, loff_t *pos) |
| 468 | { | 485 | { |
diff --git a/fs/ubifs/budget.c b/fs/ubifs/budget.c index 73db464cd08..1a4973e1066 100644 --- a/fs/ubifs/budget.c +++ b/fs/ubifs/budget.c | |||
| @@ -414,19 +414,21 @@ static int do_budget_space(struct ubifs_info *c) | |||
| 414 | * @c->lst.empty_lebs + @c->freeable_cnt + @c->idx_gc_cnt - | 414 | * @c->lst.empty_lebs + @c->freeable_cnt + @c->idx_gc_cnt - |
| 415 | * @c->lst.taken_empty_lebs | 415 | * @c->lst.taken_empty_lebs |
| 416 | * | 416 | * |
| 417 | * @empty_lebs are available because they are empty. @freeable_cnt are | 417 | * @c->lst.empty_lebs are available because they are empty. |
| 418 | * available because they contain only free and dirty space and the | 418 | * @c->freeable_cnt are available because they contain only free and |
| 419 | * index allocation always occurs after wbufs are synch'ed. | 419 | * dirty space, @c->idx_gc_cnt are available because they are index |
| 420 | * @idx_gc_cnt are available because they are index LEBs that have been | 420 | * LEBs that have been garbage collected and are awaiting the commit |
| 421 | * garbage collected (including trivial GC) and are awaiting the commit | 421 | * before they can be used. And the in-the-gaps method will grab these |
| 422 | * before they can be unmapped - note that the in-the-gaps method will | 422 | * if it needs them. @c->lst.taken_empty_lebs are empty LEBs that have |
| 423 | * grab these if it needs them. @taken_empty_lebs are empty_lebs that | 423 | * already been allocated for some purpose. |
| 424 | * have already been allocated for some purpose (also includes those | ||
| 425 | * LEBs on the @idx_gc list). | ||
| 426 | * | 424 | * |
| 427 | * Note, @taken_empty_lebs may temporarily be higher by one because of | 425 | * Note, @c->idx_gc_cnt is included to both @c->lst.empty_lebs (because |
| 428 | * the way we serialize LEB allocations and budgeting. See a comment in | 426 | * these LEBs are empty) and to @c->lst.taken_empty_lebs (because they |
| 429 | * 'ubifs_find_free_space()'. | 427 | * are taken until after the commit). |
| 428 | * | ||
| 429 | * Note, @c->lst.taken_empty_lebs may temporarily be higher by one | ||
| 430 | * because of the way we serialize LEB allocations and budgeting. See a | ||
| 431 | * comment in 'ubifs_find_free_space()'. | ||
| 430 | */ | 432 | */ |
| 431 | lebs = c->lst.empty_lebs + c->freeable_cnt + c->idx_gc_cnt - | 433 | lebs = c->lst.empty_lebs + c->freeable_cnt + c->idx_gc_cnt - |
| 432 | c->lst.taken_empty_lebs; | 434 | c->lst.taken_empty_lebs; |
diff --git a/fs/ubifs/compress.c b/fs/ubifs/compress.c index 5bb51dac3c1..a0ada596b17 100644 --- a/fs/ubifs/compress.c +++ b/fs/ubifs/compress.c | |||
| @@ -91,8 +91,6 @@ struct ubifs_compressor *ubifs_compressors[UBIFS_COMPR_TYPES_CNT]; | |||
| 91 | * | 91 | * |
| 92 | * Note, if the input buffer was not compressed, it is copied to the output | 92 | * Note, if the input buffer was not compressed, it is copied to the output |
| 93 | * buffer and %UBIFS_COMPR_NONE is returned in @compr_type. | 93 | * buffer and %UBIFS_COMPR_NONE is returned in @compr_type. |
| 94 | * | ||
| 95 | * This functions returns %0 on success or a negative error code on failure. | ||
| 96 | */ | 94 | */ |
| 97 | void ubifs_compress(const void *in_buf, int in_len, void *out_buf, int *out_len, | 95 | void ubifs_compress(const void *in_buf, int in_len, void *out_buf, int *out_len, |
| 98 | int *compr_type) | 96 | int *compr_type) |
diff --git a/fs/ubifs/debug.c b/fs/ubifs/debug.c index d7f7645779f..7186400750e 100644 --- a/fs/ubifs/debug.c +++ b/fs/ubifs/debug.c | |||
| @@ -222,30 +222,38 @@ void dbg_dump_inode(const struct ubifs_info *c, const struct inode *inode) | |||
| 222 | { | 222 | { |
| 223 | const struct ubifs_inode *ui = ubifs_inode(inode); | 223 | const struct ubifs_inode *ui = ubifs_inode(inode); |
| 224 | 224 | ||
| 225 | printk(KERN_DEBUG "inode %lu\n", inode->i_ino); | 225 | printk(KERN_DEBUG "Dump in-memory inode:"); |
| 226 | printk(KERN_DEBUG "size %llu\n", | 226 | printk(KERN_DEBUG "\tinode %lu\n", inode->i_ino); |
| 227 | printk(KERN_DEBUG "\tsize %llu\n", | ||
| 227 | (unsigned long long)i_size_read(inode)); | 228 | (unsigned long long)i_size_read(inode)); |
| 228 | printk(KERN_DEBUG "nlink %u\n", inode->i_nlink); | 229 | printk(KERN_DEBUG "\tnlink %u\n", inode->i_nlink); |
| 229 | printk(KERN_DEBUG "uid %u\n", (unsigned int)inode->i_uid); | 230 | printk(KERN_DEBUG "\tuid %u\n", (unsigned int)inode->i_uid); |
| 230 | printk(KERN_DEBUG "gid %u\n", (unsigned int)inode->i_gid); | 231 | printk(KERN_DEBUG "\tgid %u\n", (unsigned int)inode->i_gid); |
| 231 | printk(KERN_DEBUG "atime %u.%u\n", | 232 | printk(KERN_DEBUG "\tatime %u.%u\n", |
| 232 | (unsigned int)inode->i_atime.tv_sec, | 233 | (unsigned int)inode->i_atime.tv_sec, |
| 233 | (unsigned int)inode->i_atime.tv_nsec); | 234 | (unsigned int)inode->i_atime.tv_nsec); |
| 234 | printk(KERN_DEBUG "mtime %u.%u\n", | 235 | printk(KERN_DEBUG "\tmtime %u.%u\n", |
| 235 | (unsigned int)inode->i_mtime.tv_sec, | 236 | (unsigned int)inode->i_mtime.tv_sec, |
| 236 | (unsigned int)inode->i_mtime.tv_nsec); | 237 | (unsigned int)inode->i_mtime.tv_nsec); |
| 237 | printk(KERN_DEBUG "ctime %u.%u\n", | 238 | printk(KERN_DEBUG "\tctime %u.%u\n", |
| 238 | (unsigned int)inode->i_ctime.tv_sec, | 239 | (unsigned int)inode->i_ctime.tv_sec, |
| 239 | (unsigned int)inode->i_ctime.tv_nsec); | 240 | (unsigned int)inode->i_ctime.tv_nsec); |
| 240 | printk(KERN_DEBUG "creat_sqnum %llu\n", ui->creat_sqnum); | 241 | printk(KERN_DEBUG "\tcreat_sqnum %llu\n", ui->creat_sqnum); |
| 241 | printk(KERN_DEBUG "xattr_size %u\n", ui->xattr_size); | 242 | printk(KERN_DEBUG "\txattr_size %u\n", ui->xattr_size); |
| 242 | printk(KERN_DEBUG "xattr_cnt %u\n", ui->xattr_cnt); | 243 | printk(KERN_DEBUG "\txattr_cnt %u\n", ui->xattr_cnt); |
| 243 | printk(KERN_DEBUG "xattr_names %u\n", ui->xattr_names); | 244 | printk(KERN_DEBUG "\txattr_names %u\n", ui->xattr_names); |
| 244 | printk(KERN_DEBUG "dirty %u\n", ui->dirty); | 245 | printk(KERN_DEBUG "\tdirty %u\n", ui->dirty); |
| 245 | printk(KERN_DEBUG "xattr %u\n", ui->xattr); | 246 | printk(KERN_DEBUG "\txattr %u\n", ui->xattr); |
| 246 | printk(KERN_DEBUG "flags %d\n", ui->flags); | 247 | printk(KERN_DEBUG "\tbulk_read %u\n", ui->xattr); |
| 247 | printk(KERN_DEBUG "compr_type %d\n", ui->compr_type); | 248 | printk(KERN_DEBUG "\tsynced_i_size %llu\n", |
| 248 | printk(KERN_DEBUG "data_len %d\n", ui->data_len); | 249 | (unsigned long long)ui->synced_i_size); |
| 250 | printk(KERN_DEBUG "\tui_size %llu\n", | ||
| 251 | (unsigned long long)ui->ui_size); | ||
| 252 | printk(KERN_DEBUG "\tflags %d\n", ui->flags); | ||
| 253 | printk(KERN_DEBUG "\tcompr_type %d\n", ui->compr_type); | ||
| 254 | printk(KERN_DEBUG "\tlast_page_read %lu\n", ui->last_page_read); | ||
| 255 | printk(KERN_DEBUG "\tread_in_a_row %lu\n", ui->read_in_a_row); | ||
| 256 | printk(KERN_DEBUG "\tdata_len %d\n", ui->data_len); | ||
| 249 | } | 257 | } |
| 250 | 258 | ||
| 251 | void dbg_dump_node(const struct ubifs_info *c, const void *node) | 259 | void dbg_dump_node(const struct ubifs_info *c, const void *node) |
| @@ -647,6 +655,43 @@ void dbg_dump_lprops(struct ubifs_info *c) | |||
| 647 | } | 655 | } |
| 648 | } | 656 | } |
| 649 | 657 | ||
| 658 | void dbg_dump_lpt_info(struct ubifs_info *c) | ||
| 659 | { | ||
| 660 | int i; | ||
| 661 | |||
| 662 | spin_lock(&dbg_lock); | ||
| 663 | printk(KERN_DEBUG "\tlpt_sz: %lld\n", c->lpt_sz); | ||
| 664 | printk(KERN_DEBUG "\tpnode_sz: %d\n", c->pnode_sz); | ||
| 665 | printk(KERN_DEBUG "\tnnode_sz: %d\n", c->nnode_sz); | ||
| 666 | printk(KERN_DEBUG "\tltab_sz: %d\n", c->ltab_sz); | ||
| 667 | printk(KERN_DEBUG "\tlsave_sz: %d\n", c->lsave_sz); | ||
| 668 | printk(KERN_DEBUG "\tbig_lpt: %d\n", c->big_lpt); | ||
| 669 | printk(KERN_DEBUG "\tlpt_hght: %d\n", c->lpt_hght); | ||
| 670 | printk(KERN_DEBUG "\tpnode_cnt: %d\n", c->pnode_cnt); | ||
| 671 | printk(KERN_DEBUG "\tnnode_cnt: %d\n", c->nnode_cnt); | ||
| 672 | printk(KERN_DEBUG "\tdirty_pn_cnt: %d\n", c->dirty_pn_cnt); | ||
| 673 | printk(KERN_DEBUG "\tdirty_nn_cnt: %d\n", c->dirty_nn_cnt); | ||
| 674 | printk(KERN_DEBUG "\tlsave_cnt: %d\n", c->lsave_cnt); | ||
| 675 | printk(KERN_DEBUG "\tspace_bits: %d\n", c->space_bits); | ||
| 676 | printk(KERN_DEBUG "\tlpt_lnum_bits: %d\n", c->lpt_lnum_bits); | ||
| 677 | printk(KERN_DEBUG "\tlpt_offs_bits: %d\n", c->lpt_offs_bits); | ||
| 678 | printk(KERN_DEBUG "\tlpt_spc_bits: %d\n", c->lpt_spc_bits); | ||
| 679 | printk(KERN_DEBUG "\tpcnt_bits: %d\n", c->pcnt_bits); | ||
| 680 | printk(KERN_DEBUG "\tlnum_bits: %d\n", c->lnum_bits); | ||
| 681 | printk(KERN_DEBUG "\tLPT root is at %d:%d\n", c->lpt_lnum, c->lpt_offs); | ||
| 682 | printk(KERN_DEBUG "\tLPT head is at %d:%d\n", | ||
| 683 | c->nhead_lnum, c->nhead_offs); | ||
| 684 | printk(KERN_DEBUG "\tLPT ltab is at %d:%d\n", c->ltab_lnum, c->ltab_offs); | ||
| 685 | if (c->big_lpt) | ||
| 686 | printk(KERN_DEBUG "\tLPT lsave is at %d:%d\n", | ||
| 687 | c->lsave_lnum, c->lsave_offs); | ||
| 688 | for (i = 0; i < c->lpt_lebs; i++) | ||
| 689 | printk(KERN_DEBUG "\tLPT LEB %d free %d dirty %d tgc %d " | ||
| 690 | "cmt %d\n", i + c->lpt_first, c->ltab[i].free, | ||
| 691 | c->ltab[i].dirty, c->ltab[i].tgc, c->ltab[i].cmt); | ||
| 692 | spin_unlock(&dbg_lock); | ||
| 693 | } | ||
| 694 | |||
| 650 | void dbg_dump_leb(const struct ubifs_info *c, int lnum) | 695 | void dbg_dump_leb(const struct ubifs_info *c, int lnum) |
| 651 | { | 696 | { |
| 652 | struct ubifs_scan_leb *sleb; | 697 | struct ubifs_scan_leb *sleb; |
diff --git a/fs/ubifs/debug.h b/fs/ubifs/debug.h index 50315fc5718..33d6b95071e 100644 --- a/fs/ubifs/debug.h +++ b/fs/ubifs/debug.h | |||
| @@ -224,6 +224,7 @@ void dbg_dump_lstats(const struct ubifs_lp_stats *lst); | |||
| 224 | void dbg_dump_budg(struct ubifs_info *c); | 224 | void dbg_dump_budg(struct ubifs_info *c); |
| 225 | void dbg_dump_lprop(const struct ubifs_info *c, const struct ubifs_lprops *lp); | 225 | void dbg_dump_lprop(const struct ubifs_info *c, const struct ubifs_lprops *lp); |
| 226 | void dbg_dump_lprops(struct ubifs_info *c); | 226 | void dbg_dump_lprops(struct ubifs_info *c); |
| 227 | void dbg_dump_lpt_info(struct ubifs_info *c); | ||
| 227 | void dbg_dump_leb(const struct ubifs_info *c, int lnum); | 228 | void dbg_dump_leb(const struct ubifs_info *c, int lnum); |
| 228 | void dbg_dump_znode(const struct ubifs_info *c, | 229 | void dbg_dump_znode(const struct ubifs_info *c, |
| 229 | const struct ubifs_znode *znode); | 230 | const struct ubifs_znode *znode); |
| @@ -249,6 +250,8 @@ int dbg_old_index_check_init(struct ubifs_info *c, struct ubifs_zbranch *zroot); | |||
| 249 | int dbg_check_old_index(struct ubifs_info *c, struct ubifs_zbranch *zroot); | 250 | int dbg_check_old_index(struct ubifs_info *c, struct ubifs_zbranch *zroot); |
| 250 | int dbg_check_cats(struct ubifs_info *c); | 251 | int dbg_check_cats(struct ubifs_info *c); |
| 251 | int dbg_check_ltab(struct ubifs_info *c); | 252 | int dbg_check_ltab(struct ubifs_info *c); |
| 253 | int dbg_chk_lpt_free_spc(struct ubifs_info *c); | ||
| 254 | int dbg_chk_lpt_sz(struct ubifs_info *c, int action, int len); | ||
| 252 | int dbg_check_synced_i_size(struct inode *inode); | 255 | int dbg_check_synced_i_size(struct inode *inode); |
| 253 | int dbg_check_dir_size(struct ubifs_info *c, const struct inode *dir); | 256 | int dbg_check_dir_size(struct ubifs_info *c, const struct inode *dir); |
| 254 | int dbg_check_tnc(struct ubifs_info *c, int extra); | 257 | int dbg_check_tnc(struct ubifs_info *c, int extra); |
| @@ -367,6 +370,7 @@ static inline int dbg_change(struct ubi_volume_desc *desc, int lnum, | |||
| 367 | #define dbg_dump_budg(c) ({}) | 370 | #define dbg_dump_budg(c) ({}) |
| 368 | #define dbg_dump_lprop(c, lp) ({}) | 371 | #define dbg_dump_lprop(c, lp) ({}) |
| 369 | #define dbg_dump_lprops(c) ({}) | 372 | #define dbg_dump_lprops(c) ({}) |
| 373 | #define dbg_dump_lpt_info(c) ({}) | ||
| 370 | #define dbg_dump_leb(c, lnum) ({}) | 374 | #define dbg_dump_leb(c, lnum) ({}) |
| 371 | #define dbg_dump_znode(c, znode) ({}) | 375 | #define dbg_dump_znode(c, znode) ({}) |
| 372 | #define dbg_dump_heap(c, heap, cat) ({}) | 376 | #define dbg_dump_heap(c, heap, cat) ({}) |
| @@ -379,6 +383,8 @@ static inline int dbg_change(struct ubi_volume_desc *desc, int lnum, | |||
| 379 | #define dbg_check_old_index(c, zroot) 0 | 383 | #define dbg_check_old_index(c, zroot) 0 |
| 380 | #define dbg_check_cats(c) 0 | 384 | #define dbg_check_cats(c) 0 |
| 381 | #define dbg_check_ltab(c) 0 | 385 | #define dbg_check_ltab(c) 0 |
| 386 | #define dbg_chk_lpt_free_spc(c) 0 | ||
| 387 | #define dbg_chk_lpt_sz(c, action, len) 0 | ||
| 382 | #define dbg_check_synced_i_size(inode) 0 | 388 | #define dbg_check_synced_i_size(inode) 0 |
| 383 | #define dbg_check_dir_size(c, dir) 0 | 389 | #define dbg_check_dir_size(c, dir) 0 |
| 384 | #define dbg_check_tnc(c, x) 0 | 390 | #define dbg_check_tnc(c, x) 0 |
diff --git a/fs/ubifs/file.c b/fs/ubifs/file.c index 3d698e2022b..51cf511d44d 100644 --- a/fs/ubifs/file.c +++ b/fs/ubifs/file.c | |||
| @@ -147,6 +147,12 @@ static int do_readpage(struct page *page) | |||
| 147 | err = ret; | 147 | err = ret; |
| 148 | if (err != -ENOENT) | 148 | if (err != -ENOENT) |
| 149 | break; | 149 | break; |
| 150 | } else if (block + 1 == beyond) { | ||
| 151 | int dlen = le32_to_cpu(dn->size); | ||
| 152 | int ilen = i_size & (UBIFS_BLOCK_SIZE - 1); | ||
| 153 | |||
| 154 | if (ilen && ilen < dlen) | ||
| 155 | memset(addr + ilen, 0, dlen - ilen); | ||
| 150 | } | 156 | } |
| 151 | } | 157 | } |
| 152 | if (++i >= UBIFS_BLOCKS_PER_PAGE) | 158 | if (++i >= UBIFS_BLOCKS_PER_PAGE) |
| @@ -577,8 +583,262 @@ out: | |||
| 577 | return copied; | 583 | return copied; |
| 578 | } | 584 | } |
| 579 | 585 | ||
| 586 | /** | ||
| 587 | * populate_page - copy data nodes into a page for bulk-read. | ||
| 588 | * @c: UBIFS file-system description object | ||
| 589 | * @page: page | ||
| 590 | * @bu: bulk-read information | ||
| 591 | * @n: next zbranch slot | ||
| 592 | * | ||
| 593 | * This function returns %0 on success and a negative error code on failure. | ||
| 594 | */ | ||
| 595 | static int populate_page(struct ubifs_info *c, struct page *page, | ||
| 596 | struct bu_info *bu, int *n) | ||
| 597 | { | ||
| 598 | int i = 0, nn = *n, offs = bu->zbranch[0].offs, hole = 0, read = 0; | ||
| 599 | struct inode *inode = page->mapping->host; | ||
| 600 | loff_t i_size = i_size_read(inode); | ||
| 601 | unsigned int page_block; | ||
| 602 | void *addr, *zaddr; | ||
| 603 | pgoff_t end_index; | ||
| 604 | |||
| 605 | dbg_gen("ino %lu, pg %lu, i_size %lld, flags %#lx", | ||
| 606 | inode->i_ino, page->index, i_size, page->flags); | ||
| 607 | |||
| 608 | addr = zaddr = kmap(page); | ||
| 609 | |||
| 610 | end_index = (i_size - 1) >> PAGE_CACHE_SHIFT; | ||
| 611 | if (!i_size || page->index > end_index) { | ||
| 612 | hole = 1; | ||
| 613 | memset(addr, 0, PAGE_CACHE_SIZE); | ||
| 614 | goto out_hole; | ||
| 615 | } | ||
| 616 | |||
| 617 | page_block = page->index << UBIFS_BLOCKS_PER_PAGE_SHIFT; | ||
| 618 | while (1) { | ||
| 619 | int err, len, out_len, dlen; | ||
| 620 | |||
| 621 | if (nn >= bu->cnt) { | ||
| 622 | hole = 1; | ||
| 623 | memset(addr, 0, UBIFS_BLOCK_SIZE); | ||
| 624 | } else if (key_block(c, &bu->zbranch[nn].key) == page_block) { | ||
| 625 | struct ubifs_data_node *dn; | ||
| 626 | |||
| 627 | dn = bu->buf + (bu->zbranch[nn].offs - offs); | ||
| 628 | |||
| 629 | ubifs_assert(dn->ch.sqnum > | ||
| 630 | ubifs_inode(inode)->creat_sqnum); | ||
| 631 | |||
| 632 | len = le32_to_cpu(dn->size); | ||
| 633 | if (len <= 0 || len > UBIFS_BLOCK_SIZE) | ||
| 634 | goto out_err; | ||
| 635 | |||
| 636 | dlen = le32_to_cpu(dn->ch.len) - UBIFS_DATA_NODE_SZ; | ||
| 637 | out_len = UBIFS_BLOCK_SIZE; | ||
| 638 | err = ubifs_decompress(&dn->data, dlen, addr, &out_len, | ||
| 639 | le16_to_cpu(dn->compr_type)); | ||
| 640 | if (err || len != out_len) | ||
| 641 | goto out_err; | ||
| 642 | |||
| 643 | if (len < UBIFS_BLOCK_SIZE) | ||
| 644 | memset(addr + len, 0, UBIFS_BLOCK_SIZE - len); | ||
| 645 | |||
| 646 | nn += 1; | ||
| 647 | read = (i << UBIFS_BLOCK_SHIFT) + len; | ||
| 648 | } else if (key_block(c, &bu->zbranch[nn].key) < page_block) { | ||
| 649 | nn += 1; | ||
| 650 | continue; | ||
| 651 | } else { | ||
| 652 | hole = 1; | ||
| 653 | memset(addr, 0, UBIFS_BLOCK_SIZE); | ||
| 654 | } | ||
| 655 | if (++i >= UBIFS_BLOCKS_PER_PAGE) | ||
| 656 | break; | ||
| 657 | addr += UBIFS_BLOCK_SIZE; | ||
| 658 | page_block += 1; | ||
| 659 | } | ||
| 660 | |||
| 661 | if (end_index == page->index) { | ||
| 662 | int len = i_size & (PAGE_CACHE_SIZE - 1); | ||
| 663 | |||
| 664 | if (len && len < read) | ||
| 665 | memset(zaddr + len, 0, read - len); | ||
| 666 | } | ||
| 667 | |||
| 668 | out_hole: | ||
| 669 | if (hole) { | ||
| 670 | SetPageChecked(page); | ||
| 671 | dbg_gen("hole"); | ||
| 672 | } | ||
| 673 | |||
| 674 | SetPageUptodate(page); | ||
| 675 | ClearPageError(page); | ||
| 676 | flush_dcache_page(page); | ||
| 677 | kunmap(page); | ||
| 678 | *n = nn; | ||
| 679 | return 0; | ||
| 680 | |||
| 681 | out_err: | ||
| 682 | ClearPageUptodate(page); | ||
| 683 | SetPageError(page); | ||
| 684 | flush_dcache_page(page); | ||
| 685 | kunmap(page); | ||
| 686 | ubifs_err("bad data node (block %u, inode %lu)", | ||
| 687 | page_block, inode->i_ino); | ||
| 688 | return -EINVAL; | ||
| 689 | } | ||
| 690 | |||
| 691 | /** | ||
| 692 | * ubifs_do_bulk_read - do bulk-read. | ||
| 693 | * @c: UBIFS file-system description object | ||
| 694 | * @page1: first page | ||
| 695 | * | ||
| 696 | * This function returns %1 if the bulk-read is done, otherwise %0 is returned. | ||
| 697 | */ | ||
| 698 | static int ubifs_do_bulk_read(struct ubifs_info *c, struct page *page1) | ||
| 699 | { | ||
| 700 | pgoff_t offset = page1->index, end_index; | ||
| 701 | struct address_space *mapping = page1->mapping; | ||
| 702 | struct inode *inode = mapping->host; | ||
| 703 | struct ubifs_inode *ui = ubifs_inode(inode); | ||
| 704 | struct bu_info *bu; | ||
| 705 | int err, page_idx, page_cnt, ret = 0, n = 0; | ||
| 706 | loff_t isize; | ||
| 707 | |||
| 708 | bu = kmalloc(sizeof(struct bu_info), GFP_NOFS); | ||
| 709 | if (!bu) | ||
| 710 | return 0; | ||
| 711 | |||
| 712 | bu->buf_len = c->bulk_read_buf_size; | ||
| 713 | bu->buf = kmalloc(bu->buf_len, GFP_NOFS); | ||
| 714 | if (!bu->buf) | ||
| 715 | goto out_free; | ||
| 716 | |||
| 717 | data_key_init(c, &bu->key, inode->i_ino, | ||
| 718 | offset << UBIFS_BLOCKS_PER_PAGE_SHIFT); | ||
| 719 | |||
| 720 | err = ubifs_tnc_get_bu_keys(c, bu); | ||
| 721 | if (err) | ||
| 722 | goto out_warn; | ||
| 723 | |||
| 724 | if (bu->eof) { | ||
| 725 | /* Turn off bulk-read at the end of the file */ | ||
| 726 | ui->read_in_a_row = 1; | ||
| 727 | ui->bulk_read = 0; | ||
| 728 | } | ||
| 729 | |||
| 730 | page_cnt = bu->blk_cnt >> UBIFS_BLOCKS_PER_PAGE_SHIFT; | ||
| 731 | if (!page_cnt) { | ||
| 732 | /* | ||
| 733 | * This happens when there are multiple blocks per page and the | ||
| 734 | * blocks for the first page we are looking for, are not | ||
| 735 | * together. If all the pages were like this, bulk-read would | ||
| 736 | * reduce performance, so we turn it off for a while. | ||
| 737 | */ | ||
| 738 | ui->read_in_a_row = 0; | ||
| 739 | ui->bulk_read = 0; | ||
| 740 | goto out_free; | ||
| 741 | } | ||
| 742 | |||
| 743 | if (bu->cnt) { | ||
| 744 | err = ubifs_tnc_bulk_read(c, bu); | ||
| 745 | if (err) | ||
| 746 | goto out_warn; | ||
| 747 | } | ||
| 748 | |||
| 749 | err = populate_page(c, page1, bu, &n); | ||
| 750 | if (err) | ||
| 751 | goto out_warn; | ||
| 752 | |||
| 753 | unlock_page(page1); | ||
| 754 | ret = 1; | ||
| 755 | |||
| 756 | isize = i_size_read(inode); | ||
| 757 | if (isize == 0) | ||
| 758 | goto out_free; | ||
| 759 | end_index = ((isize - 1) >> PAGE_CACHE_SHIFT); | ||
| 760 | |||
| 761 | for (page_idx = 1; page_idx < page_cnt; page_idx++) { | ||
| 762 | pgoff_t page_offset = offset + page_idx; | ||
| 763 | struct page *page; | ||
| 764 | |||
| 765 | if (page_offset > end_index) | ||
| 766 | break; | ||
| 767 | page = find_or_create_page(mapping, page_offset, | ||
| 768 | GFP_NOFS | __GFP_COLD); | ||
| 769 | if (!page) | ||
| 770 | break; | ||
| 771 | if (!PageUptodate(page)) | ||
| 772 | err = populate_page(c, page, bu, &n); | ||
| 773 | unlock_page(page); | ||
| 774 | page_cache_release(page); | ||
| 775 | if (err) | ||
| 776 | break; | ||
| 777 | } | ||
| 778 | |||
| 779 | ui->last_page_read = offset + page_idx - 1; | ||
| 780 | |||
| 781 | out_free: | ||
| 782 | kfree(bu->buf); | ||
| 783 | kfree(bu); | ||
| 784 | return ret; | ||
| 785 | |||
| 786 | out_warn: | ||
| 787 | ubifs_warn("ignoring error %d and skipping bulk-read", err); | ||
| 788 | goto out_free; | ||
| 789 | } | ||
| 790 | |||
| 791 | /** | ||
| 792 | * ubifs_bulk_read - determine whether to bulk-read and, if so, do it. | ||
| 793 | * @page: page from which to start bulk-read. | ||
| 794 | * | ||
| 795 | * Some flash media are capable of reading sequentially at faster rates. UBIFS | ||
| 796 | * bulk-read facility is designed to take advantage of that, by reading in one | ||
| 797 | * go consecutive data nodes that are also located consecutively in the same | ||
| 798 | * LEB. This function returns %1 if a bulk-read is done and %0 otherwise. | ||
| 799 | */ | ||
| 800 | static int ubifs_bulk_read(struct page *page) | ||
| 801 | { | ||
| 802 | struct inode *inode = page->mapping->host; | ||
| 803 | struct ubifs_info *c = inode->i_sb->s_fs_info; | ||
| 804 | struct ubifs_inode *ui = ubifs_inode(inode); | ||
| 805 | pgoff_t index = page->index, last_page_read = ui->last_page_read; | ||
| 806 | int ret = 0; | ||
| 807 | |||
| 808 | ui->last_page_read = index; | ||
| 809 | |||
| 810 | if (!c->bulk_read) | ||
| 811 | return 0; | ||
| 812 | /* | ||
| 813 | * Bulk-read is protected by ui_mutex, but it is an optimization, so | ||
| 814 | * don't bother if we cannot lock the mutex. | ||
| 815 | */ | ||
| 816 | if (!mutex_trylock(&ui->ui_mutex)) | ||
| 817 | return 0; | ||
| 818 | if (index != last_page_read + 1) { | ||
| 819 | /* Turn off bulk-read if we stop reading sequentially */ | ||
| 820 | ui->read_in_a_row = 1; | ||
| 821 | if (ui->bulk_read) | ||
| 822 | ui->bulk_read = 0; | ||
| 823 | goto out_unlock; | ||
| 824 | } | ||
| 825 | if (!ui->bulk_read) { | ||
| 826 | ui->read_in_a_row += 1; | ||
| 827 | if (ui->read_in_a_row < 3) | ||
| 828 | goto out_unlock; | ||
| 829 | /* Three reads in a row, so switch on bulk-read */ | ||
| 830 | ui->bulk_read = 1; | ||
| 831 | } | ||
| 832 | ret = ubifs_do_bulk_read(c, page); | ||
| 833 | out_unlock: | ||
| 834 | mutex_unlock(&ui->ui_mutex); | ||
| 835 | return ret; | ||
| 836 | } | ||
| 837 | |||
| 580 | static int ubifs_readpage(struct file *file, struct page *page) | 838 | static int ubifs_readpage(struct file *file, struct page *page) |
| 581 | { | 839 | { |
| 840 | if (ubifs_bulk_read(page)) | ||
| 841 | return 0; | ||
| 582 | do_readpage(page); | 842 | do_readpage(page); |
| 583 | unlock_page(page); | 843 | unlock_page(page); |
| 584 | return 0; | 844 | return 0; |
diff --git a/fs/ubifs/find.c b/fs/ubifs/find.c index 47814cde240..717d79c97c5 100644 --- a/fs/ubifs/find.c +++ b/fs/ubifs/find.c | |||
| @@ -901,11 +901,11 @@ static int get_idx_gc_leb(struct ubifs_info *c) | |||
| 901 | * it is needed now for this commit. | 901 | * it is needed now for this commit. |
| 902 | */ | 902 | */ |
| 903 | lp = ubifs_lpt_lookup_dirty(c, lnum); | 903 | lp = ubifs_lpt_lookup_dirty(c, lnum); |
| 904 | if (unlikely(IS_ERR(lp))) | 904 | if (IS_ERR(lp)) |
| 905 | return PTR_ERR(lp); | 905 | return PTR_ERR(lp); |
| 906 | lp = ubifs_change_lp(c, lp, LPROPS_NC, LPROPS_NC, | 906 | lp = ubifs_change_lp(c, lp, LPROPS_NC, LPROPS_NC, |
| 907 | lp->flags | LPROPS_INDEX, -1); | 907 | lp->flags | LPROPS_INDEX, -1); |
| 908 | if (unlikely(IS_ERR(lp))) | 908 | if (IS_ERR(lp)) |
| 909 | return PTR_ERR(lp); | 909 | return PTR_ERR(lp); |
| 910 | dbg_find("LEB %d, dirty %d and free %d flags %#x", | 910 | dbg_find("LEB %d, dirty %d and free %d flags %#x", |
| 911 | lp->lnum, lp->dirty, lp->free, lp->flags); | 911 | lp->lnum, lp->dirty, lp->free, lp->flags); |
diff --git a/fs/ubifs/gc.c b/fs/ubifs/gc.c index 02aba36fe3d..0bef6501d58 100644 --- a/fs/ubifs/gc.c +++ b/fs/ubifs/gc.c | |||
| @@ -96,6 +96,48 @@ static int switch_gc_head(struct ubifs_info *c) | |||
| 96 | } | 96 | } |
| 97 | 97 | ||
| 98 | /** | 98 | /** |
| 99 | * joinup - bring data nodes for an inode together. | ||
| 100 | * @c: UBIFS file-system description object | ||
| 101 | * @sleb: describes scanned LEB | ||
| 102 | * @inum: inode number | ||
| 103 | * @blk: block number | ||
| 104 | * @data: list to which to add data nodes | ||
| 105 | * | ||
| 106 | * This function looks at the first few nodes in the scanned LEB @sleb and adds | ||
| 107 | * them to @data if they are data nodes from @inum and have a larger block | ||
| 108 | * number than @blk. This function returns %0 on success and a negative error | ||
| 109 | * code on failure. | ||
| 110 | */ | ||
| 111 | static int joinup(struct ubifs_info *c, struct ubifs_scan_leb *sleb, ino_t inum, | ||
| 112 | unsigned int blk, struct list_head *data) | ||
| 113 | { | ||
| 114 | int err, cnt = 6, lnum = sleb->lnum, offs; | ||
| 115 | struct ubifs_scan_node *snod, *tmp; | ||
| 116 | union ubifs_key *key; | ||
| 117 | |||
| 118 | list_for_each_entry_safe(snod, tmp, &sleb->nodes, list) { | ||
| 119 | key = &snod->key; | ||
| 120 | if (key_inum(c, key) == inum && | ||
| 121 | key_type(c, key) == UBIFS_DATA_KEY && | ||
| 122 | key_block(c, key) > blk) { | ||
| 123 | offs = snod->offs; | ||
| 124 | err = ubifs_tnc_has_node(c, key, 0, lnum, offs, 0); | ||
| 125 | if (err < 0) | ||
| 126 | return err; | ||
| 127 | list_del(&snod->list); | ||
| 128 | if (err) { | ||
| 129 | list_add_tail(&snod->list, data); | ||
| 130 | blk = key_block(c, key); | ||
| 131 | } else | ||
| 132 | kfree(snod); | ||
| 133 | cnt = 6; | ||
| 134 | } else if (--cnt == 0) | ||
| 135 | break; | ||
| 136 | } | ||
| 137 | return 0; | ||
| 138 | } | ||
| 139 | |||
| 140 | /** | ||
| 99 | * move_nodes - move nodes. | 141 | * move_nodes - move nodes. |
| 100 | * @c: UBIFS file-system description object | 142 | * @c: UBIFS file-system description object |
| 101 | * @sleb: describes nodes to move | 143 | * @sleb: describes nodes to move |
| @@ -116,16 +158,21 @@ static int switch_gc_head(struct ubifs_info *c) | |||
| 116 | static int move_nodes(struct ubifs_info *c, struct ubifs_scan_leb *sleb) | 158 | static int move_nodes(struct ubifs_info *c, struct ubifs_scan_leb *sleb) |
| 117 | { | 159 | { |
| 118 | struct ubifs_scan_node *snod, *tmp; | 160 | struct ubifs_scan_node *snod, *tmp; |
| 119 | struct list_head large, medium, small; | 161 | struct list_head data, large, medium, small; |
| 120 | struct ubifs_wbuf *wbuf = &c->jheads[GCHD].wbuf; | 162 | struct ubifs_wbuf *wbuf = &c->jheads[GCHD].wbuf; |
| 121 | int avail, err, min = INT_MAX; | 163 | int avail, err, min = INT_MAX; |
| 164 | unsigned int blk = 0; | ||
| 165 | ino_t inum = 0; | ||
| 122 | 166 | ||
| 167 | INIT_LIST_HEAD(&data); | ||
| 123 | INIT_LIST_HEAD(&large); | 168 | INIT_LIST_HEAD(&large); |
| 124 | INIT_LIST_HEAD(&medium); | 169 | INIT_LIST_HEAD(&medium); |
| 125 | INIT_LIST_HEAD(&small); | 170 | INIT_LIST_HEAD(&small); |
| 126 | 171 | ||
| 127 | list_for_each_entry_safe(snod, tmp, &sleb->nodes, list) { | 172 | while (!list_empty(&sleb->nodes)) { |
| 128 | struct list_head *lst; | 173 | struct list_head *lst = sleb->nodes.next; |
| 174 | |||
| 175 | snod = list_entry(lst, struct ubifs_scan_node, list); | ||
| 129 | 176 | ||
| 130 | ubifs_assert(snod->type != UBIFS_IDX_NODE); | 177 | ubifs_assert(snod->type != UBIFS_IDX_NODE); |
| 131 | ubifs_assert(snod->type != UBIFS_REF_NODE); | 178 | ubifs_assert(snod->type != UBIFS_REF_NODE); |
| @@ -136,7 +183,6 @@ static int move_nodes(struct ubifs_info *c, struct ubifs_scan_leb *sleb) | |||
| 136 | if (err < 0) | 183 | if (err < 0) |
| 137 | goto out; | 184 | goto out; |
| 138 | 185 | ||
| 139 | lst = &snod->list; | ||
| 140 | list_del(lst); | 186 | list_del(lst); |
| 141 | if (!err) { | 187 | if (!err) { |
| 142 | /* The node is obsolete, remove it from the list */ | 188 | /* The node is obsolete, remove it from the list */ |
| @@ -145,15 +191,30 @@ static int move_nodes(struct ubifs_info *c, struct ubifs_scan_leb *sleb) | |||
| 145 | } | 191 | } |
| 146 | 192 | ||
| 147 | /* | 193 | /* |
| 148 | * Sort the list of nodes so that large nodes go first, and | 194 | * Sort the list of nodes so that data nodes go first, large |
| 149 | * small nodes go last. | 195 | * nodes go second, and small nodes go last. |
| 150 | */ | 196 | */ |
| 151 | if (snod->len > MEDIUM_NODE_WM) | 197 | if (key_type(c, &snod->key) == UBIFS_DATA_KEY) { |
| 152 | list_add(lst, &large); | 198 | if (inum != key_inum(c, &snod->key)) { |
| 199 | if (inum) { | ||
| 200 | /* | ||
| 201 | * Try to move data nodes from the same | ||
| 202 | * inode together. | ||
| 203 | */ | ||
| 204 | err = joinup(c, sleb, inum, blk, &data); | ||
| 205 | if (err) | ||
| 206 | goto out; | ||
| 207 | } | ||
| 208 | inum = key_inum(c, &snod->key); | ||
| 209 | blk = key_block(c, &snod->key); | ||
| 210 | } | ||
| 211 | list_add_tail(lst, &data); | ||
| 212 | } else if (snod->len > MEDIUM_NODE_WM) | ||
| 213 | list_add_tail(lst, &large); | ||
| 153 | else if (snod->len > SMALL_NODE_WM) | 214 | else if (snod->len > SMALL_NODE_WM) |
| 154 | list_add(lst, &medium); | 215 | list_add_tail(lst, &medium); |
| 155 | else | 216 | else |
| 156 | list_add(lst, &small); | 217 | list_add_tail(lst, &small); |
| 157 | 218 | ||
| 158 | /* And find the smallest node */ | 219 | /* And find the smallest node */ |
| 159 | if (snod->len < min) | 220 | if (snod->len < min) |
| @@ -164,6 +225,7 @@ static int move_nodes(struct ubifs_info *c, struct ubifs_scan_leb *sleb) | |||
| 164 | * Join the tree lists so that we'd have one roughly sorted list | 225 | * Join the tree lists so that we'd have one roughly sorted list |
| 165 | * ('large' will be the head of the joined list). | 226 | * ('large' will be the head of the joined list). |
| 166 | */ | 227 | */ |
| 228 | list_splice(&data, &large); | ||
| 167 | list_splice(&medium, large.prev); | 229 | list_splice(&medium, large.prev); |
| 168 | list_splice(&small, large.prev); | 230 | list_splice(&small, large.prev); |
| 169 | 231 | ||
| @@ -653,7 +715,7 @@ int ubifs_gc_start_commit(struct ubifs_info *c) | |||
| 653 | */ | 715 | */ |
| 654 | while (1) { | 716 | while (1) { |
| 655 | lp = ubifs_fast_find_freeable(c); | 717 | lp = ubifs_fast_find_freeable(c); |
| 656 | if (unlikely(IS_ERR(lp))) { | 718 | if (IS_ERR(lp)) { |
| 657 | err = PTR_ERR(lp); | 719 | err = PTR_ERR(lp); |
| 658 | goto out; | 720 | goto out; |
| 659 | } | 721 | } |
| @@ -665,7 +727,7 @@ int ubifs_gc_start_commit(struct ubifs_info *c) | |||
| 665 | if (err) | 727 | if (err) |
| 666 | goto out; | 728 | goto out; |
| 667 | lp = ubifs_change_lp(c, lp, c->leb_size, 0, lp->flags, 0); | 729 | lp = ubifs_change_lp(c, lp, c->leb_size, 0, lp->flags, 0); |
| 668 | if (unlikely(IS_ERR(lp))) { | 730 | if (IS_ERR(lp)) { |
| 669 | err = PTR_ERR(lp); | 731 | err = PTR_ERR(lp); |
| 670 | goto out; | 732 | goto out; |
| 671 | } | 733 | } |
| @@ -680,7 +742,7 @@ int ubifs_gc_start_commit(struct ubifs_info *c) | |||
| 680 | /* Record index freeable LEBs for unmapping after commit */ | 742 | /* Record index freeable LEBs for unmapping after commit */ |
| 681 | while (1) { | 743 | while (1) { |
| 682 | lp = ubifs_fast_find_frdi_idx(c); | 744 | lp = ubifs_fast_find_frdi_idx(c); |
| 683 | if (unlikely(IS_ERR(lp))) { | 745 | if (IS_ERR(lp)) { |
| 684 | err = PTR_ERR(lp); | 746 | err = PTR_ERR(lp); |
| 685 | goto out; | 747 | goto out; |
| 686 | } | 748 | } |
| @@ -696,7 +758,7 @@ int ubifs_gc_start_commit(struct ubifs_info *c) | |||
| 696 | /* Don't release the LEB until after the next commit */ | 758 | /* Don't release the LEB until after the next commit */ |
| 697 | flags = (lp->flags | LPROPS_TAKEN) ^ LPROPS_INDEX; | 759 | flags = (lp->flags | LPROPS_TAKEN) ^ LPROPS_INDEX; |
| 698 | lp = ubifs_change_lp(c, lp, c->leb_size, 0, flags, 1); | 760 | lp = ubifs_change_lp(c, lp, c->leb_size, 0, flags, 1); |
| 699 | if (unlikely(IS_ERR(lp))) { | 761 | if (IS_ERR(lp)) { |
| 700 | err = PTR_ERR(lp); | 762 | err = PTR_ERR(lp); |
| 701 | kfree(idx_gc); | 763 | kfree(idx_gc); |
| 702 | goto out; | 764 | goto out; |
diff --git a/fs/ubifs/io.c b/fs/ubifs/io.c index 054363f2b20..01682713af6 100644 --- a/fs/ubifs/io.c +++ b/fs/ubifs/io.c | |||
| @@ -62,6 +62,7 @@ void ubifs_ro_mode(struct ubifs_info *c, int err) | |||
| 62 | { | 62 | { |
| 63 | if (!c->ro_media) { | 63 | if (!c->ro_media) { |
| 64 | c->ro_media = 1; | 64 | c->ro_media = 1; |
| 65 | c->no_chk_data_crc = 0; | ||
| 65 | ubifs_warn("switched to read-only mode, error %d", err); | 66 | ubifs_warn("switched to read-only mode, error %d", err); |
| 66 | dbg_dump_stack(); | 67 | dbg_dump_stack(); |
| 67 | } | 68 | } |
| @@ -74,6 +75,7 @@ void ubifs_ro_mode(struct ubifs_info *c, int err) | |||
| 74 | * @lnum: logical eraseblock number | 75 | * @lnum: logical eraseblock number |
| 75 | * @offs: offset within the logical eraseblock | 76 | * @offs: offset within the logical eraseblock |
| 76 | * @quiet: print no messages | 77 | * @quiet: print no messages |
| 78 | * @chk_crc: indicates whether to always check the CRC | ||
| 77 | * | 79 | * |
| 78 | * This function checks node magic number and CRC checksum. This function also | 80 | * This function checks node magic number and CRC checksum. This function also |
| 79 | * validates node length to prevent UBIFS from becoming crazy when an attacker | 81 | * validates node length to prevent UBIFS from becoming crazy when an attacker |
| @@ -85,7 +87,7 @@ void ubifs_ro_mode(struct ubifs_info *c, int err) | |||
| 85 | * or magic. | 87 | * or magic. |
| 86 | */ | 88 | */ |
| 87 | int ubifs_check_node(const struct ubifs_info *c, const void *buf, int lnum, | 89 | int ubifs_check_node(const struct ubifs_info *c, const void *buf, int lnum, |
| 88 | int offs, int quiet) | 90 | int offs, int quiet, int chk_crc) |
| 89 | { | 91 | { |
| 90 | int err = -EINVAL, type, node_len; | 92 | int err = -EINVAL, type, node_len; |
| 91 | uint32_t crc, node_crc, magic; | 93 | uint32_t crc, node_crc, magic; |
| @@ -121,6 +123,10 @@ int ubifs_check_node(const struct ubifs_info *c, const void *buf, int lnum, | |||
| 121 | node_len > c->ranges[type].max_len) | 123 | node_len > c->ranges[type].max_len) |
| 122 | goto out_len; | 124 | goto out_len; |
| 123 | 125 | ||
| 126 | if (!chk_crc && type == UBIFS_DATA_NODE && !c->always_chk_crc) | ||
| 127 | if (c->no_chk_data_crc) | ||
| 128 | return 0; | ||
| 129 | |||
| 124 | crc = crc32(UBIFS_CRC32_INIT, buf + 8, node_len - 8); | 130 | crc = crc32(UBIFS_CRC32_INIT, buf + 8, node_len - 8); |
| 125 | node_crc = le32_to_cpu(ch->crc); | 131 | node_crc = le32_to_cpu(ch->crc); |
| 126 | if (crc != node_crc) { | 132 | if (crc != node_crc) { |
| @@ -722,7 +728,7 @@ int ubifs_read_node_wbuf(struct ubifs_wbuf *wbuf, void *buf, int type, int len, | |||
| 722 | goto out; | 728 | goto out; |
| 723 | } | 729 | } |
| 724 | 730 | ||
| 725 | err = ubifs_check_node(c, buf, lnum, offs, 0); | 731 | err = ubifs_check_node(c, buf, lnum, offs, 0, 0); |
| 726 | if (err) { | 732 | if (err) { |
| 727 | ubifs_err("expected node type %d", type); | 733 | ubifs_err("expected node type %d", type); |
| 728 | return err; | 734 | return err; |
| @@ -781,7 +787,7 @@ int ubifs_read_node(const struct ubifs_info *c, void *buf, int type, int len, | |||
| 781 | goto out; | 787 | goto out; |
| 782 | } | 788 | } |
| 783 | 789 | ||
| 784 | err = ubifs_check_node(c, buf, lnum, offs, 0); | 790 | err = ubifs_check_node(c, buf, lnum, offs, 0, 0); |
| 785 | if (err) { | 791 | if (err) { |
| 786 | ubifs_err("expected node type %d", type); | 792 | ubifs_err("expected node type %d", type); |
| 787 | return err; | 793 | return err; |
diff --git a/fs/ubifs/key.h b/fs/ubifs/key.h index 8f747600754..9ee65086f62 100644 --- a/fs/ubifs/key.h +++ b/fs/ubifs/key.h | |||
| @@ -484,7 +484,7 @@ static inline void key_copy(const struct ubifs_info *c, | |||
| 484 | * @key2: the second key to compare | 484 | * @key2: the second key to compare |
| 485 | * | 485 | * |
| 486 | * This function compares 2 keys and returns %-1 if @key1 is less than | 486 | * This function compares 2 keys and returns %-1 if @key1 is less than |
| 487 | * @key2, 0 if the keys are equivalent and %1 if @key1 is greater than @key2. | 487 | * @key2, %0 if the keys are equivalent and %1 if @key1 is greater than @key2. |
| 488 | */ | 488 | */ |
| 489 | static inline int keys_cmp(const struct ubifs_info *c, | 489 | static inline int keys_cmp(const struct ubifs_info *c, |
| 490 | const union ubifs_key *key1, | 490 | const union ubifs_key *key1, |
| @@ -503,6 +503,26 @@ static inline int keys_cmp(const struct ubifs_info *c, | |||
| 503 | } | 503 | } |
| 504 | 504 | ||
| 505 | /** | 505 | /** |
| 506 | * keys_eq - determine if keys are equivalent. | ||
| 507 | * @c: UBIFS file-system description object | ||
| 508 | * @key1: the first key to compare | ||
| 509 | * @key2: the second key to compare | ||
| 510 | * | ||
| 511 | * This function compares 2 keys and returns %1 if @key1 is equal to @key2 and | ||
| 512 | * %0 if not. | ||
| 513 | */ | ||
| 514 | static inline int keys_eq(const struct ubifs_info *c, | ||
| 515 | const union ubifs_key *key1, | ||
| 516 | const union ubifs_key *key2) | ||
| 517 | { | ||
| 518 | if (key1->u32[0] != key2->u32[0]) | ||
| 519 | return 0; | ||
| 520 | if (key1->u32[1] != key2->u32[1]) | ||
| 521 | return 0; | ||
| 522 | return 1; | ||
| 523 | } | ||
| 524 | |||
| 525 | /** | ||
| 506 | * is_hash_key - is a key vulnerable to hash collisions. | 526 | * is_hash_key - is a key vulnerable to hash collisions. |
| 507 | * @c: UBIFS file-system description object | 527 | * @c: UBIFS file-system description object |
| 508 | * @key: key | 528 | * @key: key |
diff --git a/fs/ubifs/lprops.c b/fs/ubifs/lprops.c index 2ba93da71b6..f27176e9b70 100644 --- a/fs/ubifs/lprops.c +++ b/fs/ubifs/lprops.c | |||
| @@ -125,6 +125,7 @@ static void adjust_lpt_heap(struct ubifs_info *c, struct ubifs_lpt_heap *heap, | |||
| 125 | } | 125 | } |
| 126 | } | 126 | } |
| 127 | } | 127 | } |
| 128 | |||
| 128 | /* Not greater than parent, so compare to children */ | 129 | /* Not greater than parent, so compare to children */ |
| 129 | while (1) { | 130 | while (1) { |
| 130 | /* Compare to left child */ | 131 | /* Compare to left child */ |
| @@ -460,18 +461,6 @@ static void change_category(struct ubifs_info *c, struct ubifs_lprops *lprops) | |||
| 460 | } | 461 | } |
| 461 | 462 | ||
| 462 | /** | 463 | /** |
| 463 | * ubifs_get_lprops - get reference to LEB properties. | ||
| 464 | * @c: the UBIFS file-system description object | ||
| 465 | * | ||
| 466 | * This function locks lprops. Lprops have to be unlocked by | ||
| 467 | * 'ubifs_release_lprops()'. | ||
| 468 | */ | ||
| 469 | void ubifs_get_lprops(struct ubifs_info *c) | ||
| 470 | { | ||
| 471 | mutex_lock(&c->lp_mutex); | ||
| 472 | } | ||
| 473 | |||
| 474 | /** | ||
| 475 | * calc_dark - calculate LEB dark space size. | 464 | * calc_dark - calculate LEB dark space size. |
| 476 | * @c: the UBIFS file-system description object | 465 | * @c: the UBIFS file-system description object |
| 477 | * @spc: amount of free and dirty space in the LEB | 466 | * @spc: amount of free and dirty space in the LEB |
| @@ -576,7 +565,6 @@ const struct ubifs_lprops *ubifs_change_lp(struct ubifs_info *c, | |||
| 576 | ubifs_assert(!(lprops->free & 7) && !(lprops->dirty & 7)); | 565 | ubifs_assert(!(lprops->free & 7) && !(lprops->dirty & 7)); |
| 577 | 566 | ||
| 578 | spin_lock(&c->space_lock); | 567 | spin_lock(&c->space_lock); |
| 579 | |||
| 580 | if ((lprops->flags & LPROPS_TAKEN) && lprops->free == c->leb_size) | 568 | if ((lprops->flags & LPROPS_TAKEN) && lprops->free == c->leb_size) |
| 581 | c->lst.taken_empty_lebs -= 1; | 569 | c->lst.taken_empty_lebs -= 1; |
| 582 | 570 | ||
| @@ -637,31 +625,12 @@ const struct ubifs_lprops *ubifs_change_lp(struct ubifs_info *c, | |||
| 637 | c->lst.taken_empty_lebs += 1; | 625 | c->lst.taken_empty_lebs += 1; |
| 638 | 626 | ||
| 639 | change_category(c, lprops); | 627 | change_category(c, lprops); |
| 640 | |||
| 641 | c->idx_gc_cnt += idx_gc_cnt; | 628 | c->idx_gc_cnt += idx_gc_cnt; |
| 642 | |||
| 643 | spin_unlock(&c->space_lock); | 629 | spin_unlock(&c->space_lock); |
| 644 | |||
| 645 | return lprops; | 630 | return lprops; |
| 646 | } | 631 | } |
| 647 | 632 | ||
| 648 | /** | 633 | /** |
| 649 | * ubifs_release_lprops - release lprops lock. | ||
| 650 | * @c: the UBIFS file-system description object | ||
| 651 | * | ||
| 652 | * This function has to be called after each 'ubifs_get_lprops()' call to | ||
| 653 | * unlock lprops. | ||
| 654 | */ | ||
| 655 | void ubifs_release_lprops(struct ubifs_info *c) | ||
| 656 | { | ||
| 657 | ubifs_assert(mutex_is_locked(&c->lp_mutex)); | ||
| 658 | ubifs_assert(c->lst.empty_lebs >= 0 && | ||
| 659 | c->lst.empty_lebs <= c->main_lebs); | ||
| 660 | |||
| 661 | mutex_unlock(&c->lp_mutex); | ||
| 662 | } | ||
| 663 | |||
| 664 | /** | ||
| 665 | * ubifs_get_lp_stats - get lprops statistics. | 634 | * ubifs_get_lp_stats - get lprops statistics. |
| 666 | * @c: UBIFS file-system description object | 635 | * @c: UBIFS file-system description object |
| 667 | * @st: return statistics | 636 | * @st: return statistics |
| @@ -1262,7 +1231,6 @@ static int scan_check_cb(struct ubifs_info *c, | |||
| 1262 | } | 1231 | } |
| 1263 | 1232 | ||
| 1264 | ubifs_scan_destroy(sleb); | 1233 | ubifs_scan_destroy(sleb); |
| 1265 | |||
| 1266 | return LPT_SCAN_CONTINUE; | 1234 | return LPT_SCAN_CONTINUE; |
| 1267 | 1235 | ||
| 1268 | out_print: | 1236 | out_print: |
diff --git a/fs/ubifs/lpt.c b/fs/ubifs/lpt.c index 9ff2463177e..db8bd0e518b 100644 --- a/fs/ubifs/lpt.c +++ b/fs/ubifs/lpt.c | |||
| @@ -109,7 +109,8 @@ static void do_calc_lpt_geom(struct ubifs_info *c) | |||
| 109 | c->lpt_sz = (long long)c->pnode_cnt * c->pnode_sz; | 109 | c->lpt_sz = (long long)c->pnode_cnt * c->pnode_sz; |
| 110 | c->lpt_sz += (long long)c->nnode_cnt * c->nnode_sz; | 110 | c->lpt_sz += (long long)c->nnode_cnt * c->nnode_sz; |
| 111 | c->lpt_sz += c->ltab_sz; | 111 | c->lpt_sz += c->ltab_sz; |
| 112 | c->lpt_sz += c->lsave_sz; | 112 | if (c->big_lpt) |
| 113 | c->lpt_sz += c->lsave_sz; | ||
| 113 | 114 | ||
| 114 | /* Add wastage */ | 115 | /* Add wastage */ |
| 115 | sz = c->lpt_sz; | 116 | sz = c->lpt_sz; |
| @@ -287,25 +288,56 @@ uint32_t ubifs_unpack_bits(uint8_t **addr, int *pos, int nrbits) | |||
| 287 | const int k = 32 - nrbits; | 288 | const int k = 32 - nrbits; |
| 288 | uint8_t *p = *addr; | 289 | uint8_t *p = *addr; |
| 289 | int b = *pos; | 290 | int b = *pos; |
| 290 | uint32_t val; | 291 | uint32_t uninitialized_var(val); |
| 292 | const int bytes = (nrbits + b + 7) >> 3; | ||
| 291 | 293 | ||
| 292 | ubifs_assert(nrbits > 0); | 294 | ubifs_assert(nrbits > 0); |
| 293 | ubifs_assert(nrbits <= 32); | 295 | ubifs_assert(nrbits <= 32); |
| 294 | ubifs_assert(*pos >= 0); | 296 | ubifs_assert(*pos >= 0); |
| 295 | ubifs_assert(*pos < 8); | 297 | ubifs_assert(*pos < 8); |
| 296 | if (b) { | 298 | if (b) { |
| 297 | val = p[1] | ((uint32_t)p[2] << 8) | ((uint32_t)p[3] << 16) | | 299 | switch (bytes) { |
| 298 | ((uint32_t)p[4] << 24); | 300 | case 2: |
| 301 | val = p[1]; | ||
| 302 | break; | ||
| 303 | case 3: | ||
| 304 | val = p[1] | ((uint32_t)p[2] << 8); | ||
| 305 | break; | ||
| 306 | case 4: | ||
| 307 | val = p[1] | ((uint32_t)p[2] << 8) | | ||
| 308 | ((uint32_t)p[3] << 16); | ||
| 309 | break; | ||
| 310 | case 5: | ||
| 311 | val = p[1] | ((uint32_t)p[2] << 8) | | ||
| 312 | ((uint32_t)p[3] << 16) | | ||
| 313 | ((uint32_t)p[4] << 24); | ||
| 314 | } | ||
| 299 | val <<= (8 - b); | 315 | val <<= (8 - b); |
| 300 | val |= *p >> b; | 316 | val |= *p >> b; |
| 301 | nrbits += b; | 317 | nrbits += b; |
| 302 | } else | 318 | } else { |
| 303 | val = p[0] | ((uint32_t)p[1] << 8) | ((uint32_t)p[2] << 16) | | 319 | switch (bytes) { |
| 304 | ((uint32_t)p[3] << 24); | 320 | case 1: |
| 321 | val = p[0]; | ||
| 322 | break; | ||
| 323 | case 2: | ||
| 324 | val = p[0] | ((uint32_t)p[1] << 8); | ||
| 325 | break; | ||
| 326 | case 3: | ||
| 327 | val = p[0] | ((uint32_t)p[1] << 8) | | ||
| 328 | ((uint32_t)p[2] << 16); | ||
| 329 | break; | ||
| 330 | case 4: | ||
| 331 | val = p[0] | ((uint32_t)p[1] << 8) | | ||
| 332 | ((uint32_t)p[2] << 16) | | ||
| 333 | ((uint32_t)p[3] << 24); | ||
| 334 | break; | ||
| 335 | } | ||
| 336 | } | ||
| 305 | val <<= k; | 337 | val <<= k; |
| 306 | val >>= k; | 338 | val >>= k; |
| 307 | b = nrbits & 7; | 339 | b = nrbits & 7; |
| 308 | p += nrbits / 8; | 340 | p += nrbits >> 3; |
| 309 | *addr = p; | 341 | *addr = p; |
| 310 | *pos = b; | 342 | *pos = b; |
| 311 | ubifs_assert((val >> nrbits) == 0 || nrbits - b == 32); | 343 | ubifs_assert((val >> nrbits) == 0 || nrbits - b == 32); |
diff --git a/fs/ubifs/lpt_commit.c b/fs/ubifs/lpt_commit.c index 5f0b83e20af..eed5a0025d6 100644 --- a/fs/ubifs/lpt_commit.c +++ b/fs/ubifs/lpt_commit.c | |||
| @@ -177,8 +177,6 @@ static int alloc_lpt_leb(struct ubifs_info *c, int *lnum) | |||
| 177 | return 0; | 177 | return 0; |
| 178 | } | 178 | } |
| 179 | } | 179 | } |
| 180 | dbg_err("last LEB %d", *lnum); | ||
| 181 | dump_stack(); | ||
| 182 | return -ENOSPC; | 180 | return -ENOSPC; |
| 183 | } | 181 | } |
| 184 | 182 | ||
| @@ -193,6 +191,9 @@ static int layout_cnodes(struct ubifs_info *c) | |||
| 193 | int lnum, offs, len, alen, done_lsave, done_ltab, err; | 191 | int lnum, offs, len, alen, done_lsave, done_ltab, err; |
| 194 | struct ubifs_cnode *cnode; | 192 | struct ubifs_cnode *cnode; |
| 195 | 193 | ||
| 194 | err = dbg_chk_lpt_sz(c, 0, 0); | ||
| 195 | if (err) | ||
| 196 | return err; | ||
| 196 | cnode = c->lpt_cnext; | 197 | cnode = c->lpt_cnext; |
| 197 | if (!cnode) | 198 | if (!cnode) |
| 198 | return 0; | 199 | return 0; |
| @@ -206,6 +207,7 @@ static int layout_cnodes(struct ubifs_info *c) | |||
| 206 | c->lsave_lnum = lnum; | 207 | c->lsave_lnum = lnum; |
| 207 | c->lsave_offs = offs; | 208 | c->lsave_offs = offs; |
| 208 | offs += c->lsave_sz; | 209 | offs += c->lsave_sz; |
| 210 | dbg_chk_lpt_sz(c, 1, c->lsave_sz); | ||
| 209 | } | 211 | } |
| 210 | 212 | ||
| 211 | if (offs + c->ltab_sz <= c->leb_size) { | 213 | if (offs + c->ltab_sz <= c->leb_size) { |
| @@ -213,6 +215,7 @@ static int layout_cnodes(struct ubifs_info *c) | |||
| 213 | c->ltab_lnum = lnum; | 215 | c->ltab_lnum = lnum; |
| 214 | c->ltab_offs = offs; | 216 | c->ltab_offs = offs; |
| 215 | offs += c->ltab_sz; | 217 | offs += c->ltab_sz; |
| 218 | dbg_chk_lpt_sz(c, 1, c->ltab_sz); | ||
| 216 | } | 219 | } |
| 217 | 220 | ||
| 218 | do { | 221 | do { |
| @@ -226,9 +229,10 @@ static int layout_cnodes(struct ubifs_info *c) | |||
| 226 | while (offs + len > c->leb_size) { | 229 | while (offs + len > c->leb_size) { |
| 227 | alen = ALIGN(offs, c->min_io_size); | 230 | alen = ALIGN(offs, c->min_io_size); |
| 228 | upd_ltab(c, lnum, c->leb_size - alen, alen - offs); | 231 | upd_ltab(c, lnum, c->leb_size - alen, alen - offs); |
| 232 | dbg_chk_lpt_sz(c, 2, alen - offs); | ||
| 229 | err = alloc_lpt_leb(c, &lnum); | 233 | err = alloc_lpt_leb(c, &lnum); |
| 230 | if (err) | 234 | if (err) |
| 231 | return err; | 235 | goto no_space; |
| 232 | offs = 0; | 236 | offs = 0; |
| 233 | ubifs_assert(lnum >= c->lpt_first && | 237 | ubifs_assert(lnum >= c->lpt_first && |
| 234 | lnum <= c->lpt_last); | 238 | lnum <= c->lpt_last); |
| @@ -238,6 +242,7 @@ static int layout_cnodes(struct ubifs_info *c) | |||
| 238 | c->lsave_lnum = lnum; | 242 | c->lsave_lnum = lnum; |
| 239 | c->lsave_offs = offs; | 243 | c->lsave_offs = offs; |
| 240 | offs += c->lsave_sz; | 244 | offs += c->lsave_sz; |
| 245 | dbg_chk_lpt_sz(c, 1, c->lsave_sz); | ||
| 241 | continue; | 246 | continue; |
| 242 | } | 247 | } |
| 243 | if (!done_ltab) { | 248 | if (!done_ltab) { |
| @@ -245,6 +250,7 @@ static int layout_cnodes(struct ubifs_info *c) | |||
| 245 | c->ltab_lnum = lnum; | 250 | c->ltab_lnum = lnum; |
| 246 | c->ltab_offs = offs; | 251 | c->ltab_offs = offs; |
| 247 | offs += c->ltab_sz; | 252 | offs += c->ltab_sz; |
| 253 | dbg_chk_lpt_sz(c, 1, c->ltab_sz); | ||
| 248 | continue; | 254 | continue; |
| 249 | } | 255 | } |
| 250 | break; | 256 | break; |
| @@ -257,6 +263,7 @@ static int layout_cnodes(struct ubifs_info *c) | |||
| 257 | c->lpt_offs = offs; | 263 | c->lpt_offs = offs; |
| 258 | } | 264 | } |
| 259 | offs += len; | 265 | offs += len; |
| 266 | dbg_chk_lpt_sz(c, 1, len); | ||
| 260 | cnode = cnode->cnext; | 267 | cnode = cnode->cnext; |
| 261 | } while (cnode && cnode != c->lpt_cnext); | 268 | } while (cnode && cnode != c->lpt_cnext); |
| 262 | 269 | ||
| @@ -265,9 +272,10 @@ static int layout_cnodes(struct ubifs_info *c) | |||
| 265 | if (offs + c->lsave_sz > c->leb_size) { | 272 | if (offs + c->lsave_sz > c->leb_size) { |
| 266 | alen = ALIGN(offs, c->min_io_size); | 273 | alen = ALIGN(offs, c->min_io_size); |
| 267 | upd_ltab(c, lnum, c->leb_size - alen, alen - offs); | 274 | upd_ltab(c, lnum, c->leb_size - alen, alen - offs); |
| 275 | dbg_chk_lpt_sz(c, 2, alen - offs); | ||
| 268 | err = alloc_lpt_leb(c, &lnum); | 276 | err = alloc_lpt_leb(c, &lnum); |
| 269 | if (err) | 277 | if (err) |
| 270 | return err; | 278 | goto no_space; |
| 271 | offs = 0; | 279 | offs = 0; |
| 272 | ubifs_assert(lnum >= c->lpt_first && | 280 | ubifs_assert(lnum >= c->lpt_first && |
| 273 | lnum <= c->lpt_last); | 281 | lnum <= c->lpt_last); |
| @@ -276,6 +284,7 @@ static int layout_cnodes(struct ubifs_info *c) | |||
| 276 | c->lsave_lnum = lnum; | 284 | c->lsave_lnum = lnum; |
| 277 | c->lsave_offs = offs; | 285 | c->lsave_offs = offs; |
| 278 | offs += c->lsave_sz; | 286 | offs += c->lsave_sz; |
| 287 | dbg_chk_lpt_sz(c, 1, c->lsave_sz); | ||
| 279 | } | 288 | } |
| 280 | 289 | ||
| 281 | /* Make sure to place LPT's own lprops table */ | 290 | /* Make sure to place LPT's own lprops table */ |
| @@ -283,9 +292,10 @@ static int layout_cnodes(struct ubifs_info *c) | |||
| 283 | if (offs + c->ltab_sz > c->leb_size) { | 292 | if (offs + c->ltab_sz > c->leb_size) { |
| 284 | alen = ALIGN(offs, c->min_io_size); | 293 | alen = ALIGN(offs, c->min_io_size); |
| 285 | upd_ltab(c, lnum, c->leb_size - alen, alen - offs); | 294 | upd_ltab(c, lnum, c->leb_size - alen, alen - offs); |
| 295 | dbg_chk_lpt_sz(c, 2, alen - offs); | ||
| 286 | err = alloc_lpt_leb(c, &lnum); | 296 | err = alloc_lpt_leb(c, &lnum); |
| 287 | if (err) | 297 | if (err) |
| 288 | return err; | 298 | goto no_space; |
| 289 | offs = 0; | 299 | offs = 0; |
| 290 | ubifs_assert(lnum >= c->lpt_first && | 300 | ubifs_assert(lnum >= c->lpt_first && |
| 291 | lnum <= c->lpt_last); | 301 | lnum <= c->lpt_last); |
| @@ -294,11 +304,23 @@ static int layout_cnodes(struct ubifs_info *c) | |||
| 294 | c->ltab_lnum = lnum; | 304 | c->ltab_lnum = lnum; |
| 295 | c->ltab_offs = offs; | 305 | c->ltab_offs = offs; |
| 296 | offs += c->ltab_sz; | 306 | offs += c->ltab_sz; |
| 307 | dbg_chk_lpt_sz(c, 1, c->ltab_sz); | ||
| 297 | } | 308 | } |
| 298 | 309 | ||
| 299 | alen = ALIGN(offs, c->min_io_size); | 310 | alen = ALIGN(offs, c->min_io_size); |
| 300 | upd_ltab(c, lnum, c->leb_size - alen, alen - offs); | 311 | upd_ltab(c, lnum, c->leb_size - alen, alen - offs); |
| 312 | dbg_chk_lpt_sz(c, 4, alen - offs); | ||
| 313 | err = dbg_chk_lpt_sz(c, 3, alen); | ||
| 314 | if (err) | ||
| 315 | return err; | ||
| 301 | return 0; | 316 | return 0; |
| 317 | |||
| 318 | no_space: | ||
| 319 | ubifs_err("LPT out of space"); | ||
| 320 | dbg_err("LPT out of space at LEB %d:%d needing %d, done_ltab %d, " | ||
| 321 | "done_lsave %d", lnum, offs, len, done_ltab, done_lsave); | ||
| 322 | dbg_dump_lpt_info(c); | ||
| 323 | return err; | ||
| 302 | } | 324 | } |
| 303 | 325 | ||
| 304 | /** | 326 | /** |
| @@ -333,8 +355,6 @@ static int realloc_lpt_leb(struct ubifs_info *c, int *lnum) | |||
| 333 | *lnum = i + c->lpt_first; | 355 | *lnum = i + c->lpt_first; |
| 334 | return 0; | 356 | return 0; |
| 335 | } | 357 | } |
| 336 | dbg_err("last LEB %d", *lnum); | ||
| 337 | dump_stack(); | ||
| 338 | return -ENOSPC; | 358 | return -ENOSPC; |
| 339 | } | 359 | } |
| 340 | 360 | ||
| @@ -369,12 +389,14 @@ static int write_cnodes(struct ubifs_info *c) | |||
| 369 | done_lsave = 1; | 389 | done_lsave = 1; |
| 370 | ubifs_pack_lsave(c, buf + offs, c->lsave); | 390 | ubifs_pack_lsave(c, buf + offs, c->lsave); |
| 371 | offs += c->lsave_sz; | 391 | offs += c->lsave_sz; |
| 392 | dbg_chk_lpt_sz(c, 1, c->lsave_sz); | ||
| 372 | } | 393 | } |
| 373 | 394 | ||
| 374 | if (offs + c->ltab_sz <= c->leb_size) { | 395 | if (offs + c->ltab_sz <= c->leb_size) { |
| 375 | done_ltab = 1; | 396 | done_ltab = 1; |
| 376 | ubifs_pack_ltab(c, buf + offs, c->ltab_cmt); | 397 | ubifs_pack_ltab(c, buf + offs, c->ltab_cmt); |
| 377 | offs += c->ltab_sz; | 398 | offs += c->ltab_sz; |
| 399 | dbg_chk_lpt_sz(c, 1, c->ltab_sz); | ||
| 378 | } | 400 | } |
| 379 | 401 | ||
| 380 | /* Loop for each cnode */ | 402 | /* Loop for each cnode */ |
| @@ -392,10 +414,12 @@ static int write_cnodes(struct ubifs_info *c) | |||
| 392 | alen, UBI_SHORTTERM); | 414 | alen, UBI_SHORTTERM); |
| 393 | if (err) | 415 | if (err) |
| 394 | return err; | 416 | return err; |
| 417 | dbg_chk_lpt_sz(c, 4, alen - wlen); | ||
| 395 | } | 418 | } |
| 419 | dbg_chk_lpt_sz(c, 2, 0); | ||
| 396 | err = realloc_lpt_leb(c, &lnum); | 420 | err = realloc_lpt_leb(c, &lnum); |
| 397 | if (err) | 421 | if (err) |
| 398 | return err; | 422 | goto no_space; |
| 399 | offs = 0; | 423 | offs = 0; |
| 400 | from = 0; | 424 | from = 0; |
| 401 | ubifs_assert(lnum >= c->lpt_first && | 425 | ubifs_assert(lnum >= c->lpt_first && |
| @@ -408,12 +432,14 @@ static int write_cnodes(struct ubifs_info *c) | |||
| 408 | done_lsave = 1; | 432 | done_lsave = 1; |
| 409 | ubifs_pack_lsave(c, buf + offs, c->lsave); | 433 | ubifs_pack_lsave(c, buf + offs, c->lsave); |
| 410 | offs += c->lsave_sz; | 434 | offs += c->lsave_sz; |
| 435 | dbg_chk_lpt_sz(c, 1, c->lsave_sz); | ||
| 411 | continue; | 436 | continue; |
| 412 | } | 437 | } |
| 413 | if (!done_ltab) { | 438 | if (!done_ltab) { |
| 414 | done_ltab = 1; | 439 | done_ltab = 1; |
| 415 | ubifs_pack_ltab(c, buf + offs, c->ltab_cmt); | 440 | ubifs_pack_ltab(c, buf + offs, c->ltab_cmt); |
| 416 | offs += c->ltab_sz; | 441 | offs += c->ltab_sz; |
| 442 | dbg_chk_lpt_sz(c, 1, c->ltab_sz); | ||
| 417 | continue; | 443 | continue; |
| 418 | } | 444 | } |
| 419 | break; | 445 | break; |
| @@ -435,6 +461,7 @@ static int write_cnodes(struct ubifs_info *c) | |||
| 435 | clear_bit(COW_ZNODE, &cnode->flags); | 461 | clear_bit(COW_ZNODE, &cnode->flags); |
| 436 | smp_mb__after_clear_bit(); | 462 | smp_mb__after_clear_bit(); |
| 437 | offs += len; | 463 | offs += len; |
| 464 | dbg_chk_lpt_sz(c, 1, len); | ||
| 438 | cnode = cnode->cnext; | 465 | cnode = cnode->cnext; |
| 439 | } while (cnode && cnode != c->lpt_cnext); | 466 | } while (cnode && cnode != c->lpt_cnext); |
| 440 | 467 | ||
| @@ -448,9 +475,10 @@ static int write_cnodes(struct ubifs_info *c) | |||
| 448 | UBI_SHORTTERM); | 475 | UBI_SHORTTERM); |
| 449 | if (err) | 476 | if (err) |
| 450 | return err; | 477 | return err; |
| 478 | dbg_chk_lpt_sz(c, 2, alen - wlen); | ||
| 451 | err = realloc_lpt_leb(c, &lnum); | 479 | err = realloc_lpt_leb(c, &lnum); |
| 452 | if (err) | 480 | if (err) |
| 453 | return err; | 481 | goto no_space; |
| 454 | offs = 0; | 482 | offs = 0; |
| 455 | ubifs_assert(lnum >= c->lpt_first && | 483 | ubifs_assert(lnum >= c->lpt_first && |
| 456 | lnum <= c->lpt_last); | 484 | lnum <= c->lpt_last); |
| @@ -461,6 +489,7 @@ static int write_cnodes(struct ubifs_info *c) | |||
| 461 | done_lsave = 1; | 489 | done_lsave = 1; |
| 462 | ubifs_pack_lsave(c, buf + offs, c->lsave); | 490 | ubifs_pack_lsave(c, buf + offs, c->lsave); |
| 463 | offs += c->lsave_sz; | 491 | offs += c->lsave_sz; |
| 492 | dbg_chk_lpt_sz(c, 1, c->lsave_sz); | ||
| 464 | } | 493 | } |
| 465 | 494 | ||
| 466 | /* Make sure to place LPT's own lprops table */ | 495 | /* Make sure to place LPT's own lprops table */ |
| @@ -473,9 +502,10 @@ static int write_cnodes(struct ubifs_info *c) | |||
| 473 | UBI_SHORTTERM); | 502 | UBI_SHORTTERM); |
| 474 | if (err) | 503 | if (err) |
| 475 | return err; | 504 | return err; |
| 505 | dbg_chk_lpt_sz(c, 2, alen - wlen); | ||
| 476 | err = realloc_lpt_leb(c, &lnum); | 506 | err = realloc_lpt_leb(c, &lnum); |
| 477 | if (err) | 507 | if (err) |
| 478 | return err; | 508 | goto no_space; |
| 479 | offs = 0; | 509 | offs = 0; |
| 480 | ubifs_assert(lnum >= c->lpt_first && | 510 | ubifs_assert(lnum >= c->lpt_first && |
| 481 | lnum <= c->lpt_last); | 511 | lnum <= c->lpt_last); |
| @@ -486,6 +516,7 @@ static int write_cnodes(struct ubifs_info *c) | |||
| 486 | done_ltab = 1; | 516 | done_ltab = 1; |
| 487 | ubifs_pack_ltab(c, buf + offs, c->ltab_cmt); | 517 | ubifs_pack_ltab(c, buf + offs, c->ltab_cmt); |
| 488 | offs += c->ltab_sz; | 518 | offs += c->ltab_sz; |
| 519 | dbg_chk_lpt_sz(c, 1, c->ltab_sz); | ||
| 489 | } | 520 | } |
| 490 | 521 | ||
| 491 | /* Write remaining data in buffer */ | 522 | /* Write remaining data in buffer */ |
| @@ -495,6 +526,12 @@ static int write_cnodes(struct ubifs_info *c) | |||
| 495 | err = ubifs_leb_write(c, lnum, buf + from, from, alen, UBI_SHORTTERM); | 526 | err = ubifs_leb_write(c, lnum, buf + from, from, alen, UBI_SHORTTERM); |
| 496 | if (err) | 527 | if (err) |
| 497 | return err; | 528 | return err; |
| 529 | |||
| 530 | dbg_chk_lpt_sz(c, 4, alen - wlen); | ||
| 531 | err = dbg_chk_lpt_sz(c, 3, ALIGN(offs, c->min_io_size)); | ||
| 532 | if (err) | ||
| 533 | return err; | ||
| 534 | |||
| 498 | c->nhead_lnum = lnum; | 535 | c->nhead_lnum = lnum; |
| 499 | c->nhead_offs = ALIGN(offs, c->min_io_size); | 536 | c->nhead_offs = ALIGN(offs, c->min_io_size); |
| 500 | 537 | ||
| @@ -503,7 +540,15 @@ static int write_cnodes(struct ubifs_info *c) | |||
| 503 | dbg_lp("LPT ltab is at %d:%d", c->ltab_lnum, c->ltab_offs); | 540 | dbg_lp("LPT ltab is at %d:%d", c->ltab_lnum, c->ltab_offs); |
| 504 | if (c->big_lpt) | 541 | if (c->big_lpt) |
| 505 | dbg_lp("LPT lsave is at %d:%d", c->lsave_lnum, c->lsave_offs); | 542 | dbg_lp("LPT lsave is at %d:%d", c->lsave_lnum, c->lsave_offs); |
| 543 | |||
| 506 | return 0; | 544 | return 0; |
| 545 | |||
| 546 | no_space: | ||
| 547 | ubifs_err("LPT out of space mismatch"); | ||
| 548 | dbg_err("LPT out of space mismatch at LEB %d:%d needing %d, done_ltab " | ||
| 549 | "%d, done_lsave %d", lnum, offs, len, done_ltab, done_lsave); | ||
| 550 | dbg_dump_lpt_info(c); | ||
| 551 | return err; | ||
| 507 | } | 552 | } |
| 508 | 553 | ||
| 509 | /** | 554 | /** |
| @@ -1044,6 +1089,8 @@ static int is_a_node(struct ubifs_info *c, uint8_t *buf, int len) | |||
| 1044 | int pos = 0, node_type, node_len; | 1089 | int pos = 0, node_type, node_len; |
| 1045 | uint16_t crc, calc_crc; | 1090 | uint16_t crc, calc_crc; |
| 1046 | 1091 | ||
| 1092 | if (len < UBIFS_LPT_CRC_BYTES + (UBIFS_LPT_TYPE_BITS + 7) / 8) | ||
| 1093 | return 0; | ||
| 1047 | node_type = ubifs_unpack_bits(&addr, &pos, UBIFS_LPT_TYPE_BITS); | 1094 | node_type = ubifs_unpack_bits(&addr, &pos, UBIFS_LPT_TYPE_BITS); |
| 1048 | if (node_type == UBIFS_LPT_NOT_A_NODE) | 1095 | if (node_type == UBIFS_LPT_NOT_A_NODE) |
| 1049 | return 0; | 1096 | return 0; |
| @@ -1156,6 +1203,9 @@ int ubifs_lpt_start_commit(struct ubifs_info *c) | |||
| 1156 | dbg_lp(""); | 1203 | dbg_lp(""); |
| 1157 | 1204 | ||
| 1158 | mutex_lock(&c->lp_mutex); | 1205 | mutex_lock(&c->lp_mutex); |
| 1206 | err = dbg_chk_lpt_free_spc(c); | ||
| 1207 | if (err) | ||
| 1208 | goto out; | ||
| 1159 | err = dbg_check_ltab(c); | 1209 | err = dbg_check_ltab(c); |
| 1160 | if (err) | 1210 | if (err) |
| 1161 | goto out; | 1211 | goto out; |
| @@ -1645,4 +1695,121 @@ int dbg_check_ltab(struct ubifs_info *c) | |||
| 1645 | return 0; | 1695 | return 0; |
| 1646 | } | 1696 | } |
| 1647 | 1697 | ||
| 1698 | /** | ||
| 1699 | * dbg_chk_lpt_free_spc - check LPT free space is enough to write entire LPT. | ||
| 1700 | * @c: the UBIFS file-system description object | ||
| 1701 | * | ||
| 1702 | * This function returns %0 on success and a negative error code on failure. | ||
| 1703 | */ | ||
| 1704 | int dbg_chk_lpt_free_spc(struct ubifs_info *c) | ||
| 1705 | { | ||
| 1706 | long long free = 0; | ||
| 1707 | int i; | ||
| 1708 | |||
| 1709 | for (i = 0; i < c->lpt_lebs; i++) { | ||
| 1710 | if (c->ltab[i].tgc || c->ltab[i].cmt) | ||
| 1711 | continue; | ||
| 1712 | if (i + c->lpt_first == c->nhead_lnum) | ||
| 1713 | free += c->leb_size - c->nhead_offs; | ||
| 1714 | else if (c->ltab[i].free == c->leb_size) | ||
| 1715 | free += c->leb_size; | ||
| 1716 | } | ||
| 1717 | if (free < c->lpt_sz) { | ||
| 1718 | dbg_err("LPT space error: free %lld lpt_sz %lld", | ||
| 1719 | free, c->lpt_sz); | ||
| 1720 | dbg_dump_lpt_info(c); | ||
| 1721 | return -EINVAL; | ||
| 1722 | } | ||
| 1723 | return 0; | ||
| 1724 | } | ||
| 1725 | |||
| 1726 | /** | ||
| 1727 | * dbg_chk_lpt_sz - check LPT does not write more than LPT size. | ||
| 1728 | * @c: the UBIFS file-system description object | ||
| 1729 | * @action: action | ||
| 1730 | * @len: length written | ||
| 1731 | * | ||
| 1732 | * This function returns %0 on success and a negative error code on failure. | ||
| 1733 | */ | ||
| 1734 | int dbg_chk_lpt_sz(struct ubifs_info *c, int action, int len) | ||
| 1735 | { | ||
| 1736 | long long chk_lpt_sz, lpt_sz; | ||
| 1737 | int err = 0; | ||
| 1738 | |||
| 1739 | switch (action) { | ||
| 1740 | case 0: | ||
| 1741 | c->chk_lpt_sz = 0; | ||
| 1742 | c->chk_lpt_sz2 = 0; | ||
| 1743 | c->chk_lpt_lebs = 0; | ||
| 1744 | c->chk_lpt_wastage = 0; | ||
| 1745 | if (c->dirty_pn_cnt > c->pnode_cnt) { | ||
| 1746 | dbg_err("dirty pnodes %d exceed max %d", | ||
| 1747 | c->dirty_pn_cnt, c->pnode_cnt); | ||
| 1748 | err = -EINVAL; | ||
| 1749 | } | ||
| 1750 | if (c->dirty_nn_cnt > c->nnode_cnt) { | ||
| 1751 | dbg_err("dirty nnodes %d exceed max %d", | ||
| 1752 | c->dirty_nn_cnt, c->nnode_cnt); | ||
| 1753 | err = -EINVAL; | ||
| 1754 | } | ||
| 1755 | return err; | ||
| 1756 | case 1: | ||
| 1757 | c->chk_lpt_sz += len; | ||
| 1758 | return 0; | ||
| 1759 | case 2: | ||
| 1760 | c->chk_lpt_sz += len; | ||
| 1761 | c->chk_lpt_wastage += len; | ||
| 1762 | c->chk_lpt_lebs += 1; | ||
| 1763 | return 0; | ||
| 1764 | case 3: | ||
| 1765 | chk_lpt_sz = c->leb_size; | ||
| 1766 | chk_lpt_sz *= c->chk_lpt_lebs; | ||
| 1767 | chk_lpt_sz += len - c->nhead_offs; | ||
| 1768 | if (c->chk_lpt_sz != chk_lpt_sz) { | ||
| 1769 | dbg_err("LPT wrote %lld but space used was %lld", | ||
| 1770 | c->chk_lpt_sz, chk_lpt_sz); | ||
| 1771 | err = -EINVAL; | ||
| 1772 | } | ||
| 1773 | if (c->chk_lpt_sz > c->lpt_sz) { | ||
| 1774 | dbg_err("LPT wrote %lld but lpt_sz is %lld", | ||
| 1775 | c->chk_lpt_sz, c->lpt_sz); | ||
| 1776 | err = -EINVAL; | ||
| 1777 | } | ||
| 1778 | if (c->chk_lpt_sz2 && c->chk_lpt_sz != c->chk_lpt_sz2) { | ||
| 1779 | dbg_err("LPT layout size %lld but wrote %lld", | ||
| 1780 | c->chk_lpt_sz, c->chk_lpt_sz2); | ||
| 1781 | err = -EINVAL; | ||
| 1782 | } | ||
| 1783 | if (c->chk_lpt_sz2 && c->new_nhead_offs != len) { | ||
| 1784 | dbg_err("LPT new nhead offs: expected %d was %d", | ||
| 1785 | c->new_nhead_offs, len); | ||
| 1786 | err = -EINVAL; | ||
| 1787 | } | ||
| 1788 | lpt_sz = (long long)c->pnode_cnt * c->pnode_sz; | ||
| 1789 | lpt_sz += (long long)c->nnode_cnt * c->nnode_sz; | ||
| 1790 | lpt_sz += c->ltab_sz; | ||
| 1791 | if (c->big_lpt) | ||
| 1792 | lpt_sz += c->lsave_sz; | ||
| 1793 | if (c->chk_lpt_sz - c->chk_lpt_wastage > lpt_sz) { | ||
| 1794 | dbg_err("LPT chk_lpt_sz %lld + waste %lld exceeds %lld", | ||
| 1795 | c->chk_lpt_sz, c->chk_lpt_wastage, lpt_sz); | ||
| 1796 | err = -EINVAL; | ||
| 1797 | } | ||
| 1798 | if (err) | ||
| 1799 | dbg_dump_lpt_info(c); | ||
| 1800 | c->chk_lpt_sz2 = c->chk_lpt_sz; | ||
| 1801 | c->chk_lpt_sz = 0; | ||
| 1802 | c->chk_lpt_wastage = 0; | ||
| 1803 | c->chk_lpt_lebs = 0; | ||
| 1804 | c->new_nhead_offs = len; | ||
| 1805 | return err; | ||
| 1806 | case 4: | ||
| 1807 | c->chk_lpt_sz += len; | ||
| 1808 | c->chk_lpt_wastage += len; | ||
| 1809 | return 0; | ||
| 1810 | default: | ||
| 1811 | return -EINVAL; | ||
| 1812 | } | ||
| 1813 | } | ||
| 1814 | |||
| 1648 | #endif /* CONFIG_UBIFS_FS_DEBUG */ | 1815 | #endif /* CONFIG_UBIFS_FS_DEBUG */ |
diff --git a/fs/ubifs/misc.h b/fs/ubifs/misc.h index 4c12a9215d7..4fa81d867e4 100644 --- a/fs/ubifs/misc.h +++ b/fs/ubifs/misc.h | |||
| @@ -310,4 +310,31 @@ static inline int ubifs_tnc_lookup(struct ubifs_info *c, | |||
| 310 | return ubifs_tnc_locate(c, key, node, NULL, NULL); | 310 | return ubifs_tnc_locate(c, key, node, NULL, NULL); |
| 311 | } | 311 | } |
| 312 | 312 | ||
| 313 | /** | ||
| 314 | * ubifs_get_lprops - get reference to LEB properties. | ||
| 315 | * @c: the UBIFS file-system description object | ||
| 316 | * | ||
| 317 | * This function locks lprops. Lprops have to be unlocked by | ||
| 318 | * 'ubifs_release_lprops()'. | ||
| 319 | */ | ||
| 320 | static inline void ubifs_get_lprops(struct ubifs_info *c) | ||
| 321 | { | ||
| 322 | mutex_lock(&c->lp_mutex); | ||
| 323 | } | ||
| 324 | |||
| 325 | /** | ||
| 326 | * ubifs_release_lprops - release lprops lock. | ||
| 327 | * @c: the UBIFS file-system description object | ||
| 328 | * | ||
| 329 | * This function has to be called after each 'ubifs_get_lprops()' call to | ||
| 330 | * unlock lprops. | ||
| 331 | */ | ||
| 332 | static inline void ubifs_release_lprops(struct ubifs_info *c) | ||
| 333 | { | ||
| 334 | ubifs_assert(mutex_is_locked(&c->lp_mutex)); | ||
| 335 | ubifs_assert(c->lst.empty_lebs >= 0 && | ||
| 336 | c->lst.empty_lebs <= c->main_lebs); | ||
| 337 | mutex_unlock(&c->lp_mutex); | ||
| 338 | } | ||
| 339 | |||
| 313 | #endif /* __UBIFS_MISC_H__ */ | 340 | #endif /* __UBIFS_MISC_H__ */ |
diff --git a/fs/ubifs/scan.c b/fs/ubifs/scan.c index acf5c5fffc6..0ed82479b44 100644 --- a/fs/ubifs/scan.c +++ b/fs/ubifs/scan.c | |||
| @@ -87,7 +87,7 @@ int ubifs_scan_a_node(const struct ubifs_info *c, void *buf, int len, int lnum, | |||
| 87 | 87 | ||
| 88 | dbg_scan("scanning %s", dbg_ntype(ch->node_type)); | 88 | dbg_scan("scanning %s", dbg_ntype(ch->node_type)); |
| 89 | 89 | ||
| 90 | if (ubifs_check_node(c, buf, lnum, offs, quiet)) | 90 | if (ubifs_check_node(c, buf, lnum, offs, quiet, 1)) |
| 91 | return SCANNED_A_CORRUPT_NODE; | 91 | return SCANNED_A_CORRUPT_NODE; |
| 92 | 92 | ||
| 93 | if (ch->node_type == UBIFS_PAD_NODE) { | 93 | if (ch->node_type == UBIFS_PAD_NODE) { |
diff --git a/fs/ubifs/super.c b/fs/ubifs/super.c index 9a9220333b3..8780efbf40a 100644 --- a/fs/ubifs/super.c +++ b/fs/ubifs/super.c | |||
| @@ -401,6 +401,16 @@ static int ubifs_show_options(struct seq_file *s, struct vfsmount *mnt) | |||
| 401 | else if (c->mount_opts.unmount_mode == 1) | 401 | else if (c->mount_opts.unmount_mode == 1) |
| 402 | seq_printf(s, ",norm_unmount"); | 402 | seq_printf(s, ",norm_unmount"); |
| 403 | 403 | ||
| 404 | if (c->mount_opts.bulk_read == 2) | ||
| 405 | seq_printf(s, ",bulk_read"); | ||
| 406 | else if (c->mount_opts.bulk_read == 1) | ||
| 407 | seq_printf(s, ",no_bulk_read"); | ||
| 408 | |||
| 409 | if (c->mount_opts.chk_data_crc == 2) | ||
| 410 | seq_printf(s, ",chk_data_crc"); | ||
| 411 | else if (c->mount_opts.chk_data_crc == 1) | ||
| 412 | seq_printf(s, ",no_chk_data_crc"); | ||
| 413 | |||
| 404 | return 0; | 414 | return 0; |
| 405 | } | 415 | } |
| 406 | 416 | ||
| @@ -408,13 +418,26 @@ static int ubifs_sync_fs(struct super_block *sb, int wait) | |||
| 408 | { | 418 | { |
| 409 | struct ubifs_info *c = sb->s_fs_info; | 419 | struct ubifs_info *c = sb->s_fs_info; |
| 410 | int i, ret = 0, err; | 420 | int i, ret = 0, err; |
| 421 | long long bud_bytes; | ||
| 411 | 422 | ||
| 412 | if (c->jheads) | 423 | if (c->jheads) { |
| 413 | for (i = 0; i < c->jhead_cnt; i++) { | 424 | for (i = 0; i < c->jhead_cnt; i++) { |
| 414 | err = ubifs_wbuf_sync(&c->jheads[i].wbuf); | 425 | err = ubifs_wbuf_sync(&c->jheads[i].wbuf); |
| 415 | if (err && !ret) | 426 | if (err && !ret) |
| 416 | ret = err; | 427 | ret = err; |
| 417 | } | 428 | } |
| 429 | |||
| 430 | /* Commit the journal unless it has too little data */ | ||
| 431 | spin_lock(&c->buds_lock); | ||
| 432 | bud_bytes = c->bud_bytes; | ||
| 433 | spin_unlock(&c->buds_lock); | ||
| 434 | if (bud_bytes > c->leb_size) { | ||
| 435 | err = ubifs_run_commit(c); | ||
| 436 | if (err) | ||
| 437 | return err; | ||
| 438 | } | ||
| 439 | } | ||
| 440 | |||
| 418 | /* | 441 | /* |
| 419 | * We ought to call sync for c->ubi but it does not have one. If it had | 442 | * We ought to call sync for c->ubi but it does not have one. If it had |
| 420 | * it would in turn call mtd->sync, however mtd operations are | 443 | * it would in turn call mtd->sync, however mtd operations are |
| @@ -538,6 +561,18 @@ static int init_constants_early(struct ubifs_info *c) | |||
| 538 | * calculations when reporting free space. | 561 | * calculations when reporting free space. |
| 539 | */ | 562 | */ |
| 540 | c->leb_overhead = c->leb_size % UBIFS_MAX_DATA_NODE_SZ; | 563 | c->leb_overhead = c->leb_size % UBIFS_MAX_DATA_NODE_SZ; |
| 564 | /* Buffer size for bulk-reads */ | ||
| 565 | c->bulk_read_buf_size = UBIFS_MAX_BULK_READ * UBIFS_MAX_DATA_NODE_SZ; | ||
| 566 | if (c->bulk_read_buf_size > c->leb_size) | ||
| 567 | c->bulk_read_buf_size = c->leb_size; | ||
| 568 | if (c->bulk_read_buf_size > 128 * 1024) { | ||
| 569 | /* Check if we can kmalloc more than 128KiB */ | ||
| 570 | void *try = kmalloc(c->bulk_read_buf_size, GFP_KERNEL); | ||
| 571 | |||
| 572 | kfree(try); | ||
| 573 | if (!try) | ||
| 574 | c->bulk_read_buf_size = 128 * 1024; | ||
| 575 | } | ||
| 541 | return 0; | 576 | return 0; |
| 542 | } | 577 | } |
| 543 | 578 | ||
| @@ -840,17 +875,29 @@ static int check_volume_empty(struct ubifs_info *c) | |||
| 840 | * | 875 | * |
| 841 | * Opt_fast_unmount: do not run a journal commit before un-mounting | 876 | * Opt_fast_unmount: do not run a journal commit before un-mounting |
| 842 | * Opt_norm_unmount: run a journal commit before un-mounting | 877 | * Opt_norm_unmount: run a journal commit before un-mounting |
| 878 | * Opt_bulk_read: enable bulk-reads | ||
| 879 | * Opt_no_bulk_read: disable bulk-reads | ||
| 880 | * Opt_chk_data_crc: check CRCs when reading data nodes | ||
| 881 | * Opt_no_chk_data_crc: do not check CRCs when reading data nodes | ||
| 843 | * Opt_err: just end of array marker | 882 | * Opt_err: just end of array marker |
| 844 | */ | 883 | */ |
| 845 | enum { | 884 | enum { |
| 846 | Opt_fast_unmount, | 885 | Opt_fast_unmount, |
| 847 | Opt_norm_unmount, | 886 | Opt_norm_unmount, |
| 887 | Opt_bulk_read, | ||
| 888 | Opt_no_bulk_read, | ||
| 889 | Opt_chk_data_crc, | ||
| 890 | Opt_no_chk_data_crc, | ||
| 848 | Opt_err, | 891 | Opt_err, |
| 849 | }; | 892 | }; |
| 850 | 893 | ||
| 851 | static const match_table_t tokens = { | 894 | static const match_table_t tokens = { |
| 852 | {Opt_fast_unmount, "fast_unmount"}, | 895 | {Opt_fast_unmount, "fast_unmount"}, |
| 853 | {Opt_norm_unmount, "norm_unmount"}, | 896 | {Opt_norm_unmount, "norm_unmount"}, |
| 897 | {Opt_bulk_read, "bulk_read"}, | ||
| 898 | {Opt_no_bulk_read, "no_bulk_read"}, | ||
| 899 | {Opt_chk_data_crc, "chk_data_crc"}, | ||
| 900 | {Opt_no_chk_data_crc, "no_chk_data_crc"}, | ||
| 854 | {Opt_err, NULL}, | 901 | {Opt_err, NULL}, |
| 855 | }; | 902 | }; |
| 856 | 903 | ||
| @@ -888,6 +935,22 @@ static int ubifs_parse_options(struct ubifs_info *c, char *options, | |||
| 888 | c->mount_opts.unmount_mode = 1; | 935 | c->mount_opts.unmount_mode = 1; |
| 889 | c->fast_unmount = 0; | 936 | c->fast_unmount = 0; |
| 890 | break; | 937 | break; |
| 938 | case Opt_bulk_read: | ||
| 939 | c->mount_opts.bulk_read = 2; | ||
| 940 | c->bulk_read = 1; | ||
| 941 | break; | ||
| 942 | case Opt_no_bulk_read: | ||
| 943 | c->mount_opts.bulk_read = 1; | ||
| 944 | c->bulk_read = 0; | ||
| 945 | break; | ||
| 946 | case Opt_chk_data_crc: | ||
| 947 | c->mount_opts.chk_data_crc = 2; | ||
| 948 | c->no_chk_data_crc = 0; | ||
| 949 | break; | ||
| 950 | case Opt_no_chk_data_crc: | ||
| 951 | c->mount_opts.chk_data_crc = 1; | ||
| 952 | c->no_chk_data_crc = 1; | ||
| 953 | break; | ||
| 891 | default: | 954 | default: |
| 892 | ubifs_err("unrecognized mount option \"%s\" " | 955 | ubifs_err("unrecognized mount option \"%s\" " |
| 893 | "or missing value", p); | 956 | "or missing value", p); |
| @@ -996,6 +1059,8 @@ static int mount_ubifs(struct ubifs_info *c) | |||
| 996 | goto out_free; | 1059 | goto out_free; |
| 997 | } | 1060 | } |
| 998 | 1061 | ||
| 1062 | c->always_chk_crc = 1; | ||
| 1063 | |||
| 999 | err = ubifs_read_superblock(c); | 1064 | err = ubifs_read_superblock(c); |
| 1000 | if (err) | 1065 | if (err) |
| 1001 | goto out_free; | 1066 | goto out_free; |
| @@ -1032,8 +1097,6 @@ static int mount_ubifs(struct ubifs_info *c) | |||
| 1032 | 1097 | ||
| 1033 | /* Create background thread */ | 1098 | /* Create background thread */ |
| 1034 | c->bgt = kthread_create(ubifs_bg_thread, c, c->bgt_name); | 1099 | c->bgt = kthread_create(ubifs_bg_thread, c, c->bgt_name); |
| 1035 | if (!c->bgt) | ||
| 1036 | c->bgt = ERR_PTR(-EINVAL); | ||
| 1037 | if (IS_ERR(c->bgt)) { | 1100 | if (IS_ERR(c->bgt)) { |
| 1038 | err = PTR_ERR(c->bgt); | 1101 | err = PTR_ERR(c->bgt); |
| 1039 | c->bgt = NULL; | 1102 | c->bgt = NULL; |
| @@ -1139,24 +1202,28 @@ static int mount_ubifs(struct ubifs_info *c) | |||
| 1139 | if (err) | 1202 | if (err) |
| 1140 | goto out_infos; | 1203 | goto out_infos; |
| 1141 | 1204 | ||
| 1205 | c->always_chk_crc = 0; | ||
| 1206 | |||
| 1142 | ubifs_msg("mounted UBI device %d, volume %d, name \"%s\"", | 1207 | ubifs_msg("mounted UBI device %d, volume %d, name \"%s\"", |
| 1143 | c->vi.ubi_num, c->vi.vol_id, c->vi.name); | 1208 | c->vi.ubi_num, c->vi.vol_id, c->vi.name); |
| 1144 | if (mounted_read_only) | 1209 | if (mounted_read_only) |
| 1145 | ubifs_msg("mounted read-only"); | 1210 | ubifs_msg("mounted read-only"); |
| 1146 | x = (long long)c->main_lebs * c->leb_size; | 1211 | x = (long long)c->main_lebs * c->leb_size; |
| 1147 | ubifs_msg("file system size: %lld bytes (%lld KiB, %lld MiB, %d LEBs)", | 1212 | ubifs_msg("file system size: %lld bytes (%lld KiB, %lld MiB, %d " |
| 1148 | x, x >> 10, x >> 20, c->main_lebs); | 1213 | "LEBs)", x, x >> 10, x >> 20, c->main_lebs); |
| 1149 | x = (long long)c->log_lebs * c->leb_size + c->max_bud_bytes; | 1214 | x = (long long)c->log_lebs * c->leb_size + c->max_bud_bytes; |
| 1150 | ubifs_msg("journal size: %lld bytes (%lld KiB, %lld MiB, %d LEBs)", | 1215 | ubifs_msg("journal size: %lld bytes (%lld KiB, %lld MiB, %d " |
| 1151 | x, x >> 10, x >> 20, c->log_lebs + c->max_bud_cnt); | 1216 | "LEBs)", x, x >> 10, x >> 20, c->log_lebs + c->max_bud_cnt); |
| 1152 | ubifs_msg("default compressor: %s", ubifs_compr_name(c->default_compr)); | 1217 | ubifs_msg("media format: %d (latest is %d)", |
| 1153 | ubifs_msg("media format %d, latest format %d", | ||
| 1154 | c->fmt_version, UBIFS_FORMAT_VERSION); | 1218 | c->fmt_version, UBIFS_FORMAT_VERSION); |
| 1219 | ubifs_msg("default compressor: %s", ubifs_compr_name(c->default_compr)); | ||
| 1220 | ubifs_msg("reserved for root: %llu bytes (%llu KiB)", | ||
| 1221 | c->report_rp_size, c->report_rp_size >> 10); | ||
| 1155 | 1222 | ||
| 1156 | dbg_msg("compiled on: " __DATE__ " at " __TIME__); | 1223 | dbg_msg("compiled on: " __DATE__ " at " __TIME__); |
| 1157 | dbg_msg("min. I/O unit size: %d bytes", c->min_io_size); | 1224 | dbg_msg("min. I/O unit size: %d bytes", c->min_io_size); |
| 1158 | dbg_msg("LEB size: %d bytes (%d KiB)", | 1225 | dbg_msg("LEB size: %d bytes (%d KiB)", |
| 1159 | c->leb_size, c->leb_size / 1024); | 1226 | c->leb_size, c->leb_size >> 10); |
| 1160 | dbg_msg("data journal heads: %d", | 1227 | dbg_msg("data journal heads: %d", |
| 1161 | c->jhead_cnt - NONDATA_JHEADS_CNT); | 1228 | c->jhead_cnt - NONDATA_JHEADS_CNT); |
| 1162 | dbg_msg("UUID: %02X%02X%02X%02X-%02X%02X" | 1229 | dbg_msg("UUID: %02X%02X%02X%02X-%02X%02X" |
| @@ -1282,6 +1349,7 @@ static int ubifs_remount_rw(struct ubifs_info *c) | |||
| 1282 | 1349 | ||
| 1283 | mutex_lock(&c->umount_mutex); | 1350 | mutex_lock(&c->umount_mutex); |
| 1284 | c->remounting_rw = 1; | 1351 | c->remounting_rw = 1; |
| 1352 | c->always_chk_crc = 1; | ||
| 1285 | 1353 | ||
| 1286 | /* Check for enough free space */ | 1354 | /* Check for enough free space */ |
| 1287 | if (ubifs_calc_available(c, c->min_idx_lebs) <= 0) { | 1355 | if (ubifs_calc_available(c, c->min_idx_lebs) <= 0) { |
| @@ -1345,20 +1413,20 @@ static int ubifs_remount_rw(struct ubifs_info *c) | |||
| 1345 | 1413 | ||
| 1346 | /* Create background thread */ | 1414 | /* Create background thread */ |
| 1347 | c->bgt = kthread_create(ubifs_bg_thread, c, c->bgt_name); | 1415 | c->bgt = kthread_create(ubifs_bg_thread, c, c->bgt_name); |
| 1348 | if (!c->bgt) | ||
| 1349 | c->bgt = ERR_PTR(-EINVAL); | ||
| 1350 | if (IS_ERR(c->bgt)) { | 1416 | if (IS_ERR(c->bgt)) { |
| 1351 | err = PTR_ERR(c->bgt); | 1417 | err = PTR_ERR(c->bgt); |
| 1352 | c->bgt = NULL; | 1418 | c->bgt = NULL; |
| 1353 | ubifs_err("cannot spawn \"%s\", error %d", | 1419 | ubifs_err("cannot spawn \"%s\", error %d", |
| 1354 | c->bgt_name, err); | 1420 | c->bgt_name, err); |
| 1355 | return err; | 1421 | goto out; |
| 1356 | } | 1422 | } |
| 1357 | wake_up_process(c->bgt); | 1423 | wake_up_process(c->bgt); |
| 1358 | 1424 | ||
| 1359 | c->orph_buf = vmalloc(c->leb_size); | 1425 | c->orph_buf = vmalloc(c->leb_size); |
| 1360 | if (!c->orph_buf) | 1426 | if (!c->orph_buf) { |
| 1361 | return -ENOMEM; | 1427 | err = -ENOMEM; |
| 1428 | goto out; | ||
| 1429 | } | ||
| 1362 | 1430 | ||
| 1363 | /* Check for enough log space */ | 1431 | /* Check for enough log space */ |
| 1364 | lnum = c->lhead_lnum + 1; | 1432 | lnum = c->lhead_lnum + 1; |
| @@ -1385,6 +1453,7 @@ static int ubifs_remount_rw(struct ubifs_info *c) | |||
| 1385 | dbg_gen("re-mounted read-write"); | 1453 | dbg_gen("re-mounted read-write"); |
| 1386 | c->vfs_sb->s_flags &= ~MS_RDONLY; | 1454 | c->vfs_sb->s_flags &= ~MS_RDONLY; |
| 1387 | c->remounting_rw = 0; | 1455 | c->remounting_rw = 0; |
| 1456 | c->always_chk_crc = 0; | ||
| 1388 | mutex_unlock(&c->umount_mutex); | 1457 | mutex_unlock(&c->umount_mutex); |
| 1389 | return 0; | 1458 | return 0; |
| 1390 | 1459 | ||
| @@ -1400,6 +1469,7 @@ out: | |||
| 1400 | c->ileb_buf = NULL; | 1469 | c->ileb_buf = NULL; |
| 1401 | ubifs_lpt_free(c, 1); | 1470 | ubifs_lpt_free(c, 1); |
| 1402 | c->remounting_rw = 0; | 1471 | c->remounting_rw = 0; |
| 1472 | c->always_chk_crc = 0; | ||
| 1403 | mutex_unlock(&c->umount_mutex); | 1473 | mutex_unlock(&c->umount_mutex); |
| 1404 | return err; | 1474 | return err; |
| 1405 | } | 1475 | } |
| @@ -1408,12 +1478,9 @@ out: | |||
| 1408 | * commit_on_unmount - commit the journal when un-mounting. | 1478 | * commit_on_unmount - commit the journal when un-mounting. |
| 1409 | * @c: UBIFS file-system description object | 1479 | * @c: UBIFS file-system description object |
| 1410 | * | 1480 | * |
| 1411 | * This function is called during un-mounting and it commits the journal unless | 1481 | * This function is called during un-mounting and re-mounting, and it commits |
| 1412 | * the "fast unmount" mode is enabled. It also avoids committing the journal if | 1482 | * the journal unless the "fast unmount" mode is enabled. It also avoids |
| 1413 | * it contains too few data. | 1483 | * committing the journal if it contains too few data. |
| 1414 | * | ||
| 1415 | * Sometimes recovery requires the journal to be committed at least once, and | ||
| 1416 | * this function takes care about this. | ||
| 1417 | */ | 1484 | */ |
| 1418 | static void commit_on_unmount(struct ubifs_info *c) | 1485 | static void commit_on_unmount(struct ubifs_info *c) |
| 1419 | { | 1486 | { |
diff --git a/fs/ubifs/tnc.c b/fs/ubifs/tnc.c index 7634c597088..d27fd918b9c 100644 --- a/fs/ubifs/tnc.c +++ b/fs/ubifs/tnc.c | |||
| @@ -284,7 +284,7 @@ static struct ubifs_znode *dirty_cow_znode(struct ubifs_info *c, | |||
| 284 | } | 284 | } |
| 285 | 285 | ||
| 286 | zn = copy_znode(c, znode); | 286 | zn = copy_znode(c, znode); |
| 287 | if (unlikely(IS_ERR(zn))) | 287 | if (IS_ERR(zn)) |
| 288 | return zn; | 288 | return zn; |
| 289 | 289 | ||
| 290 | if (zbr->len) { | 290 | if (zbr->len) { |
| @@ -470,6 +470,10 @@ static int try_read_node(const struct ubifs_info *c, void *buf, int type, | |||
| 470 | if (node_len != len) | 470 | if (node_len != len) |
| 471 | return 0; | 471 | return 0; |
| 472 | 472 | ||
| 473 | if (type == UBIFS_DATA_NODE && !c->always_chk_crc) | ||
| 474 | if (c->no_chk_data_crc) | ||
| 475 | return 0; | ||
| 476 | |||
| 473 | crc = crc32(UBIFS_CRC32_INIT, buf + 8, node_len - 8); | 477 | crc = crc32(UBIFS_CRC32_INIT, buf + 8, node_len - 8); |
| 474 | node_crc = le32_to_cpu(ch->crc); | 478 | node_crc = le32_to_cpu(ch->crc); |
| 475 | if (crc != node_crc) | 479 | if (crc != node_crc) |
| @@ -1128,7 +1132,7 @@ static struct ubifs_znode *dirty_cow_bottom_up(struct ubifs_info *c, | |||
| 1128 | ubifs_assert(znode == c->zroot.znode); | 1132 | ubifs_assert(znode == c->zroot.znode); |
| 1129 | znode = dirty_cow_znode(c, &c->zroot); | 1133 | znode = dirty_cow_znode(c, &c->zroot); |
| 1130 | } | 1134 | } |
| 1131 | if (unlikely(IS_ERR(znode)) || !p) | 1135 | if (IS_ERR(znode) || !p) |
| 1132 | break; | 1136 | break; |
| 1133 | ubifs_assert(path[p - 1] >= 0); | 1137 | ubifs_assert(path[p - 1] >= 0); |
| 1134 | ubifs_assert(path[p - 1] < znode->child_cnt); | 1138 | ubifs_assert(path[p - 1] < znode->child_cnt); |
| @@ -1492,6 +1496,289 @@ out: | |||
| 1492 | } | 1496 | } |
| 1493 | 1497 | ||
| 1494 | /** | 1498 | /** |
| 1499 | * ubifs_tnc_get_bu_keys - lookup keys for bulk-read. | ||
| 1500 | * @c: UBIFS file-system description object | ||
| 1501 | * @bu: bulk-read parameters and results | ||
| 1502 | * | ||
| 1503 | * Lookup consecutive data node keys for the same inode that reside | ||
| 1504 | * consecutively in the same LEB. | ||
| 1505 | */ | ||
| 1506 | int ubifs_tnc_get_bu_keys(struct ubifs_info *c, struct bu_info *bu) | ||
| 1507 | { | ||
| 1508 | int n, err = 0, lnum = -1, uninitialized_var(offs); | ||
| 1509 | int uninitialized_var(len); | ||
| 1510 | unsigned int block = key_block(c, &bu->key); | ||
| 1511 | struct ubifs_znode *znode; | ||
| 1512 | |||
| 1513 | bu->cnt = 0; | ||
| 1514 | bu->blk_cnt = 0; | ||
| 1515 | bu->eof = 0; | ||
| 1516 | |||
| 1517 | mutex_lock(&c->tnc_mutex); | ||
| 1518 | /* Find first key */ | ||
| 1519 | err = ubifs_lookup_level0(c, &bu->key, &znode, &n); | ||
| 1520 | if (err < 0) | ||
| 1521 | goto out; | ||
| 1522 | if (err) { | ||
| 1523 | /* Key found */ | ||
| 1524 | len = znode->zbranch[n].len; | ||
| 1525 | /* The buffer must be big enough for at least 1 node */ | ||
| 1526 | if (len > bu->buf_len) { | ||
| 1527 | err = -EINVAL; | ||
| 1528 | goto out; | ||
| 1529 | } | ||
| 1530 | /* Add this key */ | ||
| 1531 | bu->zbranch[bu->cnt++] = znode->zbranch[n]; | ||
| 1532 | bu->blk_cnt += 1; | ||
| 1533 | lnum = znode->zbranch[n].lnum; | ||
| 1534 | offs = ALIGN(znode->zbranch[n].offs + len, 8); | ||
| 1535 | } | ||
| 1536 | while (1) { | ||
| 1537 | struct ubifs_zbranch *zbr; | ||
| 1538 | union ubifs_key *key; | ||
| 1539 | unsigned int next_block; | ||
| 1540 | |||
| 1541 | /* Find next key */ | ||
| 1542 | err = tnc_next(c, &znode, &n); | ||
| 1543 | if (err) | ||
| 1544 | goto out; | ||
| 1545 | zbr = &znode->zbranch[n]; | ||
| 1546 | key = &zbr->key; | ||
| 1547 | /* See if there is another data key for this file */ | ||
| 1548 | if (key_inum(c, key) != key_inum(c, &bu->key) || | ||
| 1549 | key_type(c, key) != UBIFS_DATA_KEY) { | ||
| 1550 | err = -ENOENT; | ||
| 1551 | goto out; | ||
| 1552 | } | ||
| 1553 | if (lnum < 0) { | ||
| 1554 | /* First key found */ | ||
| 1555 | lnum = zbr->lnum; | ||
| 1556 | offs = ALIGN(zbr->offs + zbr->len, 8); | ||
| 1557 | len = zbr->len; | ||
| 1558 | if (len > bu->buf_len) { | ||
| 1559 | err = -EINVAL; | ||
| 1560 | goto out; | ||
| 1561 | } | ||
| 1562 | } else { | ||
| 1563 | /* | ||
| 1564 | * The data nodes must be in consecutive positions in | ||
| 1565 | * the same LEB. | ||
| 1566 | */ | ||
| 1567 | if (zbr->lnum != lnum || zbr->offs != offs) | ||
| 1568 | goto out; | ||
| 1569 | offs += ALIGN(zbr->len, 8); | ||
| 1570 | len = ALIGN(len, 8) + zbr->len; | ||
| 1571 | /* Must not exceed buffer length */ | ||
| 1572 | if (len > bu->buf_len) | ||
| 1573 | goto out; | ||
| 1574 | } | ||
| 1575 | /* Allow for holes */ | ||
| 1576 | next_block = key_block(c, key); | ||
| 1577 | bu->blk_cnt += (next_block - block - 1); | ||
| 1578 | if (bu->blk_cnt >= UBIFS_MAX_BULK_READ) | ||
| 1579 | goto out; | ||
| 1580 | block = next_block; | ||
| 1581 | /* Add this key */ | ||
| 1582 | bu->zbranch[bu->cnt++] = *zbr; | ||
| 1583 | bu->blk_cnt += 1; | ||
| 1584 | /* See if we have room for more */ | ||
| 1585 | if (bu->cnt >= UBIFS_MAX_BULK_READ) | ||
| 1586 | goto out; | ||
| 1587 | if (bu->blk_cnt >= UBIFS_MAX_BULK_READ) | ||
| 1588 | goto out; | ||
| 1589 | } | ||
| 1590 | out: | ||
| 1591 | if (err == -ENOENT) { | ||
| 1592 | bu->eof = 1; | ||
| 1593 | err = 0; | ||
| 1594 | } | ||
| 1595 | bu->gc_seq = c->gc_seq; | ||
| 1596 | mutex_unlock(&c->tnc_mutex); | ||
| 1597 | if (err) | ||
| 1598 | return err; | ||
| 1599 | /* | ||
| 1600 | * An enormous hole could cause bulk-read to encompass too many | ||
| 1601 | * page cache pages, so limit the number here. | ||
| 1602 | */ | ||
| 1603 | if (bu->blk_cnt > UBIFS_MAX_BULK_READ) | ||
| 1604 | bu->blk_cnt = UBIFS_MAX_BULK_READ; | ||
| 1605 | /* | ||
| 1606 | * Ensure that bulk-read covers a whole number of page cache | ||
| 1607 | * pages. | ||
| 1608 | */ | ||
| 1609 | if (UBIFS_BLOCKS_PER_PAGE == 1 || | ||
| 1610 | !(bu->blk_cnt & (UBIFS_BLOCKS_PER_PAGE - 1))) | ||
| 1611 | return 0; | ||
| 1612 | if (bu->eof) { | ||
| 1613 | /* At the end of file we can round up */ | ||
| 1614 | bu->blk_cnt += UBIFS_BLOCKS_PER_PAGE - 1; | ||
| 1615 | return 0; | ||
| 1616 | } | ||
| 1617 | /* Exclude data nodes that do not make up a whole page cache page */ | ||
| 1618 | block = key_block(c, &bu->key) + bu->blk_cnt; | ||
| 1619 | block &= ~(UBIFS_BLOCKS_PER_PAGE - 1); | ||
| 1620 | while (bu->cnt) { | ||
| 1621 | if (key_block(c, &bu->zbranch[bu->cnt - 1].key) < block) | ||
| 1622 | break; | ||
| 1623 | bu->cnt -= 1; | ||
| 1624 | } | ||
| 1625 | return 0; | ||
| 1626 | } | ||
| 1627 | |||
| 1628 | /** | ||
| 1629 | * read_wbuf - bulk-read from a LEB with a wbuf. | ||
| 1630 | * @wbuf: wbuf that may overlap the read | ||
| 1631 | * @buf: buffer into which to read | ||
| 1632 | * @len: read length | ||
| 1633 | * @lnum: LEB number from which to read | ||
| 1634 | * @offs: offset from which to read | ||
| 1635 | * | ||
| 1636 | * This functions returns %0 on success or a negative error code on failure. | ||
| 1637 | */ | ||
| 1638 | static int read_wbuf(struct ubifs_wbuf *wbuf, void *buf, int len, int lnum, | ||
| 1639 | int offs) | ||
| 1640 | { | ||
| 1641 | const struct ubifs_info *c = wbuf->c; | ||
| 1642 | int rlen, overlap; | ||
| 1643 | |||
| 1644 | dbg_io("LEB %d:%d, length %d", lnum, offs, len); | ||
| 1645 | ubifs_assert(wbuf && lnum >= 0 && lnum < c->leb_cnt && offs >= 0); | ||
| 1646 | ubifs_assert(!(offs & 7) && offs < c->leb_size); | ||
| 1647 | ubifs_assert(offs + len <= c->leb_size); | ||
| 1648 | |||
| 1649 | spin_lock(&wbuf->lock); | ||
| 1650 | overlap = (lnum == wbuf->lnum && offs + len > wbuf->offs); | ||
| 1651 | if (!overlap) { | ||
| 1652 | /* We may safely unlock the write-buffer and read the data */ | ||
| 1653 | spin_unlock(&wbuf->lock); | ||
| 1654 | return ubi_read(c->ubi, lnum, buf, offs, len); | ||
| 1655 | } | ||
| 1656 | |||
| 1657 | /* Don't read under wbuf */ | ||
| 1658 | rlen = wbuf->offs - offs; | ||
| 1659 | if (rlen < 0) | ||
| 1660 | rlen = 0; | ||
| 1661 | |||
| 1662 | /* Copy the rest from the write-buffer */ | ||
| 1663 | memcpy(buf + rlen, wbuf->buf + offs + rlen - wbuf->offs, len - rlen); | ||
| 1664 | spin_unlock(&wbuf->lock); | ||
| 1665 | |||
| 1666 | if (rlen > 0) | ||
| 1667 | /* Read everything that goes before write-buffer */ | ||
| 1668 | return ubi_read(c->ubi, lnum, buf, offs, rlen); | ||
| 1669 | |||
| 1670 | return 0; | ||
| 1671 | } | ||
| 1672 | |||
| 1673 | /** | ||
| 1674 | * validate_data_node - validate data nodes for bulk-read. | ||
| 1675 | * @c: UBIFS file-system description object | ||
| 1676 | * @buf: buffer containing data node to validate | ||
| 1677 | * @zbr: zbranch of data node to validate | ||
| 1678 | * | ||
| 1679 | * This functions returns %0 on success or a negative error code on failure. | ||
| 1680 | */ | ||
| 1681 | static int validate_data_node(struct ubifs_info *c, void *buf, | ||
| 1682 | struct ubifs_zbranch *zbr) | ||
| 1683 | { | ||
| 1684 | union ubifs_key key1; | ||
| 1685 | struct ubifs_ch *ch = buf; | ||
| 1686 | int err, len; | ||
| 1687 | |||
| 1688 | if (ch->node_type != UBIFS_DATA_NODE) { | ||
| 1689 | ubifs_err("bad node type (%d but expected %d)", | ||
| 1690 | ch->node_type, UBIFS_DATA_NODE); | ||
| 1691 | goto out_err; | ||
| 1692 | } | ||
| 1693 | |||
| 1694 | err = ubifs_check_node(c, buf, zbr->lnum, zbr->offs, 0, 0); | ||
| 1695 | if (err) { | ||
| 1696 | ubifs_err("expected node type %d", UBIFS_DATA_NODE); | ||
| 1697 | goto out; | ||
| 1698 | } | ||
| 1699 | |||
| 1700 | len = le32_to_cpu(ch->len); | ||
| 1701 | if (len != zbr->len) { | ||
| 1702 | ubifs_err("bad node length %d, expected %d", len, zbr->len); | ||
| 1703 | goto out_err; | ||
| 1704 | } | ||
| 1705 | |||
| 1706 | /* Make sure the key of the read node is correct */ | ||
| 1707 | key_read(c, buf + UBIFS_KEY_OFFSET, &key1); | ||
| 1708 | if (!keys_eq(c, &zbr->key, &key1)) { | ||
| 1709 | ubifs_err("bad key in node at LEB %d:%d", | ||
| 1710 | zbr->lnum, zbr->offs); | ||
| 1711 | dbg_tnc("looked for key %s found node's key %s", | ||
| 1712 | DBGKEY(&zbr->key), DBGKEY1(&key1)); | ||
| 1713 | goto out_err; | ||
| 1714 | } | ||
| 1715 | |||
| 1716 | return 0; | ||
| 1717 | |||
| 1718 | out_err: | ||
| 1719 | err = -EINVAL; | ||
| 1720 | out: | ||
| 1721 | ubifs_err("bad node at LEB %d:%d", zbr->lnum, zbr->offs); | ||
| 1722 | dbg_dump_node(c, buf); | ||
| 1723 | dbg_dump_stack(); | ||
| 1724 | return err; | ||
| 1725 | } | ||
| 1726 | |||
| 1727 | /** | ||
| 1728 | * ubifs_tnc_bulk_read - read a number of data nodes in one go. | ||
| 1729 | * @c: UBIFS file-system description object | ||
| 1730 | * @bu: bulk-read parameters and results | ||
| 1731 | * | ||
| 1732 | * This functions reads and validates the data nodes that were identified by the | ||
| 1733 | * 'ubifs_tnc_get_bu_keys()' function. This functions returns %0 on success, | ||
| 1734 | * -EAGAIN to indicate a race with GC, or another negative error code on | ||
| 1735 | * failure. | ||
| 1736 | */ | ||
| 1737 | int ubifs_tnc_bulk_read(struct ubifs_info *c, struct bu_info *bu) | ||
| 1738 | { | ||
| 1739 | int lnum = bu->zbranch[0].lnum, offs = bu->zbranch[0].offs, len, err, i; | ||
| 1740 | struct ubifs_wbuf *wbuf; | ||
| 1741 | void *buf; | ||
| 1742 | |||
| 1743 | len = bu->zbranch[bu->cnt - 1].offs; | ||
| 1744 | len += bu->zbranch[bu->cnt - 1].len - offs; | ||
| 1745 | if (len > bu->buf_len) { | ||
| 1746 | ubifs_err("buffer too small %d vs %d", bu->buf_len, len); | ||
| 1747 | return -EINVAL; | ||
| 1748 | } | ||
| 1749 | |||
| 1750 | /* Do the read */ | ||
| 1751 | wbuf = ubifs_get_wbuf(c, lnum); | ||
| 1752 | if (wbuf) | ||
| 1753 | err = read_wbuf(wbuf, bu->buf, len, lnum, offs); | ||
| 1754 | else | ||
| 1755 | err = ubi_read(c->ubi, lnum, bu->buf, offs, len); | ||
| 1756 | |||
| 1757 | /* Check for a race with GC */ | ||
| 1758 | if (maybe_leb_gced(c, lnum, bu->gc_seq)) | ||
| 1759 | return -EAGAIN; | ||
| 1760 | |||
| 1761 | if (err && err != -EBADMSG) { | ||
| 1762 | ubifs_err("failed to read from LEB %d:%d, error %d", | ||
| 1763 | lnum, offs, err); | ||
| 1764 | dbg_dump_stack(); | ||
| 1765 | dbg_tnc("key %s", DBGKEY(&bu->key)); | ||
| 1766 | return err; | ||
| 1767 | } | ||
| 1768 | |||
| 1769 | /* Validate the nodes read */ | ||
| 1770 | buf = bu->buf; | ||
| 1771 | for (i = 0; i < bu->cnt; i++) { | ||
| 1772 | err = validate_data_node(c, buf, &bu->zbranch[i]); | ||
| 1773 | if (err) | ||
| 1774 | return err; | ||
| 1775 | buf = buf + ALIGN(bu->zbranch[i].len, 8); | ||
| 1776 | } | ||
| 1777 | |||
| 1778 | return 0; | ||
| 1779 | } | ||
| 1780 | |||
| 1781 | /** | ||
| 1495 | * do_lookup_nm- look up a "hashed" node. | 1782 | * do_lookup_nm- look up a "hashed" node. |
| 1496 | * @c: UBIFS file-system description object | 1783 | * @c: UBIFS file-system description object |
| 1497 | * @key: node key to lookup | 1784 | * @key: node key to lookup |
| @@ -1675,7 +1962,7 @@ static int tnc_insert(struct ubifs_info *c, struct ubifs_znode *znode, | |||
| 1675 | { | 1962 | { |
| 1676 | struct ubifs_znode *zn, *zi, *zp; | 1963 | struct ubifs_znode *zn, *zi, *zp; |
| 1677 | int i, keep, move, appending = 0; | 1964 | int i, keep, move, appending = 0; |
| 1678 | union ubifs_key *key = &zbr->key; | 1965 | union ubifs_key *key = &zbr->key, *key1; |
| 1679 | 1966 | ||
| 1680 | ubifs_assert(n >= 0 && n <= c->fanout); | 1967 | ubifs_assert(n >= 0 && n <= c->fanout); |
| 1681 | 1968 | ||
| @@ -1716,20 +2003,33 @@ again: | |||
| 1716 | zn->level = znode->level; | 2003 | zn->level = znode->level; |
| 1717 | 2004 | ||
| 1718 | /* Decide where to split */ | 2005 | /* Decide where to split */ |
| 1719 | if (znode->level == 0 && n == c->fanout && | 2006 | if (znode->level == 0 && key_type(c, key) == UBIFS_DATA_KEY) { |
| 1720 | key_type(c, key) == UBIFS_DATA_KEY) { | 2007 | /* Try not to split consecutive data keys */ |
| 1721 | union ubifs_key *key1; | 2008 | if (n == c->fanout) { |
| 1722 | 2009 | key1 = &znode->zbranch[n - 1].key; | |
| 1723 | /* | 2010 | if (key_inum(c, key1) == key_inum(c, key) && |
| 1724 | * If this is an inode which is being appended - do not split | 2011 | key_type(c, key1) == UBIFS_DATA_KEY) |
| 1725 | * it because no other zbranches can be inserted between | 2012 | appending = 1; |
| 1726 | * zbranches of consecutive data nodes anyway. | 2013 | } else |
| 1727 | */ | 2014 | goto check_split; |
| 1728 | key1 = &znode->zbranch[n - 1].key; | 2015 | } else if (appending && n != c->fanout) { |
| 1729 | if (key_inum(c, key1) == key_inum(c, key) && | 2016 | /* Try not to split consecutive data keys */ |
| 1730 | key_type(c, key1) == UBIFS_DATA_KEY && | 2017 | appending = 0; |
| 1731 | key_block(c, key1) == key_block(c, key) - 1) | 2018 | check_split: |
| 1732 | appending = 1; | 2019 | if (n >= (c->fanout + 1) / 2) { |
| 2020 | key1 = &znode->zbranch[0].key; | ||
| 2021 | if (key_inum(c, key1) == key_inum(c, key) && | ||
| 2022 | key_type(c, key1) == UBIFS_DATA_KEY) { | ||
| 2023 | key1 = &znode->zbranch[n].key; | ||
| 2024 | if (key_inum(c, key1) != key_inum(c, key) || | ||
| 2025 | key_type(c, key1) != UBIFS_DATA_KEY) { | ||
| 2026 | keep = n; | ||
| 2027 | move = c->fanout - keep; | ||
| 2028 | zi = znode; | ||
| 2029 | goto do_split; | ||
| 2030 | } | ||
| 2031 | } | ||
| 2032 | } | ||
| 1733 | } | 2033 | } |
| 1734 | 2034 | ||
| 1735 | if (appending) { | 2035 | if (appending) { |
| @@ -1759,6 +2059,8 @@ again: | |||
| 1759 | zbr->znode->parent = zn; | 2059 | zbr->znode->parent = zn; |
| 1760 | } | 2060 | } |
| 1761 | 2061 | ||
| 2062 | do_split: | ||
| 2063 | |||
| 1762 | __set_bit(DIRTY_ZNODE, &zn->flags); | 2064 | __set_bit(DIRTY_ZNODE, &zn->flags); |
| 1763 | atomic_long_inc(&c->dirty_zn_cnt); | 2065 | atomic_long_inc(&c->dirty_zn_cnt); |
| 1764 | 2066 | ||
| @@ -1785,14 +2087,11 @@ again: | |||
| 1785 | 2087 | ||
| 1786 | /* Insert new znode (produced by spitting) into the parent */ | 2088 | /* Insert new znode (produced by spitting) into the parent */ |
| 1787 | if (zp) { | 2089 | if (zp) { |
| 1788 | i = n; | 2090 | if (n == 0 && zi == znode && znode->iip == 0) |
| 2091 | correct_parent_keys(c, znode); | ||
| 2092 | |||
| 1789 | /* Locate insertion point */ | 2093 | /* Locate insertion point */ |
| 1790 | n = znode->iip + 1; | 2094 | n = znode->iip + 1; |
| 1791 | if (appending && n != c->fanout) | ||
| 1792 | appending = 0; | ||
| 1793 | |||
| 1794 | if (i == 0 && zi == znode && znode->iip == 0) | ||
| 1795 | correct_parent_keys(c, znode); | ||
| 1796 | 2095 | ||
| 1797 | /* Tail recursion */ | 2096 | /* Tail recursion */ |
| 1798 | zbr->key = zn->zbranch[0].key; | 2097 | zbr->key = zn->zbranch[0].key; |
diff --git a/fs/ubifs/tnc_misc.c b/fs/ubifs/tnc_misc.c index a25c1cc1f8d..b48db999903 100644 --- a/fs/ubifs/tnc_misc.c +++ b/fs/ubifs/tnc_misc.c | |||
| @@ -480,8 +480,8 @@ int ubifs_tnc_read_node(struct ubifs_info *c, struct ubifs_zbranch *zbr, | |||
| 480 | } | 480 | } |
| 481 | 481 | ||
| 482 | /* Make sure the key of the read node is correct */ | 482 | /* Make sure the key of the read node is correct */ |
| 483 | key_read(c, key, &key1); | 483 | key_read(c, node + UBIFS_KEY_OFFSET, &key1); |
| 484 | if (memcmp(node + UBIFS_KEY_OFFSET, &key1, c->key_len)) { | 484 | if (!keys_eq(c, key, &key1)) { |
| 485 | ubifs_err("bad key in node at LEB %d:%d", | 485 | ubifs_err("bad key in node at LEB %d:%d", |
| 486 | zbr->lnum, zbr->offs); | 486 | zbr->lnum, zbr->offs); |
| 487 | dbg_tnc("looked for key %s found node's key %s", | 487 | dbg_tnc("looked for key %s found node's key %s", |
diff --git a/fs/ubifs/ubifs-media.h b/fs/ubifs/ubifs-media.h index a9ecbd9af20..0b378042a3a 100644 --- a/fs/ubifs/ubifs-media.h +++ b/fs/ubifs/ubifs-media.h | |||
| @@ -75,7 +75,6 @@ | |||
| 75 | */ | 75 | */ |
| 76 | #define UBIFS_BLOCK_SIZE 4096 | 76 | #define UBIFS_BLOCK_SIZE 4096 |
| 77 | #define UBIFS_BLOCK_SHIFT 12 | 77 | #define UBIFS_BLOCK_SHIFT 12 |
| 78 | #define UBIFS_BLOCK_MASK 0x00000FFF | ||
| 79 | 78 | ||
| 80 | /* UBIFS padding byte pattern (must not be first or last byte of node magic) */ | 79 | /* UBIFS padding byte pattern (must not be first or last byte of node magic) */ |
| 81 | #define UBIFS_PADDING_BYTE 0xCE | 80 | #define UBIFS_PADDING_BYTE 0xCE |
diff --git a/fs/ubifs/ubifs.h b/fs/ubifs/ubifs.h index 17c620b93ee..a7bd32fa15b 100644 --- a/fs/ubifs/ubifs.h +++ b/fs/ubifs/ubifs.h | |||
| @@ -142,6 +142,9 @@ | |||
| 142 | /* Maximum expected tree height for use by bottom_up_buf */ | 142 | /* Maximum expected tree height for use by bottom_up_buf */ |
| 143 | #define BOTTOM_UP_HEIGHT 64 | 143 | #define BOTTOM_UP_HEIGHT 64 |
| 144 | 144 | ||
| 145 | /* Maximum number of data nodes to bulk-read */ | ||
| 146 | #define UBIFS_MAX_BULK_READ 32 | ||
| 147 | |||
| 145 | /* | 148 | /* |
| 146 | * Lockdep classes for UBIFS inode @ui_mutex. | 149 | * Lockdep classes for UBIFS inode @ui_mutex. |
| 147 | */ | 150 | */ |
| @@ -328,9 +331,10 @@ struct ubifs_gced_idx_leb { | |||
| 328 | * this inode | 331 | * this inode |
| 329 | * @dirty: non-zero if the inode is dirty | 332 | * @dirty: non-zero if the inode is dirty |
| 330 | * @xattr: non-zero if this is an extended attribute inode | 333 | * @xattr: non-zero if this is an extended attribute inode |
| 334 | * @bulk_read: non-zero if bulk-read should be used | ||
| 331 | * @ui_mutex: serializes inode write-back with the rest of VFS operations, | 335 | * @ui_mutex: serializes inode write-back with the rest of VFS operations, |
| 332 | * serializes "clean <-> dirty" state changes, protects @dirty, | 336 | * serializes "clean <-> dirty" state changes, serializes bulk-read, |
| 333 | * @ui_size, and @xattr_size | 337 | * protects @dirty, @bulk_read, @ui_size, and @xattr_size |
| 334 | * @ui_lock: protects @synced_i_size | 338 | * @ui_lock: protects @synced_i_size |
| 335 | * @synced_i_size: synchronized size of inode, i.e. the value of inode size | 339 | * @synced_i_size: synchronized size of inode, i.e. the value of inode size |
| 336 | * currently stored on the flash; used only for regular file | 340 | * currently stored on the flash; used only for regular file |
| @@ -338,6 +342,8 @@ struct ubifs_gced_idx_leb { | |||
| 338 | * @ui_size: inode size used by UBIFS when writing to flash | 342 | * @ui_size: inode size used by UBIFS when writing to flash |
| 339 | * @flags: inode flags (@UBIFS_COMPR_FL, etc) | 343 | * @flags: inode flags (@UBIFS_COMPR_FL, etc) |
| 340 | * @compr_type: default compression type used for this inode | 344 | * @compr_type: default compression type used for this inode |
| 345 | * @last_page_read: page number of last page read (for bulk read) | ||
| 346 | * @read_in_a_row: number of consecutive pages read in a row (for bulk read) | ||
| 341 | * @data_len: length of the data attached to the inode | 347 | * @data_len: length of the data attached to the inode |
| 342 | * @data: inode's data | 348 | * @data: inode's data |
| 343 | * | 349 | * |
| @@ -379,12 +385,15 @@ struct ubifs_inode { | |||
| 379 | unsigned int xattr_names; | 385 | unsigned int xattr_names; |
| 380 | unsigned int dirty:1; | 386 | unsigned int dirty:1; |
| 381 | unsigned int xattr:1; | 387 | unsigned int xattr:1; |
| 388 | unsigned int bulk_read:1; | ||
| 382 | struct mutex ui_mutex; | 389 | struct mutex ui_mutex; |
| 383 | spinlock_t ui_lock; | 390 | spinlock_t ui_lock; |
| 384 | loff_t synced_i_size; | 391 | loff_t synced_i_size; |
| 385 | loff_t ui_size; | 392 | loff_t ui_size; |
| 386 | int flags; | 393 | int flags; |
| 387 | int compr_type; | 394 | int compr_type; |
| 395 | pgoff_t last_page_read; | ||
| 396 | pgoff_t read_in_a_row; | ||
| 388 | int data_len; | 397 | int data_len; |
| 389 | void *data; | 398 | void *data; |
| 390 | }; | 399 | }; |
| @@ -698,8 +707,8 @@ struct ubifs_jhead { | |||
| 698 | * struct ubifs_zbranch - key/coordinate/length branch stored in znodes. | 707 | * struct ubifs_zbranch - key/coordinate/length branch stored in znodes. |
| 699 | * @key: key | 708 | * @key: key |
| 700 | * @znode: znode address in memory | 709 | * @znode: znode address in memory |
| 701 | * @lnum: LEB number of the indexing node | 710 | * @lnum: LEB number of the target node (indexing node or data node) |
| 702 | * @offs: offset of the indexing node within @lnum | 711 | * @offs: target node offset within @lnum |
| 703 | * @len: target node length | 712 | * @len: target node length |
| 704 | */ | 713 | */ |
| 705 | struct ubifs_zbranch { | 714 | struct ubifs_zbranch { |
| @@ -744,6 +753,28 @@ struct ubifs_znode { | |||
| 744 | }; | 753 | }; |
| 745 | 754 | ||
| 746 | /** | 755 | /** |
| 756 | * struct bu_info - bulk-read information | ||
| 757 | * @key: first data node key | ||
| 758 | * @zbranch: zbranches of data nodes to bulk read | ||
| 759 | * @buf: buffer to read into | ||
| 760 | * @buf_len: buffer length | ||
| 761 | * @gc_seq: GC sequence number to detect races with GC | ||
| 762 | * @cnt: number of data nodes for bulk read | ||
| 763 | * @blk_cnt: number of data blocks including holes | ||
| 764 | * @oef: end of file reached | ||
| 765 | */ | ||
| 766 | struct bu_info { | ||
| 767 | union ubifs_key key; | ||
| 768 | struct ubifs_zbranch zbranch[UBIFS_MAX_BULK_READ]; | ||
| 769 | void *buf; | ||
| 770 | int buf_len; | ||
| 771 | int gc_seq; | ||
| 772 | int cnt; | ||
| 773 | int blk_cnt; | ||
| 774 | int eof; | ||
| 775 | }; | ||
| 776 | |||
| 777 | /** | ||
| 747 | * struct ubifs_node_range - node length range description data structure. | 778 | * struct ubifs_node_range - node length range description data structure. |
| 748 | * @len: fixed node length | 779 | * @len: fixed node length |
| 749 | * @min_len: minimum possible node length | 780 | * @min_len: minimum possible node length |
| @@ -862,9 +893,13 @@ struct ubifs_orphan { | |||
| 862 | /** | 893 | /** |
| 863 | * struct ubifs_mount_opts - UBIFS-specific mount options information. | 894 | * struct ubifs_mount_opts - UBIFS-specific mount options information. |
| 864 | * @unmount_mode: selected unmount mode (%0 default, %1 normal, %2 fast) | 895 | * @unmount_mode: selected unmount mode (%0 default, %1 normal, %2 fast) |
| 896 | * @bulk_read: enable bulk-reads | ||
| 897 | * @chk_data_crc: check CRCs when reading data nodes | ||
| 865 | */ | 898 | */ |
| 866 | struct ubifs_mount_opts { | 899 | struct ubifs_mount_opts { |
| 867 | unsigned int unmount_mode:2; | 900 | unsigned int unmount_mode:2; |
| 901 | unsigned int bulk_read:2; | ||
| 902 | unsigned int chk_data_crc:2; | ||
| 868 | }; | 903 | }; |
| 869 | 904 | ||
| 870 | /** | 905 | /** |
| @@ -905,13 +940,12 @@ struct ubifs_mount_opts { | |||
| 905 | * @cmt_state: commit state | 940 | * @cmt_state: commit state |
| 906 | * @cs_lock: commit state lock | 941 | * @cs_lock: commit state lock |
| 907 | * @cmt_wq: wait queue to sleep on if the log is full and a commit is running | 942 | * @cmt_wq: wait queue to sleep on if the log is full and a commit is running |
| 943 | * | ||
| 908 | * @fast_unmount: do not run journal commit before un-mounting | 944 | * @fast_unmount: do not run journal commit before un-mounting |
| 909 | * @big_lpt: flag that LPT is too big to write whole during commit | 945 | * @big_lpt: flag that LPT is too big to write whole during commit |
| 910 | * @check_lpt_free: flag that indicates LPT GC may be needed | 946 | * @no_chk_data_crc: do not check CRCs when reading data nodes (except during |
| 911 | * @nospace: non-zero if the file-system does not have flash space (used as | 947 | * recovery) |
| 912 | * optimization) | 948 | * @bulk_read: enable bulk-reads |
| 913 | * @nospace_rp: the same as @nospace, but additionally means that even reserved | ||
| 914 | * pool is full | ||
| 915 | * | 949 | * |
| 916 | * @tnc_mutex: protects the Tree Node Cache (TNC), @zroot, @cnext, @enext, and | 950 | * @tnc_mutex: protects the Tree Node Cache (TNC), @zroot, @cnext, @enext, and |
| 917 | * @calc_idx_sz | 951 | * @calc_idx_sz |
| @@ -935,6 +969,7 @@ struct ubifs_mount_opts { | |||
| 935 | * @mst_node: master node | 969 | * @mst_node: master node |
| 936 | * @mst_offs: offset of valid master node | 970 | * @mst_offs: offset of valid master node |
| 937 | * @mst_mutex: protects the master node area, @mst_node, and @mst_offs | 971 | * @mst_mutex: protects the master node area, @mst_node, and @mst_offs |
| 972 | * @bulk_read_buf_size: buffer size for bulk-reads | ||
| 938 | * | 973 | * |
| 939 | * @log_lebs: number of logical eraseblocks in the log | 974 | * @log_lebs: number of logical eraseblocks in the log |
| 940 | * @log_bytes: log size in bytes | 975 | * @log_bytes: log size in bytes |
| @@ -977,12 +1012,17 @@ struct ubifs_mount_opts { | |||
| 977 | * but which still have to be taken into account because | 1012 | * but which still have to be taken into account because |
| 978 | * the index has not been committed so far | 1013 | * the index has not been committed so far |
| 979 | * @space_lock: protects @budg_idx_growth, @budg_data_growth, @budg_dd_growth, | 1014 | * @space_lock: protects @budg_idx_growth, @budg_data_growth, @budg_dd_growth, |
| 980 | * @budg_uncommited_idx, @min_idx_lebs, @old_idx_sz, and @lst; | 1015 | * @budg_uncommited_idx, @min_idx_lebs, @old_idx_sz, @lst, |
| 1016 | * @nospace, and @nospace_rp; | ||
| 981 | * @min_idx_lebs: minimum number of LEBs required for the index | 1017 | * @min_idx_lebs: minimum number of LEBs required for the index |
| 982 | * @old_idx_sz: size of index on flash | 1018 | * @old_idx_sz: size of index on flash |
| 983 | * @calc_idx_sz: temporary variable which is used to calculate new index size | 1019 | * @calc_idx_sz: temporary variable which is used to calculate new index size |
| 984 | * (contains accurate new index size at end of TNC commit start) | 1020 | * (contains accurate new index size at end of TNC commit start) |
| 985 | * @lst: lprops statistics | 1021 | * @lst: lprops statistics |
| 1022 | * @nospace: non-zero if the file-system does not have flash space (used as | ||
| 1023 | * optimization) | ||
| 1024 | * @nospace_rp: the same as @nospace, but additionally means that even reserved | ||
| 1025 | * pool is full | ||
| 986 | * | 1026 | * |
| 987 | * @page_budget: budget for a page | 1027 | * @page_budget: budget for a page |
| 988 | * @inode_budget: budget for an inode | 1028 | * @inode_budget: budget for an inode |
| @@ -1061,6 +1101,7 @@ struct ubifs_mount_opts { | |||
| 1061 | * @lpt_drty_flgs: dirty flags for LPT special nodes e.g. ltab | 1101 | * @lpt_drty_flgs: dirty flags for LPT special nodes e.g. ltab |
| 1062 | * @dirty_nn_cnt: number of dirty nnodes | 1102 | * @dirty_nn_cnt: number of dirty nnodes |
| 1063 | * @dirty_pn_cnt: number of dirty pnodes | 1103 | * @dirty_pn_cnt: number of dirty pnodes |
| 1104 | * @check_lpt_free: flag that indicates LPT GC may be needed | ||
| 1064 | * @lpt_sz: LPT size | 1105 | * @lpt_sz: LPT size |
| 1065 | * @lpt_nod_buf: buffer for an on-flash nnode or pnode | 1106 | * @lpt_nod_buf: buffer for an on-flash nnode or pnode |
| 1066 | * @lpt_buf: buffer of LEB size used by LPT | 1107 | * @lpt_buf: buffer of LEB size used by LPT |
| @@ -1102,6 +1143,7 @@ struct ubifs_mount_opts { | |||
| 1102 | * @rcvrd_mst_node: recovered master node to write when mounting ro to rw | 1143 | * @rcvrd_mst_node: recovered master node to write when mounting ro to rw |
| 1103 | * @size_tree: inode size information for recovery | 1144 | * @size_tree: inode size information for recovery |
| 1104 | * @remounting_rw: set while remounting from ro to rw (sb flags have MS_RDONLY) | 1145 | * @remounting_rw: set while remounting from ro to rw (sb flags have MS_RDONLY) |
| 1146 | * @always_chk_crc: always check CRCs (while mounting and remounting rw) | ||
| 1105 | * @mount_opts: UBIFS-specific mount options | 1147 | * @mount_opts: UBIFS-specific mount options |
| 1106 | * | 1148 | * |
| 1107 | * @dbg_buf: a buffer of LEB size used for debugging purposes | 1149 | * @dbg_buf: a buffer of LEB size used for debugging purposes |
| @@ -1146,11 +1188,11 @@ struct ubifs_info { | |||
| 1146 | int cmt_state; | 1188 | int cmt_state; |
| 1147 | spinlock_t cs_lock; | 1189 | spinlock_t cs_lock; |
| 1148 | wait_queue_head_t cmt_wq; | 1190 | wait_queue_head_t cmt_wq; |
| 1191 | |||
| 1149 | unsigned int fast_unmount:1; | 1192 | unsigned int fast_unmount:1; |
| 1150 | unsigned int big_lpt:1; | 1193 | unsigned int big_lpt:1; |
| 1151 | unsigned int check_lpt_free:1; | 1194 | unsigned int no_chk_data_crc:1; |
| 1152 | unsigned int nospace:1; | 1195 | unsigned int bulk_read:1; |
| 1153 | unsigned int nospace_rp:1; | ||
| 1154 | 1196 | ||
| 1155 | struct mutex tnc_mutex; | 1197 | struct mutex tnc_mutex; |
| 1156 | struct ubifs_zbranch zroot; | 1198 | struct ubifs_zbranch zroot; |
| @@ -1175,6 +1217,7 @@ struct ubifs_info { | |||
| 1175 | struct ubifs_mst_node *mst_node; | 1217 | struct ubifs_mst_node *mst_node; |
| 1176 | int mst_offs; | 1218 | int mst_offs; |
| 1177 | struct mutex mst_mutex; | 1219 | struct mutex mst_mutex; |
| 1220 | int bulk_read_buf_size; | ||
| 1178 | 1221 | ||
| 1179 | int log_lebs; | 1222 | int log_lebs; |
| 1180 | long long log_bytes; | 1223 | long long log_bytes; |
| @@ -1218,6 +1261,8 @@ struct ubifs_info { | |||
| 1218 | unsigned long long old_idx_sz; | 1261 | unsigned long long old_idx_sz; |
| 1219 | unsigned long long calc_idx_sz; | 1262 | unsigned long long calc_idx_sz; |
| 1220 | struct ubifs_lp_stats lst; | 1263 | struct ubifs_lp_stats lst; |
| 1264 | unsigned int nospace:1; | ||
| 1265 | unsigned int nospace_rp:1; | ||
| 1221 | 1266 | ||
| 1222 | int page_budget; | 1267 | int page_budget; |
| 1223 | int inode_budget; | 1268 | int inode_budget; |
| @@ -1294,6 +1339,7 @@ struct ubifs_info { | |||
| 1294 | int lpt_drty_flgs; | 1339 | int lpt_drty_flgs; |
| 1295 | int dirty_nn_cnt; | 1340 | int dirty_nn_cnt; |
| 1296 | int dirty_pn_cnt; | 1341 | int dirty_pn_cnt; |
| 1342 | int check_lpt_free; | ||
| 1297 | long long lpt_sz; | 1343 | long long lpt_sz; |
| 1298 | void *lpt_nod_buf; | 1344 | void *lpt_nod_buf; |
| 1299 | void *lpt_buf; | 1345 | void *lpt_buf; |
| @@ -1335,6 +1381,7 @@ struct ubifs_info { | |||
| 1335 | struct ubifs_mst_node *rcvrd_mst_node; | 1381 | struct ubifs_mst_node *rcvrd_mst_node; |
| 1336 | struct rb_root size_tree; | 1382 | struct rb_root size_tree; |
| 1337 | int remounting_rw; | 1383 | int remounting_rw; |
| 1384 | int always_chk_crc; | ||
| 1338 | struct ubifs_mount_opts mount_opts; | 1385 | struct ubifs_mount_opts mount_opts; |
| 1339 | 1386 | ||
| 1340 | #ifdef CONFIG_UBIFS_FS_DEBUG | 1387 | #ifdef CONFIG_UBIFS_FS_DEBUG |
| @@ -1347,6 +1394,12 @@ struct ubifs_info { | |||
| 1347 | unsigned long fail_timeout; | 1394 | unsigned long fail_timeout; |
| 1348 | unsigned int fail_cnt; | 1395 | unsigned int fail_cnt; |
| 1349 | unsigned int fail_cnt_max; | 1396 | unsigned int fail_cnt_max; |
| 1397 | long long chk_lpt_sz; | ||
| 1398 | long long chk_lpt_sz2; | ||
| 1399 | long long chk_lpt_wastage; | ||
| 1400 | int chk_lpt_lebs; | ||
| 1401 | int new_nhead_lnum; | ||
| 1402 | int new_nhead_offs; | ||
| 1350 | #endif | 1403 | #endif |
| 1351 | }; | 1404 | }; |
| 1352 | 1405 | ||
| @@ -1377,7 +1430,7 @@ int ubifs_read_node_wbuf(struct ubifs_wbuf *wbuf, void *buf, int type, int len, | |||
| 1377 | int ubifs_write_node(struct ubifs_info *c, void *node, int len, int lnum, | 1430 | int ubifs_write_node(struct ubifs_info *c, void *node, int len, int lnum, |
| 1378 | int offs, int dtype); | 1431 | int offs, int dtype); |
| 1379 | int ubifs_check_node(const struct ubifs_info *c, const void *buf, int lnum, | 1432 | int ubifs_check_node(const struct ubifs_info *c, const void *buf, int lnum, |
| 1380 | int offs, int quiet); | 1433 | int offs, int quiet, int chk_crc); |
| 1381 | void ubifs_prepare_node(struct ubifs_info *c, void *buf, int len, int pad); | 1434 | void ubifs_prepare_node(struct ubifs_info *c, void *buf, int len, int pad); |
| 1382 | void ubifs_prep_grp_node(struct ubifs_info *c, void *node, int len, int last); | 1435 | void ubifs_prep_grp_node(struct ubifs_info *c, void *node, int len, int last); |
| 1383 | int ubifs_io_init(struct ubifs_info *c); | 1436 | int ubifs_io_init(struct ubifs_info *c); |
| @@ -1490,6 +1543,8 @@ void destroy_old_idx(struct ubifs_info *c); | |||
| 1490 | int is_idx_node_in_tnc(struct ubifs_info *c, union ubifs_key *key, int level, | 1543 | int is_idx_node_in_tnc(struct ubifs_info *c, union ubifs_key *key, int level, |
| 1491 | int lnum, int offs); | 1544 | int lnum, int offs); |
| 1492 | int insert_old_idx_znode(struct ubifs_info *c, struct ubifs_znode *znode); | 1545 | int insert_old_idx_znode(struct ubifs_info *c, struct ubifs_znode *znode); |
| 1546 | int ubifs_tnc_get_bu_keys(struct ubifs_info *c, struct bu_info *bu); | ||
| 1547 | int ubifs_tnc_bulk_read(struct ubifs_info *c, struct bu_info *bu); | ||
| 1493 | 1548 | ||
| 1494 | /* tnc_misc.c */ | 1549 | /* tnc_misc.c */ |
| 1495 | struct ubifs_znode *ubifs_tnc_levelorder_next(struct ubifs_znode *zr, | 1550 | struct ubifs_znode *ubifs_tnc_levelorder_next(struct ubifs_znode *zr, |
| @@ -1586,12 +1641,10 @@ int ubifs_lpt_post_commit(struct ubifs_info *c); | |||
| 1586 | void ubifs_lpt_free(struct ubifs_info *c, int wr_only); | 1641 | void ubifs_lpt_free(struct ubifs_info *c, int wr_only); |
| 1587 | 1642 | ||
| 1588 | /* lprops.c */ | 1643 | /* lprops.c */ |
| 1589 | void ubifs_get_lprops(struct ubifs_info *c); | ||
| 1590 | const struct ubifs_lprops *ubifs_change_lp(struct ubifs_info *c, | 1644 | const struct ubifs_lprops *ubifs_change_lp(struct ubifs_info *c, |
| 1591 | const struct ubifs_lprops *lp, | 1645 | const struct ubifs_lprops *lp, |
| 1592 | int free, int dirty, int flags, | 1646 | int free, int dirty, int flags, |
| 1593 | int idx_gc_cnt); | 1647 | int idx_gc_cnt); |
| 1594 | void ubifs_release_lprops(struct ubifs_info *c); | ||
| 1595 | void ubifs_get_lp_stats(struct ubifs_info *c, struct ubifs_lp_stats *stats); | 1648 | void ubifs_get_lp_stats(struct ubifs_info *c, struct ubifs_lp_stats *stats); |
| 1596 | void ubifs_add_to_cat(struct ubifs_info *c, struct ubifs_lprops *lprops, | 1649 | void ubifs_add_to_cat(struct ubifs_info *c, struct ubifs_lprops *lprops, |
| 1597 | int cat); | 1650 | int cat); |
diff --git a/fs/ubifs/xattr.c b/fs/ubifs/xattr.c index 649bec78b64..cfd31e229c8 100644 --- a/fs/ubifs/xattr.c +++ b/fs/ubifs/xattr.c | |||
| @@ -446,7 +446,7 @@ ssize_t ubifs_listxattr(struct dentry *dentry, char *buffer, size_t size) | |||
| 446 | int type; | 446 | int type; |
| 447 | 447 | ||
| 448 | xent = ubifs_tnc_next_ent(c, &key, &nm); | 448 | xent = ubifs_tnc_next_ent(c, &key, &nm); |
| 449 | if (unlikely(IS_ERR(xent))) { | 449 | if (IS_ERR(xent)) { |
| 450 | err = PTR_ERR(xent); | 450 | err = PTR_ERR(xent); |
| 451 | break; | 451 | break; |
| 452 | } | 452 | } |
