Skip to content

Commit 8bb1f22

Browse files
committed
Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs
Pull second try at vfs part d#2 from Al Viro: "Miklos' first series (with do_lookup() rewrite split into edible chunks) + assorted bits and pieces. The 'untangling of do_lookup()' series is is a splitup of what used to be a monolithic patch from Miklos, so this series is basically "how do I convince myself that his patch is correct (or find a hole in it)". No holes found and I like the resulting cleanup, so in it went..." Changes from try 1: Fix a boot problem with selinux, and commit messages prettied up a bit. * 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs: (24 commits) vfs: fix out-of-date dentry_unhash() comment vfs: split __lookup_hash untangling do_lookup() - take __lookup_hash()-calling case out of line. untangling do_lookup() - switch to calling __lookup_hash() untangling do_lookup() - merge d_alloc_and_lookup() callers untangling do_lookup() - merge failure exits in !dentry case untangling do_lookup() - massage !dentry case towards __lookup_hash() untangling do_lookup() - get rid of need_reval in !dentry case untangling do_lookup() - eliminate a loop. untangling do_lookup() - expand the area under ->i_mutex untangling do_lookup() - isolate !dentry stuff from the rest of it. vfs: move MAY_EXEC check from __lookup_hash() vfs: don't revalidate just looked up dentry vfs: fix d_need_lookup/d_revalidate order in do_lookup ext3: move headers to fs/ext3/ migrate ext2_fs.h guts to fs/ext2/ext2.h new helper: ext2_image_size() get rid of pointless includes of ext2_fs.h ext2: No longer export ext2_fs.h to user space mtdchar: kill persistently held vfsmount ...
2 parents f22e08a + c0d0259 commit 8bb1f22

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

41 files changed

+1249
-1640
lines changed

arch/blackfin/kernel/setup.c

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -550,6 +550,7 @@ static __init void memory_setup(void)
550550
{
551551
#ifdef CONFIG_MTD_UCLINUX
552552
unsigned long mtd_phys = 0;
553+
unsigned long n;
553554
#endif
554555
unsigned long max_mem;
555556

@@ -593,9 +594,9 @@ static __init void memory_setup(void)
593594
mtd_size = PAGE_ALIGN(*((unsigned long *)(mtd_phys + 8)));
594595

595596
# if defined(CONFIG_EXT2_FS) || defined(CONFIG_EXT3_FS)
596-
if (*((unsigned short *)(mtd_phys + 0x438)) == EXT2_SUPER_MAGIC)
597-
mtd_size =
598-
PAGE_ALIGN(*((unsigned long *)(mtd_phys + 0x404)) << 10);
597+
n = ext2_image_size((void *)(mtd_phys + 0x400));
598+
if (n)
599+
mtd_size = PAGE_ALIGN(n * 1024);
599600
# endif
600601

601602
# if defined(CONFIG_CRAMFS)

drivers/mtd/mtdchar.c

Lines changed: 16 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,6 @@
3939
#include <asm/uaccess.h>
4040

4141
static DEFINE_MUTEX(mtd_mutex);
42-
static struct vfsmount *mtd_inode_mnt __read_mostly;
4342

4443
/*
4544
* Data structure to hold the pointer to the mtd device as well
@@ -75,7 +74,9 @@ static loff_t mtdchar_lseek(struct file *file, loff_t offset, int orig)
7574
return -EINVAL;
7675
}
7776

78-
77+
static int count;
78+
static struct vfsmount *mnt;
79+
static struct file_system_type mtd_inodefs_type;
7980

8081
static int mtdchar_open(struct inode *inode, struct file *file)
8182
{
@@ -92,6 +93,10 @@ static int mtdchar_open(struct inode *inode, struct file *file)
9293
if ((file->f_mode & FMODE_WRITE) && (minor & 1))
9394
return -EACCES;
9495

96+
ret = simple_pin_fs(&mtd_inodefs_type, &mnt, &count);
97+
if (ret)
98+
return ret;
99+
95100
mutex_lock(&mtd_mutex);
96101
mtd = get_mtd_device(NULL, devnum);
97102

@@ -106,7 +111,7 @@ static int mtdchar_open(struct inode *inode, struct file *file)
106111
goto out;
107112
}
108113

109-
mtd_ino = iget_locked(mtd_inode_mnt->mnt_sb, devnum);
114+
mtd_ino = iget_locked(mnt->mnt_sb, devnum);
110115
if (!mtd_ino) {
111116
put_mtd_device(mtd);
112117
ret = -ENOMEM;
@@ -141,6 +146,7 @@ static int mtdchar_open(struct inode *inode, struct file *file)
141146

142147
out:
143148
mutex_unlock(&mtd_mutex);
149+
simple_release_fs(&mnt, &count);
144150
return ret;
145151
} /* mtdchar_open */
146152

@@ -162,6 +168,7 @@ static int mtdchar_close(struct inode *inode, struct file *file)
162168
put_mtd_device(mtd);
163169
file->private_data = NULL;
164170
kfree(mfi);
171+
simple_release_fs(&mnt, &count);
165172

166173
return 0;
167174
} /* mtdchar_close */
@@ -1175,10 +1182,15 @@ static const struct file_operations mtd_fops = {
11751182
#endif
11761183
};
11771184

