Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
matisse
android_kernel_samsung_matisse
Commits
80c05315
Commit
80c05315
authored
19 years ago
by
Linus Torvalds
Browse files
Options
Download
Plain Diff
Merge master.kernel.org:/pub/scm/linux/kernel/git/mingo/mutex-2.6
parents
a457aa6c
11b751ae
Changes
198
Hide whitespace changes
Inline
Side-by-side
Showing
20 changed files
with
244 additions
and
82 deletions
+244
-82
Documentation/DocBook/kernel-locking.tmpl
Documentation/DocBook/kernel-locking.tmpl
+14
-8
Documentation/mutex-design.txt
Documentation/mutex-design.txt
+135
-0
arch/i386/mm/pageattr.c
arch/i386/mm/pageattr.c
+4
-0
arch/powerpc/platforms/cell/spufs/inode.c
arch/powerpc/platforms/cell/spufs/inode.c
+6
-6
drivers/block/loop.c
drivers/block/loop.c
+14
-17
drivers/block/sx8.c
drivers/block/sx8.c
+6
-6
drivers/char/mem.c
drivers/char/mem.c
+2
-2
drivers/char/sysrq.c
drivers/char/sysrq.c
+19
-0
drivers/char/watchdog/cpu5wdt.c
drivers/char/watchdog/cpu5wdt.c
+5
-4
drivers/ide/ide-probe.c
drivers/ide/ide-probe.c
+2
-2
drivers/ide/ide.c
drivers/ide/ide.c
+4
-4
drivers/isdn/capi/capifs.c
drivers/isdn/capi/capifs.c
+3
-3
drivers/md/dm.c
drivers/md/dm.c
+2
-2
drivers/md/md.c
drivers/md/md.c
+4
-4
drivers/pci/proc.c
drivers/pci/proc.c
+2
-2
drivers/usb/core/inode.c
drivers/usb/core/inode.c
+14
-14
drivers/usb/gadget/file_storage.c
drivers/usb/gadget/file_storage.c
+2
-2
drivers/usb/gadget/inode.c
drivers/usb/gadget/inode.c
+2
-2
fs/affs/inode.c
fs/affs/inode.c
+2
-2
fs/autofs/root.c
fs/autofs/root.c
+2
-2
No files found.
Documentation/DocBook/kernel-locking.tmpl
View file @
80c05315
...
...
@@ -222,7 +222,7 @@
<title>Two Main Types of Kernel Locks: Spinlocks and Semaphores</title>
<para>
There are t
wo
main types of kernel locks. The fundamental type
There are t
hree
main types of kernel locks. The fundamental type
is the spinlock
(<filename class="headerfile">include/asm/spinlock.h</filename>),
which is a very simple single-holder lock: if you can't get the
...
...
@@ -230,16 +230,22 @@
very small and fast, and can be used anywhere.
</para>
<para>
The second type is a semaphore
The second type is a mutex
(<filename class="headerfile">include/linux/mutex.h</filename>): it
is like a spinlock, but you may block holding a mutex.
If you can't lock a mutex, your task will suspend itself, and be woken
up when the mutex is released. This means the CPU can do something
else while you are waiting. There are many cases when you simply
can't sleep (see <xref linkend="sleeping-things"/>), and so have to
use a spinlock instead.
</para>
<para>
The third type is a semaphore
(<filename class="headerfile">include/asm/semaphore.h</filename>): it
can have more than one holder at any time (the number decided at
initialization time), although it is most commonly used as a
single-holder lock (a mutex). If you can't get a semaphore,
your task will put itself on the queue, and be woken up when the
semaphore is released. This means the CPU will do something
else while you are waiting, but there are many cases when you
simply can't sleep (see <xref linkend="sleeping-things"/>), and so
have to use a spinlock instead.
single-holder lock (a mutex). If you can't get a semaphore, your
task will be suspended and later on woken up - just like for mutexes.
</para>
<para>
Neither type of lock is recursive: see
...
...
This diff is collapsed.
Click to expand it.
Documentation/mutex-design.txt
0 → 100644
View file @
80c05315
Generic Mutex Subsystem
started by Ingo Molnar <mingo@redhat.com>
"Why on earth do we need a new mutex subsystem, and what's wrong
with semaphores?"
firstly, there's nothing wrong with semaphores. But if the simpler
mutex semantics are sufficient for your code, then there are a couple
of advantages of mutexes:
- 'struct mutex' is smaller on most architectures: .e.g on x86,
'struct semaphore' is 20 bytes, 'struct mutex' is 16 bytes.
A smaller structure size means less RAM footprint, and better
CPU-cache utilization.
- tighter code. On x86 i get the following .text sizes when
switching all mutex-alike semaphores in the kernel to the mutex
subsystem:
text data bss dec hex filename
3280380 868188 396860 4545428 455b94 vmlinux-semaphore
3255329 865296 396732 4517357 44eded vmlinux-mutex
that's 25051 bytes of code saved, or a 0.76% win - off the hottest
codepaths of the kernel. (The .data savings are 2892 bytes, or 0.33%)
Smaller code means better icache footprint, which is one of the
major optimization goals in the Linux kernel currently.
- the mutex subsystem is slightly faster and has better scalability for
contended workloads. On an 8-way x86 system, running a mutex-based
kernel and testing creat+unlink+close (of separate, per-task files)
in /tmp with 16 parallel tasks, the average number of ops/sec is:
Semaphores: Mutexes:
$ ./test-mutex V 16 10 $ ./test-mutex V 16 10
8 CPUs, running 16 tasks. 8 CPUs, running 16 tasks.
checking VFS performance. checking VFS performance.
avg loops/sec: 34713 avg loops/sec: 84153
CPU utilization: 63% CPU utilization: 22%
i.e. in this workload, the mutex based kernel was 2.4 times faster
than the semaphore based kernel, _and_ it also had 2.8 times less CPU
utilization. (In terms of 'ops per CPU cycle', the semaphore kernel
performed 551 ops/sec per 1% of CPU time used, while the mutex kernel
performed 3825 ops/sec per 1% of CPU time used - it was 6.9 times
more efficient.)
the scalability difference is visible even on a 2-way P4 HT box:
Semaphores: Mutexes:
$ ./test-mutex V 16 10 $ ./test-mutex V 16 10
4 CPUs, running 16 tasks. 8 CPUs, running 16 tasks.
checking VFS performance. checking VFS performance.
avg loops/sec: 127659 avg loops/sec: 181082
CPU utilization: 100% CPU utilization: 34%
(the straight performance advantage of mutexes is 41%, the per-cycle
efficiency of mutexes is 4.1 times better.)
- there are no fastpath tradeoffs, the mutex fastpath is just as tight
as the semaphore fastpath. On x86, the locking fastpath is 2
instructions:
c0377ccb <mutex_lock>:
c0377ccb: f0 ff 08 lock decl (%eax)
c0377cce: 78 0e js c0377cde <.text.lock.mutex>
c0377cd0: c3 ret
the unlocking fastpath is equally tight:
c0377cd1 <mutex_unlock>:
c0377cd1: f0 ff 00 lock incl (%eax)
c0377cd4: 7e 0f jle c0377ce5 <.text.lock.mutex+0x7>
c0377cd6: c3 ret
- 'struct mutex' semantics are well-defined and are enforced if
CONFIG_DEBUG_MUTEXES is turned on. Semaphores on the other hand have
virtually no debugging code or instrumentation. The mutex subsystem
checks and enforces the following rules:
* - only one task can hold the mutex at a time
* - only the owner can unlock the mutex
* - multiple unlocks are not permitted
* - recursive locking is not permitted
* - a mutex object must be initialized via the API
* - a mutex object must not be initialized via memset or copying
* - task may not exit with mutex held
* - memory areas where held locks reside must not be freed
* - held mutexes must not be reinitialized
* - mutexes may not be used in irq contexts
furthermore, there are also convenience features in the debugging
code:
* - uses symbolic names of mutexes, whenever they are printed in debug output
* - point-of-acquire tracking, symbolic lookup of function names
* - list of all locks held in the system, printout of them
* - owner tracking
* - detects self-recursing locks and prints out all relevant info
* - detects multi-task circular deadlocks and prints out all affected
* locks and tasks (and only those tasks)
Disadvantages
-------------
The stricter mutex API means you cannot use mutexes the same way you
can use semaphores: e.g. they cannot be used from an interrupt context,
nor can they be unlocked from a different context that which acquired
it. [ I'm not aware of any other (e.g. performance) disadvantages from
using mutexes at the moment, please let me know if you find any. ]
Implementation of mutexes
-------------------------
'struct mutex' is the new mutex type, defined in include/linux/mutex.h
and implemented in kernel/mutex.c. It is a counter-based mutex with a
spinlock and a wait-list. The counter has 3 states: 1 for "unlocked",
0 for "locked" and negative numbers (usually -1) for "locked, potential
waiters queued".
the APIs of 'struct mutex' have been streamlined:
DEFINE_MUTEX(name);
mutex_init(mutex);
void mutex_lock(struct mutex *lock);
int mutex_lock_interruptible(struct mutex *lock);
int mutex_trylock(struct mutex *lock);
void mutex_unlock(struct mutex *lock);
int mutex_is_locked(struct mutex *lock);
This diff is collapsed.
Click to expand it.
arch/i386/mm/pageattr.c
View file @
80c05315
...
...
@@ -222,6 +222,10 @@ void kernel_map_pages(struct page *page, int numpages, int enable)
{
if
(
PageHighMem
(
page
))
return
;
if
(
!
enable
)
mutex_debug_check_no_locks_freed
(
page_address
(
page
),
page_address
(
page
+
numpages
));
/* the return value is ignored - the calls cannot fail,
* large pages are disabled at boot time.
*/
...
...
This diff is collapsed.
Click to expand it.
arch/powerpc/platforms/cell/spufs/inode.c
View file @
80c05315
...
...
@@ -137,7 +137,7 @@ spufs_delete_inode(struct inode *inode)
static
void
spufs_prune_dir
(
struct
dentry
*
dir
)
{
struct
dentry
*
dentry
,
*
tmp
;
down
(
&
dir
->
d_inode
->
i_
sem
);
mutex_lock
(
&
dir
->
d_inode
->
i_
mutex
);
list_for_each_entry_safe
(
dentry
,
tmp
,
&
dir
->
d_subdirs
,
d_child
)
{
spin_lock
(
&
dcache_lock
);
spin_lock
(
&
dentry
->
d_lock
);
...
...
@@ -154,7 +154,7 @@ static void spufs_prune_dir(struct dentry *dir)
}
}
shrink_dcache_parent
(
dir
);
up
(
&
dir
->
d_inode
->
i_
sem
);
mutex_unlock
(
&
dir
->
d_inode
->
i_
mutex
);
}
static
int
spufs_rmdir
(
struct
inode
*
root
,
struct
dentry
*
dir_dentry
)
...
...
@@ -162,15 +162,15 @@ static int spufs_rmdir(struct inode *root, struct dentry *dir_dentry)
struct
spu_context
*
ctx
;
/* remove all entries */
down
(
&
root
->
i_
sem
);
mutex_lock
(
&
root
->
i_
mutex
);
spufs_prune_dir
(
dir_dentry
);
up
(
&
root
->
i_
sem
);
mutex_unlock
(
&
root
->
i_
mutex
);
/* We have to give up the mm_struct */
ctx
=
SPUFS_I
(
dir_dentry
->
d_inode
)
->
i_ctx
;
spu_forget
(
ctx
);
/* XXX Do we need to hold i_
sem
here ? */
/* XXX Do we need to hold i_
mutex
here ? */
return
simple_rmdir
(
root
,
dir_dentry
);
}
...
...
@@ -330,7 +330,7 @@ long spufs_create_thread(struct nameidata *nd,
out_dput:
dput
(
dentry
);
out_dir:
up
(
&
nd
->
dentry
->
d_inode
->
i_
sem
);
mutex_unlock
(
&
nd
->
dentry
->
d_inode
->
i_
mutex
);
out:
return
ret
;
}
...
...
This diff is collapsed.
Click to expand it.
drivers/block/loop.c
View file @
80c05315
...
...
@@ -215,7 +215,7 @@ static int do_lo_send_aops(struct loop_device *lo, struct bio_vec *bvec,
unsigned
offset
,
bv_offs
;
int
len
,
ret
;
down
(
&
mapping
->
host
->
i_
sem
);
mutex_lock
(
&
mapping
->
host
->
i_
mutex
);
index
=
pos
>>
PAGE_CACHE_SHIFT
;
offset
=
pos
&
((
pgoff_t
)
PAGE_CACHE_SIZE
-
1
);
bv_offs
=
bvec
->
bv_offset
;
...
...
@@ -278,7 +278,7 @@ static int do_lo_send_aops(struct loop_device *lo, struct bio_vec *bvec,
}
ret
=
0
;
out:
up
(
&
mapping
->
host
->
i_
sem
);
mutex_unlock
(
&
mapping
->
host
->
i_
mutex
);
return
ret
;
unlock:
unlock_page
(
page
);
...
...
@@ -527,12 +527,12 @@ static int loop_make_request(request_queue_t *q, struct bio *old_bio)
lo
->
lo_pending
++
;
loop_add_bio
(
lo
,
old_bio
);
spin_unlock_irq
(
&
lo
->
lo_lock
);
up
(
&
lo
->
lo_bh_
mutex
);
complete
(
&
lo
->
lo_bh_
done
);
return
0
;
out:
if
(
lo
->
lo_pending
==
0
)
up
(
&
lo
->
lo_bh_
mutex
);
complete
(
&
lo
->
lo_bh_
done
);
spin_unlock_irq
(
&
lo
->
lo_lock
);
bio_io_error
(
old_bio
,
old_bio
->
bi_size
);
return
0
;
...
...
@@ -593,23 +593,20 @@ static int loop_thread(void *data)
lo
->
lo_pending
=
1
;
/*
*
up sem
, we are running
*
complete it
, we are running
*/
up
(
&
lo
->
lo_
sem
);
complete
(
&
lo
->
lo_
done
);
for
(;;)
{
int
pending
;
/*
* interruptible just to not contribute to load avg
*/
if
(
down_interruptible
(
&
lo
->
lo_bh_mutex
))
if
(
wait_for_completion_interruptible
(
&
lo
->
lo_bh_done
))
continue
;
spin_lock_irq
(
&
lo
->
lo_lock
);
/*
* could be
upp
ed because of tear-down, not pending work
* could be
complet
ed because of tear-down, not pending work
*/
if
(
unlikely
(
!
lo
->
lo_pending
))
{
spin_unlock_irq
(
&
lo
->
lo_lock
);
...
...
@@ -632,7 +629,7 @@ static int loop_thread(void *data)
break
;
}
up
(
&
lo
->
lo_
sem
);
complete
(
&
lo
->
lo_
done
);
return
0
;
}
...
...
@@ -843,7 +840,7 @@ static int loop_set_fd(struct loop_device *lo, struct file *lo_file,
set_blocksize
(
bdev
,
lo_blocksize
);
kernel_thread
(
loop_thread
,
lo
,
CLONE_KERNEL
);
dow
n
(
&
lo
->
lo_
sem
);
wait_for_completio
n
(
&
lo
->
lo_
done
);
return
0
;
out_putf:
...
...
@@ -909,10 +906,10 @@ static int loop_clr_fd(struct loop_device *lo, struct block_device *bdev)
lo
->
lo_state
=
Lo_rundown
;
lo
->
lo_pending
--
;
if
(
!
lo
->
lo_pending
)
up
(
&
lo
->
lo_bh_
mutex
);
complete
(
&
lo
->
lo_bh_
done
);
spin_unlock_irq
(
&
lo
->
lo_lock
);
dow
n
(
&
lo
->
lo_
sem
);
wait_for_completio
n
(
&
lo
->
lo_
done
);
lo
->
lo_backing_file
=
NULL
;
...
...
@@ -1289,8 +1286,8 @@ static int __init loop_init(void)
if
(
!
lo
->
lo_queue
)
goto
out_mem4
;
init_MUTEX
(
&
lo
->
lo_ctl_mutex
);
init_
MUTEX_LOCKED
(
&
lo
->
lo_
sem
);
init_
MUTEX_LOCKED
(
&
lo
->
lo_bh_
mutex
);
init_
completion
(
&
lo
->
lo_
done
);
init_
completion
(
&
lo
->
lo_bh_
done
);
lo
->
lo_number
=
i
;
spin_lock_init
(
&
lo
->
lo_lock
);
disk
->
major
=
LOOP_MAJOR
;
...
...
This diff is collapsed.
Click to expand it.
drivers/block/sx8.c
View file @
80c05315
...
...
@@ -27,8 +27,8 @@
#include <linux/time.h>
#include <linux/hdreg.h>
#include <linux/dma-mapping.h>
#include <linux/completion.h>
#include <asm/io.h>
#include <asm/semaphore.h>
#include <asm/uaccess.h>
#if 0
...
...
@@ -303,7 +303,7 @@ struct carm_host {
struct
work_struct
fsm_task
;
struct
semaphore
probe_
sem
;
struct
completion
probe_
comp
;
};
struct
carm_response
{
...
...
@@ -1346,7 +1346,7 @@ static void carm_fsm_task (void *_data)
}
case
HST_PROBE_FINISHED
:
up
(
&
host
->
probe_
sem
);
complete
(
&
host
->
probe_
comp
);
break
;
case
HST_ERROR
:
...
...
@@ -1622,7 +1622,7 @@ static int carm_init_one (struct pci_dev *pdev, const struct pci_device_id *ent)
host
->
flags
=
pci_dac
?
FL_DAC
:
0
;
spin_lock_init
(
&
host
->
lock
);
INIT_WORK
(
&
host
->
fsm_task
,
carm_fsm_task
,
host
);
init_
MUTEX_LOCKED
(
&
host
->
probe_
sem
);
init_
completion
(
&
host
->
probe_
comp
);
for
(
i
=
0
;
i
<
ARRAY_SIZE
(
host
->
req
);
i
++
)
host
->
req
[
i
].
tag
=
i
;
...
...
@@ -1691,8 +1691,8 @@ static int carm_init_one (struct pci_dev *pdev, const struct pci_device_id *ent)
if
(
rc
)
goto
err_out_free_irq
;
DPRINTK
(
"waiting for probe_
sem
\n
"
);
dow
n
(
&
host
->
probe_
sem
);
DPRINTK
(
"waiting for probe_
comp
\n
"
);
wait_for_completio
n
(
&
host
->
probe_
comp
);
printk
(
KERN_INFO
"%s: pci %s, ports %d, io %lx, irq %u, major %d
\n
"
,
host
->
name
,
pci_name
(
pdev
),
(
int
)
CARM_MAX_PORTS
,
...
...
This diff is collapsed.
Click to expand it.
drivers/char/mem.c
View file @
80c05315
...
...
@@ -741,7 +741,7 @@ static loff_t memory_lseek(struct file * file, loff_t offset, int orig)
{
loff_t
ret
;
down
(
&
file
->
f_dentry
->
d_inode
->
i_
sem
);
mutex_lock
(
&
file
->
f_dentry
->
d_inode
->
i_
mutex
);
switch
(
orig
)
{
case
0
:
file
->
f_pos
=
offset
;
...
...
@@ -756,7 +756,7 @@ static loff_t memory_lseek(struct file * file, loff_t offset, int orig)
default:
ret
=
-
EINVAL
;
}
up
(
&
file
->
f_dentry
->
d_inode
->
i_
sem
);
mutex_unlock
(
&
file
->
f_dentry
->
d_inode
->
i_
mutex
);
return
ret
;
}
...
...
This diff is collapsed.
Click to expand it.
drivers/char/sysrq.c
View file @
80c05315
...
...
@@ -153,6 +153,21 @@ static struct sysrq_key_op sysrq_mountro_op = {
/* END SYNC SYSRQ HANDLERS BLOCK */
#ifdef CONFIG_DEBUG_MUTEXES
static
void
sysrq_handle_showlocks
(
int
key
,
struct
pt_regs
*
pt_regs
,
struct
tty_struct
*
tty
)
{
mutex_debug_show_all_locks
();
}
static
struct
sysrq_key_op
sysrq_showlocks_op
=
{
.
handler
=
sysrq_handle_showlocks
,
.
help_msg
=
"show-all-locks(D)"
,
.
action_msg
=
"Show Locks Held"
,
};
#endif
/* SHOW SYSRQ HANDLERS BLOCK */
...
...
@@ -294,7 +309,11 @@ static struct sysrq_key_op *sysrq_key_table[SYSRQ_KEY_TABLE_LENGTH] = {
#else
/* c */
NULL
,
#endif
#ifdef CONFIG_DEBUG_MUTEXES
/* d */
&
sysrq_showlocks_op
,
#else
/* d */
NULL
,
#endif
/* e */
&
sysrq_term_op
,
/* f */
&
sysrq_moom_op
,
/* g */
NULL
,
...
...
This diff is collapsed.
Click to expand it.
drivers/char/watchdog/cpu5wdt.c
View file @
80c05315
...
...
@@ -28,6 +28,7 @@
#include <linux/init.h>
#include <linux/ioport.h>
#include <linux/timer.h>
#include <linux/completion.h>
#include <linux/jiffies.h>
#include <asm/io.h>
#include <asm/uaccess.h>
...
...
@@ -57,7 +58,7 @@ static int ticks = 10000;
/* some device data */
static
struct
{
struct
semaphore
stop
;
struct
completion
stop
;
volatile
int
running
;
struct
timer_list
timer
;
volatile
int
queue
;
...
...
@@ -85,7 +86,7 @@ static void cpu5wdt_trigger(unsigned long unused)
}
else
{
/* ticks doesn't matter anyway */
up
(
&
cpu5wdt_device
.
stop
);
complete
(
&
cpu5wdt_device
.
stop
);
}
}
...
...
@@ -239,7 +240,7 @@ static int __devinit cpu5wdt_init(void)
if
(
!
val
)
printk
(
KERN_INFO
PFX
"sorry, was my fault
\n
"
);
init_
MUTEX_LOCKED
(
&
cpu5wdt_device
.
stop
);
init_
completion
(
&
cpu5wdt_device
.
stop
);
cpu5wdt_device
.
queue
=
0
;
clear_bit
(
0
,
&
cpu5wdt_device
.
inuse
);
...
...
@@ -269,7 +270,7 @@ static void __devexit cpu5wdt_exit(void)
{
if
(
cpu5wdt_device
.
queue
)
{
cpu5wdt_device
.
queue
=
0
;
dow
n
(
&
cpu5wdt_device
.
stop
);
wait_for_completio
n
(
&
cpu5wdt_device
.
stop
);
}
misc_deregister
(
&
cpu5wdt_misc
);
...
...
This diff is collapsed.
Click to expand it.
drivers/ide/ide-probe.c
View file @
80c05315
...
...
@@ -655,7 +655,7 @@ static void hwif_release_dev (struct device *dev)
{
ide_hwif_t
*
hwif
=
container_of
(
dev
,
ide_hwif_t
,
gendev
);
up
(
&
hwif
->
gendev_rel_
sem
);
complete
(
&
hwif
->
gendev_rel_
comp
);
}
static
void
hwif_register
(
ide_hwif_t
*
hwif
)
...
...
@@ -1327,7 +1327,7 @@ static void drive_release_dev (struct device *dev)
drive
->
queue
=
NULL
;
spin_unlock_irq
(
&
ide_lock
);
up
(
&
drive
->
gendev_rel_
sem
);
complete
(
&
drive
->
gendev_rel_
comp
);
}
/*
...
...
This diff is collapsed.
Click to expand it.
drivers/ide/ide.c
View file @
80c05315
...
...
@@ -222,7 +222,7 @@ static void init_hwif_data(ide_hwif_t *hwif, unsigned int index)
hwif
->
mwdma_mask
=
0x80
;
/* disable all mwdma */
hwif
->
swdma_mask
=
0x80
;
/* disable all swdma */
sema_init
(
&
hwif
->
gendev_rel_
sem
,
0
);
init_completion
(
&
hwif
->
gendev_rel_
comp
);
default_hwif_iops
(
hwif
);
default_hwif_transport
(
hwif
);
...
...
@@ -245,7 +245,7 @@ static void init_hwif_data(ide_hwif_t *hwif, unsigned int index)
drive
->
is_flash
=
0
;
drive
->
vdma
=
0
;
INIT_LIST_HEAD
(
&
drive
->
list
);
sema_init
(
&
drive
->
gendev_rel_
sem
,
0
);
init_completion
(
&
drive
->
gendev_rel_
comp
);
}
}
...
...
@@ -602,7 +602,7 @@ void ide_unregister(unsigned int index)
}
spin_unlock_irq
(
&
ide_lock
);
device_unregister
(
&
drive
->
gendev
);
dow
n
(
&
drive
->
gendev_rel_
sem
);
wait_for_completio
n
(
&
drive
->
gendev_rel_
comp
);
spin_lock_irq
(
&
ide_lock
);
}
hwif
->
present
=
0
;
...
...
@@ -662,7 +662,7 @@ void ide_unregister(unsigned int index)
/* More messed up locking ... */
spin_unlock_irq
(
&
ide_lock
);
device_unregister
(
&
hwif
->
gendev
);
dow
n
(
&
hwif
->
gendev_rel_
sem
);
wait_for_completio
n
(
&
hwif
->
gendev_rel_
comp
);
/*
* Remove us from the kernel's knowledge
...
...
This diff is collapsed.
Click to expand it.
drivers/isdn/capi/capifs.c
View file @
80c05315
...
...
@@ -138,7 +138,7 @@ static struct dentry *get_node(int num)
{
char
s
[
10
];
struct
dentry
*
root
=
capifs_root
;
down
(
&
root
->
d_inode
->
i_
sem
);
mutex_lock
(
&
root
->
d_inode
->
i_
mutex
);
return
lookup_one_len
(
s
,
root
,
sprintf
(
s
,
"%d"
,
num
));
}
...
...
@@ -159,7 +159,7 @@ void capifs_new_ncci(unsigned int number, dev_t device)
dentry
=
get_node
(
number
);
if
(
!
IS_ERR
(
dentry
)
&&
!
dentry
->
d_inode
)
d_instantiate
(
dentry
,
inode
);
up
(
&
capifs_root
->
d_inode
->
i_
sem
);
mutex_unlock
(
&
capifs_root
->
d_inode
->
i_
mutex
);
}
void
capifs_free_ncci
(
unsigned
int
number
)
...
...
@@ -175,7 +175,7 @@ void capifs_free_ncci(unsigned int number)
}
dput
(
dentry
);
}
up
(
&
capifs_root
->
d_inode
->
i_
sem
);
mutex_unlock
(
&
capifs_root
->
d_inode
->
i_
mutex
);
}
static
int
__init
capifs_init
(
void
)
...
...
This diff is collapsed.
Click to expand it.
drivers/md/dm.c
View file @
80c05315
...
...
@@ -837,9 +837,9 @@ static void __set_size(struct mapped_device *md, sector_t size)
{
set_capacity
(
md
->
disk
,
size
);
down
(
&
md
->
suspended_bdev
->
bd_inode
->
i_
sem
);
mutex_lock
(
&
md
->
suspended_bdev
->
bd_inode
->
i_
mutex
);
i_size_write
(
md
->
suspended_bdev
->
bd_inode
,
(
loff_t
)
size
<<
SECTOR_SHIFT
);
up
(
&
md
->
suspended_bdev
->
bd_inode
->
i_
sem
);
mutex_unlock
(
&
md
->
suspended_bdev
->
bd_inode
->
i_
mutex
);
}
static
int
__bind
(
struct
mapped_device
*
md
,
struct
dm_table
*
t
)
...
...
This diff is collapsed.
Click to expand it.
drivers/md/md.c
View file @
80c05315
...
...
@@ -3460,9 +3460,9 @@ static int update_size(mddev_t *mddev, unsigned long size)
bdev
=
bdget_disk
(
mddev
->
gendisk
,
0
);
if
(
bdev
)
{
down
(
&
bdev
->
bd_inode
->
i_
sem
);
mutex_lock
(
&
bdev
->
bd_inode
->
i_
mutex
);
i_size_write
(
bdev
->
bd_inode
,
mddev
->
array_size
<<
10
);
up
(
&
bdev
->
bd_inode
->
i_
sem
);
mutex_unlock
(
&
bdev
->
bd_inode
->
i_
mutex
);
bdput
(
bdev
);
}
}
...
...
@@ -3486,9 +3486,9 @@ static int update_raid_disks(mddev_t *mddev, int raid_disks)
bdev
=
bdget_disk
(
mddev
->
gendisk
,
0
);
if
(
bdev
)
{
down
(
&
bdev
->
bd_inode
->
i_
sem
);
mutex_lock
(
&
bdev
->
bd_inode
->
i_
mutex
);
i_size_write
(
bdev
->
bd_inode
,
mddev
->
array_size
<<
10
);
up
(
&
bdev
->
bd_inode
->
i_
sem
);
mutex_unlock
(
&
bdev
->
bd_inode
->
i_
mutex
);
bdput
(
bdev
);
}
}
...
...
This diff is collapsed.
Click to expand it.
drivers/pci/proc.c
View file @
80c05315
...
...
@@ -25,7 +25,7 @@ proc_bus_pci_lseek(struct file *file, loff_t off, int whence)
loff_t
new
=
-
1
;
struct
inode
*
inode
=
file
->
f_dentry
->
d_inode
;
down
(
&
inode
->
i_
sem
);
mutex_lock
(
&
inode
->
i_
mutex
);
switch
(
whence
)
{
case
0
:
new
=
off
;
...
...
@@ -41,7 +41,7 @@ proc_bus_pci_lseek(struct file *file, loff_t off, int whence)
new
=
-
EINVAL
;
else
file
->
f_pos
=
new
;
up
(
&
inode
->
i_
sem
);
mutex_unlock
(
&
inode
->
i_
mutex
);
return
new
;
}
...
...
This diff is collapsed.
Click to expand it.
drivers/usb/core/inode.c
View file @
80c05315
...
...
@@ -184,13 +184,13 @@ static void update_bus(struct dentry *bus)
bus
->
d_inode
->
i_gid
=
busgid
;
bus
->
d_inode
->
i_mode
=
S_IFDIR
|
busmode
;
down
(
&
bus
->
d_inode
->
i_
sem
);
mutex_lock
(
&
bus
->
d_inode
->
i_
mutex
);
list_for_each_entry
(
dev
,
&
bus
->
d_subdirs
,
d_u
.
d_child
)
if
(
dev
->
d_inode
)
update_dev
(
dev
);
up
(
&
bus
->
d_inode
->
i_
sem
);
mutex_unlock
(
&
bus
->
d_inode
->
i_
mutex
);
}
static
void
update_sb
(
struct
super_block
*
sb
)
...
...
@@ -201,7 +201,7 @@ static void update_sb(struct super_block *sb)
if
(
!
root
)
return
;
down
(
&
root
->
d_inode
->
i_
sem
);
mutex_lock
(
&
root
->
d_inode
->
i_
mutex
);
list_for_each_entry
(
bus
,
&
root
->
d_subdirs
,
d_u
.
d_child
)
{
if
(
bus
->
d_inode
)
{
...
...
@@ -219,7 +219,7 @@ static void update_sb(struct super_block *sb)
}
}
up
(
&
root
->
d_inode
->
i_
sem
);
mutex_unlock
(
&
root
->
d_inode
->
i_
mutex
);
}
static
int
remount
(
struct
super_block
*
sb
,
int
*
flags
,
char
*
data
)
...
...
@@ -333,10 +333,10 @@ static int usbfs_empty (struct dentry *dentry)
static
int
usbfs_unlink
(
struct
inode
*
dir
,
struct
dentry
*
dentry
)
{
struct
inode
*
inode
=
dentry
->
d_inode
;
down
(
&
inode
->
i_
sem
);
mutex_lock
(
&
inode
->
i_
mutex
);
dentry
->
d_inode
->
i_nlink
--
;
dput
(
dentry
);
up
(
&
inode
->
i_
sem
);
mutex_unlock
(
&
inode
->
i_
mutex
);
d_delete
(
dentry
);
return
0
;
}
...
...
@@ -346,7 +346,7 @@ static int usbfs_rmdir(struct inode *dir, struct dentry *dentry)
int
error
=
-
ENOTEMPTY
;
struct
inode
*
inode
=
dentry
->
d_inode
;
down
(
&
inode
->
i_
sem
);
mutex_lock
(
&
inode
->
i_
mutex
);
dentry_unhash
(
dentry
);
if
(
usbfs_empty
(
dentry
))
{
dentry
->
d_inode
->
i_nlink
-=
2
;
...
...
@@ -355,7 +355,7 @@ static int usbfs_rmdir(struct inode *dir, struct dentry *dentry)
dir
->
i_nlink
--
;
error
=
0
;
}
up
(
&
inode
->
i_
sem
);
mutex_unlock
(
&
inode
->
i_
mutex
);
if
(
!
error
)
d_delete
(
dentry
);
dput
(
dentry
);
...
...
@@ -380,7 +380,7 @@ static loff_t default_file_lseek (struct file *file, loff_t offset, int orig)
{
loff_t
retval
=
-
EINVAL
;
down
(
&
file
->
f_dentry
->
d_inode
->
i_
sem
);
mutex_lock
(
&
file
->
f_dentry
->
d_inode
->
i_
mutex
);
switch
(
orig
)
{
case
0
:
if
(
offset
>
0
)
{
...
...
@@ -397,7 +397,7 @@ static loff_t default_file_lseek (struct file *file, loff_t offset, int orig)
default:
break
;
}
up
(
&
file
->
f_dentry
->
d_inode
->
i_
sem
);
mutex_unlock
(
&
file
->
f_dentry
->
d_inode
->
i_
mutex
);
return
retval
;
}
...
...
@@ -480,7 +480,7 @@ static int fs_create_by_name (const char *name, mode_t mode,
}
*
dentry
=
NULL
;
down
(
&
parent
->
d_inode
->
i_
sem
);
mutex_lock
(
&
parent
->
d_inode
->
i_
mutex
);
*
dentry
=
lookup_one_len
(
name
,
parent
,
strlen
(
name
));
if
(
!
IS_ERR
(
dentry
))
{
if
((
mode
&
S_IFMT
)
==
S_IFDIR
)
...
...
@@ -489,7 +489,7 @@ static int fs_create_by_name (const char *name, mode_t mode,
error
=
usbfs_create
(
parent
->
d_inode
,
*
dentry
,
mode
);
}
else
error
=
PTR_ERR
(
dentry
);
up
(
&
parent
->
d_inode
->
i_
sem
);
mutex_unlock
(
&
parent
->
d_inode
->
i_
mutex
);
return
error
;
}
...
...
@@ -528,7 +528,7 @@ static void fs_remove_file (struct dentry *dentry)
if
(
!
parent
||
!
parent
->
d_inode
)
return
;
down
(
&
parent
->
d_inode
->
i_
sem
);
mutex_lock
(
&
parent
->
d_inode
->
i_
mutex
);
if
(
usbfs_positive
(
dentry
))
{
if
(
dentry
->
d_inode
)
{
if
(
S_ISDIR
(
dentry
->
d_inode
->
i_mode
))
...
...
@@ -538,7 +538,7 @@ static void fs_remove_file (struct dentry *dentry)
dput
(
dentry
);
}
}
up
(
&
parent
->
d_inode
->
i_
sem
);
mutex_unlock
(
&
parent
->
d_inode
->
i_
mutex
);
}
/* --------------------------------------------------------------------- */
...
...
This diff is collapsed.
Click to expand it.
drivers/usb/gadget/file_storage.c
View file @
80c05315
...
...
@@ -1891,7 +1891,7 @@ static int fsync_sub(struct lun *curlun)
return
-
EINVAL
;
inode
=
filp
->
f_dentry
->
d_inode
;
down
(
&
inode
->
i_
sem
);
mutex_lock
(
&
inode
->
i_
mutex
);
current
->
flags
|=
PF_SYNCWRITE
;
rc
=
filemap_fdatawrite
(
inode
->
i_mapping
);
err
=
filp
->
f_op
->
fsync
(
filp
,
filp
->
f_dentry
,
1
);
...
...
@@ -1901,7 +1901,7 @@ static int fsync_sub(struct lun *curlun)
if
(
!
rc
)
rc
=
err
;
current
->
flags
&=
~
PF_SYNCWRITE
;
up
(
&
inode
->
i_
sem
);
mutex_unlock
(
&
inode
->
i_
mutex
);
VLDBG
(
curlun
,
"fdatasync -> %d
\n
"
,
rc
);
return
rc
;
}
...
...
This diff is collapsed.
Click to expand it.
drivers/usb/gadget/inode.c
View file @
80c05315
...
...
@@ -1562,10 +1562,10 @@ restart:
spin_unlock_irq
(
&
dev
->
lock
);
/* break link to dcache */
down
(
&
parent
->
i_
sem
);
mutex_lock
(
&
parent
->
i_
mutex
);
d_delete
(
dentry
);
dput
(
dentry
);
up
(
&
parent
->
i_
sem
);
mutex_unlock
(
&
parent
->
i_
mutex
);
/* fds may still be open */
goto
restart
;
...
...
This diff is collapsed.
Click to expand it.
fs/affs/inode.c
View file @
80c05315
...
...
@@ -244,10 +244,10 @@ affs_put_inode(struct inode *inode)
pr_debug
(
"AFFS: put_inode(ino=%lu, nlink=%u)
\n
"
,
inode
->
i_ino
,
inode
->
i_nlink
);
affs_free_prealloc
(
inode
);
if
(
atomic_read
(
&
inode
->
i_count
)
==
1
)
{
down
(
&
inode
->
i_
sem
);
mutex_lock
(
&
inode
->
i_
mutex
);
if
(
inode
->
i_size
!=
AFFS_I
(
inode
)
->
mmu_private
)
affs_truncate
(
inode
);
up
(
&
inode
->
i_
sem
);
mutex_unlock
(
&
inode
->
i_
mutex
);
}
}
...
...
This diff is collapsed.
Click to expand it.
fs/autofs/root.c
View file @
80c05315
...
...
@@ -229,9 +229,9 @@ static struct dentry *autofs_root_lookup(struct inode *dir, struct dentry *dentr
dentry
->
d_flags
|=
DCACHE_AUTOFS_PENDING
;
d_add
(
dentry
,
NULL
);
up
(
&
dir
->
i_
sem
);
mutex_unlock
(
&
dir
->
i_
mutex
);
autofs_revalidate
(
dentry
,
nd
);
down
(
&
dir
->
i_
sem
);
mutex_lock
(
&
dir
->
i_
mutex
);
/*
* If we are still pending, check if we had to handle
...
...
This diff is collapsed.
Click to expand it.
Prev
1
2
3
4
5
…
10
Next
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment