From mboxrd@z Thu Jan 1 00:00:00 1970 From: Shirish Pargaonkar Subject: Re: [linux-cifs-client][patch] utilize lookup intents to open in lookup Date: Thu, 9 Apr 2009 08:46:07 -0500 Message-ID: <4a4634330904090646v32f469f3g2303f64a75ff7389@mail.gmail.com> References: <4a4634330903310957j25bbefcibb28e09a3eaf0c10@mail.gmail.com> <4a4634330904011233q5423fb2bydafd445134fc0717@mail.gmail.com> <20090409085554.1648fed8@barsoom.rdu.redhat.com> Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: QUOTED-PRINTABLE Cc: "linux-cifs-client@lists.samba.org" , linux-fsdevel , Steve French , viro@zeniv.linux.org.uk, Trond Myklebust To: Jeff Layton Return-path: Received: from an-out-0708.google.com ([209.85.132.248]:10627 "EHLO an-out-0708.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752743AbZDINqL convert rfc822-to-8bit (ORCPT ); Thu, 9 Apr 2009 09:46:11 -0400 Received: by an-out-0708.google.com with SMTP id d14so561857and.1 for ; Thu, 09 Apr 2009 06:46:09 -0700 (PDT) In-Reply-To: <20090409085554.1648fed8@barsoom.rdu.redhat.com> Sender: linux-fsdevel-owner@vger.kernel.org List-ID: On Thu, Apr 9, 2009 at 7:55 AM, Jeff Layton wrote: > On Wed, 1 Apr 2009 14:33:23 -0500 > Shirish Pargaonkar wrote: > > Sorry I'm late. I know Steve has already committed this, but here are > some comments. Maybe we can fix them in a later patch... > >> diff --git a/fs/cifs/cifsglob.h b/fs/cifs/cifsglob.h >> index 9fbf4df..9a8368f 100644 >> --- a/fs/cifs/cifsglob.h >> +++ b/fs/cifs/cifsglob.h >> @@ -350,7 +350,7 @@ struct cifsFileInfo { >> =A0 =A0 =A0 bool invalidHandle:1; =A0 /* file closed via session abe= nd */ >> =A0 =A0 =A0 bool messageMode:1; =A0 =A0 /* for pipes: message vs byt= e mode */ >> =A0 =A0 =A0 atomic_t wrtPending; =A0 /* handle in use - defer close = */ >> - =A0 =A0 struct semaphore fh_sem; /* prevents reopen race after dea= d ses*/ >> + =A0 =A0 struct mutex fh_mutex; /* prevents reopen race after dead = ses*/ >> =A0 =A0 =A0 struct cifs_search_info srch_inf; >> =A0}; >> >> diff --git a/fs/cifs/dir.c b/fs/cifs/dir.c >> index f9b6f68..f473c73 100644 >> --- a/fs/cifs/dir.c >> +++ b/fs/cifs/dir.c >> @@ -129,12 +129,64 @@ cifs_bp_rename_retry: >> =A0 =A0 =A0 return full_path; >> =A0} >> >> +static void >> +cifs_fill_fileinfo(struct inode *newinode, __u16 fileHandle, >> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 struct cifsTconInfo *tcon,= bool write_only) >> +{ >> + =A0 =A0 int oplock =3D 0; >> + =A0 =A0 struct cifsFileInfo *pCifsFile; >> + =A0 =A0 struct cifsInodeInfo *pCifsInode; >> + >> + =A0 =A0 pCifsFile =3D kzalloc(sizeof(struct cifsFileInfo), GFP_KER= NEL); >> + >> + =A0 =A0 if (pCifsFile =3D=3D NULL) >> + =A0 =A0 =A0 =A0 =A0 =A0 return; >> + >> + =A0 =A0 if (oplockEnabled) >> + =A0 =A0 =A0 =A0 =A0 =A0 oplock =3D REQ_OPLOCK; >> + >> + =A0 =A0 pCifsFile->netfid =3D fileHandle; >> + =A0 =A0 pCifsFile->pid =3D current->tgid; >> + =A0 =A0 pCifsFile->pInode =3D newinode; >> + =A0 =A0 pCifsFile->invalidHandle =3D false; >> + =A0 =A0 pCifsFile->closePend =A0 =A0 =3D false; > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0^^^^^^^ > None of the other '=3D' are lined up. Why here? > >> + =A0 =A0 mutex_init(&pCifsFile->fh_mutex); >> + =A0 =A0 mutex_init(&pCifsFile->lock_mutex); >> + =A0 =A0 INIT_LIST_HEAD(&pCifsFile->llist); >> + =A0 =A0 atomic_set(&pCifsFile->wrtPending, 0); >> + >> + =A0 =A0 /* set the following in open now >> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 pCifsFile->pfile =3D file;= */ >> + =A0 =A0 write_lock(&GlobalSMBSeslock); >> + =A0 =A0 list_add(&pCifsFile->tlist, &tcon->openFileList); >> + =A0 =A0 pCifsInode =3D CIFS_I(newinode); >> + =A0 =A0 if (pCifsInode) { >> + =A0 =A0 =A0 =A0 =A0 =A0 /* if readable file instance put first in = list*/ >> + =A0 =A0 =A0 =A0 =A0 =A0 if (write_only) { >> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 list_add_tail(&pCifsFile->= flist, >> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0= &pCifsInode->openFileList); >> + =A0 =A0 =A0 =A0 =A0 =A0 } else { >> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 list_add(&pCifsFile->flist= , >> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0&pCifsI= node->openFileList); >> + =A0 =A0 =A0 =A0 =A0 =A0 } > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0^^^^^^^^ > Are these brackets needed? > >> + =A0 =A0 =A0 =A0 =A0 =A0 if ((oplock & 0xF) =3D=3D OPLOCK_EXCLUSIVE= ) { >> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 pCifsInode->clientCanCache= All =3D true; >> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 pCifsInode->clientCanCache= Read =3D true; >> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 cFYI(1, ("Exclusive Oplock= inode %p", >> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 newinode))= ; >> + =A0 =A0 =A0 =A0 =A0 =A0 } else if ((oplock & 0xF) =3D=3D OPLOCK_RE= AD) >> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 pCifsInode->clientCanCache= Read =3D true; >> + =A0 =A0 } > > Ditto =A0 =A0 =A0 =A0 =A0 ^^^^^^^^^ >> + =A0 =A0 write_unlock(&GlobalSMBSeslock); >> +} >> + >> =A0int cifs_posix_open(char *full_path, struct inode **pinode, >> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 struct super_block *sb, int mode= , int oflags, >> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 int *poplock, __u16 *pnetfid, in= t xid) >> =A0{ >> =A0 =A0 =A0 int rc; >> =A0 =A0 =A0 __u32 oplock; >> + =A0 =A0 bool write_only =3D false; >> =A0 =A0 =A0 FILE_UNIX_BASIC_INFO *presp_data; >> =A0 =A0 =A0 __u32 posix_flags =3D 0; >> =A0 =A0 =A0 struct cifs_sb_info *cifs_sb =3D CIFS_SB(sb); >> @@ -172,6 +224,8 @@ int cifs_posix_open(char *full_path, struct inod= e **pinode, >> =A0 =A0 =A0 if (oflags & O_DIRECT) >> =A0 =A0 =A0 =A0 =A0 =A0 =A0 posix_flags |=3D SMB_O_DIRECT; >> >> + =A0 =A0 if (!(oflags & FMODE_READ)) >> + =A0 =A0 =A0 =A0 =A0 =A0 write_only =3D true; >> >> =A0 =A0 =A0 rc =3D CIFSPOSIXCreate(xid, cifs_sb->tcon, posix_flags, = mode, >> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 pnetfid, presp_data, &op= lock, full_path, >> @@ -198,6 +252,8 @@ int cifs_posix_open(char *full_path, struct inod= e **pinode, >> >> =A0 =A0 =A0 posix_fill_in_inode(*pinode, presp_data, 1); >> >> + =A0 =A0 cifs_fill_fileinfo(*pinode, *pnetfid, cifs_sb->tcon, write= _only); >> + >> =A0posix_open_ret: >> =A0 =A0 =A0 kfree(presp_data); >> =A0 =A0 =A0 return rc; >> @@ -239,7 +295,6 @@ cifs_create(struct inode *inode, struct dentry *= direntry, int mode, >> =A0 =A0 =A0 char *full_path =3D NULL; >> =A0 =A0 =A0 FILE_ALL_INFO *buf =3D NULL; >> =A0 =A0 =A0 struct inode *newinode =3D NULL; >> - =A0 =A0 struct cifsInodeInfo *pCifsInode; >> =A0 =A0 =A0 int disposition =3D FILE_OVERWRITE_IF; >> =A0 =A0 =A0 bool write_only =3D false; >> >> @@ -410,44 +465,8 @@ cifs_create_set_dentry: >> =A0 =A0 =A0 =A0 =A0 =A0 =A0 /* mknod case - do not leave file open *= / >> =A0 =A0 =A0 =A0 =A0 =A0 =A0 CIFSSMBClose(xid, tcon, fileHandle); >> =A0 =A0 =A0 } else if (newinode) { >> - =A0 =A0 =A0 =A0 =A0 =A0 struct cifsFileInfo *pCifsFile =3D >> - =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 kzalloc(sizeof(struct cifs= =46ileInfo), GFP_KERNEL); >> - >> - =A0 =A0 =A0 =A0 =A0 =A0 if (pCifsFile =3D=3D NULL) >> - =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 goto cifs_create_out; >> - =A0 =A0 =A0 =A0 =A0 =A0 pCifsFile->netfid =3D fileHandle; >> - =A0 =A0 =A0 =A0 =A0 =A0 pCifsFile->pid =3D current->tgid; >> - =A0 =A0 =A0 =A0 =A0 =A0 pCifsFile->pInode =3D newinode; >> - =A0 =A0 =A0 =A0 =A0 =A0 pCifsFile->invalidHandle =3D false; >> - =A0 =A0 =A0 =A0 =A0 =A0 pCifsFile->closePend =A0 =A0 =3D false; >> - =A0 =A0 =A0 =A0 =A0 =A0 init_MUTEX(&pCifsFile->fh_sem); >> - =A0 =A0 =A0 =A0 =A0 =A0 mutex_init(&pCifsFile->lock_mutex); >> - =A0 =A0 =A0 =A0 =A0 =A0 INIT_LIST_HEAD(&pCifsFile->llist); >> - =A0 =A0 =A0 =A0 =A0 =A0 atomic_set(&pCifsFile->wrtPending, 0); >> - >> - =A0 =A0 =A0 =A0 =A0 =A0 /* set the following in open now >> - =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 pCifsFile-= >pfile =3D file; */ >> - =A0 =A0 =A0 =A0 =A0 =A0 write_lock(&GlobalSMBSeslock); >> - =A0 =A0 =A0 =A0 =A0 =A0 list_add(&pCifsFile->tlist, &tcon->openFil= eList); >> - =A0 =A0 =A0 =A0 =A0 =A0 pCifsInode =3D CIFS_I(newinode); >> - =A0 =A0 =A0 =A0 =A0 =A0 if (pCifsInode) { >> - =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 /* if readable file instan= ce put first in list*/ >> - =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 if (write_only) { >> - =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 list_add_t= ail(&pCifsFile->flist, >> - =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0= =A0 =A0 =A0 =A0 &pCifsInode->openFileList); >> - =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 } else { >> - =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 list_add(&= pCifsFile->flist, >> - =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0= =A0 =A0&pCifsInode->openFileList); >> - =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 } >> - =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 if ((oplock & 0xF) =3D=3D = OPLOCK_EXCLUSIVE) { >> - =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 pCifsInode= ->clientCanCacheAll =3D true; >> - =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 pCifsInode= ->clientCanCacheRead =3D true; >> - =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 cFYI(1, ("= Exclusive Oplock inode %p", >> - =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0= =A0 newinode)); >> - =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 } else if ((oplock & 0xF) = =3D=3D OPLOCK_READ) >> - =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 pCifsInode= ->clientCanCacheRead =3D true; >> - =A0 =A0 =A0 =A0 =A0 =A0 } >> - =A0 =A0 =A0 =A0 =A0 =A0 write_unlock(&GlobalSMBSeslock); >> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 cifs_fill_fileinfo(newinod= e, fileHandle, >> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0= =A0 cifs_sb->tcon, write_only); >> =A0 =A0 =A0 } >> =A0cifs_create_out: >> =A0 =A0 =A0 kfree(buf); >> @@ -580,17 +599,21 @@ int cifs_mknod(struct inode *inode, struct den= try *direntry, int mode, >> =A0 =A0 =A0 return rc; >> =A0} >> >> - >> =A0struct dentry * >> =A0cifs_lookup(struct inode *parent_dir_inode, struct dentry *dirent= ry, >> =A0 =A0 =A0 =A0 =A0 struct nameidata *nd) >> =A0{ >> =A0 =A0 =A0 int xid; >> =A0 =A0 =A0 int rc =3D 0; /* to get around spurious gcc warning, set= to zero here */ >> + =A0 =A0 int oplock =3D 0; >> + =A0 =A0 int mode; >> + =A0 =A0 __u16 fileHandle =3D 0; >> + =A0 =A0 bool posix_open =3D false; >> =A0 =A0 =A0 struct cifs_sb_info *cifs_sb; >> =A0 =A0 =A0 struct cifsTconInfo *pTcon; >> =A0 =A0 =A0 struct inode *newInode =3D NULL; >> =A0 =A0 =A0 char *full_path =3D NULL; >> + =A0 =A0 struct file *filp; >> >> =A0 =A0 =A0 xid =3D GetXid(); >> >> @@ -632,12 +655,27 @@ cifs_lookup(struct inode *parent_dir_inode, st= ruct dentry *direntry, >> =A0 =A0 =A0 } >> =A0 =A0 =A0 cFYI(1, ("Full path: %s inode =3D 0x%p", full_path, dire= ntry->d_inode)); >> >> - =A0 =A0 if (pTcon->unix_ext) >> - =A0 =A0 =A0 =A0 =A0 =A0 rc =3D cifs_get_inode_info_unix(&newInode,= full_path, >> - =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0= =A0 =A0 =A0 =A0 parent_dir_inode->i_sb, xid); >> - =A0 =A0 else >> + =A0 =A0 if (pTcon->unix_ext) { >> + =A0 =A0 =A0 =A0 =A0 =A0 if (!(nd->flags & (LOOKUP_PARENT | LOOKUP_= DIRECTORY)) && >> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 (nd->flags= & LOOKUP_OPEN)) { >> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 if (!((nd->intent.open.fla= gs & O_CREAT) && >> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0= =A0 (nd->intent.open.flags & O_EXCL))) { >> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 mode =3D n= d->intent.open.create_mode & >> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0= =A0 =A0 =A0 =A0 =A0 ~current->fs->umask; >> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 rc =3D cif= s_posix_open(full_path, &newInode, >> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0= =A0 parent_dir_inode->i_sb, mode, >> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0= =A0 nd->intent.open.flags, &oplock, >> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0= =A0 &fileHandle, xid); >> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 if ((rc !=3D= -EINVAL) && (rc !=3D -EOPNOTSUPP)) > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0= =A0 =A0^^^^^^^^^^^^^^^^^^^^^^^^^^^^ > This looks wrong to me. =A0It's possible that you'd get a different > return code here on an unsuccessful open call? Why would we want to > instantiate the filp on any error from cifs_posix_open? For instance, > that function can return -ENOMEM. I don't think we want to instantiat= e > the filp in that case. Jeff, Thanks, will handle the identation/formatting errors in a subsequent pa= tch for sure. If there is any other error code returned besides these two error codes= , it is handled as an error, so file pointer will not be instantiated (as posix_open will be true). These two errors are there to handle the bug in samba posix open and if either of these error codes are returned, cifs_lookup does what it had been doing (as posix_open will be false),. > > Maybe that should just be: "if (!rc)" ? > >> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0= =A0 posix_open =3D true; >> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 } >> + =A0 =A0 =A0 =A0 =A0 =A0 } >> + =A0 =A0 =A0 =A0 =A0 =A0 if (!posix_open) >> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 rc =3D cifs_get_inode_info= _unix(&newInode, full_path, >> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0= =A0 =A0 =A0 =A0 =A0 parent_dir_inode->i_sb, xid); >> + =A0 =A0 } else >> =A0 =A0 =A0 =A0 =A0 =A0 =A0 rc =3D cifs_get_inode_info(&newInode, fu= ll_path, NULL, >> - =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0= =A0 =A0parent_dir_inode->i_sb, xid, NULL); >> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 parent_dir= _inode->i_sb, xid, NULL); >> >> =A0 =A0 =A0 if ((rc =3D=3D 0) && (newInode !=3D NULL)) { >> =A0 =A0 =A0 =A0 =A0 =A0 =A0 if (pTcon->nocase) >> @@ -645,7 +683,8 @@ cifs_lookup(struct inode *parent_dir_inode, stru= ct dentry *direntry, >> =A0 =A0 =A0 =A0 =A0 =A0 =A0 else >> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 direntry->d_op =3D &cifs= _dentry_ops; >> =A0 =A0 =A0 =A0 =A0 =A0 =A0 d_add(direntry, newInode); >> - >> + =A0 =A0 =A0 =A0 =A0 =A0 if (posix_open) >> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 filp =3D lookup_instantiat= e_filp(nd, direntry, NULL); >> =A0 =A0 =A0 =A0 =A0 =A0 =A0 /* since paths are not looked up by comp= onent - the parent >> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0directories are presumed to be go= od here */ >> =A0 =A0 =A0 =A0 =A0 =A0 =A0 renew_parental_timestamps(direntry); >> diff --git a/fs/cifs/file.c b/fs/cifs/file.c >> index 81747ac..c3f51de 100644 >> --- a/fs/cifs/file.c >> +++ b/fs/cifs/file.c >> @@ -46,7 +46,7 @@ static inline struct cifsFileInfo *cifs_init_priva= te( >> =A0 =A0 =A0 memset(private_data, 0, sizeof(struct cifsFileInfo)); >> =A0 =A0 =A0 private_data->netfid =3D netfid; >> =A0 =A0 =A0 private_data->pid =3D current->tgid; >> - =A0 =A0 init_MUTEX(&private_data->fh_sem); >> + =A0 =A0 mutex_init(&private_data->fh_mutex); >> =A0 =A0 =A0 mutex_init(&private_data->lock_mutex); >> =A0 =A0 =A0 INIT_LIST_HEAD(&private_data->llist); >> =A0 =A0 =A0 private_data->pfile =3D file; /* needed for writepage */ >> @@ -284,35 +284,34 @@ int cifs_open(struct inode *inode, struct file= *file) >> =A0 =A0 =A0 cifs_sb =3D CIFS_SB(inode->i_sb); >> =A0 =A0 =A0 tcon =3D cifs_sb->tcon; >> >> - =A0 =A0 if (file->f_flags & O_CREAT) { >> - =A0 =A0 =A0 =A0 =A0 =A0 /* search inode for this file and fill in = file->private_data */ >> - =A0 =A0 =A0 =A0 =A0 =A0 pCifsInode =3D CIFS_I(file->f_path.dentry-= >d_inode); >> - =A0 =A0 =A0 =A0 =A0 =A0 read_lock(&GlobalSMBSeslock); >> - =A0 =A0 =A0 =A0 =A0 =A0 list_for_each(tmp, &pCifsInode->openFileLi= st) { >> - =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 pCifsFile =3D list_entry(t= mp, struct cifsFileInfo, >> - =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0= =A0 =A0 =A0 =A0 =A0flist); >> - =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 if ((pCifsFile->pfile =3D=3D= NULL) && >> - =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 (pCifsFile->pid =3D= =3D current->tgid)) { >> - =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 /* mode se= t in cifs_create */ >> - >> - =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 /* needed = for writepage */ >> - =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 pCifsFile-= >pfile =3D file; >> - >> - =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 file->priv= ate_data =3D pCifsFile; >> - =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 break; >> - =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 } >> - =A0 =A0 =A0 =A0 =A0 =A0 } >> - =A0 =A0 =A0 =A0 =A0 =A0 read_unlock(&GlobalSMBSeslock); >> - =A0 =A0 =A0 =A0 =A0 =A0 if (file->private_data !=3D NULL) { >> - =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 rc =3D 0; >> - =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 FreeXid(xid); >> - =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 return rc; >> - =A0 =A0 =A0 =A0 =A0 =A0 } else { >> - =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 if (file->f_flags & O_EXCL= ) >> - =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 cERROR(1, = ("could not find file instance for " >> - =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0= =A0 =A0 =A0"new file %p", file)); >> + =A0 =A0 /* search inode for this file and fill in file->private_da= ta */ >> + =A0 =A0 pCifsInode =3D CIFS_I(file->f_path.dentry->d_inode); >> + =A0 =A0 read_lock(&GlobalSMBSeslock); >> + =A0 =A0 list_for_each(tmp, &pCifsInode->openFileList) { >> + =A0 =A0 =A0 =A0 =A0 =A0 pCifsFile =3D list_entry(tmp, struct cifsF= ileInfo, >> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0= =A0flist); >> + =A0 =A0 =A0 =A0 =A0 =A0 if ((pCifsFile->pfile =3D=3D NULL) && >> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 (pCifsFile->pid =3D=3D current->tg= id)) { >> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 /* mode set in cifs_create= */ >> + >> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 /* needed for writepage */ >> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 pCifsFile->pfile =3D file; >> + >> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 file->private_data =3D pCi= fsFile; >> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 break; >> =A0 =A0 =A0 =A0 =A0 =A0 =A0 } >> =A0 =A0 =A0 } >> + =A0 =A0 read_unlock(&GlobalSMBSeslock); >> + >> + =A0 =A0 if (file->private_data !=3D NULL) { >> + =A0 =A0 =A0 =A0 =A0 =A0 rc =3D 0; >> + =A0 =A0 =A0 =A0 =A0 =A0 FreeXid(xid); >> + =A0 =A0 =A0 =A0 =A0 =A0 return rc; >> + =A0 =A0 } else { >> + =A0 =A0 =A0 =A0 =A0 =A0 if ((file->f_flags & O_CREAT) && (file->f_= flags & O_EXCL)) > > =A0 =A0 =A0 =A0^^^^^ how about "else if" here and reduce the indentat= ion below? > >> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 cERROR(1, ("could not find= file instance for " >> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0"ne= w file %p", file)); >> + =A0 =A0 } >> >> =A0 =A0 =A0 full_path =3D build_path_from_dentry(file->f_path.dentry= ); >> =A0 =A0 =A0 if (full_path =3D=3D NULL) { >> @@ -500,9 +499,9 @@ static int cifs_reopen_file(struct file *file, b= ool can_flush) >> =A0 =A0 =A0 =A0 =A0 =A0 =A0 return -EBADF; >> >> =A0 =A0 =A0 xid =3D GetXid(); >> - =A0 =A0 down(&pCifsFile->fh_sem); >> + =A0 =A0 mutex_unlock(&pCifsFile->fh_mutex); >> =A0 =A0 =A0 if (!pCifsFile->invalidHandle) { >> - =A0 =A0 =A0 =A0 =A0 =A0 up(&pCifsFile->fh_sem); >> + =A0 =A0 =A0 =A0 =A0 =A0 mutex_lock(&pCifsFile->fh_mutex); >> =A0 =A0 =A0 =A0 =A0 =A0 =A0 FreeXid(xid); >> =A0 =A0 =A0 =A0 =A0 =A0 =A0 return 0; >> =A0 =A0 =A0 } >> @@ -533,7 +532,7 @@ static int cifs_reopen_file(struct file *file, b= ool can_flush) >> =A0 =A0 =A0 if (full_path =3D=3D NULL) { >> =A0 =A0 =A0 =A0 =A0 =A0 =A0 rc =3D -ENOMEM; >> =A0reopen_error_exit: >> - =A0 =A0 =A0 =A0 =A0 =A0 up(&pCifsFile->fh_sem); >> + =A0 =A0 =A0 =A0 =A0 =A0 mutex_lock(&pCifsFile->fh_mutex); >> =A0 =A0 =A0 =A0 =A0 =A0 =A0 FreeXid(xid); >> =A0 =A0 =A0 =A0 =A0 =A0 =A0 return rc; >> =A0 =A0 =A0 } >> @@ -575,14 +574,14 @@ reopen_error_exit: >> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0cifs_sb->local_nls, c= ifs_sb->mnt_cifs_flags & >> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 CIFS_MOU= NT_MAP_SPECIAL_CHR); >> =A0 =A0 =A0 if (rc) { >> - =A0 =A0 =A0 =A0 =A0 =A0 up(&pCifsFile->fh_sem); >> + =A0 =A0 =A0 =A0 =A0 =A0 mutex_lock(&pCifsFile->fh_mutex); >> =A0 =A0 =A0 =A0 =A0 =A0 =A0 cFYI(1, ("cifs_open returned 0x%x", rc))= ; >> =A0 =A0 =A0 =A0 =A0 =A0 =A0 cFYI(1, ("oplock: %d", oplock)); >> =A0 =A0 =A0 } else { >> =A0reopen_success: >> =A0 =A0 =A0 =A0 =A0 =A0 =A0 pCifsFile->netfid =3D netfid; >> =A0 =A0 =A0 =A0 =A0 =A0 =A0 pCifsFile->invalidHandle =3D false; >> - =A0 =A0 =A0 =A0 =A0 =A0 up(&pCifsFile->fh_sem); >> + =A0 =A0 =A0 =A0 =A0 =A0 mutex_lock(&pCifsFile->fh_mutex); >> =A0 =A0 =A0 =A0 =A0 =A0 =A0 pCifsInode =3D CIFS_I(inode); >> =A0 =A0 =A0 =A0 =A0 =A0 =A0 if (pCifsInode) { >> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 if (can_flush) { > > > -- > Jeff Layton > -- To unsubscribe from this list: send the line "unsubscribe linux-fsdevel= " in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html