mirror of
https://github.com/torvalds/linux.git
synced 2024-11-22 12:11:40 +00:00
ext2_find_entry()/ext2_dotdot(): callers don't need page_addr anymore
... and that's how it should've been done in the first place Signed-off-by: Al Viro <viro@zeniv.linux.org.uk> Reviewed-by: Fabio M. De Francesco <fmdefrancesco@gmail.com> Tested-by: Fabio M. De Francesco <fmdefrancesco@gmail.com> Signed-off-by: Jan Kara <jack@suse.cz>
This commit is contained in:
parent
dae42837ba
commit
b8b9e8b35d
@ -339,8 +339,7 @@ ext2_readdir(struct file *file, struct dir_context *ctx)
|
|||||||
* should be treated as a call to ext2_get_page() for nesting purposes.
|
* should be treated as a call to ext2_get_page() for nesting purposes.
|
||||||
*/
|
*/
|
||||||
struct ext2_dir_entry_2 *ext2_find_entry (struct inode *dir,
|
struct ext2_dir_entry_2 *ext2_find_entry (struct inode *dir,
|
||||||
const struct qstr *child, struct page **res_page,
|
const struct qstr *child, struct page **res_page)
|
||||||
void **res_page_addr)
|
|
||||||
{
|
{
|
||||||
const char *name = child->name;
|
const char *name = child->name;
|
||||||
int namelen = child->len;
|
int namelen = child->len;
|
||||||
@ -350,27 +349,22 @@ struct ext2_dir_entry_2 *ext2_find_entry (struct inode *dir,
|
|||||||
struct page *page = NULL;
|
struct page *page = NULL;
|
||||||
struct ext2_inode_info *ei = EXT2_I(dir);
|
struct ext2_inode_info *ei = EXT2_I(dir);
|
||||||
ext2_dirent * de;
|
ext2_dirent * de;
|
||||||
void *page_addr;
|
|
||||||
|
|
||||||
if (npages == 0)
|
if (npages == 0)
|
||||||
goto out;
|
goto out;
|
||||||
|
|
||||||
/* OFFSET_CACHE */
|
/* OFFSET_CACHE */
|
||||||
*res_page = NULL;
|
*res_page = NULL;
|
||||||
*res_page_addr = NULL;
|
|
||||||
|
|
||||||
start = ei->i_dir_start_lookup;
|
start = ei->i_dir_start_lookup;
|
||||||
if (start >= npages)
|
if (start >= npages)
|
||||||
start = 0;
|
start = 0;
|
||||||
n = start;
|
n = start;
|
||||||
do {
|
do {
|
||||||
char *kaddr;
|
char *kaddr = ext2_get_page(dir, n, 0, &page);
|
||||||
|
if (IS_ERR(kaddr))
|
||||||
|
return ERR_CAST(kaddr);
|
||||||
|
|
||||||
page_addr = ext2_get_page(dir, n, 0, &page);
|
|
||||||
if (IS_ERR(page_addr))
|
|
||||||
return ERR_CAST(page_addr);
|
|
||||||
|
|
||||||
kaddr = page_addr;
|
|
||||||
de = (ext2_dirent *) kaddr;
|
de = (ext2_dirent *) kaddr;
|
||||||
kaddr += ext2_last_byte(dir, n) - reclen;
|
kaddr += ext2_last_byte(dir, n) - reclen;
|
||||||
while ((char *) de <= kaddr) {
|
while ((char *) de <= kaddr) {
|
||||||
@ -402,7 +396,6 @@ out:
|
|||||||
|
|
||||||
found:
|
found:
|
||||||
*res_page = page;
|
*res_page = page;
|
||||||
*res_page_addr = page_addr;
|
|
||||||
ei->i_dir_start_lookup = n;
|
ei->i_dir_start_lookup = n;
|
||||||
return de;
|
return de;
|
||||||
}
|
}
|
||||||
@ -419,26 +412,21 @@ found:
|
|||||||
* ext2_find_entry() and ext2_dotdot() act as a call to ext2_get_page() and
|
* ext2_find_entry() and ext2_dotdot() act as a call to ext2_get_page() and
|
||||||
* should be treated as a call to ext2_get_page() for nesting purposes.
|
* should be treated as a call to ext2_get_page() for nesting purposes.
|
||||||
*/
|
*/
|
||||||
struct ext2_dir_entry_2 *ext2_dotdot(struct inode *dir, struct page **p,
|
struct ext2_dir_entry_2 *ext2_dotdot(struct inode *dir, struct page **p)
|
||||||
void **pa)
|
|
||||||
{
|
{
|
||||||
void *page_addr = ext2_get_page(dir, 0, 0, p);
|
ext2_dirent *de = ext2_get_page(dir, 0, 0, p);
|
||||||
ext2_dirent *de = NULL;
|
|
||||||
|
|
||||||
if (!IS_ERR(page_addr)) {
|
if (!IS_ERR(de))
|
||||||
de = ext2_next_entry((ext2_dirent *) page_addr);
|
return ext2_next_entry(de);
|
||||||
*pa = page_addr;
|
return NULL;
|
||||||
}
|
|
||||||
return de;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int ext2_inode_by_name(struct inode *dir, const struct qstr *child, ino_t *ino)
|
int ext2_inode_by_name(struct inode *dir, const struct qstr *child, ino_t *ino)
|
||||||
{
|
{
|
||||||
struct ext2_dir_entry_2 *de;
|
struct ext2_dir_entry_2 *de;
|
||||||
struct page *page;
|
struct page *page;
|
||||||
void *page_addr;
|
|
||||||
|
|
||||||
de = ext2_find_entry(dir, child, &page, &page_addr);
|
de = ext2_find_entry(dir, child, &page);
|
||||||
if (IS_ERR(de))
|
if (IS_ERR(de))
|
||||||
return PTR_ERR(de);
|
return PTR_ERR(de);
|
||||||
|
|
||||||
@ -510,10 +498,9 @@ int ext2_add_link (struct dentry *dentry, struct inode *inode)
|
|||||||
* to protect that region.
|
* to protect that region.
|
||||||
*/
|
*/
|
||||||
for (n = 0; n <= npages; n++) {
|
for (n = 0; n <= npages; n++) {
|
||||||
char *kaddr;
|
char *kaddr = ext2_get_page(dir, n, 0, &page);
|
||||||
char *dir_end;
|
char *dir_end;
|
||||||
|
|
||||||
kaddr = ext2_get_page(dir, n, 0, &page);
|
|
||||||
if (IS_ERR(kaddr))
|
if (IS_ERR(kaddr))
|
||||||
return PTR_ERR(kaddr);
|
return PTR_ERR(kaddr);
|
||||||
lock_page(page);
|
lock_page(page);
|
||||||
|
@ -730,10 +730,10 @@ extern int ext2_inode_by_name(struct inode *dir,
|
|||||||
const struct qstr *child, ino_t *ino);
|
const struct qstr *child, ino_t *ino);
|
||||||
extern int ext2_make_empty(struct inode *, struct inode *);
|
extern int ext2_make_empty(struct inode *, struct inode *);
|
||||||
extern struct ext2_dir_entry_2 *ext2_find_entry(struct inode *, const struct qstr *,
|
extern struct ext2_dir_entry_2 *ext2_find_entry(struct inode *, const struct qstr *,
|
||||||
struct page **, void **res_page_addr);
|
struct page **);
|
||||||
extern int ext2_delete_entry(struct ext2_dir_entry_2 *dir, struct page *page);
|
extern int ext2_delete_entry(struct ext2_dir_entry_2 *dir, struct page *page);
|
||||||
extern int ext2_empty_dir (struct inode *);
|
extern int ext2_empty_dir (struct inode *);
|
||||||
extern struct ext2_dir_entry_2 *ext2_dotdot(struct inode *dir, struct page **p, void **pa);
|
extern struct ext2_dir_entry_2 *ext2_dotdot(struct inode *dir, struct page **p);
|
||||||
int ext2_set_link(struct inode *dir, struct ext2_dir_entry_2 *de,
|
int ext2_set_link(struct inode *dir, struct ext2_dir_entry_2 *de,
|
||||||
struct page *page, struct inode *inode, bool update_times);
|
struct page *page, struct inode *inode, bool update_times);
|
||||||
static inline void ext2_put_page(struct page *page, void *page_addr)
|
static inline void ext2_put_page(struct page *page, void *page_addr)
|
||||||
|
@ -269,19 +269,18 @@ out_dir:
|
|||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int ext2_unlink(struct inode * dir, struct dentry *dentry)
|
static int ext2_unlink(struct inode *dir, struct dentry *dentry)
|
||||||
{
|
{
|
||||||
struct inode * inode = d_inode(dentry);
|
struct inode *inode = d_inode(dentry);
|
||||||
struct ext2_dir_entry_2 * de;
|
struct ext2_dir_entry_2 *de;
|
||||||
struct page * page;
|
struct page *page;
|
||||||
void *page_addr;
|
|
||||||
int err;
|
int err;
|
||||||
|
|
||||||
err = dquot_initialize(dir);
|
err = dquot_initialize(dir);
|
||||||
if (err)
|
if (err)
|
||||||
goto out;
|
goto out;
|
||||||
|
|
||||||
de = ext2_find_entry(dir, &dentry->d_name, &page, &page_addr);
|
de = ext2_find_entry(dir, &dentry->d_name, &page);
|
||||||
if (IS_ERR(de)) {
|
if (IS_ERR(de)) {
|
||||||
err = PTR_ERR(de);
|
err = PTR_ERR(de);
|
||||||
goto out;
|
goto out;
|
||||||
@ -323,10 +322,8 @@ static int ext2_rename (struct mnt_idmap * idmap,
|
|||||||
struct inode * old_inode = d_inode(old_dentry);
|
struct inode * old_inode = d_inode(old_dentry);
|
||||||
struct inode * new_inode = d_inode(new_dentry);
|
struct inode * new_inode = d_inode(new_dentry);
|
||||||
struct page * dir_page = NULL;
|
struct page * dir_page = NULL;
|
||||||
void *dir_page_addr;
|
|
||||||
struct ext2_dir_entry_2 * dir_de = NULL;
|
struct ext2_dir_entry_2 * dir_de = NULL;
|
||||||
struct page * old_page;
|
struct page * old_page;
|
||||||
void *old_page_addr;
|
|
||||||
struct ext2_dir_entry_2 * old_de;
|
struct ext2_dir_entry_2 * old_de;
|
||||||
int err;
|
int err;
|
||||||
|
|
||||||
@ -341,20 +338,18 @@ static int ext2_rename (struct mnt_idmap * idmap,
|
|||||||
if (err)
|
if (err)
|
||||||
return err;
|
return err;
|
||||||
|
|
||||||
old_de = ext2_find_entry(old_dir, &old_dentry->d_name, &old_page,
|
old_de = ext2_find_entry(old_dir, &old_dentry->d_name, &old_page);
|
||||||
&old_page_addr);
|
|
||||||
if (IS_ERR(old_de))
|
if (IS_ERR(old_de))
|
||||||
return PTR_ERR(old_de);
|
return PTR_ERR(old_de);
|
||||||
|
|
||||||
if (S_ISDIR(old_inode->i_mode)) {
|
if (S_ISDIR(old_inode->i_mode)) {
|
||||||
err = -EIO;
|
err = -EIO;
|
||||||
dir_de = ext2_dotdot(old_inode, &dir_page, &dir_page_addr);
|
dir_de = ext2_dotdot(old_inode, &dir_page);
|
||||||
if (!dir_de)
|
if (!dir_de)
|
||||||
goto out_old;
|
goto out_old;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (new_inode) {
|
if (new_inode) {
|
||||||
void *page_addr;
|
|
||||||
struct page *new_page;
|
struct page *new_page;
|
||||||
struct ext2_dir_entry_2 *new_de;
|
struct ext2_dir_entry_2 *new_de;
|
||||||
|
|
||||||
@ -363,7 +358,7 @@ static int ext2_rename (struct mnt_idmap * idmap,
|
|||||||
goto out_dir;
|
goto out_dir;
|
||||||
|
|
||||||
new_de = ext2_find_entry(new_dir, &new_dentry->d_name,
|
new_de = ext2_find_entry(new_dir, &new_dentry->d_name,
|
||||||
&new_page, &page_addr);
|
&new_page);
|
||||||
if (IS_ERR(new_de)) {
|
if (IS_ERR(new_de)) {
|
||||||
err = PTR_ERR(new_de);
|
err = PTR_ERR(new_de);
|
||||||
goto out_dir;
|
goto out_dir;
|
||||||
|
Loading…
Reference in New Issue
Block a user