Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
L
linux
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
linux
Commits
cb625b80
Commit
cb625b80
authored
Feb 17, 2002
by
Alexander Viro
Committed by
Linus Torvalds
Feb 17, 2002
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[PATCH] BKL shifting - ->rename()
parent
a9b979a5
Changes
23
Hide whitespace changes
Inline
Side-by-side
Showing
23 changed files
with
84 additions
and
24 deletions
+84
-24
Documentation/filesystems/Locking
Documentation/filesystems/Locking
+1
-1
Documentation/filesystems/porting
Documentation/filesystems/porting
+5
-5
fs/affs/namei.c
fs/affs/namei.c
+5
-1
fs/bfs/dir.c
fs/bfs/dir.c
+2
-0
fs/coda/dir.c
fs/coda/dir.c
+2
-0
fs/ext2/namei.c
fs/ext2/namei.c
+0
-1
fs/ext3/namei.c
fs/ext3/namei.c
+6
-2
fs/hfs/dir.c
fs/hfs/dir.c
+12
-4
fs/hfs/dir_dbl.c
fs/hfs/dir_dbl.c
+2
-0
fs/hfs/dir_nat.c
fs/hfs/dir_nat.c
+4
-1
fs/hpfs/namei.c
fs/hpfs/namei.c
+2
-0
fs/jffs/inode-v23.c
fs/jffs/inode-v23.c
+3
-0
fs/jffs2/dir.c
fs/jffs2/dir.c
+5
-1
fs/minix/namei.c
fs/minix/namei.c
+0
-1
fs/msdos/namei.c
fs/msdos/namei.c
+2
-0
fs/namei.c
fs/namei.c
+6
-4
fs/ncpfs/dir.c
fs/ncpfs/dir.c
+2
-0
fs/nfs/dir.c
fs/nfs/dir.c
+2
-0
fs/reiserfs/namei.c
fs/reiserfs/namei.c
+14
-3
fs/smbfs/dir.c
fs/smbfs/dir.c
+2
-0
fs/udf/namei.c
fs/udf/namei.c
+2
-0
fs/ufs/namei.c
fs/ufs/namei.c
+3
-0
fs/vfat/namei.c
fs/vfat/namei.c
+2
-0
No files found.
Documentation/filesystems/Locking
View file @
cb625b80
...
@@ -61,7 +61,7 @@ symlink: no yes
...
@@ -61,7 +61,7 @@ symlink: no yes
mkdir: no yes
mkdir: no yes
unlink: no yes (both)
unlink: no yes (both)
rmdir: no yes (both) (see below)
rmdir: no yes (both) (see below)
rename:
yes
yes (all) (see below)
rename:
no
yes (all) (see below)
readlink: no no
readlink: no no
follow_link: no no
follow_link: no no
truncate: no yes (see below)
truncate: no yes (see below)
...
...
Documentation/filesystems/porting
View file @
cb625b80
...
@@ -81,11 +81,11 @@ can relax your locking.
...
@@ -81,11 +81,11 @@ can relax your locking.
[mandatory]
[mandatory]
->lookup(), ->truncate(), ->create(), ->unlink(), ->mknod(), ->mkdir(),
->lookup(), ->truncate(), ->create(), ->unlink(), ->mknod(), ->mkdir(),
->rmdir(), ->link()
and ->symlink() are called without BKL now. Grab it
->rmdir(), ->link()
, ->symlink() and ->rename() are called without BKL now.
on the entry, drop upon return - that will guarantee the same locking you
Grab it on the entry, drop upon return - that will guarantee the same
used to have. If your method or its parts do not need BKL - better yet,
locking you used to have. If your method or its parts do not need BKL -
now you can shift lock_kernel() / unlock_kernel() so that they would protec
t
better yet, now you can shift lock_kernel() / unlock_kernel() so tha
t
exactly what needs to be protected.
they would protect
exactly what needs to be protected.
---
---
[informational]
[informational]
...
...
fs/affs/namei.c
View file @
cb625b80
...
@@ -462,6 +462,7 @@ affs_rename(struct inode *old_dir, struct dentry *old_dentry,
...
@@ -462,6 +462,7 @@ affs_rename(struct inode *old_dir, struct dentry *old_dentry,
struct
buffer_head
*
bh
=
NULL
;
struct
buffer_head
*
bh
=
NULL
;
int
retval
;
int
retval
;
lock_kernel
();
pr_debug
(
"AFFS: rename(old=%u,
\"
%*s
\"
to new=%u,
\"
%*s
\"
)
\n
"
,
pr_debug
(
"AFFS: rename(old=%u,
\"
%*s
\"
to new=%u,
\"
%*s
\"
)
\n
"
,
(
u32
)
old_dir
->
i_ino
,
(
int
)
old_dentry
->
d_name
.
len
,
old_dentry
->
d_name
.
name
,
(
u32
)
old_dir
->
i_ino
,
(
int
)
old_dentry
->
d_name
.
len
,
old_dentry
->
d_name
.
name
,
(
u32
)
new_dir
->
i_ino
,
(
int
)
new_dentry
->
d_name
.
len
,
new_dentry
->
d_name
.
name
);
(
u32
)
new_dir
->
i_ino
,
(
int
)
new_dentry
->
d_name
.
len
,
new_dentry
->
d_name
.
name
);
...
@@ -472,8 +473,10 @@ affs_rename(struct inode *old_dir, struct dentry *old_dentry,
...
@@ -472,8 +473,10 @@ affs_rename(struct inode *old_dir, struct dentry *old_dentry,
/* Unlink destination if it already exists */
/* Unlink destination if it already exists */
if
(
new_dentry
->
d_inode
)
{
if
(
new_dentry
->
d_inode
)
{
retval
=
affs_remove_header
(
new_dentry
);
retval
=
affs_remove_header
(
new_dentry
);
if
(
retval
)
if
(
retval
)
{
unlock_kernel
();
return
retval
;
return
retval
;
}
}
}
retval
=
-
EIO
;
retval
=
-
EIO
;
...
@@ -499,5 +502,6 @@ affs_rename(struct inode *old_dir, struct dentry *old_dentry,
...
@@ -499,5 +502,6 @@ affs_rename(struct inode *old_dir, struct dentry *old_dentry,
done:
done:
mark_buffer_dirty_inode
(
bh
,
retval
?
old_dir
:
new_dir
);
mark_buffer_dirty_inode
(
bh
,
retval
?
old_dir
:
new_dir
);
affs_brelse
(
bh
);
affs_brelse
(
bh
);
unlock_kernel
();
return
retval
;
return
retval
;
}
}
fs/bfs/dir.c
View file @
cb625b80
...
@@ -213,6 +213,7 @@ static int bfs_rename(struct inode * old_dir, struct dentry * old_dentry,
...
@@ -213,6 +213,7 @@ static int bfs_rename(struct inode * old_dir, struct dentry * old_dentry,
if
(
S_ISDIR
(
old_inode
->
i_mode
))
if
(
S_ISDIR
(
old_inode
->
i_mode
))
return
-
EINVAL
;
return
-
EINVAL
;
lock_kernel
();
old_bh
=
bfs_find_entry
(
old_dir
,
old_bh
=
bfs_find_entry
(
old_dir
,
old_dentry
->
d_name
.
name
,
old_dentry
->
d_name
.
name
,
old_dentry
->
d_name
.
len
,
&
old_de
);
old_dentry
->
d_name
.
len
,
&
old_de
);
...
@@ -249,6 +250,7 @@ static int bfs_rename(struct inode * old_dir, struct dentry * old_dentry,
...
@@ -249,6 +250,7 @@ static int bfs_rename(struct inode * old_dir, struct dentry * old_dentry,
error
=
0
;
error
=
0
;
end_rename:
end_rename:
unlock_kernel
();
brelse
(
old_bh
);
brelse
(
old_bh
);
brelse
(
new_bh
);
brelse
(
new_bh
);
return
error
;
return
error
;
...
...
fs/coda/dir.c
View file @
cb625b80
...
@@ -501,6 +501,7 @@ static int coda_rename(struct inode *old_dir, struct dentry *old_dentry,
...
@@ -501,6 +501,7 @@ static int coda_rename(struct inode *old_dir, struct dentry *old_dentry,
int
link_adjust
=
0
;
int
link_adjust
=
0
;
int
error
;
int
error
;
lock_kernel
();
coda_vfs_stat
.
rename
++
;
coda_vfs_stat
.
rename
++
;
CDEBUG
(
D_INODE
,
"old: %s, (%d length), new: %s"
CDEBUG
(
D_INODE
,
"old: %s, (%d length), new: %s"
...
@@ -527,6 +528,7 @@ static int coda_rename(struct inode *old_dir, struct dentry *old_dentry,
...
@@ -527,6 +528,7 @@ static int coda_rename(struct inode *old_dir, struct dentry *old_dentry,
}
}
CDEBUG
(
D_INODE
,
"result %d
\n
"
,
error
);
CDEBUG
(
D_INODE
,
"result %d
\n
"
,
error
);
unlock_kernel
();
return
error
;
return
error
;
}
}
...
...
fs/ext2/namei.c
View file @
cb625b80
...
@@ -31,7 +31,6 @@
...
@@ -31,7 +31,6 @@
#include "ext2.h"
#include "ext2.h"
#include <linux/pagemap.h>
#include <linux/pagemap.h>
#include <linux/smp_lock.h>
/*
/*
* Couple of helper functions - make the code slightly cleaner.
* Couple of helper functions - make the code slightly cleaner.
...
...
fs/ext3/namei.c
View file @
cb625b80
...
@@ -1027,9 +1027,12 @@ static int ext3_rename (struct inode * old_dir, struct dentry *old_dentry,
...
@@ -1027,9 +1027,12 @@ static int ext3_rename (struct inode * old_dir, struct dentry *old_dentry,
old_bh
=
new_bh
=
dir_bh
=
NULL
;
old_bh
=
new_bh
=
dir_bh
=
NULL
;
lock_kernel
();
handle
=
ext3_journal_start
(
old_dir
,
2
*
EXT3_DATA_TRANS_BLOCKS
+
2
);
handle
=
ext3_journal_start
(
old_dir
,
2
*
EXT3_DATA_TRANS_BLOCKS
+
2
);
if
(
IS_ERR
(
handle
))
if
(
IS_ERR
(
handle
))
{
unlock_kernel
();
return
PTR_ERR
(
handle
);
return
PTR_ERR
(
handle
);
}
if
(
IS_SYNC
(
old_dir
)
||
IS_SYNC
(
new_dir
))
if
(
IS_SYNC
(
old_dir
)
||
IS_SYNC
(
new_dir
))
handle
->
h_sync
=
1
;
handle
->
h_sync
=
1
;
...
@@ -1138,6 +1141,7 @@ static int ext3_rename (struct inode * old_dir, struct dentry *old_dentry,
...
@@ -1138,6 +1141,7 @@ static int ext3_rename (struct inode * old_dir, struct dentry *old_dentry,
brelse
(
old_bh
);
brelse
(
old_bh
);
brelse
(
new_bh
);
brelse
(
new_bh
);
ext3_journal_stop
(
handle
,
old_dir
);
ext3_journal_stop
(
handle
,
old_dir
);
unlock_kernel
();
return
retval
;
return
retval
;
}
}
...
@@ -1153,5 +1157,5 @@ struct inode_operations ext3_dir_inode_operations = {
...
@@ -1153,5 +1157,5 @@ struct inode_operations ext3_dir_inode_operations = {
mkdir:
ext3_mkdir
,
mkdir:
ext3_mkdir
,
rmdir:
ext3_rmdir
,
rmdir:
ext3_rmdir
,
mknod:
ext3_mknod
,
mknod:
ext3_mknod
,
rename:
ext3_rename
,
/* BKL held */
rename:
ext3_rename
,
};
};
fs/hfs/dir.c
View file @
cb625b80
...
@@ -376,20 +376,27 @@ int hfs_rmdir(struct inode * parent, struct dentry *dentry)
...
@@ -376,20 +376,27 @@ int hfs_rmdir(struct inode * parent, struct dentry *dentry)
int
hfs_rename
(
struct
inode
*
old_dir
,
struct
dentry
*
old_dentry
,
int
hfs_rename
(
struct
inode
*
old_dir
,
struct
dentry
*
old_dentry
,
struct
inode
*
new_dir
,
struct
dentry
*
new_dentry
)
struct
inode
*
new_dir
,
struct
dentry
*
new_dentry
)
{
{
struct
hfs_cat_entry
*
old_parent
=
HFS_I
(
old_dir
)
->
entry
;
struct
hfs_cat_entry
*
old_parent
;
struct
hfs_cat_entry
*
new_parent
=
HFS_I
(
new_dir
)
->
entry
;
struct
hfs_cat_entry
*
new_parent
;
struct
hfs_cat_entry
*
victim
=
NULL
;
struct
hfs_cat_entry
*
victim
=
NULL
;
struct
hfs_cat_entry
*
deleted
;
struct
hfs_cat_entry
*
deleted
;
struct
hfs_cat_key
key
;
struct
hfs_cat_key
key
;
int
error
;
int
error
;
lock_kernel
();
old_parent
=
HFS_I
(
old_dir
)
->
entry
;
new_parent
=
HFS_I
(
new_dir
)
->
entry
;
if
(
build_key
(
&
key
,
old_dir
,
old_dentry
->
d_name
.
name
,
if
(
build_key
(
&
key
,
old_dir
,
old_dentry
->
d_name
.
name
,
old_dentry
->
d_name
.
len
)
||
old_dentry
->
d_name
.
len
)
||
(
HFS_ITYPE
(
old_dir
->
i_ino
)
!=
HFS_ITYPE
(
new_dir
->
i_ino
)))
(
HFS_ITYPE
(
old_dir
->
i_ino
)
!=
HFS_ITYPE
(
new_dir
->
i_ino
)))
{
unlock_kernel
();
return
-
EPERM
;
return
-
EPERM
;
}
if
(
!
(
victim
=
hfs_cat_get
(
old_parent
->
mdb
,
&
key
)))
if
(
!
(
victim
=
hfs_cat_get
(
old_parent
->
mdb
,
&
key
)))
{
unlock_kernel
();
return
-
ENOENT
;
return
-
ENOENT
;
}
error
=
-
EPERM
;
error
=
-
EPERM
;
if
(
build_key
(
&
key
,
new_dir
,
new_dentry
->
d_name
.
name
,
if
(
build_key
(
&
key
,
new_dir
,
new_dentry
->
d_name
.
name
,
...
@@ -418,5 +425,6 @@ int hfs_rename(struct inode *old_dir, struct dentry *old_dentry,
...
@@ -418,5 +425,6 @@ int hfs_rename(struct inode *old_dir, struct dentry *old_dentry,
hfs_rename_put:
hfs_rename_put:
hfs_cat_put
(
victim
);
/* Note that hfs_cat_put(NULL) is safe. */
hfs_cat_put
(
victim
);
/* Note that hfs_cat_put(NULL) is safe. */
unlock_kernel
();
return
error
;
return
error
;
}
}
fs/hfs/dir_dbl.c
View file @
cb625b80
...
@@ -366,6 +366,7 @@ static int dbl_rename(struct inode *old_dir, struct dentry *old_dentry,
...
@@ -366,6 +366,7 @@ static int dbl_rename(struct inode *old_dir, struct dentry *old_dentry,
{
{
int
error
;
int
error
;
lock_kernel
();
if
(
is_hdr
(
new_dir
,
new_dentry
->
d_name
.
name
,
if
(
is_hdr
(
new_dir
,
new_dentry
->
d_name
.
name
,
new_dentry
->
d_name
.
len
))
{
new_dentry
->
d_name
.
len
))
{
error
=
-
EPERM
;
error
=
-
EPERM
;
...
@@ -378,6 +379,7 @@ static int dbl_rename(struct inode *old_dir, struct dentry *old_dentry,
...
@@ -378,6 +379,7 @@ static int dbl_rename(struct inode *old_dir, struct dentry *old_dentry,
error
=
-
EPERM
;
error
=
-
EPERM
;
}
}
}
}
unlock_kernel
();
return
error
;
return
error
;
}
}
...
...
fs/hfs/dir_nat.c
View file @
cb625b80
...
@@ -425,9 +425,11 @@ static int nat_hdr_unlink(struct inode *dir, struct dentry *dentry)
...
@@ -425,9 +425,11 @@ static int nat_hdr_unlink(struct inode *dir, struct dentry *dentry)
static
int
nat_hdr_rename
(
struct
inode
*
old_dir
,
struct
dentry
*
old_dentry
,
static
int
nat_hdr_rename
(
struct
inode
*
old_dir
,
struct
dentry
*
old_dentry
,
struct
inode
*
new_dir
,
struct
dentry
*
new_dentry
)
struct
inode
*
new_dir
,
struct
dentry
*
new_dentry
)
{
{
struct
hfs_cat_entry
*
entry
=
HFS_I
(
old_dir
)
->
entry
;
struct
hfs_cat_entry
*
entry
;
int
error
=
0
;
int
error
=
0
;
lock_kernel
();
entry
=
HFS_I
(
old_dir
)
->
entry
;
if
(
!
HFS_SB
(
old_dir
->
i_sb
)
->
s_afpd
)
{
if
(
!
HFS_SB
(
old_dir
->
i_sb
)
->
s_afpd
)
{
/* Not in AFPD compatibility mode */
/* Not in AFPD compatibility mode */
error
=
-
EPERM
;
error
=
-
EPERM
;
...
@@ -456,5 +458,6 @@ static int nat_hdr_rename(struct inode *old_dir, struct dentry *old_dentry,
...
@@ -456,5 +458,6 @@ static int nat_hdr_rename(struct inode *old_dir, struct dentry *old_dentry,
error
=
-
EPERM
;
error
=
-
EPERM
;
}
}
}
}
unlock_kernel
();
return
error
;
return
error
;
}
}
fs/hpfs/namei.c
View file @
cb625b80
...
@@ -482,6 +482,7 @@ int hpfs_rename(struct inode *old_dir, struct dentry *old_dentry,
...
@@ -482,6 +482,7 @@ int hpfs_rename(struct inode *old_dir, struct dentry *old_dentry,
err
=
0
;
err
=
0
;
hpfs_adjust_length
((
char
*
)
old_name
,
&
old_len
);
hpfs_adjust_length
((
char
*
)
old_name
,
&
old_len
);
lock_kernel
();
hpfs_lock_3inodes
(
old_dir
,
new_dir
,
i
);
hpfs_lock_3inodes
(
old_dir
,
new_dir
,
i
);
/* Erm? Moving over the empty non-busy directory is perfectly legal */
/* Erm? Moving over the empty non-busy directory is perfectly legal */
...
@@ -562,5 +563,6 @@ int hpfs_rename(struct inode *old_dir, struct dentry *old_dentry,
...
@@ -562,5 +563,6 @@ int hpfs_rename(struct inode *old_dir, struct dentry *old_dentry,
hpfs_decide_conv
(
i
,
(
char
*
)
new_name
,
new_len
);
hpfs_decide_conv
(
i
,
(
char
*
)
new_name
,
new_len
);
end1:
end1:
hpfs_unlock_3inodes
(
old_dir
,
new_dir
,
i
);
hpfs_unlock_3inodes
(
old_dir
,
new_dir
,
i
);
unlock_kernel
();
return
err
;
return
err
;
}
}
fs/jffs/inode-v23.c
View file @
cb625b80
...
@@ -422,10 +422,12 @@ jffs_rename(struct inode *old_dir, struct dentry *old_dentry,
...
@@ -422,10 +422,12 @@ jffs_rename(struct inode *old_dir, struct dentry *old_dentry,
old_dir
,
old_dentry
->
d_name
.
name
,
old_dir
,
old_dentry
->
d_name
.
name
,
new_dir
,
new_dentry
->
d_name
.
name
));
new_dir
,
new_dentry
->
d_name
.
name
));
lock_kernel
();
c
=
(
struct
jffs_control
*
)
old_dir
->
i_sb
->
u
.
generic_sbp
;
c
=
(
struct
jffs_control
*
)
old_dir
->
i_sb
->
u
.
generic_sbp
;
ASSERT
(
if
(
!
c
)
{
ASSERT
(
if
(
!
c
)
{
printk
(
KERN_ERR
"jffs_rename(): The old_dir inode "
printk
(
KERN_ERR
"jffs_rename(): The old_dir inode "
"didn't have a reference to a jffs_file struct
\n
"
);
"didn't have a reference to a jffs_file struct
\n
"
);
unlock_kernel
();
return
-
EIO
;
return
-
EIO
;
});
});
...
@@ -544,6 +546,7 @@ jffs_rename(struct inode *old_dir, struct dentry *old_dentry,
...
@@ -544,6 +546,7 @@ jffs_rename(struct inode *old_dir, struct dentry *old_dentry,
jffs_rename_end:
jffs_rename_end:
D3
(
printk
(
KERN_NOTICE
"rename(): up biglock
\n
"
));
D3
(
printk
(
KERN_NOTICE
"rename(): up biglock
\n
"
));
up
(
&
c
->
fmc
->
biglock
);
up
(
&
c
->
fmc
->
biglock
);
unlock_kernel
();
return
result
;
return
result
;
}
/* jffs_rename() */
}
/* jffs_rename() */
...
...
fs/jffs2/dir.c
View file @
cb625b80
...
@@ -978,9 +978,12 @@ static int jffs2_rename (struct inode *old_dir_i, struct dentry *old_dentry,
...
@@ -978,9 +978,12 @@ static int jffs2_rename (struct inode *old_dir_i, struct dentry *old_dentry,
*/
*/
/* Make a hard link */
/* Make a hard link */
lock_kernel
();
ret
=
jffs2_do_link
(
old_dentry
,
new_dir_i
,
new_dentry
,
1
);
ret
=
jffs2_do_link
(
old_dentry
,
new_dir_i
,
new_dentry
,
1
);
if
(
ret
)
if
(
ret
)
{
unlock_kernel
();
return
ret
;
return
ret
;
}
/* Unlink the original */
/* Unlink the original */
ret
=
jffs2_do_unlink
(
old_dir_i
,
old_dentry
,
1
);
ret
=
jffs2_do_unlink
(
old_dir_i
,
old_dentry
,
1
);
...
@@ -1001,6 +1004,7 @@ static int jffs2_rename (struct inode *old_dir_i, struct dentry *old_dentry,
...
@@ -1001,6 +1004,7 @@ static int jffs2_rename (struct inode *old_dir_i, struct dentry *old_dentry,
}
}
}
}
unlock_kernel
();
return
ret
;
return
ret
;
}
}
fs/minix/namei.c
View file @
cb625b80
...
@@ -6,7 +6,6 @@
...
@@ -6,7 +6,6 @@
#include <linux/fs.h>
#include <linux/fs.h>
#include <linux/minix_fs.h>
#include <linux/minix_fs.h>
#include <linux/smp_lock.h>
#include <linux/pagemap.h>
#include <linux/pagemap.h>
static
inline
void
inc_count
(
struct
inode
*
inode
)
static
inline
void
inc_count
(
struct
inode
*
inode
)
...
...
fs/msdos/namei.c
View file @
cb625b80
...
@@ -561,6 +561,7 @@ int msdos_rename(struct inode *old_dir,struct dentry *old_dentry,
...
@@ -561,6 +561,7 @@ int msdos_rename(struct inode *old_dir,struct dentry *old_dentry,
int
is_hid
,
old_hid
;
/* if new file and old file are hidden */
int
is_hid
,
old_hid
;
/* if new file and old file are hidden */
char
old_msdos_name
[
MSDOS_NAME
],
new_msdos_name
[
MSDOS_NAME
];
char
old_msdos_name
[
MSDOS_NAME
],
new_msdos_name
[
MSDOS_NAME
];
lock_kernel
();
error
=
msdos_format_name
(
old_dentry
->
d_name
.
name
,
error
=
msdos_format_name
(
old_dentry
->
d_name
.
name
,
old_dentry
->
d_name
.
len
,
old_msdos_name
,
old_dentry
->
d_name
.
len
,
old_msdos_name
,
&
MSDOS_SB
(
old_dir
->
i_sb
)
->
options
);
&
MSDOS_SB
(
old_dir
->
i_sb
)
->
options
);
...
@@ -584,6 +585,7 @@ int msdos_rename(struct inode *old_dir,struct dentry *old_dentry,
...
@@ -584,6 +585,7 @@ int msdos_rename(struct inode *old_dir,struct dentry *old_dentry,
fat_brelse
(
sb
,
old_bh
);
fat_brelse
(
sb
,
old_bh
);
rename_done:
rename_done:
unlock_kernel
();
return
error
;
return
error
;
}
}
...
...
fs/namei.c
View file @
cb625b80
...
@@ -1743,8 +1743,11 @@ int vfs_rename_dir(struct inode *old_dir, struct dentry *old_dentry,
...
@@ -1743,8 +1743,11 @@ int vfs_rename_dir(struct inode *old_dir, struct dentry *old_dentry,
d_rehash
(
new_dentry
);
d_rehash
(
new_dentry
);
dput
(
new_dentry
);
dput
(
new_dentry
);
}
}
if
(
!
error
)
if
(
!
error
)
{
lock_kernel
();
d_move
(
old_dentry
,
new_dentry
);
d_move
(
old_dentry
,
new_dentry
);
unlock_kernel
();
}
return
error
;
return
error
;
}
}
...
@@ -1765,7 +1768,9 @@ int vfs_rename_other(struct inode *old_dir, struct dentry *old_dentry,
...
@@ -1765,7 +1768,9 @@ int vfs_rename_other(struct inode *old_dir, struct dentry *old_dentry,
if
(
!
error
)
{
if
(
!
error
)
{
/* The following d_move() should become unconditional */
/* The following d_move() should become unconditional */
if
(
!
(
old_dir
->
i_sb
->
s_type
->
fs_flags
&
FS_ODD_RENAME
))
{
if
(
!
(
old_dir
->
i_sb
->
s_type
->
fs_flags
&
FS_ODD_RENAME
))
{
lock_kernel
();
d_move
(
old_dentry
,
new_dentry
);
d_move
(
old_dentry
,
new_dentry
);
unlock_kernel
();
}
}
}
}
if
(
target
)
if
(
target
)
...
@@ -1880,11 +1885,8 @@ static inline int do_rename(const char * oldname, const char * newname)
...
@@ -1880,11 +1885,8 @@ static inline int do_rename(const char * oldname, const char * newname)
if
(
new_dentry
==
trap
)
if
(
new_dentry
==
trap
)
goto
exit5
;
goto
exit5
;
lock_kernel
();
error
=
vfs_rename
(
old_dir
->
d_inode
,
old_dentry
,
error
=
vfs_rename
(
old_dir
->
d_inode
,
old_dentry
,
new_dir
->
d_inode
,
new_dentry
);
new_dir
->
d_inode
,
new_dentry
);
unlock_kernel
();
exit5:
exit5:
dput
(
new_dentry
);
dput
(
new_dentry
);
exit4:
exit4:
...
...
fs/ncpfs/dir.c
View file @
cb625b80
...
@@ -1035,6 +1035,7 @@ static int ncp_rename(struct inode *old_dir, struct dentry *old_dentry,
...
@@ -1035,6 +1035,7 @@ static int ncp_rename(struct inode *old_dir, struct dentry *old_dentry,
new_dentry
->
d_parent
->
d_name
.
name
,
new_dentry
->
d_name
.
name
);
new_dentry
->
d_parent
->
d_name
.
name
,
new_dentry
->
d_name
.
name
);
error
=
-
EIO
;
error
=
-
EIO
;
lock_kernel
();
if
(
!
ncp_conn_valid
(
server
))
if
(
!
ncp_conn_valid
(
server
))
goto
out
;
goto
out
;
...
@@ -1078,6 +1079,7 @@ static int ncp_rename(struct inode *old_dir, struct dentry *old_dentry,
...
@@ -1078,6 +1079,7 @@ static int ncp_rename(struct inode *old_dir, struct dentry *old_dentry,
break
;
break
;
}
}
out:
out:
unlock_kernel
();
return
error
;
return
error
;
}
}
...
...
fs/nfs/dir.c
View file @
cb625b80
...
@@ -998,6 +998,7 @@ static int nfs_rename(struct inode *old_dir, struct dentry *old_dentry,
...
@@ -998,6 +998,7 @@ static int nfs_rename(struct inode *old_dir, struct dentry *old_dentry,
* To prevent any new references to the target during the rename,
* To prevent any new references to the target during the rename,
* we unhash the dentry and free the inode in advance.
* we unhash the dentry and free the inode in advance.
*/
*/
lock_kernel
();
if
(
!
d_unhashed
(
new_dentry
))
{
if
(
!
d_unhashed
(
new_dentry
))
{
d_drop
(
new_dentry
);
d_drop
(
new_dentry
);
rehash
=
new_dentry
;
rehash
=
new_dentry
;
...
@@ -1074,6 +1075,7 @@ static int nfs_rename(struct inode *old_dir, struct dentry *old_dentry,
...
@@ -1074,6 +1075,7 @@ static int nfs_rename(struct inode *old_dir, struct dentry *old_dentry,
/* new dentry created? */
/* new dentry created? */
if
(
dentry
)
if
(
dentry
)
dput
(
dentry
);
dput
(
dentry
);
unlock_kernel
();
return
error
;
return
error
;
}
}
...
...
fs/reiserfs/namei.c
View file @
cb625b80
...
@@ -1101,13 +1101,17 @@ static int reiserfs_rename (struct inode * old_dir, struct dentry *old_dentry,
...
@@ -1101,13 +1101,17 @@ static int reiserfs_rename (struct inode * old_dir, struct dentry *old_dentry,
// make sure, that oldname still exists and points to an object we
// make sure, that oldname still exists and points to an object we
// are going to rename
// are going to rename
old_de
.
de_gen_number_bit_string
=
0
;
old_de
.
de_gen_number_bit_string
=
0
;
lock_kernel
();
retval
=
reiserfs_find_entry
(
old_dir
,
old_dentry
->
d_name
.
name
,
old_dentry
->
d_name
.
len
,
retval
=
reiserfs_find_entry
(
old_dir
,
old_dentry
->
d_name
.
name
,
old_dentry
->
d_name
.
len
,
&
old_entry_path
,
&
old_de
);
&
old_entry_path
,
&
old_de
);
pathrelse
(
&
old_entry_path
);
pathrelse
(
&
old_entry_path
);
if
(
retval
==
IO_ERROR
)
if
(
retval
==
IO_ERROR
)
{
unlock_kernel
();
return
-
EIO
;
return
-
EIO
;
}
if
(
retval
!=
NAME_FOUND
||
old_de
.
de_objectid
!=
old_inode
->
i_ino
)
{
if
(
retval
!=
NAME_FOUND
||
old_de
.
de_objectid
!=
old_inode
->
i_ino
)
{
unlock_kernel
();
return
-
ENOENT
;
return
-
ENOENT
;
}
}
...
@@ -1118,6 +1122,7 @@ static int reiserfs_rename (struct inode * old_dir, struct dentry *old_dentry,
...
@@ -1118,6 +1122,7 @@ static int reiserfs_rename (struct inode * old_dir, struct dentry *old_dentry,
if
(
new_inode
)
{
if
(
new_inode
)
{
if
(
!
reiserfs_empty_dir
(
new_inode
))
{
if
(
!
reiserfs_empty_dir
(
new_inode
))
{
unlock_kernel
();
return
-
ENOTEMPTY
;
return
-
ENOTEMPTY
;
}
}
}
}
...
@@ -1128,12 +1133,16 @@ static int reiserfs_rename (struct inode * old_dir, struct dentry *old_dentry,
...
@@ -1128,12 +1133,16 @@ static int reiserfs_rename (struct inode * old_dir, struct dentry *old_dentry,
dot_dot_de
.
de_gen_number_bit_string
=
0
;
dot_dot_de
.
de_gen_number_bit_string
=
0
;
retval
=
reiserfs_find_entry
(
old_inode
,
".."
,
2
,
&
dot_dot_entry_path
,
&
dot_dot_de
);
retval
=
reiserfs_find_entry
(
old_inode
,
".."
,
2
,
&
dot_dot_entry_path
,
&
dot_dot_de
);
pathrelse
(
&
dot_dot_entry_path
);
pathrelse
(
&
dot_dot_entry_path
);
if
(
retval
!=
NAME_FOUND
)
if
(
retval
!=
NAME_FOUND
)
{
unlock_kernel
();
return
-
EIO
;
return
-
EIO
;
}
/* inode number of .. must equal old_dir->i_ino */
/* inode number of .. must equal old_dir->i_ino */
if
(
dot_dot_de
.
de_objectid
!=
old_dir
->
i_ino
)
if
(
dot_dot_de
.
de_objectid
!=
old_dir
->
i_ino
)
{
unlock_kernel
();
return
-
EIO
;
return
-
EIO
;
}
}
}
journal_begin
(
&
th
,
old_dir
->
i_sb
,
jbegin_count
)
;
journal_begin
(
&
th
,
old_dir
->
i_sb
,
jbegin_count
)
;
...
@@ -1152,6 +1161,7 @@ static int reiserfs_rename (struct inode * old_dir, struct dentry *old_dentry,
...
@@ -1152,6 +1161,7 @@ static int reiserfs_rename (struct inode * old_dir, struct dentry *old_dentry,
}
else
if
(
retval
)
{
}
else
if
(
retval
)
{
pop_journal_writer
(
windex
)
;
pop_journal_writer
(
windex
)
;
journal_end
(
&
th
,
old_dir
->
i_sb
,
jbegin_count
)
;
journal_end
(
&
th
,
old_dir
->
i_sb
,
jbegin_count
)
;
unlock_kernel
();
return
retval
;
return
retval
;
}
}
...
@@ -1298,6 +1308,7 @@ static int reiserfs_rename (struct inode * old_dir, struct dentry *old_dentry,
...
@@ -1298,6 +1308,7 @@ static int reiserfs_rename (struct inode * old_dir, struct dentry *old_dentry,
pop_journal_writer
(
windex
)
;
pop_journal_writer
(
windex
)
;
journal_end
(
&
th
,
old_dir
->
i_sb
,
jbegin_count
)
;
journal_end
(
&
th
,
old_dir
->
i_sb
,
jbegin_count
)
;
unlock_kernel
();
return
0
;
return
0
;
}
}
...
...
fs/smbfs/dir.c
View file @
cb625b80
...
@@ -570,6 +570,7 @@ smb_rename(struct inode *old_dir, struct dentry *old_dentry,
...
@@ -570,6 +570,7 @@ smb_rename(struct inode *old_dir, struct dentry *old_dentry,
* Close any open files, and check whether to delete the
* Close any open files, and check whether to delete the
* target before attempting the rename.
* target before attempting the rename.
*/
*/
lock_kernel
();
if
(
old_dentry
->
d_inode
)
if
(
old_dentry
->
d_inode
)
smb_close
(
old_dentry
->
d_inode
);
smb_close
(
old_dentry
->
d_inode
);
if
(
new_dentry
->
d_inode
)
{
if
(
new_dentry
->
d_inode
)
{
...
@@ -592,5 +593,6 @@ smb_rename(struct inode *old_dir, struct dentry *old_dentry,
...
@@ -592,5 +593,6 @@ smb_rename(struct inode *old_dir, struct dentry *old_dentry,
smb_renew_times
(
new_dentry
);
smb_renew_times
(
new_dentry
);
}
}
out:
out:
unlock_kernel
();
return
error
;
return
error
;
}
}
fs/udf/namei.c
View file @
cb625b80
...
@@ -1167,6 +1167,7 @@ static int udf_rename (struct inode * old_dir, struct dentry * old_dentry,
...
@@ -1167,6 +1167,7 @@ static int udf_rename (struct inode * old_dir, struct dentry * old_dentry,
struct
buffer_head
*
dir_bh
=
NULL
;
struct
buffer_head
*
dir_bh
=
NULL
;
int
retval
=
-
ENOENT
;
int
retval
=
-
ENOENT
;
lock_kernel
();
if
((
ofi
=
udf_find_entry
(
old_dir
,
old_dentry
,
&
ofibh
,
&
ocfi
)))
if
((
ofi
=
udf_find_entry
(
old_dir
,
old_dentry
,
&
ofibh
,
&
ocfi
)))
{
{
if
(
ofibh
.
sbh
!=
ofibh
.
ebh
)
if
(
ofibh
.
sbh
!=
ofibh
.
ebh
)
...
@@ -1296,6 +1297,7 @@ static int udf_rename (struct inode * old_dir, struct dentry * old_dentry,
...
@@ -1296,6 +1297,7 @@ static int udf_rename (struct inode * old_dir, struct dentry * old_dentry,
udf_release_data
(
nfibh
.
ebh
);
udf_release_data
(
nfibh
.
ebh
);
udf_release_data
(
nfibh
.
sbh
);
udf_release_data
(
nfibh
.
sbh
);
}
}
unlock_kernel
();
return
retval
;
return
retval
;
}
}
...
...
fs/ufs/namei.c
View file @
cb625b80
...
@@ -282,6 +282,7 @@ static int ufs_rename (struct inode * old_dir, struct dentry * old_dentry,
...
@@ -282,6 +282,7 @@ static int ufs_rename (struct inode * old_dir, struct dentry * old_dentry,
struct
ufs_dir_entry
*
old_de
;
struct
ufs_dir_entry
*
old_de
;
int
err
=
-
ENOENT
;
int
err
=
-
ENOENT
;
lock_kernel
();
old_de
=
ufs_find_entry
(
old_dentry
,
&
old_bh
);
old_de
=
ufs_find_entry
(
old_dentry
,
&
old_bh
);
if
(
!
old_de
)
if
(
!
old_de
)
goto
out
;
goto
out
;
...
@@ -334,6 +335,7 @@ static int ufs_rename (struct inode * old_dir, struct dentry * old_dentry,
...
@@ -334,6 +335,7 @@ static int ufs_rename (struct inode * old_dir, struct dentry * old_dentry,
ufs_set_link
(
old_inode
,
dir_de
,
dir_bh
,
new_dir
);
ufs_set_link
(
old_inode
,
dir_de
,
dir_bh
,
new_dir
);
ufs_dec_count
(
old_dir
);
ufs_dec_count
(
old_dir
);
}
}
unlock_kernel
();
return
0
;
return
0
;
out_dir:
out_dir:
...
@@ -342,6 +344,7 @@ static int ufs_rename (struct inode * old_dir, struct dentry * old_dentry,
...
@@ -342,6 +344,7 @@ static int ufs_rename (struct inode * old_dir, struct dentry * old_dentry,
out_old:
out_old:
brelse
(
old_bh
);
brelse
(
old_bh
);
out:
out:
unlock_kernel
();
return
err
;
return
err
;
}
}
...
...
fs/vfat/namei.c
View file @
cb625b80
...
@@ -1199,6 +1199,7 @@ int vfat_rename(struct inode *old_dir,struct dentry *old_dentry,
...
@@ -1199,6 +1199,7 @@ int vfat_rename(struct inode *old_dir,struct dentry *old_dentry,
old_bh
=
new_bh
=
dotdot_bh
=
NULL
;
old_bh
=
new_bh
=
dotdot_bh
=
NULL
;
old_inode
=
old_dentry
->
d_inode
;
old_inode
=
old_dentry
->
d_inode
;
new_inode
=
new_dentry
->
d_inode
;
new_inode
=
new_dentry
->
d_inode
;
lock_kernel
();
res
=
vfat_find
(
old_dir
,
&
old_dentry
->
d_name
,
&
old_sinfo
,
&
old_bh
,
&
old_de
);
res
=
vfat_find
(
old_dir
,
&
old_dentry
->
d_name
,
&
old_sinfo
,
&
old_bh
,
&
old_de
);
PRINTK3
((
"vfat_rename 2
\n
"
));
PRINTK3
((
"vfat_rename 2
\n
"
));
if
(
res
<
0
)
goto
rename_done
;
if
(
res
<
0
)
goto
rename_done
;
...
@@ -1265,6 +1266,7 @@ int vfat_rename(struct inode *old_dir,struct dentry *old_dentry,
...
@@ -1265,6 +1266,7 @@ int vfat_rename(struct inode *old_dir,struct dentry *old_dentry,
fat_brelse
(
sb
,
dotdot_bh
);
fat_brelse
(
sb
,
dotdot_bh
);
fat_brelse
(
sb
,
old_bh
);
fat_brelse
(
sb
,
old_bh
);
fat_brelse
(
sb
,
new_bh
);
fat_brelse
(
sb
,
new_bh
);
unlock_kernel
();
return
res
;
return
res
;
}
}
...
...
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