1185+
static const struct super_operations mtd_ops = {
1186+
.drop_inode = generic_delete_inode,
1187+
.statfs = simple_statfs,
1188+
};
1189+
11781190
static struct dentry *mtd_inodefs_mount(struct file_system_type *fs_type,
11791191
int flags, const char *dev_name, void *data)
11801192
{
1181-
return mount_pseudo(fs_type, "mtd_inode:", NULL, NULL, MTD_INODE_FS_MAGIC);
1193+
return mount_pseudo(fs_type, "mtd_inode:", &mtd_ops, NULL, MTD_INODE_FS_MAGIC);
11821194
}
11831195

11841196
static struct file_system_type mtd_inodefs_type = {
@@ -1187,26 +1199,6 @@ static struct file_system_type mtd_inodefs_type = {
11871199
.kill_sb = kill_anon_super,
11881200
};
11891201

1190-
static void mtdchar_notify_add(struct mtd_info *mtd)
1191-
{
1192-
}
1193-
1194-
static void mtdchar_notify_remove(struct mtd_info *mtd)
1195-
{
1196-
struct inode *mtd_ino = ilookup(mtd_inode_mnt->mnt_sb, mtd->index);
1197-
1198-
if (mtd_ino) {
1199-
/* Destroy the inode if it exists */
1200-
clear_nlink(mtd_ino);
1201-
iput(mtd_ino);
1202-
}
1203-
}
1204-
1205-
static struct mtd_notifier mtdchar_notifier = {
1206-
.add = mtdchar_notify_add,
1207-
.remove = mtdchar_notify_remove,
1208-
};
1209-
12101202
static int __init init_mtdchar(void)
12111203
{
12121204
int ret;
@@ -1224,28 +1216,15 @@ static int __init init_mtdchar(void)
12241216
pr_notice("Can't register mtd_inodefs filesystem: %d\n", ret);
12251217
goto err_unregister_chdev;
12261218
}
1227-
1228-
mtd_inode_mnt = kern_mount(&mtd_inodefs_type);
1229-
if (IS_ERR(mtd_inode_mnt)) {
1230-
ret = PTR_ERR(mtd_inode_mnt);
1231-
pr_notice("Error mounting mtd_inodefs filesystem: %d\n", ret);
1232-
goto err_unregister_filesystem;
1233-
}
1234-
register_mtd_user(&mtdchar_notifier);
1235-
12361219
return ret;
12371220

1238-
err_unregister_filesystem:
1239-
unregister_filesystem(&mtd_inodefs_type);
12401221
err_unregister_chdev:
12411222
__unregister_chrdev(MTD_CHAR_MAJOR, 0, 1 << MINORBITS, "mtd");
12421223
return ret;
12431224
}
12441225

12451226
static void __exit cleanup_mtdchar(void)
12461227
{
1247-
unregister_mtd_user(&mtdchar_notifier);
1248-
kern_unmount(mtd_inode_mnt);
12491228
unregister_filesystem(&mtd_inodefs_type);
12501229
__unregister_chrdev(MTD_CHAR_MAJOR, 0, 1 << MINORBITS, "mtd");
12511230
}

