diff options
| author | Linus Torvalds <torvalds@linux-foundation.org> | 2011-07-22 22:02:39 -0400 |
|---|---|---|
| committer | Linus Torvalds <torvalds@linux-foundation.org> | 2011-07-22 22:02:39 -0400 |
| commit | bbd9d6f7fbb0305c9a592bf05a32e87eb364a4ff (patch) | |
| tree | 12b2bb4202b05f6ae6a43c6ce830a0472043dbe5 /drivers | |
| parent | 8e204874db000928e37199c2db82b7eb8966cc3c (diff) | |
| parent | 5a9a43646cf709312d71eca71cef90ad802f28f9 (diff) | |
Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs-2.6
* 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs-2.6: (107 commits)
vfs: use ERR_CAST for err-ptr tossing in lookup_instantiate_filp
isofs: Remove global fs lock
jffs2: fix IN_DELETE_SELF on overwriting rename() killing a directory
fix IN_DELETE_SELF on overwriting rename() on ramfs et.al.
mm/truncate.c: fix build for CONFIG_BLOCK not enabled
fs:update the NOTE of the file_operations structure
Remove dead code in dget_parent()
AFS: Fix silly characters in a comment
switch d_add_ci() to d_splice_alias() in "found negative" case as well
simplify gfs2_lookup()
jfs_lookup(): don't bother with . or ..
get rid of useless dget_parent() in btrfs rename() and link()
get rid of useless dget_parent() in fs/btrfs/ioctl.c
fs: push i_mutex and filemap_write_and_wait down into ->fsync() handlers
drivers: fix up various ->llseek() implementations
fs: handle SEEK_HOLE/SEEK_DATA properly in all fs's that define their own llseek
Ext4: handle SEEK_HOLE/SEEK_DATA generically
Btrfs: implement our own ->llseek
fs: add SEEK_HOLE and SEEK_DATA flags
reiserfs: make reiserfs default to barrier=flush
...
Fix up trivial conflicts in fs/xfs/linux-2.6/xfs_super.c due to the new
shrinker callout for the inode cache, that clashed with the xfs code to
start the periodic workers later.
Diffstat (limited to 'drivers')
| -rw-r--r-- | drivers/base/devtmpfs.c | 337 | ||||
| -rw-r--r-- | drivers/block/pktcdvd.c | 2 | ||||
| -rw-r--r-- | drivers/char/generic_nvram.c | 4 | ||||
| -rw-r--r-- | drivers/char/nvram.c | 2 | ||||
| -rw-r--r-- | drivers/char/ps3flash.c | 13 | ||||
| -rw-r--r-- | drivers/macintosh/nvram.c | 4 | ||||
| -rw-r--r-- | drivers/md/md.c | 26 | ||||
| -rw-r--r-- | drivers/mtd/ubi/cdev.c | 10 | ||||
| -rw-r--r-- | drivers/sh/clk/core.c | 7 | ||||
| -rw-r--r-- | drivers/staging/pohmelfs/dir.c | 2 | ||||
| -rw-r--r-- | drivers/staging/pohmelfs/inode.c | 11 | ||||
| -rw-r--r-- | drivers/usb/gadget/printer.c | 5 | ||||
| -rw-r--r-- | drivers/video/fb_defio.c | 11 |
13 files changed, 259 insertions, 175 deletions
diff --git a/drivers/base/devtmpfs.c b/drivers/base/devtmpfs.c index 82bbb5967aa9..6d678c99512e 100644 --- a/drivers/base/devtmpfs.c +++ b/drivers/base/devtmpfs.c | |||
| @@ -21,12 +21,11 @@ | |||
| 21 | #include <linux/fs.h> | 21 | #include <linux/fs.h> |
| 22 | #include <linux/shmem_fs.h> | 22 | #include <linux/shmem_fs.h> |
| 23 | #include <linux/ramfs.h> | 23 | #include <linux/ramfs.h> |
| 24 | #include <linux/cred.h> | ||
| 25 | #include <linux/sched.h> | 24 | #include <linux/sched.h> |
| 26 | #include <linux/init_task.h> | ||
| 27 | #include <linux/slab.h> | 25 | #include <linux/slab.h> |
| 26 | #include <linux/kthread.h> | ||
| 28 | 27 | ||
| 29 | static struct vfsmount *dev_mnt; | 28 | static struct task_struct *thread; |
| 30 | 29 | ||
| 31 | #if defined CONFIG_DEVTMPFS_MOUNT | 30 | #if defined CONFIG_DEVTMPFS_MOUNT |
| 32 | static int mount_dev = 1; | 31 | static int mount_dev = 1; |
| @@ -34,7 +33,16 @@ static int mount_dev = 1; | |||
| 34 | static int mount_dev; | 33 | static int mount_dev; |
| 35 | #endif | 34 | #endif |
| 36 | 35 | ||
| 37 | static DEFINE_MUTEX(dirlock); | 36 | static DEFINE_SPINLOCK(req_lock); |
| 37 | |||
| 38 | static struct req { | ||
| 39 | struct req *next; | ||
| 40 | struct completion done; | ||
| 41 | int err; | ||
| 42 | const char *name; | ||
| 43 | mode_t mode; /* 0 => delete */ | ||
| 44 | struct device *dev; | ||
| 45 | } *requests; | ||
| 38 | 46 | ||
| 39 | static int __init mount_param(char *str) | 47 | static int __init mount_param(char *str) |
| 40 | { | 48 | { |
| @@ -68,131 +76,152 @@ static inline int is_blockdev(struct device *dev) | |||
| 68 | static inline int is_blockdev(struct device *dev) { return 0; } | 76 | static inline int is_blockdev(struct device *dev) { return 0; } |
| 69 | #endif | 77 | #endif |
| 70 | 78 | ||
| 79 | int devtmpfs_create_node(struct device *dev) | ||
| 80 | { | ||
| 81 | const char *tmp = NULL; | ||
| 82 | struct req req; | ||
| 83 | |||
| 84 | if (!thread) | ||
| 85 | return 0; | ||
| 86 | |||
| 87 | req.mode = 0; | ||
| 88 | req.name = device_get_devnode(dev, &req.mode, &tmp); | ||
| 89 | if (!req.name) | ||
| 90 | return -ENOMEM; | ||
| 91 | |||
| 92 | if (req.mode == 0) | ||
| 93 | req.mode = 0600; | ||
| 94 | if (is_blockdev(dev)) | ||
| 95 | req.mode |= S_IFBLK; | ||
| 96 | else | ||
| 97 | req.mode |= S_IFCHR; | ||
| 98 | |||
| 99 | req.dev = dev; | ||
| 100 | |||
| 101 | init_completion(&req.done); | ||
| 102 | |||
| 103 | spin_lock(&req_lock); | ||
| 104 | req.next = requests; | ||
| 105 | requests = &req; | ||
| 106 | spin_unlock(&req_lock); | ||
| 107 | |||
| 108 | wake_up_process(thread); | ||
| 109 | wait_for_completion(&req.done); | ||
| 110 | |||
| 111 | kfree(tmp); | ||
| 112 | |||
| 113 | return req.err; | ||
| 114 | } | ||
| 115 | |||
| 116 | int devtmpfs_delete_node(struct device *dev) | ||
| 117 | { | ||
| 118 | const char *tmp = NULL; | ||
| 119 | struct req req; | ||
| 120 | |||
| 121 | if (!thread) | ||
| 122 | return 0; | ||
| 123 | |||
| 124 | req.name = device_get_devnode(dev, NULL, &tmp); | ||
| 125 | if (!req.name) | ||
| 126 | return -ENOMEM; | ||
| 127 | |||
| 128 | req.mode = 0; | ||
| 129 | req.dev = dev; | ||
| 130 | |||
| 131 | init_completion(&req.done); | ||
| 132 | |||
| 133 | spin_lock(&req_lock); | ||
| 134 | req.next = requests; | ||
| 135 | requests = &req; | ||
| 136 | spin_unlock(&req_lock); | ||
| 137 | |||
| 138 | wake_up_process(thread); | ||
| 139 | wait_for_completion(&req.done); | ||
| 140 | |||
| 141 | kfree(tmp); | ||
| 142 | return req.err; | ||
| 143 | } | ||
| 144 | |||
| 71 | static int dev_mkdir(const char *name, mode_t mode) | 145 | static int dev_mkdir(const char *name, mode_t mode) |
| 72 | { | 146 | { |
| 73 | struct nameidata nd; | ||
| 74 | struct dentry *dentry; | 147 | struct dentry *dentry; |
| 148 | struct path path; | ||
| 75 | int err; | 149 | int err; |
| 76 | 150 | ||
| 77 | err = vfs_path_lookup(dev_mnt->mnt_root, dev_mnt, | 151 | dentry = kern_path_create(AT_FDCWD, name, &path, 1); |
| 78 | name, LOOKUP_PARENT, &nd); | 152 | if (IS_ERR(dentry)) |
| 79 | if (err) | 153 | return PTR_ERR(dentry); |
| 80 | return err; | 154 | |
| 81 | 155 | err = vfs_mkdir(path.dentry->d_inode, dentry, mode); | |
| 82 | dentry = lookup_create(&nd, 1); | 156 | if (!err) |
| 83 | if (!IS_ERR(dentry)) { | 157 | /* mark as kernel-created inode */ |
| 84 | err = vfs_mkdir(nd.path.dentry->d_inode, dentry, mode); | 158 | dentry->d_inode->i_private = &thread; |
| 85 | if (!err) | 159 | dput(dentry); |
| 86 | /* mark as kernel-created inode */ | 160 | mutex_unlock(&path.dentry->d_inode->i_mutex); |
| 87 | dentry->d_inode->i_private = &dev_mnt; | 161 | path_put(&path); |
| 88 | dput(dentry); | ||
| 89 | } else { | ||
| 90 | err = PTR_ERR(dentry); | ||
| 91 | } | ||
| 92 | |||
| 93 | mutex_unlock(&nd.path.dentry->d_inode->i_mutex); | ||
| 94 | path_put(&nd.path); | ||
| 95 | return err; | 162 | return err; |
| 96 | } | 163 | } |
| 97 | 164 | ||
| 98 | static int create_path(const char *nodepath) | 165 | static int create_path(const char *nodepath) |
| 99 | { | 166 | { |
| 167 | char *path; | ||
| 168 | char *s; | ||
| 100 | int err; | 169 | int err; |
| 101 | 170 | ||
| 102 | mutex_lock(&dirlock); | 171 | /* parent directories do not exist, create them */ |
| 103 | err = dev_mkdir(nodepath, 0755); | 172 | path = kstrdup(nodepath, GFP_KERNEL); |
| 104 | if (err == -ENOENT) { | 173 | if (!path) |
| 105 | char *path; | 174 | return -ENOMEM; |
| 106 | char *s; | 175 | |
| 107 | 176 | s = path; | |
| 108 | /* parent directories do not exist, create them */ | 177 | for (;;) { |
| 109 | path = kstrdup(nodepath, GFP_KERNEL); | 178 | s = strchr(s, '/'); |
| 110 | if (!path) { | 179 | if (!s) |
| 111 | err = -ENOMEM; | 180 | break; |
| 112 | goto out; | 181 | s[0] = '\0'; |
| 113 | } | 182 | err = dev_mkdir(path, 0755); |
| 114 | s = path; | 183 | if (err && err != -EEXIST) |
| 115 | for (;;) { | 184 | break; |
| 116 | s = strchr(s, '/'); | 185 | s[0] = '/'; |
| 117 | if (!s) | 186 | s++; |
| 118 | break; | ||
| 119 | s[0] = '\0'; | ||
| 120 | err = dev_mkdir(path, 0755); | ||
| 121 | if (err && err != -EEXIST) | ||
| 122 | break; | ||
| 123 | s[0] = '/'; | ||
| 124 | s++; | ||
| 125 | } | ||
| 126 | kfree(path); | ||
| 127 | } | 187 | } |
| 128 | out: | 188 | kfree(path); |
| 129 | mutex_unlock(&dirlock); | ||
| 130 | return err; | 189 | return err; |
| 131 | } | 190 | } |
| 132 | 191 | ||
| 133 | int devtmpfs_create_node(struct device *dev) | 192 | static int handle_create(const char *nodename, mode_t mode, struct device *dev) |
| 134 | { | 193 | { |
| 135 | const char *tmp = NULL; | ||
| 136 | const char *nodename; | ||
| 137 | const struct cred *curr_cred; | ||
| 138 | mode_t mode = 0; | ||
| 139 | struct nameidata nd; | ||
| 140 | struct dentry *dentry; | 194 | struct dentry *dentry; |
| 195 | struct path path; | ||
| 141 | int err; | 196 | int err; |
| 142 | 197 | ||
| 143 | if (!dev_mnt) | 198 | dentry = kern_path_create(AT_FDCWD, nodename, &path, 0); |
| 144 | return 0; | 199 | if (dentry == ERR_PTR(-ENOENT)) { |
| 145 | |||
| 146 | nodename = device_get_devnode(dev, &mode, &tmp); | ||
| 147 | if (!nodename) | ||
| 148 | return -ENOMEM; | ||
| 149 | |||
| 150 | if (mode == 0) | ||
| 151 | mode = 0600; | ||
| 152 | if (is_blockdev(dev)) | ||
| 153 | mode |= S_IFBLK; | ||
| 154 | else | ||
| 155 | mode |= S_IFCHR; | ||
| 156 | |||
| 157 | curr_cred = override_creds(&init_cred); | ||
| 158 | |||
| 159 | err = vfs_path_lookup(dev_mnt->mnt_root, dev_mnt, | ||
| 160 | nodename, LOOKUP_PARENT, &nd); | ||
| 161 | if (err == -ENOENT) { | ||
| 162 | create_path(nodename); | 200 | create_path(nodename); |
| 163 | err = vfs_path_lookup(dev_mnt->mnt_root, dev_mnt, | 201 | dentry = kern_path_create(AT_FDCWD, nodename, &path, 0); |
| 164 | nodename, LOOKUP_PARENT, &nd); | ||
| 165 | } | 202 | } |
| 166 | if (err) | 203 | if (IS_ERR(dentry)) |
| 167 | goto out; | 204 | return PTR_ERR(dentry); |
| 168 | 205 | ||
| 169 | dentry = lookup_create(&nd, 0); | 206 | err = vfs_mknod(path.dentry->d_inode, |
| 170 | if (!IS_ERR(dentry)) { | 207 | dentry, mode, dev->devt); |
| 171 | err = vfs_mknod(nd.path.dentry->d_inode, | 208 | if (!err) { |
| 172 | dentry, mode, dev->devt); | 209 | struct iattr newattrs; |
| 173 | if (!err) { | 210 | |
| 174 | struct iattr newattrs; | 211 | /* fixup possibly umasked mode */ |
| 175 | 212 | newattrs.ia_mode = mode; | |
| 176 | /* fixup possibly umasked mode */ | 213 | newattrs.ia_valid = ATTR_MODE; |
| 177 | newattrs.ia_mode = mode; | 214 | mutex_lock(&dentry->d_inode->i_mutex); |
| 178 | newattrs.ia_valid = ATTR_MODE; | 215 | notify_change(dentry, &newattrs); |
| 179 | mutex_lock(&dentry->d_inode->i_mutex); | 216 | mutex_unlock(&dentry->d_inode->i_mutex); |
| 180 | notify_change(dentry, &newattrs); | 217 | |
| 181 | mutex_unlock(&dentry->d_inode->i_mutex); | 218 | /* mark as kernel-created inode */ |
| 182 | 219 | dentry->d_inode->i_private = &thread; | |
| 183 | /* mark as kernel-created inode */ | ||
| 184 | dentry->d_inode->i_private = &dev_mnt; | ||
| 185 | } | ||
| 186 | dput(dentry); | ||
| 187 | } else { | ||
| 188 | err = PTR_ERR(dentry); | ||
| 189 | } | 220 | } |
| 221 | dput(dentry); | ||
| 190 | 222 | ||
| 191 | mutex_unlock(&nd.path.dentry->d_inode->i_mutex); | 223 | mutex_unlock(&path.dentry->d_inode->i_mutex); |
| 192 | path_put(&nd.path); | 224 | path_put(&path); |
| 193 | out: | ||
| 194 | kfree(tmp); | ||
| 195 | revert_creds(curr_cred); | ||
| 196 | return err; | 225 | return err; |
| 197 | } | 226 | } |
| 198 | 227 | ||
| @@ -202,8 +231,7 @@ static int dev_rmdir(const char *name) | |||
| 202 | struct dentry *dentry; | 231 | struct dentry *dentry; |
| 203 | int err; | 232 | int err; |
| 204 | 233 | ||
| 205 | err = vfs_path_lookup(dev_mnt->mnt_root, dev_mnt, | 234 | err = kern_path_parent(name, &nd); |
| 206 | name, LOOKUP_PARENT, &nd); | ||
| 207 | if (err) | 235 | if (err) |
| 208 | return err; | 236 | return err; |
| 209 | 237 | ||
| @@ -211,7 +239,7 @@ static int dev_rmdir(const char *name) | |||
| 211 | dentry = lookup_one_len(nd.last.name, nd.path.dentry, nd.last.len); | 239 | dentry = lookup_one_len(nd.last.name, nd.path.dentry, nd.last.len); |
| 212 | if (!IS_ERR(dentry)) { | 240 | if (!IS_ERR(dentry)) { |
| 213 | if (dentry->d_inode) { | 241 | if (dentry->d_inode) { |
| 214 | if (dentry->d_inode->i_private == &dev_mnt) | 242 | if (dentry->d_inode->i_private == &thread) |
| 215 | err = vfs_rmdir(nd.path.dentry->d_inode, | 243 | err = vfs_rmdir(nd.path.dentry->d_inode, |
| 216 | dentry); | 244 | dentry); |
| 217 | else | 245 | else |
| @@ -238,7 +266,6 @@ static int delete_path(const char *nodepath) | |||
| 238 | if (!path) | 266 | if (!path) |
| 239 | return -ENOMEM; | 267 | return -ENOMEM; |
| 240 | 268 | ||
| 241 | mutex_lock(&dirlock); | ||
| 242 | for (;;) { | 269 | for (;;) { |
| 243 | char *base; | 270 | char *base; |
| 244 | 271 | ||
| @@ -250,7 +277,6 @@ static int delete_path(const char *nodepath) | |||
| 250 | if (err) | 277 | if (err) |
| 251 | break; | 278 | break; |
| 252 | } | 279 | } |
| 253 | mutex_unlock(&dirlock); | ||
| 254 | 280 | ||
| 255 | kfree(path); | 281 | kfree(path); |
| 256 | return err; | 282 | return err; |
| @@ -259,7 +285,7 @@ static int delete_path(const char *nodepath) | |||
| 259 | static int dev_mynode(struct device *dev, struct inode *inode, struct kstat *stat) | 285 | static int dev_mynode(struct device *dev, struct inode *inode, struct kstat *stat) |
| 260 | { | 286 | { |
| 261 | /* did we create it */ | 287 | /* did we create it */ |
| 262 | if (inode->i_private != &dev_mnt) | 288 | if (inode->i_private != &thread) |
| 263 | return 0; | 289 | return 0; |
| 264 | 290 | ||
| 265 | /* does the dev_t match */ | 291 | /* does the dev_t match */ |
| @@ -277,29 +303,17 @@ static int dev_mynode(struct device *dev, struct inode *inode, struct kstat *sta | |||
| 277 | return 1; | 303 | return 1; |
| 278 | } | 304 | } |
| 279 | 305 | ||
| 280 | int devtmpfs_delete_node(struct device *dev) | 306 | static int handle_remove(const char *nodename, struct device *dev) |
| 281 | { | 307 | { |
| 282 | const char *tmp = NULL; | ||
| 283 | const char *nodename; | ||
| 284 | const struct cred *curr_cred; | ||
| 285 | struct nameidata nd; | 308 | struct nameidata nd; |
| 286 | struct dentry *dentry; | 309 | struct dentry *dentry; |
| 287 | struct kstat stat; | 310 | struct kstat stat; |
| 288 | int deleted = 1; | 311 | int deleted = 1; |
| 289 | int err; | 312 | int err; |
| 290 | 313 | ||
| 291 | if (!dev_mnt) | 314 | err = kern_path_parent(nodename, &nd); |
| 292 | return 0; | ||
| 293 | |||
| 294 | nodename = device_get_devnode(dev, NULL, &tmp); | ||
| 295 | if (!nodename) | ||
| 296 | return -ENOMEM; | ||
| 297 | |||
| 298 | curr_cred = override_creds(&init_cred); | ||
| 299 | err = vfs_path_lookup(dev_mnt->mnt_root, dev_mnt, | ||
| 300 | nodename, LOOKUP_PARENT, &nd); | ||
| 301 | if (err) | 315 | if (err) |
| 302 | goto out; | 316 | return err; |
| 303 | 317 | ||
| 304 | mutex_lock_nested(&nd.path.dentry->d_inode->i_mutex, I_MUTEX_PARENT); | 318 | mutex_lock_nested(&nd.path.dentry->d_inode->i_mutex, I_MUTEX_PARENT); |
| 305 | dentry = lookup_one_len(nd.last.name, nd.path.dentry, nd.last.len); | 319 | dentry = lookup_one_len(nd.last.name, nd.path.dentry, nd.last.len); |
| @@ -337,9 +351,6 @@ int devtmpfs_delete_node(struct device *dev) | |||
| 337 | path_put(&nd.path); | 351 | path_put(&nd.path); |
| 338 | if (deleted && strchr(nodename, '/')) | 352 | if (deleted && strchr(nodename, '/')) |
| 339 | delete_path(nodename); | 353 | delete_path(nodename); |
| 340 | out: | ||
| 341 | kfree(tmp); | ||
| 342 | revert_creds(curr_cred); | ||
| 343 | return err; | 354 | return err; |
| 344 | } | 355 | } |
| 345 | 356 | ||
| @@ -354,7 +365,7 @@ int devtmpfs_mount(const char *mntdir) | |||
| 354 | if (!mount_dev) | 365 | if (!mount_dev) |
| 355 | return 0; | 366 | return 0; |
| 356 | 367 | ||
| 357 | if (!dev_mnt) | 368 | if (!thread) |
| 358 | return 0; | 369 | return 0; |
| 359 | 370 | ||
| 360 | err = sys_mount("devtmpfs", (char *)mntdir, "devtmpfs", MS_SILENT, NULL); | 371 | err = sys_mount("devtmpfs", (char *)mntdir, "devtmpfs", MS_SILENT, NULL); |
| @@ -365,31 +376,79 @@ int devtmpfs_mount(const char *mntdir) | |||
| 365 | return err; | 376 | return err; |
| 366 | } | 377 | } |
| 367 | 378 | ||
| 379 | static __initdata DECLARE_COMPLETION(setup_done); | ||
| 380 | |||
| 381 | static int handle(const char *name, mode_t mode, struct device *dev) | ||
| 382 | { | ||
| 383 | if (mode) | ||
| 384 | return handle_create(name, mode, dev); | ||
| 385 | else | ||
| 386 | return handle_remove(name, dev); | ||
| 387 | } | ||
| 388 | |||
| 389 | static int devtmpfsd(void *p) | ||
| 390 | { | ||
| 391 | char options[] = "mode=0755"; | ||
| 392 | int *err = p; | ||
| 393 | *err = sys_unshare(CLONE_NEWNS); | ||
| 394 | if (*err) | ||
| 395 | goto out; | ||
| 396 | *err = sys_mount("devtmpfs", "/", "devtmpfs", MS_SILENT, options); | ||
| 397 | if (*err) | ||
| 398 | goto out; | ||
| 399 | sys_chdir("/.."); /* will traverse into overmounted root */ | ||
| 400 | sys_chroot("."); | ||
| 401 | complete(&setup_done); | ||
| 402 | while (1) { | ||
| 403 | spin_lock(&req_lock); | ||
| 404 | while (requests) { | ||
| 405 | struct req *req = requests; | ||
| 406 | requests = NULL; | ||
| 407 | spin_unlock(&req_lock); | ||
| 408 | while (req) { | ||
| 409 | req->err = handle(req->name, req->mode, req->dev); | ||
| 410 | complete(&req->done); | ||
| 411 | req = req->next; | ||
| 412 | } | ||
| 413 | spin_lock(&req_lock); | ||
| 414 | } | ||
| 415 | set_current_state(TASK_INTERRUPTIBLE); | ||
| 416 | spin_unlock(&req_lock); | ||
| 417 | schedule(); | ||
| 418 | __set_current_state(TASK_RUNNING); | ||
| 419 | } | ||
| 420 | return 0; | ||
| 421 | out: | ||
| 422 | complete(&setup_done); | ||
| 423 | return *err; | ||
| 424 | } | ||
| 425 | |||
| 368 | /* | 426 | /* |
| 369 | * Create devtmpfs instance, driver-core devices will add their device | 427 | * Create devtmpfs instance, driver-core devices will add their device |
| 370 | * nodes here. | 428 | * nodes here. |
| 371 | */ | 429 | */ |
| 372 | int __init devtmpfs_init(void) | 430 | int __init devtmpfs_init(void) |
| 373 | { | 431 | { |
| 374 | int err; | 432 | int err = register_filesystem(&dev_fs_type); |
| 375 | struct vfsmount *mnt; | ||
| 376 | char options[] = "mode=0755"; | ||
| 377 | |||
| 378 | err = register_filesystem(&dev_fs_type); | ||
| 379 | if (err) { | 433 | if (err) { |
| 380 | printk(KERN_ERR "devtmpfs: unable to register devtmpfs " | 434 | printk(KERN_ERR "devtmpfs: unable to register devtmpfs " |
| 381 | "type %i\n", err); | 435 | "type %i\n", err); |
| 382 | return err; | 436 | return err; |
| 383 | } | 437 | } |
| 384 | 438 | ||
| 385 | mnt = kern_mount_data(&dev_fs_type, options); | 439 | thread = kthread_run(devtmpfsd, &err, "kdevtmpfs"); |
| 386 | if (IS_ERR(mnt)) { | 440 | if (!IS_ERR(thread)) { |
| 387 | err = PTR_ERR(mnt); | 441 | wait_for_completion(&setup_done); |
| 442 | } else { | ||
| 443 | err = PTR_ERR(thread); | ||
| 444 | thread = NULL; | ||
| 445 | } | ||
| 446 | |||
| 447 | if (err) { | ||
| 388 | printk(KERN_ERR "devtmpfs: unable to create devtmpfs %i\n", err); | 448 | printk(KERN_ERR "devtmpfs: unable to create devtmpfs %i\n", err); |
| 389 | unregister_filesystem(&dev_fs_type); | 449 | unregister_filesystem(&dev_fs_type); |
| 390 | return err; | 450 | return err; |
| 391 | } | 451 | } |
| 392 | dev_mnt = mnt; | ||
| 393 | 452 | ||
| 394 | printk(KERN_INFO "devtmpfs: initialized\n"); | 453 | printk(KERN_INFO "devtmpfs: initialized\n"); |
| 395 | return 0; | 454 | return 0; |
diff --git a/drivers/block/pktcdvd.c b/drivers/block/pktcdvd.c index 07a382eaf0a8..e133f094ab08 100644 --- a/drivers/block/pktcdvd.c +++ b/drivers/block/pktcdvd.c | |||
| @@ -1206,7 +1206,7 @@ static int pkt_start_recovery(struct packet_data *pkt) | |||
| 1206 | if (!sb) | 1206 | if (!sb) |
| 1207 | return 0; | 1207 | return 0; |
| 1208 | 1208 | ||
| 1209 | if (!sb->s_op || !sb->s_op->relocate_blocks) | 1209 | if (!sb->s_op->relocate_blocks) |
| 1210 | goto out; | 1210 | goto out; |
| 1211 | 1211 | ||
| 1212 | old_block = pkt->sector / (CD_FRAMESIZE >> 9); | 1212 | old_block = pkt->sector / (CD_FRAMESIZE >> 9); |
diff --git a/drivers/char/generic_nvram.c b/drivers/char/generic_nvram.c index 0e941b57482e..6c4f4b5a9dd3 100644 --- a/drivers/char/generic_nvram.c +++ b/drivers/char/generic_nvram.c | |||
| @@ -34,12 +34,16 @@ static ssize_t nvram_len; | |||
| 34 | static loff_t nvram_llseek(struct file *file, loff_t offset, int origin) | 34 | static loff_t nvram_llseek(struct file *file, loff_t offset, int origin) |
| 35 | { | 35 | { |
| 36 | switch (origin) { | 36 | switch (origin) { |
| 37 | case 0: | ||
| 38 | break; | ||
| 37 | case 1: | 39 | case 1: |
| 38 | offset += file->f_pos; | 40 | offset += file->f_pos; |
| 39 | break; | 41 | break; |
| 40 | case 2: | 42 | case 2: |
| 41 | offset += nvram_len; | 43 | offset += nvram_len; |
| 42 | break; | 44 | break; |
| 45 | default: | ||
| 46 | offset = -1; | ||
| 43 | } | 47 | } |
| 44 | if (offset < 0) | 48 | if (offset < 0) |
| 45 | return -EINVAL; | 49 | return -EINVAL; |
diff --git a/drivers/char/nvram.c b/drivers/char/nvram.c index 166f1e7aaa7e..da3cfee782dc 100644 --- a/drivers/char/nvram.c +++ b/drivers/char/nvram.c | |||
| @@ -224,6 +224,8 @@ static loff_t nvram_llseek(struct file *file, loff_t offset, int origin) | |||
| 224 | case 2: | 224 | case 2: |
| 225 | offset += NVRAM_BYTES; | 225 | offset += NVRAM_BYTES; |
| 226 | break; | 226 | break; |
| 227 | default: | ||
| 228 | return -EINVAL; | ||
| 227 | } | 229 | } |
| 228 | 230 | ||
| 229 | return (offset >= 0) ? (file->f_pos = offset) : -EINVAL; | 231 | return (offset >= 0) ? (file->f_pos = offset) : -EINVAL; |
diff --git a/drivers/char/ps3flash.c b/drivers/char/ps3flash.c index 85c004a518ee..d0c57c2e2909 100644 --- a/drivers/char/ps3flash.c +++ b/drivers/char/ps3flash.c | |||
| @@ -101,12 +101,16 @@ static loff_t ps3flash_llseek(struct file *file, loff_t offset, int origin) | |||
| 101 | 101 | ||
| 102 | mutex_lock(&file->f_mapping->host->i_mutex); | 102 | mutex_lock(&file->f_mapping->host->i_mutex); |
| 103 | switch (origin) { | 103 | switch (origin) { |
| 104 | case 0: | ||
| 105 | break; | ||
| 104 | case 1: | 106 | case 1: |
| 105 | offset += file->f_pos; | 107 | offset += file->f_pos; |
| 106 | break; | 108 | break; |
| 107 | case 2: | 109 | case 2: |
| 108 | offset += dev->regions[dev->region_idx].size*dev->blk_size; | 110 | offset += dev->regions[dev->region_idx].size*dev->blk_size; |
| 109 | break; | 111 | break; |
| 112 | default: | ||
| 113 | offset = -1; | ||
| 110 | } | 114 | } |
| 111 | if (offset < 0) { | 115 | if (offset < 0) { |
| 112 | res = -EINVAL; | 116 | res = -EINVAL; |
| @@ -305,9 +309,14 @@ static int ps3flash_flush(struct file *file, fl_owner_t id) | |||
| 305 | return ps3flash_writeback(ps3flash_dev); | 309 | return ps3flash_writeback(ps3flash_dev); |
| 306 | } | 310 | } |
| 307 | 311 | ||
| 308 | static int ps3flash_fsync(struct file *file, int datasync) | 312 | static int ps3flash_fsync(struct file *file, loff_t start, loff_t end, int datasync) |
| 309 | { | 313 | { |
| 310 | return ps3flash_writeback(ps3flash_dev); | 314 | struct inode *inode = file->f_path.dentry->d_inode; |
| 315 | int err; | ||
| 316 | mutex_lock(&inode->i_mutex); | ||
| 317 | err = ps3flash_writeback(ps3flash_dev); | ||
| 318 | mutex_unlock(&inode->i_mutex); | ||
| 319 | return err; | ||
| 311 | } | 320 | } |
| 312 | 321 | ||
| 313 | static irqreturn_t ps3flash_interrupt(int irq, void *data) | 322 | static irqreturn_t ps3flash_interrupt(int irq, void *data) |
diff --git a/drivers/macintosh/nvram.c b/drivers/macintosh/nvram.c index a271c8218d82..f0e03e7937e3 100644 --- a/drivers/macintosh/nvram.c +++ b/drivers/macintosh/nvram.c | |||
| @@ -21,12 +21,16 @@ | |||
| 21 | static loff_t nvram_llseek(struct file *file, loff_t offset, int origin) | 21 | static loff_t nvram_llseek(struct file *file, loff_t offset, int origin) |
| 22 | { | 22 | { |
| 23 | switch (origin) { | 23 | switch (origin) { |
| 24 | case 0: | ||
| 25 | break; | ||
| 24 | case 1: | 26 | case 1: |
| 25 | offset += file->f_pos; | 27 | offset += file->f_pos; |
| 26 | break; | 28 | break; |
| 27 | case 2: | 29 | case 2: |
| 28 | offset += NVRAM_SIZE; | 30 | offset += NVRAM_SIZE; |
| 29 | break; | 31 | break; |
| 32 | default: | ||
| 33 | offset = -1; | ||
| 30 | } | 34 | } |
| 31 | if (offset < 0) | 35 | if (offset < 0) |
| 32 | return -EINVAL; | 36 | return -EINVAL; |
diff --git a/drivers/md/md.c b/drivers/md/md.c index 91e31e260b4a..dfc9425db70b 100644 --- a/drivers/md/md.c +++ b/drivers/md/md.c | |||
| @@ -6394,16 +6394,11 @@ static void md_seq_stop(struct seq_file *seq, void *v) | |||
| 6394 | mddev_put(mddev); | 6394 | mddev_put(mddev); |
| 6395 | } | 6395 | } |
| 6396 | 6396 | ||
| 6397 | struct mdstat_info { | ||
| 6398 | int event; | ||
| 6399 | }; | ||
| 6400 | |||
| 6401 | static int md_seq_show(struct seq_file *seq, void *v) | 6397 | static int md_seq_show(struct seq_file *seq, void *v) |
| 6402 | { | 6398 | { |
| 6403 | mddev_t *mddev = v; | 6399 | mddev_t *mddev = v; |
| 6404 | sector_t sectors; | 6400 | sector_t sectors; |
| 6405 | mdk_rdev_t *rdev; | 6401 | mdk_rdev_t *rdev; |
| 6406 | struct mdstat_info *mi = seq->private; | ||
| 6407 | struct bitmap *bitmap; | 6402 | struct bitmap *bitmap; |
| 6408 | 6403 | ||
| 6409 | if (v == (void*)1) { | 6404 | if (v == (void*)1) { |
| @@ -6415,7 +6410,7 @@ static int md_seq_show(struct seq_file *seq, void *v) | |||
| 6415 | 6410 | ||
| 6416 | spin_unlock(&pers_lock); | 6411 | spin_unlock(&pers_lock); |
| 6417 | seq_printf(seq, "\n"); | 6412 | seq_printf(seq, "\n"); |
| 6418 | mi->event = atomic_read(&md_event_count); | 6413 | seq->poll_event = atomic_read(&md_event_count); |
| 6419 | return 0; | 6414 | return 0; |
| 6420 | } | 6415 | } |
| 6421 | if (v == (void*)2) { | 6416 | if (v == (void*)2) { |
| @@ -6527,26 +6522,21 @@ static const struct seq_operations md_seq_ops = { | |||
| 6527 | 6522 | ||
| 6528 | static int md_seq_open(struct inode *inode, struct file *file) | 6523 | static int md_seq_open(struct inode *inode, struct file *file) |
| 6529 | { | 6524 | { |
| 6525 | struct seq_file *seq; | ||
| 6530 | int error; | 6526 | int error; |
| 6531 | struct mdstat_info *mi = kmalloc(sizeof(*mi), GFP_KERNEL); | ||
| 6532 | if (mi == NULL) | ||
| 6533 | return -ENOMEM; | ||
| 6534 | 6527 | ||
| 6535 | error = seq_open(file, &md_seq_ops); | 6528 | error = seq_open(file, &md_seq_ops); |
| 6536 | if (error) | 6529 | if (error) |
| 6537 | kfree(mi); | 6530 | return error; |
| 6538 | else { | 6531 | |
| 6539 | struct seq_file *p = file->private_data; | 6532 | seq = file->private_data; |
| 6540 | p->private = mi; | 6533 | seq->poll_event = atomic_read(&md_event_count); |
| 6541 | mi->event = atomic_read(&md_event_count); | ||
| 6542 | } | ||
| 6543 | return error; | 6534 | return error; |
| 6544 | } | 6535 | } |
| 6545 | 6536 | ||
| 6546 | static unsigned int mdstat_poll(struct file *filp, poll_table *wait) | 6537 | static unsigned int mdstat_poll(struct file *filp, poll_table *wait) |
| 6547 | { | 6538 | { |
| 6548 | struct seq_file *m = filp->private_data; | 6539 | struct seq_file *seq = filp->private_data; |
| 6549 | struct mdstat_info *mi = m->private; | ||
| 6550 | int mask; | 6540 | int mask; |
| 6551 | 6541 | ||
| 6552 | poll_wait(filp, &md_event_waiters, wait); | 6542 | poll_wait(filp, &md_event_waiters, wait); |
| @@ -6554,7 +6544,7 @@ static unsigned int mdstat_poll(struct file *filp, poll_table *wait) | |||
| 6554 | /* always allow read */ | 6544 | /* always allow read */ |
| 6555 | mask = POLLIN | POLLRDNORM; | 6545 | mask = POLLIN | POLLRDNORM; |
| 6556 | 6546 | ||
| 6557 | if (mi->event != atomic_read(&md_event_count)) | 6547 | if (seq->poll_event != atomic_read(&md_event_count)) |
| 6558 | mask |= POLLERR | POLLPRI; | 6548 | mask |= POLLERR | POLLPRI; |
| 6559 | return mask; | 6549 | return mask; |
| 6560 | } | 6550 | } |
diff --git a/drivers/mtd/ubi/cdev.c b/drivers/mtd/ubi/cdev.c index 191f3bb3c41a..3320a50ba4f0 100644 --- a/drivers/mtd/ubi/cdev.c +++ b/drivers/mtd/ubi/cdev.c | |||
| @@ -189,12 +189,16 @@ static loff_t vol_cdev_llseek(struct file *file, loff_t offset, int origin) | |||
| 189 | return new_offset; | 189 | return new_offset; |
| 190 | } | 190 | } |
| 191 | 191 | ||
| 192 | static int vol_cdev_fsync(struct file *file, int datasync) | 192 | static int vol_cdev_fsync(struct file *file, loff_t start, loff_t end, int datasync) |
| 193 | { | 193 | { |
| 194 | struct ubi_volume_desc *desc = file->private_data; | 194 | struct ubi_volume_desc *desc = file->private_data; |
| 195 | struct ubi_device *ubi = desc->vol->ubi; | 195 | struct ubi_device *ubi = desc->vol->ubi; |
| 196 | 196 | struct inode *inode = file->f_path.dentry->d_inode; | |
| 197 | return ubi_sync(ubi->ubi_num); | 197 | int err; |
| 198 | mutex_lock(&inode->i_mutex); | ||
| 199 | err = ubi_sync(ubi->ubi_num); | ||
| 200 | mutex_unlock(&inode->i_mutex); | ||
| 201 | return err; | ||
| 198 | } | 202 | } |
| 199 | 203 | ||
| 200 | 204 | ||
diff --git a/drivers/sh/clk/core.c b/drivers/sh/clk/core.c index 7e9c39951ecb..d6702e57d428 100644 --- a/drivers/sh/clk/core.c +++ b/drivers/sh/clk/core.c | |||
| @@ -670,7 +670,7 @@ static struct dentry *clk_debugfs_root; | |||
| 670 | static int clk_debugfs_register_one(struct clk *c) | 670 | static int clk_debugfs_register_one(struct clk *c) |
| 671 | { | 671 | { |
| 672 | int err; | 672 | int err; |
| 673 | struct dentry *d, *child, *child_tmp; | 673 | struct dentry *d; |
| 674 | struct clk *pa = c->parent; | 674 | struct clk *pa = c->parent; |
| 675 | char s[255]; | 675 | char s[255]; |
| 676 | char *p = s; | 676 | char *p = s; |
| @@ -699,10 +699,7 @@ static int clk_debugfs_register_one(struct clk *c) | |||
| 699 | return 0; | 699 | return 0; |
| 700 | 700 | ||
| 701 | err_out: | 701 | err_out: |
| 702 | d = c->dentry; | 702 | debugfs_remove_recursive(c->dentry); |
| 703 | list_for_each_entry_safe(child, child_tmp, &d->d_subdirs, d_u.d_child) | ||
| 704 | debugfs_remove(child); | ||
| 705 | debugfs_remove(c->dentry); | ||
| 706 | return err; | 703 | return err; |
| 707 | } | 704 | } |
| 708 | 705 | ||
diff --git a/drivers/staging/pohmelfs/dir.c b/drivers/staging/pohmelfs/dir.c index 9732a9666cc4..7598e77672a5 100644 --- a/drivers/staging/pohmelfs/dir.c +++ b/drivers/staging/pohmelfs/dir.c | |||
| @@ -512,7 +512,7 @@ struct dentry *pohmelfs_lookup(struct inode *dir, struct dentry *dentry, struct | |||
| 512 | int err, lock_type = POHMELFS_READ_LOCK, need_lock = 1; | 512 | int err, lock_type = POHMELFS_READ_LOCK, need_lock = 1; |
| 513 | struct qstr str = dentry->d_name; | 513 | struct qstr str = dentry->d_name; |
| 514 | 514 | ||
| 515 | if ((nd->intent.open.flags & O_ACCMODE) > 1) | 515 | if ((nd->intent.open.flags & O_ACCMODE) != O_RDONLY) |
| 516 | lock_type = POHMELFS_WRITE_LOCK; | 516 | lock_type = POHMELFS_WRITE_LOCK; |
| 517 | 517 | ||
| 518 | if (test_bit(NETFS_INODE_OWNED, &parent->state)) { | 518 | if (test_bit(NETFS_INODE_OWNED, &parent->state)) { |
diff --git a/drivers/staging/pohmelfs/inode.c b/drivers/staging/pohmelfs/inode.c index c0f0ac7c1cdb..f3c6060c96b8 100644 --- a/drivers/staging/pohmelfs/inode.c +++ b/drivers/staging/pohmelfs/inode.c | |||
| @@ -887,11 +887,16 @@ static struct inode *pohmelfs_alloc_inode(struct super_block *sb) | |||
| 887 | /* | 887 | /* |
| 888 | * We want fsync() to work on POHMELFS. | 888 | * We want fsync() to work on POHMELFS. |
| 889 | */ | 889 | */ |
| 890 | static int pohmelfs_fsync(struct file *file, int datasync) | 890 | static int pohmelfs_fsync(struct file *file, loff_t start, loff_t end, int datasync) |
| 891 | { | 891 | { |
| 892 | struct inode *inode = file->f_mapping->host; | 892 | struct inode *inode = file->f_mapping->host; |
| 893 | 893 | int err = filemap_write_and_wait_range(inode->i_mapping, start, end); | |
| 894 | return sync_inode_metadata(inode, 1); | 894 | if (!err) { |
| 895 | mutex_lock(&inode->i_mutex); | ||
| 896 | err = sync_inode_metadata(inode, 1); | ||
| 897 | mutex_unlock(&inode->i_mutex); | ||
| 898 | } | ||
| 899 | return err; | ||
| 895 | } | 900 | } |
| 896 | 901 | ||
| 897 | ssize_t pohmelfs_write(struct file *file, const char __user *buf, | 902 | ssize_t pohmelfs_write(struct file *file, const char __user *buf, |
diff --git a/drivers/usb/gadget/printer.c b/drivers/usb/gadget/printer.c index 271ef94668e7..978e6a101bf2 100644 --- a/drivers/usb/gadget/printer.c +++ b/drivers/usb/gadget/printer.c | |||
| @@ -795,12 +795,14 @@ printer_write(struct file *fd, const char __user *buf, size_t len, loff_t *ptr) | |||
| 795 | } | 795 | } |
| 796 | 796 | ||
| 797 | static int | 797 | static int |
| 798 | printer_fsync(struct file *fd, int datasync) | 798 | printer_fsync(struct file *fd, loff_t start, loff_t end, int datasync) |
| 799 | { | 799 | { |
| 800 | struct printer_dev *dev = fd->private_data; | 800 | struct printer_dev *dev = fd->private_data; |
| 801 | struct inode *inode = fd->f_path.dentry->d_inode; | ||
| 801 | unsigned long flags; | 802 | unsigned long flags; |
| 802 | int tx_list_empty; | 803 | int tx_list_empty; |
| 803 | 804 | ||
| 805 | mutex_lock(&inode->i_mutex); | ||
| 804 | spin_lock_irqsave(&dev->lock, flags); | 806 | spin_lock_irqsave(&dev->lock, flags); |
| 805 | tx_list_empty = (likely(list_empty(&dev->tx_reqs))); | 807 | tx_list_empty = (likely(list_empty(&dev->tx_reqs))); |
| 806 | spin_unlock_irqrestore(&dev->lock, flags); | 808 | spin_unlock_irqrestore(&dev->lock, flags); |
| @@ -810,6 +812,7 @@ printer_fsync(struct file *fd, int datasync) | |||
| 810 | wait_event_interruptible(dev->tx_flush_wait, | 812 | wait_event_interruptible(dev->tx_flush_wait, |
| 811 | (likely(list_empty(&dev->tx_reqs_active)))); | 813 | (likely(list_empty(&dev->tx_reqs_active)))); |
| 812 | } | 814 | } |
| 815 | mutex_unlock(&inode->i_mutex); | ||
| 813 | 816 | ||
| 814 | return 0; | 817 | return 0; |
| 815 | } | 818 | } |
diff --git a/drivers/video/fb_defio.c b/drivers/video/fb_defio.c index 804000183c5e..32814e8800e0 100644 --- a/drivers/video/fb_defio.c +++ b/drivers/video/fb_defio.c | |||
| @@ -66,19 +66,26 @@ static int fb_deferred_io_fault(struct vm_area_struct *vma, | |||
| 66 | return 0; | 66 | return 0; |
| 67 | } | 67 | } |
| 68 | 68 | ||
| 69 | int fb_deferred_io_fsync(struct file *file, int datasync) | 69 | int fb_deferred_io_fsync(struct file *file, loff_t start, loff_t end, int datasync) |
| 70 | { | 70 | { |
| 71 | struct fb_info *info = file->private_data; | 71 | struct fb_info *info = file->private_data; |
| 72 | struct inode *inode = file->f_path.dentry->d_inode; | ||
| 73 | int err = filemap_write_and_wait_range(inode->i_mapping, start, end); | ||
| 74 | if (err) | ||
| 75 | return err; | ||
| 72 | 76 | ||
| 73 | /* Skip if deferred io is compiled-in but disabled on this fbdev */ | 77 | /* Skip if deferred io is compiled-in but disabled on this fbdev */ |
| 74 | if (!info->fbdefio) | 78 | if (!info->fbdefio) |
| 75 | return 0; | 79 | return 0; |
| 76 | 80 | ||
| 81 | mutex_lock(&inode->i_mutex); | ||
| 77 | /* Kill off the delayed work */ | 82 | /* Kill off the delayed work */ |
| 78 | cancel_delayed_work_sync(&info->deferred_work); | 83 | cancel_delayed_work_sync(&info->deferred_work); |
| 79 | 84 | ||
| 80 | /* Run it immediately */ | 85 | /* Run it immediately */ |
| 81 | return schedule_delayed_work(&info->deferred_work, 0); | 86 | err = schedule_delayed_work(&info->deferred_work, 0); |
| 87 | mutex_unlock(&inode->i_mutex); | ||
| 88 | return err; | ||
| 82 | } | 89 | } |
| 83 | EXPORT_SYMBOL_GPL(fb_deferred_io_fsync); | 90 | EXPORT_SYMBOL_GPL(fb_deferred_io_fsync); |
| 84 | 91 | ||
