Skip to content

Commit ce634ab

Browse files
dhowellsLinus Torvalds
authored andcommitted
iget: stop CIFS from using iget() and read_inode()
Stop the CIFS filesystem from using iget() and read_inode(). Replace cifs_read_inode() with cifs_iget(), and call that instead of iget(). cifs_iget() then uses iget_locked() directly and returns a proper error code instead of an inode in the event of an error. cifs_read_super() now returns any error incurred when getting the root inode instead of ENOMEM. cifs_iget() needs examining. The comment "can not call macro FreeXid here since in a void func" is no longer true. Signed-off-by: David Howells <[email protected]> Cc: Steven French <[email protected]> Acked-by: Christoph Hellwig <[email protected]> Signed-off-by: Andrew Morton <[email protected]> Signed-off-by: Linus Torvalds <[email protected]>
1 parent e33ab08 commit ce634ab

File tree

3 files changed

+24
-7
lines changed

3 files changed

+24
-7
lines changed

fs/cifs/cifsfs.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -147,10 +147,11 @@ cifs_read_super(struct super_block *sb, void *data,
147147
#endif
148148
sb->s_blocksize = CIFS_MAX_MSGSIZE;
149149
sb->s_blocksize_bits = 14; /* default 2**14 = CIFS_MAX_MSGSIZE */
150-
inode = iget(sb, ROOT_I);
150+
inode = cifs_iget(sb, ROOT_I);
151151

152-
if (!inode) {
153-
rc = -ENOMEM;
152+
if (IS_ERR(inode)) {
153+
rc = PTR_ERR(inode);
154+
inode = NULL;
154155
goto out_no_root;
155156
}
156157

@@ -520,7 +521,6 @@ static int cifs_remount(struct super_block *sb, int *flags, char *data)
520521
}
521522

522523
static const struct super_operations cifs_super_ops = {
523-
.read_inode = cifs_read_inode,
524524
.put_super = cifs_put_super,
525525
.statfs = cifs_statfs,
526526
.alloc_inode = cifs_alloc_inode,

fs/cifs/cifsfs.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ extern void cifs_read_inode(struct inode *);
4444

4545
/* Functions related to inodes */
4646
extern const struct inode_operations cifs_dir_inode_ops;
47+
extern struct inode *cifs_iget(struct super_block *, unsigned long);
4748
extern int cifs_create(struct inode *, struct dentry *, int,
4849
struct nameidata *);
4950
extern struct dentry *cifs_lookup(struct inode *, struct dentry *,

fs/cifs/inode.c

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -586,10 +586,18 @@ static const struct inode_operations cifs_ipc_inode_ops = {
586586
};
587587

588588
/* gets root inode */
589-
void cifs_read_inode(struct inode *inode)
589+
struct inode *cifs_iget(struct super_block *sb, unsigned long ino)
590590
{
591-
int xid, rc;
591+
int xid;
592592
struct cifs_sb_info *cifs_sb;
593+
struct inode *inode;
594+
long rc;
595+
596+
inode = iget_locked(sb, ino);
597+
if (!inode)
598+
return ERR_PTR(-ENOMEM);
599+
if (!(inode->i_state & I_NEW))
600+
return inode;
593601

594602
cifs_sb = CIFS_SB(inode->i_sb);
595603
xid = GetXid();
@@ -606,10 +614,18 @@ void cifs_read_inode(struct inode *inode)
606614
inode->i_fop = &simple_dir_operations;
607615
inode->i_uid = cifs_sb->mnt_uid;
608616
inode->i_gid = cifs_sb->mnt_gid;
617+
_FreeXid(xid);
618+
iget_failed(inode);
619+
return ERR_PTR(rc);
609620
}
610621

611-
/* can not call macro FreeXid here since in a void func */
622+
unlock_new_inode(inode);
623+
624+
/* can not call macro FreeXid here since in a void func
625+
* TODO: This is no longer true
626+
*/
612627
_FreeXid(xid);
628+
return inode;
613629
}
614630

615631
int cifs_unlink(struct inode *inode, struct dentry *direntry)

0 commit comments

Comments
 (0)