fs/aio.c

Lines changed: 11 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -305,15 +305,18 @@ static struct kioctx *ioctx_alloc(unsigned nr_events)
305305
return ERR_PTR(err);
306306
}
307307

308-
/* aio_cancel_all
308+
/* kill_ctx
309309
* Cancels all outstanding aio requests on an aio context. Used
310310
* when the processes owning a context have all exited to encourage
311311
* the rapid destruction of the kioctx.
312312
*/
313-
static void aio_cancel_all(struct kioctx *ctx)
313+
static void kill_ctx(struct kioctx *ctx)
314314
{
315315
int (*cancel)(struct kiocb *, struct io_event *);
316+
struct task_struct *tsk = current;
317+
DECLARE_WAITQUEUE(wait, tsk);
316318
struct io_event res;
319+
317320
spin_lock_irq(&ctx->ctx_lock);
318321
ctx->dead = 1;
319322
while (!list_empty(&ctx->active_reqs)) {
@@ -329,15 +332,7 @@ static void aio_cancel_all(struct kioctx *ctx)
329332
spin_lock_irq(&ctx->ctx_lock);
330333
}
331334
}
332-
spin_unlock_irq(&ctx->ctx_lock);
333-
}
334-
335-
static void wait_for_all_aios(struct kioctx *ctx)
336-
{
337-
struct task_struct *tsk = current;
338-
DECLARE_WAITQUEUE(wait, tsk);
339335

340-
spin_lock_irq(&ctx->ctx_lock);
341336
if (!ctx->reqs_active)
342337
goto out;
343338

@@ -387,9 +382,7 @@ void exit_aio(struct mm_struct *mm)
387382
ctx = hlist_entry(mm->ioctx_list.first, struct kioctx, list);
388383
hlist_del_rcu(&ctx->list);
389384

390-
aio_cancel_all(ctx);
391-
392-
wait_for_all_aios(ctx);
385+
kill_ctx(ctx);
393386

394387
if (1 != atomic_read(&ctx->users))
395388
printk(KERN_DEBUG
@@ -1269,16 +1262,14 @@ static void io_destroy(struct kioctx *ioctx)
12691262
if (likely(!was_dead))
12701263
put_ioctx(ioctx); /* twice for the list */
12711264

1272-
aio_cancel_all(ioctx);
1273-
wait_for_all_aios(ioctx);
1265+
kill_ctx(ioctx);
12741266

12751267
/*
12761268
* Wake up any waiters. The setting of ctx->dead must be seen
12771269
* by other CPUs at this point. Right now, we rely on the
12781270
* locking done by the above calls to ensure this consistency.
12791271
*/
12801272
wake_up_all(&ioctx->wait);
1281-
put_ioctx(ioctx); /* once for the lookup */
12821273
}
12831274

12841275
/* sys_io_setup:
@@ -1315,11 +1306,9 @@ SYSCALL_DEFINE2(io_setup, unsigned, nr_events, aio_context_t __user *, ctxp)
13151306
ret = PTR_ERR(ioctx);
13161307
if (!IS_ERR(ioctx)) {
13171308
ret = put_user(ioctx->user_id, ctxp);
1318-
if (!ret) {
1319-
put_ioctx(ioctx);
1320-
return 0;
1321-
}
1322-
io_destroy(ioctx);
1309+
if (ret)
1310+
io_destroy(ioctx);
1311+
put_ioctx(ioctx);
13231312
}
13241313

13251314
out:
@@ -1337,6 +1326,7 @@ SYSCALL_DEFINE1(io_destroy, aio_context_t, ctx)
13371326
struct kioctx *ioctx = lookup_ioctx(ctx);
13381327
if (likely(NULL != ioctx)) {
13391328
io_destroy(ioctx);
1329+
put_ioctx(ioctx);
13401330
return 0;
13411331
}
13421332
pr_debug("EINVAL: io_destroy: invalid context id\n");

0 commit comments

Comments
 (0)