CIFS: Simplify non-posix open stuff
Subsystems (2)
PATCH 1/2 CIFS: Simplify non-posix open stuff
Delete cifs_open_inode_helper and move non-posix open related things to cifs_nt_open function.
--- fs/cifs/cifsproto.h | 4 + fs/cifs/file.c | 184 +++++++++++++++++++-------------------------------- 2 files changed, 72 insertions(+), 116 deletions(-)
fs/cifs/cifsproto.h +4 -0
@@ -113,6 +113,10 @@ extern int cifs_posix_open(char *full_path, struct inode **pinode,struct super_block *sb, int mode, unsigned int f_flags, __u32 *poplock, __u16 *pnetfid, int xid); +extern int cifs_nt_open (char *full_path,struct inode **pinode, +struct cifs_sb_info *cifs_sb,struct cifsTconInfo *tcon, +unsigned int f_flags,__u32 *poplock,__u16 *pnetfid, +int xid);void cifs_fill_uniqueid (struct super_block *sb,struct cifs_fattr *fattr); extern void cifs_unix_basic_to_fattr(struct cifs_fattr *fattr, FILE_UNIX_BASIC_INFO *info,
fs/cifs/file.c +68 -116
215 lines not on this page · raw message
Signature · 1 line
1.7.0.4
A message that is not in the archive (sent off-list or not yet received): 1290696298-5204-1-git-send-email-piastryyy-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org
PATCH 2/2 CIFS: Simplify cifs_open code
Make the code more general for use in posix and non-posix open.
--- fs/cifs/file.c | 54 +++++++++++++++++++++++------------------------------- 1 files changed, 23 insertions(+), 31 deletions(-)
fs/cifs/file.c +23 -31
@@ -335,6 +335,7 @@ int cifs_open(struct inode *inode, struct file *file)struct cifsFileInfo *pCifsFile =NULL ;struct cifsInodeInfo *pCifsInode;char *full_path =NULL ; +bool posix_open_ok = false;__u16 netfid; xid =GetXid ();
@@ -373,17 +374,7 @@ int cifs_open(struct inode *inode, struct file *file) file->f_flags, &oplock, &netfid, xid);if (rc ==0 ) {cFYI (1 ,"posix open succeeded" ); - - pCifsFile =cifs_new_fileinfo (netfid, file, tlink, - oplock); -if (pCifsFile ==NULL ) { -CIFSSMBClose (xid, tcon, netfid); - rc = -ENOMEM ; - } - -cifs_fscache_set_inode_cookie (inode, file); - - goto out; + posix_open_ok = true; }else if ((rc == -EINVAL ) || (rc == -EOPNOTSUPP )) {if (tcon->ses->serverNOS) cERROR(1, "server %s of type %s returned"
@@ -400,37 +391,38 @@ int cifs_open(struct inode *inode, struct file *file)or DFS errors */ } - rc =cifs_nt_open (full_path, &inode, cifs_sb, tcon, file->f_flags, - &oplock, &netfid, xid); -if (rc) - goto out; +if (!posix_open_ok) { + rc =cifs_nt_open (full_path, &inode, cifs_sb, tcon, + file->f_flags, &oplock, &netfid, xid); +if (rc) + goto out; + } pCifsFile =cifs_new_fileinfo (netfid, file, tlink, oplock);if (pCifsFile ==NULL ) { +CIFSSMBClose (xid, tcon, netfid); rc = -ENOMEM ; goto out; }cifs_fscache_set_inode_cookie (inode, file); -if (oplock &CIFS_CREATE_ACTION ) { +if ((oplock &CIFS_CREATE_ACTION ) && !posix_open_ok && tcon->unix_ext) {/* time to set mode which we can not set earlier due to problems creating new read-only files */ -if (tcon->unix_ext) { -struct cifs_unix_set_info_args args = { - .mode = inode->i_mode, - .uid =NO_CHANGE_64 , - .gid =NO_CHANGE_64 , - .ctime =NO_CHANGE_64 , - .atime =NO_CHANGE_64 , - .mtime =NO_CHANGE_64 , - .device =0 , - }; -CIFSSMBUnixSetPathInfo (xid, tcon, full_path, &args, - cifs_sb->local_nls, - cifs_sb->mnt_cifs_flags & -CIFS_MOUNT_MAP_SPECIAL_CHR ); - } +struct cifs_unix_set_info_args args = { + .mode = inode->i_mode, + .uid =NO_CHANGE_64 , + .gid =NO_CHANGE_64 , + .ctime =NO_CHANGE_64 , + .atime =NO_CHANGE_64 , + .mtime =NO_CHANGE_64 , + .device =0 , + }; +CIFSSMBUnixSetPathInfo (xid, tcon, full_path, &args, + cifs_sb->local_nls, + cifs_sb->mnt_cifs_flags & +CIFS_MOUNT_MAP_SPECIAL_CHR ); } out:
Signature · 1 line
1.7.0.4
A message that is not in the archive (sent off-list or not yet received): 1290696298-5204-2-git-send-email-piastryyy-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org
Re: [PATCH 2/2] CIFS: Simplify cifs_open code
2010/11/25 Pavel Shilovsky <[email protected]>:
Quoted 96 lines
Make the code more general for use in posix and non-posix open.
Signed-off-by Pavel Shilovsky <[email protected]>---
fs/cifs/file.c | 54 +++++++++++++++++++++++-------------------------------1 files changed, 23 insertions(+), 31 deletions(-)fs/cifs/file.c +2
-11@@ -335,6 +335,7 @@ int cifs_open(struct inode *inode, struct file *file) struct cifsFileInfo *pCifsFile = NULL; struct cifsInodeInfo *pCifsInode; char *full_path = NULL; + bool posix_open_ok = false; __u16 netfid; xid = GetXid();@@ -373,17 +374,7 @@ int cifs_open(struct inode *inode, struct file *file) file->f_flags, &oplock, &netfid, xid); if (rc == 0) { cFYI(1, "posix open succeeded"); - - pCifsFile = cifs_new_fileinfo(netfid, file, tlink, - oplock); - if (pCifsFile == NULL) { - CIFSSMBClose(xid, tcon, netfid); - rc = -ENOMEM; - } - - cifs_fscache_set_inode_cookie(inode, file); - - goto out; + posix_open_ok = true; } else if ((rc == -EINVAL) || (rc == -EOPNOTSUPP)) { if (tcon->ses->serverNOS)cERROR(1, "server %s of type %s returned"
fs/cifs/file.c +0
-0@@ -400,37 +391,38 @@ int cifs_open(struct inode *inode, struct file *file)or DFS errors */
}- rc = cifs_nt_open(full_path, &inode,
cifs_sb, tcon,file->f_flags,
- &oplock, &netfid, xid);
- if (rc)
- goto out;
+ if (!posix_open_ok) {
+ rc = cifs_nt_open(full_path, &inode,cifs_sb, tcon,
+file->f_flags, &oplock, &netfid, xid);
+ if (rc)
+ goto out;
+ }pCifsFile =
cifs_new_fileinfo(netfid, file, tlink, oplock); if (pCifsFile == NULL) {
+CIFSSMBClose(xid, tcon, netfid);
rc =-ENOMEM;
goto out;
}cifs_fscache_set_inode_cookie(inode, file);
- if (oplock &
CIFS_CREATE_ACTION) {
+ if ((oplock &CIFS_CREATE_ACTION) && !posix_open_ok &&tcon->unix_ext) { /* time to set mode which we can not set earlier due to problems creating new read-only files */
- if (tcon->unix_ext) {
- structcifs_unix_set_info_argsargs = {
- .mode =inode->i_mode,
- .uid =NO_CHANGE_64,
- .gid =NO_CHANGE_64,
- .ctime =NO_CHANGE_64,
- .atime =NO_CHANGE_64,
- .mtime =NO_CHANGE_64,
- .device = 0,
- };
- CIFSSMBUnixSetPathInfo(xid, tcon,full_path, &args,
- cifs_sb->local_nls,
- cifs_sb->mnt_cifs_flags &
-CIFS_MOUNT_MAP_SPECIAL_CHR);
- }
+ structcifs_unix_set_info_argsargs = {
+ .mode =inode->i_mode,
+ .uid =NO_CHANGE_64,
+ .gid =NO_CHANGE_64,
+ .ctime =NO_CHANGE_64,
+ .atime =NO_CHANGE_64,
+ .mtime =NO_CHANGE_64,
+ .device = 0,
+ };
+ CIFSSMBUnixSetPathInfo(xid, tcon,full_path, &args,
+ cifs_sb->local_nls,
+ cifs_sb->mnt_cifs_flags &
+CIFS_MOUNT_MAP_SPECIAL_CHR); }
Quoted 5 lines
out:
--
1.7.0.4
Since I have reviewed patch number 1 ([PATCH 1/2] CIFS: Simplify non-posix open stuff (try #2)) could you review this one, please?
Signature · 2 lines
Best regards, Pavel Shilovsky.
A message that is not in the archive (sent off-list or not yet received): AANLkTi=5Fixa9piVpqWc5ZmNA0ZeTwRRXsUZQwU=b-9h-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org
Re: [PATCH 2/2] CIFS: Simplify cifs_open code
2010/12/8 Pavel Shilovsky <[email protected]>:
Quoted 2 lines
Since I have reviewed patch number 1 ([PATCH 1/2] CIFS: Simplify
Since I have patch number 1 reviewed (sorry for typying mistake here)
Quoted 2 lines
non-posix open stuff (try #2)) could you review this one, please?
Signature · 2 lines
Best regards, Pavel Shilovsky.
Jeff Layton
Reviewed-byRe: [PATCH 2/2] CIFS: Simplify cifs_open code
In reply to a message not in the archiveQuoted 84 lines · On Thu, 25 Nov 2010 17:44:58 +0300 Pavel Shilovsky…
Make the code more general for use in posix and non-posix open.
Signed-off-by Pavel Shilovsky <[email protected]>--- fs/cifs/file.c | 54 +++++++++++++++++++++++------------------------------- 1 files changed, 23 insertions(+), 31 deletions(-)fs/cifs/file.c +13
-31@@ -335,6 +335,7 @@ int cifs_open(struct inode *inode, struct file *file)struct cifsFileInfo *pCifsFile =NULL ;struct cifsInodeInfo *pCifsInode;char *full_path =NULL ; +bool posix_open_ok = false;__u16 netfid; xid =GetXid ();@@ -373,17 +374,7 @@ int cifs_open(struct inode *inode, struct file *file) file->f_flags, &oplock, &netfid, xid);if (rc ==0 ) {cFYI (1 ,"posix open succeeded" ); - - pCifsFile =cifs_new_fileinfo (netfid, file, tlink, - oplock); -if (pCifsFile ==NULL ) { -CIFSSMBClose (xid, tcon, netfid); - rc = -ENOMEM ; - } - -cifs_fscache_set_inode_cookie (inode, file); - - goto out; + posix_open_ok = true; }else if ((rc == -EINVAL ) || (rc == -EOPNOTSUPP )) {if (tcon->ses->serverNOS) cERROR(1, "server %s of type %s returned"@@ -400,37 +391,38 @@ int cifs_open(struct inode *inode, struct file *file)or DFS errors */ } - rc =cifs_nt_open (full_path, &inode, cifs_sb, tcon, file->f_flags, - &oplock, &netfid, xid); -if (rc) - goto out; +if (!posix_open_ok) { + rc =cifs_nt_open (full_path, &inode, cifs_sb, tcon, + file->f_flags, &oplock, &netfid, xid); +if (rc) + goto out; + } pCifsFile =cifs_new_fileinfo (netfid, file, tlink, oplock);if (pCifsFile ==NULL ) { +CIFSSMBClose (xid, tcon, netfid); rc = -ENOMEM ; goto out; }cifs_fscache_set_inode_cookie (inode, file); -if (oplock &CIFS_CREATE_ACTION ) { +if ((oplock &CIFS_CREATE_ACTION ) && !posix_open_ok && tcon->unix_ext) {/* time to set mode which we can not set earlier due to problems creating new read-only files */ -if (tcon->unix_ext) { -struct cifs_unix_set_info_args args = { - .mode = inode->i_mode, - .uid =NO_CHANGE_64 , - .gid =NO_CHANGE_64 , - .ctime =NO_CHANGE_64 , - .atime =NO_CHANGE_64 , - .mtime =NO_CHANGE_64 , - .device =0 , - }; -CIFSSMBUnixSetPathInfo (xid, tcon, full_path, &args, - cifs_sb->local_nls, - cifs_sb->mnt_cifs_flags & -CIFS_MOUNT_MAP_SPECIAL_CHR ); - } +struct cifs_unix_set_info_args args = { + .mode = inode->i_mode, + .uid =NO_CHANGE_64 ,
fs/cifs/file.c int cifs_open(struct inode *inode, struct file *file) · line 425
Quoted 10 lines
fs/cifs/file.c +10
-0+ .gid = NO_CHANGE_64, + .ctime = NO_CHANGE_64, + .atime = NO_CHANGE_64, + .mtime = NO_CHANGE_64, + .device = 0, + }; +CIFSSMBUnixSetPathInfo (xid, tcon, full_path, &args, + cifs_sb->local_nls, + cifs_sb->mnt_cifs_flags & +CIFS_MOUNT_MAP_SPECIAL_CHR );
Hmm...we have a fid so we probably ought to switch the above call to a SetFileInfo call. That's outside the scope of this patch though.
fs/cifs/file.c int cifs_open(struct inode *inode, struct file *file) · line 428
Quoted 3 lines
fs/cifs/file.c +0
-0} out:
Looks good to me. Nice cleanup.
Quoted 14 lines · On Thu, 25 Nov 2010 17:44:57 +0300 Pavel Shilovsky…
Delete
cifs_open_inode_helperand move non-posix open related things tocifs_nt_openfunction.Signed-off-by Pavel Shilovsky <[email protected]>--- fs/cifs/cifsproto.h | 4 + fs/cifs/file.c | 184 +++++++++++++++++++-------------------------------- 2 files changed, 72 insertions(+), 116 deletions(-)fs/cifs/cifsproto.h +0
-0
fs/cifs/cifsproto.h extern int cifs_posix_open(char *full_path, struct inode **pinode, · line 119
Quoted 7 lines
fs/cifs/cifsproto.h +4
-0@@ -113,6 +113,10 @@ extern int cifs_posix_open(char *full_path, struct inode **pinode,struct super_block *sb, int mode, unsigned int f_flags, __u32 *poplock, __u16 *pnetfid, int xid); +extern int cifs_nt_open (char *full_path,struct inode **pinode, +struct cifs_sb_info *cifs_sb,struct cifsTconInfo *tcon, +unsigned int f_flags,__u32 *poplock,__u16 *pnetfid, +int xid);
If the only place this gets called is in file.c then you can drop the above and make the function static.
Quoted 115 lines
fs/cifs/cifsproto.h +0
-0void cifs_fill_uniqueid (struct super_block *sb,struct cifs_fattr *fattr); extern void cifs_unix_basic_to_fattr(struct cifs_fattr *fattr, FILE_UNIX_BASIC_INFO *info,fs/cifs/file.c +50
-47@@ -104,53 +104,6 @@ static inline int cifs_get_disposition(unsigned int flags)return FILE_OPEN ; } -static inline int cifs_open_inode_helper (struct inode *inode, -struct cifsTconInfo *pTcon,__u32 oplock,FILE_ALL_INFO *buf, -char *full_path,int xid) -{ -struct cifsInodeInfo *pCifsInode =CIFS_I (inode); -struct timespec temp; -int rc; - -if (pCifsInode->clientCanCacheRead) { -/* we have the inode open somewhere else -no need to discard cache data */ - goto client_can_cache; - } - -/* BB need same check in cifs_create too? */ -/* if not oplocked, invalidate inode pages if mtime or file -size changed */ - temp =cifs_NTtimeToUnix (buf->LastWriteTime); -if (timespec_equal (&inode->i_mtime, &temp) && - (inode->i_size == - (loff_t )le64_to_cpu (buf->EndOfFile))) { -cFYI (1 ,"inode unchanged on server" ); - }else { -if (inode->i_mapping) { -/* BB no need to lock inode until after invalidate -since namei code should already have it locked? */ - rc =filemap_write_and_wait (inode->i_mapping); -mapping_set_error (inode->i_mapping, rc); - } -cFYI (1 ,"invalidating remote inode since open detected it " -"changed" ); -invalidate_remote_inode (inode); - } - -client_can_cache: -if (pTcon->unix_ext) - rc =cifs_get_inode_info_unix (&inode, full_path, inode->i_sb, - xid); -else - rc =cifs_get_inode_info (&inode, full_path, buf, inode->i_sb, - xid,NULL ); - -cifs_set_oplock_level (pCifsInode, oplock); - -return rc; -} -int cifs_posix_open (char *full_path,struct inode **pinode,struct super_block *sb,int mode,unsigned int f_flags,__u32 *poplock,__u16 *pnetfid,int xid)@@ -213,6 +166,71 @@ posix_open_ret:return rc; } +int cifs_nt_open (char *full_path,struct inode **pinode, +struct cifs_sb_info *cifs_sb,struct cifsTconInfo *tcon, +unsigned int f_flags,__u32 *poplock,__u16 *pnetfid,int xid) +{ +int rc; +int desiredAccess; +int disposition; +FILE_ALL_INFO *buf; + + desiredAccess =cifs_convert_flags (f_flags); + +/********************************************************************* +* open flag mapping table: +* +* POSIX Flag CIFS Disposition +* ---------- ---------------- +* O_CREAT FILE_OPEN_IF +* O_CREAT | O_EXCL FILE_CREATE +* O_CREAT | O_TRUNC FILE_OVERWRITE_IF +* O_TRUNC FILE_OVERWRITE +* none of the above FILE_OPEN +* +* Note that there is not a direct match between disposition +* FILE_SUPERSEDE (ie create whether or not file exists although +* O_CREAT | O_TRUNC is similar but truncates the existing +* file rather than creating a new file as FILE_SUPERSEDE does +* (which uses the attributes / metadata passed in on open call) +*? +*? O_SYNC is a reasonable match to CIFS writethrough flag +*? and the read write flags match reasonably. O_LARGEFILE +*? is irrelevant because largefile support is always used +*? by this client. Flags O_APPEND, O_DIRECT, O_DIRECTORY, +* O_FASYNC, O_NOFOLLOW, O_NONBLOCK need further investigation +*********************************************************************/ + + disposition =cifs_get_disposition (f_flags); + +/* BB pass O_SYNC flag through on file attributes .. BB */ + + buf =kmalloc (sizeof (FILE_ALL_INFO ),GFP_KERNEL ); +if (!buf) +return -ENOMEM ; + +if (tcon->ses->capabilities &CAP_NT_SMBS ) + rc =CIFSSMBOpen (xid, tcon, full_path, disposition, + desiredAccess,CREATE_NOT_DIR , pnetfid, poplock, buf, + cifs_sb->local_nls, cifs_sb->mnt_cifs_flags + &CIFS_MOUNT_MAP_SPECIAL_CHR ); +else + rc = SMBLegacyOpen(xid, tcon, full_path, disposition,
fs/cifs/file.c posix_open_ret: · line 228
Quoted 10 lines
fs/cifs/file.c +10
-0+ desiredAccess,CREATE_NOT_DIR , pnetfid, poplock, buf, + cifs_sb->local_nls, cifs_sb->mnt_cifs_flags + & CIFS_MOUNT_MAP_SPECIAL_CHR); + +if (rc) + goto out; + + rc =cifs_get_inode_info (pinode, full_path, buf, (*pinode)->i_sb, + xid,NULL ); +
Can "*pinode" ever be NULL here? If not, then it would be clearer to pass in a "struct inode *" rather than a "struct inode **". If it can be NULL, then the above is going to cause an oops.
Quoted 102 lines
fs/cifs/file.c +8
-69+out: +kfree (buf); +return rc; +} +struct cifsFileInfo *cifs_new_fileinfo (__u16 fileHandle,struct file *file,struct tcon_link *tlink,__u32 oplock)@@ -317,10 +335,7 @@ int cifs_open(struct inode *inode, struct file *file)struct cifsFileInfo *pCifsFile =NULL ;struct cifsInodeInfo *pCifsInode;char *full_path =NULL ; -int desiredAccess; -int disposition;__u16 netfid; -FILE_ALL_INFO *buf =NULL ; xid =GetXid ();@@ -385,71 +400,9 @@ int cifs_open(struct inode *inode, struct file *file)or DFS errors */ } - desiredAccess =cifs_convert_flags (file->f_flags); - -/********************************************************************* -* open flag mapping table: -* -* POSIX Flag CIFS Disposition -* ---------- ---------------- -* O_CREAT FILE_OPEN_IF -* O_CREAT | O_EXCL FILE_CREATE -* O_CREAT | O_TRUNC FILE_OVERWRITE_IF -* O_TRUNC FILE_OVERWRITE -* none of the above FILE_OPEN -* -* Note that there is not a direct match between disposition -* FILE_SUPERSEDE (ie create whether or not file exists although -* O_CREAT | O_TRUNC is similar but truncates the existing -* file rather than creating a new file as FILE_SUPERSEDE does -* (which uses the attributes / metadata passed in on open call) -*? -*? O_SYNC is a reasonable match to CIFS writethrough flag -*? and the read write flags match reasonably. O_LARGEFILE -*? is irrelevant because largefile support is always used -*? by this client. Flags O_APPEND, O_DIRECT, O_DIRECTORY, -* O_FASYNC, O_NOFOLLOW, O_NONBLOCK need further investigation -*********************************************************************/ - - disposition =cifs_get_disposition (file->f_flags); - -/* BB pass O_SYNC flag through on file attributes .. BB */ - -/* Also refresh inode by passing in file_info buf returned by SMBOpen -and calling get_inode_info with returned buf (at least helps -non-Unix server case) */ - -/* BB we can not do this if this is the second open of a file -and the first handle has writebehind data, we might be -able to simply do a filemap_fdatawrite/filemap_fdatawait first */ - buf =kmalloc (sizeof (FILE_ALL_INFO ),GFP_KERNEL ); -if (!buf) { - rc = -ENOMEM ; - goto out; - } - -if (tcon->ses->capabilities &CAP_NT_SMBS ) - rc =CIFSSMBOpen (xid, tcon, full_path, disposition, - desiredAccess,CREATE_NOT_DIR , &netfid, &oplock, buf, - cifs_sb->local_nls, cifs_sb->mnt_cifs_flags - &CIFS_MOUNT_MAP_SPECIAL_CHR ); -else - rc = -EIO ;/* no NT SMB support fall into legacy open below */ - -if (rc == -EIO ) { -/* Old server, try legacy style OpenX */ - rc =SMBLegacyOpen (xid, tcon, full_path, disposition, - desiredAccess,CREATE_NOT_DIR , &netfid, &oplock, buf, - cifs_sb->local_nls, cifs_sb->mnt_cifs_flags - &CIFS_MOUNT_MAP_SPECIAL_CHR ); - } -if (rc) { -cFYI (1 ,"cifs_open returned 0x%x" , rc); - goto out; - } - - rc =cifs_open_inode_helper (inode, tcon, oplock, buf, full_path, xid); -if (rc !=0 ) + rc =cifs_nt_open (full_path, &inode, cifs_sb, tcon, file->f_flags, + &oplock, &netfid, xid); +if (rc) goto out; pCifsFile =cifs_new_fileinfo (netfid, file, tlink, oplock);@@ -481,7 +434,6 @@ int cifs_open(struct inode *inode, struct file *file) } out: -kfree (buf);kfree (full_path);FreeXid (xid);cifs_put_tlink (tlink);
Signature · 1 line
Jeff Layton <[email protected]>
A message that is not in the archive (sent off-list or not yet received): 20101127073753.44e1f20b-9yPaYZwiELC+kQycOl6kW4xkIHaj4LzF@public.gmane.org
2010/11/27 Jeff Layton <[email protected]>:
Quoted 149 lines
Quoted 14 lines · On Thu, 25 Nov 2010 17:44:57 +0300 Pavel Shilovsky…
Delete
cifs_open_inode_helperand move non-posix open related things tocifs_nt_openfunction.Signed-off-by Pavel Shilovsky <[email protected]>---
fs/cifs/cifsproto.h | 4 +
fs/cifs/file.c | 184 +++++++++++++++++++--------------------------------2 files changed, 72 insertions(+), 116 deletions(-)fs/cifs/cifsproto.h +0
-0fs/cifs/cifsproto.h extern int cifs_posix_open(char *full_path, struct inode **pinode, · line 119
Quoted 7 lines
fs/cifs/cifsproto.h +4
-0@@ -113,6 +113,10 @@ extern int cifs_posix_open(char *full_path, struct inode **pinode, struct super_block *sb, int mode, unsigned int f_flags, __u32 *poplock, __u16 *pnetfid, int xid); +extern int cifs_nt_open (char *full_path,struct inode **pinode, + struct cifs_sb_info *cifs_sb, struct cifsTconInfo *tcon, + unsigned int f_flags, __u32 *poplock, __u16 *pnetfid, + int xid);If the only place this gets called is in
file.cthen you can drop the above and make the function static.Quoted 121 lines
fs/cifs/cifsproto.h +0
-0void cifs_fill_uniqueid(struct super_block *sb, struct cifs_fattr *fattr); extern void cifs_unix_basic_to_fattr(struct cifs_fattr *fattr, FILE_UNIX_BASIC_INFO *info,fs/cifs/file.c +56
-47@@ -104,53 +104,6 @@ static inline int cifs_get_disposition(unsigned int flags) return FILE_OPEN; } -static inline int cifs_open_inode_helper (struct inode *inode, - struct cifsTconInfo *pTcon, __u32 oplock, FILE_ALL_INFO *buf, - char *full_path, int xid) -{ - struct cifsInodeInfo *pCifsInode = CIFS_I(inode); - struct timespec temp; - int rc; - - if (pCifsInode->clientCanCacheRead) { - /* we have the inode open somewhere else - no need to discard cache data */ - goto client_can_cache; - } - - /* BB need same check in cifs_create too? */ - /* if not oplocked, invalidate inode pages if mtime or file - size changed */ - temp = cifs_NTtimeToUnix(buf->LastWriteTime); - if (timespec_equal(&inode->i_mtime, &temp) && - (inode->i_size == - (loff_t)le64_to_cpu(buf->EndOfFile))) { - cFYI(1, "inode unchanged on server"); - } else { - if (inode->i_mapping) { - /* BB no need to lock inode until after invalidate - since namei code should already have it locked? */ - rc = filemap_write_and_wait(inode->i_mapping); - mapping_set_error(inode->i_mapping, rc); - } - cFYI(1, "invalidating remote inode since open detected it " - "changed"); - invalidate_remote_inode(inode); - } - -client_can_cache: - if (pTcon->unix_ext) - rc = cifs_get_inode_info_unix(&inode, full_path, inode->i_sb, - xid); - else - rc = cifs_get_inode_info(&inode, full_path, buf, inode->i_sb, - xid, NULL); - - cifs_set_oplock_level(pCifsInode, oplock); - - return rc; -} - int cifs_posix_open(char *full_path, struct inode **pinode, struct super_block *sb, int mode, unsigned int f_flags, __u32 *poplock, __u16 *pnetfid, int xid)@@ -213,6 +166,71 @@ posix_open_ret: return rc; } +int cifs_nt_open (char *full_path,struct inode **pinode, + struct cifs_sb_info *cifs_sb, struct cifsTconInfo *tcon, + unsigned int f_flags, __u32 *poplock, __u16 *pnetfid, int xid) +{ + int rc; + int desiredAccess; + int disposition; + FILE_ALL_INFO *buf; + + desiredAccess = cifs_convert_flags(f_flags); + +/********************************************************************* +* open flag mapping table: +* +* POSIX Flag CIFS Disposition +* ---------- ---------------- +* O_CREAT FILE_OPEN_IF +* O_CREAT | O_EXCL FILE_CREATE +* O_CREAT | O_TRUNC FILE_OVERWRITE_IF +* O_TRUNC FILE_OVERWRITE +* none of the above FILE_OPEN +* +* Note that there is not a direct match between disposition +* FILE_SUPERSEDE (ie create whether or not file exists although +* O_CREAT | O_TRUNC is similar but truncates the existing +* file rather than creating a new file as FILE_SUPERSEDE does +* (which uses the attributes / metadata passed in on open call) +*? +*? O_SYNC is a reasonable match to CIFS writethrough flag +*? and the read write flags match reasonably. O_LARGEFILE +*? is irrelevant because largefile support is always used +*? by this client. Flags O_APPEND, O_DIRECT, O_DIRECTORY, +* O_FASYNC, O_NOFOLLOW, O_NONBLOCK need further investigation +*********************************************************************/ + + disposition = cifs_get_disposition(f_flags); + + /* BB pass O_SYNC flag through on file attributes .. BB */ + + buf = kmalloc(sizeof(FILE_ALL_INFO), GFP_KERNEL); + if (!buf) + return -ENOMEM; + + if (tcon->ses->capabilities & CAP_NT_SMBS) + rc = CIFSSMBOpen(xid, tcon, full_path, disposition, + desiredAccess, CREATE_NOT_DIR, pnetfid, poplock, buf, + cifs_sb->local_nls, cifs_sb->mnt_cifs_flags + & CIFS_MOUNT_MAP_SPECIAL_CHR); + else + rc = SMBLegacyOpen(xid, tcon, full_path, disposition, + desiredAccess, CREATE_NOT_DIR, pnetfid, poplock, buf, + cifs_sb->local_nls, cifs_sb->mnt_cifs_flags + & CIFS_MOUNT_MAP_SPECIAL_CHR); + + if (rc) + goto out;
Quoted 8 lines
fs/cifs/file.c posix_open_ret: · line 228
Quoted 4 lines
fs/cifs/file.c +4
-0+ + rc = cifs_get_inode_info(pinode, full_path, buf, (*pinode)->i_sb, + xid, NULL); +Can "*pinode" ever be NULL here? If not, then it would be clearer to pass in a "struct inode *" rather than a "struct inode **". If it can be NULL, then the above is going to cause an oops.
I think no, at least because we have "cifs_sb = CIFS_SB(inode->i_sb);" at the top of cifs_open code. I will replace it with struct inode *.
Quoted 108 lines
Quoted 98 lines
fs/cifs/file.c +5
-0+out: + kfree(buf); + return rc; +} +struct cifsFileInfo *
cifs_new_fileinfo(__u16 fileHandle, struct file *file, structtcon_link*tlink,__u32oplock)fs/cifs/file.c +0
-3@@ -317,10 +335,7 @@ int cifs_open(struct inode *inode, struct file *file) struct cifsFileInfo *pCifsFile = NULL; struct cifsInodeInfo *pCifsInode; char *full_path = NULL; - int desiredAccess; - int disposition; __u16 netfid; - FILE_ALL_INFO *buf = NULL; xid = GetXid();@@ -385,71 +400,9 @@ int cifs_open(struct inode *inode, struct file *file)or DFS errors */
}- desiredAccess =
cifs_convert_flags(file->f_flags);fs/cifs/file.c +3
-64- -/********************************************************************* -* open flag mapping table: -* -* POSIX Flag CIFS Disposition -* ---------- ---------------- -* O_CREAT FILE_OPEN_IF -* O_CREAT | O_EXCL FILE_CREATE -* O_CREAT | O_TRUNC FILE_OVERWRITE_IF -* O_TRUNC FILE_OVERWRITE -* none of the above FILE_OPEN -* -* Note that there is not a direct match between disposition -* FILE_SUPERSEDE (ie create whether or not file exists although -* O_CREAT | O_TRUNC is similar but truncates the existing -* file rather than creating a new file as FILE_SUPERSEDE does -* (which uses the attributes / metadata passed in on open call) -*? -*? O_SYNC is a reasonable match to CIFS writethrough flag -*? and the read write flags match reasonably. O_LARGEFILE -*? is irrelevant because largefile support is always used -*? by this client. Flags O_APPEND, O_DIRECT, O_DIRECTORY, -* O_FASYNC, O_NOFOLLOW, O_NONBLOCK need further investigation -*********************************************************************/ - - disposition = cifs_get_disposition(file->f_flags); - - /* BB pass O_SYNC flag through on file attributes .. BB */ - - /* Also refresh inode by passing in file_info buf returned by SMBOpen - and calling get_inode_info with returned buf (at least helps - non-Unix server case) */ - - /* BB we can not do this if this is the second open of a file - and the first handle has writebehind data, we might be - able to simply do a filemap_fdatawrite/filemap_fdatawait first */ - buf = kmalloc(sizeof(FILE_ALL_INFO), GFP_KERNEL); - if (!buf) { - rc = -ENOMEM; - goto out; - } - - if (tcon->ses->capabilities & CAP_NT_SMBS) - rc = CIFSSMBOpen(xid, tcon, full_path, disposition, - desiredAccess, CREATE_NOT_DIR, &netfid, &oplock, buf, - cifs_sb->local_nls, cifs_sb->mnt_cifs_flags - & CIFS_MOUNT_MAP_SPECIAL_CHR); - else - rc = -EIO; /* no NT SMB support fall into legacy open below */ - - if (rc == -EIO) { - /* Old server, try legacy style OpenX */ - rc = SMBLegacyOpen(xid, tcon, full_path, disposition, - desiredAccess, CREATE_NOT_DIR, &netfid, &oplock, buf, - cifs_sb->local_nls, cifs_sb->mnt_cifs_flags - & CIFS_MOUNT_MAP_SPECIAL_CHR); - } - if (rc) { - cFYI(1, "cifs_open returned 0x%x", rc); - goto out; - } - - rc = cifs_open_inode_helper(inode, tcon, oplock, buf, full_path, xid); - if (rc != 0) + rc = cifs_nt_open(full_path, &inode, cifs_sb, tcon, file->f_flags, + &oplock, &netfid, xid); + if (rc)goto out;
pCifsFile =
cifs_new_fileinfo(netfid, file, tlink, oplock);fs/cifs/file.c +0
-0@@ -481,7 +434,6 @@ int cifs_open(struct inode *inode, struct file *file) }Quoted 5 lines
out:
- kfree(buf);
kfree(full_path);
FreeXid(xid);
cifs_put_tlink(tlink);--
Jeff Layton <[email protected]>
Signature · 2 lines
Best regards, Pavel Shilovsky.
Quoted 135 lines · Pavel Shilovsky
Delete
cifs_open_inode_helperand move non-posix open related things tocifs_nt_openfunction.Signed-off-by Pavel Shilovsky <[email protected]>---
fs/cifs/cifsproto.h | 4 +
fs/cifs/file.c | 184 +++++++++++++++++++--------------------------------2 files changed, 72 insertions(+), 116 deletions(-)fs/cifs/cifsproto.h +4
-0@@ -113,6 +113,10 @@ extern int cifs_posix_open(char *full_path, struct inode **pinode, struct super_block *sb, int mode, unsigned int f_flags, __u32 *poplock, __u16 *pnetfid, int xid); +extern int cifs_nt_open (char *full_path,struct inode **pinode, + struct cifs_sb_info *cifs_sb, struct cifsTconInfo *tcon, + unsigned int f_flags, __u32 *poplock, __u16 *pnetfid, + int xid); void cifs_fill_uniqueid(struct super_block *sb, struct cifs_fattr *fattr); extern void cifs_unix_basic_to_fattr(struct cifs_fattr *fattr, FILE_UNIX_BASIC_INFO *info,fs/cifs/file.c +49
-47@@ -104,53 +104,6 @@ static inline int cifs_get_disposition(unsigned int flags) return FILE_OPEN; } -static inline int cifs_open_inode_helper (struct inode *inode, - struct cifsTconInfo *pTcon, __u32 oplock, FILE_ALL_INFO *buf, - char *full_path, int xid) -{ - struct cifsInodeInfo *pCifsInode = CIFS_I(inode); - struct timespec temp; - int rc; - - if (pCifsInode->clientCanCacheRead) { - /* we have the inode open somewhere else - no need to discard cache data */ - goto client_can_cache; - } - - /* BB need same check in cifs_create too? */ - /* if not oplocked, invalidate inode pages if mtime or file - size changed */ - temp = cifs_NTtimeToUnix(buf->LastWriteTime); - if (timespec_equal(&inode->i_mtime, &temp) && - (inode->i_size == - (loff_t)le64_to_cpu(buf->EndOfFile))) { - cFYI(1, "inode unchanged on server"); - } else { - if (inode->i_mapping) { - /* BB no need to lock inode until after invalidate - since namei code should already have it locked? */ - rc = filemap_write_and_wait(inode->i_mapping); - mapping_set_error(inode->i_mapping, rc); - } - cFYI(1, "invalidating remote inode since open detected it " - "changed"); - invalidate_remote_inode(inode); - } - -client_can_cache: - if (pTcon->unix_ext) - rc = cifs_get_inode_info_unix(&inode, full_path, inode->i_sb, - xid); - else - rc = cifs_get_inode_info(&inode, full_path, buf, inode->i_sb, - xid, NULL); - - cifs_set_oplock_level(pCifsInode, oplock); - - return rc; -} - int cifs_posix_open(char *full_path, struct inode **pinode, struct super_block *sb, int mode, unsigned int f_flags, __u32 *poplock, __u16 *pnetfid, int xid)@@ -213,6 +166,71 @@ posix_open_ret: return rc; } +int cifs_nt_open (char *full_path,struct inode **pinode, + struct cifs_sb_info *cifs_sb, struct cifsTconInfo *tcon, + unsigned int f_flags, __u32 *poplock, __u16 *pnetfid, int xid) +{ + int rc; + int desiredAccess; + int disposition; + FILE_ALL_INFO *buf; + + desiredAccess = cifs_convert_flags(f_flags); + +/********************************************************************* +* open flag mapping table: +* +* POSIX Flag CIFS Disposition +* ---------- ---------------- +* O_CREAT FILE_OPEN_IF +* O_CREAT | O_EXCL FILE_CREATE +* O_CREAT | O_TRUNC FILE_OVERWRITE_IF +* O_TRUNC FILE_OVERWRITE +* none of the above FILE_OPEN +* +* Note that there is not a direct match between disposition +* FILE_SUPERSEDE (ie create whether or not file exists although +* O_CREAT | O_TRUNC is similar but truncates the existing +* file rather than creating a new file as FILE_SUPERSEDE does +* (which uses the attributes / metadata passed in on open call) +*? +*? O_SYNC is a reasonable match to CIFS writethrough flag +*? and the read write flags match reasonably. O_LARGEFILE +*? is irrelevant because largefile support is always used +*? by this client. Flags O_APPEND, O_DIRECT, O_DIRECTORY, +* O_FASYNC, O_NOFOLLOW, O_NONBLOCK need further investigation +*********************************************************************/ + + disposition = cifs_get_disposition(f_flags); + + /* BB pass O_SYNC flag through on file attributes .. BB */ + + buf = kmalloc(sizeof(FILE_ALL_INFO), GFP_KERNEL); + if (!buf) + return -ENOMEM; + + if (tcon->ses->capabilities & CAP_NT_SMBS) + rc = CIFSSMBOpen(xid, tcon, full_path, disposition, + desiredAccess, CREATE_NOT_DIR, pnetfid, poplock, buf, + cifs_sb->local_nls, cifs_sb->mnt_cifs_flags + & CIFS_MOUNT_MAP_SPECIAL_CHR); + else
fs/cifs/file.c posix_open_ret: · line 227
Quoted 10 lines
fs/cifs/file.c +10
-0+ rc = SMBLegacyOpen(xid, tcon, full_path, disposition, + desiredAccess, CREATE_NOT_DIR, pnetfid, poplock, buf, + cifs_sb->local_nls, cifs_sb->mnt_cifs_flags + & CIFS_MOUNT_MAP_SPECIAL_CHR); + + if (rc) + goto out; + + rc = cifs_get_inode_info(pinode, full_path, buf, (*pinode)->i_sb, + xid, NULL);
I think netfid should be passed to cifs_get_inode_info.
Quoted 111 lines
fs/cifs/file.c +6
-0+ +out: + kfree(buf); + return rc; +} +struct cifsFileInfo *
cifs_new_fileinfo(__u16 fileHandle, struct file *file, structtcon_link*tlink,__u32oplock)fs/cifs/file.c +0
-3@@ -317,10 +335,7 @@ int cifs_open(struct inode *inode, struct file *file) struct cifsFileInfo *pCifsFile = NULL; struct cifsInodeInfo *pCifsInode; char *full_path = NULL; - int desiredAccess; - int disposition; __u16 netfid; - FILE_ALL_INFO *buf = NULL; xid = GetXid();@@ -385,71 +400,9 @@ int cifs_open(struct inode *inode, struct file *file)or DFS errors */
}- desiredAccess =
cifs_convert_flags(file->f_flags);fs/cifs/file.c +3
-64- -/********************************************************************* -* open flag mapping table: -* -* POSIX Flag CIFS Disposition -* ---------- ---------------- -* O_CREAT FILE_OPEN_IF -* O_CREAT | O_EXCL FILE_CREATE -* O_CREAT | O_TRUNC FILE_OVERWRITE_IF -* O_TRUNC FILE_OVERWRITE -* none of the above FILE_OPEN -* -* Note that there is not a direct match between disposition -* FILE_SUPERSEDE (ie create whether or not file exists although -* O_CREAT | O_TRUNC is similar but truncates the existing -* file rather than creating a new file as FILE_SUPERSEDE does -* (which uses the attributes / metadata passed in on open call) -*? -*? O_SYNC is a reasonable match to CIFS writethrough flag -*? and the read write flags match reasonably. O_LARGEFILE -*? is irrelevant because largefile support is always used -*? by this client. Flags O_APPEND, O_DIRECT, O_DIRECTORY, -* O_FASYNC, O_NOFOLLOW, O_NONBLOCK need further investigation -*********************************************************************/ - - disposition = cifs_get_disposition(file->f_flags); - - /* BB pass O_SYNC flag through on file attributes .. BB */ - - /* Also refresh inode by passing in file_info buf returned by SMBOpen - and calling get_inode_info with returned buf (at least helps - non-Unix server case) */ - - /* BB we can not do this if this is the second open of a file - and the first handle has writebehind data, we might be - able to simply do a filemap_fdatawrite/filemap_fdatawait first */ - buf = kmalloc(sizeof(FILE_ALL_INFO), GFP_KERNEL); - if (!buf) { - rc = -ENOMEM; - goto out; - } - - if (tcon->ses->capabilities & CAP_NT_SMBS) - rc = CIFSSMBOpen(xid, tcon, full_path, disposition, - desiredAccess, CREATE_NOT_DIR, &netfid, &oplock, buf, - cifs_sb->local_nls, cifs_sb->mnt_cifs_flags - & CIFS_MOUNT_MAP_SPECIAL_CHR); - else - rc = -EIO; /* no NT SMB support fall into legacy open below */ - - if (rc == -EIO) { - /* Old server, try legacy style OpenX */ - rc = SMBLegacyOpen(xid, tcon, full_path, disposition, - desiredAccess, CREATE_NOT_DIR, &netfid, &oplock, buf, - cifs_sb->local_nls, cifs_sb->mnt_cifs_flags - & CIFS_MOUNT_MAP_SPECIAL_CHR); - } - if (rc) { - cFYI(1, "cifs_open returned 0x%x", rc); - goto out; - } - - rc = cifs_open_inode_helper(inode, tcon, oplock, buf, full_path, xid); - if (rc != 0) + rc = cifs_nt_open(full_path, &inode, cifs_sb, tcon, file->f_flags, + &oplock, &netfid, xid); + if (rc)goto out;
pCifsFile =
cifs_new_fileinfo(netfid, file, tlink, oplock);fs/cifs/file.c +0
-0@@ -481,7 +434,6 @@ int cifs_open(struct inode *inode, struct file *file) }out:
- kfree(buf);
kfree(full_path);
FreeXid(xid);
cifs_put_tlink(tlink);
--
1.7.0.4--
To unsubscribe from this list: send the line "unsubscribe linux-cifs" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
A message that is not in the archive (sent off-list or not yet received): AANLkTimd-f-X4Y6QZOOKZyg4mDhYezyRuyW_1j6ffZbP-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org
2010/11/27 Shirish Pargaonkar <[email protected]>:
Quoted 140 lines · Pavel Shilovsky
Quoted 139 lines
Delete
cifs_open_inode_helperand move non-posix open related things tocifs_nt_openfunction.Signed-off-by Pavel Shilovsky <[email protected]>---
fs/cifs/cifsproto.h | 4 +
fs/cifs/file.c | 184 +++++++++++++++++++--------------------------------2 files changed, 72 insertions(+), 116 deletions(-)fs/cifs/cifsproto.h +4
-0@@ -113,6 +113,10 @@ extern int cifs_posix_open(char *full_path, struct inode **pinode, struct super_block *sb, int mode, unsigned int f_flags, __u32 *poplock, __u16 *pnetfid, int xid); +extern int cifs_nt_open (char *full_path,struct inode **pinode, + struct cifs_sb_info *cifs_sb, struct cifsTconInfo *tcon, + unsigned int f_flags, __u32 *poplock, __u16 *pnetfid, + int xid); void cifs_fill_uniqueid(struct super_block *sb, struct cifs_fattr *fattr); extern void cifs_unix_basic_to_fattr(struct cifs_fattr *fattr, FILE_UNIX_BASIC_INFO *info,fs/cifs/file.c +53
-47@@ -104,53 +104,6 @@ static inline int cifs_get_disposition(unsigned int flags) return FILE_OPEN; } -static inline int cifs_open_inode_helper (struct inode *inode, - struct cifsTconInfo *pTcon, __u32 oplock, FILE_ALL_INFO *buf, - char *full_path, int xid) -{ - struct cifsInodeInfo *pCifsInode = CIFS_I(inode); - struct timespec temp; - int rc; - - if (pCifsInode->clientCanCacheRead) { - /* we have the inode open somewhere else - no need to discard cache data */ - goto client_can_cache; - } - - /* BB need same check in cifs_create too? */ - /* if not oplocked, invalidate inode pages if mtime or file - size changed */ - temp = cifs_NTtimeToUnix(buf->LastWriteTime); - if (timespec_equal(&inode->i_mtime, &temp) && - (inode->i_size == - (loff_t)le64_to_cpu(buf->EndOfFile))) { - cFYI(1, "inode unchanged on server"); - } else { - if (inode->i_mapping) { - /* BB no need to lock inode until after invalidate - since namei code should already have it locked? */ - rc = filemap_write_and_wait(inode->i_mapping); - mapping_set_error(inode->i_mapping, rc); - } - cFYI(1, "invalidating remote inode since open detected it " - "changed"); - invalidate_remote_inode(inode); - } - -client_can_cache: - if (pTcon->unix_ext) - rc = cifs_get_inode_info_unix(&inode, full_path, inode->i_sb, - xid); - else - rc = cifs_get_inode_info(&inode, full_path, buf, inode->i_sb, - xid, NULL); - - cifs_set_oplock_level(pCifsInode, oplock); - - return rc; -} - int cifs_posix_open(char *full_path, struct inode **pinode, struct super_block *sb, int mode, unsigned int f_flags, __u32 *poplock, __u16 *pnetfid, int xid)@@ -213,6 +166,71 @@ posix_open_ret: return rc; } +int cifs_nt_open (char *full_path,struct inode **pinode, + struct cifs_sb_info *cifs_sb, struct cifsTconInfo *tcon, + unsigned int f_flags, __u32 *poplock, __u16 *pnetfid, int xid) +{ + int rc; + int desiredAccess; + int disposition; + FILE_ALL_INFO *buf; + + desiredAccess = cifs_convert_flags(f_flags); + +/********************************************************************* +* open flag mapping table: +* +* POSIX Flag CIFS Disposition +* ---------- ---------------- +* O_CREAT FILE_OPEN_IF +* O_CREAT | O_EXCL FILE_CREATE +* O_CREAT | O_TRUNC FILE_OVERWRITE_IF +* O_TRUNC FILE_OVERWRITE +* none of the above FILE_OPEN +* +* Note that there is not a direct match between disposition +* FILE_SUPERSEDE (ie create whether or not file exists although +* O_CREAT | O_TRUNC is similar but truncates the existing +* file rather than creating a new file as FILE_SUPERSEDE does +* (which uses the attributes / metadata passed in on open call) +*? +*? O_SYNC is a reasonable match to CIFS writethrough flag +*? and the read write flags match reasonably. O_LARGEFILE +*? is irrelevant because largefile support is always used +*? by this client. Flags O_APPEND, O_DIRECT, O_DIRECTORY, +* O_FASYNC, O_NOFOLLOW, O_NONBLOCK need further investigation +*********************************************************************/ + + disposition = cifs_get_disposition(f_flags); + + /* BB pass O_SYNC flag through on file attributes .. BB */ + + buf = kmalloc(sizeof(FILE_ALL_INFO), GFP_KERNEL); + if (!buf) + return -ENOMEM; + + if (tcon->ses->capabilities & CAP_NT_SMBS) + rc = CIFSSMBOpen(xid, tcon, full_path, disposition, + desiredAccess, CREATE_NOT_DIR, pnetfid, poplock, buf, + cifs_sb->local_nls, cifs_sb->mnt_cifs_flags + & CIFS_MOUNT_MAP_SPECIAL_CHR); + else + rc = SMBLegacyOpen(xid, tcon, full_path, disposition, + desiredAccess, CREATE_NOT_DIR, pnetfid, poplock, buf, + cifs_sb->local_nls, cifs_sb->mnt_cifs_flags + & CIFS_MOUNT_MAP_SPECIAL_CHR);
Quoted 8 lines
fs/cifs/file.c posix_open_ret: · line 227
Quoted 6 lines
fs/cifs/file.c +6
-0+ + if (rc) + goto out; + + rc = cifs_get_inode_info(pinode, full_path, buf, (*pinode)->i_sb, + xid, NULL);I think netfid should be passed to
cifs_get_inode_info.
Why do we need it?
Quoted 113 lines
Quoted 112 lines
fs/cifs/file.c +6
-0+ +out: + kfree(buf); + return rc; +} +struct cifsFileInfo *
cifs_new_fileinfo(__u16 fileHandle, struct file *file, structtcon_link*tlink,__u32oplock)fs/cifs/file.c +0
-3@@ -317,10 +335,7 @@ int cifs_open(struct inode *inode, struct file *file) struct cifsFileInfo *pCifsFile = NULL; struct cifsInodeInfo *pCifsInode; char *full_path = NULL; - int desiredAccess; - int disposition; __u16 netfid; - FILE_ALL_INFO *buf = NULL; xid = GetXid();@@ -385,71 +400,9 @@ int cifs_open(struct inode *inode, struct file *file)or DFS errors */
}- desiredAccess =
cifs_convert_flags(file->f_flags);fs/cifs/file.c +3
-64- -/********************************************************************* -* open flag mapping table: -* -* POSIX Flag CIFS Disposition -* ---------- ---------------- -* O_CREAT FILE_OPEN_IF -* O_CREAT | O_EXCL FILE_CREATE -* O_CREAT | O_TRUNC FILE_OVERWRITE_IF -* O_TRUNC FILE_OVERWRITE -* none of the above FILE_OPEN -* -* Note that there is not a direct match between disposition -* FILE_SUPERSEDE (ie create whether or not file exists although -* O_CREAT | O_TRUNC is similar but truncates the existing -* file rather than creating a new file as FILE_SUPERSEDE does -* (which uses the attributes / metadata passed in on open call) -*? -*? O_SYNC is a reasonable match to CIFS writethrough flag -*? and the read write flags match reasonably. O_LARGEFILE -*? is irrelevant because largefile support is always used -*? by this client. Flags O_APPEND, O_DIRECT, O_DIRECTORY, -* O_FASYNC, O_NOFOLLOW, O_NONBLOCK need further investigation -*********************************************************************/ - - disposition = cifs_get_disposition(file->f_flags); - - /* BB pass O_SYNC flag through on file attributes .. BB */ - - /* Also refresh inode by passing in file_info buf returned by SMBOpen - and calling get_inode_info with returned buf (at least helps - non-Unix server case) */ - - /* BB we can not do this if this is the second open of a file - and the first handle has writebehind data, we might be - able to simply do a filemap_fdatawrite/filemap_fdatawait first */ - buf = kmalloc(sizeof(FILE_ALL_INFO), GFP_KERNEL); - if (!buf) { - rc = -ENOMEM; - goto out; - } - - if (tcon->ses->capabilities & CAP_NT_SMBS) - rc = CIFSSMBOpen(xid, tcon, full_path, disposition, - desiredAccess, CREATE_NOT_DIR, &netfid, &oplock, buf, - cifs_sb->local_nls, cifs_sb->mnt_cifs_flags - & CIFS_MOUNT_MAP_SPECIAL_CHR); - else - rc = -EIO; /* no NT SMB support fall into legacy open below */ - - if (rc == -EIO) { - /* Old server, try legacy style OpenX */ - rc = SMBLegacyOpen(xid, tcon, full_path, disposition, - desiredAccess, CREATE_NOT_DIR, &netfid, &oplock, buf, - cifs_sb->local_nls, cifs_sb->mnt_cifs_flags - & CIFS_MOUNT_MAP_SPECIAL_CHR); - } - if (rc) { - cFYI(1, "cifs_open returned 0x%x", rc); - goto out; - } - - rc = cifs_open_inode_helper(inode, tcon, oplock, buf, full_path, xid); - if (rc != 0) + rc = cifs_nt_open(full_path, &inode, cifs_sb, tcon, file->f_flags, + &oplock, &netfid, xid); + if (rc)goto out;
pCifsFile =
cifs_new_fileinfo(netfid, file, tlink, oplock);fs/cifs/file.c +0
-0@@ -481,7 +434,6 @@ int cifs_open(struct inode *inode, struct file *file) }out:
- kfree(buf);
kfree(full_path);
FreeXid(xid);
cifs_put_tlink(tlink);
--
1.7.0.4--
To unsubscribe from this list: send the line "unsubscribe linux-cifs" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
Signature · 2 lines
Best regards, Pavel Shilovsky.
A message that is not in the archive (sent off-list or not yet received): AANLkTinYie4B2ioRsmzoVwntjaqnJqW8u7F7wnPcpDy+-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org
2010/11/28 Pavel Shilovsky <[email protected]>:
Quoted 150 lines
2010/11/27 Shirish Pargaonkar <[email protected]>:
Quoted 140 lines · Pavel Shilovsky
Quoted 139 lines
Delete
cifs_open_inode_helperand move non-posix open related things tocifs_nt_openfunction.Signed-off-by Pavel Shilovsky <[email protected]>---
fs/cifs/cifsproto.h | 4 +
fs/cifs/file.c | 184 +++++++++++++++++++--------------------------------2 files changed, 72 insertions(+), 116 deletions(-)fs/cifs/cifsproto.h +4
-0@@ -113,6 +113,10 @@ extern int cifs_posix_open(char *full_path, struct inode **pinode, struct super_block *sb, int mode, unsigned int f_flags, __u32 *poplock, __u16 *pnetfid, int xid); +extern int cifs_nt_open (char *full_path,struct inode **pinode, + struct cifs_sb_info *cifs_sb, struct cifsTconInfo *tcon, + unsigned int f_flags, __u32 *poplock, __u16 *pnetfid, + int xid); void cifs_fill_uniqueid(struct super_block *sb, struct cifs_fattr *fattr); extern void cifs_unix_basic_to_fattr(struct cifs_fattr *fattr, FILE_UNIX_BASIC_INFO *info,fs/cifs/file.c +53
-47@@ -104,53 +104,6 @@ static inline int cifs_get_disposition(unsigned int flags) return FILE_OPEN; } -static inline int cifs_open_inode_helper (struct inode *inode, - struct cifsTconInfo *pTcon, __u32 oplock, FILE_ALL_INFO *buf, - char *full_path, int xid) -{ - struct cifsInodeInfo *pCifsInode = CIFS_I(inode); - struct timespec temp; - int rc; - - if (pCifsInode->clientCanCacheRead) { - /* we have the inode open somewhere else - no need to discard cache data */ - goto client_can_cache; - } - - /* BB need same check in cifs_create too? */ - /* if not oplocked, invalidate inode pages if mtime or file - size changed */ - temp = cifs_NTtimeToUnix(buf->LastWriteTime); - if (timespec_equal(&inode->i_mtime, &temp) && - (inode->i_size == - (loff_t)le64_to_cpu(buf->EndOfFile))) { - cFYI(1, "inode unchanged on server"); - } else { - if (inode->i_mapping) { - /* BB no need to lock inode until after invalidate - since namei code should already have it locked? */ - rc = filemap_write_and_wait(inode->i_mapping); - mapping_set_error(inode->i_mapping, rc); - } - cFYI(1, "invalidating remote inode since open detected it " - "changed"); - invalidate_remote_inode(inode); - } - -client_can_cache: - if (pTcon->unix_ext) - rc = cifs_get_inode_info_unix(&inode, full_path, inode->i_sb, - xid); - else - rc = cifs_get_inode_info(&inode, full_path, buf, inode->i_sb, - xid, NULL); - - cifs_set_oplock_level(pCifsInode, oplock); - - return rc; -} - int cifs_posix_open(char *full_path, struct inode **pinode, struct super_block *sb, int mode, unsigned int f_flags, __u32 *poplock, __u16 *pnetfid, int xid)@@ -213,6 +166,71 @@ posix_open_ret: return rc; } +int cifs_nt_open (char *full_path,struct inode **pinode, + struct cifs_sb_info *cifs_sb, struct cifsTconInfo *tcon, + unsigned int f_flags, __u32 *poplock, __u16 *pnetfid, int xid) +{ + int rc; + int desiredAccess; + int disposition; + FILE_ALL_INFO *buf; + + desiredAccess = cifs_convert_flags(f_flags); + +/********************************************************************* +* open flag mapping table: +* +* POSIX Flag CIFS Disposition +* ---------- ---------------- +* O_CREAT FILE_OPEN_IF +* O_CREAT | O_EXCL FILE_CREATE +* O_CREAT | O_TRUNC FILE_OVERWRITE_IF +* O_TRUNC FILE_OVERWRITE +* none of the above FILE_OPEN +* +* Note that there is not a direct match between disposition +* FILE_SUPERSEDE (ie create whether or not file exists although +* O_CREAT | O_TRUNC is similar but truncates the existing +* file rather than creating a new file as FILE_SUPERSEDE does +* (which uses the attributes / metadata passed in on open call) +*? +*? O_SYNC is a reasonable match to CIFS writethrough flag +*? and the read write flags match reasonably. O_LARGEFILE +*? is irrelevant because largefile support is always used +*? by this client. Flags O_APPEND, O_DIRECT, O_DIRECTORY, +* O_FASYNC, O_NOFOLLOW, O_NONBLOCK need further investigation +*********************************************************************/ + + disposition = cifs_get_disposition(f_flags); + + /* BB pass O_SYNC flag through on file attributes .. BB */ + + buf = kmalloc(sizeof(FILE_ALL_INFO), GFP_KERNEL); + if (!buf) + return -ENOMEM; + + if (tcon->ses->capabilities & CAP_NT_SMBS) + rc = CIFSSMBOpen(xid, tcon, full_path, disposition, + desiredAccess, CREATE_NOT_DIR, pnetfid, poplock, buf, + cifs_sb->local_nls, cifs_sb->mnt_cifs_flags + & CIFS_MOUNT_MAP_SPECIAL_CHR); + else + rc = SMBLegacyOpen(xid, tcon, full_path, disposition, + desiredAccess, CREATE_NOT_DIR, pnetfid, poplock, buf, + cifs_sb->local_nls, cifs_sb->mnt_cifs_flags + & CIFS_MOUNT_MAP_SPECIAL_CHR);Quoted 8 lines
fs/cifs/file.c posix_open_ret: · line 227
Quoted 6 lines
fs/cifs/file.c +6
-0+ + if (rc) + goto out; + + rc = cifs_get_inode_info(pinode, full_path, buf, (*pinode)->i_sb, + xid, NULL);I think netfid should be passed to
cifs_get_inode_info.
Quoted 1 line
Why do we need it?
Let's drop this question - you are right :)
Quoted 121 lines
Quoted 108 lines
Quoted 108 lines
fs/cifs/file.c +6
-0+ +out: + kfree(buf); + return rc; +} +struct cifsFileInfo *
cifs_new_fileinfo(__u16 fileHandle, struct file *file, structtcon_link*tlink,__u32oplock)fs/cifs/file.c +0
-3@@ -317,10 +335,7 @@ int cifs_open(struct inode *inode, struct file *file) struct cifsFileInfo *pCifsFile = NULL; struct cifsInodeInfo *pCifsInode; char *full_path = NULL; - int desiredAccess; - int disposition; __u16 netfid; - FILE_ALL_INFO *buf = NULL; xid = GetXid();@@ -385,71 +400,9 @@ int cifs_open(struct inode *inode, struct file *file)or DFS errors */
}- desiredAccess =
cifs_convert_flags(file->f_flags);fs/cifs/file.c +3
-64- -/********************************************************************* -* open flag mapping table: -* -* POSIX Flag CIFS Disposition -* ---------- ---------------- -* O_CREAT FILE_OPEN_IF -* O_CREAT | O_EXCL FILE_CREATE -* O_CREAT | O_TRUNC FILE_OVERWRITE_IF -* O_TRUNC FILE_OVERWRITE -* none of the above FILE_OPEN -* -* Note that there is not a direct match between disposition -* FILE_SUPERSEDE (ie create whether or not file exists although -* O_CREAT | O_TRUNC is similar but truncates the existing -* file rather than creating a new file as FILE_SUPERSEDE does -* (which uses the attributes / metadata passed in on open call) -*? -*? O_SYNC is a reasonable match to CIFS writethrough flag -*? and the read write flags match reasonably. O_LARGEFILE -*? is irrelevant because largefile support is always used -*? by this client. Flags O_APPEND, O_DIRECT, O_DIRECTORY, -* O_FASYNC, O_NOFOLLOW, O_NONBLOCK need further investigation -*********************************************************************/ - - disposition = cifs_get_disposition(file->f_flags); - - /* BB pass O_SYNC flag through on file attributes .. BB */ - - /* Also refresh inode by passing in file_info buf returned by SMBOpen - and calling get_inode_info with returned buf (at least helps - non-Unix server case) */ - - /* BB we can not do this if this is the second open of a file - and the first handle has writebehind data, we might be - able to simply do a filemap_fdatawrite/filemap_fdatawait first */ - buf = kmalloc(sizeof(FILE_ALL_INFO), GFP_KERNEL); - if (!buf) { - rc = -ENOMEM; - goto out; - } - - if (tcon->ses->capabilities & CAP_NT_SMBS) - rc = CIFSSMBOpen(xid, tcon, full_path, disposition, - desiredAccess, CREATE_NOT_DIR, &netfid, &oplock, buf, - cifs_sb->local_nls, cifs_sb->mnt_cifs_flags - & CIFS_MOUNT_MAP_SPECIAL_CHR); - else - rc = -EIO; /* no NT SMB support fall into legacy open below */ - - if (rc == -EIO) { - /* Old server, try legacy style OpenX */ - rc = SMBLegacyOpen(xid, tcon, full_path, disposition, - desiredAccess, CREATE_NOT_DIR, &netfid, &oplock, buf, - cifs_sb->local_nls, cifs_sb->mnt_cifs_flags - & CIFS_MOUNT_MAP_SPECIAL_CHR); - } - if (rc) { - cFYI(1, "cifs_open returned 0x%x", rc); - goto out; - } - - rc = cifs_open_inode_helper(inode, tcon, oplock, buf, full_path, xid); - if (rc != 0) + rc = cifs_nt_open(full_path, &inode, cifs_sb, tcon, file->f_flags, + &oplock, &netfid, xid); + if (rc)goto out;
pCifsFile =
cifs_new_fileinfo(netfid, file, tlink, oplock);fs/cifs/file.c +0
-0@@ -481,7 +434,6 @@ int cifs_open(struct inode *inode, struct file *file) }out:
- kfree(buf);
kfree(full_path);
FreeXid(xid);
cifs_put_tlink(tlink);
--
1.7.0.4Quoted 6 lines
Quoted 5 lines
--
To unsubscribe from this list: send the line "unsubscribe linux-cifs" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html--
Best regards,
Pavel Shilovsky.
Signature · 2 lines
Best regards, Pavel Shilovsky.
Quoted 140 lines · Shirish Pargaonkar
Quoted 139 lines · Pavel Shilovsky
Delete
cifs_open_inode_helperand move non-posix open related things tocifs_nt_openfunction.Signed-off-by Pavel Shilovsky <[email protected]>---
fs/cifs/cifsproto.h | 4 +
fs/cifs/file.c | 184 +++++++++++++++++++--------------------------------2 files changed, 72 insertions(+), 116 deletions(-)fs/cifs/cifsproto.h +4
-0@@ -113,6 +113,10 @@ extern int cifs_posix_open(char *full_path, struct inode **pinode, struct super_block *sb, int mode, unsigned int f_flags, __u32 *poplock, __u16 *pnetfid, int xid); +extern int cifs_nt_open (char *full_path,struct inode **pinode, + struct cifs_sb_info *cifs_sb, struct cifsTconInfo *tcon, + unsigned int f_flags, __u32 *poplock, __u16 *pnetfid, + int xid); void cifs_fill_uniqueid(struct super_block *sb, struct cifs_fattr *fattr); extern void cifs_unix_basic_to_fattr(struct cifs_fattr *fattr, FILE_UNIX_BASIC_INFO *info,fs/cifs/file.c +53
-47@@ -104,53 +104,6 @@ static inline int cifs_get_disposition(unsigned int flags) return FILE_OPEN; } -static inline int cifs_open_inode_helper (struct inode *inode, - struct cifsTconInfo *pTcon, __u32 oplock, FILE_ALL_INFO *buf, - char *full_path, int xid) -{ - struct cifsInodeInfo *pCifsInode = CIFS_I(inode); - struct timespec temp; - int rc; - - if (pCifsInode->clientCanCacheRead) { - /* we have the inode open somewhere else - no need to discard cache data */ - goto client_can_cache; - } - - /* BB need same check in cifs_create too? */ - /* if not oplocked, invalidate inode pages if mtime or file - size changed */ - temp = cifs_NTtimeToUnix(buf->LastWriteTime); - if (timespec_equal(&inode->i_mtime, &temp) && - (inode->i_size == - (loff_t)le64_to_cpu(buf->EndOfFile))) { - cFYI(1, "inode unchanged on server"); - } else { - if (inode->i_mapping) { - /* BB no need to lock inode until after invalidate - since namei code should already have it locked? */ - rc = filemap_write_and_wait(inode->i_mapping); - mapping_set_error(inode->i_mapping, rc); - } - cFYI(1, "invalidating remote inode since open detected it " - "changed"); - invalidate_remote_inode(inode); - } - -client_can_cache: - if (pTcon->unix_ext) - rc = cifs_get_inode_info_unix(&inode, full_path, inode->i_sb, - xid); - else - rc = cifs_get_inode_info(&inode, full_path, buf, inode->i_sb, - xid, NULL); - - cifs_set_oplock_level(pCifsInode, oplock); - - return rc; -} - int cifs_posix_open(char *full_path, struct inode **pinode, struct super_block *sb, int mode, unsigned int f_flags, __u32 *poplock, __u16 *pnetfid, int xid)@@ -213,6 +166,71 @@ posix_open_ret: return rc; } +int cifs_nt_open (char *full_path,struct inode **pinode, + struct cifs_sb_info *cifs_sb, struct cifsTconInfo *tcon, + unsigned int f_flags, __u32 *poplock, __u16 *pnetfid, int xid) +{ + int rc; + int desiredAccess; + int disposition; + FILE_ALL_INFO *buf; + + desiredAccess = cifs_convert_flags(f_flags); + +/********************************************************************* +* open flag mapping table: +* +* POSIX Flag CIFS Disposition +* ---------- ---------------- +* O_CREAT FILE_OPEN_IF +* O_CREAT | O_EXCL FILE_CREATE +* O_CREAT | O_TRUNC FILE_OVERWRITE_IF +* O_TRUNC FILE_OVERWRITE +* none of the above FILE_OPEN +* +* Note that there is not a direct match between disposition +* FILE_SUPERSEDE (ie create whether or not file exists although +* O_CREAT | O_TRUNC is similar but truncates the existing +* file rather than creating a new file as FILE_SUPERSEDE does +* (which uses the attributes / metadata passed in on open call) +*? +*? O_SYNC is a reasonable match to CIFS writethrough flag +*? and the read write flags match reasonably. O_LARGEFILE +*? is irrelevant because largefile support is always used +*? by this client. Flags O_APPEND, O_DIRECT, O_DIRECTORY, +* O_FASYNC, O_NOFOLLOW, O_NONBLOCK need further investigation +*********************************************************************/ + + disposition = cifs_get_disposition(f_flags); + + /* BB pass O_SYNC flag through on file attributes .. BB */ + + buf = kmalloc(sizeof(FILE_ALL_INFO), GFP_KERNEL); + if (!buf) + return -ENOMEM; + + if (tcon->ses->capabilities & CAP_NT_SMBS) + rc = CIFSSMBOpen(xid, tcon, full_path, disposition, + desiredAccess, CREATE_NOT_DIR, pnetfid, poplock, buf, + cifs_sb->local_nls, cifs_sb->mnt_cifs_flags + & CIFS_MOUNT_MAP_SPECIAL_CHR); + else + rc = SMBLegacyOpen(xid, tcon, full_path, disposition, + desiredAccess, CREATE_NOT_DIR, pnetfid, poplock, buf, + cifs_sb->local_nls, cifs_sb->mnt_cifs_flags + & CIFS_MOUNT_MAP_SPECIAL_CHR);
Quoted 9 lines
fs/cifs/file.c posix_open_ret: · line 227
Quoted 6 lines
fs/cifs/file.c +6
-0+ + if (rc) + goto out; + + rc = cifs_get_inode_info(pinode, full_path, buf, (*pinode)->i_sb, + xid, NULL);I think netfid should be passed to
cifs_get_inode_info.
Pavel, were you planning on re-posting this patch? Would like to get this specific code change in. I can post a separate patch with just this change to the existing functions if it would be a while before could you re-spin your patch.
Quoted 112 lines
Quoted 111 lines
fs/cifs/file.c +6
-0+ +out: + kfree(buf); + return rc; +} +struct cifsFileInfo *
cifs_new_fileinfo(__u16 fileHandle, struct file *file, structtcon_link*tlink,__u32oplock)fs/cifs/file.c +0
-3@@ -317,10 +335,7 @@ int cifs_open(struct inode *inode, struct file *file) struct cifsFileInfo *pCifsFile = NULL; struct cifsInodeInfo *pCifsInode; char *full_path = NULL; - int desiredAccess; - int disposition; __u16 netfid; - FILE_ALL_INFO *buf = NULL; xid = GetXid();@@ -385,71 +400,9 @@ int cifs_open(struct inode *inode, struct file *file)or DFS errors */
}- desiredAccess =
cifs_convert_flags(file->f_flags);fs/cifs/file.c +3
-64- -/********************************************************************* -* open flag mapping table: -* -* POSIX Flag CIFS Disposition -* ---------- ---------------- -* O_CREAT FILE_OPEN_IF -* O_CREAT | O_EXCL FILE_CREATE -* O_CREAT | O_TRUNC FILE_OVERWRITE_IF -* O_TRUNC FILE_OVERWRITE -* none of the above FILE_OPEN -* -* Note that there is not a direct match between disposition -* FILE_SUPERSEDE (ie create whether or not file exists although -* O_CREAT | O_TRUNC is similar but truncates the existing -* file rather than creating a new file as FILE_SUPERSEDE does -* (which uses the attributes / metadata passed in on open call) -*? -*? O_SYNC is a reasonable match to CIFS writethrough flag -*? and the read write flags match reasonably. O_LARGEFILE -*? is irrelevant because largefile support is always used -*? by this client. Flags O_APPEND, O_DIRECT, O_DIRECTORY, -* O_FASYNC, O_NOFOLLOW, O_NONBLOCK need further investigation -*********************************************************************/ - - disposition = cifs_get_disposition(file->f_flags); - - /* BB pass O_SYNC flag through on file attributes .. BB */ - - /* Also refresh inode by passing in file_info buf returned by SMBOpen - and calling get_inode_info with returned buf (at least helps - non-Unix server case) */ - - /* BB we can not do this if this is the second open of a file - and the first handle has writebehind data, we might be - able to simply do a filemap_fdatawrite/filemap_fdatawait first */ - buf = kmalloc(sizeof(FILE_ALL_INFO), GFP_KERNEL); - if (!buf) { - rc = -ENOMEM; - goto out; - } - - if (tcon->ses->capabilities & CAP_NT_SMBS) - rc = CIFSSMBOpen(xid, tcon, full_path, disposition, - desiredAccess, CREATE_NOT_DIR, &netfid, &oplock, buf, - cifs_sb->local_nls, cifs_sb->mnt_cifs_flags - & CIFS_MOUNT_MAP_SPECIAL_CHR); - else - rc = -EIO; /* no NT SMB support fall into legacy open below */ - - if (rc == -EIO) { - /* Old server, try legacy style OpenX */ - rc = SMBLegacyOpen(xid, tcon, full_path, disposition, - desiredAccess, CREATE_NOT_DIR, &netfid, &oplock, buf, - cifs_sb->local_nls, cifs_sb->mnt_cifs_flags - & CIFS_MOUNT_MAP_SPECIAL_CHR); - } - if (rc) { - cFYI(1, "cifs_open returned 0x%x", rc); - goto out; - } - - rc = cifs_open_inode_helper(inode, tcon, oplock, buf, full_path, xid); - if (rc != 0) + rc = cifs_nt_open(full_path, &inode, cifs_sb, tcon, file->f_flags, + &oplock, &netfid, xid); + if (rc)goto out;
pCifsFile =
cifs_new_fileinfo(netfid, file, tlink, oplock);fs/cifs/file.c +0
-0@@ -481,7 +434,6 @@ int cifs_open(struct inode *inode, struct file *file) }out:
- kfree(buf);
kfree(full_path);
FreeXid(xid);
cifs_put_tlink(tlink);
--
1.7.0.4--
To unsubscribe from this list: send the line "unsubscribe linux-cifs" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
A message that is not in the archive (sent off-list or not yet received): AANLkTiknMpTb1CEVrBA7mg1b0onK_r+ATwtZhP+NmMht-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org
2010/12/8 Shirish Pargaonkar <[email protected]>:
Quoted 152 lines
Quoted 140 lines · Shirish Pargaonkar
Quoted 139 lines · Pavel Shilovsky
Delete
cifs_open_inode_helperand move non-posix open related things tocifs_nt_openfunction.Signed-off-by Pavel Shilovsky <[email protected]>---
fs/cifs/cifsproto.h | 4 +
fs/cifs/file.c | 184 +++++++++++++++++++--------------------------------2 files changed, 72 insertions(+), 116 deletions(-)fs/cifs/cifsproto.h +4
-0@@ -113,6 +113,10 @@ extern int cifs_posix_open(char *full_path, struct inode **pinode, struct super_block *sb, int mode, unsigned int f_flags, __u32 *poplock, __u16 *pnetfid, int xid); +extern int cifs_nt_open (char *full_path,struct inode **pinode, + struct cifs_sb_info *cifs_sb, struct cifsTconInfo *tcon, + unsigned int f_flags, __u32 *poplock, __u16 *pnetfid, + int xid); void cifs_fill_uniqueid(struct super_block *sb, struct cifs_fattr *fattr); extern void cifs_unix_basic_to_fattr(struct cifs_fattr *fattr, FILE_UNIX_BASIC_INFO *info,fs/cifs/file.c +53
-47@@ -104,53 +104,6 @@ static inline int cifs_get_disposition(unsigned int flags) return FILE_OPEN; } -static inline int cifs_open_inode_helper (struct inode *inode, - struct cifsTconInfo *pTcon, __u32 oplock, FILE_ALL_INFO *buf, - char *full_path, int xid) -{ - struct cifsInodeInfo *pCifsInode = CIFS_I(inode); - struct timespec temp; - int rc; - - if (pCifsInode->clientCanCacheRead) { - /* we have the inode open somewhere else - no need to discard cache data */ - goto client_can_cache; - } - - /* BB need same check in cifs_create too? */ - /* if not oplocked, invalidate inode pages if mtime or file - size changed */ - temp = cifs_NTtimeToUnix(buf->LastWriteTime); - if (timespec_equal(&inode->i_mtime, &temp) && - (inode->i_size == - (loff_t)le64_to_cpu(buf->EndOfFile))) { - cFYI(1, "inode unchanged on server"); - } else { - if (inode->i_mapping) { - /* BB no need to lock inode until after invalidate - since namei code should already have it locked? */ - rc = filemap_write_and_wait(inode->i_mapping); - mapping_set_error(inode->i_mapping, rc); - } - cFYI(1, "invalidating remote inode since open detected it " - "changed"); - invalidate_remote_inode(inode); - } - -client_can_cache: - if (pTcon->unix_ext) - rc = cifs_get_inode_info_unix(&inode, full_path, inode->i_sb, - xid); - else - rc = cifs_get_inode_info(&inode, full_path, buf, inode->i_sb, - xid, NULL); - - cifs_set_oplock_level(pCifsInode, oplock); - - return rc; -} - int cifs_posix_open(char *full_path, struct inode **pinode, struct super_block *sb, int mode, unsigned int f_flags, __u32 *poplock, __u16 *pnetfid, int xid)@@ -213,6 +166,71 @@ posix_open_ret: return rc; } +int cifs_nt_open (char *full_path,struct inode **pinode, + struct cifs_sb_info *cifs_sb, struct cifsTconInfo *tcon, + unsigned int f_flags, __u32 *poplock, __u16 *pnetfid, int xid) +{ + int rc; + int desiredAccess; + int disposition; + FILE_ALL_INFO *buf; + + desiredAccess = cifs_convert_flags(f_flags); + +/********************************************************************* +* open flag mapping table: +* +* POSIX Flag CIFS Disposition +* ---------- ---------------- +* O_CREAT FILE_OPEN_IF +* O_CREAT | O_EXCL FILE_CREATE +* O_CREAT | O_TRUNC FILE_OVERWRITE_IF +* O_TRUNC FILE_OVERWRITE +* none of the above FILE_OPEN +* +* Note that there is not a direct match between disposition +* FILE_SUPERSEDE (ie create whether or not file exists although +* O_CREAT | O_TRUNC is similar but truncates the existing +* file rather than creating a new file as FILE_SUPERSEDE does +* (which uses the attributes / metadata passed in on open call) +*? +*? O_SYNC is a reasonable match to CIFS writethrough flag +*? and the read write flags match reasonably. O_LARGEFILE +*? is irrelevant because largefile support is always used +*? by this client. Flags O_APPEND, O_DIRECT, O_DIRECTORY, +* O_FASYNC, O_NOFOLLOW, O_NONBLOCK need further investigation +*********************************************************************/ + + disposition = cifs_get_disposition(f_flags); + + /* BB pass O_SYNC flag through on file attributes .. BB */ + + buf = kmalloc(sizeof(FILE_ALL_INFO), GFP_KERNEL); + if (!buf) + return -ENOMEM; + + if (tcon->ses->capabilities & CAP_NT_SMBS) + rc = CIFSSMBOpen(xid, tcon, full_path, disposition, + desiredAccess, CREATE_NOT_DIR, pnetfid, poplock, buf, + cifs_sb->local_nls, cifs_sb->mnt_cifs_flags + & CIFS_MOUNT_MAP_SPECIAL_CHR); + else + rc = SMBLegacyOpen(xid, tcon, full_path, disposition, + desiredAccess, CREATE_NOT_DIR, pnetfid, poplock, buf, + cifs_sb->local_nls, cifs_sb->mnt_cifs_flags + & CIFS_MOUNT_MAP_SPECIAL_CHR);Quoted 9 lines
fs/cifs/file.c posix_open_ret: · line 227
Quoted 6 lines
fs/cifs/file.c +6
-0+ + if (rc) + goto out; + + rc = cifs_get_inode_info(pinode, full_path, buf, (*pinode)->i_sb, + xid, NULL);I think netfid should be passed to
cifs_get_inode_info.
Quoted 6 lines
Pavel, were you planning on re-posting this patch? Would like to get this specific code change in. I can post a separate patch with just this change to the existing functions if it would be a while before could you re-spin your patch.
Yes, I have right variant of this patch. The reason that I don't post it yet - is I want to finish with strict cache io before posting any other patches. But if it needs to be posted now, I am ready to do it :)
Signature · 2 lines
Best regards, Pavel Shilovsky.